var b=Object.defineProperty;var f=(a,e,t)=>e in a?b(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t;var d=(a,e,t)=>(f(a,typeof e!="symbol"?e+"":e,t),t);import{d as w,K as g,L as v,b as k,u as $,A as C}from"./registerWidgets.a9b9c198.js";import{a as I}from"./asyncComputed.380e0794.js";import{C as l}from"./gateway.ff7b2acd.js";import{A}from"./activeRecord.ded96690.js";import"./index.6965b89d.js";import{C as _}from"./CrudView.17d5ced2.js";import{q as j}from"./icons.e4ff78f2.js";import"./passwordlessManager.18e9d509.js";import"./pubsub.d6cf90d7.js";import"./DropdownMenu.cf7e2976.js";import"./Modal.0c783a31.js";import"./LoadingIndicator.32e0b7e2.js";import"./lottie.cb2a87b3.js";(function(){try{var a=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},e=new Error().stack;e&&(a._sentryDebugIds=a._sentryDebugIds||{},a._sentryDebugIds[e]="c29a2563-2888-412b-8515-ad6b3be6811c",a._sentryDebugIdIdentifier="sentry-dbid-c29a2563-2888-412b-8515-ad6b3be6811c")}catch{}})();class P{constructor(){d(this,"urlPath","env-vars")}async create(e){return l.post(`projects/${e.projectId}/${this.urlPath}`,{name:e.name,value:e.value})}async delete(e,t){await l.delete(`projects/${e}/${this.urlPath}/${t}`)}async list(e){return l.get(`projects/${e}/${this.urlPath}`)}async get(e){return l.get(`${this.urlPath}/${e}`)}async update(e,t){return l.patch(`${this.urlPath}/${e}`,t)}}const n=new P;class s{constructor(e,t){d(this,"record");this.projectId=e,this.record=A.create(n,t,"id")}static async list(e){return(await n.list(e)).map(r=>new s(e,r))}static async create(e,t,r){const o=await n.create({projectId:e,name:t,value:r});return new s(e,o)}static async get(e,t){const r=await n.get(t);return new s(e,r)}static async update(e,t,r){const o=await n.update(t,r);return new s(e,o)}get key(){return this.record.get("name")}get value(){return this.record.get("value")}set value(e){this.record.set("value",e)}async save(){await this.record.save()}async delete(){await n.delete(this.projectId,this.key)}hasChanges(){return this.record.hasChanges()}}const H=w({__name:"EnvVars",setup(a){const t=g().params.projectId,{loading:r,result:o,refetch:p}=I(()=>s.list(t)),m=[{label:"Variable name",key:"key"},{label:"Variable value",key:"value",type:"password"}];async function y({key:c,value:i}){await s.create(t,c,i),p()}const h=v(()=>{var c,i;return{columns:[{name:"Key"},{name:"Actions"}],rows:(i=(c=o.value)==null?void 0:c.map(u=>({key:u.key,cells:[{text:u.key,classes:["title","centered"]},{text:"Actions",classes:["centered"],actions:[{icon:j,label:"Delete",async onClick(){await u.delete(),p()},dangerous:!0}]}]})))!=null?i:[]}});return(c,i)=>(k(),$(_,{"entity-name":"env-vars",loading:C(r),title:"Environment Variables",description:"Set environment variables for your project.","empty-title":"No environment variables set",table:h.value,"create-button-text":"Add Environment Variable",fields:m,onCreate:y},null,8,["loading","table"]))}});export{H as default};
//# sourceMappingURL=EnvVars.acce065f.js.map
