var b=Object.defineProperty;var h=(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)=>(h(a,typeof e!="symbol"?e+"":e,t),t);import{d as g,eB as w,G as v,b as k,c as $,u as I}from"./outputWidgets.04a14374.js";import{a as C}from"./asyncComputed.53598080.js";import"./router.4677d467.js";import{C as c}from"./gateway.f7d4a0c5.js";import{E as _}from"./record.b64a41e6.js";import"./columns.19f4f485.js";import{g as j}from"./icons.dee9dbe8.js";import{C as P}from"./CrudView.a6f509b7.js";import"./Base.0c1843db.js";import"./transButton.772cc0ed.js";import"./Text.84d5ffc7.js";import"./Title.9beb186f.js";import"./index.5d9ba614.js";import"./pubsub.bb759777.js";import"./url.311573c2.js";import"./index.9bdc1e6b.js";import"./index.90d3343e.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]="eb56215e-09e6-4176-bf6e-9aa7720025a0",a._sentryDebugIdIdentifier="sentry-dbid-eb56215e-09e6-4176-bf6e-9aa7720025a0")}catch{}})();class x{constructor(){d(this,"urlPath","env-vars")}async create(e){return c.post(`projects/${e.projectId}/${this.urlPath}`,{name:e.name,value:e.value})}async delete(e,t){await c.delete(`projects/${e}/${this.urlPath}/${t}`)}async list(e){return c.get(`projects/${e}/${this.urlPath}`)}async get(e){return c.get(`${this.urlPath}/${e}`)}async update(e,t){return c.patch(`${this.urlPath}/${e}`,t)}}const l=new x;class n{constructor(e,t){d(this,"record");this.projectId=e,this.record=_.from(t)}static async list(e){return(await l.list(e)).map(r=>new n(e,r))}static async create(e,t,r){const s=await l.create({projectId:e,name:t,value:r});return new n(e,s)}static async get(e,t){const r=await l.get(t);return new n(e,r)}static async update(e,t,r){const s=await l.update(t,r);return new n(e,s)}get key(){return this.record.get("name")}get value(){return this.record.get("value")}set value(e){this.record.set("value",e)}async delete(){await l.delete(this.projectId,this.key)}}const T=g({__name:"EnvVars",setup(a){const t=w().params.projectId,{loading:r,result:s,refetch:p}=C(()=>n.list(t)),m=[{label:"Variable name",key:"key"},{label:"Variable value",key:"value",type:"password"}];async function y({key:o,value:i}){await n.create(t,o,i),p()}const f=v(()=>{var o,i;return{columns:[{name:"Key"},{name:"Actions",align:"right"}],rows:(i=(o=s.value)==null?void 0:o.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?i:[]}});return(o,i)=>(k(),$(P,{"entity-name":"Env var",loading:I(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{T as default};
//# sourceMappingURL=EnvVars.e4a747b3.js.map
