import{getDocUrl as e}from"./lib/dev-hub-url.js";import{sendToApi as t}from"./lib/send-to-api.js";import{defineSmartComponent as a}from"./lib/smart/define-smart-component.js";import{i18n as o}from"./translation.js";import"./cc-smart-container.js";import{CcAddonCredentialsBetaClient as n}from"./cc-addon-credentials-beta.client.js";import"./cc-addon-credentials-beta.js";const r={type:"loading",tabs:{default:{content:[{code:"host",value:"fake-skeleton"},{code:"port",value:"fake-skeleton"},{code:"token",value:"fake-skeleton"}],docLink:{text:o("cc-addon-credentials-beta.doc-link.materia-kv"),href:e("/addons/materia-kv")}}}};a({selector:'cc-addon-credentials-beta[smart-mode="materia-kv"]',params:{apiConfig:{type:Object},addonId:{type:String},ownerId:{type:String}},onContextUpdate({context:e,updateComponent:t,signal:a}){const{apiConfig:o,addonId:n,ownerId:i}=e,s=new d({apiConfig:o,ownerId:i,addonId:n,signal:a});t("state",r),s.getCredentials().then((e=>{t("state",(t=>{t.type="loaded",t.tabs.default.content=e}))})).catch((e=>{console.error(e),t("state",{type:"error"})}))}});class d extends n{constructor({apiConfig:e,ownerId:t,addonId:a,signal:o}){super({apiConfig:e,ownerId:t,addonId:a,providerId:"kv",signal:o})}async getMateriaKvInfo(){const e=await this._getAddon();return(a={ownerId:this._ownerId,materiaKvId:e.realId},Promise.resolve({method:"get",url:`/v4/materia/organisations/${a.ownerId}/materia/databases/${a.materiaKvId}`})).then(t({apiConfig:this._apiConfig,signal:this._signal}));var a}async getCredentials(){const e=await this.getMateriaKvInfo();return[{code:"host",value:e.host},{code:"port",value:String(e.port)},{code:"token",value:e.token}]}}
//# sourceMappingURL=cc-addon-credentials-beta.smart-materia-kv.js.map
