@floating-ui/react-dom-interactions
Advanced tools
Comparing version 0.8.0 to 0.8.1
@@ -1,1 +0,1 @@ | ||
import{useFloating as e,offset as n,detectOverflow as t,getOverflowAncestors as r}from"@floating-ui/react-dom";export*from"@floating-ui/react-dom";import*as o from"react";import{useLayoutEffect as u,useEffect as c,useRef as l}from"react";import{createPortal as i,flushSync as s}from"react-dom";import{hideOthers as a}from"aria-hidden";var f="undefined"!=typeof document?u:c;function d(){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 m=!1,v=0;const p=()=>"floating-ui-"+v++;const g=o["useId".toString()],h=null!=g?g:function(){const[e,n]=o.useState((()=>m?p():void 0));return f((()=>{null==e&&n(p())}),[]),o.useEffect((()=>{m||(m=!0)}),[]),e},b=o.createContext(null),y=o.createContext(null),w=()=>{var e,n;return null!=(e=null==(n=o.useContext(b))?void 0:n.id)?e:null},E=()=>o.useContext(y),R=()=>{const e=h(),n=E(),t=w();return f((()=>{const r={id:e,parentId:t};return null==n||n.addNode(r),()=>{null==n||n.removeNode(r)}}),[n,e,t]),e},x=e=>{let{children:n,id:t}=e;const r=w();return o.createElement(b.Provider,{value:o.useMemo((()=>({id:t,parentId:r})),[t,r])},n)},T=e=>{let{children:n}=e;const t=o.useRef([]),r=o.useCallback((e=>{t.current=[...t.current,e]}),[]),u=o.useCallback((e=>{t.current=t.current.filter((n=>n!==e))}),[]),c=o.useState((()=>d()))[0];return o.createElement(y.Provider,{value:o.useMemo((()=>({nodesRef:t,addNode:r,removeNode:u,events:c})),[t,r,u,c])},n)};function L(e){var n;return null!=(n=null==e?void 0:e.ownerDocument)?n:document}function I(e){var n;return null!=(n=L(e).defaultView)?n:window}function k(e){return!!e&&e instanceof I(e).Element}function C(e){return!!e&&e instanceof I(e).HTMLElement}function A(n){let{open:t=!1,onOpenChange:r=(()=>{}),whileElementsMounted:u,placement:c,middleware:l,strategy:i,nodeId:s}=void 0===n?{}:n;const a=E(),m=o.useRef(null),v=o.useRef({}),p=o.useState((()=>d()))[0],g=e({placement:c,middleware:l,strategy:i,whileElementsMounted:u}),h=o.useMemo((()=>({...g.refs,domReference:m})),[g.refs]),b=o.useMemo((()=>({...g,refs:h,dataRef:v,nodeId:s,events:p,open:t,onOpenChange:r})),[g,s,p,t,r,h]);f((()=>{const e=null==a?void 0:a.nodesRef.current.find((e=>e.id===s));e&&(e.context=b)}));const{reference:y}=g,w=o.useCallback((e=>{(k(e)||null===e)&&(b.refs.domReference.current=e),y(e)}),[y,b.refs]);return o.useMemo((()=>({...g,context:b,refs:h,reference:w})),[g,h,b,w])}function M(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 O=function(e){return void 0===e&&(e=[]),{getReferenceProps:n=>M(n,e,"reference"),getFloatingProps:n=>M(n,e,"floating"),getItemProps:n=>M(n,e,"item")}};function D(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 P(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:s,nodeId:a,tree:f,leave:d=!1}=e;return function(e){var m,v;function p(){clearTimeout(n),s()}if(clearTimeout(n),e.pointerType&&"mouse"!==e.pointerType)return;const{clientX:g,clientY:h}=e,b="composedPath"in e?e.composedPath()[0]:e.target;if("pointermove"===e.type&&null!=(m=i.domReference.current)&&m.contains(b))return;if(f&&D(f.nodesRef.current,a).some((e=>{let{context:n}=e;return null==n?void 0:n.open})))return;if(null!=(v=i.floating.current)&&v.contains(b)&&!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(),w=i.floating.current.getBoundingClientRect(),E=l.split("-")[0],R=o>w.right-w.width/2,x=c>w.bottom-w.height/2;if("top"===E&&c>=y.bottom-1||"bottom"===E&&c<=y.top+1||"left"===E&&o>=y.right-1||"right"===E&&o<=y.left+1)return p();switch(E){case"top":if(g>=w.left&&g<=w.right&&h>=w.top&&h<=y.top+1)return;break;case"bottom":if(g>=w.left&&g<=w.right&&h>=y.bottom-1&&h<=w.bottom)return;break;case"left":if(g>=w.left&&g<=y.left+1&&h>=w.top&&h<=w.bottom)return;break;case"right":if(g>=y.right-1&&g<=w.right&&h>=w.top&&h<=w.bottom)return}if(u)return p();const T=function(e){let[n,t]=e;const o=w.width>y.width,u=w.height>y.height;switch(E){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],...[[w.left,R||o?w.bottom-r:w.top],[w.right,R?o?w.bottom-r:w.top:w.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],...[[w.left,R||o?w.top+r:w.bottom],[w.right,R?o?w.top+r:w.bottom:w.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?w.right-r:w.left,w.top],[x?u?w.right-r:w.left:w.right-r,w.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?w.left+r:w.right,w.top],[x?u?w.left+r:w.right:w.left+r,w.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,s]=n[c]||[0,0];l>=r!=s>=r&&t<=(i-u)*(r-l)/(s-l)+u&&(o=!o)}return o}([g,h],T)?p():t&&(n=setTimeout(s,t))}}}const S="floating-ui-root",F=function(e){let{id:n=S,enabled:t=!0}=void 0===e?{}:e;const[r,u]=o.useState(null);return f((()=>{if(!t)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,t]),r},H=e=>{let{children:n,id:t=S,root:r=null}=e;const o=F({id:t,enabled:!r});return r?i(n,r):o?i(n,o):null};function K(){return K=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},K.apply(this,arguments)}const j="data-floating-ui-scroll-lock",N=o.forwardRef((function(e,n){let{lockScroll:t=!1,...r}=e;return f((()=>{var e,n,r,o;if(!t)return;if(document.body.hasAttribute(j))return;document.body.setAttribute(j,"");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(j),Object.assign(document.body.style,{overflow:"",[u]:""})};const l=null!=(e=null==(n=window.visualViewport)?void 0:n.offsetLeft)?e:0,i=null!=(r=null==(o=window.visualViewport)?void 0:o.offsetTop)?r:0,s=window.pageXOffset,a=window.pageYOffset;return Object.assign(document.body.style,{position:"fixed",overflow:"hidden",top:-(a-Math.floor(i))+"px",left:-(s-Math.floor(l))+"px",right:"0",[u]:c+"px"}),()=>{Object.assign(document.body.style,{position:"",overflow:"",top:"",left:"",right:"",[u]:""}),document.body.removeAttribute(j),window.scrollTo(s,a)}}),[t]),o.createElement("div",K({ref:n},r,{style:{position:"fixed",overflow:"auto",top:0,right:0,bottom:0,left:0,...r.style}}))}));function V(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 B="input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";function q(e){return C(e)&&e.matches(B)}function U(e){e.preventDefault(),e.stopPropagation()}function Y(e){const n=l(e);return f((()=>{n.current=e})),n}function X(e,n){void 0===n&&(n=!1),requestAnimationFrame((()=>{null==e||e.focus({preventScroll:n})}))}const W=o.forwardRef((function(e,n){return o.createElement("span",K({},e,{ref:n,tabIndex:0,style:{position:"fixed",opacity:"0",pointerEvents:"none",outline:"0"}}))}));function z(e){var n;let{context:{refs:t,nodeId:r,onOpenChange:u,dataRef:c,events:l},children:i,order:s=["content"],endGuard:f=!0,preventTabbing:d=!1,initialFocus:m=0,returnFocus:v=!0,modal:p=!0}=e;const g=Y(s),h=Y(u),b=E(),y=null==(null==b||null==(n=b.nodesRef.current.find((e=>e.id===r)))?void 0:n.parentId),w=o.useCallback((()=>g.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(C(e)){var n;return"-"!==(null!=(n=e.getAttribute("tabindex"))?n:"0")[0].trim()}}))),[g,t]);o.useEffect((()=>{if(!p)return;const e=0===w().filter((e=>e!==t.floating.current&&e!==t.domReference.current)).length;function n(n){if("Tab"===n.key){(d||e)&&U(n);const r=w(),o="composedPath"in n?n.composedPath()[0]:n.target;"reference"===g.current[0]&&o===t.domReference.current&&(U(n),n.shiftKey?X(r[r.length-1]):X(r[1])),"floating"===g.current[1]&&o===t.floating.current&&n.shiftKey&&(U(n),X(r[0]))}}const r=L(t.floating.current);return r.addEventListener("keydown",n),()=>{r.removeEventListener("keydown",n)}}),[d,p,w,g,t]),o.useEffect((()=>{function e(e){var n,o;const u=e.relatedTarget,c=!(null!=(n=t.floating.current)&&n.contains(u)),l=k(t.domReference.current)&&!t.domReference.current.contains(u),i=b&&D(b.nodesRef.current,r).length>0,s=b&&e.currentTarget===t.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&&l&&!i&&!s&&h.current(!1)}const n=t.floating.current,o=t.domReference.current;if(n&&C(o)){let t;return!p&&n.addEventListener("focusout",e),!p&&o.addEventListener("focusout",e),p&&(t=g.current.includes("reference")?a([o,n]):a(n)),()=>{!p&&n.removeEventListener("focusout",e),!p&&o.removeEventListener("focusout",e),null==t||t()}}}),[r,b,p,h,g,c,w,t]),o.useEffect((()=>{if(d&&!y)return;const e=t.floating.current,n=L(e);let r=v,o=!1,u=V(n);var c;if(u===n.body&&t.domReference.current&&(u=t.domReference.current),!d)if("number"==typeof m)X(null!=(c=w()[m])?c:e);else if(C(null==m?void 0:m.current)){var i;X(null!=(i=m.current)?i:e)}function s(e){void 0===e&&(e=!1),"object"==typeof e?(r=!0,o=e.preventScroll):r=e}return l.on("dismiss",s),()=>{l.off("dismiss",s),r&&C(u)&&X(u,o)}}),[d,w,m,v,t,l,y]);const R=()=>{var e;return"combobox"===(null==(e=t.domReference.current)?void 0:e.getAttribute("role"))&&q(t.domReference.current)};return o.createElement(o.Fragment,null,p&&o.createElement(W,{onFocus:e=>{if(R())return;U(e);const n=w();"reference"===s[0]?X(n[0]):X(n[n.length-1])}}),o.cloneElement(i,s.includes("floating")?{tabIndex:0}:{}),p&&f&&o.createElement(W,{onFocus:e=>{R()||(U(e),X(w()[0]))}}))}function G(e){const n=l();return f((()=>{n.current=e}),[e]),n.current}function J(e,n,t){return t&&"mouse"!==t?0:"number"==typeof e?e:null==e?void 0:e[n]}const Q=function(e,n){let{enabled:t=!0,delay:r=0,handleClose:u=null,mouseOnly:c=!1,restMs:l=0}=void 0===n?{}:n;const{open:i,onOpenChange:s,dataRef:a,events:d,refs:m}=e,v=E(),p=w(),g=Y(s),h=Y(u),b=G(i),y=o.useRef(),R=o.useRef(),x=o.useRef(),T=o.useRef(),I=o.useRef(!0),C=o.useRef(!1);o.useEffect((()=>{if(t)return d.on("dismiss",e),()=>{d.off("dismiss",e)};function e(){clearTimeout(R.current),clearTimeout(T.current),I.current=!0}}),[t,d,m]),o.useEffect((()=>{if(!t||!h.current)return;function e(){var e;const n=null==(e=a.current.openEvent)?void 0:e.type;null!=n&&n.includes("mouse")&&"mousedown"!==n&&g.current(!1)}const n=L(m.floating.current).documentElement;return n.addEventListener("mouseleave",e),()=>{n.removeEventListener("mouseleave",e)}}),[m,g,t,h,a]);const A=o.useCallback((function(e){void 0===e&&(e=!0);const n=J(r,"close",y.current);n&&!x.current?(clearTimeout(R.current),R.current=setTimeout((()=>g.current(!1)),n)):e&&(clearTimeout(R.current),g.current(!1))}),[r,g]),M=o.useCallback((()=>{x.current&&(L(m.floating.current).removeEventListener("pointermove",x.current),x.current=void 0)}),[m]),O=o.useCallback((()=>{L(m.floating.current).body.style.pointerEvents="",C.current=!1}),[m]);if(o.useEffect((()=>{if(!t)return;function n(){return!!a.current.openEvent&&["click","mousedown"].includes(a.current.openEvent.type)}function o(e){if(clearTimeout(R.current),I.current=!1,i||c&&"mouse"!==y.current||l>0&&0===J(r,"open"))return;a.current.openEvent=e;const n=J(r,"open",y.current);n?R.current=setTimeout((()=>{g.current(!0)}),n):g.current(!0)}function u(t){if(n())return;const r=L(m.floating.current);if(clearTimeout(T.current),h.current)return clearTimeout(R.current),x.current&&r.removeEventListener("pointermove",x.current),x.current=h.current({...e,tree:v,x:t.clientX,y:t.clientY,onClose(){M(),A()}}),void r.addEventListener("pointermove",x.current);A()}function s(t){n()||null==h.current||h.current({...e,tree:v,x:t.clientX,y:t.clientY,leave:!0,onClose(){M(),A()}})(t)}const f=m.floating.current,d=m.domReference.current;return k(d)?(i&&d.addEventListener("mouseleave",s),null==f||f.addEventListener("mouseleave",s),d.addEventListener("mousemove",o,{once:!0}),d.addEventListener("mouseenter",o),d.addEventListener("mouseleave",u),()=>{i&&d.removeEventListener("mouseleave",s),null==f||f.removeEventListener("mouseleave",s),d.removeEventListener("mousemove",o),d.removeEventListener("mouseenter",o),d.removeEventListener("mouseleave",u)}):void 0}),[t,A,e,r,h,a,c,g,i,v,l,M,m]),f((()=>{if(t&&i&&h.current){L(m.floating.current).body.style.pointerEvents="none",C.current=!0;const t=m.domReference.current,r=m.floating.current;if(k(t)&&r){var e,n;const o=null==v||null==(e=v.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=""}}}}),[t,i,p,m,v,h,a]),f((()=>{b&&!i&&(y.current=void 0,M(),O())})),o.useEffect((()=>()=>{M(),clearTimeout(R.current),clearTimeout(T.current),C.current&&O()}),[M,O]),!t)return{};function D(e){y.current=e.pointerType}return{reference:{onPointerDown:D,onPointerEnter:D,onMouseMove(){i||0===l||(clearTimeout(T.current),T.current=setTimeout((()=>{I.current||s(!0)}),l))}},floating:{onMouseEnter(){clearTimeout(R.current)},onMouseLeave(){A(!1)}}}},Z=o.createContext({delay:1e3,initialDelay:1e3,currentId:null,setCurrentId:()=>{},setState:()=>{}}),$=()=>o.useContext(Z),_=e=>{let{children:n,delay:t}=e;const[r,u]=o.useState({delay:t,initialDelay:t,currentId:null}),c=o.useCallback((e=>{u((n=>({...n,currentId:e})))}),[]);return o.createElement(Z.Provider,{value:o.useMemo((()=>({...r,setState:u,setCurrentId:c})),[r,u,c])},n)},ee=(e,n)=>{let{open:t,onOpenChange:r}=e,{id:u}=n;const{currentId:c,initialDelay:l,setState:i}=$(),s=Y(r);o.useEffect((()=>{c&&s.current&&(i((e=>({...e,delay:{open:1,close:J(l,"close")}}))),c!==u&&s.current(!1))}),[u,s,i,c,l]),o.useEffect((()=>{!t&&c===u&&s.current&&(s.current(!1),i((e=>({...e,delay:l,currentId:null}))))}),[t,i,c,u,s,l])};function ne(e,n){return{...e,rects:{...e.rects,floating:{...e.rects.floating,height:e.elements.floating[n]}}}}const te=e=>({name:"inner",options:e,async fn(r){const{listRef:o,overflowRef:u,onFallbackChange:c,offset:l=0,index:i=0,minItemsVisible:a=4,referenceOverflowThreshold:f=0,...d}=e,{rects:m,elements:{floating:v}}=r,p=o.current[i];if(!p)return{};const g={...r,...await n(-p.offsetTop-m.reference.height/2-p.offsetHeight/2-l).fn(r)},h=await t(ne(g,"scrollHeight"),d),b=await t(g,{...d,elementContext:"reference"}),y=Math.max(0,h.top),w=g.y+y,E=Math.max(0,v.scrollHeight-y-Math.max(0,h.bottom));return v.style.maxHeight=E+"px",v.scrollTop=y,c&&(v.offsetHeight<p.offsetHeight*Math.min(a,o.current.length-1)-1||b.top>=-f||b.bottom>=-f?s((()=>c(!0))):s((()=>c(!1)))),u&&(u.current=await t(ne({...g,y:w},"offsetHeight"),d)),{y:w}}}),re=(e,n)=>{let{open:t,refs:r}=e,{enabled:u=!0,overflowRef:c,onChange:l}=n;const i=Y(l),a=o.useRef(!1),f=o.useRef(null),d=o.useRef(null);return o.useEffect((()=>{if(!u)return;function e(e){if(e.ctrlKey||!n||null==c.current)return;const t=e.deltaY,r=c.current.top>=-.5,o=c.current.bottom>=-.5,u=n.scrollHeight-n.clientHeight,l=t<0?-1:1,a=t<0?"max":"min";n.scrollHeight<=n.clientHeight||(!r&&t>0||!o&&t<0?(e.preventDefault(),s((()=>{i.current((e=>e+Math[a](t,u*l)))}))):/firefox/i.test(function(){const e=navigator.userAgentData;return null!=e&&e.brands?e.brands.map((e=>{let{brand:n,version:t}=e;return n+"/"+t})).join(" "):navigator.userAgent}())&&(n.scrollTop+=t))}const n=r.floating.current;return t&&n?(n.addEventListener("wheel",e),requestAnimationFrame((()=>{f.current=n.scrollTop,null!=c.current&&(d.current={...c.current})})),()=>{f.current=null,d.current=null,n.removeEventListener("wheel",e)}):void 0}),[u,t,r,c,i]),u?{floating:{onKeyDown(){a.current=!0},onWheel(){a.current=!1},onPointerMove(){a.current=!1},onScroll(){const e=r.floating.current;if(c.current&&e&&a.current){if(null!==f.current){const n=e.scrollTop-f.current;(c.current.bottom<-.5&&n<-1||c.current.top<-.5&&n>1)&&s((()=>l((e=>e+n))))}requestAnimationFrame((()=>{f.current=e.scrollTop}))}}}}:{}},oe=function(e,n){let{open:t}=e,{enabled:r=!0,role:o="dialog"}=void 0===n?{}:n;const u=h(),c=h(),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}}}:{}},ue=function(e,n){let{open:t,onOpenChange:r,dataRef:u,refs:c}=e,{enabled:l=!0,pointerDown:i=!1,toggle:s=!0,ignoreMouse:a=!1}=void 0===n?{}:n;const f=o.useRef();function d(){var e;return"BUTTON"===(null==(e=c.domReference.current)?void 0:e.tagName)}function m(){return q(c.domReference.current)}return l?{reference:{onPointerDown(e){f.current=e.pointerType},onMouseDown(e){0===e.button&&("mouse"===f.current&&a||i&&(t?!s||u.current.openEvent&&"mousedown"!==u.current.openEvent.type||r(!1):r(!0),u.current.openEvent=e.nativeEvent))},onClick(e){i&&f.current?f.current=void 0:"mouse"===f.current&&a||(t?!s||u.current.openEvent&&"click"!==u.current.openEvent.type||r(!1):r(!0),u.current.openEvent=e.nativeEvent)},onKeyDown(e){f.current=void 0,d()||(" "!==e.key||m()||e.preventDefault(),"Enter"===e.key&&(t?s&&r(!1):r(!0)))},onKeyUp(e){d()||m()||" "===e.key&&(t?s&&r(!1):r(!0))}}}:{}};function ce(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 le=function(e,n){let{open:t,onOpenChange:u,refs:c,events:l,nodeId:i}=e,{enabled:s=!0,escapeKey:a=!0,outsidePointerDown:f=!0,referencePointerDown:d=!1,ancestorScroll:m=!1,bubbles:v=!0}=void 0===n?{}:n;const p=E(),g=Y(u),h=null!=w();return o.useEffect((()=>{if(!t||!s)return;function e(e){if("Escape"===e.key){if(!v&&p&&D(p.nodesRef.current,i).length>0)return;l.emit("dismiss",{preventScroll:!1}),g.current(!1)}}function n(e){const n=p&&D(p.nodesRef.current,i).some((n=>{var t;return ce(e,null==(t=n.context)?void 0:t.refs.floating.current)}));ce(e,c.floating.current)||ce(e,c.domReference.current)||n||!v&&p&&D(p.nodesRef.current,i).length>0||(l.emit("dismiss",!!h&&{preventScroll:!0}),g.current(!1))}function o(){g.current(!1)}const u=L(c.floating.current);a&&u.addEventListener("keydown",e),f&&u.addEventListener("pointerdown",n);const d=(m?[...k(c.reference.current)?r(c.reference.current):[],...k(c.floating.current)?r(c.floating.current):[]]:[]).filter((e=>{var n;return e!==(null==(n=u.defaultView)?void 0:n.visualViewport)}));return d.forEach((e=>e.addEventListener("scroll",o,{passive:!0}))),()=>{a&&u.removeEventListener("keydown",e),f&&u.removeEventListener("pointerdown",n),d.forEach((e=>e.removeEventListener("scroll",o)))}}),[a,f,l,p,i,t,g,m,s,v,c,h]),s?{reference:{onPointerDown(){d&&(l.emit("dismiss"),u(!1))}}}:{}},ie=function(e,n){let{open:t,onOpenChange:r,dataRef:u,refs:c,events:l}=e,{enabled:i=!0,keyboardOnly:s=!0}=void 0===n?{}:n;const a=o.useRef(""),f=o.useRef(!1);return o.useEffect((()=>{var e;if(!i)return;const n=L(c.floating.current),r=null!=(e=n.defaultView)?e:window;function o(){a.current&&c.domReference.current===V(n)&&(f.current=!t)}function u(){setTimeout((()=>{f.current=!1,a.current=""}))}return r.addEventListener("focus",u),r.addEventListener("blur",o),()=>{r.removeEventListener("focus",u),r.removeEventListener("blur",o)}}),[c,t,i]),o.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;a.current=n,f.current=!(!n||!s)},onFocus(e){var n,t,o;f.current||"focus"===e.type&&"mousedown"===(null==(n=u.current.openEvent)?void 0:n.type)&&null!=(t=c.domReference.current)&&t.contains(null==(o=u.current.openEvent)?void 0:o.target)||(u.current.openEvent=e.nativeEvent,r(!0))},onBlur(e){var n,t;const o=e.relatedTarget;null!=(n=c.floating.current)&&n.contains(o)||null!=(t=c.domReference.current)&&t.contains(o)||(f.current=!1,r(!1))}}}:{}};function se(e,n){return n<0||n>=e.current.length}function ae(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 fe(e,n,t){switch(e){case"vertical":return n;case"horizontal":return t;default:return n||t}}function de(e,n){return fe(n,"ArrowUp"===e||"ArrowDown"===e,"ArrowLeft"===e||"ArrowRight"===e)}function me(e,n,t){return fe(n,"ArrowDown"===e,t?"ArrowLeft"===e:"ArrowRight"===e)||"Enter"===e||" "==e||""===e}function ve(e,n){return ae(e,{disabledIndices:n})}function pe(e,n){return ae(e,{decrement:!0,startingIndex:e.current.length,disabledIndices:n})}const ge=function(e,n){let{open:t,onOpenChange:r,refs:u}=e,{listRef:c,activeIndex:l,onNavigate:i,enabled:s=!0,selectedIndex:a=null,allowEscape:d=!1,loop:m=!1,nested:v=!1,rtl:p=!1,virtual:g=!1,focusItemOnOpen:h="auto",focusItemOnHover:b=!0,openOnArrowKeyDown:y=!0,disabledIndices:R=(y?void 0:[]),orientation:x="vertical"}=void 0===n?{listRef:{current:[]},activeIndex:null,onNavigate:()=>{}}:n;const T=w(),I=E(),k=G(t),A=o.useRef(h),M=o.useRef(null!=a?a:-1),O=o.useRef(null),D=Y(G(i)),P=Y(i),S=Y(R),F=o.useRef(!1),H=o.useRef(-1),[K,j]=o.useState(),N=o.useCallback(((e,n)=>{H.current=requestAnimationFrame((()=>{var t,r;g?j(null==(t=e.current[n.current])?void 0:t.id):null==(r=e.current[n.current])||r.focus({preventScroll:!0})}))}),[g]);function B(e){if(F.current=!0,v&&function(e,n,t){return fe(n,t?"ArrowRight"===e:"ArrowLeft"===e,"ArrowUp"===e)}(e.key,x,p))return U(e),r(!1),void(C(u.domReference.current)&&u.domReference.current.focus());const n=M.current,o=ve(c,R),l=pe(c,R);if("Home"===e.key&&(M.current=o,i(M.current)),"End"===e.key&&(M.current=l,i(M.current)),de(e.key,x)){if(U(e),t&&!g&&V(e.currentTarget.ownerDocument)===e.currentTarget)return M.current=me(e.key,x,p)?o:l,void i(M.current);me(e.key,x,p)?M.current=m?n>=l?d&&n!==c.current.length?-1:o:ae(c,{startingIndex:n,disabledIndices:R}):Math.min(l,ae(c,{startingIndex:n,disabledIndices:R})):M.current=m?n<=o?d&&-1!==n?c.current.length:l:ae(c,{startingIndex:n,decrement:!0,disabledIndices:R}):Math.max(o,ae(c,{startingIndex:n,decrement:!0,disabledIndices:R})),se(c,M.current)?i(null):i(M.current)}}return f((()=>{s&&(!k&&t&&A.current&&null!=a&&P.current(a),k&&!t&&(cancelAnimationFrame(H.current),M.current=-1,null==D.current||D.current(null)))}),[t,k,a,c,P,D,N,s]),f((()=>{if(s&&t)if(null==l){if(null!=a)return;k&&(M.current=-1,N(c,M)),!k&&A.current&&(null!=O.current||!0===A.current&&null==O.current)&&(M.current=null==O.current||me(O.current,x,p)||v?ve(c,S.current):pe(c,S.current),P.current(M.current),N(c,M))}else se(c,l)||(M.current=l,N(c,M))}),[t,k,l,a,v,c,P,N,s,d,x,p,g,S]),f((()=>{if(s&&!t&&k){var e,n;const t=null==I||null==(e=I.nodesRef.current.find((e=>e.id===T)))||null==(n=e.context)?void 0:n.refs.floating.current;t&&!t.contains(V(L(t)))&&t.focus({preventScroll:!0})}}),[s,t,k,I,T]),f((()=>{O.current=null})),s?{reference:{...g&&t&&null!=l&&{"aria-activedescendant":K},onKeyDown(e){if(F.current=!0,g&&t)return B(e);(0===e.key.indexOf("Arrow")||"Enter"===e.key||" "===e.key||""===e.key)&&(O.current=e.key),v?function(e,n,t){return fe(n,t?"ArrowLeft"===e:"ArrowRight"===e,"ArrowDown"===e)}(e.key,x,p)&&(U(e),t?(M.current=ve(c,R),i(M.current)):r(!0)):de(e.key,x)&&(null!=a&&(M.current=a),U(e),!t&&y?r(!0):B(e),t&&i(M.current))}},floating:{"aria-orientation":"both"===x?void 0:x,...g&&null!=l&&{"aria-activedescendant":K},onKeyDown:B,onPointerMove(){F.current=!1}},item:{onFocus(e){let{currentTarget:n}=e;const t=c.current.indexOf(n);-1!==t&&i(t)},onClick:e=>{let{currentTarget:n}=e;return n.focus({preventScroll:!0})},...b&&{onMouseMove(e){let{currentTarget:n}=e;const t=n;if(t){const e=c.current.indexOf(t);-1!==e&&i(e)}},onPointerLeave(){var e;F.current||(M.current=-1,N(c,M),P.current(null),g||null==(e=u.floating.current)||e.focus({preventScroll:!0}))}}}}:{}},he=function(e,n){var t;let{open:r,dataRef:u}=e,{listRef:c,activeIndex:l,onMatch:i=(()=>{}),enabled:s=!0,findMatch:a=null,resetMs:d=1e3,ignoreKeys:m=[],selectedIndex:v=null}=void 0===n?{listRef:{current:[]},activeIndex:null}:n;const p=o.useRef(),g=o.useRef(""),h=o.useRef(null!=(t=null!=v?v:l)?t:-1),b=o.useRef(null);function y(e){if(!e.currentTarget.contains(V(L(e.currentTarget))))return;g.current.length>0&&" "!==g.current[0]&&(u.current.typing=!0," "===e.key&&U(e));const n=c.current;if(null==n||["Home","End","Escape","Enter","Tab","ArrowUp","ArrowDown","ArrowLeft","ArrowRight",...m].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="",h.current=b.current),g.current+=e.key,clearTimeout(p.current),p.current=setTimeout((()=>{g.current="",h.current=b.current,u.current.typing=!1}),d);const t=h.current,r=[...n.slice((null!=t?t:0)+1),...n.slice(0,(null!=t?t:0)+1)],o=a?a(r,g.current):r.find((e=>0===(null==e?void 0:e.toLocaleLowerCase().indexOf(g.current)))),l=o?n.indexOf(o):-1;-1!==l&&(i(l),b.current=l)}return f((()=>{r&&(clearTimeout(p.current),b.current=null,g.current="")}),[r]),f((()=>{var e;r&&""===g.current&&(h.current=null!=(e=null!=v?v:l)?e:-1)}),[r,v,l]),s?{reference:{onKeyDown:y},floating:{onKeyDown:y}}:{}};export{_ as FloatingDelayGroup,z as FloatingFocusManager,x as FloatingNode,N as FloatingOverlay,H as FloatingPortal,T as FloatingTree,te as inner,P as safePolygon,ue as useClick,ee as useDelayGroup,$ as useDelayGroupContext,le as useDismiss,A as useFloating,R as useFloatingNodeId,w as useFloatingParentNodeId,F as useFloatingPortalNode,E as useFloatingTree,ie as useFocus,Q as useHover,h as useId,re as useInnerOffset,O as useInteractions,ge as useListNavigation,oe as useRole,he as useTypeahead}; | ||
import{useFloating as e,offset as n,detectOverflow as t,getOverflowAncestors as r}from"@floating-ui/react-dom";export*from"@floating-ui/react-dom";import*as o from"react";import{useLayoutEffect as u,useEffect as c,useRef as l}from"react";import{createPortal as i,flushSync as s}from"react-dom";import{hideOthers as a}from"aria-hidden";var f="undefined"!=typeof document?u:c;function d(){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 v=!1,m=0;const p=()=>"floating-ui-"+m++;const g=o["useId".toString()],h=null!=g?g:function(){const[e,n]=o.useState((()=>v?p():void 0));return f((()=>{null==e&&n(p())}),[]),o.useEffect((()=>{v||(v=!0)}),[]),e},b=o.createContext(null),y=o.createContext(null),w=()=>{var e,n;return null!=(e=null==(n=o.useContext(b))?void 0:n.id)?e:null},E=()=>o.useContext(y),R=()=>{const e=h(),n=E(),t=w();return f((()=>{const r={id:e,parentId:t};return null==n||n.addNode(r),()=>{null==n||n.removeNode(r)}}),[n,e,t]),e},x=e=>{let{children:n,id:t}=e;const r=w();return o.createElement(b.Provider,{value:o.useMemo((()=>({id:t,parentId:r})),[t,r])},n)},T=e=>{let{children:n}=e;const t=o.useRef([]),r=o.useCallback((e=>{t.current=[...t.current,e]}),[]),u=o.useCallback((e=>{t.current=t.current.filter((n=>n!==e))}),[]),c=o.useState((()=>d()))[0];return o.createElement(y.Provider,{value:o.useMemo((()=>({nodesRef:t,addNode:r,removeNode:u,events:c})),[t,r,u,c])},n)};function L(e){var n;return null!=(n=null==e?void 0:e.ownerDocument)?n:document}function I(e){var n;return null!=(n=L(e).defaultView)?n:window}function k(e){return!!e&&e instanceof I(e).Element}function C(e){return!!e&&e instanceof I(e).HTMLElement}function A(n){let{open:t=!1,onOpenChange:r=(()=>{}),whileElementsMounted:u,placement:c,middleware:l,strategy:i,nodeId:s}=void 0===n?{}:n;const a=E(),v=o.useRef(null),m=o.useRef({}),p=o.useState((()=>d()))[0],g=e({placement:c,middleware:l,strategy:i,whileElementsMounted:u}),h=o.useMemo((()=>({...g.refs,domReference:v})),[g.refs]),b=o.useMemo((()=>({...g,refs:h,dataRef:m,nodeId:s,events:p,open:t,onOpenChange:r})),[g,s,p,t,r,h]);f((()=>{const e=null==a?void 0:a.nodesRef.current.find((e=>e.id===s));e&&(e.context=b)}));const{reference:y}=g,w=o.useCallback((e=>{(k(e)||null===e)&&(b.refs.domReference.current=e),y(e)}),[y,b.refs]);return o.useMemo((()=>({...g,context:b,refs:h,reference:w})),[g,h,b,w])}function M(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 O=function(e){return void 0===e&&(e=[]),{getReferenceProps:n=>M(n,e,"reference"),getFloatingProps:n=>M(n,e,"floating"),getItemProps:n=>M(n,e,"item")}};function D(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 P(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: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:h}=e,b="composedPath"in e?e.composedPath()[0]:e.target;if("pointermove"===e.type&&null!=(v=i.domReference.current)&&v.contains(b))return;if(f&&D(f.nodesRef.current,a).some((e=>{let{context:n}=e;return null==n?void 0:n.open})))return;if(null!=(m=i.floating.current)&&m.contains(b)&&!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(),w=i.floating.current.getBoundingClientRect(),E=l.split("-")[0],R=o>w.right-w.width/2,x=c>w.bottom-w.height/2;if("top"===E&&c>=y.bottom-1||"bottom"===E&&c<=y.top+1||"left"===E&&o>=y.right-1||"right"===E&&o<=y.left+1)return p();switch(E){case"top":if(g>=w.left&&g<=w.right&&h>=w.top&&h<=y.top+1)return;break;case"bottom":if(g>=w.left&&g<=w.right&&h>=y.bottom-1&&h<=w.bottom)return;break;case"left":if(g>=w.left&&g<=y.left+1&&h>=w.top&&h<=w.bottom)return;break;case"right":if(g>=y.right-1&&g<=w.right&&h>=w.top&&h<=w.bottom)return}if(u)return p();const T=function(e){let[n,t]=e;const o=w.width>y.width,u=w.height>y.height;switch(E){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],...[[w.left,R||o?w.bottom-r:w.top],[w.right,R?o?w.bottom-r:w.top:w.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],...[[w.left,R||o?w.top+r:w.bottom],[w.right,R?o?w.top+r:w.bottom:w.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?w.right-r:w.left,w.top],[x?u?w.right-r:w.left:w.right-r,w.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?w.left+r:w.right,w.top],[x?u?w.left+r:w.right:w.left+r,w.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,s]=n[c]||[0,0];l>=r!=s>=r&&t<=(i-u)*(r-l)/(s-l)+u&&(o=!o)}return o}([g,h],T)?p():t&&(n=setTimeout(s,t))}}}const S="floating-ui-root",F=function(e){let{id:n=S,enabled:t=!0}=void 0===e?{}:e;const[r,u]=o.useState(null);return f((()=>{if(!t)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,t]),r},H=e=>{let{children:n,id:t=S,root:r=null}=e;const o=F({id:t,enabled:!r});return r?i(n,r):o?i(n,o):null};function K(){return K=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},K.apply(this,arguments)}const j="data-floating-ui-scroll-lock",N=o.forwardRef((function(e,n){let{lockScroll:t=!1,...r}=e;return f((()=>{var e,n,r,o;if(!t)return;if(document.body.hasAttribute(j))return;document.body.setAttribute(j,"");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(j),Object.assign(document.body.style,{overflow:"",[u]:""})};const l=null!=(e=null==(n=window.visualViewport)?void 0:n.offsetLeft)?e:0,i=null!=(r=null==(o=window.visualViewport)?void 0:o.offsetTop)?r:0,s=window.pageXOffset,a=window.pageYOffset;return Object.assign(document.body.style,{position:"fixed",overflow:"hidden",top:-(a-Math.floor(i))+"px",left:-(s-Math.floor(l))+"px",right:"0",[u]:c+"px"}),()=>{Object.assign(document.body.style,{position:"",overflow:"",top:"",left:"",right:"",[u]:""}),document.body.removeAttribute(j),window.scrollTo(s,a)}}),[t]),o.createElement("div",K({ref:n},r,{style:{position:"fixed",overflow:"auto",top:0,right:0,bottom:0,left:0,...r.style}}))}));function V(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 B="input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";function q(e){return C(e)&&e.matches(B)}function U(e){e.preventDefault(),e.stopPropagation()}function Y(e){const n=l(e);return f((()=>{n.current=e})),n}function X(e,n){void 0===n&&(n=!1),requestAnimationFrame((()=>{null==e||e.focus({preventScroll:n})}))}const W=o.forwardRef((function(e,n){return o.createElement("span",K({},e,{ref:n,tabIndex:0,style:{position:"fixed",opacity:"0",pointerEvents:"none",outline:"0"}}))}));function z(e){var n;let{context:{refs:t,nodeId:r,onOpenChange:u,dataRef:c,events:l},children:i,order:s=["content"],endGuard:f=!0,preventTabbing:d=!1,initialFocus:v=0,returnFocus:m=!0,modal:p=!0}=e;const g=Y(s),h=Y(u),b=E(),y=null==(null==b||null==(n=b.nodesRef.current.find((e=>e.id===r)))?void 0:n.parentId),w=o.useCallback((()=>g.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(C(e)){var n;return"-"!==(null!=(n=e.getAttribute("tabindex"))?n:"0")[0].trim()}}))),[g,t]);o.useEffect((()=>{if(!p)return;const e=0===w().filter((e=>e!==t.floating.current&&e!==t.domReference.current)).length;function n(n){if("Tab"===n.key){(d||e)&&U(n);const r=w(),o="composedPath"in n?n.composedPath()[0]:n.target;"reference"===g.current[0]&&o===t.domReference.current&&(U(n),n.shiftKey?X(r[r.length-1]):X(r[1])),"floating"===g.current[1]&&o===t.floating.current&&n.shiftKey&&(U(n),X(r[0]))}}const r=L(t.floating.current);return r.addEventListener("keydown",n),()=>{r.removeEventListener("keydown",n)}}),[d,p,w,g,t]),o.useEffect((()=>{function e(e){var n,o;const u=e.relatedTarget,c=!(null!=(n=t.floating.current)&&n.contains(u)),l=k(t.domReference.current)&&!t.domReference.current.contains(u),i=b&&D(b.nodesRef.current,r).length>0,s=b&&e.currentTarget===t.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&&l&&!i&&!s&&h.current(!1)}const n=t.floating.current,o=t.domReference.current;if(n&&C(o)){let t;return!p&&n.addEventListener("focusout",e),!p&&o.addEventListener("focusout",e),p&&(t=g.current.includes("reference")?a([o,n]):a(n)),()=>{!p&&n.removeEventListener("focusout",e),!p&&o.removeEventListener("focusout",e),null==t||t()}}}),[r,b,p,h,g,c,w,t]),o.useEffect((()=>{if(d&&!y)return;const e=t.floating.current,n=L(e);let r=m,o=!1,u=V(n);var c;if(u===n.body&&t.domReference.current&&(u=t.domReference.current),!d)if("number"==typeof v)X(null!=(c=w()[v])?c:e);else if(C(null==v?void 0:v.current)){var i;X(null!=(i=v.current)?i:e)}function s(e){void 0===e&&(e=!1),"object"==typeof e?(r=!0,o=e.preventScroll):r=e}return l.on("dismiss",s),()=>{l.off("dismiss",s),r&&C(u)&&X(u,o)}}),[d,w,v,m,t,l,y]);const R=()=>{var e;return"combobox"===(null==(e=t.domReference.current)?void 0:e.getAttribute("role"))&&q(t.domReference.current)};return o.createElement(o.Fragment,null,p&&o.createElement(W,{onFocus:e=>{if(R())return;U(e);const n=w();"reference"===s[0]?X(n[0]):X(n[n.length-1])}}),o.cloneElement(i,s.includes("floating")?{tabIndex:0}:{}),p&&f&&o.createElement(W,{onFocus:e=>{R()||(U(e),X(w()[0]))}}))}function G(e){const n=l();return f((()=>{n.current=e}),[e]),n.current}function J(e,n,t){return t&&"mouse"!==t?0:"number"==typeof e?e:null==e?void 0:e[n]}const Q=function(e,n){let{enabled:t=!0,delay:r=0,handleClose:u=null,mouseOnly:c=!1,restMs:l=0}=void 0===n?{}:n;const{open:i,onOpenChange:s,dataRef:a,events:d,refs:v}=e,m=E(),p=w(),g=Y(s),h=Y(u),b=G(i),y=o.useRef(),R=o.useRef(),x=o.useRef(),T=o.useRef(),I=o.useRef(!0),C=o.useRef(!1),A=o.useCallback((()=>{var e;const n=null==(e=a.current.openEvent)?void 0:e.type;return(null==n?void 0:n.includes("mouse"))&&"mousedown"!==n}),[a]);o.useEffect((()=>{if(t)return d.on("dismiss",e),()=>{d.off("dismiss",e)};function e(){clearTimeout(R.current),clearTimeout(T.current),I.current=!0}}),[t,d,v]),o.useEffect((()=>{if(!t||!h.current)return;function e(){A()&&g.current(!1)}const n=L(v.floating.current).documentElement;return n.addEventListener("mouseleave",e),()=>{n.removeEventListener("mouseleave",e)}}),[v,g,t,h,a,A]);const M=o.useCallback((function(e){void 0===e&&(e=!0);const n=J(r,"close",y.current);n&&!x.current?(clearTimeout(R.current),R.current=setTimeout((()=>g.current(!1)),n)):e&&(clearTimeout(R.current),g.current(!1))}),[r,g]),O=o.useCallback((()=>{x.current&&(L(v.floating.current).removeEventListener("pointermove",x.current),x.current=void 0)}),[v]),D=o.useCallback((()=>{L(v.floating.current).body.style.pointerEvents="",C.current=!1}),[v]);if(o.useEffect((()=>{if(!t)return;function n(){return!!a.current.openEvent&&["click","mousedown"].includes(a.current.openEvent.type)}function o(e){if(clearTimeout(R.current),I.current=!1,i||c&&"mouse"!==y.current||l>0&&0===J(r,"open"))return;a.current.openEvent=e;const n=J(r,"open",y.current);n?R.current=setTimeout((()=>{g.current(!0)}),n):g.current(!0)}function u(t){if(n())return;const r=L(v.floating.current);if(clearTimeout(T.current),h.current)return clearTimeout(R.current),x.current&&r.removeEventListener("pointermove",x.current),x.current=h.current({...e,tree:m,x:t.clientX,y:t.clientY,onClose(){D(),O(),M()}}),void r.addEventListener("pointermove",x.current);M()}function s(t){n()||null==h.current||h.current({...e,tree:m,x:t.clientX,y:t.clientY,leave:!0,onClose(){D(),O(),M()}})(t)}const f=v.floating.current,d=v.domReference.current;return k(d)?(i&&d.addEventListener("mouseleave",s),null==f||f.addEventListener("mouseleave",s),d.addEventListener("mousemove",o,{once:!0}),d.addEventListener("mouseenter",o),d.addEventListener("mouseleave",u),()=>{i&&d.removeEventListener("mouseleave",s),null==f||f.removeEventListener("mouseleave",s),d.removeEventListener("mousemove",o),d.removeEventListener("mouseenter",o),d.removeEventListener("mouseleave",u)}):void 0}),[t,M,e,r,h,a,c,g,i,m,l,O,D,v]),f((()=>{if(t&&i&&h.current&&A()){L(v.floating.current).body.style.pointerEvents="none",C.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=""}}}}),[t,i,p,v,m,h,a,A]),f((()=>{b&&!i&&(y.current=void 0,O(),D())})),o.useEffect((()=>()=>{O(),clearTimeout(R.current),clearTimeout(T.current),C.current&&D()}),[t,O,D]),!t)return{};function P(e){y.current=e.pointerType}return{reference:{onPointerDown:P,onPointerEnter:P,onMouseMove(){i||0===l||(clearTimeout(T.current),T.current=setTimeout((()=>{I.current||s(!0)}),l))}},floating:{onMouseEnter(){clearTimeout(R.current)},onMouseLeave(){M(!1)}}}},Z=o.createContext({delay:1e3,initialDelay:1e3,currentId:null,setCurrentId:()=>{},setState:()=>{}}),$=()=>o.useContext(Z),_=e=>{let{children:n,delay:t}=e;const[r,u]=o.useState({delay:t,initialDelay:t,currentId:null}),c=o.useCallback((e=>{u((n=>({...n,currentId:e})))}),[]);return o.createElement(Z.Provider,{value:o.useMemo((()=>({...r,setState:u,setCurrentId:c})),[r,u,c])},n)},ee=(e,n)=>{let{open:t,onOpenChange:r}=e,{id:u}=n;const{currentId:c,initialDelay:l,setState:i}=$(),s=Y(r);o.useEffect((()=>{c&&s.current&&(i((e=>({...e,delay:{open:1,close:J(l,"close")}}))),c!==u&&s.current(!1))}),[u,s,i,c,l]),o.useEffect((()=>{!t&&c===u&&s.current&&(s.current(!1),i((e=>({...e,delay:l,currentId:null}))))}),[t,i,c,u,s,l])};function ne(e,n){return{...e,rects:{...e.rects,floating:{...e.rects.floating,height:e.elements.floating[n]}}}}const te=e=>({name:"inner",options:e,async fn(r){const{listRef:o,overflowRef:u,onFallbackChange:c,offset:l=0,index:i=0,minItemsVisible:a=4,referenceOverflowThreshold:f=0,...d}=e,{rects:v,elements:{floating:m}}=r,p=o.current[i];if(!p)return{};const g={...r,...await n(-p.offsetTop-v.reference.height/2-p.offsetHeight/2-l).fn(r)},h=await t(ne(g,"scrollHeight"),d),b=await t(g,{...d,elementContext:"reference"}),y=Math.max(0,h.top),w=g.y+y,E=Math.max(0,m.scrollHeight-y-Math.max(0,h.bottom));return m.style.maxHeight=E+"px",m.scrollTop=y,c&&(m.offsetHeight<p.offsetHeight*Math.min(a,o.current.length-1)-1||b.top>=-f||b.bottom>=-f?s((()=>c(!0))):s((()=>c(!1)))),u&&(u.current=await t(ne({...g,y:w},"offsetHeight"),d)),{y:w}}}),re=(e,n)=>{let{open:t,refs:r}=e,{enabled:u=!0,overflowRef:c,onChange:l}=n;const i=Y(l),a=o.useRef(!1),f=o.useRef(null),d=o.useRef(null);return o.useEffect((()=>{if(!u)return;function e(e){if(e.ctrlKey||!n||null==c.current)return;const t=e.deltaY,r=c.current.top>=-.5,o=c.current.bottom>=-.5,u=n.scrollHeight-n.clientHeight,l=t<0?-1:1,a=t<0?"max":"min";n.scrollHeight<=n.clientHeight||(!r&&t>0||!o&&t<0?(e.preventDefault(),s((()=>{i.current((e=>e+Math[a](t,u*l)))}))):/firefox/i.test(function(){const e=navigator.userAgentData;return null!=e&&e.brands?e.brands.map((e=>{let{brand:n,version:t}=e;return n+"/"+t})).join(" "):navigator.userAgent}())&&(n.scrollTop+=t))}const n=r.floating.current;return t&&n?(n.addEventListener("wheel",e),requestAnimationFrame((()=>{f.current=n.scrollTop,null!=c.current&&(d.current={...c.current})})),()=>{f.current=null,d.current=null,n.removeEventListener("wheel",e)}):void 0}),[u,t,r,c,i]),u?{floating:{onKeyDown(){a.current=!0},onWheel(){a.current=!1},onPointerMove(){a.current=!1},onScroll(){const e=r.floating.current;if(c.current&&e&&a.current){if(null!==f.current){const n=e.scrollTop-f.current;(c.current.bottom<-.5&&n<-1||c.current.top<-.5&&n>1)&&s((()=>l((e=>e+n))))}requestAnimationFrame((()=>{f.current=e.scrollTop}))}}}}:{}},oe=function(e,n){let{open:t}=e,{enabled:r=!0,role:o="dialog"}=void 0===n?{}:n;const u=h(),c=h(),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}}}:{}},ue=function(e,n){let{open:t,onOpenChange:r,dataRef:u,refs:c}=e,{enabled:l=!0,pointerDown:i=!1,toggle:s=!0,ignoreMouse:a=!1}=void 0===n?{}:n;const f=o.useRef();function d(){var e;return"BUTTON"===(null==(e=c.domReference.current)?void 0:e.tagName)}function v(){return q(c.domReference.current)}return l?{reference:{onPointerDown(e){f.current=e.pointerType},onMouseDown(e){0===e.button&&("mouse"===f.current&&a||i&&(t?!s||u.current.openEvent&&"mousedown"!==u.current.openEvent.type||r(!1):r(!0),u.current.openEvent=e.nativeEvent))},onClick(e){i&&f.current?f.current=void 0:"mouse"===f.current&&a||(t?!s||u.current.openEvent&&"click"!==u.current.openEvent.type||r(!1):r(!0),u.current.openEvent=e.nativeEvent)},onKeyDown(e){f.current=void 0,d()||(" "!==e.key||v()||e.preventDefault(),"Enter"===e.key&&(t?s&&r(!1):r(!0)))},onKeyUp(e){d()||v()||" "===e.key&&(t?s&&r(!1):r(!0))}}}:{}};function ce(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 le=function(e,n){let{open:t,onOpenChange:u,refs:c,events:l,nodeId:i}=e,{enabled:s=!0,escapeKey:a=!0,outsidePointerDown:f=!0,referencePointerDown:d=!1,ancestorScroll:v=!1,bubbles:m=!0}=void 0===n?{}:n;const p=E(),g=Y(u),h=null!=w();return o.useEffect((()=>{if(!t||!s)return;function e(e){if("Escape"===e.key){if(!m&&p&&D(p.nodesRef.current,i).length>0)return;l.emit("dismiss",{preventScroll:!1}),g.current(!1)}}function n(e){const n=p&&D(p.nodesRef.current,i).some((n=>{var t;return ce(e,null==(t=n.context)?void 0:t.refs.floating.current)}));ce(e,c.floating.current)||ce(e,c.domReference.current)||n||!m&&p&&D(p.nodesRef.current,i).length>0||(l.emit("dismiss",!!h&&{preventScroll:!0}),g.current(!1))}function o(){g.current(!1)}const u=L(c.floating.current);a&&u.addEventListener("keydown",e),f&&u.addEventListener("pointerdown",n);const d=(v?[...k(c.reference.current)?r(c.reference.current):[],...k(c.floating.current)?r(c.floating.current):[]]:[]).filter((e=>{var n;return e!==(null==(n=u.defaultView)?void 0:n.visualViewport)}));return d.forEach((e=>e.addEventListener("scroll",o,{passive:!0}))),()=>{a&&u.removeEventListener("keydown",e),f&&u.removeEventListener("pointerdown",n),d.forEach((e=>e.removeEventListener("scroll",o)))}}),[a,f,l,p,i,t,g,v,s,m,c,h]),s?{reference:{onPointerDown(){d&&(l.emit("dismiss"),u(!1))}}}:{}},ie=function(e,n){let{open:t,onOpenChange:r,dataRef:u,refs:c,events:l}=e,{enabled:i=!0,keyboardOnly:s=!0}=void 0===n?{}:n;const a=o.useRef(""),f=o.useRef(!1);return o.useEffect((()=>{var e;if(!i)return;const n=L(c.floating.current),r=null!=(e=n.defaultView)?e:window;function o(){a.current&&c.domReference.current===V(n)&&(f.current=!t)}function u(){setTimeout((()=>{f.current=!1,a.current=""}))}return r.addEventListener("focus",u),r.addEventListener("blur",o),()=>{r.removeEventListener("focus",u),r.removeEventListener("blur",o)}}),[c,t,i]),o.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;a.current=n,f.current=!(!n||!s)},onFocus(e){var n,t,o;f.current||"focus"===e.type&&"mousedown"===(null==(n=u.current.openEvent)?void 0:n.type)&&null!=(t=c.domReference.current)&&t.contains(null==(o=u.current.openEvent)?void 0:o.target)||(u.current.openEvent=e.nativeEvent,r(!0))},onBlur(e){var n,t;const o=e.relatedTarget;null!=(n=c.floating.current)&&n.contains(o)||null!=(t=c.domReference.current)&&t.contains(o)||(f.current=!1,r(!1))}}}:{}};function se(e,n){return n<0||n>=e.current.length}function ae(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 fe(e,n,t){switch(e){case"vertical":return n;case"horizontal":return t;default:return n||t}}function de(e,n){return fe(n,"ArrowUp"===e||"ArrowDown"===e,"ArrowLeft"===e||"ArrowRight"===e)}function ve(e,n,t){return fe(n,"ArrowDown"===e,t?"ArrowLeft"===e:"ArrowRight"===e)||"Enter"===e||" "==e||""===e}function me(e,n){return ae(e,{disabledIndices:n})}function pe(e,n){return ae(e,{decrement:!0,startingIndex:e.current.length,disabledIndices:n})}const ge=function(e,n){let{open:t,onOpenChange:r,refs:u}=e,{listRef:c,activeIndex:l,onNavigate:i,enabled:s=!0,selectedIndex:a=null,allowEscape:d=!1,loop:v=!1,nested:m=!1,rtl:p=!1,virtual:g=!1,focusItemOnOpen:h="auto",focusItemOnHover:b=!0,openOnArrowKeyDown:y=!0,disabledIndices:R=(y?void 0:[]),orientation:x="vertical"}=void 0===n?{listRef:{current:[]},activeIndex:null,onNavigate:()=>{}}:n;const T=w(),I=E(),k=G(t),A=o.useRef(h),M=o.useRef(null!=a?a:-1),O=o.useRef(null),D=Y(G(i)),P=Y(i),S=Y(R),F=o.useRef(!1),H=o.useRef(-1),[K,j]=o.useState(),N=o.useCallback(((e,n)=>{H.current=requestAnimationFrame((()=>{var t,r;g?j(null==(t=e.current[n.current])?void 0:t.id):null==(r=e.current[n.current])||r.focus({preventScroll:!0})}))}),[g]);function B(e){if(F.current=!0,m&&function(e,n,t){return fe(n,t?"ArrowRight"===e:"ArrowLeft"===e,"ArrowUp"===e)}(e.key,x,p))return U(e),r(!1),void(C(u.domReference.current)&&u.domReference.current.focus());const n=M.current,o=me(c,R),l=pe(c,R);if("Home"===e.key&&(M.current=o,i(M.current)),"End"===e.key&&(M.current=l,i(M.current)),de(e.key,x)){if(U(e),t&&!g&&V(e.currentTarget.ownerDocument)===e.currentTarget)return M.current=ve(e.key,x,p)?o:l,void i(M.current);ve(e.key,x,p)?M.current=v?n>=l?d&&n!==c.current.length?-1:o:ae(c,{startingIndex:n,disabledIndices:R}):Math.min(l,ae(c,{startingIndex:n,disabledIndices:R})):M.current=v?n<=o?d&&-1!==n?c.current.length:l:ae(c,{startingIndex:n,decrement:!0,disabledIndices:R}):Math.max(o,ae(c,{startingIndex:n,decrement:!0,disabledIndices:R})),se(c,M.current)?i(null):i(M.current)}}return f((()=>{s&&(!k&&t&&A.current&&null!=a&&P.current(a),k&&!t&&(cancelAnimationFrame(H.current),M.current=-1,null==D.current||D.current(null)))}),[t,k,a,c,P,D,N,s]),f((()=>{if(s&&t)if(null==l){if(null!=a)return;k&&(M.current=-1,N(c,M)),!k&&A.current&&(null!=O.current||!0===A.current&&null==O.current)&&(M.current=null==O.current||ve(O.current,x,p)||m?me(c,S.current):pe(c,S.current),P.current(M.current),N(c,M))}else se(c,l)||(M.current=l,N(c,M))}),[t,k,l,a,m,c,P,N,s,d,x,p,g,S]),f((()=>{if(s&&!t&&k){var e,n;const t=null==I||null==(e=I.nodesRef.current.find((e=>e.id===T)))||null==(n=e.context)?void 0:n.refs.floating.current;t&&!t.contains(V(L(t)))&&t.focus({preventScroll:!0})}}),[s,t,k,I,T]),f((()=>{O.current=null})),s?{reference:{...g&&t&&null!=l&&{"aria-activedescendant":K},onKeyDown(e){if(F.current=!0,g&&t)return B(e);(0===e.key.indexOf("Arrow")||"Enter"===e.key||" "===e.key||""===e.key)&&(O.current=e.key),m?function(e,n,t){return fe(n,t?"ArrowLeft"===e:"ArrowRight"===e,"ArrowDown"===e)}(e.key,x,p)&&(U(e),t?(M.current=me(c,R),i(M.current)):r(!0)):de(e.key,x)&&(null!=a&&(M.current=a),U(e),!t&&y?r(!0):B(e),t&&i(M.current))}},floating:{"aria-orientation":"both"===x?void 0:x,...g&&null!=l&&{"aria-activedescendant":K},onKeyDown:B,onPointerMove(){F.current=!1}},item:{onFocus(e){let{currentTarget:n}=e;const t=c.current.indexOf(n);-1!==t&&i(t)},onClick:e=>{let{currentTarget:n}=e;return n.focus({preventScroll:!0})},...b&&{onMouseMove(e){let{currentTarget:n}=e;const t=n;if(t){const e=c.current.indexOf(t);-1!==e&&i(e)}},onPointerLeave(){var e;F.current||(M.current=-1,N(c,M),P.current(null),g||null==(e=u.floating.current)||e.focus({preventScroll:!0}))}}}}:{}},he=function(e,n){var t;let{open:r,dataRef:u}=e,{listRef:c,activeIndex:l,onMatch:i=(()=>{}),enabled:s=!0,findMatch:a=null,resetMs:d=1e3,ignoreKeys:v=[],selectedIndex:m=null}=void 0===n?{listRef:{current:[]},activeIndex:null}:n;const p=o.useRef(),g=o.useRef(""),h=o.useRef(null!=(t=null!=m?m:l)?t:-1),b=o.useRef(null);function y(e){if(!e.currentTarget.contains(V(L(e.currentTarget))))return;g.current.length>0&&" "!==g.current[0]&&(u.current.typing=!0," "===e.key&&U(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="",h.current=b.current),g.current+=e.key,clearTimeout(p.current),p.current=setTimeout((()=>{g.current="",h.current=b.current,u.current.typing=!1}),d);const t=h.current,r=[...n.slice((null!=t?t:0)+1),...n.slice(0,(null!=t?t:0)+1)],o=a?a(r,g.current):r.find((e=>0===(null==e?void 0:e.toLocaleLowerCase().indexOf(g.current)))),l=o?n.indexOf(o):-1;-1!==l&&(i(l),b.current=l)}return f((()=>{r&&(clearTimeout(p.current),b.current=null,g.current="")}),[r]),f((()=>{var e;r&&""===g.current&&(h.current=null!=(e=null!=m?m:l)?e:-1)}),[r,m,l]),s?{reference:{onKeyDown:y},floating:{onKeyDown:y}}:{}};export{_ as FloatingDelayGroup,z as FloatingFocusManager,x as FloatingNode,N as FloatingOverlay,H as FloatingPortal,T as FloatingTree,te as inner,P as safePolygon,ue as useClick,ee as useDelayGroup,$ as useDelayGroupContext,le as useDismiss,A as useFloating,R as useFloatingNodeId,w as useFloatingParentNodeId,F as useFloatingPortalNode,E as useFloatingTree,ie as useFocus,Q as useHover,h as useId,re as useInnerOffset,O as useInteractions,ge as useListNavigation,oe as useRole,he 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 l(){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 i=!1,a=0;const s=()=>"floating-ui-"+a++;const f=u["useId".toString()],d=null!=f?f:function(){const[e,t]=u.useState((()=>i?s():void 0));return c((()=>{null==e&&t(s())}),[]),u.useEffect((()=>{i||(i=!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 h(e){var t;return null!=(t=null==e?void 0:e.ownerDocument)?t:document}function y(e){var t;return null!=(t=h(e).defaultView)?t:window}function b(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",T=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 k(){return k=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},k.apply(this,arguments)}const I="data-floating-ui-scroll-lock",O=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(I))return;document.body.setAttribute(I,"");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(I),Object.assign(document.body.style,{overflow:"",[u]:""})};const l=null!=(e=null==(t=window.visualViewport)?void 0:t.offsetLeft)?e:0,i=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(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(I),window.scrollTo(a,s)}}),[n]),u.createElement("div",k({ref:t},r,{style:{position:"fixed",overflow:"auto",top:0,right:0,bottom:0,left:0,...r.style}}))}));var L=new WeakMap,M=new WeakMap,C={},A=0,D=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];C[n]||(C[n]=new WeakMap);var o=C[n],u=[],c=new Set,l=function(e){e&&!c.has(e)&&(c.add(e),l(e.parentNode))};r.forEach(l);var i=function(e){!e||r.indexOf(e)>=0||Array.prototype.forEach.call(e.children,(function(e){if(c.has(e))i(e);else{var t=e.getAttribute("aria-hidden"),r=null!==t&&"false"!==t,l=(L.get(e)||0)+1,a=(o.get(e)||0)+1;L.set(e,l),o.set(e,a),u.push(e),1===l&&r&&M.set(e,!0),1===a&&e.setAttribute(n,"true"),r||e.setAttribute("aria-hidden","true")}}))};return i(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||(M.has(e)||e.removeAttribute("aria-hidden"),M.delete(e)),r||e.removeAttribute(n)})),--A||(L=new WeakMap,L=new WeakMap,M=new WeakMap,C={})}};function P(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 H(e){const t=n.useRef(e);return c((()=>{t.current=e})),t}function N(e,t){void 0===t&&(t=!1),requestAnimationFrame((()=>{null==e||e.focus({preventScroll:t})}))}const K=u.forwardRef((function(e,t){return u.createElement("span",k({},e,{ref:t,tabIndex:0,style:{position:"fixed",opacity:"0",pointerEvents:"none",outline:"0"}}))}));function W(e){const t=n.useRef();return c((()=>{t.current=e}),[e]),t.current}function q(e,t,n){return n&&"mouse"!==n?0:"number"==typeof e?e:null==e?void 0:e[t]}const V=u.createContext({delay:1e3,initialDelay:1e3,currentId:null,setCurrentId:()=>{},setState:()=>{}}),B=()=>u.useContext(V);function U(e,t){return{...e,rects:{...e.rects,floating:{...e.rects.floating,height:e.elements.floating[t]}}}}function Y(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",_="ArrowLeft",z="ArrowRight";function J(e,t){return t<0||t>=e.current.length}function Q(e,t){let{startingIndex:n=-1,decrement:r=!1,disabledIndices:o}=void 0===t?{}:t;const u=e.current;let c=n;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 Z(e,t,n){switch(e){case"vertical":return t;case"horizontal":return n;default:return t||n}}function $(e,t){return Z(t,e===G||e===X,e===_||e===z)}function ee(e,t,n){return Z(t,e===X,n?e===_:e===z)||"Enter"===e||" "==e||""===e}function te(e,t){return Q(e,{disabledIndices:t})}function ne(e,t){return Q(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(V.Provider,{value:u.useMemo((()=>({...r,setState:o,setCurrentId:c})),[r,o,c])},t)},e.FloatingFocusManager=function(e){var t;let{context:{refs:n,nodeId:r,onOpenChange:o,dataRef:c,events:l},children:i,order:a=["content"],endGuard:s=!0,preventTabbing:f=!1,initialFocus:d=0,returnFocus:v=!0,modal:m=!0}=e;const p=H(a),y=H(o),w=g(),x=null==(null==w||null==(t=w.nodesRef.current.find((e=>e.id===r)))?void 0:t.parentId),T=u.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(E(e)){var t;return"-"!==(null!=(t=e.getAttribute("tabindex"))?t:"0")[0].trim()}}))),[p,n]);u.useEffect((()=>{if(!m)return;const e=0===T().filter((e=>e!==n.floating.current&&e!==n.domReference.current)).length;function t(t){if("Tab"===t.key){(f||e)&&j(t);const r=T(),o="composedPath"in t?t.composedPath()[0]:t.target;"reference"===p.current[0]&&o===n.domReference.current&&(j(t),t.shiftKey?N(r[r.length-1]):N(r[1])),"floating"===p.current[1]&&o===n.floating.current&&t.shiftKey&&(j(t),N(r[0]))}}const r=h(n.floating.current);return r.addEventListener("keydown",t),()=>{r.removeEventListener("keydown",t)}}),[f,m,T,p,n]),u.useEffect((()=>{function e(e){var t,o;const u=e.relatedTarget,c=!(null!=(t=n.floating.current)&&t.contains(u)),l=b(n.domReference.current)&&!n.domReference.current.contains(u),i=w&&R(w.nodesRef.current,r).length>0,a=w&&e.currentTarget===n.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}(w.nodesRef.current,r))?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&&l&&!i&&!a&&y.current(!1)}const t=n.floating.current,o=n.domReference.current;if(t&&E(o)){let n;return!m&&t.addEventListener("focusout",e),!m&&o.addEventListener("focusout",e),m&&(n=p.current.includes("reference")?D([o,t]):D(t)),()=>{!m&&t.removeEventListener("focusout",e),!m&&o.removeEventListener("focusout",e),null==n||n()}}}),[r,w,m,y,p,c,T,n]),u.useEffect((()=>{if(f&&!x)return;const e=n.floating.current,t=h(e);let r=v,o=!1,u=P(t);var c;if(u===t.body&&n.domReference.current&&(u=n.domReference.current),!f)if("number"==typeof d)N(null!=(c=T()[d])?c:e);else if(E(null==d?void 0:d.current)){var i;N(null!=(i=d.current)?i:e)}function a(e){void 0===e&&(e=!1),"object"==typeof e?(r=!0,o=e.preventScroll):r=e}return l.on("dismiss",a),()=>{l.off("dismiss",a),r&&E(u)&&N(u,o)}}),[f,T,d,v,n,l,x]);const k=()=>{var e;return"combobox"===(null==(e=n.domReference.current)?void 0:e.getAttribute("role"))&&S(n.domReference.current)};return u.createElement(u.Fragment,null,m&&u.createElement(K,{onFocus:e=>{if(k())return;j(e);const t=T();"reference"===a[0]?N(t[0]):N(t[t.length-1])}}),u.cloneElement(i,a.includes("floating")?{tabIndex:0}:{}),m&&s&&u.createElement(K,{onFocus:e=>{k()||(j(e),N(T()[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=O,e.FloatingPortal=e=>{let{children:t,id:n=x,root:o=null}=e;const u=T({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((()=>l()))[0];return u.createElement(m.Provider,{value:u.useMemo((()=>({nodesRef:n,addNode:r,removeNode:o,events:c})),[n,r,o,c])},t)},e.inner=e=>({name:"inner",options:e,async fn(n){const{listRef:o,overflowRef:u,onFallbackChange:c,offset:l=0,index:i=0,minItemsVisible:a=4,referenceOverflowThreshold:s=0,...f}=e,{rects:d,elements:{floating:v}}=n,m=o.current[i];if(!m)return{};const p={...n,...await t.offset(-m.offsetTop-d.reference.height/2-m.offsetHeight/2-l).fn(n)},g=await t.detectOverflow(U(p,"scrollHeight"),f),h=await t.detectOverflow(p,{...f,elementContext:"reference"}),y=Math.max(0,g.top),b=p.y+y,E=Math.max(0,v.scrollHeight-y-Math.max(0,g.bottom));return v.style.maxHeight=E+"px",v.scrollTop=y,c&&(v.offsetHeight<m.offsetHeight*Math.min(a,o.current.length-1)-1||h.top>=-s||h.bottom>=-s?r.flushSync((()=>c(!0))):r.flushSync((()=>c(!1)))),u&&(u.current=await t.detectOverflow(U({...p,y:b},"offsetHeight"),f)),{y:b}}}),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:l,refs:i,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:h}=e,y="composedPath"in e?e.composedPath()[0]:e.target;if("pointermove"===e.type&&null!=(v=i.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=i.floating.current)&&m.contains(y)&&!d)return void(u=!0);if(!i.domReference.current||!i.floating.current||null==l||null==o||null==c)return;const b=i.domReference.current.getBoundingClientRect(),E=i.floating.current.getBoundingClientRect(),w=l.split("-")[0],x=o>E.right-E.width/2,T=c>E.bottom-E.height/2;if("top"===w&&c>=b.bottom-1||"bottom"===w&&c<=b.top+1||"left"===w&&o>=b.right-1||"right"===w&&o<=b.left+1)return p();switch(w){case"top":if(g>=E.left&&g<=E.right&&h>=E.top&&h<=b.top+1)return;break;case"bottom":if(g>=E.left&&g<=E.right&&h>=b.bottom-1&&h<=E.bottom)return;break;case"left":if(g>=E.left&&g<=b.left+1&&h>=E.top&&h<=E.bottom)return;break;case"right":if(g>=b.right-1&&g<=E.right&&h>=E.top&&h<=E.bottom)return}if(u)return p();const k=function(e){let[t,n]=e;const o=E.width>b.width,u=E.height>b.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:T?n+4*r:n-4*r],o=[t+r+1,u?n-r/2:T?n+4*r:n-4*r];return[...[[T||u?E.right-r:E.left,E.top],[T?u?E.right-r:E.left:E.right-r,E.bottom]],e,o]}case"right":return[[t-r,u?n+r/2:T?n+4*r:n-4*r],[t-r,u?n-r/2:T?n+4*r:n-4*r],...[[T||u?E.left+r:E.right,E.top],[T?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,l]=t[e]||[0,0],[i,a]=t[c]||[0,0];l>=r!=a>=r&&n<=(i-u)*(r-l)/(a-l)+u&&(o=!o)}return o}([g,h],k)?p():n&&(t=setTimeout(a,n))}}},e.useClick=function(e,t){let{open:n,onOpenChange:r,dataRef:o,refs:c}=e,{enabled:l=!0,pointerDown:i=!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 l?{reference:{onPointerDown(e){f.current=e.pointerType},onMouseDown(e){0===e.button&&("mouse"===f.current&&s||i&&(n?!a||o.current.openEvent&&"mousedown"!==o.current.openEvent.type||r(!1):r(!0),o.current.openEvent=e.nativeEvent))},onClick(e){i&&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:l,setState:i}=B(),a=H(r);u.useEffect((()=>{c&&a.current&&(i((e=>({...e,delay:{open:1,close:q(l,"close")}}))),c!==o&&a.current(!1))}),[o,a,i,c,l]),u.useEffect((()=>{!n&&c===o&&a.current&&(a.current(!1),i((e=>({...e,delay:l,currentId:null}))))}),[n,i,c,o,a,l])},e.useDelayGroupContext=B,e.useDismiss=function(e,n){let{open:r,onOpenChange:o,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===n?{}:n;const y=g(),E=H(o),w=null!=p();return u.useEffect((()=>{if(!r||!a)return;function e(e){if("Escape"===e.key){if(!m&&y&&R(y.nodesRef.current,i).length>0)return;l.emit("dismiss",{preventScroll:!1}),E.current(!1)}}function n(e){const t=y&&R(y.nodesRef.current,i).some((t=>{var n;return Y(e,null==(n=t.context)?void 0:n.refs.floating.current)}));Y(e,c.floating.current)||Y(e,c.domReference.current)||t||!m&&y&&R(y.nodesRef.current,i).length>0||(l.emit("dismiss",!!w&&{preventScroll:!0}),E.current(!1))}function o(){E.current(!1)}const u=h(c.floating.current);s&&u.addEventListener("keydown",e),f&&u.addEventListener("pointerdown",n);const d=(v?[...b(c.reference.current)?t.getOverflowAncestors(c.reference.current):[],...b(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("pointerdown",n),d.forEach((e=>e.removeEventListener("scroll",o)))}}),[s,f,l,y,i,r,E,v,a,m,c,w]),a?{reference:{onPointerDown(){d&&(l.emit("dismiss"),o(!1))}}}:{}},e.useFloating=function(e){let{open:n=!1,onOpenChange:r=(()=>{}),whileElementsMounted:o,placement:i,middleware:a,strategy:s,nodeId:f}=void 0===e?{}:e;const d=g(),v=u.useRef(null),m=u.useRef({}),p=u.useState((()=>l()))[0],h=t.useFloating({placement:i,middleware:a,strategy:s,whileElementsMounted:o}),y=u.useMemo((()=>({...h.refs,domReference:v})),[h.refs]),E=u.useMemo((()=>({...h,refs:y,dataRef:m,nodeId:f,events:p,open:n,onOpenChange:r})),[h,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}=h,R=u.useCallback((e=>{(b(e)||null===e)&&(E.refs.domReference.current=e),w(e)}),[w,E.refs]);return u.useMemo((()=>({...h,context:E,refs:y,reference:R})),[h,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=T,e.useFloatingTree=g,e.useFocus=function(e,t){let{open:n,onOpenChange:r,dataRef:o,refs:c,events:l}=e,{enabled:i=!0,keyboardOnly:a=!0}=void 0===t?{}:t;const s=u.useRef(""),f=u.useRef(!1);return u.useEffect((()=>{var e;if(!i)return;const t=h(c.floating.current),r=null!=(e=t.defaultView)?e:window;function o(){s.current&&c.domReference.current===P(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,i]),u.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: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:l=!1,restMs:i=0}=void 0===t?{}:t;const{open:a,onOpenChange:s,dataRef:f,events:d,refs:v}=e,m=g(),y=p(),E=H(s),w=H(o),R=W(a),x=u.useRef(),T=u.useRef(),k=u.useRef(),I=u.useRef(),O=u.useRef(!0),L=u.useRef(!1);u.useEffect((()=>{if(n)return d.on("dismiss",e),()=>{d.off("dismiss",e)};function e(){clearTimeout(T.current),clearTimeout(I.current),O.current=!0}}),[n,d,v]),u.useEffect((()=>{if(!n||!w.current)return;function e(){var e;const t=null==(e=f.current.openEvent)?void 0:e.type;null!=t&&t.includes("mouse")&&"mousedown"!==t&&E.current(!1)}const t=h(v.floating.current).documentElement;return t.addEventListener("mouseleave",e),()=>{t.removeEventListener("mouseleave",e)}}),[v,E,n,w,f]);const M=u.useCallback((function(e){void 0===e&&(e=!0);const t=q(r,"close",x.current);t&&!k.current?(clearTimeout(T.current),T.current=setTimeout((()=>E.current(!1)),t)):e&&(clearTimeout(T.current),E.current(!1))}),[r,E]),C=u.useCallback((()=>{k.current&&(h(v.floating.current).removeEventListener("pointermove",k.current),k.current=void 0)}),[v]),A=u.useCallback((()=>{h(v.floating.current).body.style.pointerEvents="",L.current=!1}),[v]);if(u.useEffect((()=>{if(!n)return;function t(){return!!f.current.openEvent&&["click","mousedown"].includes(f.current.openEvent.type)}function o(e){if(clearTimeout(T.current),O.current=!1,a||l&&"mouse"!==x.current||i>0&&0===q(r,"open"))return;f.current.openEvent=e;const t=q(r,"open",x.current);t?T.current=setTimeout((()=>{E.current(!0)}),t):E.current(!0)}function u(n){if(t())return;const r=h(v.floating.current);if(clearTimeout(I.current),w.current)return clearTimeout(T.current),k.current&&r.removeEventListener("pointermove",k.current),k.current=w.current({...e,tree:m,x:n.clientX,y:n.clientY,onClose(){C(),M()}}),void r.addEventListener("pointermove",k.current);M()}function c(n){t()||null==w.current||w.current({...e,tree:m,x:n.clientX,y:n.clientY,leave:!0,onClose(){C(),M()}})(n)}const s=v.floating.current,d=v.domReference.current;return b(d)?(a&&d.addEventListener("mouseleave",c),null==s||s.addEventListener("mouseleave",c),d.addEventListener("mousemove",o,{once:!0}),d.addEventListener("mouseenter",o),d.addEventListener("mouseleave",u),()=>{a&&d.removeEventListener("mouseleave",c),null==s||s.removeEventListener("mouseleave",c),d.removeEventListener("mousemove",o),d.removeEventListener("mouseenter",o),d.removeEventListener("mouseleave",u)}):void 0}),[n,M,e,r,w,f,l,E,a,m,i,C,v]),c((()=>{if(n&&a&&w.current){h(v.floating.current).body.style.pointerEvents="none",L.current=!0;const n=v.domReference.current,r=v.floating.current;if(b(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,w,f]),c((()=>{R&&!a&&(x.current=void 0,C(),A())})),u.useEffect((()=>()=>{C(),clearTimeout(T.current),clearTimeout(I.current),L.current&&A()}),[C,A]),!n)return{};function D(e){x.current=e.pointerType}return{reference:{onPointerDown:D,onPointerEnter:D,onMouseMove(){a||0===i||(clearTimeout(I.current),I.current=setTimeout((()=>{O.current||s(!0)}),i))}},floating:{onMouseEnter(){clearTimeout(T.current)},onMouseLeave(){M(!1)}}}},e.useId=d,e.useInnerOffset=(e,t)=>{let{open:n,refs:o}=e,{enabled:c=!0,overflowRef:l,onChange:i}=t;const a=H(i),s=u.useRef(!1),f=u.useRef(null),d=u.useRef(null);return u.useEffect((()=>{if(!c)return;function e(e){if(e.ctrlKey||!t||null==l.current)return;const n=e.deltaY,o=l.current.top>=-.5,u=l.current.bottom>=-.5,c=t.scrollHeight-t.clientHeight,i=n<0?-1:1,s=n<0?"max":"min";t.scrollHeight<=t.clientHeight||(!o&&n>0||!u&&n<0?(e.preventDefault(),r.flushSync((()=>{a.current((e=>e+Math[s](n,c*i)))}))):/firefox/i.test(function(){const e=navigator.userAgentData;return null!=e&&e.brands?e.brands.map((e=>{let{brand:t,version:n}=e;return t+"/"+n})).join(" "):navigator.userAgent}())&&(t.scrollTop+=n))}const t=o.floating.current;return n&&t?(t.addEventListener("wheel",e),requestAnimationFrame((()=>{f.current=t.scrollTop,null!=l.current&&(d.current={...l.current})})),()=>{f.current=null,d.current=null,t.removeEventListener("wheel",e)}):void 0}),[c,n,o,l,a]),c?{floating:{onKeyDown(){s.current=!0},onWheel(){s.current=!1},onPointerMove(){s.current=!1},onScroll(){const e=o.floating.current;if(l.current&&e&&s.current){if(null!==f.current){const t=e.scrollTop-f.current;(l.current.bottom<-.5&&t<-1||l.current.top<-.5&&t>1)&&r.flushSync((()=>i((e=>e+t))))}requestAnimationFrame((()=>{f.current=e.scrollTop}))}}}}:{}},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:l,activeIndex:i,onNavigate:a,enabled:s=!0,selectedIndex:f=null,allowEscape:d=!1,loop:v=!1,nested:m=!1,rtl:y=!1,virtual:b=!1,focusItemOnOpen:w="auto",focusItemOnHover:R=!0,openOnArrowKeyDown:x=!0,disabledIndices:T=(x?void 0:[]),orientation:k="vertical"}=void 0===t?{listRef:{current:[]},activeIndex:null,onNavigate:()=>{}}:t;const I=p(),O=g(),L=W(n),M=u.useRef(w),C=u.useRef(null!=f?f:-1),A=u.useRef(null),D=H(W(a)),F=H(a),S=H(T),N=u.useRef(!1),K=u.useRef(-1),[q,V]=u.useState(),B=u.useCallback(((e,t)=>{K.current=requestAnimationFrame((()=>{var n,r;b?V(null==(n=e.current[t.current])?void 0:n.id):null==(r=e.current[t.current])||r.focus({preventScroll:!0})}))}),[b]);function U(e){if(N.current=!0,m&&function(e,t,n){return Z(t,n?e===z:e===_,e===G)}(e.key,k,y))return j(e),r(!1),void(E(o.domReference.current)&&o.domReference.current.focus());const t=C.current,u=te(l,T),c=ne(l,T);if("Home"===e.key&&(C.current=u,a(C.current)),"End"===e.key&&(C.current=c,a(C.current)),$(e.key,k)){if(j(e),n&&!b&&P(e.currentTarget.ownerDocument)===e.currentTarget)return C.current=ee(e.key,k,y)?u:c,void a(C.current);ee(e.key,k,y)?C.current=v?t>=c?d&&t!==l.current.length?-1:u:Q(l,{startingIndex:t,disabledIndices:T}):Math.min(c,Q(l,{startingIndex:t,disabledIndices:T})):C.current=v?t<=u?d&&-1!==t?l.current.length:c:Q(l,{startingIndex:t,decrement:!0,disabledIndices:T}):Math.max(u,Q(l,{startingIndex:t,decrement:!0,disabledIndices:T})),J(l,C.current)?a(null):a(C.current)}}return c((()=>{s&&(!L&&n&&M.current&&null!=f&&F.current(f),L&&!n&&(cancelAnimationFrame(K.current),C.current=-1,null==D.current||D.current(null)))}),[n,L,f,l,F,D,B,s]),c((()=>{if(s&&n)if(null==i){if(null!=f)return;L&&(C.current=-1,B(l,C)),!L&&M.current&&(null!=A.current||!0===M.current&&null==A.current)&&(C.current=null==A.current||ee(A.current,k,y)||m?te(l,S.current):ne(l,S.current),F.current(C.current),B(l,C))}else J(l,i)||(C.current=i,B(l,C))}),[n,L,i,f,m,l,F,B,s,d,k,y,b,S]),c((()=>{if(s&&!n&&L){var e,t;const n=null==O||null==(e=O.nodesRef.current.find((e=>e.id===I)))||null==(t=e.context)?void 0:t.refs.floating.current;n&&!n.contains(P(h(n)))&&n.focus({preventScroll:!0})}}),[s,n,L,O,I]),c((()=>{A.current=null})),s?{reference:{...b&&n&&null!=i&&{"aria-activedescendant":q},onKeyDown(e){if(N.current=!0,b&&n)return U(e);(0===e.key.indexOf("Arrow")||"Enter"===e.key||" "===e.key||""===e.key)&&(A.current=e.key),m?function(e,t,n){return Z(t,n?e===_:e===z,e===X)}(e.key,k,y)&&(j(e),n?(C.current=te(l,T),a(C.current)):r(!0)):$(e.key,k)&&(null!=f&&(C.current=f),j(e),!n&&x?r(!0):U(e),n&&a(C.current))}},floating:{"aria-orientation":"both"===k?void 0:k,...b&&null!=i&&{"aria-activedescendant":q},onKeyDown:U,onPointerMove(){N.current=!1}},item:{onFocus(e){let{currentTarget:t}=e;const n=l.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=l.current.indexOf(n);-1!==e&&a(e)}},onPointerLeave(){var e;N.current||(C.current=-1,B(l,C),F.current(null),b||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(),l={id:u,role:o};return r?"tooltip"===o?{reference:{"aria-describedby":n?u:void 0},floating:l}:{reference:{"aria-expanded":n?"true":"false","aria-haspopup":o,"aria-controls":n?u:void 0,..."listbox"===o&&{role:"combobox"},..."menu"===o&&{id:c}},floating:{...l,..."menu"===o&&{"aria-labelledby":c}}}:{}},e.useTypeahead=function(e,t){var n;let{open:r,dataRef:o}=e,{listRef:l,activeIndex:i,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:i)?n:-1),b=u.useRef(null);function E(e){if(!e.currentTarget.contains(P(h(e.currentTarget))))return;g.current.length>0&&" "!==g.current[0]&&(o.current.typing=!0," "===e.key&&j(e));const t=l.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=b.current),g.current+=e.key,clearTimeout(p.current),p.current=setTimeout((()=>{g.current="",y.current=b.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),b.current=c)}return c((()=>{r&&(clearTimeout(p.current),b.current=null,g.current="")}),[r]),c((()=>{var e;r&&""===g.current&&(y.current=null!=(e=null!=m?m:i)?e:-1)}),[r,m,i]),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 l(){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 i=!1,a=0;const s=()=>"floating-ui-"+a++;const f=u["useId".toString()],d=null!=f?f:function(){const[e,t]=u.useState((()=>i?s():void 0));return c((()=>{null==e&&t(s())}),[]),u.useEffect((()=>{i||(i=!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 h(e){var t;return null!=(t=null==e?void 0:e.ownerDocument)?t:document}function b(e){var t;return null!=(t=h(e).defaultView)?t:window}function y(e){return!!e&&e instanceof b(e).Element}function E(e){return!!e&&e instanceof b(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 T(){return T=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},T.apply(this,arguments)}const I="data-floating-ui-scroll-lock",O=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(I))return;document.body.setAttribute(I,"");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(I),Object.assign(document.body.style,{overflow:"",[u]:""})};const l=null!=(e=null==(t=window.visualViewport)?void 0:t.offsetLeft)?e:0,i=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(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(I),window.scrollTo(a,s)}}),[n]),u.createElement("div",T({ref:t},r,{style:{position:"fixed",overflow:"auto",top:0,right:0,bottom:0,left:0,...r.style}}))}));var L=new WeakMap,M=new WeakMap,C={},A=0,D=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];C[n]||(C[n]=new WeakMap);var o=C[n],u=[],c=new Set,l=function(e){e&&!c.has(e)&&(c.add(e),l(e.parentNode))};r.forEach(l);var i=function(e){!e||r.indexOf(e)>=0||Array.prototype.forEach.call(e.children,(function(e){if(c.has(e))i(e);else{var t=e.getAttribute("aria-hidden"),r=null!==t&&"false"!==t,l=(L.get(e)||0)+1,a=(o.get(e)||0)+1;L.set(e,l),o.set(e,a),u.push(e),1===l&&r&&M.set(e,!0),1===a&&e.setAttribute(n,"true"),r||e.setAttribute("aria-hidden","true")}}))};return i(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||(M.has(e)||e.removeAttribute("aria-hidden"),M.delete(e)),r||e.removeAttribute(n)})),--A||(L=new WeakMap,L=new WeakMap,M=new WeakMap,C={})}};function P(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 H(e){const t=n.useRef(e);return c((()=>{t.current=e})),t}function N(e,t){void 0===t&&(t=!1),requestAnimationFrame((()=>{null==e||e.focus({preventScroll:t})}))}const K=u.forwardRef((function(e,t){return u.createElement("span",T({},e,{ref:t,tabIndex:0,style:{position:"fixed",opacity:"0",pointerEvents:"none",outline:"0"}}))}));function W(e){const t=n.useRef();return c((()=>{t.current=e}),[e]),t.current}function q(e,t,n){return n&&"mouse"!==n?0:"number"==typeof e?e:null==e?void 0:e[t]}const V=u.createContext({delay:1e3,initialDelay:1e3,currentId:null,setCurrentId:()=>{},setState:()=>{}}),B=()=>u.useContext(V);function U(e,t){return{...e,rects:{...e.rects,floating:{...e.rects.floating,height:e.elements.floating[t]}}}}function Y(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",_="ArrowLeft",z="ArrowRight";function J(e,t){return t<0||t>=e.current.length}function Q(e,t){let{startingIndex:n=-1,decrement:r=!1,disabledIndices:o}=void 0===t?{}:t;const u=e.current;let c=n;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 Z(e,t,n){switch(e){case"vertical":return t;case"horizontal":return n;default:return t||n}}function $(e,t){return Z(t,e===G||e===X,e===_||e===z)}function ee(e,t,n){return Z(t,e===X,n?e===_:e===z)||"Enter"===e||" "==e||""===e}function te(e,t){return Q(e,{disabledIndices:t})}function ne(e,t){return Q(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(V.Provider,{value:u.useMemo((()=>({...r,setState:o,setCurrentId:c})),[r,o,c])},t)},e.FloatingFocusManager=function(e){var t;let{context:{refs:n,nodeId:r,onOpenChange:o,dataRef:c,events:l},children:i,order:a=["content"],endGuard:s=!0,preventTabbing:f=!1,initialFocus:d=0,returnFocus:v=!0,modal:m=!0}=e;const p=H(a),b=H(o),w=g(),x=null==(null==w||null==(t=w.nodesRef.current.find((e=>e.id===r)))?void 0:t.parentId),k=u.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(E(e)){var t;return"-"!==(null!=(t=e.getAttribute("tabindex"))?t:"0")[0].trim()}}))),[p,n]);u.useEffect((()=>{if(!m)return;const e=0===k().filter((e=>e!==n.floating.current&&e!==n.domReference.current)).length;function t(t){if("Tab"===t.key){(f||e)&&j(t);const r=k(),o="composedPath"in t?t.composedPath()[0]:t.target;"reference"===p.current[0]&&o===n.domReference.current&&(j(t),t.shiftKey?N(r[r.length-1]):N(r[1])),"floating"===p.current[1]&&o===n.floating.current&&t.shiftKey&&(j(t),N(r[0]))}}const r=h(n.floating.current);return r.addEventListener("keydown",t),()=>{r.removeEventListener("keydown",t)}}),[f,m,k,p,n]),u.useEffect((()=>{function e(e){var t,o;const u=e.relatedTarget,c=!(null!=(t=n.floating.current)&&t.contains(u)),l=y(n.domReference.current)&&!n.domReference.current.contains(u),i=w&&R(w.nodesRef.current,r).length>0,a=w&&e.currentTarget===n.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}(w.nodesRef.current,r))?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&&l&&!i&&!a&&b.current(!1)}const t=n.floating.current,o=n.domReference.current;if(t&&E(o)){let n;return!m&&t.addEventListener("focusout",e),!m&&o.addEventListener("focusout",e),m&&(n=p.current.includes("reference")?D([o,t]):D(t)),()=>{!m&&t.removeEventListener("focusout",e),!m&&o.removeEventListener("focusout",e),null==n||n()}}}),[r,w,m,b,p,c,k,n]),u.useEffect((()=>{if(f&&!x)return;const e=n.floating.current,t=h(e);let r=v,o=!1,u=P(t);var c;if(u===t.body&&n.domReference.current&&(u=n.domReference.current),!f)if("number"==typeof d)N(null!=(c=k()[d])?c:e);else if(E(null==d?void 0:d.current)){var i;N(null!=(i=d.current)?i:e)}function a(e){void 0===e&&(e=!1),"object"==typeof e?(r=!0,o=e.preventScroll):r=e}return l.on("dismiss",a),()=>{l.off("dismiss",a),r&&E(u)&&N(u,o)}}),[f,k,d,v,n,l,x]);const T=()=>{var e;return"combobox"===(null==(e=n.domReference.current)?void 0:e.getAttribute("role"))&&S(n.domReference.current)};return u.createElement(u.Fragment,null,m&&u.createElement(K,{onFocus:e=>{if(T())return;j(e);const t=k();"reference"===a[0]?N(t[0]):N(t[t.length-1])}}),u.cloneElement(i,a.includes("floating")?{tabIndex:0}:{}),m&&s&&u.createElement(K,{onFocus:e=>{T()||(j(e),N(k()[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=O,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((()=>l()))[0];return u.createElement(m.Provider,{value:u.useMemo((()=>({nodesRef:n,addNode:r,removeNode:o,events:c})),[n,r,o,c])},t)},e.inner=e=>({name:"inner",options:e,async fn(n){const{listRef:o,overflowRef:u,onFallbackChange:c,offset:l=0,index:i=0,minItemsVisible:a=4,referenceOverflowThreshold:s=0,...f}=e,{rects:d,elements:{floating:v}}=n,m=o.current[i];if(!m)return{};const p={...n,...await t.offset(-m.offsetTop-d.reference.height/2-m.offsetHeight/2-l).fn(n)},g=await t.detectOverflow(U(p,"scrollHeight"),f),h=await t.detectOverflow(p,{...f,elementContext:"reference"}),b=Math.max(0,g.top),y=p.y+b,E=Math.max(0,v.scrollHeight-b-Math.max(0,g.bottom));return v.style.maxHeight=E+"px",v.scrollTop=b,c&&(v.offsetHeight<m.offsetHeight*Math.min(a,o.current.length-1)-1||h.top>=-s||h.bottom>=-s?r.flushSync((()=>c(!0))):r.flushSync((()=>c(!1)))),u&&(u.current=await t.detectOverflow(U({...p,y:y},"offsetHeight"),f)),{y:y}}}),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:l,refs:i,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:h}=e,b="composedPath"in e?e.composedPath()[0]:e.target;if("pointermove"===e.type&&null!=(v=i.domReference.current)&&v.contains(b))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=i.floating.current)&&m.contains(b)&&!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],x=o>E.right-E.width/2,k=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&&h>=E.top&&h<=y.top+1)return;break;case"bottom":if(g>=E.left&&g<=E.right&&h>=y.bottom-1&&h<=E.bottom)return;break;case"left":if(g>=E.left&&g<=y.left+1&&h>=E.top&&h<=E.bottom)return;break;case"right":if(g>=y.right-1&&g<=E.right&&h>=E.top&&h<=E.bottom)return}if(u)return p();const T=function(e){let[t,n]=e;const o=E.width>y.width,u=E.height>y.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,l]=t[e]||[0,0],[i,a]=t[c]||[0,0];l>=r!=a>=r&&n<=(i-u)*(r-l)/(a-l)+u&&(o=!o)}return o}([g,h],T)?p():n&&(t=setTimeout(a,n))}}},e.useClick=function(e,t){let{open:n,onOpenChange:r,dataRef:o,refs:c}=e,{enabled:l=!0,pointerDown:i=!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 l?{reference:{onPointerDown(e){f.current=e.pointerType},onMouseDown(e){0===e.button&&("mouse"===f.current&&s||i&&(n?!a||o.current.openEvent&&"mousedown"!==o.current.openEvent.type||r(!1):r(!0),o.current.openEvent=e.nativeEvent))},onClick(e){i&&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:l,setState:i}=B(),a=H(r);u.useEffect((()=>{c&&a.current&&(i((e=>({...e,delay:{open:1,close:q(l,"close")}}))),c!==o&&a.current(!1))}),[o,a,i,c,l]),u.useEffect((()=>{!n&&c===o&&a.current&&(a.current(!1),i((e=>({...e,delay:l,currentId:null}))))}),[n,i,c,o,a,l])},e.useDelayGroupContext=B,e.useDismiss=function(e,n){let{open:r,onOpenChange:o,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===n?{}:n;const b=g(),E=H(o),w=null!=p();return u.useEffect((()=>{if(!r||!a)return;function e(e){if("Escape"===e.key){if(!m&&b&&R(b.nodesRef.current,i).length>0)return;l.emit("dismiss",{preventScroll:!1}),E.current(!1)}}function n(e){const t=b&&R(b.nodesRef.current,i).some((t=>{var n;return Y(e,null==(n=t.context)?void 0:n.refs.floating.current)}));Y(e,c.floating.current)||Y(e,c.domReference.current)||t||!m&&b&&R(b.nodesRef.current,i).length>0||(l.emit("dismiss",!!w&&{preventScroll:!0}),E.current(!1))}function o(){E.current(!1)}const u=h(c.floating.current);s&&u.addEventListener("keydown",e),f&&u.addEventListener("pointerdown",n);const d=(v?[...y(c.reference.current)?t.getOverflowAncestors(c.reference.current):[],...y(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("pointerdown",n),d.forEach((e=>e.removeEventListener("scroll",o)))}}),[s,f,l,b,i,r,E,v,a,m,c,w]),a?{reference:{onPointerDown(){d&&(l.emit("dismiss"),o(!1))}}}:{}},e.useFloating=function(e){let{open:n=!1,onOpenChange:r=(()=>{}),whileElementsMounted:o,placement:i,middleware:a,strategy:s,nodeId:f}=void 0===e?{}:e;const d=g(),v=u.useRef(null),m=u.useRef({}),p=u.useState((()=>l()))[0],h=t.useFloating({placement:i,middleware:a,strategy:s,whileElementsMounted:o}),b=u.useMemo((()=>({...h.refs,domReference:v})),[h.refs]),E=u.useMemo((()=>({...h,refs:b,dataRef:m,nodeId:f,events:p,open:n,onOpenChange:r})),[h,f,p,n,r,b]);c((()=>{const e=null==d?void 0:d.nodesRef.current.find((e=>e.id===f));e&&(e.context=E)}));const{reference:w}=h,R=u.useCallback((e=>{(y(e)||null===e)&&(E.refs.domReference.current=e),w(e)}),[w,E.refs]);return u.useMemo((()=>({...h,context:E,refs:b,reference:R})),[h,b,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:l}=e,{enabled:i=!0,keyboardOnly:a=!0}=void 0===t?{}:t;const s=u.useRef(""),f=u.useRef(!1);return u.useEffect((()=>{var e;if(!i)return;const t=h(c.floating.current),r=null!=(e=t.defaultView)?e:window;function o(){s.current&&c.domReference.current===P(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,i]),u.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: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:l=!1,restMs:i=0}=void 0===t?{}:t;const{open:a,onOpenChange:s,dataRef:f,events:d,refs:v}=e,m=g(),b=p(),E=H(s),w=H(o),R=W(a),x=u.useRef(),k=u.useRef(),T=u.useRef(),I=u.useRef(),O=u.useRef(!0),L=u.useRef(!1),M=u.useCallback((()=>{var e;const t=null==(e=f.current.openEvent)?void 0:e.type;return(null==t?void 0:t.includes("mouse"))&&"mousedown"!==t}),[f]);u.useEffect((()=>{if(n)return d.on("dismiss",e),()=>{d.off("dismiss",e)};function e(){clearTimeout(k.current),clearTimeout(I.current),O.current=!0}}),[n,d,v]),u.useEffect((()=>{if(!n||!w.current)return;function e(){M()&&E.current(!1)}const t=h(v.floating.current).documentElement;return t.addEventListener("mouseleave",e),()=>{t.removeEventListener("mouseleave",e)}}),[v,E,n,w,f,M]);const C=u.useCallback((function(e){void 0===e&&(e=!0);const t=q(r,"close",x.current);t&&!T.current?(clearTimeout(k.current),k.current=setTimeout((()=>E.current(!1)),t)):e&&(clearTimeout(k.current),E.current(!1))}),[r,E]),A=u.useCallback((()=>{T.current&&(h(v.floating.current).removeEventListener("pointermove",T.current),T.current=void 0)}),[v]),D=u.useCallback((()=>{h(v.floating.current).body.style.pointerEvents="",L.current=!1}),[v]);if(u.useEffect((()=>{if(!n)return;function t(){return!!f.current.openEvent&&["click","mousedown"].includes(f.current.openEvent.type)}function o(e){if(clearTimeout(k.current),O.current=!1,a||l&&"mouse"!==x.current||i>0&&0===q(r,"open"))return;f.current.openEvent=e;const t=q(r,"open",x.current);t?k.current=setTimeout((()=>{E.current(!0)}),t):E.current(!0)}function u(n){if(t())return;const r=h(v.floating.current);if(clearTimeout(I.current),w.current)return clearTimeout(k.current),T.current&&r.removeEventListener("pointermove",T.current),T.current=w.current({...e,tree:m,x:n.clientX,y:n.clientY,onClose(){D(),A(),C()}}),void r.addEventListener("pointermove",T.current);C()}function c(n){t()||null==w.current||w.current({...e,tree:m,x:n.clientX,y:n.clientY,leave:!0,onClose(){D(),A(),C()}})(n)}const s=v.floating.current,d=v.domReference.current;return y(d)?(a&&d.addEventListener("mouseleave",c),null==s||s.addEventListener("mouseleave",c),d.addEventListener("mousemove",o,{once:!0}),d.addEventListener("mouseenter",o),d.addEventListener("mouseleave",u),()=>{a&&d.removeEventListener("mouseleave",c),null==s||s.removeEventListener("mouseleave",c),d.removeEventListener("mousemove",o),d.removeEventListener("mouseenter",o),d.removeEventListener("mouseleave",u)}):void 0}),[n,C,e,r,w,f,l,E,a,m,i,A,D,v]),c((()=>{if(n&&a&&w.current&&M()){h(v.floating.current).body.style.pointerEvents="none",L.current=!0;const n=v.domReference.current,r=v.floating.current;if(y(n)&&r){var e,t;const o=null==m||null==(e=m.nodesRef.current.find((e=>e.id===b)))||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,b,v,m,w,f,M]),c((()=>{R&&!a&&(x.current=void 0,A(),D())})),u.useEffect((()=>()=>{A(),clearTimeout(k.current),clearTimeout(I.current),L.current&&D()}),[n,A,D]),!n)return{};function P(e){x.current=e.pointerType}return{reference:{onPointerDown:P,onPointerEnter:P,onMouseMove(){a||0===i||(clearTimeout(I.current),I.current=setTimeout((()=>{O.current||s(!0)}),i))}},floating:{onMouseEnter(){clearTimeout(k.current)},onMouseLeave(){C(!1)}}}},e.useId=d,e.useInnerOffset=(e,t)=>{let{open:n,refs:o}=e,{enabled:c=!0,overflowRef:l,onChange:i}=t;const a=H(i),s=u.useRef(!1),f=u.useRef(null),d=u.useRef(null);return u.useEffect((()=>{if(!c)return;function e(e){if(e.ctrlKey||!t||null==l.current)return;const n=e.deltaY,o=l.current.top>=-.5,u=l.current.bottom>=-.5,c=t.scrollHeight-t.clientHeight,i=n<0?-1:1,s=n<0?"max":"min";t.scrollHeight<=t.clientHeight||(!o&&n>0||!u&&n<0?(e.preventDefault(),r.flushSync((()=>{a.current((e=>e+Math[s](n,c*i)))}))):/firefox/i.test(function(){const e=navigator.userAgentData;return null!=e&&e.brands?e.brands.map((e=>{let{brand:t,version:n}=e;return t+"/"+n})).join(" "):navigator.userAgent}())&&(t.scrollTop+=n))}const t=o.floating.current;return n&&t?(t.addEventListener("wheel",e),requestAnimationFrame((()=>{f.current=t.scrollTop,null!=l.current&&(d.current={...l.current})})),()=>{f.current=null,d.current=null,t.removeEventListener("wheel",e)}):void 0}),[c,n,o,l,a]),c?{floating:{onKeyDown(){s.current=!0},onWheel(){s.current=!1},onPointerMove(){s.current=!1},onScroll(){const e=o.floating.current;if(l.current&&e&&s.current){if(null!==f.current){const t=e.scrollTop-f.current;(l.current.bottom<-.5&&t<-1||l.current.top<-.5&&t>1)&&r.flushSync((()=>i((e=>e+t))))}requestAnimationFrame((()=>{f.current=e.scrollTop}))}}}}:{}},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:l,activeIndex:i,onNavigate:a,enabled:s=!0,selectedIndex:f=null,allowEscape:d=!1,loop:v=!1,nested:m=!1,rtl:b=!1,virtual:y=!1,focusItemOnOpen:w="auto",focusItemOnHover:R=!0,openOnArrowKeyDown:x=!0,disabledIndices:k=(x?void 0:[]),orientation:T="vertical"}=void 0===t?{listRef:{current:[]},activeIndex:null,onNavigate:()=>{}}:t;const I=p(),O=g(),L=W(n),M=u.useRef(w),C=u.useRef(null!=f?f:-1),A=u.useRef(null),D=H(W(a)),F=H(a),S=H(k),N=u.useRef(!1),K=u.useRef(-1),[q,V]=u.useState(),B=u.useCallback(((e,t)=>{K.current=requestAnimationFrame((()=>{var n,r;y?V(null==(n=e.current[t.current])?void 0:n.id):null==(r=e.current[t.current])||r.focus({preventScroll:!0})}))}),[y]);function U(e){if(N.current=!0,m&&function(e,t,n){return Z(t,n?e===z:e===_,e===G)}(e.key,T,b))return j(e),r(!1),void(E(o.domReference.current)&&o.domReference.current.focus());const t=C.current,u=te(l,k),c=ne(l,k);if("Home"===e.key&&(C.current=u,a(C.current)),"End"===e.key&&(C.current=c,a(C.current)),$(e.key,T)){if(j(e),n&&!y&&P(e.currentTarget.ownerDocument)===e.currentTarget)return C.current=ee(e.key,T,b)?u:c,void a(C.current);ee(e.key,T,b)?C.current=v?t>=c?d&&t!==l.current.length?-1:u:Q(l,{startingIndex:t,disabledIndices:k}):Math.min(c,Q(l,{startingIndex:t,disabledIndices:k})):C.current=v?t<=u?d&&-1!==t?l.current.length:c:Q(l,{startingIndex:t,decrement:!0,disabledIndices:k}):Math.max(u,Q(l,{startingIndex:t,decrement:!0,disabledIndices:k})),J(l,C.current)?a(null):a(C.current)}}return c((()=>{s&&(!L&&n&&M.current&&null!=f&&F.current(f),L&&!n&&(cancelAnimationFrame(K.current),C.current=-1,null==D.current||D.current(null)))}),[n,L,f,l,F,D,B,s]),c((()=>{if(s&&n)if(null==i){if(null!=f)return;L&&(C.current=-1,B(l,C)),!L&&M.current&&(null!=A.current||!0===M.current&&null==A.current)&&(C.current=null==A.current||ee(A.current,T,b)||m?te(l,S.current):ne(l,S.current),F.current(C.current),B(l,C))}else J(l,i)||(C.current=i,B(l,C))}),[n,L,i,f,m,l,F,B,s,d,T,b,y,S]),c((()=>{if(s&&!n&&L){var e,t;const n=null==O||null==(e=O.nodesRef.current.find((e=>e.id===I)))||null==(t=e.context)?void 0:t.refs.floating.current;n&&!n.contains(P(h(n)))&&n.focus({preventScroll:!0})}}),[s,n,L,O,I]),c((()=>{A.current=null})),s?{reference:{...y&&n&&null!=i&&{"aria-activedescendant":q},onKeyDown(e){if(N.current=!0,y&&n)return U(e);(0===e.key.indexOf("Arrow")||"Enter"===e.key||" "===e.key||""===e.key)&&(A.current=e.key),m?function(e,t,n){return Z(t,n?e===_:e===z,e===X)}(e.key,T,b)&&(j(e),n?(C.current=te(l,k),a(C.current)):r(!0)):$(e.key,T)&&(null!=f&&(C.current=f),j(e),!n&&x?r(!0):U(e),n&&a(C.current))}},floating:{"aria-orientation":"both"===T?void 0:T,...y&&null!=i&&{"aria-activedescendant":q},onKeyDown:U,onPointerMove(){N.current=!1}},item:{onFocus(e){let{currentTarget:t}=e;const n=l.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=l.current.indexOf(n);-1!==e&&a(e)}},onPointerLeave(){var e;N.current||(C.current=-1,B(l,C),F.current(null),y||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(),l={id:u,role:o};return r?"tooltip"===o?{reference:{"aria-describedby":n?u:void 0},floating:l}:{reference:{"aria-expanded":n?"true":"false","aria-haspopup":o,"aria-controls":n?u:void 0,..."listbox"===o&&{role:"combobox"},..."menu"===o&&{id:c}},floating:{...l,..."menu"===o&&{"aria-labelledby":c}}}:{}},e.useTypeahead=function(e,t){var n;let{open:r,dataRef:o}=e,{listRef:l,activeIndex:i,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(""),b=u.useRef(null!=(n=null!=m?m:i)?n:-1),y=u.useRef(null);function E(e){if(!e.currentTarget.contains(P(h(e.currentTarget))))return;g.current.length>0&&" "!==g.current[0]&&(o.current.typing=!0," "===e.key&&j(e));const t=l.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="",b.current=y.current),g.current+=e.key,clearTimeout(p.current),p.current=setTimeout((()=>{g.current="",b.current=y.current,o.current.typing=!1}),d);const n=b.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),y.current=c)}return c((()=>{r&&(clearTimeout(p.current),y.current=null,g.current="")}),[r]),c((()=>{var e;r&&""===g.current&&(b.current=null!=(e=null!=m?m:i)?e:-1)}),[r,m,i]),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.8.0", | ||
"version": "0.8.1", | ||
"@rollingversions": { | ||
@@ -5,0 +5,0 @@ "baseVersion": [ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
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
320315
7119