import{d as b,r as A,eB as _,G as k,b as C,eu as h,f as l,u as i,w as d,a_ as v,aq as f,eD as x}from"./outputWidgets.df68f70a.js";import{a as P}from"./asyncComputed.c4f3fa7a.js";import"./router.d34810ba.js";import"./index.5b8834fd.js";import{M as D}from"./member.62fd6cbe.js";import{A as c}from"./apiKey.a21e902c.js";import{P as M}from"./project.7e3804c0.js";import{g as N}from"./icons.6f0b428b.js";import{C as T}from"./CrudView.8169c4b4.js";import{f as j}from"./index.b048d0fb.js";import{b as B,c as K}from"./Text.5293eafa.js";import{M as V}from"./transButton.b32cb3fc.js";import"./Base.8da1f136.js";import"./Title.d7a9606c.js";import"./index.a1698b08.js";import"./record.493f7d84.js";import"./pubsub.26abae80.js";import"./gateway.104fd643.js";import"./url.e14018a7.js";import"./index.4c2136c4.js";import"./index.f12da0b9.js";(function(){try{var n=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},o=new Error().stack;o&&(n._sentryDebugIds=n._sentryDebugIds||{},n._sentryDebugIds[o]="f182da6a-90a8-466b-88d1-c976c2adca9a",n._sentryDebugIdIdentifier="sentry-dbid-f182da6a-90a8-466b-88d1-c976c2adca9a")}catch{}})();const ne=b({__name:"ApiKeys",setup(n){const o=A(null),m=[{key:"name",label:"API key name"}],s=_().params.projectId,{loading:y,result:g,refetch:p}=P(async()=>Promise.all([c.list(s),M.get(s).then(e=>D.list(e.organizationId))]).then(([e,t])=>e.map(a=>({apiKey:a,member:t.find(r=>r.authorId===a.ownerId)})))),I=async e=>{const t=await c.create({projectId:s,name:e.name});p(),o.value=t.value},w=k(()=>{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:a,member:r})=>{var u;return{key:a.id,cells:[{text:a.name},{text:j(a.createdAt,Date.now(),{addSuffix:!0})},{text:(u=r==null?void 0:r.email)!=null?u:"Unknown"},{text:"actions",actions:[{label:"Delete",icon:N,dangerous:!0,onClick:async()=>{await c.delete(s,a.id),p()}}]}]}}))!=null?t:[]}});return(e,t)=>(C(),h(v,null,[l(T,{"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:w.value,fields:m,onCreate:I},null,8,["loading","table"]),l(i(V),{open:!!o.value,title:"Api key generated",onCancel:t[0]||(t[0]=a=>o.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(o.value),1)]),_:1})]),_:1},8,["open"])],64))}});export{ne as default};
//# sourceMappingURL=ApiKeys.1365ecfe.js.map
