import{getAllEnvVarsForDependencies as e,get as a}from"@clevercloud/client/esm/api/v2/application.js";import{sendToApi as n}from"./lib/send-to-api.js";import{defineSmartComponent as p}from"./lib/smart/define-smart-component.js";import"./cc-smart-container.js";import"./cc-env-var-linked-services.js";p({selector:'cc-env-var-linked-services[type="app"]',params:{apiConfig:{type:Object},ownerId:{type:String},appId:{type:String}},onContextUpdate({context:e,updateComponent:a,signal:n}){const{apiConfig:p,ownerId:i,appId:s}=e;a("state",{type:"loading",name:""});const o=new t(p,n);o.fetchAppName({ownerId:i,appId:s}).then((e=>{a("appName",e)})),o.fetchEnvVarLinkedApps({ownerId:i,appId:s}).then((e=>{a("state",{type:"loaded",services:e})})).catch((e=>{console.error(e),a("state",{type:"error"})}))}});class t{constructor(e,a){this.apiConfig=e,this.signal=a}async fetchEnvVarLinkedApps({ownerId:a,appId:p}){return(await e({id:a,appId:p}).then(n({apiConfig:this.apiConfig,signal:this.signal}))).map((e=>({id:e.app_id,name:e.app_name,variables:e.env})))}async fetchAppName({ownerId:e,appId:p}){return(await a({id:e,appId:p}).then(n({apiConfig:this.apiConfig,signal:this.signal}))).name}}
//# sourceMappingURL=cc-env-var-linked-services.smart-app.js.map
