import{getLinkedApplications as n}from"@clevercloud/client/esm/api/v2/addon.js";import{listZones as o}from"@clevercloud/client/esm/api/v4/product.js";import{ONE_DAY as a}from"@clevercloud/client/esm/with-cache.js";import{sendToApi as i}from"./lib/send-to-api.js";import{defineSmartComponent as e}from"./lib/smart/define-smart-component.js";import"./cc-smart-container.js";import"./cc-addon-linked-apps.js";function t({apiConfig:n,signal:e,ownerId:t}){return o({ownerId:t}).then(i({apiConfig:n,signal:e,cacheDelay:a}))}function r({apiConfig:o,signal:a,ownerId:e,addonId:t}){return n({id:e,addonId:t}).then(i({apiConfig:o,signal:a}))}e({selector:"cc-addon-linked-apps",params:{apiConfig:{type:Object},ownerId:{type:String},addonId:{type:String}},onContextUpdate({context:n,updateComponent:o,signal:a}){o("state",{type:"loading"});const{apiConfig:i,ownerId:e,addonId:d}=n;(function({apiConfig:n,signal:o,ownerId:a,addonId:i}){return Promise.all([t({apiConfig:n,signal:o,ownerId:a}),r({apiConfig:n,signal:o,ownerId:a,addonId:i})]).then((([n,o])=>o.map((o=>{const{name:i,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}`}(a,o.id);return{name:i,link:d,variantName:t,variantLogoUrl:r,zone:n.find((n=>n.name===o.zone))}}))))})({apiConfig:i,ownerId:e,addonId:d,signal:a}).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
