vrembem 4.0.0-next.30 → 4.0.0-next.32

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.
@@ -1,10 +1,10 @@
1
- (function(S,A){typeof exports=="object"&&typeof module<"u"?A(exports):typeof define=="function"&&define.amd?define(["exports"],A):(S=typeof globalThis<"u"?globalThis:S||self,A(S.vrembem={}))})(this,function(S){"use strict";var Re=S=>{throw TypeError(S)};var De=(S,A,O)=>A.has(S)||Re("Cannot "+O);var w=(S,A,O)=>(De(S,A,"read from private field"),O?O.call(S):A.get(S)),L=(S,A,O)=>A.has(S)?Re("Cannot add the same private member more than once"):A instanceof WeakSet?A.add(S):A.set(S,O),C=(S,A,O,yt)=>(De(S,A,"write to private field"),yt?yt.call(S,O):A.set(S,O),O);var M,ct,q,tt,ft,ut,dt,ht,gt,mt,pt,F,j,wt;function A(t){return t.split("-").map((e,i)=>i===0?e:e.charAt(0).toUpperCase()+e.slice(1)).join("")}function O(t){return t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function yt(t){if(typeof t=="number")return t;const e=parseFloat(t);if(!Number.isNaN(e)){const i=t.includes("ms");return e*(i?1:1e3)}throw new Error(`Could not convert value to milliseconds: ${t}`)}function Pt(){return getComputedStyle(document.body).getPropertyValue("--vb-prefix").trim()}function se(t,e){const i={fallback:null,element:document.body,...e};if(t.slice(0,2)!=="--"){const n=Pt();n&&(t=`${n}${t}`),t=`--${t}`}const s=getComputedStyle(i.element).getPropertyValue(t).trim();if(s)return s;if(i.fallback)return i.fallback;throw new Error(`CSS variable "${t}" was not found!`)}function ne(t,e="config"){const s=(t.getAttribute(`data-${e}`)||"").replace(/'/g,'"');return s?JSON.parse(s):{}}function oe(t){const e=getComputedStyle(t.el),i={},s=t.getSetting("customProps");for(let n=0;n<s.length;n++){const o=Pt(),r=t.context.module.toLowerCase(),l=O(s[n]),a=e.getPropertyValue(`--${o}${r}-${l}`).trim();a&&(i[l]=a)}return i}function re(t){return typeof t=="string"?document.getElementById(t):t instanceof HTMLElement?t:null}function Me(t,e,i="camel"){return e=i==="camel"?A(e):O(e),t.split(".").concat(e).reduce((s,n)=>s==null?void 0:s[n],this)}function le(t,e={}){const{fallback:i,props:s=["dataConfig","customProps","settings","context.settings"]}=e;for(const n of s){const o=n!=="customProps"?"camel":"kebab",r=Me.call(this,n,t,o);if(r!==void 0)return r}if(i!==void 0)return i;throw new Error(`${this.context.module} setting does not exist: ${t}`)}async function $(t,...e){t in this&&typeof this[t]=="function"&&await this[t](...e)}function xt(t,e,i,s,n=0){return new Promise(o=>{t.classList.remove(e),t.classList.add(i),setTimeout(()=>{t.classList.add(s),t.classList.remove(i),o(t)},yt(n))})}function Fe(t,e){e&&document.querySelectorAll(e).forEach(s=>{t?s.style.overflow="hidden":s.style.removeProperty("overflow")})}function Ie(t,e){e&&document.querySelectorAll(e).forEach(s=>{t?(s.inert=!0,s.setAttribute("aria-hidden",!0)):(s.inert=null,s.removeAttribute("aria-hidden"))})}function vt(t,e,i){Ie(!!t,e),Fe(!!t,i)}class ae{constructor(e,i){L(this,M);this.value=e,C(this,M,i),this.mql=null}get handler(){return w(this,M)}set handler(e){this.mql&&this.mql.removeEventListener("change",w(this,M)),C(this,M,e)}mount(e,i){return e&&(this.value=e),i&&C(this,M,i),this.value?(this.mql=window.matchMedia(`(min-width: ${this.value})`),this.mql.addEventListener("change",w(this,M)),w(this,M).call(this,this.mql),this):this}unmount(){return this.mql?(this.mql.removeEventListener("change",w(this,M)),this.value=null,C(this,M,null),this.mql=null,this):this}}M=new WeakMap;class Rt{constructor(e={}){this.module=this.constructor.name,this.collection=[],this.settings=Object.assign({dataConfig:"config",customProps:[],teleport:null,teleportMethod:"append"},e)}get(e,i="id"){return this.collection.find(s=>s[i]===e)}applySettings(e){return Object.assign(this.settings,e)}async createEntry(e,i){return new St(this,e,i)}async register(e,i={}){await this.deregister((e==null?void 0:e.id)||e,!0);const s=await this.createEntry(e,i);return await s.mount(),await $.call(this,"beforeRegister",s),await $.call(s,"beforeRegister"),this.collection.push(s),await $.call(s,"afterRegister"),await $.call(this,"afterRegister",s),s}async deregister(e,i=!1){const s=this.collection.findIndex(n=>n.id===e);if(~s){const n=this.collection[s];await n.unmount(i),await $.call(this,"beforeDeregister",n),await $.call(n,"beforeDeregister",i),Object.getOwnPropertyNames(n).forEach(o=>{o!="beforeDeregister"&&o!="afterDeregister"&&delete n[o]}),this.collection.splice(s,1),await $.call(n,"afterDeregister",i),await $.call(this,"afterDeregister",n)}return this.collection}async mount(e={}){this.applySettings(e),await $.call(this,"beforeMount");const i=document.querySelectorAll(this.settings.selector);for(const s of i)await this.register(s);return await $.call(this,"afterMount"),this}async unmount(){for(await $.call(this,"beforeUnmount");this.collection.length>0;)await this.deregister(this.collection[0].id);return await $.call(this,"afterUnmount"),this}}class St{constructor(e,i,s={}){this.context=e,this.id=(i==null?void 0:i.id)||i,this.el=re(i),this.settings=Object.assign({},s),this.dataConfig={},this.customProps={},this.returnRef=null}applySettings(e){return Object.assign(this.settings,e)}getDataConfig(){return Object.assign(this.dataConfig,ne(this.el,this.getSetting("dataConfig")))}getCustomProps(){return Object.assign(this.customProps,oe(this))}getSetting(e,i={}){return le.call(this,e,i)}async mount(e={}){if(this.el===null)throw new Error(`${this.context.module} element was not found with ID: "${this.id}"`);this.applySettings(e),this.getDataConfig(),this.getCustomProps(),await $.call(this,"beforeMount"),this.getSetting("teleport")&&this.teleport(),await $.call(this,"afterMount")}async unmount(e=!1){await $.call(this,"beforeUnmount",e),this.getSetting("teleport")&&this.teleportReturn(),await $.call(this,"afterUnmount",e)}teleport(e=this.getSetting("teleport"),i=this.getSetting("teleportMethod")){return this.returnRef?(console.error("Element has already been teleported:",this.el),!1):(this.returnRef=Wt(this.el,e,i),this.el)}teleportReturn(){return this.returnRef?(this.returnRef=Wt(this.el,this.returnRef),this.el):(console.error("No return reference found:",this.el),!1)}}class _t{constructor(e=null,i="[data-focus]"){L(this,ct);L(this,q);L(this,tt);this.el=e,this.selectorFocus=i,C(this,q,Be.bind(this)),C(this,tt,Ve.bind(this))}get focusable(){return w(this,ct)}set focusable(e){C(this,ct,e),w(this,ct).length?(document.removeEventListener("keydown",w(this,tt)),document.addEventListener("keydown",w(this,q))):(document.removeEventListener("keydown",w(this,q)),document.addEventListener("keydown",w(this,tt)))}get focusableFirst(){return this.focusable[0]}get focusableLast(){return this.focusable[this.focusable.length-1]}mount(e,i){e&&(this.el=e),i&&(this.selectorFocus=i),this.focusable=this.getFocusable(),this.focus()}unmount(){this.el=null,this.focusable=[],document.removeEventListener("keydown",w(this,q)),document.removeEventListener("keydown",w(this,tt))}focus(e=this.el,i=this.selectorFocus){(e.querySelector(i)||e).focus()}getFocusable(e=this.el){const i=[],s=document.activeElement,n=e.scrollTop,o=Ne.join(",");return e.querySelectorAll(o).forEach(l=>{l.focus(),document.activeElement===l&&i.push(l)}),e.scrollTop=n,s.focus(),i}}ct=new WeakMap,q=new WeakMap,tt=new WeakMap;const T=":not([inert])",P=':not([tabindex^="-"])',Et=":not(:disabled)",Ne=[`a[href]${T}${P}`,`area[href]${T}${P}`,`input:not([type="hidden"]):not([type="radio"])${T}${P}${Et}`,`input[type="radio"]${T}${P}${Et}`,`select${T}${P}${Et}`,`textarea${T}${P}${Et}`,`button${T}${P}${Et}`,`details${T} > summary:first-of-type${P}`,`iframe${T}${P}`,`audio[controls]${T}${P}`,`video[controls]${T}${P}`,`[contenteditable]${T}${P}`,`[tabindex]${T}${P}`];function Be(t){(t.key==="Tab"||t.keyCode===9)&&(t.shiftKey?(document.activeElement===this.focusableFirst||document.activeElement===this.el)&&(t.preventDefault(),this.focusableLast.focus()):(document.activeElement===this.focusableLast||document.activeElement===this.el)&&(t.preventDefault(),this.focusableFirst.focus()))}function Ve(t){(t.key==="Tab"||t.keyCode===9)&&t.preventDefault()}function zt(t,e=!0){const i=localStorage.getItem(t),s=i?JSON.parse(i):{};return{get(n){return n?s[n]:s},set(n,o){return o?s[n]=o:delete s[n],e&&localStorage.setItem(t,JSON.stringify(s)),s}}}function Wt(t,e,i){const s=e.nodeType===Node.COMMENT_NODE,n=e.nodeType===Node.ELEMENT_NODE;if(e=s||n?e:document.querySelector(e),s&&(i="after"),!e)throw new Error(`Not a valid teleport reference: '${e}'`);if(typeof e[i]!="function")throw new Error(`Not a valid teleport method: '${i}'`);let o=null;return s||(o=document.createComment("teleported #"+t.id),t.before(o)),e[i](t),s&&e.remove(),o}function He(t){const e={prefix:se("prefix-themes",{fallback:"vb-theme-"}),themes:["root","light","dark"],storeKey:"VB:Profile"};for(const[o]of Object.entries(e))t&&t[o]&&(e[o]=t[o]);const i={onInit(){},onChange(){}};for(const[o]of Object.entries(i))t&&t[o]&&(i[o]=t[o]);const s=zt(e.storeKey),n={settings:e,add(o){e.themes.push(o)},remove(o){const r=e.themes.indexOf(o);~r&&e.themes.splice(r,1)},callback(o){i[o].call(this)},get class(){return`${e.prefix}${this.theme}`},get classes(){return e.themes.map(o=>`${e.prefix}${o}`)},get themes(){return e.themes},get theme(){return s.get("theme")||"root"},set theme(o){e.themes.includes(o)?this.theme!=o&&(s.set("theme",o),document.documentElement.classList.remove(...this.classes),document.documentElement.classList.add(`${e.prefix}${o}`),this.callback("onChange")):console.error(`Not a valid theme value: "${o}"`)}};return n.callback("onInit"),n}const _e=Object.freeze(Object.defineProperty({__proto__:null,Breakpoint:ae,Collection:Rt,CollectionEntry:St,FocusTrap:_t,cssVar:se,getConfig:ne,getCustomProps:oe,getElement:re,getPrefix:Pt,getSetting:le,lifecycleHook:$,localStore:zt,setGlobalState:vt,teleport:Wt,themeStore:He,toCamel:A,toKebab:O,toMilliseconds:yt,transition:xt},Symbol.toStringTag,{value:"Module"})),ze={dataOpen:"drawer-open",dataClose:"drawer-close",dataToggle:"drawer-toggle",dataBreakpoint:"drawer-breakpoint",selector:".drawer",selectorDialog:".drawer__dialog",selectorScreen:".drawer",selectorFocus:"[data-focus]",selectorInert:null,selectorOverflow:"body",stateOpened:"is-opened",stateOpening:"is-opening",stateClosing:"is-closing",stateClosed:"is-closed",classModal:"drawer_modal",customProps:["transition-duration"],breakpoints:null,customEventPrefix:"drawer:",store:!0,storeKey:"VB:DrawerState",setTabindex:!0,teleport:null,teleportMethod:"prepend",transition:!0,transitionDuration:300};function We(t){t.store==="opened"?t.open(!1,!1):t.store==="closed"?t.close(!1,!1):t.store==="indeterminate"?t.state="indeterminate":t.el.classList.contains(t.getSetting("stateOpened"))?t.open(!1,!1):t.el.classList.contains(t.getSetting("stateClosed"))?t.close(!1,!1):t.state="indeterminate"}async function Ue(t){t.store==="opened"?await t.open(!1,!1):t.store==="closed"?await t.close(!1,!1):t.store==="indeterminate"?t.state!="indeterminate"&&(t.state="indeterminate"):(t.state!=t.inlineState&&(t.state=t.inlineState),t.inlineState==="opened"?await t.open(!1,!1):t.inlineState==="closed"&&await t.close(!1,!1))}function je(t){const e=Pt(),i=t.getAttribute(`data-${this.settings.dataBreakpoint}`);return this.settings.breakpoints&&this.settings.breakpoints[i]?this.settings.breakpoints[i]:getComputedStyle(document.body).getPropertyValue(`--${e}breakpoint-${i}`).trim()?getComputedStyle(document.body).getPropertyValue(`--${e}breakpoint-${i}`).trim():i}function nt(t){const e=typeof t=="string"?this.get(t):t;if(e)return e;throw new Error(`Drawer not found in collection with id of "${t.id||t}".`)}function ce(t){t.state==="opened"?t.mode==="modal"?this.focusTrap.mount(t.dialog,this.settings.selectorFocus):this.focusTrap.focus(t.dialog,this.settings.selectorFocus):(t.trigger&&(t.trigger.focus(),t.trigger=null),this.focusTrap.unmount())}function Ke(t){switch(t.mode){case"inline":return Xe.call(this,t);case"modal":return Ye.call(this,t);default:throw new Error(`"${t.mode}" is not a valid drawer mode.`)}}async function Xe(t){return t.el.classList.remove(t.getSetting("classModal")),t.dialog.removeAttribute("aria-modal"),vt(!1,t.getSetting("selectorInert"),t.getSetting("selectorOverflow")),this.focusTrap.unmount(),await Ue(t),t.el.dispatchEvent(new CustomEvent(t.getSetting("customEventPrefix")+"switchMode",{detail:this,bubbles:!0})),t}async function Ye(t){return t.el.classList.add(t.getSetting("classModal")),t.dialog.setAttribute("aria-modal","true"),await t.close(!1,!1),t.el.dispatchEvent(new CustomEvent(t.getSetting("customEventPrefix")+"switchMode",{detail:this,bubbles:!0})),t}class Ge extends St{constructor(i,s,n={}){super(i,s,n);L(this,ft);L(this,ut);L(this,dt);this.dialog=null,this.trigger=null,C(this,dt,new ae),C(this,ft,"indeterminate"),C(this,ut,"indeterminate"),this.inlineState="indeterminate"}get breakpoint(){return je.call(this.context,this.el)}get store(){return this.context.store.get(this.id)}get mode(){return w(this,ft)}set mode(i){C(this,ft,i),Ke.call(this.context,this)}get state(){return w(this,ut)}set state(i){C(this,ut,i),this.mode==="inline"&&i!="opening"&&i!="closing"&&(this.inlineState=i,this.getSetting("store")&&this.context.store.set(this.id,i)),i==="indeterminate"&&(this.el.classList.remove(this.getSetting("stateOpened")),this.el.classList.remove(this.getSetting("stateOpening")),this.el.classList.remove(this.getSetting("stateClosed")),this.el.classList.remove(this.getSetting("stateClosing")))}async open(i,s){return this.context.open(this,i,s)}async close(i,s){return this.context.close(this,i,s)}async toggle(i,s){return this.context.toggle(this,i,s)}async deregister(){return this.context.deregister(this.id)}mountBreakpoint(){const i=this.breakpoint,s=this.handleBreakpoint.bind(this);w(this,dt).mount(i,s)}unmountBreakpoint(){w(this,dt).unmount()}handleBreakpoint(i){const s=i.matches?"inline":"modal";this.mode!=s&&(this.mode=s)}async beforeMount(){const i=this.el.querySelector(this.getSetting("selectorDialog"));this.dialog=i||this.el,this.getSetting("setTabindex")&&this.dialog.setAttribute("tabindex","-1"),We(this),this.inlineState=this.state,this.mode=this.el.classList.contains(this.getSetting("classModal"))?"modal":"inline",this.breakpoint&&this.mountBreakpoint()}async beforeUnmount(i=!0){i&&this.state==="opened"&&await this.close(!1),this.context.store.set(this.id),this.unmountBreakpoint()}}ft=new WeakMap,ut=new WeakMap,dt=new WeakMap;async function Je(t){const e=t.target.closest(`
2
- [data-${this.settings.dataOpen}],
3
- [data-${this.settings.dataToggle}],
4
- [data-${this.settings.dataClose}]
5
- `);if(e){t.preventDefault(),e.matches(`[data-${this.settings.dataToggle}]`)&&e.getAttribute(`data-${this.settings.dataToggle}`).trim().split(" ").forEach(s=>{const n=nt.call(this,s);return n.trigger=e,n.toggle()}),e.matches(`[data-${this.settings.dataOpen}]`)&&e.getAttribute(`data-${this.settings.dataOpen}`).trim().split(" ").forEach(s=>{const n=nt.call(this,s);return n.trigger=e,n.open()}),e.matches(`[data-${this.settings.dataClose}]`)&&e.getAttribute(`data-${this.settings.dataClose}`).trim().split(" ").forEach(s=>{if(s){const n=nt.call(this,s);return n.trigger=e,n.close()}else{const n=t.target.closest(this.settings.selector);if(n)return this.close(n.id)}});return}if(this.activeModal&&t.target.matches(this.settings.selectorScreen))return this.close(this.activeModal.id)}function Ze(t){if(t.key==="Escape"&&this.activeModal)return this.close(this.activeModal.id)}async function fe(t,e,i=!0){const s=nt.call(this,t);return(s.state==="closed"||s.state==="indeterminate")&&(s.state="opening",e??s.getSetting("transition")?await xt(s.el,s.getSetting("stateClosed"),s.getSetting("stateOpening"),s.getSetting("stateOpened"),s.getSetting("transitionDuration")):(s.el.classList.add(s.getSetting("stateOpened")),s.el.classList.remove(s.getSetting("stateClosed"))),s.state="opened",s.mode==="modal"&&vt(!0,s.getSetting("selectorInert"),s.getSetting("selectorOverflow")),i&&ce.call(this,s),s.el.dispatchEvent(new CustomEvent(s.getSetting("customEventPrefix")+"opened",{detail:this,bubbles:!0}))),s}async function ue(t,e,i=!0){const s=nt.call(this,t);return(s.state==="opened"||s.state==="indeterminate")&&(s.state="closing",document.activeElement.blur(),e??s.getSetting("transition")?await xt(s.el,s.getSetting("stateOpened"),s.getSetting("stateClosing"),s.getSetting("stateClosed"),s.getSetting("transitionDuration")):(s.el.classList.add(s.getSetting("stateClosed")),s.el.classList.remove(s.getSetting("stateOpened"))),s.state="closed",s.mode==="modal"&&vt(!1,s.getSetting("selectorInert"),s.getSetting("selectorOverflow")),i&&ce.call(this,s),s.el.dispatchEvent(new CustomEvent(s.getSetting("customEventPrefix")+"closed",{detail:this,bubbles:!0}))),s}async function Qe(t,e,i){const s=nt.call(this,t);return s.state==="closed"?fe.call(this,s,e,i):ue.call(this,s,e,i)}class qe extends Rt{constructor(i){super({...ze,...i});L(this,ht);L(this,gt);this.focusTrap=new _t,C(this,ht,Je.bind(this)),C(this,gt,Ze.bind(this)),this.store=zt(this.settings.storeKey,this.settings.store)}get activeModal(){return this.collection.find(i=>i.state==="opened"&&i.mode==="modal")}async createEntry(i,s){return new Ge(this,i,s)}async open(i,s,n){return fe.call(this,i,s,n)}async close(i,s,n){return ue.call(this,i,s,n)}async toggle(i,s,n){return Qe.call(this,i,s,n)}async afterMount(){document.addEventListener("click",w(this,ht),!1),document.addEventListener("keydown",w(this,gt),!1)}async beforeUnmount(){this.trigger=null}async afterUnmount(){document.removeEventListener("click",w(this,ht),!1),document.removeEventListener("keydown",w(this,gt),!1)}}ht=new WeakMap,gt=new WeakMap;const ti={dataOpen:"modal-open",dataClose:"modal-close",dataReplace:"modal-replace",selector:".modal",selectorDialog:".modal__dialog",selectorScreen:".modal",selectorRequired:'[role="alertdialog"]',selectorFocus:"[data-focus]",selectorInert:null,selectorOverflow:"body",stateOpened:"is-opened",stateOpening:"is-opening",stateClosing:"is-closing",stateClosed:"is-closed",customProps:["transition-duration"],customEventPrefix:"modal:",setTabindex:!0,teleport:null,teleportMethod:"append",transition:!0,transitionDuration:300};class ei extends St{constructor(e,i,s={}){super(e,i,s),this.state="closed",this.dialog=null}get isRequired(){return this.dialog.matches(this.getSetting("selectorRequired"))}async open(e,i){return this.context.open(this,e,i)}async close(e,i){return this.context.close(this,e,i)}async replace(e,i){return this.context.replace(this,e,i)}async deregister(){return this.context.deregister(this.id)}async beforeMount(){const e=this.el.querySelector(this.getSetting("selectorDialog"));this.dialog=e||this.el,this.dialog.setAttribute("aria-modal","true"),this.dialog.hasAttribute("role")||this.dialog.setAttribute("role","dialog"),this.getSetting("setTabindex")&&this.dialog.setAttribute("tabindex","-1")}async afterRegister(){this.el.classList.contains(this.getSetting("stateOpened"))?await this.open(!1):(this.el.classList.remove(this.getSetting("stateOpening")),this.el.classList.remove(this.getSetting("stateClosing")),this.el.classList.add(this.getSetting("stateClosed")))}async beforeUnmount(e=!1){!e&&this.state==="opened"?await this.close(!1):this.context.stack.remove(this)}}function Ct(t){const e=typeof t=="string"?this.get(t):this.get(t.id);if(e)return e;throw new Error(`Modal not found in collection with id of "${t.id||t}".`)}function Dt(){this.active?this.focusTrap.mount(this.active.dialog,this.settings.selectorFocus):(this.trigger&&(this.trigger.focus(),this.trigger=null),this.focusTrap.unmount())}async function ii(t){const e=t.target.closest(`
6
- [data-${this.settings.dataOpen}],
7
- [data-${this.settings.dataReplace}],
8
- [data-${this.settings.dataClose}]
9
- `);if(e){if(t.preventDefault(),e.matches(`[data-${this.settings.dataOpen}]`)){const i=e.getAttribute(`data-${this.settings.dataOpen}`).trim(),s=Ct.call(this,i);return t.target.closest(this.settings.selector)||(this.trigger=e),s.open()}if(e.matches(`[data-${this.settings.dataReplace}]`)){const i=e.getAttribute(`data-${this.settings.dataReplace}`).trim(),s=Ct.call(this,i);return t.target.closest(this.settings.selector)||(this.trigger=e),s.replace()}if(e.matches(`[data-${this.settings.dataClose}]`)){const i=e.getAttribute(`data-${this.settings.dataClose}`).trim();return i==="*"?this.closeAll():this.close(i)}}if(this.active&&t.target.matches(this.settings.selectorScreen)&&!this.active.isRequired)return this.close(this.active.id)}function si(t){if(t.key==="Escape"&&this.active&&!this.active.dialog.matches(this.settings.selectorRequired))return this.close()}async function de(t,e=void 0,i=!0){const s=Ct.call(this,t);return this.stack.moveToTop(s),s.state==="closed"&&(s.state="opening",this.stack.add(s),e??s.getSetting("transition")?await xt(s.el,s.getSetting("stateClosed"),s.getSetting("stateOpening"),s.getSetting("stateOpened"),s.getSetting("transitionDuration")):(s.el.classList.add(s.getSetting("stateOpened")),s.el.classList.remove(s.getSetting("stateClosed"))),s.state="opened"),i&&Dt.call(this),s.el.dispatchEvent(new CustomEvent(s.getSetting("customEventPrefix")+"opened",{detail:this,bubbles:!0})),s}async function he(t,e,i=!0){const s=t?Ct.call(this,t):this.active;return s&&s.state==="opened"&&(s.state="closing",document.activeElement.blur(),e??s.getSetting("transition")?await xt(s.el,s.getSetting("stateOpened"),s.getSetting("stateClosing"),s.getSetting("stateClosed"),s.getSetting("transitionDuration")):(s.el.classList.add(s.getSetting("stateClosed")),s.el.classList.remove(s.getSetting("stateOpened"))),this.stack.remove(s),s.state="closed",i&&Dt.call(this),s.el.dispatchEvent(new CustomEvent(s.getSetting("customEventPrefix")+"closed",{detail:this,bubbles:!0}))),s}async function Ut(t,e){const i=[];return await Promise.all(this.stack.value.map(async s=>{t&&t===s.id?Promise.resolve():i.push(await he.call(this,s,e,!1)),s.trigger=null})),i}async function ni(t,e,i=!0){const s=Ct.call(this,t);let n,o;return s.state==="opened"?(n=s,o=await Ut.call(this,s.id,e)):(o=Ut.call(this,!1,e),n=de.call(this,s,e,!1),await Promise.all([n,o])),i&&Dt.call(this),{opened:n,closed:o}}function oi(t){const e=[];return{get value(){return[...e]},get top(){const i=e[e.length-1];return i||null},updateIndex(){e.forEach((i,s)=>{i.el.style.zIndex=null;const n=getComputedStyle(i.el)["z-index"];i.el.style.zIndex=parseInt(n)+s+1})},setGlobalState(){vt(this.top,t.selectorInert,t.selectorOverflow),this.updateIndex()},add(i){i.el.style.zIndex=null;const s=getComputedStyle(i.el)["z-index"];i.el.style.zIndex=parseInt(s)+e.length+1,e.push(i),this.setGlobalState()},remove(i){const s=e.findIndex(n=>n.id===i.id);s>=0&&(i.el.style.zIndex=null,e.splice(s,1),this.setGlobalState())},moveToTop(i){const s=e.findIndex(n=>n.id===i.id);s>=0&&(e.splice(s,1),this.add(i))}}}class ri extends Rt{constructor(i){super({...ti,...i});L(this,mt);L(this,pt);this.trigger=null,this.focusTrap=new _t,C(this,mt,ii.bind(this)),C(this,pt,si.bind(this)),this.stack=oi(this.settings)}get active(){return this.stack.top}async createEntry(i,s){return new ei(this,i,s)}async open(i,s,n){return de.call(this,i,s,n)}async close(i,s,n){return he.call(this,i,s,n)}async replace(i,s,n){return ni.call(this,i,s,n)}async closeAll(i=!1,s,n=!0){const o=await Ut.call(this,i,s);return n&&Dt.call(this),o}async afterMount(){document.addEventListener("click",w(this,mt),!1),document.addEventListener("keydown",w(this,pt),!1)}async beforeUnmount(){this.trigger=null}async afterUnmount(){document.removeEventListener("click",w(this,mt),!1),document.removeEventListener("keydown",w(this,pt),!1)}}mt=new WeakMap,pt=new WeakMap;const li={selector:".popover",selectorTooltip:".popover_tooltip",selectorArrow:".popover__arrow",stateActive:"is-active",customProps:["placement","event","offset","flip-padding","shift-padding","arrow-padding","toggle-delay"],placement:"bottom",event:"click",offset:0,flipPadding:0,shiftPadding:0,arrowPadding:0,toggleDelay:0,teleport:null,teleportMethod:"append"};function ge(t,e,i){Object.assign(t.style,{left:e!=null?`${e}px`:"",top:i!=null?`${i}px`:""})}function me(t,e){let i=t.getSetting("toggle-delay");typeof i=="string"&&(i.indexOf(",")>-1&&(i=i.split(",")),i.indexOf(" ")>-1&&(i=i.split(" "))),Array.isArray(i)&&(i=i[e]);const s=Number(i);if(Number.isNaN(s))throw new Error(`Provided delay value is not a number: "${i}"`);return s}function jt(t){let e;const i=typeof t=="string"?t.trim().split(" "):[t];for(let s=0;s<i.length;s++)i[s]=Number(i[s]);switch(i.length){case 1:e=i[0];break;case 2:e={top:i[0],right:i[1],bottom:i[0],left:i[1]};break;case 3:e={top:i[0],right:i[1],bottom:i[2],left:i[1]};break;case 4:e={top:i[0],right:i[1],bottom:i[2],left:i[3]};break;default:e=!1;break}return e}function ai(t){return{offset:Number(t.getSetting("offset")),flip:{padding:jt(t.getSetting("flip-padding"))},shift:{padding:jt(t.getSetting("shift-padding"))},arrow:{element:t.getSetting("selectorArrow"),padding:jt(t.getSetting("arrow-padding"))}}}function pe(t){const e=typeof t=="string"?this.get(t):this.get(t.id);if(e)return e;throw new Error(`Popover not found in collection with id of "${t}".`)}async function we(t){const e=t?pe.call(this,t):await be.call(this);return e&&e.state==="opened"&&(e.el.inert=!0,e.el.classList.remove(this.settings.stateActive),e.isTooltip||e.trigger.setAttribute("aria-expanded","false"),e.floatingCleanup(),e.state="closed",e.trigger===this.trigger&&(this.trigger=null)),e}async function be(){const t=[];return await Promise.all(this.collection.map(async e=>{e.state==="opened"&&t.push(await we.call(this,e))})),t}function ye(t){t.state=="opened"&&setTimeout(()=>{const e=t.el.matches(":hover")===t.el||t.trigger.matches(":hover")===t.trigger;let i=document.activeElement.closest(`#${t.id}, [aria-controls="${t.id}"], [aria-describedby="${t.id}"]`);return i=i?i.matches(":focus-visible"):!1,!e&&!i&&t.close(),t},1)}function ci(t){t.state==="opened"?t.close():(this.trigger=t.trigger,t.open())}function fi(t){t.isTooltip&&(t.toggleDelayId&&clearTimeout(t.toggleDelayId),t.close())}function ui(t,e){if(t.isHovered=e,e.type=="focus"&&!t.trigger.matches(":focus-visible"))return;t.toggleDelayId&&clearTimeout(t.toggleDelayId);const i=t.trigger.getAttribute("aria-expanded");if(i&&i=="true")return;const s=this.activeHover?0:me(t,0);this.activeHover&&this.activeHover.close(),t.toggleDelayId=setTimeout(()=>{t.id&&t.open()},s)}function di(t,e){setTimeout(()=>{t.isHovered=e,!t.isHovered&&(t.toggleDelayId&&clearTimeout(t.toggleDelayId),t.toggleDelayId=setTimeout(()=>{ye.call(this,t)},me(t,1)))},1)}function hi(t){switch(t.key){case"Escape":this.trigger&&this.trigger.focus(),be.call(this);return;case"Tab":this.collection.forEach(e=>{ye.call(this,e)});return;default:return}}function gi(t){const e=this;document.addEventListener("click",function i(s){s.target.closest(`#${t.id}, [aria-controls="${t.id}"], [aria-describedby="${t.id}"]`)?t.el&&!t.el.classList.contains(e.settings.stateActive)&&this.removeEventListener("click",i):(t.el&&t.el.classList.contains(e.settings.stateActive)&&t.close(),this.removeEventListener("click",i))})}class mi extends St{constructor(i,s,n={}){super(i,s,n);L(this,F);L(this,j);this.state="closed",this.toggleDelayId=null,this.trigger=null,C(this,F,null),C(this,j,{el:!1,trigger:!1}),this.floatingCleanup=()=>{}}get isTooltip(){return!!this.el.closest(this.getSetting("selectorTooltip"))||this.el.getAttribute("role")=="tooltip"}get isHovered(){return w(this,j).el||w(this,j).trigger}set isHovered(i){const s=i.type=="mouseenter"?!0:i.type=="mouseleave"?!1:void 0;if(s!=null)switch(i.target){case this.el:w(this,j).el=s;break;case this.trigger:w(this,j).trigger=s;break}}async open(){return this.context.open(this)}async close(){return this.context.close(this)}async deregister(){return this.context.deregister(this.id)}registerEventListeners(){w(this,F)||(this.getSetting("event")==="hover"?(C(this,F,[{el:["el","trigger"],type:["mouseenter","focus"],listener:ui.bind(this.context,this)},{el:["el","trigger"],type:["mouseleave","focusout"],listener:di.bind(this.context,this)},{el:["trigger"],type:["click"],listener:fi.bind(this.context,this)}]),w(this,F).forEach(s=>{s.el.forEach(n=>{s.type.forEach(o=>{this[n].addEventListener(o,s.listener,!1)})})})):(C(this,F,[{el:["trigger"],type:["click"],listener:ci.bind(this.context,this)}]),w(this,F).forEach(s=>{s.el.forEach(n=>{s.type.forEach(o=>{this[n].addEventListener(o,s.listener,!1)})})})))}deregisterEventListeners(){w(this,F)&&(w(this,F).forEach(i=>{i.el.forEach(s=>{i.type.forEach(n=>{this[s].removeEventListener(n,i.listener,!1)})})}),C(this,F,null))}async beforeMount(){this.trigger=document.querySelector(`[aria-controls="${this.id}"], [aria-describedby="${this.id}"]`),this.isTooltip?(this.settings.event="hover",this.el.setAttribute("role","tooltip")):this.trigger.setAttribute("aria-expanded","false"),this.registerEventListeners()}async afterRegister(){this.el.classList.contains(this.getSetting("stateActive"))?await this.open():this.el.inert=!0}async beforeUnmount(){this.state==="opened"&&await this.close(),this.floatingCleanup(),this.deregisterEventListeners()}}F=new WeakMap,j=new WeakMap;const ot=Math.min,G=Math.max,Mt=Math.round,Ft=Math.floor,z=t=>({x:t,y:t}),pi={left:"right",right:"left",bottom:"top",top:"bottom"},wi={start:"end",end:"start"};function Kt(t,e,i){return G(t,ot(e,i))}function J(t,e){return typeof t=="function"?t(e):t}function W(t){return t.split("-")[0]}function At(t){return t.split("-")[1]}function Xt(t){return t==="x"?"y":"x"}function Yt(t){return t==="y"?"height":"width"}function Z(t){return["top","bottom"].includes(W(t))?"y":"x"}function Gt(t){return Xt(Z(t))}function bi(t,e,i){i===void 0&&(i=!1);const s=At(t),n=Gt(t),o=Yt(n);let r=n==="x"?s===(i?"end":"start")?"right":"left":s==="start"?"bottom":"top";return e.reference[o]>e.floating[o]&&(r=It(r)),[r,It(r)]}function yi(t){const e=It(t);return[Jt(t),e,Jt(e)]}function Jt(t){return t.replace(/start|end/g,e=>wi[e])}function xi(t,e,i){const s=["left","right"],n=["right","left"],o=["top","bottom"],r=["bottom","top"];switch(t){case"top":case"bottom":return i?e?n:s:e?s:n;case"left":case"right":return e?o:r;default:return[]}}function vi(t,e,i,s){const n=At(t);let o=xi(W(t),i==="start",s);return n&&(o=o.map(r=>r+"-"+n),e&&(o=o.concat(o.map(Jt)))),o}function It(t){return t.replace(/left|right|bottom|top/g,e=>pi[e])}function Si(t){return{top:0,right:0,bottom:0,left:0,...t}}function xe(t){return typeof t!="number"?Si(t):{top:t,right:t,bottom:t,left:t}}function Nt(t){const{x:e,y:i,width:s,height:n}=t;return{width:s,height:n,top:i,left:e,right:e+s,bottom:i+n,x:e,y:i}}function ve(t,e,i){let{reference:s,floating:n}=t;const o=Z(e),r=Gt(e),l=Yt(r),a=W(e),c=o==="y",d=s.x+s.width/2-n.width/2,u=s.y+s.height/2-n.height/2,h=s[l]/2-n[l]/2;let f;switch(a){case"top":f={x:d,y:s.y-n.height};break;case"bottom":f={x:d,y:s.y+s.height};break;case"right":f={x:s.x+s.width,y:u};break;case"left":f={x:s.x-n.width,y:u};break;default:f={x:s.x,y:s.y}}switch(At(e)){case"start":f[r]-=h*(i&&c?-1:1);break;case"end":f[r]+=h*(i&&c?-1:1);break}return f}const Ei=async(t,e,i)=>{const{placement:s="bottom",strategy:n="absolute",middleware:o=[],platform:r}=i,l=o.filter(Boolean),a=await(r.isRTL==null?void 0:r.isRTL(e));let c=await r.getElementRects({reference:t,floating:e,strategy:n}),{x:d,y:u}=ve(c,s,a),h=s,f={},g=0;for(let m=0;m<l.length;m++){const{name:b,fn:p}=l[m],{x:y,y:x,data:E,reset:v}=await p({x:d,y:u,initialPlacement:s,placement:h,strategy:n,middlewareData:f,rects:c,platform:r,elements:{reference:t,floating:e}});d=y??d,u=x??u,f={...f,[b]:{...f[b],...E}},v&&g<=50&&(g++,typeof v=="object"&&(v.placement&&(h=v.placement),v.rects&&(c=v.rects===!0?await r.getElementRects({reference:t,floating:e,strategy:n}):v.rects),{x:d,y:u}=ve(c,h,a)),m=-1)}return{x:d,y:u,placement:h,strategy:n,middlewareData:f}};async function Se(t,e){var i;e===void 0&&(e={});const{x:s,y:n,platform:o,rects:r,elements:l,strategy:a}=t,{boundary:c="clippingAncestors",rootBoundary:d="viewport",elementContext:u="floating",altBoundary:h=!1,padding:f=0}=J(e,t),g=xe(f),b=l[h?u==="floating"?"reference":"floating":u],p=Nt(await o.getClippingRect({element:(i=await(o.isElement==null?void 0:o.isElement(b)))==null||i?b:b.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(l.floating)),boundary:c,rootBoundary:d,strategy:a})),y=u==="floating"?{x:s,y:n,width:r.floating.width,height:r.floating.height}:r.reference,x=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l.floating)),E=await(o.isElement==null?void 0:o.isElement(x))?await(o.getScale==null?void 0:o.getScale(x))||{x:1,y:1}:{x:1,y:1},v=Nt(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:y,offsetParent:x,strategy:a}):y);return{top:(p.top-v.top+g.top)/E.y,bottom:(v.bottom-p.bottom+g.bottom)/E.y,left:(p.left-v.left+g.left)/E.x,right:(v.right-p.right+g.right)/E.x}}const Ci=t=>({name:"arrow",options:t,async fn(e){const{x:i,y:s,placement:n,rects:o,platform:r,elements:l,middlewareData:a}=e,{element:c,padding:d=0}=J(t,e)||{};if(c==null)return{};const u=xe(d),h={x:i,y:s},f=Gt(n),g=Yt(f),m=await r.getDimensions(c),b=f==="y",p=b?"top":"left",y=b?"bottom":"right",x=b?"clientHeight":"clientWidth",E=o.reference[g]+o.reference[f]-h[f]-o.floating[g],v=h[f]-o.reference[f],D=await(r.getOffsetParent==null?void 0:r.getOffsetParent(c));let et=D?D[x]:0;(!et||!await(r.isElement==null?void 0:r.isElement(D)))&&(et=l.floating[x]||o.floating[g]);const Lt=E/2-v/2,it=et/2-m[g]/2-1,K=ot(u[p],it),Ot=ot(u[y],it),st=K,Tt=et-m[g]-Ot,k=et/2-m[g]/2+Lt,bt=Kt(st,k,Tt),_=!a.arrow&&At(n)!=null&&k!==bt&&o.reference[g]/2-(k<st?K:Ot)-m[g]/2<0,H=_?k<st?k-st:k-Tt:0;return{[f]:h[f]+H,data:{[f]:bt,centerOffset:k-bt-H,..._&&{alignmentOffset:H}},reset:_}}}),Ai=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var i,s;const{placement:n,middlewareData:o,rects:r,initialPlacement:l,platform:a,elements:c}=e,{mainAxis:d=!0,crossAxis:u=!0,fallbackPlacements:h,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:m=!0,...b}=J(t,e);if((i=o.arrow)!=null&&i.alignmentOffset)return{};const p=W(n),y=Z(l),x=W(l)===l,E=await(a.isRTL==null?void 0:a.isRTL(c.floating)),v=h||(x||!m?[It(l)]:yi(l)),D=g!=="none";!h&&D&&v.push(...vi(l,m,g,E));const et=[l,...v],Lt=await Se(e,b),it=[];let K=((s=o.flip)==null?void 0:s.overflows)||[];if(d&&it.push(Lt[p]),u){const k=bi(n,r,E);it.push(Lt[k[0]],Lt[k[1]])}if(K=[...K,{placement:n,overflows:it}],!it.every(k=>k<=0)){var Ot,st;const k=(((Ot=o.flip)==null?void 0:Ot.index)||0)+1,bt=et[k];if(bt)return{data:{index:k,overflows:K},reset:{placement:bt}};let _=(st=K.filter(H=>H.overflows[0]<=0).sort((H,X)=>H.overflows[1]-X.overflows[1])[0])==null?void 0:st.placement;if(!_)switch(f){case"bestFit":{var Tt;const H=(Tt=K.filter(X=>{if(D){const Y=Z(X.placement);return Y===y||Y==="y"}return!0}).map(X=>[X.placement,X.overflows.filter(Y=>Y>0).reduce((Y,is)=>Y+is,0)]).sort((X,Y)=>X[1]-Y[1])[0])==null?void 0:Tt[0];H&&(_=H);break}case"initialPlacement":_=l;break}if(n!==_)return{reset:{placement:_}}}return{}}}};async function $i(t,e){const{placement:i,platform:s,elements:n}=t,o=await(s.isRTL==null?void 0:s.isRTL(n.floating)),r=W(i),l=At(i),a=Z(i)==="y",c=["left","top"].includes(r)?-1:1,d=o&&a?-1:1,u=J(e,t);let{mainAxis:h,crossAxis:f,alignmentAxis:g}=typeof u=="number"?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return l&&typeof g=="number"&&(f=l==="end"?g*-1:g),a?{x:f*d,y:h*c}:{x:h*c,y:f*d}}const ki=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var i,s;const{x:n,y:o,placement:r,middlewareData:l}=e,a=await $i(e,t);return r===((i=l.offset)==null?void 0:i.placement)&&(s=l.arrow)!=null&&s.alignmentOffset?{}:{x:n+a.x,y:o+a.y,data:{...a,placement:r}}}}},Li=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:i,y:s,placement:n}=e,{mainAxis:o=!0,crossAxis:r=!1,limiter:l={fn:b=>{let{x:p,y}=b;return{x:p,y}}},...a}=J(t,e),c={x:i,y:s},d=await Se(e,a),u=Z(W(n)),h=Xt(u);let f=c[h],g=c[u];if(o){const b=h==="y"?"top":"left",p=h==="y"?"bottom":"right",y=f+d[b],x=f-d[p];f=Kt(y,f,x)}if(r){const b=u==="y"?"top":"left",p=u==="y"?"bottom":"right",y=g+d[b],x=g-d[p];g=Kt(y,g,x)}const m=l.fn({...e,[h]:f,[u]:g});return{...m,data:{x:m.x-i,y:m.y-s,enabled:{[h]:o,[u]:r}}}}}},Oi=function(t){return t===void 0&&(t={}),{options:t,fn(e){const{x:i,y:s,placement:n,rects:o,middlewareData:r}=e,{offset:l=0,mainAxis:a=!0,crossAxis:c=!0}=J(t,e),d={x:i,y:s},u=Z(n),h=Xt(u);let f=d[h],g=d[u];const m=J(l,e),b=typeof m=="number"?{mainAxis:m,crossAxis:0}:{mainAxis:0,crossAxis:0,...m};if(a){const x=h==="y"?"height":"width",E=o.reference[h]-o.floating[x]+b.mainAxis,v=o.reference[h]+o.reference[x]-b.mainAxis;f<E?f=E:f>v&&(f=v)}if(c){var p,y;const x=h==="y"?"width":"height",E=["top","left"].includes(W(n)),v=o.reference[u]-o.floating[x]+(E&&((p=r.offset)==null?void 0:p[u])||0)+(E?0:b.crossAxis),D=o.reference[u]+o.reference[x]+(E?0:((y=r.offset)==null?void 0:y[u])||0)-(E?b.crossAxis:0);g<v?g=v:g>D&&(g=D)}return{[h]:f,[u]:g}}}};function Bt(){return typeof window<"u"}function rt(t){return Ee(t)?(t.nodeName||"").toLowerCase():"#document"}function R(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function B(t){var e;return(e=(Ee(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function Ee(t){return Bt()?t instanceof Node||t instanceof R(t).Node:!1}function I(t){return Bt()?t instanceof Element||t instanceof R(t).Element:!1}function V(t){return Bt()?t instanceof HTMLElement||t instanceof R(t).HTMLElement:!1}function Ce(t){return!Bt()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof R(t).ShadowRoot}function $t(t){const{overflow:e,overflowX:i,overflowY:s,display:n}=N(t);return/auto|scroll|overlay|hidden|clip/.test(e+s+i)&&!["inline","contents"].includes(n)}function Ti(t){return["table","td","th"].includes(rt(t))}function Vt(t){return[":popover-open",":modal"].some(e=>{try{return t.matches(e)}catch{return!1}})}function Zt(t){const e=Qt(),i=I(t)?N(t):t;return i.transform!=="none"||i.perspective!=="none"||(i.containerType?i.containerType!=="normal":!1)||!e&&(i.backdropFilter?i.backdropFilter!=="none":!1)||!e&&(i.filter?i.filter!=="none":!1)||["transform","perspective","filter"].some(s=>(i.willChange||"").includes(s))||["paint","layout","strict","content"].some(s=>(i.contain||"").includes(s))}function Pi(t){let e=U(t);for(;V(e)&&!lt(e);){if(Zt(e))return e;if(Vt(e))return null;e=U(e)}return null}function Qt(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function lt(t){return["html","body","#document"].includes(rt(t))}function N(t){return R(t).getComputedStyle(t)}function Ht(t){return I(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function U(t){if(rt(t)==="html")return t;const e=t.assignedSlot||t.parentNode||Ce(t)&&t.host||B(t);return Ce(e)?e.host:e}function Ae(t){const e=U(t);return lt(e)?t.ownerDocument?t.ownerDocument.body:t.body:V(e)&&$t(e)?e:Ae(e)}function kt(t,e,i){var s;e===void 0&&(e=[]),i===void 0&&(i=!0);const n=Ae(t),o=n===((s=t.ownerDocument)==null?void 0:s.body),r=R(n);if(o){const l=qt(r);return e.concat(r,r.visualViewport||[],$t(n)?n:[],l&&i?kt(l):[])}return e.concat(n,kt(n,[],i))}function qt(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function $e(t){const e=N(t);let i=parseFloat(e.width)||0,s=parseFloat(e.height)||0;const n=V(t),o=n?t.offsetWidth:i,r=n?t.offsetHeight:s,l=Mt(i)!==o||Mt(s)!==r;return l&&(i=o,s=r),{width:i,height:s,$:l}}function te(t){return I(t)?t:t.contextElement}function at(t){const e=te(t);if(!V(e))return z(1);const i=e.getBoundingClientRect(),{width:s,height:n,$:o}=$e(e);let r=(o?Mt(i.width):i.width)/s,l=(o?Mt(i.height):i.height)/n;return(!r||!Number.isFinite(r))&&(r=1),(!l||!Number.isFinite(l))&&(l=1),{x:r,y:l}}const Ri=z(0);function ke(t){const e=R(t);return!Qt()||!e.visualViewport?Ri:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function Di(t,e,i){return e===void 0&&(e=!1),!i||e&&i!==R(t)?!1:e}function Q(t,e,i,s){e===void 0&&(e=!1),i===void 0&&(i=!1);const n=t.getBoundingClientRect(),o=te(t);let r=z(1);e&&(s?I(s)&&(r=at(s)):r=at(t));const l=Di(o,i,s)?ke(o):z(0);let a=(n.left+l.x)/r.x,c=(n.top+l.y)/r.y,d=n.width/r.x,u=n.height/r.y;if(o){const h=R(o),f=s&&I(s)?R(s):s;let g=h,m=qt(g);for(;m&&s&&f!==g;){const b=at(m),p=m.getBoundingClientRect(),y=N(m),x=p.left+(m.clientLeft+parseFloat(y.paddingLeft))*b.x,E=p.top+(m.clientTop+parseFloat(y.paddingTop))*b.y;a*=b.x,c*=b.y,d*=b.x,u*=b.y,a+=x,c+=E,g=R(m),m=qt(g)}}return Nt({width:d,height:u,x:a,y:c})}function Mi(t){let{elements:e,rect:i,offsetParent:s,strategy:n}=t;const o=n==="fixed",r=B(s),l=e?Vt(e.floating):!1;if(s===r||l&&o)return i;let a={scrollLeft:0,scrollTop:0},c=z(1);const d=z(0),u=V(s);if((u||!u&&!o)&&((rt(s)!=="body"||$t(r))&&(a=Ht(s)),V(s))){const h=Q(s);c=at(s),d.x=h.x+s.clientLeft,d.y=h.y+s.clientTop}return{width:i.width*c.x,height:i.height*c.y,x:i.x*c.x-a.scrollLeft*c.x+d.x,y:i.y*c.y-a.scrollTop*c.y+d.y}}function Fi(t){return Array.from(t.getClientRects())}function ee(t,e){const i=Ht(t).scrollLeft;return e?e.left+i:Q(B(t)).left+i}function Ii(t){const e=B(t),i=Ht(t),s=t.ownerDocument.body,n=G(e.scrollWidth,e.clientWidth,s.scrollWidth,s.clientWidth),o=G(e.scrollHeight,e.clientHeight,s.scrollHeight,s.clientHeight);let r=-i.scrollLeft+ee(t);const l=-i.scrollTop;return N(s).direction==="rtl"&&(r+=G(e.clientWidth,s.clientWidth)-n),{width:n,height:o,x:r,y:l}}function Ni(t,e){const i=R(t),s=B(t),n=i.visualViewport;let o=s.clientWidth,r=s.clientHeight,l=0,a=0;if(n){o=n.width,r=n.height;const c=Qt();(!c||c&&e==="fixed")&&(l=n.offsetLeft,a=n.offsetTop)}return{width:o,height:r,x:l,y:a}}function Bi(t,e){const i=Q(t,!0,e==="fixed"),s=i.top+t.clientTop,n=i.left+t.clientLeft,o=V(t)?at(t):z(1),r=t.clientWidth*o.x,l=t.clientHeight*o.y,a=n*o.x,c=s*o.y;return{width:r,height:l,x:a,y:c}}function Le(t,e,i){let s;if(e==="viewport")s=Ni(t,i);else if(e==="document")s=Ii(B(t));else if(I(e))s=Bi(e,i);else{const n=ke(t);s={...e,x:e.x-n.x,y:e.y-n.y}}return Nt(s)}function Oe(t,e){const i=U(t);return i===e||!I(i)||lt(i)?!1:N(i).position==="fixed"||Oe(i,e)}function Vi(t,e){const i=e.get(t);if(i)return i;let s=kt(t,[],!1).filter(l=>I(l)&&rt(l)!=="body"),n=null;const o=N(t).position==="fixed";let r=o?U(t):t;for(;I(r)&&!lt(r);){const l=N(r),a=Zt(r);!a&&l.position==="fixed"&&(n=null),(o?!a&&!n:!a&&l.position==="static"&&!!n&&["absolute","fixed"].includes(n.position)||$t(r)&&!a&&Oe(t,r))?s=s.filter(d=>d!==r):n=l,r=U(r)}return e.set(t,s),s}function Hi(t){let{element:e,boundary:i,rootBoundary:s,strategy:n}=t;const r=[...i==="clippingAncestors"?Vt(e)?[]:Vi(e,this._c):[].concat(i),s],l=r[0],a=r.reduce((c,d)=>{const u=Le(e,d,n);return c.top=G(u.top,c.top),c.right=ot(u.right,c.right),c.bottom=ot(u.bottom,c.bottom),c.left=G(u.left,c.left),c},Le(e,l,n));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}}function _i(t){const{width:e,height:i}=$e(t);return{width:e,height:i}}function zi(t,e,i){const s=V(e),n=B(e),o=i==="fixed",r=Q(t,!0,o,e);let l={scrollLeft:0,scrollTop:0};const a=z(0);if(s||!s&&!o)if((rt(e)!=="body"||$t(n))&&(l=Ht(e)),s){const f=Q(e,!0,o,e);a.x=f.x+e.clientLeft,a.y=f.y+e.clientTop}else n&&(a.x=ee(n));let c=0,d=0;if(n&&!s&&!o){const f=n.getBoundingClientRect();d=f.top+l.scrollTop,c=f.left+l.scrollLeft-ee(n,f)}const u=r.left+l.scrollLeft-a.x-c,h=r.top+l.scrollTop-a.y-d;return{x:u,y:h,width:r.width,height:r.height}}function ie(t){return N(t).position==="static"}function Te(t,e){if(!V(t)||N(t).position==="fixed")return null;if(e)return e(t);let i=t.offsetParent;return B(t)===i&&(i=i.ownerDocument.body),i}function Pe(t,e){const i=R(t);if(Vt(t))return i;if(!V(t)){let n=U(t);for(;n&&!lt(n);){if(I(n)&&!ie(n))return n;n=U(n)}return i}let s=Te(t,e);for(;s&&Ti(s)&&ie(s);)s=Te(s,e);return s&&lt(s)&&ie(s)&&!Zt(s)?i:s||Pi(t)||i}const Wi=async function(t){const e=this.getOffsetParent||Pe,i=this.getDimensions,s=await i(t.floating);return{reference:zi(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:s.width,height:s.height}}};function Ui(t){return N(t).direction==="rtl"}const ji={convertOffsetParentRelativeRectToViewportRelativeRect:Mi,getDocumentElement:B,getClippingRect:Hi,getOffsetParent:Pe,getElementRects:Wi,getClientRects:Fi,getDimensions:_i,getScale:at,isElement:I,isRTL:Ui};function Ki(t,e){let i=null,s;const n=B(t);function o(){var l;clearTimeout(s),(l=i)==null||l.disconnect(),i=null}function r(l,a){l===void 0&&(l=!1),a===void 0&&(a=1),o();const{left:c,top:d,width:u,height:h}=t.getBoundingClientRect();if(l||e(),!u||!h)return;const f=Ft(d),g=Ft(n.clientWidth-(c+u)),m=Ft(n.clientHeight-(d+h)),b=Ft(c),y={rootMargin:-f+"px "+-g+"px "+-m+"px "+-b+"px",threshold:G(0,ot(1,a))||1};let x=!0;function E(v){const D=v[0].intersectionRatio;if(D!==a){if(!x)return r();D?r(!1,D):s=setTimeout(()=>{r(!1,1e-7)},1e3)}x=!1}try{i=new IntersectionObserver(E,{...y,root:n.ownerDocument})}catch{i=new IntersectionObserver(E,y)}i.observe(t)}return r(!0),o}function Xi(t,e,i,s){s===void 0&&(s={});const{ancestorScroll:n=!0,ancestorResize:o=!0,elementResize:r=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:a=!1}=s,c=te(t),d=n||o?[...c?kt(c):[],...kt(e)]:[];d.forEach(p=>{n&&p.addEventListener("scroll",i,{passive:!0}),o&&p.addEventListener("resize",i)});const u=c&&l?Ki(c,i):null;let h=-1,f=null;r&&(f=new ResizeObserver(p=>{let[y]=p;y&&y.target===c&&f&&(f.unobserve(e),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var x;(x=f)==null||x.observe(e)})),i()}),c&&!a&&f.observe(c),f.observe(e));let g,m=a?Q(t):null;a&&b();function b(){const p=Q(t);m&&(p.x!==m.x||p.y!==m.y||p.width!==m.width||p.height!==m.height)&&i(),m=p,g=requestAnimationFrame(b)}return i(),()=>{var p;d.forEach(y=>{n&&y.removeEventListener("scroll",i),o&&y.removeEventListener("resize",i)}),u==null||u(),(p=f)==null||p.disconnect(),f=null,a&&cancelAnimationFrame(g)}}const Yi=ki,Gi=Li,Ji=Ai,Zi=Ci,Qi=Oi,qi=(t,e,i)=>{const s=new Map,n={platform:ji,...i},o={...n.platform,_c:s};return Ei(t,e,{...n,platform:o})};async function ts(t){const e=pe.call(this,t);e.el.inert=!1,e.el.classList.add(this.settings.stateActive),e.isTooltip||e.trigger.setAttribute("aria-expanded","true"),e.getCustomProps();const i=ai(e),s=e.el.querySelector(i.arrow.element);return i.arrow.element=s||void 0,e.floatingCleanup=Xi(e.trigger,e.el,()=>{qi(e.trigger,e.el,{placement:e.getSetting("placement"),middleware:[Ji(i.flip),Gi({...i.shift,limiter:Qi()}),Yi(i.offset),Zi(i.arrow)]}).then(({x:n,y:o,placement:r,middlewareData:l})=>{if(e.el){if(ge(e.el,n,o),i.arrow.element&&l.arrow){const{x:a,y:c}=l.arrow;ge(i.arrow.element,a,c)}e.el.setAttribute("data-floating-placement",r)}})}),e.state="opened",e.getSetting("event")==="click"&&gi.call(this,e),e}class es extends Rt{constructor(i={}){super({...li,...i});L(this,wt);this.trigger=null,C(this,wt,hi.bind(this))}get active(){return this.get("opened","state")}get activeHover(){return this.collection.find(i=>i.state=="opened"&&i.getSetting("event")=="hover")}async createEntry(i,s){return new mi(this,i,s)}async open(i){return ts.call(this,i)}async close(i){return we.call(this,i)}async afterMount(){document.addEventListener("keydown",w(this,wt),!1)}async beforeUnmount(){this.trigger=null}async afterUnmount(){document.removeEventListener("keydown",w(this,wt),!1)}}wt=new WeakMap,S.Drawer=qe,S.Modal=ri,S.Popover=es,S.core=_e,Object.defineProperty(S,Symbol.toStringTag,{value:"Module"})});
1
+ (function(D,x){typeof exports=="object"&&typeof module<"u"?x(exports):typeof define=="function"&&define.amd?define(["exports"],x):(D=typeof globalThis<"u"?globalThis:D||self,x(D.vrembem={}))})(this,function(D){"use strict";const x=":not([inert])",C=':not([tabindex^="-"])',at=":not(:disabled)",Vt=[`a[href]${x}${C}`,`area[href]${x}${C}`,`input:not([type="hidden"]):not([type="radio"])${x}${C}${at}`,`input[type="radio"]${x}${C}${at}`,`select${x}${C}${at}`,`textarea${x}${C}${at}`,`button${x}${C}${at}`,`details${x} > summary:first-of-type${C}`,`iframe${x}${C}`,`audio[controls]${x}${C}`,`video[controls]${x}${C}`,`[contenteditable]${x}${C}`,`[tabindex]${x}${C}`];function _t(t,e="config"){const n=(t.getAttribute(`data-${e}`)||"").replace(/'/g,'"');return n?JSON.parse(n):{}}function St(t){if(typeof t=="string"){const e=document.getElementById(t);if(e)return e;throw new Error(`Element not found with ID: "${t}"`)}else if(t instanceof HTMLElement){if(!t.id)throw new Error("HTMLElement must have an ID");return t}else throw new Error("Invalid argument: query must be a string or HTMLElement")}async function j(t,e,...n){e in t&&typeof t[e]=="function"&&await t[e](...n)}function Wt(t,e,n){if(typeof e=="string"){const r=document.querySelector(e);if(!r)throw new Error(`No teleport reference found for selector: ${e}`);e=r}else if(!(e instanceof HTMLElement))throw new Error(`Not a valid teleport reference: '${e}'`);if(typeof e[n]!="function")throw new Error(`Not a valid teleport method: '${n}'`);let s=document.createComment("teleported #"+t.id);return t.before(s),e[n](t),()=>{s&&(s.after(t),s.remove(),s=null)}}function Qt(t){return t.split("-").map((e,n)=>n===0?e:e.charAt(0).toUpperCase()+e.slice(1)).join("")}function Ct(t){return t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function Jt(t){if(typeof t=="number")return t;const e=parseFloat(t);if(!Number.isNaN(e)){const n=t.includes("ms");return e*(n?1:1e3)}throw new Error(`Could not convert value to milliseconds: ${t}`)}function ze(t,e,n,s,r=0){return new Promise(i=>{t.classList.remove(e),t.classList.add(n),setTimeout(()=>{t.classList.add(s),t.classList.remove(n),i(t)},Jt(r))})}function Zt(t,e={}){const n={fallback:null,element:document.body,...e};if(!t.startsWith("--")){const r=pt();r&&(t=`${r}${t}`),t=`--${t}`}const s=getComputedStyle(n.element).getPropertyValue(t).trim();if(s)return s;if(n.fallback)return n.fallback;throw new Error(`CSS variable "${t}" was not found!`)}async function M(t,e,n){await j(e,t,n),n&&await j(n,t);for(const s of e.plugins)await j(s,t,{plugin:s,parent:e,entry:n});await e.emit(t,n)}function Kt(t){const e=getComputedStyle(t.el),n={},s=t.getSetting("customProps");for(let r=0;r<s.length;r++){const i=pt(),o=t.parent.module.toLowerCase(),a=Ct(s[r]),l=e.getPropertyValue(`--${i}${o}-${a}`).trim();l&&(n[a]=l)}return n}function pt(){return getComputedStyle(document.body).getPropertyValue("--vb-prefix").trim()}function Be(t,e,n="camel"){return e=n==="camel"?Qt(e):Ct(e),t.split(".").concat(e).reduce((s,r)=>s?.[r],this)}function Yt(t,e={}){const{fallback:n,props:s=["dataConfig","customProps","settings","parent.settings"]}=e;for(const r of s){const i=r!=="customProps"?"camel":"kebab",o=Be.call(this,r,t,i);if(o!==void 0)return o}if(n!==void 0)return n;throw new Error(`${this.parent.module} setting does not exist: ${t}`)}function Ve(t,e){e&&document.querySelectorAll(e).forEach(n=>{t?n.style.overflow="hidden":n.style.removeProperty("overflow")})}function _e(t,e){e&&document.querySelectorAll(e).forEach(n=>{t?(n.inert=!0,n.setAttribute("aria-hidden","true")):(n.inert=!1,n.removeAttribute("aria-hidden"))})}function We(t,e,n){_e(!!t,e),Ve(!!t,n)}const Gt={events:{},on(t,e,...n){this.events[t]||(this.events[t]=[]),this.events[t].some(s=>s.listener===e)||this.events[t].push({listener:e,args:n})},off(t,e){this.events[t]&&(this.events[t]=this.events[t].filter(n=>n.listener!==e))},async emit(t,e){if(t=t.startsWith("on")?t.slice(2,3).toLowerCase()+t.slice(3):t,!!this.events[t])for(const{listener:n,args:s}of this.events[t])await n(e,...s)}};let Xt=class extends Array{constructor(e=null){super(),this.el=e,this.el&&this.set()}get first(){return this[0]}get last(){return this[this.length-1]}set(e=this.el){this.length=0,e&&this.push(...e.querySelectorAll(Vt.join(",")))}clear(){this.length=0}},te=class{constructor(e=null){this.el=e,this.focusable=new Xt,this.handleFocusTrap=Qe.bind(this)}on(e=this.el){this.focusable.set(e),this.focusable.length?document.addEventListener("keydown",this.handleFocusTrap):document.addEventListener("keydown",ee)}off(){this.focusable.clear(),document.removeEventListener("keydown",this.handleFocusTrap),document.removeEventListener("keydown",ee)}};function ee(t){(t.key==="Tab"||t.keyCode===9)&&t.preventDefault()}function Qe(t){if(t.key!=="Tab"&&t.keyCode!==9)return;const{activeElement:e}=document,{el:n,focusable:s}=this,r=t.shiftKey,i=e===s.first||e===n,o=e===s.last||e===n;if(r&&i||!r&&o){t.preventDefault();const a=r?s.last:s.first;a&&typeof a.focus=="function"&&a.focus()}}function At(t,e=!0){const n=localStorage.getItem(t),s=n?JSON.parse(n):{};return{get(r,i){return r?r in s?s[r]:i:s},set(r,i){return i?s[r]=i:delete s[r],e&&localStorage.setItem(t,JSON.stringify(s)),s}}}let ne=class extends Array{constructor(e={}){super(),this.presets=e}applySettings(e){const n=e?.defaults||{},s=this.presets?.[e.name]||{},r=e?.options||{};e.settings={...n,...s,...r}}validate(e){return!("name"in e)||typeof e.name!="string"?(console.error("Plugin requires a name!"),!1):!0}get(e){return this.find(n=>n.name===e)}add(e){if(Array.isArray(e))e.forEach(n=>this.add(n));else if(this.applySettings(e),this.validate(e)){const n=this.findIndex(s=>s.name===e.name);~n?this[n]=e:this.push(e)}}remove(e){const n=this.findIndex(s=>s.name===e);~n&&this.splice(n,1)}};class Je extends Array{constructor(e={}){super(),this.settings=e}get copy(){return[...this]}get top(){return this[this.length-1]||null}updateIndex(){this.forEach((e,n)=>{e.el.style.zIndex="";const s=getComputedStyle(e.el)["z-index"];e.el.style.zIndex=String(parseInt(s,10)+n+1)})}onChange(){this.updateIndex(),typeof this.settings.onChange=="function"&&this.settings.onChange()}add(e){this.push(e),this.onChange()}remove(e){const n=this.findIndex(s=>s.id===e.id);~n&&(e.el.style.zIndex="",this.splice(n,1),this.onChange())}moveToTop(e){const n=this.findIndex(s=>s.id===e.id);~n&&(this.splice(n,1),this.add(e))}}const Ze={condition:!0},Ke={primary:"hsl(152deg 60% 50%)",secondary:"hsl(214deg 50% 50%)",neutral:"hsl(214deg 20% 50%)",important:"hsl(0deg 80% 50%)"};function Ye(t={}){const e={name:"debug",defaults:Ze,options:t};function n(i,o=[],a=["primary","secondary"]){const l=a.map(c=>`color: ${Ke[c]}`);console.log(`%c📡 DEBUG: %c${i}`,...l,...o)}function s(i,...o){return typeof i=="function"?i(...o):i}const r={beforeMountRef:n.bind(null,"Event > beforeMount()"),afterMountRef:n.bind(null,"Event > afterMount()"),beforeUnmountRef:n.bind(null,"Event > beforeUnmount()",[],["important","neutral"]),afterUnmountRef:n.bind(null,"Event > afterUnmount()",[],["important","neutral"]),createEntryRef:(i,{parent:o,plugin:a})=>{if(s(a.settings.condition,i)){const l=o.collection.length;n(`Event > createEntry() > [${l}] #${i.id}`)}},registerEntryRef:(i,{parent:o,plugin:a})=>{if(s(a.settings.condition,i)){const l=o.collection.length;n(`Event > registerEntry() > [${l}] #${i.id}`)}},destroyEntryRef:(i,{parent:o,plugin:a})=>{if(s(a.settings.condition,i)){const l=o.collection.length;n(`Event > destroyEntry() > [${l}] #${i.id}`,[],["important","neutral"])}},deregisterEntryRef:(i,{parent:o,plugin:a})=>{if(s(a.settings.condition,i)){const l=o.collection.length;n(`Event > deregisterEntry() > [${l}]`,[],["important","neutral"])}}};return{...e,setup({parent:i}){n("Plugin > setup()",Array.from(arguments),["secondary","neutral"]),i.on("beforeMount",r.beforeMountRef),i.on("createEntry",r.createEntryRef,{parent:i,plugin:this}),i.on("registerEntry",r.registerEntryRef,{parent:i,plugin:this}),i.on("afterMount",r.afterMountRef),i.on("beforeUnmount",r.beforeUnmountRef),i.on("destroyEntry",r.destroyEntryRef,{parent:i,plugin:this}),i.on("deregisterEntry",r.deregisterEntryRef,{parent:i,plugin:this}),i.on("afterUnmount",r.afterUnmountRef)},teardown({parent:i}){n("Plugin > teardown()",Array.from(arguments),["secondary","neutral"]),i.off("beforeMount",r.beforeMountRef),i.off("createEntry",r.createEntryRef),i.off("registerEntry",r.registerEntryRef),i.off("afterMount",r.afterMountRef),i.off("beforeUnmount",r.beforeUnmountRef),i.off("destroyEntry",r.destroyEntryRef),i.off("deregisterEntry",r.deregisterEntryRef),i.off("afterUnmount",r.afterUnmountRef)},beforeMount(){n("Hook > beforeMount()",Array.from(arguments))},onCreateEntry({parent:i,entry:o}){if(s(this.settings.condition,o)){const a=i.collection.length;n(`Hook > onCreateEntry() > [${a}] #${o.id}`,Array.from(arguments))}},onRegisterEntry({parent:i,entry:o}){if(s(this.settings.condition,o)){const a=i.collection.length-1;n(`Hook > onRegisterEntry() > [${a}] #${o.id}`,Array.from(arguments))}},afterMount(){n("Hook > afterMount()",Array.from(arguments))},beforeUnmount(){n("Hook > beforeUnmount()",Array.from(arguments),["important","neutral"])},onDestroyEntry({parent:i,entry:o}){if(s(this.settings.condition,o)){const a=i.collection.length-1;n(`Hook > onDestroyEntry() > [${a}] #${o.id}`,Array.from(arguments),["important","neutral"])}},onDeregisterEntry({parent:i,entry:o}){if(s(this.settings.condition,o)){const a=i.collection.length;n(`Hook > onDeregisterEntry() > [${a}]`,Array.from(arguments),["important","neutral"])}},afterUnmount(){n("Hook > afterUnmount()",Array.from(arguments),["important","neutral"])}}}const Ge={condition:!0};function Xe(t={}){const e={name:"focusTrap",defaults:Ge,options:t},n={setup({parent:o}){o.on("opened",r,this),o.on("closed",i,this)},teardown({parent:o}){o.off("opened",r),o.off("closed",i)},onCreateEntry({entry:o}){o.focusTrap=new te}};function s(o,...a){return typeof o=="function"?o(...a):o}function r(o,a){const l={plugin:a,parent:o.parent,entry:o};s(a.settings.condition,l)&&o.focusTrap?.on(o.dialog)}function i(o,a){const l={plugin:a,parent:o.parent,entry:o};s(a.settings.condition,l)&&o.focusTrap?.off()}return{...e,...n}}const tn={dataBreakpoint:"breakpoint",dataMediaQuery:"media-query",token:"{{BP}}",breakpoint:null,mediaQuery:"(min-width: {{BP}})",breakpoints:{},mediaQueries:{},onChange:()=>{}};function en(t={}){const e={name:"mediaQuery",defaults:tn,options:t},n={onCreateEntry({entry:a}){i.call(this,a)},onDestroyEntry({entry:a}){o(a)}};function s(a){const l=a.el.getAttribute(`data-${this.settings.dataMediaQuery}`);return!l&&a.id in this.settings.mediaQueries?this.settings.mediaQueries[a.id]:l||void 0}function r(a){let l=a.el.getAttribute(`data-${this.settings.dataBreakpoint}`);return!l&&a.id in this.settings.breakpoints&&(l=this.settings.breakpoints[a.id]),l&&l in this.settings.breakpoints&&(l=this.settings.breakpoints[l]),l&&(l=getComputedStyle(document.body).getPropertyValue(`--${pt()}breakpoint-${l}`).trim()||l),l||this.settings.breakpoint}function i(a){let l=s.call(this,a);const c=r.call(this,a);if(!c&&!l)return;c&&!l&&(l=this.settings.mediaQuery);const h=l.replace(new RegExp(`${this.settings.token}`,"g"),c);a.mql=window.matchMedia(h),a.mql.onchange=f=>{this.settings.onChange(f,a)},this.settings.onChange(a.mql,a)}function o(a){a.mql&&(a.mql.onchange=null,a.mql=null)}return{...e,...n}}const nn={prop:"state",value:null,keyPrefix:"VB:",key:null,condition:!1,onChange(){}};function sn(t={}){const e={name:"propStore",defaults:nn,options:t,store:null},n={setup({parent:a}){this.store=At(o.call(this,a.module))},async onCreateEntry({entry:a}){await s.call(this,a)},onDestroyEntry({entry:a}){i.call(this,a)}};async function s(a){let l=a[this.settings.prop]||null;const c={plugin:this,parent:a.parent,entry:a};Object.defineProperty(a,this.settings.prop,{configurable:!0,get(){return l},set:async h=>{if(l===h)return;const f=l;l=h,r(this.settings.condition,c,h,f)&&this.store.set(a.id,h),await this.settings.onChange(c,h,f)}}),Object.defineProperty(a,"store",{configurable:!0,get:()=>this.store.get(a.id),set:h=>{a[this.settings.prop]=h}}),a[this.settings.prop]=await r(this.settings.value,c)||a[this.settings.prop]}function r(a,...l){return typeof a=="function"?a(...l):a}async function i(a){const l=a[this.settings.prop];delete a[this.settings.prop],a[this.settings.prop]=l,this.store.set(a.id,null)}function o(a){const l=this.settings.prop.charAt(0).toUpperCase()+this.settings.prop.slice(1),c=this.settings.key||a+l;return this.settings.keyPrefix+c}return{...e,...n}}const rn={where:null,how:"append"};function on(t={}){const e={name:"teleport",defaults:rn,options:t},n={onCreateEntry({plugin:i,entry:o}){s(i,o)},onDestroyEntry({plugin:i,entry:o}){r(i,o)}};function s(i,o){o.teleport=()=>{typeof o.teleportReturn=="function"&&o.teleportReturn(),o.teleportReturn=Wt(o.el,o.getSetting("teleport",{fallback:i.settings.where}),o.getSetting("teleportMethod",{fallback:i.settings.how}))},o.teleport(),o.parent.emit("teleport",{plugin:i,parent:o.parent,entry:o})}function r(i,o){typeof o.teleportReturn=="function"&&o.teleportReturn(),o.parent.emit("teleportReturn",{plugin:i,parent:o.parent,entry:o})}return{...e,...n}}const an={dataConfig:"config",customProps:[]};let se=class{constructor(e,n,s={}){this.parent=e,this.el=St(n),this.settings={...s},this.dataConfig={},this.customProps={}}get id(){return this.el.id}applySettings(e){return Object.assign(this.settings,e)}getSetting(e,n){return Yt.call(this,e,n)}buildDataConfig(){return Object.assign(this.dataConfig,_t(this.el,this.getSetting("dataConfig")))}buildCustomProps(){return Object.assign(this.customProps,Kt(this))}async init(e={}){this.applySettings(e),this.buildDataConfig(),this.buildCustomProps()}async destroy(){Object.getOwnPropertyNames(this).forEach(e=>{delete this[e]})}},ln=class{constructor(e={}){this.module=this.constructor.name,this.collection=[],this.entryClass=se,this.settings={...an,...e},this.plugins=new ne(this.settings.presets),this.events={},Object.assign(this,Gt)}get(e,n="id"){return this.collection.find(s=>s[n]===e)}applySettings(e){return Object.assign(this.settings,e)}async createEntry(e,n){const s=new this.entryClass(this,e,n);return await j(s,"init"),await M("onCreateEntry",this,s),s}async destroyEntry(e){return await M("onDestroyEntry",this,e),await j(e,"destroy"),e}async register(e,n={}){const s=St(e),r=this.collection.findIndex(i=>i.id===s.id);if(~r){const i=this.collection[r];return i.el=s,typeof i.init=="function"&&await i.init(n),i}else{const i=await this.createEntry(s,n);return this.collection.push(i),await M("onRegisterEntry",this,i),i}}async deregister(e){const n=this.collection.findIndex(s=>s.id===e);if(~n){const s=await this.destroyEntry(this.collection[n]);return await M("onDeregisterEntry",this,this.collection[n]),this.collection.splice(n,1),s}return null}async mount(e={}){this.applySettings(e);for(const s of this.settings?.plugins||[])this.plugins.add(s);for(const s of this.plugins)await j(s,"setup",{plugin:s,parent:this});await M("beforeMount",this);const n=document.querySelectorAll(this.settings.selector);for(const s of n)await this.register(s);return await M("afterMount",this),this}async unmount(){for(await M("beforeUnmount",this);this.collection.length>0;)await this.deregister(this.collection[0].id);await M("afterUnmount",this);for(const e of this.plugins)await j(e,"teardown",{plugin:e,parent:this});for(const e of[...this.plugins])this.plugins.remove(e.name);return this}};function cn(t={}){const e={prefix:Zt("prefix-themes",{fallback:"vb-theme-"}),themes:["root","light","dark"],storeKey:"VB:Profile"};for(const[i]of Object.entries(e))t&&t[i]&&(e[i]=t[i]);const n={onInit(){},onChange(){}};for(const[i]of Object.entries(n))t&&t[i]&&(n[i]=t[i]);const s=At(e.storeKey),r={settings:e,add(i){e.themes.push(i)},remove(i){const o=e.themes.indexOf(i);~o&&e.themes.splice(o,1)},callback(i){n[i].call(this)},get class(){return`${e.prefix}${this.theme}`},get classes(){return e.themes.map(i=>`${e.prefix}${i}`)},get themes(){return e.themes},get theme(){return s.get("theme")||"root"},set theme(i){e.themes.includes(i)?this.theme!=i&&(s.set("theme",i),document.documentElement.classList.remove(...this.classes),document.documentElement.classList.add(`${e.prefix}${i}`),this.callback("onChange")):console.error(`Not a valid theme value: "${i}"`)}};return r.callback("onInit"),r}const un=Object.freeze(Object.defineProperty({__proto__:null,Collection:ln,CollectionEntry:se,FocusTrap:te,FocusableArray:Xt,PluginsArray:ne,StackArray:Je,cssVar:Zt,debug:Ye,dispatchLifecycleHook:M,eventEmitter:Gt,focusTrap:Xe,focusableSelectors:Vt,getCustomProps:Kt,getDataConfig:_t,getElement:St,getPrefix:pt,getSetting:Yt,localStore:At,maybeRunMethod:j,mediaQuery:en,propStore:sn,setGlobalState:We,teleport:on,teleportElement:Wt,themeStore:cn,toCamel:Qt,toKebab:Ct,toMilliseconds:Jt,transition:ze},Symbol.toStringTag,{value:"Module"}));function fn(t,e="config"){const n=(t.getAttribute(`data-${e}`)||"").replace(/'/g,'"');return n?JSON.parse(n):{}}function ie(t){if(typeof t=="string"){const e=document.getElementById(t);if(e)return e;throw new Error(`Element not found with ID: "${t}"`)}else if(t instanceof HTMLElement){if(!t.id)throw new Error("HTMLElement must have an ID");return t}else throw new Error("Invalid argument: query must be a string or HTMLElement")}async function W(t,e,...n){e in t&&typeof t[e]=="function"&&await t[e](...n)}function hn(t){return t.split("-").map((e,n)=>n===0?e:e.charAt(0).toUpperCase()+e.slice(1)).join("")}function re(t){return t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function dn(t){if(typeof t=="number")return t;const e=parseFloat(t);if(!Number.isNaN(e)){const n=t.includes("ms");return e*(n?1:1e3)}throw new Error(`Could not convert value to milliseconds: ${t}`)}function oe(t,e,n,s,r=0){return new Promise(i=>{t.classList.remove(e),t.classList.add(n),setTimeout(()=>{t.classList.add(s),t.classList.remove(n),i(t)},dn(r))})}async function N(t,e,n){await W(e,t,n),n&&await W(n,t);for(const s of e.plugins)await W(s,t,{plugin:s,parent:e,entry:n});await e.emit(t,n)}function gn(t){const e=getComputedStyle(t.el),n={},s=t.getSetting("customProps");for(let r=0;r<s.length;r++){const i=pn(),o=t.parent.module.toLowerCase(),a=re(s[r]),l=e.getPropertyValue(`--${i}${o}-${a}`).trim();l&&(n[a]=l)}return n}function pn(){return getComputedStyle(document.body).getPropertyValue("--vb-prefix").trim()}function mn(t,e,n="camel"){return e=n==="camel"?hn(e):re(e),t.split(".").concat(e).reduce((s,r)=>s?.[r],this)}function yn(t,e={}){const{fallback:n,props:s=["dataConfig","customProps","settings","parent.settings"]}=e;for(const r of s){const i=r!=="customProps"?"camel":"kebab",o=mn.call(this,r,t,i);if(o!==void 0)return o}if(n!==void 0)return n;throw new Error(`${this.parent.module} setting does not exist: ${t}`)}function wn(t,e){e&&document.querySelectorAll(e).forEach(n=>{t?n.style.overflow="hidden":n.style.removeProperty("overflow")})}function vn(t,e){e&&document.querySelectorAll(e).forEach(n=>{t?(n.inert=!0,n.setAttribute("aria-hidden","true")):(n.inert=!1,n.removeAttribute("aria-hidden"))})}function Lt(t,e,n){vn(!!t,e),wn(!!t,n)}const bn={events:{},on(t,e,...n){this.events[t]||(this.events[t]=[]),this.events[t].some(s=>s.listener===e)||this.events[t].push({listener:e,args:n})},off(t,e){this.events[t]&&(this.events[t]=this.events[t].filter(n=>n.listener!==e))},async emit(t,e){if(t=t.startsWith("on")?t.slice(2,3).toLowerCase()+t.slice(3):t,!!this.events[t])for(const{listener:n,args:s}of this.events[t])await n(e,...s)}};let En=class extends Array{constructor(e={}){super(),this.presets=e}applySettings(e){const n=e?.defaults||{},s=this.presets?.[e.name]||{},r=e?.options||{};e.settings={...n,...s,...r}}validate(e){return!("name"in e)||typeof e.name!="string"?(console.error("Plugin requires a name!"),!1):!0}get(e){return this.find(n=>n.name===e)}add(e){if(Array.isArray(e))e.forEach(n=>this.add(n));else if(this.applySettings(e),this.validate(e)){const n=this.findIndex(s=>s.name===e.name);~n?this[n]=e:this.push(e)}}remove(e){const n=this.findIndex(s=>s.name===e);~n&&this.splice(n,1)}};const xn={dataConfig:"config",customProps:[]};let ae=class{constructor(e,n,s={}){this.parent=e,this.el=ie(n),this.settings={...s},this.dataConfig={},this.customProps={}}get id(){return this.el.id}applySettings(e){return Object.assign(this.settings,e)}getSetting(e,n){return yn.call(this,e,n)}buildDataConfig(){return Object.assign(this.dataConfig,fn(this.el,this.getSetting("dataConfig")))}buildCustomProps(){return Object.assign(this.customProps,gn(this))}async init(e={}){this.applySettings(e),this.buildDataConfig(),this.buildCustomProps()}async destroy(){Object.getOwnPropertyNames(this).forEach(e=>{delete this[e]})}},$n=class{constructor(e={}){this.module=this.constructor.name,this.collection=[],this.entryClass=ae,this.settings={...xn,...e},this.plugins=new En(this.settings.presets),this.events={},Object.assign(this,bn)}get(e,n="id"){return this.collection.find(s=>s[n]===e)}applySettings(e){return Object.assign(this.settings,e)}async createEntry(e,n){const s=new this.entryClass(this,e,n);return await W(s,"init"),await N("onCreateEntry",this,s),s}async destroyEntry(e){return await N("onDestroyEntry",this,e),await W(e,"destroy"),e}async register(e,n={}){const s=ie(e),r=this.collection.findIndex(i=>i.id===s.id);if(~r){const i=this.collection[r];return i.el=s,typeof i.init=="function"&&await i.init(n),i}else{const i=await this.createEntry(s,n);return this.collection.push(i),await N("onRegisterEntry",this,i),i}}async deregister(e){const n=this.collection.findIndex(s=>s.id===e);if(~n){const s=await this.destroyEntry(this.collection[n]);return await N("onDeregisterEntry",this,this.collection[n]),this.collection.splice(n,1),s}return null}async mount(e={}){this.applySettings(e);for(const s of this.settings?.plugins||[])this.plugins.add(s);for(const s of this.plugins)await W(s,"setup",{plugin:s,parent:this});await N("beforeMount",this);const n=document.querySelectorAll(this.settings.selector);for(const s of n)await this.register(s);return await N("afterMount",this),this}async unmount(){for(await N("beforeUnmount",this);this.collection.length>0;)await this.deregister(this.collection[0].id);await N("afterUnmount",this);for(const e of this.plugins)await W(e,"teardown",{plugin:e,parent:this});for(const e of[...this.plugins])this.plugins.remove(e.name);return this}};const Sn={focusTrap:{condition:({entry:t})=>t.state==="closed"||t.state==="opened"&&t.mode==="modal"},mediaQuery:{onChange(t,e){e.mode=t.matches?"inline":"modal"}},propStore:{prop:"inlineState",value:({entry:t})=>t.store,condition:({entry:t})=>["opened","closed","indeterminate"].includes(t.state),onChange:({entry:t})=>t.applyState()}},Cn={presets:Sn,dataOpen:"drawer-open",dataClose:"drawer-close",dataToggle:"drawer-toggle",selector:".drawer",selectorDialog:".drawer__dialog",selectorScreen:".drawer",selectorFocus:"[data-focus]",selectorInert:null,selectorOverflow:"body",stateOpened:"is-opened",stateOpening:"is-opening",stateClosing:"is-closing",stateClosed:"is-closed",classModal:"drawer_modal",customProps:["transition-duration"],breakpoints:null,customEventPrefix:"drawer:",setTabindex:!0,transition:!0,transitionDuration:300};function An(t){switch(t.mode){case"inline":return Ln(t);case"modal":return Pn(t);default:throw new Error(`"${t.mode}" is not a valid drawer mode.`)}}async function Ln(t){return t.el.classList.remove(t.getSetting("classModal")),t.dialog.removeAttribute("aria-modal"),Lt(!1,t.getSetting("selectorInert"),t.getSetting("selectorOverflow")),t.applyState(),t.el.dispatchEvent(new CustomEvent(t.getSetting("customEventPrefix")+"switchMode",{detail:t.parent,bubbles:!0})),await t.parent.emit("switchMode",t),t}async function Pn(t){return t.el.classList.add(t.getSetting("classModal")),t.dialog.setAttribute("aria-modal","true"),await t.close(!1,!1),t.el.dispatchEvent(new CustomEvent(t.getSetting("customEventPrefix")+"switchMode",{detail:t.parent,bubbles:!0})),await t.parent.emit("switchMode",t),t}function le(t){t.dialog&&t.state==="opened"?(t.dialog.querySelector(t.parent.settings.selectorFocus)||t.dialog).focus():t.trigger&&(t.trigger.focus(),t.trigger=null)}async function Pt(t,e,n=!0){return(t.state==="closed"||t.state==="indeterminate"||t.state===null)&&(t.setState("opening"),e??t.getSetting("transition")?await oe(t.el,t.getSetting("stateClosed"),t.getSetting("stateOpening"),t.getSetting("stateOpened"),t.getSetting("transitionDuration")):(t.el.classList.add(t.getSetting("stateOpened")),t.el.classList.remove(t.getSetting("stateClosed"))),t.setState("opened"),t.mode==="modal"&&Lt(!0,t.getSetting("selectorInert"),t.getSetting("selectorOverflow")),n&&le(t),t.el.dispatchEvent(new CustomEvent(t.getSetting("customEventPrefix")+"opened",{detail:t.parent,bubbles:!0})),await t.parent.emit("opened",t)),t}async function kt(t,e,n=!0){return(t.state==="opened"||t.state==="indeterminate"||t.state===null)&&(t.setState("closing"),document.activeElement&&document.activeElement instanceof HTMLElement&&document.activeElement.blur(),e??t.getSetting("transition")?await oe(t.el,t.getSetting("stateOpened"),t.getSetting("stateClosing"),t.getSetting("stateClosed"),t.getSetting("transitionDuration")):(t.el.classList.add(t.getSetting("stateClosed")),t.el.classList.remove(t.getSetting("stateOpened"))),t.setState("closed"),t.mode==="modal"&&Lt(!1,t.getSetting("selectorInert"),t.getSetting("selectorOverflow")),n&&le(t),t.el.dispatchEvent(new CustomEvent(t.getSetting("customEventPrefix")+"closed",{detail:t.parent,bubbles:!0})),await t.parent.emit("closed",t)),t}async function ce(t,e,n){return t.state==="closed"?Pt(t,e,n):kt(t,e,n)}class kn extends ae{#t;constructor(e,n,s={}){super(e,n,s),this.#t="indeterminate",this.dialog=this.el.querySelector(this.getSetting("selectorDialog"))||this.el,this.trigger=null,this.state=null,this.inlineState=null}get mode(){return this.#t}set mode(e){this.#t!==e&&(this.#t=e,An(this))}setState(e){this.state=e;const n=["opening","closing"];this.mode==="inline"&&!n.includes(e)&&(this.inlineState=e),e==="indeterminate"&&(this.el.classList.remove(this.getSetting("stateOpened")),this.el.classList.remove(this.getSetting("stateOpening")),this.el.classList.remove(this.getSetting("stateClosed")),this.el.classList.remove(this.getSetting("stateClosing")))}async applyState(){if(this.mode==="modal")return this;if(this.inlineState==="opened")return await this.open(!1,!1);if(this.inlineState==="closed")return await this.close(!1,!1);if(this.state===null){if(this.el.classList.contains(this.getSetting("stateOpened")))return await this.open(!1,!1);if(this.el.classList.contains(this.getSetting("stateClosed")))return await this.close(!1,!1)}return this.setState("indeterminate"),this}async open(e,n){return Pt(this,e,n)}async close(e,n){return kt(this,e,n)}async toggle(e,n){return ce(this,e,n)}async deregister(){return this.parent.deregister(this.id)}async onCreateEntry(){this.getSetting("setTabindex")&&this.dialog&&this.dialog.setAttribute("tabindex","-1"),await this.applyState(),this.inlineState=this.state,this.mode=this.el&&this.el.classList.contains(this.getSetting("classModal"))?"modal":"inline"}async onDestroyEntry(){this.mode==="modal"&&this.state==="opened"&&await this.close(!1)}}function nt(t){const e=this.get(t);if(e)return e;throw new Error(`Drawer not found in collection with id of "${t}"`)}async function Tn(t){const e=t.target;if(e){const n=e.closest(`
2
+ [data-${this.settings.dataOpen}],
3
+ [data-${this.settings.dataToggle}],
4
+ [data-${this.settings.dataClose}]
5
+ `);if(n){t.preventDefault(),n.matches(`[data-${this.settings.dataToggle}]`)&&n.getAttribute(`data-${this.settings.dataToggle}`)?.trim().split(" ")?.forEach(s=>{const r=nt.call(this,s);return r.trigger=n,r.toggle()}),n.matches(`[data-${this.settings.dataOpen}]`)&&n.getAttribute(`data-${this.settings.dataOpen}`)?.trim().split(" ")?.forEach(s=>{const r=nt.call(this,s);return r.trigger=n,r.open()}),n.matches(`[data-${this.settings.dataClose}]`)&&n.getAttribute(`data-${this.settings.dataClose}`)?.trim().split(" ")?.forEach(s=>{if(s){const r=nt.call(this,s);return r.trigger=n,r.close()}else{const r=e.closest(this.settings.selector);if(r)return this.close(r.id)}});return}if(this.activeModal&&e.matches(this.settings.selectorScreen))return this.close(this.activeModal.id)}}function On(t){if(t.key==="Escape"&&this.activeModal)return this.close(this.activeModal.id)}let Rn=class extends $n{#t;#e;constructor(e){super({...Cn,...e}),this.module="Drawer",this.entryClass=kn,this.#t=Tn.bind(this),this.#e=On.bind(this)}get activeModal(){return this.collection.find(e=>e.state==="opened"&&e.mode==="modal")}async open(e,n,s){const r=nt.call(this,e);return Pt(r,n,s)}async close(e,n,s){const r=nt.call(this,e);return kt(r,n,s)}async toggle(e,n,s){const r=nt.call(this,e);return ce(r,n,s)}async afterMount(){document.addEventListener("click",this.#t,!1),document.addEventListener("keydown",this.#e,!1)}async afterUnmount(){document.removeEventListener("click",this.#t,!1),document.removeEventListener("keydown",this.#e,!1)}};function Dn(t,e="config"){const n=(t.getAttribute(`data-${e}`)||"").replace(/'/g,'"');return n?JSON.parse(n):{}}function ue(t){if(typeof t=="string"){const e=document.getElementById(t);if(e)return e;throw new Error(`Element not found with ID: "${t}"`)}else if(t instanceof HTMLElement){if(!t.id)throw new Error("HTMLElement must have an ID");return t}else throw new Error("Invalid argument: query must be a string or HTMLElement")}async function Q(t,e,...n){e in t&&typeof t[e]=="function"&&await t[e](...n)}function Mn(t){return t.split("-").map((e,n)=>n===0?e:e.charAt(0).toUpperCase()+e.slice(1)).join("")}function fe(t){return t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function In(t){if(typeof t=="number")return t;const e=parseFloat(t);if(!Number.isNaN(e)){const n=t.includes("ms");return e*(n?1:1e3)}throw new Error(`Could not convert value to milliseconds: ${t}`)}function he(t,e,n,s,r=0){return new Promise(i=>{t.classList.remove(e),t.classList.add(n),setTimeout(()=>{t.classList.add(s),t.classList.remove(n),i(t)},In(r))})}async function U(t,e,n){await Q(e,t,n),n&&await Q(n,t);for(const s of e.plugins)await Q(s,t,{plugin:s,parent:e,entry:n});await e.emit(t,n)}function Hn(t){const e=getComputedStyle(t.el),n={},s=t.getSetting("customProps");for(let r=0;r<s.length;r++){const i=qn(),o=t.parent.module.toLowerCase(),a=fe(s[r]),l=e.getPropertyValue(`--${i}${o}-${a}`).trim();l&&(n[a]=l)}return n}function qn(){return getComputedStyle(document.body).getPropertyValue("--vb-prefix").trim()}function jn(t,e,n="camel"){return e=n==="camel"?Mn(e):fe(e),t.split(".").concat(e).reduce((s,r)=>s?.[r],this)}function Nn(t,e={}){const{fallback:n,props:s=["dataConfig","customProps","settings","parent.settings"]}=e;for(const r of s){const i=r!=="customProps"?"camel":"kebab",o=jn.call(this,r,t,i);if(o!==void 0)return o}if(n!==void 0)return n;throw new Error(`${this.parent.module} setting does not exist: ${t}`)}function Un(t,e){e&&document.querySelectorAll(e).forEach(n=>{t?n.style.overflow="hidden":n.style.removeProperty("overflow")})}function Fn(t,e){e&&document.querySelectorAll(e).forEach(n=>{t?(n.inert=!0,n.setAttribute("aria-hidden","true")):(n.inert=!1,n.removeAttribute("aria-hidden"))})}function zn(t,e,n){Fn(!!t,e),Un(!!t,n)}const Bn={events:{},on(t,e,...n){this.events[t]||(this.events[t]=[]),this.events[t].some(s=>s.listener===e)||this.events[t].push({listener:e,args:n})},off(t,e){this.events[t]&&(this.events[t]=this.events[t].filter(n=>n.listener!==e))},async emit(t,e){if(t=t.startsWith("on")?t.slice(2,3).toLowerCase()+t.slice(3):t,!!this.events[t])for(const{listener:n,args:s}of this.events[t])await n(e,...s)}};class Vn extends Array{constructor(e={}){super(),this.presets=e}applySettings(e){const n=e?.defaults||{},s=this.presets?.[e.name]||{},r=e?.options||{};e.settings={...n,...s,...r}}validate(e){return!("name"in e)||typeof e.name!="string"?(console.error("Plugin requires a name!"),!1):!0}get(e){return this.find(n=>n.name===e)}add(e){if(Array.isArray(e))e.forEach(n=>this.add(n));else if(this.applySettings(e),this.validate(e)){const n=this.findIndex(s=>s.name===e.name);~n?this[n]=e:this.push(e)}}remove(e){const n=this.findIndex(s=>s.name===e);~n&&this.splice(n,1)}}let _n=class extends Array{constructor(e={}){super(),this.settings=e}get copy(){return[...this]}get top(){return this[this.length-1]||null}updateIndex(){this.forEach((e,n)=>{e.el.style.zIndex="";const s=getComputedStyle(e.el)["z-index"];e.el.style.zIndex=String(parseInt(s,10)+n+1)})}onChange(){this.updateIndex(),typeof this.settings.onChange=="function"&&this.settings.onChange()}add(e){this.push(e),this.onChange()}remove(e){const n=this.findIndex(s=>s.id===e.id);~n&&(e.el.style.zIndex="",this.splice(n,1),this.onChange())}moveToTop(e){const n=this.findIndex(s=>s.id===e.id);~n&&(this.splice(n,1),this.add(e))}};const Wn={dataConfig:"config",customProps:[]};class de{constructor(e,n,s={}){this.parent=e,this.el=ue(n),this.settings={...s},this.dataConfig={},this.customProps={}}get id(){return this.el.id}applySettings(e){return Object.assign(this.settings,e)}getSetting(e,n){return Nn.call(this,e,n)}buildDataConfig(){return Object.assign(this.dataConfig,Dn(this.el,this.getSetting("dataConfig")))}buildCustomProps(){return Object.assign(this.customProps,Hn(this))}async init(e={}){this.applySettings(e),this.buildDataConfig(),this.buildCustomProps()}async destroy(){Object.getOwnPropertyNames(this).forEach(e=>{delete this[e]})}}let Qn=class{constructor(e={}){this.module=this.constructor.name,this.collection=[],this.entryClass=de,this.settings={...Wn,...e},this.plugins=new Vn(this.settings.presets),this.events={},Object.assign(this,Bn)}get(e,n="id"){return this.collection.find(s=>s[n]===e)}applySettings(e){return Object.assign(this.settings,e)}async createEntry(e,n){const s=new this.entryClass(this,e,n);return await Q(s,"init"),await U("onCreateEntry",this,s),s}async destroyEntry(e){return await U("onDestroyEntry",this,e),await Q(e,"destroy"),e}async register(e,n={}){const s=ue(e),r=this.collection.findIndex(i=>i.id===s.id);if(~r){const i=this.collection[r];return i.el=s,typeof i.init=="function"&&await i.init(n),i}else{const i=await this.createEntry(s,n);return this.collection.push(i),await U("onRegisterEntry",this,i),i}}async deregister(e){const n=this.collection.findIndex(s=>s.id===e);if(~n){const s=await this.destroyEntry(this.collection[n]);return await U("onDeregisterEntry",this,this.collection[n]),this.collection.splice(n,1),s}return null}async mount(e={}){this.applySettings(e);for(const s of this.settings?.plugins||[])this.plugins.add(s);for(const s of this.plugins)await Q(s,"setup",{plugin:s,parent:this});await U("beforeMount",this);const n=document.querySelectorAll(this.settings.selector);for(const s of n)await this.register(s);return await U("afterMount",this),this}async unmount(){for(await U("beforeUnmount",this);this.collection.length>0;)await this.deregister(this.collection[0].id);await U("afterUnmount",this);for(const e of this.plugins)await Q(e,"teardown",{plugin:e,parent:this});for(const e of[...this.plugins])this.plugins.remove(e.name);return this}};const Jn={dataOpen:"modal-open",dataClose:"modal-close",dataReplace:"modal-replace",selector:".modal",selectorDialog:".modal__dialog",selectorScreen:".modal",selectorRequired:'[role="alertdialog"]',selectorFocus:"[data-focus]",selectorInert:null,selectorOverflow:"body",stateOpened:"is-opened",stateOpening:"is-opening",stateClosing:"is-closing",stateClosed:"is-closed",customProps:["transition-duration"],customEventPrefix:"modal:",setTabindex:!0,transition:!0,transitionDuration:300};function mt(t){t.active?(t.active.dialog.querySelector(t.settings.selectorFocus)||t.active.dialog).focus():t.trigger&&(t.trigger.focus(),t.trigger=null)}async function Tt(t,e,n=!0){return t.parent.stack.moveToTop(t),t.state==="closed"&&(t.state="opening",t.parent.stack.add(t),e??t.getSetting("transition")?await he(t.el,t.getSetting("stateClosed"),t.getSetting("stateOpening"),t.getSetting("stateOpened"),t.getSetting("transitionDuration")):(t.el.classList.add(t.getSetting("stateOpened")),t.el.classList.remove(t.getSetting("stateClosed"))),t.state="opened"),n&&mt(t.parent),t.el.dispatchEvent(new CustomEvent(t.getSetting("customEventPrefix")+"opened",{detail:t.parent,bubbles:!0})),await t.parent.emit("opened",t),t}async function Ot(t,e,n=!0){return t&&t.state==="opened"&&(t.state="closing",document.activeElement&&document.activeElement instanceof HTMLElement&&document.activeElement.blur(),e??t.getSetting("transition")?await he(t.el,t.getSetting("stateOpened"),t.getSetting("stateClosing"),t.getSetting("stateClosed"),t.getSetting("transitionDuration")):(t.el.classList.add(t.getSetting("stateClosed")),t.el.classList.remove(t.getSetting("stateOpened"))),t.parent.stack.remove(t),t.state="closed",n&&mt(t.parent),t.el.dispatchEvent(new CustomEvent(t.getSetting("customEventPrefix")+"closed",{detail:t.parent,bubbles:!0})),await t.parent.emit("closed",t)),t}async function ge(t,e,n=!0){let s,r;return t.state==="opened"?(s=t,r=await t.parent.closeAll(t.id,e)):[r,s]=await Promise.all([t.parent.closeAll("",e),Tt(t,e,!1)]),n&&mt(t.parent),{opened:s,closed:r}}let Zn=class extends de{constructor(e,n,s={}){super(e,n,s),this.state="closed",this.dialog=this.el.querySelector(this.getSetting("selectorDialog"))||this.el}get isRequired(){return this.dialog.matches(this.getSetting("selectorRequired"))}async open(e,n){return Tt(this,e,n)}async close(e,n){return Ot(this,e,n)}async replace(e,n){return ge(this,e,n)}async deregister(){return this.parent.deregister(this.id)}async onCreateEntry(){this.dialog.setAttribute("aria-modal","true"),this.dialog.hasAttribute("role")||this.dialog.setAttribute("role","dialog"),this.getSetting("setTabindex")&&this.dialog.setAttribute("tabindex","-1")}async onRegisterEntry(){this.el.classList.contains(this.getSetting("stateOpened"))?await this.open(!1):(this.el.classList.remove(this.getSetting("stateOpening")),this.el.classList.remove(this.getSetting("stateClosing")),this.el.classList.add(this.getSetting("stateClosed")))}async onDestroyEntry(){this.state==="opened"&&await this.close(!1)}};function lt(t){const e=this.get(t);if(e)return e;throw new Error(`Modal not found in collection with id of "${t}".`)}async function Kn(t){const e=t.target;if(e){const n=e.closest(`
6
+ [data-${this.settings.dataOpen}],
7
+ [data-${this.settings.dataReplace}],
8
+ [data-${this.settings.dataClose}]
9
+ `);if(n){if(t.preventDefault(),n.matches(`[data-${this.settings.dataOpen}]`)){const s=n.getAttribute(`data-${this.settings.dataOpen}`)?.trim(),r=lt.call(this,s);return e.closest(this.settings.selector)||(this.trigger=n),r.open()}if(n.matches(`[data-${this.settings.dataReplace}]`)){const s=n.getAttribute(`data-${this.settings.dataReplace}`)?.trim(),r=lt.call(this,s);return e.closest(this.settings.selector)||(this.trigger=n),r.replace()}if(n.matches(`[data-${this.settings.dataClose}]`)){const s=n.getAttribute(`data-${this.settings.dataClose}`)?.trim();return s==="*"?this.closeAll():this.close(s||"")}}if(this.active&&e.matches(this.settings.selectorScreen)&&!this.active.isRequired)return this.close()}}function Yn(t){if(t.key==="Escape"&&this.active&&!this.active.dialog.matches(this.settings.selectorRequired))return this.close()}async function Gn(t="",e){const n=[];return await Promise.all(this.stack.copy.map(async s=>{t&&t===s.id||n.push(await Ot(s,e,!1))})),n}let Xn=class extends Qn{#t;#e;constructor(e){super({...Jn,...e}),this.module="Modal",this.entryClass=Zn,this.trigger=null,this.#t=Kn.bind(this),this.#e=Yn.bind(this),this.stack=new _n({onChange:()=>{zn(!!this.stack.top,this.settings.selectorInert,this.settings.selectorOverflow)}})}get active(){return this.stack.top}async open(e,n,s){const r=lt.call(this,e);return Tt(r,n,s)}async close(e,n,s){const r=e?lt.call(this,e):this.active;return Ot(r,n,s)}async replace(e,n,s){const r=lt.call(this,e);return ge(r,n,s)}async closeAll(e,n,s=!0){const r=await Gn.call(this,e,n);return s&&mt(this),r}async afterMount(){document.addEventListener("click",this.#t,!1),document.addEventListener("keydown",this.#e,!1)}async beforeUnmount(){this.trigger=null}async afterUnmount(){document.removeEventListener("click",this.#t,!1),document.removeEventListener("keydown",this.#e,!1)}};function ts(t,e="config"){const n=(t.getAttribute(`data-${e}`)||"").replace(/'/g,'"');return n?JSON.parse(n):{}}function pe(t){if(typeof t=="string"){const e=document.getElementById(t);if(e)return e;throw new Error(`Element not found with ID: "${t}"`)}else if(t instanceof HTMLElement){if(!t.id)throw new Error("HTMLElement must have an ID");return t}else throw new Error("Invalid argument: query must be a string or HTMLElement")}async function J(t,e,...n){e in t&&typeof t[e]=="function"&&await t[e](...n)}function es(t){return t.split("-").map((e,n)=>n===0?e:e.charAt(0).toUpperCase()+e.slice(1)).join("")}function me(t){return t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}async function F(t,e,n){await J(e,t,n),n&&await J(n,t);for(const s of e.plugins)await J(s,t,{plugin:s,parent:e,entry:n});await e.emit(t,n)}function ns(t){const e=getComputedStyle(t.el),n={},s=t.getSetting("customProps");for(let r=0;r<s.length;r++){const i=ss(),o=t.parent.module.toLowerCase(),a=me(s[r]),l=e.getPropertyValue(`--${i}${o}-${a}`).trim();l&&(n[a]=l)}return n}function ss(){return getComputedStyle(document.body).getPropertyValue("--vb-prefix").trim()}function is(t,e,n="camel"){return e=n==="camel"?es(e):me(e),t.split(".").concat(e).reduce((s,r)=>s?.[r],this)}function rs(t,e={}){const{fallback:n,props:s=["dataConfig","customProps","settings","parent.settings"]}=e;for(const r of s){const i=r!=="customProps"?"camel":"kebab",o=is.call(this,r,t,i);if(o!==void 0)return o}if(n!==void 0)return n;throw new Error(`${this.parent.module} setting does not exist: ${t}`)}const os={events:{},on(t,e,...n){this.events[t]||(this.events[t]=[]),this.events[t].some(s=>s.listener===e)||this.events[t].push({listener:e,args:n})},off(t,e){this.events[t]&&(this.events[t]=this.events[t].filter(n=>n.listener!==e))},async emit(t,e){if(t=t.startsWith("on")?t.slice(2,3).toLowerCase()+t.slice(3):t,!!this.events[t])for(const{listener:n,args:s}of this.events[t])await n(e,...s)}};class as extends Array{constructor(e={}){super(),this.presets=e}applySettings(e){const n=e?.defaults||{},s=this.presets?.[e.name]||{},r=e?.options||{};e.settings={...n,...s,...r}}validate(e){return!("name"in e)||typeof e.name!="string"?(console.error("Plugin requires a name!"),!1):!0}get(e){return this.find(n=>n.name===e)}add(e){if(Array.isArray(e))e.forEach(n=>this.add(n));else if(this.applySettings(e),this.validate(e)){const n=this.findIndex(s=>s.name===e.name);~n?this[n]=e:this.push(e)}}remove(e){const n=this.findIndex(s=>s.name===e);~n&&this.splice(n,1)}}const ls={dataConfig:"config",customProps:[]};class ye{constructor(e,n,s={}){this.parent=e,this.el=pe(n),this.settings={...s},this.dataConfig={},this.customProps={}}get id(){return this.el.id}applySettings(e){return Object.assign(this.settings,e)}getSetting(e,n){return rs.call(this,e,n)}buildDataConfig(){return Object.assign(this.dataConfig,ts(this.el,this.getSetting("dataConfig")))}buildCustomProps(){return Object.assign(this.customProps,ns(this))}async init(e={}){this.applySettings(e),this.buildDataConfig(),this.buildCustomProps()}async destroy(){Object.getOwnPropertyNames(this).forEach(e=>{delete this[e]})}}class cs{constructor(e={}){this.module=this.constructor.name,this.collection=[],this.entryClass=ye,this.settings={...ls,...e},this.plugins=new as(this.settings.presets),this.events={},Object.assign(this,os)}get(e,n="id"){return this.collection.find(s=>s[n]===e)}applySettings(e){return Object.assign(this.settings,e)}async createEntry(e,n){const s=new this.entryClass(this,e,n);return await J(s,"init"),await F("onCreateEntry",this,s),s}async destroyEntry(e){return await F("onDestroyEntry",this,e),await J(e,"destroy"),e}async register(e,n={}){const s=pe(e),r=this.collection.findIndex(i=>i.id===s.id);if(~r){const i=this.collection[r];return i.el=s,typeof i.init=="function"&&await i.init(n),i}else{const i=await this.createEntry(s,n);return this.collection.push(i),await F("onRegisterEntry",this,i),i}}async deregister(e){const n=this.collection.findIndex(s=>s.id===e);if(~n){const s=await this.destroyEntry(this.collection[n]);return await F("onDeregisterEntry",this,this.collection[n]),this.collection.splice(n,1),s}return null}async mount(e={}){this.applySettings(e);for(const s of this.settings?.plugins||[])this.plugins.add(s);for(const s of this.plugins)await J(s,"setup",{plugin:s,parent:this});await F("beforeMount",this);const n=document.querySelectorAll(this.settings.selector);for(const s of n)await this.register(s);return await F("afterMount",this),this}async unmount(){for(await F("beforeUnmount",this);this.collection.length>0;)await this.deregister(this.collection[0].id);await F("afterUnmount",this);for(const e of this.plugins)await J(e,"teardown",{plugin:e,parent:this});for(const e of[...this.plugins])this.plugins.remove(e.name);return this}}const us={selector:".popover",selectorTooltip:".popover_tooltip",selectorArrow:".popover__arrow",stateActive:"is-active",customProps:["placement","event","offset","flip-padding","shift-padding","arrow-padding","toggle-delay"],customEventPrefix:"popover:",placement:"bottom",event:"click",offset:0,flipPadding:0,shiftPadding:0,arrowPadding:0,toggleDelay:0},st=Math.min,Z=Math.max,yt=Math.round,wt=Math.floor,T=t=>({x:t,y:t}),fs={left:"right",right:"left",bottom:"top",top:"bottom"},hs={start:"end",end:"start"};function Rt(t,e,n){return Z(t,st(e,n))}function K(t,e){return typeof t=="function"?t(e):t}function z(t){return t.split("-")[0]}function ct(t){return t.split("-")[1]}function Dt(t){return t==="x"?"y":"x"}function Mt(t){return t==="y"?"height":"width"}const ds=new Set(["top","bottom"]);function I(t){return ds.has(z(t))?"y":"x"}function It(t){return Dt(I(t))}function gs(t,e,n){n===void 0&&(n=!1);const s=ct(t),r=It(t),i=Mt(r);let o=r==="x"?s===(n?"end":"start")?"right":"left":s==="start"?"bottom":"top";return e.reference[i]>e.floating[i]&&(o=vt(o)),[o,vt(o)]}function ps(t){const e=vt(t);return[Ht(t),e,Ht(e)]}function Ht(t){return t.replace(/start|end/g,e=>hs[e])}const we=["left","right"],ve=["right","left"],ms=["top","bottom"],ys=["bottom","top"];function ws(t,e,n){switch(t){case"top":case"bottom":return n?e?ve:we:e?we:ve;case"left":case"right":return e?ms:ys;default:return[]}}function vs(t,e,n,s){const r=ct(t);let i=ws(z(t),n==="start",s);return r&&(i=i.map(o=>o+"-"+r),e&&(i=i.concat(i.map(Ht)))),i}function vt(t){return t.replace(/left|right|bottom|top/g,e=>fs[e])}function bs(t){return{top:0,right:0,bottom:0,left:0,...t}}function be(t){return typeof t!="number"?bs(t):{top:t,right:t,bottom:t,left:t}}function bt(t){const{x:e,y:n,width:s,height:r}=t;return{width:s,height:r,top:n,left:e,right:e+s,bottom:n+r,x:e,y:n}}function Ee(t,e,n){let{reference:s,floating:r}=t;const i=I(e),o=It(e),a=Mt(o),l=z(e),c=i==="y",h=s.x+s.width/2-r.width/2,f=s.y+s.height/2-r.height/2,d=s[a]/2-r[a]/2;let u;switch(l){case"top":u={x:h,y:s.y-r.height};break;case"bottom":u={x:h,y:s.y+s.height};break;case"right":u={x:s.x+s.width,y:f};break;case"left":u={x:s.x-r.width,y:f};break;default:u={x:s.x,y:s.y}}switch(ct(e)){case"start":u[o]-=d*(n&&c?-1:1);break;case"end":u[o]+=d*(n&&c?-1:1);break}return u}const Es=async(t,e,n)=>{const{placement:s="bottom",strategy:r="absolute",middleware:i=[],platform:o}=n,a=i.filter(Boolean),l=await(o.isRTL==null?void 0:o.isRTL(e));let c=await o.getElementRects({reference:t,floating:e,strategy:r}),{x:h,y:f}=Ee(c,s,l),d=s,u={},g=0;for(let p=0;p<a.length;p++){const{name:m,fn:y}=a[p],{x:w,y:v,data:b,reset:E}=await y({x:h,y:f,initialPlacement:s,placement:d,strategy:r,middlewareData:u,rects:c,platform:o,elements:{reference:t,floating:e}});h=w??h,f=v??f,u={...u,[m]:{...u[m],...b}},E&&g<=50&&(g++,typeof E=="object"&&(E.placement&&(d=E.placement),E.rects&&(c=E.rects===!0?await o.getElementRects({reference:t,floating:e,strategy:r}):E.rects),{x:h,y:f}=Ee(c,d,l)),p=-1)}return{x:h,y:f,placement:d,strategy:r,middlewareData:u}};async function xe(t,e){var n;e===void 0&&(e={});const{x:s,y:r,platform:i,rects:o,elements:a,strategy:l}=t,{boundary:c="clippingAncestors",rootBoundary:h="viewport",elementContext:f="floating",altBoundary:d=!1,padding:u=0}=K(e,t),g=be(u),p=a[d?f==="floating"?"reference":"floating":f],m=bt(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(p)))==null||n?p:p.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(a.floating)),boundary:c,rootBoundary:h,strategy:l})),y=f==="floating"?{x:s,y:r,width:o.floating.width,height:o.floating.height}:o.reference,w=await(i.getOffsetParent==null?void 0:i.getOffsetParent(a.floating)),v=await(i.isElement==null?void 0:i.isElement(w))?await(i.getScale==null?void 0:i.getScale(w))||{x:1,y:1}:{x:1,y:1},b=bt(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:y,offsetParent:w,strategy:l}):y);return{top:(m.top-b.top+g.top)/v.y,bottom:(b.bottom-m.bottom+g.bottom)/v.y,left:(m.left-b.left+g.left)/v.x,right:(b.right-m.right+g.right)/v.x}}const xs=t=>({name:"arrow",options:t,async fn(e){const{x:n,y:s,placement:r,rects:i,platform:o,elements:a,middlewareData:l}=e,{element:c,padding:h=0}=K(t,e)||{};if(c==null)return{};const f=be(h),d={x:n,y:s},u=It(r),g=Mt(u),p=await o.getDimensions(c),m=u==="y",y=m?"top":"left",w=m?"bottom":"right",v=m?"clientHeight":"clientWidth",b=i.reference[g]+i.reference[u]-d[u]-i.floating[g],E=d[u]-i.reference[u],S=await(o.getOffsetParent==null?void 0:o.getOffsetParent(c));let G=S?S[v]:0;(!G||!await(o.isElement==null?void 0:o.isElement(S)))&&(G=a.floating[v]||i.floating[g]);const ht=b/2-E/2,X=G/2-p[g]/2-1,H=st(f[y],X),dt=st(f[w],X),tt=H,gt=G-p[g]-dt,$=G/2-p[g]/2+ht,et=Rt(tt,$,gt),q=!l.arrow&&ct(r)!=null&&$!==et&&i.reference[g]/2-($<tt?H:dt)-p[g]/2<0,L=q?$<tt?$-tt:$-gt:0;return{[u]:d[u]+L,data:{[u]:et,centerOffset:$-et-L,...q&&{alignmentOffset:L}},reset:q}}}),$s=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,s;const{placement:r,middlewareData:i,rects:o,initialPlacement:a,platform:l,elements:c}=e,{mainAxis:h=!0,crossAxis:f=!0,fallbackPlacements:d,fallbackStrategy:u="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:p=!0,...m}=K(t,e);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const y=z(r),w=I(a),v=z(a)===a,b=await(l.isRTL==null?void 0:l.isRTL(c.floating)),E=d||(v||!p?[vt(a)]:ps(a)),S=g!=="none";!d&&S&&E.push(...vs(a,p,g,b));const G=[a,...E],ht=await xe(e,m),X=[];let H=((s=i.flip)==null?void 0:s.overflows)||[];if(h&&X.push(ht[y]),f){const $=gs(r,o,b);X.push(ht[$[0]],ht[$[1]])}if(H=[...H,{placement:r,overflows:X}],!X.every($=>$<=0)){var dt,tt;const $=(((dt=i.flip)==null?void 0:dt.index)||0)+1,et=G[$];if(et&&(!(f==="alignment"&&w!==I(et))||H.every(L=>L.overflows[0]>0&&I(L.placement)===w)))return{data:{index:$,overflows:H},reset:{placement:et}};let q=(tt=H.filter(L=>L.overflows[0]<=0).sort((L,V)=>L.overflows[1]-V.overflows[1])[0])==null?void 0:tt.placement;if(!q)switch(u){case"bestFit":{var gt;const L=(gt=H.filter(V=>{if(S){const _=I(V.placement);return _===w||_==="y"}return!0}).map(V=>[V.placement,V.overflows.filter(_=>_>0).reduce((_,pi)=>_+pi,0)]).sort((V,_)=>V[1]-_[1])[0])==null?void 0:gt[0];L&&(q=L);break}case"initialPlacement":q=a;break}if(r!==q)return{reset:{placement:q}}}return{}}}},$e=new Set(["left","top"]);async function Ss(t,e){const{placement:n,platform:s,elements:r}=t,i=await(s.isRTL==null?void 0:s.isRTL(r.floating)),o=z(n),a=ct(n),l=I(n)==="y",c=$e.has(o)?-1:1,h=i&&l?-1:1,f=K(e,t);let{mainAxis:d,crossAxis:u,alignmentAxis:g}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof g=="number"&&(u=a==="end"?g*-1:g),l?{x:u*h,y:d*c}:{x:d*c,y:u*h}}const Cs=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,s;const{x:r,y:i,placement:o,middlewareData:a}=e,l=await Ss(e,t);return o===((n=a.offset)==null?void 0:n.placement)&&(s=a.arrow)!=null&&s.alignmentOffset?{}:{x:r+l.x,y:i+l.y,data:{...l,placement:o}}}}},As=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:s,placement:r}=e,{mainAxis:i=!0,crossAxis:o=!1,limiter:a={fn:m=>{let{x:y,y:w}=m;return{x:y,y:w}}},...l}=K(t,e),c={x:n,y:s},h=await xe(e,l),f=I(z(r)),d=Dt(f);let u=c[d],g=c[f];if(i){const m=d==="y"?"top":"left",y=d==="y"?"bottom":"right",w=u+h[m],v=u-h[y];u=Rt(w,u,v)}if(o){const m=f==="y"?"top":"left",y=f==="y"?"bottom":"right",w=g+h[m],v=g-h[y];g=Rt(w,g,v)}const p=a.fn({...e,[d]:u,[f]:g});return{...p,data:{x:p.x-n,y:p.y-s,enabled:{[d]:i,[f]:o}}}}}},Ls=function(t){return t===void 0&&(t={}),{options:t,fn(e){const{x:n,y:s,placement:r,rects:i,middlewareData:o}=e,{offset:a=0,mainAxis:l=!0,crossAxis:c=!0}=K(t,e),h={x:n,y:s},f=I(r),d=Dt(f);let u=h[d],g=h[f];const p=K(a,e),m=typeof p=="number"?{mainAxis:p,crossAxis:0}:{mainAxis:0,crossAxis:0,...p};if(l){const v=d==="y"?"height":"width",b=i.reference[d]-i.floating[v]+m.mainAxis,E=i.reference[d]+i.reference[v]-m.mainAxis;u<b?u=b:u>E&&(u=E)}if(c){var y,w;const v=d==="y"?"width":"height",b=$e.has(z(r)),E=i.reference[f]-i.floating[v]+(b&&((y=o.offset)==null?void 0:y[f])||0)+(b?0:m.crossAxis),S=i.reference[f]+i.reference[v]+(b?0:((w=o.offset)==null?void 0:w[f])||0)-(b?m.crossAxis:0);g<E?g=E:g>S&&(g=S)}return{[d]:u,[f]:g}}}};function Et(){return typeof window<"u"}function it(t){return Se(t)?(t.nodeName||"").toLowerCase():"#document"}function A(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function O(t){var e;return(e=(Se(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function Se(t){return Et()?t instanceof Node||t instanceof A(t).Node:!1}function P(t){return Et()?t instanceof Element||t instanceof A(t).Element:!1}function R(t){return Et()?t instanceof HTMLElement||t instanceof A(t).HTMLElement:!1}function Ce(t){return!Et()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof A(t).ShadowRoot}const Ps=new Set(["inline","contents"]);function ut(t){const{overflow:e,overflowX:n,overflowY:s,display:r}=k(t);return/auto|scroll|overlay|hidden|clip/.test(e+s+n)&&!Ps.has(r)}const ks=new Set(["table","td","th"]);function Ts(t){return ks.has(it(t))}const Os=[":popover-open",":modal"];function xt(t){return Os.some(e=>{try{return t.matches(e)}catch{return!1}})}const Rs=["transform","translate","scale","rotate","perspective"],Ds=["transform","translate","scale","rotate","perspective","filter"],Ms=["paint","layout","strict","content"];function qt(t){const e=jt(),n=P(t)?k(t):t;return Rs.some(s=>n[s]?n[s]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||Ds.some(s=>(n.willChange||"").includes(s))||Ms.some(s=>(n.contain||"").includes(s))}function Is(t){let e=B(t);for(;R(e)&&!rt(e);){if(qt(e))return e;if(xt(e))return null;e=B(e)}return null}function jt(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Hs=new Set(["html","body","#document"]);function rt(t){return Hs.has(it(t))}function k(t){return A(t).getComputedStyle(t)}function $t(t){return P(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function B(t){if(it(t)==="html")return t;const e=t.assignedSlot||t.parentNode||Ce(t)&&t.host||O(t);return Ce(e)?e.host:e}function Ae(t){const e=B(t);return rt(e)?t.ownerDocument?t.ownerDocument.body:t.body:R(e)&&ut(e)?e:Ae(e)}function ft(t,e,n){var s;e===void 0&&(e=[]),n===void 0&&(n=!0);const r=Ae(t),i=r===((s=t.ownerDocument)==null?void 0:s.body),o=A(r);if(i){const a=Nt(o);return e.concat(o,o.visualViewport||[],ut(r)?r:[],a&&n?ft(a):[])}return e.concat(r,ft(r,[],n))}function Nt(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function Le(t){const e=k(t);let n=parseFloat(e.width)||0,s=parseFloat(e.height)||0;const r=R(t),i=r?t.offsetWidth:n,o=r?t.offsetHeight:s,a=yt(n)!==i||yt(s)!==o;return a&&(n=i,s=o),{width:n,height:s,$:a}}function Ut(t){return P(t)?t:t.contextElement}function ot(t){const e=Ut(t);if(!R(e))return T(1);const n=e.getBoundingClientRect(),{width:s,height:r,$:i}=Le(e);let o=(i?yt(n.width):n.width)/s,a=(i?yt(n.height):n.height)/r;return(!o||!Number.isFinite(o))&&(o=1),(!a||!Number.isFinite(a))&&(a=1),{x:o,y:a}}const qs=T(0);function Pe(t){const e=A(t);return!jt()||!e.visualViewport?qs:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function js(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==A(t)?!1:e}function Y(t,e,n,s){e===void 0&&(e=!1),n===void 0&&(n=!1);const r=t.getBoundingClientRect(),i=Ut(t);let o=T(1);e&&(s?P(s)&&(o=ot(s)):o=ot(t));const a=js(i,n,s)?Pe(i):T(0);let l=(r.left+a.x)/o.x,c=(r.top+a.y)/o.y,h=r.width/o.x,f=r.height/o.y;if(i){const d=A(i),u=s&&P(s)?A(s):s;let g=d,p=Nt(g);for(;p&&s&&u!==g;){const m=ot(p),y=p.getBoundingClientRect(),w=k(p),v=y.left+(p.clientLeft+parseFloat(w.paddingLeft))*m.x,b=y.top+(p.clientTop+parseFloat(w.paddingTop))*m.y;l*=m.x,c*=m.y,h*=m.x,f*=m.y,l+=v,c+=b,g=A(p),p=Nt(g)}}return bt({width:h,height:f,x:l,y:c})}function Ft(t,e){const n=$t(t).scrollLeft;return e?e.left+n:Y(O(t)).left+n}function ke(t,e,n){n===void 0&&(n=!1);const s=t.getBoundingClientRect(),r=s.left+e.scrollLeft-(n?0:Ft(t,s)),i=s.top+e.scrollTop;return{x:r,y:i}}function Ns(t){let{elements:e,rect:n,offsetParent:s,strategy:r}=t;const i=r==="fixed",o=O(s),a=e?xt(e.floating):!1;if(s===o||a&&i)return n;let l={scrollLeft:0,scrollTop:0},c=T(1);const h=T(0),f=R(s);if((f||!f&&!i)&&((it(s)!=="body"||ut(o))&&(l=$t(s)),R(s))){const u=Y(s);c=ot(s),h.x=u.x+s.clientLeft,h.y=u.y+s.clientTop}const d=o&&!f&&!i?ke(o,l,!0):T(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+h.x+d.x,y:n.y*c.y-l.scrollTop*c.y+h.y+d.y}}function Us(t){return Array.from(t.getClientRects())}function Fs(t){const e=O(t),n=$t(t),s=t.ownerDocument.body,r=Z(e.scrollWidth,e.clientWidth,s.scrollWidth,s.clientWidth),i=Z(e.scrollHeight,e.clientHeight,s.scrollHeight,s.clientHeight);let o=-n.scrollLeft+Ft(t);const a=-n.scrollTop;return k(s).direction==="rtl"&&(o+=Z(e.clientWidth,s.clientWidth)-r),{width:r,height:i,x:o,y:a}}function zs(t,e){const n=A(t),s=O(t),r=n.visualViewport;let i=s.clientWidth,o=s.clientHeight,a=0,l=0;if(r){i=r.width,o=r.height;const c=jt();(!c||c&&e==="fixed")&&(a=r.offsetLeft,l=r.offsetTop)}return{width:i,height:o,x:a,y:l}}const Bs=new Set(["absolute","fixed"]);function Vs(t,e){const n=Y(t,!0,e==="fixed"),s=n.top+t.clientTop,r=n.left+t.clientLeft,i=R(t)?ot(t):T(1),o=t.clientWidth*i.x,a=t.clientHeight*i.y,l=r*i.x,c=s*i.y;return{width:o,height:a,x:l,y:c}}function Te(t,e,n){let s;if(e==="viewport")s=zs(t,n);else if(e==="document")s=Fs(O(t));else if(P(e))s=Vs(e,n);else{const r=Pe(t);s={x:e.x-r.x,y:e.y-r.y,width:e.width,height:e.height}}return bt(s)}function Oe(t,e){const n=B(t);return n===e||!P(n)||rt(n)?!1:k(n).position==="fixed"||Oe(n,e)}function _s(t,e){const n=e.get(t);if(n)return n;let s=ft(t,[],!1).filter(a=>P(a)&&it(a)!=="body"),r=null;const i=k(t).position==="fixed";let o=i?B(t):t;for(;P(o)&&!rt(o);){const a=k(o),l=qt(o);!l&&a.position==="fixed"&&(r=null),(i?!l&&!r:!l&&a.position==="static"&&r&&Bs.has(r.position)||ut(o)&&!l&&Oe(t,o))?s=s.filter(c=>c!==o):r=a,o=B(o)}return e.set(t,s),s}function Ws(t){let{element:e,boundary:n,rootBoundary:s,strategy:r}=t;const i=[...n==="clippingAncestors"?xt(e)?[]:_s(e,this._c):[].concat(n),s],o=i[0],a=i.reduce((l,c)=>{const h=Te(e,c,r);return l.top=Z(h.top,l.top),l.right=st(h.right,l.right),l.bottom=st(h.bottom,l.bottom),l.left=Z(h.left,l.left),l},Te(e,o,r));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}}function Qs(t){const{width:e,height:n}=Le(t);return{width:e,height:n}}function Js(t,e,n){const s=R(e),r=O(e),i=n==="fixed",o=Y(t,!0,i,e);let a={scrollLeft:0,scrollTop:0};const l=T(0);function c(){l.x=Ft(r)}if(s||!s&&!i)if((it(e)!=="body"||ut(r))&&(a=$t(e)),s){const u=Y(e,!0,i,e);l.x=u.x+e.clientLeft,l.y=u.y+e.clientTop}else r&&c();i&&!s&&r&&c();const h=r&&!s&&!i?ke(r,a):T(0),f=o.left+a.scrollLeft-l.x-h.x,d=o.top+a.scrollTop-l.y-h.y;return{x:f,y:d,width:o.width,height:o.height}}function zt(t){return k(t).position==="static"}function Re(t,e){if(!R(t)||k(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return O(t)===n&&(n=n.ownerDocument.body),n}function De(t,e){const n=A(t);if(xt(t))return n;if(!R(t)){let r=B(t);for(;r&&!rt(r);){if(P(r)&&!zt(r))return r;r=B(r)}return n}let s=Re(t,e);for(;s&&Ts(s)&&zt(s);)s=Re(s,e);return s&&rt(s)&&zt(s)&&!qt(s)?n:s||Is(t)||n}const Zs=async function(t){const e=this.getOffsetParent||De,n=this.getDimensions,s=await n(t.floating);return{reference:Js(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:s.width,height:s.height}}};function Ks(t){return k(t).direction==="rtl"}const Ys={convertOffsetParentRelativeRectToViewportRelativeRect:Ns,getDocumentElement:O,getClippingRect:Ws,getOffsetParent:De,getElementRects:Zs,getClientRects:Us,getDimensions:Qs,getScale:ot,isElement:P,isRTL:Ks};function Me(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function Gs(t,e){let n=null,s;const r=O(t);function i(){var a;clearTimeout(s),(a=n)==null||a.disconnect(),n=null}function o(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),i();const c=t.getBoundingClientRect(),{left:h,top:f,width:d,height:u}=c;if(a||e(),!d||!u)return;const g=wt(f),p=wt(r.clientWidth-(h+d)),m=wt(r.clientHeight-(f+u)),y=wt(h),w={rootMargin:-g+"px "+-p+"px "+-m+"px "+-y+"px",threshold:Z(0,st(1,l))||1};let v=!0;function b(E){const S=E[0].intersectionRatio;if(S!==l){if(!v)return o();S?o(!1,S):s=setTimeout(()=>{o(!1,1e-7)},1e3)}S===1&&!Me(c,t.getBoundingClientRect())&&o(),v=!1}try{n=new IntersectionObserver(b,{...w,root:r.ownerDocument})}catch{n=new IntersectionObserver(b,w)}n.observe(t)}return o(!0),i}function Xs(t,e,n,s){s===void 0&&(s={});const{ancestorScroll:r=!0,ancestorResize:i=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=s,c=Ut(t),h=r||i?[...c?ft(c):[],...ft(e)]:[];h.forEach(y=>{r&&y.addEventListener("scroll",n,{passive:!0}),i&&y.addEventListener("resize",n)});const f=c&&a?Gs(c,n):null;let d=-1,u=null;o&&(u=new ResizeObserver(y=>{let[w]=y;w&&w.target===c&&u&&(u.unobserve(e),cancelAnimationFrame(d),d=requestAnimationFrame(()=>{var v;(v=u)==null||v.observe(e)})),n()}),c&&!l&&u.observe(c),u.observe(e));let g,p=l?Y(t):null;l&&m();function m(){const y=Y(t);p&&!Me(p,y)&&n(),p=y,g=requestAnimationFrame(m)}return n(),()=>{var y;h.forEach(w=>{r&&w.removeEventListener("scroll",n),i&&w.removeEventListener("resize",n)}),f?.(),(y=u)==null||y.disconnect(),u=null,l&&cancelAnimationFrame(g)}}const ti=Cs,ei=As,ni=$s,si=xs,ii=Ls,ri=(t,e,n)=>{const s=new Map,r={platform:Ys,...n},i={...r.platform,_c:s};return Es(t,e,{...r,platform:i})};function Ie(t,e,n){Object.assign(t.style,{left:e!=null?`${e}px`:"",top:n!=null?`${n}px`:""})}function He(t,e){let n=t.getSetting("toggle-delay");typeof n=="string"&&(n.indexOf(",")>-1&&(n=n.split(",")),n.indexOf(" ")>-1&&(n=n.split(" "))),Array.isArray(n)&&(n=n[e]);const s=Number(n);if(Number.isNaN(s))throw new Error(`Provided delay value is not a number: "${n}"`);return s}function Bt(t){let e;const n=typeof t=="string"?t.trim().split(" ").map(s=>parseFloat(s)).filter(s=>!isNaN(s)):[t];for(let s=0;s<n.length;s++)n[s]=Number(n[s]);switch(n.length){case 1:e=n[0];break;case 2:e={top:n[0],right:n[1],bottom:n[0],left:n[1]};break;case 3:e={top:n[0],right:n[1],bottom:n[2],left:n[1]};break;case 4:e={top:n[0],right:n[1],bottom:n[2],left:n[3]};break;default:e=void 0;break}return e}function oi(t){return{offset:Number(t.getSetting("offset")),flip:{padding:Bt(t.getSetting("flip-padding"))},shift:{padding:Bt(t.getSetting("shift-padding"))},arrow:{selector:t.getSetting("selectorArrow"),element:null,padding:Bt(t.getSetting("arrow-padding"))}}}function qe(t){const e=this.get(t);if(e)return e;throw new Error(`Popover not found in collection with id of "${t}".`)}async function je(t){return t&&t.state==="opened"&&(t.el.inert=!0,t.el.classList.remove(t.parent.settings.stateActive),t.isTooltip||t.trigger?.setAttribute("aria-expanded","false"),t.floatingCleanup(),t.state="closed",t.trigger===t.parent.trigger&&(t.parent.trigger=null),t.el.dispatchEvent(new CustomEvent(t.getSetting("customEventPrefix")+"closed",{detail:t.parent,bubbles:!0})),await t.parent.emit("closed",t)),t}async function Ne(t){const e=[];for(const n of t.collection)n.state==="opened"&&e.push(await n.close());return e}function Ue(t){t.state=="opened"&&setTimeout(()=>(document.activeElement?.closest(`#${t.id}, [aria-controls="${t.id}"], [aria-describedby="${t.id}"]`)||t.close(),t),1)}function ai(t){t.state==="opened"?t.close():(this.trigger=t.trigger,t.open())}function li(t){t.isTooltip&&(t.toggleDelayId&&clearTimeout(t.toggleDelayId),t.close())}function ci(t,e){if(t.isHovered=e,e.type=="focus"&&t.trigger&&!t.trigger.matches(":focus-visible"))return;t.toggleDelayId&&clearTimeout(t.toggleDelayId);const n=t.trigger?.getAttribute("aria-expanded");if(n&&n=="true")return;const s=this.activeHover?0:He(t,0);this.activeHover&&this.activeHover.close(),t.toggleDelayId=setTimeout(()=>{t.id&&t.open()},s)}function ui(t,e){setTimeout(()=>{t.isHovered=e,!t.isHovered&&(t.toggleDelayId&&clearTimeout(t.toggleDelayId),t.toggleDelayId=setTimeout(()=>Ue(t),He(t,1)))},1)}function fi(t){switch(t.key){case"Escape":this.trigger&&this.trigger.focus(),Ne(this);return;case"Tab":this.collection.forEach(e=>{Ue(e)});return;default:return}}function hi(t){const e=this;document.addEventListener("click",function n(s){const r=s.target;r&&(r.closest(`#${t.id}, [aria-controls="${t.id}"], [aria-describedby="${t.id}"]`)?t.el&&!t.el.classList.contains(e.settings.stateActive)&&this.removeEventListener("click",n):(t.el&&t.el.classList.contains(e.settings.stateActive)&&t.close(),this.removeEventListener("click",n)))})}async function Fe(t){t.el.inert=!1,t.el.classList.add(t.parent.settings.stateActive),t.isTooltip||t.trigger?.setAttribute("aria-expanded","true"),t.buildCustomProps();const e=oi(t),n=t.el.querySelector(e.arrow.selector);return e.arrow.element=n||null,t.trigger instanceof HTMLElement&&(t.floatingCleanup=Xs(t.trigger,t.el,()=>{const s=[ni(e.flip),ei({...e.shift,limiter:ii()}),ti(e.offset)];e.arrow.element&&s.push(si({...e.arrow,element:e.arrow.element})),ri(t.trigger,t.el,{placement:t.getSetting("placement"),middleware:s}).then(({x:r,y:i,placement:o,middlewareData:a})=>{if(t.el){if(Ie(t.el,r,i),e.arrow.element&&a.arrow){const{x:l,y:c}=a.arrow;Ie(e.arrow.element,l,c)}t.el.setAttribute("data-floating-placement",o)}})})),t.state="opened",t.getSetting("event")==="click"&&hi.call(t.parent,t),t.el.dispatchEvent(new CustomEvent(t.getSetting("customEventPrefix")+"opened",{detail:t.parent,bubbles:!0})),await t.parent.emit("opened",t),t}class di extends ye{#t;#e;constructor(e,n,s={}){super(e,n,s),this.state="closed",this.toggleDelayId=null,this.trigger=null,this.#t=null,this.#e={el:!1,trigger:!1},this.floatingCleanup=()=>{}}get isTooltip(){return!!this.el.closest(this.getSetting("selectorTooltip"))||this.el.getAttribute("role")=="tooltip"}get isHovered(){return this.#e.el||this.#e.trigger}set isHovered(e){const n=e.type=="mouseenter"?!0:e.type=="mouseleave"?!1:void 0;if(n!=null)switch(e.target){case this.el:this.#e.el=n;break;case this.trigger:this.#e.trigger=n;break}}async open(){return Fe(this)}async close(){return je(this)}async deregister(){return this.parent.deregister(this.id)}registerEventListeners(){this.#t||(this.getSetting("event")==="hover"?(this.#t=[{el:["el","trigger"],type:["mouseenter","focus"],listener:ci.bind(this.parent,this)},{el:["el","trigger"],type:["mouseleave","focusout"],listener:ui.bind(this.parent,this)},{el:["trigger"],type:["click"],listener:li.bind(this.parent,this)}],this.#t.forEach(e=>{e.el.forEach(n=>{e.type.forEach(s=>{this[n].addEventListener(s,e.listener,!1)})})})):(this.#t=[{el:["trigger"],type:["click"],listener:ai.bind(this.parent,this)}],this.#t.forEach(e=>{e.el.forEach(n=>{e.type.forEach(s=>{this[n].addEventListener(s,e.listener,!1)})})})))}deregisterEventListeners(){this.#t&&(this.#t.forEach(e=>{e.el.forEach(n=>{e.type.forEach(s=>{this[n].removeEventListener(s,e.listener,!1)})})}),this.#t=null)}async onCreateEntry(){this.trigger=document.querySelector(`[aria-controls="${this.id}"], [aria-describedby="${this.id}"]`),this.isTooltip?(this.settings.event="hover",this.el.setAttribute("role","tooltip")):this.trigger&&this.trigger instanceof HTMLElement&&this.trigger.setAttribute("aria-expanded","false"),this.registerEventListeners()}async onRegisterEntry(){this.el.classList.contains(this.getSetting("stateActive"))?await this.open():this.el.inert=!0}async onDestroyEntry(){this.state==="opened"&&await this.close(),this.floatingCleanup(),this.deregisterEventListeners()}}class gi extends cs{#t;constructor(e){super({...us,...e}),this.module="Popover",this.entryClass=di,this.trigger=null,this.#t=fi.bind(this)}get active(){return this.get("opened","state")}get activeHover(){return this.collection.find(e=>e.state=="opened"&&e.getSetting("event")=="hover")}async open(e){const n=qe.call(this,e);return Fe(n)}async close(e){const n=e?qe.call(this,e):void 0;return n?je(n):Ne(this)}async afterMount(){document.addEventListener("keydown",this.#t,!1)}async beforeUnmount(){this.trigger=null}async afterUnmount(){document.removeEventListener("keydown",this.#t,!1)}}D.Drawer=Rn,D.Modal=Xn,D.Popover=gi,D.core=un,Object.defineProperty(D,Symbol.toStringTag,{value:"Module"})});
10
10
  //# sourceMappingURL=index.umd.cjs.map