let e;const t=e=>`color: ${e}; font-weight: bold;`;function n({component:e,e:n,module:o,color:s}){if("boolean"==typeof __DEV__&&!__DEV__)return;const c=n.type;console.groupCollapsed(`${o}> %c${c}%c on %c${e}`,t(s||"#f012be"),"",t("#1a80cc")),console.log(n),n.target&&console.log(n.target),console.groupEnd()}const o={};function s(e,t){if(!e)throw new Error(t)}function c(t){s("string"==typeof t&&!!t,"Component name must be a non-empty string");const c=`${t}-💊`,i=[({el:e})=>{e.classList.add(t),e.classList.add(c),e.addEventListener(`__ummount__:${t}`,(()=>{e.classList.remove(c)}),{once:!0})}],a=e=>{if(!e.classList.contains(c)){const t=r(new CustomEvent("__mount__",{bubbles:!1}),e);i.forEach((e=>{e(t)}))}};a.sel=`.${t}:not(.${c})`,o[t]=a,(e=e||new Promise((e=>{const t=document,n=()=>{"complete"===t.readyState&&(e(),t.removeEventListener("readystatechange",n))};t.addEventListener("readystatechange",n),n()}))).then((()=>{l(t)}));const m=new Proxy((()=>{}),{set:(e,n,o)=>u(t,i,n,o),get:(e,o)=>"outside"===o?new Proxy({},{set:(e,o,c)=>(s("function"==typeof c,`Event handler must be a function, ${typeof c} (${c}) is given`),i.push((({el:e})=>{const s=o=>{e===o.target||e.contains(o.target)||(n({module:"outside",color:"#39cccc",e:o,component:t}),c(r(o,e)))};document.addEventListener(o,s),e.addEventListener(`__unmount__:${t}`,(()=>{document.removeEventListener(o,s)}),{once:!0})})),!0)}):null,apply(e,n,o){const c=o[0];return s("string"==typeof c,"Delegation selector must be a string. ${typeof selector} is given."),new Proxy({},{set:(e,n,o)=>u(t,i,n,o,c)})}}),d=e=>{i.push((({el:t})=>{t.classList.add(e)}))};return{on:m,is:d,sub:e=>d(`sub:${e}`),innerHTML:e=>{i.push((({el:t})=>{t.innerHTML=e}))}}}function r(e,t){return{e:e,el:t,query:e=>t.querySelector(e),queryAll:e=>t.querySelectorAll(e),pub:(e,t)=>{document.querySelectorAll(`.sub\\:${e}`).forEach((n=>{n.dispatchEvent(new CustomEvent(e,{bubbles:!1,detail:t}))}))},emit:(e,n)=>{t.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:n}))}}}function u(e,t,o,c,u){return s("function"==typeof c,`Event handler must be a function, ${typeof c} (${c}) is given`),"__mount__"===o?(t.push(c),!0):"__unmount__"===o?(t.push((({el:t})=>{t.addEventListener(`__unmount__:${e}`,(()=>{c(r(new CustomEvent("__unmount__"),t))}),{once:!0})})),!0):(t.push((({el:t})=>{const s=o=>{u&&![].some.call(t.querySelectorAll(u),(e=>e===o.target||e.contains(o.target)))||(n({module:"💊",color:"#e0407b",e:o,component:e}),c(r(o,t)))};t.addEventListener(`__unmount__:${e}`,(()=>{t.removeEventListener(o,s)}),{once:!0}),t.addEventListener(o,s)})),!0)}function l(e,t){let n;e?(!function(e){s("string"==typeof e,"The name should be a string"),s(!!o[e],`The component of the given name is not registered: ${e}`)}(e),n=[e]):n=Object.keys(o),n.map((e=>{[].map.call((t||document).querySelectorAll(o[e].sel),o[e])}))}function i(e,t){t.dispatchEvent(new CustomEvent(`__unmount__:${e}`))}export{c as component};export{l as mount};export{i as unmount};