import{d as w,r as A,eB as _,G as h,b as k,eu as C,f as l,u as i,w as d,a_ as v,aq as f,eD as x}from"./outputWidgets.e60ab380.js";import{a as P}from"./asyncComputed.7ba647bd.js";import{P as D}from"./project.fe39956f.js";import"./router.0cf2e70d.js";import{M}from"./member.9816b3a0.js";import{A as m}from"./apiKey.523be18c.js";import"./columns.4c9d4799.js";import{g as T}from"./icons.6c1915db.js";import{C as N}from"./CrudView.a4f4d47c.js";import{f as j}from"./index.b048d0fb.js";import{b as B,c as K}from"./Text.742cb8ec.js";import{M as V}from"./transButton.1b3f66c8.js";import"./gateway.990f0877.js";import"./record.04c6d5a0.js";import"./pubsub.e6733ea4.js";import"./Base.0638c3f7.js";import"./Title.666a14b1.js";import"./index.1462457d.js";import"./url.7bd60adc.js";import"./index.ed25df4f.js";import"./index.aaa1fe24.js";(function(){try{var n=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},a=new Error().stack;a&&(n._sentryDebugIds=n._sentryDebugIds||{},n._sentryDebugIds[a]="99ad8a4f-573b-492c-a155-795eb5a284d9",n._sentryDebugIdIdentifier="sentry-dbid-99ad8a4f-573b-492c-a155-795eb5a284d9")}catch{}})();const ne=w({__name:"ApiKeys",setup(n){const a=A(null),p=[{key:"name",label:"API key name"}],s=_().params.projectId,{loading:y,result:g,refetch:c}=P(async()=>Promise.all([m.list(s),D.get(s).then(e=>M.list(e.organizationId))]).then(([e,t])=>e.map(o=>({apiKey:o,member:t.find(r=>r.authorId===o.ownerId)})))),I=async e=>{const t=await m.create({projectId:s,name:e.name});c(),a.value=t.value},b=h(()=>{var e,t;return{columns:[{name:"Name"},{name:"Creation date"},{name:"Owner"},{name:"Actions",align:"right"}],rows:(t=(e=g.value)==null?void 0:e.map(({apiKey:o,member:r})=>{var u;return{key:o.id,cells:[{text:o.name},{text:j(o.createdAt,Date.now(),{addSuffix:!0})},{text:(u=r==null?void 0:r.email)!=null?u:"Unknown"},{text:"actions",actions:[{label:"Delete",icon:T,dangerous:!0,onClick:async()=>{await m.delete(s,o.id),c()}}]}]}}))!=null?t:[]}});return(e,t)=>(k(),C(v,null,[l(N,{"entity-name":"API key","create-button-text":"Create API Key",loading:i(y),title:"API Keys",description:"API Keys are used to deploy your app from the local editor.","empty-title":"No API keys here yet",table:b.value,fields:p,onCreate:I},null,8,["loading","table"]),l(i(V),{open:!!a.value,title:"Api key generated",onCancel:t[0]||(t[0]=o=>a.value=null)},{footer:d(()=>[]),default:d(()=>[l(i(B),null,{default:d(()=>[f("Your API key was successfully generated. Use this code to login on your local development environment or deploy using CI")]),_:1}),l(i(K),{code:"",copyable:""},{default:d(()=>[f(x(a.value),1)]),_:1})]),_:1},8,["open"])],64))}});export{ne as default};
//# sourceMappingURL=ApiKeys.8e340f0d.js.map
