var f=Object.defineProperty;var g=(a,e,t)=>e in a?f(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t;var p=(a,e,t)=>(g(a,typeof e!="symbol"?e+"":e,t),t);import{d as w,eB as h,G as v,b as k,c as I,u as _}from"./outputWidgets.a5fcf389.js";import{a as $}from"./asyncComputed.b7d3265e.js";import"./router.8a74f04b.js";import"./index.b67da7e9.js";import{C as i}from"./gateway.5878b159.js";import{g as C}from"./icons.1a1dc210.js";import{C as j}from"./CrudView.cee1047f.js";import"./Base.175f3ec4.js";import"./transButton.fc314012.js";import"./Text.d2260f67.js";import"./Title.42ad4bfb.js";import"./index.39083dd8.js";import"./record.e2e84f62.js";import"./pubsub.903f7e54.js";import"./url.d6641ded.js";import"./index.48f4731a.js";import"./index.5b7d1aca.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]="eb6b0d43-adec-41d2-8257-e376ac697064",a._sentryDebugIdIdentifier="sentry-dbid-eb6b0d43-adec-41d2-8257-e376ac697064")}catch{}})();class P{constructor(){p(this,"urlPath","env-vars")}async create(e){return i.post(`projects/${e.projectId}/${this.urlPath}`,{name:e.name,value:e.value})}async delete(e,t){await i.delete(`projects/${e}/${this.urlPath}/${t}`)}async list(e){return i.get(`projects/${e}/${this.urlPath}`)}async get(e){return i.get(`${this.urlPath}/${e}`)}}const c=new P;class n{constructor(e,t){this.projectId=e,this.dto=t}static async list(e){return(await c.list(e)).map(r=>new n(e,r))}static async create(e,t,r){const l=await c.create({projectId:e,name:t,value:r});return new n(e,l)}static async get(e,t){const r=await c.get(t);return new n(e,r)}get key(){return this.dto.name}get value(){return this.dto.value}async delete(){await c.delete(this.projectId,this.key)}}const Q=w({__name:"EnvVars",setup(a){const t=h().params.projectId,{loading:r,result:l,refetch:u}=$(()=>n.list(t)),m=[{label:"Variable name",key:"key"},{label:"Variable value",key:"value",type:"password"}];async function y({key:o,value:s}){await n.create(t,o,s),u()}const b=v(()=>{var o,s;return{columns:[{name:"Key"},{name:"Actions",align:"right"}],rows:(s=(o=l.value)==null?void 0:o.map(d=>({key:d.key,cells:[{text:d.key},{text:"Actions",actions:[{icon:C,label:"Delete",async onClick(){await d.delete(),u()},dangerous:!0}]}]})))!=null?s:[]}});return(o,s)=>(k(),I(j,{"entity-name":"Env var",loading:_(r),title:"Environment Variables",description:"Set environment variables for your project.","empty-title":"No environment variables set",table:b.value,"create-button-text":"Add Environment Variable",fields:m,onCreate:y},null,8,["loading","table"]))}});export{Q as default};
//# sourceMappingURL=EnvVars.1f179a3b.js.map
