import{getAddon as e}from"@clevercloud/client/esm/api/v2/providers.js";import{ONE_SECOND as a}from"@clevercloud/client/esm/with-cache.js";import{getDocUrl as n}from"./lib/dev-hub-url.js";import{formatAddonFeatures as t}from"./lib/product.js";import{sendToApi as i}from"./lib/send-to-api.js";import{defineSmartComponent as o}from"./lib/smart/define-smart-component.js";import{i18n as r}from"./translation.js";import"./cc-smart-container.js";import{CcAddonInfoClient as l}from"./cc-addon-info.client.js";import"./cc-addon-info.js";o({selector:'cc-addon-info[smart-mode="elastic"]',params:{apiConfig:{type:Object},ownerId:{type:String},addonId:{type:String},appOverviewUrlPattern:{type:String},scalabilityUrlPattern:{type:String},grafanaLink:{type:Object,optional:!0}},onContextUpdate({context:e,updateComponent:a,signal:i}){const{apiConfig:o,ownerId:l,addonId:p,appOverviewUrlPattern:d,scalabilityUrlPattern:c,grafanaLink:m}=e,f=new s({apiConfig:o,ownerId:l,addonId:p,grafanaLink:m,signal:i});a("state",{type:"loading",version:{stateType:"up-to-date",installed:"0.0.0",latest:"0.0.0"},creationDate:"2025-08-06 15:03:00",plan:"XS",features:[{code:"cpu",type:"number",value:2},{code:"memory",type:"bytes",value:2},{code:"disk-size",type:"bytes",value:40},{code:"encryption-at-rest",type:"boolean",value:"false"}],openGrafanaLink:null!=m?"https://example.com":null,openScalabilityLink:"/placeholder",linkedServices:[{type:"app",name:"Kibana",logoUrl:"https://example.com",link:"https://example.com"},{type:"app",name:"APM",logoUrl:"https://example.com",link:"https://example.com"}]}),a("docLink",{text:r("cc-addon-info.doc-link.elastic"),href:n("/addons/elastic")}),f.getElasticAddonInfo().then((({rawAddon:e,addonProvider:n,grafanaAppLink:i,isKibanaEnabled:o})=>{const r=t(e.plan.features,["cpu","memory","disk-size"]),l=n.features.find((e=>"encryption"===e.name));l&&r.push({code:"encryption-at-rest",type:"boolean",value:l.enabled?"true":"false"}),a("state",{type:"loaded",version:{stateType:"up-to-date",installed:n.version,latest:n.version},creationDate:e.creationDate,plan:e.plan.name,features:r,openGrafanaLink:i,openScalabilityLink:o?c.replace(":id",n.kibana_application):null,linkedServices:n.services.filter((e=>e.enabled)).map((e=>function(e,a,n){switch(e){case"kibana":return{type:"app",name:"Kibana",logoUrl:"https://assets.clever-cloud.com/logos/elasticsearch-kibana.svg",link:n.replace(":id",a.kibana_application)};case"apm":return{type:"app",name:"APM",logoUrl:"https://assets.clever-cloud.com/logos/elasticsearch-apm.svg",link:n.replace(":id",a.apm_application)};default:return null}}(e.name,n,d)))})})).catch((e=>{console.error(e),a("state",{type:"error"})}))}});class s extends l{constructor({apiConfig:e,ownerId:a,addonId:n,grafanaLink:t,signal:i}){super({apiConfig:e,ownerId:a,addonId:n,providerId:"es-addon",grafanaLink:t,signal:i})}_getAddonProvider(n){return e({providerId:n,addonId:this._addonId}).then(i({apiConfig:this._apiConfig,signal:this._signal,cacheDelay:a}))}async getElasticAddonInfo(){const e=await this._getAddon(),a=await this._getAddonProvider(e.provider.id),n=a.services.some((e=>"kibana"===e.name&&e.enabled));return{rawAddon:e,addonProvider:a,grafanaAppLink:null!=this._grafanaLink?await this._getGrafanaAppLink({appId:a.app_id,signal:this._signal}):null,isKibanaEnabled:n}}}
//# sourceMappingURL=cc-addon-info.smart-elastic.js.map
