@floating-ui/react-dom-interactions
Advanced tools
Comparing version 0.3.0 to 0.3.1
@@ -1,2 +0,2 @@ | ||
import * as React$1 from 'react'; | ||
import * as React from 'react'; | ||
import React__default, { useLayoutEffect, useEffect, useContext, useMemo, useRef, useCallback, useState, createContext, forwardRef, cloneElement } from 'react'; | ||
@@ -37,3 +37,3 @@ import { getOverflowAncestors, useFloating as useFloating$1 } from '@floating-ui/react-dom'; | ||
function useFloatingId() { | ||
const [id, setId] = React$1.useState(() => serverHandoffComplete ? genId() : undefined); | ||
const [id, setId] = React.useState(() => serverHandoffComplete ? genId() : undefined); | ||
index(() => { | ||
@@ -45,3 +45,3 @@ if (id == null) { | ||
}, []); | ||
React$1.useEffect(() => { | ||
React.useEffect(() => { | ||
if (!serverHandoffComplete) { | ||
@@ -55,3 +55,3 @@ serverHandoffComplete = true; | ||
const useReactId = React$1[/*#__PURE__*/'useId'.toString()]; | ||
const useReactId = React[/*#__PURE__*/'useId'.toString()]; | ||
/** | ||
@@ -547,3 +547,3 @@ * Uses React 18's built-in `useId()` when available, or falls back to a | ||
const FocusGuard = /*#__PURE__*/forwardRef(function FocusGuard(props, ref) { | ||
return /*#__PURE__*/React.createElement("span", _extends({}, props, { | ||
return /*#__PURE__*/React__default.createElement("span", _extends({}, props, { | ||
ref: ref, | ||
@@ -702,3 +702,3 @@ tabIndex: 0, | ||
}, [preventTabbing, getTabbableElements, initialFocus, modal, returnFocus, refs.floating]); | ||
return /*#__PURE__*/React.createElement(React.Fragment, null, modal && /*#__PURE__*/React.createElement(FocusGuard, { | ||
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, modal && /*#__PURE__*/React__default.createElement(FocusGuard, { | ||
onFocus: event => { | ||
@@ -716,3 +716,3 @@ stopEvent(event); | ||
tabIndex: 0 | ||
} : {}), modal && endGuard && /*#__PURE__*/React.createElement(FocusGuard, { | ||
} : {}), modal && endGuard && /*#__PURE__*/React__default.createElement(FocusGuard, { | ||
onFocus: event => { | ||
@@ -987,7 +987,8 @@ stopEvent(event); | ||
} = useDelayGroupContext(); | ||
const onOpenChangeRef = useLatestRef(onOpenChange); | ||
useEffect(() => { | ||
if (currentId && onOpenChange) { | ||
if (currentId && onOpenChangeRef.current) { | ||
setState(state => ({ ...state, | ||
delay: { | ||
open: 0, | ||
open: 1, | ||
close: getDelay(initialDelay, 'close') | ||
@@ -998,9 +999,9 @@ } | ||
if (currentId !== id) { | ||
onOpenChange(false); | ||
onOpenChangeRef.current(false); | ||
} | ||
} | ||
}, [id, onOpenChange, setState, currentId, initialDelay]); | ||
}, [id, onOpenChangeRef, setState, currentId, initialDelay]); | ||
useEffect(() => { | ||
if (!open && currentId === id && onOpenChange) { | ||
onOpenChange(false); | ||
if (!open && currentId === id && onOpenChangeRef.current) { | ||
onOpenChangeRef.current(false); | ||
setState(state => ({ ...state, | ||
@@ -1011,3 +1012,3 @@ delay: initialDelay, | ||
} | ||
}, [open, setState, currentId, id, onOpenChange, initialDelay]); | ||
}, [open, setState, currentId, id, onOpenChangeRef, initialDelay]); | ||
}; | ||
@@ -1014,0 +1015,0 @@ |
@@ -1,1 +0,1 @@ | ||
import*as e from"react";import n,{useLayoutEffect as t,useEffect as r,useContext as o,useMemo as u,useRef as c,useCallback as i,useState as l,createContext as a,forwardRef as f,cloneElement as s}from"react";import{getOverflowAncestors as d,useFloating as v}from"@floating-ui/react-dom";export*from"@floating-ui/react-dom";import m from"point-in-polygon";import{createPortal as g}from"react-dom";import{hideOthers as p}from"aria-hidden";var h="undefined"!=typeof document?t:r;function b(){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 y=!1,E=0;const w=()=>"floating-ui-"+E++;const x=e["useId".toString()],L=null!=x?x:function(){const[n,t]=e.useState((()=>y?w():void 0));return h((()=>{null==n&&t(w())}),[]),e.useEffect((()=>{y||(y=!0)}),[]),n},T=a(null),I=a(null),A=()=>{var e,n;return null!=(e=null==(n=o(T))?void 0:n.id)?e:null},k=()=>o(I),R=()=>{const e=L(),n=k(),t=A();return h((()=>{const r={id:e,parentId:t};return null==n||n.addNode(r),()=>{null==n||n.removeNode(r)}}),[n,e,t]),e},O=e=>{let{children:t,id:r}=e;const o=A();return n.createElement(T.Provider,{value:u((()=>({id:r,parentId:o})),[r,o])},t)},C=e=>{let{children:t}=e;const r=c([]),o=i((e=>{r.current=[...r.current,e]}),[]),a=i((e=>{r.current=r.current.filter((n=>n!==e))}),[]),f=l((()=>b()))[0];return n.createElement(I.Provider,{value:u((()=>({nodesRef:r,addNode:o,removeNode:a,events:f})),[r,o,a,f])},t)};function D(e,n,t){const r={};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;0===t.indexOf("on")?(r[t]||(r[t]=[]),"function"==typeof o&&r[t].push(o),e[t]=function(){for(var e=arguments.length,n=new Array(e),o=0;o<e;o++)n[o]=arguments[o];r[t].forEach((e=>e(...n)))}):e[t]=o})),e):e),{})}}const P=function(e){return void 0===e&&(e=[]),{getReferenceProps:n=>D(n,e,"reference"),getFloatingProps:n=>D(n,e,"floating"),getItemProps:n=>D(n,e,"item")}};function M(e){var n;return null!=(n=null==e?void 0:e.ownerDocument)?n:document}function S(e){var n;return null!=(n=M(e).defaultView)?n:window}function F(e){return!!e&&e instanceof S(e).Element}function j(e){return!!e&&e instanceof S(e).HTMLElement}function N(e,n){var t;let r=null!=(t=null==e?void 0:e.nodesRef.current.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=null==e?void 0:e.nodesRef.current.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 B(e){let n,{restMs:t=0,buffer:r=1,debug:o=null}=void 0===e?{}:e;return e=>{let{x:o,y:u,placement:c,refs:i,onClose:l,nodeId:a,tree:f}=e;return function(e){var s;if(clearTimeout(n),e.pointerType&&"mouse"!==e.pointerType)return;const{target:d,clientX:v,clientY:g}=e,p=d;if("pointermove"===e.type&&F(i.reference.current)&&i.reference.current.contains(p)||null!=(s=i.floating.current)&&s.contains(p))return;if(f&&N(f,a).some((e=>{let{context:n}=e;return null==n?void 0:n.open})))return;if(!i.reference.current||!i.floating.current||null==c||null==o||null==u)return;const h=i.reference.current.getBoundingClientRect(),b=i.floating.current.getBoundingClientRect(),y=c.split("-")[0],E=o>b.right-b.width/2,w=u>b.bottom-b.height/2;switch(y){case"top":if(v>=b.left&&v<=b.right&&g>=b.bottom&&g<=h.top)return;break;case"bottom":if(v>=b.left&&v<=b.right&&g>=h.bottom&&g<=b.top)return;break;case"left":if(v>=b.right&&v<=h.left&&g>=b.left&&g<=b.right)return;break;case"right":if(v>=b.right&&v<=h.left&&g>=b.right&&g<=h.left)return}const x=function(e){let[n,t]=e;const o=b.width>h.width,u=b.height>h.height;switch(y){case"top":{const e=[o?n:E?n+r:n-r,t+r],u=[o?n:E?n-r:n+r,t+r],c=[[b.left,E||o?b.bottom-r:b.top],[b.right,E?o?b.bottom-r:b.top:b.bottom-r]];return E?[e,u,...c]:[e,...c,u]}case"bottom":{const e=[o?n:E?n+r:n-r,t-r],u=[o?n:E?n-r:n+r,t-r],c=[[b.left,E||o?b.top+r:b.bottom],[b.right,E?o?b.top+r:b.bottom:b.top+r]];return E?[e,u,...c]:[e,...c,u]}case"left":{const e=[n+r,u?t:w?t-r:t+r],o=[n+r,u?t:w?t+r:t-r],c=[[w||u?b.right-r:b.left,b.top],[w?u?b.right-r:b.left:b.right-r,b.bottom]];return w?[e,...c,o]:[...c,e,o]}case"right":{const e=[n-r,u?t:w?t+r:t-r],o=[n-r,u?t:w?t-r:t+r],c=[[w||u?b.left+r:b.right,b.top],[w?u?b.left+r:b.right:b.left+r,b.bottom]];return w?[e,o,...c]:[e,...c,o]}}}([o,u]);m([v,g],x)?t&&(n=setTimeout(l,t)):(clearTimeout(n),l())}}}const K="floating-ui-root",q=e=>{let{children:n,id:t=K}=e;const[r,o]=l(!1),u=c(null);return h((()=>{const e=document.getElementById(t);e?u.current=e:(u.current=document.createElement("div"),u.current.id=t);const n=u.current;document.body.contains(n)||document.body.appendChild(n),o(!0)}),[t]),r&&u.current?g(n,u.current):null};function H(){return H=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},H.apply(this,arguments)}const U="data-floating-ui-scroll-lock",V=f((function(e,t){let{lockScroll:r=!1,...o}=e;return h((()=>{if(!r)return;const e=window.pageXOffset,n=window.pageYOffset,t=Math.round(document.documentElement.getBoundingClientRect().left)+document.documentElement.scrollLeft?"paddingLeft":"paddingRight",o=window.innerWidth-document.documentElement.clientWidth;return document.body.hasAttribute(U)?void 0:(Object.assign(document.body.style,{position:"fixed",overflow:"hidden",top:"-"+n+"px",left:"-"+e+"px",right:"0",[t]:o+"px"}),document.body.setAttribute(U,""),()=>{Object.assign(document.body.style,{position:"",overflow:"",top:"",left:"",right:"",[t]:""}),document.body.removeAttribute(U),window.scrollTo(e,n)})}),[r]),n.createElement("div",H({ref:t},o,{style:{position:"fixed",overflow:"auto",top:0,right:0,bottom:0,left:0,...o.style}}))}));function X(e){e.preventDefault(),e.stopPropagation()}function Y(e){const n=c(e);return h((()=>{n.current=e})),n}function W(e){requestAnimationFrame((()=>{null==e||e.focus()}))}const z=f((function(e,n){return React.createElement("span",H({},e,{ref:n,tabIndex:0,style:{position:"fixed",opacity:"0",pointerEvents:"none",outline:"0"}}))}));function G(e){let{context:{refs:n,nodeId:t,onOpenChange:o},children:u,order:c=["content"],endGuard:l=!0,preventTabbing:a=!1,initialFocus:f=0,returnFocus:d=!0,modal:v=!0}=e;const m=Y(c),g=Y(o),h=k(),b=i((()=>m.current.map((e=>{return j(n.reference.current)&&"reference"===e?n.reference.current:n.floating.current&&"floating"===e?n.floating.current:"content"===e?Array.from(null!=(t=null==(r=n.floating.current)?void 0:r.querySelectorAll("input:not([type='hidden']):not([disabled]),select:not([disabled]),textarea:not([disabled]),a[href],button:not([disabled]),[tabindex],iframe,object,embed,area[href],audio[controls],video[controls],[contenteditable]:not([contenteditable='false'])"))?t:[]):null;var t,r})).flat().filter((e=>{if(e===n.floating.current||e===n.reference.current)return!0;if(j(e)){var t;return"-"!==(null!=(t=e.getAttribute("tabindex"))?t:"0")[0].trim()}}))),[m,n.floating,n.reference]);return r((()=>{const e=0===b().filter((e=>e!==n.floating.current&&e!==n.reference.current)).length;function t(t){if("Tab"===t.key){(a||e)&&X(t);const r=b();"reference"===m.current[0]&&t.target===n.reference.current&&(X(t),t.shiftKey?W(r[r.length-1]):W(r[1])),"floating"===m.current[1]&&t.target===n.floating.current&&t.shiftKey&&(X(t),W(r[0]))}}const r=M(n.floating.current);return r.addEventListener("keydown",t),()=>{r.removeEventListener("keydown",t)}}),[a,b,m,n.floating,n.reference]),r((()=>{function e(e){var r;const o=e.relatedTarget;null!=(r=n.floating.current)&&r.contains(o)||!F(n.reference.current)||n.reference.current.contains(o)||h&&N(h,t).some((e=>{var n,t;return null==(n=e.context)||null==(t=n.refs.floating.current)?void 0:t.contains(o)}))||g.current(!1)}const r=n.floating.current,o=n.reference.current;if(r&&j(o)){!v&&r.addEventListener("focusout",e);const n=v?p(r):null;return()=>{!v&&r.removeEventListener("focusout",e),null==n||n()}}}),[t,h,v,g,b,f,n.floating,n.reference]),r((()=>{var e;if(a)return;const t=n.floating.current,r=null!=(e=M(t).activeElement)?e:document.activeElement;var o;if("number"==typeof f)W(null!=(o=b()[f])?o:t);else if(j(null==f?void 0:f.current)){var u;W(null!=(u=f.current)?u:t)}return()=>{d&&j(r)&&W(r)}}),[a,b,f,v,d,n.floating]),React.createElement(React.Fragment,null,v&&React.createElement(z,{onFocus:e=>{X(e);const n=b();"reference"===c[0]?W(n[0]):W(n[n.length-1])}}),s(u,c.includes("floating")?{tabIndex:0}:{}),v&&l&&React.createElement(z,{onFocus:e=>{X(e),W(b()[0])}}))}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:o=0,handleClose:u=null,mouseOnly:l=!1,restMs:a=0}=void 0===n?{}:n;const{open:f,onOpenChange:s,dataRef:d,events:v,refs:m}=e,g=k(),p=Y(s),b=Y(u),y=c(),E=c(),w=c(),x=c(),L=c(!0);h((()=>{t&&(f||(y.current=void 0))})),r((()=>{if(t)return v.on("dismiss",e),()=>{v.off("dismiss",e)};function e(){clearTimeout(E.current),clearTimeout(x.current),L.current=!0}}),[t,v,m.floating]),r((()=>{if(!t||!b.current)return;function e(){var e;null!=(e=d.current.openEvent)&&e.type.includes("mouse")&&p.current(!1)}const n=M(m.floating.current).documentElement;return n.addEventListener("mouseleave",e),()=>{n.removeEventListener("mouseleave",e)}}),[m.floating,p,t,b,d]);const T=i((function(e){void 0===e&&(e=!0),o&&!w.current?(clearTimeout(E.current),E.current=setTimeout((()=>p.current(!1)),J(o,"close",y.current))):e&&p.current(!1)}),[o,p]),I=i((()=>{w.current&&(M(m.floating.current).removeEventListener("pointermove",w.current),w.current=void 0)}),[m.floating]);if(r((()=>{f||I()}),[f,t,I]),r((()=>{if(!t)return;function n(e){clearTimeout(E.current),L.current=!1,f||l&&"mouse"!==y.current||a>0&&0===J(o,"open")||(d.current.openEvent=e,o?E.current=setTimeout((()=>{p.current(!0)}),J(o,"open",y.current)):p.current(!0))}function r(n){var t,r;if("click"===(null==(t=d.current.openEvent)?void 0:t.type)||"pointerdown"===(null==(r=d.current.openEvent)?void 0:r.type))return;const o=M(m.floating.current);if(clearTimeout(x.current),b.current)return clearTimeout(E.current),w.current&&o.removeEventListener("pointermove",w.current),w.current=b.current({...e,tree:g,x:n.clientX,y:n.clientY,onClose(){I(),T()}}),void o.addEventListener("pointermove",w.current);T()}const u=m.reference.current;return F(u)?(u.addEventListener("mouseenter",n),u.addEventListener("mouseleave",r),()=>{u.removeEventListener("mouseenter",n),u.removeEventListener("mouseleave",r)}):void 0}),[t,T,e,o,b,d,l,p,f,g,a,I,m.reference,m.floating]),!t)return{};function A(e){y.current=e.pointerType}return{reference:{onPointerDown:A,onPointerEnter:A,onMouseMove(){f||0===a||(clearTimeout(x.current),x.current=setTimeout((()=>{L.current||s(!0)}),a))}},floating:{onMouseEnter(){clearTimeout(E.current)},onMouseLeave:()=>T(!1)}}},Z=a({delay:1e3,initialDelay:1e3,currentId:null,setCurrentId:()=>{},setState:()=>{}}),$=()=>o(Z),_=e=>{let{children:t,delay:r}=e;const[o,c]=l({delay:r,initialDelay:r,currentId:null}),a=i((e=>{c((n=>({...n,currentId:e})))}),[]);return n.createElement(Z.Provider,{value:u((()=>({...o,setState:c,setCurrentId:a})),[o,c,a])},t)},ee=(e,n)=>{let{open:t,onOpenChange:o}=e,{id:u}=n;const{currentId:c,initialDelay:i,setState:l}=$();r((()=>{c&&o&&(l((e=>({...e,delay:{open:0,close:J(i,"close")}}))),c!==u&&o(!1))}),[u,o,l,c,i]),r((()=>{!t&&c===u&&o&&(o(!1),l((e=>({...e,delay:i,currentId:null}))))}),[t,l,c,u,o,i])},ne=function(e,n){let{open:t}=e,{enabled:r=!0,role:o="dialog"}=void 0===n?{}:n;const u=L(),c=L(),i={id:u,role:o};return r?"tooltip"===o?{reference:{"aria-describedby":t?u:void 0},floating:i}:{reference:{"aria-expanded":t?"true":"false","aria-haspopup":o,"aria-controls":t?u:void 0,..."listbox"===o&&{role:"combobox"},..."menu"===o&&{id:c}},floating:{...i,..."menu"===o&&{"aria-labelledby":c}}}:{}},te=function(e,n){let{open:t,onOpenChange:r,dataRef:o}=e,{enabled:u=!0,pointerDown:i=!1,toggle:l=!0}=void 0===n?{}:n;const a=c();return u?{reference:{...i&&{onPointerDown(e){var n;(a.current=e.pointerType,t)?l&&"pointerdown"===(null==(n=o.current.openEvent)?void 0:n.type)&&r(!1):r(!0);o.current.openEvent=e.nativeEvent}},onClick(e){if(i&&a.current)a.current=void 0;else{var n;if(t)l&&"click"===(null==(n=o.current.openEvent)?void 0:n.type)&&r(!1);else r(!0);o.current.openEvent=e.nativeEvent}}}}:{}},re=function(e,n){let{open:t,onOpenChange:o,refs:u,events:c,nodeId:l}=e,{enabled:a=!0,escapeKey:f=!0,outsidePointerDown:s=!0,referencePointerDown:v=!1,ancestorScroll:m=!1,bubbles:g=!0}=void 0===n?{}:n;const p=k(),h=Y(o),b=i((()=>{var e;return null==(e=u.floating.current)?void 0:e.contains(M(u.floating.current).activeElement)}),[u.floating]),y=i((()=>{j(u.reference.current)&&u.reference.current.focus()}),[u.reference]);return r((()=>{if(!t||!a)return;function e(e){if("Escape"===e.key){if(!g&&!b())return;c.emit("dismiss"),h.current(!1),y()}}function n(e){var n;const t=p&&N(p,l).some((n=>{var t,r;return null==(t=n.context)||null==(r=t.refs.floating.current)?void 0:r.contains(e.target)}));null!=(n=u.floating.current)&&n.contains(e.target)||F(u.reference.current)&&u.reference.current.contains(e.target)||t||(g||b())&&(c.emit("dismiss"),h.current(!1),y())}function r(){h.current(!1)}const o=M(u.floating.current);f&&o.addEventListener("keydown",e),s&&o.addEventListener("mousedown",n);const i=(m?[...F(u.reference.current)?d(u.reference.current):[],...F(u.floating.current)?d(u.floating.current):[]]:[]).filter((e=>{var n;return e!==(null==(n=o.defaultView)?void 0:n.visualViewport)}));return i.forEach((e=>e.addEventListener("scroll",r,{passive:!0}))),()=>{f&&o.removeEventListener("keydown",e),s&&o.removeEventListener("mousedown",n),i.forEach((e=>e.removeEventListener("scroll",r)))}}),[f,s,c,p,l,t,h,y,m,a,g,b,u.floating,u.reference]),a?{reference:{onPointerDown(){v&&(c.emit("dismiss"),o(!1))}}}:{}},oe=function(e,n){let{open:t,onOpenChange:o,dataRef:u,refs:i,events:l}=e,{enabled:a=!0,keyboardOnly:f=!0}=void 0===n?{}:n;const s=c(!1);return r((()=>{var e;if(!a)return;const n=null!=(e=M(i.floating.current).defaultView)?e:window;function r(){s.current=!t}function o(){setTimeout((()=>{s.current=!1}))}return n.addEventListener("focus",o),n.addEventListener("blur",r),()=>{n.removeEventListener("focus",o),n.removeEventListener("blur",r)}}),[i.floating,t,a]),r((()=>{if(a)return l.on("dismiss",e),()=>{l.off("dismiss",e)};function e(){s.current=!0}}),[l,a]),a?{reference:{onPointerDown(e){let{pointerType:n}=e;s.current=!(!n||!f)},onFocus(e){var n,t,r;s.current||"focus"===e.type&&"mousedown"===(null==(n=u.current.openEvent)?void 0:n.type)&&F(i.reference.current)&&null!=(t=i.reference.current)&&t.contains(null==(r=u.current.openEvent)?void 0:r.target)||(u.current.openEvent=e.nativeEvent,o(!0))},onBlur(e){var n;const t=e.relatedTarget;null!=(n=i.floating.current)&&n.contains(t)||F(i.reference.current)&&i.reference.current.contains(t)||(s.current=!1,o(!1))}}}:{}},ue=["content"];function ce(e){requestAnimationFrame((()=>{null==e||e.focus()}))}const ie=function(e,n){let{open:t,onOpenChange:o,refs:u,nodeId:l}=e,{enabled:a=!0,initialContentFocus:f=0,order:s=ue,modal:d=!0,inert:v=!1}=void 0===n?{}:n;const m=c(!1),g=c(null),b=c(null),y=Y(d),E=Y(s),w=i((()=>E.current.map((e=>{return j(u.reference.current)&&"reference"===e?u.reference.current:u.floating.current&&"floating"===e?u.floating.current:"content"===e?Array.from(null!=(n=null==(t=u.floating.current)?void 0:t.querySelectorAll("a[href],area[href],input:not([disabled]),select:not([disabled]),textarea:not([disabled]),button:not([disabled]),iframe,object,embed,*[tabindex],*[contenteditable]"))?n:[]):null;var n,t})).filter(Boolean).flat()),[u.floating,u.reference]);h((()=>{const e=u.floating.current;if(!(a&&t&&e&&d))return;function n(){const n=M(e).createElement("div");return n.tabIndex=0,Object.assign(n.style,{position:"fixed",outline:"0",pointerEvents:"none"}),n.setAttribute("aria-hidden","true"),n}g.current||(g.current=n()),b.current||(b.current=n());const r=g.current,o=b.current;function c(e){var n;X(e);const t=w();null==(n=t[e.target===o?0:t.length-1])||n.focus()}return e.insertAdjacentElement("beforebegin",r),e.insertAdjacentElement("afterend",o),r.addEventListener("focus",c),o.addEventListener("focus",c),()=>{var e,n;r.removeEventListener("focus",c),o.removeEventListener("focus",c),null!=(e=r.parentNode)&&e.contains(r)&&r.parentNode.removeChild(r),null!=(n=o.parentNode)&&n.contains(o)&&o.parentNode.removeChild(o)}}),[a,t,d,v,w,u.floating]),r((()=>{if(!a||!t||!v)return;function e(e){"Tab"===e.key&&X(e)}const n=M(u.floating.current);return n.addEventListener("keydown",e),()=>{n.removeEventListener("keydown",e)}}),[a,t,v,u.floating]),r((()=>{if(!a)return;const e=w();if(v){if(t){const n=e[0];n!==u.floating.current||n.contains(n.ownerDocument.activeElement)||ce(n)}}else t&&("number"==typeof f?ce(e[f]):f.current&&ce(e.find((e=>e===f.current))))}),[w,t,v,d,f,a,u.reference,u.floating]),r((()=>{a&&!v&&!t&&y.current&&m.current&&j(u.reference.current)&&ce(u.reference.current)}),[t,a,v,y,u.reference]),r((()=>{if(t&&d&&a&&u.floating.current)return p(u.floating.current)}),[t,d,a,u.floating]),r((()=>(m.current=!0,()=>{m.current=!1})),[]);const x=k();function L(e){var n;const t=e.relatedTarget;null!=(n=u.floating.current)&&n.contains(t)||!F(u.reference.current)||u.reference.current.contains(t)||x&&N(x,l).some((e=>{var n,r,o;return null==(n=e.context)||null==(r=n.refs.floating)||null==(o=r.current)?void 0:o.contains(t)}))||o(!1)}return a?d?{floating:{"aria-modal":"true"}}:{reference:{onBlur:L},floating:{onBlur:L}}:{}};function le(e,n){let{startingIndex:t=-1,decrement:r=!1}=void 0===n?{}:n;const o=e.current;let u=t;do{var c,i;u+=r?-1:1}while(u>=0&&u<=o.length-1&&(null==o[u]||null!=(c=o[u])&&c.hasAttribute("disabled")||"true"===(null==(i=o[u])?void 0:i.getAttribute("aria-disabled"))));return u}function ae(e,n,t){switch(e){case"vertical":return n;case"horizontal":return t;default:return n||t}}function fe(e,n){return ae(n,"ArrowUp"===e||"ArrowDown"===e,"ArrowLeft"===e||"ArrowRight"===e)}function se(e,n,t){return ae(n,"ArrowDown"===e,t?"ArrowLeft"===e:"ArrowRight"===e)}function de(e){return le(e)}function ve(e){return le(e,{decrement:!0,startingIndex:e.current.length})}const me=function(e,n){let{open:t,onOpenChange:r,refs:o}=e,{listRef:u,activeIndex:a,onNavigate:f,enabled:s=!0,selectedIndex:d=null,allowEscape:v=!1,loop:m=!1,nested:g=!1,rtl:p=!1,virtual:b=!1,focusItemOnOpen:y="auto",focusItemOnHover:E=!0,orientation:w="vertical"}=void 0===n?{listRef:{current:[]},activeIndex:null,onNavigate:()=>{}}:n;const x=A(),L=k(),T=function(e){const n=c();return h((()=>{n.current=e}),[e]),n.current}(t),I=c(y),R=c(null!=d?d:-1),O=c(""),C=c(!1),D=Y(f),P=c(!1),[M,S]=l(),F=i(((e,n)=>{var t,r;b?S(null==(t=e.current[n.current])?void 0:t.id):null==(r=e.current[n.current])||r.focus({preventScroll:!0})}),[b]);function N(e){"auto"===y&&(I.current=!e.pointerType)}function B(e){if(P.current=!0,g&&function(e,n,t){return ae(n,t?"ArrowRight"===e:"ArrowLeft"===e,"ArrowUp"===e)}(e.key,w,p))return X(e),r(!1),void(j(o.reference.current)&&o.reference.current.focus());const n=R.current,t=de(u),c=ve(u);if("Home"===e.key&&(R.current=t,f(R.current)),"End"===e.key&&(R.current=c,f(R.current)),fe(e.key,w)){if(X(e),!b&&e.currentTarget.ownerDocument.activeElement===e.currentTarget)return R.current=null!=d?d:se(e.key,w,p)?t:c,void f(R.current);se(e.key,w,p)?R.current=m?n>=c?v&&n!==u.current.length?-1:t:le(u,{startingIndex:n}):Math.min(c,le(u,{startingIndex:n})):R.current=m?n<=t?v&&-1!==n?u.current.length:c:le(u,{startingIndex:n,decrement:!0}):Math.max(t,le(u,{startingIndex:n,decrement:!0})),f(R.current)}}return h((()=>{s&&(null!=d&&(R.current=d),!T&&t&&I.current&&(D.current(R.current),F(u,R)))}),[t,T,d,u,D,F,s]),h((()=>{s&&t&&(null===a?(!T&&I.current&&null==d||v)&&(R.current=v?-1:de(u),D.current(a),F(u,R)):(R.current=a,D.current(a),F(u,R)))}),[t,T,a,d,g,u,D,F,s,x,v,o.floating,null==L?void 0:L.nodesRef]),h((()=>{if(null==d&&s){if(t&&(fe(O.current,w)||I.current&&(" "===O.current||"Enter"===O.current))){const e=de(u),n=ve(u);R.current=function(e,n,t){return ae(n,"ArrowUp"===e,t?"ArrowRight"===e:"ArrowLeft"===e)}(O.current,w,p)?v?u.current.length:n:v?-1:e,D.current(R.current),F(u,R)}O.current=""}}),[t,u,d,D,F,s,w,p,v]),h((()=>{s&&!t&&C.current&&null!=d&&j(o.reference.current)&&o.reference.current.focus()}),[o.reference,d,t,s]),h((()=>(C.current=!0,()=>{C.current=!1})),[]),h((()=>{var e;s&&(t||("auto"===y&&(I.current=!0),R.current=null!=(e=null!=d?d:a)?e:-1,D.current(null)))}),[t,d,a,s,y,D]),s?{reference:{...b&&t&&null!=a&&{"aria-activedescendant":M},onPointerEnter:N,onPointerDown:N,onKeyDown(e){if(P.current=!0,b&&t)return B(e);"auto"===y&&(I.current=!0),O.current=e.key,g?function(e,n,t){return ae(n,t?"ArrowLeft"===e:"ArrowRight"===e,"ArrowDown"===e)}(e.key,w,p)&&(X(e),t?(R.current=de(u),f(R.current)):r(!0)):(fe(e.key,w)&&(R.current=null==d?se(e.key,w,p)?de(u):ve(u):d,X(e),r(!0),f(R.current)),b&&!t&&B(e))}},floating:{"aria-orientation":"both"===w?void 0:w,...b&&null!=a&&{"aria-activedescendant":M},onKeyDown:B,onPointerMove(){P.current=!1}},item:{onClick:e=>{let{currentTarget:n}=e;return n.focus({preventScroll:!0})},...E&&{onPointerMove(e){let{currentTarget:n}=e;const t=n;if(t){const e=u.current.indexOf(t);-1!==e&&f(e)}},onPointerLeave(){var e;P.current||(f(null),b?(R.current=-1,F(u,R)):null==(e=o.floating.current)||e.focus({preventScroll:!0}))}}}}:{}},ge=function(e,n){var t;let{open:r,dataRef:o}=e,{listRef:u,activeIndex:i,onMatch:l=(()=>{}),enabled:a=!0,findMatch:f=null,resetMs:s=1e3,ignoreKeys:d=[],selectedIndex:v=null}=void 0===n?{listRef:{current:[]},activeIndex:null}:n;const m=c(),g=c(""),p=c(null!=(t=null!=v?v:i)?t:-1),b=c(null);function y(e){if(!e.currentTarget.contains(M(e.currentTarget).activeElement))return;g.current.length>0&&" "!==g.current[0]&&(o.current.typing=!0," "===e.key&&X(e));const n=u.current;if(null==n||["Home","End","Escape","Enter","Tab","ArrowUp","ArrowDown","ArrowLeft","ArrowRight",...d].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="",p.current=b.current),g.current+=e.key,clearTimeout(m.current),m.current=setTimeout((()=>{g.current="",p.current=b.current,o.current.typing=!1}),s);const t=p.current,r=[...n.slice((null!=t?t:0)+1),...n.slice(0,(null!=t?t:0)+1)],c=f?f(r,g.current):r.find((e=>0===(null==e?void 0:e.toLocaleLowerCase().indexOf(g.current)))),i=c?n.indexOf(c):-1;-1!==i&&(l(i),b.current=i)}return h((()=>{r&&(clearTimeout(m.current),b.current=null,g.current="")}),[r]),h((()=>{var e;r&&""===g.current&&(p.current=null!=(e=null!=v?v:i)?e:-1)}),[r,v,i]),a?{reference:{onKeyDown:y},floating:{onKeyDown:y}}:{}};function pe(e){let{open:n=!1,onOpenChange:t=(()=>{}),placement:r,middleware:o,strategy:i,nodeId:a}=void 0===e?{}:e;const f=k(),s=c({}),d=l((()=>b()))[0],m=v({placement:r,middleware:o,strategy:i}),g=u((()=>({...m,dataRef:s,nodeId:a,events:d,open:n,onOpenChange:t})),[m,s,a,d,n,t]);return h((()=>{const e=null==f?void 0:f.nodesRef.current.find((e=>e.id===a));e&&(e.context=g)})),u((()=>({context:g,...m})),[m,g])}export{_ as FloatingDelayGroup,G as FloatingFocusManager,O as FloatingNode,V as FloatingOverlay,q as FloatingPortal,C as FloatingTree,B as safePolygon,te as useClick,ee as useDelayGroup,$ as useDelayGroupContext,re as useDismiss,pe as useFloating,R as useFloatingNodeId,A as useFloatingParentNodeId,k as useFloatingTree,oe as useFocus,ie as useFocusTrap,Q as useHover,L as useId,P as useInteractions,me as useListNavigation,ne as useRole,ge as useTypeahead}; | ||
import*as e from"react";import n,{useLayoutEffect as t,useEffect as r,useContext as o,useMemo as u,useRef as c,useCallback as i,useState as l,createContext as a,forwardRef as f,cloneElement as s}from"react";import{getOverflowAncestors as d,useFloating as v}from"@floating-ui/react-dom";export*from"@floating-ui/react-dom";import m from"point-in-polygon";import{createPortal as g}from"react-dom";import{hideOthers as p}from"aria-hidden";var h="undefined"!=typeof document?t:r;function b(){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 y=!1,E=0;const w=()=>"floating-ui-"+E++;const x=e["useId".toString()],L=null!=x?x:function(){const[n,t]=e.useState((()=>y?w():void 0));return h((()=>{null==n&&t(w())}),[]),e.useEffect((()=>{y||(y=!0)}),[]),n},T=a(null),I=a(null),A=()=>{var e,n;return null!=(e=null==(n=o(T))?void 0:n.id)?e:null},k=()=>o(I),O=()=>{const e=L(),n=k(),t=A();return h((()=>{const r={id:e,parentId:t};return null==n||n.addNode(r),()=>{null==n||n.removeNode(r)}}),[n,e,t]),e},C=e=>{let{children:t,id:r}=e;const o=A();return n.createElement(T.Provider,{value:u((()=>({id:r,parentId:o})),[r,o])},t)},R=e=>{let{children:t}=e;const r=c([]),o=i((e=>{r.current=[...r.current,e]}),[]),a=i((e=>{r.current=r.current.filter((n=>n!==e))}),[]),f=l((()=>b()))[0];return n.createElement(I.Provider,{value:u((()=>({nodesRef:r,addNode:o,removeNode:a,events:f})),[r,o,a,f])},t)};function D(e,n,t){const r={};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;0===t.indexOf("on")?(r[t]||(r[t]=[]),"function"==typeof o&&r[t].push(o),e[t]=function(){for(var e=arguments.length,n=new Array(e),o=0;o<e;o++)n[o]=arguments[o];r[t].forEach((e=>e(...n)))}):e[t]=o})),e):e),{})}}const P=function(e){return void 0===e&&(e=[]),{getReferenceProps:n=>D(n,e,"reference"),getFloatingProps:n=>D(n,e,"floating"),getItemProps:n=>D(n,e,"item")}};function M(e){var n;return null!=(n=null==e?void 0:e.ownerDocument)?n:document}function S(e){var n;return null!=(n=M(e).defaultView)?n:window}function F(e){return!!e&&e instanceof S(e).Element}function j(e){return!!e&&e instanceof S(e).HTMLElement}function N(e,n){var t;let r=null!=(t=null==e?void 0:e.nodesRef.current.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=null==e?void 0:e.nodesRef.current.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 B(e){let n,{restMs:t=0,buffer:r=1,debug:o=null}=void 0===e?{}:e;return e=>{let{x:o,y:u,placement:c,refs:i,onClose:l,nodeId:a,tree:f}=e;return function(e){var s;if(clearTimeout(n),e.pointerType&&"mouse"!==e.pointerType)return;const{target:d,clientX:v,clientY:g}=e,p=d;if("pointermove"===e.type&&F(i.reference.current)&&i.reference.current.contains(p)||null!=(s=i.floating.current)&&s.contains(p))return;if(f&&N(f,a).some((e=>{let{context:n}=e;return null==n?void 0:n.open})))return;if(!i.reference.current||!i.floating.current||null==c||null==o||null==u)return;const h=i.reference.current.getBoundingClientRect(),b=i.floating.current.getBoundingClientRect(),y=c.split("-")[0],E=o>b.right-b.width/2,w=u>b.bottom-b.height/2;switch(y){case"top":if(v>=b.left&&v<=b.right&&g>=b.bottom&&g<=h.top)return;break;case"bottom":if(v>=b.left&&v<=b.right&&g>=h.bottom&&g<=b.top)return;break;case"left":if(v>=b.right&&v<=h.left&&g>=b.left&&g<=b.right)return;break;case"right":if(v>=b.right&&v<=h.left&&g>=b.right&&g<=h.left)return}const x=function(e){let[n,t]=e;const o=b.width>h.width,u=b.height>h.height;switch(y){case"top":{const e=[o?n:E?n+r:n-r,t+r],u=[o?n:E?n-r:n+r,t+r],c=[[b.left,E||o?b.bottom-r:b.top],[b.right,E?o?b.bottom-r:b.top:b.bottom-r]];return E?[e,u,...c]:[e,...c,u]}case"bottom":{const e=[o?n:E?n+r:n-r,t-r],u=[o?n:E?n-r:n+r,t-r],c=[[b.left,E||o?b.top+r:b.bottom],[b.right,E?o?b.top+r:b.bottom:b.top+r]];return E?[e,u,...c]:[e,...c,u]}case"left":{const e=[n+r,u?t:w?t-r:t+r],o=[n+r,u?t:w?t+r:t-r],c=[[w||u?b.right-r:b.left,b.top],[w?u?b.right-r:b.left:b.right-r,b.bottom]];return w?[e,...c,o]:[...c,e,o]}case"right":{const e=[n-r,u?t:w?t+r:t-r],o=[n-r,u?t:w?t-r:t+r],c=[[w||u?b.left+r:b.right,b.top],[w?u?b.left+r:b.right:b.left+r,b.bottom]];return w?[e,o,...c]:[e,...c,o]}}}([o,u]);m([v,g],x)?t&&(n=setTimeout(l,t)):(clearTimeout(n),l())}}}const K="floating-ui-root",q=e=>{let{children:n,id:t=K}=e;const[r,o]=l(!1),u=c(null);return h((()=>{const e=document.getElementById(t);e?u.current=e:(u.current=document.createElement("div"),u.current.id=t);const n=u.current;document.body.contains(n)||document.body.appendChild(n),o(!0)}),[t]),r&&u.current?g(n,u.current):null};function H(){return H=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},H.apply(this,arguments)}const U="data-floating-ui-scroll-lock",V=f((function(e,t){let{lockScroll:r=!1,...o}=e;return h((()=>{if(!r)return;const e=window.pageXOffset,n=window.pageYOffset,t=Math.round(document.documentElement.getBoundingClientRect().left)+document.documentElement.scrollLeft?"paddingLeft":"paddingRight",o=window.innerWidth-document.documentElement.clientWidth;return document.body.hasAttribute(U)?void 0:(Object.assign(document.body.style,{position:"fixed",overflow:"hidden",top:"-"+n+"px",left:"-"+e+"px",right:"0",[t]:o+"px"}),document.body.setAttribute(U,""),()=>{Object.assign(document.body.style,{position:"",overflow:"",top:"",left:"",right:"",[t]:""}),document.body.removeAttribute(U),window.scrollTo(e,n)})}),[r]),n.createElement("div",H({ref:t},o,{style:{position:"fixed",overflow:"auto",top:0,right:0,bottom:0,left:0,...o.style}}))}));function X(e){e.preventDefault(),e.stopPropagation()}function Y(e){const n=c(e);return h((()=>{n.current=e})),n}function W(e){requestAnimationFrame((()=>{null==e||e.focus()}))}const z=f((function(e,t){return n.createElement("span",H({},e,{ref:t,tabIndex:0,style:{position:"fixed",opacity:"0",pointerEvents:"none",outline:"0"}}))}));function G(e){let{context:{refs:t,nodeId:o,onOpenChange:u},children:c,order:l=["content"],endGuard:a=!0,preventTabbing:f=!1,initialFocus:d=0,returnFocus:v=!0,modal:m=!0}=e;const g=Y(l),h=Y(u),b=k(),y=i((()=>g.current.map((e=>{return j(t.reference.current)&&"reference"===e?t.reference.current:t.floating.current&&"floating"===e?t.floating.current:"content"===e?Array.from(null!=(n=null==(r=t.floating.current)?void 0:r.querySelectorAll("input:not([type='hidden']):not([disabled]),select:not([disabled]),textarea:not([disabled]),a[href],button:not([disabled]),[tabindex],iframe,object,embed,area[href],audio[controls],video[controls],[contenteditable]:not([contenteditable='false'])"))?n:[]):null;var n,r})).flat().filter((e=>{if(e===t.floating.current||e===t.reference.current)return!0;if(j(e)){var n;return"-"!==(null!=(n=e.getAttribute("tabindex"))?n:"0")[0].trim()}}))),[g,t.floating,t.reference]);return r((()=>{const e=0===y().filter((e=>e!==t.floating.current&&e!==t.reference.current)).length;function n(n){if("Tab"===n.key){(f||e)&&X(n);const r=y();"reference"===g.current[0]&&n.target===t.reference.current&&(X(n),n.shiftKey?W(r[r.length-1]):W(r[1])),"floating"===g.current[1]&&n.target===t.floating.current&&n.shiftKey&&(X(n),W(r[0]))}}const r=M(t.floating.current);return r.addEventListener("keydown",n),()=>{r.removeEventListener("keydown",n)}}),[f,y,g,t.floating,t.reference]),r((()=>{function e(e){var n;const r=e.relatedTarget;null!=(n=t.floating.current)&&n.contains(r)||!F(t.reference.current)||t.reference.current.contains(r)||b&&N(b,o).some((e=>{var n,t;return null==(n=e.context)||null==(t=n.refs.floating.current)?void 0:t.contains(r)}))||h.current(!1)}const n=t.floating.current,r=t.reference.current;if(n&&j(r)){!m&&n.addEventListener("focusout",e);const t=m?p(n):null;return()=>{!m&&n.removeEventListener("focusout",e),null==t||t()}}}),[o,b,m,h,y,d,t.floating,t.reference]),r((()=>{var e;if(f)return;const n=t.floating.current,r=null!=(e=M(n).activeElement)?e:document.activeElement;var o;if("number"==typeof d)W(null!=(o=y()[d])?o:n);else if(j(null==d?void 0:d.current)){var u;W(null!=(u=d.current)?u:n)}return()=>{v&&j(r)&&W(r)}}),[f,y,d,m,v,t.floating]),n.createElement(n.Fragment,null,m&&n.createElement(z,{onFocus:e=>{X(e);const n=y();"reference"===l[0]?W(n[0]):W(n[n.length-1])}}),s(c,l.includes("floating")?{tabIndex:0}:{}),m&&a&&n.createElement(z,{onFocus:e=>{X(e),W(y()[0])}}))}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:o=0,handleClose:u=null,mouseOnly:l=!1,restMs:a=0}=void 0===n?{}:n;const{open:f,onOpenChange:s,dataRef:d,events:v,refs:m}=e,g=k(),p=Y(s),b=Y(u),y=c(),E=c(),w=c(),x=c(),L=c(!0);h((()=>{t&&(f||(y.current=void 0))})),r((()=>{if(t)return v.on("dismiss",e),()=>{v.off("dismiss",e)};function e(){clearTimeout(E.current),clearTimeout(x.current),L.current=!0}}),[t,v,m.floating]),r((()=>{if(!t||!b.current)return;function e(){var e;null!=(e=d.current.openEvent)&&e.type.includes("mouse")&&p.current(!1)}const n=M(m.floating.current).documentElement;return n.addEventListener("mouseleave",e),()=>{n.removeEventListener("mouseleave",e)}}),[m.floating,p,t,b,d]);const T=i((function(e){void 0===e&&(e=!0),o&&!w.current?(clearTimeout(E.current),E.current=setTimeout((()=>p.current(!1)),J(o,"close",y.current))):e&&p.current(!1)}),[o,p]),I=i((()=>{w.current&&(M(m.floating.current).removeEventListener("pointermove",w.current),w.current=void 0)}),[m.floating]);if(r((()=>{f||I()}),[f,t,I]),r((()=>{if(!t)return;function n(e){clearTimeout(E.current),L.current=!1,f||l&&"mouse"!==y.current||a>0&&0===J(o,"open")||(d.current.openEvent=e,o?E.current=setTimeout((()=>{p.current(!0)}),J(o,"open",y.current)):p.current(!0))}function r(n){var t,r;if("click"===(null==(t=d.current.openEvent)?void 0:t.type)||"pointerdown"===(null==(r=d.current.openEvent)?void 0:r.type))return;const o=M(m.floating.current);if(clearTimeout(x.current),b.current)return clearTimeout(E.current),w.current&&o.removeEventListener("pointermove",w.current),w.current=b.current({...e,tree:g,x:n.clientX,y:n.clientY,onClose(){I(),T()}}),void o.addEventListener("pointermove",w.current);T()}const u=m.reference.current;return F(u)?(u.addEventListener("mouseenter",n),u.addEventListener("mouseleave",r),()=>{u.removeEventListener("mouseenter",n),u.removeEventListener("mouseleave",r)}):void 0}),[t,T,e,o,b,d,l,p,f,g,a,I,m.reference,m.floating]),!t)return{};function A(e){y.current=e.pointerType}return{reference:{onPointerDown:A,onPointerEnter:A,onMouseMove(){f||0===a||(clearTimeout(x.current),x.current=setTimeout((()=>{L.current||s(!0)}),a))}},floating:{onMouseEnter(){clearTimeout(E.current)},onMouseLeave:()=>T(!1)}}},Z=a({delay:1e3,initialDelay:1e3,currentId:null,setCurrentId:()=>{},setState:()=>{}}),$=()=>o(Z),_=e=>{let{children:t,delay:r}=e;const[o,c]=l({delay:r,initialDelay:r,currentId:null}),a=i((e=>{c((n=>({...n,currentId:e})))}),[]);return n.createElement(Z.Provider,{value:u((()=>({...o,setState:c,setCurrentId:a})),[o,c,a])},t)},ee=(e,n)=>{let{open:t,onOpenChange:o}=e,{id:u}=n;const{currentId:c,initialDelay:i,setState:l}=$(),a=Y(o);r((()=>{c&&a.current&&(l((e=>({...e,delay:{open:1,close:J(i,"close")}}))),c!==u&&a.current(!1))}),[u,a,l,c,i]),r((()=>{!t&&c===u&&a.current&&(a.current(!1),l((e=>({...e,delay:i,currentId:null}))))}),[t,l,c,u,a,i])},ne=function(e,n){let{open:t}=e,{enabled:r=!0,role:o="dialog"}=void 0===n?{}:n;const u=L(),c=L(),i={id:u,role:o};return r?"tooltip"===o?{reference:{"aria-describedby":t?u:void 0},floating:i}:{reference:{"aria-expanded":t?"true":"false","aria-haspopup":o,"aria-controls":t?u:void 0,..."listbox"===o&&{role:"combobox"},..."menu"===o&&{id:c}},floating:{...i,..."menu"===o&&{"aria-labelledby":c}}}:{}},te=function(e,n){let{open:t,onOpenChange:r,dataRef:o}=e,{enabled:u=!0,pointerDown:i=!1,toggle:l=!0}=void 0===n?{}:n;const a=c();return u?{reference:{...i&&{onPointerDown(e){var n;(a.current=e.pointerType,t)?l&&"pointerdown"===(null==(n=o.current.openEvent)?void 0:n.type)&&r(!1):r(!0);o.current.openEvent=e.nativeEvent}},onClick(e){if(i&&a.current)a.current=void 0;else{var n;if(t)l&&"click"===(null==(n=o.current.openEvent)?void 0:n.type)&&r(!1);else r(!0);o.current.openEvent=e.nativeEvent}}}}:{}},re=function(e,n){let{open:t,onOpenChange:o,refs:u,events:c,nodeId:l}=e,{enabled:a=!0,escapeKey:f=!0,outsidePointerDown:s=!0,referencePointerDown:v=!1,ancestorScroll:m=!1,bubbles:g=!0}=void 0===n?{}:n;const p=k(),h=Y(o),b=i((()=>{var e;return null==(e=u.floating.current)?void 0:e.contains(M(u.floating.current).activeElement)}),[u.floating]),y=i((()=>{j(u.reference.current)&&u.reference.current.focus()}),[u.reference]);return r((()=>{if(!t||!a)return;function e(e){if("Escape"===e.key){if(!g&&!b())return;c.emit("dismiss"),h.current(!1),y()}}function n(e){var n;const t=p&&N(p,l).some((n=>{var t,r;return null==(t=n.context)||null==(r=t.refs.floating.current)?void 0:r.contains(e.target)}));null!=(n=u.floating.current)&&n.contains(e.target)||F(u.reference.current)&&u.reference.current.contains(e.target)||t||(g||b())&&(c.emit("dismiss"),h.current(!1),y())}function r(){h.current(!1)}const o=M(u.floating.current);f&&o.addEventListener("keydown",e),s&&o.addEventListener("mousedown",n);const i=(m?[...F(u.reference.current)?d(u.reference.current):[],...F(u.floating.current)?d(u.floating.current):[]]:[]).filter((e=>{var n;return e!==(null==(n=o.defaultView)?void 0:n.visualViewport)}));return i.forEach((e=>e.addEventListener("scroll",r,{passive:!0}))),()=>{f&&o.removeEventListener("keydown",e),s&&o.removeEventListener("mousedown",n),i.forEach((e=>e.removeEventListener("scroll",r)))}}),[f,s,c,p,l,t,h,y,m,a,g,b,u.floating,u.reference]),a?{reference:{onPointerDown(){v&&(c.emit("dismiss"),o(!1))}}}:{}},oe=function(e,n){let{open:t,onOpenChange:o,dataRef:u,refs:i,events:l}=e,{enabled:a=!0,keyboardOnly:f=!0}=void 0===n?{}:n;const s=c(!1);return r((()=>{var e;if(!a)return;const n=null!=(e=M(i.floating.current).defaultView)?e:window;function r(){s.current=!t}function o(){setTimeout((()=>{s.current=!1}))}return n.addEventListener("focus",o),n.addEventListener("blur",r),()=>{n.removeEventListener("focus",o),n.removeEventListener("blur",r)}}),[i.floating,t,a]),r((()=>{if(a)return l.on("dismiss",e),()=>{l.off("dismiss",e)};function e(){s.current=!0}}),[l,a]),a?{reference:{onPointerDown(e){let{pointerType:n}=e;s.current=!(!n||!f)},onFocus(e){var n,t,r;s.current||"focus"===e.type&&"mousedown"===(null==(n=u.current.openEvent)?void 0:n.type)&&F(i.reference.current)&&null!=(t=i.reference.current)&&t.contains(null==(r=u.current.openEvent)?void 0:r.target)||(u.current.openEvent=e.nativeEvent,o(!0))},onBlur(e){var n;const t=e.relatedTarget;null!=(n=i.floating.current)&&n.contains(t)||F(i.reference.current)&&i.reference.current.contains(t)||(s.current=!1,o(!1))}}}:{}},ue=["content"];function ce(e){requestAnimationFrame((()=>{null==e||e.focus()}))}const ie=function(e,n){let{open:t,onOpenChange:o,refs:u,nodeId:l}=e,{enabled:a=!0,initialContentFocus:f=0,order:s=ue,modal:d=!0,inert:v=!1}=void 0===n?{}:n;const m=c(!1),g=c(null),b=c(null),y=Y(d),E=Y(s),w=i((()=>E.current.map((e=>{return j(u.reference.current)&&"reference"===e?u.reference.current:u.floating.current&&"floating"===e?u.floating.current:"content"===e?Array.from(null!=(n=null==(t=u.floating.current)?void 0:t.querySelectorAll("a[href],area[href],input:not([disabled]),select:not([disabled]),textarea:not([disabled]),button:not([disabled]),iframe,object,embed,*[tabindex],*[contenteditable]"))?n:[]):null;var n,t})).filter(Boolean).flat()),[u.floating,u.reference]);h((()=>{const e=u.floating.current;if(!(a&&t&&e&&d))return;function n(){const n=M(e).createElement("div");return n.tabIndex=0,Object.assign(n.style,{position:"fixed",outline:"0",pointerEvents:"none"}),n.setAttribute("aria-hidden","true"),n}g.current||(g.current=n()),b.current||(b.current=n());const r=g.current,o=b.current;function c(e){var n;X(e);const t=w();null==(n=t[e.target===o?0:t.length-1])||n.focus()}return e.insertAdjacentElement("beforebegin",r),e.insertAdjacentElement("afterend",o),r.addEventListener("focus",c),o.addEventListener("focus",c),()=>{var e,n;r.removeEventListener("focus",c),o.removeEventListener("focus",c),null!=(e=r.parentNode)&&e.contains(r)&&r.parentNode.removeChild(r),null!=(n=o.parentNode)&&n.contains(o)&&o.parentNode.removeChild(o)}}),[a,t,d,v,w,u.floating]),r((()=>{if(!a||!t||!v)return;function e(e){"Tab"===e.key&&X(e)}const n=M(u.floating.current);return n.addEventListener("keydown",e),()=>{n.removeEventListener("keydown",e)}}),[a,t,v,u.floating]),r((()=>{if(!a)return;const e=w();if(v){if(t){const n=e[0];n!==u.floating.current||n.contains(n.ownerDocument.activeElement)||ce(n)}}else t&&("number"==typeof f?ce(e[f]):f.current&&ce(e.find((e=>e===f.current))))}),[w,t,v,d,f,a,u.reference,u.floating]),r((()=>{a&&!v&&!t&&y.current&&m.current&&j(u.reference.current)&&ce(u.reference.current)}),[t,a,v,y,u.reference]),r((()=>{if(t&&d&&a&&u.floating.current)return p(u.floating.current)}),[t,d,a,u.floating]),r((()=>(m.current=!0,()=>{m.current=!1})),[]);const x=k();function L(e){var n;const t=e.relatedTarget;null!=(n=u.floating.current)&&n.contains(t)||!F(u.reference.current)||u.reference.current.contains(t)||x&&N(x,l).some((e=>{var n,r,o;return null==(n=e.context)||null==(r=n.refs.floating)||null==(o=r.current)?void 0:o.contains(t)}))||o(!1)}return a?d?{floating:{"aria-modal":"true"}}:{reference:{onBlur:L},floating:{onBlur:L}}:{}};function le(e,n){let{startingIndex:t=-1,decrement:r=!1}=void 0===n?{}:n;const o=e.current;let u=t;do{var c,i;u+=r?-1:1}while(u>=0&&u<=o.length-1&&(null==o[u]||null!=(c=o[u])&&c.hasAttribute("disabled")||"true"===(null==(i=o[u])?void 0:i.getAttribute("aria-disabled"))));return u}function ae(e,n,t){switch(e){case"vertical":return n;case"horizontal":return t;default:return n||t}}function fe(e,n){return ae(n,"ArrowUp"===e||"ArrowDown"===e,"ArrowLeft"===e||"ArrowRight"===e)}function se(e,n,t){return ae(n,"ArrowDown"===e,t?"ArrowLeft"===e:"ArrowRight"===e)}function de(e){return le(e)}function ve(e){return le(e,{decrement:!0,startingIndex:e.current.length})}const me=function(e,n){let{open:t,onOpenChange:r,refs:o}=e,{listRef:u,activeIndex:a,onNavigate:f,enabled:s=!0,selectedIndex:d=null,allowEscape:v=!1,loop:m=!1,nested:g=!1,rtl:p=!1,virtual:b=!1,focusItemOnOpen:y="auto",focusItemOnHover:E=!0,orientation:w="vertical"}=void 0===n?{listRef:{current:[]},activeIndex:null,onNavigate:()=>{}}:n;const x=A(),L=k(),T=function(e){const n=c();return h((()=>{n.current=e}),[e]),n.current}(t),I=c(y),O=c(null!=d?d:-1),C=c(""),R=c(!1),D=Y(f),P=c(!1),[M,S]=l(),F=i(((e,n)=>{var t,r;b?S(null==(t=e.current[n.current])?void 0:t.id):null==(r=e.current[n.current])||r.focus({preventScroll:!0})}),[b]);function N(e){"auto"===y&&(I.current=!e.pointerType)}function B(e){if(P.current=!0,g&&function(e,n,t){return ae(n,t?"ArrowRight"===e:"ArrowLeft"===e,"ArrowUp"===e)}(e.key,w,p))return X(e),r(!1),void(j(o.reference.current)&&o.reference.current.focus());const n=O.current,t=de(u),c=ve(u);if("Home"===e.key&&(O.current=t,f(O.current)),"End"===e.key&&(O.current=c,f(O.current)),fe(e.key,w)){if(X(e),!b&&e.currentTarget.ownerDocument.activeElement===e.currentTarget)return O.current=null!=d?d:se(e.key,w,p)?t:c,void f(O.current);se(e.key,w,p)?O.current=m?n>=c?v&&n!==u.current.length?-1:t:le(u,{startingIndex:n}):Math.min(c,le(u,{startingIndex:n})):O.current=m?n<=t?v&&-1!==n?u.current.length:c:le(u,{startingIndex:n,decrement:!0}):Math.max(t,le(u,{startingIndex:n,decrement:!0})),f(O.current)}}return h((()=>{s&&(null!=d&&(O.current=d),!T&&t&&I.current&&(D.current(O.current),F(u,O)))}),[t,T,d,u,D,F,s]),h((()=>{s&&t&&(null===a?(!T&&I.current&&null==d||v)&&(O.current=v?-1:de(u),D.current(a),F(u,O)):(O.current=a,D.current(a),F(u,O)))}),[t,T,a,d,g,u,D,F,s,x,v,o.floating,null==L?void 0:L.nodesRef]),h((()=>{if(null==d&&s){if(t&&(fe(C.current,w)||I.current&&(" "===C.current||"Enter"===C.current))){const e=de(u),n=ve(u);O.current=function(e,n,t){return ae(n,"ArrowUp"===e,t?"ArrowRight"===e:"ArrowLeft"===e)}(C.current,w,p)?v?u.current.length:n:v?-1:e,D.current(O.current),F(u,O)}C.current=""}}),[t,u,d,D,F,s,w,p,v]),h((()=>{s&&!t&&R.current&&null!=d&&j(o.reference.current)&&o.reference.current.focus()}),[o.reference,d,t,s]),h((()=>(R.current=!0,()=>{R.current=!1})),[]),h((()=>{var e;s&&(t||("auto"===y&&(I.current=!0),O.current=null!=(e=null!=d?d:a)?e:-1,D.current(null)))}),[t,d,a,s,y,D]),s?{reference:{...b&&t&&null!=a&&{"aria-activedescendant":M},onPointerEnter:N,onPointerDown:N,onKeyDown(e){if(P.current=!0,b&&t)return B(e);"auto"===y&&(I.current=!0),C.current=e.key,g?function(e,n,t){return ae(n,t?"ArrowLeft"===e:"ArrowRight"===e,"ArrowDown"===e)}(e.key,w,p)&&(X(e),t?(O.current=de(u),f(O.current)):r(!0)):(fe(e.key,w)&&(O.current=null==d?se(e.key,w,p)?de(u):ve(u):d,X(e),r(!0),f(O.current)),b&&!t&&B(e))}},floating:{"aria-orientation":"both"===w?void 0:w,...b&&null!=a&&{"aria-activedescendant":M},onKeyDown:B,onPointerMove(){P.current=!1}},item:{onClick:e=>{let{currentTarget:n}=e;return n.focus({preventScroll:!0})},...E&&{onPointerMove(e){let{currentTarget:n}=e;const t=n;if(t){const e=u.current.indexOf(t);-1!==e&&f(e)}},onPointerLeave(){var e;P.current||(f(null),b?(O.current=-1,F(u,O)):null==(e=o.floating.current)||e.focus({preventScroll:!0}))}}}}:{}},ge=function(e,n){var t;let{open:r,dataRef:o}=e,{listRef:u,activeIndex:i,onMatch:l=(()=>{}),enabled:a=!0,findMatch:f=null,resetMs:s=1e3,ignoreKeys:d=[],selectedIndex:v=null}=void 0===n?{listRef:{current:[]},activeIndex:null}:n;const m=c(),g=c(""),p=c(null!=(t=null!=v?v:i)?t:-1),b=c(null);function y(e){if(!e.currentTarget.contains(M(e.currentTarget).activeElement))return;g.current.length>0&&" "!==g.current[0]&&(o.current.typing=!0," "===e.key&&X(e));const n=u.current;if(null==n||["Home","End","Escape","Enter","Tab","ArrowUp","ArrowDown","ArrowLeft","ArrowRight",...d].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="",p.current=b.current),g.current+=e.key,clearTimeout(m.current),m.current=setTimeout((()=>{g.current="",p.current=b.current,o.current.typing=!1}),s);const t=p.current,r=[...n.slice((null!=t?t:0)+1),...n.slice(0,(null!=t?t:0)+1)],c=f?f(r,g.current):r.find((e=>0===(null==e?void 0:e.toLocaleLowerCase().indexOf(g.current)))),i=c?n.indexOf(c):-1;-1!==i&&(l(i),b.current=i)}return h((()=>{r&&(clearTimeout(m.current),b.current=null,g.current="")}),[r]),h((()=>{var e;r&&""===g.current&&(p.current=null!=(e=null!=v?v:i)?e:-1)}),[r,v,i]),a?{reference:{onKeyDown:y},floating:{onKeyDown:y}}:{}};function pe(e){let{open:n=!1,onOpenChange:t=(()=>{}),placement:r,middleware:o,strategy:i,nodeId:a}=void 0===e?{}:e;const f=k(),s=c({}),d=l((()=>b()))[0],m=v({placement:r,middleware:o,strategy:i}),g=u((()=>({...m,dataRef:s,nodeId:a,events:d,open:n,onOpenChange:t})),[m,s,a,d,n,t]);return h((()=>{const e=null==f?void 0:f.nodesRef.current.find((e=>e.id===a));e&&(e.context=g)})),u((()=>({context:g,...m})),[m,g])}export{_ as FloatingDelayGroup,G as FloatingFocusManager,C as FloatingNode,V as FloatingOverlay,q as FloatingPortal,R as FloatingTree,B as safePolygon,te as useClick,ee as useDelayGroup,$ as useDelayGroupContext,re as useDismiss,pe as useFloating,O as useFloatingNodeId,A as useFloatingParentNodeId,k as useFloatingTree,oe as useFocus,ie as useFocusTrap,Q as useHover,L as useId,P as useInteractions,me as useListNavigation,ne as useRole,ge as useTypeahead}; |
@@ -1,1 +0,1 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("react"),require("@floating-ui/react-dom"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","react","@floating-ui/react-dom","react-dom"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).FloatingUIReactDOM={},e.React,e.FloatingUIReactDOM,e.ReactDOM)}(this,(function(e,n,t,r){"use strict";function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function u(e){if(e&&e.__esModule)return e;var n=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})}})),n.default=e,Object.freeze(n)}var c=u(n),i=o(n),l="undefined"!=typeof document?n.useLayoutEffect:n.useEffect;function a(){const e=new Map;return{emit(n,t){var r;null==(r=e.get(n))||r.forEach((e=>e(t)))},on(n,t){e.set(n,[...e.get(n)||[],t])},off(n,t){e.set(n,(e.get(n)||[]).filter((e=>e!==t)))}}}let f=!1,s=0;const d=()=>"floating-ui-"+s++;const v=c["useId".toString()],g=null!=v?v:function(){const[e,n]=c.useState((()=>f?d():void 0));return l((()=>{null==e&&n(d())}),[]),c.useEffect((()=>{f||(f=!0)}),[]),e},m=n.createContext(null),p=n.createContext(null),b=()=>{var e,t;return null!=(e=null==(t=n.useContext(m))?void 0:t.id)?e:null},y=()=>n.useContext(p);function h(e,n,t){const r={};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;0===t.indexOf("on")?(r[t]||(r[t]=[]),"function"==typeof o&&r[t].push(o),e[t]=function(){for(var e=arguments.length,n=new Array(e),o=0;o<e;o++)n[o]=arguments[o];r[t].forEach((e=>e(...n)))}):e[t]=o})),e):e),{})}}var E={exports:{}},w=function(e,n,t,r){var o=e[0],u=e[1],c=!1;void 0===t&&(t=0),void 0===r&&(r=n.length);for(var i=(r-t)/2,l=0,a=i-1;l<i;a=l++){var f=n[t+2*l+0],s=n[t+2*l+1],d=n[t+2*a+0],v=n[t+2*a+1];s>u!=v>u&&o<(d-f)*(u-s)/(v-s)+f&&(c=!c)}return c},x=function(e,n,t,r){var o=e[0],u=e[1],c=!1;void 0===t&&(t=0),void 0===r&&(r=n.length);for(var i=r-t,l=0,a=i-1;l<i;a=l++){var f=n[l+t][0],s=n[l+t][1],d=n[a+t][0],v=n[a+t][1];s>u!=v>u&&o<(d-f)*(u-s)/(v-s)+f&&(c=!c)}return c};E.exports=function(e,n,t,r){return n.length>0&&Array.isArray(n[0])?x(e,n,t,r):w(e,n,t,r)},E.exports.nested=x,E.exports.flat=w;var R=E.exports;function k(e){var n;return null!=(n=null==e?void 0:e.ownerDocument)?n:document}function C(e){var n;return null!=(n=k(e).defaultView)?n:window}function O(e){return!!e&&e instanceof C(e).Element}function T(e){return!!e&&e instanceof C(e).HTMLElement}function I(e,n){var t;let r=null!=(t=null==e?void 0:e.nodesRef.current.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=null==e?void 0:e.nodesRef.current.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}const L="floating-ui-root";function A(){return A=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},A.apply(this,arguments)}const M="data-floating-ui-scroll-lock",D=n.forwardRef((function(e,n){let{lockScroll:t=!1,...r}=e;return l((()=>{if(!t)return;const e=window.pageXOffset,n=window.pageYOffset,r=Math.round(document.documentElement.getBoundingClientRect().left)+document.documentElement.scrollLeft?"paddingLeft":"paddingRight",o=window.innerWidth-document.documentElement.clientWidth;return document.body.hasAttribute(M)?void 0:(Object.assign(document.body.style,{position:"fixed",overflow:"hidden",top:"-"+n+"px",left:"-"+e+"px",right:"0",[r]:o+"px"}),document.body.setAttribute(M,""),()=>{Object.assign(document.body.style,{position:"",overflow:"",top:"",left:"",right:"",[r]:""}),document.body.removeAttribute(M),window.scrollTo(e,n)})}),[t]),i.default.createElement("div",A({ref:n},r,{style:{position:"fixed",overflow:"auto",top:0,right:0,bottom:0,left:0,...r.style}}))}));var P=new WeakMap,F=new WeakMap,j={},S=0,N=function(e,n,t){void 0===n&&(n=function(e){return"undefined"==typeof document?null:(Array.isArray(e)?e[0]:e).ownerDocument.body}(e)),void 0===t&&(t="data-aria-hidden");var r=Array.isArray(e)?e:[e];j[t]||(j[t]=new WeakMap);var o=j[t],u=[],c=new Set,i=function(e){e&&!c.has(e)&&(c.add(e),i(e.parentNode))};r.forEach(i);var l=function(e){!e||r.indexOf(e)>=0||Array.prototype.forEach.call(e.children,(function(e){if(c.has(e))l(e);else{var n=e.getAttribute("aria-hidden"),r=null!==n&&"false"!==n,i=(P.get(e)||0)+1,a=(o.get(e)||0)+1;P.set(e,i),o.set(e,a),u.push(e),1===i&&r&&F.set(e,!0),1===a&&e.setAttribute(t,"true"),r||e.setAttribute("aria-hidden","true")}}))};return l(n),c.clear(),S++,function(){u.forEach((function(e){var n=P.get(e)-1,r=o.get(e)-1;P.set(e,n),o.set(e,r),n||(F.has(e)||e.removeAttribute("aria-hidden"),F.delete(e)),r||e.removeAttribute(t)})),--S||(P=new WeakMap,P=new WeakMap,F=new WeakMap,j={})}};function B(e){e.preventDefault(),e.stopPropagation()}function K(e){const t=n.useRef(e);return l((()=>{t.current=e})),t}function W(e){requestAnimationFrame((()=>{null==e||e.focus()}))}const q=n.forwardRef((function(e,n){return React.createElement("span",A({},e,{ref:n,tabIndex:0,style:{position:"fixed",opacity:"0",pointerEvents:"none",outline:"0"}}))}));function H(e,n,t){return t&&"mouse"!==t?0:"number"==typeof e?e:null==e?void 0:e[n]}const G=n.createContext({delay:1e3,initialDelay:1e3,currentId:null,setCurrentId:()=>{},setState:()=>{}}),U=()=>n.useContext(G),V=["content"];function _(e){requestAnimationFrame((()=>{null==e||e.focus()}))}const X="ArrowUp",Y="ArrowDown",z="ArrowLeft",J="ArrowRight";function Q(e,n){let{startingIndex:t=-1,decrement:r=!1}=void 0===n?{}:n;const o=e.current;let u=t;do{var c,i;u+=r?-1:1}while(u>=0&&u<=o.length-1&&(null==o[u]||null!=(c=o[u])&&c.hasAttribute("disabled")||"true"===(null==(i=o[u])?void 0:i.getAttribute("aria-disabled"))));return u}function Z(e,n,t){switch(e){case"vertical":return n;case"horizontal":return t;default:return n||t}}function $(e,n){return Z(n,e===X||e===Y,e===z||e===J)}function ee(e,n,t){return Z(n,e===Y,t?e===z:e===J)}function ne(e){return Q(e)}function te(e){return Q(e,{decrement:!0,startingIndex:e.current.length})}e.FloatingDelayGroup=e=>{let{children:t,delay:r}=e;const[o,u]=n.useState({delay:r,initialDelay:r,currentId:null}),c=n.useCallback((e=>{u((n=>({...n,currentId:e})))}),[]);return i.default.createElement(G.Provider,{value:n.useMemo((()=>({...o,setState:u,setCurrentId:c})),[o,u,c])},t)},e.FloatingFocusManager=function(e){let{context:{refs:t,nodeId:r,onOpenChange:o},children:u,order:c=["content"],endGuard:i=!0,preventTabbing:l=!1,initialFocus:a=0,returnFocus:f=!0,modal:s=!0}=e;const d=K(c),v=K(o),g=y(),m=n.useCallback((()=>d.current.map((e=>{return T(t.reference.current)&&"reference"===e?t.reference.current:t.floating.current&&"floating"===e?t.floating.current:"content"===e?Array.from(null!=(n=null==(r=t.floating.current)?void 0:r.querySelectorAll("input:not([type='hidden']):not([disabled]),select:not([disabled]),textarea:not([disabled]),a[href],button:not([disabled]),[tabindex],iframe,object,embed,area[href],audio[controls],video[controls],[contenteditable]:not([contenteditable='false'])"))?n:[]):null;var n,r})).flat().filter((e=>{if(e===t.floating.current||e===t.reference.current)return!0;if(T(e)){var n;return"-"!==(null!=(n=e.getAttribute("tabindex"))?n:"0")[0].trim()}}))),[d,t.floating,t.reference]);return n.useEffect((()=>{const e=0===m().filter((e=>e!==t.floating.current&&e!==t.reference.current)).length;function n(n){if("Tab"===n.key){(l||e)&&B(n);const r=m();"reference"===d.current[0]&&n.target===t.reference.current&&(B(n),n.shiftKey?W(r[r.length-1]):W(r[1])),"floating"===d.current[1]&&n.target===t.floating.current&&n.shiftKey&&(B(n),W(r[0]))}}const r=k(t.floating.current);return r.addEventListener("keydown",n),()=>{r.removeEventListener("keydown",n)}}),[l,m,d,t.floating,t.reference]),n.useEffect((()=>{function e(e){var n;const o=e.relatedTarget;null!=(n=t.floating.current)&&n.contains(o)||!O(t.reference.current)||t.reference.current.contains(o)||g&&I(g,r).some((e=>{var n,t;return null==(n=e.context)||null==(t=n.refs.floating.current)?void 0:t.contains(o)}))||v.current(!1)}const n=t.floating.current,o=t.reference.current;if(n&&T(o)){!s&&n.addEventListener("focusout",e);const t=s?N(n):null;return()=>{!s&&n.removeEventListener("focusout",e),null==t||t()}}}),[r,g,s,v,m,a,t.floating,t.reference]),n.useEffect((()=>{var e;if(l)return;const n=t.floating.current,r=null!=(e=k(n).activeElement)?e:document.activeElement;var o;if("number"==typeof a)W(null!=(o=m()[a])?o:n);else if(T(null==a?void 0:a.current)){var u;W(null!=(u=a.current)?u:n)}return()=>{f&&T(r)&&W(r)}}),[l,m,a,s,f,t.floating]),React.createElement(React.Fragment,null,s&&React.createElement(q,{onFocus:e=>{B(e);const n=m();"reference"===c[0]?W(n[0]):W(n[n.length-1])}}),n.cloneElement(u,c.includes("floating")?{tabIndex:0}:{}),s&&i&&React.createElement(q,{onFocus:e=>{B(e),W(m()[0])}}))},e.FloatingNode=e=>{let{children:t,id:r}=e;const o=b();return i.default.createElement(m.Provider,{value:n.useMemo((()=>({id:r,parentId:o})),[r,o])},t)},e.FloatingOverlay=D,e.FloatingPortal=e=>{let{children:t,id:o=L}=e;const[u,c]=n.useState(!1),i=n.useRef(null);return l((()=>{const e=document.getElementById(o);e?i.current=e:(i.current=document.createElement("div"),i.current.id=o);const n=i.current;document.body.contains(n)||document.body.appendChild(n),c(!0)}),[o]),u&&i.current?r.createPortal(t,i.current):null},e.FloatingTree=e=>{let{children:t}=e;const r=n.useRef([]),o=n.useCallback((e=>{r.current=[...r.current,e]}),[]),u=n.useCallback((e=>{r.current=r.current.filter((n=>n!==e))}),[]),c=n.useState((()=>a()))[0];return i.default.createElement(p.Provider,{value:n.useMemo((()=>({nodesRef:r,addNode:o,removeNode:u,events:c})),[r,o,u,c])},t)},e.safePolygon=function(e){let n,{restMs:t=0,buffer:r=1,debug:o=null}=void 0===e?{}:e;return e=>{let{x:o,y:u,placement:c,refs:i,onClose:l,nodeId:a,tree:f}=e;return function(e){var s;if(clearTimeout(n),e.pointerType&&"mouse"!==e.pointerType)return;const{target:d,clientX:v,clientY:g}=e,m=d;if("pointermove"===e.type&&O(i.reference.current)&&i.reference.current.contains(m)||null!=(s=i.floating.current)&&s.contains(m))return;if(f&&I(f,a).some((e=>{let{context:n}=e;return null==n?void 0:n.open})))return;if(!i.reference.current||!i.floating.current||null==c||null==o||null==u)return;const p=i.reference.current.getBoundingClientRect(),b=i.floating.current.getBoundingClientRect(),y=c.split("-")[0],h=o>b.right-b.width/2,E=u>b.bottom-b.height/2;switch(y){case"top":if(v>=b.left&&v<=b.right&&g>=b.bottom&&g<=p.top)return;break;case"bottom":if(v>=b.left&&v<=b.right&&g>=p.bottom&&g<=b.top)return;break;case"left":if(v>=b.right&&v<=p.left&&g>=b.left&&g<=b.right)return;break;case"right":if(v>=b.right&&v<=p.left&&g>=b.right&&g<=p.left)return}const w=function(e){let[n,t]=e;const o=b.width>p.width,u=b.height>p.height;switch(y){case"top":{const e=[o?n:h?n+r:n-r,t+r],u=[o?n:h?n-r:n+r,t+r],c=[[b.left,h||o?b.bottom-r:b.top],[b.right,h?o?b.bottom-r:b.top:b.bottom-r]];return h?[e,u,...c]:[e,...c,u]}case"bottom":{const e=[o?n:h?n+r:n-r,t-r],u=[o?n:h?n-r:n+r,t-r],c=[[b.left,h||o?b.top+r:b.bottom],[b.right,h?o?b.top+r:b.bottom:b.top+r]];return h?[e,u,...c]:[e,...c,u]}case"left":{const e=[n+r,u?t:E?t-r:t+r],o=[n+r,u?t:E?t+r:t-r],c=[[E||u?b.right-r:b.left,b.top],[E?u?b.right-r:b.left:b.right-r,b.bottom]];return E?[e,...c,o]:[...c,e,o]}case"right":{const e=[n-r,u?t:E?t+r:t-r],o=[n-r,u?t:E?t-r:t+r],c=[[E||u?b.left+r:b.right,b.top],[E?u?b.left+r:b.right:b.left+r,b.bottom]];return E?[e,o,...c]:[e,...c,o]}}}([o,u]);R([v,g],w)?t&&(n=setTimeout(l,t)):(clearTimeout(n),l())}}},e.useClick=function(e,t){let{open:r,onOpenChange:o,dataRef:u}=e,{enabled:c=!0,pointerDown:i=!1,toggle:l=!0}=void 0===t?{}:t;const a=n.useRef();return c?{reference:{...i&&{onPointerDown(e){var n;(a.current=e.pointerType,r)?l&&"pointerdown"===(null==(n=u.current.openEvent)?void 0:n.type)&&o(!1):o(!0);u.current.openEvent=e.nativeEvent}},onClick(e){if(i&&a.current)a.current=void 0;else{var n;if(r)l&&"click"===(null==(n=u.current.openEvent)?void 0:n.type)&&o(!1);else o(!0);u.current.openEvent=e.nativeEvent}}}}:{}},e.useDelayGroup=(e,t)=>{let{open:r,onOpenChange:o}=e,{id:u}=t;const{currentId:c,initialDelay:i,setState:l}=U();n.useEffect((()=>{c&&o&&(l((e=>({...e,delay:{open:0,close:H(i,"close")}}))),c!==u&&o(!1))}),[u,o,l,c,i]),n.useEffect((()=>{!r&&c===u&&o&&(o(!1),l((e=>({...e,delay:i,currentId:null}))))}),[r,l,c,u,o,i])},e.useDelayGroupContext=U,e.useDismiss=function(e,r){let{open:o,onOpenChange:u,refs:c,events:i,nodeId:l}=e,{enabled:a=!0,escapeKey:f=!0,outsidePointerDown:s=!0,referencePointerDown:d=!1,ancestorScroll:v=!1,bubbles:g=!0}=void 0===r?{}:r;const m=y(),p=K(u),b=n.useCallback((()=>{var e;return null==(e=c.floating.current)?void 0:e.contains(k(c.floating.current).activeElement)}),[c.floating]),h=n.useCallback((()=>{T(c.reference.current)&&c.reference.current.focus()}),[c.reference]);return n.useEffect((()=>{if(!o||!a)return;function e(e){if("Escape"===e.key){if(!g&&!b())return;i.emit("dismiss"),p.current(!1),h()}}function n(e){var n;const t=m&&I(m,l).some((n=>{var t,r;return null==(t=n.context)||null==(r=t.refs.floating.current)?void 0:r.contains(e.target)}));null!=(n=c.floating.current)&&n.contains(e.target)||O(c.reference.current)&&c.reference.current.contains(e.target)||t||(g||b())&&(i.emit("dismiss"),p.current(!1),h())}function r(){p.current(!1)}const u=k(c.floating.current);f&&u.addEventListener("keydown",e),s&&u.addEventListener("mousedown",n);const d=(v?[...O(c.reference.current)?t.getOverflowAncestors(c.reference.current):[],...O(c.floating.current)?t.getOverflowAncestors(c.floating.current):[]]:[]).filter((e=>{var n;return e!==(null==(n=u.defaultView)?void 0:n.visualViewport)}));return d.forEach((e=>e.addEventListener("scroll",r,{passive:!0}))),()=>{f&&u.removeEventListener("keydown",e),s&&u.removeEventListener("mousedown",n),d.forEach((e=>e.removeEventListener("scroll",r)))}}),[f,s,i,m,l,o,p,h,v,a,g,b,c.floating,c.reference]),a?{reference:{onPointerDown(){d&&(i.emit("dismiss"),u(!1))}}}:{}},e.useFloating=function(e){let{open:r=!1,onOpenChange:o=(()=>{}),placement:u,middleware:c,strategy:i,nodeId:f}=void 0===e?{}:e;const s=y(),d=n.useRef({}),v=n.useState((()=>a()))[0],g=t.useFloating({placement:u,middleware:c,strategy:i}),m=n.useMemo((()=>({...g,dataRef:d,nodeId:f,events:v,open:r,onOpenChange:o})),[g,d,f,v,r,o]);return l((()=>{const e=null==s?void 0:s.nodesRef.current.find((e=>e.id===f));e&&(e.context=m)})),n.useMemo((()=>({context:m,...g})),[g,m])},e.useFloatingNodeId=()=>{const e=g(),n=y(),t=b();return l((()=>{const r={id:e,parentId:t};return null==n||n.addNode(r),()=>{null==n||n.removeNode(r)}}),[n,e,t]),e},e.useFloatingParentNodeId=b,e.useFloatingTree=y,e.useFocus=function(e,t){let{open:r,onOpenChange:o,dataRef:u,refs:c,events:i}=e,{enabled:l=!0,keyboardOnly:a=!0}=void 0===t?{}:t;const f=n.useRef(!1);return n.useEffect((()=>{var e;if(!l)return;const n=null!=(e=k(c.floating.current).defaultView)?e:window;function t(){f.current=!r}function o(){setTimeout((()=>{f.current=!1}))}return n.addEventListener("focus",o),n.addEventListener("blur",t),()=>{n.removeEventListener("focus",o),n.removeEventListener("blur",t)}}),[c.floating,r,l]),n.useEffect((()=>{if(l)return i.on("dismiss",e),()=>{i.off("dismiss",e)};function e(){f.current=!0}}),[i,l]),l?{reference:{onPointerDown(e){let{pointerType:n}=e;f.current=!(!n||!a)},onFocus(e){var n,t,r;f.current||"focus"===e.type&&"mousedown"===(null==(n=u.current.openEvent)?void 0:n.type)&&O(c.reference.current)&&null!=(t=c.reference.current)&&t.contains(null==(r=u.current.openEvent)?void 0:r.target)||(u.current.openEvent=e.nativeEvent,o(!0))},onBlur(e){var n;const t=e.relatedTarget;null!=(n=c.floating.current)&&n.contains(t)||O(c.reference.current)&&c.reference.current.contains(t)||(f.current=!1,o(!1))}}}:{}},e.useFocusTrap=function(e,t){let{open:r,onOpenChange:o,refs:u,nodeId:c}=e,{enabled:i=!0,initialContentFocus:a=0,order:f=V,modal:s=!0,inert:d=!1}=void 0===t?{}:t;const v=n.useRef(!1),g=n.useRef(null),m=n.useRef(null),p=K(s),b=K(f),h=n.useCallback((()=>b.current.map((e=>{return T(u.reference.current)&&"reference"===e?u.reference.current:u.floating.current&&"floating"===e?u.floating.current:"content"===e?Array.from(null!=(n=null==(t=u.floating.current)?void 0:t.querySelectorAll("a[href],area[href],input:not([disabled]),select:not([disabled]),textarea:not([disabled]),button:not([disabled]),iframe,object,embed,*[tabindex],*[contenteditable]"))?n:[]):null;var n,t})).filter(Boolean).flat()),[u.floating,u.reference]);l((()=>{const e=u.floating.current;if(!(i&&r&&e&&s))return;function n(){const n=k(e).createElement("div");return n.tabIndex=0,Object.assign(n.style,{position:"fixed",outline:"0",pointerEvents:"none"}),n.setAttribute("aria-hidden","true"),n}g.current||(g.current=n()),m.current||(m.current=n());const t=g.current,o=m.current;function c(e){var n;B(e);const t=h();null==(n=t[e.target===o?0:t.length-1])||n.focus()}return e.insertAdjacentElement("beforebegin",t),e.insertAdjacentElement("afterend",o),t.addEventListener("focus",c),o.addEventListener("focus",c),()=>{var e,n;t.removeEventListener("focus",c),o.removeEventListener("focus",c),null!=(e=t.parentNode)&&e.contains(t)&&t.parentNode.removeChild(t),null!=(n=o.parentNode)&&n.contains(o)&&o.parentNode.removeChild(o)}}),[i,r,s,d,h,u.floating]),n.useEffect((()=>{if(!i||!r||!d)return;function e(e){"Tab"===e.key&&B(e)}const n=k(u.floating.current);return n.addEventListener("keydown",e),()=>{n.removeEventListener("keydown",e)}}),[i,r,d,u.floating]),n.useEffect((()=>{if(!i)return;const e=h();if(d){if(r){const n=e[0];n!==u.floating.current||n.contains(n.ownerDocument.activeElement)||_(n)}}else r&&("number"==typeof a?_(e[a]):a.current&&_(e.find((e=>e===a.current))))}),[h,r,d,s,a,i,u.reference,u.floating]),n.useEffect((()=>{i&&!d&&!r&&p.current&&v.current&&T(u.reference.current)&&_(u.reference.current)}),[r,i,d,p,u.reference]),n.useEffect((()=>{if(r&&s&&i&&u.floating.current)return N(u.floating.current)}),[r,s,i,u.floating]),n.useEffect((()=>(v.current=!0,()=>{v.current=!1})),[]);const E=y();function w(e){var n;const t=e.relatedTarget;null!=(n=u.floating.current)&&n.contains(t)||!O(u.reference.current)||u.reference.current.contains(t)||E&&I(E,c).some((e=>{var n,r,o;return null==(n=e.context)||null==(r=n.refs.floating)||null==(o=r.current)?void 0:o.contains(t)}))||o(!1)}return i?s?{floating:{"aria-modal":"true"}}:{reference:{onBlur:w},floating:{onBlur:w}}:{}},e.useHover=function(e,t){let{enabled:r=!0,delay:o=0,handleClose:u=null,mouseOnly:c=!1,restMs:i=0}=void 0===t?{}:t;const{open:a,onOpenChange:f,dataRef:s,events:d,refs:v}=e,g=y(),m=K(f),p=K(u),b=n.useRef(),h=n.useRef(),E=n.useRef(),w=n.useRef(),x=n.useRef(!0);l((()=>{r&&(a||(b.current=void 0))})),n.useEffect((()=>{if(r)return d.on("dismiss",e),()=>{d.off("dismiss",e)};function e(){clearTimeout(h.current),clearTimeout(w.current),x.current=!0}}),[r,d,v.floating]),n.useEffect((()=>{if(!r||!p.current)return;function e(){var e;null!=(e=s.current.openEvent)&&e.type.includes("mouse")&&m.current(!1)}const n=k(v.floating.current).documentElement;return n.addEventListener("mouseleave",e),()=>{n.removeEventListener("mouseleave",e)}}),[v.floating,m,r,p,s]);const R=n.useCallback((function(e){void 0===e&&(e=!0),o&&!E.current?(clearTimeout(h.current),h.current=setTimeout((()=>m.current(!1)),H(o,"close",b.current))):e&&m.current(!1)}),[o,m]),C=n.useCallback((()=>{E.current&&(k(v.floating.current).removeEventListener("pointermove",E.current),E.current=void 0)}),[v.floating]);if(n.useEffect((()=>{a||C()}),[a,r,C]),n.useEffect((()=>{if(!r)return;function n(e){clearTimeout(h.current),x.current=!1,a||c&&"mouse"!==b.current||i>0&&0===H(o,"open")||(s.current.openEvent=e,o?h.current=setTimeout((()=>{m.current(!0)}),H(o,"open",b.current)):m.current(!0))}function t(n){var t,r;if("click"===(null==(t=s.current.openEvent)?void 0:t.type)||"pointerdown"===(null==(r=s.current.openEvent)?void 0:r.type))return;const o=k(v.floating.current);if(clearTimeout(w.current),p.current)return clearTimeout(h.current),E.current&&o.removeEventListener("pointermove",E.current),E.current=p.current({...e,tree:g,x:n.clientX,y:n.clientY,onClose(){C(),R()}}),void o.addEventListener("pointermove",E.current);R()}const u=v.reference.current;return O(u)?(u.addEventListener("mouseenter",n),u.addEventListener("mouseleave",t),()=>{u.removeEventListener("mouseenter",n),u.removeEventListener("mouseleave",t)}):void 0}),[r,R,e,o,p,s,c,m,a,g,i,C,v.reference,v.floating]),!r)return{};function T(e){b.current=e.pointerType}return{reference:{onPointerDown:T,onPointerEnter:T,onMouseMove(){a||0===i||(clearTimeout(w.current),w.current=setTimeout((()=>{x.current||f(!0)}),i))}},floating:{onMouseEnter(){clearTimeout(h.current)},onMouseLeave:()=>R(!1)}}},e.useId=g,e.useInteractions=function(e){return void 0===e&&(e=[]),{getReferenceProps:n=>h(n,e,"reference"),getFloatingProps:n=>h(n,e,"floating"),getItemProps:n=>h(n,e,"item")}},e.useListNavigation=function(e,t){let{open:r,onOpenChange:o,refs:u}=e,{listRef:c,activeIndex:i,onNavigate:a,enabled:f=!0,selectedIndex:s=null,allowEscape:d=!1,loop:v=!1,nested:g=!1,rtl:m=!1,virtual:p=!1,focusItemOnOpen:h="auto",focusItemOnHover:E=!0,orientation:w="vertical"}=void 0===t?{listRef:{current:[]},activeIndex:null,onNavigate:()=>{}}:t;const x=b(),R=y(),k=function(e){const t=n.useRef();return l((()=>{t.current=e}),[e]),t.current}(r),C=n.useRef(h),O=n.useRef(null!=s?s:-1),I=n.useRef(""),L=n.useRef(!1),A=K(a),M=n.useRef(!1),[D,P]=n.useState(),F=n.useCallback(((e,n)=>{var t,r;p?P(null==(t=e.current[n.current])?void 0:t.id):null==(r=e.current[n.current])||r.focus({preventScroll:!0})}),[p]);function j(e){"auto"===h&&(C.current=!e.pointerType)}function S(e){if(M.current=!0,g&&function(e,n,t){return Z(n,t?e===J:e===z,e===X)}(e.key,w,m))return B(e),o(!1),void(T(u.reference.current)&&u.reference.current.focus());const n=O.current,t=ne(c),r=te(c);if("Home"===e.key&&(O.current=t,a(O.current)),"End"===e.key&&(O.current=r,a(O.current)),$(e.key,w)){if(B(e),!p&&e.currentTarget.ownerDocument.activeElement===e.currentTarget)return O.current=null!=s?s:ee(e.key,w,m)?t:r,void a(O.current);ee(e.key,w,m)?O.current=v?n>=r?d&&n!==c.current.length?-1:t:Q(c,{startingIndex:n}):Math.min(r,Q(c,{startingIndex:n})):O.current=v?n<=t?d&&-1!==n?c.current.length:r:Q(c,{startingIndex:n,decrement:!0}):Math.max(t,Q(c,{startingIndex:n,decrement:!0})),a(O.current)}}return l((()=>{f&&(null!=s&&(O.current=s),!k&&r&&C.current&&(A.current(O.current),F(c,O)))}),[r,k,s,c,A,F,f]),l((()=>{f&&r&&(null===i?(!k&&C.current&&null==s||d)&&(O.current=d?-1:ne(c),A.current(i),F(c,O)):(O.current=i,A.current(i),F(c,O)))}),[r,k,i,s,g,c,A,F,f,x,d,u.floating,null==R?void 0:R.nodesRef]),l((()=>{if(null==s&&f){if(r&&($(I.current,w)||C.current&&(" "===I.current||"Enter"===I.current))){const e=ne(c),n=te(c);O.current=function(e,n,t){return Z(n,e===X,t?e===J:e===z)}(I.current,w,m)?d?c.current.length:n:d?-1:e,A.current(O.current),F(c,O)}I.current=""}}),[r,c,s,A,F,f,w,m,d]),l((()=>{f&&!r&&L.current&&null!=s&&T(u.reference.current)&&u.reference.current.focus()}),[u.reference,s,r,f]),l((()=>(L.current=!0,()=>{L.current=!1})),[]),l((()=>{var e;f&&(r||("auto"===h&&(C.current=!0),O.current=null!=(e=null!=s?s:i)?e:-1,A.current(null)))}),[r,s,i,f,h,A]),f?{reference:{...p&&r&&null!=i&&{"aria-activedescendant":D},onPointerEnter:j,onPointerDown:j,onKeyDown(e){if(M.current=!0,p&&r)return S(e);"auto"===h&&(C.current=!0),I.current=e.key,g?function(e,n,t){return Z(n,t?e===z:e===J,e===Y)}(e.key,w,m)&&(B(e),r?(O.current=ne(c),a(O.current)):o(!0)):($(e.key,w)&&(O.current=null==s?ee(e.key,w,m)?ne(c):te(c):s,B(e),o(!0),a(O.current)),p&&!r&&S(e))}},floating:{"aria-orientation":"both"===w?void 0:w,...p&&null!=i&&{"aria-activedescendant":D},onKeyDown:S,onPointerMove(){M.current=!1}},item:{onClick:e=>{let{currentTarget:n}=e;return n.focus({preventScroll:!0})},...E&&{onPointerMove(e){let{currentTarget:n}=e;const t=n;if(t){const e=c.current.indexOf(t);-1!==e&&a(e)}},onPointerLeave(){var e;M.current||(a(null),p?(O.current=-1,F(c,O)):null==(e=u.floating.current)||e.focus({preventScroll:!0}))}}}}:{}},e.useRole=function(e,n){let{open:t}=e,{enabled:r=!0,role:o="dialog"}=void 0===n?{}:n;const u=g(),c=g(),i={id:u,role:o};return r?"tooltip"===o?{reference:{"aria-describedby":t?u:void 0},floating:i}:{reference:{"aria-expanded":t?"true":"false","aria-haspopup":o,"aria-controls":t?u:void 0,..."listbox"===o&&{role:"combobox"},..."menu"===o&&{id:c}},floating:{...i,..."menu"===o&&{"aria-labelledby":c}}}:{}},e.useTypeahead=function(e,t){var r;let{open:o,dataRef:u}=e,{listRef:c,activeIndex:i,onMatch:a=(()=>{}),enabled:f=!0,findMatch:s=null,resetMs:d=1e3,ignoreKeys:v=[],selectedIndex:g=null}=void 0===t?{listRef:{current:[]},activeIndex:null}:t;const m=n.useRef(),p=n.useRef(""),b=n.useRef(null!=(r=null!=g?g:i)?r:-1),y=n.useRef(null);function h(e){if(!e.currentTarget.contains(k(e.currentTarget).activeElement))return;p.current.length>0&&" "!==p.current[0]&&(u.current.typing=!0," "===e.key&&B(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())}))&&p.current===e.key&&(p.current="",b.current=y.current),p.current+=e.key,clearTimeout(m.current),m.current=setTimeout((()=>{p.current="",b.current=y.current,u.current.typing=!1}),d);const t=b.current,r=[...n.slice((null!=t?t:0)+1),...n.slice(0,(null!=t?t:0)+1)],o=s?s(r,p.current):r.find((e=>0===(null==e?void 0:e.toLocaleLowerCase().indexOf(p.current)))),i=o?n.indexOf(o):-1;-1!==i&&(a(i),y.current=i)}return l((()=>{o&&(clearTimeout(m.current),y.current=null,p.current="")}),[o]),l((()=>{var e;o&&""===p.current&&(b.current=null!=(e=null!=g?g:i)?e:-1)}),[o,g,i]),f?{reference:{onKeyDown:h},floating:{onKeyDown:h}}:{}},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,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("react"),require("@floating-ui/react-dom"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","react","@floating-ui/react-dom","react-dom"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).FloatingUIReactDOM={},e.React,e.FloatingUIReactDOM,e.ReactDOM)}(this,(function(e,n,t,r){"use strict";function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function u(e){if(e&&e.__esModule)return e;var n=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})}})),n.default=e,Object.freeze(n)}var c=u(n),i=o(n),l="undefined"!=typeof document?n.useLayoutEffect:n.useEffect;function a(){const e=new Map;return{emit(n,t){var r;null==(r=e.get(n))||r.forEach((e=>e(t)))},on(n,t){e.set(n,[...e.get(n)||[],t])},off(n,t){e.set(n,(e.get(n)||[]).filter((e=>e!==t)))}}}let f=!1,s=0;const d=()=>"floating-ui-"+s++;const v=c["useId".toString()],g=null!=v?v:function(){const[e,n]=c.useState((()=>f?d():void 0));return l((()=>{null==e&&n(d())}),[]),c.useEffect((()=>{f||(f=!0)}),[]),e},m=n.createContext(null),p=n.createContext(null),b=()=>{var e,t;return null!=(e=null==(t=n.useContext(m))?void 0:t.id)?e:null},y=()=>n.useContext(p);function h(e,n,t){const r={};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;0===t.indexOf("on")?(r[t]||(r[t]=[]),"function"==typeof o&&r[t].push(o),e[t]=function(){for(var e=arguments.length,n=new Array(e),o=0;o<e;o++)n[o]=arguments[o];r[t].forEach((e=>e(...n)))}):e[t]=o})),e):e),{})}}var E={exports:{}},w=function(e,n,t,r){var o=e[0],u=e[1],c=!1;void 0===t&&(t=0),void 0===r&&(r=n.length);for(var i=(r-t)/2,l=0,a=i-1;l<i;a=l++){var f=n[t+2*l+0],s=n[t+2*l+1],d=n[t+2*a+0],v=n[t+2*a+1];s>u!=v>u&&o<(d-f)*(u-s)/(v-s)+f&&(c=!c)}return c},x=function(e,n,t,r){var o=e[0],u=e[1],c=!1;void 0===t&&(t=0),void 0===r&&(r=n.length);for(var i=r-t,l=0,a=i-1;l<i;a=l++){var f=n[l+t][0],s=n[l+t][1],d=n[a+t][0],v=n[a+t][1];s>u!=v>u&&o<(d-f)*(u-s)/(v-s)+f&&(c=!c)}return c};E.exports=function(e,n,t,r){return n.length>0&&Array.isArray(n[0])?x(e,n,t,r):w(e,n,t,r)},E.exports.nested=x,E.exports.flat=w;var k=E.exports;function R(e){var n;return null!=(n=null==e?void 0:e.ownerDocument)?n:document}function C(e){var n;return null!=(n=R(e).defaultView)?n:window}function O(e){return!!e&&e instanceof C(e).Element}function T(e){return!!e&&e instanceof C(e).HTMLElement}function I(e,n){var t;let r=null!=(t=null==e?void 0:e.nodesRef.current.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=null==e?void 0:e.nodesRef.current.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}const L="floating-ui-root";function A(){return A=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},A.apply(this,arguments)}const M="data-floating-ui-scroll-lock",D=n.forwardRef((function(e,n){let{lockScroll:t=!1,...r}=e;return l((()=>{if(!t)return;const e=window.pageXOffset,n=window.pageYOffset,r=Math.round(document.documentElement.getBoundingClientRect().left)+document.documentElement.scrollLeft?"paddingLeft":"paddingRight",o=window.innerWidth-document.documentElement.clientWidth;return document.body.hasAttribute(M)?void 0:(Object.assign(document.body.style,{position:"fixed",overflow:"hidden",top:"-"+n+"px",left:"-"+e+"px",right:"0",[r]:o+"px"}),document.body.setAttribute(M,""),()=>{Object.assign(document.body.style,{position:"",overflow:"",top:"",left:"",right:"",[r]:""}),document.body.removeAttribute(M),window.scrollTo(e,n)})}),[t]),i.default.createElement("div",A({ref:n},r,{style:{position:"fixed",overflow:"auto",top:0,right:0,bottom:0,left:0,...r.style}}))}));var P=new WeakMap,F=new WeakMap,j={},S=0,N=function(e,n,t){void 0===n&&(n=function(e){return"undefined"==typeof document?null:(Array.isArray(e)?e[0]:e).ownerDocument.body}(e)),void 0===t&&(t="data-aria-hidden");var r=Array.isArray(e)?e:[e];j[t]||(j[t]=new WeakMap);var o=j[t],u=[],c=new Set,i=function(e){e&&!c.has(e)&&(c.add(e),i(e.parentNode))};r.forEach(i);var l=function(e){!e||r.indexOf(e)>=0||Array.prototype.forEach.call(e.children,(function(e){if(c.has(e))l(e);else{var n=e.getAttribute("aria-hidden"),r=null!==n&&"false"!==n,i=(P.get(e)||0)+1,a=(o.get(e)||0)+1;P.set(e,i),o.set(e,a),u.push(e),1===i&&r&&F.set(e,!0),1===a&&e.setAttribute(t,"true"),r||e.setAttribute("aria-hidden","true")}}))};return l(n),c.clear(),S++,function(){u.forEach((function(e){var n=P.get(e)-1,r=o.get(e)-1;P.set(e,n),o.set(e,r),n||(F.has(e)||e.removeAttribute("aria-hidden"),F.delete(e)),r||e.removeAttribute(t)})),--S||(P=new WeakMap,P=new WeakMap,F=new WeakMap,j={})}};function B(e){e.preventDefault(),e.stopPropagation()}function K(e){const t=n.useRef(e);return l((()=>{t.current=e})),t}function W(e){requestAnimationFrame((()=>{null==e||e.focus()}))}const q=n.forwardRef((function(e,n){return i.default.createElement("span",A({},e,{ref:n,tabIndex:0,style:{position:"fixed",opacity:"0",pointerEvents:"none",outline:"0"}}))}));function H(e,n,t){return t&&"mouse"!==t?0:"number"==typeof e?e:null==e?void 0:e[n]}const G=n.createContext({delay:1e3,initialDelay:1e3,currentId:null,setCurrentId:()=>{},setState:()=>{}}),U=()=>n.useContext(G),V=["content"];function _(e){requestAnimationFrame((()=>{null==e||e.focus()}))}const X="ArrowUp",Y="ArrowDown",z="ArrowLeft",J="ArrowRight";function Q(e,n){let{startingIndex:t=-1,decrement:r=!1}=void 0===n?{}:n;const o=e.current;let u=t;do{var c,i;u+=r?-1:1}while(u>=0&&u<=o.length-1&&(null==o[u]||null!=(c=o[u])&&c.hasAttribute("disabled")||"true"===(null==(i=o[u])?void 0:i.getAttribute("aria-disabled"))));return u}function Z(e,n,t){switch(e){case"vertical":return n;case"horizontal":return t;default:return n||t}}function $(e,n){return Z(n,e===X||e===Y,e===z||e===J)}function ee(e,n,t){return Z(n,e===Y,t?e===z:e===J)}function ne(e){return Q(e)}function te(e){return Q(e,{decrement:!0,startingIndex:e.current.length})}e.FloatingDelayGroup=e=>{let{children:t,delay:r}=e;const[o,u]=n.useState({delay:r,initialDelay:r,currentId:null}),c=n.useCallback((e=>{u((n=>({...n,currentId:e})))}),[]);return i.default.createElement(G.Provider,{value:n.useMemo((()=>({...o,setState:u,setCurrentId:c})),[o,u,c])},t)},e.FloatingFocusManager=function(e){let{context:{refs:t,nodeId:r,onOpenChange:o},children:u,order:c=["content"],endGuard:l=!0,preventTabbing:a=!1,initialFocus:f=0,returnFocus:s=!0,modal:d=!0}=e;const v=K(c),g=K(o),m=y(),p=n.useCallback((()=>v.current.map((e=>{return T(t.reference.current)&&"reference"===e?t.reference.current:t.floating.current&&"floating"===e?t.floating.current:"content"===e?Array.from(null!=(n=null==(r=t.floating.current)?void 0:r.querySelectorAll("input:not([type='hidden']):not([disabled]),select:not([disabled]),textarea:not([disabled]),a[href],button:not([disabled]),[tabindex],iframe,object,embed,area[href],audio[controls],video[controls],[contenteditable]:not([contenteditable='false'])"))?n:[]):null;var n,r})).flat().filter((e=>{if(e===t.floating.current||e===t.reference.current)return!0;if(T(e)){var n;return"-"!==(null!=(n=e.getAttribute("tabindex"))?n:"0")[0].trim()}}))),[v,t.floating,t.reference]);return n.useEffect((()=>{const e=0===p().filter((e=>e!==t.floating.current&&e!==t.reference.current)).length;function n(n){if("Tab"===n.key){(a||e)&&B(n);const r=p();"reference"===v.current[0]&&n.target===t.reference.current&&(B(n),n.shiftKey?W(r[r.length-1]):W(r[1])),"floating"===v.current[1]&&n.target===t.floating.current&&n.shiftKey&&(B(n),W(r[0]))}}const r=R(t.floating.current);return r.addEventListener("keydown",n),()=>{r.removeEventListener("keydown",n)}}),[a,p,v,t.floating,t.reference]),n.useEffect((()=>{function e(e){var n;const o=e.relatedTarget;null!=(n=t.floating.current)&&n.contains(o)||!O(t.reference.current)||t.reference.current.contains(o)||m&&I(m,r).some((e=>{var n,t;return null==(n=e.context)||null==(t=n.refs.floating.current)?void 0:t.contains(o)}))||g.current(!1)}const n=t.floating.current,o=t.reference.current;if(n&&T(o)){!d&&n.addEventListener("focusout",e);const t=d?N(n):null;return()=>{!d&&n.removeEventListener("focusout",e),null==t||t()}}}),[r,m,d,g,p,f,t.floating,t.reference]),n.useEffect((()=>{var e;if(a)return;const n=t.floating.current,r=null!=(e=R(n).activeElement)?e:document.activeElement;var o;if("number"==typeof f)W(null!=(o=p()[f])?o:n);else if(T(null==f?void 0:f.current)){var u;W(null!=(u=f.current)?u:n)}return()=>{s&&T(r)&&W(r)}}),[a,p,f,d,s,t.floating]),i.default.createElement(i.default.Fragment,null,d&&i.default.createElement(q,{onFocus:e=>{B(e);const n=p();"reference"===c[0]?W(n[0]):W(n[n.length-1])}}),n.cloneElement(u,c.includes("floating")?{tabIndex:0}:{}),d&&l&&i.default.createElement(q,{onFocus:e=>{B(e),W(p()[0])}}))},e.FloatingNode=e=>{let{children:t,id:r}=e;const o=b();return i.default.createElement(m.Provider,{value:n.useMemo((()=>({id:r,parentId:o})),[r,o])},t)},e.FloatingOverlay=D,e.FloatingPortal=e=>{let{children:t,id:o=L}=e;const[u,c]=n.useState(!1),i=n.useRef(null);return l((()=>{const e=document.getElementById(o);e?i.current=e:(i.current=document.createElement("div"),i.current.id=o);const n=i.current;document.body.contains(n)||document.body.appendChild(n),c(!0)}),[o]),u&&i.current?r.createPortal(t,i.current):null},e.FloatingTree=e=>{let{children:t}=e;const r=n.useRef([]),o=n.useCallback((e=>{r.current=[...r.current,e]}),[]),u=n.useCallback((e=>{r.current=r.current.filter((n=>n!==e))}),[]),c=n.useState((()=>a()))[0];return i.default.createElement(p.Provider,{value:n.useMemo((()=>({nodesRef:r,addNode:o,removeNode:u,events:c})),[r,o,u,c])},t)},e.safePolygon=function(e){let n,{restMs:t=0,buffer:r=1,debug:o=null}=void 0===e?{}:e;return e=>{let{x:o,y:u,placement:c,refs:i,onClose:l,nodeId:a,tree:f}=e;return function(e){var s;if(clearTimeout(n),e.pointerType&&"mouse"!==e.pointerType)return;const{target:d,clientX:v,clientY:g}=e,m=d;if("pointermove"===e.type&&O(i.reference.current)&&i.reference.current.contains(m)||null!=(s=i.floating.current)&&s.contains(m))return;if(f&&I(f,a).some((e=>{let{context:n}=e;return null==n?void 0:n.open})))return;if(!i.reference.current||!i.floating.current||null==c||null==o||null==u)return;const p=i.reference.current.getBoundingClientRect(),b=i.floating.current.getBoundingClientRect(),y=c.split("-")[0],h=o>b.right-b.width/2,E=u>b.bottom-b.height/2;switch(y){case"top":if(v>=b.left&&v<=b.right&&g>=b.bottom&&g<=p.top)return;break;case"bottom":if(v>=b.left&&v<=b.right&&g>=p.bottom&&g<=b.top)return;break;case"left":if(v>=b.right&&v<=p.left&&g>=b.left&&g<=b.right)return;break;case"right":if(v>=b.right&&v<=p.left&&g>=b.right&&g<=p.left)return}const w=function(e){let[n,t]=e;const o=b.width>p.width,u=b.height>p.height;switch(y){case"top":{const e=[o?n:h?n+r:n-r,t+r],u=[o?n:h?n-r:n+r,t+r],c=[[b.left,h||o?b.bottom-r:b.top],[b.right,h?o?b.bottom-r:b.top:b.bottom-r]];return h?[e,u,...c]:[e,...c,u]}case"bottom":{const e=[o?n:h?n+r:n-r,t-r],u=[o?n:h?n-r:n+r,t-r],c=[[b.left,h||o?b.top+r:b.bottom],[b.right,h?o?b.top+r:b.bottom:b.top+r]];return h?[e,u,...c]:[e,...c,u]}case"left":{const e=[n+r,u?t:E?t-r:t+r],o=[n+r,u?t:E?t+r:t-r],c=[[E||u?b.right-r:b.left,b.top],[E?u?b.right-r:b.left:b.right-r,b.bottom]];return E?[e,...c,o]:[...c,e,o]}case"right":{const e=[n-r,u?t:E?t+r:t-r],o=[n-r,u?t:E?t-r:t+r],c=[[E||u?b.left+r:b.right,b.top],[E?u?b.left+r:b.right:b.left+r,b.bottom]];return E?[e,o,...c]:[e,...c,o]}}}([o,u]);k([v,g],w)?t&&(n=setTimeout(l,t)):(clearTimeout(n),l())}}},e.useClick=function(e,t){let{open:r,onOpenChange:o,dataRef:u}=e,{enabled:c=!0,pointerDown:i=!1,toggle:l=!0}=void 0===t?{}:t;const a=n.useRef();return c?{reference:{...i&&{onPointerDown(e){var n;(a.current=e.pointerType,r)?l&&"pointerdown"===(null==(n=u.current.openEvent)?void 0:n.type)&&o(!1):o(!0);u.current.openEvent=e.nativeEvent}},onClick(e){if(i&&a.current)a.current=void 0;else{var n;if(r)l&&"click"===(null==(n=u.current.openEvent)?void 0:n.type)&&o(!1);else o(!0);u.current.openEvent=e.nativeEvent}}}}:{}},e.useDelayGroup=(e,t)=>{let{open:r,onOpenChange:o}=e,{id:u}=t;const{currentId:c,initialDelay:i,setState:l}=U(),a=K(o);n.useEffect((()=>{c&&a.current&&(l((e=>({...e,delay:{open:1,close:H(i,"close")}}))),c!==u&&a.current(!1))}),[u,a,l,c,i]),n.useEffect((()=>{!r&&c===u&&a.current&&(a.current(!1),l((e=>({...e,delay:i,currentId:null}))))}),[r,l,c,u,a,i])},e.useDelayGroupContext=U,e.useDismiss=function(e,r){let{open:o,onOpenChange:u,refs:c,events:i,nodeId:l}=e,{enabled:a=!0,escapeKey:f=!0,outsidePointerDown:s=!0,referencePointerDown:d=!1,ancestorScroll:v=!1,bubbles:g=!0}=void 0===r?{}:r;const m=y(),p=K(u),b=n.useCallback((()=>{var e;return null==(e=c.floating.current)?void 0:e.contains(R(c.floating.current).activeElement)}),[c.floating]),h=n.useCallback((()=>{T(c.reference.current)&&c.reference.current.focus()}),[c.reference]);return n.useEffect((()=>{if(!o||!a)return;function e(e){if("Escape"===e.key){if(!g&&!b())return;i.emit("dismiss"),p.current(!1),h()}}function n(e){var n;const t=m&&I(m,l).some((n=>{var t,r;return null==(t=n.context)||null==(r=t.refs.floating.current)?void 0:r.contains(e.target)}));null!=(n=c.floating.current)&&n.contains(e.target)||O(c.reference.current)&&c.reference.current.contains(e.target)||t||(g||b())&&(i.emit("dismiss"),p.current(!1),h())}function r(){p.current(!1)}const u=R(c.floating.current);f&&u.addEventListener("keydown",e),s&&u.addEventListener("mousedown",n);const d=(v?[...O(c.reference.current)?t.getOverflowAncestors(c.reference.current):[],...O(c.floating.current)?t.getOverflowAncestors(c.floating.current):[]]:[]).filter((e=>{var n;return e!==(null==(n=u.defaultView)?void 0:n.visualViewport)}));return d.forEach((e=>e.addEventListener("scroll",r,{passive:!0}))),()=>{f&&u.removeEventListener("keydown",e),s&&u.removeEventListener("mousedown",n),d.forEach((e=>e.removeEventListener("scroll",r)))}}),[f,s,i,m,l,o,p,h,v,a,g,b,c.floating,c.reference]),a?{reference:{onPointerDown(){d&&(i.emit("dismiss"),u(!1))}}}:{}},e.useFloating=function(e){let{open:r=!1,onOpenChange:o=(()=>{}),placement:u,middleware:c,strategy:i,nodeId:f}=void 0===e?{}:e;const s=y(),d=n.useRef({}),v=n.useState((()=>a()))[0],g=t.useFloating({placement:u,middleware:c,strategy:i}),m=n.useMemo((()=>({...g,dataRef:d,nodeId:f,events:v,open:r,onOpenChange:o})),[g,d,f,v,r,o]);return l((()=>{const e=null==s?void 0:s.nodesRef.current.find((e=>e.id===f));e&&(e.context=m)})),n.useMemo((()=>({context:m,...g})),[g,m])},e.useFloatingNodeId=()=>{const e=g(),n=y(),t=b();return l((()=>{const r={id:e,parentId:t};return null==n||n.addNode(r),()=>{null==n||n.removeNode(r)}}),[n,e,t]),e},e.useFloatingParentNodeId=b,e.useFloatingTree=y,e.useFocus=function(e,t){let{open:r,onOpenChange:o,dataRef:u,refs:c,events:i}=e,{enabled:l=!0,keyboardOnly:a=!0}=void 0===t?{}:t;const f=n.useRef(!1);return n.useEffect((()=>{var e;if(!l)return;const n=null!=(e=R(c.floating.current).defaultView)?e:window;function t(){f.current=!r}function o(){setTimeout((()=>{f.current=!1}))}return n.addEventListener("focus",o),n.addEventListener("blur",t),()=>{n.removeEventListener("focus",o),n.removeEventListener("blur",t)}}),[c.floating,r,l]),n.useEffect((()=>{if(l)return i.on("dismiss",e),()=>{i.off("dismiss",e)};function e(){f.current=!0}}),[i,l]),l?{reference:{onPointerDown(e){let{pointerType:n}=e;f.current=!(!n||!a)},onFocus(e){var n,t,r;f.current||"focus"===e.type&&"mousedown"===(null==(n=u.current.openEvent)?void 0:n.type)&&O(c.reference.current)&&null!=(t=c.reference.current)&&t.contains(null==(r=u.current.openEvent)?void 0:r.target)||(u.current.openEvent=e.nativeEvent,o(!0))},onBlur(e){var n;const t=e.relatedTarget;null!=(n=c.floating.current)&&n.contains(t)||O(c.reference.current)&&c.reference.current.contains(t)||(f.current=!1,o(!1))}}}:{}},e.useFocusTrap=function(e,t){let{open:r,onOpenChange:o,refs:u,nodeId:c}=e,{enabled:i=!0,initialContentFocus:a=0,order:f=V,modal:s=!0,inert:d=!1}=void 0===t?{}:t;const v=n.useRef(!1),g=n.useRef(null),m=n.useRef(null),p=K(s),b=K(f),h=n.useCallback((()=>b.current.map((e=>{return T(u.reference.current)&&"reference"===e?u.reference.current:u.floating.current&&"floating"===e?u.floating.current:"content"===e?Array.from(null!=(n=null==(t=u.floating.current)?void 0:t.querySelectorAll("a[href],area[href],input:not([disabled]),select:not([disabled]),textarea:not([disabled]),button:not([disabled]),iframe,object,embed,*[tabindex],*[contenteditable]"))?n:[]):null;var n,t})).filter(Boolean).flat()),[u.floating,u.reference]);l((()=>{const e=u.floating.current;if(!(i&&r&&e&&s))return;function n(){const n=R(e).createElement("div");return n.tabIndex=0,Object.assign(n.style,{position:"fixed",outline:"0",pointerEvents:"none"}),n.setAttribute("aria-hidden","true"),n}g.current||(g.current=n()),m.current||(m.current=n());const t=g.current,o=m.current;function c(e){var n;B(e);const t=h();null==(n=t[e.target===o?0:t.length-1])||n.focus()}return e.insertAdjacentElement("beforebegin",t),e.insertAdjacentElement("afterend",o),t.addEventListener("focus",c),o.addEventListener("focus",c),()=>{var e,n;t.removeEventListener("focus",c),o.removeEventListener("focus",c),null!=(e=t.parentNode)&&e.contains(t)&&t.parentNode.removeChild(t),null!=(n=o.parentNode)&&n.contains(o)&&o.parentNode.removeChild(o)}}),[i,r,s,d,h,u.floating]),n.useEffect((()=>{if(!i||!r||!d)return;function e(e){"Tab"===e.key&&B(e)}const n=R(u.floating.current);return n.addEventListener("keydown",e),()=>{n.removeEventListener("keydown",e)}}),[i,r,d,u.floating]),n.useEffect((()=>{if(!i)return;const e=h();if(d){if(r){const n=e[0];n!==u.floating.current||n.contains(n.ownerDocument.activeElement)||_(n)}}else r&&("number"==typeof a?_(e[a]):a.current&&_(e.find((e=>e===a.current))))}),[h,r,d,s,a,i,u.reference,u.floating]),n.useEffect((()=>{i&&!d&&!r&&p.current&&v.current&&T(u.reference.current)&&_(u.reference.current)}),[r,i,d,p,u.reference]),n.useEffect((()=>{if(r&&s&&i&&u.floating.current)return N(u.floating.current)}),[r,s,i,u.floating]),n.useEffect((()=>(v.current=!0,()=>{v.current=!1})),[]);const E=y();function w(e){var n;const t=e.relatedTarget;null!=(n=u.floating.current)&&n.contains(t)||!O(u.reference.current)||u.reference.current.contains(t)||E&&I(E,c).some((e=>{var n,r,o;return null==(n=e.context)||null==(r=n.refs.floating)||null==(o=r.current)?void 0:o.contains(t)}))||o(!1)}return i?s?{floating:{"aria-modal":"true"}}:{reference:{onBlur:w},floating:{onBlur:w}}:{}},e.useHover=function(e,t){let{enabled:r=!0,delay:o=0,handleClose:u=null,mouseOnly:c=!1,restMs:i=0}=void 0===t?{}:t;const{open:a,onOpenChange:f,dataRef:s,events:d,refs:v}=e,g=y(),m=K(f),p=K(u),b=n.useRef(),h=n.useRef(),E=n.useRef(),w=n.useRef(),x=n.useRef(!0);l((()=>{r&&(a||(b.current=void 0))})),n.useEffect((()=>{if(r)return d.on("dismiss",e),()=>{d.off("dismiss",e)};function e(){clearTimeout(h.current),clearTimeout(w.current),x.current=!0}}),[r,d,v.floating]),n.useEffect((()=>{if(!r||!p.current)return;function e(){var e;null!=(e=s.current.openEvent)&&e.type.includes("mouse")&&m.current(!1)}const n=R(v.floating.current).documentElement;return n.addEventListener("mouseleave",e),()=>{n.removeEventListener("mouseleave",e)}}),[v.floating,m,r,p,s]);const k=n.useCallback((function(e){void 0===e&&(e=!0),o&&!E.current?(clearTimeout(h.current),h.current=setTimeout((()=>m.current(!1)),H(o,"close",b.current))):e&&m.current(!1)}),[o,m]),C=n.useCallback((()=>{E.current&&(R(v.floating.current).removeEventListener("pointermove",E.current),E.current=void 0)}),[v.floating]);if(n.useEffect((()=>{a||C()}),[a,r,C]),n.useEffect((()=>{if(!r)return;function n(e){clearTimeout(h.current),x.current=!1,a||c&&"mouse"!==b.current||i>0&&0===H(o,"open")||(s.current.openEvent=e,o?h.current=setTimeout((()=>{m.current(!0)}),H(o,"open",b.current)):m.current(!0))}function t(n){var t,r;if("click"===(null==(t=s.current.openEvent)?void 0:t.type)||"pointerdown"===(null==(r=s.current.openEvent)?void 0:r.type))return;const o=R(v.floating.current);if(clearTimeout(w.current),p.current)return clearTimeout(h.current),E.current&&o.removeEventListener("pointermove",E.current),E.current=p.current({...e,tree:g,x:n.clientX,y:n.clientY,onClose(){C(),k()}}),void o.addEventListener("pointermove",E.current);k()}const u=v.reference.current;return O(u)?(u.addEventListener("mouseenter",n),u.addEventListener("mouseleave",t),()=>{u.removeEventListener("mouseenter",n),u.removeEventListener("mouseleave",t)}):void 0}),[r,k,e,o,p,s,c,m,a,g,i,C,v.reference,v.floating]),!r)return{};function T(e){b.current=e.pointerType}return{reference:{onPointerDown:T,onPointerEnter:T,onMouseMove(){a||0===i||(clearTimeout(w.current),w.current=setTimeout((()=>{x.current||f(!0)}),i))}},floating:{onMouseEnter(){clearTimeout(h.current)},onMouseLeave:()=>k(!1)}}},e.useId=g,e.useInteractions=function(e){return void 0===e&&(e=[]),{getReferenceProps:n=>h(n,e,"reference"),getFloatingProps:n=>h(n,e,"floating"),getItemProps:n=>h(n,e,"item")}},e.useListNavigation=function(e,t){let{open:r,onOpenChange:o,refs:u}=e,{listRef:c,activeIndex:i,onNavigate:a,enabled:f=!0,selectedIndex:s=null,allowEscape:d=!1,loop:v=!1,nested:g=!1,rtl:m=!1,virtual:p=!1,focusItemOnOpen:h="auto",focusItemOnHover:E=!0,orientation:w="vertical"}=void 0===t?{listRef:{current:[]},activeIndex:null,onNavigate:()=>{}}:t;const x=b(),k=y(),R=function(e){const t=n.useRef();return l((()=>{t.current=e}),[e]),t.current}(r),C=n.useRef(h),O=n.useRef(null!=s?s:-1),I=n.useRef(""),L=n.useRef(!1),A=K(a),M=n.useRef(!1),[D,P]=n.useState(),F=n.useCallback(((e,n)=>{var t,r;p?P(null==(t=e.current[n.current])?void 0:t.id):null==(r=e.current[n.current])||r.focus({preventScroll:!0})}),[p]);function j(e){"auto"===h&&(C.current=!e.pointerType)}function S(e){if(M.current=!0,g&&function(e,n,t){return Z(n,t?e===J:e===z,e===X)}(e.key,w,m))return B(e),o(!1),void(T(u.reference.current)&&u.reference.current.focus());const n=O.current,t=ne(c),r=te(c);if("Home"===e.key&&(O.current=t,a(O.current)),"End"===e.key&&(O.current=r,a(O.current)),$(e.key,w)){if(B(e),!p&&e.currentTarget.ownerDocument.activeElement===e.currentTarget)return O.current=null!=s?s:ee(e.key,w,m)?t:r,void a(O.current);ee(e.key,w,m)?O.current=v?n>=r?d&&n!==c.current.length?-1:t:Q(c,{startingIndex:n}):Math.min(r,Q(c,{startingIndex:n})):O.current=v?n<=t?d&&-1!==n?c.current.length:r:Q(c,{startingIndex:n,decrement:!0}):Math.max(t,Q(c,{startingIndex:n,decrement:!0})),a(O.current)}}return l((()=>{f&&(null!=s&&(O.current=s),!R&&r&&C.current&&(A.current(O.current),F(c,O)))}),[r,R,s,c,A,F,f]),l((()=>{f&&r&&(null===i?(!R&&C.current&&null==s||d)&&(O.current=d?-1:ne(c),A.current(i),F(c,O)):(O.current=i,A.current(i),F(c,O)))}),[r,R,i,s,g,c,A,F,f,x,d,u.floating,null==k?void 0:k.nodesRef]),l((()=>{if(null==s&&f){if(r&&($(I.current,w)||C.current&&(" "===I.current||"Enter"===I.current))){const e=ne(c),n=te(c);O.current=function(e,n,t){return Z(n,e===X,t?e===J:e===z)}(I.current,w,m)?d?c.current.length:n:d?-1:e,A.current(O.current),F(c,O)}I.current=""}}),[r,c,s,A,F,f,w,m,d]),l((()=>{f&&!r&&L.current&&null!=s&&T(u.reference.current)&&u.reference.current.focus()}),[u.reference,s,r,f]),l((()=>(L.current=!0,()=>{L.current=!1})),[]),l((()=>{var e;f&&(r||("auto"===h&&(C.current=!0),O.current=null!=(e=null!=s?s:i)?e:-1,A.current(null)))}),[r,s,i,f,h,A]),f?{reference:{...p&&r&&null!=i&&{"aria-activedescendant":D},onPointerEnter:j,onPointerDown:j,onKeyDown(e){if(M.current=!0,p&&r)return S(e);"auto"===h&&(C.current=!0),I.current=e.key,g?function(e,n,t){return Z(n,t?e===z:e===J,e===Y)}(e.key,w,m)&&(B(e),r?(O.current=ne(c),a(O.current)):o(!0)):($(e.key,w)&&(O.current=null==s?ee(e.key,w,m)?ne(c):te(c):s,B(e),o(!0),a(O.current)),p&&!r&&S(e))}},floating:{"aria-orientation":"both"===w?void 0:w,...p&&null!=i&&{"aria-activedescendant":D},onKeyDown:S,onPointerMove(){M.current=!1}},item:{onClick:e=>{let{currentTarget:n}=e;return n.focus({preventScroll:!0})},...E&&{onPointerMove(e){let{currentTarget:n}=e;const t=n;if(t){const e=c.current.indexOf(t);-1!==e&&a(e)}},onPointerLeave(){var e;M.current||(a(null),p?(O.current=-1,F(c,O)):null==(e=u.floating.current)||e.focus({preventScroll:!0}))}}}}:{}},e.useRole=function(e,n){let{open:t}=e,{enabled:r=!0,role:o="dialog"}=void 0===n?{}:n;const u=g(),c=g(),i={id:u,role:o};return r?"tooltip"===o?{reference:{"aria-describedby":t?u:void 0},floating:i}:{reference:{"aria-expanded":t?"true":"false","aria-haspopup":o,"aria-controls":t?u:void 0,..."listbox"===o&&{role:"combobox"},..."menu"===o&&{id:c}},floating:{...i,..."menu"===o&&{"aria-labelledby":c}}}:{}},e.useTypeahead=function(e,t){var r;let{open:o,dataRef:u}=e,{listRef:c,activeIndex:i,onMatch:a=(()=>{}),enabled:f=!0,findMatch:s=null,resetMs:d=1e3,ignoreKeys:v=[],selectedIndex:g=null}=void 0===t?{listRef:{current:[]},activeIndex:null}:t;const m=n.useRef(),p=n.useRef(""),b=n.useRef(null!=(r=null!=g?g:i)?r:-1),y=n.useRef(null);function h(e){if(!e.currentTarget.contains(R(e.currentTarget).activeElement))return;p.current.length>0&&" "!==p.current[0]&&(u.current.typing=!0," "===e.key&&B(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())}))&&p.current===e.key&&(p.current="",b.current=y.current),p.current+=e.key,clearTimeout(m.current),m.current=setTimeout((()=>{p.current="",b.current=y.current,u.current.typing=!1}),d);const t=b.current,r=[...n.slice((null!=t?t:0)+1),...n.slice(0,(null!=t?t:0)+1)],o=s?s(r,p.current):r.find((e=>0===(null==e?void 0:e.toLocaleLowerCase().indexOf(p.current)))),i=o?n.indexOf(o):-1;-1!==i&&(a(i),y.current=i)}return l((()=>{o&&(clearTimeout(m.current),y.current=null,p.current="")}),[o]),l((()=>{var e;o&&""===p.current&&(b.current=null!=(e=null!=g?g:i)?e:-1)}),[o,g,i]),f?{reference:{onKeyDown:h},floating:{onKeyDown:h}}:{}},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.3.0", | ||
"version": "0.3.1", | ||
"@rollingversions": { | ||
@@ -5,0 +5,0 @@ "baseVersion": [ |
@@ -1,4 +0,3 @@ | ||
/// <reference types="react" /> | ||
import { ReferenceType } from '.'; | ||
import type { FloatingContext } from './types'; | ||
import React from 'react'; | ||
import type { FloatingContext, ReferenceType } from './types'; | ||
interface Props<RT extends ReferenceType = ReferenceType> { | ||
@@ -5,0 +4,0 @@ context: FloatingContext<RT>; |
@@ -9,2 +9,2 @@ import React from 'react'; | ||
id?: string; | ||
}) => React.ReactPortal; | ||
}) => React.ReactPortal | null; |
@@ -23,4 +23,4 @@ import React from 'react'; | ||
*/ | ||
export declare const FloatingTree: ({ children }: { | ||
export declare const FloatingTree: ({ children, }: { | ||
children?: React.ReactNode; | ||
}) => JSX.Element; |
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
277600
6226