UNPKG

@lexical/react

Version:

This package provides Lexical components and hooks for React applications.

13 lines (12 loc) 62.4 kB
/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * */ import*as e from"react";import{useLayoutEffect as t,useEffect as n,forwardRef as r,useState as o,useRef as i}from"react";import{jsxs as l,jsx as u,Fragment as c}from"react/jsx-runtime";import*as s from"react-dom";import{useLexicalComposerContext as a}from"@lexical/react/LexicalComposerContext";import{$getNearestNodeFromDOMNode as f}from"lexical";function d(){return"undefined"!=typeof window}function p(e){return h(e)?(e.nodeName||"").toLowerCase():"#document"}function m(e){var t;return(null==e||null==(t=e.ownerDocument)?void 0:t.defaultView)||window}function v(e){var t;return null==(t=(h(e)?e.ownerDocument:e.document)||window.document)?void 0:t.documentElement}function h(e){return!!d()&&(e instanceof Node||e instanceof m(e).Node)}function g(e){return!!d()&&(e instanceof Element||e instanceof m(e).Element)}function y(e){return!!d()&&(e instanceof HTMLElement||e instanceof m(e).HTMLElement)}function b(e){return!(!d()||"undefined"==typeof ShadowRoot)&&(e instanceof ShadowRoot||e instanceof m(e).ShadowRoot)}function w(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=S(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!["inline","contents"].includes(o)}function x(e){return["table","td","th"].includes(p(e))}function R(e){return[":popover-open",":modal"].some((t=>{try{return e.matches(t)}catch(e){return!1}}))}function E(e){const t=k(),n=g(e)?S(e):e;return["transform","translate","scale","rotate","perspective"].some((e=>!!n[e]&&"none"!==n[e]))||!!n.containerType&&"normal"!==n.containerType||!t&&!!n.backdropFilter&&"none"!==n.backdropFilter||!t&&!!n.filter&&"none"!==n.filter||["transform","translate","scale","rotate","perspective","filter"].some((e=>(n.willChange||"").includes(e)))||["paint","layout","strict","content"].some((e=>(n.contain||"").includes(e)))}function k(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}function I(e){return["html","body","#document"].includes(p(e))}function S(e){return m(e).getComputedStyle(e)}function A(e){return g(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function C(e){if("html"===p(e))return e;const t=e.assignedSlot||e.parentNode||b(e)&&e.host||v(e);return b(t)?t.host:t}function L(e){const t=C(e);return I(t)?e.ownerDocument?e.ownerDocument.body:e.body:y(t)&&w(t)?t:L(t)}function M(e,t,n){var r;void 0===t&&(t=[]),void 0===n&&(n=!0);const o=L(e),i=o===(null==(r=e.ownerDocument)?void 0:r.body),l=m(o);if(i){const e=O(l);return t.concat(l,l.visualViewport||[],w(o)?o:[],e&&n?M(e):[])}return t.concat(o,M(o,[],n))}function O(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}const T=Math.min,N=Math.max,P=Math.round,D=Math.floor,F=e=>({x:e,y:e}),W={left:"right",right:"left",bottom:"top",top:"bottom"},B={start:"end",end:"start"};function V(e,t,n){return N(e,T(t,n))}function K(e,t){return"function"==typeof e?e(t):e}function H(e){return e.split("-")[0]}function q(e){return e.split("-")[1]}function j(e){return"x"===e?"y":"x"}function $(e){return"y"===e?"height":"width"}function _(e){return["top","bottom"].includes(H(e))?"y":"x"}function z(e){return j(_(e))}function U(e){return e.replace(/start|end/g,(e=>B[e]))}function X(e){return e.replace(/left|right|bottom|top/g,(e=>W[e]))}function Y(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}} /*! * tabbable 6.2.0 * @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE */var G=["input:not([inert])","select:not([inert])","textarea:not([inert])","a[href]:not([inert])","button:not([inert])","[tabindex]:not(slot):not([inert])","audio[controls]:not([inert])","video[controls]:not([inert])",'[contenteditable]:not([contenteditable="false"]):not([inert])',"details>summary:first-of-type:not([inert])","details:not([inert])"].join(","),J="undefined"==typeof Element,Q=J?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,Z=!J&&Element.prototype.getRootNode?function(e){var t;return null==e||null===(t=e.getRootNode)||void 0===t?void 0:t.call(e)}:function(e){return null==e?void 0:e.ownerDocument},ee=function e(t,n){var r;void 0===n&&(n=!0);var o=null==t||null===(r=t.getAttribute)||void 0===r?void 0:r.call(t,"inert");return""===o||"true"===o||n&&t&&e(t.parentNode)},te=function(e,t,n){if(ee(e))return[];var r=Array.prototype.slice.apply(e.querySelectorAll(G));return t&&Q.call(e,G)&&r.unshift(e),r=r.filter(n)},ne=function e(t,n,r){for(var o=[],i=Array.from(t);i.length;){var l=i.shift();if(!ee(l,!1))if("SLOT"===l.tagName){var u=l.assignedElements(),c=e(u.length?u:l.children,!0,r);r.flatten?o.push.apply(o,c):o.push({scopeParent:l,candidates:c})}else{Q.call(l,G)&&r.filter(l)&&(n||!t.includes(l))&&o.push(l);var s=l.shadowRoot||"function"==typeof r.getShadowRoot&&r.getShadowRoot(l),a=!ee(s,!1)&&(!r.shadowRootFilter||r.shadowRootFilter(l));if(s&&a){var f=e(!0===s?l.children:s.children,!0,r);r.flatten?o.push.apply(o,f):o.push({scopeParent:l,candidates:f})}else i.unshift.apply(i,l.children)}}return o},re=function(e){return!isNaN(parseInt(e.getAttribute("tabindex"),10))},oe=function(e){if(!e)throw new Error("No node provided");return e.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(e.tagName)||function(e){var t,n=null==e||null===(t=e.getAttribute)||void 0===t?void 0:t.call(e,"contenteditable");return""===n||"true"===n}(e))&&!re(e)?0:e.tabIndex},ie=function(e,t){return e.tabIndex===t.tabIndex?e.documentOrder-t.documentOrder:e.tabIndex-t.tabIndex},le=function(e){return"INPUT"===e.tagName},ue=function(e){return function(e){return le(e)&&"radio"===e.type}(e)&&!function(e){if(!e.name)return!0;var t,n=e.form||Z(e),r=function(e){return n.querySelectorAll('input[type="radio"][name="'+e+'"]')};if("undefined"!=typeof window&&void 0!==window.CSS&&"function"==typeof window.CSS.escape)t=r(window.CSS.escape(e.name));else try{t=r(e.name)}catch(e){return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",e.message),!1}var o=function(e,t){for(var n=0;n<e.length;n++)if(e[n].checked&&e[n].form===t)return e[n]}(t,e.form);return!o||o===e}(e)},ce=function(e){var t=e.getBoundingClientRect(),n=t.width,r=t.height;return 0===n&&0===r},se=function(e,t){var n=t.displayCheck,r=t.getShadowRoot;if("hidden"===getComputedStyle(e).visibility)return!0;var o=Q.call(e,"details>summary:first-of-type")?e.parentElement:e;if(Q.call(o,"details:not([open]) *"))return!0;if(n&&"full"!==n&&"legacy-full"!==n){if("non-zero-area"===n)return ce(e)}else{if("function"==typeof r){for(var i=e;e;){var l=e.parentElement,u=Z(e);if(l&&!l.shadowRoot&&!0===r(l))return ce(e);e=e.assignedSlot?e.assignedSlot:l||u===e.ownerDocument?l:u.host}e=i}if(function(e){var t,n,r,o,i=e&&Z(e),l=null===(t=i)||void 0===t?void 0:t.host,u=!1;if(i&&i!==e)for(u=!!(null!==(n=l)&&void 0!==n&&null!==(r=n.ownerDocument)&&void 0!==r&&r.contains(l)||null!=e&&null!==(o=e.ownerDocument)&&void 0!==o&&o.contains(e));!u&&l;){var c,s,a;u=!(null===(s=l=null===(c=i=Z(l))||void 0===c?void 0:c.host)||void 0===s||null===(a=s.ownerDocument)||void 0===a||!a.contains(l))}return u}(e))return!e.getClientRects().length;if("legacy-full"!==n)return!0}return!1},ae=function(e,t){return!(t.disabled||ee(t)||function(e){return le(e)&&"hidden"===e.type}(t)||se(t,e)||function(e){return"DETAILS"===e.tagName&&Array.prototype.slice.apply(e.children).some((function(e){return"SUMMARY"===e.tagName}))}(t)||function(e){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(e.tagName))for(var t=e.parentElement;t;){if("FIELDSET"===t.tagName&&t.disabled){for(var n=0;n<t.children.length;n++){var r=t.children.item(n);if("LEGEND"===r.tagName)return!!Q.call(t,"fieldset[disabled] *")||!r.contains(e)}return!0}t=t.parentElement}return!1}(t))},fe=function(e,t){return!(ue(t)||oe(t)<0||!ae(e,t))},de=function(e){var t=parseInt(e.getAttribute("tabindex"),10);return!!(isNaN(t)||t>=0)},pe=function e(t){var n=[],r=[];return t.forEach((function(t,o){var i=!!t.scopeParent,l=i?t.scopeParent:t,u=function(e,t){var n=oe(e);return n<0&&t&&!re(e)?0:n}(l,i),c=i?e(t.candidates):l;0===u?i?n.push.apply(n,c):n.push(l):r.push({documentOrder:o,tabIndex:u,item:t,isScope:i,content:c})})),r.sort(ie).reduce((function(e,t){return t.isScope?e.push.apply(e,t.content):e.push(t.content),e}),[]).concat(n)},me=function(e,t){var n;return n=(t=t||{}).getShadowRoot?ne([e],t.includeContainer,{filter:fe.bind(null,t),flatten:!1,getShadowRoot:t.getShadowRoot,shadowRootFilter:de}):te(e,t.includeContainer,fe.bind(null,t)),pe(n)},ve=function(e,t){return(t=t||{}).getShadowRoot?ne([e],t.includeContainer,{filter:ae.bind(null,t),flatten:!0,getShadowRoot:t.getShadowRoot}):te(e,t.includeContainer,ae.bind(null,t))},he=function(e,t){if(t=t||{},!e)throw new Error("No node provided");return!1!==Q.call(e,G)&&fe(t,e)};function ge(){const e=navigator.userAgentData;return null!=e&&e.platform?e.platform:navigator.platform}function ye(){const e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map((e=>{let{brand:t,version:n}=e;return t+"/"+n})).join(" "):navigator.userAgent}function be(){const e=/android/i;return e.test(ge())||e.test(ye())}const we="data-floating-ui-focusable",xe="input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])",Re="ArrowLeft",Ee="ArrowRight",ke="ArrowUp",Ie="ArrowDown";function Se(e){let t=e.activeElement;for(;null!=(null==(n=t)||null==(n=n.shadowRoot)?void 0:n.activeElement);){var n;t=t.shadowRoot.activeElement}return t}function Ae(e,t){if(!e||!t)return!1;const n=null==t.getRootNode?void 0:t.getRootNode();if(e.contains(t))return!0;if(n&&b(n)){let n=t;for(;n;){if(e===n)return!0;n=n.parentNode||n.host}}return!1}function Ce(e){return"composedPath"in e?e.composedPath()[0]:e.target}function Le(e,t){if(null==t)return!1;if("composedPath"in e)return e.composedPath().includes(t);const n=e;return null!=n.target&&t.contains(n.target)}function Me(e){return(null==e?void 0:e.ownerDocument)||document}function Oe(e){return!!e&&("combobox"===e.getAttribute("role")&&function(e){return y(e)&&e.matches(xe)}(e))}function Te(e){return e?e.hasAttribute(we)?e:e.querySelector("["+we+"]")||e:null}function Ne(e,t,n){void 0===n&&(n=!0);let r=e.filter((e=>{var n;return e.parentId===t&&(null==(n=e.context)?void 0:n.open)})),o=r;for(;o.length;)o=n?e.filter((e=>{var t;return null==(t=o)?void 0:t.some((t=>{var n;return e.parentId===t.id&&(null==(n=e.context)?void 0:n.open)}))})):e,r=r.concat(o);return r}function Pe(e,t){var n;let r=[],o=null==(n=e.find((e=>e.id===t)))?void 0:n.parentId;for(;o;){const t=e.find((e=>e.id===o));o=null==t?void 0:t.parentId,t&&(r=r.concat(t))}return r}function De(e){e.preventDefault(),e.stopPropagation()}function Fe(e){return!(0!==e.mozInputSource||!e.isTrusted)||(be()&&e.pointerType?"click"===e.type&&1===e.buttons:0===e.detail&&!e.pointerType)}function We(e){return!ye().includes("jsdom/")&&(!be()&&0===e.width&&0===e.height||be()&&1===e.width&&1===e.height&&0===e.pressure&&0===e.detail&&"mouse"===e.pointerType||e.width<1&&e.height<1&&0===e.pressure&&0===e.detail&&"touch"===e.pointerType)}var Be="undefined"!=typeof document?t:n;function Ve(t){const n=e.useRef(t);return Be((()=>{n.current=t})),n}const Ke={...e}.useInsertionEffect||(e=>e());function He(t){const n=e.useRef((()=>{if("production"!==process.env.NODE_ENV)throw new Error("Cannot call an event handler while rendering.")}));return Ke((()=>{n.current=t})),e.useCallback((function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return null==n.current?void 0:n.current(...t)}),[])}function qe(e,t,n){return Math.floor(e/t)!==n}function je(e,t){return t<0||t>=e.current.length}function $e(e,t){return ze(e,{disabledIndices:t})}function _e(e,t){return ze(e,{decrement:!0,startingIndex:e.current.length,disabledIndices:t})}function ze(e,t){let{startingIndex:n=-1,decrement:r=!1,disabledIndices:o,amount:i=1}=void 0===t?{}:t,l=n;do{l+=r?-i:i}while(l>=0&&l<=e.current.length-1&&Ye(e,l,o));return l}function Ue(e,t,n,r,o){if(-1===e)return-1;const i=n.indexOf(e),l=t[e];switch(o){case"tl":return i;case"tr":return l?i+l.width-1:i;case"bl":return l?i+(l.height-1)*r:i;case"br":return n.lastIndexOf(e)}}function Xe(e,t){return t.flatMap(((t,n)=>e.includes(t)?[n]:[]))}function Ye(e,t,n){if(n)return n.includes(t);const r=e.current[t];return null==r||r.hasAttribute("disabled")||"true"===r.getAttribute("aria-disabled")}const Ge=()=>({getShadowRoot:!0,displayCheck:"function"==typeof ResizeObserver&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function Je(e,t){const n=me(e,Ge()),r=n.length;if(0===r)return;const o=Se(Me(e)),i=n.indexOf(o);return n[-1===i?1===t?0:r-1:i+t]}function Qe(e){return Je(Me(e).body,1)||e}function Ze(e){return Je(Me(e).body,-1)||e}function et(e,t){const n=t||e.currentTarget,r=e.relatedTarget;return!r||!Ae(n,r)}function tt(e){me(e,Ge()).forEach((e=>{e.dataset.tabindex=e.getAttribute("tabindex")||"",e.setAttribute("tabindex","-1")}))}function nt(e){e.querySelectorAll("[data-tabindex]").forEach((e=>{const t=e.dataset.tabindex;delete e.dataset.tabindex,t?e.setAttribute("tabindex",t):e.removeAttribute("tabindex")}))}function rt(e,t,n){let{reference:r,floating:o}=e;const i=_(t),l=z(t),u=$(l),c=H(t),s="y"===i,a=r.x+r.width/2-o.width/2,f=r.y+r.height/2-o.height/2,d=r[u]/2-o[u]/2;let p;switch(c){case"top":p={x:a,y:r.y-o.height};break;case"bottom":p={x:a,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:f};break;case"left":p={x:r.x-o.width,y:f};break;default:p={x:r.x,y:r.y}}switch(q(t)){case"start":p[l]-=d*(n&&s?-1:1);break;case"end":p[l]+=d*(n&&s?-1:1)}return p}async function ot(e,t){var n;void 0===t&&(t={});const{x:r,y:o,platform:i,rects:l,elements:u,strategy:c}=e,{boundary:s="clippingAncestors",rootBoundary:a="viewport",elementContext:f="floating",altBoundary:d=!1,padding:p=0}=K(t,e),m=function(e){return"number"!=typeof e?function(e){return{top:0,right:0,bottom:0,left:0,...e}}(e):{top:e,right:e,bottom:e,left:e}}(p),v=u[d?"floating"===f?"reference":"floating":f],h=Y(await i.getClippingRect({element:null==(n=await(null==i.isElement?void 0:i.isElement(v)))||n?v:v.contextElement||await(null==i.getDocumentElement?void 0:i.getDocumentElement(u.floating)),boundary:s,rootBoundary:a,strategy:c})),g="floating"===f?{x:r,y:o,width:l.floating.width,height:l.floating.height}:l.reference,y=await(null==i.getOffsetParent?void 0:i.getOffsetParent(u.floating)),b=await(null==i.isElement?void 0:i.isElement(y))&&await(null==i.getScale?void 0:i.getScale(y))||{x:1,y:1},w=Y(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:u,rect:g,offsetParent:y,strategy:c}):g);return{top:(h.top-w.top+m.top)/b.y,bottom:(w.bottom-h.bottom+m.bottom)/b.y,left:(h.left-w.left+m.left)/b.x,right:(w.right-h.right+m.right)/b.x}}function it(e){const t=S(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=y(e),i=o?e.offsetWidth:n,l=o?e.offsetHeight:r,u=P(n)!==i||P(r)!==l;return u&&(n=i,r=l),{width:n,height:r,$:u}}function lt(e){return g(e)?e:e.contextElement}function ut(e){const t=lt(e);if(!y(t))return F(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:i}=it(t);let l=(i?P(n.width):n.width)/r,u=(i?P(n.height):n.height)/o;return l&&Number.isFinite(l)||(l=1),u&&Number.isFinite(u)||(u=1),{x:l,y:u}}const ct=F(0);function st(e){const t=m(e);return k()&&t.visualViewport?{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}:ct}function at(e,t,n,r){void 0===t&&(t=!1),void 0===n&&(n=!1);const o=e.getBoundingClientRect(),i=lt(e);let l=F(1);t&&(r?g(r)&&(l=ut(r)):l=ut(e));const u=function(e,t,n){return void 0===t&&(t=!1),!(!n||t&&n!==m(e))&&t}(i,n,r)?st(i):F(0);let c=(o.left+u.x)/l.x,s=(o.top+u.y)/l.y,a=o.width/l.x,f=o.height/l.y;if(i){const e=m(i),t=r&&g(r)?m(r):r;let n=e,o=O(n);for(;o&&r&&t!==n;){const e=ut(o),t=o.getBoundingClientRect(),r=S(o),i=t.left+(o.clientLeft+parseFloat(r.paddingLeft))*e.x,l=t.top+(o.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,s*=e.y,a*=e.x,f*=e.y,c+=i,s+=l,n=m(o),o=O(n)}}return Y({width:a,height:f,x:c,y:s})}function ft(e,t){const n=A(e).scrollLeft;return t?t.left+n:at(v(e)).left+n}function dt(e,t,n){void 0===n&&(n=!1);const r=e.getBoundingClientRect();return{x:r.left+t.scrollLeft-(n?0:ft(e,r)),y:r.top+t.scrollTop}}function pt(e,t,n){let r;if("viewport"===t)r=function(e,t){const n=m(e),r=v(e),o=n.visualViewport;let i=r.clientWidth,l=r.clientHeight,u=0,c=0;if(o){i=o.width,l=o.height;const e=k();(!e||e&&"fixed"===t)&&(u=o.offsetLeft,c=o.offsetTop)}return{width:i,height:l,x:u,y:c}}(e,n);else if("document"===t)r=function(e){const t=v(e),n=A(e),r=e.ownerDocument.body,o=N(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),i=N(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let l=-n.scrollLeft+ft(e);const u=-n.scrollTop;return"rtl"===S(r).direction&&(l+=N(t.clientWidth,r.clientWidth)-o),{width:o,height:i,x:l,y:u}}(v(e));else if(g(t))r=function(e,t){const n=at(e,!0,"fixed"===t),r=n.top+e.clientTop,o=n.left+e.clientLeft,i=y(e)?ut(e):F(1);return{width:e.clientWidth*i.x,height:e.clientHeight*i.y,x:o*i.x,y:r*i.y}}(t,n);else{const n=st(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return Y(r)}function mt(e,t){const n=C(e);return!(n===t||!g(n)||I(n))&&("fixed"===S(n).position||mt(n,t))}function vt(e,t,n){const r=y(t),o=v(t),i="fixed"===n,l=at(e,!0,i,t);let u={scrollLeft:0,scrollTop:0};const c=F(0);if(r||!r&&!i)if(("body"!==p(t)||w(o))&&(u=A(t)),r){const e=at(t,!0,i,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}else o&&(c.x=ft(o));const s=!o||r||i?F(0):dt(o,u);return{x:l.left+u.scrollLeft-c.x-s.x,y:l.top+u.scrollTop-c.y-s.y,width:l.width,height:l.height}}function ht(e){return"static"===S(e).position}function gt(e,t){if(!y(e)||"fixed"===S(e).position)return null;if(t)return t(e);let n=e.offsetParent;return v(e)===n&&(n=n.ownerDocument.body),n}function yt(e,t){const n=m(e);if(R(e))return n;if(!y(e)){let t=C(e);for(;t&&!I(t);){if(g(t)&&!ht(t))return t;t=C(t)}return n}let r=gt(e,t);for(;r&&x(r)&&ht(r);)r=gt(r,t);return r&&I(r)&&ht(r)&&!E(r)?n:r||function(e){let t=C(e);for(;y(t)&&!I(t);){if(E(t))return t;if(R(t))return null;t=C(t)}return null}(e)||n}const bt={convertOffsetParentRelativeRectToViewportRelativeRect:function(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const i="fixed"===o,l=v(r),u=!!t&&R(t.floating);if(r===l||u&&i)return n;let c={scrollLeft:0,scrollTop:0},s=F(1);const a=F(0),f=y(r);if((f||!f&&!i)&&(("body"!==p(r)||w(l))&&(c=A(r)),y(r))){const e=at(r);s=ut(r),a.x=e.x+r.clientLeft,a.y=e.y+r.clientTop}const d=!l||f||i?F(0):dt(l,c,!0);return{width:n.width*s.x,height:n.height*s.y,x:n.x*s.x-c.scrollLeft*s.x+a.x+d.x,y:n.y*s.y-c.scrollTop*s.y+a.y+d.y}},getDocumentElement:v,getClippingRect:function(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[..."clippingAncestors"===n?R(t)?[]:function(e,t){const n=t.get(e);if(n)return n;let r=M(e,[],!1).filter((e=>g(e)&&"body"!==p(e))),o=null;const i="fixed"===S(e).position;let l=i?C(e):e;for(;g(l)&&!I(l);){const t=S(l),n=E(l);n||"fixed"!==t.position||(o=null),(i?!n&&!o:!n&&"static"===t.position&&o&&["absolute","fixed"].includes(o.position)||w(l)&&!n&&mt(e,l))?r=r.filter((e=>e!==l)):o=t,l=C(l)}return t.set(e,r),r}(t,this._c):[].concat(n),r],l=i[0],u=i.reduce(((e,n)=>{const r=pt(t,n,o);return e.top=N(r.top,e.top),e.right=T(r.right,e.right),e.bottom=T(r.bottom,e.bottom),e.left=N(r.left,e.left),e}),pt(t,l,o));return{width:u.right-u.left,height:u.bottom-u.top,x:u.left,y:u.top}},getOffsetParent:yt,getElementRects:async function(e){const t=this.getOffsetParent||yt,n=this.getDimensions,r=await n(e.floating);return{reference:vt(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}},getClientRects:function(e){return Array.from(e.getClientRects())},getDimensions:function(e){const{width:t,height:n}=it(e);return{width:t,height:n}},getScale:ut,isElement:g,isRTL:function(e){return"rtl"===S(e).direction}};function wt(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function xt(e,t,n,r){void 0===r&&(r={});const{ancestorScroll:o=!0,ancestorResize:i=!0,elementResize:l="function"==typeof ResizeObserver,layoutShift:u="function"==typeof IntersectionObserver,animationFrame:c=!1}=r,s=lt(e),a=o||i?[...s?M(s):[],...M(t)]:[];a.forEach((e=>{o&&e.addEventListener("scroll",n,{passive:!0}),i&&e.addEventListener("resize",n)}));const f=s&&u?function(e,t){let n,r=null;const o=v(e);function i(){var e;clearTimeout(n),null==(e=r)||e.disconnect(),r=null}return function l(u,c){void 0===u&&(u=!1),void 0===c&&(c=1),i();const s=e.getBoundingClientRect(),{left:a,top:f,width:d,height:p}=s;if(u||t(),!d||!p)return;const m={rootMargin:-D(f)+"px "+-D(o.clientWidth-(a+d))+"px "+-D(o.clientHeight-(f+p))+"px "+-D(a)+"px",threshold:N(0,T(1,c))||1};let v=!0;function h(t){const r=t[0].intersectionRatio;if(r!==c){if(!v)return l();r?l(!1,r):n=setTimeout((()=>{l(!1,1e-7)}),1e3)}1!==r||wt(s,e.getBoundingClientRect())||l(),v=!1}try{r=new IntersectionObserver(h,{...m,root:o.ownerDocument})}catch(e){r=new IntersectionObserver(h,m)}r.observe(e)}(!0),i}(s,n):null;let d,p=-1,m=null;l&&(m=new ResizeObserver((e=>{let[r]=e;r&&r.target===s&&m&&(m.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame((()=>{var e;null==(e=m)||e.observe(t)}))),n()})),s&&!c&&m.observe(s),m.observe(t));let h=c?at(e):null;return c&&function t(){const r=at(e);h&&!wt(h,r)&&n();h=r,d=requestAnimationFrame(t)}(),n(),()=>{var e;a.forEach((e=>{o&&e.removeEventListener("scroll",n),i&&e.removeEventListener("resize",n)})),null==f||f(),null==(e=m)||e.disconnect(),m=null,c&&cancelAnimationFrame(d)}}const Rt=function(e){return void 0===e&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:i,placement:l,middlewareData:u}=t,c=await async function(e,t){const{placement:n,platform:r,elements:o}=e,i=await(null==r.isRTL?void 0:r.isRTL(o.floating)),l=H(n),u=q(n),c="y"===_(n),s=["left","top"].includes(l)?-1:1,a=i&&c?-1:1,f=K(t,e);let{mainAxis:d,crossAxis:p,alignmentAxis:m}="number"==typeof f?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return u&&"number"==typeof m&&(p="end"===u?-1*m:m),c?{x:p*a,y:d*s}:{x:d*s,y:p*a}}(t,e);return l===(null==(n=u.offset)?void 0:n.placement)&&null!=(r=u.arrow)&&r.alignmentOffset?{}:{x:o+c.x,y:i+c.y,data:{...c,placement:l}}}}},Et=function(e){return void 0===e&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:i=!0,crossAxis:l=!1,limiter:u={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...c}=K(e,t),s={x:n,y:r},a=await ot(t,c),f=_(H(o)),d=j(f);let p=s[d],m=s[f];if(i){const e="y"===d?"bottom":"right";p=V(p+a["y"===d?"top":"left"],p,p-a[e])}if(l){const e="y"===f?"bottom":"right";m=V(m+a["y"===f?"top":"left"],m,m-a[e])}const v=u.fn({...t,[d]:p,[f]:m});return{...v,data:{x:v.x-n,y:v.y-r,enabled:{[d]:i,[f]:l}}}}}},kt=function(e){return void 0===e&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:i,rects:l,initialPlacement:u,platform:c,elements:s}=t,{mainAxis:a=!0,crossAxis:f=!0,fallbackPlacements:d,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:v=!0,...h}=K(e,t);if(null!=(n=i.arrow)&&n.alignmentOffset)return{};const g=H(o),y=_(u),b=H(u)===u,w=await(null==c.isRTL?void 0:c.isRTL(s.floating)),x=d||(b||!v?[X(u)]:function(e){const t=X(e);return[U(e),t,U(t)]}(u)),R="none"!==m;!d&&R&&x.push(...function(e,t,n,r){const o=q(e);let i=function(e,t,n){const r=["left","right"],o=["right","left"],i=["top","bottom"],l=["bottom","top"];switch(e){case"top":case"bottom":return n?t?o:r:t?r:o;case"left":case"right":return t?i:l;default:return[]}}(H(e),"start"===n,r);return o&&(i=i.map((e=>e+"-"+o)),t&&(i=i.concat(i.map(U)))),i}(u,v,m,w));const E=[u,...x],k=await ot(t,h),I=[];let S=(null==(r=i.flip)?void 0:r.overflows)||[];if(a&&I.push(k[g]),f){const e=function(e,t,n){void 0===n&&(n=!1);const r=q(e),o=z(e),i=$(o);let l="x"===o?r===(n?"end":"start")?"right":"left":"start"===r?"bottom":"top";return t.reference[i]>t.floating[i]&&(l=X(l)),[l,X(l)]}(o,l,w);I.push(k[e[0]],k[e[1]])}if(S=[...S,{placement:o,overflows:I}],!I.every((e=>e<=0))){var A,C;const e=((null==(A=i.flip)?void 0:A.index)||0)+1,t=E[e];if(t)return{data:{index:e,overflows:S},reset:{placement:t}};let n=null==(C=S.filter((e=>e.overflows[0]<=0)).sort(((e,t)=>e.overflows[1]-t.overflows[1]))[0])?void 0:C.placement;if(!n)switch(p){case"bestFit":{var L;const e=null==(L=S.filter((e=>{if(R){const t=_(e.placement);return t===y||"y"===t}return!0})).map((e=>[e.placement,e.overflows.filter((e=>e>0)).reduce(((e,t)=>e+t),0)])).sort(((e,t)=>e[1]-t[1]))[0])?void 0:L[0];e&&(n=e);break}case"initialPlacement":n=u}if(o!==n)return{reset:{placement:n}}}return{}}}},It=(e,t,n)=>{const r=new Map,o={platform:bt,...n},i={...o.platform,_c:r};return(async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:i=[],platform:l}=n,u=i.filter(Boolean),c=await(null==l.isRTL?void 0:l.isRTL(t));let s=await l.getElementRects({reference:e,floating:t,strategy:o}),{x:a,y:f}=rt(s,r,c),d=r,p={},m=0;for(let n=0;n<u.length;n++){const{name:i,fn:v}=u[n],{x:h,y:g,data:y,reset:b}=await v({x:a,y:f,initialPlacement:r,placement:d,strategy:o,middlewareData:p,rects:s,platform:l,elements:{reference:e,floating:t}});a=null!=h?h:a,f=null!=g?g:f,p={...p,[i]:{...p[i],...y}},b&&m<=50&&(m++,"object"==typeof b&&(b.placement&&(d=b.placement),b.rects&&(s=!0===b.rects?await l.getElementRects({reference:e,floating:t,strategy:o}):b.rects),({x:a,y:f}=rt(s,d,c))),n=-1)}return{x:a,y:f,placement:d,strategy:o,middlewareData:p}})(e,t,{...o,platform:i})};var St="undefined"!=typeof document?t:n;function At(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if("function"==typeof e&&e.toString()===t.toString())return!0;let n,r,o;if(e&&t&&"object"==typeof e){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;0!=r--;)if(!At(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;0!=r--;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;0!=r--;){const n=o[r];if(("_owner"!==n||!e.$$typeof)&&!At(e[n],t[n]))return!1}return!0}return e!=e&&t!=t}function Ct(e){if("undefined"==typeof window)return 1;return(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Lt(e,t){const n=Ct(e);return Math.round(t*n)/n}function Mt(t){const n=e.useRef(t);return St((()=>{n.current=t})),n}const Ot=(e,t)=>({...Et(e),options:[e,t]}),Tt=(e,t)=>({...kt(e),options:[e,t]}),Nt="data-floating-ui-focusable",Pt="active",Dt="selected",Ft="ArrowLeft",Wt="ArrowRight",Bt="ArrowUp",Vt="ArrowDown",Kt={...e};let Ht=!1,qt=0;const jt=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+qt++;const $t=Kt.useId||function(){const[t,n]=e.useState((()=>Ht?jt():void 0));return Be((()=>{null==t&&n(jt())}),[]),e.useEffect((()=>{Ht=!0}),[]),t};let _t;function zt(){for(var e,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];const o="Floating UI: "+n.join(" ");var i;null!=(e=_t)&&e.has(o)||(null==(i=_t)||i.add(o),console.warn(o))}"production"!==process.env.NODE_ENV&&(_t=new Set);const Ut=e.createContext(null),Xt=e.createContext(null),Yt=()=>{var t;return(null==(t=e.useContext(Ut))?void 0:t.id)||null},Gt=()=>e.useContext(Xt);function Jt(e){return"data-floating-ui-"+e}function Qt(e){-1!==e.current&&(clearTimeout(e.current),e.current=-1)}let Zt=0;function en(e,t){void 0===t&&(t={});const{preventScroll:n=!1,cancelPrevious:r=!0,sync:o=!1}=t;r&&cancelAnimationFrame(Zt);const i=()=>null==e?void 0:e.focus({preventScroll:n});o?i():Zt=requestAnimationFrame(i)}let tn=new WeakMap,nn=new WeakSet,rn={},on=0;const ln=e=>e&&(e.host||ln(e.parentNode)),un=(e,t)=>t.map((t=>{if(e.contains(t))return t;const n=ln(t);return e.contains(n)?n:null})).filter((e=>null!=e));function cn(e,t,n){void 0===t&&(t=!1),void 0===n&&(n=!1);const r=(o=e[0],(null==o?void 0:o.ownerDocument)||document).body;var o;return function(e,t,n,r){const o="data-floating-ui-inert",i=r?"inert":n?"aria-hidden":null,l=un(t,e),u=new Set,c=new Set(l),s=[];rn[o]||(rn[o]=new WeakMap);const a=rn[o];return l.forEach((function e(t){t&&!u.has(t)&&(u.add(t),t.parentNode&&e(t.parentNode))})),function e(t){t&&!c.has(t)&&[].forEach.call(t.children,(t=>{if("script"!==p(t))if(u.has(t))e(t);else{const e=i?t.getAttribute(i):null,n=null!==e&&"false"!==e,r=tn.get(t)||0,l=i?r+1:r,u=(a.get(t)||0)+1;tn.set(t,l),a.set(t,u),s.push(t),1===l&&n&&nn.add(t),1===u&&t.setAttribute(o,""),!n&&i&&t.setAttribute(i,"inert"===i?"":"true")}}))}(t),u.clear(),on++,()=>{s.forEach((e=>{const t=tn.get(e)||0,n=i?t-1:t,r=(a.get(e)||0)-1;tn.set(e,n),a.set(e,r),n||(!nn.has(e)&&i&&e.removeAttribute(i),nn.delete(e)),r||e.removeAttribute(o)})),on--,on||(tn=new WeakMap,tn=new WeakMap,nn=new WeakSet,rn={})}}(e.concat(Array.from(r.querySelectorAll("[aria-live]"))),r,t,n)}const sn={border:0,clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"fixed",whiteSpace:"nowrap",width:"1px",top:0,left:0},an=e.forwardRef((function(t,n){const[r,o]=e.useState();Be((()=>{/apple/i.test(navigator.vendor)&&o("button")}),[]);const i={ref:n,tabIndex:0,role:r,"aria-hidden":!r||void 0,[Jt("focus-guard")]:"",style:sn};return u("span",{...t,...i})})),fn=e.createContext(null),dn=Jt("portal");function pn(t){const{children:n,id:r,root:o,preserveTabOrder:i=!0}=t,c=function(t){void 0===t&&(t={});const{id:n,root:r}=t,o=$t(),i=mn(),[l,u]=e.useState(null),c=e.useRef(null);return Be((()=>()=>{null==l||l.remove(),queueMicrotask((()=>{c.current=null}))}),[l]),Be((()=>{if(!o)return;if(c.current)return;const e=n?document.getElementById(n):null;if(!e)return;const t=document.createElement("div");t.id=o,t.setAttribute(dn,""),e.appendChild(t),c.current=t,u(t)}),[n,o]),Be((()=>{if(null===r)return;if(!o)return;if(c.current)return;let e=r||(null==i?void 0:i.portalNode);e&&!g(e)&&(e=e.current),e=e||document.body;let t=null;n&&(t=document.createElement("div"),t.id=n,e.appendChild(t));const l=document.createElement("div");l.id=o,l.setAttribute(dn,""),e=t||e,e.appendChild(l),c.current=l,u(l)}),[n,r,o,i]),l}({id:r,root:o}),[a,f]=e.useState(null),d=e.useRef(null),p=e.useRef(null),m=e.useRef(null),v=e.useRef(null),h=null==a?void 0:a.modal,y=null==a?void 0:a.open,b=!!a&&!a.modal&&a.open&&i&&!(!o&&!c);return e.useEffect((()=>{if(c&&i&&!h)return c.addEventListener("focusin",e,!0),c.addEventListener("focusout",e,!0),()=>{c.removeEventListener("focusin",e,!0),c.removeEventListener("focusout",e,!0)};function e(e){if(c&&et(e)){("focusin"===e.type?nt:tt)(c)}}}),[c,i,h]),e.useEffect((()=>{c&&(y||nt(c))}),[y,c]),l(fn.Provider,{value:e.useMemo((()=>({preserveTabOrder:i,beforeOutsideRef:d,afterOutsideRef:p,beforeInsideRef:m,afterInsideRef:v,portalNode:c,setFocusManagerState:f})),[i,c]),children:[b&&c&&u(an,{"data-type":"outside",ref:d,onFocus:e=>{if(et(e,c)){var t;null==(t=m.current)||t.focus()}else{const e=Ze(a?a.domReference:null);null==e||e.focus()}}}),b&&c&&u("span",{"aria-owns":c.id,style:sn}),c&&s.createPortal(n,c),b&&c&&u(an,{"data-type":"outside",ref:p,onFocus:e=>{if(et(e,c)){var t;null==(t=v.current)||t.focus()}else{const t=Qe(a?a.domReference:null);null==t||t.focus(),(null==a?void 0:a.closeOnFocusOut)&&(null==a||a.onOpenChange(!1,e.nativeEvent,"focus-out"))}}})]})}const mn=()=>e.useContext(fn);function vn(t){return e.useMemo((()=>e=>{t.forEach((t=>{t&&(t.current=e)}))}),t)}const hn=20;let gn=[];function yn(){return gn.slice().reverse().find((e=>e.isConnected))}function bn(e,t){var n;if(!(t.current.includes("floating")||null!=(n=e.getAttribute("role"))&&n.includes("dialog")))return;const r=Ge(),o=ve(e,r).filter((e=>{const t=e.getAttribute("data-tabindex")||"";return he(e,r)||e.hasAttribute("data-tabindex")&&!t.startsWith("-")})),i=e.getAttribute("tabindex");t.current.includes("floating")||0===o.length?"0"!==i&&e.setAttribute("tabindex","0"):("-1"!==i||e.hasAttribute("data-tabindex")&&"-1"!==e.getAttribute("data-tabindex"))&&(e.setAttribute("tabindex","-1"),e.setAttribute("data-tabindex","-1"))}const wn=e.forwardRef((function(e,t){return u("button",{...e,type:"button",ref:t,tabIndex:-1,style:sn})}));function xn(t){const{context:n,children:r,disabled:o=!1,order:i=["content"],guards:s=!0,initialFocus:a=0,returnFocus:f=!0,restoreFocus:d=!1,modal:m=!0,visuallyHiddenDismiss:v=!1,closeOnFocusOut:h=!0,outsideElementsInert:g=!1,getInsideElements:b=(()=>[])}=t,{open:w,onOpenChange:x,events:R,dataRef:E,elements:{domReference:k,floating:I}}=n,S=He((()=>{var e;return null==(e=E.current.floatingContext)?void 0:e.nodeId})),A=He(b),C="number"==typeof a&&a<0,L=Oe(k)&&C,M="undefined"!=typeof HTMLElement&&"inert"in HTMLElement.prototype,O=!M||s,T=!O||M&&g,N=Ve(i),P=Ve(a),D=Ve(f),F=Gt(),W=mn(),B=e.useRef(null),V=e.useRef(null),K=e.useRef(!1),H=e.useRef(!1),q=e.useRef(-1),j=null!=W,$=Te(I),_=He((function(e){return void 0===e&&(e=$),e?me(e,Ge()):[]})),z=He((e=>{const t=_(e);return N.current.map((e=>k&&"reference"===e?k:$&&"floating"===e?$:t)).filter(Boolean).flat()}));e.useEffect((()=>{if(o)return;if(!m)return;function e(e){if("Tab"===e.key){Ae($,Se(Me($)))&&0===_().length&&!L&&De(e);const t=z(),n=Ce(e);"reference"===N.current[0]&&n===k&&(De(e),e.shiftKey?en(t[t.length-1]):en(t[1])),"floating"===N.current[1]&&n===$&&e.shiftKey&&(De(e),en(t[0]))}}const t=Me($);return t.addEventListener("keydown",e),()=>{t.removeEventListener("keydown",e)}}),[o,k,$,m,N,L,_,z]),e.useEffect((()=>{if(!o&&I)return I.addEventListener("focusin",e),()=>{I.removeEventListener("focusin",e)};function e(e){const t=Ce(e),n=_().indexOf(t);-1!==n&&(q.current=n)}}),[o,I,_]),e.useEffect((()=>{if(!o&&h)return I&&y(k)?(k.addEventListener("focusout",t),k.addEventListener("pointerdown",e),I.addEventListener("focusout",t),()=>{k.removeEventListener("focusout",t),k.removeEventListener("pointerdown",e),I.removeEventListener("focusout",t)}):void 0;function e(){H.current=!0,setTimeout((()=>{H.current=!1}))}function t(e){const t=e.relatedTarget,n=e.currentTarget;queueMicrotask((()=>{const r=S(),o=!(Ae(k,t)||Ae(I,t)||Ae(t,I)||Ae(null==W?void 0:W.portalNode,t)||null!=t&&t.hasAttribute(Jt("focus-guard"))||F&&(Ne(F.nodesRef.current,r).find((e=>{var n,r;return Ae(null==(n=e.context)?void 0:n.elements.floating,t)||Ae(null==(r=e.context)?void 0:r.elements.domReference,t)}))||Pe(F.nodesRef.current,r).find((e=>{var n,r,o;return[null==(n=e.context)?void 0:n.elements.floating,Te(null==(r=e.context)?void 0:r.elements.floating)].includes(t)||(null==(o=e.context)?void 0:o.elements.domReference)===t}))));if(n===k&&$&&bn($,N),d&&o&&Se(Me($))===Me($).body){y($)&&$.focus();const e=q.current,t=_(),n=t[e]||t[t.length-1]||$;y(n)&&n.focus()}!L&&m||!t||!o||H.current||t===yn()||(K.current=!0,x(!1,e,"focus-out"))}))}}),[o,k,I,$,m,F,W,x,h,d,_,L,S,N]);const U=e.useRef(null),X=e.useRef(null),Y=vn([U,null==W?void 0:W.beforeInsideRef]),G=vn([X,null==W?void 0:W.afterInsideRef]);function J(e){return!o&&v&&m?u(wn,{ref:"start"===e?B:V,onClick:e=>x(!1,e.nativeEvent),children:"string"==typeof v?v:"Dismiss"}):null}e.useEffect((()=>{var e,t;if(o)return;if(!I)return;const n=Array.from((null==W||null==(e=W.portalNode)?void 0:e.querySelectorAll("["+Jt("portal")+"]"))||[]),r=F?Pe(F.nodesRef.current,S()):[],i=F&&!m?r.map((e=>{var t;return null==(t=e.context)?void 0:t.elements.floating})):[],l=null==(t=r.find((e=>{var t;return Oe((null==(t=e.context)?void 0:t.elements.domReference)||null)})))||null==(t=t.context)?void 0:t.elements.domReference,u=[I,l,...n,...i,...A(),B.current,V.current,U.current,X.current,null==W?void 0:W.beforeOutsideRef.current,null==W?void 0:W.afterOutsideRef.current,N.current.includes("reference")||L?k:null].filter((e=>null!=e)),c=m||L?cn(u,!T,T):cn(u);return()=>{c()}}),[o,k,I,m,N,W,L,O,T,F,S,A]),Be((()=>{if(o||!y($))return;const e=Se(Me($));queueMicrotask((()=>{const t=z($),n=P.current,r=("number"==typeof n?t[n]:n.current)||$,o=Ae($,e);C||o||!w||en(r,{preventScroll:r===$})}))}),[o,w,$,C,z,P]),Be((()=>{if(o||!$)return;let e=!1;const t=Me($),n=Se(t);var r;function i(t){let{reason:n,event:r,nested:o}=t;if(["hover","safe-polygon"].includes(n)&&"mouseleave"===r.type&&(K.current=!0),"outside-press"===n)if(o)K.current=!1,e=!0;else if(Fe(r)||We(r))K.current=!1;else{let t=!1;document.createElement("div").focus({get preventScroll(){return t=!0,!1}}),t?(K.current=!1,e=!0):K.current=!0}}r=n,gn=gn.filter((e=>e.isConnected)),r&&"body"!==p(r)&&(gn.push(r),gn.length>hn&&(gn=gn.slice(-20))),R.on("openchange",i);const l=t.createElement("span");return l.setAttribute("tabindex","-1"),l.setAttribute("aria-hidden","true"),Object.assign(l.style,sn),j&&k&&k.insertAdjacentElement("afterend",l),()=>{R.off("openchange",i);const n=Se(t),r=Ae(I,n)||F&&Ne(F.nodesRef.current,S()).some((e=>{var t;return Ae(null==(t=e.context)?void 0:t.elements.floating,n)})),o=function(){if("boolean"==typeof D.current){const e=k||yn();return e&&e.isConnected?e:l}return D.current.current||l}();queueMicrotask((()=>{const i=function(e){const t=Ge();return he(e,t)?e:me(e,t)[0]||e}(o);D.current&&!K.current&&y(i)&&(i===n||n===t.body||r)&&i.focus({preventScroll:e}),l.remove()}))}}),[o,I,$,D,E,R,F,j,k,S]),e.useEffect((()=>{queueMicrotask((()=>{K.current=!1}))}),[o]),Be((()=>{if(!o&&W)return W.setFocusManagerState({modal:m,closeOnFocusOut:h,open:w,onOpenChange:x,domReference:k}),()=>{W.setFocusManagerState(null)}}),[o,W,m,w,x,h,k]),Be((()=>{o||$&&bn($,N)}),[o,$,N]);const Q=!o&&O&&(!m||!L)&&(j||m);return l(c,{children:[Q&&u(an,{"data-type":"inside",ref:Y,onFocus:e=>{if(m){const e=z();en("reference"===i[0]?e[0]:e[e.length-1])}else if(null!=W&&W.preserveTabOrder&&W.portalNode)if(K.current=!1,et(e,W.portalNode)){const e=Qe(k);null==e||e.focus()}else{var t;null==(t=W.beforeOutsideRef.current)||t.focus()}}}),!L&&J("start"),r,J("end"),Q&&u(an,{"data-type":"inside",ref:G,onFocus:e=>{if(m)en(z()[0]);else if(null!=W&&W.preserveTabOrder&&W.portalNode)if(h&&(K.current=!0),et(e,W.portalNode)){const e=Ze(k);null==e||e.focus()}else{var t;null==(t=W.afterOutsideRef.current)||t.focus()}}})]})}let Rn=0;let En=()=>{};const kn=e.forwardRef((function(e,t){const{lockScroll:n=!1,...r}=e;return Be((()=>{if(n)return Rn++,1===Rn&&(En=function(){const e=/iP(hone|ad|od)|iOS/.test(ge()),t=document.body.style,n=Math.round(document.documentElement.getBoundingClientRect().left)+document.documentElement.scrollLeft?"paddingLeft":"paddingRight",r=window.innerWidth-document.documentElement.clientWidth,o=t.left?parseFloat(t.left):window.scrollX,i=t.top?parseFloat(t.top):window.scrollY;if(t.overflow="hidden",r&&(t[n]=r+"px"),e){var l,u;const e=(null==(l=window.visualViewport)?void 0:l.offsetLeft)||0,n=(null==(u=window.visualViewport)?void 0:u.offsetTop)||0;Object.assign(t,{position:"fixed",top:-(i-Math.floor(n))+"px",left:-(o-Math.floor(e))+"px",right:"0"})}return()=>{Object.assign(t,{overflow:"",[n]:""}),e&&(Object.assign(t,{position:"",top:"",left:"",right:""}),window.scrollTo(o,i))}}()),()=>{Rn--,0===Rn&&En()}}),[n]),u("div",{ref:t,...r,style:{position:"fixed",overflow:"auto",top:0,right:0,bottom:0,left:0,...r.style}})})),In={pointerdown:"onPointerDown",mousedown:"onMouseDown",click:"onClick"},Sn={pointerdown:"onPointerDownCapture",mousedown:"onMouseDownCapture",click:"onClickCapture"},An=e=>{var t,n;return{escapeKey:"boolean"==typeof e?e:null!=(t=null==e?void 0:e.escapeKey)&&t,outsidePress:"boolean"==typeof e?e:null==(n=null==e?void 0:e.outsidePress)||n}};function Cn(t){const{open:n=!1,onOpenChange:r,elements:o}=t,i=$t(),l=e.useRef({}),[u]=e.useState((()=>function(){const e=new Map;return{emit(t,n){var r;null==(r=e.get(t))||r.forEach((e=>e(n)))},on(t,n){e.has(t)||e.set(t,new Set),e.get(t).add(n)},off(t,n){var r;null==(r=e.get(t))||r.delete(n)}}}())),c=null!=Yt();if("production"!==process.env.NODE_ENV){const e=o.reference;e&&!g(e)&&function(){for(var e,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];const o="Floating UI: "+n.join(" ");var i;null!=(e=_t)&&e.has(o)||(null==(i=_t)||i.add(o),console.error(o))}("Cannot pass a virtual element to the `elements.reference` option,","as it must be a real DOM element. Use `refs.setPositionReference()`","instead.")}const[s,a]=e.useState(o.reference),f=He(((e,t,n)=>{l.current.openEvent=e?t:void 0,u.emit("openchange",{open:e,event:t,reason:n,nested:c}),null==r||r(e,t,n)})),d=e.useMemo((()=>({setPositionReference:a})),[]),p=e.useMemo((()=>({reference:s||o.reference||null,floating:o.floating||null,domReference:o.reference})),[s,o.reference,o.floating]);return e.useMemo((()=>({dataRef:l,open:n,onOpenChange:f,elements:p,events:u,floatingId:i,refs:d})),[n,f,p,u,i,d])}function Ln(t){void 0===t&&(t={});const{nodeId:n}=t,r=Cn({...t,elements:{reference:null,floating:null,...t.elements}}),o=t.rootContext||r,i=o.elements,[l,u]=e.useState(null),[c,a]=e.useState(null),f=(null==i?void 0:i.domReference)||l,d=e.useRef(null),p=Gt();Be((()=>{f&&(d.current=f)}),[f]);const m=function(t){void 0===t&&(t={});const{placement:n="bottom",strategy:r="absolute",middleware:o=[],platform:i,elements:{reference:l,floating:u}={},transform:c=!0,whileElementsMounted:a,open:f}=t,[d,p]=e.useState({x:0,y:0,strategy:r,placement:n,middlewareData:{},isPositioned:!1}),[m,v]=e.useState(o);At(m,o)||v(o);const[h,g]=e.useState(null),[y,b]=e.useState(null),w=e.useCallback((e=>{e!==k.current&&(k.current=e,g(e))}),[]),x=e.useCallback((e=>{e!==I.current&&(I.current=e,b(e))}),[]),R=l||h,E=u||y,k=e.useRef(null),I=e.useRef(null),S=e.useRef(d),A=null!=a,C=Mt(a),L=Mt(i),M=Mt(f),O=e.useCallback((()=>{if(!k.current||!I.current)return;const e={placement:n,strategy:r,middleware:m};L.current&&(e.platform=L.current),It(k.current,I.current,e).then((e=>{const t={...e,isPositioned:!1!==M.current};T.current&&!At(S.current,t)&&(S.current=t,s.flushSync((()=>{p(t)})))}))}),[m,n,r,L,M]);St((()=>{!1===f&&S.current.isPositioned&&(S.current.isPositioned=!1,p((e=>({...e,isPositioned:!1}))))}),[f]);const T=e.useRef(!1);St((()=>(T.current=!0,()=>{T.current=!1})),[]),St((()=>{if(R&&(k.current=R),E&&(I.current=E),R&&E){if(C.current)return C.current(R,E,O);O()}}),[R,E,O,C,A]);const N=e.useMemo((()=>({reference:k,floating:I,setReference:w,setFloating:x})),[w,x]),P=e.useMemo((()=>({reference:R,floating:E})),[R,E]),D=e.useMemo((()=>{const e={position:r,left:0,top:0};if(!P.floating)return e;const t=Lt(P.floating,d.x),n=Lt(P.floating,d.y);return c?{...e,transform:"translate("+t+"px, "+n+"px)",...Ct(P.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:t,top:n}}),[r,c,P.floating,d.x,d.y]);return e.useMemo((()=>({...d,update:O,refs:N,elements:P,floatingStyles:D})),[d,O,N,P,D])}({...t,elements:{...i,...c&&{reference:c}}}),v=e.useCallback((e=>{const t=g(e)?{getBoundingClientRect:()=>e.getBoundingClientRect(),getClientRects:()=>e.getClientRects(),contextElement:e}:e;a(t),m.refs.setReference(t)}),[m.refs]),h=e.useCallback((e=>{(g(e)||null===e)&&(d.current=e,u(e)),(g(m.refs.reference.current)||null===m.refs.reference.current||null!==e&&!g(e))&&m.refs.setReference(e)}),[m.refs]),y=e.useMemo((()=>({...m.refs,setReference:h,setPositionReference:v,domReference:d})),[m.refs,h,v]),b=e.useMemo((()=>({...m.elements,domReference:f})),[m.elements,f]),w=e.useMemo((()=>({...m,...o,refs:y,elements:b,nodeId:n})),[m,y,b,n,o]);return Be((()=>{o.dataRef.current.floatingContext=w;const e=null==p?void 0:p.nodesRef.current.find((e=>e.id===n));e&&(e.context=w)})),e.useMemo((()=>({...m,context:w,refs:y,elements:b})),[m,y,b,w])}function Mn(e,t,n){const r=new Map,o="item"===n;let i=e;if(o&&e){const{[Pt]:t,[Dt]:n,...r}=e;i=r}return{..."floating"===n&&{tabIndex:-1,[Nt]:""},...i,...t.map((t=>{const r=t?t[n]:null;return"function"==typeof r?e?r(e):null:r})).concat(e).reduce(((e,t)=>t?(Object.entries(t).forEach((t=>{let[n,i]=t;var l;o&&[Pt,Dt].includes(n)||(0===n.indexOf("on")?(r.has(n)||r.set(n,[]),"function"==typeof i&&(null==(l=r.get(n))||l.push(i),e[n]=function(){for(var e,t=arguments.length,o=new Array(t),i=0;i<t;i++)o[i]=arguments[i];return null==(e=r.get(n))?void 0:e.map((e=>e(...o))).find((e=>void 0!==e))})):e[n]=i)})),e):e),{})}}const On="Escape";function Tn(e,t,n){switch(e){case"vertical":return t;case"horizontal":return n;default:return t||n}}function Nn(e,t){return Tn(t,e===Bt||e===Vt,e===Ft||e===Wt)}function Pn(e,t,n){return Tn(t,e===Vt,n?e===Ft:e===Wt)||"Enter"===e||" "===e||""===e}function Dn(e,t,n){return Tn(t,n?e===Ft:e===Wt,e===Vt)}function Fn(e,t,n,r){return"both"===t||"horizontal"===t&&r&&r>1?e===On:Tn(t,n?e===Wt:e===Ft,e===Bt)}function Wn(t,n){const{open:r,onOpenChange:o,elements:i,floatingId:l}=t,{listRef:u,activeIndex:c,onNavigate:s=(()=>{}),enabled:a=!0,selectedIndex:f=null,allowEscape:d=!1,loop:p=!1,nested:m=!1,rtl:v=!1,virtual:h=!1,focusItemOnOpen:g="auto",focusItemOnHover:b=!0,openOnArrowKeyDown:w=!0,disabledIndices:x,orientation:R="vertical",parentOrientation:E,cols:k=1,scrollItemIntoView:I=!0,virtualItemRef:S,itemSizes:A,dense:C=!1}=n;"production"!==process.env.NODE_ENV&&(d&&(p||zt("`useListNavigation` looping must be enabled to allow escaping."),h||zt("`useListNavigation` must be virtual to allow escaping.")),"vertical"===R&&k>1&&zt("In grid list navigation mode (`cols` > 1), the `orientation` should",'be either "horizontal" or "both".'));const L=Ve(Te(i.floating)),M=Yt(),O=Gt();Be((()=>{t.dataRef.current.orientation=R}),[t,R]);const T=He((()=>{s(-1===F.current?null:F.current)})),N=Oe(i.domReference),P=e.useRef(g),F=e.useRef(null!=f?f:-1),W=e.useRef(null),B=e.useRef(!0),V=e.useRef(T),K=e.useRef(!!i.floating),H=e.useRef(r),q=e.useRef(!1),j=e.useRef(!1),$=Ve(x),_=Ve(r),z=Ve(I),U=Ve(f),[X,Y]=e.useState(),[G,J]=e.useState(),Q=He((()=>{function e(e){var t;h?(null!=(t=e.id)&&t.endsWith("-fui-option")&&(e.id=l+"-"+Math.random().toString(16).slice(2,10)),Y(e.id),null==O||O.events.emit("virtualfocus",e),S&&(S.current=e)):en(e,{sync:q.current,preventScroll:!0})}const t=u.current[F.current],n=j.current;t&&e(t);(q.current?e=>e():requestAnimationFrame)((()=>{const r=u.current[F.current]||t;if(!r)return;t||e(r);const o=z.current;o&&ee&&(n||!B.current)&&(null==r.scrollIntoView||r.scrollIntoView("boolean"==typeof o?{block:"nearest",inline:"nearest"}:o))}))}));Be((()=>{a&&(r&&i.floating?P.current&&null!=f&&(j.current=!0,F.current=f,T()):K.current&&(F.current=-1,V.current()))}),[a,r,i.floating,f,T]),Be((()=>{if(a&&r&&i.floating)if(null==c){if(q.current=!1,null!=U.current)return;if(K.current&&(F.current=-1,Q()),(!H.current||!K.current)&&P.current&&(null!=W.current||!0===P.current&&null==W.current)){let e=0;const t=()=>{if(null==u.current[0]){if(e<2){(e?requestAnimationFrame:queueMicrotask)(t)}e++}else F.current=null==W.current||Pn(W.current,R,v)||m?$e(u,$.current):_e(u,$.current),W.current=null,T()};t()}}else je(u,c)||(F.current=c,Q(),j.current=!1)}),[a,r,i.floating,c,U,m,u,R,v,T,Q,$]),Be((()=>{var e;if(!a||i.floating||!O||h||!K.current)return;const t=O.nodesRef.current,n=null==(e=t.find((e=>e.id===M)))||null==(e=e.context)?void 0:e.elements.floating,r=Se(Me(i.floating)),o=t.some((e=>e.context&&Ae(e.context.elements.floating,r)));n&&!o&&B.current&&n.focus({preventScroll:!0})}),[a,i.floating,O,M,h]),Be((()=>{if(a&&O&&h&&!M)return O.events.on("virtualfocus",e),()=>{O.events.off("virtualfocus",e)};function e(e){J(e.id),S&&(S.current=e)}}),[a,O,h,M,S]),Be((()=>{V.current=T,H.current=r,K.current=!!i.floating})),Be((()=>{r||(W.current=null)}),[r]);const Z=null!=c,ee=e.useMemo((()=>{function e(e){if(!r)return;const t=u.current.indexOf(e);-1!==t&&F.current!==t&&(F.current=t,T())}return{onFocus(t){let{currentTarget:n}=t;q.current=!0,e(n)},onClick:e=>{let{currentTarget:t}=e;return t.focus({preventScroll:!0})},...b&&{onMouseMove(t){let{currentTarget:n}=t;q.current=!0,j.current=!1,e(n)},onPointerLeave(e){let{pointerType:t}=e;var n;B.current&&"touch"!==t&&(q.current=!0,F.current=-1,T(),h||null==(n=L.current)||n.focus({preventScroll:!0}))}}}}),[r,L,b,u,T,h]),te=e.useCallback((()=>{var e;return null!=E?E:null==O||null==(e=O.nodesRef.current.find((e=>e.id===M)))||null==(e=e.context)||null==(e=e.dataRef)?void 0:e.current.orientation}),[M,O,E]),ne=He((e=>{if(B.current=!1,q.current=!0,229===e.which)return;if(!_.current&&e.currentTarget===L.current)return;if(m&&Fn(e.key,R,v,k))return Nn(e.key,te())||De(e),o(!1,e.nativeEvent,"list-navigation"),void(y(i.domReference)&&(h?null==O||O.events.emit("virtualfocus",i.domReference):i.domReference.focus()));const t=F.current,n=$e(u,x),l=_e(u,x);if(N||("Home"===e.key&&(De(e),F.current=n,T()),"End"===e.key&&(De(e),F.current=l,T())),k>1){const t=A||Array.from({length:u.current.length},(()=>({width:1,height:1}))),r=function(e,t,n){const r=[];let o=0;return e.forEach(((e,i)=>{let{width:l,height:u}=e;if(l>t&&"production"!==process.env.NODE_ENV)throw new Error("[Floating UI]: Invalid grid - item width at index "+i+" is greater than grid columns");let c=!1;for(n&&(o=0);!c;){const e=[];for(let n=0;n<l;n++)for(let r=0;r<u;r++)e.push(o+n+r*t);o%t+l<=t&&e.every((e=>null==r[e]))?(e.forEach((e=>{r[e]=i})),c=!0):o++}})),[...r]}(t,k,C),o=r.findIndex((e=>null!=e&&!Ye(u,e,x))),i=r.reduce(((e,t,n)=>null==t||Ye(u,t,x)?e:n),-1),c=r[function(e,t){let{event:n,orientation:r,loop:o,rtl:i,cols:l,disabledIndices:u,minIndex:c,maxIndex:s,prevIndex:a,stopEvent:f=!1}=t,d=a;if(n.key===ke){if(f&&De(n),-1===a)d=s;else if(d=ze(e,{startingIndex:d,amount:l,decrement:!0,disabledIndices:u}),o&&(a-l<c||d<0)){const e=a%l,t=s%l,n=s-(t-e);d=t===e?s:t>e?n:n-l}je(e,d)&&(d=a)}if(n.key===Ie&&(f&&De(n),-1===a?d=c:(d=ze(e,{startingIndex:a,amount:l,disabledIndices:u}),o&&a+l>s&&(d=ze(e,{startingIndex:a%l-l,amount:l,disabledIndices:u}))),je(e,d)&&(d=a)),"both"===r){const t=D(a/l);n.key===(i?Re:Ee)&&(f&&De(n),a%l!=l-1?(d=ze(e,{startingIndex:a,disabledIndices:u}),o&&qe(d,l,t)&&(d=ze(e,{startingIndex:a-a%l-1,disabledIndices:u}))):o&&(d=ze(e,{startingIndex:a-a%l-1,disabledIndices:u})),qe(d,l,t)&&(d=a)),n.key===(i?Ee:Re)&&(f&&