export class BaseElement extends HTMLElement{constructor(){super(),this.render&&this.attachShadow({mode:"open"})}isMounted=!1;connectedCallback(){this.beforeRender&&this.beforeRender(),this.#e()}#e(){this.#t(),this.render&&(this.shadowRoot.innerHTML=this.render(),this.#r()),this.isMounted=!0,this.mounted&&this.mounted()}#t(){if(!this.properties)return;const e={};Object.keys(this.properties).forEach(t=>{e[t]={enumerable:!0,get(){const e=this.properties[t],r=t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`),i=this.getAttribute(r),s=e.value;return this.#i({attribute:r,value:null==i?s:i,type:e.type||e,required:e.required,validator:e.validator})},set(e){const r=this.properties[t],i=t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`),s=this.#i({attribute:i,value:e,type:r.type||r,required:r.required,validator:r.validator});return this.updated&&this.updated(t,this[t],s),!1===s?this.removeAttribute(i):!0===s?this.setAttribute(i,""):this.setAttribute(i,s),s}}}),Object.keys(e).forEach(t=>{void 0===this[t]&&Object.defineProperty(this,t,e[t])})}#r(){if(this.styles){const e=document.createElement("style");e.textContent=`\n :host {\n display: block;\n }\n ${this.styles()}\n `,this.shadowRoot.prepend(e)}}#i(e){var t=e.value;return e.type===String?t=t||0===t?String(t):"":e.type===Number?t=!1===t||!0===t||isNaN(t)?null:Number(t):e.type===Boolean&&(t="true"===t||!0===t||""===t),e.required&&!t&&console.error(`Required property ${e.attribute} is missing`),t&&e.validator&&!e.validator(t)&&console.error(`Property ${e.attribute} failed validation`),t}attributeChangedCallback(e,t,r){if(this.isMounted&&t!==r){const i=e.replace(/-([a-z])/g,(e,t)=>t.toUpperCase());this[i]=r,this.updated&&this.updated(i,t,this[i])}}}