import{getAssetUrl as e}from"./lib/assets-url.js";import{getDocUrl as a}from"./lib/dev-hub-url.js";import{sendToApi as o}from"./lib/send-to-api.js";import{defineSmartComponent as n}from"./lib/smart/define-smart-component.js";import{i18n as t}from"./translation.js";import"./cc-smart-container.js";import{CcAddonInfoClient as r}from"./cc-addon-info.client.js";import"./cc-addon-info.js";n({selector:'cc-addon-info[smart-mode="matomo"]',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,updateComponent:n,signal:r}){const{apiConfig:d,ownerId:s,addonId:l,appOverviewUrlPattern:p,addonDashboardUrlPattern:c,scalabilityUrlPattern:g,grafanaLink:m}=o,f=new i({apiConfig:d,ownerId:s,addonId:l,grafanaLink:m,signal:r});n("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!=m?"https://example.com":null,openScalabilityLink:"/placeholder",linkedServices:[{type:"app",name:"PHP",logoUrl:null,link:"https://example.com"},{type:"addon",name:"MySQL",logoUrl:null,link:"https://example.com"},{type:"addon",name:"Redis",logoUrl:null,link:"https://example.com"}]}),n("docLink",{text:t("cc-addon-info.doc-link.matomo"),href:a("/addons/matomo")}),f.getMatomoAddonInfo().then((({addonInfo:a,grafanaAppLink:o,operator:t,operatorVersion:r})=>{const i=t.resources.entrypoint;n("state",{type:"loaded",version:{stateType:"up-to-date",installed:r,latest:r},creationDate:a.creationDate,openGrafanaLink:o,openScalabilityLink:g.replace(":id",i),linkedServices:[{type:"app",name:"PHP",logoUrl:e("/logos/php.svg"),link:p.replace(":id",i)},{type:"addon",name:"MySQL",logoUrl:e("/logos/mysql.svg"),link:c.replace(":id",t.resources.mysqlId)},{type:"addon",name:"Redis",logoUrl:e("/logos/redis.svg"),link:c.replace(":id",t.resources.redisId)}]})})).catch((e=>{console.error(e),n("state",{type:"error"})}))}});class i extends r{constructor({apiConfig:e,ownerId:a,addonId:o,grafanaLink:n,signal:t}){super({apiConfig:e,ownerId:a,addonId:o,providerId:"matomo",grafanaLink:n,signal:t})}_getMatomoOperator(e,a){return(n={providerId:e,realId:a},Promise.resolve({method:"get",url:`/v4/addon-providers/${n.providerId}/addons/${n.realId}`,headers:{Accept:"application/json"}})).then(o({apiConfig:this._apiConfig,signal:this._signal}));var n}getOperatorVersionInfo(){return(e={providerId:this._providerId,realId:this._realId},Promise.resolve({method:"get",url:`/v4/addon-providers/${e.providerId}/addons/${e.realId}/version/check`,headers:{Accept:"application/json"}})).then(o({apiConfig:this._apiConfig,signal:this._signal}));var e}async getMatomoAddonInfo(){const e=await this._getAddon();this._realId=e.realId,this._providerId=e.provider.id;const a=await this._getMatomoOperator(this._providerId,this._realId);return{addonInfo:e,operator:a,operatorVersion:a.version,grafanaAppLink:null!=this._grafanaLink?await this._getGrafanaAppLink({appId:a.resources.entrypoint,signal:this._signal}):null}}}
//# sourceMappingURL=cc-addon-info.smart-matomo.js.map
