var h=Object.defineProperty;var g=(a,t,e)=>t in a?h(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e;var u=(a,t,e)=>(g(a,typeof t!="symbol"?t+"":t,e),e);import{d as w,eA as b,J as v,b as k,c as $,u as _}from"./outputWidgets.52de64cd.js";import{a as I}from"./asyncComputed.00e76dd1.js";import"./console.4411c7a7.js";import{C as l}from"./gateway.e1457457.js";import{A}from"./activeRecord.ebcbfc07.js";import"./index.8361ad88.js";import{q as C}from"./icons.bf6505eb.js";import{_ as j}from"./CrudView.vue_vue_type_script_setup_true_lang.70304edb.js";import"./index.a07ffcc5.js";import"./Form.09072055.js";import"./Title.baba2b21.js";import"./index.7800af0b.js";import"./index.c0e74c90.js";import"./index.e5d92658.js";import"./dayjs.7ad6aa6d.js";import"./index.5718341d.js";import"./index.3ed5d65c.js";import"./TabPane.c3c2f5a1.js";import"./index.396ff1b5.js";import"./CollapsePanel.d756b861.js";import"./index.9b3c2ba8.js";import"./index.f6c308cc.js";import"./index.f7915957.js";import"./index.1ebdd57a.js";import"./index.7fdb6bd8.js";import"./index.693f4596.js";import"./index.5a37ef67.js";import"./index.19e4a065.js";import"./pubsub.6e9aa6f2.js";(function(){try{var a=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},t=new Error().stack;t&&(a._sentryDebugIds=a._sentryDebugIds||{},a._sentryDebugIds[t]="fa1a1952-6f84-4113-9f6c-2a57eff7067e",a._sentryDebugIdIdentifier="sentry-dbid-fa1a1952-6f84-4113-9f6c-2a57eff7067e")}catch{}})();class P{constructor(){u(this,"urlPath","env-vars")}async create(t){return l.post(`projects/${t.projectId}/${this.urlPath}`,{name:t.name,value:t.value})}async delete(t,e){await l.delete(`projects/${t}/${this.urlPath}/${e}`)}async list(t){return l.get(`projects/${t}/${this.urlPath}`)}async get(t){return l.get(`${this.urlPath}/${t}`)}async update(t,e){return l.patch(`${this.urlPath}/${t}`,e)}}const s=new P;class o{constructor(t,e){u(this,"record");this.projectId=t,this.record=A.create(s,e,"id")}static async list(t){return(await s.list(t)).map(r=>new o(t,r))}static async create(t,e,r){const n=await s.create({projectId:t,name:e,value:r});return new o(t,n)}static async get(t,e){const r=await s.get(e);return new o(t,r)}static async update(t,e,r){const n=await s.update(e,r);return new o(t,n)}get key(){return this.record.get("name")}get value(){return this.record.get("value")}set value(t){this.record.set("value",t)}async save(){await this.record.save()}async delete(){await s.delete(this.projectId,this.key)}hasChanges(){return this.record.hasChanges()}}const st=w({__name:"EnvVars",setup(a){const e=b().params.projectId,{loading:r,result:n,refetch:m}=I(()=>o.list(e)),d=[{label:"Variable name",key:"key"},{label:"Variable value",key:"value",type:"password"}];async function y({key:i,value:c}){await o.create(e,i,c),m()}const f=v(()=>{var i,c;return{columns:[{name:"Key"},{name:"Actions",align:"right"}],rows:(c=(i=n.value)==null?void 0:i.map(p=>({key:p.key,cells:[{text:p.key},{text:"Actions",actions:[{icon:C,label:"Delete",async onClick(){await p.delete(),m()},dangerous:!0}]}]})))!=null?c:[]}});return(i,c)=>(k(),$(j,{"entity-name":"Env var",loading:_(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:d,onCreate:y},null,8,["loading","table"]))}});export{st as default};
//# sourceMappingURL=EnvVars.7b06126c.js.map
