@floating-ui/react-dom-interactions
Advanced tools
Comparing version 0.6.5 to 0.6.6
@@ -1,1 +0,1 @@ | ||
import{useFloating as e,getOverflowAncestors as n}from"@floating-ui/react-dom";export*from"@floating-ui/react-dom";import*as t from"react";import{useLayoutEffect as r,useEffect as o,useRef as u}from"react";import{createPortal as c}from"react-dom";import{hideOthers as l}from"aria-hidden";var i="undefined"!=typeof document?r:o;function a(){const e=new Map;return{emit(n,t){var r;null==(r=e.get(n))||r.forEach((e=>e(t)))},on(n,t){e.set(n,[...e.get(n)||[],t])},off(n,t){e.set(n,(e.get(n)||[]).filter((e=>e!==t)))}}}let s=!1,f=0;const d=()=>"floating-ui-"+f++;const v=t["useId".toString()],m=null!=v?v:function(){const[e,n]=t.useState((()=>s?d():void 0));return i((()=>{null==e&&n(d())}),[]),t.useEffect((()=>{s||(s=!0)}),[]),e},p=t.createContext(null),g=t.createContext(null),b=()=>{var e,n;return null!=(e=null==(n=t.useContext(p))?void 0:n.id)?e:null},h=()=>t.useContext(g),y=()=>{const e=m(),n=h(),t=b();return i((()=>{const r={id:e,parentId:t};return null==n||n.addNode(r),()=>{null==n||n.removeNode(r)}}),[n,e,t]),e},E=e=>{let{children:n,id:r}=e;const o=b();return t.createElement(p.Provider,{value:t.useMemo((()=>({id:r,parentId:o})),[r,o])},n)},w=e=>{let{children:n}=e;const r=t.useRef([]),o=t.useCallback((e=>{r.current=[...r.current,e]}),[]),u=t.useCallback((e=>{r.current=r.current.filter((n=>n!==e))}),[]),c=t.useState((()=>a()))[0];return t.createElement(g.Provider,{value:t.useMemo((()=>({nodesRef:r,addNode:o,removeNode:u,events:c})),[r,o,u,c])},n)};function R(e){var n;return null!=(n=null==e?void 0:e.ownerDocument)?n:document}function x(e){var n;return null!=(n=R(e).defaultView)?n:window}function L(e){return!!e&&e instanceof x(e).Element}function k(e){return!!e&&e instanceof x(e).HTMLElement}function I(n){let{open:r=!1,onOpenChange:o=(()=>{}),whileElementsMounted:u,placement:c,middleware:l,strategy:s,nodeId:f}=void 0===n?{}:n;const d=h(),v=t.useRef(null),m=t.useRef({}),p=t.useState((()=>a()))[0],g=e({placement:c,middleware:l,strategy:s,whileElementsMounted:u}),b=t.useMemo((()=>({...g.refs,domReference:v})),[g.refs]),y=t.useMemo((()=>({...g,refs:b,dataRef:m,nodeId:f,events:p,open:r,onOpenChange:o})),[g,f,p,r,o,b]);i((()=>{const e=null==d?void 0:d.nodesRef.current.find((e=>e.id===f));e&&(e.context=y)}));const{reference:E}=g,w=t.useCallback((e=>{(L(e)||null===e)&&(y.refs.domReference.current=e),E(e)}),[E,y.refs]);return t.useMemo((()=>({...g,context:y,refs:b,reference:w})),[g,b,y,w])}function T(e,n,t){const r=new Map;return{..."floating"===t&&{tabIndex:-1},...e,...n.map((e=>e?e[t]:null)).concat(e).reduce(((e,n)=>n?(Object.entries(n).forEach((n=>{let[t,o]=n;if(0===t.indexOf("on")){var u;if(r.has(t)||r.set(t,[]),"function"==typeof o)null==(u=r.get(t))||u.push(o);e[t]=function(){for(var e,n=arguments.length,o=new Array(n),u=0;u<n;u++)o[u]=arguments[u];null==(e=r.get(t))||e.forEach((e=>e(...o)))}}else e[t]=o})),e):e),{})}}const C=function(e){return void 0===e&&(e=[]),{getReferenceProps:n=>T(n,e,"reference"),getFloatingProps:n=>T(n,e,"floating"),getItemProps:n=>T(n,e,"item")}};function A(e,n){var t;let r=null!=(t=e.filter((e=>{var t;return e.parentId===n&&(null==(t=e.context)?void 0:t.open)})))?t:[],o=r;for(;o.length;){var u;o=null!=(u=e.filter((e=>{var n;return null==(n=o)?void 0:n.some((n=>{var t;return e.parentId===n.id&&(null==(t=e.context)?void 0:t.open)}))})))?u:[],r=r.concat(o)}return r}function O(e){let n,{restMs:t=0,buffer:r=.5,debug:o=null}=void 0===e?{}:e,u=!1;return e=>{let{x:o,y:c,placement:l,refs:i,onClose:a,nodeId:s,tree:f,leave:d=!1}=e;return function(e){var v,m;function p(){clearTimeout(n),a()}if(clearTimeout(n),e.pointerType&&"mouse"!==e.pointerType)return;const{clientX:g,clientY:b}=e,h="composedPath"in e?e.composedPath()[0]:e.target;if("pointermove"===e.type&&null!=(v=i.domReference.current)&&v.contains(h))return;if(f&&A(f.nodesRef.current,s).some((e=>{let{context:n}=e;return null==n?void 0:n.open})))return;if(null!=(m=i.floating.current)&&m.contains(h)&&!d)return void(u=!0);if(!i.domReference.current||!i.floating.current||null==l||null==o||null==c)return;const y=i.domReference.current.getBoundingClientRect(),E=i.floating.current.getBoundingClientRect(),w=l.split("-")[0],R=o>E.right-E.width/2,x=c>E.bottom-E.height/2;if("top"===w&&c>=y.bottom-1||"bottom"===w&&c<=y.top+1||"left"===w&&o>=y.right-1||"right"===w&&o<=y.left+1)return p();switch(w){case"top":if(g>=E.left&&g<=E.right&&b>=E.top&&b<=y.top+1)return;break;case"bottom":if(g>=E.left&&g<=E.right&&b>=y.bottom-1&&b<=E.bottom)return;break;case"left":if(g>=E.left&&g<=y.left+1&&b>=E.top&&b<=E.bottom)return;break;case"right":if(g>=y.right-1&&g<=E.right&&b>=E.top&&b<=E.bottom)return}if(u)return p();const L=function(e){let[n,t]=e;const o=E.width>y.width,u=E.height>y.height;switch(w){case"top":return[[o?n+r/2:R?n+4*r:n-4*r,t+r+1],[o?n-r/2:R?n+4*r:n-4*r,t+r+1],...[[E.left,R||o?E.bottom-r:E.top],[E.right,R?o?E.bottom-r:E.top:E.bottom-r]]];case"bottom":return[[o?n+r/2:R?n+4*r:n-4*r,t-r],[o?n-r/2:R?n+4*r:n-4*r,t-r],...[[E.left,R||o?E.top+r:E.bottom],[E.right,R?o?E.top+r:E.bottom:E.top+r]]];case"left":{const e=[n+r+1,u?t+r/2:x?t+4*r:t-4*r],o=[n+r+1,u?t-r/2:x?t+4*r:t-4*r];return[...[[x||u?E.right-r:E.left,E.top],[x?u?E.right-r:E.left:E.right-r,E.bottom]],e,o]}case"right":return[[n-r,u?t+r/2:x?t+4*r:t-4*r],[n-r,u?t-r/2:x?t+4*r:t-4*r],...[[x||u?E.left+r:E.right,E.top],[x?u?E.left+r:E.right:E.left+r,E.bottom]]]}}([o,c]);!function(e,n){const[t,r]=e;let o=!1;const u=n.length;for(let e=0,c=u-1;e<u;c=e++){const[u,l]=n[e]||[0,0],[i,a]=n[c]||[0,0];l>=r!=a>=r&&t<=(i-u)*(r-l)/(a-l)+u&&(o=!o)}return o}([g,b],L)?p():t&&(n=setTimeout(a,t))}}}const M="floating-ui-root",D=function(e){let{id:n=M,enabled:r=!0}=void 0===e?{}:e;const[o,u]=t.useState(null);return i((()=>{if(!r)return;const e=document.getElementById(n);if(e)u(e);else{const e=document.createElement("div");e.id=n,u(e),document.body.contains(e)||document.body.appendChild(e)}}),[n,r]),o},P=e=>{let{children:n,id:t=M,root:r=null}=e;const o=D({id:t,enabled:!r});return r?c(n,r):o?c(n,o):null};function S(){return S=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},S.apply(this,arguments)}const F="data-floating-ui-scroll-lock";const K=t.forwardRef((function(e,n){let{lockScroll:r=!1,...o}=e;return i((()=>{var e,n,t,o;if(!r)return;if(document.body.hasAttribute(F))return;document.body.setAttribute(F,"");const u=Math.round(document.documentElement.getBoundingClientRect().left)+document.documentElement.scrollLeft?"paddingLeft":"paddingRight",c=window.innerWidth-document.documentElement.clientWidth;if(!/iP(hone|ad|od)|iOS/.test(function(){const e=navigator.userAgentData;return null!=e&&e.platform?e.platform:navigator.platform}()))return Object.assign(document.body.style,{overflow:"hidden",[u]:c+"px"}),()=>{document.body.removeAttribute(F),Object.assign(document.body.style,{overflow:"",[u]:""})};const l=null!=(e=null==(n=window.visualViewport)?void 0:n.offsetLeft)?e:0,i=null!=(t=null==(o=window.visualViewport)?void 0:o.offsetTop)?t:0,a=window.pageXOffset,s=window.pageYOffset;return Object.assign(document.body.style,{position:"fixed",overflow:"hidden",top:-(s-Math.floor(i))+"px",left:-(a-Math.floor(l))+"px",right:"0",[u]:c+"px"}),()=>{Object.assign(document.body.style,{position:"",overflow:"",top:"",left:"",right:"",[u]:""}),document.body.removeAttribute(F),window.scrollTo(a,s)}}),[r]),t.createElement("div",S({ref:n},o,{style:{position:"fixed",overflow:"auto",top:0,right:0,bottom:0,left:0,...o.style}}))}));function j(e){let n=e.activeElement;for(;null!=(null==(t=n)||null==(r=t.shadowRoot)?void 0:r.activeElement);){var t,r;n=n.shadowRoot.activeElement}return n}const N="input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";function B(e){return k(e)&&e.matches(N)}function V(e){e.preventDefault(),e.stopPropagation()}function U(e){const n=u(e);return i((()=>{n.current=e})),n}function H(e){requestAnimationFrame((()=>{null==e||e.focus()}))}const X=t.forwardRef((function(e,n){return t.createElement("span",S({},e,{ref:n,tabIndex:0,style:{position:"fixed",opacity:"0",pointerEvents:"none",outline:"0"}}))}));function Y(e){let{context:{refs:n,nodeId:r,onOpenChange:o,dataRef:u},children:c,order:i=["content"],endGuard:a=!0,preventTabbing:s=!1,initialFocus:f=0,returnFocus:d=!0,modal:v=!0}=e;const m=U(i),p=U(o),g=h(),b=t.useCallback((()=>m.current.map((e=>{return"reference"===e?n.domReference.current:n.floating.current&&"floating"===e?n.floating.current:"content"===e?Array.from(null!=(t=null==(r=n.floating.current)?void 0:r.querySelectorAll("select:not([disabled]),a[href],button:not([disabled]),[tabindex],iframe,object,embed,area[href],audio[controls],video[controls],input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])"))?t:[]):null;var t,r})).flat().filter((e=>{if(e===n.floating.current||e===n.domReference.current)return!0;if(k(e)){var t;return"-"!==(null!=(t=e.getAttribute("tabindex"))?t:"0")[0].trim()}}))),[m,n]);t.useEffect((()=>{if(!v)return;const e=0===b().filter((e=>e!==n.floating.current&&e!==n.domReference.current)).length;function t(t){if("Tab"===t.key){(s||e)&&V(t);const r=b(),o="composedPath"in t?t.composedPath()[0]:t.target;"reference"===m.current[0]&&o===n.domReference.current&&(V(t),t.shiftKey?H(r[r.length-1]):H(r[1])),"floating"===m.current[1]&&o===n.floating.current&&t.shiftKey&&(V(t),H(r[0]))}}const r=R(n.floating.current);return r.addEventListener("keydown",t),()=>{r.removeEventListener("keydown",t)}}),[s,v,b,m,n]),t.useEffect((()=>{function e(e){var t,o;const u=e.relatedTarget,c=!(null!=(t=n.floating.current)&&t.contains(u)),l=L(n.domReference.current)&&!n.domReference.current.contains(u),i=g&&A(g.nodesRef.current,r).length>0,a=g&&e.currentTarget===n.domReference.current&&(null==(o=function(e,n){var t;let r=[],o=null==(t=e.find((e=>e.id===n)))?void 0:t.parentId;for(;o;){const n=e.find((e=>e.id===o));o=null==n?void 0:n.parentId,n&&(r=r.concat(n))}return r}(g.nodesRef.current,r))?void 0:o.some((e=>{var n,t;return null==(n=e.context)||null==(t=n.refs.floating.current)?void 0:t.contains(u)})));c&&l&&!i&&!a&&p.current(!1)}const t=n.floating.current,o=n.domReference.current;if(t&&k(o)){let n;return!v&&t.addEventListener("focusout",e),!v&&o.addEventListener("focusout",e),v&&(n=m.current.includes("reference")?l([o,t]):l(t)),()=>{!v&&t.removeEventListener("focusout",e),!v&&o.removeEventListener("focusout",e),null==n||n()}}}),[r,g,v,p,m,u,b,n]),t.useEffect((()=>{if(s)return;const e=n.floating.current,t=j(R(e));var r;if("number"==typeof f)H(null!=(r=b()[f])?r:e);else if(k(null==f?void 0:f.current)){var o;H(null!=(o=f.current)?o:e)}return()=>{d&&k(t)&&H(t)}}),[s,b,f,d,n]);const y=()=>{var e;return"combobox"===(null==(e=n.domReference.current)?void 0:e.getAttribute("role"))&&B(n.domReference.current)};return t.createElement(t.Fragment,null,v&&t.createElement(X,{onFocus:e=>{if(y())return;V(e);const n=b();"reference"===i[0]?H(n[0]):H(n[n.length-1])}}),t.cloneElement(c,i.includes("floating")?{tabIndex:0}:{}),v&&a&&t.createElement(X,{onFocus:e=>{y()||(V(e),H(b()[0]))}}))}function q(e){const n=u();return i((()=>{n.current=e}),[e]),n.current}function W(e,n,t){return t&&"mouse"!==t?0:"number"==typeof e?e:null==e?void 0:e[n]}const z=function(e,n){let{enabled:r=!0,delay:o=0,handleClose:u=null,mouseOnly:c=!1,restMs:l=0}=void 0===n?{}:n;const{open:a,onOpenChange:s,dataRef:f,events:d,refs:v}=e,m=h(),p=b(),g=U(s),y=U(u),E=q(a),w=t.useRef(),x=t.useRef(),I=t.useRef(),T=t.useRef(),C=t.useRef(!0),A=t.useRef(!1);t.useEffect((()=>{if(r)return d.on("dismiss",e),()=>{d.off("dismiss",e)};function e(){clearTimeout(x.current),clearTimeout(T.current),C.current=!0}}),[r,d,v]),t.useEffect((()=>{if(!r||!y.current)return;function e(){var e;null!=(e=f.current.openEvent)&&e.type.includes("mouse")&&g.current(!1)}const n=R(v.floating.current).documentElement;return n.addEventListener("mouseleave",e),()=>{n.removeEventListener("mouseleave",e)}}),[v,g,r,y,f]);const O=t.useCallback((function(e){void 0===e&&(e=!0);const n=W(o,"close",w.current);n&&!I.current?(clearTimeout(x.current),x.current=setTimeout((()=>g.current(!1)),n)):e&&(clearTimeout(x.current),g.current(!1))}),[o,g]),M=t.useCallback((()=>{I.current&&(R(v.floating.current).removeEventListener("pointermove",I.current),I.current=void 0)}),[v]),D=t.useCallback((()=>{R(v.floating.current).body.style.pointerEvents="",A.current=!1}),[v]);if(t.useEffect((()=>{if(!r)return;function n(e){if(clearTimeout(x.current),C.current=!1,a||c&&"mouse"!==w.current||l>0&&0===W(o,"open"))return;f.current.openEvent=e;const n=W(o,"open",w.current);n?x.current=setTimeout((()=>{g.current(!0)}),n):g.current(!0)}function t(n){var t,r;if("click"===(null==(t=f.current.openEvent)?void 0:t.type)||"pointerdown"===(null==(r=f.current.openEvent)?void 0:r.type))return;const o=R(v.floating.current);if(clearTimeout(T.current),y.current)return clearTimeout(x.current),I.current&&o.removeEventListener("pointermove",I.current),I.current=y.current({...e,tree:m,x:n.clientX,y:n.clientY,onClose(){M(),O()}}),void o.addEventListener("pointermove",I.current);O()}function u(n){null==y.current||y.current({...e,tree:m,x:n.clientX,y:n.clientY,leave:!0,onClose(){M(),O()}})(n)}const i=v.floating.current,s=v.domReference.current;return L(s)?(a&&s.addEventListener("mouseleave",u),null==i||i.addEventListener("mouseleave",u),s.addEventListener("mousemove",n,{once:!0}),s.addEventListener("mouseenter",n),s.addEventListener("mouseleave",t),()=>{a&&s.removeEventListener("mouseleave",u),null==i||i.removeEventListener("mouseleave",u),s.removeEventListener("mousemove",n),s.removeEventListener("mouseenter",n),s.removeEventListener("mouseleave",t)}):void 0}),[r,O,e,o,y,f,c,g,a,m,l,M,v]),i((()=>{if(r&&a&&y.current){R(v.floating.current).body.style.pointerEvents="none",A.current=!0;const t=v.domReference.current,r=v.floating.current;if(k(t)&&r){var e,n;const o=null==m||null==(e=m.nodesRef.current.find((e=>e.id===p)))||null==(n=e.context)?void 0:n.refs.floating.current;return o&&(o.style.pointerEvents=""),t.style.pointerEvents="auto",r.style.pointerEvents="auto",()=>{t.style.pointerEvents="",r.style.pointerEvents=""}}}}),[r,a,p,v,m,y,f]),i((()=>{E&&!a&&(w.current=void 0,M(),D())})),t.useEffect((()=>()=>{M(),clearTimeout(x.current),clearTimeout(T.current),A.current&&D()}),[M,D]),!r)return{};function P(e){w.current=e.pointerType}return{reference:{onPointerDown:P,onPointerEnter:P,onMouseMove(){a||0===l||(clearTimeout(T.current),T.current=setTimeout((()=>{C.current||s(!0)}),l))}},floating:{onMouseEnter(){clearTimeout(x.current)},onMouseLeave(){O(!1)}}}},G=t.createContext({delay:1e3,initialDelay:1e3,currentId:null,setCurrentId:()=>{},setState:()=>{}}),J=()=>t.useContext(G),Q=e=>{let{children:n,delay:r}=e;const[o,u]=t.useState({delay:r,initialDelay:r,currentId:null}),c=t.useCallback((e=>{u((n=>({...n,currentId:e})))}),[]);return t.createElement(G.Provider,{value:t.useMemo((()=>({...o,setState:u,setCurrentId:c})),[o,u,c])},n)},Z=(e,n)=>{let{open:r,onOpenChange:o}=e,{id:u}=n;const{currentId:c,initialDelay:l,setState:i}=J(),a=U(o);t.useEffect((()=>{c&&a.current&&(i((e=>({...e,delay:{open:1,close:W(l,"close")}}))),c!==u&&a.current(!1))}),[u,a,i,c,l]),t.useEffect((()=>{!r&&c===u&&a.current&&(a.current(!1),i((e=>({...e,delay:l,currentId:null}))))}),[r,i,c,u,a,l])},$=function(e,n){let{open:t}=e,{enabled:r=!0,role:o="dialog"}=void 0===n?{}:n;const u=m(),c=m(),l={id:u,role:o};return r?"tooltip"===o?{reference:{"aria-describedby":t?u:void 0},floating:l}:{reference:{"aria-expanded":t?"true":"false","aria-haspopup":o,"aria-controls":t?u:void 0,..."listbox"===o&&{role:"combobox"},..."menu"===o&&{id:c}},floating:{...l,..."menu"===o&&{"aria-labelledby":c}}}:{}},_=function(e,n){let{open:r,onOpenChange:o,dataRef:u,refs:c}=e,{enabled:l=!0,pointerDown:i=!1,toggle:a=!0,ignoreMouse:s=!1}=void 0===n?{}:n;const f=t.useRef();function d(){var e;return"BUTTON"===(null==(e=c.domReference.current)?void 0:e.tagName)}function v(){return B(c.domReference.current)}return l?{reference:{onPointerDown(e){0===e.button&&(f.current=e.pointerType,"mouse"===f.current&&s||i&&(r?!a||u.current.openEvent&&"pointerdown"!==u.current.openEvent.type||o(!1):o(!0),u.current.openEvent=e.nativeEvent))},onClick(e){i&&f.current?f.current=void 0:"mouse"===f.current&&s||(r?!a||u.current.openEvent&&"click"!==u.current.openEvent.type||o(!1):o(!0),u.current.openEvent=e.nativeEvent)},onKeyDown(e){f.current=void 0,d()||(" "!==e.key||v()||e.preventDefault(),"Enter"===e.key&&(r?a&&o(!1):o(!0)))},onKeyUp(e){d()||v()||" "===e.key&&(r?a&&o(!1):o(!0))}}}:{}};function ee(e,n){if(null==n)return!1;if("composedPath"in e)return e.composedPath().includes(n);const t=e;return null!=t.target&&n.contains(t.target)}const ne=function(e,r){let{open:o,onOpenChange:u,refs:c,events:l,nodeId:i}=e,{enabled:a=!0,escapeKey:s=!0,outsidePointerDown:f=!0,referencePointerDown:d=!1,ancestorScroll:v=!1,bubbles:m=!0}=void 0===r?{}:r;const p=h(),g=U(u),b=t.useCallback((()=>{var e;return null==(e=c.floating.current)?void 0:e.contains(j(R(c.floating.current)))}),[c]),y=t.useCallback((()=>{k(c.domReference.current)&&c.domReference.current.focus()}),[c]);return t.useEffect((()=>{if(!o||!a)return;function e(e){if("Escape"===e.key){if(!m&&!b())return;l.emit("dismiss"),g.current(!1),y()}}function t(e){const n=p&&A(p.nodesRef.current,i).some((n=>{var t;return ee(e,null==(t=n.context)?void 0:t.refs.floating.current)}));ee(e,c.floating.current)||ee(e,c.domReference.current)||n||(m||b())&&(l.emit("dismiss"),g.current(!1),y())}function r(){g.current(!1)}const u=R(c.floating.current);s&&u.addEventListener("keydown",e),f&&u.addEventListener("mousedown",t);const d=(v?[...L(c.reference.current)?n(c.reference.current):[],...L(c.floating.current)?n(c.floating.current):[]]:[]).filter((e=>{var n;return e!==(null==(n=u.defaultView)?void 0:n.visualViewport)}));return d.forEach((e=>e.addEventListener("scroll",r,{passive:!0}))),()=>{s&&u.removeEventListener("keydown",e),f&&u.removeEventListener("mousedown",t),d.forEach((e=>e.removeEventListener("scroll",r)))}}),[s,f,l,p,i,o,g,y,v,a,m,b,c]),a?{reference:{onPointerDown(){d&&(l.emit("dismiss"),u(!1))}}}:{}},te=function(e,n){let{open:r,onOpenChange:o,dataRef:u,refs:c,events:l}=e,{enabled:i=!0,keyboardOnly:a=!0}=void 0===n?{}:n;const s=t.useRef(""),f=t.useRef(!1);return t.useEffect((()=>{var e;if(!i)return;const n=R(c.floating.current),t=null!=(e=n.defaultView)?e:window;function o(){s.current&&c.domReference.current===j(n)&&(f.current=!r)}function u(){setTimeout((()=>{f.current=!1,s.current=""}))}return t.addEventListener("focus",u),t.addEventListener("blur",o),()=>{t.removeEventListener("focus",u),t.removeEventListener("blur",o)}}),[c,r,i]),t.useEffect((()=>{if(i)return l.on("dismiss",e),()=>{l.off("dismiss",e)};function e(){f.current=!0}}),[l,i]),i?{reference:{onPointerDown(e){let{pointerType:n}=e;s.current=n,f.current=!(!n||!a)},onFocus(e){var n,t,r;f.current||"focus"===e.type&&"mousedown"===(null==(n=u.current.openEvent)?void 0:n.type)&&null!=(t=c.domReference.current)&&t.contains(null==(r=u.current.openEvent)?void 0:r.target)||(u.current.openEvent=e.nativeEvent,o(!0))},onBlur(e){var n,t;const r=e.relatedTarget;null!=(n=c.floating.current)&&n.contains(r)||null!=(t=c.domReference.current)&&t.contains(r)||(f.current=!1,o(!1))}}}:{}};function re(e,n){return n<0||n>=e.current.length}function oe(e,n){let{startingIndex:t=-1,decrement:r=!1,disabledIndices:o}=void 0===n?{}:n;const u=e.current;let c=t;do{var l,i;c+=r?-1:1}while(c>=0&&c<=u.length-1&&(o?o.includes(c):null==u[c]||(null==(l=u[c])?void 0:l.hasAttribute("disabled"))||"true"===(null==(i=u[c])?void 0:i.getAttribute("aria-disabled"))));return c}function ue(e,n,t){switch(e){case"vertical":return n;case"horizontal":return t;default:return n||t}}function ce(e,n){return ue(n,"ArrowUp"===e||"ArrowDown"===e,"ArrowLeft"===e||"ArrowRight"===e)}function le(e,n,t){return ue(n,"ArrowDown"===e,t?"ArrowLeft"===e:"ArrowRight"===e)||"Enter"===e||" "==e||""===e}function ie(e,n){return oe(e,{disabledIndices:n})}function ae(e,n){return oe(e,{decrement:!0,startingIndex:e.current.length,disabledIndices:n})}const se=function(e,n){let{open:r,onOpenChange:o,refs:u}=e,{listRef:c,activeIndex:l,onNavigate:a,enabled:s=!0,selectedIndex:f=null,allowEscape:d=!1,loop:v=!1,nested:m=!1,rtl:p=!1,virtual:g=!1,focusItemOnOpen:y="auto",focusItemOnHover:E=!0,openOnArrowKeyDown:w=!0,disabledIndices:x=(w?void 0:[]),orientation:L="vertical"}=void 0===n?{listRef:{current:[]},activeIndex:null,onNavigate:()=>{}}:n;const I=b(),T=h(),C=q(r),A=t.useRef(y),O=t.useRef(null!=f?f:-1),M=t.useRef(null),D=U(q(a)),P=U(a),S=U(x),F=t.useRef(!1),K=t.useRef(-1),[N,B]=t.useState(),H=t.useCallback(((e,n)=>{K.current=requestAnimationFrame((()=>{var t,r;g?B(null==(t=e.current[n.current])?void 0:t.id):null==(r=e.current[n.current])||r.focus({preventScroll:!0})}))}),[g]);function X(e){if(F.current=!0,m&&function(e,n,t){return ue(n,t?"ArrowRight"===e:"ArrowLeft"===e,"ArrowUp"===e)}(e.key,L,p))return V(e),o(!1),void(k(u.domReference.current)&&u.domReference.current.focus());const n=O.current,t=ie(c,x),l=ae(c,x);if("Home"===e.key&&(O.current=t,a(O.current)),"End"===e.key&&(O.current=l,a(O.current)),ce(e.key,L)){if(V(e),r&&!g&&j(e.currentTarget.ownerDocument)===e.currentTarget)return O.current=le(e.key,L,p)?t:l,void a(O.current);le(e.key,L,p)?O.current=v?n>=l?d&&n!==c.current.length?-1:t:oe(c,{startingIndex:n,disabledIndices:x}):Math.min(l,oe(c,{startingIndex:n,disabledIndices:x})):O.current=v?n<=t?d&&-1!==n?c.current.length:l:oe(c,{startingIndex:n,decrement:!0,disabledIndices:x}):Math.max(t,oe(c,{startingIndex:n,decrement:!0,disabledIndices:x})),re(c,O.current)?a(null):a(O.current)}}return i((()=>{s&&(!C&&r&&A.current&&null!=f&&P.current(f),C&&!r&&(cancelAnimationFrame(K.current),O.current=-1,null==D.current||D.current(null)))}),[r,C,f,c,P,D,H,s]),i((()=>{if(s&&r)if(null==l){if(null!=f)return;C&&(O.current=-1,H(c,O)),!C&&A.current&&(null!=M.current||!0===A.current&&null==M.current)&&(O.current=null==M.current||le(M.current,L,p)||m?ie(c,S.current):ae(c,S.current),P.current(O.current),H(c,O))}else re(c,l)||(O.current=l,H(c,O))}),[r,C,l,f,m,c,P,H,s,d,L,p,g,S]),i((()=>{s&&!r&&C&&null!=f&&k(u.domReference.current)&&u.domReference.current.focus()}),[u,f,r,C,s]),i((()=>{if(s&&!r&&C){var e,n;const t=null==T||null==(e=T.nodesRef.current.find((e=>e.id===I)))||null==(n=e.context)?void 0:n.refs.floating.current;t&&!t.contains(j(R(t)))&&t.focus({preventScroll:!0})}}),[s,r,C,T,I]),i((()=>{M.current=null})),s?{reference:{...g&&r&&null!=l&&{"aria-activedescendant":N},onKeyDown(e){if(F.current=!0,g&&r)return X(e);(0===e.key.indexOf("Arrow")||"Enter"===e.key||" "===e.key||""===e.key)&&(M.current=e.key),m?function(e,n,t){return ue(n,t?"ArrowLeft"===e:"ArrowRight"===e,"ArrowDown"===e)}(e.key,L,p)&&(V(e),r?(O.current=ie(c,x),a(O.current)):o(!0)):ce(e.key,L)&&(null!=f&&(O.current=f),V(e),!r&&w?o(!0):X(e),r&&a(O.current))}},floating:{"aria-orientation":"both"===L?void 0:L,...g&&null!=l&&{"aria-activedescendant":N},onKeyDown:X,onPointerMove(){F.current=!1}},item:{onFocus(e){let{currentTarget:n}=e;const t=c.current.indexOf(n);-1!==t&&a(t)},onClick:e=>{let{currentTarget:n}=e;return n.focus({preventScroll:!0})},...E&&{onMouseMove(e){let{currentTarget:n}=e;const t=n;if(t){const e=c.current.indexOf(t);-1!==e&&a(e)}},onMouseLeave(){var e;F.current||(O.current=-1,H(c,O),P.current(null),g||null==(e=u.floating.current)||e.focus({preventScroll:!0}))}}}}:{}},fe=function(e,n){var r;let{open:o,dataRef:u}=e,{listRef:c,activeIndex:l,onMatch:a=(()=>{}),enabled:s=!0,findMatch:f=null,resetMs:d=1e3,ignoreKeys:v=[],selectedIndex:m=null}=void 0===n?{listRef:{current:[]},activeIndex:null}:n;const p=t.useRef(),g=t.useRef(""),b=t.useRef(null!=(r=null!=m?m:l)?r:-1),h=t.useRef(null);function y(e){if(!e.currentTarget.contains(j(R(e.currentTarget))))return;g.current.length>0&&" "!==g.current[0]&&(u.current.typing=!0," "===e.key&&V(e));const n=c.current;if(null==n||["Home","End","Escape","Enter","Tab","ArrowUp","ArrowDown","ArrowLeft","ArrowRight",...v].includes(e.key))return;n.every((e=>{var n,t;return!e||(null==(n=e[0])?void 0:n.toLocaleLowerCase())!==(null==(t=e[1])?void 0:t.toLocaleLowerCase())}))&&g.current===e.key&&(g.current="",b.current=h.current),g.current+=e.key,clearTimeout(p.current),p.current=setTimeout((()=>{g.current="",b.current=h.current,u.current.typing=!1}),d);const t=b.current,r=[...n.slice((null!=t?t:0)+1),...n.slice(0,(null!=t?t:0)+1)],o=f?f(r,g.current):r.find((e=>0===(null==e?void 0:e.toLocaleLowerCase().indexOf(g.current)))),l=o?n.indexOf(o):-1;-1!==l&&(a(l),h.current=l)}return i((()=>{o&&(clearTimeout(p.current),h.current=null,g.current="")}),[o]),i((()=>{var e;o&&""===g.current&&(b.current=null!=(e=null!=m?m:l)?e:-1)}),[o,m,l]),s?{reference:{onKeyDown:y},floating:{onKeyDown:y}}:{}};export{Q as FloatingDelayGroup,Y as FloatingFocusManager,E as FloatingNode,K as FloatingOverlay,P as FloatingPortal,w as FloatingTree,O as safePolygon,_ as useClick,Z as useDelayGroup,J as useDelayGroupContext,ne as useDismiss,I as useFloating,y as useFloatingNodeId,b as useFloatingParentNodeId,D as useFloatingPortalNode,h as useFloatingTree,te as useFocus,z as useHover,m as useId,C as useInteractions,se as useListNavigation,$ as useRole,fe as useTypeahead}; | ||
import{useFloating as e,getOverflowAncestors as n}from"@floating-ui/react-dom";export*from"@floating-ui/react-dom";import*as t from"react";import{useLayoutEffect as r,useEffect as o,useRef as u}from"react";import{createPortal as c}from"react-dom";import{hideOthers as i}from"aria-hidden";var l="undefined"!=typeof document?r:o;function s(){const e=new Map;return{emit(n,t){var r;null==(r=e.get(n))||r.forEach((e=>e(t)))},on(n,t){e.set(n,[...e.get(n)||[],t])},off(n,t){e.set(n,(e.get(n)||[]).filter((e=>e!==t)))}}}let a=!1,f=0;const d=()=>"floating-ui-"+f++;const v=t["useId".toString()],m=null!=v?v:function(){const[e,n]=t.useState((()=>a?d():void 0));return l((()=>{null==e&&n(d())}),[]),t.useEffect((()=>{a||(a=!0)}),[]),e},p=t.createContext(null),g=t.createContext(null),b=()=>{var e,n;return null!=(e=null==(n=t.useContext(p))?void 0:n.id)?e:null},h=()=>t.useContext(g),y=()=>{const e=m(),n=h(),t=b();return l((()=>{const r={id:e,parentId:t};return null==n||n.addNode(r),()=>{null==n||n.removeNode(r)}}),[n,e,t]),e},E=e=>{let{children:n,id:r}=e;const o=b();return t.createElement(p.Provider,{value:t.useMemo((()=>({id:r,parentId:o})),[r,o])},n)},w=e=>{let{children:n}=e;const r=t.useRef([]),o=t.useCallback((e=>{r.current=[...r.current,e]}),[]),u=t.useCallback((e=>{r.current=r.current.filter((n=>n!==e))}),[]),c=t.useState((()=>s()))[0];return t.createElement(g.Provider,{value:t.useMemo((()=>({nodesRef:r,addNode:o,removeNode:u,events:c})),[r,o,u,c])},n)};function R(e){var n;return null!=(n=null==e?void 0:e.ownerDocument)?n:document}function x(e){var n;return null!=(n=R(e).defaultView)?n:window}function L(e){return!!e&&e instanceof x(e).Element}function k(e){return!!e&&e instanceof x(e).HTMLElement}function I(n){let{open:r=!1,onOpenChange:o=(()=>{}),whileElementsMounted:u,placement:c,middleware:i,strategy:a,nodeId:f}=void 0===n?{}:n;const d=h(),v=t.useRef(null),m=t.useRef({}),p=t.useState((()=>s()))[0],g=e({placement:c,middleware:i,strategy:a,whileElementsMounted:u}),b=t.useMemo((()=>({...g.refs,domReference:v})),[g.refs]),y=t.useMemo((()=>({...g,refs:b,dataRef:m,nodeId:f,events:p,open:r,onOpenChange:o})),[g,f,p,r,o,b]);l((()=>{const e=null==d?void 0:d.nodesRef.current.find((e=>e.id===f));e&&(e.context=y)}));const{reference:E}=g,w=t.useCallback((e=>{(L(e)||null===e)&&(y.refs.domReference.current=e),E(e)}),[E,y.refs]);return t.useMemo((()=>({...g,context:y,refs:b,reference:w})),[g,b,y,w])}function T(e,n,t){const r=new Map;return{..."floating"===t&&{tabIndex:-1},...e,...n.map((e=>e?e[t]:null)).concat(e).reduce(((e,n)=>n?(Object.entries(n).forEach((n=>{let[t,o]=n;if(0===t.indexOf("on")){var u;if(r.has(t)||r.set(t,[]),"function"==typeof o)null==(u=r.get(t))||u.push(o);e[t]=function(){for(var e,n=arguments.length,o=new Array(n),u=0;u<n;u++)o[u]=arguments[u];null==(e=r.get(t))||e.forEach((e=>e(...o)))}}else e[t]=o})),e):e),{})}}const C=function(e){return void 0===e&&(e=[]),{getReferenceProps:n=>T(n,e,"reference"),getFloatingProps:n=>T(n,e,"floating"),getItemProps:n=>T(n,e,"item")}};function A(e,n){var t;let r=null!=(t=e.filter((e=>{var t;return e.parentId===n&&(null==(t=e.context)?void 0:t.open)})))?t:[],o=r;for(;o.length;){var u;o=null!=(u=e.filter((e=>{var n;return null==(n=o)?void 0:n.some((n=>{var t;return e.parentId===n.id&&(null==(t=e.context)?void 0:t.open)}))})))?u:[],r=r.concat(o)}return r}function O(e){let n,{restMs:t=0,buffer:r=.5,debug:o=null}=void 0===e?{}:e,u=!1;return e=>{let{x:o,y:c,placement:i,refs:l,onClose:s,nodeId:a,tree:f,leave:d=!1}=e;return function(e){var v,m;function p(){clearTimeout(n),s()}if(clearTimeout(n),e.pointerType&&"mouse"!==e.pointerType)return;const{clientX:g,clientY:b}=e,h="composedPath"in e?e.composedPath()[0]:e.target;if("pointermove"===e.type&&null!=(v=l.domReference.current)&&v.contains(h))return;if(f&&A(f.nodesRef.current,a).some((e=>{let{context:n}=e;return null==n?void 0:n.open})))return;if(null!=(m=l.floating.current)&&m.contains(h)&&!d)return void(u=!0);if(!l.domReference.current||!l.floating.current||null==i||null==o||null==c)return;const y=l.domReference.current.getBoundingClientRect(),E=l.floating.current.getBoundingClientRect(),w=i.split("-")[0],R=o>E.right-E.width/2,x=c>E.bottom-E.height/2;if("top"===w&&c>=y.bottom-1||"bottom"===w&&c<=y.top+1||"left"===w&&o>=y.right-1||"right"===w&&o<=y.left+1)return p();switch(w){case"top":if(g>=E.left&&g<=E.right&&b>=E.top&&b<=y.top+1)return;break;case"bottom":if(g>=E.left&&g<=E.right&&b>=y.bottom-1&&b<=E.bottom)return;break;case"left":if(g>=E.left&&g<=y.left+1&&b>=E.top&&b<=E.bottom)return;break;case"right":if(g>=y.right-1&&g<=E.right&&b>=E.top&&b<=E.bottom)return}if(u)return p();const L=function(e){let[n,t]=e;const o=E.width>y.width,u=E.height>y.height;switch(w){case"top":return[[o?n+r/2:R?n+4*r:n-4*r,t+r+1],[o?n-r/2:R?n+4*r:n-4*r,t+r+1],...[[E.left,R||o?E.bottom-r:E.top],[E.right,R?o?E.bottom-r:E.top:E.bottom-r]]];case"bottom":return[[o?n+r/2:R?n+4*r:n-4*r,t-r],[o?n-r/2:R?n+4*r:n-4*r,t-r],...[[E.left,R||o?E.top+r:E.bottom],[E.right,R?o?E.top+r:E.bottom:E.top+r]]];case"left":{const e=[n+r+1,u?t+r/2:x?t+4*r:t-4*r],o=[n+r+1,u?t-r/2:x?t+4*r:t-4*r];return[...[[x||u?E.right-r:E.left,E.top],[x?u?E.right-r:E.left:E.right-r,E.bottom]],e,o]}case"right":return[[n-r,u?t+r/2:x?t+4*r:t-4*r],[n-r,u?t-r/2:x?t+4*r:t-4*r],...[[x||u?E.left+r:E.right,E.top],[x?u?E.left+r:E.right:E.left+r,E.bottom]]]}}([o,c]);!function(e,n){const[t,r]=e;let o=!1;const u=n.length;for(let e=0,c=u-1;e<u;c=e++){const[u,i]=n[e]||[0,0],[l,s]=n[c]||[0,0];i>=r!=s>=r&&t<=(l-u)*(r-i)/(s-i)+u&&(o=!o)}return o}([g,b],L)?p():t&&(n=setTimeout(s,t))}}}const M="floating-ui-root",D=function(e){let{id:n=M,enabled:r=!0}=void 0===e?{}:e;const[o,u]=t.useState(null);return l((()=>{if(!r)return;const e=document.getElementById(n);if(e)u(e);else{const e=document.createElement("div");e.id=n,u(e),document.body.contains(e)||document.body.appendChild(e)}}),[n,r]),o},P=e=>{let{children:n,id:t=M,root:r=null}=e;const o=D({id:t,enabled:!r});return r?c(n,r):o?c(n,o):null};function S(){return S=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},S.apply(this,arguments)}const F="data-floating-ui-scroll-lock";const K=t.forwardRef((function(e,n){let{lockScroll:r=!1,...o}=e;return l((()=>{var e,n,t,o;if(!r)return;if(document.body.hasAttribute(F))return;document.body.setAttribute(F,"");const u=Math.round(document.documentElement.getBoundingClientRect().left)+document.documentElement.scrollLeft?"paddingLeft":"paddingRight",c=window.innerWidth-document.documentElement.clientWidth;if(!/iP(hone|ad|od)|iOS/.test(function(){const e=navigator.userAgentData;return null!=e&&e.platform?e.platform:navigator.platform}()))return Object.assign(document.body.style,{overflow:"hidden",[u]:c+"px"}),()=>{document.body.removeAttribute(F),Object.assign(document.body.style,{overflow:"",[u]:""})};const i=null!=(e=null==(n=window.visualViewport)?void 0:n.offsetLeft)?e:0,l=null!=(t=null==(o=window.visualViewport)?void 0:o.offsetTop)?t:0,s=window.pageXOffset,a=window.pageYOffset;return Object.assign(document.body.style,{position:"fixed",overflow:"hidden",top:-(a-Math.floor(l))+"px",left:-(s-Math.floor(i))+"px",right:"0",[u]:c+"px"}),()=>{Object.assign(document.body.style,{position:"",overflow:"",top:"",left:"",right:"",[u]:""}),document.body.removeAttribute(F),window.scrollTo(s,a)}}),[r]),t.createElement("div",S({ref:n},o,{style:{position:"fixed",overflow:"auto",top:0,right:0,bottom:0,left:0,...o.style}}))}));function j(e){let n=e.activeElement;for(;null!=(null==(t=n)||null==(r=t.shadowRoot)?void 0:r.activeElement);){var t,r;n=n.shadowRoot.activeElement}return n}const N="input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";function B(e){return k(e)&&e.matches(N)}function V(e){e.preventDefault(),e.stopPropagation()}function U(e){const n=u(e);return l((()=>{n.current=e})),n}function H(e){requestAnimationFrame((()=>{null==e||e.focus()}))}const X=t.forwardRef((function(e,n){return t.createElement("span",S({},e,{ref:n,tabIndex:0,style:{position:"fixed",opacity:"0",pointerEvents:"none",outline:"0"}}))}));function Y(e){let{context:{refs:n,nodeId:r,onOpenChange:o,dataRef:u,events:c},children:l,order:s=["content"],endGuard:a=!0,preventTabbing:f=!1,initialFocus:d=0,returnFocus:v=!0,modal:m=!0}=e;const p=U(s),g=U(o),b=h(),y=t.useCallback((()=>p.current.map((e=>{return"reference"===e?n.domReference.current:n.floating.current&&"floating"===e?n.floating.current:"content"===e?Array.from(null!=(t=null==(r=n.floating.current)?void 0:r.querySelectorAll("select:not([disabled]),a[href],button:not([disabled]),[tabindex],iframe,object,embed,area[href],audio[controls],video[controls],input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])"))?t:[]):null;var t,r})).flat().filter((e=>{if(e===n.floating.current||e===n.domReference.current)return!0;if(k(e)){var t;return"-"!==(null!=(t=e.getAttribute("tabindex"))?t:"0")[0].trim()}}))),[p,n]);t.useEffect((()=>{if(!m)return;const e=0===y().filter((e=>e!==n.floating.current&&e!==n.domReference.current)).length;function t(t){if("Tab"===t.key){(f||e)&&V(t);const r=y(),o="composedPath"in t?t.composedPath()[0]:t.target;"reference"===p.current[0]&&o===n.domReference.current&&(V(t),t.shiftKey?H(r[r.length-1]):H(r[1])),"floating"===p.current[1]&&o===n.floating.current&&t.shiftKey&&(V(t),H(r[0]))}}const r=R(n.floating.current);return r.addEventListener("keydown",t),()=>{r.removeEventListener("keydown",t)}}),[f,m,y,p,n]),t.useEffect((()=>{function e(e){var t,o;const u=e.relatedTarget,c=!(null!=(t=n.floating.current)&&t.contains(u)),i=L(n.domReference.current)&&!n.domReference.current.contains(u),l=b&&A(b.nodesRef.current,r).length>0,s=b&&e.currentTarget===n.domReference.current&&(null==(o=function(e,n){var t;let r=[],o=null==(t=e.find((e=>e.id===n)))?void 0:t.parentId;for(;o;){const n=e.find((e=>e.id===o));o=null==n?void 0:n.parentId,n&&(r=r.concat(n))}return r}(b.nodesRef.current,r))?void 0:o.some((e=>{var n,t;return null==(n=e.context)||null==(t=n.refs.floating.current)?void 0:t.contains(u)})));c&&i&&!l&&!s&&g.current(!1)}const t=n.floating.current,o=n.domReference.current;if(t&&k(o)){let n;return!m&&t.addEventListener("focusout",e),!m&&o.addEventListener("focusout",e),m&&(n=p.current.includes("reference")?i([o,t]):i(t)),()=>{!m&&t.removeEventListener("focusout",e),!m&&o.removeEventListener("focusout",e),null==n||n()}}}),[r,b,m,g,p,u,y,n]),t.useEffect((()=>{if(f)return;let e=v;const t=n.floating.current,r=j(R(t));var o;if("number"==typeof d)H(null!=(o=y()[d])?o:t);else if(k(null==d?void 0:d.current)){var u;H(null!=(u=d.current)?u:t)}function i(){e=!1}return c.on("dismiss",i),()=>{c.off("dismiss",i),e&&k(r)&&H(r)}}),[f,y,d,v,n,c]);const E=()=>{var e;return"combobox"===(null==(e=n.domReference.current)?void 0:e.getAttribute("role"))&&B(n.domReference.current)};return t.createElement(t.Fragment,null,m&&t.createElement(X,{onFocus:e=>{if(E())return;V(e);const n=y();"reference"===s[0]?H(n[0]):H(n[n.length-1])}}),t.cloneElement(l,s.includes("floating")?{tabIndex:0}:{}),m&&a&&t.createElement(X,{onFocus:e=>{E()||(V(e),H(y()[0]))}}))}function q(e){const n=u();return l((()=>{n.current=e}),[e]),n.current}function W(e,n,t){return t&&"mouse"!==t?0:"number"==typeof e?e:null==e?void 0:e[n]}const z=function(e,n){let{enabled:r=!0,delay:o=0,handleClose:u=null,mouseOnly:c=!1,restMs:i=0}=void 0===n?{}:n;const{open:s,onOpenChange:a,dataRef:f,events:d,refs:v}=e,m=h(),p=b(),g=U(a),y=U(u),E=q(s),w=t.useRef(),x=t.useRef(),I=t.useRef(),T=t.useRef(),C=t.useRef(!0),A=t.useRef(!1);t.useEffect((()=>{if(r)return d.on("dismiss",e),()=>{d.off("dismiss",e)};function e(){clearTimeout(x.current),clearTimeout(T.current),C.current=!0}}),[r,d,v]),t.useEffect((()=>{if(!r||!y.current)return;function e(){var e;null!=(e=f.current.openEvent)&&e.type.includes("mouse")&&g.current(!1)}const n=R(v.floating.current).documentElement;return n.addEventListener("mouseleave",e),()=>{n.removeEventListener("mouseleave",e)}}),[v,g,r,y,f]);const O=t.useCallback((function(e){void 0===e&&(e=!0);const n=W(o,"close",w.current);n&&!I.current?(clearTimeout(x.current),x.current=setTimeout((()=>g.current(!1)),n)):e&&(clearTimeout(x.current),g.current(!1))}),[o,g]),M=t.useCallback((()=>{I.current&&(R(v.floating.current).removeEventListener("pointermove",I.current),I.current=void 0)}),[v]),D=t.useCallback((()=>{R(v.floating.current).body.style.pointerEvents="",A.current=!1}),[v]);if(t.useEffect((()=>{if(!r)return;function n(e){if(clearTimeout(x.current),C.current=!1,s||c&&"mouse"!==w.current||i>0&&0===W(o,"open"))return;f.current.openEvent=e;const n=W(o,"open",w.current);n?x.current=setTimeout((()=>{g.current(!0)}),n):g.current(!0)}function t(n){var t,r;if("click"===(null==(t=f.current.openEvent)?void 0:t.type)||"pointerdown"===(null==(r=f.current.openEvent)?void 0:r.type))return;const o=R(v.floating.current);if(clearTimeout(T.current),y.current)return clearTimeout(x.current),I.current&&o.removeEventListener("pointermove",I.current),I.current=y.current({...e,tree:m,x:n.clientX,y:n.clientY,onClose(){M(),O()}}),void o.addEventListener("pointermove",I.current);O()}function u(n){null==y.current||y.current({...e,tree:m,x:n.clientX,y:n.clientY,leave:!0,onClose(){M(),O()}})(n)}const l=v.floating.current,a=v.domReference.current;return L(a)?(s&&a.addEventListener("mouseleave",u),null==l||l.addEventListener("mouseleave",u),a.addEventListener("mousemove",n,{once:!0}),a.addEventListener("mouseenter",n),a.addEventListener("mouseleave",t),()=>{s&&a.removeEventListener("mouseleave",u),null==l||l.removeEventListener("mouseleave",u),a.removeEventListener("mousemove",n),a.removeEventListener("mouseenter",n),a.removeEventListener("mouseleave",t)}):void 0}),[r,O,e,o,y,f,c,g,s,m,i,M,v]),l((()=>{if(r&&s&&y.current){R(v.floating.current).body.style.pointerEvents="none",A.current=!0;const t=v.domReference.current,r=v.floating.current;if(k(t)&&r){var e,n;const o=null==m||null==(e=m.nodesRef.current.find((e=>e.id===p)))||null==(n=e.context)?void 0:n.refs.floating.current;return o&&(o.style.pointerEvents=""),t.style.pointerEvents="auto",r.style.pointerEvents="auto",()=>{t.style.pointerEvents="",r.style.pointerEvents=""}}}}),[r,s,p,v,m,y,f]),l((()=>{E&&!s&&(w.current=void 0,M(),D())})),t.useEffect((()=>()=>{M(),clearTimeout(x.current),clearTimeout(T.current),A.current&&D()}),[M,D]),!r)return{};function P(e){w.current=e.pointerType}return{reference:{onPointerDown:P,onPointerEnter:P,onMouseMove(){s||0===i||(clearTimeout(T.current),T.current=setTimeout((()=>{C.current||a(!0)}),i))}},floating:{onMouseEnter(){clearTimeout(x.current)},onMouseLeave(){O(!1)}}}},G=t.createContext({delay:1e3,initialDelay:1e3,currentId:null,setCurrentId:()=>{},setState:()=>{}}),J=()=>t.useContext(G),Q=e=>{let{children:n,delay:r}=e;const[o,u]=t.useState({delay:r,initialDelay:r,currentId:null}),c=t.useCallback((e=>{u((n=>({...n,currentId:e})))}),[]);return t.createElement(G.Provider,{value:t.useMemo((()=>({...o,setState:u,setCurrentId:c})),[o,u,c])},n)},Z=(e,n)=>{let{open:r,onOpenChange:o}=e,{id:u}=n;const{currentId:c,initialDelay:i,setState:l}=J(),s=U(o);t.useEffect((()=>{c&&s.current&&(l((e=>({...e,delay:{open:1,close:W(i,"close")}}))),c!==u&&s.current(!1))}),[u,s,l,c,i]),t.useEffect((()=>{!r&&c===u&&s.current&&(s.current(!1),l((e=>({...e,delay:i,currentId:null}))))}),[r,l,c,u,s,i])},$=function(e,n){let{open:t}=e,{enabled:r=!0,role:o="dialog"}=void 0===n?{}:n;const u=m(),c=m(),i={id:u,role:o};return r?"tooltip"===o?{reference:{"aria-describedby":t?u:void 0},floating:i}:{reference:{"aria-expanded":t?"true":"false","aria-haspopup":o,"aria-controls":t?u:void 0,..."listbox"===o&&{role:"combobox"},..."menu"===o&&{id:c}},floating:{...i,..."menu"===o&&{"aria-labelledby":c}}}:{}},_=function(e,n){let{open:r,onOpenChange:o,dataRef:u,refs:c}=e,{enabled:i=!0,pointerDown:l=!1,toggle:s=!0,ignoreMouse:a=!1}=void 0===n?{}:n;const f=t.useRef();function d(){var e;return"BUTTON"===(null==(e=c.domReference.current)?void 0:e.tagName)}function v(){return B(c.domReference.current)}return i?{reference:{onPointerDown(e){0===e.button&&(f.current=e.pointerType,"mouse"===f.current&&a||l&&(r?!s||u.current.openEvent&&"pointerdown"!==u.current.openEvent.type||o(!1):o(!0),u.current.openEvent=e.nativeEvent))},onClick(e){l&&f.current?f.current=void 0:"mouse"===f.current&&a||(r?!s||u.current.openEvent&&"click"!==u.current.openEvent.type||o(!1):o(!0),u.current.openEvent=e.nativeEvent)},onKeyDown(e){f.current=void 0,d()||(" "!==e.key||v()||e.preventDefault(),"Enter"===e.key&&(r?s&&o(!1):o(!0)))},onKeyUp(e){d()||v()||" "===e.key&&(r?s&&o(!1):o(!0))}}}:{}};function ee(e,n){if(null==n)return!1;if("composedPath"in e)return e.composedPath().includes(n);const t=e;return null!=t.target&&n.contains(t.target)}const ne=function(e,r){let{open:o,onOpenChange:u,refs:c,events:i,nodeId:l}=e,{enabled:s=!0,escapeKey:a=!0,outsidePointerDown:f=!0,referencePointerDown:d=!1,ancestorScroll:v=!1,bubbles:m=!0}=void 0===r?{}:r;const p=h(),g=U(u),b=t.useCallback((()=>{var e;return null==(e=c.floating.current)?void 0:e.contains(j(R(c.floating.current)))}),[c]);return t.useEffect((()=>{if(!o||!s)return;function e(e){if("Escape"===e.key){if(!m&&!b())return;i.emit("dismiss"),g.current(!1),k(c.domReference.current)&&c.domReference.current.focus()}}function t(e){const n=p&&A(p.nodesRef.current,l).some((n=>{var t;return ee(e,null==(t=n.context)?void 0:t.refs.floating.current)}));ee(e,c.floating.current)||ee(e,c.domReference.current)||n||(m||b())&&(i.emit("dismiss"),g.current(!1))}function r(){g.current(!1)}const u=R(c.floating.current);a&&u.addEventListener("keydown",e),f&&u.addEventListener("mousedown",t);const d=(v?[...L(c.reference.current)?n(c.reference.current):[],...L(c.floating.current)?n(c.floating.current):[]]:[]).filter((e=>{var n;return e!==(null==(n=u.defaultView)?void 0:n.visualViewport)}));return d.forEach((e=>e.addEventListener("scroll",r,{passive:!0}))),()=>{a&&u.removeEventListener("keydown",e),f&&u.removeEventListener("mousedown",t),d.forEach((e=>e.removeEventListener("scroll",r)))}}),[a,f,i,p,l,o,g,v,s,m,b,c]),s?{reference:{onPointerDown(){d&&(i.emit("dismiss"),u(!1))}}}:{}},te=function(e,n){let{open:r,onOpenChange:o,dataRef:u,refs:c,events:i}=e,{enabled:l=!0,keyboardOnly:s=!0}=void 0===n?{}:n;const a=t.useRef(""),f=t.useRef(!1);return t.useEffect((()=>{var e;if(!l)return;const n=R(c.floating.current),t=null!=(e=n.defaultView)?e:window;function o(){a.current&&c.domReference.current===j(n)&&(f.current=!r)}function u(){setTimeout((()=>{f.current=!1,a.current=""}))}return t.addEventListener("focus",u),t.addEventListener("blur",o),()=>{t.removeEventListener("focus",u),t.removeEventListener("blur",o)}}),[c,r,l]),t.useEffect((()=>{if(l)return i.on("dismiss",e),()=>{i.off("dismiss",e)};function e(){f.current=!0}}),[i,l]),l?{reference:{onPointerDown(e){let{pointerType:n}=e;a.current=n,f.current=!(!n||!s)},onFocus(e){var n,t,r;f.current||"focus"===e.type&&"mousedown"===(null==(n=u.current.openEvent)?void 0:n.type)&&null!=(t=c.domReference.current)&&t.contains(null==(r=u.current.openEvent)?void 0:r.target)||(u.current.openEvent=e.nativeEvent,o(!0))},onBlur(e){var n,t;const r=e.relatedTarget;null!=(n=c.floating.current)&&n.contains(r)||null!=(t=c.domReference.current)&&t.contains(r)||(f.current=!1,o(!1))}}}:{}};function re(e,n){return n<0||n>=e.current.length}function oe(e,n){let{startingIndex:t=-1,decrement:r=!1,disabledIndices:o}=void 0===n?{}:n;const u=e.current;let c=t;do{var i,l;c+=r?-1:1}while(c>=0&&c<=u.length-1&&(o?o.includes(c):null==u[c]||(null==(i=u[c])?void 0:i.hasAttribute("disabled"))||"true"===(null==(l=u[c])?void 0:l.getAttribute("aria-disabled"))));return c}function ue(e,n,t){switch(e){case"vertical":return n;case"horizontal":return t;default:return n||t}}function ce(e,n){return ue(n,"ArrowUp"===e||"ArrowDown"===e,"ArrowLeft"===e||"ArrowRight"===e)}function ie(e,n,t){return ue(n,"ArrowDown"===e,t?"ArrowLeft"===e:"ArrowRight"===e)||"Enter"===e||" "==e||""===e}function le(e,n){return oe(e,{disabledIndices:n})}function se(e,n){return oe(e,{decrement:!0,startingIndex:e.current.length,disabledIndices:n})}const ae=function(e,n){let{open:r,onOpenChange:o,refs:u}=e,{listRef:c,activeIndex:i,onNavigate:s,enabled:a=!0,selectedIndex:f=null,allowEscape:d=!1,loop:v=!1,nested:m=!1,rtl:p=!1,virtual:g=!1,focusItemOnOpen:y="auto",focusItemOnHover:E=!0,openOnArrowKeyDown:w=!0,disabledIndices:x=(w?void 0:[]),orientation:L="vertical"}=void 0===n?{listRef:{current:[]},activeIndex:null,onNavigate:()=>{}}:n;const I=b(),T=h(),C=q(r),A=t.useRef(y),O=t.useRef(null!=f?f:-1),M=t.useRef(null),D=U(q(s)),P=U(s),S=U(x),F=t.useRef(!1),K=t.useRef(-1),[N,B]=t.useState(),H=t.useCallback(((e,n)=>{K.current=requestAnimationFrame((()=>{var t,r;g?B(null==(t=e.current[n.current])?void 0:t.id):null==(r=e.current[n.current])||r.focus({preventScroll:!0})}))}),[g]);function X(e){if(F.current=!0,m&&function(e,n,t){return ue(n,t?"ArrowRight"===e:"ArrowLeft"===e,"ArrowUp"===e)}(e.key,L,p))return V(e),o(!1),void(k(u.domReference.current)&&u.domReference.current.focus());const n=O.current,t=le(c,x),i=se(c,x);if("Home"===e.key&&(O.current=t,s(O.current)),"End"===e.key&&(O.current=i,s(O.current)),ce(e.key,L)){if(V(e),r&&!g&&j(e.currentTarget.ownerDocument)===e.currentTarget)return O.current=ie(e.key,L,p)?t:i,void s(O.current);ie(e.key,L,p)?O.current=v?n>=i?d&&n!==c.current.length?-1:t:oe(c,{startingIndex:n,disabledIndices:x}):Math.min(i,oe(c,{startingIndex:n,disabledIndices:x})):O.current=v?n<=t?d&&-1!==n?c.current.length:i:oe(c,{startingIndex:n,decrement:!0,disabledIndices:x}):Math.max(t,oe(c,{startingIndex:n,decrement:!0,disabledIndices:x})),re(c,O.current)?s(null):s(O.current)}}return l((()=>{a&&(!C&&r&&A.current&&null!=f&&P.current(f),C&&!r&&(cancelAnimationFrame(K.current),O.current=-1,null==D.current||D.current(null)))}),[r,C,f,c,P,D,H,a]),l((()=>{if(a&&r)if(null==i){if(null!=f)return;C&&(O.current=-1,H(c,O)),!C&&A.current&&(null!=M.current||!0===A.current&&null==M.current)&&(O.current=null==M.current||ie(M.current,L,p)||m?le(c,S.current):se(c,S.current),P.current(O.current),H(c,O))}else re(c,i)||(O.current=i,H(c,O))}),[r,C,i,f,m,c,P,H,a,d,L,p,g,S]),l((()=>{a&&!r&&C&&null!=f&&k(u.domReference.current)&&u.domReference.current.focus()}),[u,f,r,C,a]),l((()=>{if(a&&!r&&C){var e,n;const t=null==T||null==(e=T.nodesRef.current.find((e=>e.id===I)))||null==(n=e.context)?void 0:n.refs.floating.current;t&&!t.contains(j(R(t)))&&t.focus({preventScroll:!0})}}),[a,r,C,T,I]),l((()=>{M.current=null})),a?{reference:{...g&&r&&null!=i&&{"aria-activedescendant":N},onKeyDown(e){if(F.current=!0,g&&r)return X(e);(0===e.key.indexOf("Arrow")||"Enter"===e.key||" "===e.key||""===e.key)&&(M.current=e.key),m?function(e,n,t){return ue(n,t?"ArrowLeft"===e:"ArrowRight"===e,"ArrowDown"===e)}(e.key,L,p)&&(V(e),r?(O.current=le(c,x),s(O.current)):o(!0)):ce(e.key,L)&&(null!=f&&(O.current=f),V(e),!r&&w?o(!0):X(e),r&&s(O.current))}},floating:{"aria-orientation":"both"===L?void 0:L,...g&&null!=i&&{"aria-activedescendant":N},onKeyDown:X,onPointerMove(){F.current=!1}},item:{onFocus(e){let{currentTarget:n}=e;const t=c.current.indexOf(n);-1!==t&&s(t)},onClick:e=>{let{currentTarget:n}=e;return n.focus({preventScroll:!0})},...E&&{onMouseMove(e){let{currentTarget:n}=e;const t=n;if(t){const e=c.current.indexOf(t);-1!==e&&s(e)}},onMouseLeave(){var e;F.current||(O.current=-1,H(c,O),P.current(null),g||null==(e=u.floating.current)||e.focus({preventScroll:!0}))}}}}:{}},fe=function(e,n){var r;let{open:o,dataRef:u}=e,{listRef:c,activeIndex:i,onMatch:s=(()=>{}),enabled:a=!0,findMatch:f=null,resetMs:d=1e3,ignoreKeys:v=[],selectedIndex:m=null}=void 0===n?{listRef:{current:[]},activeIndex:null}:n;const p=t.useRef(),g=t.useRef(""),b=t.useRef(null!=(r=null!=m?m:i)?r:-1),h=t.useRef(null);function y(e){if(!e.currentTarget.contains(j(R(e.currentTarget))))return;g.current.length>0&&" "!==g.current[0]&&(u.current.typing=!0," "===e.key&&V(e));const n=c.current;if(null==n||["Home","End","Escape","Enter","Tab","ArrowUp","ArrowDown","ArrowLeft","ArrowRight",...v].includes(e.key))return;n.every((e=>{var n,t;return!e||(null==(n=e[0])?void 0:n.toLocaleLowerCase())!==(null==(t=e[1])?void 0:t.toLocaleLowerCase())}))&&g.current===e.key&&(g.current="",b.current=h.current),g.current+=e.key,clearTimeout(p.current),p.current=setTimeout((()=>{g.current="",b.current=h.current,u.current.typing=!1}),d);const t=b.current,r=[...n.slice((null!=t?t:0)+1),...n.slice(0,(null!=t?t:0)+1)],o=f?f(r,g.current):r.find((e=>0===(null==e?void 0:e.toLocaleLowerCase().indexOf(g.current)))),i=o?n.indexOf(o):-1;-1!==i&&(s(i),h.current=i)}return l((()=>{o&&(clearTimeout(p.current),h.current=null,g.current="")}),[o]),l((()=>{var e;o&&""===g.current&&(b.current=null!=(e=null!=m?m:i)?e:-1)}),[o,m,i]),a?{reference:{onKeyDown:y},floating:{onKeyDown:y}}:{}};export{Q as FloatingDelayGroup,Y as FloatingFocusManager,E as FloatingNode,K as FloatingOverlay,P as FloatingPortal,w as FloatingTree,O as safePolygon,_ as useClick,Z as useDelayGroup,J as useDelayGroupContext,ne as useDismiss,I as useFloating,y as useFloatingNodeId,b as useFloatingParentNodeId,D as useFloatingPortalNode,h as useFloatingTree,te as useFocus,z as useHover,m as useId,C as useInteractions,ae as useListNavigation,$ as useRole,fe as useTypeahead}; |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@floating-ui/react-dom"),require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","@floating-ui/react-dom","react","react-dom"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).FloatingUIReactDOM={},e.FloatingUIReactDOM,e.React,e.ReactDOM)}(this,(function(e,t,n,r){"use strict";function o(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var u=o(n),c="undefined"!=typeof document?n.useLayoutEffect:n.useEffect;function i(){const e=new Map;return{emit(t,n){var r;null==(r=e.get(t))||r.forEach((e=>e(n)))},on(t,n){e.set(t,[...e.get(t)||[],n])},off(t,n){e.set(t,(e.get(t)||[]).filter((e=>e!==n)))}}}let l=!1,a=0;const s=()=>"floating-ui-"+a++;const f=u["useId".toString()],d=null!=f?f:function(){const[e,t]=u.useState((()=>l?s():void 0));return c((()=>{null==e&&t(s())}),[]),u.useEffect((()=>{l||(l=!0)}),[]),e},v=u.createContext(null),m=u.createContext(null),p=()=>{var e,t;return null!=(e=null==(t=u.useContext(v))?void 0:t.id)?e:null},g=()=>u.useContext(m);function b(e){var t;return null!=(t=null==e?void 0:e.ownerDocument)?t:document}function y(e){var t;return null!=(t=b(e).defaultView)?t:window}function h(e){return!!e&&e instanceof y(e).Element}function E(e){return!!e&&e instanceof y(e).HTMLElement}function w(e,t,n){const r=new Map;return{..."floating"===n&&{tabIndex:-1},...e,...t.map((e=>e?e[n]:null)).concat(e).reduce(((e,t)=>t?(Object.entries(t).forEach((t=>{let[n,o]=t;if(0===n.indexOf("on")){var u;if(r.has(n)||r.set(n,[]),"function"==typeof o)null==(u=r.get(n))||u.push(o);e[n]=function(){for(var e,t=arguments.length,o=new Array(t),u=0;u<t;u++)o[u]=arguments[u];null==(e=r.get(n))||e.forEach((e=>e(...o)))}}else e[n]=o})),e):e),{})}}function R(e,t){var n;let r=null!=(n=e.filter((e=>{var n;return e.parentId===t&&(null==(n=e.context)?void 0:n.open)})))?n:[],o=r;for(;o.length;){var u;o=null!=(u=e.filter((e=>{var t;return null==(t=o)?void 0:t.some((t=>{var n;return e.parentId===t.id&&(null==(n=e.context)?void 0:n.open)}))})))?u:[],r=r.concat(o)}return r}const x="floating-ui-root",k=function(e){let{id:t=x,enabled:n=!0}=void 0===e?{}:e;const[r,o]=u.useState(null);return c((()=>{if(!n)return;const e=document.getElementById(t);if(e)o(e);else{const e=document.createElement("div");e.id=t,o(e),document.body.contains(e)||document.body.appendChild(e)}}),[t,n]),r};function I(){return I=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},I.apply(this,arguments)}const O="data-floating-ui-scroll-lock";const T=u.forwardRef((function(e,t){let{lockScroll:n=!1,...r}=e;return c((()=>{var e,t,r,o;if(!n)return;if(document.body.hasAttribute(O))return;document.body.setAttribute(O,"");const u=Math.round(document.documentElement.getBoundingClientRect().left)+document.documentElement.scrollLeft?"paddingLeft":"paddingRight",c=window.innerWidth-document.documentElement.clientWidth;if(!/iP(hone|ad|od)|iOS/.test(function(){const e=navigator.userAgentData;return null!=e&&e.platform?e.platform:navigator.platform}()))return Object.assign(document.body.style,{overflow:"hidden",[u]:c+"px"}),()=>{document.body.removeAttribute(O),Object.assign(document.body.style,{overflow:"",[u]:""})};const i=null!=(e=null==(t=window.visualViewport)?void 0:t.offsetLeft)?e:0,l=null!=(r=null==(o=window.visualViewport)?void 0:o.offsetTop)?r:0,a=window.pageXOffset,s=window.pageYOffset;return Object.assign(document.body.style,{position:"fixed",overflow:"hidden",top:-(s-Math.floor(l))+"px",left:-(a-Math.floor(i))+"px",right:"0",[u]:c+"px"}),()=>{Object.assign(document.body.style,{position:"",overflow:"",top:"",left:"",right:"",[u]:""}),document.body.removeAttribute(O),window.scrollTo(a,s)}}),[n]),u.createElement("div",I({ref:t},r,{style:{position:"fixed",overflow:"auto",top:0,right:0,bottom:0,left:0,...r.style}}))}));var L=new WeakMap,C=new WeakMap,M={},A=0,P=function(e,t,n){void 0===t&&(t=function(e){return"undefined"==typeof document?null:(Array.isArray(e)?e[0]:e).ownerDocument.body}(e)),void 0===n&&(n="data-aria-hidden");var r=Array.isArray(e)?e:[e];M[n]||(M[n]=new WeakMap);var o=M[n],u=[],c=new Set,i=function(e){e&&!c.has(e)&&(c.add(e),i(e.parentNode))};r.forEach(i);var l=function(e){!e||r.indexOf(e)>=0||Array.prototype.forEach.call(e.children,(function(e){if(c.has(e))l(e);else{var t=e.getAttribute("aria-hidden"),r=null!==t&&"false"!==t,i=(L.get(e)||0)+1,a=(o.get(e)||0)+1;L.set(e,i),o.set(e,a),u.push(e),1===i&&r&&C.set(e,!0),1===a&&e.setAttribute(n,"true"),r||e.setAttribute("aria-hidden","true")}}))};return l(t),c.clear(),A++,function(){u.forEach((function(e){var t=L.get(e)-1,r=o.get(e)-1;L.set(e,t),o.set(e,r),t||(C.has(e)||e.removeAttribute("aria-hidden"),C.delete(e)),r||e.removeAttribute(n)})),--A||(L=new WeakMap,L=new WeakMap,C=new WeakMap,M={})}};function D(e){let t=e.activeElement;for(;null!=(null==(n=t)||null==(r=n.shadowRoot)?void 0:r.activeElement);){var n,r;t=t.shadowRoot.activeElement}return t}const F="input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";function S(e){return E(e)&&e.matches(F)}function j(e){e.preventDefault(),e.stopPropagation()}function N(e){const t=n.useRef(e);return c((()=>{t.current=e})),t}function K(e){requestAnimationFrame((()=>{null==e||e.focus()}))}const W=u.forwardRef((function(e,t){return u.createElement("span",I({},e,{ref:t,tabIndex:0,style:{position:"fixed",opacity:"0",pointerEvents:"none",outline:"0"}}))}));function q(e){const t=n.useRef();return c((()=>{t.current=e}),[e]),t.current}function B(e,t,n){return n&&"mouse"!==n?0:"number"==typeof e?e:null==e?void 0:e[t]}const U=u.createContext({delay:1e3,initialDelay:1e3,currentId:null,setCurrentId:()=>{},setState:()=>{}}),V=()=>u.useContext(U);function H(e,t){if(null==t)return!1;if("composedPath"in e)return e.composedPath().includes(t);const n=e;return null!=n.target&&t.contains(n.target)}const G="ArrowUp",X="ArrowDown",Y="ArrowLeft",_="ArrowRight";function z(e,t){return t<0||t>=e.current.length}function J(e,t){let{startingIndex:n=-1,decrement:r=!1,disabledIndices:o}=void 0===t?{}:t;const u=e.current;let c=n;do{var i,l;c+=r?-1:1}while(c>=0&&c<=u.length-1&&(o?o.includes(c):null==u[c]||(null==(i=u[c])?void 0:i.hasAttribute("disabled"))||"true"===(null==(l=u[c])?void 0:l.getAttribute("aria-disabled"))));return c}function Q(e,t,n){switch(e){case"vertical":return t;case"horizontal":return n;default:return t||n}}function Z(e,t){return Q(t,e===G||e===X,e===Y||e===_)}function $(e,t,n){return Q(t,e===X,n?e===Y:e===_)||"Enter"===e||" "==e||""===e}function ee(e,t){return J(e,{disabledIndices:t})}function te(e,t){return J(e,{decrement:!0,startingIndex:e.current.length,disabledIndices:t})}e.FloatingDelayGroup=e=>{let{children:t,delay:n}=e;const[r,o]=u.useState({delay:n,initialDelay:n,currentId:null}),c=u.useCallback((e=>{o((t=>({...t,currentId:e})))}),[]);return u.createElement(U.Provider,{value:u.useMemo((()=>({...r,setState:o,setCurrentId:c})),[r,o,c])},t)},e.FloatingFocusManager=function(e){let{context:{refs:t,nodeId:n,onOpenChange:r,dataRef:o},children:c,order:i=["content"],endGuard:l=!0,preventTabbing:a=!1,initialFocus:s=0,returnFocus:f=!0,modal:d=!0}=e;const v=N(i),m=N(r),p=g(),y=u.useCallback((()=>v.current.map((e=>{return"reference"===e?t.domReference.current:t.floating.current&&"floating"===e?t.floating.current:"content"===e?Array.from(null!=(n=null==(r=t.floating.current)?void 0:r.querySelectorAll("select:not([disabled]),a[href],button:not([disabled]),[tabindex],iframe,object,embed,area[href],audio[controls],video[controls],input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])"))?n:[]):null;var n,r})).flat().filter((e=>{if(e===t.floating.current||e===t.domReference.current)return!0;if(E(e)){var n;return"-"!==(null!=(n=e.getAttribute("tabindex"))?n:"0")[0].trim()}}))),[v,t]);u.useEffect((()=>{if(!d)return;const e=0===y().filter((e=>e!==t.floating.current&&e!==t.domReference.current)).length;function n(n){if("Tab"===n.key){(a||e)&&j(n);const r=y(),o="composedPath"in n?n.composedPath()[0]:n.target;"reference"===v.current[0]&&o===t.domReference.current&&(j(n),n.shiftKey?K(r[r.length-1]):K(r[1])),"floating"===v.current[1]&&o===t.floating.current&&n.shiftKey&&(j(n),K(r[0]))}}const r=b(t.floating.current);return r.addEventListener("keydown",n),()=>{r.removeEventListener("keydown",n)}}),[a,d,y,v,t]),u.useEffect((()=>{function e(e){var r,o;const u=e.relatedTarget,c=!(null!=(r=t.floating.current)&&r.contains(u)),i=h(t.domReference.current)&&!t.domReference.current.contains(u),l=p&&R(p.nodesRef.current,n).length>0,a=p&&e.currentTarget===t.domReference.current&&(null==(o=function(e,t){var n;let r=[],o=null==(n=e.find((e=>e.id===t)))?void 0:n.parentId;for(;o;){const t=e.find((e=>e.id===o));o=null==t?void 0:t.parentId,t&&(r=r.concat(t))}return r}(p.nodesRef.current,n))?void 0:o.some((e=>{var t,n;return null==(t=e.context)||null==(n=t.refs.floating.current)?void 0:n.contains(u)})));c&&i&&!l&&!a&&m.current(!1)}const r=t.floating.current,o=t.domReference.current;if(r&&E(o)){let t;return!d&&r.addEventListener("focusout",e),!d&&o.addEventListener("focusout",e),d&&(t=v.current.includes("reference")?P([o,r]):P(r)),()=>{!d&&r.removeEventListener("focusout",e),!d&&o.removeEventListener("focusout",e),null==t||t()}}}),[n,p,d,m,v,o,y,t]),u.useEffect((()=>{if(a)return;const e=t.floating.current,n=D(b(e));var r;if("number"==typeof s)K(null!=(r=y()[s])?r:e);else if(E(null==s?void 0:s.current)){var o;K(null!=(o=s.current)?o:e)}return()=>{f&&E(n)&&K(n)}}),[a,y,s,f,t]);const w=()=>{var e;return"combobox"===(null==(e=t.domReference.current)?void 0:e.getAttribute("role"))&&S(t.domReference.current)};return u.createElement(u.Fragment,null,d&&u.createElement(W,{onFocus:e=>{if(w())return;j(e);const t=y();"reference"===i[0]?K(t[0]):K(t[t.length-1])}}),u.cloneElement(c,i.includes("floating")?{tabIndex:0}:{}),d&&l&&u.createElement(W,{onFocus:e=>{w()||(j(e),K(y()[0]))}}))},e.FloatingNode=e=>{let{children:t,id:n}=e;const r=p();return u.createElement(v.Provider,{value:u.useMemo((()=>({id:n,parentId:r})),[n,r])},t)},e.FloatingOverlay=T,e.FloatingPortal=e=>{let{children:t,id:n=x,root:o=null}=e;const u=k({id:n,enabled:!o});return o?r.createPortal(t,o):u?r.createPortal(t,u):null},e.FloatingTree=e=>{let{children:t}=e;const n=u.useRef([]),r=u.useCallback((e=>{n.current=[...n.current,e]}),[]),o=u.useCallback((e=>{n.current=n.current.filter((t=>t!==e))}),[]),c=u.useState((()=>i()))[0];return u.createElement(m.Provider,{value:u.useMemo((()=>({nodesRef:n,addNode:r,removeNode:o,events:c})),[n,r,o,c])},t)},e.safePolygon=function(e){let t,{restMs:n=0,buffer:r=.5,debug:o=null}=void 0===e?{}:e,u=!1;return e=>{let{x:o,y:c,placement:i,refs:l,onClose:a,nodeId:s,tree:f,leave:d=!1}=e;return function(e){var v,m;function p(){clearTimeout(t),a()}if(clearTimeout(t),e.pointerType&&"mouse"!==e.pointerType)return;const{clientX:g,clientY:b}=e,y="composedPath"in e?e.composedPath()[0]:e.target;if("pointermove"===e.type&&null!=(v=l.domReference.current)&&v.contains(y))return;if(f&&R(f.nodesRef.current,s).some((e=>{let{context:t}=e;return null==t?void 0:t.open})))return;if(null!=(m=l.floating.current)&&m.contains(y)&&!d)return void(u=!0);if(!l.domReference.current||!l.floating.current||null==i||null==o||null==c)return;const h=l.domReference.current.getBoundingClientRect(),E=l.floating.current.getBoundingClientRect(),w=i.split("-")[0],x=o>E.right-E.width/2,k=c>E.bottom-E.height/2;if("top"===w&&c>=h.bottom-1||"bottom"===w&&c<=h.top+1||"left"===w&&o>=h.right-1||"right"===w&&o<=h.left+1)return p();switch(w){case"top":if(g>=E.left&&g<=E.right&&b>=E.top&&b<=h.top+1)return;break;case"bottom":if(g>=E.left&&g<=E.right&&b>=h.bottom-1&&b<=E.bottom)return;break;case"left":if(g>=E.left&&g<=h.left+1&&b>=E.top&&b<=E.bottom)return;break;case"right":if(g>=h.right-1&&g<=E.right&&b>=E.top&&b<=E.bottom)return}if(u)return p();const I=function(e){let[t,n]=e;const o=E.width>h.width,u=E.height>h.height;switch(w){case"top":return[[o?t+r/2:x?t+4*r:t-4*r,n+r+1],[o?t-r/2:x?t+4*r:t-4*r,n+r+1],...[[E.left,x||o?E.bottom-r:E.top],[E.right,x?o?E.bottom-r:E.top:E.bottom-r]]];case"bottom":return[[o?t+r/2:x?t+4*r:t-4*r,n-r],[o?t-r/2:x?t+4*r:t-4*r,n-r],...[[E.left,x||o?E.top+r:E.bottom],[E.right,x?o?E.top+r:E.bottom:E.top+r]]];case"left":{const e=[t+r+1,u?n+r/2:k?n+4*r:n-4*r],o=[t+r+1,u?n-r/2:k?n+4*r:n-4*r];return[...[[k||u?E.right-r:E.left,E.top],[k?u?E.right-r:E.left:E.right-r,E.bottom]],e,o]}case"right":return[[t-r,u?n+r/2:k?n+4*r:n-4*r],[t-r,u?n-r/2:k?n+4*r:n-4*r],...[[k||u?E.left+r:E.right,E.top],[k?u?E.left+r:E.right:E.left+r,E.bottom]]]}}([o,c]);!function(e,t){const[n,r]=e;let o=!1;const u=t.length;for(let e=0,c=u-1;e<u;c=e++){const[u,i]=t[e]||[0,0],[l,a]=t[c]||[0,0];i>=r!=a>=r&&n<=(l-u)*(r-i)/(a-i)+u&&(o=!o)}return o}([g,b],I)?p():n&&(t=setTimeout(a,n))}}},e.useClick=function(e,t){let{open:n,onOpenChange:r,dataRef:o,refs:c}=e,{enabled:i=!0,pointerDown:l=!1,toggle:a=!0,ignoreMouse:s=!1}=void 0===t?{}:t;const f=u.useRef();function d(){var e;return"BUTTON"===(null==(e=c.domReference.current)?void 0:e.tagName)}function v(){return S(c.domReference.current)}return i?{reference:{onPointerDown(e){0===e.button&&(f.current=e.pointerType,"mouse"===f.current&&s||l&&(n?!a||o.current.openEvent&&"pointerdown"!==o.current.openEvent.type||r(!1):r(!0),o.current.openEvent=e.nativeEvent))},onClick(e){l&&f.current?f.current=void 0:"mouse"===f.current&&s||(n?!a||o.current.openEvent&&"click"!==o.current.openEvent.type||r(!1):r(!0),o.current.openEvent=e.nativeEvent)},onKeyDown(e){f.current=void 0,d()||(" "!==e.key||v()||e.preventDefault(),"Enter"===e.key&&(n?a&&r(!1):r(!0)))},onKeyUp(e){d()||v()||" "===e.key&&(n?a&&r(!1):r(!0))}}}:{}},e.useDelayGroup=(e,t)=>{let{open:n,onOpenChange:r}=e,{id:o}=t;const{currentId:c,initialDelay:i,setState:l}=V(),a=N(r);u.useEffect((()=>{c&&a.current&&(l((e=>({...e,delay:{open:1,close:B(i,"close")}}))),c!==o&&a.current(!1))}),[o,a,l,c,i]),u.useEffect((()=>{!n&&c===o&&a.current&&(a.current(!1),l((e=>({...e,delay:i,currentId:null}))))}),[n,l,c,o,a,i])},e.useDelayGroupContext=V,e.useDismiss=function(e,n){let{open:r,onOpenChange:o,refs:c,events:i,nodeId:l}=e,{enabled:a=!0,escapeKey:s=!0,outsidePointerDown:f=!0,referencePointerDown:d=!1,ancestorScroll:v=!1,bubbles:m=!0}=void 0===n?{}:n;const p=g(),y=N(o),w=u.useCallback((()=>{var e;return null==(e=c.floating.current)?void 0:e.contains(D(b(c.floating.current)))}),[c]),x=u.useCallback((()=>{E(c.domReference.current)&&c.domReference.current.focus()}),[c]);return u.useEffect((()=>{if(!r||!a)return;function e(e){if("Escape"===e.key){if(!m&&!w())return;i.emit("dismiss"),y.current(!1),x()}}function n(e){const t=p&&R(p.nodesRef.current,l).some((t=>{var n;return H(e,null==(n=t.context)?void 0:n.refs.floating.current)}));H(e,c.floating.current)||H(e,c.domReference.current)||t||(m||w())&&(i.emit("dismiss"),y.current(!1),x())}function o(){y.current(!1)}const u=b(c.floating.current);s&&u.addEventListener("keydown",e),f&&u.addEventListener("mousedown",n);const d=(v?[...h(c.reference.current)?t.getOverflowAncestors(c.reference.current):[],...h(c.floating.current)?t.getOverflowAncestors(c.floating.current):[]]:[]).filter((e=>{var t;return e!==(null==(t=u.defaultView)?void 0:t.visualViewport)}));return d.forEach((e=>e.addEventListener("scroll",o,{passive:!0}))),()=>{s&&u.removeEventListener("keydown",e),f&&u.removeEventListener("mousedown",n),d.forEach((e=>e.removeEventListener("scroll",o)))}}),[s,f,i,p,l,r,y,x,v,a,m,w,c]),a?{reference:{onPointerDown(){d&&(i.emit("dismiss"),o(!1))}}}:{}},e.useFloating=function(e){let{open:n=!1,onOpenChange:r=(()=>{}),whileElementsMounted:o,placement:l,middleware:a,strategy:s,nodeId:f}=void 0===e?{}:e;const d=g(),v=u.useRef(null),m=u.useRef({}),p=u.useState((()=>i()))[0],b=t.useFloating({placement:l,middleware:a,strategy:s,whileElementsMounted:o}),y=u.useMemo((()=>({...b.refs,domReference:v})),[b.refs]),E=u.useMemo((()=>({...b,refs:y,dataRef:m,nodeId:f,events:p,open:n,onOpenChange:r})),[b,f,p,n,r,y]);c((()=>{const e=null==d?void 0:d.nodesRef.current.find((e=>e.id===f));e&&(e.context=E)}));const{reference:w}=b,R=u.useCallback((e=>{(h(e)||null===e)&&(E.refs.domReference.current=e),w(e)}),[w,E.refs]);return u.useMemo((()=>({...b,context:E,refs:y,reference:R})),[b,y,E,R])},e.useFloatingNodeId=()=>{const e=d(),t=g(),n=p();return c((()=>{const r={id:e,parentId:n};return null==t||t.addNode(r),()=>{null==t||t.removeNode(r)}}),[t,e,n]),e},e.useFloatingParentNodeId=p,e.useFloatingPortalNode=k,e.useFloatingTree=g,e.useFocus=function(e,t){let{open:n,onOpenChange:r,dataRef:o,refs:c,events:i}=e,{enabled:l=!0,keyboardOnly:a=!0}=void 0===t?{}:t;const s=u.useRef(""),f=u.useRef(!1);return u.useEffect((()=>{var e;if(!l)return;const t=b(c.floating.current),r=null!=(e=t.defaultView)?e:window;function o(){s.current&&c.domReference.current===D(t)&&(f.current=!n)}function u(){setTimeout((()=>{f.current=!1,s.current=""}))}return r.addEventListener("focus",u),r.addEventListener("blur",o),()=>{r.removeEventListener("focus",u),r.removeEventListener("blur",o)}}),[c,n,l]),u.useEffect((()=>{if(l)return i.on("dismiss",e),()=>{i.off("dismiss",e)};function e(){f.current=!0}}),[i,l]),l?{reference:{onPointerDown(e){let{pointerType:t}=e;s.current=t,f.current=!(!t||!a)},onFocus(e){var t,n,u;f.current||"focus"===e.type&&"mousedown"===(null==(t=o.current.openEvent)?void 0:t.type)&&null!=(n=c.domReference.current)&&n.contains(null==(u=o.current.openEvent)?void 0:u.target)||(o.current.openEvent=e.nativeEvent,r(!0))},onBlur(e){var t,n;const o=e.relatedTarget;null!=(t=c.floating.current)&&t.contains(o)||null!=(n=c.domReference.current)&&n.contains(o)||(f.current=!1,r(!1))}}}:{}},e.useHover=function(e,t){let{enabled:n=!0,delay:r=0,handleClose:o=null,mouseOnly:i=!1,restMs:l=0}=void 0===t?{}:t;const{open:a,onOpenChange:s,dataRef:f,events:d,refs:v}=e,m=g(),y=p(),w=N(s),R=N(o),x=q(a),k=u.useRef(),I=u.useRef(),O=u.useRef(),T=u.useRef(),L=u.useRef(!0),C=u.useRef(!1);u.useEffect((()=>{if(n)return d.on("dismiss",e),()=>{d.off("dismiss",e)};function e(){clearTimeout(I.current),clearTimeout(T.current),L.current=!0}}),[n,d,v]),u.useEffect((()=>{if(!n||!R.current)return;function e(){var e;null!=(e=f.current.openEvent)&&e.type.includes("mouse")&&w.current(!1)}const t=b(v.floating.current).documentElement;return t.addEventListener("mouseleave",e),()=>{t.removeEventListener("mouseleave",e)}}),[v,w,n,R,f]);const M=u.useCallback((function(e){void 0===e&&(e=!0);const t=B(r,"close",k.current);t&&!O.current?(clearTimeout(I.current),I.current=setTimeout((()=>w.current(!1)),t)):e&&(clearTimeout(I.current),w.current(!1))}),[r,w]),A=u.useCallback((()=>{O.current&&(b(v.floating.current).removeEventListener("pointermove",O.current),O.current=void 0)}),[v]),P=u.useCallback((()=>{b(v.floating.current).body.style.pointerEvents="",C.current=!1}),[v]);if(u.useEffect((()=>{if(!n)return;function t(e){if(clearTimeout(I.current),L.current=!1,a||i&&"mouse"!==k.current||l>0&&0===B(r,"open"))return;f.current.openEvent=e;const t=B(r,"open",k.current);t?I.current=setTimeout((()=>{w.current(!0)}),t):w.current(!0)}function o(t){var n,r;if("click"===(null==(n=f.current.openEvent)?void 0:n.type)||"pointerdown"===(null==(r=f.current.openEvent)?void 0:r.type))return;const o=b(v.floating.current);if(clearTimeout(T.current),R.current)return clearTimeout(I.current),O.current&&o.removeEventListener("pointermove",O.current),O.current=R.current({...e,tree:m,x:t.clientX,y:t.clientY,onClose(){A(),M()}}),void o.addEventListener("pointermove",O.current);M()}function u(t){null==R.current||R.current({...e,tree:m,x:t.clientX,y:t.clientY,leave:!0,onClose(){A(),M()}})(t)}const c=v.floating.current,s=v.domReference.current;return h(s)?(a&&s.addEventListener("mouseleave",u),null==c||c.addEventListener("mouseleave",u),s.addEventListener("mousemove",t,{once:!0}),s.addEventListener("mouseenter",t),s.addEventListener("mouseleave",o),()=>{a&&s.removeEventListener("mouseleave",u),null==c||c.removeEventListener("mouseleave",u),s.removeEventListener("mousemove",t),s.removeEventListener("mouseenter",t),s.removeEventListener("mouseleave",o)}):void 0}),[n,M,e,r,R,f,i,w,a,m,l,A,v]),c((()=>{if(n&&a&&R.current){b(v.floating.current).body.style.pointerEvents="none",C.current=!0;const n=v.domReference.current,r=v.floating.current;if(E(n)&&r){var e,t;const o=null==m||null==(e=m.nodesRef.current.find((e=>e.id===y)))||null==(t=e.context)?void 0:t.refs.floating.current;return o&&(o.style.pointerEvents=""),n.style.pointerEvents="auto",r.style.pointerEvents="auto",()=>{n.style.pointerEvents="",r.style.pointerEvents=""}}}}),[n,a,y,v,m,R,f]),c((()=>{x&&!a&&(k.current=void 0,A(),P())})),u.useEffect((()=>()=>{A(),clearTimeout(I.current),clearTimeout(T.current),C.current&&P()}),[A,P]),!n)return{};function D(e){k.current=e.pointerType}return{reference:{onPointerDown:D,onPointerEnter:D,onMouseMove(){a||0===l||(clearTimeout(T.current),T.current=setTimeout((()=>{L.current||s(!0)}),l))}},floating:{onMouseEnter(){clearTimeout(I.current)},onMouseLeave(){M(!1)}}}},e.useId=d,e.useInteractions=function(e){return void 0===e&&(e=[]),{getReferenceProps:t=>w(t,e,"reference"),getFloatingProps:t=>w(t,e,"floating"),getItemProps:t=>w(t,e,"item")}},e.useListNavigation=function(e,t){let{open:n,onOpenChange:r,refs:o}=e,{listRef:i,activeIndex:l,onNavigate:a,enabled:s=!0,selectedIndex:f=null,allowEscape:d=!1,loop:v=!1,nested:m=!1,rtl:y=!1,virtual:h=!1,focusItemOnOpen:w="auto",focusItemOnHover:R=!0,openOnArrowKeyDown:x=!0,disabledIndices:k=(x?void 0:[]),orientation:I="vertical"}=void 0===t?{listRef:{current:[]},activeIndex:null,onNavigate:()=>{}}:t;const O=p(),T=g(),L=q(n),C=u.useRef(w),M=u.useRef(null!=f?f:-1),A=u.useRef(null),P=N(q(a)),F=N(a),S=N(k),K=u.useRef(!1),W=u.useRef(-1),[B,U]=u.useState(),V=u.useCallback(((e,t)=>{W.current=requestAnimationFrame((()=>{var n,r;h?U(null==(n=e.current[t.current])?void 0:n.id):null==(r=e.current[t.current])||r.focus({preventScroll:!0})}))}),[h]);function H(e){if(K.current=!0,m&&function(e,t,n){return Q(t,n?e===_:e===Y,e===G)}(e.key,I,y))return j(e),r(!1),void(E(o.domReference.current)&&o.domReference.current.focus());const t=M.current,u=ee(i,k),c=te(i,k);if("Home"===e.key&&(M.current=u,a(M.current)),"End"===e.key&&(M.current=c,a(M.current)),Z(e.key,I)){if(j(e),n&&!h&&D(e.currentTarget.ownerDocument)===e.currentTarget)return M.current=$(e.key,I,y)?u:c,void a(M.current);$(e.key,I,y)?M.current=v?t>=c?d&&t!==i.current.length?-1:u:J(i,{startingIndex:t,disabledIndices:k}):Math.min(c,J(i,{startingIndex:t,disabledIndices:k})):M.current=v?t<=u?d&&-1!==t?i.current.length:c:J(i,{startingIndex:t,decrement:!0,disabledIndices:k}):Math.max(u,J(i,{startingIndex:t,decrement:!0,disabledIndices:k})),z(i,M.current)?a(null):a(M.current)}}return c((()=>{s&&(!L&&n&&C.current&&null!=f&&F.current(f),L&&!n&&(cancelAnimationFrame(W.current),M.current=-1,null==P.current||P.current(null)))}),[n,L,f,i,F,P,V,s]),c((()=>{if(s&&n)if(null==l){if(null!=f)return;L&&(M.current=-1,V(i,M)),!L&&C.current&&(null!=A.current||!0===C.current&&null==A.current)&&(M.current=null==A.current||$(A.current,I,y)||m?ee(i,S.current):te(i,S.current),F.current(M.current),V(i,M))}else z(i,l)||(M.current=l,V(i,M))}),[n,L,l,f,m,i,F,V,s,d,I,y,h,S]),c((()=>{s&&!n&&L&&null!=f&&E(o.domReference.current)&&o.domReference.current.focus()}),[o,f,n,L,s]),c((()=>{if(s&&!n&&L){var e,t;const n=null==T||null==(e=T.nodesRef.current.find((e=>e.id===O)))||null==(t=e.context)?void 0:t.refs.floating.current;n&&!n.contains(D(b(n)))&&n.focus({preventScroll:!0})}}),[s,n,L,T,O]),c((()=>{A.current=null})),s?{reference:{...h&&n&&null!=l&&{"aria-activedescendant":B},onKeyDown(e){if(K.current=!0,h&&n)return H(e);(0===e.key.indexOf("Arrow")||"Enter"===e.key||" "===e.key||""===e.key)&&(A.current=e.key),m?function(e,t,n){return Q(t,n?e===Y:e===_,e===X)}(e.key,I,y)&&(j(e),n?(M.current=ee(i,k),a(M.current)):r(!0)):Z(e.key,I)&&(null!=f&&(M.current=f),j(e),!n&&x?r(!0):H(e),n&&a(M.current))}},floating:{"aria-orientation":"both"===I?void 0:I,...h&&null!=l&&{"aria-activedescendant":B},onKeyDown:H,onPointerMove(){K.current=!1}},item:{onFocus(e){let{currentTarget:t}=e;const n=i.current.indexOf(t);-1!==n&&a(n)},onClick:e=>{let{currentTarget:t}=e;return t.focus({preventScroll:!0})},...R&&{onMouseMove(e){let{currentTarget:t}=e;const n=t;if(n){const e=i.current.indexOf(n);-1!==e&&a(e)}},onMouseLeave(){var e;K.current||(M.current=-1,V(i,M),F.current(null),h||null==(e=o.floating.current)||e.focus({preventScroll:!0}))}}}}:{}},e.useRole=function(e,t){let{open:n}=e,{enabled:r=!0,role:o="dialog"}=void 0===t?{}:t;const u=d(),c=d(),i={id:u,role:o};return r?"tooltip"===o?{reference:{"aria-describedby":n?u:void 0},floating:i}:{reference:{"aria-expanded":n?"true":"false","aria-haspopup":o,"aria-controls":n?u:void 0,..."listbox"===o&&{role:"combobox"},..."menu"===o&&{id:c}},floating:{...i,..."menu"===o&&{"aria-labelledby":c}}}:{}},e.useTypeahead=function(e,t){var n;let{open:r,dataRef:o}=e,{listRef:i,activeIndex:l,onMatch:a=(()=>{}),enabled:s=!0,findMatch:f=null,resetMs:d=1e3,ignoreKeys:v=[],selectedIndex:m=null}=void 0===t?{listRef:{current:[]},activeIndex:null}:t;const p=u.useRef(),g=u.useRef(""),y=u.useRef(null!=(n=null!=m?m:l)?n:-1),h=u.useRef(null);function E(e){if(!e.currentTarget.contains(D(b(e.currentTarget))))return;g.current.length>0&&" "!==g.current[0]&&(o.current.typing=!0," "===e.key&&j(e));const t=i.current;if(null==t||["Home","End","Escape","Enter","Tab","ArrowUp","ArrowDown","ArrowLeft","ArrowRight",...v].includes(e.key))return;t.every((e=>{var t,n;return!e||(null==(t=e[0])?void 0:t.toLocaleLowerCase())!==(null==(n=e[1])?void 0:n.toLocaleLowerCase())}))&&g.current===e.key&&(g.current="",y.current=h.current),g.current+=e.key,clearTimeout(p.current),p.current=setTimeout((()=>{g.current="",y.current=h.current,o.current.typing=!1}),d);const n=y.current,r=[...t.slice((null!=n?n:0)+1),...t.slice(0,(null!=n?n:0)+1)],u=f?f(r,g.current):r.find((e=>0===(null==e?void 0:e.toLocaleLowerCase().indexOf(g.current)))),c=u?t.indexOf(u):-1;-1!==c&&(a(c),h.current=c)}return c((()=>{r&&(clearTimeout(p.current),h.current=null,g.current="")}),[r]),c((()=>{var e;r&&""===g.current&&(y.current=null!=(e=null!=m?m:l)?e:-1)}),[r,m,l]),s?{reference:{onKeyDown:E},floating:{onKeyDown:E}}:{}},Object.keys(t).forEach((function(n){"default"===n||e.hasOwnProperty(n)||Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[n]}})})),Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@floating-ui/react-dom"),require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","@floating-ui/react-dom","react","react-dom"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).FloatingUIReactDOM={},e.FloatingUIReactDOM,e.React,e.ReactDOM)}(this,(function(e,t,n,r){"use strict";function o(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var u=o(n),c="undefined"!=typeof document?n.useLayoutEffect:n.useEffect;function i(){const e=new Map;return{emit(t,n){var r;null==(r=e.get(t))||r.forEach((e=>e(n)))},on(t,n){e.set(t,[...e.get(t)||[],n])},off(t,n){e.set(t,(e.get(t)||[]).filter((e=>e!==n)))}}}let l=!1,a=0;const s=()=>"floating-ui-"+a++;const f=u["useId".toString()],d=null!=f?f:function(){const[e,t]=u.useState((()=>l?s():void 0));return c((()=>{null==e&&t(s())}),[]),u.useEffect((()=>{l||(l=!0)}),[]),e},v=u.createContext(null),m=u.createContext(null),p=()=>{var e,t;return null!=(e=null==(t=u.useContext(v))?void 0:t.id)?e:null},g=()=>u.useContext(m);function b(e){var t;return null!=(t=null==e?void 0:e.ownerDocument)?t:document}function y(e){var t;return null!=(t=b(e).defaultView)?t:window}function h(e){return!!e&&e instanceof y(e).Element}function E(e){return!!e&&e instanceof y(e).HTMLElement}function w(e,t,n){const r=new Map;return{..."floating"===n&&{tabIndex:-1},...e,...t.map((e=>e?e[n]:null)).concat(e).reduce(((e,t)=>t?(Object.entries(t).forEach((t=>{let[n,o]=t;if(0===n.indexOf("on")){var u;if(r.has(n)||r.set(n,[]),"function"==typeof o)null==(u=r.get(n))||u.push(o);e[n]=function(){for(var e,t=arguments.length,o=new Array(t),u=0;u<t;u++)o[u]=arguments[u];null==(e=r.get(n))||e.forEach((e=>e(...o)))}}else e[n]=o})),e):e),{})}}function R(e,t){var n;let r=null!=(n=e.filter((e=>{var n;return e.parentId===t&&(null==(n=e.context)?void 0:n.open)})))?n:[],o=r;for(;o.length;){var u;o=null!=(u=e.filter((e=>{var t;return null==(t=o)?void 0:t.some((t=>{var n;return e.parentId===t.id&&(null==(n=e.context)?void 0:n.open)}))})))?u:[],r=r.concat(o)}return r}const x="floating-ui-root",k=function(e){let{id:t=x,enabled:n=!0}=void 0===e?{}:e;const[r,o]=u.useState(null);return c((()=>{if(!n)return;const e=document.getElementById(t);if(e)o(e);else{const e=document.createElement("div");e.id=t,o(e),document.body.contains(e)||document.body.appendChild(e)}}),[t,n]),r};function I(){return I=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},I.apply(this,arguments)}const O="data-floating-ui-scroll-lock";const T=u.forwardRef((function(e,t){let{lockScroll:n=!1,...r}=e;return c((()=>{var e,t,r,o;if(!n)return;if(document.body.hasAttribute(O))return;document.body.setAttribute(O,"");const u=Math.round(document.documentElement.getBoundingClientRect().left)+document.documentElement.scrollLeft?"paddingLeft":"paddingRight",c=window.innerWidth-document.documentElement.clientWidth;if(!/iP(hone|ad|od)|iOS/.test(function(){const e=navigator.userAgentData;return null!=e&&e.platform?e.platform:navigator.platform}()))return Object.assign(document.body.style,{overflow:"hidden",[u]:c+"px"}),()=>{document.body.removeAttribute(O),Object.assign(document.body.style,{overflow:"",[u]:""})};const i=null!=(e=null==(t=window.visualViewport)?void 0:t.offsetLeft)?e:0,l=null!=(r=null==(o=window.visualViewport)?void 0:o.offsetTop)?r:0,a=window.pageXOffset,s=window.pageYOffset;return Object.assign(document.body.style,{position:"fixed",overflow:"hidden",top:-(s-Math.floor(l))+"px",left:-(a-Math.floor(i))+"px",right:"0",[u]:c+"px"}),()=>{Object.assign(document.body.style,{position:"",overflow:"",top:"",left:"",right:"",[u]:""}),document.body.removeAttribute(O),window.scrollTo(a,s)}}),[n]),u.createElement("div",I({ref:t},r,{style:{position:"fixed",overflow:"auto",top:0,right:0,bottom:0,left:0,...r.style}}))}));var L=new WeakMap,C=new WeakMap,M={},A=0,P=function(e,t,n){void 0===t&&(t=function(e){return"undefined"==typeof document?null:(Array.isArray(e)?e[0]:e).ownerDocument.body}(e)),void 0===n&&(n="data-aria-hidden");var r=Array.isArray(e)?e:[e];M[n]||(M[n]=new WeakMap);var o=M[n],u=[],c=new Set,i=function(e){e&&!c.has(e)&&(c.add(e),i(e.parentNode))};r.forEach(i);var l=function(e){!e||r.indexOf(e)>=0||Array.prototype.forEach.call(e.children,(function(e){if(c.has(e))l(e);else{var t=e.getAttribute("aria-hidden"),r=null!==t&&"false"!==t,i=(L.get(e)||0)+1,a=(o.get(e)||0)+1;L.set(e,i),o.set(e,a),u.push(e),1===i&&r&&C.set(e,!0),1===a&&e.setAttribute(n,"true"),r||e.setAttribute("aria-hidden","true")}}))};return l(t),c.clear(),A++,function(){u.forEach((function(e){var t=L.get(e)-1,r=o.get(e)-1;L.set(e,t),o.set(e,r),t||(C.has(e)||e.removeAttribute("aria-hidden"),C.delete(e)),r||e.removeAttribute(n)})),--A||(L=new WeakMap,L=new WeakMap,C=new WeakMap,M={})}};function D(e){let t=e.activeElement;for(;null!=(null==(n=t)||null==(r=n.shadowRoot)?void 0:r.activeElement);){var n,r;t=t.shadowRoot.activeElement}return t}const F="input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";function S(e){return E(e)&&e.matches(F)}function j(e){e.preventDefault(),e.stopPropagation()}function N(e){const t=n.useRef(e);return c((()=>{t.current=e})),t}function K(e){requestAnimationFrame((()=>{null==e||e.focus()}))}const W=u.forwardRef((function(e,t){return u.createElement("span",I({},e,{ref:t,tabIndex:0,style:{position:"fixed",opacity:"0",pointerEvents:"none",outline:"0"}}))}));function q(e){const t=n.useRef();return c((()=>{t.current=e}),[e]),t.current}function B(e,t,n){return n&&"mouse"!==n?0:"number"==typeof e?e:null==e?void 0:e[t]}const U=u.createContext({delay:1e3,initialDelay:1e3,currentId:null,setCurrentId:()=>{},setState:()=>{}}),V=()=>u.useContext(U);function H(e,t){if(null==t)return!1;if("composedPath"in e)return e.composedPath().includes(t);const n=e;return null!=n.target&&t.contains(n.target)}const G="ArrowUp",X="ArrowDown",Y="ArrowLeft",_="ArrowRight";function z(e,t){return t<0||t>=e.current.length}function J(e,t){let{startingIndex:n=-1,decrement:r=!1,disabledIndices:o}=void 0===t?{}:t;const u=e.current;let c=n;do{var i,l;c+=r?-1:1}while(c>=0&&c<=u.length-1&&(o?o.includes(c):null==u[c]||(null==(i=u[c])?void 0:i.hasAttribute("disabled"))||"true"===(null==(l=u[c])?void 0:l.getAttribute("aria-disabled"))));return c}function Q(e,t,n){switch(e){case"vertical":return t;case"horizontal":return n;default:return t||n}}function Z(e,t){return Q(t,e===G||e===X,e===Y||e===_)}function $(e,t,n){return Q(t,e===X,n?e===Y:e===_)||"Enter"===e||" "==e||""===e}function ee(e,t){return J(e,{disabledIndices:t})}function te(e,t){return J(e,{decrement:!0,startingIndex:e.current.length,disabledIndices:t})}e.FloatingDelayGroup=e=>{let{children:t,delay:n}=e;const[r,o]=u.useState({delay:n,initialDelay:n,currentId:null}),c=u.useCallback((e=>{o((t=>({...t,currentId:e})))}),[]);return u.createElement(U.Provider,{value:u.useMemo((()=>({...r,setState:o,setCurrentId:c})),[r,o,c])},t)},e.FloatingFocusManager=function(e){let{context:{refs:t,nodeId:n,onOpenChange:r,dataRef:o,events:c},children:i,order:l=["content"],endGuard:a=!0,preventTabbing:s=!1,initialFocus:f=0,returnFocus:d=!0,modal:v=!0}=e;const m=N(l),p=N(r),y=g(),w=u.useCallback((()=>m.current.map((e=>{return"reference"===e?t.domReference.current:t.floating.current&&"floating"===e?t.floating.current:"content"===e?Array.from(null!=(n=null==(r=t.floating.current)?void 0:r.querySelectorAll("select:not([disabled]),a[href],button:not([disabled]),[tabindex],iframe,object,embed,area[href],audio[controls],video[controls],input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])"))?n:[]):null;var n,r})).flat().filter((e=>{if(e===t.floating.current||e===t.domReference.current)return!0;if(E(e)){var n;return"-"!==(null!=(n=e.getAttribute("tabindex"))?n:"0")[0].trim()}}))),[m,t]);u.useEffect((()=>{if(!v)return;const e=0===w().filter((e=>e!==t.floating.current&&e!==t.domReference.current)).length;function n(n){if("Tab"===n.key){(s||e)&&j(n);const r=w(),o="composedPath"in n?n.composedPath()[0]:n.target;"reference"===m.current[0]&&o===t.domReference.current&&(j(n),n.shiftKey?K(r[r.length-1]):K(r[1])),"floating"===m.current[1]&&o===t.floating.current&&n.shiftKey&&(j(n),K(r[0]))}}const r=b(t.floating.current);return r.addEventListener("keydown",n),()=>{r.removeEventListener("keydown",n)}}),[s,v,w,m,t]),u.useEffect((()=>{function e(e){var r,o;const u=e.relatedTarget,c=!(null!=(r=t.floating.current)&&r.contains(u)),i=h(t.domReference.current)&&!t.domReference.current.contains(u),l=y&&R(y.nodesRef.current,n).length>0,a=y&&e.currentTarget===t.domReference.current&&(null==(o=function(e,t){var n;let r=[],o=null==(n=e.find((e=>e.id===t)))?void 0:n.parentId;for(;o;){const t=e.find((e=>e.id===o));o=null==t?void 0:t.parentId,t&&(r=r.concat(t))}return r}(y.nodesRef.current,n))?void 0:o.some((e=>{var t,n;return null==(t=e.context)||null==(n=t.refs.floating.current)?void 0:n.contains(u)})));c&&i&&!l&&!a&&p.current(!1)}const r=t.floating.current,o=t.domReference.current;if(r&&E(o)){let t;return!v&&r.addEventListener("focusout",e),!v&&o.addEventListener("focusout",e),v&&(t=m.current.includes("reference")?P([o,r]):P(r)),()=>{!v&&r.removeEventListener("focusout",e),!v&&o.removeEventListener("focusout",e),null==t||t()}}}),[n,y,v,p,m,o,w,t]),u.useEffect((()=>{if(s)return;let e=d;const n=t.floating.current,r=D(b(n));var o;if("number"==typeof f)K(null!=(o=w()[f])?o:n);else if(E(null==f?void 0:f.current)){var u;K(null!=(u=f.current)?u:n)}function i(){e=!1}return c.on("dismiss",i),()=>{c.off("dismiss",i),e&&E(r)&&K(r)}}),[s,w,f,d,t,c]);const x=()=>{var e;return"combobox"===(null==(e=t.domReference.current)?void 0:e.getAttribute("role"))&&S(t.domReference.current)};return u.createElement(u.Fragment,null,v&&u.createElement(W,{onFocus:e=>{if(x())return;j(e);const t=w();"reference"===l[0]?K(t[0]):K(t[t.length-1])}}),u.cloneElement(i,l.includes("floating")?{tabIndex:0}:{}),v&&a&&u.createElement(W,{onFocus:e=>{x()||(j(e),K(w()[0]))}}))},e.FloatingNode=e=>{let{children:t,id:n}=e;const r=p();return u.createElement(v.Provider,{value:u.useMemo((()=>({id:n,parentId:r})),[n,r])},t)},e.FloatingOverlay=T,e.FloatingPortal=e=>{let{children:t,id:n=x,root:o=null}=e;const u=k({id:n,enabled:!o});return o?r.createPortal(t,o):u?r.createPortal(t,u):null},e.FloatingTree=e=>{let{children:t}=e;const n=u.useRef([]),r=u.useCallback((e=>{n.current=[...n.current,e]}),[]),o=u.useCallback((e=>{n.current=n.current.filter((t=>t!==e))}),[]),c=u.useState((()=>i()))[0];return u.createElement(m.Provider,{value:u.useMemo((()=>({nodesRef:n,addNode:r,removeNode:o,events:c})),[n,r,o,c])},t)},e.safePolygon=function(e){let t,{restMs:n=0,buffer:r=.5,debug:o=null}=void 0===e?{}:e,u=!1;return e=>{let{x:o,y:c,placement:i,refs:l,onClose:a,nodeId:s,tree:f,leave:d=!1}=e;return function(e){var v,m;function p(){clearTimeout(t),a()}if(clearTimeout(t),e.pointerType&&"mouse"!==e.pointerType)return;const{clientX:g,clientY:b}=e,y="composedPath"in e?e.composedPath()[0]:e.target;if("pointermove"===e.type&&null!=(v=l.domReference.current)&&v.contains(y))return;if(f&&R(f.nodesRef.current,s).some((e=>{let{context:t}=e;return null==t?void 0:t.open})))return;if(null!=(m=l.floating.current)&&m.contains(y)&&!d)return void(u=!0);if(!l.domReference.current||!l.floating.current||null==i||null==o||null==c)return;const h=l.domReference.current.getBoundingClientRect(),E=l.floating.current.getBoundingClientRect(),w=i.split("-")[0],x=o>E.right-E.width/2,k=c>E.bottom-E.height/2;if("top"===w&&c>=h.bottom-1||"bottom"===w&&c<=h.top+1||"left"===w&&o>=h.right-1||"right"===w&&o<=h.left+1)return p();switch(w){case"top":if(g>=E.left&&g<=E.right&&b>=E.top&&b<=h.top+1)return;break;case"bottom":if(g>=E.left&&g<=E.right&&b>=h.bottom-1&&b<=E.bottom)return;break;case"left":if(g>=E.left&&g<=h.left+1&&b>=E.top&&b<=E.bottom)return;break;case"right":if(g>=h.right-1&&g<=E.right&&b>=E.top&&b<=E.bottom)return}if(u)return p();const I=function(e){let[t,n]=e;const o=E.width>h.width,u=E.height>h.height;switch(w){case"top":return[[o?t+r/2:x?t+4*r:t-4*r,n+r+1],[o?t-r/2:x?t+4*r:t-4*r,n+r+1],...[[E.left,x||o?E.bottom-r:E.top],[E.right,x?o?E.bottom-r:E.top:E.bottom-r]]];case"bottom":return[[o?t+r/2:x?t+4*r:t-4*r,n-r],[o?t-r/2:x?t+4*r:t-4*r,n-r],...[[E.left,x||o?E.top+r:E.bottom],[E.right,x?o?E.top+r:E.bottom:E.top+r]]];case"left":{const e=[t+r+1,u?n+r/2:k?n+4*r:n-4*r],o=[t+r+1,u?n-r/2:k?n+4*r:n-4*r];return[...[[k||u?E.right-r:E.left,E.top],[k?u?E.right-r:E.left:E.right-r,E.bottom]],e,o]}case"right":return[[t-r,u?n+r/2:k?n+4*r:n-4*r],[t-r,u?n-r/2:k?n+4*r:n-4*r],...[[k||u?E.left+r:E.right,E.top],[k?u?E.left+r:E.right:E.left+r,E.bottom]]]}}([o,c]);!function(e,t){const[n,r]=e;let o=!1;const u=t.length;for(let e=0,c=u-1;e<u;c=e++){const[u,i]=t[e]||[0,0],[l,a]=t[c]||[0,0];i>=r!=a>=r&&n<=(l-u)*(r-i)/(a-i)+u&&(o=!o)}return o}([g,b],I)?p():n&&(t=setTimeout(a,n))}}},e.useClick=function(e,t){let{open:n,onOpenChange:r,dataRef:o,refs:c}=e,{enabled:i=!0,pointerDown:l=!1,toggle:a=!0,ignoreMouse:s=!1}=void 0===t?{}:t;const f=u.useRef();function d(){var e;return"BUTTON"===(null==(e=c.domReference.current)?void 0:e.tagName)}function v(){return S(c.domReference.current)}return i?{reference:{onPointerDown(e){0===e.button&&(f.current=e.pointerType,"mouse"===f.current&&s||l&&(n?!a||o.current.openEvent&&"pointerdown"!==o.current.openEvent.type||r(!1):r(!0),o.current.openEvent=e.nativeEvent))},onClick(e){l&&f.current?f.current=void 0:"mouse"===f.current&&s||(n?!a||o.current.openEvent&&"click"!==o.current.openEvent.type||r(!1):r(!0),o.current.openEvent=e.nativeEvent)},onKeyDown(e){f.current=void 0,d()||(" "!==e.key||v()||e.preventDefault(),"Enter"===e.key&&(n?a&&r(!1):r(!0)))},onKeyUp(e){d()||v()||" "===e.key&&(n?a&&r(!1):r(!0))}}}:{}},e.useDelayGroup=(e,t)=>{let{open:n,onOpenChange:r}=e,{id:o}=t;const{currentId:c,initialDelay:i,setState:l}=V(),a=N(r);u.useEffect((()=>{c&&a.current&&(l((e=>({...e,delay:{open:1,close:B(i,"close")}}))),c!==o&&a.current(!1))}),[o,a,l,c,i]),u.useEffect((()=>{!n&&c===o&&a.current&&(a.current(!1),l((e=>({...e,delay:i,currentId:null}))))}),[n,l,c,o,a,i])},e.useDelayGroupContext=V,e.useDismiss=function(e,n){let{open:r,onOpenChange:o,refs:c,events:i,nodeId:l}=e,{enabled:a=!0,escapeKey:s=!0,outsidePointerDown:f=!0,referencePointerDown:d=!1,ancestorScroll:v=!1,bubbles:m=!0}=void 0===n?{}:n;const p=g(),y=N(o),w=u.useCallback((()=>{var e;return null==(e=c.floating.current)?void 0:e.contains(D(b(c.floating.current)))}),[c]);return u.useEffect((()=>{if(!r||!a)return;function e(e){if("Escape"===e.key){if(!m&&!w())return;i.emit("dismiss"),y.current(!1),E(c.domReference.current)&&c.domReference.current.focus()}}function n(e){const t=p&&R(p.nodesRef.current,l).some((t=>{var n;return H(e,null==(n=t.context)?void 0:n.refs.floating.current)}));H(e,c.floating.current)||H(e,c.domReference.current)||t||(m||w())&&(i.emit("dismiss"),y.current(!1))}function o(){y.current(!1)}const u=b(c.floating.current);s&&u.addEventListener("keydown",e),f&&u.addEventListener("mousedown",n);const d=(v?[...h(c.reference.current)?t.getOverflowAncestors(c.reference.current):[],...h(c.floating.current)?t.getOverflowAncestors(c.floating.current):[]]:[]).filter((e=>{var t;return e!==(null==(t=u.defaultView)?void 0:t.visualViewport)}));return d.forEach((e=>e.addEventListener("scroll",o,{passive:!0}))),()=>{s&&u.removeEventListener("keydown",e),f&&u.removeEventListener("mousedown",n),d.forEach((e=>e.removeEventListener("scroll",o)))}}),[s,f,i,p,l,r,y,v,a,m,w,c]),a?{reference:{onPointerDown(){d&&(i.emit("dismiss"),o(!1))}}}:{}},e.useFloating=function(e){let{open:n=!1,onOpenChange:r=(()=>{}),whileElementsMounted:o,placement:l,middleware:a,strategy:s,nodeId:f}=void 0===e?{}:e;const d=g(),v=u.useRef(null),m=u.useRef({}),p=u.useState((()=>i()))[0],b=t.useFloating({placement:l,middleware:a,strategy:s,whileElementsMounted:o}),y=u.useMemo((()=>({...b.refs,domReference:v})),[b.refs]),E=u.useMemo((()=>({...b,refs:y,dataRef:m,nodeId:f,events:p,open:n,onOpenChange:r})),[b,f,p,n,r,y]);c((()=>{const e=null==d?void 0:d.nodesRef.current.find((e=>e.id===f));e&&(e.context=E)}));const{reference:w}=b,R=u.useCallback((e=>{(h(e)||null===e)&&(E.refs.domReference.current=e),w(e)}),[w,E.refs]);return u.useMemo((()=>({...b,context:E,refs:y,reference:R})),[b,y,E,R])},e.useFloatingNodeId=()=>{const e=d(),t=g(),n=p();return c((()=>{const r={id:e,parentId:n};return null==t||t.addNode(r),()=>{null==t||t.removeNode(r)}}),[t,e,n]),e},e.useFloatingParentNodeId=p,e.useFloatingPortalNode=k,e.useFloatingTree=g,e.useFocus=function(e,t){let{open:n,onOpenChange:r,dataRef:o,refs:c,events:i}=e,{enabled:l=!0,keyboardOnly:a=!0}=void 0===t?{}:t;const s=u.useRef(""),f=u.useRef(!1);return u.useEffect((()=>{var e;if(!l)return;const t=b(c.floating.current),r=null!=(e=t.defaultView)?e:window;function o(){s.current&&c.domReference.current===D(t)&&(f.current=!n)}function u(){setTimeout((()=>{f.current=!1,s.current=""}))}return r.addEventListener("focus",u),r.addEventListener("blur",o),()=>{r.removeEventListener("focus",u),r.removeEventListener("blur",o)}}),[c,n,l]),u.useEffect((()=>{if(l)return i.on("dismiss",e),()=>{i.off("dismiss",e)};function e(){f.current=!0}}),[i,l]),l?{reference:{onPointerDown(e){let{pointerType:t}=e;s.current=t,f.current=!(!t||!a)},onFocus(e){var t,n,u;f.current||"focus"===e.type&&"mousedown"===(null==(t=o.current.openEvent)?void 0:t.type)&&null!=(n=c.domReference.current)&&n.contains(null==(u=o.current.openEvent)?void 0:u.target)||(o.current.openEvent=e.nativeEvent,r(!0))},onBlur(e){var t,n;const o=e.relatedTarget;null!=(t=c.floating.current)&&t.contains(o)||null!=(n=c.domReference.current)&&n.contains(o)||(f.current=!1,r(!1))}}}:{}},e.useHover=function(e,t){let{enabled:n=!0,delay:r=0,handleClose:o=null,mouseOnly:i=!1,restMs:l=0}=void 0===t?{}:t;const{open:a,onOpenChange:s,dataRef:f,events:d,refs:v}=e,m=g(),y=p(),w=N(s),R=N(o),x=q(a),k=u.useRef(),I=u.useRef(),O=u.useRef(),T=u.useRef(),L=u.useRef(!0),C=u.useRef(!1);u.useEffect((()=>{if(n)return d.on("dismiss",e),()=>{d.off("dismiss",e)};function e(){clearTimeout(I.current),clearTimeout(T.current),L.current=!0}}),[n,d,v]),u.useEffect((()=>{if(!n||!R.current)return;function e(){var e;null!=(e=f.current.openEvent)&&e.type.includes("mouse")&&w.current(!1)}const t=b(v.floating.current).documentElement;return t.addEventListener("mouseleave",e),()=>{t.removeEventListener("mouseleave",e)}}),[v,w,n,R,f]);const M=u.useCallback((function(e){void 0===e&&(e=!0);const t=B(r,"close",k.current);t&&!O.current?(clearTimeout(I.current),I.current=setTimeout((()=>w.current(!1)),t)):e&&(clearTimeout(I.current),w.current(!1))}),[r,w]),A=u.useCallback((()=>{O.current&&(b(v.floating.current).removeEventListener("pointermove",O.current),O.current=void 0)}),[v]),P=u.useCallback((()=>{b(v.floating.current).body.style.pointerEvents="",C.current=!1}),[v]);if(u.useEffect((()=>{if(!n)return;function t(e){if(clearTimeout(I.current),L.current=!1,a||i&&"mouse"!==k.current||l>0&&0===B(r,"open"))return;f.current.openEvent=e;const t=B(r,"open",k.current);t?I.current=setTimeout((()=>{w.current(!0)}),t):w.current(!0)}function o(t){var n,r;if("click"===(null==(n=f.current.openEvent)?void 0:n.type)||"pointerdown"===(null==(r=f.current.openEvent)?void 0:r.type))return;const o=b(v.floating.current);if(clearTimeout(T.current),R.current)return clearTimeout(I.current),O.current&&o.removeEventListener("pointermove",O.current),O.current=R.current({...e,tree:m,x:t.clientX,y:t.clientY,onClose(){A(),M()}}),void o.addEventListener("pointermove",O.current);M()}function u(t){null==R.current||R.current({...e,tree:m,x:t.clientX,y:t.clientY,leave:!0,onClose(){A(),M()}})(t)}const c=v.floating.current,s=v.domReference.current;return h(s)?(a&&s.addEventListener("mouseleave",u),null==c||c.addEventListener("mouseleave",u),s.addEventListener("mousemove",t,{once:!0}),s.addEventListener("mouseenter",t),s.addEventListener("mouseleave",o),()=>{a&&s.removeEventListener("mouseleave",u),null==c||c.removeEventListener("mouseleave",u),s.removeEventListener("mousemove",t),s.removeEventListener("mouseenter",t),s.removeEventListener("mouseleave",o)}):void 0}),[n,M,e,r,R,f,i,w,a,m,l,A,v]),c((()=>{if(n&&a&&R.current){b(v.floating.current).body.style.pointerEvents="none",C.current=!0;const n=v.domReference.current,r=v.floating.current;if(E(n)&&r){var e,t;const o=null==m||null==(e=m.nodesRef.current.find((e=>e.id===y)))||null==(t=e.context)?void 0:t.refs.floating.current;return o&&(o.style.pointerEvents=""),n.style.pointerEvents="auto",r.style.pointerEvents="auto",()=>{n.style.pointerEvents="",r.style.pointerEvents=""}}}}),[n,a,y,v,m,R,f]),c((()=>{x&&!a&&(k.current=void 0,A(),P())})),u.useEffect((()=>()=>{A(),clearTimeout(I.current),clearTimeout(T.current),C.current&&P()}),[A,P]),!n)return{};function D(e){k.current=e.pointerType}return{reference:{onPointerDown:D,onPointerEnter:D,onMouseMove(){a||0===l||(clearTimeout(T.current),T.current=setTimeout((()=>{L.current||s(!0)}),l))}},floating:{onMouseEnter(){clearTimeout(I.current)},onMouseLeave(){M(!1)}}}},e.useId=d,e.useInteractions=function(e){return void 0===e&&(e=[]),{getReferenceProps:t=>w(t,e,"reference"),getFloatingProps:t=>w(t,e,"floating"),getItemProps:t=>w(t,e,"item")}},e.useListNavigation=function(e,t){let{open:n,onOpenChange:r,refs:o}=e,{listRef:i,activeIndex:l,onNavigate:a,enabled:s=!0,selectedIndex:f=null,allowEscape:d=!1,loop:v=!1,nested:m=!1,rtl:y=!1,virtual:h=!1,focusItemOnOpen:w="auto",focusItemOnHover:R=!0,openOnArrowKeyDown:x=!0,disabledIndices:k=(x?void 0:[]),orientation:I="vertical"}=void 0===t?{listRef:{current:[]},activeIndex:null,onNavigate:()=>{}}:t;const O=p(),T=g(),L=q(n),C=u.useRef(w),M=u.useRef(null!=f?f:-1),A=u.useRef(null),P=N(q(a)),F=N(a),S=N(k),K=u.useRef(!1),W=u.useRef(-1),[B,U]=u.useState(),V=u.useCallback(((e,t)=>{W.current=requestAnimationFrame((()=>{var n,r;h?U(null==(n=e.current[t.current])?void 0:n.id):null==(r=e.current[t.current])||r.focus({preventScroll:!0})}))}),[h]);function H(e){if(K.current=!0,m&&function(e,t,n){return Q(t,n?e===_:e===Y,e===G)}(e.key,I,y))return j(e),r(!1),void(E(o.domReference.current)&&o.domReference.current.focus());const t=M.current,u=ee(i,k),c=te(i,k);if("Home"===e.key&&(M.current=u,a(M.current)),"End"===e.key&&(M.current=c,a(M.current)),Z(e.key,I)){if(j(e),n&&!h&&D(e.currentTarget.ownerDocument)===e.currentTarget)return M.current=$(e.key,I,y)?u:c,void a(M.current);$(e.key,I,y)?M.current=v?t>=c?d&&t!==i.current.length?-1:u:J(i,{startingIndex:t,disabledIndices:k}):Math.min(c,J(i,{startingIndex:t,disabledIndices:k})):M.current=v?t<=u?d&&-1!==t?i.current.length:c:J(i,{startingIndex:t,decrement:!0,disabledIndices:k}):Math.max(u,J(i,{startingIndex:t,decrement:!0,disabledIndices:k})),z(i,M.current)?a(null):a(M.current)}}return c((()=>{s&&(!L&&n&&C.current&&null!=f&&F.current(f),L&&!n&&(cancelAnimationFrame(W.current),M.current=-1,null==P.current||P.current(null)))}),[n,L,f,i,F,P,V,s]),c((()=>{if(s&&n)if(null==l){if(null!=f)return;L&&(M.current=-1,V(i,M)),!L&&C.current&&(null!=A.current||!0===C.current&&null==A.current)&&(M.current=null==A.current||$(A.current,I,y)||m?ee(i,S.current):te(i,S.current),F.current(M.current),V(i,M))}else z(i,l)||(M.current=l,V(i,M))}),[n,L,l,f,m,i,F,V,s,d,I,y,h,S]),c((()=>{s&&!n&&L&&null!=f&&E(o.domReference.current)&&o.domReference.current.focus()}),[o,f,n,L,s]),c((()=>{if(s&&!n&&L){var e,t;const n=null==T||null==(e=T.nodesRef.current.find((e=>e.id===O)))||null==(t=e.context)?void 0:t.refs.floating.current;n&&!n.contains(D(b(n)))&&n.focus({preventScroll:!0})}}),[s,n,L,T,O]),c((()=>{A.current=null})),s?{reference:{...h&&n&&null!=l&&{"aria-activedescendant":B},onKeyDown(e){if(K.current=!0,h&&n)return H(e);(0===e.key.indexOf("Arrow")||"Enter"===e.key||" "===e.key||""===e.key)&&(A.current=e.key),m?function(e,t,n){return Q(t,n?e===Y:e===_,e===X)}(e.key,I,y)&&(j(e),n?(M.current=ee(i,k),a(M.current)):r(!0)):Z(e.key,I)&&(null!=f&&(M.current=f),j(e),!n&&x?r(!0):H(e),n&&a(M.current))}},floating:{"aria-orientation":"both"===I?void 0:I,...h&&null!=l&&{"aria-activedescendant":B},onKeyDown:H,onPointerMove(){K.current=!1}},item:{onFocus(e){let{currentTarget:t}=e;const n=i.current.indexOf(t);-1!==n&&a(n)},onClick:e=>{let{currentTarget:t}=e;return t.focus({preventScroll:!0})},...R&&{onMouseMove(e){let{currentTarget:t}=e;const n=t;if(n){const e=i.current.indexOf(n);-1!==e&&a(e)}},onMouseLeave(){var e;K.current||(M.current=-1,V(i,M),F.current(null),h||null==(e=o.floating.current)||e.focus({preventScroll:!0}))}}}}:{}},e.useRole=function(e,t){let{open:n}=e,{enabled:r=!0,role:o="dialog"}=void 0===t?{}:t;const u=d(),c=d(),i={id:u,role:o};return r?"tooltip"===o?{reference:{"aria-describedby":n?u:void 0},floating:i}:{reference:{"aria-expanded":n?"true":"false","aria-haspopup":o,"aria-controls":n?u:void 0,..."listbox"===o&&{role:"combobox"},..."menu"===o&&{id:c}},floating:{...i,..."menu"===o&&{"aria-labelledby":c}}}:{}},e.useTypeahead=function(e,t){var n;let{open:r,dataRef:o}=e,{listRef:i,activeIndex:l,onMatch:a=(()=>{}),enabled:s=!0,findMatch:f=null,resetMs:d=1e3,ignoreKeys:v=[],selectedIndex:m=null}=void 0===t?{listRef:{current:[]},activeIndex:null}:t;const p=u.useRef(),g=u.useRef(""),y=u.useRef(null!=(n=null!=m?m:l)?n:-1),h=u.useRef(null);function E(e){if(!e.currentTarget.contains(D(b(e.currentTarget))))return;g.current.length>0&&" "!==g.current[0]&&(o.current.typing=!0," "===e.key&&j(e));const t=i.current;if(null==t||["Home","End","Escape","Enter","Tab","ArrowUp","ArrowDown","ArrowLeft","ArrowRight",...v].includes(e.key))return;t.every((e=>{var t,n;return!e||(null==(t=e[0])?void 0:t.toLocaleLowerCase())!==(null==(n=e[1])?void 0:n.toLocaleLowerCase())}))&&g.current===e.key&&(g.current="",y.current=h.current),g.current+=e.key,clearTimeout(p.current),p.current=setTimeout((()=>{g.current="",y.current=h.current,o.current.typing=!1}),d);const n=y.current,r=[...t.slice((null!=n?n:0)+1),...t.slice(0,(null!=n?n:0)+1)],u=f?f(r,g.current):r.find((e=>0===(null==e?void 0:e.toLocaleLowerCase().indexOf(g.current)))),c=u?t.indexOf(u):-1;-1!==c&&(a(c),h.current=c)}return c((()=>{r&&(clearTimeout(p.current),h.current=null,g.current="")}),[r]),c((()=>{var e;r&&""===g.current&&(y.current=null!=(e=null!=m?m:l)?e:-1)}),[r,m,l]),s?{reference:{onKeyDown:E},floating:{onKeyDown:E}}:{}},Object.keys(t).forEach((function(n){"default"===n||e.hasOwnProperty(n)||Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[n]}})})),Object.defineProperty(e,"__esModule",{value:!0})})); |
{ | ||
"name": "@floating-ui/react-dom-interactions", | ||
"version": "0.6.5", | ||
"version": "0.6.6", | ||
"@rollingversions": { | ||
@@ -5,0 +5,0 @@ "baseVersion": [ |
@@ -17,2 +17,2 @@ import * as React from 'react'; | ||
*/ | ||
export declare function FloatingFocusManager<RT extends ReferenceType = ReferenceType>({ context: { refs, nodeId, onOpenChange, dataRef }, children, order, endGuard, preventTabbing, initialFocus, returnFocus, modal, }: Props<RT>): JSX.Element; | ||
export declare function FloatingFocusManager<RT extends ReferenceType = ReferenceType>({ context: { refs, nodeId, onOpenChange, dataRef, events }, children, order, endGuard, preventTabbing, initialFocus, returnFocus, modal, }: Props<RT>): JSX.Element; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
295643
6501
113764