@hygular/core 1.0.0-beta.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +26 -0
- package/README.md +5 -5
- package/build/breakpoints.js +1 -1
- package/dist/css/hygular.css +1 -1
- package/dist/css/hygular.min.css +1 -1
- package/dist/js/hygular.esm.js +17 -8
- package/dist/js/hygular.esm.js.map +1 -1
- package/dist/js/hygular.min.js +2 -2
- package/dist/js/hygular.min.js.map +1 -1
- package/dist/js/shared/{Range-DHxtxXvi.js → Range-QfhWGhrF.js} +499 -200
- package/dist/js/shared/Range-QfhWGhrF.js.map +1 -0
- package/dist/react/hygular-react.esm.js +8 -4
- package/dist/react/hygular-react.esm.js.map +1 -1
- package/dist/react/index.d.ts +1 -1
- package/index.d.ts +1 -1
- package/package.json +2 -2
- package/dist/js/shared/Range-DHxtxXvi.js.map +0 -1
package/dist/js/hygular.min.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Hygular v1.0.0
|
|
2
|
+
* Hygular v1.0.0
|
|
3
3
|
* (c) Eyruz Badalzada
|
|
4
4
|
* Released under the MIT License
|
|
5
5
|
* https://hygular.com
|
|
6
6
|
*/
|
|
7
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Hygular=t()}(this,function(){"use strict";const e={enabled:!1},t={log:{label:"LOG",color:"#3b82f6"},warn:{label:"WARN",color:"#f59e0b"},error:{label:"ERROR",color:"#ef4444"}},s=e=>{return[`%c Hygular %c ${t[e].label} `,"background:#0f172a;color:#f8fafc;font-weight:600;padding:2px 8px;border-radius:4px 0 0 4px;",(s=t[e].color,`background:${s};color:#0f172a;font-weight:700;padding:2px 8px;border-radius:0 4px 4px 0;`)];var s};function i(t,i,n,o){n&&!e.enabled||console[t](...s(i),...o)}const n={enable(){e.enabled=!0},disable(){e.enabled=!1},set(t){e.enabled=Boolean(t)},get isEnabled(){return e.enabled},log(...e){i("log","log",!0,e)},warn(...e){i("warn","warn",!0,e)},error(...e){i("error","error",!1,e)},group(t){e.enabled&&console.group(...s("log"),t)},groupEnd(){e.enabled&&console.groupEnd()}};class o{static slideUp(e,t=350,s=!1){return new Promise(i=>{if(!e)return i();const n=e.getBoundingClientRect().height;if(0===n)return e.style.display="none",s&&e.remove(),i();e.style.overflow="hidden",e.style.height=n+"px",e.style.marginTop=getComputedStyle(e).marginTop,e.style.marginBottom=getComputedStyle(e).marginBottom;const o=e.animate([{height:n+"px",marginTop:getComputedStyle(e).marginTop,marginBottom:getComputedStyle(e).marginBottom},{height:"0px",marginTop:"0px",marginBottom:"0px"}],{duration:t,easing:"ease-out",fill:"forwards"});o.onfinish=()=>{o.cancel(),e.style.height=e.style.overflow="",e.style.marginTop=e.style.marginBottom="",e.style.display="none",s&&e.remove(),i()},o.oncancel=i})}static slideDown(e,t=350,s="block"){return new Promise(i=>{if(!e)return i();e.style.display=s,e.offsetHeight;const n=e.scrollHeight,o=getComputedStyle(e),r=e.animate([{height:"0px",overflow:"hidden",marginTop:"0px",marginBottom:"0px"},{height:n+"px",overflow:"hidden",marginTop:o.marginTop,marginBottom:o.marginBottom}],{duration:t,easing:"ease-out",fill:"forwards"});r.onfinish=()=>{r.cancel(),i()},r.oncancel=i})}static closeOnEscape(e,t,s=350){if("undefined"==typeof window||"undefined"==typeof document)return()=>{};e._escapeHandler&&document.removeEventListener("keydown",e._escapeHandler);const i=i=>{"Escape"===i.key&&"none"!==getComputedStyle(e).display&&(o.slideUp(e,s).then(()=>{t&&t.classList.remove("is-active")}),document.removeEventListener("keydown",e._escapeHandler),e._escapeHandler=null)};return e._escapeHandler=i,document.addEventListener("keydown",i),()=>{document.removeEventListener("keydown",e._escapeHandler),e._escapeHandler=null}}static afterPaint(e){requestAnimationFrame(()=>{requestAnimationFrame(e)})}}const r=new WeakMap;function a(e,t,s,i){let n=e.styles.get(t);n||(n=new Map,e.styles.set(t,n)),n.has(s)||n.set(s,{value:t.style.getPropertyValue(s),priority:t.style.getPropertyPriority(s)}),t.style.setProperty(s,i,"important")}function l(e){for(const[t,s]of e.styles)for(const[e,i]of s)i.value?t.style.setProperty(e,i.value,i.priority):t.style.removeProperty(e);e.styles.clear()}function c(e){const t=e?.defaultView;return t&&e.documentElement?Math.max(0,t.innerWidth-e.documentElement.clientWidth):0}class d{#e;#t=null;constructor(e){this.#e=e}get isLocked(){return null!==this.#t}getScrollbarWidth(){const e=this.#t||this.#s();return r.get(e)?.width??c(e)}lock(){if(this.#t)return this;const e=this.#s();if(!e?.body||!e.defaultView)return this;let t=r.get(e);if(!t){t={owners:new Set,styles:new Map,width:c(e)};try{!function(e,t){const s=e.defaultView,i=e.documentElement,n=e.body,o=s.getComputedStyle(i),r=e=>{const t=s.getComputedStyle(e);return{element:e,rect:e.getBoundingClientRect(),left:parseFloat(t.paddingLeft)||0,right:parseFloat(t.paddingRight)||0}},l=r(n),c=[...e.querySelectorAll("[data-fixed-lock], [data-sticky-lock]")].filter(e=>e!==n&&e!==i).map(r);a(t,i,"--hygular-scrollbar-width",`${t.width}px`),a(t,i,"overflow-anchor","none"),a(t,n,"overflow-anchor","none"),t.width>0&&s.CSS?.supports("scrollbar-gutter","stable")&&!o.scrollbarGutter.includes("stable")&&a(t,i,"scrollbar-gutter","stable");for(const e of[i,n])a(t,e,"overflow-x","hidden"),a(t,e,"overflow-y","hidden");for(const e of[l,...c]){const s=e.element.getBoundingClientRect(),i=Math.max(0,e.rect.left-s.left),n=Math.max(0,s.right-e.rect.right);i>0&&a(t,e.element,"padding-left",`${e.left+i}px`),n>0&&a(t,e.element,"padding-right",`${e.right+n}px`)}}(e,t)}catch(e){throw l(t),e}r.set(e,t)}return t.owners.add(this),this.#t=e,this}unlock(){const e=this.#t;if(!e)return this;this.#t=null;const t=r.get(e);return t?(t.owners.delete(this),0===t.owners.size&&(l(t),r.delete(e)),this):this}#s(){return this.#e??("undefined"==typeof document?null:document)}}class h{static#i=0;static alert(){const e='[data-hygular="alert"]',t={closeBtn:".alert-close"},s={persistent:"data-persistent",dismissKey:"data-dismiss-key",animation:"data-close-animation"},i=e=>{try{return localStorage.getItem(e)}catch(e){return null}},n=(e,t)=>{try{localStorage.setItem(e,t)}catch(e){}};document.querySelectorAll(`${e}[${s.persistent}="true"]`).forEach(e=>{const t=e.getAttribute(s.dismissKey);t&&i(`dismissed-${t}`)&&e.remove()});const r=i=>{const r=i.target.closest(t.closeBtn);if(!r)return;const a=r.closest(e);if(!a)return;i.preventDefault();const l=new CustomEvent("hygular.alert.close",{detail:{alert:a},cancelable:!0});if(a.dispatchEvent(l),l.defaultPrevented)return;if("true"===a.getAttribute(s.persistent)){const e=a.getAttribute(s.dismissKey);e&&n(`dismissed-${e}`,"true")}const c=a.getAttribute(s.animation);let d=!1;const h=()=>{d||(d=!0,document.dispatchEvent(new CustomEvent("hygular.alert.closed",{detail:{alert:a}})),a.remove())};"slide"===c?o.slideUp(a,300).then(h):(a.style.transition="opacity 0.25s ease",a.style.opacity="0",a.addEventListener("transitionend",h,{once:!0}),setTimeout(h,350))};return document.addEventListener("click",r),()=>document.removeEventListener("click",r)}static accordion(){const e='[data-hygular="accordion"]',t={open:"is-open",disabled:"is-disabled"},s={toggler:".accordion-toggler",content:".accordion-content"},i={expanded:"aria-expanded"},n=async i=>{const n=i.target.closest(s.toggler);if(!n||n.disabled||"true"===n.getAttribute("aria-disabled")||n.classList.contains(t.disabled))return;const l=n.closest(e);if(!l)return;if(l.accordionLock)return;l.accordionLock=!0;const c="true"===l.getAttribute("data-allow-multiple");if(n.classList.contains(t.open))await a(n);else{if(await async function(e){const i=e.parentElement,n=i.querySelector(s.content);if(!n)return!1;const a=new CustomEvent("hygular.accordion.open",{detail:{trigger:e,content:n,item:i},bubbles:!0,cancelable:!0});return i.dispatchEvent(a),!a.defaultPrevented&&(e.classList.add(t.open),r(e,n,!0),await o.slideDown(n,200),i.dispatchEvent(new CustomEvent("hygular.accordion.opened",{detail:{trigger:e,content:n,item:i},bubbles:!0})),!0)}(n)&&!c){const e=[...l.querySelectorAll(s.toggler)].filter(e=>e!==n&&e.classList.contains(t.open));await Promise.all(e.map(e=>a(e)))}}l.accordionLock=!1},r=(e,t,s)=>{if(e.setAttribute(i.expanded,String(s)),!t.id){let e;do{e="hygular-accordion-"+ ++h.#i}while(document.getElementById(e));t.id=e}e.setAttribute("aria-controls",t.id)};return document.querySelectorAll(e).forEach(e=>{if(e.querySelectorAll(s.toggler).forEach(e=>{const i=e.parentElement.querySelector(s.content);i&&r(e,i,e.classList.contains(t.open))}),"true"!==e.getAttribute("data-open-first"))return;const i=e.querySelector(s.toggler);if(!i)return;i.classList.add(t.open);const n=i.parentElement.querySelector(s.content);n&&(n.style.display="block",r(i,n,!0))}),document.addEventListener("click",n),()=>document.removeEventListener("click",n);async function a(e){const i=e.parentElement,n=i.querySelector(s.content);if(!n)return!1;const a=new CustomEvent("hygular.accordion.close",{detail:{trigger:e,content:n,item:i},bubbles:!0,cancelable:!0});return i.dispatchEvent(a),!a.defaultPrevented&&(e.classList.remove(t.open),r(e,n,!1),await o.slideUp(n,200),i.dispatchEvent(new CustomEvent("hygular.accordion.closed",{detail:{trigger:e,content:n,item:i},bubbles:!0})),!0)}}static badge(e){const t=e.getAttribute("data-count");if(!t)return;const s=Number(t);Number.isNaN(s)||(e.textContent=s<100?s:"99+",e.setAttribute("aria-label",`${s}`))}static collapse(){const e='[data-hygular-toggle="collapse"]',t={target:"data-target"},s={open:"is-open"},i={duration:300},n=new WeakSet,r=(e,t,i)=>{e.classList.toggle(s.open,i),e.setAttribute("aria-expanded",i?"true":"false"),t.id&&e.setAttribute("aria-controls",t.id),t.classList.toggle(s.open,i),t.setAttribute("data-state",i?"open":"closed")},a=a=>{const l=a.target.closest(e);l&&(a.preventDefault(),(async e=>{if(e.disabled||"true"===e.getAttribute("aria-disabled"))return;const a=e.getAttribute(t.target);if(!a)return;const l=document.querySelector(a);if(!l)return;if(n.has(l))return;n.add(l);const c=l.classList.contains(s.open),d=new CustomEvent("hygular.collapse."+(c?"close":"open"),{detail:{trigger:e,target:l},bubbles:!0,cancelable:!0});l.dispatchEvent(d),d.defaultPrevented||(r(e,l,!c),c?await o.slideUp(l,i.duration):await o.slideDown(l,i.duration),l.dispatchEvent(new CustomEvent("hygular.collapse."+(c?"closed":"opened"),{detail:{trigger:e,target:l},bubbles:!0}))),n.delete(l)})(l))};return document.querySelectorAll(e).forEach(e=>{const i=e.getAttribute(t.target);if(!i)return;const n=document.querySelector(i);if(!n)return;const o=e.classList.contains(s.open)||n.classList.contains(s.open)||"true"===n.getAttribute("data-initial-open");r(e,n,o),n.style.display=o?"block":"none"}),document.addEventListener("click",a),()=>{document.removeEventListener("click",a)}}static drawer(){const e=".drawer",t={dismissBtn:".drawer-close",panel:".drawer-panel",focusable:'a[href], button, input, select, textarea, [tabindex]:not([tabindex="-1"])'},s={open:"is-open"},i={target:"data-target"},n={transitionDuration:420};let r=null,a=!1;const l=new Set,c=new Map,h=new Set,u=(e,t)=>{const s=setTimeout(()=>{l.delete(s),a||e()},t);l.add(s)};let p=!1;const m=new d,g=e=>{e._focusHandler&&(e.removeEventListener("keydown",e._focusHandler),e._focusHandler=null)},f=e=>{if(a||p||e.classList.contains(s.open))return;const i=new CustomEvent("hygular.drawer.open",{detail:{drawer:e},bubbles:!0,cancelable:!0});e.dispatchEvent(i),i.defaultPrevented||a||(p=!0,r=e,h.add(e),e.setAttribute("aria-modal","true"),e.setAttribute("role","dialog"),e.setAttribute("tabindex","-1"),e.classList.contains("has-no-backdrop")||m.lock(),o.afterPaint(()=>{!a&&r===e&&h.has(e)&&e.classList.add(s.open)}),u(()=>{r===e&&((e=>{const s=Array.from(e.querySelectorAll(t.focusable)).filter(e=>null!==e.offsetParent);if(!s.length)return void e.focus();const i=s[0],n=s[s.length-1],o=e=>{"Tab"===e.key&&(e.shiftKey&&document.activeElement===i?(e.preventDefault(),n.focus()):e.shiftKey||document.activeElement!==n||(e.preventDefault(),i.focus()))};e._focusHandler=o,e.addEventListener("keydown",o),i.focus()})(e),p=!1,e.dispatchEvent(new CustomEvent("hygular.drawer.opened",{detail:{drawer:e},bubbles:!0})))},n.transitionDuration+50))},v=e=>{if(!e.classList.contains(s.open))return;const i=new CustomEvent("hygular.drawer.close",{detail:{drawer:e},bubbles:!0,cancelable:!0});if(e.dispatchEvent(i),i.defaultPrevented)return;r===e&&(r=null),p=!0,e.classList.remove(s.open),e.removeAttribute("aria-modal"),e.removeAttribute("role"),g(e);let o=!1;const a=()=>{o||(o=!0,e.removeEventListener("transitionend",l),c.delete(e),h.delete(e),p=!1,e.classList.contains("has-no-backdrop")||m.unlock(),e.dispatchEvent(new CustomEvent("hygular.drawer.closed",{detail:{drawer:e},bubbles:!0})))},l=s=>{s.target!==e&&s.target!==e.querySelector(t.panel)||(e.removeEventListener("transitionend",l),a())};c.set(e,l),e.addEventListener("transitionend",l),u(a,n.transitionDuration+50)},y=n=>{const o=n.target.closest('[data-hygular-toggle="drawer"]'),a=n.target.closest(t.dismissBtn);if(o){n.preventDefault();const t=o.getAttribute(i.target),s=t?document.querySelector(t):o.closest(e);if(!s)return;return void f(s)}if(a){n.preventDefault();const t=a.closest(e);return void(t&&v(t))}if(r){const e=n.target.closest("a");e&&r.contains(e)&&(e=>{if(!e)return!1;if(e.hasAttribute("data-hygular-toggle")||e.closest("[data-hygular-toggle]"))return!1;const t=e.getAttribute("href");if(null===t)return!1;const s=t.trim();return""!==s&&"#"!==s&&!s.toLowerCase().startsWith("javascript:")})(e)&&v(r)}if(r&&r.classList.contains(s.open)){const e=r.querySelector(t.panel);!e||e.contains(n.target)||n.target.closest('[data-hygular-toggle="drawer"]')||v(r)}},b=e=>{"Escape"!==e.key&&"Esc"!==e.key||!r||v(r)};return document.addEventListener("click",y),document.addEventListener("keydown",b),()=>{document.removeEventListener("click",y),document.removeEventListener("keydown",b),a=!0,l.forEach(clearTimeout),l.clear(),c.forEach((e,t)=>t.removeEventListener("transitionend",e)),c.clear(),h.forEach(e=>{e.classList.remove(s.open),e.removeAttribute("aria-modal"),e.removeAttribute("role"),g(e)}),h.clear(),r=null,m.unlock()}}static navbar(){const e='[data-hygular-toggle="navbar"]',t={menu:".navbar-menu"},s={toggle:"is-active"},i=new WeakMap,n=new Set;let r=!1;const a=async a=>{const l=a.target.closest(e);if(!l)return;a.preventDefault();const c=l.getAttribute("data-target");if(!c)return;const d=document.querySelector(c);if(!d)return;if(r||i.get(d))return;n.add(d),d._disposeEsc?.(),d._disposeEsc=null,i.set(d,!0);const h=l.classList.contains(s.toggle);if(document.querySelectorAll(t.menu).forEach(e=>{e!==d&&o.slideUp(e).finally(()=>i.set(e,!1))}),document.querySelectorAll(e).forEach(e=>{e!==l&&e.classList.remove(s.toggle)}),h)l.classList.remove(s.toggle),await o.slideUp(d,300);else{if(l.classList.add(s.toggle),await o.slideDown(d,300,"flex"),r)return;const e=o.closeOnEscape(d,l,300);d._disposeEsc=e}i.set(d,!1)};return document.body.addEventListener("click",a),()=>{r=!0,document.body.removeEventListener("click",a),n.forEach(e=>{e._disposeEsc?.(),e._disposeEsc=null,e.getAnimations?.().forEach(e=>e.cancel())}),n.clear()}}static dropdown(){const e=".dropdown",t='[data-hygular-toggle="dropdown"]',s={menu:".dropdown-menu"},i={active:"is-active"},n={triggerMode:"data-trigger"},o=(e,s)=>{s?e.classList.add(i.active):e.classList.remove(i.active);const n=e.querySelector(t);n&&n.setAttribute("aria-expanded",s?"true":"false")},r=(t=null)=>{document.querySelectorAll(`${e}.${i.active}`).forEach(e=>{e!==t&&o(e,!1)})},a=n=>{const a=n.target.closest(t),l=n.target.closest(s.menu);if(l){if(n.target.closest("a")){const t=l.closest(e);t&&o(t,!1)}return}if(!a)return void r();const c=a.closest(e);if(!c)return;r(c);const d=c.classList.contains(i.active);o(c,!d)},l=e=>{"Escape"!==e.key&&"Esc"!==e.key||r()};if(document.addEventListener("click",a),document.addEventListener("keydown",l),window.matchMedia("(hover: hover) and (pointer: fine)").matches){const t=new WeakMap,s=s=>{const i=s.target.closest(`${e}[${n.triggerMode}="hover"]`);i&&(t.has(i)&&(clearTimeout(t.get(i)),t.delete(i)),r(i),o(i,!0))},i=s=>{const i=s.target.closest(`${e}[${n.triggerMode}="hover"]`);if(!i)return;t.has(i)&&clearTimeout(t.get(i));const r=setTimeout(()=>{i.matches(":hover")||i.querySelector(":hover")||o(i,!1),t.delete(i)},150);t.set(i,r)};return document.addEventListener("mouseover",s),document.addEventListener("mouseout",i),()=>{document.removeEventListener("click",a),document.removeEventListener("keydown",l),document.removeEventListener("mouseover",s),document.removeEventListener("mouseout",i)}}return()=>{document.removeEventListener("click",a),document.removeEventListener("keydown",l)}}static tabview(e){if("undefined"==typeof document||"undefined"==typeof window)return;if(!e)return;const t={tab:"data-tab",indicator:"data-tab-indicator"},s={active:"is-active",open:"is-open",underline:"tab-indicator",instant:"is-instant"},i=Array.from(e.querySelectorAll(`[${t.tab}]`));if(!i.length)return;const n=e.getAttribute(t.indicator),o="true"===n||""===n;let r=e.querySelector(`.${s.underline}`);const a=o&&!r;o?("static"===getComputedStyle(e).position&&(e.style.position="relative"),r||(r=document.createElement("div"),r.className=s.underline,e.appendChild(r)),r.style.display=""):r&&(r.style.display="none");const l=new Map;i.forEach(e=>{const s=e.getAttribute(t.tab),i=s?document.querySelector(s):null;i&&l.set(s,i),e.id||(e.id=`tab-${Math.random().toString(36).slice(2,9)}`),e.setAttribute("role","tab"),i&&(i.id||(i.id=`panel-${Math.random().toString(36).slice(2,9)}`),e.setAttribute("aria-controls",i.id),i.setAttribute("role","tabpanel"),i.setAttribute("aria-labelledby",e.id))}),e.setAttribute("role","tablist");const c=parseFloat(getComputedStyle(e).getPropertyValue("--tab-indicator-size"))||3;let d=null,h=!1;function u(t=!1){if(!o||!r)return;const i=e.querySelector(`.${s.active}`);i&&(0===i.offsetWidth&&0===i.offsetHeight||(null!==d&&cancelAnimationFrame(d),d=requestAnimationFrame(()=>{d=null;const{left:n,top:o,width:a,height:l}=(t=>{const s=e.getBoundingClientRect(),i=t.getBoundingClientRect();return{left:i.left-s.left+e.scrollLeft,top:i.top-s.top+e.scrollTop,width:i.width,height:i.height}})(i),{vertical:h,rtl:u}=(()=>{const t=getComputedStyle(e),s=t.flexDirection;return{vertical:"column"===s||"column-reverse"===s,rtl:"rtl"===t.direction}})();let p,m,g,f;h?(g=Math.round(c),f=Math.round(l),m=Math.round(o),p=u?Math.round(n+a-c):Math.round(n)):(g=Math.round(a),f=Math.round(c),p=Math.round(n),m=Math.round(o+l-c)),t&&r.classList.add(s.instant),r.style.transform=`translate3d(${p}px, ${m}px, 0)`,r.style.width=`${g}px`,r.style.height=`${f}px`,t&&(r.offsetWidth,requestAnimationFrame(()=>r.classList.remove(s.instant)))})))}function p(e,{focus:n=!1}={}){i.forEach(t=>{const i=t===e;t.classList.toggle(s.active,i),t.setAttribute("aria-selected",String(i)),t.tabIndex=i?0:-1}),l.forEach(e=>e.classList.remove(s.open));const o=e.getAttribute(t.tab),r=l.get(o);r&&r.classList.add(s.open),u(),n&&e.focus()}p(e.querySelector(`.${s.active}`)||i[0]),r&&u(!0);const m=i=>{const n=i.target.closest(`[${t.tab}]`);n&&e.contains(n)&&(n.classList.contains(s.active)||(i.preventDefault(),p(n)))},g=s=>{const n=s.target.closest(`[${t.tab}]`);if(!n||!e.contains(n))return;const o=i.indexOf(n);if(-1===o)return;let r=null;switch(s.key){case"ArrowRight":r=(o+1)%i.length;break;case"ArrowLeft":r=(o-1+i.length)%i.length;break;case"Home":r=0;break;case"End":r=i.length-1;break;default:return}s.preventDefault(),p(i[r],{focus:!0})};e.addEventListener("click",m),e.addEventListener("keydown",g);const f="undefined"!=typeof ResizeObserver?new ResizeObserver(()=>u()):null;return f&&(f.observe(e),i.forEach(e=>f.observe(e))),document.fonts&&document.fonts.ready&&document.fonts.ready.then(()=>{h||u()}),{dispose:()=>{h=!0,null!==d&&cancelAnimationFrame(d),e.removeEventListener("click",m),e.removeEventListener("keydown",g),f&&f.disconnect(),a&&r&&r.parentNode===e&&r.remove()}}}static swiper(e){if(!e)return;const t=e.querySelector(".swiper-wrapper");if(!t)return;let s=!1,i=0,n=0,o=!1;const r=r=>{s=!0,o=!1,e.classList.add("is-dragging"),i=r.clientX,n=t.scrollLeft,t.setPointerCapture(r.pointerId)},a=e=>{if(!s)return;const r=e.clientX-i;Math.abs(r)>3&&(o=!0);const a=1.15*r;t.scrollLeft=n-a},l=i=>{if(s&&(s=!1,e.classList.remove("is-dragging"),t.releasePointerCapture(i.pointerId),o)){const e=e=>{e.preventDefault(),e.stopImmediatePropagation()};t.addEventListener("click",e,{capture:!0,once:!0})}};return t.addEventListener("pointerdown",r,{passive:!0}),t.addEventListener("pointermove",a,{passive:!1}),t.addEventListener("pointerup",l,{passive:!0}),t.addEventListener("pointercancel",l,{passive:!0}),t.addEventListener("pointerleave",l,{passive:!0}),{dispose:()=>{t.removeEventListener("pointerdown",r),t.removeEventListener("pointermove",a),t.removeEventListener("pointerup",l),t.removeEventListener("pointercancel",l),t.removeEventListener("pointerleave",l)}}}}const u={body:"--body",bodyText:"--body-text",primary:"--primary",primaryContrast:"--primary-contrast",font:"--font",fontMono:"--font-monospace",spaceXs:"--space-xs",spaceSm:"--space-sm",spaceMd:"--space-md",spaceLg:"--space-lg",spaceXl:"--space-xl",space2xl:"--space-2xl"};function p(e={}){if("undefined"==typeof document)return;if(document.querySelector('link[href*="hygular.build.css"]'))return;const t=e||{};if(Object.keys(t).length){if(t.theme){const e=[];if(Object.keys(u).forEach(s=>{t.theme[s]&&e.push(` ${u[s]}: ${t.theme[s]};`)}),t.theme.extend&&Object.entries(t.theme.extend).forEach(([t,s])=>{const i=t.startsWith("--")?t:`--${t}`;e.push(` ${i}: ${s};`)}),e.length>0&&m(`:root {\n${e.join("\n")}\n}`,"hygular-theme-styles"),t.theme.dark){const e=[];Object.keys(u).forEach(s=>{t.theme.dark[s]&&e.push(` ${u[s]}: ${t.theme.dark[s]};`)}),t.theme.dark.extend&&Object.entries(t.theme.dark.extend).forEach(([t,s])=>{const i=t.startsWith("--")?t:`--${t}`;e.push(` ${i}: ${s};`)}),e.length>0&&m(`[data-hygular-theme="dark"] {\n${e.join("\n")}\n}`,"hygular-theme-dark-styles")}}t.classes&&function(e){if(!e||"object"!=typeof e||Array.isArray(e))return;const t=[],s=[];Object.entries(e).forEach(([e,i])=>{if(!e||"string"!=typeof e)return;if("string"==typeof i&&i.trim())return void t.push(`.${e} { ${i.trim()} }`);if(!i||"object"!=typeof i||Array.isArray(i))return;const{dark:n,...o}=i;if(Object.keys(o).length){const s=Object.entries(o).filter(([e,t])=>e&&null!=t&&""!==t).map(([e,t])=>` ${e}: ${t};`).join("\n");s&&t.push(`.${e} {\n${s}\n}`)}if(n&&"object"==typeof n&&!Array.isArray(n)&&Object.keys(n).length){const t=Object.entries(n).filter(([e,t])=>e&&null!=t&&""!==t).map(([e,t])=>` ${e}: ${t};`).join("\n");t&&s.push(`[data-hygular-theme="dark"] .${e} {\n${t}\n}`)}});const i=[...t,...s].join("\n\n");i&&m(i,"hygular-custom-classes")}(t.classes),t.fonts&&Array.isArray(t.fonts)&&function(e){g("https://fonts.googleapis.com"),g("https://fonts.gstatic.com",!0);const t=[];let s="";e.forEach(e=>{if("object"!=typeof e||!e.family)return;t.push(e);const i=e.alias||e.family.toLowerCase().replace(/\s+/g,"-"),n=e.category||"sans-serif";s+=`.font-${i} {\n --hygular-font-family: "${e.family}", ${n};\n font-family: var(--hygular-font-family) !important;\n}\n`}),t.length>0&&(!function(e){const t=e.map(e=>{const t=e.family.trim().replace(/ /g,"+");if(e.weights){return`family=${t}:wght@${e.weights.toString().replace(/,/g,";").replace(/\s/g,"")}`}return`family=${t}`}).join("&"),s=`https://fonts.googleapis.com/css2?${t}&display=swap`;if(!document.head.querySelector(`link[href="${s}"]`)){const e=document.createElement("link");e.href=s,e.rel="stylesheet",document.head.appendChild(e)}}(t),m(s,"hygular-font-classes"))}(t.fonts)}}function m(e,t){if(!e)return;let s=document.getElementById(t);s&&s.remove(),s=document.createElement("style"),s.id=t,s.textContent=e,document.head.appendChild(s)}function g(e,t=!1){if(!document.head.querySelector(`link[rel="preconnect"][href="${e}"]`)){const s=document.createElement("link");s.rel="preconnect",s.href=e,t&&(s.crossOrigin="anonymous"),document.head.appendChild(s)}}class f{static#n=new Map;static#o=0;static get instances(){return f.#n}static create(e,t={}){const s=new f(e,t);return s.#r&&s.#a&&s.#l?.length?(s.build(),s):(n.warn("[Carousel] Missing root, inner element, or carousel items. Instance was not created."),null)}static get(e){return f.#n.get(e)}#c=null;#r=null;#a=null;#l=null;#d=null;#h=null;#u=null;#p=!1;#m=!1;#g=!1;#f=null;#v=null;#y=null;#b=null;#E=null;#w=null;#k=null;#A={x:null,y:null,dx:0,dy:0,startTime:0,threshold:40};#C={};#L=1;static defaults={mode:"slide",autoplay:{enabled:!0,interval:4e3,pauseOnHover:!0,pauseOnSwipe:!0},controls:!0,pager:!0,thumbnails:{enabled:!1,clickable:!0},swipe:!0,loop:!0};static selector={inner:".carousel-items",pager:".pager",thumbs:".thumbnails",next:".carousel-next",prev:".carousel-prev"};static class={active:"is-active",fade:"is-fade"};static template={next:'<button type="button" class="button carousel-next next-icon" aria-label="Next"></button>',prev:'<button type="button" class="button carousel-prev prev-icon" aria-label="Prev"></button>',pager:'<ul class="pager"></ul>',pagerItem:'<li class="item"><button type="button"></button></li>',thumbs:'<ul class="thumbnails"></ul>'};constructor(e,t={}){"undefined"!=typeof window&&"undefined"!=typeof document&&(this.#r=e instanceof Element?e:document.querySelector(e),this.#r instanceof Element?(this.#C=f.deepMerge(f.defaults,t),this.#a=this.#r.querySelector(f.selector.inner),this.#l=[...this.#a?.children??[]],this.#a&&this.#l.length&&(this.#c="carousel-"+ ++f.#o,f.#n.set(this.#c,this),this.#x())):n.warn("[Carousel] Target element was not found."))}static deepMerge(e,t){const s={...e};for(const i in t)t[i]instanceof Object&&i in e?s[i]=f.deepMerge(e[i],t[i]):s[i]=t[i];return s}build(){this.#r.setAttribute("role","region"),this.#r.setAttribute("aria-roledescription","carousel"),this.#r.setAttribute("aria-live",this.#C.autoplay.enabled?"off":"polite"),this.#S(),this.#T(),this.#C.swipe&&this.#O(),this.#C.autoplay.enabled&&this.#D(),this.#I(),this.go(1)}go(e){const t=this.#l.length;this.#C.loop?(e>t&&(e=1),e<1&&(e=t)):e=Math.min(Math.max(e,1),t),this.#L=e;const s=100*-(e-1)+"%";"fade"===this.#C.mode?(this.#a.style.transform="",this.#r.classList.add(f.class.fade),this.#l.forEach(e=>e.classList.remove(f.class.active)),this.#l[e-1].classList.add(f.class.active)):(this.#r.classList.remove(f.class.fade),this.#a.style.transform=`translateX(${s})`),this.#M(this.#d),this.#M(this.#h)}next(){this.#N(),this.go(this.#L+1),this.#$()}prev(){this.#N(),this.go(this.#L-1),this.#$()}#S(){this.#C.controls&&(this.#r.insertAdjacentHTML("beforeend",f.template.prev),this.#r.insertAdjacentHTML("beforeend",f.template.next),this.#r.querySelector(f.selector.next).addEventListener("click",this.#f),this.#r.querySelector(f.selector.prev).addEventListener("click",this.#v))}#T(){this.#C.pager&&this.#C.thumbnails.enabled&&(this.#C.pager=!1),this.#C.pager?this.#H():this.#C.thumbnails.enabled&&this.#B()}#H(){this.#a.insertAdjacentHTML("afterend",f.template.pager),this.#d=this.#r.querySelector(f.selector.pager),this.#l.forEach(()=>this.#d.insertAdjacentHTML("beforeend",f.template.pagerItem)),[...this.#d.children].forEach((e,t)=>{const s=e.querySelector("button");s.setAttribute("aria-label",`Go to slide ${t+1}`),s.addEventListener("click",()=>{this.go(t+1),this.#P()})})}#B(){this.#a.insertAdjacentHTML("afterend",f.template.thumbs),this.#h=this.#r.querySelector(f.selector.thumbs),this.#l.forEach((e,t)=>{const s=e.querySelector("img"),i=document.createElement("li");i.className="item";const n=document.createElement("img");n.className="thumbnail-image";try{n.src=new URL(s?.src??"",location.href).href}catch{n.src=""}if(n.alt="",this.#C.thumbnails.clickable){const e=document.createElement("button");e.type="button",e.setAttribute("aria-label",`Go to slide ${t+1}`),e.appendChild(n),i.appendChild(e)}else i.appendChild(n);this.#h.appendChild(i)}),this.#C.thumbnails.clickable&&[...this.#h.children].forEach((e,t)=>e.querySelector("button").addEventListener("click",()=>{this.go(t+1),this.#P()}))}#M(e){e&&[...e.children].forEach((e,t)=>{const s=t===this.#L-1;e.classList.toggle(f.class.active,s),e.querySelector("button")?.setAttribute("aria-current",String(s))})}#O(){this.#a.addEventListener("pointerdown",this.#y),this.#a.addEventListener("pointermove",this.#b),this.#a.addEventListener("pointerup",this.#E),this.#a.addEventListener("pointercancel",this.#E)}#q(e){e.preventDefault(),this.#p=!0,this.#C.autoplay.pauseOnSwipe&&(this.#g=!0,this.#N()),this.#A.dx=0,this.#A.dy=0,this.#A.x=e.clientX,this.#A.y=e.clientY,this.#A.startTime=performance.now()}#R(e){this.#p&&(this.#A.dx=this.#A.x-e.clientX,this.#A.dy=this.#A.y-e.clientY)}#F(){if(!this.#p)return;this.#p=!1,this.#C.autoplay.pauseOnSwipe&&(this.#g=!1,this.#m||this.#$());const e=performance.now()-this.#A.startTime;Math.abs(this.#A.dx)>Math.abs(this.#A.dy)&&Math.abs(this.#A.dx)>this.#A.threshold&&e>120&&(this.#A.dx>0?this.next():this.prev())}#D(){this.#C.autoplay.enabled&&!this.#u&&(this.#u=setInterval(()=>this.go(this.#L+1),this.#C.autoplay.interval))}#N(){this.#u&&(clearInterval(this.#u),this.#u=null)}#$(){!this.#C.autoplay.enabled||this.#m||this.#g||this.#D()}#P(){this.#C.autoplay.enabled&&(this.#N(),this.#$())}#x(){this.#f=()=>this.next(),this.#v=()=>this.prev(),this.#y=e=>this.#q(e),this.#b=e=>this.#R(e),this.#E=()=>this.#F(),this.#w=()=>{this.#m=!0,this.#N()},this.#k=()=>{this.#m=!1,this.#g||this.#$()}}#I(){this.#C.autoplay.pauseOnHover&&(this.#r.addEventListener("pointerenter",this.#w),this.#r.addEventListener("pointerleave",this.#k))}dispose(){this.#N(),this.#r&&this.#a&&(this.#r.querySelector(f.selector.next)?.removeEventListener("click",this.#f),this.#r.querySelector(f.selector.prev)?.removeEventListener("click",this.#v),this.#d?.remove(),this.#h?.remove(),this.#r.querySelector(f.selector.next)?.remove(),this.#r.querySelector(f.selector.prev)?.remove(),this.#a.removeEventListener("pointerdown",this.#y),this.#a.removeEventListener("pointermove",this.#b),this.#a.removeEventListener("pointerup",this.#E),this.#a.removeEventListener("pointercancel",this.#E),f.#n.delete(this.#c),this.#r.removeEventListener("pointerenter",this.#w),this.#r.removeEventListener("pointerleave",this.#k))}}class v{static#j=[];static#z=!1;static TRANSITION_DURATION=280;static TRANSITION_BUFFER=60;static#_=new WeakMap;static enqueue(e){v.#j.push(e),v.#W()}static async#W(){if(!v.#z){for(v.#z=!0;v.#j.length;){const e=v.#j.shift();try{const t=new v(e.type,e.options).build();if(t instanceof Promise){const s=await t;e.resolve?.(s)}else e.resolve?.(void 0)}catch(t){e.reject?.(t)}}v.#z=!1}}static#V(e,t={},s=!1){return"undefined"==typeof document||"undefined"==typeof window?Promise.resolve("confirm"!==e&&void 0):new Promise((i,n)=>{if(s)return void v.enqueue({type:e,options:t,resolve:i,reject:n});new v(e,t).build().then(i).catch(n)})}static confirm(e={}){return v.#V("confirm",e)}static alert(e={}){return v.#V("default",e)}static custom(e={}){return"undefined"==typeof window||"undefined"==typeof document?Promise.resolve():v.#V("custom",e)}static queue={alert:(e={})=>v.#V("default",e,!0),confirm:(e={})=>v.#V("confirm",e,!0)};#U={opened:"is-open",align:{top:"is-top",center:"is-center",bottom:"is-bottom"}};#C=null;#K=null;#G=null;#Q=null;#X=null;#Y=null;#J=null;#Z=null;#ee=!1;#te=!1;#se=!1;#ie=new Set;#ne=null;#oe=null;static#re=new d;static#ae=0;#le={esc:null,backdropClick:null,dismissClick:null,confirmClick:null,transitionEnd:null};static#ce(){v.#ae+=1,1===v.#ae&&v.#re.lock()}static#de(){v.#ae=Math.max(0,v.#ae-1),0===v.#ae&&v.#re.unlock()}constructor(e,t={}){if(!["default","confirm","custom"].includes(e))throw new Error(`Invalid modal type "${e}". Must be: default, confirm, custom`);const s={default:{heading:void 0,content:"This is a Modal message",align:"center",dispose:!1,dismissText:"OK",icon:{visible:!1,type:"none"},guardMode:!1,guardButtonText:"Go here",guardButtonClass:"",guardButtonUrl:"",closeOnEsc:!0,backdrop:!0,backdropClose:!0,focusFirst:!0,onOpen:null,onOpened:null,onClose:null,onClosed:null},confirm:{heading:void 0,content:"Are you sure?",align:"center",dispose:!1,actions:{cancelText:"No",confirmText:"Yes"},closeOnEsc:!1,backdrop:!0,backdropClose:!1,focusFirst:!0,onOpen:null,onOpened:null,onClose:null,onClosed:null},custom:{id:"#",onOpen:null,onOpened:null,onClose:null,onClosed:null,closeOnEsc:!0,backdropClose:!0,focusFirst:!0}};this.type=e,this.#C={...s[e],...t},"confirm"===e&&(this.#C.actions={...s.confirm.actions,...t.actions}),this.#C.icon={visible:!1,type:"none",...this.#C.icon||{}},this.#le.esc=this.#he.bind(this),this.#le.dismissClick=this.#ue.bind(this),this.#le.confirmClick=this.#pe.bind(this)}#me(){"custom"!==this.type&&(this.#J=document.createElement("div"),this.#J.className="modal-backdrop generated-by-hygular-backdrop",this.#K=document.createElement("div"),this.#K.className="modal generated-by-hygular",this.#K.setAttribute("role","dialog"),this.#K.setAttribute("aria-modal","true"),this.#G=document.createElement("div"),this.#G.className="modal-dialog",this.#Q=document.createElement("div"),this.#Q.className="modal-header",this.#X=document.createElement("div"),this.#X.className="modal-body",this.#G.append(this.#Q,this.#X),this.#K.append(this.#G),this.#J.appendChild(this.#K),document.body.appendChild(this.#J))}#ge(){this.#C.heading&&(this.#Q.id="hygular-modal-title-"+crypto.randomUUID(),this.#Q.textContent=this.#C.heading,this.#K.setAttribute("aria-labelledby",this.#Q.id)),this.#X.textContent=this.#C.content}#fe(){if(this.#Y=document.createElement("div"),this.#Y.className="modal-actions","default"===this.type){const e=document.createElement("button");e.type="button",e.className="button is-primary-ghost modal-close",e.textContent=this.#C.dismissText,this.#Y.appendChild(e)}else if("confirm"===this.type){const e=document.createElement("button");e.type="button",e.className="button is-dark-ghost modal-close",e.textContent=this.#C.actions.cancelText;const t=document.createElement("button");t.type="button",t.className="button is-primary-ghost modal-confirm",t.textContent=this.#C.actions.confirmText,this.#Y.append(e,t)}if(this.#G.appendChild(this.#Y),this.#C.guardMode){this.#Y.innerHTML="";const e=document.createElement("button");if(e.type="button",e.className="button",e.textContent=this.#C.guardButtonText||"Go here","string"==typeof this.#C.guardButtonClass){const t=this.#C.guardButtonClass.split(" ").filter(e=>/^[a-z0-9-_]+$/i.test(e));e.classList.add(...t)}return e.addEventListener("click",()=>{this.#ve("guard-exit")&&this.#C.guardButtonUrl&&(window.location.href=this.#C.guardButtonUrl)}),void this.#Y.appendChild(e)}}#ye(){const{icon:e}=this.#C;if(!e.visible||"none"===e.type)return;const t={success:'\n <div class="status-icon is-success is-animated">\n <svg class="status-svg" viewBox="0 0 80 80" aria-hidden="true" focusable="false">\n <circle class="status-ring" cx="40" cy="40" r="32"></circle>\n <path class="status-mark" d="M25 41 L35 51 L56 29"></path>\n </svg>\n </div>\n ',error:'\n <div class="status-icon is-error is-animated">\n <svg class="status-svg" viewBox="0 0 80 80" aria-hidden="true" focusable="false">\n <circle class="status-ring" cx="40" cy="40" r="32"></circle>\n <path class="status-mark" d="M28 28 L52 52"></path>\n <path class="status-mark is-second" d="M52 28 L28 52"></path>\n </svg>\n </div>\n ',warning:'\n <div class="status-icon is-warning is-animated">\n <svg class="status-svg" viewBox="0 0 80 80" aria-hidden="true" focusable="false">\n <path class="status-ring" d="M40 12 L68 62 H12 Z" stroke-linejoin="round"></path>\n <path class="status-mark" d="M40 27 V45"></path>\n <circle class="status-dot" cx="40" cy="55" r="3.5"></circle>\n </svg>\n </div>\n ',info:'\n <div class="status-icon is-info is-animated">\n <svg class="status-svg" viewBox="0 0 80 80" aria-hidden="true" focusable="false">\n <circle class="status-ring" cx="40" cy="40" r="32"></circle>\n <path class="status-mark" d="M40 37 V55"></path>\n <circle class="status-dot" cx="40" cy="25" r="3.5"></circle>\n </svg>\n </div>\n '}[e.type];t&&this.#G.insertAdjacentHTML("afterbegin",t)}#be(){const e=this.#U.align[this.#C.align];e?this.#K.classList.add(e):this.#K.classList.add(this.#U.align.center)}#Ee(){this.#ne=document.activeElement,this.#G&&(this.#oe=e=>{if("Tab"!==e.key)return;const t=[...this.#G.querySelectorAll("a[href], button, input, select, textarea, [tabindex]")].filter(e=>!e.disabled&&e.tabIndex>=0&&e.getClientRects().length),s=t[0],i=t.at(-1);s?!e.shiftKey||document.activeElement!==s&&t.includes(document.activeElement)?e.shiftKey||document.activeElement!==i&&t.includes(document.activeElement)||(e.preventDefault(),s.focus()):(e.preventDefault(),i.focus()):(e.preventDefault(),this.#G.focus())},this.#G.addEventListener("keydown",this.#oe),this.#C.focusFirst&&this.#G.setAttribute("tabindex","-1"))}#he(e){"Escape"===e.key&&this.#C.closeOnEsc&&this.#ve("esc")}#ue(e){e.preventDefault(),this.#ve("dismiss")}#pe(e){e.preventDefault(),this.#we()}build(){if(this.#ee||this.#K||"undefined"==typeof document)return Promise.resolve("confirm"!==this.type&&void 0);if("custom"===this.type)return this.#ke();if(this.#me(),this.#be(),this.#ge(),this.#fe(),this.#ye(),"function"==typeof this.#C.onOpen){const e=this.#C.onOpen(this.#K);if(this.#ee)return Promise.resolve("confirm"!==this.type&&void 0);if(!1===e)return this.#J.remove(),Promise.reject("Cancelled by onOpen callback")}return this.#C.backdrop&&this.#C.backdropClose&&!this.#C.guardMode&&(this.#le.backdropClick=e=>{this.#G.contains(e.target)||this.#ve("backdrop")},this.#J.addEventListener("click",this.#le.backdropClick)),this.#C.closeOnEsc&&!this.#C.guardMode&&document.addEventListener("keydown",this.#le.esc),this.#Y?.querySelectorAll(".modal-close")?.forEach(e=>{e.addEventListener("click",this.#le.dismissClick)}),this.#Y?.querySelectorAll(".modal-confirm")?.forEach(e=>{e.addEventListener("click",this.#le.confirmClick)}),this.#Ae()}#Ae(){v.#ce(),this.#se=!0;const e=new Promise(e=>{this.#Z=e});this.#Ee(),o.afterPaint(()=>{this.#te||this.#ee||(this.#K.classList.add(this.#U.opened),this.#C.focusFirst&&this.#G.focus())});const t=setTimeout(()=>{this.#ie.delete(t),this.#te||this.#ee||this.#C.onOpened?.(this.#K)},v.TRANSITION_DURATION+v.TRANSITION_BUFFER);return this.#ie.add(t),e}#we(){this.#ve("confirm")}#ve(e="dismiss"){if(this.#ee||this.#te||!this.#K)return!1;if(!1===this.#C.onClose?.(this.#K,e))return!1;if(this.#ee)return!1;this.#te=!0,this.#Ce(),this.#Le(),this.#K.classList.remove(this.#U.opened);let t=!1;const s=()=>{if(t||this.#ee)return;t=!0,this.#Ce(),this.#xe(),this.#J?.remove();const s=this.#Z;this.#Z=null,this.#ne?.isConnected&&this.#ne.focus(),s?.("guard-exit"===e?"guard-exit":"confirm"===this.type?"confirm"===e:void 0);try{this.#C.onClosed?.(this.#K,e)}finally{this.#C?.dispose&&this.dispose()}};this.#le.transitionEnd=e=>{e.target===this.#K&&s()},this.#K.addEventListener("transitionend",this.#le.transitionEnd);const i=setTimeout(s,v.TRANSITION_DURATION+v.TRANSITION_BUFFER);return this.#ie.add(i),!0}#Ce(){this.#ie.forEach(clearTimeout),this.#ie.clear(),this.#K?.removeEventListener("transitionend",this.#le.transitionEnd),this.#le.transitionEnd=null}#Le(){this.#K?.ownerDocument.removeEventListener("keydown",this.#le.esc),(this.#J||this.#K)?.removeEventListener("click",this.#le.backdropClick),this.#K?.querySelectorAll(".modal-close").forEach(e=>{e.removeEventListener("click",this.#le.dismissClick),v.#_.get(e)===this.#le.dismissClick&&v.#_.delete(e)}),this.#K?.querySelectorAll(".modal-confirm").forEach(e=>e.removeEventListener("click",this.#le.confirmClick)),this.#G?.removeEventListener("keydown",this.#oe)}#xe(){this.#se&&(this.#se=!1,v.#de())}#ke(){const e=this.#C.id instanceof Element?this.#C.id:document.querySelector(this.#C.id);return e?!1===this.#C.onOpen?.(e)?Promise.reject(new Error("Cancelled by onOpen")):(this.#K=e,this.#G=e.querySelector(".modal-dialog")||e,e.querySelectorAll(".modal-close").forEach(e=>{const t=v.#_.get(e);t&&e.removeEventListener("click",t),v.#_.set(e,this.#le.dismissClick),e.addEventListener("click",this.#le.dismissClick)}),this.#C.closeOnEsc&&document.addEventListener("keydown",this.#le.esc),this.#C.backdropClose&&(this.#le.backdropClick=e=>{this.#G.contains(e.target)||this.#ve("backdrop")},e.addEventListener("click",this.#le.backdropClick)),this.#Ae()):Promise.reject(new Error("Custom modal element not found: "+this.#C.id))}dispose(){this.#ee||(this.#ee=!0,this.#Ce(),this.#Le(),this.#xe(),this.#K?.classList.remove(this.#U.opened),this.#J?.remove(),this.#Z?.("confirm"!==this.type&&void 0),this.#ne?.isConnected&&this.#ne.focus(),this.#ne=null,this.#K=null,this.#G=null,this.#Q=null,this.#X=null,this.#Y=null,this.#J=null,this.#Z=null,this.#C=null)}}class y{#Se=null;#C=null;#Te=null;#Oe=new Set;#De=new Map;#ee=!1;#Ie=["success","danger","warning","info","default"];#U={icon:"has-icon",animated:"animation-none",bordered:"border-0",alertBase:"alert",closeBtn:"alert-close"};#Me={message:"This is an alert message",status:"default",hasIcon:!1,dismissible:!0,position:"before",animated:!0,animation:"fade",bordered:!1,autoClean:!1};static create(e,t={}){const s=new y(e,t);return s.#Se?(s.build(),s):(n.warn(`[Alert] Target element "${e}" was not found. Instance was not created.`),null)}constructor(e,t={}){if("undefined"!=typeof window&&"undefined"!=typeof document){if(this.#Se=e instanceof Element?e:document.querySelector(e),!(this.#Se instanceof Element))return n.warn(`[Alert] Target element "${e}" was not found. Instance was not created.`),null;this.#C={...this.#Me,...t},this.#Te=this.#ue.bind(this)}}build(){if(this.#ee||!this.#Se)return;const e=this.#Ne(),t="before"===this.#C.position?"beforebegin":"afterend";return this.#Se.insertAdjacentElement(t,e),this.#C.dismissible&&e.addEventListener("click",this.#Te),this.#Oe.add(e),e}#$e(e="is-"){return this.#Ie.includes(this.#C.status)?`${e}${this.#C.status}`:`${e}default`}#Ne(){const e=[this.#U.alertBase,this.#$e(),this.#C.hasIcon?this.#U.icon:"",!1===this.#C.animated?this.#U.animated:"",!1===this.#C.bordered?this.#U.bordered:""].filter(Boolean).join(" "),t=document.createElement("div");t.setAttribute("role","alert");const s=document.createElement("span");if(t.className=e,s.className="alert-content",s.appendChild(document.createTextNode(this.#C.message)),t.appendChild(s),this.#C.dismissible){const e=document.createElement("button");e.type="button",e.className=`button ${this.#U.closeBtn}`,e.setAttribute("aria-label","Dismiss alert"),t.appendChild(e)}return t}#ue(e){if(this.#ee)return;const t=e.target.closest(`.${this.#U.closeBtn}`),s=t?.closest(`.${this.#U.alertBase}`);if(s&&this.#Oe.has(s)&&!this.#De.has(s))if(e.preventDefault(),s.removeEventListener("click",this.#Te),"slide"===this.#C.animation)this.#De.set(s,()=>{s.getAnimations?.().forEach(e=>e.cancel())}),o.slideUp(s,200,!0).then(()=>this.#He(s));else{const e=e=>{e.target===s&&"opacity"===e.propertyName&&this.#He(s)},t=setTimeout(()=>this.#He(s),250);this.#De.set(s,()=>{clearTimeout(t),s.removeEventListener("transitionend",e)}),s.addEventListener("transitionend",e),s.style.transition="opacity 0.2s ease",s.style.opacity="0"}}#He(e){this.#Oe.has(e)&&(this.#De.get(e)?.(),this.#De.delete(e),e.removeEventListener("click",this.#Te),e.remove(),this.#Oe.delete(e),this.#C?.autoClean&&this.dispose())}dispose(){this.#ee||(this.#ee=!0,this.#De.forEach(e=>e()),this.#De.clear(),this.#Oe.forEach(e=>{e.removeEventListener("click",this.#Te),e.remove()}),this.#Oe.clear(),this.#Se=null,this.#C=null,this.#Te=null)}}class b{#Be;#C;#Pe;#qe=[];#r;#Re;#Fe;#je;#ze;#_e;#We;#Ve;#Ue;#Ke;#Ge=null;#Qe;#Xe=[];#Ye=-1;#Je=!1;#ee=!1;#Ze=null;#et;#tt;static#o=0;static defaults={inputName:"select",multiple:!1,defaultValue:null,data:[],search:!1,placeholder:"--SELECT--"};static variables={animationDuration:200};constructor(e,t={}){"undefined"!=typeof window&&"undefined"!=typeof document&&(this.#Be=e instanceof Element?e:document.querySelector(e),this.#Be instanceof Element?(this.#C={...b.defaults,...t,data:t.data??b.defaults.data},this.#Pe=this.#C.data,this.#We=b.variables.animationDuration,this.#st()):n.warn("[Select] Target element was not found."))}#st(){this.#it(),this.#nt(),null!=this.#C.defaultValue&&this.#ot()}#it(){this.#r=document.createElement("div"),this.#r.className="custom-select",this.#r.setAttribute("aria-expanded","false"),this.#r.setAttribute("aria-haspopup","listbox"),this.#Re=document.createElement("div"),this.#Re.className="selected-option",this.#Re.tabIndex=0,this.#Re.setAttribute("role","combobox"),this.#Re.setAttribute("aria-expanded","false"),this.#Re.setAttribute("aria-haspopup","listbox");const e=this.#Be.getAttribute("aria-labelledby"),t=this.#Be.getAttribute("aria-label")||Array.from(this.#Be.labels||[]).map(e=>e.textContent.trim()).join(" ");e?this.#Re.setAttribute("aria-labelledby",e):this.#Re.setAttribute("aria-label",t||this.#C.placeholder),this.#Re.innerText=this.#C.placeholder,this.#r.appendChild(this.#Re),this.#Fe=document.createElement("div"),this.#Fe.className="options-container",this.#Fe.style.transition=`opacity ${this.#We}ms ease, transform ${this.#We}ms ease`,this.#Fe.hidden=!0,this.#r.appendChild(this.#Fe),this.#je=document.createElement("input"),this.#je.type="hidden",this.#je.name=this.#C.inputName,this.#r.appendChild(this.#je),this.#C.search&&(this.#ze=document.createElement("input"),this.#ze.type="text",this.#ze.placeholder="Search...",this.#ze.className="form-input",this.#Ue=()=>this.#rt(),this.#ze.addEventListener("input",this.#Ue),this.#Fe.appendChild(this.#ze)),this.#Qe=document.createElement("div"),this.#Qe.id="hygular-select-"+ ++b.#o,this.#Qe.setAttribute("role","listbox"),this.#Qe.setAttribute("aria-label",t||this.#C.placeholder),this.#C.multiple&&this.#Qe.setAttribute("aria-multiselectable","true"),this.#Fe.appendChild(this.#Qe),this.#Re.setAttribute("aria-controls",this.#Qe.id),this.#ze&&(this.#ze.setAttribute("role","combobox"),this.#ze.setAttribute("aria-label",t?`Search ${t}`:"Search options"),this.#ze.setAttribute("aria-autocomplete","list"),this.#ze.setAttribute("aria-controls",this.#Qe.id),this.#ze.setAttribute("aria-expanded","false")),this.#Pe.forEach(e=>this.#at(e)),this.#Ve=()=>{this.toggle(),this.#Je&&this.#ze?.focus()},this.#Re.addEventListener("click",this.#Ve),this.#et=e=>this.#lt(e),this.#tt=e=>{this.#r.contains(e.relatedTarget)||this.close()},this.#r.addEventListener("keydown",this.#et),this.#r.addEventListener("focusout",this.#tt),this.#Be.insertAdjacentElement("afterend",this.#r),this.#C.multiple&&"undefined"!=typeof ResizeObserver&&(this.#Ke=new ResizeObserver(()=>this.#ct()),this.#Ke.observe(this.#Re))}#at(e){const t=document.createElement("div");if(t.setAttribute("role","option"),t.className="select-option",t.id=`${this.#Qe.id}-option-${this.#Xe.length}`,t.setAttribute("aria-selected","false"),this.#Xe.push(t),t.dataset.value=e.value,t.dataset.name=e.name.toLowerCase(),e.icon){const s=document.createElement("img");s.src=e.icon,s.className="option-icon",t.appendChild(s)}const s=document.createTextNode(e.name);t.appendChild(s),t.addEventListener("click",()=>{this.select(e),this.#ee||(this.#Je&&this.#ze?this.#ze:this.#Re).focus()}),this.#Qe.appendChild(t)}select(e){if(!this.#ee&&this.#r&&e){if(this.#C.multiple){if(this.#qe.find(t=>t.value===e.value))return;this.#qe.push(e),this.#dt()}else{if(this.#qe=[e],this.#Re.innerHTML="",e.icon){const t=document.createElement("img");t.src=e.icon,t.className="option-icon",this.#Re.appendChild(t)}this.#Re.appendChild(document.createTextNode(e.name)),this.close()}this.#ht()}}#dt(){this.#Re.innerHTML="",this.#C.multiple&&0!==this.#qe.length?(this.#qe.forEach(e=>{const t=document.createElement("div");if(t.className="select-tag",e.icon){const s=document.createElement("img");s.src=e.icon,s.className="option-icon",t.appendChild(s)}t.appendChild(document.createTextNode(e.name));const s=document.createElement("button");s.type="button",s.setAttribute("aria-label",`Remove ${e.name}`),s.className="tag-remove",s.textContent="×",s.onclick=t=>{t.stopPropagation(),this.remove(e.value),this.#ee||this.#Re.focus()},t.appendChild(s),this.#Re.appendChild(t)}),this.#ct()):this.#Re.innerText=this.#C.placeholder}#ct(){this.#ee||null!==this.#Ze||(this.#Ze=requestAnimationFrame(()=>{if(this.#Ze=null,this.#ee)return;const e=this.#Re.getBoundingClientRect().width;if(e<=0)return;let t=0,s=0;if(this.#Re.querySelectorAll(".select-tag").forEach(i=>{i.style.display="inline-flex";const n=i.offsetWidth+6;t+n>e-55?(i.style.display="none",s++):t+=n}),this.#Re.querySelector(".more-tag")?.remove(),s){const e=document.createElement("div");e.className="more-tag",e.textContent=`+${s} more`,this.#Re.appendChild(e)}}))}#ht(){this.#ut(),this.#je.value=this.#qe.map(e=>e.value).join(","),this.#Be.value=this.#je.value,this.#Be.dispatchEvent(new Event("change"))}#ut(){this.#Xe.forEach((e,t)=>{const s=this.#qe.some(e=>e.value===this.#Pe[t].value);e.setAttribute("aria-selected",String(s))})}#pt(e){this.#Ye=e,this.#Xe.forEach((t,s)=>t.classList.toggle("is-active",s===e));const t=this.#Xe[e];for(const e of[this.#Re,this.#ze])e&&(t?e.setAttribute("aria-activedescendant",t.id):e.removeAttribute("aria-activedescendant"));t?.scrollIntoView?.({block:"nearest"})}#lt(e){if(this.#ee||e.target.closest(".tag-remove")||e.isComposing)return;const t=e.target===this.#ze;if("Tab"===e.key)return void this.close();if("Escape"===e.key)return void(this.#Je&&(e.preventDefault(),e.stopPropagation(),this.close(),this.#Re.focus()));const s="ArrowDown"===e.key||"ArrowUp"===e.key,i=!t&&("Home"===e.key||"End"===e.key);if(s||i){e.preventDefault();const t=this.#Je;this.open();const s=this.#Xe.map((e,t)=>e.hidden?-1:t).filter(e=>e>=0);let i=s.indexOf(this.#Ye);return"Home"===e.key?i=0:"End"===e.key?i=s.length-1:t?i=i<0?"ArrowUp"===e.key?s.length-1:0:Math.max(0,Math.min(s.length-1,i+("ArrowUp"===e.key?-1:1))):"ArrowUp"===e.key&&(i=s.length-1),void this.#pt(s[i]??-1)}if("Enter"===e.key||" "===e.key&&!t)if(e.preventDefault(),this.#Je){if(this.#Ye>=0){const e=this.#Pe[this.#Ye];this.#C.multiple&&this.#qe.some(t=>t.value===e.value)?this.remove(e.value):this.select(e),this.#ee||this.#Je||this.#Re.focus()}}else this.open(),this.#ze?.focus()}remove(e){!this.#ee&&this.#r&&(this.#qe=this.#qe.filter(t=>t.value!==e),this.#dt(),this.#ut(),this.#je.value=this.#qe.map(e=>e.value).join(","),this.#Be.value=this.#je.value,this.#Be.dispatchEvent(new Event("change")))}#ot(){(Array.isArray(this.#C.defaultValue)?this.#C.defaultValue.map(e=>this.#Pe.find(t=>t.value==e)):[this.#Pe.find(e=>e.value==this.#C.defaultValue)]).forEach(e=>e&&this.select(e))}open(){this.#ee||!this.#r||this.#Je||(this.#Je=!0,this.#Fe.hidden=!1,this.#Re.setAttribute("aria-expanded","true"),this.#ze?.setAttribute("aria-expanded","true"),this.#pt(this.#Xe.findIndex(e=>!e.hidden&&"true"===e.getAttribute("aria-selected"))),this.#Ye<0&&this.#pt(this.#Xe.findIndex(e=>!e.hidden)),clearTimeout(this.#Ge),this.#Ge=null,this.#Fe.style.display="block",this.#Fe.offsetWidth,this.#Fe.style.opacity="1",this.#Fe.style.transform="translateX(-50%) translateY(0)",this.#r.setAttribute("aria-expanded","true"))}close(){!this.#ee&&this.#r&&this.#Je&&(this.#Je=!1,this.#Re.setAttribute("aria-expanded","false"),this.#ze?.setAttribute("aria-expanded","false"),this.#pt(-1),clearTimeout(this.#Ge),this.#Fe.style.opacity="0",this.#Fe.style.transform="translateX(-50%) translateY(-8px)",this.#r.setAttribute("aria-expanded","false"),this.#Ge=setTimeout(()=>{this.#Fe.style.display="none",this.#Fe.hidden=!0,this.#Ge=null},this.#We))}toggle(){this.#Je?this.close():this.open()}#rt(){const e=this.#ze.value.toLowerCase();this.#Fe.querySelectorAll(".select-option").forEach(t=>{const s=t.dataset.name;t.hidden=!s.includes(e),t.style.display=t.hidden?"none":"flex"}),this.#pt(this.#Xe.findIndex(e=>!e.hidden))}#nt(){this.#_e=e=>{this.#r.contains(e.target)||this.close()},document.addEventListener("click",this.#_e)}dispose(){this.#ee||(this.#ee=!0,null!==this.#Ze&&cancelAnimationFrame(this.#Ze),this.#Ze=null,this.#r?.removeEventListener("keydown",this.#et),this.#r?.removeEventListener("focusout",this.#tt),clearTimeout(this.#Ge),this.#Ge=null,this.#r?.ownerDocument.removeEventListener("click",this.#_e),this.#Re?.removeEventListener("click",this.#Ve),this.#ze&&this.#Ue&&this.#ze.removeEventListener("input",this.#Ue),this.#r?.remove(),this.#Ke&&(this.#Ke.disconnect(),this.#Ke=null))}}class E{static#n=new WeakMap;#Be=null;#mt=null;#C=null;#gt=!1;#ee=!1;#ft=null;#vt=null;#yt=null;#bt=null;#Et=null;#wt=null;#Me={message:"Hi, I am a tooltip message",placement:"auto",hasArrow:!0,autoClean:!1};#U={tooltip:"tooltip",active:"is-open",arrow:"has-arrow",top:"is-top",bottom:"is-bottom",left:"is-left",right:"is-right"};constructor(e,t={}){if("undefined"==typeof window||"undefined"==typeof document)return;if(this.#Be="string"==typeof e?document.querySelector(e):e,!(this.#Be instanceof Element))return void n.warn("[Tooltip] Target element is not a valid DOM element.");const s=E.#n.get(this.#Be);s&&s.dispose(),this.#C=this.#kt(t),E.#n.set(this.#Be,this),this.#At()}#kt(e={}){const t={message:this.#Be.dataset.tooltip,placement:this.#Be.dataset.placement};return{...this.#Me,...this.#Ct(t),...this.#Ct(e)}}#Ct(e){return Object.fromEntries(Object.entries(e).filter(([,e])=>null!=e&&""!==e))}#At(){const e="ontouchstart"in window||navigator.maxTouchPoints>0;this.#yt=e=>{"Escape"===e.key&&this.hide()},this.#ft=()=>this.show(),this.#vt=()=>this.hide(),e?(this.#Be.addEventListener("touchstart",this.#ft,{passive:!0}),this.#Be.addEventListener("touchend",this.#vt),this.#Be.addEventListener("touchcancel",this.#vt)):(this.#Be.addEventListener("mouseenter",this.#ft),this.#Be.addEventListener("mouseleave",this.#vt)),this.#Be.addEventListener("focus",this.#ft),this.#Be.addEventListener("blur",this.#vt),document.addEventListener("keydown",this.#yt)}show(){if(this.#ee||this.#gt||!this.#Be)return;const e=String(this.#C.message??"").trim();if(!e)return;const t=this.#Lt();this.#mt=document.createElement("div"),this.#mt.id=t,this.#mt.className=this.#U.tooltip,this.#mt.setAttribute("role","tooltip"),this.#mt.textContent=e,this.#C.hasArrow&&this.#mt.classList.add(this.#U.arrow),this.#Et=this.#Be.getAttribute("aria-describedby"),this.#Be.setAttribute("aria-describedby",[this.#Et,t].filter(Boolean).join(" ")),"static"===getComputedStyle(this.#Be).position&&(this.#wt={value:this.#Be.style.getPropertyValue("position"),priority:this.#Be.style.getPropertyPriority("position")},this.#Be.style.position="relative"),this.#Be.appendChild(this.#mt);const s=this.#mt;o.afterPaint(()=>{this.#mt!==s||this.#ee||(this.#xt(),this.#mt.classList.add(this.#U.active))}),this.#gt=!0,this.#St()}#xt(){if(!this.#mt||!this.#Be)return;this.#Tt();const e=this.#Ot();this.#mt.classList.add(this.#U[e])}#Ot(){const e=this.#Dt(this.#C.placement),t=this.#Be.getBoundingClientRect(),s=this.#mt.getBoundingClientRect(),i=window.innerWidth,n=window.innerHeight,o={top:t.top,bottom:n-t.bottom,left:t.left,right:i-t.right},r={top:o.top>=s.height,bottom:o.bottom>=s.height,left:o.left>=s.width,right:o.right>=s.width};if("auto"!==e&&r[e])return e;const a=Object.keys(r).filter(e=>r[e]);return a.length?this.#It(a,o,s):this.#It(["top","bottom","left","right"],o,s)}#It(e,t,s){const i={top:t.top/s.height,bottom:t.bottom/s.height,left:t.left/s.width,right:t.right/s.width};return e.sort((e,t)=>i[t]-i[e])[0]}#Dt(e){return["auto","top","bottom","left","right"].includes(e)?e:"auto"}#Tt(){this.#mt.classList.remove(this.#U.top,this.#U.bottom,this.#U.left,this.#U.right)}#St(){this.#bt||(this.#bt=()=>{this.#gt&&this.#xt()},window.addEventListener("resize",this.#bt),window.addEventListener("scroll",this.#bt,!0))}#Mt(){this.#bt&&(window.removeEventListener("resize",this.#bt),window.removeEventListener("scroll",this.#bt,!0),this.#bt=null)}hide(){this.#gt&&!this.#ee&&(this.#Mt(),this.#mt?.remove(),this.#mt=null,this.#gt=!1,null===this.#Et?this.#Be?.removeAttribute("aria-describedby"):this.#Be?.setAttribute("aria-describedby",this.#Et),this.#wt&&(this.#wt.value?this.#Be.style.setProperty("position",this.#wt.value,this.#wt.priority):this.#Be.style.removeProperty("position"),this.#wt=null),this.#C.autoClean&&this.dispose())}#Lt(){return`hygular-tooltip-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}static getInstance(e){return E.#n.get(e)}static init(e='[data-hygular="tooltip"]'){return"undefined"==typeof document?[]:[...document.querySelectorAll(e)].map(e=>E.#n.get(e)||new E(e))}dispose(){this.#ee||(this.hide(),this.#Be?.removeEventListener("mouseenter",this.#ft),this.#Be?.removeEventListener("mouseleave",this.#vt),this.#Be?.removeEventListener("touchstart",this.#ft),this.#Be?.removeEventListener("touchend",this.#vt),this.#Be?.removeEventListener("touchcancel",this.#vt),this.#Be?.removeEventListener("focus",this.#ft),this.#Be?.removeEventListener("blur",this.#vt),this.#Be?.ownerDocument.removeEventListener("keydown",this.#yt),E.#n.delete(this.#Be),this.#ee=!0,this.#Be=null,this.#mt=null,this.#C=null)}}class w{static#n=new Map;static#Nt=0;static get instances(){return w.#n}#c=null;#C=null;#Be=null;#$t=null;#Ht=null;#Bt;#Pt=null;#Me={message:"Hi, I am a toast message",status:"default",position:"bottom",duration:4e3,dismissPrevious:!1,showIcon:!1,autoClean:!1};#qt={rootParent:"body",toastBase:"toast",generated:"generated-by-hygular"};#U={active:"is-active",posTop:"is-top",posBottom:"is-bottom"};#Rt={success:"is-success",danger:"is-danger",warning:"is-warning",info:"is-info",default:"is-default"};constructor(e={}){this.#C={...this.#Me,...e},this.#C.duration=Math.min(Math.max(parseInt(this.#C.duration)||0,1e3),1e4),this.#c="toast-"+ ++w.#Nt,w.#n.set(this.#c,this)}static show(e={}){const t=new w(e);return t.build(),t}build(){if(!this.#C||this.#Be)return;if("undefined"==typeof window||"undefined"==typeof document)return;w.#n.set(this.#c,this);const e=this.#qt.rootParent instanceof Element?this.#qt.rootParent:document.querySelector(this.#qt.rootParent)||document.body,t=`hygular-toast-container-${this.#C.position}`;let s=e.querySelector(`.${t}`);s||(s=document.createElement("div"),s.className=`hygular-toast-container ${t}`,e.appendChild(s)),this.#Pt=s,this.#C.dismissPrevious&&this.#Ft(this.#Pt),this.#me(this.#Pt),this.#jt(),this.#zt()}dismiss(){this.#_t(),this.#Wt(),w.#n.delete(this.#c),this.#C?.autoClean&&this.dispose()}#me(e){const t=document.createElement("div");if(t.classList.add(this.#qt.toastBase,this.#qt.generated),t.setAttribute("data-toast-id",this.#c),t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),this.#C.showIcon){const e=document.createElement("span");e.className="toast-icon",t.appendChild(e)}const s=document.createElement("span");s.className="toast-message",s.textContent=this.#C.message,t.appendChild(s);const i=document.createElement("div");i.className="toast-progress",t.appendChild(i),e.appendChild(t),this.#Be=t,this.#$t=i,o.afterPaint(()=>{this.#Be===t&&t.classList.add(this.#U.active)})}#jt(){if(!(this.#Be instanceof Element))return void n.warn("[Toast] Target element was not found.");this.#Bt=()=>this.dismiss(),this.#Be.addEventListener("click",this.#Bt);const e="top"===this.#C.position?this.#U.posTop:this.#U.posBottom;this.#Be.classList.add(e);const t=this.#Rt[this.#C.status]??this.#Rt.default;this.#Be.classList.add(t),this.#C.showIcon&&this.#Be.classList.add("has-icon")}#zt(){if(!this.#$t||!this.#Be)return;this.#$t.style.width="100%";const e=this.#$t;o.afterPaint(()=>{this.#$t===e&&(this.#$t.style.transition=`width ${this.#C.duration}ms linear`,this.#$t.style.width="0%")}),this.#Ht=setTimeout(()=>{this.#Be&&this.#Be.parentNode&&this.dismiss(),this.#Ht=null},this.#C.duration)}#_t(){this.#Ht&&(clearTimeout(this.#Ht),this.#Ht=null),this.#$t&&(this.#$t.style.transition="")}#Wt(){if(this.#Be){this.#Bt&&this.#Be.removeEventListener("click",this.#Bt);try{this.#Be.parentNode&&this.#Be.parentNode.removeChild(this.#Be)}catch(e){}this.#Be=null,this.#$t=null,this.#Bt=null}}#Ft(e){e.querySelectorAll(`.${this.#qt.generated}`).forEach(e=>{const t=w.#n.get(e.getAttribute("data-toast-id"));t?t.dismiss():e.remove()})}dispose(){this.#_t(),this.#Wt(),w.#n.delete(this.#c),this.#c=null,this.#C=null}}class k{#C;#r;#Pt;#Vt;#Ut=null;#Kt="darkMode";#Gt;#Qt=null;#Xt=null;#Yt=null;#Jt=[];constructor(e={}){if("undefined"==typeof window||"undefined"==typeof document)return;this.#r=document.documentElement;this.#C={container:"body",customBtn:!1,autoCreateBtn:!0,...e},this.#Pt=document.querySelector(this.#C.container)||document.body,this.#st()}#Zt(){this.#Vt=document.createElement("label"),this.#Vt.classList.add("dark-mode-toggler"),"body"===this.#C.container&&(this.#Vt.classList.add("is-fixed"),this.#Vt.setAttribute("data-fixed-lock","")),this.#Vt.setAttribute("aria-label","Dark Mode Toggle Button"),this.#Vt.addEventListener("mousedown",e=>e.preventDefault()),this.#Ut=document.createElement("input"),this.#Ut.type="checkbox",this.#Ut.setAttribute("aria-label","Enable dark mode"),this.#Ut.setAttribute("role","switch");const e=document.createElement("div");e.classList.add("dark-mode-toggler-track");const t=document.createElement("div");t.classList.add("dark-mode-toggler-thumb"),t.innerHTML='\n <span class="dark-mode-toggler-sun" aria-hidden="true">\n <svg width="14" height="14" viewBox="0 0 24 24" fill="none"\n stroke="currentColor" stroke-width="2.5"\n stroke-linecap="round" stroke-linejoin="round">\n <circle cx="12" cy="12" r="4"/>\n <line x1="12" y1="2" x2="12" y2="6"/>\n <line x1="12" y1="18" x2="12" y2="22"/>\n <line x1="2" y1="12" x2="6" y2="12"/>\n <line x1="18" y1="12" x2="22" y2="12"/>\n <line x1="4.22" y1="4.22" x2="7.05" y2="7.05"/>\n <line x1="16.95" y1="16.95" x2="19.78" y2="19.78"/>\n <line x1="4.22" y1="19.78" x2="7.05" y2="16.95"/>\n <line x1="16.95" y1="7.05" x2="19.78" y2="4.22"/>\n </svg>\n </span>\n <span class="dark-mode-toggler-moon" aria-hidden="true">\n <svg width="13" height="13" viewBox="0 0 24 24" fill="none"\n stroke="currentColor" stroke-width="2.5"\n stroke-linecap="round" stroke-linejoin="round">\n <path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"/>\n </svg>\n </span>\n ',e.appendChild(t),this.#Vt.appendChild(this.#Ut),this.#Vt.appendChild(e),this.#Pt.appendChild(this.#Vt)}#es(){const e=this.#ts();"enabled"===e?this.#ss(!0):"disabled"===e?this.#ss(!1):null===e&&this.#ss(window.matchMedia("(prefers-color-scheme: dark)").matches)}#ss(e){e?this.#r.setAttribute("data-hygular-theme","dark"):this.#r.removeAttribute("data-hygular-theme"),this.#Ut&&(this.#Ut.checked=e),this.#Qt?.classList.toggle("is-dark",e)}#is(){const e=this.isDark();this.#Jt.forEach(t=>t(e)),this.#r.dispatchEvent(new CustomEvent("hygular.theme.change",{detail:{isDark:e}}))}#ts(){try{return localStorage.getItem(this.#Kt)}catch{return null}}#ns(e){try{localStorage.setItem(this.#Kt,e)}catch{}}#os(){const e=!this.isDark();this.#ss(e),this.#ns(e?"enabled":"disabled"),this.#is()}#At(){if(this.#Ut&&this.#Ut.addEventListener("change",()=>this.#os()),this.#C.customBtn){if(this.#Qt=document.querySelector(this.#C.customBtn),!this.#Qt)return;this.#Gt=()=>this.#os(),this.#Qt.addEventListener("click",this.#Gt)}}#st(){if(this.#C.autoCreateBtn&&!this.#C.customBtn&&this.#Zt(),this.#At(),this.#es(),"undefined"!=typeof window){const e=window.matchMedia("(prefers-color-scheme: dark)");this.#Yt=e,this.#Xt=e=>{null===this.#ts()&&(this.#ss(e.matches),this.#is())},e.addEventListener("change",this.#Xt)}}isDark(){return"dark"===this.#r?.getAttribute("data-hygular-theme")}onChange(e){"function"==typeof e&&this.#Jt.push(e)}dispose(){this.#Vt?.remove(),this.#Vt=null,this.#Ut=null,this.#Xt&&this.#Yt?.removeEventListener("change",this.#Xt),this.#Qt&&this.#Gt&&this.#Qt.removeEventListener("click",this.#Gt),this.#Jt=[],this.#Qt=null,this.#Gt=null,this.#Xt=null,this.#Yt=null}}class A{static show(e){e&&!e.skeletonActive&&(A._emit(e,"hygular.skeleton.show",!0)||(e.skeletonActive=!0,e.skeletonAriaHidden=e.getAttribute("aria-hidden"),e.skeletonAriaLabel=e.getAttribute("aria-label"),e.setAttribute("aria-hidden","true"),e.setAttribute("aria-label","Loading…"),e.setAttribute("data-skeleton",""),A.clearError(e),A.injectWave(e),A.watchResize(e),A._emit(e,"hygular.skeleton.shown")))}static hide(e){e&&e.skeletonActive&&(A._emit(e,"hygular.skeleton.hide",!0)||(A.resetLoading(e),A._emit(e,"hygular.skeleton.hidden")))}static error(e,t={}){if(!e)return;const{message:s="Failed to load",retry:i=!1,onRetry:n=null}=t;e.skeletonActive&&A.resetLoading(e),A.clearError(e),e.setAttribute("data-skeleton-error",""),e.setAttribute("aria-live","polite");const o=A._createElement("div","hygular-sk-error-layer",{"data-skeleton-injected":"","data-skeleton-ignore":"",role:"alert"});o.appendChild(A.createErrorIcon());const r=A._createElement("p","hygular-sk-error-msg");if(r.textContent=s,o.appendChild(r),i){const t=A._createElement("button","hygular-sk-retry");t.type="button",t.textContent="Try again",t.addEventListener("click",()=>{A.clearError(e),"function"==typeof n&&n(e),A._emit(e,"hygular.skeleton.retry")}),o.appendChild(t)}e.appendChild(o),A._emit(e,"hygular.skeleton.error",!1,{message:s})}static async wrap(e,t,s={}){A.show(e);try{return await t()}catch(t){throw A.error(e,{message:s.message??t.message??"Failed to load",retry:s.retry??!1,onRetry:s.onRetry??null}),t}finally{e.skeletonActive&&A.hide(e)}}static mount(){if("undefined"==typeof window||"undefined"==typeof document)return()=>{};if(A.mountCleanup)return A.mountCleanup;const e=new Set;let t=!1;const s=t=>{"false"===t.getAttribute("data-skeleton-auto")||t.skeletonActive||(A.show(t),t.skeletonActive&&e.add(t))};document.querySelectorAll("[data-skeleton]").forEach(s),A._mutationObserver=new MutationObserver(e=>{if(!t)for(const t of e)for(const e of t.addedNodes)1===e.nodeType&&(e.hasAttribute("data-skeleton")&&s(e),e.querySelectorAll("[data-skeleton]").forEach(s))}),A._mutationObserver.observe(document.body,{childList:!0,subtree:!0});const i=()=>{t||(t=!0,A._mutationObserver.disconnect(),A._mutationObserver=null,A.mountCleanup=null,e.forEach(e=>{e.skeletonActive&&A.resetLoading(e)}),e.clear())};return A.mountCleanup=i,i}static resetLoading(e){e.skeletonActive=!1,e.removeAttribute("data-skeleton"),A.unwatchResize(e),A.restoreAria(e),A.removeOverlay(e)}static watchResize(e){e.skeletonResizeObserver||"undefined"==typeof ResizeObserver||(e.skeletonResizeObserver=new ResizeObserver(()=>{e.skeletonActive&&(A.removeOverlay(e),A.injectWave(e))}),e.skeletonResizeObserver.observe(e))}static unwatchResize(e){e.skeletonResizeObserver&&(e.skeletonResizeObserver.disconnect(),e.skeletonResizeObserver=null)}static injectWave(e){if(e.querySelector("[data-skeleton-injected]"))return;const t=A._createElement("div","hygular-sk-wave-overlay",{"data-skeleton-injected":"","data-skeleton-ignore":"","aria-hidden":"true"}),s=e.getAttribute("data-skeleton-layout")||"auto",i=e.offsetWidth||300,n=e.offsetHeight||200,o="card"===s?A.createCard(e,i,n):"list"===s?A.createList(e,i,n):"article"===s?A.createArticle(i,n):"profile"===s?A.createProfile(i,n):A.detectShapes(e,e.getBoundingClientRect());if(0===o.length){const e=A._createElement("span","hygular-sk-ghost");e.style.cssText="position:absolute;inset:0;border-radius:inherit;",t.appendChild(e)}else for(const e of o){const s=A._createElement("span","hygular-sk-ghost");s.style.cssText=`position:absolute;top:${e.top}px;left:${e.left}px;width:${e.width}px;height:${e.height}px;border-radius:${e.radius};`,t.appendChild(s)}e.appendChild(t)}static createCard(e,t,s){const i=Math.max(1,parseInt(e.getAttribute("data-skeleton-cols"),10)||Math.max(1,Math.round(t/220))),n=Math.max(1,parseInt(e.getAttribute("data-skeleton-rows"),10)||2),o=(t-12*(i-1))/i,r=(s-12*(n-1))/n,a=[];for(let e=0;e<n;e++)for(let t=0;t<i;t++){const s=t*(o+12),i=e*(r+12);a.push({top:i,left:s,width:o,height:.52*r,radius:"8px"}),a.push({top:i+.57*r,left:s,width:32,height:32,radius:"50%"}),a.push({top:i+.57*r+6,left:s+42,width:.55*o,height:11,radius:"6px"}),a.push({top:i+.57*r+24,left:s+42,width:.35*o,height:9,radius:"6px"}),a.push({top:i+.83*r,left:s,width:.42*o,height:9,radius:"6px"})}return a}static createList(e,t,s){const i=Math.max(1,parseInt(e.getAttribute("data-skeleton-rows"),10)||5),n=[];for(let e=0;e<i;e++){const s=56*e;n.push({top:s+10,left:12,width:36,height:36,radius:"50%"}),n.push({top:s+13,left:60,width:t*(.4+e%3*.07),height:11,radius:"6px"}),n.push({top:s+31,left:60,width:t*(.25+e%2*.06),height:9,radius:"6px"})}return n}static createArticle(e,t){const s=Math.min(200,.4*t),i=[{top:0,left:0,width:e,height:s,radius:"10px"}],n=[.9,.76,.83,.6,.78,.5];let o=s+18;for(const t of n)i.push({top:o,left:0,width:e*t,height:12,radius:"6px"}),o+=21;return i}static createProfile(e){const t=e-80-8;return[{top:0,left:0,width:64,height:64,radius:"50%"},{top:5,left:80,width:.55*t,height:13,radius:"6px"},{top:25,left:80,width:.38*t,height:11,radius:"6px"},{top:50,left:80,width:.7*t,height:10,radius:"6px"},{top:67,left:80,width:.5*t,height:10,radius:"6px"}]}static detectShapes(e,t){const s=[],i=new Set(["SPAN","A","STRONG","EM","B","I","LABEL","H1","H2","H3","H4","H5","H6","P","LI","TD","TH","CAPTION","FIGCAPTION","TIME","CODE","KBD","MARK","SMALL"]),n=new Set(["IMG","SVG","VIDEO","CANVAS","INPUT","TEXTAREA","SELECT","BUTTON","PICTURE","FIGURE","IFRAME","HR","TABLE","PROGRESS","METER"]),o=e=>{try{const t=getComputedStyle(e),s=t.borderRadius||"0px",i=parseFloat(s),n=Math.min(parseFloat(t.width)||0,parseFloat(t.height)||0);return i>=n/2&&n>0?"50%":s}catch{return"4px"}},r=e=>{if(1!==e.nodeType)return;if(e.hasAttribute?.("data-skeleton-ignore"))return;if(e.hasAttribute?.("data-skeleton-injected"))return;const a=e.getBoundingClientRect();if(a.width<2||a.height<2)return;const l=a.top-t.top,c=a.left-t.left;if(l+a.height<0||c+a.width<0)return;if(l>t.height||c>t.width)return;const d=e.tagName,h=n.has(d),u=i.has(d);if(!h&&!u||(s.push({top:Math.max(0,l),left:Math.max(0,c),width:Math.min(a.width,t.width-Math.max(0,c)),height:Math.min(a.height,t.height-Math.max(0,l)),radius:o(e)}),!h))for(const t of e.children)r(t)};for(const t of e.children)r(t);return A.removeContainedShapes(s)}static removeContainedShapes(e){return e.filter((t,s)=>!e.some((e,i)=>{if(s===i)return!1;return t.top>=e.top&&t.left>=e.left&&t.top+t.height<=e.top+e.height&&t.left+t.width<=e.left+e.width&&e.width*e.height>t.width*t.height}))}static removeOverlay(e){e.querySelectorAll("[data-skeleton-injected]").forEach(e=>e.remove())}static clearError(e){e.removeAttribute("data-skeleton-error"),e.removeAttribute("aria-live"),e.querySelectorAll(".hygular-sk-error-layer").forEach(e=>e.remove())}static restoreAria(e){null===e.skeletonAriaHidden?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",e.skeletonAriaHidden),null===e.skeletonAriaLabel?e.removeAttribute("aria-label"):e.setAttribute("aria-label",e.skeletonAriaLabel)}static _emit(e,t,s=!1,i={}){const n=new CustomEvent(t,{bubbles:!0,cancelable:s,detail:{el:e,...i}});return e.dispatchEvent(n),n.defaultPrevented}static _createElement(e,t="",s={}){const i=document.createElement(e);t&&(i.className=t);for(const[e,t]of Object.entries(s))i.setAttribute(e,t);return i}static createErrorIcon(){const e="http://www.w3.org/2000/svg",t=document.createElementNS(e,"svg"),s=(e,t)=>{for(const[s,i]of Object.entries(t))e.setAttribute(s,i);return e},i=(t,i)=>s(document.createElementNS(e,t),i);return s(t,{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"}),t.appendChild(i("circle",{cx:"12",cy:"12",r:"10"})),t.appendChild(i("line",{x1:"12",y1:"8",x2:"12",y2:"12"})),t.appendChild(i("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})),t}}class C{static#rs=new WeakSet;static load(e){if(!e?.dataset.src||!e.parentNode||C.#rs.has(e))return;C.#rs.add(e);const t=e.dataset.errorText||"Image failed to load",s=document.createElement("div");s.className="hygular-image-wrap",e.parentNode.insertBefore(s,e),s.appendChild(e);const i=document.createElement("div");i.className="hygular-image-shimmer",s.appendChild(i);const n=document.createElement("div");n.className="hygular-image-error-layer",n.appendChild(C.createErrorSVG());const o=document.createElement("span");o.textContent=t,n.appendChild(o),s.appendChild(n);const r=new Image;r.onload=()=>{C.#rs.delete(e),e.src=r.src,e.removeAttribute("data-src"),e.classList.add("hygular-image-loaded"),i.remove()},r.onerror=()=>{C.#rs.delete(e),r.onerror=null,i.remove(),e.removeAttribute("data-src"),n.classList.add("is-visible")},r.src=e.dataset.src}static observe(e="img[data-src]"){if("undefined"==typeof window||"undefined"==typeof document)return()=>{};let t=!1;const s=new IntersectionObserver(e=>{t||e.forEach(e=>{e.isIntersecting&&(C.load(e.target),s.unobserve(e.target))})},{rootMargin:"100px 0px",threshold:.1});document.querySelectorAll(e).forEach(e=>s.observe(e));const i=new MutationObserver(i=>{t||i.forEach(t=>{t.addedNodes.forEach(t=>{1===t.nodeType&&(t.matches?.(e)&&s.observe(t),t.querySelectorAll?.(e).forEach(e=>s.observe(e)))})})});return i.observe(document.body,{childList:!0,subtree:!0}),()=>{t=!0,s.disconnect(),i.disconnect()}}static createErrorSVG(){const e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("width","24"),e.setAttribute("height","24"),e.setAttribute("viewBox","0 0 24 24"),e.setAttribute("fill","none"),e.setAttribute("stroke","currentColor"),e.setAttribute("stroke-width","1.5"),e.setAttribute("stroke-linecap","round"),e.setAttribute("stroke-linejoin","round");const t=document.createElementNS("http://www.w3.org/2000/svg","rect");t.setAttribute("x","3"),t.setAttribute("y","3"),t.setAttribute("width","18"),t.setAttribute("height","18"),t.setAttribute("rx","2");const s=document.createElementNS("http://www.w3.org/2000/svg","circle");s.setAttribute("cx","8.5"),s.setAttribute("cy","8.5"),s.setAttribute("r","1.5");const i=document.createElementNS("http://www.w3.org/2000/svg","path");return i.setAttribute("d","m21 15-5-5L5 21"),e.appendChild(t),e.appendChild(s),e.appendChild(i),e}}class L{static#n=new WeakMap;#Be=null;#as=null;#C=null;#gt=!1;#ee=!1;#ls=!1;#cs=null;#c=null;#ds=null;#yt=null;#hs=null;#bt=null;#Me={title:"",content:"",target:null,placement:"auto",trigger:"click",hasArrow:!0,closeOnOutsideClick:!0,closeOnEscape:!0,offset:10,autoClean:!1};#U={popover:"popover",active:"is-open",arrow:"has-arrow",header:"popover-header",body:"popover-body",top:"is-top",bottom:"is-bottom",left:"is-left",right:"is-right",start:"is-start",end:"is-end"};constructor(e,t={}){if("undefined"==typeof window||"undefined"==typeof document)return;if(this.#Be="string"==typeof e?document.querySelector(e):e,!(this.#Be instanceof Element))return void n.warn("[Popover] Target element was not found or is not a valid DOM element.");const s=L.#n.get(this.#Be);s&&s.dispose(),this.#cs=new Map(["aria-expanded","aria-controls"].map(e=>[e,this.#Be.getAttribute(e)])),this.#C=this.#kt(t),this.#c=this.#Lt(),L.#n.set(this.#Be,this),this.#At()}#kt(e={}){const t={title:this.#Be.dataset.title,content:this.#Be.dataset.content||this.#Be.dataset.popover,target:this.#Be.dataset.target||this.#Be.dataset.popoverTarget,placement:this.#Be.dataset.placement,trigger:this.#Be.dataset.trigger,hasArrow:this.#us(this.#Be.dataset.arrow),closeOnOutsideClick:this.#us(this.#Be.dataset.closeOutside),closeOnEscape:this.#us(this.#Be.dataset.closeEscape),offset:this.#ps(this.#Be.dataset.offset)};return{...this.#Me,...this.#Ct(t),...this.#Ct(e)}}#Ct(e){return Object.fromEntries(Object.entries(e).filter(([,e])=>null!=e&&""!==e))}#us(e){if(null!=e&&""!==e)return"true"===e||!0===e}#ps(e){if(null==e||""===e)return;const t=Number(e);return Number.isFinite(t)?t:void 0}#At(){const e=this.#ms(this.#C.trigger);this.#yt=e=>{this.#C.closeOnEscape&&"Escape"===e.key&&this.#gt&&this.hide()},this.#hs=e=>{if(!this.#C.closeOnOutsideClick||!this.#gt)return;const t=e.target;this.#Be?.contains(t)||this.#as?.contains(t)||this.hide()},this.#ds=e=>{e.preventDefault(),this.toggle()},"click"===e&&this.#Be.addEventListener("click",this.#ds),document.addEventListener("keydown",this.#yt)}show(){if(this.#ee||this.#gt||!this.#Be)return;if(!this.#gs("hygular.popover.show",!0)||this.#ee)return;const e=this.#fs(),t=String(this.#C.title??"").trim();if(!t&&!e)return;if(this.#as=document.createElement("div"),this.#as.id=this.#c,this.#as.className=this.#U.popover,this.#as.setAttribute("role","dialog"),this.#C.hasArrow&&this.#as.classList.add(this.#U.arrow),t){const e=document.createElement("div");e.className=this.#U.header,e.id=`${this.#c}-title`,e.textContent=t,this.#as.setAttribute("aria-labelledby",e.id),this.#as.appendChild(e)}if(e){const t=document.createElement("div");t.className=this.#U.body,t.appendChild(e),this.#as.appendChild(t)}this.#Be.setAttribute("aria-expanded","true"),this.#Be.setAttribute("aria-controls",this.#c),document.body.appendChild(this.#as);const s=this.#as;o.afterPaint(()=>{!this.#ee&&this.#gt&&this.#as===s&&(this.update(),this.#as.classList.add(this.#U.active),this.#gs("hygular.popover.shown"))}),this.#gt=!0,this.#St(),this.#C.closeOnOutsideClick&&o.afterPaint(()=>{!this.#ee&&this.#gt&&this.#as===s&&document.addEventListener("pointerdown",this.#hs)})}hide(){if(this.#gt&&!this.#ee&&!this.#ls){this.#ls=!0;try{if(!this.#gs("hygular.popover.hide",!0)||this.#ee)return;this.#vs(),this.#gs("hygular.popover.hidden"),this.#C?.autoClean&&!this.#gt&&this.dispose()}finally{this.#ls=!1}}}#vs(){this.#Mt(),this.#Be?.ownerDocument.removeEventListener("pointerdown",this.#hs),this.#as?.remove(),this.#as=null,this.#gt=!1,this.#Be?.setAttribute("aria-expanded","false"),this.#Be?.removeAttribute("aria-controls")}toggle(){this.#gt?this.hide():this.show()}update(){if(!this.#gt||!this.#as||!this.#Be)return;this.#Tt();const e=this.#Ot(),{side:t,align:s}=e;this.#as.classList.add(this.#U[t]),s&&this.#U[s]&&this.#as.classList.add(this.#U[s]),this.#ys(t,s)}#fs(){const e=this.#C.target?document.querySelector(this.#C.target):null;if(e){const t=document.createDocumentFragment();return[...e.childNodes].forEach(e=>{t.appendChild(e.cloneNode(!0))}),t.childNodes.length?t:null}const t=this.#C.content;if(t instanceof Node){const e=document.createDocumentFragment();return e.appendChild(t.cloneNode(!0)),e}const s=String(t??"").trim();if(!s)return null;const i=document.createDocumentFragment();return i.appendChild(document.createTextNode(s)),i}#Ot(){const e=this.#Dt(this.#C.placement),t=("auto"===e.side?this.#bs():[e,...this.#bs()]).filter((e,t,s)=>s.findIndex(t=>t.side===e.side&&t.align===e.align)===t);return t.find(e=>this.#Es(e.side))||t[0]}#bs(){const e=this.#Be.getBoundingClientRect(),t=window.innerWidth,s=window.innerHeight,i={top:e.top,bottom:s-e.bottom,left:e.left,right:t-e.right};return["bottom","top","right","left"].sort((e,t)=>i[t]-i[e]).map(e=>({side:e,align:"center"}))}#Es(e){if(!this.#as||!this.#Be)return!1;const t=this.#Be.getBoundingClientRect(),s=this.#as.getBoundingClientRect(),i=window.innerWidth,n=window.innerHeight,o=this.#C.offset,r={top:t.top,bottom:n-t.bottom,left:t.left,right:i-t.right};return"top"===e||"bottom"===e?r[e]>=s.height+o:r[e]>=s.width+o}#ys(e,t="center"){const s=this.#Be.getBoundingClientRect(),i=this.#as.getBoundingClientRect(),n=window.scrollX||window.pageXOffset,o=window.scrollY||window.pageYOffset,r=this.#C.offset;let a=0,l=0;"top"===e&&(a=s.top+o-i.height-r,l=this.#ws(s,i,t)+n),"bottom"===e&&(a=s.bottom+o+r,l=this.#ws(s,i,t)+n),"left"===e&&(a=this.#ks(s,i,t)+o,l=s.left+n-i.width-r),"right"===e&&(a=this.#ks(s,i,t)+o,l=s.right+n+r);l=Math.max(8+n,Math.min(l,window.innerWidth+n-i.width-8)),a=Math.max(8+o,Math.min(a,window.innerHeight+o-i.height-8)),Object.assign(this.#as.style,{position:"absolute",top:`${a}px`,left:`${l}px`})}#ws(e,t,s){return"start"===s?e.left:"end"===s?e.right-t.width:e.left+e.width/2-t.width/2}#ks(e,t,s){return"start"===s?e.top:"end"===s?e.bottom-t.height:e.top+e.height/2-t.height/2}#ms(e){return["click","manual"].includes(e)?e:"click"}#Dt(e){const t=String(e||"auto").trim(),[s,i]=t.split("-");return{side:["auto","top","bottom","left","right"].includes(s)?s:"auto",align:["start","end"].includes(i)?i:"center"}}#Tt(){this.#as.classList.remove(this.#U.top,this.#U.bottom,this.#U.left,this.#U.right,this.#U.start,this.#U.end)}#St(){this.#bt||(this.#bt=()=>this.update(),window.addEventListener("resize",this.#bt),window.addEventListener("scroll",this.#bt,!0))}#Mt(){this.#bt&&(window.removeEventListener("resize",this.#bt),window.removeEventListener("scroll",this.#bt,!0),this.#bt=null)}#gs(e,t=!1){if(!this.#Be)return!1;const s=new CustomEvent(e,{bubbles:!0,cancelable:t,detail:{instance:this,trigger:this.#Be,popover:this.#as}});return this.#Be.dispatchEvent(s)}#Lt(){return`hygular-popover-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}static getInstance(e){return L.#n.get(e)}static init(e='[data-hygular-toggle="popover"], [data-hygular="popover"]'){return"undefined"==typeof document?[]:[...document.querySelectorAll(e)].map(e=>L.#n.get(e)||new L(e))}dispose(){this.#ee||(this.#ee=!0,this.#vs(),this.#Be?.removeEventListener("click",this.#ds),this.#Be?.ownerDocument.removeEventListener("keydown",this.#yt),this.#cs?.forEach((e,t)=>{null===e?this.#Be?.removeAttribute(t):this.#Be?.setAttribute(t,e)}),L.#n.delete(this.#Be),this.#cs=null,this.#Be=null,this.#C=null,this.#c=null)}}class x{static#As={email:e=>/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/.test(e)||"Please enter a valid email address.",phone:e=>/^\+?[1-9]\d{1,14}$/.test(e.replace(/[\s\-()]/g,""))||"Please enter a valid phone number.",number:e=>/^-?\d+(\.\d+)?$/.test(e)||"This field must be a valid number.",integer:e=>/^-?\d+$/.test(e)||"This field must be an integer.",alphanumeric:e=>/^[a-zA-Z0-9]+$/.test(e)||"Only letters and numbers are allowed.",url:e=>/^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([/\w .-]*)*\/?$/.test(e)||"Please enter a valid URL.","password-strength":e=>/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[\s\S]{8,}$/.test(e)||"Password must be 8+ chars, include uppercase, lowercase, and a number.","no-spaces":e=>!/\s/.test(e)||"Spaces are not allowed.",min:(e,t)=>{const s=Number(t);if(isNaN(s))return`Invalid min param: "${t}".`;return/^-?\d+(\.\d+)?$/.test(e.trim())?Number(e)>=s||`Value must be at least ${s}.`:e.length>=s||`Must be at least ${s} characters.`},max:(e,t)=>{const s=Number(t);if(isNaN(s))return`Invalid max param: "${t}".`;return/^-?\d+(\.\d+)?$/.test(e.trim())?Number(e)<=s||`Value must be no more than ${s}.`:e.length<=s||`Must be no more than ${s} characters.`},minlen:(e,t)=>{const s=Number(t);return isNaN(s)?`Invalid minlen param: "${t}".`:e.length>=s||`Must be at least ${s} characters.`},maxlen:(e,t)=>{const s=Number(t);return isNaN(s)?`Invalid maxlen param: "${t}".`:e.length<=s||`Must be no more than ${s} characters.`},minval:(e,t)=>{const s=Number(t);return isNaN(s)?`Invalid minval param: "${t}".`:Number(e)>=s||`Value must be at least ${s}.`},maxval:(e,t)=>{const s=Number(t);return isNaN(s)?`Invalid maxval param: "${t}".`:Number(e)<=s||`Value must be no more than ${s}.`},exact:(e,t)=>{const s=Number(t);return isNaN(s)?`Invalid exact param: "${t}".`:e.length===s||`Must be exactly ${s} characters.`},match:(e,t)=>{if(!t)return"match rule requires a selector param, e.g. match:#other-id";const s=document.querySelector(t);return s?e===s.value||"Fields do not match.":(console.warn(`Hygular [match]: No element found for selector "${t}"`),`match rule: target "${t}" not found.`)},contains:(e,t)=>!!e.includes(t)||`Must contain "${t}".`,startswith:(e,t)=>!!e.startsWith(t)||`Must start with "${t}".`,endswith:(e,t)=>!!e.endsWith(t)||`Must end with "${t}".`,"file-max":(e,t,s)=>{if("file"!==s.type||!s.files||0===s.files.length)return!0;const i=1024*Number(t)*1024;return!Array.from(s.files).find(e=>e.size>i)||`File size cannot exceed ${t}MB.`},"file-ext":(e,t,s)=>{if("file"!==s.type||!s.files||0===s.files.length)return!0;const i=t.split(",").map(e=>e.trim().toLowerCase());return!Array.from(s.files).find(e=>{const t=e.name.match(/\.([a-z0-9]+)$/i);return!i.includes(t?t[1].toLowerCase():"")})||`Allowed file types: ${i.join(", ")}`}};static addRule(e,t){"string"==typeof e&&e.trim()?"function"==typeof t?(x.#As[e]&&console.warn(`Hygular [addRule]: Rule "${e}" already exists — overwriting.`),x.#As[e]=t):console.warn(`Hygular [addRule]: Rule "${e}" must be a function.`):console.warn("Hygular [addRule]: Rule name must be a non-empty string.")}static init(){if("undefined"==typeof document)return()=>{};const e='[data-hygular="form"]',t={groupFile:".group-file",inputFile:".form-file",uploadDisplay:".upload-display"},s={validated:"is-validated",loading:"is-loading"},i={ajaxTimeout:3e4},n=new Set(["hidden","submit","button","reset","image"]),o=e=>{if(n.has(e.type))return null;if(e.hasAttribute("data-no-feedback"))return null;const t=e.closest(".group-checkbox, .group-radio, .group-switch"),s=t?.closest(".group")||t||e.parentNode;let i=s.querySelector(":scope > .form-feedback.is-invalid");return i||(i=document.createElement("div"),i.className="form-feedback is-invalid",s.appendChild(i)),i},r=e=>{e.querySelectorAll(".form-feedback.is-server").forEach(e=>{e.classList.remove("is-server","with-success","with-error"),e.textContent=""})},a=e=>{if(n.has(e.type))return;if(e.setCustomValidity(""),(e=>{if("checkbox"===e.type)return!e.checked;if("radio"===e.type){const t=(e.form||document).querySelectorAll(`input[type="radio"][name="${CSS.escape(e.name)}"]`);return!Array.from(t).some(e=>e.checked)}return"file"===e.type?0===e.files.length:!e.value})(e)){if(e.required){const t=e.getAttribute("data-required-msg")||"This field is required.";e.setCustomValidity(t);const s=o(e);s&&(s.textContent=t)}return}let t=null;if(t=(e=>{const t=e.getAttribute("data-rule");if(!t)return null;if(!e.value&&"file"!==e.type)return null;for(const s of t.trim().split(/\s+/)){const t=s.indexOf(":"),i=-1===t?s:s.slice(0,t),n=-1===t?void 0:s.slice(t+1),o=x.#As[i];if(!o){console.warn(`Hygular: Unknown rule "${i}"`);continue}const r=o(e.value,n,e);if(!0!==r)return String(r)}return null})(e),!t){const s=e.getAttribute("data-regex");if(s)try{new RegExp(s).test(e.value)||(t=e.getAttribute("data-error-msg")||"Format is invalid.")}catch{console.error(`Hygular: Invalid regex pattern: ${s}`)}}if(t&&e.setCustomValidity(t),!e.validity.valid){const s=o(e);s&&(s.textContent=e.getAttribute("data-error-msg")||t||e.validationMessage)}},l=new WeakSet,c=new WeakSet,d=new Set;let h=!1;const u=async(e,t)=>{if(h||c.has(e))return;c.add(e),t?.classList.add(s.loading),t&&(t.disabled=!0);const n=(e.getAttribute("method")||"POST").toUpperCase();let a={};const u=e.getAttribute("data-ajax-headers");if(u)try{a=JSON.parse(u)}catch{console.warn("Hygular: Invalid JSON in data-ajax-headers — ignoring.",e)}const p=Number(e.getAttribute("data-ajax-timeout"))||i.ajaxTimeout,m=new AbortController,g=setTimeout(()=>m.abort(),p),f={controller:m,timeoutId:g,submitBtn:t};d.add(f),e.dispatchEvent(new CustomEvent("hygular.form.start",{detail:{form:e}}));try{if(h)return;const t=new FormData(e),i=new URL(e.action||window.location.href),c="GET"!==n&&"HEAD"!==n;if(!c)for(const[e,s]of t)i.searchParams.append(e,"string"==typeof s?s:s.name);const d=await fetch(i.href,{method:n,...c?{body:t}:{},headers:{"X-Requested-With":"XMLHttpRequest",Accept:"application/json",...a},signal:m.signal}),u=await d.json().catch(()=>null);if(h)return;d.ok?(r(e),e.reset(),e.classList.remove(s.validated),e.querySelectorAll("input, select, textarea").forEach(e=>{l.delete(e)}),e.dispatchEvent(new CustomEvent("hygular.form.success",{bubbles:!0,detail:{response:d,data:u}}))):(((e,t)=>{const s=t?.errors;s&&"object"==typeof s&&(Object.entries(s).forEach(([t,s])=>{const i=e.querySelector(`[name="${CSS.escape(t)}"]`);if(!i)return;const n=Array.isArray(s)?s[0]:s;if(!n)return;i.setCustomValidity(String(n));const r=o(i);r&&(r.textContent=String(n),r.classList.add("form-feedback","is-server","with-error"))}),e.querySelector(":invalid")?.focus())})(e,u),e.dispatchEvent(new CustomEvent("hygular.form.error",{detail:{response:d,data:u}})))}catch(t){if(h)return;const s="AbortError"===t.name;console.error(s?"Hygular AJAX Form Error: request timed out.":"Hygular AJAX Form Error:",s?"":t),e.dispatchEvent(new CustomEvent("hygular.form.error",{detail:{error:t,timeout:s}}))}finally{clearTimeout(g),d.delete(f),c.delete(e),t?.classList.remove(s.loading),t&&(t.disabled=!1)}},p=t=>{const i=t.target.closest(e);if(i){if(r(i),i.classList.add(s.validated),i.querySelectorAll("input, select, textarea").forEach(e=>{l.add(e),a(e)}),!i.checkValidity())return t.preventDefault(),t.stopPropagation(),void i.querySelector(":invalid")?.focus();"true"===i.getAttribute("data-ajax")&&(t.preventDefault(),u(i,t.submitter))}},m=t=>{const s=t.target;s.matches("input, select, textarea")&&s.closest(e)&&(l.add(s),a(s))},g=t=>{const s=t.target;if(!s.matches("input, select, textarea"))return;const i=s.closest(e);i&&(l.has(s)&&a(s),i.querySelectorAll("input[data-rule], select[data-rule], textarea[data-rule]").forEach(e=>{if(e===s||!l.has(e))return;e.getAttribute("data-rule").trim().split(/\s+/).some(e=>{if(!e.startsWith("match:"))return!1;try{return document.querySelector(e.slice(6))===s}catch{return!1}})&&a(e)}))},f=e=>{g(e);const s=e.target;if(!s.matches(t.inputFile))return;const i=s.closest(t.groupFile);if(!i)return;const n=i.querySelector(t.uploadDisplay);n&&(0===s.files.length?n.textContent=i.getAttribute("data-default-text")||"No file selected":1===s.files.length?n.textContent=`Selected: ${s.files[0].name.replace(/[<>/\\|:*?"']/g,"_")}`:n.textContent=`${s.files.length} items selected`),l.add(s),a(s)};return document.addEventListener("submit",p),document.addEventListener("change",f),document.addEventListener("input",g),document.addEventListener("blur",m,!0),document.querySelectorAll(".group.floating-label select").forEach(e=>{const t=e.nextElementSibling?.classList.contains("select-label")?e.nextElementSibling:null;if(e.labelToggle)return;const s=t||document.createElement("label");s.className="select-label floating-label-hidden",s.textContent=e.options[0]?.textContent||"Select an option",e.insertAdjacentElement("afterend",s),e.labelToggle=()=>{const t=""!==e.value;s.classList.toggle("floating-label-visible",t),s.classList.toggle("floating-label-hidden",!t)},e.addEventListener("change",e.labelToggle),e.labelToggle()}),document.querySelectorAll(`${e} input, ${e} select, ${e} textarea`).forEach(o),()=>{h=!0,d.forEach(({controller:e,timeoutId:t,submitBtn:i})=>{clearTimeout(t),e.abort(),i?.classList.remove(s.loading),i&&(i.disabled=!1)}),d.clear(),document.removeEventListener("submit",p),document.removeEventListener("change",f),document.removeEventListener("input",g),document.removeEventListener("blur",m,!0),document.querySelectorAll(".group.floating-label select").forEach(e=>{e.labelToggle&&(e.removeEventListener("change",e.labelToggle),delete e.labelToggle)})}}}const S=new WeakMap;class T{static NAME="range";static SELECTOR='[data-hygular="range"]';#Be;#Cs;#Ls;#xs=null;#Ss;#Ts=[];#Os;#Ds;#Is;#Ms;#Ke;constructor(e,t={}){if("undefined"!=typeof window&&"undefined"!=typeof document){if(S.has(e))return S.get(e);this.#Be=e,this.options={tooltip:!0,ticks:!0,valueLabel:null,...t},this.#Cs=Array.from(e.querySelectorAll('input[type="range"]')),this.#Ls=2===this.#Cs.length,0!==this.#Cs.length?this.#Cs.length>2?n.error(`Range: expected 1 or 2 input[type='range'] elements, found ${this.#Cs.length}`,this.#Be):(this.#xs=null,this.#Ss="rtl"===getComputedStyle(e).direction,this.#Ts=[],this._onResize=this._onResize.bind(this),this.buildTooltips(),this.buildDualFill(),this.buildTicks(),this.bindEvents(),"undefined"!=typeof ResizeObserver&&(this.#Ke=new ResizeObserver(this._onResize),this.#Ke.observe(this.#Be)),this.update(),S.set(e,this)):n.error("Range: no input[type='range'] found inside element",this.#Be)}}static getInstance(e){return S.get(e)??null}static getOrCreateInstance(e,t){return S.get(e)??new T(e,t)}static init(e){"undefined"!=typeof window&&"undefined"!=typeof document&&(e??=document,e.querySelectorAll(T.SELECTOR).forEach(e=>T.getOrCreateInstance(e)))}buildTooltips(){this.options.tooltip&&(this.#Os=this.#Cs.map(()=>{const e=document.createElement("span");return e.className="form-range-tooltip",e.setAttribute("aria-hidden","true"),this.#Be.appendChild(e),e}))}buildDualFill(){this.#Ls&&(this.#Ds=document.createElement("span"),this.#Ds.className="form-range-dual-track",this.#Is=document.createElement("span"),this.#Is.className="form-range-dual-fill",this.#Be.prepend(this.#Is),this.#Be.prepend(this.#Ds))}buildTicks(){if(!this.options.ticks)return;if(this.#Ls)return;this.#Ms&&(this.#Ms.remove(),this.#Ms=null);const e=this.#Cs[0],t=e.getAttribute("list");if(!t)return;const s=document.getElementById(t);if(!s)return;const i=Array.from(s.querySelectorAll("option"));if(0===i.length)return;const n=parseFloat(e.min||0),o=parseFloat(e.max||100);this.#Ms=document.createElement("div"),this.#Ms.className="form-range-ticks",this.#Ms.setAttribute("aria-hidden","true"),i.forEach(e=>{const t=parseFloat(e.value),s=o===n?0:(t-n)/(o-n)*100,i=this.#Ss?100-s:s,r=document.createElement("span");if(r.className="form-range-tick",r.style.left=`${i}%`,this.#Ms.appendChild(r),e.label){const t=document.createElement("span");t.className="form-range-tick-label",t.style.left=`${i}%`,t.textContent=e.label,this.#Ms.appendChild(t)}}),this.#Be.after(this.#Ms)}bindEvents(){this.#Cs.forEach((e,t)=>{const s=(t,s,i)=>{e.addEventListener(t,s,i),this.#Ts.push({input:e,type:t,handler:s,opts:i})};s("input",()=>this._onInput(t)),s("change",()=>this._onChange(t)),s("pointerdown",()=>this.showTooltip(t),{passive:!0}),s("pointerup",()=>this.hideTooltip(t),{passive:!0}),s("focus",()=>this.showTooltip(t)),s("blur",()=>this.hideTooltip(t)),s("keydown",()=>this.showTooltip(t),{passive:!0})})}_onInput(e){this.#Ns(e),this.#xs&&cancelAnimationFrame(this.#xs),this.#xs=requestAnimationFrame(()=>this.update(e)),this.#Be.dispatchEvent(new CustomEvent("hygular.range.input",{bubbles:!0,detail:{value:this.getValue(),index:e}}))}#Ns(e){if(!this.#Ls||void 0===e)return;const[t,s]=this.#Cs,i="any"===t.step?0:parseFloat(t.step||1);parseFloat(t.value)<=parseFloat(s.value)-i||(0===e?t.value=String(parseFloat(s.value)-i):s.value=String(parseFloat(t.value)+i))}_onChange(e){this.#Be.dispatchEvent(new CustomEvent("hygular.range.change",{bubbles:!0,detail:{value:this.getValue(),index:e}}))}showTooltip(e){this.#Os?.[e]?.classList.add("is-visible")}hideTooltip(e){this.#Os?.[e]?.classList.remove("is-visible")}_onResize(){this.positionTooltips()}percentage(e){const t=parseFloat(e.min||0),s=parseFloat(e.max||100);if(s===t)return 0;const i=(parseFloat(e.value)-t)/(s-t)*100;return this.#Ss?100-i:i}update(e){if(this.#Ls){const[t,s]=this.#Cs;this.#Ns(e);const i=this.percentage(t),n=this.percentage(s),[o,r]=i<=n?[i,n]:[n,i];this.#Is.style.setProperty("--range-min",`${o}%`),this.#Is.style.setProperty("--range-max",`${r}%`),t.style.zIndex=document.activeElement===t?"2":"1",s.style.zIndex=document.activeElement===s?"2":"1",t.setAttribute("aria-valuetext",this.formatValue(t.value)),s.setAttribute("aria-valuetext",this.formatValue(s.value))}else{const e=this.#Cs[0];e.style.setProperty("--range-progress",`${this.percentage(e)}%`),e.setAttribute("aria-valuetext",this.formatValue(e.value))}this.options.tooltip&&this.positionTooltips()}positionTooltips(){this.#Cs.forEach((e,t)=>{const s=this.#Os?.[t];if(!s)return;s.textContent=this.formatValue(e.value);const i=this.percentage(e),n=parseFloat(getComputedStyle(e).getPropertyValue("--range-thumb"))||20,o=i/100*(e.offsetWidth-n)+n/2;s.style.setProperty("--range-tooltip-x",`${o}px`)})}formatValue(e){return"function"==typeof this.options.valueLabel?this.options.valueLabel(e):"string"==typeof this.options.valueLabel?this.options.valueLabel.replace("{value}",e):String(e)}getValue(){return this.#Ls?this.#Cs.map(e=>parseFloat(e.value)):parseFloat(this.#Cs[0].value)}setValue(e){this.#Ls&&Array.isArray(e)?(this.#Cs[0].value=String(e[0]),this.#Cs[1].value=String(e[1])):this.#Cs[0].value=String(e),this.update(),this.#Cs.forEach(e=>e.dispatchEvent(new Event("input",{bubbles:!0})))}refresh(){this.buildTicks(),this.update()}dispose(){this.#xs&&cancelAnimationFrame(this.#xs),this.#Ke?.disconnect(),this.#Ts.forEach(({input:e,type:t,handler:s,opts:i})=>e.removeEventListener(t,s,i)),this.#Ts=[],this.#Os?.forEach(e=>e.remove()),this.#Ds?.remove(),this.#Is?.remove(),this.#Ms?.remove(),S.delete(this.#Be)}}const O='[data-hygular], [data-hygular-toggle="popover"]';function D(e){return e.getAttribute("data-hygular")||("popover"===e.getAttribute("data-hygular-toggle")?"popover":null)}return class{#ee=!1;#$s=new Map;constructor(e={}){"undefined"!=typeof window&&"undefined"!=typeof document&&(e.debug&&n.enable(),this.registry={delegate:{navbar:h.navbar,collapse:h.collapse,dropdown:h.dropdown,drawer:h.drawer,accordion:h.accordion,alert:h.alert,form:x.init},lazy:{swiper:h.swiper,badge:h.badge,tabview:h.tabview,tooltip:e=>new E(e),popover:e=>new L(e),range:e=>new T(e)}},this.config=e,p(e),this.modal=v,this.toast=w,this.carousel=f,this.alert={create:y.create},this.darkMode=k,this.select=b,this.skeleton=A,this.tooltip=E,this.popover=L,this.form=x,this.range=T,this.componentInstances=new Set,this.loadedComponents=new WeakSet,this.observer=this.setupObserver(),this.mutationObserver=this.setupMutationObserver(),this.startObserving(document.body),this.init())}init(){if(!this.#ee&&"undefined"!=typeof document){this.disposeMap?.forEach(e=>e()),this.disposeMap=new Map;for(const e in this.registry.delegate){const t=this.registry.delegate[e]?.();"function"==typeof t&&this.disposeMap.set(`delegate:${e}`,t)}document.querySelectorAll(O).forEach(e=>{const t=D(e);this.registry.lazy[t]&&this.observeElement(e)}),document.querySelectorAll("img[data-src]").forEach(e=>this.observeElement(e))}}setupObserver(){return new IntersectionObserver(e=>{this.#ee||e.forEach(e=>{if(e.isIntersecting&&!this.loadedComponents.has(e.target)){const t=e.target;if("IMG"===t.tagName&&t.dataset.src)return C.load(t),this.loadedComponents.add(t),void this.observer.unobserve(t);if(t.FnCallback&&"function"==typeof t.FnCallback)return t.FnCallback(t),this.loadedComponents.add(t),void this.observer.unobserve(t);this.handleVisibleComponent(e.target),this.observer.unobserve(e.target)}})},{rootMargin:"100px 0px",threshold:.1})}setupMutationObserver(){return new MutationObserver(e=>{this.#ee||(e.some(e=>e.removedNodes.length)&&this.#$s.forEach((e,t)=>{t.isConnected||(e.dispose(),this.componentInstances.delete(e),this.loadedComponents.delete(t),this.#$s.delete(t))}),e.forEach(e=>{e.addedNodes.forEach(e=>{if(1===e.nodeType&&!this.loadedComponents.has(e)){if(e.matches(O)){const t=D(e);this.registry.lazy[t]&&this.observeElement(e)}"IMG"===e.tagName&&e.dataset.src&&this.observeElement(e),e.querySelectorAll?.(O).forEach(e=>{if(!this.loadedComponents.has(e)){const t=D(e);this.registry.lazy[t]&&this.observeElement(e)}}),e.querySelectorAll?.("img[data-src]").forEach(e=>{this.loadedComponents.has(e)||this.observeElement(e)})}})}))})}handleVisibleComponent(e){const t=D(e);this.initializeComponent(t,e)}initializeComponent(e,t){if(this.#ee)return null;if(this.loadedComponents.has(t))return this.#$s.get(t)??null;const s=this.registry.lazy[e];if("function"==typeof s){const e=s(t);return e&&"function"==typeof e.dispose&&(this.componentInstances.add(e),this.#$s.set(t,e)),this.loadedComponents.add(t),e}return console.error(`Hygular: lazy component not found: ${e}`),null}observeElement(e){this.#ee||this.loadedComponents.has(e)||this.observer.observe(e)}startObserving(e){e&&this.mutationObserver.observe(e,{childList:!0,subtree:!0})}dispose(){this.#ee||(this.#ee=!0,this.observer?.disconnect(),this.mutationObserver?.disconnect(),this.disposeMap?.forEach(e=>e()),this.disposeMap?.clear(),this.componentInstances?.forEach(e=>{e.dispose?.()}),this.componentInstances?.clear(),this.#$s.clear(),this.loadedComponents=null)}}});
|
|
7
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Hygular=t()}(this,function(){"use strict";const e={enabled:!1},t={log:{label:"LOG",color:"#3b82f6"},warn:{label:"WARN",color:"#f59e0b"},error:{label:"ERROR",color:"#ef4444"}},s=e=>{return[`%c Hygular %c ${t[e].label} `,"background:#0f172a;color:#f8fafc;font-weight:600;padding:2px 8px;border-radius:4px 0 0 4px;",(s=t[e].color,`background:${s};color:#0f172a;font-weight:700;padding:2px 8px;border-radius:0 4px 4px 0;`)];var s};function i(t,i,n,o){n&&!e.enabled||console[t](...s(i),...o)}const n={enable(){e.enabled=!0},disable(){e.enabled=!1},set(t){e.enabled=Boolean(t)},get isEnabled(){return e.enabled},log(...e){i("log","log",!0,e)},warn(...e){i("warn","warn",!0,e)},error(...e){i("error","error",!1,e)},group(t){e.enabled&&console.group(...s("log"),t)},groupEnd(){e.enabled&&console.groupEnd()}};class o{static#e=new WeakMap;static cancelSlide(e){o.#e.get(e)?.()}static slideUp(e,t=350,s=!1){return new Promise(i=>{if(!e)return i();o.cancelSlide(e);const n=e.getBoundingClientRect().height;if(0===n)return e.style.display="none",s&&e.remove(),i();const r=["height","overflow","margin-top","margin-bottom"].map(t=>[t,e.style.getPropertyValue(t),e.style.getPropertyPriority(t)]);e.style.overflow="hidden",e.style.height=n+"px",e.style.marginTop=getComputedStyle(e).marginTop,e.style.marginBottom=getComputedStyle(e).marginBottom;const a=e.animate([{height:n+"px",marginTop:getComputedStyle(e).marginTop,marginBottom:getComputedStyle(e).marginBottom},{height:"0px",marginTop:"0px",marginBottom:"0px"}],{duration:t,easing:"ease-out",fill:"forwards"});let l=!1;const c=t=>{l||(l=!0,a.onfinish=a.oncancel=null,o.#e.get(e)===d&&o.#e.delete(e),a.cancel(),r.forEach(([t,s,i])=>{s?e.style.setProperty(t,s,i):e.style.removeProperty(t)}),t&&(e.style.display="none",s&&e.remove()),i())},d=()=>c(!1);o.#e.set(e,d),a.onfinish=()=>c(!0),a.oncancel=d})}static slideDown(e,t=350,s="block"){return new Promise(i=>{if(!e)return i();o.cancelSlide(e),e.style.display=s,e.offsetHeight;const n=e.scrollHeight,r=getComputedStyle(e),a=e.animate([{height:"0px",overflow:"hidden",marginTop:"0px",marginBottom:"0px"},{height:n+"px",overflow:"hidden",marginTop:r.marginTop,marginBottom:r.marginBottom}],{duration:t,easing:"ease-out",fill:"forwards"});let l=!1;const c=()=>{l||(l=!0,a.onfinish=a.oncancel=null,o.#e.get(e)===c&&o.#e.delete(e),a.cancel(),i())};o.#e.set(e,c),a.onfinish=a.oncancel=c})}static closeOnEscape(e,t,s=350){const i=e?.ownerDocument;if(!i?.defaultView)return()=>{};e._escapeHandler&&i.removeEventListener("keydown",e._escapeHandler);let n=!1,r=!1;const a=l=>{"Escape"!==l.key||l.defaultPrevented||r||"none"!==i.defaultView.getComputedStyle(e).display&&(r=!0,i.removeEventListener("keydown",a),o.slideUp(e,s).then(()=>{!n&&t&&t.classList.remove("is-active"),e._escapeHandler===a&&(e._escapeHandler=null)}))};return e._escapeHandler=a,i.addEventListener("keydown",a),()=>{n=!0,i.removeEventListener("keydown",a),e._escapeHandler===a&&(e._escapeHandler=null),r&&o.cancelSlide(e)}}static afterPaint(e){requestAnimationFrame(()=>{requestAnimationFrame(e)})}}const r=new WeakMap;function a(e,t,s,i){let n=e.styles.get(t);n||(n=new Map,e.styles.set(t,n)),n.has(s)||n.set(s,{value:t.style.getPropertyValue(s),priority:t.style.getPropertyPriority(s)}),t.style.setProperty(s,i,"important")}function l(e){for(const[t,s]of e.styles)for(const[e,i]of s)i.value?t.style.setProperty(e,i.value,i.priority):t.style.removeProperty(e);e.styles.clear()}function c(e){const t=e?.defaultView;return t&&e.documentElement?Math.max(0,t.innerWidth-e.documentElement.clientWidth):0}class d{#t;#s=null;constructor(e){this.#t=e}get isLocked(){return null!==this.#s}getScrollbarWidth(){const e=this.#s||this.#i();return r.get(e)?.width??c(e)}lock(){if(this.#s)return this;const e=this.#i();if(!e?.body||!e.defaultView)return this;let t=r.get(e);if(!t){t={owners:new Set,styles:new Map,width:c(e)};try{!function(e,t){const s=e.defaultView,i=e.documentElement,n=e.body,o=s.getComputedStyle(i),r=e=>{const t=s.getComputedStyle(e);return{element:e,rect:e.getBoundingClientRect(),left:parseFloat(t.paddingLeft)||0,right:parseFloat(t.paddingRight)||0}},l=r(n),c=[...e.querySelectorAll("[data-fixed-lock], [data-sticky-lock]")].filter(e=>e!==n&&e!==i).map(r);a(t,i,"--hygular-scrollbar-width",`${t.width}px`),a(t,i,"overflow-anchor","none"),a(t,n,"overflow-anchor","none"),t.width>0&&s.CSS?.supports("scrollbar-gutter","stable")&&!o.scrollbarGutter.includes("stable")&&a(t,i,"scrollbar-gutter","stable");for(const e of[i,n])a(t,e,"overflow-x","hidden"),a(t,e,"overflow-y","hidden");for(const e of[l,...c]){const s=e.element.getBoundingClientRect(),i=Math.max(0,e.rect.left-s.left),n=Math.max(0,s.right-e.rect.right);i>0&&a(t,e.element,"padding-left",`${e.left+i}px`),n>0&&a(t,e.element,"padding-right",`${e.right+n}px`)}}(e,t)}catch(e){throw l(t),e}r.set(e,t)}return t.owners.add(this),this.#s=e,this}unlock(){const e=this.#s;if(!e)return this;this.#s=null;const t=r.get(e);return t?(t.owners.delete(this),0===t.owners.size&&(l(t),r.delete(e)),this):this}#i(){return this.#t??("undefined"==typeof document?null:document)}}class h{static#n=new WeakMap;static subscribe(e,t){if("undefined"==typeof document)return()=>{};const s=document;let i=h.#n.get(s);i||(i={bindings:new Map,observer:null},h.#n.set(s,i));const{bindings:n}=i;let o=n.get(e);if(!o){const i=t(s);o={subscribers:0,dispose:"function"==typeof i?i:i.dispose,refresh:i.refresh,refreshing:!1},n.set(e,o)}o.subscribers++,o.refresh&&!i.observer&&(i.observer=new s.defaultView.MutationObserver(e=>{if(e.some(e=>[...e.addedNodes].some(e=>1===e.nodeType)))for(const e of[...n.values()])e.subscribers&&h.#o(e)}),i.observer.observe(s.documentElement,{childList:!0,subtree:!0}));let r=!1;const a=()=>{r||(r=!0,0===--o.subscribers&&(n.delete(e),n.size||(i.observer?.disconnect(),h.#n.delete(s)),o.dispose()))};try{h.#o(o)}catch(e){throw a(),e}return a}static#o(e){if(e.refresh&&!e.refreshing){e.refreshing=!0;try{e.refresh()}finally{e.refreshing=!1}}}}class u{static#r=0;static alert(){return h.subscribe("alert",u.#a)}static#a(e){const t='[data-hygular="alert"]',s={closeBtn:".alert-close"},i={persistent:"data-persistent",dismissKey:"data-dismiss-key",animation:"data-close-animation"},n=t=>{try{return e.defaultView.localStorage.getItem(t)}catch(e){return null}},r=(t,s)=>{try{e.defaultView.localStorage.setItem(t,s)}catch(e){}};let a=!1;const l=new Map,c=n=>{const c=n.target.closest(s.closeBtn),d=c?.closest(t);if(a||!d||l.has(d))return;n.preventDefault();const h={timer:null,onEnd:null,restore:null};l.set(d,h);const u=new CustomEvent("hygular.alert.close",{detail:{alert:d},cancelable:!0});if(d.dispatchEvent(u),a||u.defaultPrevented||!e.contains(d))return void l.delete(d);const p=()=>{if(!a&&l.get(d)===h){if(clearTimeout(h.timer),d.removeEventListener("transitionend",h.onEnd),d.remove(),l.delete(d),"true"===d.getAttribute(i.persistent)){const e=d.getAttribute(i.dismissKey);e&&r(`dismissed-${e}`,"true")}e.dispatchEvent(new CustomEvent("hygular.alert.closed",{detail:{alert:d}}))}},m=["display","transition","opacity"].map(e=>[e,d.style.getPropertyValue(e),d.style.getPropertyPriority(e)]);h.restore=()=>m.forEach(([e,t,s])=>{t?d.style.setProperty(e,t,s):d.style.removeProperty(e)}),"slide"===d.getAttribute(i.animation)?o.slideUp(d,300).then(p):(h.onEnd=e=>{e.target===d&&"opacity"===e.propertyName&&p()},d.style.transition="opacity 0.25s ease",d.style.opacity="0",d.addEventListener("transitionend",h.onEnd),h.timer=setTimeout(p,350))};return e.addEventListener("click",c),{refresh:()=>{e.querySelectorAll(`${t}[${i.persistent}="true"]`).forEach(e=>{if(l.has(e))return;const t=e.getAttribute(i.dismissKey);t&&n(`dismissed-${t}`)&&e.remove()})},dispose(){a=!0,e.removeEventListener("click",c),l.forEach((e,t)=>{clearTimeout(e.timer),t.removeEventListener("transitionend",e.onEnd),o.cancelSlide(t),e.restore?.()}),l.clear()}}}static accordion(){return h.subscribe("accordion",u.#l)}static#l(e){const t='[data-hygular="accordion"]',s={open:"is-open",disabled:"is-disabled"},i={toggler:".accordion-toggler",content:".accordion-content"},n={expanded:"aria-expanded"};let r=!1;const a=new WeakSet,l=new WeakSet,c=new Set,d=new Set,h=async n=>{const a=n.target.closest(i.toggler);if(r||!a||a.disabled||"true"===a.getAttribute("aria-disabled")||a.classList.contains(s.disabled))return;const l=a.closest(t);if(!l)return;if(c.has(l))return;c.add(l),n.preventDefault();const h="true"===l.getAttribute("data-allow-multiple"),u=a.classList.contains(s.open);try{if(u)await m(a);else{const t=await async function(t){const n=t.parentElement,a=n.querySelector(i.content);if(r||!a)return!1;const l=new CustomEvent("hygular.accordion.open",{detail:{trigger:t,content:a,item:n},bubbles:!0,cancelable:!0});return n.dispatchEvent(l),!(r||l.defaultPrevented||!e.contains(n))&&(t.classList.add(s.open),p(t,a,!0),d.add(a),await o.slideDown(a,200),d.delete(a),!(r||!e.contains(n))&&(n.dispatchEvent(new CustomEvent("hygular.accordion.opened",{detail:{trigger:t,content:a,item:n},bubbles:!0})),!0))}(a);if(!r&&t&&!h){const e=[...l.querySelectorAll(i.toggler)].filter(e=>e!==a&&e.classList.contains(s.open));await Promise.all(e.map(e=>m(e)))}}}finally{c.delete(l)}},p=(t,s,i)=>{if(t.setAttribute(n.expanded,String(i)),!s.id){let t;do{t="hygular-accordion-"+ ++u.#r}while(e.getElementById(t));s.id=t}t.setAttribute("aria-controls",s.id)};return e.addEventListener("click",h),{refresh:()=>e.querySelectorAll(t).forEach(e=>{if(e.querySelectorAll(i.toggler).forEach(e=>{const t=e.parentElement.querySelector(i.content);t&&!l.has(e)&&(l.add(e),p(e,t,e.classList.contains(s.open)))}),a.has(e))return;const t=e.querySelector(i.toggler);if(!t)return;if(a.add(e),"true"!==e.getAttribute("data-open-first"))return;t.classList.add(s.open);const n=t.parentElement.querySelector(i.content);n&&(n.style.display="block",p(t,n,!0))}),dispose(){r=!0,e.removeEventListener("click",h),d.forEach(e=>{o.cancelSlide(e);const t=e.parentElement?.querySelector(i.toggler);e.style.display=t?.classList.contains(s.open)?"block":"none"}),d.clear(),c.clear()}};async function m(t){const n=t.parentElement,a=n.querySelector(i.content);if(r||!a)return!1;const l=new CustomEvent("hygular.accordion.close",{detail:{trigger:t,content:a,item:n},bubbles:!0,cancelable:!0});return n.dispatchEvent(l),!(r||l.defaultPrevented||!e.contains(n))&&(t.classList.remove(s.open),p(t,a,!1),d.add(a),await o.slideUp(a,200),d.delete(a),!(r||!e.contains(n))&&(n.dispatchEvent(new CustomEvent("hygular.accordion.closed",{detail:{trigger:t,content:a,item:n},bubbles:!0})),!0))}}static badge(e){const t=e.getAttribute("data-count");if(!t)return;const s=Number(t);Number.isNaN(s)||(e.textContent=s<100?s:"99+",e.setAttribute("aria-label",`${s}`))}static collapse(){return h.subscribe("collapse",u.#c)}static#c(e){const t='[data-hygular-toggle="collapse"]',s={target:"data-target"},i={open:"is-open"},n={duration:300},r=new Set,a=new WeakSet,l=new WeakMap;let c=!1;const d=(e,t,s)=>{e.classList.toggle(i.open,s),e.setAttribute("aria-expanded",s?"true":"false"),t.id&&e.setAttribute("aria-controls",t.id),t.classList.toggle(i.open,s),t.setAttribute("data-state",s?"open":"closed")},h=a=>{const l=a.target.closest(t);l&&(a.preventDefault(),(async t=>{if(c||t.disabled||"true"===t.getAttribute("aria-disabled"))return;const a=t.getAttribute(s.target);if(!a)return;const l=e.querySelector(a);if(!l)return;if(r.has(l))return;r.add(l);const h=l.classList.contains(i.open),u=new CustomEvent("hygular.collapse."+(h?"close":"open"),{detail:{trigger:t,target:l},bubbles:!0,cancelable:!0});l.dispatchEvent(u),c||u.defaultPrevented||!e.contains(l)?r.delete(l):(d(t,l,!h),h?await o.slideUp(l,n.duration):await o.slideDown(l,n.duration),!c&&e.contains(l)?(l.dispatchEvent(new CustomEvent("hygular.collapse."+(h?"closed":"opened"),{detail:{trigger:t,target:l},bubbles:!0})),r.delete(l)):r.delete(l))})(l))};return e.addEventListener("click",h),{refresh:()=>{e.querySelectorAll(t).forEach(t=>{const n=t.getAttribute(s.target);if(!n)return;const o=e.querySelector(n);if(!o)return;if(l.get(t)===o)return;if(l.set(t,o),a.has(o))return void d(t,o,o.classList.contains(i.open));a.add(o);const r=t.classList.contains(i.open)||o.classList.contains(i.open)||"true"===o.getAttribute("data-initial-open");d(t,o,r),o.style.display=r?"block":"none"})},dispose(){c=!0,e.removeEventListener("click",h),r.forEach(e=>{o.cancelSlide(e),e.style.display=e.classList.contains(i.open)?"block":"none"}),r.clear()}}}static drawer(){return h.subscribe("drawer",u.#d)}static#d(e){const t=".drawer",s={dismissBtn:".drawer-close",panel:".drawer-panel",focusable:'a[href], button, input, select, textarea, [tabindex]:not([tabindex="-1"])'},i={open:"is-open"},n={target:"data-target"},r={transitionDuration:420};let a=null,l=null,c=null,h=null,u=!1,p=!1,m=0;const f=new Set,g=new Map,v=new Set,y=(e,t)=>{const s=setTimeout(()=>{f.delete(s),u||e()},t);return f.add(s),s},b=e=>{clearTimeout(e),f.delete(e)},E=new d(e),w=e=>{e._focusHandler&&(e.removeEventListener("keydown",e._focusHandler),e._focusHandler=null)},k=t=>{if(!v.has(t))return;m++,b(c),b(h),c=h=null;const s=g.get(t);s&&t.removeEventListener("transitionend",s),g.delete(t),v.delete(t),t.classList.remove(i.open),t.removeAttribute("aria-modal"),t.removeAttribute("role"),w(t),a=null,A.disconnect(),E.unlock();const n=l;l=null,t.dispatchEvent(new CustomEvent("hygular.drawer.closed",{detail:{drawer:t},bubbles:!0})),!u&&!a&&n&&e.contains(n)&&L(n,!0)},A=new e.defaultView.MutationObserver(()=>{a&&!e.contains(a)&&k(a)}),L=(t,n=!1)=>{if(u||p||!e.contains(t)||a===t||t.classList.contains(i.open))return;if(!n&&l===t)return;if(!n){const s=new CustomEvent("hygular.drawer.open",{detail:{drawer:t},bubbles:!0,cancelable:!0});p=!0;try{t.dispatchEvent(s)}finally{p=!1}if(s.defaultPrevented||u||!e.contains(t))return}if(a)return l=t,void(g.has(a)||C(a)||(l=null));const d=++m;a=t,v.add(t),t.setAttribute("aria-modal","true"),t.setAttribute("role","dialog"),t.setAttribute("tabindex","-1"),A.observe(e.documentElement,{childList:!0,subtree:!0}),t.classList.contains("has-no-backdrop")||E.lock(),o.afterPaint(()=>{u||m!==d||a!==t||g.has(t)||t.classList.add(i.open)}),c=y(()=>{c=null,m!==d||a!==t||g.has(t)||((t=>{const i=Array.from(t.querySelectorAll(s.focusable)).filter(e=>null!==e.offsetParent);if(!i.length)return void t.focus();const n=i[0],o=i[i.length-1],r=t=>{"Tab"===t.key&&(t.shiftKey&&e.activeElement===n?(t.preventDefault(),o.focus()):t.shiftKey||e.activeElement!==o||(t.preventDefault(),n.focus()))};t._focusHandler=r,t.addEventListener("keydown",r),n.focus()})(t),u||m!==d||a!==t||t.dispatchEvent(new CustomEvent("hygular.drawer.opened",{detail:{drawer:t},bubbles:!0})))},r.transitionDuration+50)},C=e=>{if(u||p||a!==e||g.has(e))return!1;const t=new CustomEvent("hygular.drawer.close",{detail:{drawer:e},bubbles:!0,cancelable:!0});p=!0;try{e.dispatchEvent(t)}finally{p=!1}if(t.defaultPrevented||u)return!1;m++,b(c),c=null,e.classList.remove(i.open),e.removeAttribute("aria-modal"),e.removeAttribute("role"),w(e);const n=e.querySelector(s.panel),o=t=>{if(n){if(t.target!==n||"transform"!==t.propertyName)return}else if(t.target!==e||"visibility"!==t.propertyName)return;k(e)};return g.set(e,o),e.addEventListener("transitionend",o),h=y(()=>k(e),r.transitionDuration+50),!0},x=o=>{const r=o.target.closest('[data-hygular-toggle="drawer"]'),l=o.target.closest(s.dismissBtn);if(r){o.preventDefault();const s=r.getAttribute(n.target),i=s?e.querySelector(s):r.closest(t);if(!i)return;return void L(i)}if(l){o.preventDefault();const e=l.closest(t);return void(e&&C(e))}if(a){const e=o.target.closest("a");e&&a.contains(e)&&(e=>{if(!e)return!1;if(e.hasAttribute("data-hygular-toggle")||e.closest("[data-hygular-toggle]"))return!1;const t=e.getAttribute("href");if(null===t)return!1;const s=t.trim();return""!==s&&"#"!==s&&!s.toLowerCase().startsWith("javascript:")})(e)&&C(a)}if(a&&a.classList.contains(i.open)){const e=a.querySelector(s.panel);!e||e.contains(o.target)||o.target.closest('[data-hygular-toggle="drawer"]')||C(a)}},S=e=>{"Escape"!==e.key&&"Esc"!==e.key||!a||C(a)};return e.addEventListener("click",x),e.addEventListener("keydown",S),()=>{e.removeEventListener("click",x),e.removeEventListener("keydown",S),u=!0,l=null,A.disconnect(),f.forEach(clearTimeout),f.clear(),g.forEach((e,t)=>t.removeEventListener("transitionend",e)),g.clear(),v.forEach(e=>{e.classList.remove(i.open),e.removeAttribute("aria-modal"),e.removeAttribute("role"),w(e)}),v.clear(),a=null,E.unlock()}}static navbar(){return h.subscribe("navbar",u.#h)}static#h(e){const t='[data-hygular-toggle="navbar"]',s={menu:".navbar-menu"},i={toggle:"is-active"},n=new WeakMap,r=new Set;let a=!1;const l=async l=>{const c=l.target.closest(t);if(!c)return;l.preventDefault();const d=c.getAttribute("data-target");if(!d)return;const h=e.querySelector(d);if(!h)return;if(a||n.get(h))return;r.add(h),h._disposeEsc?.(),h._disposeEsc=null;const u={};n.set(h,u);const p=c.classList.contains(i.toggle);if(e.querySelectorAll(s.menu).forEach(e=>{if(e!==h){r.add(e),e._disposeEsc?.(),e._disposeEsc=null;const t={};n.set(e,t),o.slideUp(e).finally(()=>{n.get(e)===t&&n.delete(e)})}}),e.querySelectorAll(t).forEach(e=>{e!==c&&e.classList.remove(i.toggle)}),p)c.classList.remove(i.toggle),await o.slideUp(h,300);else{if(c.classList.add(i.toggle),await o.slideDown(h,300,"flex"),a||n.get(h)!==u)return;const e=o.closeOnEscape(h,c,300);h._disposeEsc=e}n.get(h)===u&&n.delete(h)};return e.addEventListener("click",l),()=>{a=!0,e.removeEventListener("click",l),r.forEach(e=>{e._disposeEsc?.(),e._disposeEsc=null,o.cancelSlide(e)}),r.clear()}}static dropdown(){return h.subscribe("dropdown",u.#u)}static#u(e){const t=".dropdown",s='[data-hygular-toggle="dropdown"]',i={menu:".dropdown-menu"},n={active:"is-active"},o={triggerMode:"data-trigger"};let r=!1;const a=new Map,l=(e,t)=>{if(r)return;t?e.classList.add(n.active):e.classList.remove(n.active);const i=e.querySelector(s);i&&i.setAttribute("aria-expanded",t?"true":"false")},c=(s=null)=>{e.querySelectorAll(`${t}.${n.active}`).forEach(e=>{e!==s&&l(e,!1)})},d=e=>{const o=e.target.closest(s),r=e.target.closest(i.menu);if(r){if(e.target.closest("a")){const e=r.closest(t);e&&l(e,!1)}return}if(!o)return void c();const a=o.closest(t);if(!a)return;c(a);const d=a.classList.contains(n.active);l(a,!d)},h=e=>{"Escape"!==e.key&&"Esc"!==e.key||c()};if(e.addEventListener("click",d),e.addEventListener("keydown",h),e.defaultView.matchMedia("(hover: hover) and (pointer: fine)").matches){const s=e=>{const s=e.target.closest(`${t}[${o.triggerMode}="hover"]`);s&&(a.has(s)&&(clearTimeout(a.get(s)),a.delete(s)),c(s),l(s,!0))},i=e=>{const s=e.target.closest(`${t}[${o.triggerMode}="hover"]`);if(!s)return;a.has(s)&&clearTimeout(a.get(s));const i=setTimeout(()=>{s.matches(":hover")||s.querySelector(":hover")||l(s,!1),a.delete(s)},150);a.set(s,i)};return e.addEventListener("mouseover",s),e.addEventListener("mouseout",i),()=>{r=!0,a.forEach(clearTimeout),a.clear(),e.removeEventListener("click",d),e.removeEventListener("keydown",h),e.removeEventListener("mouseover",s),e.removeEventListener("mouseout",i)}}return()=>{r=!0,e.removeEventListener("click",d),e.removeEventListener("keydown",h)}}static tabview(e){if("undefined"==typeof document||"undefined"==typeof window)return;if(!e)return;const t={tab:"data-tab",indicator:"data-tab-indicator"},s={active:"is-active",open:"is-open",underline:"tab-indicator",instant:"is-instant"},i=Array.from(e.querySelectorAll(`[${t.tab}]`));if(!i.length)return;const n=e.getAttribute(t.indicator),o="true"===n||""===n;let r=e.querySelector(`.${s.underline}`);const a=o&&!r;o?("static"===getComputedStyle(e).position&&(e.style.position="relative"),r||(r=document.createElement("div"),r.className=s.underline,e.appendChild(r)),r.style.display=""):r&&(r.style.display="none");const l=new Map;i.forEach(e=>{const s=e.getAttribute(t.tab),i=s?document.querySelector(s):null;i&&l.set(s,i),e.id||(e.id=`tab-${Math.random().toString(36).slice(2,9)}`),e.setAttribute("role","tab"),i&&(i.id||(i.id=`panel-${Math.random().toString(36).slice(2,9)}`),e.setAttribute("aria-controls",i.id),i.setAttribute("role","tabpanel"),i.setAttribute("aria-labelledby",e.id))}),e.setAttribute("role","tablist");const c=parseFloat(getComputedStyle(e).getPropertyValue("--tab-indicator-size"))||3;let d=null,h=!1;function u(t=!1){if(!o||!r)return;const i=e.querySelector(`.${s.active}`);i&&(0===i.offsetWidth&&0===i.offsetHeight||(null!==d&&cancelAnimationFrame(d),d=requestAnimationFrame(()=>{d=null;const{left:n,top:o,width:a,height:l}=(t=>{const s=e.getBoundingClientRect(),i=t.getBoundingClientRect();return{left:i.left-s.left+e.scrollLeft,top:i.top-s.top+e.scrollTop,width:i.width,height:i.height}})(i),{vertical:h,rtl:u}=(()=>{const t=getComputedStyle(e),s=t.flexDirection;return{vertical:"column"===s||"column-reverse"===s,rtl:"rtl"===t.direction}})();let p,m,f,g;h?(f=Math.round(c),g=Math.round(l),m=Math.round(o),p=u?Math.round(n+a-c):Math.round(n)):(f=Math.round(a),g=Math.round(c),p=Math.round(n),m=Math.round(o+l-c)),t&&r.classList.add(s.instant),r.style.transform=`translate3d(${p}px, ${m}px, 0)`,r.style.width=`${f}px`,r.style.height=`${g}px`,t&&(r.offsetWidth,requestAnimationFrame(()=>r.classList.remove(s.instant)))})))}function p(e,{focus:n=!1}={}){i.forEach(t=>{const i=t===e;t.classList.toggle(s.active,i),t.setAttribute("aria-selected",String(i)),t.tabIndex=i?0:-1}),l.forEach(e=>e.classList.remove(s.open));const o=e.getAttribute(t.tab),r=l.get(o);r&&r.classList.add(s.open),u(),n&&e.focus()}p(e.querySelector(`.${s.active}`)||i[0]),r&&u(!0);const m=i=>{const n=i.target.closest(`[${t.tab}]`);n&&e.contains(n)&&(n.classList.contains(s.active)||(i.preventDefault(),p(n)))},f=s=>{const n=s.target.closest(`[${t.tab}]`);if(!n||!e.contains(n))return;const o=i.indexOf(n);if(-1===o)return;let r=null;switch(s.key){case"ArrowRight":r=(o+1)%i.length;break;case"ArrowLeft":r=(o-1+i.length)%i.length;break;case"Home":r=0;break;case"End":r=i.length-1;break;default:return}s.preventDefault(),p(i[r],{focus:!0})};e.addEventListener("click",m),e.addEventListener("keydown",f);const g="undefined"!=typeof ResizeObserver?new ResizeObserver(()=>u()):null;return g&&(g.observe(e),i.forEach(e=>g.observe(e))),document.fonts&&document.fonts.ready&&document.fonts.ready.then(()=>{h||u()}),{dispose:()=>{h=!0,null!==d&&cancelAnimationFrame(d),e.removeEventListener("click",m),e.removeEventListener("keydown",f),g&&g.disconnect(),a&&r&&r.parentNode===e&&r.remove()}}}static swiper(e){if(!e)return;const t=e.querySelector(".swiper-wrapper");if(!t)return;let s=!1,i=0,n=0,o=!1;const r=r=>{s=!0,o=!1,e.classList.add("is-dragging"),i=r.clientX,n=t.scrollLeft,t.setPointerCapture(r.pointerId)},a=e=>{if(!s)return;const r=e.clientX-i;Math.abs(r)>3&&(o=!0);const a=1.15*r;t.scrollLeft=n-a},l=i=>{if(s&&(s=!1,e.classList.remove("is-dragging"),t.releasePointerCapture(i.pointerId),o)){const e=e=>{e.preventDefault(),e.stopImmediatePropagation()};t.addEventListener("click",e,{capture:!0,once:!0})}};return t.addEventListener("pointerdown",r,{passive:!0}),t.addEventListener("pointermove",a,{passive:!1}),t.addEventListener("pointerup",l,{passive:!0}),t.addEventListener("pointercancel",l,{passive:!0}),t.addEventListener("pointerleave",l,{passive:!0}),{dispose:()=>{t.removeEventListener("pointerdown",r),t.removeEventListener("pointermove",a),t.removeEventListener("pointerup",l),t.removeEventListener("pointercancel",l),t.removeEventListener("pointerleave",l)}}}}const p={body:"--body",bodyText:"--body-text",primary:"--primary",primaryContrast:"--primary-contrast",font:"--font",fontMono:"--font-monospace",spaceXs:"--space-xs",spaceSm:"--space-sm",spaceMd:"--space-md",spaceLg:"--space-lg",spaceXl:"--space-xl",space2xl:"--space-2xl"};function m(e={}){if("undefined"==typeof document)return;if(document.querySelector('link[href*="hygular.build.css"]'))return;const t=e||{};if(Object.keys(t).length){if(t.theme){const e=[];if(Object.keys(p).forEach(s=>{t.theme[s]&&e.push(` ${p[s]}: ${t.theme[s]};`)}),t.theme.extend&&Object.entries(t.theme.extend).forEach(([t,s])=>{const i=t.startsWith("--")?t:`--${t}`;e.push(` ${i}: ${s};`)}),e.length>0&&f(`:root {\n${e.join("\n")}\n}`,"hygular-theme-styles"),t.theme.dark){const e=[];Object.keys(p).forEach(s=>{t.theme.dark[s]&&e.push(` ${p[s]}: ${t.theme.dark[s]};`)}),t.theme.dark.extend&&Object.entries(t.theme.dark.extend).forEach(([t,s])=>{const i=t.startsWith("--")?t:`--${t}`;e.push(` ${i}: ${s};`)}),e.length>0&&f(`[data-hygular-theme="dark"] {\n${e.join("\n")}\n}`,"hygular-theme-dark-styles")}}t.classes&&function(e){if(!e||"object"!=typeof e||Array.isArray(e))return;const t=[],s=[];Object.entries(e).forEach(([e,i])=>{if(!e||"string"!=typeof e)return;if("string"==typeof i&&i.trim())return void t.push(`.${e} { ${i.trim()} }`);if(!i||"object"!=typeof i||Array.isArray(i))return;const{dark:n,...o}=i;if(Object.keys(o).length){const s=Object.entries(o).filter(([e,t])=>e&&null!=t&&""!==t).map(([e,t])=>` ${e}: ${t};`).join("\n");s&&t.push(`.${e} {\n${s}\n}`)}if(n&&"object"==typeof n&&!Array.isArray(n)&&Object.keys(n).length){const t=Object.entries(n).filter(([e,t])=>e&&null!=t&&""!==t).map(([e,t])=>` ${e}: ${t};`).join("\n");t&&s.push(`[data-hygular-theme="dark"] .${e} {\n${t}\n}`)}});const i=[...t,...s].join("\n\n");i&&f(i,"hygular-custom-classes")}(t.classes),t.fonts&&Array.isArray(t.fonts)&&function(e){g("https://fonts.googleapis.com"),g("https://fonts.gstatic.com",!0);const t=[];let s="";e.forEach(e=>{if("object"!=typeof e||!e.family)return;t.push(e);const i=e.alias||e.family.toLowerCase().replace(/\s+/g,"-"),n=e.category||"sans-serif";s+=`.font-${i} {\n --hygular-font-family: "${e.family}", ${n};\n font-family: var(--hygular-font-family) !important;\n}\n`}),t.length>0&&(!function(e){const t=e.map(e=>{const t=e.family.trim().replace(/ /g,"+");if(e.weights){return`family=${t}:wght@${e.weights.toString().replace(/,/g,";").replace(/\s/g,"")}`}return`family=${t}`}).join("&"),s=`https://fonts.googleapis.com/css2?${t}&display=swap`;if(!document.head.querySelector(`link[href="${s}"]`)){const e=document.createElement("link");e.href=s,e.rel="stylesheet",document.head.appendChild(e)}}(t),f(s,"hygular-font-classes"))}(t.fonts)}}function f(e,t){if(!e)return;let s=document.getElementById(t);s&&s.remove(),s=document.createElement("style"),s.id=t,s.textContent=e,document.head.appendChild(s)}function g(e,t=!1){if(!document.head.querySelector(`link[rel="preconnect"][href="${e}"]`)){const s=document.createElement("link");s.rel="preconnect",s.href=e,t&&(s.crossOrigin="anonymous"),document.head.appendChild(s)}}class v{static#p=new Map;static#m=0;static get instances(){return v.#p}static create(e,t={}){const s=new v(e,t);return s.#f&&s.#g&&s.#v?.length?(s.build(),s):(n.warn("[Carousel] Missing root, inner element, or carousel items. Instance was not created."),null)}static get(e){return v.#p.get(e)}#y=null;#f=null;#g=null;#v=null;#b=null;#E=null;#w=null;#k=!1;#A=!1;#L=!1;#C=null;#x=null;#S=null;#T=null;#D=null;#O=null;#M=null;#N={x:null,y:null,dx:0,dy:0,startTime:0,threshold:40};#I={};#$=1;static defaults={mode:"slide",autoplay:{enabled:!0,interval:4e3,pauseOnHover:!0,pauseOnSwipe:!0},controls:!0,pager:!0,thumbnails:{enabled:!1,clickable:!0},swipe:!0,loop:!0};static selector={inner:".carousel-items",pager:".pager",thumbs:".thumbnails",next:".carousel-next",prev:".carousel-prev"};static class={active:"is-active",fade:"is-fade"};static template={next:'<button type="button" class="button carousel-next next-icon" aria-label="Next"></button>',prev:'<button type="button" class="button carousel-prev prev-icon" aria-label="Prev"></button>',pager:'<ul class="pager"></ul>',pagerItem:'<li class="item"><button type="button"></button></li>',thumbs:'<ul class="thumbnails"></ul>'};constructor(e,t={}){"undefined"!=typeof window&&"undefined"!=typeof document&&(this.#f=e instanceof Element?e:document.querySelector(e),this.#f instanceof Element?(this.#I=v.deepMerge(v.defaults,t),this.#g=this.#f.querySelector(v.selector.inner),this.#v=[...this.#g?.children??[]],this.#g&&this.#v.length&&(this.#y="carousel-"+ ++v.#m,v.#p.set(this.#y,this),this.#H())):n.warn("[Carousel] Target element was not found."))}static deepMerge(e,t){const s={...e};for(const i in t)t[i]instanceof Object&&i in e?s[i]=v.deepMerge(e[i],t[i]):s[i]=t[i];return s}build(){this.#f.setAttribute("role","region"),this.#f.setAttribute("aria-roledescription","carousel"),this.#f.setAttribute("aria-live",this.#I.autoplay.enabled?"off":"polite"),this.#P(),this.#B(),this.#I.swipe&&this.#q(),this.#I.autoplay.enabled&&this.#R(),this.#F(),this.go(1)}go(e){const t=this.#v.length;this.#I.loop?(e>t&&(e=1),e<1&&(e=t)):e=Math.min(Math.max(e,1),t),this.#$=e;const s=100*-(e-1)+"%";"fade"===this.#I.mode?(this.#g.style.transform="",this.#f.classList.add(v.class.fade),this.#v.forEach(e=>e.classList.remove(v.class.active)),this.#v[e-1].classList.add(v.class.active)):(this.#f.classList.remove(v.class.fade),this.#g.style.transform=`translateX(${s})`),this.#j(this.#b),this.#j(this.#E)}next(){this.#z(),this.go(this.#$+1),this.#V()}prev(){this.#z(),this.go(this.#$-1),this.#V()}#P(){this.#I.controls&&(this.#f.insertAdjacentHTML("beforeend",v.template.prev),this.#f.insertAdjacentHTML("beforeend",v.template.next),this.#f.querySelector(v.selector.next).addEventListener("click",this.#C),this.#f.querySelector(v.selector.prev).addEventListener("click",this.#x))}#B(){this.#I.pager&&this.#I.thumbnails.enabled&&(this.#I.pager=!1),this.#I.pager?this.#_():this.#I.thumbnails.enabled&&this.#W()}#_(){this.#g.insertAdjacentHTML("afterend",v.template.pager),this.#b=this.#f.querySelector(v.selector.pager),this.#v.forEach(()=>this.#b.insertAdjacentHTML("beforeend",v.template.pagerItem)),[...this.#b.children].forEach((e,t)=>{const s=e.querySelector("button");s.setAttribute("aria-label",`Go to slide ${t+1}`),s.addEventListener("click",()=>{this.go(t+1),this.#U()})})}#W(){this.#g.insertAdjacentHTML("afterend",v.template.thumbs),this.#E=this.#f.querySelector(v.selector.thumbs),this.#v.forEach((e,t)=>{const s=e.querySelector("img"),i=document.createElement("li");i.className="item";const n=document.createElement("img");n.className="thumbnail-image";try{n.src=new URL(s?.src??"",location.href).href}catch{n.src=""}if(n.alt="",this.#I.thumbnails.clickable){const e=document.createElement("button");e.type="button",e.setAttribute("aria-label",`Go to slide ${t+1}`),e.appendChild(n),i.appendChild(e)}else i.appendChild(n);this.#E.appendChild(i)}),this.#I.thumbnails.clickable&&[...this.#E.children].forEach((e,t)=>e.querySelector("button").addEventListener("click",()=>{this.go(t+1),this.#U()}))}#j(e){e&&[...e.children].forEach((e,t)=>{const s=t===this.#$-1;e.classList.toggle(v.class.active,s),e.querySelector("button")?.setAttribute("aria-current",String(s))})}#q(){this.#g.addEventListener("pointerdown",this.#S),this.#g.addEventListener("pointermove",this.#T),this.#g.addEventListener("pointerup",this.#D),this.#g.addEventListener("pointercancel",this.#D)}#K(e){e.preventDefault(),this.#k=!0,this.#I.autoplay.pauseOnSwipe&&(this.#L=!0,this.#z()),this.#N.dx=0,this.#N.dy=0,this.#N.x=e.clientX,this.#N.y=e.clientY,this.#N.startTime=performance.now()}#G(e){this.#k&&(this.#N.dx=this.#N.x-e.clientX,this.#N.dy=this.#N.y-e.clientY)}#Q(){if(!this.#k)return;this.#k=!1,this.#I.autoplay.pauseOnSwipe&&(this.#L=!1,this.#A||this.#V());const e=performance.now()-this.#N.startTime;Math.abs(this.#N.dx)>Math.abs(this.#N.dy)&&Math.abs(this.#N.dx)>this.#N.threshold&&e>120&&(this.#N.dx>0?this.next():this.prev())}#R(){this.#I.autoplay.enabled&&!this.#w&&(this.#w=setInterval(()=>this.go(this.#$+1),this.#I.autoplay.interval))}#z(){this.#w&&(clearInterval(this.#w),this.#w=null)}#V(){!this.#I.autoplay.enabled||this.#A||this.#L||this.#R()}#U(){this.#I.autoplay.enabled&&(this.#z(),this.#V())}#H(){this.#C=()=>this.next(),this.#x=()=>this.prev(),this.#S=e=>this.#K(e),this.#T=e=>this.#G(e),this.#D=()=>this.#Q(),this.#O=()=>{this.#A=!0,this.#z()},this.#M=()=>{this.#A=!1,this.#L||this.#V()}}#F(){this.#I.autoplay.pauseOnHover&&(this.#f.addEventListener("pointerenter",this.#O),this.#f.addEventListener("pointerleave",this.#M))}dispose(){this.#z(),this.#f&&this.#g&&(this.#f.querySelector(v.selector.next)?.removeEventListener("click",this.#C),this.#f.querySelector(v.selector.prev)?.removeEventListener("click",this.#x),this.#b?.remove(),this.#E?.remove(),this.#f.querySelector(v.selector.next)?.remove(),this.#f.querySelector(v.selector.prev)?.remove(),this.#g.removeEventListener("pointerdown",this.#S),this.#g.removeEventListener("pointermove",this.#T),this.#g.removeEventListener("pointerup",this.#D),this.#g.removeEventListener("pointercancel",this.#D),v.#p.delete(this.#y),this.#f.removeEventListener("pointerenter",this.#O),this.#f.removeEventListener("pointerleave",this.#M))}}class y{static#X=[];static#Y=!1;static TRANSITION_DURATION=280;static TRANSITION_BUFFER=60;static#J=new WeakMap;static enqueue(e){y.#X.push(e),y.#Z()}static async#Z(){if(!y.#Y){for(y.#Y=!0;y.#X.length;){const e=y.#X.shift();try{const t=new y(e.type,e.options).build();if(t instanceof Promise){const s=await t;e.resolve?.(s)}else e.resolve?.(void 0)}catch(t){e.reject?.(t)}}y.#Y=!1}}static#ee(e,t={},s=!1){return"undefined"==typeof document||"undefined"==typeof window?Promise.resolve("confirm"!==e&&void 0):new Promise((i,n)=>{if(s)return void y.enqueue({type:e,options:t,resolve:i,reject:n});new y(e,t).build().then(i).catch(n)})}static confirm(e={}){return y.#ee("confirm",e)}static alert(e={}){return y.#ee("default",e)}static custom(e={}){return"undefined"==typeof window||"undefined"==typeof document?Promise.resolve():y.#ee("custom",e)}static queue={alert:(e={})=>y.#ee("default",e,!0),confirm:(e={})=>y.#ee("confirm",e,!0)};#te={opened:"is-open",align:{top:"is-top",center:"is-center",bottom:"is-bottom"}};#I=null;#se=null;#ie=null;#ne=null;#oe=null;#re=null;#ae=null;#le=null;#ce=!1;#de=!1;#he=!1;#ue=new Set;#pe=null;#me=null;static#fe=new d;static#ge=0;#ve={esc:null,backdropClick:null,dismissClick:null,confirmClick:null,transitionEnd:null};static#ye(){y.#ge+=1,1===y.#ge&&y.#fe.lock()}static#be(){y.#ge=Math.max(0,y.#ge-1),0===y.#ge&&y.#fe.unlock()}constructor(e,t={}){if(!["default","confirm","custom"].includes(e))throw new Error(`Invalid modal type "${e}". Must be: default, confirm, custom`);const s={default:{heading:void 0,content:"This is a Modal message",align:"center",dispose:!1,dismissText:"OK",icon:{visible:!1,type:"none"},guardMode:!1,guardButtonText:"Go here",guardButtonClass:"",guardButtonUrl:"",closeOnEsc:!0,backdrop:!0,backdropClose:!0,focusFirst:!0,onOpen:null,onOpened:null,onClose:null,onClosed:null},confirm:{heading:void 0,content:"Are you sure?",align:"center",dispose:!1,actions:{cancelText:"No",confirmText:"Yes"},closeOnEsc:!1,backdrop:!0,backdropClose:!1,focusFirst:!0,onOpen:null,onOpened:null,onClose:null,onClosed:null},custom:{id:"#",onOpen:null,onOpened:null,onClose:null,onClosed:null,closeOnEsc:!0,backdropClose:!0,focusFirst:!0}};this.type=e,this.#I={...s[e],...t},"confirm"===e&&(this.#I.actions={...s.confirm.actions,...t.actions}),this.#I.icon={visible:!1,type:"none",...this.#I.icon||{}},this.#ve.esc=this.#Ee.bind(this),this.#ve.dismissClick=this.#we.bind(this),this.#ve.confirmClick=this.#ke.bind(this)}#Ae(){"custom"!==this.type&&(this.#ae=document.createElement("div"),this.#ae.className="modal-backdrop generated-by-hygular-backdrop",this.#se=document.createElement("div"),this.#se.className="modal generated-by-hygular",this.#se.setAttribute("role","dialog"),this.#se.setAttribute("aria-modal","true"),this.#ie=document.createElement("div"),this.#ie.className="modal-dialog",this.#ne=document.createElement("div"),this.#ne.className="modal-header",this.#oe=document.createElement("div"),this.#oe.className="modal-body",this.#ie.append(this.#ne,this.#oe),this.#se.append(this.#ie),this.#ae.appendChild(this.#se),document.body.appendChild(this.#ae))}#Le(){this.#I.heading&&(this.#ne.id="hygular-modal-title-"+crypto.randomUUID(),this.#ne.textContent=this.#I.heading,this.#se.setAttribute("aria-labelledby",this.#ne.id)),this.#oe.textContent=this.#I.content}#Ce(){if(this.#re=document.createElement("div"),this.#re.className="modal-actions","default"===this.type){const e=document.createElement("button");e.type="button",e.className="button is-primary-ghost modal-close",e.textContent=this.#I.dismissText,this.#re.appendChild(e)}else if("confirm"===this.type){const e=document.createElement("button");e.type="button",e.className="button is-dark-ghost modal-close",e.textContent=this.#I.actions.cancelText;const t=document.createElement("button");t.type="button",t.className="button is-primary-ghost modal-confirm",t.textContent=this.#I.actions.confirmText,this.#re.append(e,t)}if(this.#ie.appendChild(this.#re),this.#I.guardMode){this.#re.innerHTML="";const e=document.createElement("button");if(e.type="button",e.className="button",e.textContent=this.#I.guardButtonText||"Go here","string"==typeof this.#I.guardButtonClass){const t=this.#I.guardButtonClass.split(" ").filter(e=>/^[a-z0-9-_]+$/i.test(e));e.classList.add(...t)}return e.addEventListener("click",()=>{this.#xe("guard-exit")&&this.#I.guardButtonUrl&&(window.location.href=this.#I.guardButtonUrl)}),void this.#re.appendChild(e)}}#Se(){const{icon:e}=this.#I;if(!e.visible||"none"===e.type)return;const t={success:'\n <div class="status-icon is-success is-animated">\n <svg class="status-svg" viewBox="0 0 80 80" aria-hidden="true" focusable="false">\n <circle class="status-ring" cx="40" cy="40" r="32"></circle>\n <path class="status-mark" d="M25 41 L35 51 L56 29"></path>\n </svg>\n </div>\n ',error:'\n <div class="status-icon is-error is-animated">\n <svg class="status-svg" viewBox="0 0 80 80" aria-hidden="true" focusable="false">\n <circle class="status-ring" cx="40" cy="40" r="32"></circle>\n <path class="status-mark" d="M28 28 L52 52"></path>\n <path class="status-mark is-second" d="M52 28 L28 52"></path>\n </svg>\n </div>\n ',warning:'\n <div class="status-icon is-warning is-animated">\n <svg class="status-svg" viewBox="0 0 80 80" aria-hidden="true" focusable="false">\n <path class="status-ring" d="M40 12 L68 62 H12 Z" stroke-linejoin="round"></path>\n <path class="status-mark" d="M40 27 V45"></path>\n <circle class="status-dot" cx="40" cy="55" r="3.5"></circle>\n </svg>\n </div>\n ',info:'\n <div class="status-icon is-info is-animated">\n <svg class="status-svg" viewBox="0 0 80 80" aria-hidden="true" focusable="false">\n <circle class="status-ring" cx="40" cy="40" r="32"></circle>\n <path class="status-mark" d="M40 37 V55"></path>\n <circle class="status-dot" cx="40" cy="25" r="3.5"></circle>\n </svg>\n </div>\n '}[e.type];t&&this.#ie.insertAdjacentHTML("afterbegin",t)}#Te(){const e=this.#te.align[this.#I.align];e?this.#se.classList.add(e):this.#se.classList.add(this.#te.align.center)}#De(){this.#pe=document.activeElement,this.#ie&&(this.#me=e=>{if("Tab"!==e.key)return;const t=[...this.#ie.querySelectorAll("a[href], button, input, select, textarea, [tabindex]")].filter(e=>!e.disabled&&e.tabIndex>=0&&e.getClientRects().length),s=t[0],i=t.at(-1);s?!e.shiftKey||document.activeElement!==s&&t.includes(document.activeElement)?e.shiftKey||document.activeElement!==i&&t.includes(document.activeElement)||(e.preventDefault(),s.focus()):(e.preventDefault(),i.focus()):(e.preventDefault(),this.#ie.focus())},this.#ie.addEventListener("keydown",this.#me),this.#I.focusFirst&&this.#ie.setAttribute("tabindex","-1"))}#Ee(e){"Escape"===e.key&&this.#I.closeOnEsc&&this.#xe("esc")}#we(e){e.preventDefault(),this.#xe("dismiss")}#ke(e){e.preventDefault(),this.#Oe()}build(){if(this.#ce||this.#se||"undefined"==typeof document)return Promise.resolve("confirm"!==this.type&&void 0);if("custom"===this.type)return this.#Me();if(this.#Ae(),this.#Te(),this.#Le(),this.#Ce(),this.#Se(),"function"==typeof this.#I.onOpen){const e=this.#I.onOpen(this.#se);if(this.#ce)return Promise.resolve("confirm"!==this.type&&void 0);if(!1===e)return this.#ae.remove(),Promise.reject("Cancelled by onOpen callback")}return this.#I.backdrop&&this.#I.backdropClose&&!this.#I.guardMode&&(this.#ve.backdropClick=e=>{this.#ie.contains(e.target)||this.#xe("backdrop")},this.#ae.addEventListener("click",this.#ve.backdropClick)),this.#I.closeOnEsc&&!this.#I.guardMode&&document.addEventListener("keydown",this.#ve.esc),this.#re?.querySelectorAll(".modal-close")?.forEach(e=>{e.addEventListener("click",this.#ve.dismissClick)}),this.#re?.querySelectorAll(".modal-confirm")?.forEach(e=>{e.addEventListener("click",this.#ve.confirmClick)}),this.#Ne()}#Ne(){y.#ye(),this.#he=!0;const e=new Promise(e=>{this.#le=e});this.#De(),o.afterPaint(()=>{this.#de||this.#ce||(this.#se.classList.add(this.#te.opened),this.#I.focusFirst&&this.#ie.focus())});const t=setTimeout(()=>{this.#ue.delete(t),this.#de||this.#ce||this.#I.onOpened?.(this.#se)},y.TRANSITION_DURATION+y.TRANSITION_BUFFER);return this.#ue.add(t),e}#Oe(){this.#xe("confirm")}#xe(e="dismiss"){if(this.#ce||this.#de||!this.#se)return!1;if(!1===this.#I.onClose?.(this.#se,e))return!1;if(this.#ce)return!1;this.#de=!0,this.#Ie(),this.#$e(),this.#se.classList.remove(this.#te.opened);let t=!1;const s=()=>{if(t||this.#ce)return;t=!0,this.#Ie(),this.#He(),this.#ae?.remove();const s=this.#le;this.#le=null,this.#pe?.isConnected&&this.#pe.focus(),s?.("guard-exit"===e?"guard-exit":"confirm"===this.type?"confirm"===e:void 0);try{this.#I.onClosed?.(this.#se,e)}finally{this.#I?.dispose&&this.dispose()}};this.#ve.transitionEnd=e=>{e.target===this.#se&&s()},this.#se.addEventListener("transitionend",this.#ve.transitionEnd);const i=setTimeout(s,y.TRANSITION_DURATION+y.TRANSITION_BUFFER);return this.#ue.add(i),!0}#Ie(){this.#ue.forEach(clearTimeout),this.#ue.clear(),this.#se?.removeEventListener("transitionend",this.#ve.transitionEnd),this.#ve.transitionEnd=null}#$e(){this.#se?.ownerDocument.removeEventListener("keydown",this.#ve.esc),(this.#ae||this.#se)?.removeEventListener("click",this.#ve.backdropClick),this.#se?.querySelectorAll(".modal-close").forEach(e=>{e.removeEventListener("click",this.#ve.dismissClick),y.#J.get(e)===this.#ve.dismissClick&&y.#J.delete(e)}),this.#se?.querySelectorAll(".modal-confirm").forEach(e=>e.removeEventListener("click",this.#ve.confirmClick)),this.#ie?.removeEventListener("keydown",this.#me)}#He(){this.#he&&(this.#he=!1,y.#be())}#Me(){const e=this.#I.id instanceof Element?this.#I.id:document.querySelector(this.#I.id);return e?!1===this.#I.onOpen?.(e)?Promise.reject(new Error("Cancelled by onOpen")):(this.#se=e,this.#ie=e.querySelector(".modal-dialog")||e,e.querySelectorAll(".modal-close").forEach(e=>{const t=y.#J.get(e);t&&e.removeEventListener("click",t),y.#J.set(e,this.#ve.dismissClick),e.addEventListener("click",this.#ve.dismissClick)}),this.#I.closeOnEsc&&document.addEventListener("keydown",this.#ve.esc),this.#I.backdropClose&&(this.#ve.backdropClick=e=>{this.#ie.contains(e.target)||this.#xe("backdrop")},e.addEventListener("click",this.#ve.backdropClick)),this.#Ne()):Promise.reject(new Error("Custom modal element not found: "+this.#I.id))}dispose(){this.#ce||(this.#ce=!0,this.#Ie(),this.#$e(),this.#He(),this.#se?.classList.remove(this.#te.opened),this.#ae?.remove(),this.#le?.("confirm"!==this.type&&void 0),this.#pe?.isConnected&&this.#pe.focus(),this.#pe=null,this.#se=null,this.#ie=null,this.#ne=null,this.#oe=null,this.#re=null,this.#ae=null,this.#le=null,this.#I=null)}}class b{#Pe=null;#I=null;#Be=null;#qe=new Set;#Re=new Map;#ce=!1;#Fe=["success","danger","warning","info","default"];#te={icon:"has-icon",animated:"animation-none",bordered:"border-0",alertBase:"alert",closeBtn:"alert-close"};#je={message:"This is an alert message",status:"default",hasIcon:!1,dismissible:!0,position:"before",animated:!0,animation:"fade",bordered:!1,autoClean:!1};static create(e,t={}){const s=new b(e,t);return s.#Pe?(s.build(),s):(n.warn(`[Alert] Target element "${e}" was not found. Instance was not created.`),null)}constructor(e,t={}){if("undefined"!=typeof window&&"undefined"!=typeof document){if(this.#Pe=e instanceof Element?e:document.querySelector(e),!(this.#Pe instanceof Element))return n.warn(`[Alert] Target element "${e}" was not found. Instance was not created.`),null;this.#I={...this.#je,...t},this.#Be=this.#we.bind(this)}}build(){if(this.#ce||!this.#Pe)return;const e=this.#ze(),t="before"===this.#I.position?"beforebegin":"afterend";return this.#Pe.insertAdjacentElement(t,e),this.#I.dismissible&&e.addEventListener("click",this.#Be),this.#qe.add(e),e}#Ve(e="is-"){return this.#Fe.includes(this.#I.status)?`${e}${this.#I.status}`:`${e}default`}#ze(){const e=[this.#te.alertBase,this.#Ve(),this.#I.hasIcon?this.#te.icon:"",!1===this.#I.animated?this.#te.animated:"",!1===this.#I.bordered?this.#te.bordered:""].filter(Boolean).join(" "),t=document.createElement("div");t.setAttribute("role","alert");const s=document.createElement("span");if(t.className=e,s.className="alert-content",s.appendChild(document.createTextNode(this.#I.message)),t.appendChild(s),this.#I.dismissible){const e=document.createElement("button");e.type="button",e.className=`button ${this.#te.closeBtn}`,e.setAttribute("aria-label","Dismiss alert"),t.appendChild(e)}return t}#we(e){if(this.#ce)return;const t=e.target.closest(`.${this.#te.closeBtn}`),s=t?.closest(`.${this.#te.alertBase}`);if(s&&this.#qe.has(s)&&!this.#Re.has(s))if(e.preventDefault(),s.removeEventListener("click",this.#Be),"slide"===this.#I.animation)this.#Re.set(s,()=>{s.getAnimations?.().forEach(e=>e.cancel())}),o.slideUp(s,200,!0).then(()=>this.#_e(s));else{const e=e=>{e.target===s&&"opacity"===e.propertyName&&this.#_e(s)},t=setTimeout(()=>this.#_e(s),250);this.#Re.set(s,()=>{clearTimeout(t),s.removeEventListener("transitionend",e)}),s.addEventListener("transitionend",e),s.style.transition="opacity 0.2s ease",s.style.opacity="0"}}#_e(e){this.#qe.has(e)&&(this.#Re.get(e)?.(),this.#Re.delete(e),e.removeEventListener("click",this.#Be),e.remove(),this.#qe.delete(e),this.#I?.autoClean&&this.dispose())}dispose(){this.#ce||(this.#ce=!0,this.#Re.forEach(e=>e()),this.#Re.clear(),this.#qe.forEach(e=>{e.removeEventListener("click",this.#Be),e.remove()}),this.#qe.clear(),this.#Pe=null,this.#I=null,this.#Be=null)}}class E{#We;#I;#Ue;#Ke=[];#f;#Ge;#Qe;#Xe;#Ye;#Je;#Ze;#et;#tt;#st;#it=null;#nt;#ot=[];#rt=-1;#at=!1;#ce=!1;#lt=null;#ct;#dt;static#m=0;static defaults={inputName:"select",multiple:!1,defaultValue:null,data:[],search:!1,placeholder:"--SELECT--"};static variables={animationDuration:200};constructor(e,t={}){"undefined"!=typeof window&&"undefined"!=typeof document&&(this.#We=e instanceof Element?e:document.querySelector(e),this.#We instanceof Element?(this.#I={...E.defaults,...t,data:t.data??E.defaults.data},this.#Ue=this.#I.data,this.#Ze=E.variables.animationDuration,this.#ht()):n.warn("[Select] Target element was not found."))}#ht(){this.#ut(),this.#pt(),null!=this.#I.defaultValue&&this.#mt()}#ut(){this.#f=document.createElement("div"),this.#f.className="custom-select",this.#f.setAttribute("aria-expanded","false"),this.#f.setAttribute("aria-haspopup","listbox"),this.#Ge=document.createElement("div"),this.#Ge.className="selected-option",this.#Ge.tabIndex=0,this.#Ge.setAttribute("role","combobox"),this.#Ge.setAttribute("aria-expanded","false"),this.#Ge.setAttribute("aria-haspopup","listbox");const e=this.#We.getAttribute("aria-labelledby"),t=this.#We.getAttribute("aria-label")||Array.from(this.#We.labels||[]).map(e=>e.textContent.trim()).join(" ");e?this.#Ge.setAttribute("aria-labelledby",e):this.#Ge.setAttribute("aria-label",t||this.#I.placeholder),this.#Ge.innerText=this.#I.placeholder,this.#f.appendChild(this.#Ge),this.#Qe=document.createElement("div"),this.#Qe.className="options-container",this.#Qe.style.transition=`opacity ${this.#Ze}ms ease, transform ${this.#Ze}ms ease`,this.#Qe.hidden=!0,this.#f.appendChild(this.#Qe),this.#Xe=document.createElement("input"),this.#Xe.type="hidden",this.#Xe.name=this.#I.inputName,this.#f.appendChild(this.#Xe),this.#I.search&&(this.#Ye=document.createElement("input"),this.#Ye.type="text",this.#Ye.placeholder="Search...",this.#Ye.className="form-input",this.#tt=()=>this.#ft(),this.#Ye.addEventListener("input",this.#tt),this.#Qe.appendChild(this.#Ye)),this.#nt=document.createElement("div"),this.#nt.id="hygular-select-"+ ++E.#m,this.#nt.setAttribute("role","listbox"),this.#nt.setAttribute("aria-label",t||this.#I.placeholder),this.#I.multiple&&this.#nt.setAttribute("aria-multiselectable","true"),this.#Qe.appendChild(this.#nt),this.#Ge.setAttribute("aria-controls",this.#nt.id),this.#Ye&&(this.#Ye.setAttribute("role","combobox"),this.#Ye.setAttribute("aria-label",t?`Search ${t}`:"Search options"),this.#Ye.setAttribute("aria-autocomplete","list"),this.#Ye.setAttribute("aria-controls",this.#nt.id),this.#Ye.setAttribute("aria-expanded","false")),this.#Ue.forEach(e=>this.#gt(e)),this.#et=()=>{this.toggle(),this.#at&&this.#Ye?.focus()},this.#Ge.addEventListener("click",this.#et),this.#ct=e=>this.#vt(e),this.#dt=e=>{this.#f.contains(e.relatedTarget)||this.close()},this.#f.addEventListener("keydown",this.#ct),this.#f.addEventListener("focusout",this.#dt),this.#We.insertAdjacentElement("afterend",this.#f),this.#I.multiple&&"undefined"!=typeof ResizeObserver&&(this.#st=new ResizeObserver(()=>this.#yt()),this.#st.observe(this.#Ge))}#gt(e){const t=document.createElement("div");if(t.setAttribute("role","option"),t.className="select-option",t.id=`${this.#nt.id}-option-${this.#ot.length}`,t.setAttribute("aria-selected","false"),this.#ot.push(t),t.dataset.value=e.value,t.dataset.name=e.name.toLowerCase(),e.icon){const s=document.createElement("img");s.src=e.icon,s.className="option-icon",t.appendChild(s)}const s=document.createTextNode(e.name);t.appendChild(s),t.addEventListener("click",()=>{this.select(e),this.#ce||(this.#at&&this.#Ye?this.#Ye:this.#Ge).focus()}),this.#nt.appendChild(t)}select(e){if(!this.#ce&&this.#f&&e){if(this.#I.multiple){if(this.#Ke.find(t=>t.value===e.value))return;this.#Ke.push(e),this.#bt()}else{if(this.#Ke=[e],this.#Ge.innerHTML="",e.icon){const t=document.createElement("img");t.src=e.icon,t.className="option-icon",this.#Ge.appendChild(t)}this.#Ge.appendChild(document.createTextNode(e.name)),this.close()}this.#Et()}}#bt(){this.#Ge.innerHTML="",this.#I.multiple&&0!==this.#Ke.length?(this.#Ke.forEach(e=>{const t=document.createElement("div");if(t.className="select-tag",e.icon){const s=document.createElement("img");s.src=e.icon,s.className="option-icon",t.appendChild(s)}t.appendChild(document.createTextNode(e.name));const s=document.createElement("button");s.type="button",s.setAttribute("aria-label",`Remove ${e.name}`),s.className="tag-remove",s.textContent="×",s.onclick=t=>{t.stopPropagation(),this.remove(e.value),this.#ce||this.#Ge.focus()},t.appendChild(s),this.#Ge.appendChild(t)}),this.#yt()):this.#Ge.innerText=this.#I.placeholder}#yt(){this.#ce||null!==this.#lt||(this.#lt=requestAnimationFrame(()=>{if(this.#lt=null,this.#ce)return;const e=this.#Ge.getBoundingClientRect().width;if(e<=0)return;let t=0,s=0;if(this.#Ge.querySelectorAll(".select-tag").forEach(i=>{i.style.display="inline-flex";const n=i.offsetWidth+6;t+n>e-55?(i.style.display="none",s++):t+=n}),this.#Ge.querySelector(".more-tag")?.remove(),s){const e=document.createElement("div");e.className="more-tag",e.textContent=`+${s} more`,this.#Ge.appendChild(e)}}))}#Et(){this.#wt(),this.#Xe.value=this.#Ke.map(e=>e.value).join(","),this.#We.value=this.#Xe.value,this.#We.dispatchEvent(new Event("change"))}#wt(){this.#ot.forEach((e,t)=>{const s=this.#Ke.some(e=>e.value===this.#Ue[t].value);e.setAttribute("aria-selected",String(s))})}#kt(e){this.#rt=e,this.#ot.forEach((t,s)=>t.classList.toggle("is-active",s===e));const t=this.#ot[e];for(const e of[this.#Ge,this.#Ye])e&&(t?e.setAttribute("aria-activedescendant",t.id):e.removeAttribute("aria-activedescendant"));t?.scrollIntoView?.({block:"nearest"})}#vt(e){if(this.#ce||e.target.closest(".tag-remove")||e.isComposing)return;const t=e.target===this.#Ye;if("Tab"===e.key)return void this.close();if("Escape"===e.key)return void(this.#at&&(e.preventDefault(),e.stopPropagation(),this.close(),this.#Ge.focus()));const s="ArrowDown"===e.key||"ArrowUp"===e.key,i=!t&&("Home"===e.key||"End"===e.key);if(s||i){e.preventDefault();const t=this.#at;this.open();const s=this.#ot.map((e,t)=>e.hidden?-1:t).filter(e=>e>=0);let i=s.indexOf(this.#rt);return"Home"===e.key?i=0:"End"===e.key?i=s.length-1:t?i=i<0?"ArrowUp"===e.key?s.length-1:0:Math.max(0,Math.min(s.length-1,i+("ArrowUp"===e.key?-1:1))):"ArrowUp"===e.key&&(i=s.length-1),void this.#kt(s[i]??-1)}if("Enter"===e.key||" "===e.key&&!t)if(e.preventDefault(),this.#at){if(this.#rt>=0){const e=this.#Ue[this.#rt];this.#I.multiple&&this.#Ke.some(t=>t.value===e.value)?this.remove(e.value):this.select(e),this.#ce||this.#at||this.#Ge.focus()}}else this.open(),this.#Ye?.focus()}remove(e){!this.#ce&&this.#f&&(this.#Ke=this.#Ke.filter(t=>t.value!==e),this.#bt(),this.#wt(),this.#Xe.value=this.#Ke.map(e=>e.value).join(","),this.#We.value=this.#Xe.value,this.#We.dispatchEvent(new Event("change")))}#mt(){(Array.isArray(this.#I.defaultValue)?this.#I.defaultValue.map(e=>this.#Ue.find(t=>t.value==e)):[this.#Ue.find(e=>e.value==this.#I.defaultValue)]).forEach(e=>e&&this.select(e))}open(){this.#ce||!this.#f||this.#at||(this.#at=!0,this.#Qe.hidden=!1,this.#Ge.setAttribute("aria-expanded","true"),this.#Ye?.setAttribute("aria-expanded","true"),this.#kt(this.#ot.findIndex(e=>!e.hidden&&"true"===e.getAttribute("aria-selected"))),this.#rt<0&&this.#kt(this.#ot.findIndex(e=>!e.hidden)),clearTimeout(this.#it),this.#it=null,this.#Qe.style.display="block",this.#Qe.offsetWidth,this.#Qe.style.opacity="1",this.#Qe.style.transform="translateX(-50%) translateY(0)",this.#f.setAttribute("aria-expanded","true"))}close(){!this.#ce&&this.#f&&this.#at&&(this.#at=!1,this.#Ge.setAttribute("aria-expanded","false"),this.#Ye?.setAttribute("aria-expanded","false"),this.#kt(-1),clearTimeout(this.#it),this.#Qe.style.opacity="0",this.#Qe.style.transform="translateX(-50%) translateY(-8px)",this.#f.setAttribute("aria-expanded","false"),this.#it=setTimeout(()=>{this.#Qe.style.display="none",this.#Qe.hidden=!0,this.#it=null},this.#Ze))}toggle(){this.#at?this.close():this.open()}#ft(){const e=this.#Ye.value.toLowerCase();this.#Qe.querySelectorAll(".select-option").forEach(t=>{const s=t.dataset.name;t.hidden=!s.includes(e),t.style.display=t.hidden?"none":"flex"}),this.#kt(this.#ot.findIndex(e=>!e.hidden))}#pt(){this.#Je=e=>{this.#f.contains(e.target)||this.close()},document.addEventListener("click",this.#Je)}dispose(){this.#ce||(this.#ce=!0,null!==this.#lt&&cancelAnimationFrame(this.#lt),this.#lt=null,this.#f?.removeEventListener("keydown",this.#ct),this.#f?.removeEventListener("focusout",this.#dt),clearTimeout(this.#it),this.#it=null,this.#f?.ownerDocument.removeEventListener("click",this.#Je),this.#Ge?.removeEventListener("click",this.#et),this.#Ye&&this.#tt&&this.#Ye.removeEventListener("input",this.#tt),this.#f?.remove(),this.#st&&(this.#st.disconnect(),this.#st=null))}}class w{static#p=new WeakMap;#We=null;#At=null;#I=null;#Lt=!1;#ce=!1;#Ct=null;#xt=null;#St=null;#Tt=null;#Dt=null;#Ot=null;#je={message:"Hi, I am a tooltip message",placement:"auto",hasArrow:!0,autoClean:!1};#te={tooltip:"tooltip",active:"is-open",arrow:"has-arrow",top:"is-top",bottom:"is-bottom",left:"is-left",right:"is-right"};constructor(e,t={}){if("undefined"==typeof window||"undefined"==typeof document)return;if(this.#We="string"==typeof e?document.querySelector(e):e,!(this.#We instanceof Element))return void n.warn("[Tooltip] Target element is not a valid DOM element.");const s=w.#p.get(this.#We);s&&s.dispose(),this.#I=this.#Mt(t),w.#p.set(this.#We,this),this.#Nt()}#Mt(e={}){const t={message:this.#We.dataset.tooltip,placement:this.#We.dataset.placement};return{...this.#je,...this.#It(t),...this.#It(e)}}#It(e){return Object.fromEntries(Object.entries(e).filter(([,e])=>null!=e&&""!==e))}#Nt(){const e="ontouchstart"in window||navigator.maxTouchPoints>0;this.#St=e=>{"Escape"===e.key&&this.hide()},this.#Ct=()=>this.show(),this.#xt=()=>this.hide(),e?(this.#We.addEventListener("touchstart",this.#Ct,{passive:!0}),this.#We.addEventListener("touchend",this.#xt),this.#We.addEventListener("touchcancel",this.#xt)):(this.#We.addEventListener("mouseenter",this.#Ct),this.#We.addEventListener("mouseleave",this.#xt)),this.#We.addEventListener("focus",this.#Ct),this.#We.addEventListener("blur",this.#xt),document.addEventListener("keydown",this.#St)}show(){if(this.#ce||this.#Lt||!this.#We)return;const e=String(this.#I.message??"").trim();if(!e)return;const t=this.#$t();this.#At=document.createElement("div"),this.#At.id=t,this.#At.className=this.#te.tooltip,this.#At.setAttribute("role","tooltip"),this.#At.textContent=e,this.#I.hasArrow&&this.#At.classList.add(this.#te.arrow),this.#Dt=this.#We.getAttribute("aria-describedby"),this.#We.setAttribute("aria-describedby",[this.#Dt,t].filter(Boolean).join(" ")),"static"===getComputedStyle(this.#We).position&&(this.#Ot={value:this.#We.style.getPropertyValue("position"),priority:this.#We.style.getPropertyPriority("position")},this.#We.style.position="relative"),this.#We.appendChild(this.#At);const s=this.#At;o.afterPaint(()=>{this.#At!==s||this.#ce||(this.#Ht(),this.#At.classList.add(this.#te.active))}),this.#Lt=!0,this.#Pt()}#Ht(){if(!this.#At||!this.#We)return;this.#Bt();const e=this.#qt();this.#At.classList.add(this.#te[e])}#qt(){const e=this.#Rt(this.#I.placement),t=this.#We.getBoundingClientRect(),s=this.#At.getBoundingClientRect(),i=window.innerWidth,n=window.innerHeight,o={top:t.top,bottom:n-t.bottom,left:t.left,right:i-t.right},r={top:o.top>=s.height,bottom:o.bottom>=s.height,left:o.left>=s.width,right:o.right>=s.width};if("auto"!==e&&r[e])return e;const a=Object.keys(r).filter(e=>r[e]);return a.length?this.#Ft(a,o,s):this.#Ft(["top","bottom","left","right"],o,s)}#Ft(e,t,s){const i={top:t.top/s.height,bottom:t.bottom/s.height,left:t.left/s.width,right:t.right/s.width};return e.sort((e,t)=>i[t]-i[e])[0]}#Rt(e){return["auto","top","bottom","left","right"].includes(e)?e:"auto"}#Bt(){this.#At.classList.remove(this.#te.top,this.#te.bottom,this.#te.left,this.#te.right)}#Pt(){this.#Tt||(this.#Tt=()=>{this.#Lt&&this.#Ht()},window.addEventListener("resize",this.#Tt),window.addEventListener("scroll",this.#Tt,!0))}#jt(){this.#Tt&&(window.removeEventListener("resize",this.#Tt),window.removeEventListener("scroll",this.#Tt,!0),this.#Tt=null)}hide(){this.#Lt&&!this.#ce&&(this.#jt(),this.#At?.remove(),this.#At=null,this.#Lt=!1,null===this.#Dt?this.#We?.removeAttribute("aria-describedby"):this.#We?.setAttribute("aria-describedby",this.#Dt),this.#Ot&&(this.#Ot.value?this.#We.style.setProperty("position",this.#Ot.value,this.#Ot.priority):this.#We.style.removeProperty("position"),this.#Ot=null),this.#I.autoClean&&this.dispose())}#$t(){return`hygular-tooltip-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}static getInstance(e){return w.#p.get(e)}static init(e='[data-hygular="tooltip"]'){return"undefined"==typeof document?[]:[...document.querySelectorAll(e)].map(e=>w.#p.get(e)||new w(e))}dispose(){this.#ce||(this.hide(),this.#We?.removeEventListener("mouseenter",this.#Ct),this.#We?.removeEventListener("mouseleave",this.#xt),this.#We?.removeEventListener("touchstart",this.#Ct),this.#We?.removeEventListener("touchend",this.#xt),this.#We?.removeEventListener("touchcancel",this.#xt),this.#We?.removeEventListener("focus",this.#Ct),this.#We?.removeEventListener("blur",this.#xt),this.#We?.ownerDocument.removeEventListener("keydown",this.#St),w.#p.delete(this.#We),this.#ce=!0,this.#We=null,this.#At=null,this.#I=null)}}class k{static#p=new Map;static#zt=0;static get instances(){return k.#p}#y=null;#I=null;#We=null;#Vt=null;#_t=null;#Wt;#Ut=null;#je={message:"Hi, I am a toast message",status:"default",position:"bottom",duration:4e3,dismissPrevious:!1,showIcon:!1,autoClean:!1};#Kt={rootParent:"body",toastBase:"toast",generated:"generated-by-hygular"};#te={active:"is-active",posTop:"is-top",posBottom:"is-bottom"};#Gt={success:"is-success",danger:"is-danger",warning:"is-warning",info:"is-info",default:"is-default"};constructor(e={}){this.#I={...this.#je,...e},this.#I.duration=Math.min(Math.max(parseInt(this.#I.duration)||0,1e3),1e4),this.#y="toast-"+ ++k.#zt,k.#p.set(this.#y,this)}static show(e={}){const t=new k(e);return t.build(),t}build(){if(!this.#I||this.#We)return;if("undefined"==typeof window||"undefined"==typeof document)return;k.#p.set(this.#y,this);const e=this.#Kt.rootParent instanceof Element?this.#Kt.rootParent:document.querySelector(this.#Kt.rootParent)||document.body,t=`hygular-toast-container-${this.#I.position}`;let s=e.querySelector(`.${t}`);s||(s=document.createElement("div"),s.className=`hygular-toast-container ${t}`,e.appendChild(s)),this.#Ut=s,this.#I.dismissPrevious&&this.#Qt(this.#Ut),this.#Ae(this.#Ut),this.#Xt(),this.#Yt()}dismiss(){this.#Jt(),this.#Zt(),k.#p.delete(this.#y),this.#I?.autoClean&&this.dispose()}#Ae(e){const t=document.createElement("div");if(t.classList.add(this.#Kt.toastBase,this.#Kt.generated),t.setAttribute("data-toast-id",this.#y),t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),this.#I.showIcon){const e=document.createElement("span");e.className="toast-icon",t.appendChild(e)}const s=document.createElement("span");s.className="toast-message",s.textContent=this.#I.message,t.appendChild(s);const i=document.createElement("div");i.className="toast-progress",t.appendChild(i),e.appendChild(t),this.#We=t,this.#Vt=i,o.afterPaint(()=>{this.#We===t&&t.classList.add(this.#te.active)})}#Xt(){if(!(this.#We instanceof Element))return void n.warn("[Toast] Target element was not found.");this.#Wt=()=>this.dismiss(),this.#We.addEventListener("click",this.#Wt);const e="top"===this.#I.position?this.#te.posTop:this.#te.posBottom;this.#We.classList.add(e);const t=this.#Gt[this.#I.status]??this.#Gt.default;this.#We.classList.add(t),this.#I.showIcon&&this.#We.classList.add("has-icon")}#Yt(){if(!this.#Vt||!this.#We)return;this.#Vt.style.width="100%";const e=this.#Vt;o.afterPaint(()=>{this.#Vt===e&&(this.#Vt.style.transition=`width ${this.#I.duration}ms linear`,this.#Vt.style.width="0%")}),this.#_t=setTimeout(()=>{this.#We&&this.#We.parentNode&&this.dismiss(),this.#_t=null},this.#I.duration)}#Jt(){this.#_t&&(clearTimeout(this.#_t),this.#_t=null),this.#Vt&&(this.#Vt.style.transition="")}#Zt(){if(this.#We){this.#Wt&&this.#We.removeEventListener("click",this.#Wt);try{this.#We.parentNode&&this.#We.parentNode.removeChild(this.#We)}catch(e){}this.#We=null,this.#Vt=null,this.#Wt=null}}#Qt(e){e.querySelectorAll(`.${this.#Kt.generated}`).forEach(e=>{const t=k.#p.get(e.getAttribute("data-toast-id"));t?t.dismiss():e.remove()})}dispose(){this.#Jt(),this.#Zt(),k.#p.delete(this.#y),this.#y=null,this.#I=null}}class A{#I;#f;#Ut;#es;#ts=null;#ss="darkMode";#is;#ns=null;#os=null;#rs=null;#as=[];constructor(e={}){if("undefined"==typeof window||"undefined"==typeof document)return;this.#f=document.documentElement;this.#I={container:"body",customBtn:!1,autoCreateBtn:!0,...e},this.#Ut=document.querySelector(this.#I.container)||document.body,this.#ht()}#ls(){this.#es=document.createElement("label"),this.#es.classList.add("dark-mode-toggler"),"body"===this.#I.container&&(this.#es.classList.add("is-fixed"),this.#es.setAttribute("data-fixed-lock","")),this.#es.setAttribute("aria-label","Dark Mode Toggle Button"),this.#es.addEventListener("mousedown",e=>e.preventDefault()),this.#ts=document.createElement("input"),this.#ts.type="checkbox",this.#ts.setAttribute("aria-label","Enable dark mode"),this.#ts.setAttribute("role","switch");const e=document.createElement("div");e.classList.add("dark-mode-toggler-track");const t=document.createElement("div");t.classList.add("dark-mode-toggler-thumb"),t.innerHTML='\n <span class="dark-mode-toggler-sun" aria-hidden="true">\n <svg width="14" height="14" viewBox="0 0 24 24" fill="none"\n stroke="currentColor" stroke-width="2.5"\n stroke-linecap="round" stroke-linejoin="round">\n <circle cx="12" cy="12" r="4"/>\n <line x1="12" y1="2" x2="12" y2="6"/>\n <line x1="12" y1="18" x2="12" y2="22"/>\n <line x1="2" y1="12" x2="6" y2="12"/>\n <line x1="18" y1="12" x2="22" y2="12"/>\n <line x1="4.22" y1="4.22" x2="7.05" y2="7.05"/>\n <line x1="16.95" y1="16.95" x2="19.78" y2="19.78"/>\n <line x1="4.22" y1="19.78" x2="7.05" y2="16.95"/>\n <line x1="16.95" y1="7.05" x2="19.78" y2="4.22"/>\n </svg>\n </span>\n <span class="dark-mode-toggler-moon" aria-hidden="true">\n <svg width="13" height="13" viewBox="0 0 24 24" fill="none"\n stroke="currentColor" stroke-width="2.5"\n stroke-linecap="round" stroke-linejoin="round">\n <path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"/>\n </svg>\n </span>\n ',e.appendChild(t),this.#es.appendChild(this.#ts),this.#es.appendChild(e),this.#Ut.appendChild(this.#es)}#cs(){const e=this.#ds();"enabled"===e?this.#hs(!0):"disabled"===e?this.#hs(!1):null===e&&this.#hs(window.matchMedia("(prefers-color-scheme: dark)").matches)}#hs(e){e?this.#f.setAttribute("data-hygular-theme","dark"):this.#f.removeAttribute("data-hygular-theme"),this.#ts&&(this.#ts.checked=e),this.#ns?.classList.toggle("is-dark",e)}#us(){const e=this.isDark();this.#as.forEach(t=>t(e)),this.#f.dispatchEvent(new CustomEvent("hygular.theme.change",{detail:{isDark:e}}))}#ds(){try{return localStorage.getItem(this.#ss)}catch{return null}}#ps(e){try{localStorage.setItem(this.#ss,e)}catch{}}#ms(){const e=!this.isDark();this.#hs(e),this.#ps(e?"enabled":"disabled"),this.#us()}#Nt(){if(this.#ts&&this.#ts.addEventListener("change",()=>this.#ms()),this.#I.customBtn){if(this.#ns=document.querySelector(this.#I.customBtn),!this.#ns)return;this.#is=()=>this.#ms(),this.#ns.addEventListener("click",this.#is)}}#ht(){if(this.#I.autoCreateBtn&&!this.#I.customBtn&&this.#ls(),this.#Nt(),this.#cs(),"undefined"!=typeof window){const e=window.matchMedia("(prefers-color-scheme: dark)");this.#rs=e,this.#os=e=>{null===this.#ds()&&(this.#hs(e.matches),this.#us())},e.addEventListener("change",this.#os)}}isDark(){return"dark"===this.#f?.getAttribute("data-hygular-theme")}onChange(e){"function"==typeof e&&this.#as.push(e)}dispose(){this.#es?.remove(),this.#es=null,this.#ts=null,this.#os&&this.#rs?.removeEventListener("change",this.#os),this.#ns&&this.#is&&this.#ns.removeEventListener("click",this.#is),this.#as=[],this.#ns=null,this.#is=null,this.#os=null,this.#rs=null}}class L{static show(e){e&&!e.skeletonActive&&(L._emit(e,"hygular.skeleton.show",!0)||(e.skeletonActive=!0,e.skeletonAriaHidden=e.getAttribute("aria-hidden"),e.skeletonAriaLabel=e.getAttribute("aria-label"),e.setAttribute("aria-hidden","true"),e.setAttribute("aria-label","Loading…"),e.setAttribute("data-skeleton",""),L.clearError(e),L.injectWave(e),L.watchResize(e),L._emit(e,"hygular.skeleton.shown")))}static hide(e){e&&e.skeletonActive&&(L._emit(e,"hygular.skeleton.hide",!0)||(L.resetLoading(e),L._emit(e,"hygular.skeleton.hidden")))}static error(e,t={}){if(!e)return;const{message:s="Failed to load",retry:i=!1,onRetry:n=null}=t;e.skeletonActive&&L.resetLoading(e),L.clearError(e),e.setAttribute("data-skeleton-error",""),e.setAttribute("aria-live","polite");const o=L._createElement("div","hygular-sk-error-layer",{"data-skeleton-injected":"","data-skeleton-ignore":"",role:"alert"});o.appendChild(L.createErrorIcon());const r=L._createElement("p","hygular-sk-error-msg");if(r.textContent=s,o.appendChild(r),i){const t=L._createElement("button","hygular-sk-retry");t.type="button",t.textContent="Try again",t.addEventListener("click",()=>{L.clearError(e),"function"==typeof n&&n(e),L._emit(e,"hygular.skeleton.retry")}),o.appendChild(t)}e.appendChild(o),L._emit(e,"hygular.skeleton.error",!1,{message:s})}static async wrap(e,t,s={}){L.show(e);try{return await t()}catch(t){throw L.error(e,{message:s.message??t.message??"Failed to load",retry:s.retry??!1,onRetry:s.onRetry??null}),t}finally{e.skeletonActive&&L.hide(e)}}static mount(){if("undefined"==typeof window||"undefined"==typeof document)return()=>{};if(L.mountCleanup)return L.mountCleanup;const e=new Set;let t=!1;const s=t=>{"false"===t.getAttribute("data-skeleton-auto")||t.skeletonActive||(L.show(t),t.skeletonActive&&e.add(t))};document.querySelectorAll("[data-skeleton]").forEach(s),L._mutationObserver=new MutationObserver(e=>{if(!t)for(const t of e)for(const e of t.addedNodes)1===e.nodeType&&(e.hasAttribute("data-skeleton")&&s(e),e.querySelectorAll("[data-skeleton]").forEach(s))}),L._mutationObserver.observe(document.body,{childList:!0,subtree:!0});const i=()=>{t||(t=!0,L._mutationObserver.disconnect(),L._mutationObserver=null,L.mountCleanup=null,e.forEach(e=>{e.skeletonActive&&L.resetLoading(e)}),e.clear())};return L.mountCleanup=i,i}static resetLoading(e){e.skeletonActive=!1,e.removeAttribute("data-skeleton"),L.unwatchResize(e),L.restoreAria(e),L.removeOverlay(e)}static watchResize(e){e.skeletonResizeObserver||"undefined"==typeof ResizeObserver||(e.skeletonResizeObserver=new ResizeObserver(()=>{e.skeletonActive&&(L.removeOverlay(e),L.injectWave(e))}),e.skeletonResizeObserver.observe(e))}static unwatchResize(e){e.skeletonResizeObserver&&(e.skeletonResizeObserver.disconnect(),e.skeletonResizeObserver=null)}static injectWave(e){if(e.querySelector("[data-skeleton-injected]"))return;const t=L._createElement("div","hygular-sk-wave-overlay",{"data-skeleton-injected":"","data-skeleton-ignore":"","aria-hidden":"true"}),s=e.getAttribute("data-skeleton-layout")||"auto",i=e.offsetWidth||300,n=e.offsetHeight||200,o="card"===s?L.createCard(e,i,n):"list"===s?L.createList(e,i,n):"article"===s?L.createArticle(i,n):"profile"===s?L.createProfile(i,n):L.detectShapes(e,e.getBoundingClientRect());if(0===o.length){const e=L._createElement("span","hygular-sk-ghost");e.style.cssText="position:absolute;inset:0;border-radius:inherit;",t.appendChild(e)}else for(const e of o){const s=L._createElement("span","hygular-sk-ghost");s.style.cssText=`position:absolute;top:${e.top}px;left:${e.left}px;width:${e.width}px;height:${e.height}px;border-radius:${e.radius};`,t.appendChild(s)}e.appendChild(t)}static createCard(e,t,s){const i=Math.max(1,parseInt(e.getAttribute("data-skeleton-cols"),10)||Math.max(1,Math.round(t/220))),n=Math.max(1,parseInt(e.getAttribute("data-skeleton-rows"),10)||2),o=(t-12*(i-1))/i,r=(s-12*(n-1))/n,a=[];for(let e=0;e<n;e++)for(let t=0;t<i;t++){const s=t*(o+12),i=e*(r+12);a.push({top:i,left:s,width:o,height:.52*r,radius:"8px"}),a.push({top:i+.57*r,left:s,width:32,height:32,radius:"50%"}),a.push({top:i+.57*r+6,left:s+42,width:.55*o,height:11,radius:"6px"}),a.push({top:i+.57*r+24,left:s+42,width:.35*o,height:9,radius:"6px"}),a.push({top:i+.83*r,left:s,width:.42*o,height:9,radius:"6px"})}return a}static createList(e,t,s){const i=Math.max(1,parseInt(e.getAttribute("data-skeleton-rows"),10)||5),n=[];for(let e=0;e<i;e++){const s=56*e;n.push({top:s+10,left:12,width:36,height:36,radius:"50%"}),n.push({top:s+13,left:60,width:t*(.4+e%3*.07),height:11,radius:"6px"}),n.push({top:s+31,left:60,width:t*(.25+e%2*.06),height:9,radius:"6px"})}return n}static createArticle(e,t){const s=Math.min(200,.4*t),i=[{top:0,left:0,width:e,height:s,radius:"10px"}],n=[.9,.76,.83,.6,.78,.5];let o=s+18;for(const t of n)i.push({top:o,left:0,width:e*t,height:12,radius:"6px"}),o+=21;return i}static createProfile(e){const t=e-80-8;return[{top:0,left:0,width:64,height:64,radius:"50%"},{top:5,left:80,width:.55*t,height:13,radius:"6px"},{top:25,left:80,width:.38*t,height:11,radius:"6px"},{top:50,left:80,width:.7*t,height:10,radius:"6px"},{top:67,left:80,width:.5*t,height:10,radius:"6px"}]}static detectShapes(e,t){const s=[],i=new Set(["SPAN","A","STRONG","EM","B","I","LABEL","H1","H2","H3","H4","H5","H6","P","LI","TD","TH","CAPTION","FIGCAPTION","TIME","CODE","KBD","MARK","SMALL"]),n=new Set(["IMG","SVG","VIDEO","CANVAS","INPUT","TEXTAREA","SELECT","BUTTON","PICTURE","FIGURE","IFRAME","HR","TABLE","PROGRESS","METER"]),o=e=>{try{const t=getComputedStyle(e),s=t.borderRadius||"0px",i=parseFloat(s),n=Math.min(parseFloat(t.width)||0,parseFloat(t.height)||0);return i>=n/2&&n>0?"50%":s}catch{return"4px"}},r=e=>{if(1!==e.nodeType)return;if(e.hasAttribute?.("data-skeleton-ignore"))return;if(e.hasAttribute?.("data-skeleton-injected"))return;const a=e.getBoundingClientRect();if(a.width<2||a.height<2)return;const l=a.top-t.top,c=a.left-t.left;if(l+a.height<0||c+a.width<0)return;if(l>t.height||c>t.width)return;const d=e.tagName,h=n.has(d),u=i.has(d);if(!h&&!u||(s.push({top:Math.max(0,l),left:Math.max(0,c),width:Math.min(a.width,t.width-Math.max(0,c)),height:Math.min(a.height,t.height-Math.max(0,l)),radius:o(e)}),!h))for(const t of e.children)r(t)};for(const t of e.children)r(t);return L.removeContainedShapes(s)}static removeContainedShapes(e){return e.filter((t,s)=>!e.some((e,i)=>{if(s===i)return!1;return t.top>=e.top&&t.left>=e.left&&t.top+t.height<=e.top+e.height&&t.left+t.width<=e.left+e.width&&e.width*e.height>t.width*t.height}))}static removeOverlay(e){e.querySelectorAll("[data-skeleton-injected]").forEach(e=>e.remove())}static clearError(e){e.removeAttribute("data-skeleton-error"),e.removeAttribute("aria-live"),e.querySelectorAll(".hygular-sk-error-layer").forEach(e=>e.remove())}static restoreAria(e){null===e.skeletonAriaHidden?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",e.skeletonAriaHidden),null===e.skeletonAriaLabel?e.removeAttribute("aria-label"):e.setAttribute("aria-label",e.skeletonAriaLabel)}static _emit(e,t,s=!1,i={}){const n=new CustomEvent(t,{bubbles:!0,cancelable:s,detail:{el:e,...i}});return e.dispatchEvent(n),n.defaultPrevented}static _createElement(e,t="",s={}){const i=document.createElement(e);t&&(i.className=t);for(const[e,t]of Object.entries(s))i.setAttribute(e,t);return i}static createErrorIcon(){const e="http://www.w3.org/2000/svg",t=document.createElementNS(e,"svg"),s=(e,t)=>{for(const[s,i]of Object.entries(t))e.setAttribute(s,i);return e},i=(t,i)=>s(document.createElementNS(e,t),i);return s(t,{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"}),t.appendChild(i("circle",{cx:"12",cy:"12",r:"10"})),t.appendChild(i("line",{x1:"12",y1:"8",x2:"12",y2:"12"})),t.appendChild(i("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})),t}}class C{static#fs=new WeakSet;static load(e){if(!e?.dataset.src||!e.parentNode||C.#fs.has(e))return;C.#fs.add(e);const t=e.dataset.errorText||"Image failed to load",s=document.createElement("div");s.className="hygular-image-wrap",e.parentNode.insertBefore(s,e),s.appendChild(e);const i=document.createElement("div");i.className="hygular-image-shimmer",s.appendChild(i);const n=document.createElement("div");n.className="hygular-image-error-layer",n.appendChild(C.createErrorSVG());const o=document.createElement("span");o.textContent=t,n.appendChild(o),s.appendChild(n);const r=new Image;r.onload=()=>{C.#fs.delete(e),e.src=r.src,e.removeAttribute("data-src"),e.classList.add("hygular-image-loaded"),i.remove()},r.onerror=()=>{C.#fs.delete(e),r.onerror=null,i.remove(),e.removeAttribute("data-src"),n.classList.add("is-visible")},r.src=e.dataset.src}static observe(e="img[data-src]"){if("undefined"==typeof window||"undefined"==typeof document)return()=>{};let t=!1;const s=new IntersectionObserver(e=>{t||e.forEach(e=>{e.isIntersecting&&(C.load(e.target),s.unobserve(e.target))})},{rootMargin:"100px 0px",threshold:.1});document.querySelectorAll(e).forEach(e=>s.observe(e));const i=new MutationObserver(i=>{t||i.forEach(t=>{t.addedNodes.forEach(t=>{1===t.nodeType&&(t.matches?.(e)&&s.observe(t),t.querySelectorAll?.(e).forEach(e=>s.observe(e)))})})});return i.observe(document.body,{childList:!0,subtree:!0}),()=>{t=!0,s.disconnect(),i.disconnect()}}static createErrorSVG(){const e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("width","24"),e.setAttribute("height","24"),e.setAttribute("viewBox","0 0 24 24"),e.setAttribute("fill","none"),e.setAttribute("stroke","currentColor"),e.setAttribute("stroke-width","1.5"),e.setAttribute("stroke-linecap","round"),e.setAttribute("stroke-linejoin","round");const t=document.createElementNS("http://www.w3.org/2000/svg","rect");t.setAttribute("x","3"),t.setAttribute("y","3"),t.setAttribute("width","18"),t.setAttribute("height","18"),t.setAttribute("rx","2");const s=document.createElementNS("http://www.w3.org/2000/svg","circle");s.setAttribute("cx","8.5"),s.setAttribute("cy","8.5"),s.setAttribute("r","1.5");const i=document.createElementNS("http://www.w3.org/2000/svg","path");return i.setAttribute("d","m21 15-5-5L5 21"),e.appendChild(t),e.appendChild(s),e.appendChild(i),e}}class x{static#p=new WeakMap;#We=null;#gs=null;#I=null;#Lt=!1;#ce=!1;#vs=!1;#ys=null;#y=null;#bs=null;#St=null;#Es=null;#Tt=null;#je={title:"",content:"",target:null,placement:"auto",trigger:"click",hasArrow:!0,closeOnOutsideClick:!0,closeOnEscape:!0,offset:10,autoClean:!1};#te={popover:"popover",active:"is-open",arrow:"has-arrow",header:"popover-header",body:"popover-body",top:"is-top",bottom:"is-bottom",left:"is-left",right:"is-right",start:"is-start",end:"is-end"};constructor(e,t={}){if("undefined"==typeof window||"undefined"==typeof document)return;if(this.#We="string"==typeof e?document.querySelector(e):e,!(this.#We instanceof Element))return void n.warn("[Popover] Target element was not found or is not a valid DOM element.");const s=x.#p.get(this.#We);s&&s.dispose(),this.#ys=new Map(["aria-expanded","aria-controls"].map(e=>[e,this.#We.getAttribute(e)])),this.#I=this.#Mt(t),this.#y=this.#$t(),x.#p.set(this.#We,this),this.#Nt()}#Mt(e={}){const t={title:this.#We.dataset.title,content:this.#We.dataset.content||this.#We.dataset.popover,target:this.#We.dataset.target||this.#We.dataset.popoverTarget,placement:this.#We.dataset.placement,trigger:this.#We.dataset.trigger,hasArrow:this.#ws(this.#We.dataset.arrow),closeOnOutsideClick:this.#ws(this.#We.dataset.closeOutside),closeOnEscape:this.#ws(this.#We.dataset.closeEscape),offset:this.#ks(this.#We.dataset.offset)};return{...this.#je,...this.#It(t),...this.#It(e)}}#It(e){return Object.fromEntries(Object.entries(e).filter(([,e])=>null!=e&&""!==e))}#ws(e){if(null!=e&&""!==e)return"true"===e||!0===e}#ks(e){if(null==e||""===e)return;const t=Number(e);return Number.isFinite(t)?t:void 0}#Nt(){const e=this.#As(this.#I.trigger);this.#St=e=>{this.#I.closeOnEscape&&"Escape"===e.key&&this.#Lt&&this.hide()},this.#Es=e=>{if(!this.#I.closeOnOutsideClick||!this.#Lt)return;const t=e.target;this.#We?.contains(t)||this.#gs?.contains(t)||this.hide()},this.#bs=e=>{e.preventDefault(),this.toggle()},"click"===e&&this.#We.addEventListener("click",this.#bs),document.addEventListener("keydown",this.#St)}show(){if(this.#ce||this.#Lt||!this.#We)return;if(!this.#Ls("hygular.popover.show",!0)||this.#ce)return;const e=this.#Cs(),t=String(this.#I.title??"").trim();if(!t&&!e)return;if(this.#gs=document.createElement("div"),this.#gs.id=this.#y,this.#gs.className=this.#te.popover,this.#gs.setAttribute("role","dialog"),this.#I.hasArrow&&this.#gs.classList.add(this.#te.arrow),t){const e=document.createElement("div");e.className=this.#te.header,e.id=`${this.#y}-title`,e.textContent=t,this.#gs.setAttribute("aria-labelledby",e.id),this.#gs.appendChild(e)}if(e){const t=document.createElement("div");t.className=this.#te.body,t.appendChild(e),this.#gs.appendChild(t)}this.#We.setAttribute("aria-expanded","true"),this.#We.setAttribute("aria-controls",this.#y),document.body.appendChild(this.#gs);const s=this.#gs;o.afterPaint(()=>{!this.#ce&&this.#Lt&&this.#gs===s&&(this.update(),this.#gs.classList.add(this.#te.active),this.#Ls("hygular.popover.shown"))}),this.#Lt=!0,this.#Pt(),this.#I.closeOnOutsideClick&&o.afterPaint(()=>{!this.#ce&&this.#Lt&&this.#gs===s&&document.addEventListener("pointerdown",this.#Es)})}hide(){if(this.#Lt&&!this.#ce&&!this.#vs){this.#vs=!0;try{if(!this.#Ls("hygular.popover.hide",!0)||this.#ce)return;this.#xs(),this.#Ls("hygular.popover.hidden"),this.#I?.autoClean&&!this.#Lt&&this.dispose()}finally{this.#vs=!1}}}#xs(){this.#jt(),this.#We?.ownerDocument.removeEventListener("pointerdown",this.#Es),this.#gs?.remove(),this.#gs=null,this.#Lt=!1,this.#We?.setAttribute("aria-expanded","false"),this.#We?.removeAttribute("aria-controls")}toggle(){this.#Lt?this.hide():this.show()}update(){if(!this.#Lt||!this.#gs||!this.#We)return;this.#Bt();const e=this.#qt(),{side:t,align:s}=e;this.#gs.classList.add(this.#te[t]),s&&this.#te[s]&&this.#gs.classList.add(this.#te[s]),this.#Ss(t,s)}#Cs(){const e=this.#I.target?document.querySelector(this.#I.target):null;if(e){const t=document.createDocumentFragment();return[...e.childNodes].forEach(e=>{t.appendChild(e.cloneNode(!0))}),t.childNodes.length?t:null}const t=this.#I.content;if(t instanceof Node){const e=document.createDocumentFragment();return e.appendChild(t.cloneNode(!0)),e}const s=String(t??"").trim();if(!s)return null;const i=document.createDocumentFragment();return i.appendChild(document.createTextNode(s)),i}#qt(){const e=this.#Rt(this.#I.placement),t=("auto"===e.side?this.#Ts():[e,...this.#Ts()]).filter((e,t,s)=>s.findIndex(t=>t.side===e.side&&t.align===e.align)===t);return t.find(e=>this.#Ds(e.side))||t[0]}#Ts(){const e=this.#We.getBoundingClientRect(),t=window.innerWidth,s=window.innerHeight,i={top:e.top,bottom:s-e.bottom,left:e.left,right:t-e.right};return["bottom","top","right","left"].sort((e,t)=>i[t]-i[e]).map(e=>({side:e,align:"center"}))}#Ds(e){if(!this.#gs||!this.#We)return!1;const t=this.#We.getBoundingClientRect(),s=this.#gs.getBoundingClientRect(),i=window.innerWidth,n=window.innerHeight,o=this.#I.offset,r={top:t.top,bottom:n-t.bottom,left:t.left,right:i-t.right};return"top"===e||"bottom"===e?r[e]>=s.height+o:r[e]>=s.width+o}#Ss(e,t="center"){const s=this.#We.getBoundingClientRect(),i=this.#gs.getBoundingClientRect(),n=window.scrollX||window.pageXOffset,o=window.scrollY||window.pageYOffset,r=this.#I.offset;let a=0,l=0;"top"===e&&(a=s.top+o-i.height-r,l=this.#Os(s,i,t)+n),"bottom"===e&&(a=s.bottom+o+r,l=this.#Os(s,i,t)+n),"left"===e&&(a=this.#Ms(s,i,t)+o,l=s.left+n-i.width-r),"right"===e&&(a=this.#Ms(s,i,t)+o,l=s.right+n+r);l=Math.max(8+n,Math.min(l,window.innerWidth+n-i.width-8)),a=Math.max(8+o,Math.min(a,window.innerHeight+o-i.height-8)),Object.assign(this.#gs.style,{position:"absolute",top:`${a}px`,left:`${l}px`})}#Os(e,t,s){return"start"===s?e.left:"end"===s?e.right-t.width:e.left+e.width/2-t.width/2}#Ms(e,t,s){return"start"===s?e.top:"end"===s?e.bottom-t.height:e.top+e.height/2-t.height/2}#As(e){return["click","manual"].includes(e)?e:"click"}#Rt(e){const t=String(e||"auto").trim(),[s,i]=t.split("-");return{side:["auto","top","bottom","left","right"].includes(s)?s:"auto",align:["start","end"].includes(i)?i:"center"}}#Bt(){this.#gs.classList.remove(this.#te.top,this.#te.bottom,this.#te.left,this.#te.right,this.#te.start,this.#te.end)}#Pt(){this.#Tt||(this.#Tt=()=>this.update(),window.addEventListener("resize",this.#Tt),window.addEventListener("scroll",this.#Tt,!0))}#jt(){this.#Tt&&(window.removeEventListener("resize",this.#Tt),window.removeEventListener("scroll",this.#Tt,!0),this.#Tt=null)}#Ls(e,t=!1){if(!this.#We)return!1;const s=new CustomEvent(e,{bubbles:!0,cancelable:t,detail:{instance:this,trigger:this.#We,popover:this.#gs}});return this.#We.dispatchEvent(s)}#$t(){return`hygular-popover-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}static getInstance(e){return x.#p.get(e)}static init(e='[data-hygular-toggle="popover"], [data-hygular="popover"]'){return"undefined"==typeof document?[]:[...document.querySelectorAll(e)].map(e=>x.#p.get(e)||new x(e))}dispose(){this.#ce||(this.#ce=!0,this.#xs(),this.#We?.removeEventListener("click",this.#bs),this.#We?.ownerDocument.removeEventListener("keydown",this.#St),this.#ys?.forEach((e,t)=>{null===e?this.#We?.removeAttribute(t):this.#We?.setAttribute(t,e)}),x.#p.delete(this.#We),this.#ys=null,this.#We=null,this.#I=null,this.#y=null)}}class S{static#Ns={email:e=>/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/.test(e)||"Please enter a valid email address.",phone:e=>/^\+?[1-9]\d{1,14}$/.test(e.replace(/[\s\-()]/g,""))||"Please enter a valid phone number.",number:e=>/^-?\d+(\.\d+)?$/.test(e)||"This field must be a valid number.",integer:e=>/^-?\d+$/.test(e)||"This field must be an integer.",alphanumeric:e=>/^[a-zA-Z0-9]+$/.test(e)||"Only letters and numbers are allowed.",url:e=>/^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([/\w .-]*)*\/?$/.test(e)||"Please enter a valid URL.","password-strength":e=>/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[\s\S]{8,}$/.test(e)||"Password must be 8+ chars, include uppercase, lowercase, and a number.","no-spaces":e=>!/\s/.test(e)||"Spaces are not allowed.",min:(e,t)=>{const s=Number(t);if(isNaN(s))return`Invalid min param: "${t}".`;return/^-?\d+(\.\d+)?$/.test(e.trim())?Number(e)>=s||`Value must be at least ${s}.`:e.length>=s||`Must be at least ${s} characters.`},max:(e,t)=>{const s=Number(t);if(isNaN(s))return`Invalid max param: "${t}".`;return/^-?\d+(\.\d+)?$/.test(e.trim())?Number(e)<=s||`Value must be no more than ${s}.`:e.length<=s||`Must be no more than ${s} characters.`},minlen:(e,t)=>{const s=Number(t);return isNaN(s)?`Invalid minlen param: "${t}".`:e.length>=s||`Must be at least ${s} characters.`},maxlen:(e,t)=>{const s=Number(t);return isNaN(s)?`Invalid maxlen param: "${t}".`:e.length<=s||`Must be no more than ${s} characters.`},minval:(e,t)=>{const s=Number(t);return isNaN(s)?`Invalid minval param: "${t}".`:Number(e)>=s||`Value must be at least ${s}.`},maxval:(e,t)=>{const s=Number(t);return isNaN(s)?`Invalid maxval param: "${t}".`:Number(e)<=s||`Value must be no more than ${s}.`},exact:(e,t)=>{const s=Number(t);return isNaN(s)?`Invalid exact param: "${t}".`:e.length===s||`Must be exactly ${s} characters.`},match:(e,t)=>{if(!t)return"match rule requires a selector param, e.g. match:#other-id";const s=document.querySelector(t);return s?e===s.value||"Fields do not match.":(console.warn(`Hygular [match]: No element found for selector "${t}"`),`match rule: target "${t}" not found.`)},contains:(e,t)=>!!e.includes(t)||`Must contain "${t}".`,startswith:(e,t)=>!!e.startsWith(t)||`Must start with "${t}".`,endswith:(e,t)=>!!e.endsWith(t)||`Must end with "${t}".`,"file-max":(e,t,s)=>{if("file"!==s.type||!s.files||0===s.files.length)return!0;const i=1024*Number(t)*1024;return!Array.from(s.files).find(e=>e.size>i)||`File size cannot exceed ${t}MB.`},"file-ext":(e,t,s)=>{if("file"!==s.type||!s.files||0===s.files.length)return!0;const i=t.split(",").map(e=>e.trim().toLowerCase());return!Array.from(s.files).find(e=>{const t=e.name.match(/\.([a-z0-9]+)$/i);return!i.includes(t?t[1].toLowerCase():"")})||`Allowed file types: ${i.join(", ")}`}};static addRule(e,t){"string"==typeof e&&e.trim()?"function"==typeof t?(S.#Ns[e]&&console.warn(`Hygular [addRule]: Rule "${e}" already exists — overwriting.`),S.#Ns[e]=t):console.warn(`Hygular [addRule]: Rule "${e}" must be a function.`):console.warn("Hygular [addRule]: Rule name must be a non-empty string.")}static init(){return h.subscribe("form",S.#Is)}static#Is(e){const t='[data-hygular="form"]',s={groupFile:".group-file",inputFile:".form-file",uploadDisplay:".upload-display"},i={validated:"is-validated",loading:"is-loading"},n={ajaxTimeout:3e4},o=new Set(["hidden","submit","button","reset","image"]),r=t=>{if(o.has(t.type))return null;if(t.hasAttribute("data-no-feedback"))return null;const s=t.closest(".group-checkbox, .group-radio, .group-switch"),i=s?.closest(".group")||s||t.parentNode;let n=i.querySelector(":scope > .form-feedback.is-invalid");return n||(n=e.createElement("div"),n.className="form-feedback is-invalid",i.appendChild(n)),n},a=e=>{e.querySelectorAll(".form-feedback.is-server").forEach(e=>{e.classList.remove("is-server","with-success","with-error"),e.textContent=""})},l=t=>{if(o.has(t.type))return;if(t.setCustomValidity(""),(t=>{if("checkbox"===t.type)return!t.checked;if("radio"===t.type){const s=(t.form||e).querySelectorAll(`input[type="radio"][name="${CSS.escape(t.name)}"]`);return!Array.from(s).some(e=>e.checked)}return"file"===t.type?0===t.files.length:!t.value})(t)){if(t.required){const e=t.getAttribute("data-required-msg")||"This field is required.";t.setCustomValidity(e);const s=r(t);s&&(s.textContent=e)}return}let s=null;if(s=(e=>{const t=e.getAttribute("data-rule");if(!t)return null;if(!e.value&&"file"!==e.type)return null;for(const s of t.trim().split(/\s+/)){const t=s.indexOf(":"),i=-1===t?s:s.slice(0,t),n=-1===t?void 0:s.slice(t+1),o=S.#Ns[i];if(!o){console.warn(`Hygular: Unknown rule "${i}"`);continue}const r=o(e.value,n,e);if(!0!==r)return String(r)}return null})(t),!s){const e=t.getAttribute("data-regex");if(e)try{new RegExp(e).test(t.value)||(s=t.getAttribute("data-error-msg")||"Format is invalid.")}catch{console.error(`Hygular: Invalid regex pattern: ${e}`)}}if(s&&t.setCustomValidity(s),!t.validity.valid){const e=r(t);e&&(e.textContent=t.getAttribute("data-error-msg")||s||t.validationMessage)}},c=new WeakSet,d=new Map;let h=!1;const u=(e,t,s=!1)=>{if(d.get(e)!==t)return;d.delete(e),clearTimeout(t.timeoutId);const n=t.submitBtn;n&&(n.classList.toggle(i.loading,t.wasLoading),n.disabled=t.wasDisabled),d.size||p.disconnect(),s&&t.controller.abort()},p=new e.defaultView.MutationObserver(()=>{d.forEach((t,s)=>{e.contains(s)||u(s,t,!0)})}),m=async(t,s)=>{if(h||d.has(t)||!e.contains(t))return;const o=(t.getAttribute("method")||"POST").toUpperCase();let l={};const m=t.getAttribute("data-ajax-headers");if(m)try{l=JSON.parse(m)}catch{console.warn("Hygular: Invalid JSON in data-ajax-headers — ignoring.",t)}const f=Number(t.getAttribute("data-ajax-timeout"))||n.ajaxTimeout,g=new AbortController,v=setTimeout(()=>g.abort(),f),y={controller:g,timeoutId:v,submitBtn:s,wasDisabled:s?.disabled??!1,wasLoading:s?.classList.contains(i.loading)??!1};d.set(t,y),s?.classList.add(i.loading),p.observe(e.documentElement,{childList:!0,subtree:!0});const E=()=>!h&&d.get(t)===y&&e.contains(t);try{const n=new CustomEvent("hygular.form.start",{detail:{form:t},cancelable:!0});if(t.dispatchEvent(n),n.defaultPrevented||!E())return;const d=s?.form===t?s:void 0,h=new e.defaultView.FormData(t,d);if(!E())return;s&&(s.disabled=!0);const u=new URL(t.action||e.defaultView.location.href),p="GET"!==o&&"HEAD"!==o;if(!p)for(const[e,t]of h)u.searchParams.append(e,"string"==typeof t?t:t.name);const m=await fetch(u.href,{method:o,...p?{body:h}:{},headers:{"X-Requested-With":"XMLHttpRequest",Accept:"application/json",...l},signal:g.signal}),f=await m.json().catch(()=>null);if(!E())return;if(g.signal.aborted)throw new e.defaultView.DOMException("Request timed out","AbortError");if(m.ok){if(a(t),t.reset(),!E())return;t.querySelectorAll(".group.floating-label select").forEach(b),t.classList.remove(i.validated),t.querySelectorAll("input, select, textarea").forEach(e=>{c.delete(e)}),t.dispatchEvent(new CustomEvent("hygular.form.success",{bubbles:!0,detail:{response:m,data:f}}))}else((e,t)=>{const s=t?.errors;s&&"object"==typeof s&&(Object.entries(s).forEach(([t,s])=>{const i=e.querySelector(`[name="${CSS.escape(t)}"]`);if(!i)return;const n=Array.isArray(s)?s[0]:s;if(!n)return;i.setCustomValidity(String(n));const o=r(i);o&&(o.textContent=String(n),o.classList.add("form-feedback","is-server","with-error"))}),e.querySelector(":invalid")?.focus())})(t,f),t.dispatchEvent(new CustomEvent("hygular.form.error",{detail:{response:m,data:f}}))}catch(e){if(!E())return;const s="AbortError"===e.name;console.error(s?"Hygular AJAX Form Error: request timed out.":"Hygular AJAX Form Error:",s?"":e),t.dispatchEvent(new CustomEvent("hygular.form.error",{detail:{error:e,timeout:s}}))}finally{u(t,y)}},f=e=>{if(h)return;const s=e.target.closest(t);if(s){if(a(s),s.classList.add(i.validated),s.querySelectorAll("input, select, textarea").forEach(e=>{c.add(e),l(e)}),!s.checkValidity())return e.preventDefault(),e.stopPropagation(),void s.querySelector(":invalid")?.focus();e.defaultPrevented||"true"!==s.getAttribute("data-ajax")||(e.preventDefault(),m(s,e.submitter))}},g=e=>{const s=e.target;s.matches("input, select, textarea")&&s.closest(t)&&(c.add(s),l(s))},v=s=>{const i=s.target;if(!i.matches("input, select, textarea"))return;const n=i.closest(t);n&&(c.has(i)&&l(i),n.querySelectorAll("input[data-rule], select[data-rule], textarea[data-rule]").forEach(t=>{if(t===i||!c.has(t))return;t.getAttribute("data-rule").trim().split(/\s+/).some(t=>{if(!t.startsWith("match:"))return!1;try{return e.querySelector(t.slice(6))===i}catch{return!1}})&&l(t)}))},y=e=>{v(e);const t=e.target;if(!t.matches(s.inputFile))return;const i=t.closest(s.groupFile);if(!i)return;const n=i.querySelector(s.uploadDisplay);n&&(0===t.files.length?n.textContent=i.getAttribute("data-default-text")||"No file selected":1===t.files.length?n.textContent=`Selected: ${t.files[0].name.replace(/[<>/\\|:*?"']/g,"_")}`:n.textContent=`${t.files.length} items selected`),c.add(t),l(t)},b=t=>{let s=t.nextElementSibling;s?.classList.contains("select-label")||(s=e.createElement("label"),s.className="select-label",s.textContent=t.options[0]?.textContent||"Select an option",t.insertAdjacentElement("afterend",s));const i=""!==t.value;s.classList.toggle("floating-label-visible",i),s.classList.toggle("floating-label-hidden",!i)},E=e=>{e.target.matches(".group.floating-label select")&&b(e.target)};return e.addEventListener("submit",f),e.addEventListener("change",y),e.addEventListener("change",E,!0),e.addEventListener("input",v),e.addEventListener("blur",g,!0),{refresh:()=>{e.querySelectorAll(".group.floating-label select").forEach(b),e.querySelectorAll(`${t} input, ${t} select, ${t} textarea`).forEach(r)},dispose(){h=!0,e.removeEventListener("submit",f),e.removeEventListener("change",y),e.removeEventListener("change",E,!0),e.removeEventListener("input",v),e.removeEventListener("blur",g,!0),p.disconnect(),d.forEach((e,t)=>u(t,e,!0))}}}}const T=new WeakMap;class D{static NAME="range";static SELECTOR='[data-hygular="range"]';#We;#$s;#Hs;#Ps=null;#Bs=null;#qs;#Rs=[];#Fs;#js;#zs;#Vs;#st;constructor(e,t={}){if("undefined"!=typeof window&&"undefined"!=typeof document){if(T.has(e))return T.get(e);this.#We=e,this.options={tooltip:!0,ticks:!0,valueLabel:null,...t},this.#$s=Array.from(e.querySelectorAll('input[type="range"]')),this.#Hs=2===this.#$s.length,0!==this.#$s.length?this.#$s.length>2?n.error(`Range: expected 1 or 2 input[type='range'] elements, found ${this.#$s.length}`,this.#We):(this.#Ps=null,this.#qs="rtl"===getComputedStyle(e).direction,this.#Rs=[],this._onResize=this._onResize.bind(this),this.buildTooltips(),this.buildDualFill(),this.buildTicks(),this.bindEvents(),"undefined"!=typeof ResizeObserver&&(this.#st=new ResizeObserver(this._onResize),this.#st.observe(this.#We)),this.update(),T.set(e,this)):n.error("Range: no input[type='range'] found inside element",this.#We)}}static getInstance(e){return T.get(e)??null}static getOrCreateInstance(e,t){return T.get(e)??new D(e,t)}static init(e){"undefined"!=typeof window&&"undefined"!=typeof document&&(e??=document,e.querySelectorAll(D.SELECTOR).forEach(e=>D.getOrCreateInstance(e)))}buildTooltips(){this.options.tooltip&&(this.#Fs=this.#$s.map(()=>{const e=document.createElement("span");return e.className="form-range-tooltip",e.setAttribute("aria-hidden","true"),this.#We.appendChild(e),e}))}buildDualFill(){this.#Hs&&(this.#js=document.createElement("span"),this.#js.className="form-range-dual-track",this.#zs=document.createElement("span"),this.#zs.className="form-range-dual-fill",this.#We.prepend(this.#zs),this.#We.prepend(this.#js))}buildTicks(){if(!this.options.ticks)return;if(this.#Hs)return;this.#Vs&&(this.#Vs.remove(),this.#Vs=null);const e=this.#$s[0],t=e.getAttribute("list");if(!t)return;const s=document.getElementById(t);if(!s)return;const i=Array.from(s.querySelectorAll("option"));if(0===i.length)return;const n=parseFloat(e.min||0),o=parseFloat(e.max||100);this.#Vs=document.createElement("div"),this.#Vs.className="form-range-ticks",this.#Vs.setAttribute("aria-hidden","true"),i.forEach(e=>{const t=parseFloat(e.value),s=o===n?0:(t-n)/(o-n)*100,i=this.#qs?100-s:s,r=document.createElement("span");if(r.className="form-range-tick",r.style.left=`${i}%`,this.#Vs.appendChild(r),e.label){const t=document.createElement("span");t.className="form-range-tick-label",t.style.left=`${i}%`,t.textContent=e.label,this.#Vs.appendChild(t)}}),this.#We.after(this.#Vs)}bindEvents(){const e=(e,t,s,i)=>{e.addEventListener(t,s,i),this.#Rs.push({target:e,type:t,handler:s,opts:i})},t=this.#We.getRootNode();e(t.isConnected?t:this.#We.ownerDocument,"reset",e=>{this.#$s.some(t=>t.form===e.target)&&(this.#Ps&&cancelAnimationFrame(this.#Ps),clearTimeout(this.#Bs),this.#Bs=setTimeout(()=>this.update(),0))},!0),this.#$s.forEach((t,s)=>{const i=(s,i,n)=>e(t,s,i,n);i("input",()=>this._onInput(s)),i("change",()=>this._onChange(s)),i("pointerdown",()=>this.showTooltip(s),{passive:!0}),i("pointerup",()=>this.hideTooltip(s),{passive:!0}),i("focus",()=>this.showTooltip(s)),i("blur",()=>this.hideTooltip(s)),i("keydown",()=>this.showTooltip(s),{passive:!0})})}_onInput(e){this.#_s(e),this.#Ps&&cancelAnimationFrame(this.#Ps),this.#Ps=requestAnimationFrame(()=>this.update(e)),this.#We.dispatchEvent(new CustomEvent("hygular.range.input",{bubbles:!0,detail:{value:this.getValue(),index:e}}))}#_s(e){if(!this.#Hs||void 0===e)return;const[t,s]=this.#$s,i="any"===t.step?0:parseFloat(t.step||1);parseFloat(t.value)<=parseFloat(s.value)-i||(0===e?t.value=String(parseFloat(s.value)-i):s.value=String(parseFloat(t.value)+i))}_onChange(e){this.#We.dispatchEvent(new CustomEvent("hygular.range.change",{bubbles:!0,detail:{value:this.getValue(),index:e}}))}showTooltip(e){this.#Fs?.[e]?.classList.add("is-visible")}hideTooltip(e){this.#Fs?.[e]?.classList.remove("is-visible")}_onResize(){this.positionTooltips()}percentage(e){const t=parseFloat(e.min||0),s=parseFloat(e.max||100);if(s===t)return 0;const i=(parseFloat(e.value)-t)/(s-t)*100;return this.#qs?100-i:i}update(e){if(this.#Hs){const[t,s]=this.#$s;this.#_s(e);const i=this.percentage(t),n=this.percentage(s),[o,r]=i<=n?[i,n]:[n,i];this.#zs.style.setProperty("--range-min",`${o}%`),this.#zs.style.setProperty("--range-max",`${r}%`),t.style.zIndex=document.activeElement===t?"2":"1",s.style.zIndex=document.activeElement===s?"2":"1",t.setAttribute("aria-valuetext",this.formatValue(t.value)),s.setAttribute("aria-valuetext",this.formatValue(s.value))}else{const e=this.#$s[0];e.style.setProperty("--range-progress",`${this.percentage(e)}%`),e.setAttribute("aria-valuetext",this.formatValue(e.value))}this.options.tooltip&&this.positionTooltips()}positionTooltips(){this.#$s.forEach((e,t)=>{const s=this.#Fs?.[t];if(!s)return;s.textContent=this.formatValue(e.value);const i=this.percentage(e),n=parseFloat(getComputedStyle(e).getPropertyValue("--range-thumb"))||20,o=i/100*(e.offsetWidth-n)+n/2;s.style.setProperty("--range-tooltip-x",`${o}px`)})}formatValue(e){return"function"==typeof this.options.valueLabel?this.options.valueLabel(e):"string"==typeof this.options.valueLabel?this.options.valueLabel.replace("{value}",e):String(e)}getValue(){return this.#Hs?this.#$s.map(e=>parseFloat(e.value)):parseFloat(this.#$s[0].value)}setValue(e){this.#Hs&&Array.isArray(e)?(this.#$s[0].value=String(e[0]),this.#$s[1].value=String(e[1])):this.#$s[0].value=String(e),this.update(),this.#$s.forEach(e=>e.dispatchEvent(new Event("input",{bubbles:!0})))}refresh(){this.buildTicks(),this.update()}dispose(){clearTimeout(this.#Bs),this.#Ps&&cancelAnimationFrame(this.#Ps),this.#st?.disconnect(),this.#Rs.forEach(({target:e,type:t,handler:s,opts:i})=>e.removeEventListener(t,s,i)),this.#Rs=[],this.#Fs?.forEach(e=>e.remove()),this.#js?.remove(),this.#zs?.remove(),this.#Vs?.remove(),T.delete(this.#We)}}const O='[data-hygular], [data-hygular-toggle="popover"]';function M(e){return e.getAttribute("data-hygular")||("popover"===e.getAttribute("data-hygular-toggle")?"popover":null)}return class{#ce=!1;#Ws=new Map;constructor(e={}){"undefined"!=typeof window&&"undefined"!=typeof document&&(e.debug&&n.enable(),this.registry={delegate:{navbar:u.navbar,collapse:u.collapse,dropdown:u.dropdown,drawer:u.drawer,accordion:u.accordion,alert:u.alert,form:S.init},lazy:{swiper:u.swiper,badge:u.badge,tabview:u.tabview,tooltip:e=>new w(e),popover:e=>new x(e),range:e=>new D(e)}},this.config=e,m(e),this.modal=y,this.toast=k,this.carousel=v,this.alert={create:b.create},this.darkMode=A,this.select=E,this.skeleton=L,this.tooltip=w,this.popover=x,this.form=S,this.range=D,this.componentInstances=new Set,this.loadedComponents=new WeakSet,this.observer=this.setupObserver(),this.mutationObserver=this.setupMutationObserver(),this.startObserving(document.body),this.init())}init(){if(this.#ce||"undefined"==typeof document)return;const e=this.disposeMap,t=new Map;try{for(const e in this.registry.delegate){const s=this.registry.delegate[e]?.();if("function"==typeof s&&t.set(`delegate:${e}`,s),this.#ce)return void t.forEach(e=>e())}}catch(e){throw t.forEach(e=>e()),e}this.disposeMap=t,e?.forEach(e=>e()),document.querySelectorAll(O).forEach(e=>{const t=M(e);this.registry.lazy[t]&&this.observeElement(e)}),document.querySelectorAll("img[data-src]").forEach(e=>this.observeElement(e))}setupObserver(){return new IntersectionObserver(e=>{this.#ce||e.forEach(e=>{if(e.isIntersecting&&!this.loadedComponents.has(e.target)){const t=e.target;if("IMG"===t.tagName&&t.dataset.src)return C.load(t),this.loadedComponents.add(t),void this.observer.unobserve(t);if(t.FnCallback&&"function"==typeof t.FnCallback)return t.FnCallback(t),this.loadedComponents.add(t),void this.observer.unobserve(t);this.handleVisibleComponent(e.target),this.observer.unobserve(e.target)}})},{rootMargin:"100px 0px",threshold:.1})}setupMutationObserver(){return new MutationObserver(e=>{this.#ce||(e.some(e=>e.removedNodes.length)&&this.#Ws.forEach((e,t)=>{t.isConnected||(e.dispose(),this.componentInstances.delete(e),this.loadedComponents.delete(t),this.#Ws.delete(t))}),e.forEach(e=>{e.addedNodes.forEach(e=>{if(1===e.nodeType&&!this.loadedComponents.has(e)){if(e.matches(O)){const t=M(e);this.registry.lazy[t]&&this.observeElement(e)}"IMG"===e.tagName&&e.dataset.src&&this.observeElement(e),e.querySelectorAll?.(O).forEach(e=>{if(!this.loadedComponents.has(e)){const t=M(e);this.registry.lazy[t]&&this.observeElement(e)}}),e.querySelectorAll?.("img[data-src]").forEach(e=>{this.loadedComponents.has(e)||this.observeElement(e)})}})}))})}handleVisibleComponent(e){const t=M(e);this.initializeComponent(t,e)}initializeComponent(e,t){if(this.#ce)return null;if(this.loadedComponents.has(t))return this.#Ws.get(t)??null;const s=this.registry.lazy[e];if("function"==typeof s){const e=s(t);return e&&"function"==typeof e.dispose&&(this.componentInstances.add(e),this.#Ws.set(t,e)),this.loadedComponents.add(t),e}return console.error(`Hygular: lazy component not found: ${e}`),null}observeElement(e){this.#ce||this.loadedComponents.has(e)||this.observer.observe(e)}startObserving(e){e&&this.mutationObserver.observe(e,{childList:!0,subtree:!0})}dispose(){this.#ce||(this.#ce=!0,this.observer?.disconnect(),this.mutationObserver?.disconnect(),this.disposeMap?.forEach(e=>e()),this.disposeMap?.clear(),this.componentInstances?.forEach(e=>{e.dispose?.()}),this.componentInstances?.clear(),this.#Ws.clear(),this.loadedComponents=null)}}});
|
|
8
8
|
//# sourceMappingURL=hygular.min.js.map
|