import{getAssetUrl as e}from"./lib/assets-url.js";import{getDocUrl as a}from"./lib/dev-hub-url.js";import{notifySuccess as t,notifyError as n}from"./lib/notifications.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 i,formatVersionState as s}from"./cc-addon-info.client.js";import"./cc-addon-info.js";o({selector:'cc-addon-info[smart-mode="metabase"]',params:{apiConfig:{type:Object},ownerId:{type:String},addonId:{type:String},appOverviewUrlPattern:{type:String},addonDashboardUrlPattern:{type:String},scalabilityUrlPattern:{type:String},grafanaLink:{type:Object,optional:!0},logsUrlPattern:{type:String}},onContextUpdate({context:o,onEvent:l,updateComponent:d,signal:p}){const{apiConfig:c,ownerId:m,addonId:g,appOverviewUrlPattern:v,addonDashboardUrlPattern:f,scalabilityUrlPattern:y,grafanaLink:u}=o;let b="";const k=new i({apiConfig:c,ownerId:m,addonId:g,providerId:"metabase",grafanaLink:u,signal:p});d("state",{type:"loading",version:{stateType:"up-to-date",installed:"0.0.0",latest:"0.0.0"},creationDate:"2025-08-06 15:03:00",openGrafanaLink:null!=u?"https://example.com":null,openScalabilityLink:"/placeholder",linkedServices:[{type:"app",name:"Java",logoUrl:null,link:"https://example.com"},{type:"addon",name:"PostgreSQL",logoUrl:null,link:"https://example.com"},{type:"addon",name:"FS Bucket",logoUrl:null,link:"https://example.com"}]}),d("docLink",{text:r("cc-addon-info.doc-link.metabase"),href:a("/addons/metabase")}),k.getAddonInfo().then((({operatorVersionInfo:a,addonInfo:t,grafanaAppLink:n,operator:r})=>{const i=r.resources.entrypoint;b=o.logsUrlPattern.replace(":id",i),d("state",{type:"loaded",version:s(a),creationDate:t.creationDate,openGrafanaLink:n,openScalabilityLink:y.replace(":id",i),linkedServices:[{type:"app",name:"Java",logoUrl:e("/logos/java-jar.svg"),link:v.replace(":id",i)},{type:"addon",name:"PostgreSQL",logoUrl:e("/logos/pgsql.svg"),link:f.replace(":id",r.resources.pgsqlId)}]})})).catch((e=>{console.error(e),d("state",{type:"error"})})),l("cc-addon-version-change",(e=>{d("state",(e=>{e.version={...e.version,stateType:"requesting-update"}})),k.updateOperatorVersion(e).then((({availableVersions:a})=>{t(r("cc-addon-info.version.update.success.content",{logsUrl:b}),r("cc-addon-info.version.update.success.heading",{version:e})),d("state",(t=>{const n=e!==t.version.latest;t.version=s({installed:e,available:a,latest:t.version.latest,needUpdate:n})}))})).catch((e=>{d("state",(e=>{e.version={...e.version,stateType:"update-available"}})),n(r("cc-addon-info.version.update.error")),console.error(e)}))}))}});
//# sourceMappingURL=cc-addon-info.smart-metabase.js.map
