import{r as t,h as s,g as a}from"./p-3b76effa.js";import"./p-d7ac2f15.js";import{T as n}from"./p-18ca1c85.js";class r{constructor(s){t(this,s),this.paramsJson="{}",this.transform="none",this.translate=n.instance}componentDidLoad(){this.postRender()}componentDidUpdate(){this.postRender()}async postRender(){let t=this.el.querySelector("span").innerText.trim();if(this.string&&""!==this.string&&(t=this.string),this.language&&this.language!==this.translate.language&&(this.translationsLocation&&(this.translate.translationsLocation=this.translationsLocation),await this.translate.use(this.language)),this.translation=this.translate.get(t),this.params&&(this.translation=this.translate.get(t,this.params)),"{}"!==this.paramsJson){let s=[t];JSON.parse(this.paramsJson).forEach(t=>{s.push(t)}),this.translation=this.translate.get.apply(this.translate,s)}this.transform&&this.transformTranslation(this.transform),this.el.querySelector("span").innerText=this.translation}async get(t){return this.translate.get(t)}async set(t,s,a){this.translation=await this.translate.get(t),this.postRender()}async setTranslateService(t){this.translate=t,this.postRender()}async update(){this.postRender()}transformTranslation(t){"lowercase"===t&&(this.translation=this.translation.toLowerCase()),"lowercaseFirst"===t&&(this.translation=this.translation.charAt(0).toLowerCase()+this.translation.slice(1)),"uppercase"===t&&(this.translation=this.translation.toUpperCase()),"uppercaseFirst"===t&&(this.translation=this.translation.charAt(0).toUpperCase()+this.translation.slice(1))}render(){return s("span",null,s("slot",null))}get el(){return a(this)}}export{r as ema_translate};