import{getLinkedApplications as n}from"@clevercloud/client/esm/api/v2/addon.js";import{getAllZones as o}from"@clevercloud/client/esm/api/v4/product.js";import{ONE_DAY as i}from"@clevercloud/client/esm/with-cache.js";import{defineSmartComponent as a}from"./lib/define-smart-component.js";import{sendToApi as e}from"./lib/send-to-api.js";import"./cc-smart-container.js";import"./cc-addon-linked-apps.js";function t({apiConfig:n,signal:a}){return o().then(e({apiConfig:n,signal:a,cacheDelay:i}))}function r({apiConfig:o,signal:i,ownerId:a,addonId:t}){return n({id:a,addonId:t}).then(e({apiConfig:o,signal:i}))}a({selector:"cc-addon-linked-apps",params:{apiConfig:{type:Object},ownerId:{type:String},addonId:{type:String}},onContextUpdate({context:n,updateComponent:o,signal:i}){o("state",{type:"loading"});const{apiConfig:a,ownerId:e,addonId:d}=n;(function({apiConfig:n,signal:o,ownerId:i,addonId:a}){return Promise.all([t({apiConfig:n,signal:o}),r({apiConfig:n,signal:o,ownerId:i,addonId:a})]).then((([n,o])=>o.map((o=>{const{name:a,instance:e}=o,t=e.variant?.name,r=e.variant?.logo,d=function(n,o){return n.startsWith("orga_")?`/organisations/${n}/applications/${o}`:`/users/me/applications/${o}`}(i,o.id);return{name:a,link:d,variantName:t,variantLogoUrl:r,zone:n.find((n=>n.name===o.zone))}}))))})({apiConfig:a,ownerId:e,addonId:d,signal:i}).then((n=>{o("state",{type:"loaded",linkedApplications:n})})).catch((n=>{console.error(n),o("state",{type:"error"})}))}});
//# sourceMappingURL=cc-addon-linked-apps.smart.js.map
