vrembem 4.0.0-next.26 → 4.0.0-next.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dev/index.js +648 -757
- package/dev/index.js.map +1 -1
- package/dev/index.umd.cjs +648 -757
- package/dev/index.umd.cjs.map +1 -1
- package/dist/index.js +1251 -1300
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +3 -3
- package/dist/index.umd.cjs.map +1 -1
- package/package.json +22 -22
package/dist/index.umd.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
(function(x,C){typeof exports=="object"&&typeof module<"u"?C(exports):typeof define=="function"&&define.amd?define(["exports"],C):(x=typeof globalThis<"u"?globalThis:x||self,C(x.vrembem={}))})(this,function(x){"use strict";var Re=x=>{throw TypeError(x)};var Me=(x,C,L)=>C.has(x)||Re("Cannot "+L);var S=(x,C,L)=>(Me(x,C,"read from private field"),L?L.call(x):C.get(x)),I=(x,C,L)=>C.has(x)?Re("Cannot add the same private member more than once"):C instanceof WeakSet?C.add(x):C.set(x,L),$=(x,C,L,et)=>(Me(x,C,"write to private field"),et?et.call(x,L):C.set(x,L),L);var D,xt,lt,U,Z,ct,at,ft,ut,dt;class C{constructor(n,i){I(this,D);this.value=n,$(this,D,i),this.mql=null}get handler(){return S(this,D)}set handler(n){this.mql&&this.mql.removeEventListener("change",S(this,D)),$(this,D,n)}mount(n,i){return n&&(this.value=n),i&&$(this,D,i),this.value?(this.mql=window.matchMedia(`(min-width: ${this.value})`),this.mql.addEventListener("change",S(this,D)),S(this,D).call(this,this.mql),this):this}unmount(){return this.mql?(this.mql.removeEventListener("change",S(this,D)),this.value=null,$(this,D,null),this.mql=null,this):this}}D=new WeakMap;class L{constructor(n={}){I(this,xt);const i=this;this.module=this.constructor.name,this.collection=[],this.settings=Object.assign({dataConfig:"config"},n),$(this,xt,{applySettings(e){return Object.assign(this.settings,e)},getDataConfig(){return Object.assign(this.dataConfig,se(this.el,this.getSetting("dataConfig")))},getCustomProps(){return Object.assign(this.customProps,oe(this.el,i.module,this.customPropKeys))},getSetting(e){const s=le(e),o=ce(e);if("dataConfig"in this&&s in this.dataConfig)return this.dataConfig[s];if("customProps"in this&&o in this.customProps)return this.customProps[o];if("settings"in this&&s in this.settings)return this.settings[s];if("settings"in i&&s in i.settings)return i.settings[s];throw new Error(`${i.module} setting does not exist: ${e}`)},teleport(e=this.getSetting("teleport"),s=this.getSetting("teleportMethod")){return this.returnRef?(console.error("Element has already been teleported:",this.el),!1):(this.returnRef=Nt(this.el,e,s),this.el)},teleportReturn(){return this.returnRef?(this.returnRef=Nt(this.el,this.returnRef),this.el):(console.error("No return reference found:",this.el),!1)}})}createEntry(n,i={}){const e=re(n),s=Object.create(S(this,xt));return Object.assign(s,{id:e==null?void 0:e.id,el:e,settings:{},dataConfig:{},customProps:{},customPropKeys:[],returnRef:null},i),s}async register(n){return await this.deregister(n),this.collection.push(n),this.collection}async deregister(n){const i=this.collection.findIndex(e=>e===n);if(i>=0){const e=this.collection[i];Object.getOwnPropertyNames(e).forEach(s=>{delete e[s]}),this.collection.splice(i,1)}return this.collection}async registerCollection(n){return await Promise.all(Array.from(n,i=>{this.register(i)})),this.collection}async deregisterCollection(){for(;this.collection.length>0;)await this.deregister(this.collection[0]);return this.collection}get(n,i="id"){return this.collection.find(e=>e[i]===n)}}xt=new WeakMap;class et{constructor(n=null,i="[data-focus]"){I(this,lt);I(this,U);I(this,Z);this.el=n,this.selectorFocus=i,$(this,U,Fe.bind(this)),$(this,Z,Ne.bind(this))}get focusable(){return S(this,lt)}set focusable(n){$(this,lt,n),S(this,lt).length?(document.removeEventListener("keydown",S(this,Z)),document.addEventListener("keydown",S(this,U))):(document.removeEventListener("keydown",S(this,U)),document.addEventListener("keydown",S(this,Z)))}get focusableFirst(){return this.focusable[0]}get focusableLast(){return this.focusable[this.focusable.length-1]}mount(n,i){n&&(this.el=n),i&&(this.selectorFocus=i),this.focusable=this.getFocusable(),this.focus()}unmount(){this.el=null,this.focusable=[],document.removeEventListener("keydown",S(this,U)),document.removeEventListener("keydown",S(this,Z))}focus(n=this.el,i=this.selectorFocus){(n.querySelector(i)||n).focus()}getFocusable(n=this.el){const i=[],e=document.activeElement,s=n.scrollTop,o=Ie.join(",");return n.querySelectorAll(o).forEach(l=>{l.focus(),document.activeElement===l&&i.push(l)}),n.scrollTop=s,e.focus(),i}}lt=new WeakMap,U=new WeakMap,Z=new WeakMap;const O=":not([inert])",k=':not([tabindex^="-"])',ht=":not(:disabled)",Ie=[`a[href]${O}${k}`,`area[href]${O}${k}`,`input:not([type="hidden"]):not([type="radio"])${O}${k}${ht}`,`input[type="radio"]${O}${k}${ht}`,`select${O}${k}${ht}`,`textarea${O}${k}${ht}`,`button${O}${k}${ht}`,`details${O} > summary:first-of-type${k}`,`iframe${O}${k}`,`audio[controls]${O}${k}`,`video[controls]${O}${k}`,`[contenteditable]${O}${k}`,`[tabindex]${O}${k}`];function Fe(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 Ne(t){(t.key==="Tab"||t.keyCode===9)&&t.preventDefault()}function Lt(){return getComputedStyle(document.body).getPropertyValue("--vb-prefix").trim()}function It(t,n){const i={fallback:null,element:document.body,...n};if(t.slice(0,2)!=="--"){const s=Lt();s&&(t=`${s}${t}`),t=`--${t}`}const e=getComputedStyle(i.element).getPropertyValue(t).trim();if(e)return e;if(i.fallback)return i.fallback;throw new Error(`CSS variable "${t}" was not found!`)}function se(t,n="config"){const e=(t.getAttribute(`data-${n}`)||"").replace(/'/g,'"');return e?JSON.parse(e):{}}function oe(t,n,i){const e=getComputedStyle(t),s={};for(let o=0;o<i.length;o++){const r=Lt(),l=e.getPropertyValue(`--${r}${n.toLowerCase()}-${i[o]}`).trim();l&&(s[i[o]]=l)}return s}function re(t){if(typeof t=="string")return document.getElementById(t);if(t instanceof HTMLElement)return t}function Ft(t,n=!0){const i=localStorage.getItem(t),e=i?JSON.parse(i):{};return{get(s){return s?e[s]:e},set(s,o){return o?e[s]=o:delete e[s],n&&localStorage.setItem(t,JSON.stringify(e)),e}}}function Nt(t,n,i){const e=n.nodeType===Node.COMMENT_NODE,s=n.nodeType===Node.ELEMENT_NODE;if(n=e||s?n:document.querySelector(n),e&&(i="after"),!n)throw new Error(`Not a valid teleport reference: '${n}'`);if(typeof n[i]!="function")throw new Error(`Not a valid teleport method: '${i}'`);let o=null;return e||(o=document.createComment("teleported #"+t.id),t.before(o)),n[i](t),e&&n.remove(),o}function _e(t){const n={prefix:It("prefix-themes",{fallback:"vb-theme-"}),themes:["root","light","dark"],storeKey:"VB:Profile"};for(const[o]of Object.entries(n))t&&t[o]&&(n[o]=t[o]);const i={onInit(){},onChange(){}};for(const[o]of Object.entries(i))t&&t[o]&&(i[o]=t[o]);const e=Ft(n.storeKey),s={settings:n,add(o){n.themes.push(o)},remove(o){const r=n.themes.indexOf(o);~r&&n.themes.splice(r,1)},callback(o){i[o].call(this)},get class(){return`${n.prefix}${this.theme}`},get classes(){return n.themes.map(o=>`${n.prefix}${o}`)},get themes(){return n.themes},get theme(){return e.get("theme")||"root"},set theme(o){n.themes.includes(o)?this.theme!=o&&(e.set("theme",o),document.documentElement.classList.remove(...this.classes),document.documentElement.classList.add(`${n.prefix}${o}`),this.callback("onChange")):console.error(`Not a valid theme value: "${o}"`)}};return s.callback("onInit"),s}function le(t){return t.split("-").map((n,i)=>i===0?n:n.charAt(0).toUpperCase()+n.slice(1)).join("")}function ce(t){return t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function mt(t,n,i,e="transition-duration"){return new Promise(s=>{if(typeof e=="string"){const o=It(e,{element:t}),r=!!o.includes("ms");e=parseFloat(o)*(r?1:1e3)}t.classList.remove(n.finish),t.classList.add(i.start),setTimeout(()=>{t.classList.add(i.finish),t.classList.remove(i.start),s(t)},e)})}function Be(t,n){n&&document.querySelectorAll(n).forEach(e=>{t?e.style.overflow="hidden":e.style.removeProperty("overflow")})}function Ve(t,n){n&&document.querySelectorAll(n).forEach(e=>{t?(e.inert=!0,e.setAttribute("aria-hidden",!0)):(e.inert=null,e.removeAttribute("aria-hidden"))})}function pt(t,n,i){Ve(!!t,n),Be(!!t,i)}const je=Object.freeze(Object.defineProperty({__proto__:null,Breakpoint:C,Collection:L,FocusTrap:et,cssVar:It,getConfig:se,getCustomProps:oe,getElement:re,getPrefix:Lt,localStore:Ft,teleport:Nt,themeStore:_e,toCamel:le,toKebab:ce,transition:mt,updateGlobalState:pt},Symbol.toStringTag,{value:"Module"})),He={dataOpen:"drawer-open",dataClose:"drawer-close",dataToggle:"drawer-toggle",dataBreakpoint:"drawer-breakpoint",selectorDrawer:".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",breakpoints:null,customEventPrefix:"drawer:",eventListeners:!0,store:!0,storeKey:"VB:DrawerState",setTabindex:!0,teleport:null,teleportMethod:"prepend",transition:!0,transitionDuration:"drawer-transition-duration"};function ze(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 We(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 Ke(t){const n=Lt(),i=t.getAttribute(`data-${this.settings.dataBreakpoint}`);return this.settings.breakpoints&&this.settings.breakpoints[i]?this.settings.breakpoints[i]:getComputedStyle(document.body).getPropertyValue(`--${n}breakpoint-${i}`).trim()?getComputedStyle(document.body).getPropertyValue(`--${n}breakpoint-${i}`).trim():i}function it(t){const n=typeof t=="string"?this.get(t):this.get(t.id);if(n)return n;throw new Error(`Drawer not found in collection with id of "${t.id||t}".`)}function ae(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())}async function Xe(t){const n=t.target.closest(`
|
|
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 Pe=S=>{throw TypeError(S)};var Re=(S,A,O)=>A.has(S)||Pe("Cannot "+O);var w=(S,A,O)=>(Re(S,A,"read from private field"),O?O.call(S):A.get(S)),L=(S,A,O)=>A.has(S)?Pe("Cannot add the same private member more than once"):A instanceof WeakSet?A.add(S):A.set(S,O),C=(S,A,O,yt)=>(Re(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,U,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=Object.keys(t.context.settings);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}async function k(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 De(t,e){e&&document.querySelectorAll(e).forEach(s=>{t?s.style.overflow="hidden":s.style.removeProperty("overflow")})}function Me(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){Me(!!t,e),De(!!t,i)}class le{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",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 k.call(this,"beforeRegister",s),await k.call(s,"beforeRegister"),this.collection.push(s),await k.call(s,"afterRegister"),await k.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 k.call(this,"beforeDeregister",n),await k.call(n,"beforeDeregister",i),Object.getOwnPropertyNames(n).forEach(o=>{o!="beforeDeregister"&&o!="afterDeregister"&&delete n[o]}),this.collection.splice(s,1),await k.call(n,"afterDeregister",i),await k.call(this,"afterDeregister",n)}return this.collection}async mount(e={}){this.applySettings(e),await k.call(this,"beforeMount");const i=document.querySelectorAll(this.settings.selector);for(const s of i)await this.register(s);return await k.call(this,"afterMount"),this}async unmount(){for(await k.call(this,"beforeUnmount");this.collection.length>0;)await this.deregister(this.collection[0].id);return await k.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){const i=A(e),s=O(e);if("dataConfig"in this&&i in this.dataConfig)return this.dataConfig[i];if("customProps"in this&&s in this.customProps)return this.customProps[s];if("settings"in this&&i in this.settings)return this.settings[i];if("settings"in this.context&&i in this.context.settings)return this.context.settings[i];throw new Error(`${this.context.module} setting does not exist: ${e}`)}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 k.call(this,"beforeMount"),this.getSetting("teleport")&&this.teleport(),await k.call(this,"afterMount")}async unmount(e=!1){await k.call(this,"beforeUnmount",e),this.getSetting("teleport")&&this.teleportReturn(),await k.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,Ie.bind(this)),C(this,tt,Ne.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=Fe.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)",Fe=[`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 Ie(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 Ne(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 Be(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 Ve=Object.freeze(Object.defineProperty({__proto__:null,Breakpoint:le,Collection:Rt,CollectionEntry:St,FocusTrap:_t,cssVar:se,getConfig:ne,getCustomProps:oe,getElement:re,getPrefix:Pt,lifecycleHook:k,localStore:zt,setGlobalState:vt,teleport:Wt,themeStore:Be,toCamel:A,toKebab:O,toMilliseconds:yt,transition:xt},Symbol.toStringTag,{value:"Module"})),He={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",breakpoints:null,customEventPrefix:"drawer:",store:!0,storeKey:"VB:DrawerState",setTabindex:!0,teleport:null,teleportMethod:"prepend",transition:!0,transitionDuration:"drawer-transition-duration"};function _e(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 ze(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 We(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 ae(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 je(t){switch(t.mode){case"inline":return Ue.call(this,t);case"modal":return Ke.call(this,t);default:throw new Error(`"${t.mode}" is not a valid drawer mode.`)}}async function Ue(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 ze(t),t.el.dispatchEvent(new CustomEvent(t.getSetting("customEventPrefix")+"switchMode",{detail:this,bubbles:!0})),t}async function Ke(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 Xe 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 le),C(this,ft,"indeterminate"),C(this,ut,"indeterminate"),this.inlineState="indeterminate"}get breakpoint(){return We.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),je.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"),_e(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 Ye(t){const e=t.target.closest(`
|
|
2
2
|
[data-${this.settings.dataOpen}],
|
|
3
3
|
[data-${this.settings.dataToggle}],
|
|
4
4
|
[data-${this.settings.dataClose}]
|
|
5
|
-
`);if(
|
|
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 Ge(t){if(t.key==="Escape"&&this.activeModal)return this.close(this.activeModal.id)}async function ce(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&&ae.call(this,s),s.el.dispatchEvent(new CustomEvent(s.getSetting("customEventPrefix")+"opened",{detail:this,bubbles:!0}))),s}async function fe(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&&ae.call(this,s),s.el.dispatchEvent(new CustomEvent(s.getSetting("customEventPrefix")+"closed",{detail:this,bubbles:!0}))),s}async function Je(t,e,i){const s=nt.call(this,t);return s.state==="closed"?ce.call(this,s,e,i):fe.call(this,s,e,i)}class Ze extends Rt{constructor(i){super({...He,...i});L(this,ht);L(this,gt);this.focusTrap=new _t,C(this,ht,Ye.bind(this)),C(this,gt,Ge.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 Xe(this,i,s)}async open(i,s,n){return ce.call(this,i,s,n)}async close(i,s,n){return fe.call(this,i,s,n)}async toggle(i,s,n){return Je.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 Qe={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",customEventPrefix:"modal:",setTabindex:!0,teleport:null,teleportMethod:"append",transition:!0,transitionDuration:"modal-transition-duration"};class qe 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 ti(t){const e=t.target.closest(`
|
|
6
6
|
[data-${this.settings.dataOpen}],
|
|
7
7
|
[data-${this.settings.dataReplace}],
|
|
8
8
|
[data-${this.settings.dataClose}]
|
|
9
|
-
`);if(n){if(t.preventDefault(),n.matches(`[data-${this.settings.dataOpen}]`)){const i=n.getAttribute(`data-${this.settings.dataOpen}`).trim(),e=wt.call(this,i);return t.target.closest(this.settings.selectorModal)||(this.trigger=n),e.open()}if(n.matches(`[data-${this.settings.dataReplace}]`)){const i=n.getAttribute(`data-${this.settings.dataReplace}`).trim(),e=wt.call(this,i);return t.target.closest(this.settings.selectorModal)||(this.trigger=n),e.replace()}if(n.matches(`[data-${this.settings.dataClose}]`)){const i=n.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 ei(t){if(t.key==="Escape"&&this.active&&!this.active.dialog.matches(this.settings.selectorRequired))return this.close()}async function Vt(t,n=!0){const i=this.collection.findIndex(e=>e.id===t.id);if(i>=0){const e=this.collection[i];n&&e.state==="opened"?await e.close(!1):this.stack.remove(e),e.getSetting("teleport")&&e.teleportReturn(),Object.getOwnPropertyNames(e).forEach(s=>{delete e[s]}),this.collection.splice(i,1)}return this.collection}async function jt(t,n=void 0,i=!0){const e=wt.call(this,t);return this.stack.moveToTop(e),e.state==="closed"&&(e.state="opening",this.stack.add(e),n??e.getSetting("transition")?await mt(e.el,{start:e.getSetting("stateClosing"),finish:e.getSetting("stateClosed")},{start:e.getSetting("stateOpening"),finish:e.getSetting("stateOpened")},e.getSetting("transitionDuration")):(e.el.classList.add(e.getSetting("stateOpened")),e.el.classList.remove(e.getSetting("stateClosed"))),e.state="opened"),i&&$t.call(this),e.el.dispatchEvent(new CustomEvent(e.getSetting("customEventPrefix")+"opened",{detail:this,bubbles:!0})),e}async function Ht(t,n,i=!0){const e=t?wt.call(this,t):this.active;return e&&e.state==="opened"&&(e.state="closing",document.activeElement.blur(),n??e.getSetting("transition")?await mt(e.el,{start:e.getSetting("stateOpening"),finish:e.getSetting("stateOpened")},{start:e.getSetting("stateClosing"),finish:e.getSetting("stateClosed")},e.getSetting("transitionDuration")):(e.el.classList.add(e.getSetting("stateClosed")),e.el.classList.remove(e.getSetting("stateOpened"))),this.stack.remove(e),e.state="closed",i&&$t.call(this),e.el.dispatchEvent(new CustomEvent(e.getSetting("customEventPrefix")+"closed",{detail:this,bubbles:!0}))),e}async function zt(t,n){const i=[];return await Promise.all(this.stack.value.map(async e=>{t&&t===e.id?Promise.resolve():i.push(await Ht.call(this,e,n,!1)),e.trigger=null})),i}async function ue(t,n,i=!0){const e=wt.call(this,t);let s,o;return e.state==="opened"?(s=e,o=await zt.call(this,e.id,n)):(o=zt.call(this,!1,n),s=jt.call(this,e,n,!1),await Promise.all([s,o])),i&&$t.call(this),{opened:s,closed:o}}async function ii(t,n={}){await Vt.call(this,t,!1);const i=this,e=this.createEntry(t);Object.assign(e,{state:"closed",dialog:null,open(o,r){return jt.call(i,this,o,r)},close(o,r){return Ht.call(i,this,o,r)},replace(o,r){return ue.call(i,this,o,r)},deregister(){return Vt.call(i,this)}}),Object.defineProperties(e,Object.getOwnPropertyDescriptors({get isRequired(){return this.dialog.matches(this.getSetting("selectorRequired"))}})),e.applySettings(n),e.getDataConfig();const s=t.querySelector(e.getSetting("selectorDialog"));return e.dialog=s||t,e.dialog.setAttribute("aria-modal","true"),e.dialog.hasAttribute("role")||e.dialog.setAttribute("role","dialog"),e.getSetting("setTabindex")&&e.dialog.setAttribute("tabindex","-1"),e.getSetting("teleport")&&e.teleport(),this.collection.push(e),e.el.classList.contains(e.getSetting("stateOpened"))?await e.open(!1):(e.el.classList.remove(e.getSetting("stateOpening")),e.el.classList.remove(e.getSetting("stateClosing")),e.el.classList.add(e.getSetting("stateClosed"))),e}function ni(t){const n=[];return{get value(){return[...n]},get top(){const i=n[n.length-1];return i||null},updateIndex(){n.forEach((i,e)=>{i.el.style.zIndex=null;const s=getComputedStyle(i.el)["z-index"];i.el.style.zIndex=parseInt(s)+e+1})},updateGlobalState(){pt(this.top,t.selectorInert,t.selectorOverflow),this.updateIndex()},add(i){i.el.style.zIndex=null;const e=getComputedStyle(i.el)["z-index"];i.el.style.zIndex=parseInt(e)+n.length+1,n.push(i),this.updateGlobalState()},remove(i){const e=n.findIndex(s=>s.id===i.id);e>=0&&(i.el.style.zIndex=null,n.splice(e,1),this.updateGlobalState())},moveToTop(i){const e=n.findIndex(s=>s.id===i.id);e>=0&&(n.splice(e,1),this.add(i))}}}class si extends L{constructor(i){super({...qe,...i});I(this,ft);I(this,ut);this.trigger=null,this.focusTrap=new et,this.stack=ni(this.settings),$(this,ft,ti.bind(this)),$(this,ut,ei.bind(this))}get active(){return this.stack.top}async mount(i){i&&(this.settings={...this.settings,...i});const e=document.querySelectorAll(this.settings.selectorModal);return await this.registerCollection(e),this.settings.eventListeners&&this.mountEventListeners(),this}async unmount(){return this.trigger=null,await this.deregisterCollection(),this.settings.eventListeners&&this.unmountEventListeners(),this}mountEventListeners(){document.addEventListener("click",S(this,ft),!1),document.addEventListener("keydown",S(this,ut),!1)}unmountEventListeners(){document.removeEventListener("click",S(this,ft),!1),document.removeEventListener("keydown",S(this,ut),!1)}register(i,e={}){let s=typeof i=="string"?document.getElementById(i):i;return s?ii.call(this,s,e):Promise.reject(new Error(`Failed to register; modal not found with ID of: "${i.id||i}".`))}deregister(i){let e=this.get(i.id||i);return e?Vt.call(this,e):Promise.reject(new Error(`Failed to deregister; modal does not exist in collection with ID of: "${i.id||i}".`))}open(i,e,s){return jt.call(this,i,e,s)}close(i,e,s){return Ht.call(this,i,e,s)}replace(i,e,s){return ue.call(this,i,e,s)}async closeAll(i=!1,e,s=!0){const o=await zt.call(this,i,e);return s&&$t.call(this),o}}ft=new WeakMap,ut=new WeakMap;const oi={selectorPopover:".popover",selectorTooltip:".popover_tooltip",selectorArrow:".popover__arrow",stateActive:"is-active",placement:"bottom",event:"click",offset:0,flipPadding:0,shiftPadding:0,arrowPadding:0,toggleDelay:0,eventListeners:!0,teleport:null,teleportMethod:"append"};function de(t,n,i){Object.assign(t.style,{left:n!=null?`${n}px`:"",top:i!=null?`${i}px`:""})}function ge(t,n){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[n]);const e=Number(i);if(Number.isNaN(e))throw new Error(`Provided delay value is not a number: "${i}"`);return e}function Wt(t){let n;const i=typeof t=="string"?t.trim().split(" "):[t];for(let e=0;e<i.length;e++)i[e]=Number(i[e]);switch(i.length){case 1:n=i[0];break;case 2:n={top:i[0],right:i[1],bottom:i[0],left:i[1]};break;case 3:n={top:i[0],right:i[1],bottom:i[2],left:i[1]};break;case 4:n={top:i[0],right:i[1],bottom:i[2],left:i[3]};break;default:n=!1;break}return n}function ri(t){return{offset:Number(t.getSetting("offset")),flip:{padding:Wt(t.getSetting("flip-padding"))},shift:{padding:Wt(t.getSetting("shift-padding"))},arrow:{element:t.getSetting("selectorArrow"),padding:Wt(t.getSetting("arrow-padding"))}}}function he(t){const n=typeof t=="string"?this.get(t):this.get(t.id);if(n)return n;throw new Error(`Popover not found in collection with id of "${t}".`)}function li(t){return typeof t=="string"?t:typeof t.hasAttribute=="function"?t.closest(this.settings.selectorPopover)?(t=t.closest(this.settings.selectorPopover),t.id):t.hasAttribute("aria-controls")?t.getAttribute("aria-controls"):t.hasAttribute("aria-describedby")?t.getAttribute("aria-describedby"):!1:!1}function ci(t){const n=li.call(this,t);if(n){const i=document.querySelector(`#${n}`),e=document.querySelector(`[aria-controls="${n}"]`)||document.querySelector(`[aria-describedby="${n}"]`);return!e&&!i?{error:new Error(`No popover elements found using the ID: "${n}".`)}:e?i?{popover:i,trigger:e}:{error:new Error(`No popover associated with the provided popover trigger: "${n}".`)}:{error:new Error(`No popover trigger associated with the provided popover: "${n}".`)}}else return{error:new Error("Could not resolve the popover ID.")}}async function Kt(t){const n=t?he.call(this,t):await me.call(this);return n&&n.state==="opened"&&(n.el.inert=!0,n.el.classList.remove(this.settings.stateActive),n.isTooltip||n.trigger.setAttribute("aria-expanded","false"),n.cleanup(),n.state="closed",n.trigger===this.trigger&&(this.trigger=null)),n}async function me(){const t=[];return await Promise.all(this.collection.map(async n=>{n.state==="opened"&&t.push(await Kt.call(this,n))})),t}function pe(t){t.state=="opened"&&setTimeout(()=>{const n=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,!n&&!i&&t.close(),t},1)}function ai(t){t.state==="opened"?t.close():(this.trigger=t.trigger,t.open(),we.call(this,t))}function fi(t){t.isTooltip&&(t.toggleDelayId&&clearTimeout(t.toggleDelayId),t.close())}function ui(t,n){if(t.isHovered=n,n.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 e=this.activeHover?0:ge(t,0);this.activeHover&&this.activeHover.close(),t.toggleDelayId=setTimeout(()=>{t.id&&t.open()},e)}function di(t,n){setTimeout(()=>{t.isHovered=n,!t.isHovered&&(t.toggleDelayId&&clearTimeout(t.toggleDelayId),t.toggleDelayId=setTimeout(()=>{pe.call(this,t)},ge(t,1)))},1)}function gi(t){switch(t.key){case"Escape":this.trigger&&this.trigger.focus(),me.call(this);return;case"Tab":this.collection.forEach(n=>{pe.call(this,n)});return;default:return}}function we(t){const n=this;document.addEventListener("click",function i(e){e.target.closest(`#${t.id}, [aria-controls="${t.id}"], [aria-describedby="${t.id}"]`)?t.el&&!t.el.classList.contains(n.settings.stateActive)&&this.removeEventListener("click",i):(t.el&&t.el.classList.contains(n.settings.stateActive)&&t.close(),this.removeEventListener("click",i))})}async function Xt(t){const n=this.collection.findIndex(i=>i.id===t.id);if(n>=0){const i=this.collection[n];i.state==="opened"&&i.close(),i.cleanup(),be(i),i.getSetting("teleport")&&i.teleportReturn(),Object.getOwnPropertyNames(i).forEach(e=>{delete i[e]}),this.collection.splice(n,1)}return this.collection}function be(t){return t._eventListeners&&(t._eventListeners.forEach(n=>{n.el.forEach(i=>{n.type.forEach(e=>{t[i].removeEventListener(e,n.listener,!1)})})}),delete t._eventListeners),t}const nt=Math.min,X=Math.max,Ot=Math.round,kt=Math.floor,V=t=>({x:t,y:t}),hi={left:"right",right:"left",bottom:"top",top:"bottom"},mi={start:"end",end:"start"};function Yt(t,n,i){return X(t,nt(n,i))}function Y(t,n){return typeof t=="function"?t(n):t}function j(t){return t.split("-")[0]}function bt(t){return t.split("-")[1]}function Gt(t){return t==="x"?"y":"x"}function Jt(t){return t==="y"?"height":"width"}function G(t){return["top","bottom"].includes(j(t))?"y":"x"}function Ut(t){return Gt(G(t))}function pi(t,n,i){i===void 0&&(i=!1);const e=bt(t),s=Ut(t),o=Jt(s);let r=s==="x"?e===(i?"end":"start")?"right":"left":e==="start"?"bottom":"top";return n.reference[o]>n.floating[o]&&(r=Pt(r)),[r,Pt(r)]}function wi(t){const n=Pt(t);return[Zt(t),n,Zt(n)]}function Zt(t){return t.replace(/start|end/g,n=>mi[n])}function bi(t,n,i){const e=["left","right"],s=["right","left"],o=["top","bottom"],r=["bottom","top"];switch(t){case"top":case"bottom":return i?n?s:e:n?e:s;case"left":case"right":return n?o:r;default:return[]}}function vi(t,n,i,e){const s=bt(t);let o=bi(j(t),i==="start",e);return s&&(o=o.map(r=>r+"-"+s),n&&(o=o.concat(o.map(Zt)))),o}function Pt(t){return t.replace(/left|right|bottom|top/g,n=>hi[n])}function yi(t){return{top:0,right:0,bottom:0,left:0,...t}}function ve(t){return typeof t!="number"?yi(t):{top:t,right:t,bottom:t,left:t}}function Tt(t){const{x:n,y:i,width:e,height:s}=t;return{width:e,height:s,top:i,left:n,right:n+e,bottom:i+s,x:n,y:i}}function ye(t,n,i){let{reference:e,floating:s}=t;const o=G(n),r=Ut(n),l=Jt(r),c=j(n),a=o==="y",d=e.x+e.width/2-s.width/2,u=e.y+e.height/2-s.height/2,g=e[l]/2-s[l]/2;let f;switch(c){case"top":f={x:d,y:e.y-s.height};break;case"bottom":f={x:d,y:e.y+e.height};break;case"right":f={x:e.x+e.width,y:u};break;case"left":f={x:e.x-s.width,y:u};break;default:f={x:e.x,y:e.y}}switch(bt(n)){case"start":f[r]-=g*(i&&a?-1:1);break;case"end":f[r]+=g*(i&&a?-1:1);break}return f}const xi=async(t,n,i)=>{const{placement:e="bottom",strategy:s="absolute",middleware:o=[],platform:r}=i,l=o.filter(Boolean),c=await(r.isRTL==null?void 0:r.isRTL(n));let a=await r.getElementRects({reference:t,floating:n,strategy:s}),{x:d,y:u}=ye(a,e,c),g=e,f={},h=0;for(let m=0;m<l.length;m++){const{name:w,fn:p}=l[m],{x:b,y:v,data:E,reset:y}=await p({x:d,y:u,initialPlacement:e,placement:g,strategy:s,middlewareData:f,rects:a,platform:r,elements:{reference:t,floating:n}});d=b??d,u=v??u,f={...f,[w]:{...f[w],...E}},y&&h<=50&&(h++,typeof y=="object"&&(y.placement&&(g=y.placement),y.rects&&(a=y.rects===!0?await r.getElementRects({reference:t,floating:n,strategy:s}):y.rects),{x:d,y:u}=ye(a,g,c)),m=-1)}return{x:d,y:u,placement:g,strategy:s,middlewareData:f}};async function xe(t,n){var i;n===void 0&&(n={});const{x:e,y:s,platform:o,rects:r,elements:l,strategy:c}=t,{boundary:a="clippingAncestors",rootBoundary:d="viewport",elementContext:u="floating",altBoundary:g=!1,padding:f=0}=Y(n,t),h=ve(f),w=l[g?u==="floating"?"reference":"floating":u],p=Tt(await o.getClippingRect({element:(i=await(o.isElement==null?void 0:o.isElement(w)))==null||i?w:w.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(l.floating)),boundary:a,rootBoundary:d,strategy:c})),b=u==="floating"?{x:e,y:s,width:r.floating.width,height:r.floating.height}:r.reference,v=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l.floating)),E=await(o.isElement==null?void 0:o.isElement(v))?await(o.getScale==null?void 0:o.getScale(v))||{x:1,y:1}:{x:1,y:1},y=Tt(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:b,offsetParent:v,strategy:c}):b);return{top:(p.top-y.top+h.top)/E.y,bottom:(y.bottom-p.bottom+h.bottom)/E.y,left:(p.left-y.left+h.left)/E.x,right:(y.right-p.right+h.right)/E.x}}const Si=t=>({name:"arrow",options:t,async fn(n){const{x:i,y:e,placement:s,rects:o,platform:r,elements:l,middlewareData:c}=n,{element:a,padding:d=0}=Y(t,n)||{};if(a==null)return{};const u=ve(d),g={x:i,y:e},f=Ut(s),h=Jt(f),m=await r.getDimensions(a),w=f==="y",p=w?"top":"left",b=w?"bottom":"right",v=w?"clientHeight":"clientWidth",E=o.reference[h]+o.reference[f]-g[f]-o.floating[h],y=g[f]-o.reference[f],T=await(r.getOffsetParent==null?void 0:r.getOffsetParent(a));let Q=T?T[v]:0;(!Q||!await(r.isElement==null?void 0:r.isElement(T)))&&(Q=l.floating[v]||o.floating[h]);const St=E/2-y/2,q=Q/2-m[h]/2-1,z=nt(u[p],q),Et=nt(u[b],q),tt=z,Ct=Q-m[h]-Et,A=Q/2-m[h]/2+St,gt=Yt(tt,A,Ct),B=!c.arrow&&bt(s)!=null&&A!==gt&&o.reference[h]/2-(A<tt?z:Et)-m[h]/2<0,_=B?A<tt?A-tt:A-Ct:0;return{[f]:g[f]+_,data:{[f]:gt,centerOffset:A-gt-_,...B&&{alignmentOffset:_}},reset:B}}}),Ei=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(n){var i,e;const{placement:s,middlewareData:o,rects:r,initialPlacement:l,platform:c,elements:a}=n,{mainAxis:d=!0,crossAxis:u=!0,fallbackPlacements:g,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:h="none",flipAlignment:m=!0,...w}=Y(t,n);if((i=o.arrow)!=null&&i.alignmentOffset)return{};const p=j(s),b=G(l),v=j(l)===l,E=await(c.isRTL==null?void 0:c.isRTL(a.floating)),y=g||(v||!m?[Pt(l)]:wi(l)),T=h!=="none";!g&&T&&y.push(...vi(l,m,h,E));const Q=[l,...y],St=await xe(n,w),q=[];let z=((e=o.flip)==null?void 0:e.overflows)||[];if(d&&q.push(St[p]),u){const A=pi(s,r,E);q.push(St[A[0]],St[A[1]])}if(z=[...z,{placement:s,overflows:q}],!q.every(A=>A<=0)){var Et,tt;const A=(((Et=o.flip)==null?void 0:Et.index)||0)+1,gt=Q[A];if(gt)return{data:{index:A,overflows:z},reset:{placement:gt}};let B=(tt=z.filter(_=>_.overflows[0]<=0).sort((_,W)=>_.overflows[1]-W.overflows[1])[0])==null?void 0:tt.placement;if(!B)switch(f){case"bestFit":{var Ct;const _=(Ct=z.filter(W=>{if(T){const K=G(W.placement);return K===b||K==="y"}return!0}).map(W=>[W.placement,W.overflows.filter(K=>K>0).reduce((K,tn)=>K+tn,0)]).sort((W,K)=>W[1]-K[1])[0])==null?void 0:Ct[0];_&&(B=_);break}case"initialPlacement":B=l;break}if(s!==B)return{reset:{placement:B}}}return{}}}};async function Ci(t,n){const{placement:i,platform:e,elements:s}=t,o=await(e.isRTL==null?void 0:e.isRTL(s.floating)),r=j(i),l=bt(i),c=G(i)==="y",a=["left","top"].includes(r)?-1:1,d=o&&c?-1:1,u=Y(n,t);let{mainAxis:g,crossAxis:f,alignmentAxis:h}=typeof u=="number"?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return l&&typeof h=="number"&&(f=l==="end"?h*-1:h),c?{x:f*d,y:g*a}:{x:g*a,y:f*d}}const Li=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(n){var i,e;const{x:s,y:o,placement:r,middlewareData:l}=n,c=await Ci(n,t);return r===((i=l.offset)==null?void 0:i.placement)&&(e=l.arrow)!=null&&e.alignmentOffset?{}:{x:s+c.x,y:o+c.y,data:{...c,placement:r}}}}},Ai=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(n){const{x:i,y:e,placement:s}=n,{mainAxis:o=!0,crossAxis:r=!1,limiter:l={fn:w=>{let{x:p,y:b}=w;return{x:p,y:b}}},...c}=Y(t,n),a={x:i,y:e},d=await xe(n,c),u=G(j(s)),g=Gt(u);let f=a[g],h=a[u];if(o){const w=g==="y"?"top":"left",p=g==="y"?"bottom":"right",b=f+d[w],v=f-d[p];f=Yt(b,f,v)}if(r){const w=u==="y"?"top":"left",p=u==="y"?"bottom":"right",b=h+d[w],v=h-d[p];h=Yt(b,h,v)}const m=l.fn({...n,[g]:f,[u]:h});return{...m,data:{x:m.x-i,y:m.y-e,enabled:{[g]:o,[u]:r}}}}}},$i=function(t){return t===void 0&&(t={}),{options:t,fn(n){const{x:i,y:e,placement:s,rects:o,middlewareData:r}=n,{offset:l=0,mainAxis:c=!0,crossAxis:a=!0}=Y(t,n),d={x:i,y:e},u=G(s),g=Gt(u);let f=d[g],h=d[u];const m=Y(l,n),w=typeof m=="number"?{mainAxis:m,crossAxis:0}:{mainAxis:0,crossAxis:0,...m};if(c){const v=g==="y"?"height":"width",E=o.reference[g]-o.floating[v]+w.mainAxis,y=o.reference[g]+o.reference[v]-w.mainAxis;f<E?f=E:f>y&&(f=y)}if(a){var p,b;const v=g==="y"?"width":"height",E=["top","left"].includes(j(s)),y=o.reference[u]-o.floating[v]+(E&&((p=r.offset)==null?void 0:p[u])||0)+(E?0:w.crossAxis),T=o.reference[u]+o.reference[v]+(E?0:((b=r.offset)==null?void 0:b[u])||0)-(E?w.crossAxis:0);h<y?h=y:h>T&&(h=T)}return{[g]:f,[u]:h}}}};function Dt(){return typeof window<"u"}function st(t){return Se(t)?(t.nodeName||"").toLowerCase():"#document"}function P(t){var n;return(t==null||(n=t.ownerDocument)==null?void 0:n.defaultView)||window}function F(t){var n;return(n=(Se(t)?t.ownerDocument:t.document)||window.document)==null?void 0:n.documentElement}function Se(t){return Dt()?t instanceof Node||t instanceof P(t).Node:!1}function R(t){return Dt()?t instanceof Element||t instanceof P(t).Element:!1}function N(t){return Dt()?t instanceof HTMLElement||t instanceof P(t).HTMLElement:!1}function Ee(t){return!Dt()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof P(t).ShadowRoot}function vt(t){const{overflow:n,overflowX:i,overflowY:e,display:s}=M(t);return/auto|scroll|overlay|hidden|clip/.test(n+e+i)&&!["inline","contents"].includes(s)}function Oi(t){return["table","td","th"].includes(st(t))}function Rt(t){return[":popover-open",":modal"].some(n=>{try{return t.matches(n)}catch{return!1}})}function Qt(t){const n=qt(),i=R(t)?M(t):t;return i.transform!=="none"||i.perspective!=="none"||(i.containerType?i.containerType!=="normal":!1)||!n&&(i.backdropFilter?i.backdropFilter!=="none":!1)||!n&&(i.filter?i.filter!=="none":!1)||["transform","perspective","filter"].some(e=>(i.willChange||"").includes(e))||["paint","layout","strict","content"].some(e=>(i.contain||"").includes(e))}function ki(t){let n=H(t);for(;N(n)&&!ot(n);){if(Qt(n))return n;if(Rt(n))return null;n=H(n)}return null}function qt(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function ot(t){return["html","body","#document"].includes(st(t))}function M(t){return P(t).getComputedStyle(t)}function Mt(t){return R(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function H(t){if(st(t)==="html")return t;const n=t.assignedSlot||t.parentNode||Ee(t)&&t.host||F(t);return Ee(n)?n.host:n}function Ce(t){const n=H(t);return ot(n)?t.ownerDocument?t.ownerDocument.body:t.body:N(n)&&vt(n)?n:Ce(n)}function yt(t,n,i){var e;n===void 0&&(n=[]),i===void 0&&(i=!0);const s=Ce(t),o=s===((e=t.ownerDocument)==null?void 0:e.body),r=P(s);if(o){const l=te(r);return n.concat(r,r.visualViewport||[],vt(s)?s:[],l&&i?yt(l):[])}return n.concat(s,yt(s,[],i))}function te(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function Le(t){const n=M(t);let i=parseFloat(n.width)||0,e=parseFloat(n.height)||0;const s=N(t),o=s?t.offsetWidth:i,r=s?t.offsetHeight:e,l=Ot(i)!==o||Ot(e)!==r;return l&&(i=o,e=r),{width:i,height:e,$:l}}function ee(t){return R(t)?t:t.contextElement}function rt(t){const n=ee(t);if(!N(n))return V(1);const i=n.getBoundingClientRect(),{width:e,height:s,$:o}=Le(n);let r=(o?Ot(i.width):i.width)/e,l=(o?Ot(i.height):i.height)/s;return(!r||!Number.isFinite(r))&&(r=1),(!l||!Number.isFinite(l))&&(l=1),{x:r,y:l}}const Pi=V(0);function Ae(t){const n=P(t);return!qt()||!n.visualViewport?Pi:{x:n.visualViewport.offsetLeft,y:n.visualViewport.offsetTop}}function Ti(t,n,i){return n===void 0&&(n=!1),!i||n&&i!==P(t)?!1:n}function J(t,n,i,e){n===void 0&&(n=!1),i===void 0&&(i=!1);const s=t.getBoundingClientRect(),o=ee(t);let r=V(1);n&&(e?R(e)&&(r=rt(e)):r=rt(t));const l=Ti(o,i,e)?Ae(o):V(0);let c=(s.left+l.x)/r.x,a=(s.top+l.y)/r.y,d=s.width/r.x,u=s.height/r.y;if(o){const g=P(o),f=e&&R(e)?P(e):e;let h=g,m=te(h);for(;m&&e&&f!==h;){const w=rt(m),p=m.getBoundingClientRect(),b=M(m),v=p.left+(m.clientLeft+parseFloat(b.paddingLeft))*w.x,E=p.top+(m.clientTop+parseFloat(b.paddingTop))*w.y;c*=w.x,a*=w.y,d*=w.x,u*=w.y,c+=v,a+=E,h=P(m),m=te(h)}}return Tt({width:d,height:u,x:c,y:a})}function Di(t){let{elements:n,rect:i,offsetParent:e,strategy:s}=t;const o=s==="fixed",r=F(e),l=n?Rt(n.floating):!1;if(e===r||l&&o)return i;let c={scrollLeft:0,scrollTop:0},a=V(1);const d=V(0),u=N(e);if((u||!u&&!o)&&((st(e)!=="body"||vt(r))&&(c=Mt(e)),N(e))){const g=J(e);a=rt(e),d.x=g.x+e.clientLeft,d.y=g.y+e.clientTop}return{width:i.width*a.x,height:i.height*a.y,x:i.x*a.x-c.scrollLeft*a.x+d.x,y:i.y*a.y-c.scrollTop*a.y+d.y}}function Ri(t){return Array.from(t.getClientRects())}function ie(t,n){const i=Mt(t).scrollLeft;return n?n.left+i:J(F(t)).left+i}function Mi(t){const n=F(t),i=Mt(t),e=t.ownerDocument.body,s=X(n.scrollWidth,n.clientWidth,e.scrollWidth,e.clientWidth),o=X(n.scrollHeight,n.clientHeight,e.scrollHeight,e.clientHeight);let r=-i.scrollLeft+ie(t);const l=-i.scrollTop;return M(e).direction==="rtl"&&(r+=X(n.clientWidth,e.clientWidth)-s),{width:s,height:o,x:r,y:l}}function Ii(t,n){const i=P(t),e=F(t),s=i.visualViewport;let o=e.clientWidth,r=e.clientHeight,l=0,c=0;if(s){o=s.width,r=s.height;const a=qt();(!a||a&&n==="fixed")&&(l=s.offsetLeft,c=s.offsetTop)}return{width:o,height:r,x:l,y:c}}function Fi(t,n){const i=J(t,!0,n==="fixed"),e=i.top+t.clientTop,s=i.left+t.clientLeft,o=N(t)?rt(t):V(1),r=t.clientWidth*o.x,l=t.clientHeight*o.y,c=s*o.x,a=e*o.y;return{width:r,height:l,x:c,y:a}}function $e(t,n,i){let e;if(n==="viewport")e=Ii(t,i);else if(n==="document")e=Mi(F(t));else if(R(n))e=Fi(n,i);else{const s=Ae(t);e={...n,x:n.x-s.x,y:n.y-s.y}}return Tt(e)}function Oe(t,n){const i=H(t);return i===n||!R(i)||ot(i)?!1:M(i).position==="fixed"||Oe(i,n)}function Ni(t,n){const i=n.get(t);if(i)return i;let e=yt(t,[],!1).filter(l=>R(l)&&st(l)!=="body"),s=null;const o=M(t).position==="fixed";let r=o?H(t):t;for(;R(r)&&!ot(r);){const l=M(r),c=Qt(r);!c&&l.position==="fixed"&&(s=null),(o?!c&&!s:!c&&l.position==="static"&&!!s&&["absolute","fixed"].includes(s.position)||vt(r)&&!c&&Oe(t,r))?e=e.filter(d=>d!==r):s=l,r=H(r)}return n.set(t,e),e}function _i(t){let{element:n,boundary:i,rootBoundary:e,strategy:s}=t;const r=[...i==="clippingAncestors"?Rt(n)?[]:Ni(n,this._c):[].concat(i),e],l=r[0],c=r.reduce((a,d)=>{const u=$e(n,d,s);return a.top=X(u.top,a.top),a.right=nt(u.right,a.right),a.bottom=nt(u.bottom,a.bottom),a.left=X(u.left,a.left),a},$e(n,l,s));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function Bi(t){const{width:n,height:i}=Le(t);return{width:n,height:i}}function Vi(t,n,i){const e=N(n),s=F(n),o=i==="fixed",r=J(t,!0,o,n);let l={scrollLeft:0,scrollTop:0};const c=V(0);if(e||!e&&!o)if((st(n)!=="body"||vt(s))&&(l=Mt(n)),e){const f=J(n,!0,o,n);c.x=f.x+n.clientLeft,c.y=f.y+n.clientTop}else s&&(c.x=ie(s));let a=0,d=0;if(s&&!e&&!o){const f=s.getBoundingClientRect();d=f.top+l.scrollTop,a=f.left+l.scrollLeft-ie(s,f)}const u=r.left+l.scrollLeft-c.x-a,g=r.top+l.scrollTop-c.y-d;return{x:u,y:g,width:r.width,height:r.height}}function ne(t){return M(t).position==="static"}function ke(t,n){if(!N(t)||M(t).position==="fixed")return null;if(n)return n(t);let i=t.offsetParent;return F(t)===i&&(i=i.ownerDocument.body),i}function Pe(t,n){const i=P(t);if(Rt(t))return i;if(!N(t)){let s=H(t);for(;s&&!ot(s);){if(R(s)&&!ne(s))return s;s=H(s)}return i}let e=ke(t,n);for(;e&&Oi(e)&&ne(e);)e=ke(e,n);return e&&ot(e)&&ne(e)&&!Qt(e)?i:e||ki(t)||i}const ji=async function(t){const n=this.getOffsetParent||Pe,i=this.getDimensions,e=await i(t.floating);return{reference:Vi(t.reference,await n(t.floating),t.strategy),floating:{x:0,y:0,width:e.width,height:e.height}}};function Hi(t){return M(t).direction==="rtl"}const zi={convertOffsetParentRelativeRectToViewportRelativeRect:Di,getDocumentElement:F,getClippingRect:_i,getOffsetParent:Pe,getElementRects:ji,getClientRects:Ri,getDimensions:Bi,getScale:rt,isElement:R,isRTL:Hi};function Wi(t,n){let i=null,e;const s=F(t);function o(){var l;clearTimeout(e),(l=i)==null||l.disconnect(),i=null}function r(l,c){l===void 0&&(l=!1),c===void 0&&(c=1),o();const{left:a,top:d,width:u,height:g}=t.getBoundingClientRect();if(l||n(),!u||!g)return;const f=kt(d),h=kt(s.clientWidth-(a+u)),m=kt(s.clientHeight-(d+g)),w=kt(a),b={rootMargin:-f+"px "+-h+"px "+-m+"px "+-w+"px",threshold:X(0,nt(1,c))||1};let v=!0;function E(y){const T=y[0].intersectionRatio;if(T!==c){if(!v)return r();T?r(!1,T):e=setTimeout(()=>{r(!1,1e-7)},1e3)}v=!1}try{i=new IntersectionObserver(E,{...b,root:s.ownerDocument})}catch{i=new IntersectionObserver(E,b)}i.observe(t)}return r(!0),o}function Ki(t,n,i,e){e===void 0&&(e={});const{ancestorScroll:s=!0,ancestorResize:o=!0,elementResize:r=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:c=!1}=e,a=ee(t),d=s||o?[...a?yt(a):[],...yt(n)]:[];d.forEach(p=>{s&&p.addEventListener("scroll",i,{passive:!0}),o&&p.addEventListener("resize",i)});const u=a&&l?Wi(a,i):null;let g=-1,f=null;r&&(f=new ResizeObserver(p=>{let[b]=p;b&&b.target===a&&f&&(f.unobserve(n),cancelAnimationFrame(g),g=requestAnimationFrame(()=>{var v;(v=f)==null||v.observe(n)})),i()}),a&&!c&&f.observe(a),f.observe(n));let h,m=c?J(t):null;c&&w();function w(){const p=J(t);m&&(p.x!==m.x||p.y!==m.y||p.width!==m.width||p.height!==m.height)&&i(),m=p,h=requestAnimationFrame(w)}return i(),()=>{var p;d.forEach(b=>{s&&b.removeEventListener("scroll",i),o&&b.removeEventListener("resize",i)}),u==null||u(),(p=f)==null||p.disconnect(),f=null,c&&cancelAnimationFrame(h)}}const Xi=Li,Yi=Ai,Gi=Ei,Ji=Si,Ui=$i,Zi=(t,n,i)=>{const e=new Map,s={platform:zi,...i},o={...s.platform,_c:e};return xi(t,n,{...s,platform:o})};async function Te(t){const n=he.call(this,t);n.el.inert=!1,n.el.classList.add(this.settings.stateActive),n.isTooltip||n.trigger.setAttribute("aria-expanded","true"),n.getCustomProps();const i=ri(n),e=n.el.querySelector(i.arrow.element);return i.arrow.element=e||void 0,n.cleanup=Ki(n.trigger,n.el,()=>{Zi(n.trigger,n.el,{placement:n.getSetting("placement"),middleware:[Gi(i.flip),Yi({...i.shift,limiter:Ui()}),Xi(i.offset),Ji(i.arrow)]}).then(({x:s,y:o,placement:r,middlewareData:l})=>{if(n.el){if(de(n.el,s,o),i.arrow.element&&l.arrow){const{x:c,y:a}=l.arrow;de(i.arrow.element,c,a)}n.el.setAttribute("data-floating-placement",r)}})}),n.state="opened",n}async function Qi(t,n,i={}){await Xt.call(this,t);const e=this,s={el:!1,trigger:!1},o=["placement","event","offset","flip-padding","shift-padding","arrow-padding","toggle-delay"],r=this.createEntry(t,{customPropKeys:o});return Object.assign(r,{state:"closed",trigger:n,toggleDelayId:null,cleanup:()=>{},open(){return Te.call(e,this)},close(){return Kt.call(e,this)},deregister(){return Xt.call(e,this)}}),Object.defineProperties(r,Object.getOwnPropertyDescriptors({set isHovered(l){const c=l.type=="mouseenter"?!0:l.type=="mouseleave"?!1:void 0;if(c!=null)switch(l.target){case this.el:s.el=c;break;case this.trigger:s.trigger=c;break}},get isHovered(){return s.el||s.trigger},get isTooltip(){return!!t.closest(e.settings.selectorTooltip)||t.getAttribute("role")=="tooltip"}})),r.isTooltip&&(r.settings.event="hover"),r.applySettings(i),r.getDataConfig(),r.getCustomProps(),r.isTooltip&&r.el.setAttribute("role","tooltip"),r.isTooltip||r.trigger.setAttribute("aria-expanded","false"),De.call(this,r),r.getSetting("teleport")&&r.teleport(),this.collection.push(r),r.el.classList.contains(this.settings.stateActive)?(await r.open(),we.call(this,r)):r.el.inert=!0,r}function De(t){return t._eventListeners||(t.getSetting("event")==="hover"?(t._eventListeners=[{el:["el","trigger"],type:["mouseenter","focus"],listener:ui.bind(this,t)},{el:["el","trigger"],type:["mouseleave","focusout"],listener:di.bind(this,t)},{el:["trigger"],type:["click"],listener:fi.bind(this,t)}],t._eventListeners.forEach(i=>{i.el.forEach(e=>{i.type.forEach(s=>{t[e].addEventListener(s,i.listener,!1)})})})):(t._eventListeners=[{el:["trigger"],type:["click"],listener:ai.bind(this,t)}],t._eventListeners.forEach(i=>{i.el.forEach(e=>{i.type.forEach(s=>{t[e].addEventListener(s,i.listener,!1)})})}))),t}class qi extends L{constructor(i){super({...oi,...i});I(this,dt);this.trigger=null,$(this,dt,gi.bind(this))}get active(){return this.collection.find(i=>i.state=="opened")}get activeHover(){return this.collection.find(i=>i.state=="opened"&&i.getSetting("event")=="hover")}async mount(i){i&&(this.settings={...this.settings,...i});const e=document.querySelectorAll(this.settings.selectorPopover);return await this.registerCollection(e),this.settings.eventListeners&&this.mountEventListeners(!1),this}async unmount(){return this.trigger=null,await this.deregisterCollection(),this.settings.eventListeners&&this.unmountEventListeners(!1),this}mountEventListeners(i=!0){i&&this.collection.forEach(e=>{De.call(this,e)}),document.addEventListener("keydown",S(this,dt),!1)}unmountEventListeners(i=!0){i&&this.collection.forEach(e=>{be(e)}),document.removeEventListener("keydown",S(this,dt),!1)}register(i,e={}){const s=ci.call(this,i);return s.error?Promise.reject(s.error):Qi.call(this,s.popover,s.trigger,e)}deregister(i){let e=this.get(i.id||i);return e?Xt.call(this,e):Promise.reject(new Error(`Failed to deregister; popover does not exist in collection with ID of: "${i.id||i}".`))}open(i){return Te.call(this,i)}close(i){return Kt.call(this,i)}}dt=new WeakMap,x.Drawer=Qe,x.Modal=si,x.Popover=qi,x.core=je,Object.defineProperty(x,Symbol.toStringTag,{value:"Module"})});
|
|
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 ei(t){if(t.key==="Escape"&&this.active&&!this.active.dialog.matches(this.settings.selectorRequired))return this.close()}async function ue(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 de(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 jt(t,e){const i=[];return await Promise.all(this.stack.value.map(async s=>{t&&t===s.id?Promise.resolve():i.push(await de.call(this,s,e,!1)),s.trigger=null})),i}async function ii(t,e,i=!0){const s=Ct.call(this,t);let n,o;return s.state==="opened"?(n=s,o=await jt.call(this,s.id,e)):(o=jt.call(this,!1,e),n=ue.call(this,s,e,!1),await Promise.all([n,o])),i&&Dt.call(this),{opened:n,closed:o}}function si(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 ni extends Rt{constructor(i){super({...Qe,...i});L(this,mt);L(this,pt);this.trigger=null,this.focusTrap=new _t,C(this,mt,ti.bind(this)),C(this,pt,ei.bind(this)),this.stack=si(this.settings)}get active(){return this.stack.top}async createEntry(i,s){return new qe(this,i,s)}async open(i,s,n){return ue.call(this,i,s,n)}async close(i,s,n){return de.call(this,i,s,n)}async replace(i,s,n){return ii.call(this,i,s,n)}async closeAll(i=!1,s,n=!0){const o=await jt.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 oi={selector:".popover",selectorTooltip:".popover_tooltip",selectorArrow:".popover__arrow",stateActive:"is-active",placement:"bottom",event:"click",offset:0,flipPadding:0,shiftPadding:0,arrowPadding:0,toggleDelay:0,teleport:null,teleportMethod:"append"};function he(t,e,i){Object.assign(t.style,{left:e!=null?`${e}px`:"",top:i!=null?`${i}px`:""})}function ge(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 Ut(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 ri(t){return{offset:Number(t.getSetting("offset")),flip:{padding:Ut(t.getSetting("flip-padding"))},shift:{padding:Ut(t.getSetting("shift-padding"))},arrow:{element:t.getSetting("selectorArrow"),padding:Ut(t.getSetting("arrow-padding"))}}}function me(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 pe(t){const e=t?me.call(this,t):await we.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 we(){const t=[];return await Promise.all(this.collection.map(async e=>{e.state==="opened"&&t.push(await pe.call(this,e))})),t}function be(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 li(t){t.state==="opened"?t.close():(this.trigger=t.trigger,t.open())}function ai(t){t.isTooltip&&(t.toggleDelayId&&clearTimeout(t.toggleDelayId),t.close())}function ci(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:ge(t,0);this.activeHover&&this.activeHover.close(),t.toggleDelayId=setTimeout(()=>{t.id&&t.open()},s)}function fi(t,e){setTimeout(()=>{t.isHovered=e,!t.isHovered&&(t.toggleDelayId&&clearTimeout(t.toggleDelayId),t.toggleDelayId=setTimeout(()=>{be.call(this,t)},ge(t,1)))},1)}function ui(t){switch(t.key){case"Escape":this.trigger&&this.trigger.focus(),we.call(this);return;case"Tab":this.collection.forEach(e=>{be.call(this,e)});return;default:return}}function di(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 hi extends St{constructor(i,s,n={}){super(i,s,n);L(this,F);L(this,U);this.state="closed",this.toggleDelayId=null,this.trigger=null,C(this,F,null),C(this,U,{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,U).el||w(this,U).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,U).el=s;break;case this.trigger:w(this,U).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:ci.bind(this.context,this)},{el:["el","trigger"],type:["mouseleave","focusout"],listener:fi.bind(this.context,this)},{el:["trigger"],type:["click"],listener:ai.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:li.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,U=new WeakMap;const ot=Math.min,G=Math.max,Mt=Math.round,Ft=Math.floor,z=t=>({x:t,y:t}),gi={left:"right",right:"left",bottom:"top",top:"bottom"},mi={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 pi(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 wi(t){const e=It(t);return[Jt(t),e,Jt(e)]}function Jt(t){return t.replace(/start|end/g,e=>mi[e])}function bi(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 yi(t,e,i,s){const n=At(t);let o=bi(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=>gi[e])}function xi(t){return{top:0,right:0,bottom:0,left:0,...t}}function ye(t){return typeof t!="number"?xi(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 xe(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 vi=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}=xe(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}=xe(c,h,a)),m=-1)}return{x:d,y:u,placement:h,strategy:n,middlewareData:f}};async function ve(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=ye(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 Si=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=ye(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,$=et/2-m[g]/2+Lt,bt=Kt(st,$,Tt),_=!a.arrow&&At(n)!=null&&$!==bt&&o.reference[g]/2-($<st?K:Ot)-m[g]/2<0,H=_?$<st?$-st:$-Tt:0;return{[f]:h[f]+H,data:{[f]:bt,centerOffset:$-bt-H,..._&&{alignmentOffset:H}},reset:_}}}),Ei=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)]:wi(l)),D=g!=="none";!h&&D&&v.push(...yi(l,m,g,E));const et=[l,...v],Lt=await ve(e,b),it=[];let K=((s=o.flip)==null?void 0:s.overflows)||[];if(d&&it.push(Lt[p]),u){const $=pi(n,r,E);it.push(Lt[$[0]],Lt[$[1]])}if(K=[...K,{placement:n,overflows:it}],!it.every($=>$<=0)){var Ot,st;const $=(((Ot=o.flip)==null?void 0:Ot.index)||0)+1,bt=et[$];if(bt)return{data:{index:$,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,ts)=>Y+ts,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 Ci(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 Ai=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 Ci(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}}}}},ki=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 ve(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}}}}}},$i=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 Se(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=(Se(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function Se(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 Ee(t){return!Bt()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof R(t).ShadowRoot}function kt(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 Li(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 Oi(t){let e=j(t);for(;V(e)&&!lt(e);){if(Zt(e))return e;if(Vt(e))return null;e=j(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 j(t){if(rt(t)==="html")return t;const e=t.assignedSlot||t.parentNode||Ee(t)&&t.host||B(t);return Ee(e)?e.host:e}function Ce(t){const e=j(t);return lt(e)?t.ownerDocument?t.ownerDocument.body:t.body:V(e)&&kt(e)?e:Ce(e)}function $t(t,e,i){var s;e===void 0&&(e=[]),i===void 0&&(i=!0);const n=Ce(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||[],kt(n)?n:[],l&&i?$t(l):[])}return e.concat(n,$t(n,[],i))}function qt(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function Ae(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}=Ae(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 Ti=z(0);function ke(t){const e=R(t);return!Qt()||!e.visualViewport?Ti:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function Pi(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=Pi(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 Ri(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"||kt(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 Di(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 Mi(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 Fi(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 Ii(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 $e(t,e,i){let s;if(e==="viewport")s=Fi(t,i);else if(e==="document")s=Mi(B(t));else if(I(e))s=Ii(e,i);else{const n=ke(t);s={...e,x:e.x-n.x,y:e.y-n.y}}return Nt(s)}function Le(t,e){const i=j(t);return i===e||!I(i)||lt(i)?!1:N(i).position==="fixed"||Le(i,e)}function Ni(t,e){const i=e.get(t);if(i)return i;let s=$t(t,[],!1).filter(l=>I(l)&&rt(l)!=="body"),n=null;const o=N(t).position==="fixed";let r=o?j(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)||kt(r)&&!a&&Le(t,r))?s=s.filter(d=>d!==r):n=l,r=j(r)}return e.set(t,s),s}function Bi(t){let{element:e,boundary:i,rootBoundary:s,strategy:n}=t;const r=[...i==="clippingAncestors"?Vt(e)?[]:Ni(e,this._c):[].concat(i),s],l=r[0],a=r.reduce((c,d)=>{const u=$e(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},$e(e,l,n));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}}function Vi(t){const{width:e,height:i}=Ae(t);return{width:e,height:i}}function Hi(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"||kt(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 Oe(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 Te(t,e){const i=R(t);if(Vt(t))return i;if(!V(t)){let n=j(t);for(;n&&!lt(n);){if(I(n)&&!ie(n))return n;n=j(n)}return i}let s=Oe(t,e);for(;s&&Li(s)&&ie(s);)s=Oe(s,e);return s&<(s)&&ie(s)&&!Zt(s)?i:s||Oi(t)||i}const _i=async function(t){const e=this.getOffsetParent||Te,i=this.getDimensions,s=await i(t.floating);return{reference:Hi(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:s.width,height:s.height}}};function zi(t){return N(t).direction==="rtl"}const Wi={convertOffsetParentRelativeRectToViewportRelativeRect:Ri,getDocumentElement:B,getClippingRect:Bi,getOffsetParent:Te,getElementRects:_i,getClientRects:Di,getDimensions:Vi,getScale:at,isElement:I,isRTL:zi};function ji(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 Ui(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?$t(c):[],...$t(e)]:[];d.forEach(p=>{n&&p.addEventListener("scroll",i,{passive:!0}),o&&p.addEventListener("resize",i)});const u=c&&l?ji(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 Ki=Ai,Xi=ki,Yi=Ei,Gi=Si,Ji=$i,Zi=(t,e,i)=>{const s=new Map,n={platform:Wi,...i},o={...n.platform,_c:s};return vi(t,e,{...n,platform:o})};async function Qi(t){const e=me.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=ri(e),s=e.el.querySelector(i.arrow.element);return i.arrow.element=s||void 0,e.floatingCleanup=Ui(e.trigger,e.el,()=>{Zi(e.trigger,e.el,{placement:e.getSetting("placement"),middleware:[Yi(i.flip),Xi({...i.shift,limiter:Ji()}),Ki(i.offset),Gi(i.arrow)]}).then(({x:n,y:o,placement:r,middlewareData:l})=>{if(e.el){if(he(e.el,n,o),i.arrow.element&&l.arrow){const{x:a,y:c}=l.arrow;he(i.arrow.element,a,c)}e.el.setAttribute("data-floating-placement",r)}})}),e.state="opened",e.getSetting("event")==="click"&&di.call(this,e),e}class qi extends Rt{constructor(i={}){super({...oi,...i});L(this,wt);this.trigger=null,C(this,wt,ui.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 hi(this,i,s)}async open(i){return Qi.call(this,i)}async close(i){return pe.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=Ze,S.Modal=ni,S.Popover=qi,S.core=Ve,Object.defineProperty(S,Symbol.toStringTag,{value:"Module"})});
|
|
10
10
|
//# sourceMappingURL=index.umd.cjs.map
|