var h=Object.defineProperty;var g=(a,e,t)=>e in a?h(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t;var d=(a,e,t)=>(g(a,typeof e!="symbol"?e+"":e,t),t);import{d as w,ez as b,H as v,b as k,c as $,u as C}from"./outputWidgets.17e2270d.js";import{a as I}from"./asyncComputed.c8589796.js";import"./router.845058a4.js";import{C as l}from"./gateway.deb7dadd.js";import{A as _}from"./activeRecord.1230459a.js";import"./columns.1320dbbc.js";import{q as j}from"./icons.ae606380.js";import{C as A}from"./CrudView.0a7d7224.js";import"./Title.7b6ce571.js";import"./index.4787064b.js";import"./pubsub.52f6192d.js";import"./index.f4ac7424.js";import"./index.23cb8791.js";import"./Form.0e9953f6.js";import"./url.6c73df07.js";import"./index.29151007.js";import"./index.4b3be88e.js";import"./index.cfd05648.js";import"./index.bedec2c6.js";import"./index.34b7172c.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]="f5c8392f-e164-4f9d-8c96-8a4c1240164f",a._sentryDebugIdIdentifier="sentry-dbid-f5c8392f-e164-4f9d-8c96-8a4c1240164f")}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=_.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 X=w({__name:"EnvVars",setup(a){const t=b().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:i,value:c}){await s.create(t,i,c),p()}const f=v(()=>{var i,c;return{columns:[{name:"Key"},{name:"Actions",align:"right"}],rows:(c=(i=o.value)==null?void 0:i.map(u=>({key:u.key,cells:[{text:u.key},{text:"Actions",actions:[{icon:j,label:"Delete",async onClick(){await u.delete(),p()},dangerous:!0}]}]})))!=null?c:[]}});return(i,c)=>(k(),$(A,{"entity-name":"Env var",loading:C(r),title:"Environment Variables",description:"Set environment variables for your project.","empty-title":"No environment variables set",table:f.value,"create-button-text":"Add Environment Variable",fields:m,onCreate:y},null,8,["loading","table"]))}});export{X as default};
//# sourceMappingURL=EnvVars.9f79431d.js.map
