import{getAllAddonProviders as t}from"@clevercloud/client/esm/api/v2/product.js";import{ONE_DAY as o}from"@clevercloud/client/esm/with-cache.js";import{fetchPriceSystem as r}from"./lib/api-helpers.js";import{defineSmartComponent as e}from"./lib/define-smart-component.js";import{formatAddonProduct as n}from"./lib/product.js";import{sendToApi as d}from"./lib/send-to-api.js";import"./cc-smart-container.js";import"./cc-pricing-product.js";function a({signal:r,productId:e}){return t().then(d({cacheDelay:o,signal:r})).then((t=>{const o=t.find((t=>t.id===e));if(null==o)throw new Error(`Unknown add-on provider ID: ${e}`);return o}))}e({selector:'cc-pricing-product[mode="addon"]',params:{addonFeatures:{type:Array},productId:{type:String},zoneId:{type:String}},onContextUpdate({context:t,updateComponent:o,signal:e}){const{productId:d,zoneId:c,addonFeatures:i}=t;o("state",{state:"loading"}),function({productId:t,zoneId:o,addonFeatures:e,signal:d}){return Promise.all([a({productId:t,signal:d}),r({zoneId:o,signal:d})]).then((([t,o])=>n(t,o,e)))}({zoneId:c,productId:d,addonFeatures:i,signal:e}).then((t=>{o("product",{state:"loaded",name:t.name,productFeatures:t.productFeatures,plans:t.plans})})).catch((t=>{console.error(t),o("product",{state:"error"})}))}});
//# sourceMappingURL=cc-pricing-product.smart-addon.js.map
