function p(n){switch(typeof n){case"number":case"boolean":case"object":return JSON.stringify(n);default:return n}}function m(n,t){switch(t){case"number":case"boolean":case"object":case"undefined":return JSON.parse(n);default:return n}}function b(n){return n.replace(/-./g,t=>t[1].toUpperCase())}function f(n){return n.replace(/[A-Z]+(?![a-z])|[A-Z]/g,(t,e)=>(e?"-":"")+t.toLowerCase())}function d(n){if(n.type){let t=document.createElement(n.type);return n.props&&Object.entries(n.props).forEach(([e,s])=>{let r=e.toLowerCase();r==="style"&&typeof s=="object"&&s?C(t,s):e in t?t[e]=s:r in t?t[r]=s:t.setAttribute(e,p(s))}),n.children?.forEach(e=>{let s=d(e);s instanceof Node&&t.appendChild(s)}),t}else{if(Array.isArray(n)){let t=document.createDocumentFragment();return t.replaceChildren(...n.map(e=>d(e))),t}return document.createTextNode(n)}}function C(n,t){Object.entries(t).forEach(([e,s])=>{e in n.style&&s&&(n.style[e]=s)})}var g=class extends HTMLElement{#t;#r;#e;#s={};static props;static styles;get template(){return""}static shadowRootInit;get props(){return this.#e}afterViewInit(){}onInit(){}onDestroy(){}onChanges(t){}constructor(){super(),this.#o(),this.#c()}static get observedAttributes(){return this.props?Object.keys(this.props).map(e=>f(e)):[]}connectedCallback(){this.onInit(),this.render(),this.afterViewInit()}disconnectedCallback(){this.onDestroy()}attributeChangedCallback(t,e,s){let r=b(t);e!==s&&(this[t]=s===""||s,this[r]=this[t],this.#i(r,this[t]),this.render(),this.onChanges({property:t,previousValue:e,currentValue:s}))}#i(t,e){let s=m(e,this.#s[t]);s!==this.props[t]&&(this.props[t]=s)}#n(t,e){let s=e.#s;return{set(r,i,a){let o=r[i];if(i in s||(s[i]=typeof a),s[i]!==typeof a)throw TypeError(`Cannot assign ${typeof a} to ${s[i]} property (setting '${i}' of ${e.constructor.name})`);if(o!==a){r[i]=a;let h=f(i);t(h,p(a))}return!0},get(r,i){return r[i]}}}#o(){let t=structuredClone(this.constructor.props)??{};Object.keys(t).forEach(e=>{let s=t[e];this.#s[e]=typeof s,this.setAttribute(f(e),p(s))}),this.#e||(this.#e=new Proxy(t,this.#n((e,s)=>this.setAttribute(e,s),this)))}#c(){this.#t=this,this.constructor.shadowRootInit&&(this.#t=this.attachShadow(this.constructor.shadowRootInit))}render(){if(typeof this.template=="string")this.innerHTML=this.template;else if(typeof this.template=="object"){let t=this.template;if(JSON.stringify(this.#r)!==JSON.stringify(t)){this.#a();let e=d(t);e&&(Array.isArray(e)?this.#t.replaceChildren(...e):this.#t.replaceChildren(e)),this.#r=t}}}#a(){if(this.constructor.styles!==void 0)try{let t=new CSSStyleSheet;t.replaceSync(this.constructor.styles),console.log(this.constructor.styles,this.constructor.props),this.#t.adoptedStyleSheets=[...this.#t.adoptedStyleSheets,t]}catch(t){console.error("ERR: Constructable stylesheets are only supported in shadow roots",t)}}};var x=function(n){for(var t,e,s=arguments,r=1,i="",a="",o=[0],h=function(c){r===1&&(c||(i=i.replace(/^\s*\n\s*|\s*\n\s*$/g,"")))?o.push(c?s[c]:i):r===3&&(c||i)?(o[1]=c?s[c]:i,r=2):r===2&&i==="..."&&c?o[2]=Object.assign(o[2]||{},s[c]):r===2&&i&&!c?(o[2]=o[2]||{})[i]=!0:r>=5&&(r===5?((o[2]=o[2]||{})[e]=c?i?i+s[c]:s[c]:i,r=6):(c||i)&&(o[2][e]+=c?i+s[c]:i)),i=""},l=0;l<n.length;l++){l&&(r===1&&h(),h(l));for(var y=0;y<n[l].length;y++)t=n[l][y],r===1?t==="<"?(h(),o=[o,"",null],r=3):i+=t:r===4?i==="--"&&t===">"?(r=1,i=""):i=t+i[0]:a?t===a?a="":i+=t:t==='"'||t==="'"?a=t:t===">"?(h(),r=1):r&&(t==="="?(r=5,e=i,i=""):t==="/"&&(r<5||n[l][y+1]===">")?(h(),r===3&&(o=o[0]),r=o,(o=o[0]).push(this.apply(null,r.slice(1))),r=0):t===" "||t==="	"||t===`
`||t==="\r"?(h(),r=2):i+=t),r===3&&i==="!--"&&(r=4,o=o[0])}return h(),o.length>2?o.slice(1):o[1]};function u(n,t,...e){return{type:n,props:t,children:e}}var S=x.bind(u);export{g as WebComponent,S as html};
/**
 * @license MIT <https://opensource.org/licenses/MIT>
 * @author Ayo Ayco <https://ayo.ayco.io>
 */
/**
 * For htm license information please see ./vendors/htm/LICENSE.txt
 * @license Apache <https://www.apache.org/licenses/LICENSE-2.0>
 * @author Jason Miller <jason@developit.ca>
 */
