import{getAvailableInstances as n}from"@clevercloud/client/esm/api/v2/product.js";import{ONE_DAY as t}from"@clevercloud/client/esm/with-cache.js";import{fetchPriceSystem as r}from"./lib/api-helpers.js";import{formatRuntimeProduct as o,getRunnerProduct as e}from"./lib/product.js";import{sendToApi as i}from"./lib/send-to-api.js";import{defineSmartComponent as c}from"./lib/smart/define-smart-component.js";import"./cc-smart-container.js";import"./cc-pricing-product.js";function p({apiConfig:r,productId:o,signal:c}){return n().then(i({apiConfig:r,cacheDelay:t,signal:c})).then((n=>{const t=n.find((n=>n.variant.slug===o));if(null==t){const n=e(o);if(null!=n)return n;throw new Error(`Unknown variant slug: ${o}`)}return t}))}c({selector:'cc-pricing-product[mode="runtime"]',params:{apiConfig:{type:Object},productId:{type:String},zoneId:{type:String,optional:!0},currency:{type:String,optional:!0}},onContextUpdate({context:n,updateComponent:t,signal:e}){const{apiConfig:i,productId:c,zoneId:a="par",currency:s="EUR"}=n;t("state",{type:"loading"}),function({apiConfig:n,productId:t,zoneId:e,currency:i,signal:c}){return Promise.all([p({apiConfig:n,productId:t,signal:c}),r({apiConfig:n,zoneId:e,currency:i,signal:c})]).then((([n,t])=>o(n,t)))}({apiConfig:i,productId:c,zoneId:a,currency:s,signal:e}).then((n=>{t("state",{type:"loaded",name:n.name,productFeatures:n.productFeatures,plans:n.plans})})).catch((n=>{console.error(n),t("state",{type:"error"})}))}});
//# sourceMappingURL=cc-pricing-product.smart-runtime.js.map
