hyperfloat 1.0.44 → 1.0.45

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,5 +1,5 @@
1
1
  /*!
2
- * Hyperfloat 1.0.44
2
+ * Hyperfloat 1.0.45
3
3
  * https://trivonui.com/hyperfloat
4
4
  *
5
5
  * Copyright 2026 — Felipe Otto (Trivon UI)
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Hyperfloat 1.0.44
2
+ * Hyperfloat 1.0.45
3
3
  * https://trivonui.com/hyperfloat
4
4
  *
5
5
  * Copyright 2026 — Felipe Otto (Trivon UI)
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Hyperfloat 1.0.44
2
+ * Hyperfloat 1.0.45
3
3
  * https://trivonui.com/hyperfloat
4
4
  *
5
5
  * Copyright 2026 — Felipe Otto (Trivon UI)
@@ -5766,7 +5766,7 @@ var Hyperfloat = (function () {
5766
5766
  //console.log('Created:', i.id);
5767
5767
  }
5768
5768
 
5769
- var version = "1.0.44";
5769
+ var version = "1.0.45";
5770
5770
  var pkg = {
5771
5771
  version: version};
5772
5772
 
@@ -1,9 +1,9 @@
1
1
  /*!
2
- * Hyperfloat 1.0.44
2
+ * Hyperfloat 1.0.45
3
3
  * https://trivonui.com/hyperfloat
4
4
  *
5
5
  * Copyright 2026 — Felipe Otto (Trivon UI)
6
6
  * Restored under the MIT License
7
7
  */
