/*! Built with http://stenciljs.com */
const{h:t}=window.webcomponents;import{Q as s,R as e,N as a}from"./chunk-d3862f1e.js";import"./chunk-d01c0689.js";import{a as r}from"./chunk-4bbd7b7f.js";class n{constructor(){this.roles=["ANONYMOUS"],this.crudArray=[],this.state={create:!1,read:!0,update:!1,delete:!1,execute:!0},this.read=!0,this.permissions=e.instance}componentDidLoad(){this.displayDefault=s.getStyle("display",this.el),this.setStyles()}componentDidUpdate(){this.setStyles()}getCrud(){return this.state}setCrud(t,s,e,a,r=!0){this.state.create=t,this.state.read=s,this.state.update=e,this.state.delete=a,this.state.execute=r}setStyles(){this.el.style.display=this.displayDefault,this.state.create,this.state.read||(this.el.style.display="none"),this.state.update,this.state.delete,console.log(this)}render(){return this.rolesOnly,this.rolesExcept,this.crud&&(this.crudArray=this.crud.split(","),this.crudArray.forEach((t,s)=>{this.crudArray[s]=r.castToType(t)}),this.setCrud(this.crudArray[0],this.crudArray[1],this.crudArray[2],this.crudArray[3])),this.read||(this.state.read=!1),t("div",null,t("slot",null))}static get is(){return"ema-permission"}static get properties(){return{crud:{type:String,attr:"crud"},el:{elementRef:!0},getCrud:{method:!0},read:{type:Boolean,attr:"read"},rolesExcept:{type:String,attr:"roles-except"},rolesOnly:{type:String,attr:"roles-only"},setCrud:{method:!0},state:{state:!0}}}static get events(){return[{name:"change",method:"change",bubbles:!0,cancelable:!0,composed:!0}]}}var i=function(t,s,e,a){return new(e||(e=Promise))(function(r,n){function i(t){try{l(a.next(t))}catch(t){n(t)}}function o(t){try{l(a.throw(t))}catch(t){n(t)}}function l(t){t.done?r(t.value):new e(function(s){s(t.value)}).then(i,o)}l((a=a.apply(t,s||[])).next())})};class o{constructor(){this.paramsJson="{}",this.transform="none",this.translate=a.instance}componentDidLoad(){this.postRender()}componentDidUpdate(){this.postRender()}postRender(){return i(this,void 0,void 0,function*(){let t=this.el.innerText.trim();if(this.language&&this.language!==this.translate.language&&(this.translationsLocation&&(this.translate.translationsLocation=this.translationsLocation),yield 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.innerText=this.translation})}get(t){return this.translate.get(t)}set(t,s,e){this.translation=this.translate.get(t)}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 t("span",null,t("slot",null))}static get is(){return"ema-translate"}static get properties(){return{el:{elementRef:!0},get:{method:!0},language:{type:String,attr:"language"},params:{type:String,attr:"params"},paramsJson:{type:String,attr:"params-json"},set:{method:!0},transform:{type:String,attr:"transform"},translation:{state:!0},translationsLocation:{type:String,attr:"translations-location"}}}}export{n as EmaPermission,o as EmaTranslate};