import{d as A,r as w,ez as k,G as _,b as h,et as C,f as i,u as l,w as d,b8 as v,aA as f,eB as x}from"./outputWidgets.0fb707c7.js";import{a as P}from"./asyncComputed.a0ca296c.js";import{P as D}from"./project.f9503600.js";import"./router.81de177d.js";import{M}from"./member.661fed75.js";import{A as m}from"./apiKey.a6a07df3.js";import"./columns.37a1e6f7.js";import{k as T}from"./icons.24a85994.js";import{C as N}from"./CrudView.e365e55f.js";import{f as j}from"./index.b048d0fb.js";import{A as B,a as K}from"./Text.3ec0a64d.js";import{M as V}from"./transButton.220177fb.js";import"./gateway.7ee47e62.js";import"./activeRecord.204186f3.js";import"./pubsub.7d8bce56.js";import"./Form.0dcb97c0.js";import"./Title.f00a58f9.js";import"./index.140c5bc8.js";import"./index.cf4c23b9.js";import"./url.d43b75f5.js";import"./index.85d2f01b.js";import"./index.8dbf2994.js";import"./index.0d3d2205.js";import"./index.e8ef1073.js";import"./index.a2e845fd.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]="b1e7b378-8155-4cf8-9dde-4e92550e9abe",n._sentryDebugIdIdentifier="sentry-dbid-b1e7b378-8155-4cf8-9dde-4e92550e9abe")}catch{}})();const le=A({__name:"ApiKeys",setup(n){const a=w(null),p=[{key:"name",label:"API key name"}],s=k().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)})))),b=async e=>{const t=await m.create({projectId:s,name:e.name});c(),a.value=t.value},I=_(()=>{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)=>(h(),C(v,null,[i(N,{"entity-name":"API key","create-button-text":"Create API Key",loading:l(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:I.value,fields:p,onCreate:b},null,8,["loading","table"]),i(l(V),{open:!!a.value,title:"Api key generated",onCancel:t[0]||(t[0]=o=>a.value=null)},{footer:d(()=>[]),default:d(()=>[i(l(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}),i(l(K),{code:"",copyable:""},{default:d(()=>[f(x(a.value),1)]),_:1})]),_:1},8,["open"])],64))}});export{le as default};
//# sourceMappingURL=ApiKeys.2ef5a582.js.map