8
- var Hyperfloat=function(){"use strict";var e=["center","top","top-start","top-end","right","right-start","right-end","bottom","bottom-start","bottom-end","left","left-start","left-end"];const t={};["onBeforeInit","onInit","onAfterInit","onReady","onSync","onDestroy","onBeforeOpen","onOpen","onAfterOpen","onBeforeClose","onClose","onAfterClose","onRefresh","onUpdate","onMove"].forEach(e=>{t[e]={type:["null","function"],default:null}});var n={id:{type:"string",default:""},meta:{type:["null","object"],default:{type:"default",variant:"default",role:"dialog"}},accessibility:{type:["null","object"],default:{role:"dialog",label:"dialog",modal:!1}},anchor:{type:["string"],values:["viewport","element","pointer"],default:"viewport"},open:{type:["null","string","element","node","nodeList","array","object"],default:null},close:{type:["null","string","element","node","nodeList","array"],default:null},ignoreCloseAll:{type:"boolean",default:!1},autoOpen:{type:"boolean",default:!1},destroyAfterClose:{type:"boolean",default:!1},overlay:{type:["boolean","object"],default:null},placement:{type:"string",values:e,default:"center"},boundaryPadding:{type:["string","number","object","null"],default:0},draggable:{type:["boolean","object"],default:null},offset:{type:["string","number","object","null"],default:null},flip:{type:["object","boolean","null"],default:null},shift:{type:["object","boolean","null"],default:null},dismiss:{type:"object",default:{outsideClick:!1,outsideWheel:!1,escapeKey:!1,pointerLeave:!1,closeWithParent:!1,timeout:null,idleTimeout:null}},size:{type:["string","number","object"],default:"small"},breakpoints:{type:"object",default:{}},content:{type:["null","string","function","node"],default:null},header:{type:["null","string","function","node"],default:null},footer:{type:["null","string","function","node"],default:null},vars:{type:["null","object"],default:{}},interpolate:{type:["null","function"],default:null},debug:{type:"boolean",default:!1},...t};function o(e,t={}){if("function"==typeof e){return o(e.call(t),t)}if(e instanceof Promise)return o(e,t);if(e instanceof Node)return e;if("string"==typeof e){const t=e.trim();if(/^<.+?>/.test(t)){const e=document.createElement("div");e.innerHTML=t;const n=document.createDocumentFragment();for(;e.firstChild;)n.appendChild(e.firstChild);return n}return document.createTextNode(t)}return e}function s(e,t={},n=null){if(!e)return null;const s=o(e,t);if(!s)return null;if(!n){const e=document.querySelector("._trivon-ui-hyperfloat");let t=e.querySelector("[data-hyperfloat-sandbox]");t||(t=document.createElement("div"),t.dataset.hyperfloatSandbox="",e.appendChild(t)),n=t}let i;return s instanceof DocumentFragment?(i=Array.from(s.childNodes),n.appendChild(s)):Array.isArray(s)?(i=s,n.append(...s)):s instanceof Node&&(i=[s],n.appendChild(s)),i?.[0]||null}function i(e,t={}){const n=document.createElement(e);if(t.class){const e=Array.isArray(t.class)?t.class:t.class.trim().split(/\s+/);n.classList.add(...e)}t.attrs&&Object.entries(t.attrs).forEach(([e,t])=>n.setAttribute(e,t)),t.text&&(n.textContent=t.text);const o=t.html??t.innerHTML??t.innerHtml??t.content??null;if(o&&s(o,{},n),t.style&&this.applyStyle(n,t.style),!t.appendTo&&!t.prependTo){const e=document.querySelector("._trivon-ui-hyperfloat");let t=e.querySelector("[data-hyperfloat-sandbox]");t||(t=document.createElement("div"),t.dataset.hyperfloatSandbox="",e.appendChild(t)),t.appendChild(n)}return t.appendTo&&t.appendTo.appendChild(n),t.prependTo&&t.prependTo.prepend(n),n}function r(e,t=("undefined"!=typeof document?document:null),n=!1){if(!e)return[];const o="undefined"!=typeof Element,s=e=>o&&e instanceof Element;if(s(e))return[e];const i="string"==typeof t&&"undefined"!=typeof document?document.querySelector(t):t,r=new Set,a=e=>{if(e)if(s(e))r.add(e);else if("string"!=typeof e){if(Array.isArray(e)||"object"==typeof e&&"number"==typeof e.length&&"function"!=typeof e)for(let t=0;t<e.length;t++)a(e[t])}else{if(n)return void r.add(e);if(i&&"function"==typeof i.querySelectorAll)try{const t=i.querySelectorAll(e);for(let e=0;e<t.length;e++)r.add(t[e])}catch{}}};return a(e),Array.from(r)}function a({prefix:e="uuid",blacklist:t=[]}={}){let n="";return n="undefined"!=typeof crypto&&"function"==typeof crypto.randomUUID?`${e}-${crypto.randomUUID()}`:"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}),t.includes(n)?a({prefix:e,blacklist:t}):n}function l(e){return null===e?"null":Array.isArray(e)?"array":"undefined"!=typeof Node&&e instanceof Node?"node":"object"==typeof e?"object":typeof e}function c(e){if("string"==typeof e){const t=e.trim();if(/^-?[\d.]+(px|%|em|rem|vh|vw)$/.test(t)||/^(var|calc|min|max|clamp)\(.+\)$/.test(t))return t;const n=parseHyperfloat(t);return isNaN(n)?null:`${n}px`}return"number"==typeof e?`${e}px`:"0px"}function d(e){"number"==typeof e&&(e=`${e}px`);const t=document.createElement("div");t.style.all="initial",t.style.position="absolute",t.style.visibility="hidden",t.style.pointerEvents="none",t.style.width=e,document.body.appendChild(t);const n=getComputedStyle(t).width;document.body.removeChild(t);const o=parseHyperfloat(n);return isNaN(o)?0:o}function u(e){if("string"==typeof e){const t=e.trim().split(/\s+/);if(1===t.length){const e=c(t[0]);return{width:e,height:e}}if(2===t.length)return{width:c(t[0]),height:c(t[1])}}if("number"==typeof e){const t=c(e);return{width:t,height:t}}return"object"==typeof e&&null!==e?{width:c(e?.width),height:c(e?.height)}:{width:"auto",height:"auto"}}function f(e,t=4e3){return Math.max(0,Math.trunc(Number(e??t)))}function p(e,t={}){const o=n,s={};for(const[e,n]of Object.entries(o)){let o=t[e];const i=Array.isArray(n.type)?n.type:[n.type];i.push("undefined");const r=l(o);if(i.includes(r)){if(!0===n.normalizeArray&&"string"===r&&(o=[o]),n.itemType&&Array.isArray(o)){if(o.filter(e=>l(e)!==n.itemType).length){console.warn(`[Trivon Ui - Hyperfloat] Invalid item type for "${e}".`,`Expected items of type: ${n.itemType}`),s[e]=structuredClone(n.default);continue}}if(n.values)if(Array.isArray(o)){const t=o.filter(e=>!n.values.includes(e));if(t.length){console.warn(`[Trivon Ui - Hyperfloat] Invalid values for "${e}".`,`Expected only: ${n.values.join(", ")}`,`Received invalid: ${t.join(", ")}`),s[e]=structuredClone(n.default);continue}}else if(!n.values.includes(o)){console.warn(`[Trivon Ui - Hyperfloat] Invalid value for "${e}".`,`Expected one of: ${n.values.join(", ")}`,`Received: ${o}`),s[e]=structuredClone(n.default);continue}void 0!==o&&(s[e]=o)}else console.warn(`[Trivon Ui - Hyperfloat] Invalid type for "${e}".`,`Expected: ${i.join(", ")}`,`Received: ${r}`),s[e]=structuredClone(n.default)}return s}function h(e,t=!1){let n=!1;if(!t)for(const[t,o]of e._instancesMap)if("pointer"===o.anchor&&o.opened){n=!0;break}t||n?(function(e){if(!e._config.autoRaf||e._state.autoRafStarted)return;e._state.autoRafStarted=!0;const t=n=>{e._config.autoRaf&&e._state.autoRafStarted&&(e._raf(n),requestAnimationFrame(t))};requestAnimationFrame(t)}(e),function(e){e._state.pointerTrackingStarted||(e._state.pointerTrackingStarted=!0,window.addEventListener("pointermove",e._handlers.pointermove,{passive:!0}))}(e)):(function(e){e._config.autoRaf&&e._state.autoRafStarted&&(e._state.autoRafStarted=!1)}(e),function(e){e._state.pointerTrackingStarted&&(e._state.pointerTrackingStarted=!1,window.removeEventListener("pointermove",e._handlers.pointermove))}(e))}function y(e){const t=["auto","small","medium","large","full"];if("object"==typeof e&&null!==e)return{type:e.type??"custom",width:e.width??"100%",height:e.height??"100%"};if("string"==typeof e){const n=e.trim();if(t.includes(n))return{type:"preset",width:n,height:n}}return{type:"custom",...u(e)}}function m(t,n){if("string"==typeof t){const n=t.trim();if(e.includes(n))return n}return"viewport"===n?"center":"bottom"}function _(e){return"boolean"==typeof e&&null!==e?{enabled:e,color:"black",blur:!0}:"object"==typeof e&&null!==e?{enabled:!0,color:e.color||"black",blur:!1!==e.blur}:{enabled:!1,color:"black",blur:!0}}function g(e){return"object"==typeof e&&null!==e?{outsideClick:!!e.outsideClick,outsideWheel:!!e.outsideWheel,escapeKey:!!e.escapeKey,pointerLeave:!(!e.pointerLeave&&!e.mouseLeave),closeWithParent:!!e.closeWithParent,timeout:e.timeout?f(e.timeout):null,idleTimeout:e.idleTimeout&&void 0===e.timeout?f(e.idleTimeout):null}:{outsideClick:!1,outsideWheel:!1,escapeKey:!1,pointerLeave:!1,closeWithParent:!1,timeout:null,idleTimeout:null}}function b(e){if(!e)return[];let t=e,n="click";var o;"object"!=typeof e||Array.isArray(e)||(o=e,"undefined"!=typeof Element&&o instanceof Element)||(e=>"undefined"!=typeof NodeList&&e instanceof NodeList||"undefined"!=typeof HTMLCollection&&e instanceof HTMLCollection)(e)||!("el"in e)||(t=e.el,"string"==typeof e.event&&e.event.trim()&&(n=e.event.trim()));return n={mouseenter:"pointerenter",mousemove:"pointermove"}[n]||n,["click","pointerenter","pointermove"].includes(n)||(n="click"),r(t).map(e=>({el:e,event:n}))}function v(e){const t=e.closest("[data-hyperfloat-id]");return t?t.dataset.hyperfloatId??null:null}function x(e){if("number"==typeof e)return{mainAxis:e,crossAxis:e,alignmentAxis:null};if("string"==typeof e){return{mainAxis:d(c(e)),crossAxis:0,alignmentAxis:null}}if("object"==typeof e&&null!==e){let t=d(c(e.mainAxis??0)),n=d(c(e.crossAxis??0)),o=e.alignmentAxis?d(c(e.alignmentAxis??0)):null;return null!==o&&(n=0),{mainAxis:t,crossAxis:n,alignmentAxis:o}}return null}function w(e){return"boolean"==typeof e?{mainAxis:e,crossAxis:e}:"object"==typeof e&&null!==e?{mainAxis:!0===e.mainAxis,crossAxis:!0===e.crossAxis}:null}function A(e){return w(e)}function T(e){return w(e)}function k(e){return null==e?0:function(e){if("string"==typeof e){const t=e.trim().split(/\s+/);if(1===t.length){const e=d(c(t[0]));return{top:e,right:e,bottom:e,left:e}}if(2===t.length){const e=d(c(t[0])),n=d(c(t[1]));return{top:e,right:n,bottom:e,left:n}}if(3===t.length){const e=d(c(t[0])),n=d(c(t[1]));return{top:e,right:n,bottom:d(c(t[2])),left:n}}if(4===t.length){const e=d(c(t[0])),n=d(c(t[1])),o=d(c(t[2]));return{top:e,right:d(c(t[3])),bottom:o,left:n}}}if("number"==typeof e){const t=d(c(e));return{top:t,right:t,bottom:t,left:t}}return"object"==typeof e&&null!==e?{top:d(c(e?.top)),right:d(c(e?.right)),bottom:d(c(e?.bottom)),left:d(c(e?.left))}:{top:0,bottom:0,left:0,right:0}}(e)}function R(e){return"object"==typeof e&&null!==e&&Object.entries(e).length?{role:e.role??"dialog",label:e.label??"dialog",modal:e.modal??!1}:{role:"dialog",label:"dialog",modal:!1}}function M(e){return"object"==typeof e&&null!==e?{...e,type:e.type??"default",variant:e.variant??"default",role:e.role??"default"}:{type:"default",variant:"default",role:"dialog"}}function C(e,t){return"viewport"!==t?{enabled:!1,bounds:!1,handle:null}:"boolean"==typeof e&&null!==e?{enabled:e,bounds:!1,handle:null}:"object"==typeof e&&null!==e?{enabled:!0,bounds:!0===e.bounds,handle:null}:{enabled:!1,bounds:!1,handle:null}}function I(e){return"function"==typeof e||"string"==typeof e||e instanceof Node?e:null}function P(e,t={},n=[]){return{...void 0!==t.meta&&!n.includes("meta")&&{meta:M(t.meta??allowedValues.meta.default)},...void 0!==t.accessibility&&!n.includes("accessibility")&&{accessibility:R(t.accessibility??allowedValues.accessibility.default)},...void 0!==t.dismiss&&!n.includes("dismiss")&&{dismiss:g(t.dismiss??allowedValues.dismiss.default)},...void 0!==t.destroyAfterClose&&!n.includes("destroyAfterClose")&&{destroyAfterClose:!0===t.destroyAfterClose},...void 0!==t.autoOpen&&!n.includes("autoOpen")&&{autoOpen:!0===t.autoOpen},...void 0!==t.ignoreCloseAll&&!n.includes("ignoreCloseAll")&&{ignoreCloseAll:!0===t.ignoreCloseAll},...void 0!==t.overlay&&!n.includes("overlay")&&{overlay:_(t.overlay??allowedValues.overlay.default)},...void 0!==t.placement&&!n.includes("placement")&&{placement:m(t.placement??allowedValues.placement.default,e.anchor)},...void 0!==t.boundaryPadding&&!n.includes("boundaryPadding")&&{boundaryPadding:k(t.boundaryPadding??allowedValues.boundaryPadding.default)},...void 0!==t.draggable&&!n.includes("draggable")&&{draggable:C(t.draggable??allowedValues.draggable.default,e.anchor)},...void 0!==t.offset&&!n.includes("offset")&&{offset:x(t.offset??allowedValues.offset.default)},...void 0!==t.flip&&!n.includes("flip")&&{flip:A(t.flip??allowedValues.flip.default)},...void 0!==t.shift&&!n.includes("shift")&&{shift:T(t.shift??allowedValues.shift.default)},...void 0!==t.size&&!n.includes("size")&&{size:y(t.size??allowedValues.size.default)},...void 0!==t.header&&!n.includes("header")&&{header:I(t.header??allowedValues.header.default)},...void 0!==t.footer&&!n.includes("footer")&&{footer:I(t.footer??allowedValues.footer.default)},...void 0!==t.breakpoints&&!n.includes("breakpoints")&&{breakpoints:t.breakpoints??{}},...void 0!==t.debug&&!n.includes("debug")&&{debug:!0===t.debug}}}class Manager{constructor(){var e;return this._instancesMap=new Map,this._root=null,this._openedInstances={viewport:[],element:[],pointer:[]},this._defaults={},this._config={zIndex:9999,autoRaf:!0},this._listeners={update:[],refresh:[],raf:[],sync:[]},this._state={pointerTrackingStarted:!1,autoRafStarted:!1},this._cache={refreshVersion:0,updateVersion:0,pointer:{x:0,y:0,target:null},raf:{time:0,deltaTime:0},lastRafTime:null},this._handlers={keydown:this._onKeydown.bind(this),update:()=>async function(e){await e._callHook("update",e),e._cache.updateVersion++}(this),pointermove:e=>function(e,t){e._cache.pointer.x=t.clientX,e._cache.pointer.y=t.clientY}(this,e),refresh:()=>{this._refreshRaf||(this._refreshRaf=requestAnimationFrame(()=>{this._refreshRaf=null,async function(e){await e._callHook("refresh",e),e._cache.refreshVersion++}(this)}))}},this._update=this._handlers.update,window.addEventListener("scroll",this._handlers.update,{passive:!0}),this._refresh=this._handlers.refresh,window.addEventListener("resize",this._handlers.refresh),this._syncPointerEngine=(...e)=>h(this,...e),this._sync=(...e)=>async function(e){await e._callHook("sync",e)}(this,...e),this._on=(...e)=>function(e,t,n,o=1e3){"function"==typeof n&&e._listeners[t]&&e._listeners[t].push({callback:n,priority:o})}(this,...e),this._off=(...e)=>function(e,t,n){"function"==typeof n&&e._listeners[t]&&(e._listeners[t]=e._listeners[t].filter(e=>e.callback!==n))}(this,...e),this._callHook=(...e)=>async function(e,t){if(e._listeners[t].length){e._listeners[t].sort((e,t)=>e.priority-t.priority);for(const{callback:n,priority:o}of e._listeners[t])try{await n()}catch(e){}}}(this,...e),this._open=async(e,t={})=>await async function(e,t,n={}){const o=e._instancesMap.get(t);o&&await o.open(n)}(this,e,t),this._close=async(e,t={})=>await async function(e,t,n={}){const o=e._instancesMap.get(t);o&&await o.close(n)}(this,e,t),this._closeAll=async(e={})=>await async function(e,t={}){const{force:n=!1,...o}=t;for(const[t,s]of e._instancesMap)s.ignoreCloseAll&&!n||await s.close(o)}(this,e),this._destroy=async(e,t={})=>await async function(e,t,n={}){const o=e._instancesMap.get(t);o&&await o.destroy(n)}(this,e,t),this._destroyAll=async(e={})=>await async function(e,t={}){for(const[n,o]of e._instancesMap)await o.destroy(t);e._instancesMap.clear()}(this,e),(e=this)._root=document.createElement("div"),e._root.classList.add("_trivon-ui-hyperfloat"),e._root.style.setProperty("--trivon-ui-hyperfloat-z-index",e._config.zIndex),document.body.prepend(e._root),document.addEventListener("keydown",e._handlers.keydown),this}_onKeydown(e){"Escape"===e.key&&this._closeFirstPriority({event:"escape"})}_setHyperfloatOpened(e,t){const n=e.id,o=e.anchor;t?this._openedInstances[o].includes(n)||this._openedInstances[o].push(n):this._openedInstances[o].includes(n)&&(this._openedInstances[o]=this._openedInstances[o].filter(e=>e!==n))}_raf(e=null){!async function(e,t){const n=t??("undefined"!=typeof performance?performance.now():Date.now());e._cache.lastRafTime||(e._cache.lastRafTime=n);const o=n-e._cache.lastRafTime;e._cache.lastRafTime=n,e._cache.raf={time:n,deltaTime:o},await e._callHook("raf",e)}(this,e)}_getAll(){const e=[];for(const[t,n]of this._instancesMap)e.push(n);return e}_getOpened(e=null,t=!1){const n=[];for(const[o,s]of this._instancesMap)if(null===e||s.anchor===e){if(t){if(!s.state.opened&&!s.state.opening)continue}else if(!s.state.opened)continue;n.push(s)}return n}_getByPriority(e=">",t=1e3){const n=[];for(const[,o]of this._instancesMap){if(!o.opened)continue;const s=o._state.priority;(">"===e?s>t:">="===e?s>=t:"<"===e?s<t:"<="===e?s<=t:"=="===e&&s===t)&&n.push(o)}return n.sort((e,t)=>e._state.priority-t._state.priority),n}_getElementsAbovePriority(e=1e3){const t=[];for(const[n,o]of this._instancesMap){const n=o.opened,s=o._state.priority,i=o.elements.box,r=o.elements.overlay;n&&s>e&&(t.push(i),r&&t.push(r))}return t}_setConfig(e={}){var t,n;e.zIndex&&(t=this,n=e.zIndex,n=Number(n),t._config.zIndex=n,t._root.style.setProperty("--trivon-ui-hyperfloat-z-index",n)),e.autoRaf&&function(e,t=!0){e._state.autoRafStarted?e._config.autoRaf?console.warn("Auto RAF has already been started. m setting can no longer be changed."):console.warn("The RAF mode has already been defined and is currently managed externally. m setting can no longer be changed."):e._config.autoRaf=t}(this,e.autoRaf)}_setDefaults(e){if(e){const t=p(0,e);this._defaults=P(this,t,["ignoreCloseAll"])}}_normalizeData(e){const t=p(0,{...e,id:e.id??a({blacklist:Array.from(this._instancesMap.keys())})});return void 0===t.anchor&&(t.anchor="viewport"),t.root=this._root,t}async _closeFirstPriority(e={}){const t=Object.values(this._openedInstances).flat();let n=null;if(1===t.length){const e=this._instancesMap.get(t[0]);e.dismiss.escapeKey&&(n=e)}else for(const[e,o]of this._instancesMap)t.includes(e)&&o.dismiss.escapeKey&&(!n||o._state.priority>n._state.priority)&&(n=o);n&&await n.close(e)}}let E=null;const O=new Proxy({},{get:(e,t)=>{if("then"!==t)return()=>{}}});function j(){return"undefined"==typeof window?O:(E??=new Manager,E)}async function H(e,t,n={},o=!0){const s=[t._data[e],t[e]].filter(e=>"function"==typeof e);if(s.length){for(const i of s){let s=i.call(t,n);if(s&&"function"==typeof s.then){if(!o){console.error(`[Trivon Ui / Hyperfloat]: the hook "${e}" must be synchronous. It cannot return a Promise.`);continue}s=await s}if(!1===s||s?.prevent)return s}return!0}}function S(e,t,n,o,s={}){if(!t||"function"!=typeof o)return;let i=e._listenersMap.get(t);i||(i=new Map,e._listenersMap.set(t,i));let r=i.get(n);r||(r=new Map,i.set(n,r)),r.has(o)||(t.addEventListener(n,o,s),r.set(o,s))}function B(e,t,n,o){if(!t)return;const s=e._listenersMap.get(t);if(!s)return;const i=s.get(n);if(!i||!i.has(o))return;const r=i.get(o);t.removeEventListener(n,o,r),i.delete(o),0===i.size&&s.delete(n),0===s.size&&e._listenersMap.delete(t)}function z(e,t){if(!t)return;const n=e._listenersMap.get(t);if(n){for(const[e,o]of n)for(const[n,s]of o)t.removeEventListener(e,n,s);e._listenersMap.delete(t),delete t.dataset.hyperfloatBound,delete t.dataset.hyperfloatOpened}}function L(e){e.dismiss.pointerLeave&&function(e){"pointer"!==e._config.anchor&&S(e,e._elements.box,"pointerleave",e._handlers.pointerLeave);[...e._registry.open.keys()].forEach(t=>{S(e,t,"pointerleave",e._handlers.pointerLeave)})}(e),e.dismiss.outsideClick&&$(e,"pointerdown"),e.dismiss.outsideWheel&&$(e,"wheel")}function $(e,t,n){const o=`outside_${t}`;e._handlers[o]||(e._handlers[o]=n=>{if(!e.opened)return;if([e._elements.box,...j()._getElementsAbovePriority(e._state.priority)].some(e=>e?.contains(n.target)))return;[...e._registry.open.keys()].some(e=>e.contains(n.target))||e.close({event:"pointerdown"===t?"outside-click":"outside-wheel"})}),S(e,window,t,e._handlers[o],n)}function D(e){if("viewport"!==e.anchor)return;if(null===e.boundaryPadding||0===e.boundaryPadding)return;const t=e._elements.boundary,n=e.boundaryPadding;t.style.paddingTop=n.top+"px",t.style.paddingRight=n.right+"px",t.style.paddingBottom=n.bottom+"px",t.style.paddingLeft=n.left+"px"}function V(e){if("viewport"!==e.anchor)return;if(null===e.offset)return;const t=function(e,t){const{mainAxis:n=0,crossAxis:o=0,alignmentAxis:s=null}=e,[i,r]=t.split("-"),a="top"===i||"bottom"===i;let l=0,c=0;a?l+="top"===i?-n:n:c+="left"===i?-n:n;let d=o;return r&&null!==s&&(d=s,"end"===r&&(d*=-1)),a?c+=d:l+=d,{top:l+"px",right:"0px",bottom:"0px",left:c+"px"}}(e.offset,e.placement),n=e._elements.box;n.style.marginTop=t.top,n.style.marginRight=t.right,n.style.marginBottom=t.bottom,n.style.marginLeft=t.left}function N(e){e._elements.boundary.dataset.hyperfloatSize="preset"==e.size.type?e.size.width:"custom","custom"==e.size.type&&(e._elements.box.style.width=e.size.width??"100%",e._elements.box.style.height=e.size.height??"100%")}function U(e){null!==e.overlay&&(e._elements.boundary.dataset.hyperfloatOverlayEnabled=e.overlay.enabled,e._elements.boundary.dataset.hyperfloatOverlayColor=e.overlay.color,e._elements.boundary.dataset.hyperfloatOverlayBlur=e.overlay.blur)}function X(e){e._elements.boundary.dataset.hyperfloatPlacement=e.placement}function Y(e,t){e._config.meta=M(t??n.meta.default);const o=e._cache.lastApplyMeta,s=e._helpers.createMetaDataset();for(const t of Object.keys(o))e._elements.boundary.removeAttribute(t);for(const[t,n]of Object.entries(s))e._elements.boundary.setAttribute(t,n)}function q(e,t){e._config.accessibility=R(t??n.accessibility.default);const o=e._cache.lastApplyAccessibility,s=e._helpers.createAccessibilityDataset();for(const t of Object.keys(o))e._elements.boundary.removeAttribute(t);for(const[t,n]of Object.entries(s))e._elements.boundary.setAttribute(t,n)}function F(e,t){e._config.dismiss=g(t??n.dismiss.default),L(e)}function W(e,t){e._config.overlay=_(t??n.overlay.default),U(e)}function K(e,t){const o=m(t??n.placement.default,e.anchor);e._config.placement=o,e._state.resolvedPlacement=o,X(e)}function G(e,t){e._config.boundaryPadding=k(t??n.placement.default),D(e)}function J(e,t){e._config.offset=x(t??n.offset.default),V(e)}function Q(e,t){e._config.flip=A(t??n.flip.default),"function"==typeof syncPosition&&e.opened&&"element"==e.anchor&&e.lastTarget&&syncPosition(e)}function Z(e,t){e._config.shift=T(t??n.shift.default),"function"==typeof syncPosition&&e.opened&&"element"==e.anchor&&e.lastTarget&&syncPosition(e)}function ee(e,t){e._config.size=y(t??n.size.default),N(e)}function te(e,t){e._config.draggable=C(t??n.draggable.default,e.anchor);const o=r(t?.handle,e._elements.boundary);o[0]&&(e._config.draggable.handle=o[0])}var ne=["meta","accessibility","dismiss","destroyAfterClose","autoOpen","overlay","placement","boundaryPadding","draggable","offset","flip","shift","ignoreCloseAll","header","footer","size","breakpoints","debug"];const oe=["breakpoints","destroyAfterClose","ignoreCloseAll","draggable","autoOpen","header","footer","debug"],se=ne.filter(e=>!oe.includes(e));function ie(e){if(!e._breakpoints||!e._breakpoints.length)return;const t=j()._cache.refreshVersion;if(e._state.firstresolveBreakpointsDone&&t===e._cache.resolveBreakpointsVersion)return;let n=!1;const o=window.innerWidth,s=e._breakpoints;for(const[t,i]of s)if(o<=t){n=!0,e._cache.lastBreakpoint!==t&&(e._cache.lastBreakpoint=t,re(e,i,t));break}if(!n){const[t,n]=e._breakpoints[e._breakpoints.length-1];e._cache.lastBreakpoint!==t&&(e._cache.lastBreakpoint=t,re(e,n,t))}e._cache.resolveBreakpointsVersion=t,e._state.firstresolveBreakpointsDone=!0}function re(e,t,n){for(const[o,s]of Object.entries(t))"meta"==o&&Y(e,s),"accessibility"==o&&q(e,s),"dismiss"==o&&F(e,s),"overlay"==o&&W(e,s),"placement"==o&&K(e,s),"boundaryPadding"==o&&G(e,s),"offset"==o&&J(e,s),"flip"==o&&Q(e,s),"shift"==o&&Z(e,s),"size"==o&&ee(e,s),e._console.log(`Breakpoint: ${n} -> ${o}:`,s)}function ae(e,t,n){const{left:o,top:s,right:i,bottom:r,width:a,height:l}=t,{width:c,height:d}=n,u=o+a/2,f=s+l/2;switch(e){case"center":default:return{left:u-c/2,top:f-d/2};case"top":return{left:u-c/2,top:s-d};case"top-start":return{left:o,top:s-d};case"top-end":return{left:i-c,top:s-d};case"right":return{left:i,top:f-d/2};case"right-start":return{left:i,top:s};case"right-end":return{left:i,top:r-d};case"bottom":return{left:u-c/2,top:r};case"bottom-start":return{left:o,top:r};case"bottom-end":return{left:i-c,top:r};case"left":return{left:o-c,top:f-d/2};case"left-start":return{left:o-c,top:s};case"left-end":return{left:o-c,top:r-d}}}function le({boundaryRect:e=window,elementRect:t=null,anchorRect:n=null,placement:o="bottom",offset:s=null,flip:i=null,shift:r=null}={}){let a,l,c=o;const d=()=>{if(({left:a,top:l}=ae(c,n,t)),null!==s&&({left:a,top:l}=function(e,t,n,o){const{mainAxis:s=0,crossAxis:i=0,alignmentAxis:r=null}=e,[a,l]=t.split("-"),c="top"===a||"bottom"===a;c?o+="top"===a?-s:s:n+="left"===a?-s:s;let d=i;return l&&null!==r&&(d=r,"end"===l&&(d*=-1)),c?n+=d:o+=d,{left:n,top:o}}(s,c,a,l)),null!==r){const o=function(e,t,n,o,s,i,r,a=null){const{mainAxis:l=!1,crossAxis:c=!1}=e,d=(e,t,n)=>Math.max(t,Math.min(e,n)),[u,f]=t.split("-"),p="top"===u||"bottom"===u,h=n.left,y=n.right-s.width,m=n.top,_=n.bottom-s.height;if(p?(c&&(i=d(i,h,y)),l&&(r=d(r,m,_))):(l&&(i=d(i,h,y)),c&&(r=d(r,m,_))),null!==a){const{mainAxis:e=!1,crossAxis:t=!1}=a;let n=!1;if(e&&("right"===u&&i<o.right&&(n=!0),"left"===u&&i+s.width>o.left&&(n=!0),"top"===u&&r+s.height>o.top&&(n=!0),"bottom"===u&&r<o.bottom&&(n=!0)),n)return null}return{left:i,top:r}}(r,c,e,n,t,a,l,i);return null!==o&&(({left:a,top:l}=o),!0)}return!0},u=d();if(null!==i&&!u){const o=function({flip:e,placement:t,boundaryRect:n,anchorRect:o,elementRect:s}){if(null===e)return null;const{mainAxis:i=!0,crossAxis:r=!1}=e,[a,l]=t.split("-"),c=(e,t)=>e>=n.left&&e+s.width<=n.right&&t>=n.top&&t+s.height<=n.bottom,d=(e,t=l)=>t?`${e}-${t}`:e;if(i){const e=(e=>{switch(e){case"top":return"bottom";case"bottom":return"top";case"left":return"right";case"right":return"left";default:return e}})(a),t=d(e),{left:n,top:i}=ae(t,o,s);if(c(n,i))return t}if(r&&l){const e=(e=>"start"===e?"end":"end"===e?"start":null)(l);if(e){const t=d(a,e),{left:n,top:i}=ae(t,o,s);if(c(n,i))return t}}return null}({flip:i,placement:c,boundaryRect:e,anchorRect:n,elementRect:t});o&&(c=o,d())}return{position:{left:a,top:l},coordinates:{left:a,top:l},placement:c,resolvedPlacement:c}}function ce(e,t,n){const o=b(n??null);if(!o.length)return()=>{};const s=[];return o.forEach(n=>{const o={hostHyperfloat:v(n.el),event:n.event};e._registry[t].set(n.el,o),s.push(n.el)}),"open"===t?de(e):fe(e),L(e),()=>{!function(e,t,n){r(n).forEach(n=>{n instanceof Element&&e._registry[t]?.has(n)&&(z(e,n),e._registry[t].delete(n),e._state.pointer.target.el==n&&(e._state.pointer.target={el:null,action:null}))})}(e,t,s)}}function de(e){for(const[t,n]of e._registry.open)t instanceof Element?"true"!==t.dataset.hyperfloatBound&&(ue(e,t,n),t.dataset.hyperfloatOpened=String(e.opened),t.dataset.hyperfloatBound="true",S(e,t,"pointerenter",()=>{e._state.pointer.target={el:t,action:"open"}})):(z(e,t),e._registry.open.delete(t))}function ue(e,t,n){const o=n.event;"click"!=o?["pointerenter","pointermove"].includes(o)&&S(e,t,"pointer"===e.anchor?"pointermove":"pointerenter",()=>e.open({target:t})):S(e,t,"click",()=>{e.opened?e.close({target:t}):e.open({target:t})})}function fe(e){for(const[t,n]of e._registry.close)t instanceof Element?"true"!==t.dataset.hyperfloatBound&&(S(e,t,"click",()=>{e.close({target:t})}),t.dataset.hyperfloatOpened=String(e.opened),t.dataset.hyperfloatBound="true",S(e,t,"pointerenter",()=>{e._state.pointer.target={el:t,action:"close"}})):(z(e,t),e._registry.close.delete(t))}async function pe(e,t,n){const o=e._data?.interpolate??e.interpolate??null;if("function"==typeof o){const s=await o.call(e,{axis:"x",current:e._state.interpolation.lastX??t,target:t,pointer:e._state.pointer});"number"==typeof s&&(t=s);const i=await o.call(e,{axis:"y",current:e._state.interpolation.lastY??n,target:n,pointer:e._state.pointer});"number"==typeof i&&(n=i)}return e._state.interpolation.lastX=t,e._state.interpolation.lastY=n,{x:t,y:n}}function he(e){const t=j();let n=0;t._instancesMap.forEach(e=>{e&&e._state.ready&&(n=Math.max(n,e._state.priority??0))});const o=n+1;e._state.priority=o;const s="pointer"===e.anchor?o+1e3:o,i=e.elements?.boundary;i&&(i.style.zIndex=String(s))}async function ye(e,t){if(!t||!e._state.drag)return;const n=t.clientX-e._state.drag.startX,o=t.clientY-e._state.drag.startY;let s=e._state.drag.initialX+n,i=e._state.drag.initialY+o;e.draggable.bounds&&(s=Math.max(e._state.drag.minX,Math.min(s,e._state.drag.maxX)),i=Math.max(e._state.drag.minY,Math.min(i,e._state.drag.maxY))),e._state.position.x=s,e._state.position.y=i;const{x:r,y:a}=await pe(e,s,i);e._elements.positioner.style.transform=`translate3d(${r}px, ${a}px, 0)`,await H("onMove",e,{x:r,y:a})}function me(e,{force:t=!1}={}){!function(e){de(e),fe(e)}(e),L(e),H("onSync",e,{})}function _e(e,{force:t=!1}={}){if(!e._elements.boundary||!e._elements.box||"element"==e.anchor&&!e._registry.open.size)return;const n=j()._cache.refreshVersion;if(!t&&e._state.firstcomputeRectsDone&&n===e._cache.computeRectsVersion)return;(["pointer","element"].includes(e.anchor)||e.draggable?.enabled)&&(e._cache.positionerRect=e._elements.positioner.getBoundingClientRect());const o=e._elements.boundary.getBoundingClientRect();if(null===e.boundaryPadding||0===e.boundaryPadding)e._cache.boundaryRect=o;else{const t=e.boundaryPadding;e._cache.boundaryRect={x:o.x,y:o.y,left:o.left+t.left,top:o.top+t.top,right:o.right-t.right,bottom:o.bottom-t.bottom,width:o.right-t.right-(o.left+t.left),height:o.bottom-t.bottom-(o.top+t.top)}}e._cache.computeRectsVersion=n,e._state.firstcomputeRectsDone=!0}async function ge(e){if(!e._registry.open.size||!e.positionerRect||!e.boundaryRect||"element"===e.anchor&&!e.lastTarget)return e._elements.positioner.style.transform="",e._state.anchored=!1,void(e._elements.boundary.dataset.hyperfloatAnchored="false");let t;if("pointer"===e.anchor){const n=j()._cache.pointer;0===n.x&&0===n.y?e._elements.positioner.style.opacity=0:"0"==e._elements.positioner.style.opacity&&(e._elements.positioner.style.opacity=""),e._state.pointer.x=n.x,e._state.pointer.y=n.y,t={left:e._state.pointer.x-5,top:e._state.pointer.y-5,right:e._state.pointer.x+5,bottom:e._state.pointer.y+5,width:10,height:10,x:e._state.pointer.x-5,y:e._state.pointer.y-5}}else t=e.lastTarget.getBoundingClientRect();(function(e){let t=null;return t="object"==typeof e&&null!==e?e:e.getBoundingClientRect(),t.bottom<=0||t.top>=window.innerHeight||t.right<=0||t.left>=window.innerWidth})(t)?e._timers.outside||(e._timers.outside=setTimeout(()=>{e.close({event:"target-outside"}),e._timers.outside=null},e._outsideCloseDelay)):(clearTimeout(e._timers.outside),e._timers.outside=null),e._state.anchored=!0,e._elements.boundary.dataset.hyperfloatAnchored="true",e._state.resolvedPlacement=e.placement;const n=le({elementRect:e.positionerRect,anchorRect:t,boundaryRect:e.boundaryRect,placement:e.placement,offset:e.offset,flip:e.flip,shift:e.shift});e._state.resolvedPlacement=n.resolvedPlacement;const{x:o,y:s}=await pe(e,n.position.left,n.position.top),i=o+"px",r=s+"px";e._elements.positioner.style.transform=`translate3d(${i}, ${r}, 0)`,await H("onMove",e,{x:i,y:r})}async function be(e,{target:t=null,event:n=null,source:o="user"}={}){if(!e._state.ready)return;if(e._state.opened||e._state.locked)return;if(e._state.locked=!0,e._state.opening=!0,e._console.log("Opening:",e.id),e._cache.parentHyperfloat=null,t){let n=e._registry.open.get(t);n&&n.hostHyperfloat!==e.id&&(e._cache.parentHyperfloat=n.hostHyperfloat)}let s=await H("onBeforeOpen",e,{target:t,event:n,source:o});if(!1===s||s?.prevent)return e._state.locked=!1,e._state.opened=!1,void(e._state.opening=!1);he(e),e._cache.lastTarget=t,e._state.pointer.target={el:t,action:"open"},"pointer"===e.anchor&&j()._syncPointerEngine(!0),["pointer","element"].includes(e.anchor)&&(e._state.firstcomputeRectsDone||(await new Promise(requestAnimationFrame),await new Promise(requestAnimationFrame)),_e(e),ge(e)),e.draggable?.enabled&&(e._state.firstcomputeRectsDone||(await new Promise(requestAnimationFrame),await new Promise(requestAnimationFrame)),_e(e),ye(e)),ie(e),e.dismiss.timeout&&null!==e.dismiss.timeout?e._handlers.startTimeoutTimer():e.dismiss.idleTimeout&&null!==e.dismiss.idleTimeout&&(S(e,e.elements.box,"pointerenter",e._handlers.stopIdleTimer),S(e,e.elements.box,"pointerleave",e._handlers.startIdleTimer),S(e,e.elements.box,"pointerdown",e._handlers.stopIdleTimer),S(e,e.elements.box,"wheel",e._handlers.stopIdleTimer,{passive:!0}),S(e,e.elements.box,"touchstart",e._handlers.stopIdleTimer,{passive:!0}),S(e,e.elements.box,"keydown",e._handlers.stopIdleTimer),S(e,e.elements.box,"focusin",e._handlers.stopIdleTimer),e._handlers.startIdleTimer()),await H("onOpen",e,{target:t,event:n,source:o}),e._state.opened=!0,e._state.opening=!1,e._elements.boundary.dataset.hyperfloatOpened="true",j()._setHyperfloatOpened(e,!0),e._console.log("Open:",e.id);for(const[t,n]of e._registry.open)t.dataset.hyperfloatOpened="true";for(const[t,n]of e._registry.close)t.dataset.hyperfloatOpened="true";await H("onAfterOpen",e,{target:t,event:n,source:o}),e._state.locked=!1}async function ve(e,{target:t=null,event:n=null,source:o="user"}={}){if(!e._state.ready)return;if(!e._state.opened||e._state.locked)return;e._state.locked=!0,e._state.opening=!1,e._console.log("Closing:",e.id);for(const[t,s]of j()._instancesMap)s.parentHyperfloat===e.id&&s.dismiss.closeWithParent&&await s.close({el:el,event:n,source:o});let s=await H("onBeforeClose",e,{target:t,event:n,source:o});if(!1===s||s?.prevent)return e._state.locked=!1,e._state.opened=!0,void(e._state.opening=!1);e._cache.lastcloseTarget=t,e._state.pointer.target={el:t,action:"close"},e.dismiss.timeout&&null!==e.dismiss.timeout?e._handlers.stopTimeoutTimer():e.dismiss.idleTimeout&&null!==e.dismiss.idleTimeout&&(e._handlers.stopIdleTimer(),B(e,e.elements.box,"pointerenter",e._handlers.stopIdleTimer),B(e,e.elements.box,"pointerleave",e._handlers.startIdleTimer),B(e,e.elements.box,"pointerdown",e._handlers.stopIdleTimer),B(e,e.elements.box,"wheel",e._handlers.stopIdleTimer),B(e,e.elements.box,"touchstart",e._handlers.stopIdleTimer),B(e,e.elements.box,"keydown",e._handlers.stopIdleTimer),B(e,e.elements.box,"focusin",e._handlers.stopIdleTimer)),await H("onClose",e,{target:t,event:n,source:o}),e._state.opened=!1,e._state.opening=!1,e._elements.boundary.dataset.hyperfloatOpened="false",j()._setHyperfloatOpened(e,!1),e._console.log("Close:",e.id);for(const[t,n]of e._registry.open)t.dataset.hyperfloatOpened="false";for(const[t,n]of e._registry.close)t.dataset.hyperfloatOpened="false";await H("onAfterClose",e,{target:t,event:n,source:o}),e._cache.lastTarget=null,e._cache.parentHyperfloat=null,e._state.pointer.target={el:null,action:null},"pointer"===e.anchor&&j()._syncPointerEngine(),e._state.locked=!1,e.destroyAfterClose&&await xe(e)}async function xe(e,{target:t=null,event:n=null,source:o="user"}={}){e.opened&&await ve(e,{event:"destroy",source:o}),await H("onDestroy",e,{target:t,event:n,source:o}),function(e){for(const[t,n]of e._listenersMap)for(const[e,o]of n)for(const[n,s]of o)t.removeEventListener(e,n,s);e._listenersMap.clear()}(e),e._elements.boundary&&e._elements.boundary.remove(),j()._off("sync",e._handlers.sync),j()._off("update",e._handlers.update),j()._off("refresh",e._handlers.refresh),j()._off("raf",e._handlers.raf),j()._instancesMap.delete(e.id)}async function we(e){await H("onBeforeInit",e,{}),function(e){e._elements.boundary=i("div",{attrs:{...e._helpers.createMetaDataset(),...e._helpers.createAccessibilityDataset(),"data-hyperfloat-boundary":"",id:`${e.id}`,"data-hyperfloat-id":`${e.id}`,"data-hyperfloat-opened":"false","data-hyperfloat-anchor":e.anchor,"data-hyperfloat-anchored":e._state.anchored,"data-hyperfloat-draggable":!0===e.draggable?.enabled},appendTo:e._elements.root}),e._elements.overlayEl=i("div",{class:"hyperfloat-overlay",attrs:{"data-hyperfloat-overlay":""},appendTo:e._elements.boundary}),U(e);const t=["pointer","element"].includes(e.anchor)||e.draggable?.enabled;t&&(e._elements.positioner=i("div",{attrs:{"data-hyperfloat-positioner":""},appendTo:e._elements.boundary}));const n=t?e._elements.positioner:e._elements.boundary;e._elements.box=i("div",{class:"hyperfloat-box",attrs:{"data-hyperfloat-box":""},appendTo:n}),e._elements.headerInner=s(e.header,e),e._elements.headerInner&&(e._elements.header=i("div",{class:"hyperfloat-header",attrs:{"data-hyperfloat-header":""},html:e._elements.headerInner,appendTo:e._elements.box}),e._elements.header.style.order=1),e._elements.content=i("div",{attrs:{"data-hyperfloat-content":""},appendTo:e._elements.box}),e._elements.content.style.order=2,e._elements.contentInner=i("div",{attrs:{"data-hyperfloat-content-inner":""},appendTo:e._elements.content}),e.content?s(e.content,{},e._elements.contentInner):e._elements.loading=i("div",{class:"hyperfloat-loading",attrs:{"data-hyperfloat-loading":""},html:'<span class="hyperfloat-loading-bar" data-hyperfloat-loading-bar></span>',appendTo:e._elements.content}),e._elements.footerInner=s(e.footer,e),e._elements.footerInner&&(e._elements.footer=i("div",{class:"hyperfloat-footer",attrs:{"data-hyperfloat-footer":""},html:e._elements.footerInner,appendTo:e._elements.box}),e._elements.footer.style.order=3),D(e),V(e),X(e),N(e),e.draggable?.enabled&&e._data?.draggable?.handle&&te(e,{bounds:e.draggable.bounds,handle:e._data?.draggable?.handle})}(e),function(e){const t=r(e._defaultCloseSelector,e._elements.boundary);e._elements.overlayEl&&t.push(e._elements.overlayEl),t.forEach(t=>{const n={hostHyperfloat:v(t),event:"click"};e._registry.close.has(t)||e._registry.close.set(t,n)})}(e),me(e),function(e){const t=e.breakpoints||{},n=Object.keys(t);if(!n.length)return void(e._breakpoints=[]);const o=(e,t)=>{const n={...e};for(const s in t)"object"!=typeof t[s]||Array.isArray(t[s])||null===t[s]||"object"!=typeof e[s]?void 0!==t[s]&&null!==t[s]&&(n[s]=t[s]):n[s]=o(e[s],t[s]);return n},s=Math.max(...n.map(Number))+1,i={};for(const t of se)void 0!==e[t]&&(i[t]=e[t]);const r=n.map(Number).sort((e,t)=>t-e);r.unshift(s);const a={};a[s]=i;for(let n=1;n<r.length;n++){const s=r[n],i=t[s];let l={};for(const e of Object.keys(i))se.includes(e)&&(l[e]=i[e]);l=P(e,l,oe);const c=a[r[n-1]];l=o(c,l),a[s]=l}e._breakpoints=Object.entries(a).map(([e,t])=>[Number(e),t]).sort((e,t)=>e[0]-t[0])}(e),function(e){e.draggable?.enabled&&(e._state.anchored=!0,e._elements.boundary.dataset.hyperfloatAnchored="true",e._handlers.pointerMove=t=>{if(e._state.drag){if(!e._state.dragging){const n=Math.abs(t.clientX-e._state.drag.startX),o=Math.abs(t.clientY-e._state.drag.startY);(n>3||o>3)&&(e._state.dragging=!0,document.body.style.userSelect="none",e._elements.box.style.touchAction="none")}e._state.dragging&&ye(e,t)}},e._handlers.pointerUp=t=>{e._state.drag&&(e._state.dragging&&(document.body.style.userSelect="",e._elements.box.style.touchAction=""),e._state.drag=null),e._state.dragging=!1,B(e,document,"pointermove",e._handlers.pointerMove),B(e,document,"pointerup",e._handlers.pointerUp)},e._handlers.pointerDown=t=>{if(0!==t.button)return;if(!e.opened)return;if(["BUTTON","INPUT","TEXTAREA","SELECT","A"].includes(t.target.tagName)||t.target.closest("[data-no-drag]"))return;if(e.draggable.handle){const n=e.draggable.handle;if("string"==typeof n){if(!t.target.closest(n))return}else if((n instanceof Node||n instanceof Element)&&!n.contains(t.target))return}const n=e.positionerRect,o=e.boundaryRect,s=e._state.position.x||0,i=e._state.position.y||0;e._state.drag={startX:t.clientX,startY:t.clientY,initialX:s,initialY:i,minX:o?s-(n.left-o.left):-1/0,maxX:o?s+(o.right-n.right):1/0,minY:o?i-(n.top-o.top):-1/0,maxY:o?i+(o.bottom-n.bottom):1/0},e._state.dragging=!1,he(e),S(e,document,"pointermove",e._handlers.pointerMove),S(e,document,"pointerup",e._handlers.pointerUp)},S(e,e._elements.box,"pointerdown",e._handlers.pointerDown))}(e),await H("onInit",e,{}),await H("onAfterInit",e,{}),function(e){e._console.log("Ready:",e.id),H("onReady",e,{})}(e),e._state.ready=!0}const Ae="1.0.44";class Hyperfloat{constructor(e){if("undefined"==typeof window)return;const t=j()._normalizeData(e);this._data=t,this._id=t.id,this._listenersMap=new Map,this._config={anchor:t.anchor??"viewport"},this._config={...this._config,...P(this,t)},this.content=t.content??null,this._console=function(e,t=""){return e.debug?{log:(...e)=>console.log(t,...e),info:(...e)=>console.info(t,...e),warn:(...e)=>console.warn(t,...e),error:(...e)=>console.error(t,...e),table:(...e)=>{const n=e.pop();console.log(t,...e),console.table(n)}}:{log:()=>{},info:()=>{},warn:()=>{},error:()=>{},table:()=>{}}}(this,"[Trivon Ui - Hyperfloat]"),this._timers={pointerLeave:null,idle:null,timeout:null,outside:null},this._outsideCloseDelay=4e3,this._elements={root:t.root,boundary:null,positioner:null,box:null,content:null,contentInner:null,overlayEl:null,header:null,headerInner:null,footer:null,footerInner:null,loading:null},this._state={ready:!1,opened:!1,opening:!1,locked:!1,dragging:!1,anchored:["element","pointer"].includes(this.anchor),priority:0,pointer:{x:0,y:0,target:{el:null,action:null}},drag:null,position:{x:0,y:0},interpolation:{lastX:0,lastY:0},resolvedPlacement:this._config.placement,firstresolveBreakpointsDone:!1,firstcomputeRectsDone:!1},this._breakpoints=[],this._handlers={startIdleTimer:()=>{clearTimeout(this._timers.idle),!this.dismiss.idleTimeout||this.dismiss.idleTimeout<=0||(this._timers.idle=setTimeout(()=>{ve(this,{event:"no-interaction"})},this.dismiss.idleTimeout))},stopIdleTimer:()=>{clearTimeout(this._timers.idle)},startTimeoutTimer:()=>{clearTimeout(this._timers.timeout),!this.dismiss.timeout||this.dismiss.timeout<=0||(this._timers.timeout=setTimeout(()=>{ve(this,{event:"timeout"})},this.dismiss.timeout))},stopTimeoutTimer:()=>{clearTimeout(this._timers.timeout)},sync:(...e)=>me(this,...e),update:(...e)=>function(e,{force:t=!1}={}){e.opened&&"element"==e.anchor&&e.lastTarget&&(ge(e),H("onUpdate",e,{}))}(this,...e),refresh:(...e)=>function(e,{force:t=!1}={}){e.opened&&(["pointer","element"].includes(e.anchor)&&_e(e,{force:t}),e.draggable?.enabled&&_e(e,{force:t}),e._breakpoints&&!e._breakpoints.length&&ie(e),["pointer","element"].includes(e.anchor)&&e.lastTarget&&ge(e),e.draggable?.enabled&&ye(e)),H("onRefresh",e,{})}(this,...e),raf:()=>{var e;(e=this).opened&&"pointer"==e.anchor&&ge(e)},pointerLeave:e=>{if(!this._state.opened&&!this._state.opening)return;const t=e.currentTarget||e.target,n=e.relatedTarget;n&&(this._elements.box.contains(n)||[...this._registry.open.keys()].some(e=>e.contains(n)))||("pointer"===this.anchor?(clearTimeout(this._timers.pointerLeave),this._timers.pointerLeave=setTimeout(()=>{this._elements.box.matches(":hover")||[...this._registry.open.keys()].some(e=>e.matches(":hover"))||this.close({target:t,event:"pointerleave"})},100)):this.close({target:t,event:"pointerleave"}))},pointerMove:()=>{},pointerDown:()=>{},pointerUp:()=>{}},this.sync=this._handlers.sync,this.update=this._handlers.update,this.refresh=this._handlers.refresh,j()._on("sync",this._handlers.sync),j()._on("update",this._handlers.update),j()._on("refresh",this._handlers.refresh),j()._on("raf",this._handlers.raf),this.open=async(...e)=>await be(this,...e),this.close=async(...e)=>await ve(this,...e),this.destroy=async(...e)=>await xe(this,...e),this._cache={boundaryRect:null,positionerRect:null,targetRects:new Map,parentHyperfloat:null,lastTarget:null,lastcloseTarget:null,lastBreakpoint:9999999999999,computeRectsVersion:0,resolveBreakpointsVersion:0,syncPositionVersion:0,lastApplyMeta:{},lastApplyAccessibility:{}},this._registry={open:new Map,close:new Map};for(const e of Object.keys(this._registry)){b(t[e]??null).forEach(t=>{this._registry[e].set(t.el,{hostHyperfloat:v(t.el),event:t.event})})}return this.registerOpen=e=>ce(this,"open",e),this.registerClose=e=>ce(this,"close",e),this.unregisterOpen=e=>unregisterAction(this,"open",e),this.unregisterClose=e=>unregisterAction(this,"close",e),this.vars=t.vars??{},j()._instancesMap.set(this.id,this),this}static async create(e={}){if("undefined"==typeof window)return null;if(e.id&&j()._instancesMap.has(e.id)){const t=j()._instancesMap.get(e.id);if(!(!0===e.overwrite))return t.sync(),t;t.destroy()}const t=new this(e);return await we(t),!0===e.autoOpen&&await be(t,{event:"initialize",source:"auto"}),t}get id(){return this._id}get anchor(){return this._config.anchor}get opened(){return this._state.opened}get resolvedPlacement(){return this._state.resolvedPlacement}get state(){return{ready:this._state.ready,priority:this._state.priority,anchored:this._state.anchored,pointer:this._state.pointer,locked:this._state.locked,opened:this._state.opened,opening:this._state.opening,dragging:this._state.dragging}}get elements(){return{boundary:this._elements.boundary,overlay:this._elements.overlayEl,positioner:this._elements.positioner,box:this._elements.box,content:this._elements.content,contentInner:this._elements.contentInner,loading:this._elements.loading,header:this._elements.header,headerInner:this._elements.headerInner,footer:this._elements.footer,footerInner:this._elements.footerInner}}get lastTarget(){return this._cache.lastTarget}get parentHyperfloat(){return this._cache.parentHyperfloat}get boundaryRect(){return this._cache.boundaryRect}get positionerRect(){return this._cache.positionerRect}get lastBreakpoint(){return this._cache.lastBreakpoint}_helpers={createAccessibilityDataset:()=>{const e=Object.fromEntries(Object.entries(this.accessibility).map(([e,t])=>{let n="";switch(e){case"role":n=e;break;case"label":n="aria-label";break;default:n=`data-${e}`}return[n,String(t)]}));return this._cache.lastApplyAccessibility=e,e},createMetaDataset:()=>{const e=Object.fromEntries(Object.entries(this.meta).map(([e,t])=>[`data-${e}`,String(t)]));return this._cache.lastApplyMeta=e,e}};static get version(){return Ae}static get _manager(){return j()}static config(e={}){j()._setConfig(e)}static defaults(e={}){j()._setDefaults(e)}static async open(e,t={}){await j()._open(e,t)}static async close(e,t={}){await j()._close(e,t)}static async closeAll(e={}){await j()._closeAll(e)}static async destroy(e,t={}){await j()._destroy(e,t)}static async destroyAll(e={}){await j()._destroyAll(e)}static sync(){j()._sync()}static update(){j()._update()}static refresh(){j()._refresh()}static raf(e){j()._raf(e)}static getAll(){return j()._getAll()}static getOpened(...e){return j()._getOpened(...e)}static getByPriority(...e){return j()._getByPriority(...e)}}return ne.forEach(e=>{Object.defineProperty(Hyperfloat.prototype,e,{get(){return this._config[e]??j()._defaults[e]??n[e].default},set(t){"meta"==e?Y(this,t):"accessibility"==e?q(this,t):"dismiss"==e?F(this,t):"overlay"==e?W(this,t):"placement"==e?K(this,t):"boundaryPadding"==e?G(this,t):"offset"==e?J(this,t):"flip"==e?Q(this,t):"shift"==e?Z(this,t):"size"==e?ee(this,t):"draggable"==e?te(this,t):["destroyAfterClose","ignoreCloseAll","debug"].includes(e)&&(this._config[e]=!0===t)},configurable:!0,enumerable:!0})}),Hyperfloat}();
8
+ var Hyperfloat=function(){"use strict";var e=["center","top","top-start","top-end","right","right-start","right-end","bottom","bottom-start","bottom-end","left","left-start","left-end"];const t={};["onBeforeInit","onInit","onAfterInit","onReady","onSync","onDestroy","onBeforeOpen","onOpen","onAfterOpen","onBeforeClose","onClose","onAfterClose","onRefresh","onUpdate","onMove"].forEach(e=>{t[e]={type:["null","function"],default:null}});var n={id:{type:"string",default:""},meta:{type:["null","object"],default:{type:"default",variant:"default",role:"dialog"}},accessibility:{type:["null","object"],default:{role:"dialog",label:"dialog",modal:!1}},anchor:{type:["string"],values:["viewport","element","pointer"],default:"viewport"},open:{type:["null","string","element","node","nodeList","array","object"],default:null},close:{type:["null","string","element","node","nodeList","array"],default:null},ignoreCloseAll:{type:"boolean",default:!1},autoOpen:{type:"boolean",default:!1},destroyAfterClose:{type:"boolean",default:!1},overlay:{type:["boolean","object"],default:null},placement:{type:"string",values:e,default:"center"},boundaryPadding:{type:["string","number","object","null"],default:0},draggable:{type:["boolean","object"],default:null},offset:{type:["string","number","object","null"],default:null},flip:{type:["object","boolean","null"],default:null},shift:{type:["object","boolean","null"],default:null},dismiss:{type:"object",default:{outsideClick:!1,outsideWheel:!1,escapeKey:!1,pointerLeave:!1,closeWithParent:!1,timeout:null,idleTimeout:null}},size:{type:["string","number","object"],default:"small"},breakpoints:{type:"object",default:{}},content:{type:["null","string","function","node"],default:null},header:{type:["null","string","function","node"],default:null},footer:{type:["null","string","function","node"],default:null},vars:{type:["null","object"],default:{}},interpolate:{type:["null","function"],default:null},debug:{type:"boolean",default:!1},...t};function o(e,t={}){if("function"==typeof e){return o(e.call(t),t)}if(e instanceof Promise)return o(e,t);if(e instanceof Node)return e;if("string"==typeof e){const t=e.trim();if(/^<.+?>/.test(t)){const e=document.createElement("div");e.innerHTML=t;const n=document.createDocumentFragment();for(;e.firstChild;)n.appendChild(e.firstChild);return n}return document.createTextNode(t)}return e}function s(e,t={},n=null){if(!e)return null;const s=o(e,t);if(!s)return null;if(!n){const e=document.querySelector("._trivon-ui-hyperfloat");let t=e.querySelector("[data-hyperfloat-sandbox]");t||(t=document.createElement("div"),t.dataset.hyperfloatSandbox="",e.appendChild(t)),n=t}let i;return s instanceof DocumentFragment?(i=Array.from(s.childNodes),n.appendChild(s)):Array.isArray(s)?(i=s,n.append(...s)):s instanceof Node&&(i=[s],n.appendChild(s)),i?.[0]||null}function i(e,t={}){const n=document.createElement(e);if(t.class){const e=Array.isArray(t.class)?t.class:t.class.trim().split(/\s+/);n.classList.add(...e)}t.attrs&&Object.entries(t.attrs).forEach(([e,t])=>n.setAttribute(e,t)),t.text&&(n.textContent=t.text);const o=t.html??t.innerHTML??t.innerHtml??t.content??null;if(o&&s(o,{},n),t.style&&this.applyStyle(n,t.style),!t.appendTo&&!t.prependTo){const e=document.querySelector("._trivon-ui-hyperfloat");let t=e.querySelector("[data-hyperfloat-sandbox]");t||(t=document.createElement("div"),t.dataset.hyperfloatSandbox="",e.appendChild(t)),t.appendChild(n)}return t.appendTo&&t.appendTo.appendChild(n),t.prependTo&&t.prependTo.prepend(n),n}function r(e,t=("undefined"!=typeof document?document:null),n=!1){if(!e)return[];const o="undefined"!=typeof Element,s=e=>o&&e instanceof Element;if(s(e))return[e];const i="string"==typeof t&&"undefined"!=typeof document?document.querySelector(t):t,r=new Set,a=e=>{if(e)if(s(e))r.add(e);else if("string"!=typeof e){if(Array.isArray(e)||"object"==typeof e&&"number"==typeof e.length&&"function"!=typeof e)for(let t=0;t<e.length;t++)a(e[t])}else{if(n)return void r.add(e);if(i&&"function"==typeof i.querySelectorAll)try{const t=i.querySelectorAll(e);for(let e=0;e<t.length;e++)r.add(t[e])}catch{}}};return a(e),Array.from(r)}function a({prefix:e="uuid",blacklist:t=[]}={}){let n="";return n="undefined"!=typeof crypto&&"function"==typeof crypto.randomUUID?`${e}-${crypto.randomUUID()}`:"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}),t.includes(n)?a({prefix:e,blacklist:t}):n}function l(e){return null===e?"null":Array.isArray(e)?"array":"undefined"!=typeof Node&&e instanceof Node?"node":"object"==typeof e?"object":typeof e}function c(e){if("string"==typeof e){const t=e.trim();if(/^-?[\d.]+(px|%|em|rem|vh|vw)$/.test(t)||/^(var|calc|min|max|clamp)\(.+\)$/.test(t))return t;const n=parseHyperfloat(t);return isNaN(n)?null:`${n}px`}return"number"==typeof e?`${e}px`:"0px"}function d(e){"number"==typeof e&&(e=`${e}px`);const t=document.createElement("div");t.style.all="initial",t.style.position="absolute",t.style.visibility="hidden",t.style.pointerEvents="none",t.style.width=e,document.body.appendChild(t);const n=getComputedStyle(t).width;document.body.removeChild(t);const o=parseHyperfloat(n);return isNaN(o)?0:o}function u(e){if("string"==typeof e){const t=e.trim().split(/\s+/);if(1===t.length){const e=c(t[0]);return{width:e,height:e}}if(2===t.length)return{width:c(t[0]),height:c(t[1])}}if("number"==typeof e){const t=c(e);return{width:t,height:t}}return"object"==typeof e&&null!==e?{width:c(e?.width),height:c(e?.height)}:{width:"auto",height:"auto"}}function f(e,t=4e3){return Math.max(0,Math.trunc(Number(e??t)))}function p(e,t={}){const o=n,s={};for(const[e,n]of Object.entries(o)){let o=t[e];const i=Array.isArray(n.type)?n.type:[n.type];i.push("undefined");const r=l(o);if(i.includes(r)){if(!0===n.normalizeArray&&"string"===r&&(o=[o]),n.itemType&&Array.isArray(o)){if(o.filter(e=>l(e)!==n.itemType).length){console.warn(`[Trivon Ui - Hyperfloat] Invalid item type for "${e}".`,`Expected items of type: ${n.itemType}`),s[e]=structuredClone(n.default);continue}}if(n.values)if(Array.isArray(o)){const t=o.filter(e=>!n.values.includes(e));if(t.length){console.warn(`[Trivon Ui - Hyperfloat] Invalid values for "${e}".`,`Expected only: ${n.values.join(", ")}`,`Received invalid: ${t.join(", ")}`),s[e]=structuredClone(n.default);continue}}else if(!n.values.includes(o)){console.warn(`[Trivon Ui - Hyperfloat] Invalid value for "${e}".`,`Expected one of: ${n.values.join(", ")}`,`Received: ${o}`),s[e]=structuredClone(n.default);continue}void 0!==o&&(s[e]=o)}else console.warn(`[Trivon Ui - Hyperfloat] Invalid type for "${e}".`,`Expected: ${i.join(", ")}`,`Received: ${r}`),s[e]=structuredClone(n.default)}return s}function h(e,t=!1){let n=!1;if(!t)for(const[t,o]of e._instancesMap)if("pointer"===o.anchor&&o.opened){n=!0;break}t||n?(function(e){if(!e._config.autoRaf||e._state.autoRafStarted)return;e._state.autoRafStarted=!0;const t=n=>{e._config.autoRaf&&e._state.autoRafStarted&&(e._raf(n),requestAnimationFrame(t))};requestAnimationFrame(t)}(e),function(e){e._state.pointerTrackingStarted||(e._state.pointerTrackingStarted=!0,window.addEventListener("pointermove",e._handlers.pointermove,{passive:!0}))}(e)):(function(e){e._config.autoRaf&&e._state.autoRafStarted&&(e._state.autoRafStarted=!1)}(e),function(e){e._state.pointerTrackingStarted&&(e._state.pointerTrackingStarted=!1,window.removeEventListener("pointermove",e._handlers.pointermove))}(e))}function y(e){const t=["auto","small","medium","large","full"];if("object"==typeof e&&null!==e)return{type:e.type??"custom",width:e.width??"100%",height:e.height??"100%"};if("string"==typeof e){const n=e.trim();if(t.includes(n))return{type:"preset",width:n,height:n}}return{type:"custom",...u(e)}}function m(t,n){if("string"==typeof t){const n=t.trim();if(e.includes(n))return n}return"viewport"===n?"center":"bottom"}function _(e){return"boolean"==typeof e&&null!==e?{enabled:e,color:"black",blur:!0}:"object"==typeof e&&null!==e?{enabled:!0,color:e.color||"black",blur:!1!==e.blur}:{enabled:!1,color:"black",blur:!0}}function g(e){return"object"==typeof e&&null!==e?{outsideClick:!!e.outsideClick,outsideWheel:!!e.outsideWheel,escapeKey:!!e.escapeKey,pointerLeave:!(!e.pointerLeave&&!e.mouseLeave),closeWithParent:!!e.closeWithParent,timeout:e.timeout?f(e.timeout):null,idleTimeout:e.idleTimeout&&void 0===e.timeout?f(e.idleTimeout):null}:{outsideClick:!1,outsideWheel:!1,escapeKey:!1,pointerLeave:!1,closeWithParent:!1,timeout:null,idleTimeout:null}}function b(e){if(!e)return[];let t=e,n="click";var o;"object"!=typeof e||Array.isArray(e)||(o=e,"undefined"!=typeof Element&&o instanceof Element)||(e=>"undefined"!=typeof NodeList&&e instanceof NodeList||"undefined"!=typeof HTMLCollection&&e instanceof HTMLCollection)(e)||!("el"in e)||(t=e.el,"string"==typeof e.event&&e.event.trim()&&(n=e.event.trim()));return n={mouseenter:"pointerenter",mousemove:"pointermove"}[n]||n,["click","pointerenter","pointermove"].includes(n)||(n="click"),r(t).map(e=>({el:e,event:n}))}function v(e){const t=e.closest("[data-hyperfloat-id]");return t?t.dataset.hyperfloatId??null:null}function x(e){if("number"==typeof e)return{mainAxis:e,crossAxis:e,alignmentAxis:null};if("string"==typeof e){return{mainAxis:d(c(e)),crossAxis:0,alignmentAxis:null}}if("object"==typeof e&&null!==e){let t=d(c(e.mainAxis??0)),n=d(c(e.crossAxis??0)),o=e.alignmentAxis?d(c(e.alignmentAxis??0)):null;return null!==o&&(n=0),{mainAxis:t,crossAxis:n,alignmentAxis:o}}return null}function w(e){return"boolean"==typeof e?{mainAxis:e,crossAxis:e}:"object"==typeof e&&null!==e?{mainAxis:!0===e.mainAxis,crossAxis:!0===e.crossAxis}:null}function A(e){return w(e)}function T(e){return w(e)}function k(e){return null==e?0:function(e){if("string"==typeof e){const t=e.trim().split(/\s+/);if(1===t.length){const e=d(c(t[0]));return{top:e,right:e,bottom:e,left:e}}if(2===t.length){const e=d(c(t[0])),n=d(c(t[1]));return{top:e,right:n,bottom:e,left:n}}if(3===t.length){const e=d(c(t[0])),n=d(c(t[1]));return{top:e,right:n,bottom:d(c(t[2])),left:n}}if(4===t.length){const e=d(c(t[0])),n=d(c(t[1])),o=d(c(t[2]));return{top:e,right:d(c(t[3])),bottom:o,left:n}}}if("number"==typeof e){const t=d(c(e));return{top:t,right:t,bottom:t,left:t}}return"object"==typeof e&&null!==e?{top:d(c(e?.top)),right:d(c(e?.right)),bottom:d(c(e?.bottom)),left:d(c(e?.left))}:{top:0,bottom:0,left:0,right:0}}(e)}function R(e){return"object"==typeof e&&null!==e&&Object.entries(e).length?{role:e.role??"dialog",label:e.label??"dialog",modal:e.modal??!1}:{role:"dialog",label:"dialog",modal:!1}}function M(e){return"object"==typeof e&&null!==e?{...e,type:e.type??"default",variant:e.variant??"default",role:e.role??"default"}:{type:"default",variant:"default",role:"dialog"}}function C(e,t){return"viewport"!==t?{enabled:!1,bounds:!1,handle:null}:"boolean"==typeof e&&null!==e?{enabled:e,bounds:!1,handle:null}:"object"==typeof e&&null!==e?{enabled:!0,bounds:!0===e.bounds,handle:null}:{enabled:!1,bounds:!1,handle:null}}function I(e){return"function"==typeof e||"string"==typeof e||e instanceof Node?e:null}function P(e,t={},n=[]){return{...void 0!==t.meta&&!n.includes("meta")&&{meta:M(t.meta??allowedValues.meta.default)},...void 0!==t.accessibility&&!n.includes("accessibility")&&{accessibility:R(t.accessibility??allowedValues.accessibility.default)},...void 0!==t.dismiss&&!n.includes("dismiss")&&{dismiss:g(t.dismiss??allowedValues.dismiss.default)},...void 0!==t.destroyAfterClose&&!n.includes("destroyAfterClose")&&{destroyAfterClose:!0===t.destroyAfterClose},...void 0!==t.autoOpen&&!n.includes("autoOpen")&&{autoOpen:!0===t.autoOpen},...void 0!==t.ignoreCloseAll&&!n.includes("ignoreCloseAll")&&{ignoreCloseAll:!0===t.ignoreCloseAll},...void 0!==t.overlay&&!n.includes("overlay")&&{overlay:_(t.overlay??allowedValues.overlay.default)},...void 0!==t.placement&&!n.includes("placement")&&{placement:m(t.placement??allowedValues.placement.default,e.anchor)},...void 0!==t.boundaryPadding&&!n.includes("boundaryPadding")&&{boundaryPadding:k(t.boundaryPadding??allowedValues.boundaryPadding.default)},...void 0!==t.draggable&&!n.includes("draggable")&&{draggable:C(t.draggable??allowedValues.draggable.default,e.anchor)},...void 0!==t.offset&&!n.includes("offset")&&{offset:x(t.offset??allowedValues.offset.default)},...void 0!==t.flip&&!n.includes("flip")&&{flip:A(t.flip??allowedValues.flip.default)},...void 0!==t.shift&&!n.includes("shift")&&{shift:T(t.shift??allowedValues.shift.default)},...void 0!==t.size&&!n.includes("size")&&{size:y(t.size??allowedValues.size.default)},...void 0!==t.header&&!n.includes("header")&&{header:I(t.header??allowedValues.header.default)},...void 0!==t.footer&&!n.includes("footer")&&{footer:I(t.footer??allowedValues.footer.default)},...void 0!==t.breakpoints&&!n.includes("breakpoints")&&{breakpoints:t.breakpoints??{}},...void 0!==t.debug&&!n.includes("debug")&&{debug:!0===t.debug}}}class Manager{constructor(){var e;return this._instancesMap=new Map,this._root=null,this._openedInstances={viewport:[],element:[],pointer:[]},this._defaults={},this._config={zIndex:9999,autoRaf:!0},this._listeners={update:[],refresh:[],raf:[],sync:[]},this._state={pointerTrackingStarted:!1,autoRafStarted:!1},this._cache={refreshVersion:0,updateVersion:0,pointer:{x:0,y:0,target:null},raf:{time:0,deltaTime:0},lastRafTime:null},this._handlers={keydown:this._onKeydown.bind(this),update:()=>async function(e){await e._callHook("update",e),e._cache.updateVersion++}(this),pointermove:e=>function(e,t){e._cache.pointer.x=t.clientX,e._cache.pointer.y=t.clientY}(this,e),refresh:()=>{this._refreshRaf||(this._refreshRaf=requestAnimationFrame(()=>{this._refreshRaf=null,async function(e){await e._callHook("refresh",e),e._cache.refreshVersion++}(this)}))}},this._update=this._handlers.update,window.addEventListener("scroll",this._handlers.update,{passive:!0}),this._refresh=this._handlers.refresh,window.addEventListener("resize",this._handlers.refresh),this._syncPointerEngine=(...e)=>h(this,...e),this._sync=(...e)=>async function(e){await e._callHook("sync",e)}(this,...e),this._on=(...e)=>function(e,t,n,o=1e3){"function"==typeof n&&e._listeners[t]&&e._listeners[t].push({callback:n,priority:o})}(this,...e),this._off=(...e)=>function(e,t,n){"function"==typeof n&&e._listeners[t]&&(e._listeners[t]=e._listeners[t].filter(e=>e.callback!==n))}(this,...e),this._callHook=(...e)=>async function(e,t){if(e._listeners[t].length){e._listeners[t].sort((e,t)=>e.priority-t.priority);for(const{callback:n,priority:o}of e._listeners[t])try{await n()}catch(e){}}}(this,...e),this._open=async(e,t={})=>await async function(e,t,n={}){const o=e._instancesMap.get(t);o&&await o.open(n)}(this,e,t),this._close=async(e,t={})=>await async function(e,t,n={}){const o=e._instancesMap.get(t);o&&await o.close(n)}(this,e,t),this._closeAll=async(e={})=>await async function(e,t={}){const{force:n=!1,...o}=t;for(const[t,s]of e._instancesMap)s.ignoreCloseAll&&!n||await s.close(o)}(this,e),this._destroy=async(e,t={})=>await async function(e,t,n={}){const o=e._instancesMap.get(t);o&&await o.destroy(n)}(this,e,t),this._destroyAll=async(e={})=>await async function(e,t={}){for(const[n,o]of e._instancesMap)await o.destroy(t);e._instancesMap.clear()}(this,e),(e=this)._root=document.createElement("div"),e._root.classList.add("_trivon-ui-hyperfloat"),e._root.style.setProperty("--trivon-ui-hyperfloat-z-index",e._config.zIndex),document.body.prepend(e._root),document.addEventListener("keydown",e._handlers.keydown),this}_onKeydown(e){"Escape"===e.key&&this._closeFirstPriority({event:"escape"})}_setHyperfloatOpened(e,t){const n=e.id,o=e.anchor;t?this._openedInstances[o].includes(n)||this._openedInstances[o].push(n):this._openedInstances[o].includes(n)&&(this._openedInstances[o]=this._openedInstances[o].filter(e=>e!==n))}_raf(e=null){!async function(e,t){const n=t??("undefined"!=typeof performance?performance.now():Date.now());e._cache.lastRafTime||(e._cache.lastRafTime=n);const o=n-e._cache.lastRafTime;e._cache.lastRafTime=n,e._cache.raf={time:n,deltaTime:o},await e._callHook("raf",e)}(this,e)}_getAll(){const e=[];for(const[t,n]of this._instancesMap)e.push(n);return e}_getOpened(e=null,t=!1){const n=[];for(const[o,s]of this._instancesMap)if(null===e||s.anchor===e){if(t){if(!s.state.opened&&!s.state.opening)continue}else if(!s.state.opened)continue;n.push(s)}return n}_getByPriority(e=">",t=1e3){const n=[];for(const[,o]of this._instancesMap){if(!o.opened)continue;const s=o._state.priority;(">"===e?s>t:">="===e?s>=t:"<"===e?s<t:"<="===e?s<=t:"=="===e&&s===t)&&n.push(o)}return n.sort((e,t)=>e._state.priority-t._state.priority),n}_getElementsAbovePriority(e=1e3){const t=[];for(const[n,o]of this._instancesMap){const n=o.opened,s=o._state.priority,i=o.elements.box,r=o.elements.overlay;n&&s>e&&(t.push(i),r&&t.push(r))}return t}_setConfig(e={}){var t,n;e.zIndex&&(t=this,n=e.zIndex,n=Number(n),t._config.zIndex=n,t._root.style.setProperty("--trivon-ui-hyperfloat-z-index",n)),e.autoRaf&&function(e,t=!0){e._state.autoRafStarted?e._config.autoRaf?console.warn("Auto RAF has already been started. m setting can no longer be changed."):console.warn("The RAF mode has already been defined and is currently managed externally. m setting can no longer be changed."):e._config.autoRaf=t}(this,e.autoRaf)}_setDefaults(e){if(e){const t=p(0,e);this._defaults=P(this,t,["ignoreCloseAll"])}}_normalizeData(e){const t=p(0,{...e,id:e.id??a({blacklist:Array.from(this._instancesMap.keys())})});return void 0===t.anchor&&(t.anchor="viewport"),t.root=this._root,t}async _closeFirstPriority(e={}){const t=Object.values(this._openedInstances).flat();let n=null;if(1===t.length){const e=this._instancesMap.get(t[0]);e.dismiss.escapeKey&&(n=e)}else for(const[e,o]of this._instancesMap)t.includes(e)&&o.dismiss.escapeKey&&(!n||o._state.priority>n._state.priority)&&(n=o);n&&await n.close(e)}}let E=null;const O=new Proxy({},{get:(e,t)=>{if("then"!==t)return()=>{}}});function j(){return"undefined"==typeof window?O:(E??=new Manager,E)}async function H(e,t,n={},o=!0){const s=[t._data[e],t[e]].filter(e=>"function"==typeof e);if(s.length){for(const i of s){let s=i.call(t,n);if(s&&"function"==typeof s.then){if(!o){console.error(`[Trivon Ui / Hyperfloat]: the hook "${e}" must be synchronous. It cannot return a Promise.`);continue}s=await s}if(!1===s||s?.prevent)return s}return!0}}function S(e,t,n,o,s={}){if(!t||"function"!=typeof o)return;let i=e._listenersMap.get(t);i||(i=new Map,e._listenersMap.set(t,i));let r=i.get(n);r||(r=new Map,i.set(n,r)),r.has(o)||(t.addEventListener(n,o,s),r.set(o,s))}function B(e,t,n,o){if(!t)return;const s=e._listenersMap.get(t);if(!s)return;const i=s.get(n);if(!i||!i.has(o))return;const r=i.get(o);t.removeEventListener(n,o,r),i.delete(o),0===i.size&&s.delete(n),0===s.size&&e._listenersMap.delete(t)}function z(e,t){if(!t)return;const n=e._listenersMap.get(t);if(n){for(const[e,o]of n)for(const[n,s]of o)t.removeEventListener(e,n,s);e._listenersMap.delete(t),delete t.dataset.hyperfloatBound,delete t.dataset.hyperfloatOpened}}function L(e){e.dismiss.pointerLeave&&function(e){"pointer"!==e._config.anchor&&S(e,e._elements.box,"pointerleave",e._handlers.pointerLeave);[...e._registry.open.keys()].forEach(t=>{S(e,t,"pointerleave",e._handlers.pointerLeave)})}(e),e.dismiss.outsideClick&&$(e,"pointerdown"),e.dismiss.outsideWheel&&$(e,"wheel")}function $(e,t,n){const o=`outside_${t}`;e._handlers[o]||(e._handlers[o]=n=>{if(!e.opened)return;if([e._elements.box,...j()._getElementsAbovePriority(e._state.priority)].some(e=>e?.contains(n.target)))return;[...e._registry.open.keys()].some(e=>e.contains(n.target))||e.close({event:"pointerdown"===t?"outside-click":"outside-wheel"})}),S(e,window,t,e._handlers[o],n)}function D(e){if("viewport"!==e.anchor)return;if(null===e.boundaryPadding||0===e.boundaryPadding)return;const t=e._elements.boundary,n=e.boundaryPadding;t.style.paddingTop=n.top+"px",t.style.paddingRight=n.right+"px",t.style.paddingBottom=n.bottom+"px",t.style.paddingLeft=n.left+"px"}function V(e){if("viewport"!==e.anchor)return;if(null===e.offset)return;const t=function(e,t){const{mainAxis:n=0,crossAxis:o=0,alignmentAxis:s=null}=e,[i,r]=t.split("-"),a="top"===i||"bottom"===i;let l=0,c=0;a?l+="top"===i?-n:n:c+="left"===i?-n:n;let d=o;return r&&null!==s&&(d=s,"end"===r&&(d*=-1)),a?c+=d:l+=d,{top:l+"px",right:"0px",bottom:"0px",left:c+"px"}}(e.offset,e.placement),n=e._elements.box;n.style.marginTop=t.top,n.style.marginRight=t.right,n.style.marginBottom=t.bottom,n.style.marginLeft=t.left}function N(e){e._elements.boundary.dataset.hyperfloatSize="preset"==e.size.type?e.size.width:"custom","custom"==e.size.type&&(e._elements.box.style.width=e.size.width??"100%",e._elements.box.style.height=e.size.height??"100%")}function U(e){null!==e.overlay&&(e._elements.boundary.dataset.hyperfloatOverlayEnabled=e.overlay.enabled,e._elements.boundary.dataset.hyperfloatOverlayColor=e.overlay.color,e._elements.boundary.dataset.hyperfloatOverlayBlur=e.overlay.blur)}function X(e){e._elements.boundary.dataset.hyperfloatPlacement=e.placement}function Y(e,t){e._config.meta=M(t??n.meta.default);const o=e._cache.lastApplyMeta,s=e._helpers.createMetaDataset();for(const t of Object.keys(o))e._elements.boundary.removeAttribute(t);for(const[t,n]of Object.entries(s))e._elements.boundary.setAttribute(t,n)}function q(e,t){e._config.accessibility=R(t??n.accessibility.default);const o=e._cache.lastApplyAccessibility,s=e._helpers.createAccessibilityDataset();for(const t of Object.keys(o))e._elements.boundary.removeAttribute(t);for(const[t,n]of Object.entries(s))e._elements.boundary.setAttribute(t,n)}function F(e,t){e._config.dismiss=g(t??n.dismiss.default),L(e)}function W(e,t){e._config.overlay=_(t??n.overlay.default),U(e)}function K(e,t){const o=m(t??n.placement.default,e.anchor);e._config.placement=o,e._state.resolvedPlacement=o,X(e)}function G(e,t){e._config.boundaryPadding=k(t??n.placement.default),D(e)}function J(e,t){e._config.offset=x(t??n.offset.default),V(e)}function Q(e,t){e._config.flip=A(t??n.flip.default),"function"==typeof syncPosition&&e.opened&&"element"==e.anchor&&e.lastTarget&&syncPosition(e)}function Z(e,t){e._config.shift=T(t??n.shift.default),"function"==typeof syncPosition&&e.opened&&"element"==e.anchor&&e.lastTarget&&syncPosition(e)}function ee(e,t){e._config.size=y(t??n.size.default),N(e)}function te(e,t){e._config.draggable=C(t??n.draggable.default,e.anchor);const o=r(t?.handle,e._elements.boundary);o[0]&&(e._config.draggable.handle=o[0])}var ne=["meta","accessibility","dismiss","destroyAfterClose","autoOpen","overlay","placement","boundaryPadding","draggable","offset","flip","shift","ignoreCloseAll","header","footer","size","breakpoints","debug"];const oe=["breakpoints","destroyAfterClose","ignoreCloseAll","draggable","autoOpen","header","footer","debug"],se=ne.filter(e=>!oe.includes(e));function ie(e){if(!e._breakpoints||!e._breakpoints.length)return;const t=j()._cache.refreshVersion;if(e._state.firstresolveBreakpointsDone&&t===e._cache.resolveBreakpointsVersion)return;let n=!1;const o=window.innerWidth,s=e._breakpoints;for(const[t,i]of s)if(o<=t){n=!0,e._cache.lastBreakpoint!==t&&(e._cache.lastBreakpoint=t,re(e,i,t));break}if(!n){const[t,n]=e._breakpoints[e._breakpoints.length-1];e._cache.lastBreakpoint!==t&&(e._cache.lastBreakpoint=t,re(e,n,t))}e._cache.resolveBreakpointsVersion=t,e._state.firstresolveBreakpointsDone=!0}function re(e,t,n){for(const[o,s]of Object.entries(t))"meta"==o&&Y(e,s),"accessibility"==o&&q(e,s),"dismiss"==o&&F(e,s),"overlay"==o&&W(e,s),"placement"==o&&K(e,s),"boundaryPadding"==o&&G(e,s),"offset"==o&&J(e,s),"flip"==o&&Q(e,s),"shift"==o&&Z(e,s),"size"==o&&ee(e,s),e._console.log(`Breakpoint: ${n} -> ${o}:`,s)}function ae(e,t,n){const{left:o,top:s,right:i,bottom:r,width:a,height:l}=t,{width:c,height:d}=n,u=o+a/2,f=s+l/2;switch(e){case"center":default:return{left:u-c/2,top:f-d/2};case"top":return{left:u-c/2,top:s-d};case"top-start":return{left:o,top:s-d};case"top-end":return{left:i-c,top:s-d};case"right":return{left:i,top:f-d/2};case"right-start":return{left:i,top:s};case"right-end":return{left:i,top:r-d};case"bottom":return{left:u-c/2,top:r};case"bottom-start":return{left:o,top:r};case"bottom-end":return{left:i-c,top:r};case"left":return{left:o-c,top:f-d/2};case"left-start":return{left:o-c,top:s};case"left-end":return{left:o-c,top:r-d}}}function le({boundaryRect:e=window,elementRect:t=null,anchorRect:n=null,placement:o="bottom",offset:s=null,flip:i=null,shift:r=null}={}){let a,l,c=o;const d=()=>{if(({left:a,top:l}=ae(c,n,t)),null!==s&&({left:a,top:l}=function(e,t,n,o){const{mainAxis:s=0,crossAxis:i=0,alignmentAxis:r=null}=e,[a,l]=t.split("-"),c="top"===a||"bottom"===a;c?o+="top"===a?-s:s:n+="left"===a?-s:s;let d=i;return l&&null!==r&&(d=r,"end"===l&&(d*=-1)),c?n+=d:o+=d,{left:n,top:o}}(s,c,a,l)),null!==r){const o=function(e,t,n,o,s,i,r,a=null){const{mainAxis:l=!1,crossAxis:c=!1}=e,d=(e,t,n)=>Math.max(t,Math.min(e,n)),[u,f]=t.split("-"),p="top"===u||"bottom"===u,h=n.left,y=n.right-s.width,m=n.top,_=n.bottom-s.height;if(p?(c&&(i=d(i,h,y)),l&&(r=d(r,m,_))):(l&&(i=d(i,h,y)),c&&(r=d(r,m,_))),null!==a){const{mainAxis:e=!1,crossAxis:t=!1}=a;let n=!1;if(e&&("right"===u&&i<o.right&&(n=!0),"left"===u&&i+s.width>o.left&&(n=!0),"top"===u&&r+s.height>o.top&&(n=!0),"bottom"===u&&r<o.bottom&&(n=!0)),n)return null}return{left:i,top:r}}(r,c,e,n,t,a,l,i);return null!==o&&(({left:a,top:l}=o),!0)}return!0},u=d();if(null!==i&&!u){const o=function({flip:e,placement:t,boundaryRect:n,anchorRect:o,elementRect:s}){if(null===e)return null;const{mainAxis:i=!0,crossAxis:r=!1}=e,[a,l]=t.split("-"),c=(e,t)=>e>=n.left&&e+s.width<=n.right&&t>=n.top&&t+s.height<=n.bottom,d=(e,t=l)=>t?`${e}-${t}`:e;if(i){const e=(e=>{switch(e){case"top":return"bottom";case"bottom":return"top";case"left":return"right";case"right":return"left";default:return e}})(a),t=d(e),{left:n,top:i}=ae(t,o,s);if(c(n,i))return t}if(r&&l){const e=(e=>"start"===e?"end":"end"===e?"start":null)(l);if(e){const t=d(a,e),{left:n,top:i}=ae(t,o,s);if(c(n,i))return t}}return null}({flip:i,placement:c,boundaryRect:e,anchorRect:n,elementRect:t});o&&(c=o,d())}return{position:{left:a,top:l},coordinates:{left:a,top:l},placement:c,resolvedPlacement:c}}function ce(e,t,n){const o=b(n??null);if(!o.length)return()=>{};const s=[];return o.forEach(n=>{const o={hostHyperfloat:v(n.el),event:n.event};e._registry[t].set(n.el,o),s.push(n.el)}),"open"===t?de(e):fe(e),L(e),()=>{!function(e,t,n){r(n).forEach(n=>{n instanceof Element&&e._registry[t]?.has(n)&&(z(e,n),e._registry[t].delete(n),e._state.pointer.target.el==n&&(e._state.pointer.target={el:null,action:null}))})}(e,t,s)}}function de(e){for(const[t,n]of e._registry.open)t instanceof Element?"true"!==t.dataset.hyperfloatBound&&(ue(e,t,n),t.dataset.hyperfloatOpened=String(e.opened),t.dataset.hyperfloatBound="true",S(e,t,"pointerenter",()=>{e._state.pointer.target={el:t,action:"open"}})):(z(e,t),e._registry.open.delete(t))}function ue(e,t,n){const o=n.event;"click"!=o?["pointerenter","pointermove"].includes(o)&&S(e,t,"pointer"===e.anchor?"pointermove":"pointerenter",()=>e.open({target:t})):S(e,t,"click",()=>{e.opened?e.close({target:t}):e.open({target:t})})}function fe(e){for(const[t,n]of e._registry.close)t instanceof Element?"true"!==t.dataset.hyperfloatBound&&(S(e,t,"click",()=>{e.close({target:t})}),t.dataset.hyperfloatOpened=String(e.opened),t.dataset.hyperfloatBound="true",S(e,t,"pointerenter",()=>{e._state.pointer.target={el:t,action:"close"}})):(z(e,t),e._registry.close.delete(t))}async function pe(e,t,n){const o=e._data?.interpolate??e.interpolate??null;if("function"==typeof o){const s=await o.call(e,{axis:"x",current:e._state.interpolation.lastX??t,target:t,pointer:e._state.pointer});"number"==typeof s&&(t=s);const i=await o.call(e,{axis:"y",current:e._state.interpolation.lastY??n,target:n,pointer:e._state.pointer});"number"==typeof i&&(n=i)}return e._state.interpolation.lastX=t,e._state.interpolation.lastY=n,{x:t,y:n}}function he(e){const t=j();let n=0;t._instancesMap.forEach(e=>{e&&e._state.ready&&(n=Math.max(n,e._state.priority??0))});const o=n+1;e._state.priority=o;const s="pointer"===e.anchor?o+1e3:o,i=e.elements?.boundary;i&&(i.style.zIndex=String(s))}async function ye(e,t){if(!t||!e._state.drag)return;const n=t.clientX-e._state.drag.startX,o=t.clientY-e._state.drag.startY;let s=e._state.drag.initialX+n,i=e._state.drag.initialY+o;e.draggable.bounds&&(s=Math.max(e._state.drag.minX,Math.min(s,e._state.drag.maxX)),i=Math.max(e._state.drag.minY,Math.min(i,e._state.drag.maxY))),e._state.position.x=s,e._state.position.y=i;const{x:r,y:a}=await pe(e,s,i);e._elements.positioner.style.transform=`translate3d(${r}px, ${a}px, 0)`,await H("onMove",e,{x:r,y:a})}function me(e,{force:t=!1}={}){!function(e){de(e),fe(e)}(e),L(e),H("onSync",e,{})}function _e(e,{force:t=!1}={}){if(!e._elements.boundary||!e._elements.box||"element"==e.anchor&&!e._registry.open.size)return;const n=j()._cache.refreshVersion;if(!t&&e._state.firstcomputeRectsDone&&n===e._cache.computeRectsVersion)return;(["pointer","element"].includes(e.anchor)||e.draggable?.enabled)&&(e._cache.positionerRect=e._elements.positioner.getBoundingClientRect());const o=e._elements.boundary.getBoundingClientRect();if(null===e.boundaryPadding||0===e.boundaryPadding)e._cache.boundaryRect=o;else{const t=e.boundaryPadding;e._cache.boundaryRect={x:o.x,y:o.y,left:o.left+t.left,top:o.top+t.top,right:o.right-t.right,bottom:o.bottom-t.bottom,width:o.right-t.right-(o.left+t.left),height:o.bottom-t.bottom-(o.top+t.top)}}e._cache.computeRectsVersion=n,e._state.firstcomputeRectsDone=!0}async function ge(e){if(!e._registry.open.size||!e.positionerRect||!e.boundaryRect||"element"===e.anchor&&!e.lastTarget)return e._elements.positioner.style.transform="",e._state.anchored=!1,void(e._elements.boundary.dataset.hyperfloatAnchored="false");let t;if("pointer"===e.anchor){const n=j()._cache.pointer;0===n.x&&0===n.y?e._elements.positioner.style.opacity=0:"0"==e._elements.positioner.style.opacity&&(e._elements.positioner.style.opacity=""),e._state.pointer.x=n.x,e._state.pointer.y=n.y,t={left:e._state.pointer.x-5,top:e._state.pointer.y-5,right:e._state.pointer.x+5,bottom:e._state.pointer.y+5,width:10,height:10,x:e._state.pointer.x-5,y:e._state.pointer.y-5}}else t=e.lastTarget.getBoundingClientRect();(function(e){let t=null;return t="object"==typeof e&&null!==e?e:e.getBoundingClientRect(),t.bottom<=0||t.top>=window.innerHeight||t.right<=0||t.left>=window.innerWidth})(t)?e._timers.outside||(e._timers.outside=setTimeout(()=>{e.close({event:"target-outside"}),e._timers.outside=null},e._outsideCloseDelay)):(clearTimeout(e._timers.outside),e._timers.outside=null),e._state.anchored=!0,e._elements.boundary.dataset.hyperfloatAnchored="true",e._state.resolvedPlacement=e.placement;const n=le({elementRect:e.positionerRect,anchorRect:t,boundaryRect:e.boundaryRect,placement:e.placement,offset:e.offset,flip:e.flip,shift:e.shift});e._state.resolvedPlacement=n.resolvedPlacement;const{x:o,y:s}=await pe(e,n.position.left,n.position.top),i=o+"px",r=s+"px";e._elements.positioner.style.transform=`translate3d(${i}, ${r}, 0)`,await H("onMove",e,{x:i,y:r})}async function be(e,{target:t=null,event:n=null,source:o="user"}={}){if(!e._state.ready)return;if(e._state.opened||e._state.locked)return;if(e._state.locked=!0,e._state.opening=!0,e._console.log("Opening:",e.id),e._cache.parentHyperfloat=null,t){let n=e._registry.open.get(t);n&&n.hostHyperfloat!==e.id&&(e._cache.parentHyperfloat=n.hostHyperfloat)}let s=await H("onBeforeOpen",e,{target:t,event:n,source:o});if(!1===s||s?.prevent)return e._state.locked=!1,e._state.opened=!1,void(e._state.opening=!1);he(e),e._cache.lastTarget=t,e._state.pointer.target={el:t,action:"open"},"pointer"===e.anchor&&j()._syncPointerEngine(!0),["pointer","element"].includes(e.anchor)&&(e._state.firstcomputeRectsDone||(await new Promise(requestAnimationFrame),await new Promise(requestAnimationFrame)),_e(e),ge(e)),e.draggable?.enabled&&(e._state.firstcomputeRectsDone||(await new Promise(requestAnimationFrame),await new Promise(requestAnimationFrame)),_e(e),ye(e)),ie(e),e.dismiss.timeout&&null!==e.dismiss.timeout?e._handlers.startTimeoutTimer():e.dismiss.idleTimeout&&null!==e.dismiss.idleTimeout&&(S(e,e.elements.box,"pointerenter",e._handlers.stopIdleTimer),S(e,e.elements.box,"pointerleave",e._handlers.startIdleTimer),S(e,e.elements.box,"pointerdown",e._handlers.stopIdleTimer),S(e,e.elements.box,"wheel",e._handlers.stopIdleTimer,{passive:!0}),S(e,e.elements.box,"touchstart",e._handlers.stopIdleTimer,{passive:!0}),S(e,e.elements.box,"keydown",e._handlers.stopIdleTimer),S(e,e.elements.box,"focusin",e._handlers.stopIdleTimer),e._handlers.startIdleTimer()),await H("onOpen",e,{target:t,event:n,source:o}),e._state.opened=!0,e._state.opening=!1,e._elements.boundary.dataset.hyperfloatOpened="true",j()._setHyperfloatOpened(e,!0),e._console.log("Open:",e.id);for(const[t,n]of e._registry.open)t.dataset.hyperfloatOpened="true";for(const[t,n]of e._registry.close)t.dataset.hyperfloatOpened="true";await H("onAfterOpen",e,{target:t,event:n,source:o}),e._state.locked=!1}async function ve(e,{target:t=null,event:n=null,source:o="user"}={}){if(!e._state.ready)return;if(!e._state.opened||e._state.locked)return;e._state.locked=!0,e._state.opening=!1,e._console.log("Closing:",e.id);for(const[t,s]of j()._instancesMap)s.parentHyperfloat===e.id&&s.dismiss.closeWithParent&&await s.close({el:el,event:n,source:o});let s=await H("onBeforeClose",e,{target:t,event:n,source:o});if(!1===s||s?.prevent)return e._state.locked=!1,e._state.opened=!0,void(e._state.opening=!1);e._cache.lastcloseTarget=t,e._state.pointer.target={el:t,action:"close"},e.dismiss.timeout&&null!==e.dismiss.timeout?e._handlers.stopTimeoutTimer():e.dismiss.idleTimeout&&null!==e.dismiss.idleTimeout&&(e._handlers.stopIdleTimer(),B(e,e.elements.box,"pointerenter",e._handlers.stopIdleTimer),B(e,e.elements.box,"pointerleave",e._handlers.startIdleTimer),B(e,e.elements.box,"pointerdown",e._handlers.stopIdleTimer),B(e,e.elements.box,"wheel",e._handlers.stopIdleTimer),B(e,e.elements.box,"touchstart",e._handlers.stopIdleTimer),B(e,e.elements.box,"keydown",e._handlers.stopIdleTimer),B(e,e.elements.box,"focusin",e._handlers.stopIdleTimer)),await H("onClose",e,{target:t,event:n,source:o}),e._state.opened=!1,e._state.opening=!1,e._elements.boundary.dataset.hyperfloatOpened="false",j()._setHyperfloatOpened(e,!1),e._console.log("Close:",e.id);for(const[t,n]of e._registry.open)t.dataset.hyperfloatOpened="false";for(const[t,n]of e._registry.close)t.dataset.hyperfloatOpened="false";await H("onAfterClose",e,{target:t,event:n,source:o}),e._cache.lastTarget=null,e._cache.parentHyperfloat=null,e._state.pointer.target={el:null,action:null},"pointer"===e.anchor&&j()._syncPointerEngine(),e._state.locked=!1,e.destroyAfterClose&&await xe(e)}async function xe(e,{target:t=null,event:n=null,source:o="user"}={}){e.opened&&await ve(e,{event:"destroy",source:o}),await H("onDestroy",e,{target:t,event:n,source:o}),function(e){for(const[t,n]of e._listenersMap)for(const[e,o]of n)for(const[n,s]of o)t.removeEventListener(e,n,s);e._listenersMap.clear()}(e),e._elements.boundary&&e._elements.boundary.remove(),j()._off("sync",e._handlers.sync),j()._off("update",e._handlers.update),j()._off("refresh",e._handlers.refresh),j()._off("raf",e._handlers.raf),j()._instancesMap.delete(e.id)}async function we(e){await H("onBeforeInit",e,{}),function(e){e._elements.boundary=i("div",{attrs:{...e._helpers.createMetaDataset(),...e._helpers.createAccessibilityDataset(),"data-hyperfloat-boundary":"",id:`${e.id}`,"data-hyperfloat-id":`${e.id}`,"data-hyperfloat-opened":"false","data-hyperfloat-anchor":e.anchor,"data-hyperfloat-anchored":e._state.anchored,"data-hyperfloat-draggable":!0===e.draggable?.enabled},appendTo:e._elements.root}),e._elements.overlayEl=i("div",{class:"hyperfloat-overlay",attrs:{"data-hyperfloat-overlay":""},appendTo:e._elements.boundary}),U(e);const t=["pointer","element"].includes(e.anchor)||e.draggable?.enabled;t&&(e._elements.positioner=i("div",{attrs:{"data-hyperfloat-positioner":""},appendTo:e._elements.boundary}));const n=t?e._elements.positioner:e._elements.boundary;e._elements.box=i("div",{class:"hyperfloat-box",attrs:{"data-hyperfloat-box":""},appendTo:n}),e._elements.headerInner=s(e.header,e),e._elements.headerInner&&(e._elements.header=i("div",{class:"hyperfloat-header",attrs:{"data-hyperfloat-header":""},html:e._elements.headerInner,appendTo:e._elements.box}),e._elements.header.style.order=1),e._elements.content=i("div",{attrs:{"data-hyperfloat-content":""},appendTo:e._elements.box}),e._elements.content.style.order=2,e._elements.contentInner=i("div",{attrs:{"data-hyperfloat-content-inner":""},appendTo:e._elements.content}),e.content?s(e.content,{},e._elements.contentInner):e._elements.loading=i("div",{class:"hyperfloat-loading",attrs:{"data-hyperfloat-loading":""},html:'<span class="hyperfloat-loading-bar" data-hyperfloat-loading-bar></span>',appendTo:e._elements.content}),e._elements.footerInner=s(e.footer,e),e._elements.footerInner&&(e._elements.footer=i("div",{class:"hyperfloat-footer",attrs:{"data-hyperfloat-footer":""},html:e._elements.footerInner,appendTo:e._elements.box}),e._elements.footer.style.order=3),D(e),V(e),X(e),N(e),e.draggable?.enabled&&e._data?.draggable?.handle&&te(e,{bounds:e.draggable.bounds,handle:e._data?.draggable?.handle})}(e),function(e){const t=r(e._defaultCloseSelector,e._elements.boundary);e._elements.overlayEl&&t.push(e._elements.overlayEl),t.forEach(t=>{const n={hostHyperfloat:v(t),event:"click"};e._registry.close.has(t)||e._registry.close.set(t,n)})}(e),me(e),function(e){const t=e.breakpoints||{},n=Object.keys(t);if(!n.length)return void(e._breakpoints=[]);const o=(e,t)=>{const n={...e};for(const s in t)"object"!=typeof t[s]||Array.isArray(t[s])||null===t[s]||"object"!=typeof e[s]?void 0!==t[s]&&null!==t[s]&&(n[s]=t[s]):n[s]=o(e[s],t[s]);return n},s=Math.max(...n.map(Number))+1,i={};for(const t of se)void 0!==e[t]&&(i[t]=e[t]);const r=n.map(Number).sort((e,t)=>t-e);r.unshift(s);const a={};a[s]=i;for(let n=1;n<r.length;n++){const s=r[n],i=t[s];let l={};for(const e of Object.keys(i))se.includes(e)&&(l[e]=i[e]);l=P(e,l,oe);const c=a[r[n-1]];l=o(c,l),a[s]=l}e._breakpoints=Object.entries(a).map(([e,t])=>[Number(e),t]).sort((e,t)=>e[0]-t[0])}(e),function(e){e.draggable?.enabled&&(e._state.anchored=!0,e._elements.boundary.dataset.hyperfloatAnchored="true",e._handlers.pointerMove=t=>{if(e._state.drag){if(!e._state.dragging){const n=Math.abs(t.clientX-e._state.drag.startX),o=Math.abs(t.clientY-e._state.drag.startY);(n>3||o>3)&&(e._state.dragging=!0,document.body.style.userSelect="none",e._elements.box.style.touchAction="none")}e._state.dragging&&ye(e,t)}},e._handlers.pointerUp=t=>{e._state.drag&&(e._state.dragging&&(document.body.style.userSelect="",e._elements.box.style.touchAction=""),e._state.drag=null),e._state.dragging=!1,B(e,document,"pointermove",e._handlers.pointerMove),B(e,document,"pointerup",e._handlers.pointerUp)},e._handlers.pointerDown=t=>{if(0!==t.button)return;if(!e.opened)return;if(["BUTTON","INPUT","TEXTAREA","SELECT","A"].includes(t.target.tagName)||t.target.closest("[data-no-drag]"))return;if(e.draggable.handle){const n=e.draggable.handle;if("string"==typeof n){if(!t.target.closest(n))return}else if((n instanceof Node||n instanceof Element)&&!n.contains(t.target))return}const n=e.positionerRect,o=e.boundaryRect,s=e._state.position.x||0,i=e._state.position.y||0;e._state.drag={startX:t.clientX,startY:t.clientY,initialX:s,initialY:i,minX:o?s-(n.left-o.left):-1/0,maxX:o?s+(o.right-n.right):1/0,minY:o?i-(n.top-o.top):-1/0,maxY:o?i+(o.bottom-n.bottom):1/0},e._state.dragging=!1,he(e),S(e,document,"pointermove",e._handlers.pointerMove),S(e,document,"pointerup",e._handlers.pointerUp)},S(e,e._elements.box,"pointerdown",e._handlers.pointerDown))}(e),await H("onInit",e,{}),await H("onAfterInit",e,{}),function(e){e._console.log("Ready:",e.id),H("onReady",e,{})}(e),e._state.ready=!0}const Ae="1.0.45";class Hyperfloat{constructor(e){if("undefined"==typeof window)return;const t=j()._normalizeData(e);this._data=t,this._id=t.id,this._listenersMap=new Map,this._config={anchor:t.anchor??"viewport"},this._config={...this._config,...P(this,t)},this.content=t.content??null,this._console=function(e,t=""){return e.debug?{log:(...e)=>console.log(t,...e),info:(...e)=>console.info(t,...e),warn:(...e)=>console.warn(t,...e),error:(...e)=>console.error(t,...e),table:(...e)=>{const n=e.pop();console.log(t,...e),console.table(n)}}:{log:()=>{},info:()=>{},warn:()=>{},error:()=>{},table:()=>{}}}(this,"[Trivon Ui - Hyperfloat]"),this._timers={pointerLeave:null,idle:null,timeout:null,outside:null},this._outsideCloseDelay=4e3,this._elements={root:t.root,boundary:null,positioner:null,box:null,content:null,contentInner:null,overlayEl:null,header:null,headerInner:null,footer:null,footerInner:null,loading:null},this._state={ready:!1,opened:!1,opening:!1,locked:!1,dragging:!1,anchored:["element","pointer"].includes(this.anchor),priority:0,pointer:{x:0,y:0,target:{el:null,action:null}},drag:null,position:{x:0,y:0},interpolation:{lastX:0,lastY:0},resolvedPlacement:this._config.placement,firstresolveBreakpointsDone:!1,firstcomputeRectsDone:!1},this._breakpoints=[],this._handlers={startIdleTimer:()=>{clearTimeout(this._timers.idle),!this.dismiss.idleTimeout||this.dismiss.idleTimeout<=0||(this._timers.idle=setTimeout(()=>{ve(this,{event:"no-interaction"})},this.dismiss.idleTimeout))},stopIdleTimer:()=>{clearTimeout(this._timers.idle)},startTimeoutTimer:()=>{clearTimeout(this._timers.timeout),!this.dismiss.timeout||this.dismiss.timeout<=0||(this._timers.timeout=setTimeout(()=>{ve(this,{event:"timeout"})},this.dismiss.timeout))},stopTimeoutTimer:()=>{clearTimeout(this._timers.timeout)},sync:(...e)=>me(this,...e),update:(...e)=>function(e,{force:t=!1}={}){e.opened&&"element"==e.anchor&&e.lastTarget&&(ge(e),H("onUpdate",e,{}))}(this,...e),refresh:(...e)=>function(e,{force:t=!1}={}){e.opened&&(["pointer","element"].includes(e.anchor)&&_e(e,{force:t}),e.draggable?.enabled&&_e(e,{force:t}),e._breakpoints&&!e._breakpoints.length&&ie(e),["pointer","element"].includes(e.anchor)&&e.lastTarget&&ge(e),e.draggable?.enabled&&ye(e)),H("onRefresh",e,{})}(this,...e),raf:()=>{var e;(e=this).opened&&"pointer"==e.anchor&&ge(e)},pointerLeave:e=>{if(!this._state.opened&&!this._state.opening)return;const t=e.currentTarget||e.target,n=e.relatedTarget;n&&(this._elements.box.contains(n)||[...this._registry.open.keys()].some(e=>e.contains(n)))||("pointer"===this.anchor?(clearTimeout(this._timers.pointerLeave),this._timers.pointerLeave=setTimeout(()=>{this._elements.box.matches(":hover")||[...this._registry.open.keys()].some(e=>e.matches(":hover"))||this.close({target:t,event:"pointerleave"})},100)):this.close({target:t,event:"pointerleave"}))},pointerMove:()=>{},pointerDown:()=>{},pointerUp:()=>{}},this.sync=this._handlers.sync,this.update=this._handlers.update,this.refresh=this._handlers.refresh,j()._on("sync",this._handlers.sync),j()._on("update",this._handlers.update),j()._on("refresh",this._handlers.refresh),j()._on("raf",this._handlers.raf),this.open=async(...e)=>await be(this,...e),this.close=async(...e)=>await ve(this,...e),this.destroy=async(...e)=>await xe(this,...e),this._cache={boundaryRect:null,positionerRect:null,targetRects:new Map,parentHyperfloat:null,lastTarget:null,lastcloseTarget:null,lastBreakpoint:9999999999999,computeRectsVersion:0,resolveBreakpointsVersion:0,syncPositionVersion:0,lastApplyMeta:{},lastApplyAccessibility:{}},this._registry={open:new Map,close:new Map};for(const e of Object.keys(this._registry)){b(t[e]??null).forEach(t=>{this._registry[e].set(t.el,{hostHyperfloat:v(t.el),event:t.event})})}return this.registerOpen=e=>ce(this,"open",e),this.registerClose=e=>ce(this,"close",e),this.unregisterOpen=e=>unregisterAction(this,"open",e),this.unregisterClose=e=>unregisterAction(this,"close",e),this.vars=t.vars??{},j()._instancesMap.set(this.id,this),this}static async create(e={}){if("undefined"==typeof window)return null;if(e.id&&j()._instancesMap.has(e.id)){const t=j()._instancesMap.get(e.id);if(!(!0===e.overwrite))return t.sync(),t;t.destroy()}const t=new this(e);return await we(t),!0===e.autoOpen&&await be(t,{event:"initialize",source:"auto"}),t}get id(){return this._id}get anchor(){return this._config.anchor}get opened(){return this._state.opened}get resolvedPlacement(){return this._state.resolvedPlacement}get state(){return{ready:this._state.ready,priority:this._state.priority,anchored:this._state.anchored,pointer:this._state.pointer,locked:this._state.locked,opened:this._state.opened,opening:this._state.opening,dragging:this._state.dragging}}get elements(){return{boundary:this._elements.boundary,overlay:this._elements.overlayEl,positioner:this._elements.positioner,box:this._elements.box,content:this._elements.content,contentInner:this._elements.contentInner,loading:this._elements.loading,header:this._elements.header,headerInner:this._elements.headerInner,footer:this._elements.footer,footerInner:this._elements.footerInner}}get lastTarget(){return this._cache.lastTarget}get parentHyperfloat(){return this._cache.parentHyperfloat}get boundaryRect(){return this._cache.boundaryRect}get positionerRect(){return this._cache.positionerRect}get lastBreakpoint(){return this._cache.lastBreakpoint}_helpers={createAccessibilityDataset:()=>{const e=Object.fromEntries(Object.entries(this.accessibility).map(([e,t])=>{let n="";switch(e){case"role":n=e;break;case"label":n="aria-label";break;default:n=`data-${e}`}return[n,String(t)]}));return this._cache.lastApplyAccessibility=e,e},createMetaDataset:()=>{const e=Object.fromEntries(Object.entries(this.meta).map(([e,t])=>[`data-${e}`,String(t)]));return this._cache.lastApplyMeta=e,e}};static get version(){return Ae}static get _manager(){return j()}static config(e={}){j()._setConfig(e)}static defaults(e={}){j()._setDefaults(e)}static async open(e,t={}){await j()._open(e,t)}static async close(e,t={}){await j()._close(e,t)}static async closeAll(e={}){await j()._closeAll(e)}static async destroy(e,t={}){await j()._destroy(e,t)}static async destroyAll(e={}){await j()._destroyAll(e)}static sync(){j()._sync()}static update(){j()._update()}static refresh(){j()._refresh()}static raf(e){j()._raf(e)}static getAll(){return j()._getAll()}static getOpened(...e){return j()._getOpened(...e)}static getByPriority(...e){return j()._getByPriority(...e)}}return ne.forEach(e=>{Object.defineProperty(Hyperfloat.prototype,e,{get(){return this._config[e]??j()._defaults[e]??n[e].default},set(t){"meta"==e?Y(this,t):"accessibility"==e?q(this,t):"dismiss"==e?F(this,t):"overlay"==e?W(this,t):"placement"==e?K(this,t):"boundaryPadding"==e?G(this,t):"offset"==e?J(this,t):"flip"==e?Q(this,t):"shift"==e?Z(this,t):"size"==e?ee(this,t):"draggable"==e?te(this,t):["destroyAfterClose","ignoreCloseAll","debug"].includes(e)&&(this._config[e]=!0===t)},configurable:!0,enumerable:!0})}),Hyperfloat}();
9
9
  //# sourceMappingURL=hyperfloat.min.js.map
@@ -1,9 +1,9 @@
1
1
  /*!
2
- * Hyperfloat 1.0.44
2
+ * Hyperfloat 1.0.45
3
3
  * https://trivonui.com/hyperfloat
4
4
  *
5
5
  * Copyright 2026 — Felipe Otto (Trivon UI)
6
6
  * Restored under the MIT License
7
7
  */
8
- var e=["center","top","top-start","top-end","right","right-start","right-end","bottom","bottom-start","bottom-end","left","left-start","left-end"];const t={};["onBeforeInit","onInit","onAfterInit","onReady","onSync","onDestroy","onBeforeOpen","onOpen","onAfterOpen","onBeforeClose","onClose","onAfterClose","onRefresh","onUpdate","onMove"].forEach(e=>{t[e]={type:["null","function"],default:null}});var n={id:{type:"string",default:""},meta:{type:["null","object"],default:{type:"default",variant:"default",role:"dialog"}},accessibility:{type:["null","object"],default:{role:"dialog",label:"dialog",modal:!1}},anchor:{type:["string"],values:["viewport","element","pointer"],default:"viewport"},open:{type:["null","string","element","node","nodeList","array","object"],default:null},close:{type:["null","string","element","node","nodeList","array"],default:null},ignoreCloseAll:{type:"boolean",default:!1},autoOpen:{type:"boolean",default:!1},destroyAfterClose:{type:"boolean",default:!1},overlay:{type:["boolean","object"],default:null},placement:{type:"string",values:e,default:"center"},boundaryPadding:{type:["string","number","object","null"],default:0},draggable:{type:["boolean","object"],default:null},offset:{type:["string","number","object","null"],default:null},flip:{type:["object","boolean","null"],default:null},shift:{type:["object","boolean","null"],default:null},dismiss:{type:"object",default:{outsideClick:!1,outsideWheel:!1,escapeKey:!1,pointerLeave:!1,closeWithParent:!1,timeout:null,idleTimeout:null}},size:{type:["string","number","object"],default:"small"},breakpoints:{type:"object",default:{}},content:{type:["null","string","function","node"],default:null},header:{type:["null","string","function","node"],default:null},footer:{type:["null","string","function","node"],default:null},vars:{type:["null","object"],default:{}},interpolate:{type:["null","function"],default:null},debug:{type:"boolean",default:!1},...t};function o(e,t={}){if("function"==typeof e){return o(e.call(t),t)}if(e instanceof Promise)return o(e,t);if(e instanceof Node)return e;if("string"==typeof e){const t=e.trim();if(/^<.+?>/.test(t)){const e=document.createElement("div");e.innerHTML=t;const n=document.createDocumentFragment();for(;e.firstChild;)n.appendChild(e.firstChild);return n}return document.createTextNode(t)}return e}function s(e,t={},n=null){if(!e)return null;const s=o(e,t);if(!s)return null;if(!n){const e=document.querySelector("._trivon-ui-hyperfloat");let t=e.querySelector("[data-hyperfloat-sandbox]");t||(t=document.createElement("div"),t.dataset.hyperfloatSandbox="",e.appendChild(t)),n=t}let i;return s instanceof DocumentFragment?(i=Array.from(s.childNodes),n.appendChild(s)):Array.isArray(s)?(i=s,n.append(...s)):s instanceof Node&&(i=[s],n.appendChild(s)),i?.[0]||null}function i(e,t={}){const n=document.createElement(e);if(t.class){const e=Array.isArray(t.class)?t.class:t.class.trim().split(/\s+/);n.classList.add(...e)}t.attrs&&Object.entries(t.attrs).forEach(([e,t])=>n.setAttribute(e,t)),t.text&&(n.textContent=t.text);const o=t.html??t.innerHTML??t.innerHtml??t.content??null;if(o&&s(o,{},n),t.style&&this.applyStyle(n,t.style),!t.appendTo&&!t.prependTo){const e=document.querySelector("._trivon-ui-hyperfloat");let t=e.querySelector("[data-hyperfloat-sandbox]");t||(t=document.createElement("div"),t.dataset.hyperfloatSandbox="",e.appendChild(t)),t.appendChild(n)}return t.appendTo&&t.appendTo.appendChild(n),t.prependTo&&t.prependTo.prepend(n),n}function r(e,t=("undefined"!=typeof document?document:null),n=!1){if(!e)return[];const o="undefined"!=typeof Element,s=e=>o&&e instanceof Element;if(s(e))return[e];const i="string"==typeof t&&"undefined"!=typeof document?document.querySelector(t):t,r=new Set,a=e=>{if(e)if(s(e))r.add(e);else if("string"!=typeof e){if(Array.isArray(e)||"object"==typeof e&&"number"==typeof e.length&&"function"!=typeof e)for(let t=0;t<e.length;t++)a(e[t])}else{if(n)return void r.add(e);if(i&&"function"==typeof i.querySelectorAll)try{const t=i.querySelectorAll(e);for(let e=0;e<t.length;e++)r.add(t[e])}catch{}}};return a(e),Array.from(r)}function a({prefix:e="uuid",blacklist:t=[]}={}){let n="";return n="undefined"!=typeof crypto&&"function"==typeof crypto.randomUUID?`${e}-${crypto.randomUUID()}`:"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}),t.includes(n)?a({prefix:e,blacklist:t}):n}function l(e){return null===e?"null":Array.isArray(e)?"array":"undefined"!=typeof Node&&e instanceof Node?"node":"object"==typeof e?"object":typeof e}function c(e){if("string"==typeof e){const t=e.trim();if(/^-?[\d.]+(px|%|em|rem|vh|vw)$/.test(t)||/^(var|calc|min|max|clamp)\(.+\)$/.test(t))return t;const n=parseHyperfloat(t);return isNaN(n)?null:`${n}px`}return"number"==typeof e?`${e}px`:"0px"}function d(e){"number"==typeof e&&(e=`${e}px`);const t=document.createElement("div");t.style.all="initial",t.style.position="absolute",t.style.visibility="hidden",t.style.pointerEvents="none",t.style.width=e,document.body.appendChild(t);const n=getComputedStyle(t).width;document.body.removeChild(t);const o=parseHyperfloat(n);return isNaN(o)?0:o}function u(e){if("string"==typeof e){const t=e.trim().split(/\s+/);if(1===t.length){const e=c(t[0]);return{width:e,height:e}}if(2===t.length)return{width:c(t[0]),height:c(t[1])}}if("number"==typeof e){const t=c(e);return{width:t,height:t}}return"object"==typeof e&&null!==e?{width:c(e?.width),height:c(e?.height)}:{width:"auto",height:"auto"}}function f(e,t=4e3){return Math.max(0,Math.trunc(Number(e??t)))}function p(e,t={}){const o=n,s={};for(const[e,n]of Object.entries(o)){let o=t[e];const i=Array.isArray(n.type)?n.type:[n.type];i.push("undefined");const r=l(o);if(i.includes(r)){if(!0===n.normalizeArray&&"string"===r&&(o=[o]),n.itemType&&Array.isArray(o)){if(o.filter(e=>l(e)!==n.itemType).length){console.warn(`[Trivon Ui - Hyperfloat] Invalid item type for "${e}".`,`Expected items of type: ${n.itemType}`),s[e]=structuredClone(n.default);continue}}if(n.values)if(Array.isArray(o)){const t=o.filter(e=>!n.values.includes(e));if(t.length){console.warn(`[Trivon Ui - Hyperfloat] Invalid values for "${e}".`,`Expected only: ${n.values.join(", ")}`,`Received invalid: ${t.join(", ")}`),s[e]=structuredClone(n.default);continue}}else if(!n.values.includes(o)){console.warn(`[Trivon Ui - Hyperfloat] Invalid value for "${e}".`,`Expected one of: ${n.values.join(", ")}`,`Received: ${o}`),s[e]=structuredClone(n.default);continue}void 0!==o&&(s[e]=o)}else console.warn(`[Trivon Ui - Hyperfloat] Invalid type for "${e}".`,`Expected: ${i.join(", ")}`,`Received: ${r}`),s[e]=structuredClone(n.default)}return s}function h(e,t=!1){let n=!1;if(!t)for(const[t,o]of e._instancesMap)if("pointer"===o.anchor&&o.opened){n=!0;break}t||n?(function(e){if(!e._config.autoRaf||e._state.autoRafStarted)return;e._state.autoRafStarted=!0;const t=n=>{e._config.autoRaf&&e._state.autoRafStarted&&(e._raf(n),requestAnimationFrame(t))};requestAnimationFrame(t)}(e),function(e){e._state.pointerTrackingStarted||(e._state.pointerTrackingStarted=!0,window.addEventListener("pointermove",e._handlers.pointermove,{passive:!0}))}(e)):(function(e){e._config.autoRaf&&e._state.autoRafStarted&&(e._state.autoRafStarted=!1)}(e),function(e){e._state.pointerTrackingStarted&&(e._state.pointerTrackingStarted=!1,window.removeEventListener("pointermove",e._handlers.pointermove))}(e))}function y(e){const t=["auto","small","medium","large","full"];if("object"==typeof e&&null!==e)return{type:e.type??"custom",width:e.width??"100%",height:e.height??"100%"};if("string"==typeof e){const n=e.trim();if(t.includes(n))return{type:"preset",width:n,height:n}}return{type:"custom",...u(e)}}function m(t,n){if("string"==typeof t){const n=t.trim();if(e.includes(n))return n}return"viewport"===n?"center":"bottom"}function _(e){return"boolean"==typeof e&&null!==e?{enabled:e,color:"black",blur:!0}:"object"==typeof e&&null!==e?{enabled:!0,color:e.color||"black",blur:!1!==e.blur}:{enabled:!1,color:"black",blur:!0}}function g(e){return"object"==typeof e&&null!==e?{outsideClick:!!e.outsideClick,outsideWheel:!!e.outsideWheel,escapeKey:!!e.escapeKey,pointerLeave:!(!e.pointerLeave&&!e.mouseLeave),closeWithParent:!!e.closeWithParent,timeout:e.timeout?f(e.timeout):null,idleTimeout:e.idleTimeout&&void 0===e.timeout?f(e.idleTimeout):null}:{outsideClick:!1,outsideWheel:!1,escapeKey:!1,pointerLeave:!1,closeWithParent:!1,timeout:null,idleTimeout:null}}function b(e){if(!e)return[];let t=e,n="click";var o;"object"!=typeof e||Array.isArray(e)||(o=e,"undefined"!=typeof Element&&o instanceof Element)||(e=>"undefined"!=typeof NodeList&&e instanceof NodeList||"undefined"!=typeof HTMLCollection&&e instanceof HTMLCollection)(e)||!("el"in e)||(t=e.el,"string"==typeof e.event&&e.event.trim()&&(n=e.event.trim()));return n={mouseenter:"pointerenter",mousemove:"pointermove"}[n]||n,["click","pointerenter","pointermove"].includes(n)||(n="click"),r(t).map(e=>({el:e,event:n}))}function v(e){const t=e.closest("[data-hyperfloat-id]");return t?t.dataset.hyperfloatId??null:null}function x(e){if("number"==typeof e)return{mainAxis:e,crossAxis:e,alignmentAxis:null};if("string"==typeof e){return{mainAxis:d(c(e)),crossAxis:0,alignmentAxis:null}}if("object"==typeof e&&null!==e){let t=d(c(e.mainAxis??0)),n=d(c(e.crossAxis??0)),o=e.alignmentAxis?d(c(e.alignmentAxis??0)):null;return null!==o&&(n=0),{mainAxis:t,crossAxis:n,alignmentAxis:o}}return null}function w(e){return"boolean"==typeof e?{mainAxis:e,crossAxis:e}:"object"==typeof e&&null!==e?{mainAxis:!0===e.mainAxis,crossAxis:!0===e.crossAxis}:null}function A(e){return w(e)}function T(e){return w(e)}function k(e){return null==e?0:function(e){if("string"==typeof e){const t=e.trim().split(/\s+/);if(1===t.length){const e=d(c(t[0]));return{top:e,right:e,bottom:e,left:e}}if(2===t.length){const e=d(c(t[0])),n=d(c(t[1]));return{top:e,right:n,bottom:e,left:n}}if(3===t.length){const e=d(c(t[0])),n=d(c(t[1]));return{top:e,right:n,bottom:d(c(t[2])),left:n}}if(4===t.length){const e=d(c(t[0])),n=d(c(t[1])),o=d(c(t[2]));return{top:e,right:d(c(t[3])),bottom:o,left:n}}}if("number"==typeof e){const t=d(c(e));return{top:t,right:t,bottom:t,left:t}}return"object"==typeof e&&null!==e?{top:d(c(e?.top)),right:d(c(e?.right)),bottom:d(c(e?.bottom)),left:d(c(e?.left))}:{top:0,bottom:0,left:0,right:0}}(e)}function R(e){return"object"==typeof e&&null!==e&&Object.entries(e).length?{role:e.role??"dialog",label:e.label??"dialog",modal:e.modal??!1}:{role:"dialog",label:"dialog",modal:!1}}function M(e){return"object"==typeof e&&null!==e?{...e,type:e.type??"default",variant:e.variant??"default",role:e.role??"default"}:{type:"default",variant:"default",role:"dialog"}}function C(e,t){return"viewport"!==t?{enabled:!1,bounds:!1,handle:null}:"boolean"==typeof e&&null!==e?{enabled:e,bounds:!1,handle:null}:"object"==typeof e&&null!==e?{enabled:!0,bounds:!0===e.bounds,handle:null}:{enabled:!1,bounds:!1,handle:null}}function I(e){return"function"==typeof e||"string"==typeof e||e instanceof Node?e:null}function P(e,t={},n=[]){return{...void 0!==t.meta&&!n.includes("meta")&&{meta:M(t.meta??allowedValues.meta.default)},...void 0!==t.accessibility&&!n.includes("accessibility")&&{accessibility:R(t.accessibility??allowedValues.accessibility.default)},...void 0!==t.dismiss&&!n.includes("dismiss")&&{dismiss:g(t.dismiss??allowedValues.dismiss.default)},...void 0!==t.destroyAfterClose&&!n.includes("destroyAfterClose")&&{destroyAfterClose:!0===t.destroyAfterClose},...void 0!==t.autoOpen&&!n.includes("autoOpen")&&{autoOpen:!0===t.autoOpen},...void 0!==t.ignoreCloseAll&&!n.includes("ignoreCloseAll")&&{ignoreCloseAll:!0===t.ignoreCloseAll},...void 0!==t.overlay&&!n.includes("overlay")&&{overlay:_(t.overlay??allowedValues.overlay.default)},...void 0!==t.placement&&!n.includes("placement")&&{placement:m(t.placement??allowedValues.placement.default,e.anchor)},...void 0!==t.boundaryPadding&&!n.includes("boundaryPadding")&&{boundaryPadding:k(t.boundaryPadding??allowedValues.boundaryPadding.default)},...void 0!==t.draggable&&!n.includes("draggable")&&{draggable:C(t.draggable??allowedValues.draggable.default,e.anchor)},...void 0!==t.offset&&!n.includes("offset")&&{offset:x(t.offset??allowedValues.offset.default)},...void 0!==t.flip&&!n.includes("flip")&&{flip:A(t.flip??allowedValues.flip.default)},...void 0!==t.shift&&!n.includes("shift")&&{shift:T(t.shift??allowedValues.shift.default)},...void 0!==t.size&&!n.includes("size")&&{size:y(t.size??allowedValues.size.default)},...void 0!==t.header&&!n.includes("header")&&{header:I(t.header??allowedValues.header.default)},...void 0!==t.footer&&!n.includes("footer")&&{footer:I(t.footer??allowedValues.footer.default)},...void 0!==t.breakpoints&&!n.includes("breakpoints")&&{breakpoints:t.breakpoints??{}},...void 0!==t.debug&&!n.includes("debug")&&{debug:!0===t.debug}}}class Manager{constructor(){var e;return this._instancesMap=new Map,this._root=null,this._openedInstances={viewport:[],element:[],pointer:[]},this._defaults={},this._config={zIndex:9999,autoRaf:!0},this._listeners={update:[],refresh:[],raf:[],sync:[]},this._state={pointerTrackingStarted:!1,autoRafStarted:!1},this._cache={refreshVersion:0,updateVersion:0,pointer:{x:0,y:0,target:null},raf:{time:0,deltaTime:0},lastRafTime:null},this._handlers={keydown:this._onKeydown.bind(this),update:()=>async function(e){await e._callHook("update",e),e._cache.updateVersion++}(this),pointermove:e=>function(e,t){e._cache.pointer.x=t.clientX,e._cache.pointer.y=t.clientY}(this,e),refresh:()=>{this._refreshRaf||(this._refreshRaf=requestAnimationFrame(()=>{this._refreshRaf=null,async function(e){await e._callHook("refresh",e),e._cache.refreshVersion++}(this)}))}},this._update=this._handlers.update,window.addEventListener("scroll",this._handlers.update,{passive:!0}),this._refresh=this._handlers.refresh,window.addEventListener("resize",this._handlers.refresh),this._syncPointerEngine=(...e)=>h(this,...e),this._sync=(...e)=>async function(e){await e._callHook("sync",e)}(this,...e),this._on=(...e)=>function(e,t,n,o=1e3){"function"==typeof n&&e._listeners[t]&&e._listeners[t].push({callback:n,priority:o})}(this,...e),this._off=(...e)=>function(e,t,n){"function"==typeof n&&e._listeners[t]&&(e._listeners[t]=e._listeners[t].filter(e=>e.callback!==n))}(this,...e),this._callHook=(...e)=>async function(e,t){if(e._listeners[t].length){e._listeners[t].sort((e,t)=>e.priority-t.priority);for(const{callback:n,priority:o}of e._listeners[t])try{await n()}catch(e){}}}(this,...e),this._open=async(e,t={})=>await async function(e,t,n={}){const o=e._instancesMap.get(t);o&&await o.open(n)}(this,e,t),this._close=async(e,t={})=>await async function(e,t,n={}){const o=e._instancesMap.get(t);o&&await o.close(n)}(this,e,t),this._closeAll=async(e={})=>await async function(e,t={}){const{force:n=!1,...o}=t;for(const[t,s]of e._instancesMap)s.ignoreCloseAll&&!n||await s.close(o)}(this,e),this._destroy=async(e,t={})=>await async function(e,t,n={}){const o=e._instancesMap.get(t);o&&await o.destroy(n)}(this,e,t),this._destroyAll=async(e={})=>await async function(e,t={}){for(const[n,o]of e._instancesMap)await o.destroy(t);e._instancesMap.clear()}(this,e),(e=this)._root=document.createElement("div"),e._root.classList.add("_trivon-ui-hyperfloat"),e._root.style.setProperty("--trivon-ui-hyperfloat-z-index",e._config.zIndex),document.body.prepend(e._root),document.addEventListener("keydown",e._handlers.keydown),this}_onKeydown(e){"Escape"===e.key&&this._closeFirstPriority({event:"escape"})}_setHyperfloatOpened(e,t){const n=e.id,o=e.anchor;t?this._openedInstances[o].includes(n)||this._openedInstances[o].push(n):this._openedInstances[o].includes(n)&&(this._openedInstances[o]=this._openedInstances[o].filter(e=>e!==n))}_raf(e=null){!async function(e,t){const n=t??("undefined"!=typeof performance?performance.now():Date.now());e._cache.lastRafTime||(e._cache.lastRafTime=n);const o=n-e._cache.lastRafTime;e._cache.lastRafTime=n,e._cache.raf={time:n,deltaTime:o},await e._callHook("raf",e)}(this,e)}_getAll(){const e=[];for(const[t,n]of this._instancesMap)e.push(n);return e}_getOpened(e=null,t=!1){const n=[];for(const[o,s]of this._instancesMap)if(null===e||s.anchor===e){if(t){if(!s.state.opened&&!s.state.opening)continue}else if(!s.state.opened)continue;n.push(s)}return n}_getByPriority(e=">",t=1e3){const n=[];for(const[,o]of this._instancesMap){if(!o.opened)continue;const s=o._state.priority;(">"===e?s>t:">="===e?s>=t:"<"===e?s<t:"<="===e?s<=t:"=="===e&&s===t)&&n.push(o)}return n.sort((e,t)=>e._state.priority-t._state.priority),n}_getElementsAbovePriority(e=1e3){const t=[];for(const[n,o]of this._instancesMap){const n=o.opened,s=o._state.priority,i=o.elements.box,r=o.elements.overlay;n&&s>e&&(t.push(i),r&&t.push(r))}return t}_setConfig(e={}){var t,n;e.zIndex&&(t=this,n=e.zIndex,n=Number(n),t._config.zIndex=n,t._root.style.setProperty("--trivon-ui-hyperfloat-z-index",n)),e.autoRaf&&function(e,t=!0){e._state.autoRafStarted?e._config.autoRaf?console.warn("Auto RAF has already been started. m setting can no longer be changed."):console.warn("The RAF mode has already been defined and is currently managed externally. m setting can no longer be changed."):e._config.autoRaf=t}(this,e.autoRaf)}_setDefaults(e){if(e){const t=p(0,e);this._defaults=P(this,t,["ignoreCloseAll"])}}_normalizeData(e){const t=p(0,{...e,id:e.id??a({blacklist:Array.from(this._instancesMap.keys())})});return void 0===t.anchor&&(t.anchor="viewport"),t.root=this._root,t}async _closeFirstPriority(e={}){const t=Object.values(this._openedInstances).flat();let n=null;if(1===t.length){const e=this._instancesMap.get(t[0]);e.dismiss.escapeKey&&(n=e)}else for(const[e,o]of this._instancesMap)t.includes(e)&&o.dismiss.escapeKey&&(!n||o._state.priority>n._state.priority)&&(n=o);n&&await n.close(e)}}let E=null;const O=new Proxy({},{get:(e,t)=>{if("then"!==t)return()=>{}}});function j(){return"undefined"==typeof window?O:(E??=new Manager,E)}async function H(e,t,n={},o=!0){const s=[t._data[e],t[e]].filter(e=>"function"==typeof e);if(s.length){for(const i of s){let s=i.call(t,n);if(s&&"function"==typeof s.then){if(!o){console.error(`[Trivon Ui / Hyperfloat]: the hook "${e}" must be synchronous. It cannot return a Promise.`);continue}s=await s}if(!1===s||s?.prevent)return s}return!0}}function S(e,t,n,o,s={}){if(!t||"function"!=typeof o)return;let i=e._listenersMap.get(t);i||(i=new Map,e._listenersMap.set(t,i));let r=i.get(n);r||(r=new Map,i.set(n,r)),r.has(o)||(t.addEventListener(n,o,s),r.set(o,s))}function B(e,t,n,o){if(!t)return;const s=e._listenersMap.get(t);if(!s)return;const i=s.get(n);if(!i||!i.has(o))return;const r=i.get(o);t.removeEventListener(n,o,r),i.delete(o),0===i.size&&s.delete(n),0===s.size&&e._listenersMap.delete(t)}function z(e,t){if(!t)return;const n=e._listenersMap.get(t);if(n){for(const[e,o]of n)for(const[n,s]of o)t.removeEventListener(e,n,s);e._listenersMap.delete(t),delete t.dataset.hyperfloatBound,delete t.dataset.hyperfloatOpened}}function L(e){e.dismiss.pointerLeave&&function(e){"pointer"!==e._config.anchor&&S(e,e._elements.box,"pointerleave",e._handlers.pointerLeave);[...e._registry.open.keys()].forEach(t=>{S(e,t,"pointerleave",e._handlers.pointerLeave)})}(e),e.dismiss.outsideClick&&$(e,"pointerdown"),e.dismiss.outsideWheel&&$(e,"wheel")}function $(e,t,n){const o=`outside_${t}`;e._handlers[o]||(e._handlers[o]=n=>{if(!e.opened)return;if([e._elements.box,...j()._getElementsAbovePriority(e._state.priority)].some(e=>e?.contains(n.target)))return;[...e._registry.open.keys()].some(e=>e.contains(n.target))||e.close({event:"pointerdown"===t?"outside-click":"outside-wheel"})}),S(e,window,t,e._handlers[o],n)}function D(e){if("viewport"!==e.anchor)return;if(null===e.boundaryPadding||0===e.boundaryPadding)return;const t=e._elements.boundary,n=e.boundaryPadding;t.style.paddingTop=n.top+"px",t.style.paddingRight=n.right+"px",t.style.paddingBottom=n.bottom+"px",t.style.paddingLeft=n.left+"px"}function V(e){if("viewport"!==e.anchor)return;if(null===e.offset)return;const t=function(e,t){const{mainAxis:n=0,crossAxis:o=0,alignmentAxis:s=null}=e,[i,r]=t.split("-"),a="top"===i||"bottom"===i;let l=0,c=0;a?l+="top"===i?-n:n:c+="left"===i?-n:n;let d=o;return r&&null!==s&&(d=s,"end"===r&&(d*=-1)),a?c+=d:l+=d,{top:l+"px",right:"0px",bottom:"0px",left:c+"px"}}(e.offset,e.placement),n=e._elements.box;n.style.marginTop=t.top,n.style.marginRight=t.right,n.style.marginBottom=t.bottom,n.style.marginLeft=t.left}function N(e){e._elements.boundary.dataset.hyperfloatSize="preset"==e.size.type?e.size.width:"custom","custom"==e.size.type&&(e._elements.box.style.width=e.size.width??"100%",e._elements.box.style.height=e.size.height??"100%")}function U(e){null!==e.overlay&&(e._elements.boundary.dataset.hyperfloatOverlayEnabled=e.overlay.enabled,e._elements.boundary.dataset.hyperfloatOverlayColor=e.overlay.color,e._elements.boundary.dataset.hyperfloatOverlayBlur=e.overlay.blur)}function X(e){e._elements.boundary.dataset.hyperfloatPlacement=e.placement}function Y(e,t){e._config.meta=M(t??n.meta.default);const o=e._cache.lastApplyMeta,s=e._helpers.createMetaDataset();for(const t of Object.keys(o))e._elements.boundary.removeAttribute(t);for(const[t,n]of Object.entries(s))e._elements.boundary.setAttribute(t,n)}function q(e,t){e._config.accessibility=R(t??n.accessibility.default);const o=e._cache.lastApplyAccessibility,s=e._helpers.createAccessibilityDataset();for(const t of Object.keys(o))e._elements.boundary.removeAttribute(t);for(const[t,n]of Object.entries(s))e._elements.boundary.setAttribute(t,n)}function F(e,t){e._config.dismiss=g(t??n.dismiss.default),L(e)}function W(e,t){e._config.overlay=_(t??n.overlay.default),U(e)}function K(e,t){const o=m(t??n.placement.default,e.anchor);e._config.placement=o,e._state.resolvedPlacement=o,X(e)}function G(e,t){e._config.boundaryPadding=k(t??n.placement.default),D(e)}function J(e,t){e._config.offset=x(t??n.offset.default),V(e)}function Q(e,t){e._config.flip=A(t??n.flip.default),"function"==typeof syncPosition&&e.opened&&"element"==e.anchor&&e.lastTarget&&syncPosition(e)}function Z(e,t){e._config.shift=T(t??n.shift.default),"function"==typeof syncPosition&&e.opened&&"element"==e.anchor&&e.lastTarget&&syncPosition(e)}function ee(e,t){e._config.size=y(t??n.size.default),N(e)}function te(e,t){e._config.draggable=C(t??n.draggable.default,e.anchor);const o=r(t?.handle,e._elements.boundary);o[0]&&(e._config.draggable.handle=o[0])}var ne=["meta","accessibility","dismiss","destroyAfterClose","autoOpen","overlay","placement","boundaryPadding","draggable","offset","flip","shift","ignoreCloseAll","header","footer","size","breakpoints","debug"];const oe=["breakpoints","destroyAfterClose","ignoreCloseAll","draggable","autoOpen","header","footer","debug"],se=ne.filter(e=>!oe.includes(e));function ie(e){if(!e._breakpoints||!e._breakpoints.length)return;const t=j()._cache.refreshVersion;if(e._state.firstresolveBreakpointsDone&&t===e._cache.resolveBreakpointsVersion)return;let n=!1;const o=window.innerWidth,s=e._breakpoints;for(const[t,i]of s)if(o<=t){n=!0,e._cache.lastBreakpoint!==t&&(e._cache.lastBreakpoint=t,re(e,i,t));break}if(!n){const[t,n]=e._breakpoints[e._breakpoints.length-1];e._cache.lastBreakpoint!==t&&(e._cache.lastBreakpoint=t,re(e,n,t))}e._cache.resolveBreakpointsVersion=t,e._state.firstresolveBreakpointsDone=!0}function re(e,t,n){for(const[o,s]of Object.entries(t))"meta"==o&&Y(e,s),"accessibility"==o&&q(e,s),"dismiss"==o&&F(e,s),"overlay"==o&&W(e,s),"placement"==o&&K(e,s),"boundaryPadding"==o&&G(e,s),"offset"==o&&J(e,s),"flip"==o&&Q(e,s),"shift"==o&&Z(e,s),"size"==o&&ee(e,s),e._console.log(`Breakpoint: ${n} -> ${o}:`,s)}function ae(e,t,n){const{left:o,top:s,right:i,bottom:r,width:a,height:l}=t,{width:c,height:d}=n,u=o+a/2,f=s+l/2;switch(e){case"center":default:return{left:u-c/2,top:f-d/2};case"top":return{left:u-c/2,top:s-d};case"top-start":return{left:o,top:s-d};case"top-end":return{left:i-c,top:s-d};case"right":return{left:i,top:f-d/2};case"right-start":return{left:i,top:s};case"right-end":return{left:i,top:r-d};case"bottom":return{left:u-c/2,top:r};case"bottom-start":return{left:o,top:r};case"bottom-end":return{left:i-c,top:r};case"left":return{left:o-c,top:f-d/2};case"left-start":return{left:o-c,top:s};case"left-end":return{left:o-c,top:r-d}}}function le({boundaryRect:e=window,elementRect:t=null,anchorRect:n=null,placement:o="bottom",offset:s=null,flip:i=null,shift:r=null}={}){let a,l,c=o;const d=()=>{if(({left:a,top:l}=ae(c,n,t)),null!==s&&({left:a,top:l}=function(e,t,n,o){const{mainAxis:s=0,crossAxis:i=0,alignmentAxis:r=null}=e,[a,l]=t.split("-"),c="top"===a||"bottom"===a;c?o+="top"===a?-s:s:n+="left"===a?-s:s;let d=i;return l&&null!==r&&(d=r,"end"===l&&(d*=-1)),c?n+=d:o+=d,{left:n,top:o}}(s,c,a,l)),null!==r){const o=function(e,t,n,o,s,i,r,a=null){const{mainAxis:l=!1,crossAxis:c=!1}=e,d=(e,t,n)=>Math.max(t,Math.min(e,n)),[u,f]=t.split("-"),p="top"===u||"bottom"===u,h=n.left,y=n.right-s.width,m=n.top,_=n.bottom-s.height;if(p?(c&&(i=d(i,h,y)),l&&(r=d(r,m,_))):(l&&(i=d(i,h,y)),c&&(r=d(r,m,_))),null!==a){const{mainAxis:e=!1,crossAxis:t=!1}=a;let n=!1;if(e&&("right"===u&&i<o.right&&(n=!0),"left"===u&&i+s.width>o.left&&(n=!0),"top"===u&&r+s.height>o.top&&(n=!0),"bottom"===u&&r<o.bottom&&(n=!0)),n)return null}return{left:i,top:r}}(r,c,e,n,t,a,l,i);return null!==o&&(({left:a,top:l}=o),!0)}return!0},u=d();if(null!==i&&!u){const o=function({flip:e,placement:t,boundaryRect:n,anchorRect:o,elementRect:s}){if(null===e)return null;const{mainAxis:i=!0,crossAxis:r=!1}=e,[a,l]=t.split("-"),c=(e,t)=>e>=n.left&&e+s.width<=n.right&&t>=n.top&&t+s.height<=n.bottom,d=(e,t=l)=>t?`${e}-${t}`:e;if(i){const e=(e=>{switch(e){case"top":return"bottom";case"bottom":return"top";case"left":return"right";case"right":return"left";default:return e}})(a),t=d(e),{left:n,top:i}=ae(t,o,s);if(c(n,i))return t}if(r&&l){const e=(e=>"start"===e?"end":"end"===e?"start":null)(l);if(e){const t=d(a,e),{left:n,top:i}=ae(t,o,s);if(c(n,i))return t}}return null}({flip:i,placement:c,boundaryRect:e,anchorRect:n,elementRect:t});o&&(c=o,d())}return{position:{left:a,top:l},coordinates:{left:a,top:l},placement:c,resolvedPlacement:c}}function ce(e,t,n){const o=b(n??null);if(!o.length)return()=>{};const s=[];return o.forEach(n=>{const o={hostHyperfloat:v(n.el),event:n.event};e._registry[t].set(n.el,o),s.push(n.el)}),"open"===t?de(e):fe(e),L(e),()=>{!function(e,t,n){r(n).forEach(n=>{n instanceof Element&&e._registry[t]?.has(n)&&(z(e,n),e._registry[t].delete(n),e._state.pointer.target.el==n&&(e._state.pointer.target={el:null,action:null}))})}(e,t,s)}}function de(e){for(const[t,n]of e._registry.open)t instanceof Element?"true"!==t.dataset.hyperfloatBound&&(ue(e,t,n),t.dataset.hyperfloatOpened=String(e.opened),t.dataset.hyperfloatBound="true",S(e,t,"pointerenter",()=>{e._state.pointer.target={el:t,action:"open"}})):(z(e,t),e._registry.open.delete(t))}function ue(e,t,n){const o=n.event;"click"!=o?["pointerenter","pointermove"].includes(o)&&S(e,t,"pointer"===e.anchor?"pointermove":"pointerenter",()=>e.open({target:t})):S(e,t,"click",()=>{e.opened?e.close({target:t}):e.open({target:t})})}function fe(e){for(const[t,n]of e._registry.close)t instanceof Element?"true"!==t.dataset.hyperfloatBound&&(S(e,t,"click",()=>{e.close({target:t})}),t.dataset.hyperfloatOpened=String(e.opened),t.dataset.hyperfloatBound="true",S(e,t,"pointerenter",()=>{e._state.pointer.target={el:t,action:"close"}})):(z(e,t),e._registry.close.delete(t))}async function pe(e,t,n){const o=e._data?.interpolate??e.interpolate??null;if("function"==typeof o){const s=await o.call(e,{axis:"x",current:e._state.interpolation.lastX??t,target:t,pointer:e._state.pointer});"number"==typeof s&&(t=s);const i=await o.call(e,{axis:"y",current:e._state.interpolation.lastY??n,target:n,pointer:e._state.pointer});"number"==typeof i&&(n=i)}return e._state.interpolation.lastX=t,e._state.interpolation.lastY=n,{x:t,y:n}}function he(e){const t=j();let n=0;t._instancesMap.forEach(e=>{e&&e._state.ready&&(n=Math.max(n,e._state.priority??0))});const o=n+1;e._state.priority=o;const s="pointer"===e.anchor?o+1e3:o,i=e.elements?.boundary;i&&(i.style.zIndex=String(s))}async function ye(e,t){if(!t||!e._state.drag)return;const n=t.clientX-e._state.drag.startX,o=t.clientY-e._state.drag.startY;let s=e._state.drag.initialX+n,i=e._state.drag.initialY+o;e.draggable.bounds&&(s=Math.max(e._state.drag.minX,Math.min(s,e._state.drag.maxX)),i=Math.max(e._state.drag.minY,Math.min(i,e._state.drag.maxY))),e._state.position.x=s,e._state.position.y=i;const{x:r,y:a}=await pe(e,s,i);e._elements.positioner.style.transform=`translate3d(${r}px, ${a}px, 0)`,await H("onMove",e,{x:r,y:a})}function me(e,{force:t=!1}={}){!function(e){de(e),fe(e)}(e),L(e),H("onSync",e,{})}function _e(e,{force:t=!1}={}){if(!e._elements.boundary||!e._elements.box||"element"==e.anchor&&!e._registry.open.size)return;const n=j()._cache.refreshVersion;if(!t&&e._state.firstcomputeRectsDone&&n===e._cache.computeRectsVersion)return;(["pointer","element"].includes(e.anchor)||e.draggable?.enabled)&&(e._cache.positionerRect=e._elements.positioner.getBoundingClientRect());const o=e._elements.boundary.getBoundingClientRect();if(null===e.boundaryPadding||0===e.boundaryPadding)e._cache.boundaryRect=o;else{const t=e.boundaryPadding;e._cache.boundaryRect={x:o.x,y:o.y,left:o.left+t.left,top:o.top+t.top,right:o.right-t.right,bottom:o.bottom-t.bottom,width:o.right-t.right-(o.left+t.left),height:o.bottom-t.bottom-(o.top+t.top)}}e._cache.computeRectsVersion=n,e._state.firstcomputeRectsDone=!0}async function ge(e){if(!e._registry.open.size||!e.positionerRect||!e.boundaryRect||"element"===e.anchor&&!e.lastTarget)return e._elements.positioner.style.transform="",e._state.anchored=!1,void(e._elements.boundary.dataset.hyperfloatAnchored="false");let t;if("pointer"===e.anchor){const n=j()._cache.pointer;0===n.x&&0===n.y?e._elements.positioner.style.opacity=0:"0"==e._elements.positioner.style.opacity&&(e._elements.positioner.style.opacity=""),e._state.pointer.x=n.x,e._state.pointer.y=n.y,t={left:e._state.pointer.x-5,top:e._state.pointer.y-5,right:e._state.pointer.x+5,bottom:e._state.pointer.y+5,width:10,height:10,x:e._state.pointer.x-5,y:e._state.pointer.y-5}}else t=e.lastTarget.getBoundingClientRect();(function(e){let t=null;return t="object"==typeof e&&null!==e?e:e.getBoundingClientRect(),t.bottom<=0||t.top>=window.innerHeight||t.right<=0||t.left>=window.innerWidth})(t)?e._timers.outside||(e._timers.outside=setTimeout(()=>{e.close({event:"target-outside"}),e._timers.outside=null},e._outsideCloseDelay)):(clearTimeout(e._timers.outside),e._timers.outside=null),e._state.anchored=!0,e._elements.boundary.dataset.hyperfloatAnchored="true",e._state.resolvedPlacement=e.placement;const n=le({elementRect:e.positionerRect,anchorRect:t,boundaryRect:e.boundaryRect,placement:e.placement,offset:e.offset,flip:e.flip,shift:e.shift});e._state.resolvedPlacement=n.resolvedPlacement;const{x:o,y:s}=await pe(e,n.position.left,n.position.top),i=o+"px",r=s+"px";e._elements.positioner.style.transform=`translate3d(${i}, ${r}, 0)`,await H("onMove",e,{x:i,y:r})}async function be(e,{target:t=null,event:n=null,source:o="user"}={}){if(!e._state.ready)return;if(e._state.opened||e._state.locked)return;if(e._state.locked=!0,e._state.opening=!0,e._console.log("Opening:",e.id),e._cache.parentHyperfloat=null,t){let n=e._registry.open.get(t);n&&n.hostHyperfloat!==e.id&&(e._cache.parentHyperfloat=n.hostHyperfloat)}let s=await H("onBeforeOpen",e,{target:t,event:n,source:o});if(!1===s||s?.prevent)return e._state.locked=!1,e._state.opened=!1,void(e._state.opening=!1);he(e),e._cache.lastTarget=t,e._state.pointer.target={el:t,action:"open"},"pointer"===e.anchor&&j()._syncPointerEngine(!0),["pointer","element"].includes(e.anchor)&&(e._state.firstcomputeRectsDone||(await new Promise(requestAnimationFrame),await new Promise(requestAnimationFrame)),_e(e),ge(e)),e.draggable?.enabled&&(e._state.firstcomputeRectsDone||(await new Promise(requestAnimationFrame),await new Promise(requestAnimationFrame)),_e(e),ye(e)),ie(e),e.dismiss.timeout&&null!==e.dismiss.timeout?e._handlers.startTimeoutTimer():e.dismiss.idleTimeout&&null!==e.dismiss.idleTimeout&&(S(e,e.elements.box,"pointerenter",e._handlers.stopIdleTimer),S(e,e.elements.box,"pointerleave",e._handlers.startIdleTimer),S(e,e.elements.box,"pointerdown",e._handlers.stopIdleTimer),S(e,e.elements.box,"wheel",e._handlers.stopIdleTimer,{passive:!0}),S(e,e.elements.box,"touchstart",e._handlers.stopIdleTimer,{passive:!0}),S(e,e.elements.box,"keydown",e._handlers.stopIdleTimer),S(e,e.elements.box,"focusin",e._handlers.stopIdleTimer),e._handlers.startIdleTimer()),await H("onOpen",e,{target:t,event:n,source:o}),e._state.opened=!0,e._state.opening=!1,e._elements.boundary.dataset.hyperfloatOpened="true",j()._setHyperfloatOpened(e,!0),e._console.log("Open:",e.id);for(const[t,n]of e._registry.open)t.dataset.hyperfloatOpened="true";for(const[t,n]of e._registry.close)t.dataset.hyperfloatOpened="true";await H("onAfterOpen",e,{target:t,event:n,source:o}),e._state.locked=!1}async function ve(e,{target:t=null,event:n=null,source:o="user"}={}){if(!e._state.ready)return;if(!e._state.opened||e._state.locked)return;e._state.locked=!0,e._state.opening=!1,e._console.log("Closing:",e.id);for(const[t,s]of j()._instancesMap)s.parentHyperfloat===e.id&&s.dismiss.closeWithParent&&await s.close({el:el,event:n,source:o});let s=await H("onBeforeClose",e,{target:t,event:n,source:o});if(!1===s||s?.prevent)return e._state.locked=!1,e._state.opened=!0,void(e._state.opening=!1);e._cache.lastcloseTarget=t,e._state.pointer.target={el:t,action:"close"},e.dismiss.timeout&&null!==e.dismiss.timeout?e._handlers.stopTimeoutTimer():e.dismiss.idleTimeout&&null!==e.dismiss.idleTimeout&&(e._handlers.stopIdleTimer(),B(e,e.elements.box,"pointerenter",e._handlers.stopIdleTimer),B(e,e.elements.box,"pointerleave",e._handlers.startIdleTimer),B(e,e.elements.box,"pointerdown",e._handlers.stopIdleTimer),B(e,e.elements.box,"wheel",e._handlers.stopIdleTimer),B(e,e.elements.box,"touchstart",e._handlers.stopIdleTimer),B(e,e.elements.box,"keydown",e._handlers.stopIdleTimer),B(e,e.elements.box,"focusin",e._handlers.stopIdleTimer)),await H("onClose",e,{target:t,event:n,source:o}),e._state.opened=!1,e._state.opening=!1,e._elements.boundary.dataset.hyperfloatOpened="false",j()._setHyperfloatOpened(e,!1),e._console.log("Close:",e.id);for(const[t,n]of e._registry.open)t.dataset.hyperfloatOpened="false";for(const[t,n]of e._registry.close)t.dataset.hyperfloatOpened="false";await H("onAfterClose",e,{target:t,event:n,source:o}),e._cache.lastTarget=null,e._cache.parentHyperfloat=null,e._state.pointer.target={el:null,action:null},"pointer"===e.anchor&&j()._syncPointerEngine(),e._state.locked=!1,e.destroyAfterClose&&await xe(e)}async function xe(e,{target:t=null,event:n=null,source:o="user"}={}){e.opened&&await ve(e,{event:"destroy",source:o}),await H("onDestroy",e,{target:t,event:n,source:o}),function(e){for(const[t,n]of e._listenersMap)for(const[e,o]of n)for(const[n,s]of o)t.removeEventListener(e,n,s);e._listenersMap.clear()}(e),e._elements.boundary&&e._elements.boundary.remove(),j()._off("sync",e._handlers.sync),j()._off("update",e._handlers.update),j()._off("refresh",e._handlers.refresh),j()._off("raf",e._handlers.raf),j()._instancesMap.delete(e.id)}async function we(e){await H("onBeforeInit",e,{}),function(e){e._elements.boundary=i("div",{attrs:{...e._helpers.createMetaDataset(),...e._helpers.createAccessibilityDataset(),"data-hyperfloat-boundary":"",id:`${e.id}`,"data-hyperfloat-id":`${e.id}`,"data-hyperfloat-opened":"false","data-hyperfloat-anchor":e.anchor,"data-hyperfloat-anchored":e._state.anchored,"data-hyperfloat-draggable":!0===e.draggable?.enabled},appendTo:e._elements.root}),e._elements.overlayEl=i("div",{class:"hyperfloat-overlay",attrs:{"data-hyperfloat-overlay":""},appendTo:e._elements.boundary}),U(e);const t=["pointer","element"].includes(e.anchor)||e.draggable?.enabled;t&&(e._elements.positioner=i("div",{attrs:{"data-hyperfloat-positioner":""},appendTo:e._elements.boundary}));const n=t?e._elements.positioner:e._elements.boundary;e._elements.box=i("div",{class:"hyperfloat-box",attrs:{"data-hyperfloat-box":""},appendTo:n}),e._elements.headerInner=s(e.header,e),e._elements.headerInner&&(e._elements.header=i("div",{class:"hyperfloat-header",attrs:{"data-hyperfloat-header":""},html:e._elements.headerInner,appendTo:e._elements.box}),e._elements.header.style.order=1),e._elements.content=i("div",{attrs:{"data-hyperfloat-content":""},appendTo:e._elements.box}),e._elements.content.style.order=2,e._elements.contentInner=i("div",{attrs:{"data-hyperfloat-content-inner":""},appendTo:e._elements.content}),e.content?s(e.content,{},e._elements.contentInner):e._elements.loading=i("div",{class:"hyperfloat-loading",attrs:{"data-hyperfloat-loading":""},html:'<span class="hyperfloat-loading-bar" data-hyperfloat-loading-bar></span>',appendTo:e._elements.content}),e._elements.footerInner=s(e.footer,e),e._elements.footerInner&&(e._elements.footer=i("div",{class:"hyperfloat-footer",attrs:{"data-hyperfloat-footer":""},html:e._elements.footerInner,appendTo:e._elements.box}),e._elements.footer.style.order=3),D(e),V(e),X(e),N(e),e.draggable?.enabled&&e._data?.draggable?.handle&&te(e,{bounds:e.draggable.bounds,handle:e._data?.draggable?.handle})}(e),function(e){const t=r(e._defaultCloseSelector,e._elements.boundary);e._elements.overlayEl&&t.push(e._elements.overlayEl),t.forEach(t=>{const n={hostHyperfloat:v(t),event:"click"};e._registry.close.has(t)||e._registry.close.set(t,n)})}(e),me(e),function(e){const t=e.breakpoints||{},n=Object.keys(t);if(!n.length)return void(e._breakpoints=[]);const o=(e,t)=>{const n={...e};for(const s in t)"object"!=typeof t[s]||Array.isArray(t[s])||null===t[s]||"object"!=typeof e[s]?void 0!==t[s]&&null!==t[s]&&(n[s]=t[s]):n[s]=o(e[s],t[s]);return n},s=Math.max(...n.map(Number))+1,i={};for(const t of se)void 0!==e[t]&&(i[t]=e[t]);const r=n.map(Number).sort((e,t)=>t-e);r.unshift(s);const a={};a[s]=i;for(let n=1;n<r.length;n++){const s=r[n],i=t[s];let l={};for(const e of Object.keys(i))se.includes(e)&&(l[e]=i[e]);l=P(e,l,oe);const c=a[r[n-1]];l=o(c,l),a[s]=l}e._breakpoints=Object.entries(a).map(([e,t])=>[Number(e),t]).sort((e,t)=>e[0]-t[0])}(e),function(e){e.draggable?.enabled&&(e._state.anchored=!0,e._elements.boundary.dataset.hyperfloatAnchored="true",e._handlers.pointerMove=t=>{if(e._state.drag){if(!e._state.dragging){const n=Math.abs(t.clientX-e._state.drag.startX),o=Math.abs(t.clientY-e._state.drag.startY);(n>3||o>3)&&(e._state.dragging=!0,document.body.style.userSelect="none",e._elements.box.style.touchAction="none")}e._state.dragging&&ye(e,t)}},e._handlers.pointerUp=t=>{e._state.drag&&(e._state.dragging&&(document.body.style.userSelect="",e._elements.box.style.touchAction=""),e._state.drag=null),e._state.dragging=!1,B(e,document,"pointermove",e._handlers.pointerMove),B(e,document,"pointerup",e._handlers.pointerUp)},e._handlers.pointerDown=t=>{if(0!==t.button)return;if(!e.opened)return;if(["BUTTON","INPUT","TEXTAREA","SELECT","A"].includes(t.target.tagName)||t.target.closest("[data-no-drag]"))return;if(e.draggable.handle){const n=e.draggable.handle;if("string"==typeof n){if(!t.target.closest(n))return}else if((n instanceof Node||n instanceof Element)&&!n.contains(t.target))return}const n=e.positionerRect,o=e.boundaryRect,s=e._state.position.x||0,i=e._state.position.y||0;e._state.drag={startX:t.clientX,startY:t.clientY,initialX:s,initialY:i,minX:o?s-(n.left-o.left):-1/0,maxX:o?s+(o.right-n.right):1/0,minY:o?i-(n.top-o.top):-1/0,maxY:o?i+(o.bottom-n.bottom):1/0},e._state.dragging=!1,he(e),S(e,document,"pointermove",e._handlers.pointerMove),S(e,document,"pointerup",e._handlers.pointerUp)},S(e,e._elements.box,"pointerdown",e._handlers.pointerDown))}(e),await H("onInit",e,{}),await H("onAfterInit",e,{}),function(e){e._console.log("Ready:",e.id),H("onReady",e,{})}(e),e._state.ready=!0}const Ae="1.0.44";class Hyperfloat{constructor(e){if("undefined"==typeof window)return;const t=j()._normalizeData(e);this._data=t,this._id=t.id,this._listenersMap=new Map,this._config={anchor:t.anchor??"viewport"},this._config={...this._config,...P(this,t)},this.content=t.content??null,this._console=function(e,t=""){return e.debug?{log:(...e)=>console.log(t,...e),info:(...e)=>console.info(t,...e),warn:(...e)=>console.warn(t,...e),error:(...e)=>console.error(t,...e),table:(...e)=>{const n=e.pop();console.log(t,...e),console.table(n)}}:{log:()=>{},info:()=>{},warn:()=>{},error:()=>{},table:()=>{}}}(this,"[Trivon Ui - Hyperfloat]"),this._timers={pointerLeave:null,idle:null,timeout:null,outside:null},this._outsideCloseDelay=4e3,this._elements={root:t.root,boundary:null,positioner:null,box:null,content:null,contentInner:null,overlayEl:null,header:null,headerInner:null,footer:null,footerInner:null,loading:null},this._state={ready:!1,opened:!1,opening:!1,locked:!1,dragging:!1,anchored:["element","pointer"].includes(this.anchor),priority:0,pointer:{x:0,y:0,target:{el:null,action:null}},drag:null,position:{x:0,y:0},interpolation:{lastX:0,lastY:0},resolvedPlacement:this._config.placement,firstresolveBreakpointsDone:!1,firstcomputeRectsDone:!1},this._breakpoints=[],this._handlers={startIdleTimer:()=>{clearTimeout(this._timers.idle),!this.dismiss.idleTimeout||this.dismiss.idleTimeout<=0||(this._timers.idle=setTimeout(()=>{ve(this,{event:"no-interaction"})},this.dismiss.idleTimeout))},stopIdleTimer:()=>{clearTimeout(this._timers.idle)},startTimeoutTimer:()=>{clearTimeout(this._timers.timeout),!this.dismiss.timeout||this.dismiss.timeout<=0||(this._timers.timeout=setTimeout(()=>{ve(this,{event:"timeout"})},this.dismiss.timeout))},stopTimeoutTimer:()=>{clearTimeout(this._timers.timeout)},sync:(...e)=>me(this,...e),update:(...e)=>function(e,{force:t=!1}={}){e.opened&&"element"==e.anchor&&e.lastTarget&&(ge(e),H("onUpdate",e,{}))}(this,...e),refresh:(...e)=>function(e,{force:t=!1}={}){e.opened&&(["pointer","element"].includes(e.anchor)&&_e(e,{force:t}),e.draggable?.enabled&&_e(e,{force:t}),e._breakpoints&&!e._breakpoints.length&&ie(e),["pointer","element"].includes(e.anchor)&&e.lastTarget&&ge(e),e.draggable?.enabled&&ye(e)),H("onRefresh",e,{})}(this,...e),raf:()=>{var e;(e=this).opened&&"pointer"==e.anchor&&ge(e)},pointerLeave:e=>{if(!this._state.opened&&!this._state.opening)return;const t=e.currentTarget||e.target,n=e.relatedTarget;n&&(this._elements.box.contains(n)||[...this._registry.open.keys()].some(e=>e.contains(n)))||("pointer"===this.anchor?(clearTimeout(this._timers.pointerLeave),this._timers.pointerLeave=setTimeout(()=>{this._elements.box.matches(":hover")||[...this._registry.open.keys()].some(e=>e.matches(":hover"))||this.close({target:t,event:"pointerleave"})},100)):this.close({target:t,event:"pointerleave"}))},pointerMove:()=>{},pointerDown:()=>{},pointerUp:()=>{}},this.sync=this._handlers.sync,this.update=this._handlers.update,this.refresh=this._handlers.refresh,j()._on("sync",this._handlers.sync),j()._on("update",this._handlers.update),j()._on("refresh",this._handlers.refresh),j()._on("raf",this._handlers.raf),this.open=async(...e)=>await be(this,...e),this.close=async(...e)=>await ve(this,...e),this.destroy=async(...e)=>await xe(this,...e),this._cache={boundaryRect:null,positionerRect:null,targetRects:new Map,parentHyperfloat:null,lastTarget:null,lastcloseTarget:null,lastBreakpoint:9999999999999,computeRectsVersion:0,resolveBreakpointsVersion:0,syncPositionVersion:0,lastApplyMeta:{},lastApplyAccessibility:{}},this._registry={open:new Map,close:new Map};for(const e of Object.keys(this._registry)){b(t[e]??null).forEach(t=>{this._registry[e].set(t.el,{hostHyperfloat:v(t.el),event:t.event})})}return this.registerOpen=e=>ce(this,"open",e),this.registerClose=e=>ce(this,"close",e),this.unregisterOpen=e=>unregisterAction(this,"open",e),this.unregisterClose=e=>unregisterAction(this,"close",e),this.vars=t.vars??{},j()._instancesMap.set(this.id,this),this}static async create(e={}){if("undefined"==typeof window)return null;if(e.id&&j()._instancesMap.has(e.id)){const t=j()._instancesMap.get(e.id);if(!(!0===e.overwrite))return t.sync(),t;t.destroy()}const t=new this(e);return await we(t),!0===e.autoOpen&&await be(t,{event:"initialize",source:"auto"}),t}get id(){return this._id}get anchor(){return this._config.anchor}get opened(){return this._state.opened}get resolvedPlacement(){return this._state.resolvedPlacement}get state(){return{ready:this._state.ready,priority:this._state.priority,anchored:this._state.anchored,pointer:this._state.pointer,locked:this._state.locked,opened:this._state.opened,opening:this._state.opening,dragging:this._state.dragging}}get elements(){return{boundary:this._elements.boundary,overlay:this._elements.overlayEl,positioner:this._elements.positioner,box:this._elements.box,content:this._elements.content,contentInner:this._elements.contentInner,loading:this._elements.loading,header:this._elements.header,headerInner:this._elements.headerInner,footer:this._elements.footer,footerInner:this._elements.footerInner}}get lastTarget(){return this._cache.lastTarget}get parentHyperfloat(){return this._cache.parentHyperfloat}get boundaryRect(){return this._cache.boundaryRect}get positionerRect(){return this._cache.positionerRect}get lastBreakpoint(){return this._cache.lastBreakpoint}_helpers={createAccessibilityDataset:()=>{const e=Object.fromEntries(Object.entries(this.accessibility).map(([e,t])=>{let n="";switch(e){case"role":n=e;break;case"label":n="aria-label";break;default:n=`data-${e}`}return[n,String(t)]}));return this._cache.lastApplyAccessibility=e,e},createMetaDataset:()=>{const e=Object.fromEntries(Object.entries(this.meta).map(([e,t])=>[`data-${e}`,String(t)]));return this._cache.lastApplyMeta=e,e}};static get version(){return Ae}static get _manager(){return j()}static config(e={}){j()._setConfig(e)}static defaults(e={}){j()._setDefaults(e)}static async open(e,t={}){await j()._open(e,t)}static async close(e,t={}){await j()._close(e,t)}static async closeAll(e={}){await j()._closeAll(e)}static async destroy(e,t={}){await j()._destroy(e,t)}static async destroyAll(e={}){await j()._destroyAll(e)}static sync(){j()._sync()}static update(){j()._update()}static refresh(){j()._refresh()}static raf(e){j()._raf(e)}static getAll(){return j()._getAll()}static getOpened(...e){return j()._getOpened(...e)}static getByPriority(...e){return j()._getByPriority(...e)}}ne.forEach(e=>{Object.defineProperty(Hyperfloat.prototype,e,{get(){return this._config[e]??j()._defaults[e]??n[e].default},set(t){"meta"==e?Y(this,t):"accessibility"==e?q(this,t):"dismiss"==e?F(this,t):"overlay"==e?W(this,t):"placement"==e?K(this,t):"boundaryPadding"==e?G(this,t):"offset"==e?J(this,t):"flip"==e?Q(this,t):"shift"==e?Z(this,t):"size"==e?ee(this,t):"draggable"==e?te(this,t):["destroyAfterClose","ignoreCloseAll","debug"].includes(e)&&(this._config[e]=!0===t)},configurable:!0,enumerable:!0})});export{Hyperfloat,Hyperfloat as default};
8
+ var e=["center","top","top-start","top-end","right","right-start","right-end","bottom","bottom-start","bottom-end","left","left-start","left-end"];const t={};["onBeforeInit","onInit","onAfterInit","onReady","onSync","onDestroy","onBeforeOpen","onOpen","onAfterOpen","onBeforeClose","onClose","onAfterClose","onRefresh","onUpdate","onMove"].forEach(e=>{t[e]={type:["null","function"],default:null}});var n={id:{type:"string",default:""},meta:{type:["null","object"],default:{type:"default",variant:"default",role:"dialog"}},accessibility:{type:["null","object"],default:{role:"dialog",label:"dialog",modal:!1}},anchor:{type:["string"],values:["viewport","element","pointer"],default:"viewport"},open:{type:["null","string","element","node","nodeList","array","object"],default:null},close:{type:["null","string","element","node","nodeList","array"],default:null},ignoreCloseAll:{type:"boolean",default:!1},autoOpen:{type:"boolean",default:!1},destroyAfterClose:{type:"boolean",default:!1},overlay:{type:["boolean","object"],default:null},placement:{type:"string",values:e,default:"center"},boundaryPadding:{type:["string","number","object","null"],default:0},draggable:{type:["boolean","object"],default:null},offset:{type:["string","number","object","null"],default:null},flip:{type:["object","boolean","null"],default:null},shift:{type:["object","boolean","null"],default:null},dismiss:{type:"object",default:{outsideClick:!1,outsideWheel:!1,escapeKey:!1,pointerLeave:!1,closeWithParent:!1,timeout:null,idleTimeout:null}},size:{type:["string","number","object"],default:"small"},breakpoints:{type:"object",default:{}},content:{type:["null","string","function","node"],default:null},header:{type:["null","string","function","node"],default:null},footer:{type:["null","string","function","node"],default:null},vars:{type:["null","object"],default:{}},interpolate:{type:["null","function"],default:null},debug:{type:"boolean",default:!1},...t};function o(e,t={}){if("function"==typeof e){return o(e.call(t),t)}if(e instanceof Promise)return o(e,t);if(e instanceof Node)return e;if("string"==typeof e){const t=e.trim();if(/^<.+?>/.test(t)){const e=document.createElement("div");e.innerHTML=t;const n=document.createDocumentFragment();for(;e.firstChild;)n.appendChild(e.firstChild);return n}return document.createTextNode(t)}return e}function s(e,t={},n=null){if(!e)return null;const s=o(e,t);if(!s)return null;if(!n){const e=document.querySelector("._trivon-ui-hyperfloat");let t=e.querySelector("[data-hyperfloat-sandbox]");t||(t=document.createElement("div"),t.dataset.hyperfloatSandbox="",e.appendChild(t)),n=t}let i;return s instanceof DocumentFragment?(i=Array.from(s.childNodes),n.appendChild(s)):Array.isArray(s)?(i=s,n.append(...s)):s instanceof Node&&(i=[s],n.appendChild(s)),i?.[0]||null}function i(e,t={}){const n=document.createElement(e);if(t.class){const e=Array.isArray(t.class)?t.class:t.class.trim().split(/\s+/);n.classList.add(...e)}t.attrs&&Object.entries(t.attrs).forEach(([e,t])=>n.setAttribute(e,t)),t.text&&(n.textContent=t.text);const o=t.html??t.innerHTML??t.innerHtml??t.content??null;if(o&&s(o,{},n),t.style&&this.applyStyle(n,t.style),!t.appendTo&&!t.prependTo){const e=document.querySelector("._trivon-ui-hyperfloat");let t=e.querySelector("[data-hyperfloat-sandbox]");t||(t=document.createElement("div"),t.dataset.hyperfloatSandbox="",e.appendChild(t)),t.appendChild(n)}return t.appendTo&&t.appendTo.appendChild(n),t.prependTo&&t.prependTo.prepend(n),n}function r(e,t=("undefined"!=typeof document?document:null),n=!1){if(!e)return[];const o="undefined"!=typeof Element,s=e=>o&&e instanceof Element;if(s(e))return[e];const i="string"==typeof t&&"undefined"!=typeof document?document.querySelector(t):t,r=new Set,a=e=>{if(e)if(s(e))r.add(e);else if("string"!=typeof e){if(Array.isArray(e)||"object"==typeof e&&"number"==typeof e.length&&"function"!=typeof e)for(let t=0;t<e.length;t++)a(e[t])}else{if(n)return void r.add(e);if(i&&"function"==typeof i.querySelectorAll)try{const t=i.querySelectorAll(e);for(let e=0;e<t.length;e++)r.add(t[e])}catch{}}};return a(e),Array.from(r)}function a({prefix:e="uuid",blacklist:t=[]}={}){let n="";return n="undefined"!=typeof crypto&&"function"==typeof crypto.randomUUID?`${e}-${crypto.randomUUID()}`:"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}),t.includes(n)?a({prefix:e,blacklist:t}):n}function l(e){return null===e?"null":Array.isArray(e)?"array":"undefined"!=typeof Node&&e instanceof Node?"node":"object"==typeof e?"object":typeof e}function c(e){if("string"==typeof e){const t=e.trim();if(/^-?[\d.]+(px|%|em|rem|vh|vw)$/.test(t)||/^(var|calc|min|max|clamp)\(.+\)$/.test(t))return t;const n=parseHyperfloat(t);return isNaN(n)?null:`${n}px`}return"number"==typeof e?`${e}px`:"0px"}function d(e){"number"==typeof e&&(e=`${e}px`);const t=document.createElement("div");t.style.all="initial",t.style.position="absolute",t.style.visibility="hidden",t.style.pointerEvents="none",t.style.width=e,document.body.appendChild(t);const n=getComputedStyle(t).width;document.body.removeChild(t);const o=parseHyperfloat(n);return isNaN(o)?0:o}function u(e){if("string"==typeof e){const t=e.trim().split(/\s+/);if(1===t.length){const e=c(t[0]);return{width:e,height:e}}if(2===t.length)return{width:c(t[0]),height:c(t[1])}}if("number"==typeof e){const t=c(e);return{width:t,height:t}}return"object"==typeof e&&null!==e?{width:c(e?.width),height:c(e?.height)}:{width:"auto",height:"auto"}}function f(e,t=4e3){return Math.max(0,Math.trunc(Number(e??t)))}function p(e,t={}){const o=n,s={};for(const[e,n]of Object.entries(o)){let o=t[e];const i=Array.isArray(n.type)?n.type:[n.type];i.push("undefined");const r=l(o);if(i.includes(r)){if(!0===n.normalizeArray&&"string"===r&&(o=[o]),n.itemType&&Array.isArray(o)){if(o.filter(e=>l(e)!==n.itemType).length){console.warn(`[Trivon Ui - Hyperfloat] Invalid item type for "${e}".`,`Expected items of type: ${n.itemType}`),s[e]=structuredClone(n.default);continue}}if(n.values)if(Array.isArray(o)){const t=o.filter(e=>!n.values.includes(e));if(t.length){console.warn(`[Trivon Ui - Hyperfloat] Invalid values for "${e}".`,`Expected only: ${n.values.join(", ")}`,`Received invalid: ${t.join(", ")}`),s[e]=structuredClone(n.default);continue}}else if(!n.values.includes(o)){console.warn(`[Trivon Ui - Hyperfloat] Invalid value for "${e}".`,`Expected one of: ${n.values.join(", ")}`,`Received: ${o}`),s[e]=structuredClone(n.default);continue}void 0!==o&&(s[e]=o)}else console.warn(`[Trivon Ui - Hyperfloat] Invalid type for "${e}".`,`Expected: ${i.join(", ")}`,`Received: ${r}`),s[e]=structuredClone(n.default)}return s}function h(e,t=!1){let n=!1;if(!t)for(const[t,o]of e._instancesMap)if("pointer"===o.anchor&&o.opened){n=!0;break}t||n?(function(e){if(!e._config.autoRaf||e._state.autoRafStarted)return;e._state.autoRafStarted=!0;const t=n=>{e._config.autoRaf&&e._state.autoRafStarted&&(e._raf(n),requestAnimationFrame(t))};requestAnimationFrame(t)}(e),function(e){e._state.pointerTrackingStarted||(e._state.pointerTrackingStarted=!0,window.addEventListener("pointermove",e._handlers.pointermove,{passive:!0}))}(e)):(function(e){e._config.autoRaf&&e._state.autoRafStarted&&(e._state.autoRafStarted=!1)}(e),function(e){e._state.pointerTrackingStarted&&(e._state.pointerTrackingStarted=!1,window.removeEventListener("pointermove",e._handlers.pointermove))}(e))}function y(e){const t=["auto","small","medium","large","full"];if("object"==typeof e&&null!==e)return{type:e.type??"custom",width:e.width??"100%",height:e.height??"100%"};if("string"==typeof e){const n=e.trim();if(t.includes(n))return{type:"preset",width:n,height:n}}return{type:"custom",...u(e)}}function m(t,n){if("string"==typeof t){const n=t.trim();if(e.includes(n))return n}return"viewport"===n?"center":"bottom"}function _(e){return"boolean"==typeof e&&null!==e?{enabled:e,color:"black",blur:!0}:"object"==typeof e&&null!==e?{enabled:!0,color:e.color||"black",blur:!1!==e.blur}:{enabled:!1,color:"black",blur:!0}}function g(e){return"object"==typeof e&&null!==e?{outsideClick:!!e.outsideClick,outsideWheel:!!e.outsideWheel,escapeKey:!!e.escapeKey,pointerLeave:!(!e.pointerLeave&&!e.mouseLeave),closeWithParent:!!e.closeWithParent,timeout:e.timeout?f(e.timeout):null,idleTimeout:e.idleTimeout&&void 0===e.timeout?f(e.idleTimeout):null}:{outsideClick:!1,outsideWheel:!1,escapeKey:!1,pointerLeave:!1,closeWithParent:!1,timeout:null,idleTimeout:null}}function b(e){if(!e)return[];let t=e,n="click";var o;"object"!=typeof e||Array.isArray(e)||(o=e,"undefined"!=typeof Element&&o instanceof Element)||(e=>"undefined"!=typeof NodeList&&e instanceof NodeList||"undefined"!=typeof HTMLCollection&&e instanceof HTMLCollection)(e)||!("el"in e)||(t=e.el,"string"==typeof e.event&&e.event.trim()&&(n=e.event.trim()));return n={mouseenter:"pointerenter",mousemove:"pointermove"}[n]||n,["click","pointerenter","pointermove"].includes(n)||(n="click"),r(t).map(e=>({el:e,event:n}))}function v(e){const t=e.closest("[data-hyperfloat-id]");return t?t.dataset.hyperfloatId??null:null}function x(e){if("number"==typeof e)return{mainAxis:e,crossAxis:e,alignmentAxis:null};if("string"==typeof e){return{mainAxis:d(c(e)),crossAxis:0,alignmentAxis:null}}if("object"==typeof e&&null!==e){let t=d(c(e.mainAxis??0)),n=d(c(e.crossAxis??0)),o=e.alignmentAxis?d(c(e.alignmentAxis??0)):null;return null!==o&&(n=0),{mainAxis:t,crossAxis:n,alignmentAxis:o}}return null}function w(e){return"boolean"==typeof e?{mainAxis:e,crossAxis:e}:"object"==typeof e&&null!==e?{mainAxis:!0===e.mainAxis,crossAxis:!0===e.crossAxis}:null}function A(e){return w(e)}function T(e){return w(e)}function k(e){return null==e?0:function(e){if("string"==typeof e){const t=e.trim().split(/\s+/);if(1===t.length){const e=d(c(t[0]));return{top:e,right:e,bottom:e,left:e}}if(2===t.length){const e=d(c(t[0])),n=d(c(t[1]));return{top:e,right:n,bottom:e,left:n}}if(3===t.length){const e=d(c(t[0])),n=d(c(t[1]));return{top:e,right:n,bottom:d(c(t[2])),left:n}}if(4===t.length){const e=d(c(t[0])),n=d(c(t[1])),o=d(c(t[2]));return{top:e,right:d(c(t[3])),bottom:o,left:n}}}if("number"==typeof e){const t=d(c(e));return{top:t,right:t,bottom:t,left:t}}return"object"==typeof e&&null!==e?{top:d(c(e?.top)),right:d(c(e?.right)),bottom:d(c(e?.bottom)),left:d(c(e?.left))}:{top:0,bottom:0,left:0,right:0}}(e)}function R(e){return"object"==typeof e&&null!==e&&Object.entries(e).length?{role:e.role??"dialog",label:e.label??"dialog",modal:e.modal??!1}:{role:"dialog",label:"dialog",modal:!1}}function M(e){return"object"==typeof e&&null!==e?{...e,type:e.type??"default",variant:e.variant??"default",role:e.role??"default"}:{type:"default",variant:"default",role:"dialog"}}function C(e,t){return"viewport"!==t?{enabled:!1,bounds:!1,handle:null}:"boolean"==typeof e&&null!==e?{enabled:e,bounds:!1,handle:null}:"object"==typeof e&&null!==e?{enabled:!0,bounds:!0===e.bounds,handle:null}:{enabled:!1,bounds:!1,handle:null}}function I(e){return"function"==typeof e||"string"==typeof e||e instanceof Node?e:null}function P(e,t={},n=[]){return{...void 0!==t.meta&&!n.includes("meta")&&{meta:M(t.meta??allowedValues.meta.default)},...void 0!==t.accessibility&&!n.includes("accessibility")&&{accessibility:R(t.accessibility??allowedValues.accessibility.default)},...void 0!==t.dismiss&&!n.includes("dismiss")&&{dismiss:g(t.dismiss??allowedValues.dismiss.default)},...void 0!==t.destroyAfterClose&&!n.includes("destroyAfterClose")&&{destroyAfterClose:!0===t.destroyAfterClose},...void 0!==t.autoOpen&&!n.includes("autoOpen")&&{autoOpen:!0===t.autoOpen},...void 0!==t.ignoreCloseAll&&!n.includes("ignoreCloseAll")&&{ignoreCloseAll:!0===t.ignoreCloseAll},...void 0!==t.overlay&&!n.includes("overlay")&&{overlay:_(t.overlay??allowedValues.overlay.default)},...void 0!==t.placement&&!n.includes("placement")&&{placement:m(t.placement??allowedValues.placement.default,e.anchor)},...void 0!==t.boundaryPadding&&!n.includes("boundaryPadding")&&{boundaryPadding:k(t.boundaryPadding??allowedValues.boundaryPadding.default)},...void 0!==t.draggable&&!n.includes("draggable")&&{draggable:C(t.draggable??allowedValues.draggable.default,e.anchor)},...void 0!==t.offset&&!n.includes("offset")&&{offset:x(t.offset??allowedValues.offset.default)},...void 0!==t.flip&&!n.includes("flip")&&{flip:A(t.flip??allowedValues.flip.default)},...void 0!==t.shift&&!n.includes("shift")&&{shift:T(t.shift??allowedValues.shift.default)},...void 0!==t.size&&!n.includes("size")&&{size:y(t.size??allowedValues.size.default)},...void 0!==t.header&&!n.includes("header")&&{header:I(t.header??allowedValues.header.default)},...void 0!==t.footer&&!n.includes("footer")&&{footer:I(t.footer??allowedValues.footer.default)},...void 0!==t.breakpoints&&!n.includes("breakpoints")&&{breakpoints:t.breakpoints??{}},...void 0!==t.debug&&!n.includes("debug")&&{debug:!0===t.debug}}}class Manager{constructor(){var e;return this._instancesMap=new Map,this._root=null,this._openedInstances={viewport:[],element:[],pointer:[]},this._defaults={},this._config={zIndex:9999,autoRaf:!0},this._listeners={update:[],refresh:[],raf:[],sync:[]},this._state={pointerTrackingStarted:!1,autoRafStarted:!1},this._cache={refreshVersion:0,updateVersion:0,pointer:{x:0,y:0,target:null},raf:{time:0,deltaTime:0},lastRafTime:null},this._handlers={keydown:this._onKeydown.bind(this),update:()=>async function(e){await e._callHook("update",e),e._cache.updateVersion++}(this),pointermove:e=>function(e,t){e._cache.pointer.x=t.clientX,e._cache.pointer.y=t.clientY}(this,e),refresh:()=>{this._refreshRaf||(this._refreshRaf=requestAnimationFrame(()=>{this._refreshRaf=null,async function(e){await e._callHook("refresh",e),e._cache.refreshVersion++}(this)}))}},this._update=this._handlers.update,window.addEventListener("scroll",this._handlers.update,{passive:!0}),this._refresh=this._handlers.refresh,window.addEventListener("resize",this._handlers.refresh),this._syncPointerEngine=(...e)=>h(this,...e),this._sync=(...e)=>async function(e){await e._callHook("sync",e)}(this,...e),this._on=(...e)=>function(e,t,n,o=1e3){"function"==typeof n&&e._listeners[t]&&e._listeners[t].push({callback:n,priority:o})}(this,...e),this._off=(...e)=>function(e,t,n){"function"==typeof n&&e._listeners[t]&&(e._listeners[t]=e._listeners[t].filter(e=>e.callback!==n))}(this,...e),this._callHook=(...e)=>async function(e,t){if(e._listeners[t].length){e._listeners[t].sort((e,t)=>e.priority-t.priority);for(const{callback:n,priority:o}of e._listeners[t])try{await n()}catch(e){}}}(this,...e),this._open=async(e,t={})=>await async function(e,t,n={}){const o=e._instancesMap.get(t);o&&await o.open(n)}(this,e,t),this._close=async(e,t={})=>await async function(e,t,n={}){const o=e._instancesMap.get(t);o&&await o.close(n)}(this,e,t),this._closeAll=async(e={})=>await async function(e,t={}){const{force:n=!1,...o}=t;for(const[t,s]of e._instancesMap)s.ignoreCloseAll&&!n||await s.close(o)}(this,e),this._destroy=async(e,t={})=>await async function(e,t,n={}){const o=e._instancesMap.get(t);o&&await o.destroy(n)}(this,e,t),this._destroyAll=async(e={})=>await async function(e,t={}){for(const[n,o]of e._instancesMap)await o.destroy(t);e._instancesMap.clear()}(this,e),(e=this)._root=document.createElement("div"),e._root.classList.add("_trivon-ui-hyperfloat"),e._root.style.setProperty("--trivon-ui-hyperfloat-z-index",e._config.zIndex),document.body.prepend(e._root),document.addEventListener("keydown",e._handlers.keydown),this}_onKeydown(e){"Escape"===e.key&&this._closeFirstPriority({event:"escape"})}_setHyperfloatOpened(e,t){const n=e.id,o=e.anchor;t?this._openedInstances[o].includes(n)||this._openedInstances[o].push(n):this._openedInstances[o].includes(n)&&(this._openedInstances[o]=this._openedInstances[o].filter(e=>e!==n))}_raf(e=null){!async function(e,t){const n=t??("undefined"!=typeof performance?performance.now():Date.now());e._cache.lastRafTime||(e._cache.lastRafTime=n);const o=n-e._cache.lastRafTime;e._cache.lastRafTime=n,e._cache.raf={time:n,deltaTime:o},await e._callHook("raf",e)}(this,e)}_getAll(){const e=[];for(const[t,n]of this._instancesMap)e.push(n);return e}_getOpened(e=null,t=!1){const n=[];for(const[o,s]of this._instancesMap)if(null===e||s.anchor===e){if(t){if(!s.state.opened&&!s.state.opening)continue}else if(!s.state.opened)continue;n.push(s)}return n}_getByPriority(e=">",t=1e3){const n=[];for(const[,o]of this._instancesMap){if(!o.opened)continue;const s=o._state.priority;(">"===e?s>t:">="===e?s>=t:"<"===e?s<t:"<="===e?s<=t:"=="===e&&s===t)&&n.push(o)}return n.sort((e,t)=>e._state.priority-t._state.priority),n}_getElementsAbovePriority(e=1e3){const t=[];for(const[n,o]of this._instancesMap){const n=o.opened,s=o._state.priority,i=o.elements.box,r=o.elements.overlay;n&&s>e&&(t.push(i),r&&t.push(r))}return t}_setConfig(e={}){var t,n;e.zIndex&&(t=this,n=e.zIndex,n=Number(n),t._config.zIndex=n,t._root.style.setProperty("--trivon-ui-hyperfloat-z-index",n)),e.autoRaf&&function(e,t=!0){e._state.autoRafStarted?e._config.autoRaf?console.warn("Auto RAF has already been started. m setting can no longer be changed."):console.warn("The RAF mode has already been defined and is currently managed externally. m setting can no longer be changed."):e._config.autoRaf=t}(this,e.autoRaf)}_setDefaults(e){if(e){const t=p(0,e);this._defaults=P(this,t,["ignoreCloseAll"])}}_normalizeData(e){const t=p(0,{...e,id:e.id??a({blacklist:Array.from(this._instancesMap.keys())})});return void 0===t.anchor&&(t.anchor="viewport"),t.root=this._root,t}async _closeFirstPriority(e={}){const t=Object.values(this._openedInstances).flat();let n=null;if(1===t.length){const e=this._instancesMap.get(t[0]);e.dismiss.escapeKey&&(n=e)}else for(const[e,o]of this._instancesMap)t.includes(e)&&o.dismiss.escapeKey&&(!n||o._state.priority>n._state.priority)&&(n=o);n&&await n.close(e)}}let E=null;const O=new Proxy({},{get:(e,t)=>{if("then"!==t)return()=>{}}});function j(){return"undefined"==typeof window?O:(E??=new Manager,E)}async function H(e,t,n={},o=!0){const s=[t._data[e],t[e]].filter(e=>"function"==typeof e);if(s.length){for(const i of s){let s=i.call(t,n);if(s&&"function"==typeof s.then){if(!o){console.error(`[Trivon Ui / Hyperfloat]: the hook "${e}" must be synchronous. It cannot return a Promise.`);continue}s=await s}if(!1===s||s?.prevent)return s}return!0}}function S(e,t,n,o,s={}){if(!t||"function"!=typeof o)return;let i=e._listenersMap.get(t);i||(i=new Map,e._listenersMap.set(t,i));let r=i.get(n);r||(r=new Map,i.set(n,r)),r.has(o)||(t.addEventListener(n,o,s),r.set(o,s))}function B(e,t,n,o){if(!t)return;const s=e._listenersMap.get(t);if(!s)return;const i=s.get(n);if(!i||!i.has(o))return;const r=i.get(o);t.removeEventListener(n,o,r),i.delete(o),0===i.size&&s.delete(n),0===s.size&&e._listenersMap.delete(t)}function z(e,t){if(!t)return;const n=e._listenersMap.get(t);if(n){for(const[e,o]of n)for(const[n,s]of o)t.removeEventListener(e,n,s);e._listenersMap.delete(t),delete t.dataset.hyperfloatBound,delete t.dataset.hyperfloatOpened}}function L(e){e.dismiss.pointerLeave&&function(e){"pointer"!==e._config.anchor&&S(e,e._elements.box,"pointerleave",e._handlers.pointerLeave);[...e._registry.open.keys()].forEach(t=>{S(e,t,"pointerleave",e._handlers.pointerLeave)})}(e),e.dismiss.outsideClick&&$(e,"pointerdown"),e.dismiss.outsideWheel&&$(e,"wheel")}function $(e,t,n){const o=`outside_${t}`;e._handlers[o]||(e._handlers[o]=n=>{if(!e.opened)return;if([e._elements.box,...j()._getElementsAbovePriority(e._state.priority)].some(e=>e?.contains(n.target)))return;[...e._registry.open.keys()].some(e=>e.contains(n.target))||e.close({event:"pointerdown"===t?"outside-click":"outside-wheel"})}),S(e,window,t,e._handlers[o],n)}function D(e){if("viewport"!==e.anchor)return;if(null===e.boundaryPadding||0===e.boundaryPadding)return;const t=e._elements.boundary,n=e.boundaryPadding;t.style.paddingTop=n.top+"px",t.style.paddingRight=n.right+"px",t.style.paddingBottom=n.bottom+"px",t.style.paddingLeft=n.left+"px"}function V(e){if("viewport"!==e.anchor)return;if(null===e.offset)return;const t=function(e,t){const{mainAxis:n=0,crossAxis:o=0,alignmentAxis:s=null}=e,[i,r]=t.split("-"),a="top"===i||"bottom"===i;let l=0,c=0;a?l+="top"===i?-n:n:c+="left"===i?-n:n;let d=o;return r&&null!==s&&(d=s,"end"===r&&(d*=-1)),a?c+=d:l+=d,{top:l+"px",right:"0px",bottom:"0px",left:c+"px"}}(e.offset,e.placement),n=e._elements.box;n.style.marginTop=t.top,n.style.marginRight=t.right,n.style.marginBottom=t.bottom,n.style.marginLeft=t.left}function N(e){e._elements.boundary.dataset.hyperfloatSize="preset"==e.size.type?e.size.width:"custom","custom"==e.size.type&&(e._elements.box.style.width=e.size.width??"100%",e._elements.box.style.height=e.size.height??"100%")}function U(e){null!==e.overlay&&(e._elements.boundary.dataset.hyperfloatOverlayEnabled=e.overlay.enabled,e._elements.boundary.dataset.hyperfloatOverlayColor=e.overlay.color,e._elements.boundary.dataset.hyperfloatOverlayBlur=e.overlay.blur)}function X(e){e._elements.boundary.dataset.hyperfloatPlacement=e.placement}function Y(e,t){e._config.meta=M(t??n.meta.default);const o=e._cache.lastApplyMeta,s=e._helpers.createMetaDataset();for(const t of Object.keys(o))e._elements.boundary.removeAttribute(t);for(const[t,n]of Object.entries(s))e._elements.boundary.setAttribute(t,n)}function q(e,t){e._config.accessibility=R(t??n.accessibility.default);const o=e._cache.lastApplyAccessibility,s=e._helpers.createAccessibilityDataset();for(const t of Object.keys(o))e._elements.boundary.removeAttribute(t);for(const[t,n]of Object.entries(s))e._elements.boundary.setAttribute(t,n)}function F(e,t){e._config.dismiss=g(t??n.dismiss.default),L(e)}function W(e,t){e._config.overlay=_(t??n.overlay.default),U(e)}function K(e,t){const o=m(t??n.placement.default,e.anchor);e._config.placement=o,e._state.resolvedPlacement=o,X(e)}function G(e,t){e._config.boundaryPadding=k(t??n.placement.default),D(e)}function J(e,t){e._config.offset=x(t??n.offset.default),V(e)}function Q(e,t){e._config.flip=A(t??n.flip.default),"function"==typeof syncPosition&&e.opened&&"element"==e.anchor&&e.lastTarget&&syncPosition(e)}function Z(e,t){e._config.shift=T(t??n.shift.default),"function"==typeof syncPosition&&e.opened&&"element"==e.anchor&&e.lastTarget&&syncPosition(e)}function ee(e,t){e._config.size=y(t??n.size.default),N(e)}function te(e,t){e._config.draggable=C(t??n.draggable.default,e.anchor);const o=r(t?.handle,e._elements.boundary);o[0]&&(e._config.draggable.handle=o[0])}var ne=["meta","accessibility","dismiss","destroyAfterClose","autoOpen","overlay","placement","boundaryPadding","draggable","offset","flip","shift","ignoreCloseAll","header","footer","size","breakpoints","debug"];const oe=["breakpoints","destroyAfterClose","ignoreCloseAll","draggable","autoOpen","header","footer","debug"],se=ne.filter(e=>!oe.includes(e));function ie(e){if(!e._breakpoints||!e._breakpoints.length)return;const t=j()._cache.refreshVersion;if(e._state.firstresolveBreakpointsDone&&t===e._cache.resolveBreakpointsVersion)return;let n=!1;const o=window.innerWidth,s=e._breakpoints;for(const[t,i]of s)if(o<=t){n=!0,e._cache.lastBreakpoint!==t&&(e._cache.lastBreakpoint=t,re(e,i,t));break}if(!n){const[t,n]=e._breakpoints[e._breakpoints.length-1];e._cache.lastBreakpoint!==t&&(e._cache.lastBreakpoint=t,re(e,n,t))}e._cache.resolveBreakpointsVersion=t,e._state.firstresolveBreakpointsDone=!0}function re(e,t,n){for(const[o,s]of Object.entries(t))"meta"==o&&Y(e,s),"accessibility"==o&&q(e,s),"dismiss"==o&&F(e,s),"overlay"==o&&W(e,s),"placement"==o&&K(e,s),"boundaryPadding"==o&&G(e,s),"offset"==o&&J(e,s),"flip"==o&&Q(e,s),"shift"==o&&Z(e,s),"size"==o&&ee(e,s),e._console.log(`Breakpoint: ${n} -> ${o}:`,s)}function ae(e,t,n){const{left:o,top:s,right:i,bottom:r,width:a,height:l}=t,{width:c,height:d}=n,u=o+a/2,f=s+l/2;switch(e){case"center":default:return{left:u-c/2,top:f-d/2};case"top":return{left:u-c/2,top:s-d};case"top-start":return{left:o,top:s-d};case"top-end":return{left:i-c,top:s-d};case"right":return{left:i,top:f-d/2};case"right-start":return{left:i,top:s};case"right-end":return{left:i,top:r-d};case"bottom":return{left:u-c/2,top:r};case"bottom-start":return{left:o,top:r};case"bottom-end":return{left:i-c,top:r};case"left":return{left:o-c,top:f-d/2};case"left-start":return{left:o-c,top:s};case"left-end":return{left:o-c,top:r-d}}}function le({boundaryRect:e=window,elementRect:t=null,anchorRect:n=null,placement:o="bottom",offset:s=null,flip:i=null,shift:r=null}={}){let a,l,c=o;const d=()=>{if(({left:a,top:l}=ae(c,n,t)),null!==s&&({left:a,top:l}=function(e,t,n,o){const{mainAxis:s=0,crossAxis:i=0,alignmentAxis:r=null}=e,[a,l]=t.split("-"),c="top"===a||"bottom"===a;c?o+="top"===a?-s:s:n+="left"===a?-s:s;let d=i;return l&&null!==r&&(d=r,"end"===l&&(d*=-1)),c?n+=d:o+=d,{left:n,top:o}}(s,c,a,l)),null!==r){const o=function(e,t,n,o,s,i,r,a=null){const{mainAxis:l=!1,crossAxis:c=!1}=e,d=(e,t,n)=>Math.max(t,Math.min(e,n)),[u,f]=t.split("-"),p="top"===u||"bottom"===u,h=n.left,y=n.right-s.width,m=n.top,_=n.bottom-s.height;if(p?(c&&(i=d(i,h,y)),l&&(r=d(r,m,_))):(l&&(i=d(i,h,y)),c&&(r=d(r,m,_))),null!==a){const{mainAxis:e=!1,crossAxis:t=!1}=a;let n=!1;if(e&&("right"===u&&i<o.right&&(n=!0),"left"===u&&i+s.width>o.left&&(n=!0),"top"===u&&r+s.height>o.top&&(n=!0),"bottom"===u&&r<o.bottom&&(n=!0)),n)return null}return{left:i,top:r}}(r,c,e,n,t,a,l,i);return null!==o&&(({left:a,top:l}=o),!0)}return!0},u=d();if(null!==i&&!u){const o=function({flip:e,placement:t,boundaryRect:n,anchorRect:o,elementRect:s}){if(null===e)return null;const{mainAxis:i=!0,crossAxis:r=!1}=e,[a,l]=t.split("-"),c=(e,t)=>e>=n.left&&e+s.width<=n.right&&t>=n.top&&t+s.height<=n.bottom,d=(e,t=l)=>t?`${e}-${t}`:e;if(i){const e=(e=>{switch(e){case"top":return"bottom";case"bottom":return"top";case"left":return"right";case"right":return"left";default:return e}})(a),t=d(e),{left:n,top:i}=ae(t,o,s);if(c(n,i))return t}if(r&&l){const e=(e=>"start"===e?"end":"end"===e?"start":null)(l);if(e){const t=d(a,e),{left:n,top:i}=ae(t,o,s);if(c(n,i))return t}}return null}({flip:i,placement:c,boundaryRect:e,anchorRect:n,elementRect:t});o&&(c=o,d())}return{position:{left:a,top:l},coordinates:{left:a,top:l},placement:c,resolvedPlacement:c}}function ce(e,t,n){const o=b(n??null);if(!o.length)return()=>{};const s=[];return o.forEach(n=>{const o={hostHyperfloat:v(n.el),event:n.event};e._registry[t].set(n.el,o),s.push(n.el)}),"open"===t?de(e):fe(e),L(e),()=>{!function(e,t,n){r(n).forEach(n=>{n instanceof Element&&e._registry[t]?.has(n)&&(z(e,n),e._registry[t].delete(n),e._state.pointer.target.el==n&&(e._state.pointer.target={el:null,action:null}))})}(e,t,s)}}function de(e){for(const[t,n]of e._registry.open)t instanceof Element?"true"!==t.dataset.hyperfloatBound&&(ue(e,t,n),t.dataset.hyperfloatOpened=String(e.opened),t.dataset.hyperfloatBound="true",S(e,t,"pointerenter",()=>{e._state.pointer.target={el:t,action:"open"}})):(z(e,t),e._registry.open.delete(t))}function ue(e,t,n){const o=n.event;"click"!=o?["pointerenter","pointermove"].includes(o)&&S(e,t,"pointer"===e.anchor?"pointermove":"pointerenter",()=>e.open({target:t})):S(e,t,"click",()=>{e.opened?e.close({target:t}):e.open({target:t})})}function fe(e){for(const[t,n]of e._registry.close)t instanceof Element?"true"!==t.dataset.hyperfloatBound&&(S(e,t,"click",()=>{e.close({target:t})}),t.dataset.hyperfloatOpened=String(e.opened),t.dataset.hyperfloatBound="true",S(e,t,"pointerenter",()=>{e._state.pointer.target={el:t,action:"close"}})):(z(e,t),e._registry.close.delete(t))}async function pe(e,t,n){const o=e._data?.interpolate??e.interpolate??null;if("function"==typeof o){const s=await o.call(e,{axis:"x",current:e._state.interpolation.lastX??t,target:t,pointer:e._state.pointer});"number"==typeof s&&(t=s);const i=await o.call(e,{axis:"y",current:e._state.interpolation.lastY??n,target:n,pointer:e._state.pointer});"number"==typeof i&&(n=i)}return e._state.interpolation.lastX=t,e._state.interpolation.lastY=n,{x:t,y:n}}function he(e){const t=j();let n=0;t._instancesMap.forEach(e=>{e&&e._state.ready&&(n=Math.max(n,e._state.priority??0))});const o=n+1;e._state.priority=o;const s="pointer"===e.anchor?o+1e3:o,i=e.elements?.boundary;i&&(i.style.zIndex=String(s))}async function ye(e,t){if(!t||!e._state.drag)return;const n=t.clientX-e._state.drag.startX,o=t.clientY-e._state.drag.startY;let s=e._state.drag.initialX+n,i=e._state.drag.initialY+o;e.draggable.bounds&&(s=Math.max(e._state.drag.minX,Math.min(s,e._state.drag.maxX)),i=Math.max(e._state.drag.minY,Math.min(i,e._state.drag.maxY))),e._state.position.x=s,e._state.position.y=i;const{x:r,y:a}=await pe(e,s,i);e._elements.positioner.style.transform=`translate3d(${r}px, ${a}px, 0)`,await H("onMove",e,{x:r,y:a})}function me(e,{force:t=!1}={}){!function(e){de(e),fe(e)}(e),L(e),H("onSync",e,{})}function _e(e,{force:t=!1}={}){if(!e._elements.boundary||!e._elements.box||"element"==e.anchor&&!e._registry.open.size)return;const n=j()._cache.refreshVersion;if(!t&&e._state.firstcomputeRectsDone&&n===e._cache.computeRectsVersion)return;(["pointer","element"].includes(e.anchor)||e.draggable?.enabled)&&(e._cache.positionerRect=e._elements.positioner.getBoundingClientRect());const o=e._elements.boundary.getBoundingClientRect();if(null===e.boundaryPadding||0===e.boundaryPadding)e._cache.boundaryRect=o;else{const t=e.boundaryPadding;e._cache.boundaryRect={x:o.x,y:o.y,left:o.left+t.left,top:o.top+t.top,right:o.right-t.right,bottom:o.bottom-t.bottom,width:o.right-t.right-(o.left+t.left),height:o.bottom-t.bottom-(o.top+t.top)}}e._cache.computeRectsVersion=n,e._state.firstcomputeRectsDone=!0}async function ge(e){if(!e._registry.open.size||!e.positionerRect||!e.boundaryRect||"element"===e.anchor&&!e.lastTarget)return e._elements.positioner.style.transform="",e._state.anchored=!1,void(e._elements.boundary.dataset.hyperfloatAnchored="false");let t;if("pointer"===e.anchor){const n=j()._cache.pointer;0===n.x&&0===n.y?e._elements.positioner.style.opacity=0:"0"==e._elements.positioner.style.opacity&&(e._elements.positioner.style.opacity=""),e._state.pointer.x=n.x,e._state.pointer.y=n.y,t={left:e._state.pointer.x-5,top:e._state.pointer.y-5,right:e._state.pointer.x+5,bottom:e._state.pointer.y+5,width:10,height:10,x:e._state.pointer.x-5,y:e._state.pointer.y-5}}else t=e.lastTarget.getBoundingClientRect();(function(e){let t=null;return t="object"==typeof e&&null!==e?e:e.getBoundingClientRect(),t.bottom<=0||t.top>=window.innerHeight||t.right<=0||t.left>=window.innerWidth})(t)?e._timers.outside||(e._timers.outside=setTimeout(()=>{e.close({event:"target-outside"}),e._timers.outside=null},e._outsideCloseDelay)):(clearTimeout(e._timers.outside),e._timers.outside=null),e._state.anchored=!0,e._elements.boundary.dataset.hyperfloatAnchored="true",e._state.resolvedPlacement=e.placement;const n=le({elementRect:e.positionerRect,anchorRect:t,boundaryRect:e.boundaryRect,placement:e.placement,offset:e.offset,flip:e.flip,shift:e.shift});e._state.resolvedPlacement=n.resolvedPlacement;const{x:o,y:s}=await pe(e,n.position.left,n.position.top),i=o+"px",r=s+"px";e._elements.positioner.style.transform=`translate3d(${i}, ${r}, 0)`,await H("onMove",e,{x:i,y:r})}async function be(e,{target:t=null,event:n=null,source:o="user"}={}){if(!e._state.ready)return;if(e._state.opened||e._state.locked)return;if(e._state.locked=!0,e._state.opening=!0,e._console.log("Opening:",e.id),e._cache.parentHyperfloat=null,t){let n=e._registry.open.get(t);n&&n.hostHyperfloat!==e.id&&(e._cache.parentHyperfloat=n.hostHyperfloat)}let s=await H("onBeforeOpen",e,{target:t,event:n,source:o});if(!1===s||s?.prevent)return e._state.locked=!1,e._state.opened=!1,void(e._state.opening=!1);he(e),e._cache.lastTarget=t,e._state.pointer.target={el:t,action:"open"},"pointer"===e.anchor&&j()._syncPointerEngine(!0),["pointer","element"].includes(e.anchor)&&(e._state.firstcomputeRectsDone||(await new Promise(requestAnimationFrame),await new Promise(requestAnimationFrame)),_e(e),ge(e)),e.draggable?.enabled&&(e._state.firstcomputeRectsDone||(await new Promise(requestAnimationFrame),await new Promise(requestAnimationFrame)),_e(e),ye(e)),ie(e),e.dismiss.timeout&&null!==e.dismiss.timeout?e._handlers.startTimeoutTimer():e.dismiss.idleTimeout&&null!==e.dismiss.idleTimeout&&(S(e,e.elements.box,"pointerenter",e._handlers.stopIdleTimer),S(e,e.elements.box,"pointerleave",e._handlers.startIdleTimer),S(e,e.elements.box,"pointerdown",e._handlers.stopIdleTimer),S(e,e.elements.box,"wheel",e._handlers.stopIdleTimer,{passive:!0}),S(e,e.elements.box,"touchstart",e._handlers.stopIdleTimer,{passive:!0}),S(e,e.elements.box,"keydown",e._handlers.stopIdleTimer),S(e,e.elements.box,"focusin",e._handlers.stopIdleTimer),e._handlers.startIdleTimer()),await H("onOpen",e,{target:t,event:n,source:o}),e._state.opened=!0,e._state.opening=!1,e._elements.boundary.dataset.hyperfloatOpened="true",j()._setHyperfloatOpened(e,!0),e._console.log("Open:",e.id);for(const[t,n]of e._registry.open)t.dataset.hyperfloatOpened="true";for(const[t,n]of e._registry.close)t.dataset.hyperfloatOpened="true";await H("onAfterOpen",e,{target:t,event:n,source:o}),e._state.locked=!1}async function ve(e,{target:t=null,event:n=null,source:o="user"}={}){if(!e._state.ready)return;if(!e._state.opened||e._state.locked)return;e._state.locked=!0,e._state.opening=!1,e._console.log("Closing:",e.id);for(const[t,s]of j()._instancesMap)s.parentHyperfloat===e.id&&s.dismiss.closeWithParent&&await s.close({el:el,event:n,source:o});let s=await H("onBeforeClose",e,{target:t,event:n,source:o});if(!1===s||s?.prevent)return e._state.locked=!1,e._state.opened=!0,void(e._state.opening=!1);e._cache.lastcloseTarget=t,e._state.pointer.target={el:t,action:"close"},e.dismiss.timeout&&null!==e.dismiss.timeout?e._handlers.stopTimeoutTimer():e.dismiss.idleTimeout&&null!==e.dismiss.idleTimeout&&(e._handlers.stopIdleTimer(),B(e,e.elements.box,"pointerenter",e._handlers.stopIdleTimer),B(e,e.elements.box,"pointerleave",e._handlers.startIdleTimer),B(e,e.elements.box,"pointerdown",e._handlers.stopIdleTimer),B(e,e.elements.box,"wheel",e._handlers.stopIdleTimer),B(e,e.elements.box,"touchstart",e._handlers.stopIdleTimer),B(e,e.elements.box,"keydown",e._handlers.stopIdleTimer),B(e,e.elements.box,"focusin",e._handlers.stopIdleTimer)),await H("onClose",e,{target:t,event:n,source:o}),e._state.opened=!1,e._state.opening=!1,e._elements.boundary.dataset.hyperfloatOpened="false",j()._setHyperfloatOpened(e,!1),e._console.log("Close:",e.id);for(const[t,n]of e._registry.open)t.dataset.hyperfloatOpened="false";for(const[t,n]of e._registry.close)t.dataset.hyperfloatOpened="false";await H("onAfterClose",e,{target:t,event:n,source:o}),e._cache.lastTarget=null,e._cache.parentHyperfloat=null,e._state.pointer.target={el:null,action:null},"pointer"===e.anchor&&j()._syncPointerEngine(),e._state.locked=!1,e.destroyAfterClose&&await xe(e)}async function xe(e,{target:t=null,event:n=null,source:o="user"}={}){e.opened&&await ve(e,{event:"destroy",source:o}),await H("onDestroy",e,{target:t,event:n,source:o}),function(e){for(const[t,n]of e._listenersMap)for(const[e,o]of n)for(const[n,s]of o)t.removeEventListener(e,n,s);e._listenersMap.clear()}(e),e._elements.boundary&&e._elements.boundary.remove(),j()._off("sync",e._handlers.sync),j()._off("update",e._handlers.update),j()._off("refresh",e._handlers.refresh),j()._off("raf",e._handlers.raf),j()._instancesMap.delete(e.id)}async function we(e){await H("onBeforeInit",e,{}),function(e){e._elements.boundary=i("div",{attrs:{...e._helpers.createMetaDataset(),...e._helpers.createAccessibilityDataset(),"data-hyperfloat-boundary":"",id:`${e.id}`,"data-hyperfloat-id":`${e.id}`,"data-hyperfloat-opened":"false","data-hyperfloat-anchor":e.anchor,"data-hyperfloat-anchored":e._state.anchored,"data-hyperfloat-draggable":!0===e.draggable?.enabled},appendTo:e._elements.root}),e._elements.overlayEl=i("div",{class:"hyperfloat-overlay",attrs:{"data-hyperfloat-overlay":""},appendTo:e._elements.boundary}),U(e);const t=["pointer","element"].includes(e.anchor)||e.draggable?.enabled;t&&(e._elements.positioner=i("div",{attrs:{"data-hyperfloat-positioner":""},appendTo:e._elements.boundary}));const n=t?e._elements.positioner:e._elements.boundary;e._elements.box=i("div",{class:"hyperfloat-box",attrs:{"data-hyperfloat-box":""},appendTo:n}),e._elements.headerInner=s(e.header,e),e._elements.headerInner&&(e._elements.header=i("div",{class:"hyperfloat-header",attrs:{"data-hyperfloat-header":""},html:e._elements.headerInner,appendTo:e._elements.box}),e._elements.header.style.order=1),e._elements.content=i("div",{attrs:{"data-hyperfloat-content":""},appendTo:e._elements.box}),e._elements.content.style.order=2,e._elements.contentInner=i("div",{attrs:{"data-hyperfloat-content-inner":""},appendTo:e._elements.content}),e.content?s(e.content,{},e._elements.contentInner):e._elements.loading=i("div",{class:"hyperfloat-loading",attrs:{"data-hyperfloat-loading":""},html:'<span class="hyperfloat-loading-bar" data-hyperfloat-loading-bar></span>',appendTo:e._elements.content}),e._elements.footerInner=s(e.footer,e),e._elements.footerInner&&(e._elements.footer=i("div",{class:"hyperfloat-footer",attrs:{"data-hyperfloat-footer":""},html:e._elements.footerInner,appendTo:e._elements.box}),e._elements.footer.style.order=3),D(e),V(e),X(e),N(e),e.draggable?.enabled&&e._data?.draggable?.handle&&te(e,{bounds:e.draggable.bounds,handle:e._data?.draggable?.handle})}(e),function(e){const t=r(e._defaultCloseSelector,e._elements.boundary);e._elements.overlayEl&&t.push(e._elements.overlayEl),t.forEach(t=>{const n={hostHyperfloat:v(t),event:"click"};e._registry.close.has(t)||e._registry.close.set(t,n)})}(e),me(e),function(e){const t=e.breakpoints||{},n=Object.keys(t);if(!n.length)return void(e._breakpoints=[]);const o=(e,t)=>{const n={...e};for(const s in t)"object"!=typeof t[s]||Array.isArray(t[s])||null===t[s]||"object"!=typeof e[s]?void 0!==t[s]&&null!==t[s]&&(n[s]=t[s]):n[s]=o(e[s],t[s]);return n},s=Math.max(...n.map(Number))+1,i={};for(const t of se)void 0!==e[t]&&(i[t]=e[t]);const r=n.map(Number).sort((e,t)=>t-e);r.unshift(s);const a={};a[s]=i;for(let n=1;n<r.length;n++){const s=r[n],i=t[s];let l={};for(const e of Object.keys(i))se.includes(e)&&(l[e]=i[e]);l=P(e,l,oe);const c=a[r[n-1]];l=o(c,l),a[s]=l}e._breakpoints=Object.entries(a).map(([e,t])=>[Number(e),t]).sort((e,t)=>e[0]-t[0])}(e),function(e){e.draggable?.enabled&&(e._state.anchored=!0,e._elements.boundary.dataset.hyperfloatAnchored="true",e._handlers.pointerMove=t=>{if(e._state.drag){if(!e._state.dragging){const n=Math.abs(t.clientX-e._state.drag.startX),o=Math.abs(t.clientY-e._state.drag.startY);(n>3||o>3)&&(e._state.dragging=!0,document.body.style.userSelect="none",e._elements.box.style.touchAction="none")}e._state.dragging&&ye(e,t)}},e._handlers.pointerUp=t=>{e._state.drag&&(e._state.dragging&&(document.body.style.userSelect="",e._elements.box.style.touchAction=""),e._state.drag=null),e._state.dragging=!1,B(e,document,"pointermove",e._handlers.pointerMove),B(e,document,"pointerup",e._handlers.pointerUp)},e._handlers.pointerDown=t=>{if(0!==t.button)return;if(!e.opened)return;if(["BUTTON","INPUT","TEXTAREA","SELECT","A"].includes(t.target.tagName)||t.target.closest("[data-no-drag]"))return;if(e.draggable.handle){const n=e.draggable.handle;if("string"==typeof n){if(!t.target.closest(n))return}else if((n instanceof Node||n instanceof Element)&&!n.contains(t.target))return}const n=e.positionerRect,o=e.boundaryRect,s=e._state.position.x||0,i=e._state.position.y||0;e._state.drag={startX:t.clientX,startY:t.clientY,initialX:s,initialY:i,minX:o?s-(n.left-o.left):-1/0,maxX:o?s+(o.right-n.right):1/0,minY:o?i-(n.top-o.top):-1/0,maxY:o?i+(o.bottom-n.bottom):1/0},e._state.dragging=!1,he(e),S(e,document,"pointermove",e._handlers.pointerMove),S(e,document,"pointerup",e._handlers.pointerUp)},S(e,e._elements.box,"pointerdown",e._handlers.pointerDown))}(e),await H("onInit",e,{}),await H("onAfterInit",e,{}),function(e){e._console.log("Ready:",e.id),H("onReady",e,{})}(e),e._state.ready=!0}const Ae="1.0.45";class Hyperfloat{constructor(e){if("undefined"==typeof window)return;const t=j()._normalizeData(e);this._data=t,this._id=t.id,this._listenersMap=new Map,this._config={anchor:t.anchor??"viewport"},this._config={...this._config,...P(this,t)},this.content=t.content??null,this._console=function(e,t=""){return e.debug?{log:(...e)=>console.log(t,...e),info:(...e)=>console.info(t,...e),warn:(...e)=>console.warn(t,...e),error:(...e)=>console.error(t,...e),table:(...e)=>{const n=e.pop();console.log(t,...e),console.table(n)}}:{log:()=>{},info:()=>{},warn:()=>{},error:()=>{},table:()=>{}}}(this,"[Trivon Ui - Hyperfloat]"),this._timers={pointerLeave:null,idle:null,timeout:null,outside:null},this._outsideCloseDelay=4e3,this._elements={root:t.root,boundary:null,positioner:null,box:null,content:null,contentInner:null,overlayEl:null,header:null,headerInner:null,footer:null,footerInner:null,loading:null},this._state={ready:!1,opened:!1,opening:!1,locked:!1,dragging:!1,anchored:["element","pointer"].includes(this.anchor),priority:0,pointer:{x:0,y:0,target:{el:null,action:null}},drag:null,position:{x:0,y:0},interpolation:{lastX:0,lastY:0},resolvedPlacement:this._config.placement,firstresolveBreakpointsDone:!1,firstcomputeRectsDone:!1},this._breakpoints=[],this._handlers={startIdleTimer:()=>{clearTimeout(this._timers.idle),!this.dismiss.idleTimeout||this.dismiss.idleTimeout<=0||(this._timers.idle=setTimeout(()=>{ve(this,{event:"no-interaction"})},this.dismiss.idleTimeout))},stopIdleTimer:()=>{clearTimeout(this._timers.idle)},startTimeoutTimer:()=>{clearTimeout(this._timers.timeout),!this.dismiss.timeout||this.dismiss.timeout<=0||(this._timers.timeout=setTimeout(()=>{ve(this,{event:"timeout"})},this.dismiss.timeout))},stopTimeoutTimer:()=>{clearTimeout(this._timers.timeout)},sync:(...e)=>me(this,...e),update:(...e)=>function(e,{force:t=!1}={}){e.opened&&"element"==e.anchor&&e.lastTarget&&(ge(e),H("onUpdate",e,{}))}(this,...e),refresh:(...e)=>function(e,{force:t=!1}={}){e.opened&&(["pointer","element"].includes(e.anchor)&&_e(e,{force:t}),e.draggable?.enabled&&_e(e,{force:t}),e._breakpoints&&!e._breakpoints.length&&ie(e),["pointer","element"].includes(e.anchor)&&e.lastTarget&&ge(e),e.draggable?.enabled&&ye(e)),H("onRefresh",e,{})}(this,...e),raf:()=>{var e;(e=this).opened&&"pointer"==e.anchor&&ge(e)},pointerLeave:e=>{if(!this._state.opened&&!this._state.opening)return;const t=e.currentTarget||e.target,n=e.relatedTarget;n&&(this._elements.box.contains(n)||[...this._registry.open.keys()].some(e=>e.contains(n)))||("pointer"===this.anchor?(clearTimeout(this._timers.pointerLeave),this._timers.pointerLeave=setTimeout(()=>{this._elements.box.matches(":hover")||[...this._registry.open.keys()].some(e=>e.matches(":hover"))||this.close({target:t,event:"pointerleave"})},100)):this.close({target:t,event:"pointerleave"}))},pointerMove:()=>{},pointerDown:()=>{},pointerUp:()=>{}},this.sync=this._handlers.sync,this.update=this._handlers.update,this.refresh=this._handlers.refresh,j()._on("sync",this._handlers.sync),j()._on("update",this._handlers.update),j()._on("refresh",this._handlers.refresh),j()._on("raf",this._handlers.raf),this.open=async(...e)=>await be(this,...e),this.close=async(...e)=>await ve(this,...e),this.destroy=async(...e)=>await xe(this,...e),this._cache={boundaryRect:null,positionerRect:null,targetRects:new Map,parentHyperfloat:null,lastTarget:null,lastcloseTarget:null,lastBreakpoint:9999999999999,computeRectsVersion:0,resolveBreakpointsVersion:0,syncPositionVersion:0,lastApplyMeta:{},lastApplyAccessibility:{}},this._registry={open:new Map,close:new Map};for(const e of Object.keys(this._registry)){b(t[e]??null).forEach(t=>{this._registry[e].set(t.el,{hostHyperfloat:v(t.el),event:t.event})})}return this.registerOpen=e=>ce(this,"open",e),this.registerClose=e=>ce(this,"close",e),this.unregisterOpen=e=>unregisterAction(this,"open",e),this.unregisterClose=e=>unregisterAction(this,"close",e),this.vars=t.vars??{},j()._instancesMap.set(this.id,this),this}static async create(e={}){if("undefined"==typeof window)return null;if(e.id&&j()._instancesMap.has(e.id)){const t=j()._instancesMap.get(e.id);if(!(!0===e.overwrite))return t.sync(),t;t.destroy()}const t=new this(e);return await we(t),!0===e.autoOpen&&await be(t,{event:"initialize",source:"auto"}),t}get id(){return this._id}get anchor(){return this._config.anchor}get opened(){return this._state.opened}get resolvedPlacement(){return this._state.resolvedPlacement}get state(){return{ready:this._state.ready,priority:this._state.priority,anchored:this._state.anchored,pointer:this._state.pointer,locked:this._state.locked,opened:this._state.opened,opening:this._state.opening,dragging:this._state.dragging}}get elements(){return{boundary:this._elements.boundary,overlay:this._elements.overlayEl,positioner:this._elements.positioner,box:this._elements.box,content:this._elements.content,contentInner:this._elements.contentInner,loading:this._elements.loading,header:this._elements.header,headerInner:this._elements.headerInner,footer:this._elements.footer,footerInner:this._elements.footerInner}}get lastTarget(){return this._cache.lastTarget}get parentHyperfloat(){return this._cache.parentHyperfloat}get boundaryRect(){return this._cache.boundaryRect}get positionerRect(){return this._cache.positionerRect}get lastBreakpoint(){return this._cache.lastBreakpoint}_helpers={createAccessibilityDataset:()=>{const e=Object.fromEntries(Object.entries(this.accessibility).map(([e,t])=>{let n="";switch(e){case"role":n=e;break;case"label":n="aria-label";break;default:n=`data-${e}`}return[n,String(t)]}));return this._cache.lastApplyAccessibility=e,e},createMetaDataset:()=>{const e=Object.fromEntries(Object.entries(this.meta).map(([e,t])=>[`data-${e}`,String(t)]));return this._cache.lastApplyMeta=e,e}};static get version(){return Ae}static get _manager(){return j()}static config(e={}){j()._setConfig(e)}static defaults(e={}){j()._setDefaults(e)}static async open(e,t={}){await j()._open(e,t)}static async close(e,t={}){await j()._close(e,t)}static async closeAll(e={}){await j()._closeAll(e)}static async destroy(e,t={}){await j()._destroy(e,t)}static async destroyAll(e={}){await j()._destroyAll(e)}static sync(){j()._sync()}static update(){j()._update()}static refresh(){j()._refresh()}static raf(e){j()._raf(e)}static getAll(){return j()._getAll()}static getOpened(...e){return j()._getOpened(...e)}static getByPriority(...e){return j()._getByPriority(...e)}}ne.forEach(e=>{Object.defineProperty(Hyperfloat.prototype,e,{get(){return this._config[e]??j()._defaults[e]??n[e].default},set(t){"meta"==e?Y(this,t):"accessibility"==e?q(this,t):"dismiss"==e?F(this,t):"overlay"==e?W(this,t):"placement"==e?K(this,t):"boundaryPadding"==e?G(this,t):"offset"==e?J(this,t):"flip"==e?Q(this,t):"shift"==e?Z(this,t):"size"==e?ee(this,t):"draggable"==e?te(this,t):["destroyAfterClose","ignoreCloseAll","debug"].includes(e)&&(this._config[e]=!0===t)},configurable:!0,enumerable:!0})});export{Hyperfloat,Hyperfloat as default};
9
9
  //# sourceMappingURL=hyperfloat.mjs.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hyperfloat",
3
- "version": "1.0.44",
3
+ "version": "1.0.45",
4
4
  "description": "Lightweight positioning engine for hyperfloating UI elements, popovers, and tooltips.",
5
5
  "author": "Felipe Otto (Trivon UI)",
6
6
  "license": "MIT",