@lexical/react 0.35.1-nightly.20250919.0 → 0.35.1-nightly.20250923.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LexicalCollaborationContext.d.ts +4 -1
- package/LexicalCollaborationContext.dev.js +35 -7
- package/LexicalCollaborationContext.dev.mjs +36 -9
- package/LexicalCollaborationContext.mjs +1 -0
- package/LexicalCollaborationContext.node.mjs +1 -0
- package/LexicalCollaborationContext.prod.js +1 -1
- package/LexicalCollaborationContext.prod.mjs +1 -1
- package/LexicalContextMenuPlugin.d.ts +2 -2
- package/LexicalContextMenuPlugin.dev.js +2 -1
- package/LexicalContextMenuPlugin.dev.mjs +2 -1
- package/LexicalContextMenuPlugin.prod.js +1 -1
- package/LexicalContextMenuPlugin.prod.mjs +1 -1
- package/LexicalEditorRefPlugin.d.ts +2 -2
- package/LexicalErrorBoundary.dev.js +2 -140
- package/LexicalErrorBoundary.dev.mjs +1 -126
- package/LexicalErrorBoundary.prod.js +1 -1
- package/LexicalErrorBoundary.prod.mjs +1 -1
- package/LexicalNestedComposer.dev.js +3 -2
- package/LexicalNestedComposer.dev.mjs +4 -3
- package/LexicalNestedComposer.prod.js +1 -1
- package/LexicalNestedComposer.prod.mjs +1 -1
- package/LexicalNodeContextMenuPlugin.d.ts +2 -2
- package/LexicalNodeContextMenuPlugin.dev.js +27 -5221
- package/LexicalNodeContextMenuPlugin.dev.mjs +3 -5184
- package/LexicalNodeContextMenuPlugin.prod.js +1 -5
- package/LexicalNodeContextMenuPlugin.prod.mjs +1 -5
- package/LexicalNodeMenuPlugin.dev.js +2 -1
- package/LexicalNodeMenuPlugin.dev.mjs +2 -1
- package/LexicalNodeMenuPlugin.prod.js +1 -1
- package/LexicalNodeMenuPlugin.prod.mjs +1 -1
- package/LexicalTypeaheadMenuPlugin.dev.js +2 -1
- package/LexicalTypeaheadMenuPlugin.dev.mjs +2 -1
- package/LexicalTypeaheadMenuPlugin.prod.js +1 -1
- package/LexicalTypeaheadMenuPlugin.prod.mjs +1 -1
- package/package.json +19 -19
- package/shared/LexicalMenu.d.ts +5 -5
- package/shared/mergeRefs.d.ts +1 -1
- package/shared/useYjsCollaboration.d.ts +1 -1
|
@@ -6,8 +6,4 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
"use strict";var e=require("react"),t=require("react/
|
|
10
|
-
/*!
|
|
11
|
-
* tabbable 6.2.0
|
|
12
|
-
* @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
|
|
13
|
-
*/var z=["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(","),U="undefined"==typeof Element,X=U?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,Y=!U&&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},G=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)},J=function(e,t,n){if(G(e))return[];var r=Array.prototype.slice.apply(e.querySelectorAll(z));return t&&X.call(e,z)&&r.unshift(e),r=r.filter(n)},Q=function e(t,n,r){for(var o=[],i=Array.from(t);i.length;){var l=i.shift();if(!G(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{X.call(l,z)&&r.filter(l)&&(n||!t.includes(l))&&o.push(l);var s=l.shadowRoot||"function"==typeof r.getShadowRoot&&r.getShadowRoot(l),a=!G(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},Z=function(e){return!isNaN(parseInt(e.getAttribute("tabindex"),10))},ee=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))&&!Z(e)?0:e.tabIndex},te=function(e,t){return e.tabIndex===t.tabIndex?e.documentOrder-t.documentOrder:e.tabIndex-t.tabIndex},ne=function(e){return"INPUT"===e.tagName},re=function(e){return function(e){return ne(e)&&"radio"===e.type}(e)&&!function(e){if(!e.name)return!0;var t,n=e.form||Y(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)},oe=function(e){var t=e.getBoundingClientRect(),n=t.width,r=t.height;return 0===n&&0===r},ie=function(e,t){var n=t.displayCheck,r=t.getShadowRoot;if("hidden"===getComputedStyle(e).visibility)return!0;var o=X.call(e,"details>summary:first-of-type")?e.parentElement:e;if(X.call(o,"details:not([open]) *"))return!0;if(n&&"full"!==n&&"legacy-full"!==n){if("non-zero-area"===n)return oe(e)}else{if("function"==typeof r){for(var i=e;e;){var l=e.parentElement,u=Y(e);if(l&&!l.shadowRoot&&!0===r(l))return oe(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&&Y(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=Y(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},le=function(e,t){return!(t.disabled||G(t)||function(e){return ne(e)&&"hidden"===e.type}(t)||ie(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!!X.call(t,"fieldset[disabled] *")||!r.contains(e)}return!0}t=t.parentElement}return!1}(t))},ue=function(e,t){return!(re(t)||ee(t)<0||!le(e,t))},ce=function(e){var t=parseInt(e.getAttribute("tabindex"),10);return!!(isNaN(t)||t>=0)},se=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=ee(e);return n<0&&t&&!Z(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(te).reduce((function(e,t){return t.isScope?e.push.apply(e,t.content):e.push(t.content),e}),[]).concat(n)},ae=function(e,t){var n;return n=(t=t||{}).getShadowRoot?Q([e],t.includeContainer,{filter:ue.bind(null,t),flatten:!1,getShadowRoot:t.getShadowRoot,shadowRootFilter:ce}):J(e,t.includeContainer,ue.bind(null,t)),se(n)},fe=function(e,t){return(t=t||{}).getShadowRoot?Q([e],t.includeContainer,{filter:le.bind(null,t),flatten:!0,getShadowRoot:t.getShadowRoot}):J(e,t.includeContainer,le.bind(null,t))},de=function(e,t){if(t=t||{},!e)throw new Error("No node provided");return!1!==X.call(e,z)&&ue(t,e)};function pe(){const e=navigator.userAgentData;return null!=e&&e.platform?e.platform:navigator.platform}function me(){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 ve(){const e=/android/i;return e.test(pe())||e.test(me())}const he="data-floating-ui-focusable",ge="input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])",ye="ArrowLeft",be="ArrowRight",we="ArrowUp",xe="ArrowDown";function Re(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 Ee(e,t){if(!e||!t)return!1;const n=null==t.getRootNode?void 0:t.getRootNode();if(e.contains(t))return!0;if(n&&v(n)){let n=t;for(;n;){if(e===n)return!0;n=n.parentNode||n.host}}return!1}function ke(e){return"composedPath"in e?e.composedPath()[0]:e.target}function Ie(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 Se(e){return(null==e?void 0:e.ownerDocument)||document}function Ce(e){return!!e&&("combobox"===e.getAttribute("role")&&function(e){return m(e)&&e.matches(ge)}(e))}function Ae(e){return e?e.hasAttribute(he)?e:e.querySelector("["+he+"]")||e:null}function Le(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 Me(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 Oe(e){e.preventDefault(),e.stopPropagation()}function Te(e){return!(0!==e.mozInputSource||!e.isTrusted)||(ve()&&e.pointerType?"click"===e.type&&1===e.buttons:0===e.detail&&!e.pointerType)}function Ne(e){return!me().includes("jsdom/")&&(!ve()&&0===e.width&&0===e.height||ve()&&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 Pe="undefined"!=typeof document?e.useLayoutEffect:e.useEffect;function De(e){const t=l.useRef(e);return Pe((()=>{t.current=e})),t}const Fe={...l}.useInsertionEffect||(e=>e());function je(e){const t=l.useRef((()=>{if("production"!==process.env.NODE_ENV)throw new Error("Cannot call an event handler while rendering.")}));return Fe((()=>{t.current=e})),l.useCallback((function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return null==t.current?void 0:t.current(...n)}),[])}function We(e,t,n){return Math.floor(e/t)!==n}function qe(e,t){return t<0||t>=e.current.length}function Be(e,t){return Ke(e,{disabledIndices:t})}function Ve(e,t){return Ke(e,{decrement:!0,startingIndex:e.current.length,disabledIndices:t})}function Ke(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&&_e(e,l,o));return l}function He(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 $e(e,t){return t.flatMap(((t,n)=>e.includes(t)?[n]:[]))}function _e(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 ze=()=>({getShadowRoot:!0,displayCheck:"function"==typeof ResizeObserver&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function Ue(e,t){const n=ae(e,ze()),r=n.length;if(0===r)return;const o=Re(Se(e)),i=n.indexOf(o);return n[-1===i?1===t?0:r-1:i+t]}function Xe(e){return Ue(Se(e).body,1)||e}function Ye(e){return Ue(Se(e).body,-1)||e}function Ge(e,t){const n=t||e.currentTarget,r=e.relatedTarget;return!r||!Ee(n,r)}function Je(e){ae(e,ze()).forEach((e=>{e.dataset.tabindex=e.getAttribute("tabindex")||"",e.setAttribute("tabindex","-1")}))}function Qe(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 Ze(e,t,n){let{reference:r,floating:o}=e;const i=V(t),l=K(t),u=B(l),c=j(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(W(t)){case"start":p[l]-=d*(n&&s?-1:1);break;case"end":p[l]+=d*(n&&s?-1:1)}return p}async function et(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}=F(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=_(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=_(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 tt(e){const t=R(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=m(e),i=o?e.offsetWidth:n,l=o?e.offsetHeight:r,u=M(n)!==i||M(r)!==l;return u&&(n=i,r=l),{width:n,height:r,$:u}}function nt(e){return p(e)?e:e.contextElement}function rt(e){const t=nt(e);if(!m(t))return T(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:i}=tt(t);let l=(i?M(n.width):n.width)/r,u=(i?M(n.height):n.height)/o;return l&&Number.isFinite(l)||(l=1),u&&Number.isFinite(u)||(u=1),{x:l,y:u}}const ot=T(0);function it(e){const t=a(e);return w()&&t.visualViewport?{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}:ot}function lt(e,t,n,r){void 0===t&&(t=!1),void 0===n&&(n=!1);const o=e.getBoundingClientRect(),i=nt(e);let l=T(1);t&&(r?p(r)&&(l=rt(r)):l=rt(e));const u=function(e,t,n){return void 0===t&&(t=!1),!(!n||t&&n!==a(e))&&t}(i,n,r)?it(i):T(0);let c=(o.left+u.x)/l.x,s=(o.top+u.y)/l.y,f=o.width/l.x,d=o.height/l.y;if(i){const e=a(i),t=r&&p(r)?a(r):r;let n=e,o=C(n);for(;o&&r&&t!==n;){const e=rt(o),t=o.getBoundingClientRect(),r=R(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,f*=e.x,d*=e.y,c+=i,s+=l,n=a(o),o=C(n)}}return _({width:f,height:d,x:c,y:s})}function ut(e,t){const n=E(e).scrollLeft;return t?t.left+n:lt(f(e)).left+n}function ct(e,t,n){void 0===n&&(n=!1);const r=e.getBoundingClientRect();return{x:r.left+t.scrollLeft-(n?0:ut(e,r)),y:r.top+t.scrollTop}}function st(e,t,n){let r;if("viewport"===t)r=function(e,t){const n=a(e),r=f(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=w();(!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=f(e),n=E(e),r=e.ownerDocument.body,o=L(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),i=L(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let l=-n.scrollLeft+ut(e);const u=-n.scrollTop;return"rtl"===R(r).direction&&(l+=L(t.clientWidth,r.clientWidth)-o),{width:o,height:i,x:l,y:u}}(f(e));else if(p(t))r=function(e,t){const n=lt(e,!0,"fixed"===t),r=n.top+e.clientTop,o=n.left+e.clientLeft,i=m(e)?rt(e):T(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=it(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return _(r)}function at(e,t){const n=k(e);return!(n===t||!p(n)||x(n))&&("fixed"===R(n).position||at(n,t))}function ft(e,t,n){const r=m(t),o=f(t),i="fixed"===n,l=lt(e,!0,i,t);let u={scrollLeft:0,scrollTop:0};const c=T(0);if(r||!r&&!i)if(("body"!==s(t)||h(o))&&(u=E(t)),r){const e=lt(t,!0,i,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}else o&&(c.x=ut(o));const a=!o||r||i?T(0):ct(o,u);return{x:l.left+u.scrollLeft-c.x-a.x,y:l.top+u.scrollTop-c.y-a.y,width:l.width,height:l.height}}function dt(e){return"static"===R(e).position}function pt(e,t){if(!m(e)||"fixed"===R(e).position)return null;if(t)return t(e);let n=e.offsetParent;return f(e)===n&&(n=n.ownerDocument.body),n}function mt(e,t){const n=a(e);if(y(e))return n;if(!m(e)){let t=k(e);for(;t&&!x(t);){if(p(t)&&!dt(t))return t;t=k(t)}return n}let r=pt(e,t);for(;r&&g(r)&&dt(r);)r=pt(r,t);return r&&x(r)&&dt(r)&&!b(r)?n:r||function(e){let t=k(e);for(;m(t)&&!x(t);){if(b(t))return t;if(y(t))return null;t=k(t)}return null}(e)||n}const vt={convertOffsetParentRelativeRectToViewportRelativeRect:function(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const i="fixed"===o,l=f(r),u=!!t&&y(t.floating);if(r===l||u&&i)return n;let c={scrollLeft:0,scrollTop:0},a=T(1);const d=T(0),p=m(r);if((p||!p&&!i)&&(("body"!==s(r)||h(l))&&(c=E(r)),m(r))){const e=lt(r);a=rt(r),d.x=e.x+r.clientLeft,d.y=e.y+r.clientTop}const v=!l||p||i?T(0):ct(l,c,!0);return{width:n.width*a.x,height:n.height*a.y,x:n.x*a.x-c.scrollLeft*a.x+d.x+v.x,y:n.y*a.y-c.scrollTop*a.y+d.y+v.y}},getDocumentElement:f,getClippingRect:function(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[..."clippingAncestors"===n?y(t)?[]:function(e,t){const n=t.get(e);if(n)return n;let r=S(e,[],!1).filter((e=>p(e)&&"body"!==s(e))),o=null;const i="fixed"===R(e).position;let l=i?k(e):e;for(;p(l)&&!x(l);){const t=R(l),n=b(l);n||"fixed"!==t.position||(o=null),(i?!n&&!o:!n&&"static"===t.position&&o&&["absolute","fixed"].includes(o.position)||h(l)&&!n&&at(e,l))?r=r.filter((e=>e!==l)):o=t,l=k(l)}return t.set(e,r),r}(t,this._c):[].concat(n),r],l=i[0],u=i.reduce(((e,n)=>{const r=st(t,n,o);return e.top=L(r.top,e.top),e.right=A(r.right,e.right),e.bottom=A(r.bottom,e.bottom),e.left=L(r.left,e.left),e}),st(t,l,o));return{width:u.right-u.left,height:u.bottom-u.top,x:u.left,y:u.top}},getOffsetParent:mt,getElementRects:async function(e){const t=this.getOffsetParent||mt,n=this.getDimensions,r=await n(e.floating);return{reference:ft(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}=tt(e);return{width:t,height:n}},getScale:rt,isElement:p,isRTL:function(e){return"rtl"===R(e).direction}};function ht(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function gt(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=nt(e),a=o||i?[...s?S(s):[],...S(t)]:[];a.forEach((e=>{o&&e.addEventListener("scroll",n,{passive:!0}),i&&e.addEventListener("resize",n)}));const d=s&&u?function(e,t){let n,r=null;const o=f(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:-O(f)+"px "+-O(o.clientWidth-(a+d))+"px "+-O(o.clientHeight-(f+p))+"px "+-O(a)+"px",threshold:L(0,A(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||ht(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 p,m=-1,v=null;l&&(v=new ResizeObserver((e=>{let[r]=e;r&&r.target===s&&v&&(v.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame((()=>{var e;null==(e=v)||e.observe(t)}))),n()})),s&&!c&&v.observe(s),v.observe(t));let h=c?lt(e):null;return c&&function t(){const r=lt(e);h&&!ht(h,r)&&n();h=r,p=requestAnimationFrame(t)}(),n(),()=>{var e;a.forEach((e=>{o&&e.removeEventListener("scroll",n),i&&e.removeEventListener("resize",n)})),null==d||d(),null==(e=v)||e.disconnect(),v=null,c&&cancelAnimationFrame(p)}}const yt=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=j(n),u=W(n),c="y"===V(n),s=["left","top"].includes(l)?-1:1,a=i&&c?-1:1,f=F(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}}}}},bt=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}=F(e,t),s={x:n,y:r},a=await et(t,c),f=V(j(o)),d=q(f);let p=s[d],m=s[f];if(i){const e="y"===d?"bottom":"right";p=D(p+a["y"===d?"top":"left"],p,p-a[e])}if(l){const e="y"===f?"bottom":"right";m=D(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}}}}}},wt=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}=F(e,t);if(null!=(n=i.arrow)&&n.alignmentOffset)return{};const g=j(o),y=V(u),b=j(u)===u,w=await(null==c.isRTL?void 0:c.isRTL(s.floating)),x=d||(b||!v?[$(u)]:function(e){const t=$(e);return[H(e),t,H(t)]}(u)),R="none"!==m;!d&&R&&x.push(...function(e,t,n,r){const o=W(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[]}}(j(e),"start"===n,r);return o&&(i=i.map((e=>e+"-"+o)),t&&(i=i.concat(i.map(H)))),i}(u,v,m,w));const E=[u,...x],k=await et(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=W(e),o=K(e),i=B(o);let l="x"===o?r===(n?"end":"start")?"right":"left":"start"===r?"bottom":"top";return t.reference[i]>t.floating[i]&&(l=$(l)),[l,$(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 C,A;const e=((null==(C=i.flip)?void 0:C.index)||0)+1,t=E[e];if(t)return{data:{index:e,overflows:S},reset:{placement:t}};let n=null==(A=S.filter((e=>e.overflows[0]<=0)).sort(((e,t)=>e.overflows[1]-t.overflows[1]))[0])?void 0:A.placement;if(!n)switch(p){case"bestFit":{var L;const e=null==(L=S.filter((e=>{if(R){const t=V(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{}}}},xt=(e,t,n)=>{const r=new Map,o={platform:vt,...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}=Ze(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}=Ze(s,d,c))),n=-1)}return{x:a,y:f,placement:d,strategy:o,middlewareData:p}})(e,t,{...o,platform:i})};var Rt="undefined"!=typeof document?e.useLayoutEffect:e.useEffect;function Et(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(!Et(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)&&!Et(e[n],t[n]))return!1}return!0}return e!=e&&t!=t}function kt(e){if("undefined"==typeof window)return 1;return(e.ownerDocument.defaultView||window).devicePixelRatio||1}function It(e,t){const n=kt(e);return Math.round(t*n)/n}function St(e){const t=l.useRef(e);return Rt((()=>{t.current=e})),t}const Ct=(e,t)=>({...bt(e),options:[e,t]}),At=(e,t)=>({...wt(e),options:[e,t]}),Lt="data-floating-ui-focusable",Mt="active",Ot="selected",Tt="ArrowLeft",Nt="ArrowRight",Pt="ArrowUp",Dt="ArrowDown",Ft={...l};let jt=!1,Wt=0;const qt=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+Wt++;const Bt=Ft.useId||function(){const[e,t]=l.useState((()=>jt?qt():void 0));return Pe((()=>{null==e&&t(qt())}),[]),l.useEffect((()=>{jt=!0}),[]),e};let Vt;function Kt(){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=Vt)&&e.has(o)||(null==(i=Vt)||i.add(o),console.warn(o))}"production"!==process.env.NODE_ENV&&(Vt=new Set);const Ht=l.createContext(null),$t=l.createContext(null),_t=()=>{var e;return(null==(e=l.useContext(Ht))?void 0:e.id)||null},zt=()=>l.useContext($t);function Ut(e){return"data-floating-ui-"+e}function Xt(e){-1!==e.current&&(clearTimeout(e.current),e.current=-1)}let Yt=0;function Gt(e,t){void 0===t&&(t={});const{preventScroll:n=!1,cancelPrevious:r=!0,sync:o=!1}=t;r&&cancelAnimationFrame(Yt);const i=()=>null==e?void 0:e.focus({preventScroll:n});o?i():Yt=requestAnimationFrame(i)}let Jt=new WeakMap,Qt=new WeakSet,Zt={},en=0;const tn=e=>e&&(e.host||tn(e.parentNode)),nn=(e,t)=>t.map((t=>{if(e.contains(t))return t;const n=tn(t);return e.contains(n)?n:null})).filter((e=>null!=e));function rn(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=nn(t,e),u=new Set,c=new Set(l),a=[];Zt[o]||(Zt[o]=new WeakMap);const f=Zt[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"!==s(t))if(u.has(t))e(t);else{const e=i?t.getAttribute(i):null,n=null!==e&&"false"!==e,r=Jt.get(t)||0,l=i?r+1:r,u=(f.get(t)||0)+1;Jt.set(t,l),f.set(t,u),a.push(t),1===l&&n&&Qt.add(t),1===u&&t.setAttribute(o,""),!n&&i&&t.setAttribute(i,"inert"===i?"":"true")}}))}(t),u.clear(),en++,()=>{a.forEach((e=>{const t=Jt.get(e)||0,n=i?t-1:t,r=(f.get(e)||0)-1;Jt.set(e,n),f.set(e,r),n||(!Qt.has(e)&&i&&e.removeAttribute(i),Qt.delete(e)),r||e.removeAttribute(o)})),en--,en||(Jt=new WeakMap,Jt=new WeakMap,Qt=new WeakSet,Zt={})}}(e.concat(Array.from(r.querySelectorAll("[aria-live]"))),r,t,n)}const on={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},ln=l.forwardRef((function(e,n){const[r,o]=l.useState();Pe((()=>{/apple/i.test(navigator.vendor)&&o("button")}),[]);const i={ref:n,tabIndex:0,role:r,"aria-hidden":!r||void 0,[Ut("focus-guard")]:"",style:on};return t.jsx("span",{...e,...i})})),un=l.createContext(null),cn=Ut("portal");function sn(e){const{children:n,id:r,root:o,preserveTabOrder:i=!0}=e,c=function(e){void 0===e&&(e={});const{id:t,root:n}=e,r=Bt(),o=an(),[i,u]=l.useState(null),c=l.useRef(null);return Pe((()=>()=>{null==i||i.remove(),queueMicrotask((()=>{c.current=null}))}),[i]),Pe((()=>{if(!r)return;if(c.current)return;const e=t?document.getElementById(t):null;if(!e)return;const n=document.createElement("div");n.id=r,n.setAttribute(cn,""),e.appendChild(n),c.current=n,u(n)}),[t,r]),Pe((()=>{if(null===n)return;if(!r)return;if(c.current)return;let e=n||(null==o?void 0:o.portalNode);e&&!p(e)&&(e=e.current),e=e||document.body;let i=null;t&&(i=document.createElement("div"),i.id=t,e.appendChild(i));const l=document.createElement("div");l.id=r,l.setAttribute(cn,""),e=i||e,e.appendChild(l),c.current=l,u(l)}),[t,n,r,o]),i}({id:r,root:o}),[s,a]=l.useState(null),f=l.useRef(null),d=l.useRef(null),m=l.useRef(null),v=l.useRef(null),h=null==s?void 0:s.modal,g=null==s?void 0:s.open,y=!!s&&!s.modal&&s.open&&i&&!(!o&&!c);return l.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&&Ge(e)){("focusin"===e.type?Qe:Je)(c)}}}),[c,i,h]),l.useEffect((()=>{c&&(g||Qe(c))}),[g,c]),t.jsxs(un.Provider,{value:l.useMemo((()=>({preserveTabOrder:i,beforeOutsideRef:f,afterOutsideRef:d,beforeInsideRef:m,afterInsideRef:v,portalNode:c,setFocusManagerState:a})),[i,c]),children:[y&&c&&t.jsx(ln,{"data-type":"outside",ref:f,onFocus:e=>{if(Ge(e,c)){var t;null==(t=m.current)||t.focus()}else{const e=Ye(s?s.domReference:null);null==e||e.focus()}}}),y&&c&&t.jsx("span",{"aria-owns":c.id,style:on}),c&&u.createPortal(n,c),y&&c&&t.jsx(ln,{"data-type":"outside",ref:d,onFocus:e=>{if(Ge(e,c)){var t;null==(t=v.current)||t.focus()}else{const t=Xe(s?s.domReference:null);null==t||t.focus(),(null==s?void 0:s.closeOnFocusOut)&&(null==s||s.onOpenChange(!1,e.nativeEvent,"focus-out"))}}})]})}const an=()=>l.useContext(un);function fn(e){return l.useMemo((()=>t=>{e.forEach((e=>{e&&(e.current=t)}))}),e)}const dn=20;let pn=[];function mn(){return pn.slice().reverse().find((e=>e.isConnected))}function vn(e,t){var n;if(!(t.current.includes("floating")||null!=(n=e.getAttribute("role"))&&n.includes("dialog")))return;const r=ze(),o=fe(e,r).filter((e=>{const t=e.getAttribute("data-tabindex")||"";return de(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 hn=l.forwardRef((function(e,n){return t.jsx("button",{...e,type:"button",ref:n,tabIndex:-1,style:on})}));function gn(e){const{context:n,children:r,disabled:o=!1,order:i=["content"],guards:u=!0,initialFocus:c=0,returnFocus:a=!0,restoreFocus:f=!1,modal:d=!0,visuallyHiddenDismiss:p=!1,closeOnFocusOut:v=!0,outsideElementsInert:h=!1,getInsideElements:g=(()=>[])}=e,{open:y,onOpenChange:b,events:w,dataRef:x,elements:{domReference:R,floating:E}}=n,k=je((()=>{var e;return null==(e=x.current.floatingContext)?void 0:e.nodeId})),I=je(g),S="number"==typeof c&&c<0,C=Ce(R)&&S,A="undefined"!=typeof HTMLElement&&"inert"in HTMLElement.prototype,L=!A||u,M=!L||A&&h,O=De(i),T=De(c),N=De(a),P=zt(),D=an(),F=l.useRef(null),j=l.useRef(null),W=l.useRef(!1),q=l.useRef(!1),B=l.useRef(-1),V=null!=D,K=Ae(E),H=je((function(e){return void 0===e&&(e=K),e?ae(e,ze()):[]})),$=je((e=>{const t=H(e);return O.current.map((e=>R&&"reference"===e?R:K&&"floating"===e?K:t)).filter(Boolean).flat()}));l.useEffect((()=>{if(o)return;if(!d)return;function e(e){if("Tab"===e.key){Ee(K,Re(Se(K)))&&0===H().length&&!C&&Oe(e);const t=$(),n=ke(e);"reference"===O.current[0]&&n===R&&(Oe(e),e.shiftKey?Gt(t[t.length-1]):Gt(t[1])),"floating"===O.current[1]&&n===K&&e.shiftKey&&(Oe(e),Gt(t[0]))}}const t=Se(K);return t.addEventListener("keydown",e),()=>{t.removeEventListener("keydown",e)}}),[o,R,K,d,O,C,H,$]),l.useEffect((()=>{if(!o&&E)return E.addEventListener("focusin",e),()=>{E.removeEventListener("focusin",e)};function e(e){const t=ke(e),n=H().indexOf(t);-1!==n&&(B.current=n)}}),[o,E,H]),l.useEffect((()=>{if(!o&&v)return E&&m(R)?(R.addEventListener("focusout",t),R.addEventListener("pointerdown",e),E.addEventListener("focusout",t),()=>{R.removeEventListener("focusout",t),R.removeEventListener("pointerdown",e),E.removeEventListener("focusout",t)}):void 0;function e(){q.current=!0,setTimeout((()=>{q.current=!1}))}function t(e){const t=e.relatedTarget,n=e.currentTarget;queueMicrotask((()=>{const r=k(),o=!(Ee(R,t)||Ee(E,t)||Ee(t,E)||Ee(null==D?void 0:D.portalNode,t)||null!=t&&t.hasAttribute(Ut("focus-guard"))||P&&(Le(P.nodesRef.current,r).find((e=>{var n,r;return Ee(null==(n=e.context)?void 0:n.elements.floating,t)||Ee(null==(r=e.context)?void 0:r.elements.domReference,t)}))||Me(P.nodesRef.current,r).find((e=>{var n,r,o;return[null==(n=e.context)?void 0:n.elements.floating,Ae(null==(r=e.context)?void 0:r.elements.floating)].includes(t)||(null==(o=e.context)?void 0:o.elements.domReference)===t}))));if(n===R&&K&&vn(K,O),f&&o&&Re(Se(K))===Se(K).body){m(K)&&K.focus();const e=B.current,t=H(),n=t[e]||t[t.length-1]||K;m(n)&&n.focus()}!C&&d||!t||!o||q.current||t===mn()||(W.current=!0,b(!1,e,"focus-out"))}))}}),[o,R,E,K,d,P,D,b,v,f,H,C,k,O]);const _=l.useRef(null),z=l.useRef(null),U=fn([_,null==D?void 0:D.beforeInsideRef]),X=fn([z,null==D?void 0:D.afterInsideRef]);function Y(e){return!o&&p&&d?t.jsx(hn,{ref:"start"===e?F:j,onClick:e=>b(!1,e.nativeEvent),children:"string"==typeof p?p:"Dismiss"}):null}l.useEffect((()=>{var e,t;if(o)return;if(!E)return;const n=Array.from((null==D||null==(e=D.portalNode)?void 0:e.querySelectorAll("["+Ut("portal")+"]"))||[]),r=P?Me(P.nodesRef.current,k()):[],i=P&&!d?r.map((e=>{var t;return null==(t=e.context)?void 0:t.elements.floating})):[],l=null==(t=r.find((e=>{var t;return Ce((null==(t=e.context)?void 0:t.elements.domReference)||null)})))||null==(t=t.context)?void 0:t.elements.domReference,u=[E,l,...n,...i,...I(),F.current,j.current,_.current,z.current,null==D?void 0:D.beforeOutsideRef.current,null==D?void 0:D.afterOutsideRef.current,O.current.includes("reference")||C?R:null].filter((e=>null!=e)),c=d||C?rn(u,!M,M):rn(u);return()=>{c()}}),[o,R,E,d,O,D,C,L,M,P,k,I]),Pe((()=>{if(o||!m(K))return;const e=Re(Se(K));queueMicrotask((()=>{const t=$(K),n=T.current,r=("number"==typeof n?t[n]:n.current)||K,o=Ee(K,e);S||o||!y||Gt(r,{preventScroll:r===K})}))}),[o,y,K,S,$,T]),Pe((()=>{if(o||!K)return;let e=!1;const t=Se(K),n=Re(t);var r;function i(t){let{reason:n,event:r,nested:o}=t;if(["hover","safe-polygon"].includes(n)&&"mouseleave"===r.type&&(W.current=!0),"outside-press"===n)if(o)W.current=!1,e=!0;else if(Te(r)||Ne(r))W.current=!1;else{let t=!1;document.createElement("div").focus({get preventScroll(){return t=!0,!1}}),t?(W.current=!1,e=!0):W.current=!0}}r=n,pn=pn.filter((e=>e.isConnected)),r&&"body"!==s(r)&&(pn.push(r),pn.length>dn&&(pn=pn.slice(-20))),w.on("openchange",i);const l=t.createElement("span");return l.setAttribute("tabindex","-1"),l.setAttribute("aria-hidden","true"),Object.assign(l.style,on),V&&R&&R.insertAdjacentElement("afterend",l),()=>{w.off("openchange",i);const n=Re(t),r=Ee(E,n)||P&&Le(P.nodesRef.current,k()).some((e=>{var t;return Ee(null==(t=e.context)?void 0:t.elements.floating,n)})),o=function(){if("boolean"==typeof N.current){const e=R||mn();return e&&e.isConnected?e:l}return N.current.current||l}();queueMicrotask((()=>{const i=function(e){const t=ze();return de(e,t)?e:ae(e,t)[0]||e}(o);N.current&&!W.current&&m(i)&&(i===n||n===t.body||r)&&i.focus({preventScroll:e}),l.remove()}))}}),[o,E,K,N,x,w,P,V,R,k]),l.useEffect((()=>{queueMicrotask((()=>{W.current=!1}))}),[o]),Pe((()=>{if(!o&&D)return D.setFocusManagerState({modal:d,closeOnFocusOut:v,open:y,onOpenChange:b,domReference:R}),()=>{D.setFocusManagerState(null)}}),[o,D,d,y,b,v,R]),Pe((()=>{o||K&&vn(K,O)}),[o,K,O]);const G=!o&&L&&(!d||!C)&&(V||d);return t.jsxs(t.Fragment,{children:[G&&t.jsx(ln,{"data-type":"inside",ref:U,onFocus:e=>{if(d){const e=$();Gt("reference"===i[0]?e[0]:e[e.length-1])}else if(null!=D&&D.preserveTabOrder&&D.portalNode)if(W.current=!1,Ge(e,D.portalNode)){const e=Xe(R);null==e||e.focus()}else{var t;null==(t=D.beforeOutsideRef.current)||t.focus()}}}),!C&&Y("start"),r,Y("end"),G&&t.jsx(ln,{"data-type":"inside",ref:X,onFocus:e=>{if(d)Gt($()[0]);else if(null!=D&&D.preserveTabOrder&&D.portalNode)if(v&&(W.current=!0),Ge(e,D.portalNode)){const e=Ye(R);null==e||e.focus()}else{var t;null==(t=D.afterOutsideRef.current)||t.focus()}}})]})}let yn=0;let bn=()=>{};const wn=l.forwardRef((function(e,n){const{lockScroll:r=!1,...o}=e;return Pe((()=>{if(r)return yn++,1===yn&&(bn=function(){const e=/iP(hone|ad|od)|iOS/.test(pe()),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))}}()),()=>{yn--,0===yn&&bn()}}),[r]),t.jsx("div",{ref:n,...o,style:{position:"fixed",overflow:"auto",top:0,right:0,bottom:0,left:0,...o.style}})})),xn={pointerdown:"onPointerDown",mousedown:"onMouseDown",click:"onClick"},Rn={pointerdown:"onPointerDownCapture",mousedown:"onMouseDownCapture",click:"onClickCapture"},En=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 kn(e){const{open:t=!1,onOpenChange:n,elements:r}=e,o=Bt(),i=l.useRef({}),[u]=l.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!=_t();if("production"!==process.env.NODE_ENV){const e=r.reference;e&&!p(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=Vt)&&e.has(o)||(null==(i=Vt)||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]=l.useState(r.reference),f=je(((e,t,r)=>{i.current.openEvent=e?t:void 0,u.emit("openchange",{open:e,event:t,reason:r,nested:c}),null==n||n(e,t,r)})),d=l.useMemo((()=>({setPositionReference:a})),[]),m=l.useMemo((()=>({reference:s||r.reference||null,floating:r.floating||null,domReference:r.reference})),[s,r.reference,r.floating]);return l.useMemo((()=>({dataRef:i,open:t,onOpenChange:f,elements:m,events:u,floatingId:o,refs:d})),[t,f,m,u,o,d])}function In(e){void 0===e&&(e={});const{nodeId:t}=e,n=kn({...e,elements:{reference:null,floating:null,...e.elements}}),r=e.rootContext||n,o=r.elements,[i,c]=l.useState(null),[s,a]=l.useState(null),f=(null==o?void 0:o.domReference)||i,d=l.useRef(null),m=zt();Pe((()=>{f&&(d.current=f)}),[f]);const v=function(e){void 0===e&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:i,floating:c}={},transform:s=!0,whileElementsMounted:a,open:f}=e,[d,p]=l.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,v]=l.useState(r);Et(m,r)||v(r);const[h,g]=l.useState(null),[y,b]=l.useState(null),w=l.useCallback((e=>{e!==k.current&&(k.current=e,g(e))}),[]),x=l.useCallback((e=>{e!==I.current&&(I.current=e,b(e))}),[]),R=i||h,E=c||y,k=l.useRef(null),I=l.useRef(null),S=l.useRef(d),C=null!=a,A=St(a),L=St(o),M=St(f),O=l.useCallback((()=>{if(!k.current||!I.current)return;const e={placement:t,strategy:n,middleware:m};L.current&&(e.platform=L.current),xt(k.current,I.current,e).then((e=>{const t={...e,isPositioned:!1!==M.current};T.current&&!Et(S.current,t)&&(S.current=t,u.flushSync((()=>{p(t)})))}))}),[m,t,n,L,M]);Rt((()=>{!1===f&&S.current.isPositioned&&(S.current.isPositioned=!1,p((e=>({...e,isPositioned:!1}))))}),[f]);const T=l.useRef(!1);Rt((()=>(T.current=!0,()=>{T.current=!1})),[]),Rt((()=>{if(R&&(k.current=R),E&&(I.current=E),R&&E){if(A.current)return A.current(R,E,O);O()}}),[R,E,O,A,C]);const N=l.useMemo((()=>({reference:k,floating:I,setReference:w,setFloating:x})),[w,x]),P=l.useMemo((()=>({reference:R,floating:E})),[R,E]),D=l.useMemo((()=>{const e={position:n,left:0,top:0};if(!P.floating)return e;const t=It(P.floating,d.x),r=It(P.floating,d.y);return s?{...e,transform:"translate("+t+"px, "+r+"px)",...kt(P.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:t,top:r}}),[n,s,P.floating,d.x,d.y]);return l.useMemo((()=>({...d,update:O,refs:N,elements:P,floatingStyles:D})),[d,O,N,P,D])}({...e,elements:{...o,...s&&{reference:s}}}),h=l.useCallback((e=>{const t=p(e)?{getBoundingClientRect:()=>e.getBoundingClientRect(),getClientRects:()=>e.getClientRects(),contextElement:e}:e;a(t),v.refs.setReference(t)}),[v.refs]),g=l.useCallback((e=>{(p(e)||null===e)&&(d.current=e,c(e)),(p(v.refs.reference.current)||null===v.refs.reference.current||null!==e&&!p(e))&&v.refs.setReference(e)}),[v.refs]),y=l.useMemo((()=>({...v.refs,setReference:g,setPositionReference:h,domReference:d})),[v.refs,g,h]),b=l.useMemo((()=>({...v.elements,domReference:f})),[v.elements,f]),w=l.useMemo((()=>({...v,...r,refs:y,elements:b,nodeId:t})),[v,y,b,t,r]);return Pe((()=>{r.dataRef.current.floatingContext=w;const e=null==m?void 0:m.nodesRef.current.find((e=>e.id===t));e&&(e.context=w)})),l.useMemo((()=>({...v,context:w,refs:y,elements:b})),[v,y,b,w])}function Sn(e,t,n){const r=new Map,o="item"===n;let i=e;if(o&&e){const{[Mt]:t,[Ot]:n,...r}=e;i=r}return{..."floating"===n&&{tabIndex:-1,[Lt]:""},...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&&[Mt,Ot].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 Cn="Escape";function An(e,t,n){switch(e){case"vertical":return t;case"horizontal":return n;default:return t||n}}function Ln(e,t){return An(t,e===Pt||e===Dt,e===Tt||e===Nt)}function Mn(e,t,n){return An(t,e===Dt,n?e===Tt:e===Nt)||"Enter"===e||" "===e||""===e}function On(e,t,n){return An(t,n?e===Tt:e===Nt,e===Dt)}function Tn(e,t,n,r){return"both"===t||"horizontal"===t&&r&&r>1?e===Cn:An(t,n?e===Nt:e===Tt,e===Pt)}function Nn(e,t){const{open:n,onOpenChange:r,elements:o,floatingId:i}=e,{listRef:u,activeIndex:c,onNavigate:s=(()=>{}),enabled:a=!0,selectedIndex:f=null,allowEscape:d=!1,loop:p=!1,nested:v=!1,rtl:h=!1,virtual:g=!1,focusItemOnOpen:y="auto",focusItemOnHover:b=!0,openOnArrowKeyDown:w=!0,disabledIndices:x,orientation:R="vertical",parentOrientation:E,cols:k=1,scrollItemIntoView:I=!0,virtualItemRef:S,itemSizes:C,dense:A=!1}=t;"production"!==process.env.NODE_ENV&&(d&&(p||Kt("`useListNavigation` looping must be enabled to allow escaping."),g||Kt("`useListNavigation` must be virtual to allow escaping.")),"vertical"===R&&k>1&&Kt("In grid list navigation mode (`cols` > 1), the `orientation` should",'be either "horizontal" or "both".'));const L=De(Ae(o.floating)),M=_t(),T=zt();Pe((()=>{e.dataRef.current.orientation=R}),[e,R]);const N=je((()=>{s(-1===F.current?null:F.current)})),P=Ce(o.domReference),D=l.useRef(y),F=l.useRef(null!=f?f:-1),j=l.useRef(null),W=l.useRef(!0),q=l.useRef(N),B=l.useRef(!!o.floating),V=l.useRef(n),K=l.useRef(!1),H=l.useRef(!1),$=De(x),_=De(n),z=De(I),U=De(f),[X,Y]=l.useState(),[G,J]=l.useState(),Q=je((()=>{function e(e){var t;g?(null!=(t=e.id)&&t.endsWith("-fui-option")&&(e.id=i+"-"+Math.random().toString(16).slice(2,10)),Y(e.id),null==T||T.events.emit("virtualfocus",e),S&&(S.current=e)):Gt(e,{sync:K.current,preventScroll:!0})}const t=u.current[F.current],n=H.current;t&&e(t);(K.current?e=>e():requestAnimationFrame)((()=>{const r=u.current[F.current]||t;if(!r)return;t||e(r);const o=z.current;o&&ee&&(n||!W.current)&&(null==r.scrollIntoView||r.scrollIntoView("boolean"==typeof o?{block:"nearest",inline:"nearest"}:o))}))}));Pe((()=>{a&&(n&&o.floating?D.current&&null!=f&&(H.current=!0,F.current=f,N()):B.current&&(F.current=-1,q.current()))}),[a,n,o.floating,f,N]),Pe((()=>{if(a&&n&&o.floating)if(null==c){if(K.current=!1,null!=U.current)return;if(B.current&&(F.current=-1,Q()),(!V.current||!B.current)&&D.current&&(null!=j.current||!0===D.current&&null==j.current)){let e=0;const t=()=>{if(null==u.current[0]){if(e<2){(e?requestAnimationFrame:queueMicrotask)(t)}e++}else F.current=null==j.current||Mn(j.current,R,h)||v?Be(u,$.current):Ve(u,$.current),j.current=null,N()};t()}}else qe(u,c)||(F.current=c,Q(),H.current=!1)}),[a,n,o.floating,c,U,v,u,R,h,N,Q,$]),Pe((()=>{var e;if(!a||o.floating||!T||g||!B.current)return;const t=T.nodesRef.current,n=null==(e=t.find((e=>e.id===M)))||null==(e=e.context)?void 0:e.elements.floating,r=Re(Se(o.floating)),i=t.some((e=>e.context&&Ee(e.context.elements.floating,r)));n&&!i&&W.current&&n.focus({preventScroll:!0})}),[a,o.floating,T,M,g]),Pe((()=>{if(a&&T&&g&&!M)return T.events.on("virtualfocus",e),()=>{T.events.off("virtualfocus",e)};function e(e){J(e.id),S&&(S.current=e)}}),[a,T,g,M,S]),Pe((()=>{q.current=N,V.current=n,B.current=!!o.floating})),Pe((()=>{n||(j.current=null)}),[n]);const Z=null!=c,ee=l.useMemo((()=>{function e(e){if(!n)return;const t=u.current.indexOf(e);-1!==t&&F.current!==t&&(F.current=t,N())}return{onFocus(t){let{currentTarget:n}=t;K.current=!0,e(n)},onClick:e=>{let{currentTarget:t}=e;return t.focus({preventScroll:!0})},...b&&{onMouseMove(t){let{currentTarget:n}=t;K.current=!0,H.current=!1,e(n)},onPointerLeave(e){let{pointerType:t}=e;var n;W.current&&"touch"!==t&&(K.current=!0,F.current=-1,N(),g||null==(n=L.current)||n.focus({preventScroll:!0}))}}}}),[n,L,b,u,N,g]),te=l.useCallback((()=>{var e;return null!=E?E:null==T||null==(e=T.nodesRef.current.find((e=>e.id===M)))||null==(e=e.context)||null==(e=e.dataRef)?void 0:e.current.orientation}),[M,T,E]),ne=je((e=>{if(W.current=!1,K.current=!0,229===e.which)return;if(!_.current&&e.currentTarget===L.current)return;if(v&&Tn(e.key,R,h,k))return Ln(e.key,te())||Oe(e),r(!1,e.nativeEvent,"list-navigation"),void(m(o.domReference)&&(g?null==T||T.events.emit("virtualfocus",o.domReference):o.domReference.focus()));const t=F.current,i=Be(u,x),l=Ve(u,x);if(P||("Home"===e.key&&(Oe(e),F.current=i,N()),"End"===e.key&&(Oe(e),F.current=l,N())),k>1){const t=C||Array.from({length:u.current.length},(()=>({width:1,height:1}))),n=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,A),r=n.findIndex((e=>null!=e&&!_e(u,e,x))),o=n.reduce(((e,t,n)=>null==t||_e(u,t,x)?e:n),-1),c=n[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===we){if(f&&Oe(n),-1===a)d=s;else if(d=Ke(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}qe(e,d)&&(d=a)}if(n.key===xe&&(f&&Oe(n),-1===a?d=c:(d=Ke(e,{startingIndex:a,amount:l,disabledIndices:u}),o&&a+l>s&&(d=Ke(e,{startingIndex:a%l-l,amount:l,disabledIndices:u}))),qe(e,d)&&(d=a)),"both"===r){const t=O(a/l);n.key===(i?ye:be)&&(f&&Oe(n),a%l!=l-1?(d=Ke(e,{startingIndex:a,disabledIndices:u}),o&&We(d,l,t)&&(d=Ke(e,{startingIndex:a-a%l-1,disabledIndices:u}))):o&&(d=Ke(e,{startingIndex:a-a%l-1,disabledIndices:u})),We(d,l,t)&&(d=a)),n.key===(i?be:ye)&&(f&&Oe(n),a%l!=0?(d=Ke(e,{startingIndex:a,decrement:!0,disabledIndices:u}),o&&We(d,l,t)&&(d=Ke(e,{startingIndex:a+(l-a%l),decrement:!0,disabledIndices:u}))):o&&(d=Ke(e,{startingIndex:a+(l-a%l),decrement:!0,disabledIndices:u})),We(d,l,t)&&(d=a));const r=O(s/l)===t;qe(e,d)&&(d=o&&r?n.key===(i?be:ye)?s:Ke(e,{startingIndex:a-a%l-1,disabledIndices:u}):a)}return d}({current:n.map((e=>null!=e?u.current[e]:null))},{event:e,orientation:R,loop:p,rtl:h,cols:k,disabledIndices:$e([...x||u.current.map(((e,t)=>_e(u,t)?t:void 0)),void 0],n),minIndex:r,maxIndex:o,prevIndex:He(F.current>l?i:F.current,t,n,k,e.key===Dt?"bl":e.key===(h?Tt:Nt)?"tr":"tl"),stopEvent:!0})];if(null!=c&&(F.current=c,N()),"both"===R)return}if(Ln(e.key,R)){if(Oe(e),n&&!g&&Re(e.currentTarget.ownerDocument)===e.currentTarget)return F.current=Mn(e.key,R,h)?i:l,void N();Mn(e.key,R,h)?F.current=p?t>=l?d&&t!==u.current.length?-1:i:Ke(u,{startingIndex:t,disabledIndices:x}):Math.min(l,Ke(u,{startingIndex:t,disabledIndices:x})):F.current=p?t<=i?d&&-1!==t?u.current.length:l:Ke(u,{startingIndex:t,decrement:!0,disabledIndices:x}):Math.max(i,Ke(u,{startingIndex:t,decrement:!0,disabledIndices:x})),qe(u,F.current)&&(F.current=-1),N()}})),re=l.useMemo((()=>g&&n&&Z&&{"aria-activedescendant":G||X}),[g,n,Z,G,X]),oe=l.useMemo((()=>({"aria-orientation":"both"===R?void 0:R,...P?{}:re,onKeyDown:ne,onPointerMove(){W.current=!0}})),[re,ne,R,P]),ie=l.useMemo((()=>{function e(e){"auto"===y&&Te(e.nativeEvent)&&(D.current=!0)}function t(e){D.current=y,"auto"===y&&Ne(e.nativeEvent)&&(D.current=!0)}return{...re,onKeyDown(e){W.current=!1;const t=e.key.startsWith("Arrow"),o=["Home","End"].includes(e.key),i=t||o,l=On(e.key,R,h),c=Tn(e.key,R,h,k),s=On(e.key,te(),h),a=Ln(e.key,R),d=(v?s:a)||"Enter"===e.key||""===e.key.trim();if(g&&n){const t=null==T?void 0:T.nodesRef.current.find((e=>null==e.parentId)),n=T&&t?function(e,t){let n,r=-1;return function t(o,i){i>r&&(n=o,r=i),Le(e,o).forEach((e=>{t(e.id,i+1)}))}(t,0),e.find((e=>e.id===n))}(T.nodesRef.current,t.id):null;if(i&&n&&S){const t=new KeyboardEvent("keydown",{key:e.key,bubbles:!0});if(l||c){var p,m;const r=(null==(p=n.context)?void 0:p.elements.domReference)===e.currentTarget,o=c&&!r?null==(m=n.context)?void 0:m.elements.domReference:l?u.current.find((e=>(null==e?void 0:e.id)===X)):null;o&&(Oe(e),o.dispatchEvent(t),J(void 0))}var y;if((a||o)&&n.context)if(n.context.open&&n.parentId&&e.currentTarget!==n.context.elements.domReference)return Oe(e),void(null==(y=n.context.elements.domReference)||y.dispatchEvent(t))}return ne(e)}if(n||w||!t){if(d){const t=Ln(e.key,te());j.current=v&&t?null:e.key}v?s&&(Oe(e),n?(F.current=Be(u,$.current),N()):r(!0,e.nativeEvent,"list-navigation")):a&&(null!=f&&(F.current=f),Oe(e),!n&&w?r(!0,e.nativeEvent,"list-navigation"):ne(e),n&&N())}},onFocus(){n&&!g&&(F.current=-1,N())},onPointerDown:t,onPointerEnter:t,onMouseDown:e,onClick:e}}),[X,re,k,ne,$,y,u,v,N,r,n,w,R,te,h,f,T,g,S]);return l.useMemo((()=>a?{reference:ie,floating:oe,item:ee}:{}),[a,ie,oe,ee])}const Pn=new Map([["select","listbox"],["combobox","listbox"],["label",!1]]);class Dn{constructor(e){this.key=e,this.ref={current:null},this.setRefElement=this.setRefElement.bind(this)}setRefElement(e){this.ref={current:e}}}const Fn=e.forwardRef((({className:e,disabled:n,...r},o)=>t.jsx("hr",{className:e}))),jn=e.forwardRef((({className:e,label:n,disabled:r,icon:o,...i},l)=>t.jsxs("button",{...i,className:e,ref:l,role:"menuitem",disabled:r,children:[o,n]}))),Wn=e.forwardRef((({items:n,className:i,itemClassName:u,separatorClassName:c},s)=>{const[a]=r.useLexicalComposerContext(),[f,d]=e.useState(null),[v,h]=e.useState(!1),g=e.useRef([]),y=e.useRef([]),{refs:b,floatingStyles:E,context:I}=In({middleware:[(C={alignmentAxis:4,mainAxis:5},{...yt(C),options:[C,A]}),At({fallbackPlacements:["left-start"]}),Ct({padding:10})],onOpenChange:h,open:v,placement:"right-start",strategy:"fixed",whileElementsMounted:gt});var C,A;const L=function(e,t){var n,r;void 0===t&&(t={});const{open:o,elements:i,floatingId:u}=e,{enabled:c=!0,role:s="dialog"}=t,a=Bt(),f=(null==(n=i.domReference)?void 0:n.id)||a,d=l.useMemo((()=>{var e;return(null==(e=Ae(i.floating))?void 0:e.id)||u}),[i.floating,u]),p=null!=(r=Pn.get(s))?r:s,m=null!=_t(),v=l.useMemo((()=>"tooltip"===p||"label"===s?{["aria-"+("label"===s?"labelledby":"describedby")]:o?d:void 0}:{"aria-expanded":o?"true":"false","aria-haspopup":"alertdialog"===p?"dialog":p,"aria-controls":o?d:void 0,..."listbox"===p&&{role:"combobox"},..."menu"===p&&{id:f},..."menu"===p&&m&&{role:"menuitem"},..."select"===s&&{"aria-autocomplete":"none"},..."combobox"===s&&{"aria-autocomplete":"list"}}),[p,d,m,o,f,s]),h=l.useMemo((()=>{const e={id:d,...p&&{role:p}};return"tooltip"===p||"label"===s?e:{...e,..."menu"===p&&{"aria-labelledby":f}}}),[p,d,f,s]),g=l.useCallback((e=>{let{active:t,selected:n}=e;const r={role:"option",...t&&{id:d+"-fui-option"}};switch(s){case"select":return{...r,"aria-selected":t&&n};case"combobox":return{...r,"aria-selected":n}}return{}}),[d,s]);return l.useMemo((()=>c?{reference:v,floating:h,item:g}:{}),[c,v,h,g])}(I,{role:"menu"}),M=function(e,t){void 0===t&&(t={});const{open:n,onOpenChange:r,elements:o,dataRef:i}=e,{enabled:u=!0,escapeKey:c=!0,outsidePress:s=!0,outsidePressEvent:a="pointerdown",referencePress:f=!1,referencePressEvent:d="pointerdown",ancestorScroll:v=!1,bubbles:h,capture:g}=t,y=zt(),b=je("function"==typeof s?s:()=>!1),E="function"==typeof s?b:s,I=l.useRef(!1),C=l.useRef(!1),{escapeKey:A,outsidePress:L}=En(h),{escapeKey:M,outsidePress:O}=En(g),T=l.useRef(!1),N=je((e=>{var t;if(!n||!u||!c||"Escape"!==e.key)return;if(T.current)return;const o=null==(t=i.current.floatingContext)?void 0:t.nodeId,l=y?Le(y.nodesRef.current,o):[];if(!A&&(e.stopPropagation(),l.length>0)){let e=!0;if(l.forEach((t=>{var n;null==(n=t.context)||!n.open||t.context.dataRef.current.__escapeKeyBubbles||(e=!1)})),!e)return}r(!1,function(e){return"nativeEvent"in e}(e)?e.nativeEvent:e,"escape-key")})),P=je((e=>{var t;const n=()=>{var t;N(e),null==(t=ke(e))||t.removeEventListener("keydown",n)};null==(t=ke(e))||t.addEventListener("keydown",n)})),D=je((e=>{var t;const n=I.current;I.current=!1;const l=C.current;if(C.current=!1,"click"===a&&l)return;if(n)return;if("function"==typeof E&&!E(e))return;const u=ke(e),c="["+Ut("inert")+"]",s=Se(o.floating).querySelectorAll(c);let f=p(u)?u:null;for(;f&&!x(f);){const e=k(f);if(x(e)||!p(e))break;f=e}if(s.length&&p(u)&&!u.matches("html,body")&&!Ee(u,o.floating)&&Array.from(s).every((e=>!Ee(f,e))))return;if(m(u)&&W){const t=x(u),n=R(u),r=/auto|scroll/,o=t||r.test(n.overflowX),i=t||r.test(n.overflowY),l=o&&u.clientWidth>0&&u.scrollWidth>u.clientWidth,c=i&&u.clientHeight>0&&u.scrollHeight>u.clientHeight,s="rtl"===n.direction,a=c&&(s?e.offsetX<=u.offsetWidth-u.clientWidth:e.offsetX>u.clientWidth),f=l&&e.offsetY>u.clientHeight;if(a||f)return}const d=null==(t=i.current.floatingContext)?void 0:t.nodeId,v=y&&Le(y.nodesRef.current,d).some((t=>{var n;return Ie(e,null==(n=t.context)?void 0:n.elements.floating)}));if(Ie(e,o.floating)||Ie(e,o.domReference)||v)return;const h=y?Le(y.nodesRef.current,d):[];if(h.length>0){let e=!0;if(h.forEach((t=>{var n;null==(n=t.context)||!n.open||t.context.dataRef.current.__outsidePressBubbles||(e=!1)})),!e)return}r(!1,e,"outside-press")})),F=je((e=>{var t;const n=()=>{var t;D(e),null==(t=ke(e))||t.removeEventListener(a,n)};null==(t=ke(e))||t.addEventListener(a,n)}));l.useEffect((()=>{if(!n||!u)return;i.current.__escapeKeyBubbles=A,i.current.__outsidePressBubbles=L;let e=-1;function t(e){r(!1,e,"ancestor-scroll")}function l(){window.clearTimeout(e),T.current=!0}function s(){e=window.setTimeout((()=>{T.current=!1}),w()?5:0)}const f=Se(o.floating);c&&(f.addEventListener("keydown",M?P:N,M),f.addEventListener("compositionstart",l),f.addEventListener("compositionend",s)),E&&f.addEventListener(a,O?F:D,O);let d=[];return v&&(p(o.domReference)&&(d=S(o.domReference)),p(o.floating)&&(d=d.concat(S(o.floating))),!p(o.reference)&&o.reference&&o.reference.contextElement&&(d=d.concat(S(o.reference.contextElement)))),d=d.filter((e=>{var t;return e!==(null==(t=f.defaultView)?void 0:t.visualViewport)})),d.forEach((e=>{e.addEventListener("scroll",t,{passive:!0})})),()=>{c&&(f.removeEventListener("keydown",M?P:N,M),f.removeEventListener("compositionstart",l),f.removeEventListener("compositionend",s)),E&&f.removeEventListener(a,O?F:D,O),d.forEach((e=>{e.removeEventListener("scroll",t)})),window.clearTimeout(e)}}),[i,o,c,E,a,n,r,v,u,A,L,N,M,P,D,O,F]),l.useEffect((()=>{I.current=!1}),[E,a]);const j=l.useMemo((()=>({onKeyDown:N,...f&&{[xn[d]]:e=>{r(!1,e.nativeEvent,"reference-press")},..."click"!==d&&{onClick(e){r(!1,e.nativeEvent,"reference-press")}}}})),[N,r,f,d]),W=l.useMemo((()=>({onKeyDown:N,onMouseDown(){C.current=!0},onMouseUp(){C.current=!0},[Rn[a]]:()=>{I.current=!0}})),[N,a]);return l.useMemo((()=>u?{reference:j,floating:W}:{}),[u,j,W])}(I),O=Nn(I,{activeIndex:f,listRef:g,onNavigate:d}),T=function(e,t){var n;const{open:r,dataRef:o}=e,{listRef:i,activeIndex:u,onMatch:c,onTypingChange:s,enabled:a=!0,findMatch:f=null,resetMs:d=750,ignoreKeys:p=[],selectedIndex:m=null}=t,v=l.useRef(-1),h=l.useRef(""),g=l.useRef(null!=(n=null!=m?m:u)?n:-1),y=l.useRef(null),b=je(c),w=je(s),x=De(f),R=De(p);Pe((()=>{r&&(Xt(v),y.current=null,h.current="")}),[r]),Pe((()=>{var e;r&&""===h.current&&(g.current=null!=(e=null!=m?m:u)?e:-1)}),[r,m,u]);const E=je((e=>{e?o.current.typing||(o.current.typing=e,w(e)):o.current.typing&&(o.current.typing=e,w(e))})),k=je((e=>{function t(e,t,n){const r=x.current?x.current(t,n):t.find((e=>0===(null==e?void 0:e.toLocaleLowerCase().indexOf(n.toLocaleLowerCase()))));return r?e.indexOf(r):-1}const n=i.current;if(h.current.length>0&&" "!==h.current[0]&&(-1===t(n,n,h.current)?E(!1):" "===e.key&&Oe(e)),null==n||R.current.includes(e.key)||1!==e.key.length||e.ctrlKey||e.metaKey||e.altKey)return;r&&" "!==e.key&&(Oe(e),E(!0)),n.every((e=>{var t,n;return!e||(null==(t=e[0])?void 0:t.toLocaleLowerCase())!==(null==(n=e[1])?void 0:n.toLocaleLowerCase())}))&&h.current===e.key&&(h.current="",g.current=y.current),h.current+=e.key,Xt(v),v.current=window.setTimeout((()=>{h.current="",g.current=y.current,E(!1)}),d);const o=g.current,l=t(n,[...n.slice((o||0)+1),...n.slice(0,(o||0)+1)],h.current);-1!==l?(b(l),y.current=l):" "!==e.key&&(h.current="",E(!1))})),I=l.useMemo((()=>({onKeyDown:k})),[k]),S=l.useMemo((()=>({onKeyDown:k,onKeyUp(e){" "===e.key&&E(!1)}})),[k,E]);return l.useMemo((()=>a?{reference:I,floating:S}:{}),[a,I,S])}(I,{activeIndex:f,enabled:v,listRef:y,onMatch:d}),{getFloatingProps:N,getItemProps:P}=function(e){void 0===e&&(e=[]);const t=e.map((e=>null==e?void 0:e.reference)),n=e.map((e=>null==e?void 0:e.floating)),r=e.map((e=>null==e?void 0:e.item)),o=l.useCallback((t=>Sn(t,e,"reference")),t),i=l.useCallback((t=>Sn(t,e,"floating")),n),u=l.useCallback((t=>Sn(t,e,"item")),r);return l.useMemo((()=>({getReferenceProps:o,getFloatingProps:i,getItemProps:u})),[o,i,u])}([L,M,O,T]),[D,F]=e.useState([]);return e.useEffect((()=>{function e(e){e.preventDefault(),b.setPositionReference({getBoundingClientRect:()=>({bottom:e.clientY,height:0,left:e.clientX,right:e.clientX,top:e.clientY,width:0,x:e.clientX,y:e.clientY})});let t=[];n&&a.read((()=>{const r=o.$getNearestNodeFromDOMNode(e.target);r&&(t=n.filter((e=>!e.$showOn||e.$showOn(r))))}));const r=t.map(((e,t)=>"separator"===e.type?{className:c,key:e.key+"-"+t,type:e.type}:{className:u,disabled:e.disabled,icon:e.icon,key:e.key,label:e.title,onClick:()=>a.update((()=>e.$onSelect())),title:e.title,type:e.type}));y.current=r.map((e=>e.key)),F(r),h(!0)}return a.registerRootListener(((t,n)=>{null!==n&&n.removeEventListener("contextmenu",e),null!==t&&t.addEventListener("contextmenu",e)}))}),[n,u,c,b,a]),t.jsx(sn,{children:v&&t.jsx(wn,{lockScroll:!0,children:t.jsx(gn,{context:I,initialFocus:b.floating,children:t.jsx("div",{className:i,ref:b.setFloating,style:E,...N(),children:D.map(((t,n)=>"item"===t.type?e.createElement(jn,{...P({...t,onClick(){t.onClick(),h(!1)},onMouseUp(){t.onClick(),h(!1)},ref(e){g.current[n]=e},tabIndex:f===n?0:-1}),key:t.key}):"separator"===t.type?e.createElement(Fn,{...P({...t,ref(e){g.current[n]=e},tabIndex:f===n?0:-1}),key:t.key}):void 0))})})})})}));exports.NodeContextMenuOption=class extends Dn{constructor(e,t){super(e),this.type="item",this.title=e,this.disabled=t.disabled??!1,this.icon=t.icon??null,this.$onSelect=t.$onSelect,t.$showOn&&(this.$showOn=t.$showOn)}},exports.NodeContextMenuPlugin=Wn,exports.NodeContextMenuSeparator=class extends Dn{constructor(e){super("_separator"),this.type="separator",e&&e.$showOn&&(this.$showOn=e.$showOn)}};
|
|
9
|
+
"use strict";var e=require("@floating-ui/react"),t=require("@lexical/react/LexicalComposerContext"),s=require("lexical"),n=require("react"),i=require("react/jsx-runtime");class a{constructor(e){this.key=e,this.ref={current:null},this.setRefElement=this.setRefElement.bind(this)}setRefElement(e){this.ref={current:e}}}const l=n.forwardRef((({className:e,disabled:t,...s},n)=>i.jsx("hr",{className:e}))),r=n.forwardRef((({className:e,label:t,disabled:s,icon:n,...a},l)=>i.jsxs("button",{...a,className:e,ref:l,role:"menuitem",disabled:s,children:[n,t]}))),o=n.forwardRef((({items:a,className:o,itemClassName:c,separatorClassName:u},d)=>{const[m]=t.useLexicalComposerContext(),[p,h]=n.useState(null),[f,x]=n.useState(!1),g=n.useRef([]),y=n.useRef([]),{refs:N,floatingStyles:b,context:k}=e.useFloating({middleware:[e.offset({alignmentAxis:4,mainAxis:5}),e.flip({fallbackPlacements:["left-start"]}),e.shift({padding:10})],onOpenChange:x,open:f,placement:"right-start",strategy:"fixed",whileElementsMounted:e.autoUpdate}),C=e.useRole(k,{role:"menu"}),w=e.useDismiss(k),R=e.useListNavigation(k,{activeIndex:p,listRef:g,onNavigate:h}),v=e.useTypeahead(k,{activeIndex:p,enabled:f,listRef:y,onMatch:h}),{getFloatingProps:O,getItemProps:$}=e.useInteractions([C,w,R,v]),[E,F]=n.useState([]);return n.useEffect((()=>{function e(e){e.preventDefault(),N.setPositionReference({getBoundingClientRect:()=>({bottom:e.clientY,height:0,left:e.clientX,right:e.clientX,top:e.clientY,width:0,x:e.clientX,y:e.clientY})});let t=[];a&&m.read((()=>{const n=s.$getNearestNodeFromDOMNode(e.target);n&&(t=a.filter((e=>!e.$showOn||e.$showOn(n))))}));const n=t.map(((e,t)=>"separator"===e.type?{className:u,key:e.key+"-"+t,type:e.type}:{className:c,disabled:e.disabled,icon:e.icon,key:e.key,label:e.title,onClick:()=>m.update((()=>e.$onSelect())),title:e.title,type:e.type}));y.current=n.map((e=>e.key)),F(n),x(!0)}return m.registerRootListener(((t,s)=>{null!==s&&s.removeEventListener("contextmenu",e),null!==t&&t.addEventListener("contextmenu",e)}))}),[a,c,u,N,m]),i.jsx(e.FloatingPortal,{children:f&&i.jsx(e.FloatingOverlay,{lockScroll:!0,children:i.jsx(e.FloatingFocusManager,{context:k,initialFocus:N.floating,children:i.jsx("div",{className:o,ref:N.setFloating,style:b,...O(),children:E.map(((e,t)=>"item"===e.type?n.createElement(r,{...$({...e,onClick(){e.onClick(),x(!1)},onMouseUp(){e.onClick(),x(!1)},ref(e){g.current[t]=e},tabIndex:p===t?0:-1}),key:e.key}):"separator"===e.type?n.createElement(l,{...$({...e,ref(e){g.current[t]=e},tabIndex:p===t?0:-1}),key:e.key}):void 0))})})})})}));exports.NodeContextMenuOption=class extends a{constructor(e,t){super(e),this.type="item",this.title=e,this.disabled=t.disabled??!1,this.icon=t.icon??null,this.$onSelect=t.$onSelect,t.$showOn&&(this.$showOn=t.$showOn)}},exports.NodeContextMenuPlugin=o,exports.NodeContextMenuSeparator=class extends a{constructor(e){super("_separator"),this.type="separator",e&&e.$showOn&&(this.$showOn=e.$showOn)}};
|
|
@@ -6,8 +6,4 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import
|
|
10
|
-
/*!
|
|
11
|
-
* tabbable 6.2.0
|
|
12
|
-
* @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
|
|
13
|
-
*/var J=["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(","),Q="undefined"==typeof Element,Z=Q?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,ee=!Q&&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},te=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)},ne=function(e,t,n){if(te(e))return[];var r=Array.prototype.slice.apply(e.querySelectorAll(J));return t&&Z.call(e,J)&&r.unshift(e),r=r.filter(n)},re=function e(t,n,r){for(var o=[],i=Array.from(t);i.length;){var l=i.shift();if(!te(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{Z.call(l,J)&&r.filter(l)&&(n||!t.includes(l))&&o.push(l);var s=l.shadowRoot||"function"==typeof r.getShadowRoot&&r.getShadowRoot(l),a=!te(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},oe=function(e){return!isNaN(parseInt(e.getAttribute("tabindex"),10))},ie=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))&&!oe(e)?0:e.tabIndex},le=function(e,t){return e.tabIndex===t.tabIndex?e.documentOrder-t.documentOrder:e.tabIndex-t.tabIndex},ue=function(e){return"INPUT"===e.tagName},ce=function(e){return function(e){return ue(e)&&"radio"===e.type}(e)&&!function(e){if(!e.name)return!0;var t,n=e.form||ee(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)},se=function(e){var t=e.getBoundingClientRect(),n=t.width,r=t.height;return 0===n&&0===r},ae=function(e,t){var n=t.displayCheck,r=t.getShadowRoot;if("hidden"===getComputedStyle(e).visibility)return!0;var o=Z.call(e,"details>summary:first-of-type")?e.parentElement:e;if(Z.call(o,"details:not([open]) *"))return!0;if(n&&"full"!==n&&"legacy-full"!==n){if("non-zero-area"===n)return se(e)}else{if("function"==typeof r){for(var i=e;e;){var l=e.parentElement,u=ee(e);if(l&&!l.shadowRoot&&!0===r(l))return se(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&&ee(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=ee(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},fe=function(e,t){return!(t.disabled||te(t)||function(e){return ue(e)&&"hidden"===e.type}(t)||ae(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!!Z.call(t,"fieldset[disabled] *")||!r.contains(e)}return!0}t=t.parentElement}return!1}(t))},de=function(e,t){return!(ce(t)||ie(t)<0||!fe(e,t))},pe=function(e){var t=parseInt(e.getAttribute("tabindex"),10);return!!(isNaN(t)||t>=0)},me=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=ie(e);return n<0&&t&&!oe(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(le).reduce((function(e,t){return t.isScope?e.push.apply(e,t.content):e.push(t.content),e}),[]).concat(n)},ve=function(e,t){var n;return n=(t=t||{}).getShadowRoot?re([e],t.includeContainer,{filter:de.bind(null,t),flatten:!1,getShadowRoot:t.getShadowRoot,shadowRootFilter:pe}):ne(e,t.includeContainer,de.bind(null,t)),me(n)},he=function(e,t){return(t=t||{}).getShadowRoot?re([e],t.includeContainer,{filter:fe.bind(null,t),flatten:!0,getShadowRoot:t.getShadowRoot}):ne(e,t.includeContainer,fe.bind(null,t))},ge=function(e,t){if(t=t||{},!e)throw new Error("No node provided");return!1!==Z.call(e,J)&&de(t,e)};function ye(){const e=navigator.userAgentData;return null!=e&&e.platform?e.platform:navigator.platform}function be(){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 we(){const e=/android/i;return e.test(ye())||e.test(be())}const xe="data-floating-ui-focusable",Re="input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])",Ee="ArrowLeft",ke="ArrowRight",Ie="ArrowUp",Se="ArrowDown";function Ae(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 Ce(e,t){if(!e||!t)return!1;const n=null==t.getRootNode?void 0:t.getRootNode();if(e.contains(t))return!0;if(n&&w(n)){let n=t;for(;n;){if(e===n)return!0;n=n.parentNode||n.host}}return!1}function Le(e){return"composedPath"in e?e.composedPath()[0]:e.target}function Me(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 Oe(e){return(null==e?void 0:e.ownerDocument)||document}function Te(e){return!!e&&("combobox"===e.getAttribute("role")&&function(e){return b(e)&&e.matches(Re)}(e))}function Ne(e){return e?e.hasAttribute(xe)?e:e.querySelector("["+xe+"]")||e:null}function Pe(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 De(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 Fe(e){e.preventDefault(),e.stopPropagation()}function We(e){return!(0!==e.mozInputSource||!e.isTrusted)||(we()&&e.pointerType?"click"===e.type&&1===e.buttons:0===e.detail&&!e.pointerType)}function Be(e){return!be().includes("jsdom/")&&(!we()&&0===e.width&&0===e.height||we()&&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 Ve="undefined"!=typeof document?t:n;function Ke(t){const n=e.useRef(t);return Ve((()=>{n.current=t})),n}const He={...e}.useInsertionEffect||(e=>e());function qe(t){const n=e.useRef((()=>{if("production"!==process.env.NODE_ENV)throw new Error("Cannot call an event handler while rendering.")}));return He((()=>{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 je(e,t,n){return Math.floor(e/t)!==n}function $e(e,t){return t<0||t>=e.current.length}function _e(e,t){return Ue(e,{disabledIndices:t})}function ze(e,t){return Ue(e,{decrement:!0,startingIndex:e.current.length,disabledIndices:t})}function Ue(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&&Ge(e,l,o));return l}function Xe(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 Ye(e,t){return t.flatMap(((t,n)=>e.includes(t)?[n]:[]))}function Ge(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 Je=()=>({getShadowRoot:!0,displayCheck:"function"==typeof ResizeObserver&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function Qe(e,t){const n=ve(e,Je()),r=n.length;if(0===r)return;const o=Ae(Oe(e)),i=n.indexOf(o);return n[-1===i?1===t?0:r-1:i+t]}function Ze(e){return Qe(Oe(e).body,1)||e}function et(e){return Qe(Oe(e).body,-1)||e}function tt(e,t){const n=t||e.currentTarget,r=e.relatedTarget;return!r||!Ce(n,r)}function nt(e){ve(e,Je()).forEach((e=>{e.dataset.tabindex=e.getAttribute("tabindex")||"",e.setAttribute("tabindex","-1")}))}function rt(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 ot(e,t,n){let{reference:r,floating:o}=e;const i=z(t),l=U(t),u=_(l),c=q(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(j(t)){case"start":p[l]-=d*(n&&s?-1:1);break;case"end":p[l]+=d*(n&&s?-1:1)}return p}async function it(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}=H(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=G(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=G(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 lt(e){const t=A(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=b(e),i=o?e.offsetWidth:n,l=o?e.offsetHeight:r,u=D(n)!==i||D(r)!==l;return u&&(n=i,r=l),{width:n,height:r,$:u}}function ut(e){return y(e)?e:e.contextElement}function ct(e){const t=ut(e);if(!b(t))return W(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:i}=lt(t);let l=(i?D(n.width):n.width)/r,u=(i?D(n.height):n.height)/o;return l&&Number.isFinite(l)||(l=1),u&&Number.isFinite(u)||(u=1),{x:l,y:u}}const st=W(0);function at(e){const t=v(e);return I()&&t.visualViewport?{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}:st}function ft(e,t,n,r){void 0===t&&(t=!1),void 0===n&&(n=!1);const o=e.getBoundingClientRect(),i=ut(e);let l=W(1);t&&(r?y(r)&&(l=ct(r)):l=ct(e));const u=function(e,t,n){return void 0===t&&(t=!1),!(!n||t&&n!==v(e))&&t}(i,n,r)?at(i):W(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=v(i),t=r&&y(r)?v(r):r;let n=e,o=T(n);for(;o&&r&&t!==n;){const e=ct(o),t=o.getBoundingClientRect(),r=A(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=v(o),o=T(n)}}return G({width:a,height:f,x:c,y:s})}function dt(e,t){const n=C(e).scrollLeft;return t?t.left+n:ft(h(e)).left+n}function pt(e,t,n){void 0===n&&(n=!1);const r=e.getBoundingClientRect();return{x:r.left+t.scrollLeft-(n?0:dt(e,r)),y:r.top+t.scrollTop}}function mt(e,t,n){let r;if("viewport"===t)r=function(e,t){const n=v(e),r=h(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=I();(!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=h(e),n=C(e),r=e.ownerDocument.body,o=P(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),i=P(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let l=-n.scrollLeft+dt(e);const u=-n.scrollTop;return"rtl"===A(r).direction&&(l+=P(t.clientWidth,r.clientWidth)-o),{width:o,height:i,x:l,y:u}}(h(e));else if(y(t))r=function(e,t){const n=ft(e,!0,"fixed"===t),r=n.top+e.clientTop,o=n.left+e.clientLeft,i=b(e)?ct(e):W(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=at(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return G(r)}function vt(e,t){const n=L(e);return!(n===t||!y(n)||S(n))&&("fixed"===A(n).position||vt(n,t))}function ht(e,t,n){const r=b(t),o=h(t),i="fixed"===n,l=ft(e,!0,i,t);let u={scrollLeft:0,scrollTop:0};const c=W(0);if(r||!r&&!i)if(("body"!==m(t)||x(o))&&(u=C(t)),r){const e=ft(t,!0,i,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}else o&&(c.x=dt(o));const s=!o||r||i?W(0):pt(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 gt(e){return"static"===A(e).position}function yt(e,t){if(!b(e)||"fixed"===A(e).position)return null;if(t)return t(e);let n=e.offsetParent;return h(e)===n&&(n=n.ownerDocument.body),n}function bt(e,t){const n=v(e);if(E(e))return n;if(!b(e)){let t=L(e);for(;t&&!S(t);){if(y(t)&&!gt(t))return t;t=L(t)}return n}let r=yt(e,t);for(;r&&R(r)&>(r);)r=yt(r,t);return r&&S(r)&>(r)&&!k(r)?n:r||function(e){let t=L(e);for(;b(t)&&!S(t);){if(k(t))return t;if(E(t))return null;t=L(t)}return null}(e)||n}const wt={convertOffsetParentRelativeRectToViewportRelativeRect:function(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const i="fixed"===o,l=h(r),u=!!t&&E(t.floating);if(r===l||u&&i)return n;let c={scrollLeft:0,scrollTop:0},s=W(1);const a=W(0),f=b(r);if((f||!f&&!i)&&(("body"!==m(r)||x(l))&&(c=C(r)),b(r))){const e=ft(r);s=ct(r),a.x=e.x+r.clientLeft,a.y=e.y+r.clientTop}const d=!l||f||i?W(0):pt(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:h,getClippingRect:function(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[..."clippingAncestors"===n?E(t)?[]:function(e,t){const n=t.get(e);if(n)return n;let r=O(e,[],!1).filter((e=>y(e)&&"body"!==m(e))),o=null;const i="fixed"===A(e).position;let l=i?L(e):e;for(;y(l)&&!S(l);){const t=A(l),n=k(l);n||"fixed"!==t.position||(o=null),(i?!n&&!o:!n&&"static"===t.position&&o&&["absolute","fixed"].includes(o.position)||x(l)&&!n&&vt(e,l))?r=r.filter((e=>e!==l)):o=t,l=L(l)}return t.set(e,r),r}(t,this._c):[].concat(n),r],l=i[0],u=i.reduce(((e,n)=>{const r=mt(t,n,o);return e.top=P(r.top,e.top),e.right=N(r.right,e.right),e.bottom=N(r.bottom,e.bottom),e.left=P(r.left,e.left),e}),mt(t,l,o));return{width:u.right-u.left,height:u.bottom-u.top,x:u.left,y:u.top}},getOffsetParent:bt,getElementRects:async function(e){const t=this.getOffsetParent||bt,n=this.getDimensions,r=await n(e.floating);return{reference:ht(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}=lt(e);return{width:t,height:n}},getScale:ct,isElement:y,isRTL:function(e){return"rtl"===A(e).direction}};function xt(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Rt(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=ut(e),a=o||i?[...s?O(s):[],...O(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=h(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:-F(f)+"px "+-F(o.clientWidth-(a+d))+"px "+-F(o.clientHeight-(f+p))+"px "+-F(a)+"px",threshold:P(0,N(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||xt(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 v=c?ft(e):null;return c&&function t(){const r=ft(e);v&&!xt(v,r)&&n();v=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 Et=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=q(n),u=j(n),c="y"===z(n),s=["left","top"].includes(l)?-1:1,a=i&&c?-1:1,f=H(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}}}}},kt=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}=H(e,t),s={x:n,y:r},a=await it(t,c),f=z(q(o)),d=$(f);let p=s[d],m=s[f];if(i){const e="y"===d?"bottom":"right";p=K(p+a["y"===d?"top":"left"],p,p-a[e])}if(l){const e="y"===f?"bottom":"right";m=K(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}}}}}},It=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}=H(e,t);if(null!=(n=i.arrow)&&n.alignmentOffset)return{};const g=q(o),y=z(u),b=q(u)===u,w=await(null==c.isRTL?void 0:c.isRTL(s.floating)),x=d||(b||!v?[Y(u)]:function(e){const t=Y(e);return[X(e),t,X(t)]}(u)),R="none"!==m;!d&&R&&x.push(...function(e,t,n,r){const o=j(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[]}}(q(e),"start"===n,r);return o&&(i=i.map((e=>e+"-"+o)),t&&(i=i.concat(i.map(X)))),i}(u,v,m,w));const E=[u,...x],k=await it(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=j(e),o=U(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=Y(l)),[l,Y(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=z(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{}}}},St=(e,t,n)=>{const r=new Map,o={platform:wt,...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}=ot(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}=ot(s,d,c))),n=-1)}return{x:a,y:f,placement:d,strategy:o,middlewareData:p}})(e,t,{...o,platform:i})};var At="undefined"!=typeof document?t:n;function Ct(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(!Ct(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)&&!Ct(e[n],t[n]))return!1}return!0}return e!=e&&t!=t}function Lt(e){if("undefined"==typeof window)return 1;return(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Mt(e,t){const n=Lt(e);return Math.round(t*n)/n}function Ot(t){const n=e.useRef(t);return At((()=>{n.current=t})),n}const Tt=(e,t)=>({...kt(e),options:[e,t]}),Nt=(e,t)=>({...It(e),options:[e,t]}),Pt="data-floating-ui-focusable",Dt="active",Ft="selected",Wt="ArrowLeft",Bt="ArrowRight",Vt="ArrowUp",Kt="ArrowDown",Ht={...e};let qt=!1,jt=0;const $t=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+jt++;const _t=Ht.useId||function(){const[t,n]=e.useState((()=>qt?$t():void 0));return Ve((()=>{null==t&&n($t())}),[]),e.useEffect((()=>{qt=!0}),[]),t};let zt;function Ut(){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=zt)&&e.has(o)||(null==(i=zt)||i.add(o),console.warn(o))}"production"!==process.env.NODE_ENV&&(zt=new Set);const Xt=e.createContext(null),Yt=e.createContext(null),Gt=()=>{var t;return(null==(t=e.useContext(Xt))?void 0:t.id)||null},Jt=()=>e.useContext(Yt);function Qt(e){return"data-floating-ui-"+e}function Zt(e){-1!==e.current&&(clearTimeout(e.current),e.current=-1)}let en=0;function tn(e,t){void 0===t&&(t={});const{preventScroll:n=!1,cancelPrevious:r=!0,sync:o=!1}=t;r&&cancelAnimationFrame(en);const i=()=>null==e?void 0:e.focus({preventScroll:n});o?i():en=requestAnimationFrame(i)}let nn=new WeakMap,rn=new WeakSet,on={},ln=0;const un=e=>e&&(e.host||un(e.parentNode)),cn=(e,t)=>t.map((t=>{if(e.contains(t))return t;const n=un(t);return e.contains(n)?n:null})).filter((e=>null!=e));function sn(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=cn(t,e),u=new Set,c=new Set(l),s=[];on[o]||(on[o]=new WeakMap);const a=on[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"!==m(t))if(u.has(t))e(t);else{const e=i?t.getAttribute(i):null,n=null!==e&&"false"!==e,r=nn.get(t)||0,l=i?r+1:r,u=(a.get(t)||0)+1;nn.set(t,l),a.set(t,u),s.push(t),1===l&&n&&rn.add(t),1===u&&t.setAttribute(o,""),!n&&i&&t.setAttribute(i,"inert"===i?"":"true")}}))}(t),u.clear(),ln++,()=>{s.forEach((e=>{const t=nn.get(e)||0,n=i?t-1:t,r=(a.get(e)||0)-1;nn.set(e,n),a.set(e,r),n||(!rn.has(e)&&i&&e.removeAttribute(i),rn.delete(e)),r||e.removeAttribute(o)})),ln--,ln||(nn=new WeakMap,nn=new WeakMap,rn=new WeakSet,on={})}}(e.concat(Array.from(r.querySelectorAll("[aria-live]"))),r,t,n)}const an={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},fn=e.forwardRef((function(t,n){const[r,o]=e.useState();Ve((()=>{/apple/i.test(navigator.vendor)&&o("button")}),[]);const i={ref:n,tabIndex:0,role:r,"aria-hidden":!r||void 0,[Qt("focus-guard")]:"",style:an};return c("span",{...t,...i})})),dn=e.createContext(null),pn=Qt("portal");function mn(t){const{children:n,id:r,root:o,preserveTabOrder:i=!0}=t,l=function(t){void 0===t&&(t={});const{id:n,root:r}=t,o=_t(),i=vn(),[l,u]=e.useState(null),c=e.useRef(null);return Ve((()=>()=>{null==l||l.remove(),queueMicrotask((()=>{c.current=null}))}),[l]),Ve((()=>{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(pn,""),e.appendChild(t),c.current=t,u(t)}),[n,o]),Ve((()=>{if(null===r)return;if(!o)return;if(c.current)return;let e=r||(null==i?void 0:i.portalNode);e&&!y(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(pn,""),e=t||e,e.appendChild(l),c.current=l,u(l)}),[n,r,o,i]),l}({id:r,root:o}),[s,f]=e.useState(null),d=e.useRef(null),p=e.useRef(null),m=e.useRef(null),v=e.useRef(null),h=null==s?void 0:s.modal,g=null==s?void 0:s.open,b=!!s&&!s.modal&&s.open&&i&&!(!o&&!l);return e.useEffect((()=>{if(l&&i&&!h)return l.addEventListener("focusin",e,!0),l.addEventListener("focusout",e,!0),()=>{l.removeEventListener("focusin",e,!0),l.removeEventListener("focusout",e,!0)};function e(e){if(l&&tt(e)){("focusin"===e.type?rt:nt)(l)}}}),[l,i,h]),e.useEffect((()=>{l&&(g||rt(l))}),[g,l]),u(dn.Provider,{value:e.useMemo((()=>({preserveTabOrder:i,beforeOutsideRef:d,afterOutsideRef:p,beforeInsideRef:m,afterInsideRef:v,portalNode:l,setFocusManagerState:f})),[i,l]),children:[b&&l&&c(fn,{"data-type":"outside",ref:d,onFocus:e=>{if(tt(e,l)){var t;null==(t=m.current)||t.focus()}else{const e=et(s?s.domReference:null);null==e||e.focus()}}}),b&&l&&c("span",{"aria-owns":l.id,style:an}),l&&a.createPortal(n,l),b&&l&&c(fn,{"data-type":"outside",ref:p,onFocus:e=>{if(tt(e,l)){var t;null==(t=v.current)||t.focus()}else{const t=Ze(s?s.domReference:null);null==t||t.focus(),(null==s?void 0:s.closeOnFocusOut)&&(null==s||s.onOpenChange(!1,e.nativeEvent,"focus-out"))}}})]})}const vn=()=>e.useContext(dn);function hn(t){return e.useMemo((()=>e=>{t.forEach((t=>{t&&(t.current=e)}))}),t)}const gn=20;let yn=[];function bn(){return yn.slice().reverse().find((e=>e.isConnected))}function wn(e,t){var n;if(!(t.current.includes("floating")||null!=(n=e.getAttribute("role"))&&n.includes("dialog")))return;const r=Je(),o=he(e,r).filter((e=>{const t=e.getAttribute("data-tabindex")||"";return ge(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 xn=e.forwardRef((function(e,t){return c("button",{...e,type:"button",ref:t,tabIndex:-1,style:an})}));function Rn(t){const{context:n,children:r,disabled:o=!1,order:i=["content"],guards:l=!0,initialFocus:a=0,returnFocus:f=!0,restoreFocus:d=!1,modal:p=!0,visuallyHiddenDismiss:v=!1,closeOnFocusOut:h=!0,outsideElementsInert:g=!1,getInsideElements:y=(()=>[])}=t,{open:w,onOpenChange:x,events:R,dataRef:E,elements:{domReference:k,floating:I}}=n,S=qe((()=>{var e;return null==(e=E.current.floatingContext)?void 0:e.nodeId})),A=qe(y),C="number"==typeof a&&a<0,L=Te(k)&&C,M="undefined"!=typeof HTMLElement&&"inert"in HTMLElement.prototype,O=!M||l,T=!O||M&&g,N=Ke(i),P=Ke(a),D=Ke(f),F=Jt(),W=vn(),B=e.useRef(null),V=e.useRef(null),K=e.useRef(!1),H=e.useRef(!1),q=e.useRef(-1),j=null!=W,$=Ne(I),_=qe((function(e){return void 0===e&&(e=$),e?ve(e,Je()):[]})),z=qe((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(!p)return;function e(e){if("Tab"===e.key){Ce($,Ae(Oe($)))&&0===_().length&&!L&&Fe(e);const t=z(),n=Le(e);"reference"===N.current[0]&&n===k&&(Fe(e),e.shiftKey?tn(t[t.length-1]):tn(t[1])),"floating"===N.current[1]&&n===$&&e.shiftKey&&(Fe(e),tn(t[0]))}}const t=Oe($);return t.addEventListener("keydown",e),()=>{t.removeEventListener("keydown",e)}}),[o,k,$,p,N,L,_,z]),e.useEffect((()=>{if(!o&&I)return I.addEventListener("focusin",e),()=>{I.removeEventListener("focusin",e)};function e(e){const t=Le(e),n=_().indexOf(t);-1!==n&&(q.current=n)}}),[o,I,_]),e.useEffect((()=>{if(!o&&h)return I&&b(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=!(Ce(k,t)||Ce(I,t)||Ce(t,I)||Ce(null==W?void 0:W.portalNode,t)||null!=t&&t.hasAttribute(Qt("focus-guard"))||F&&(Pe(F.nodesRef.current,r).find((e=>{var n,r;return Ce(null==(n=e.context)?void 0:n.elements.floating,t)||Ce(null==(r=e.context)?void 0:r.elements.domReference,t)}))||De(F.nodesRef.current,r).find((e=>{var n,r,o;return[null==(n=e.context)?void 0:n.elements.floating,Ne(null==(r=e.context)?void 0:r.elements.floating)].includes(t)||(null==(o=e.context)?void 0:o.elements.domReference)===t}))));if(n===k&&$&&wn($,N),d&&o&&Ae(Oe($))===Oe($).body){b($)&&$.focus();const e=q.current,t=_(),n=t[e]||t[t.length-1]||$;b(n)&&n.focus()}!L&&p||!t||!o||H.current||t===bn()||(K.current=!0,x(!1,e,"focus-out"))}))}}),[o,k,I,$,p,F,W,x,h,d,_,L,S,N]);const U=e.useRef(null),X=e.useRef(null),Y=hn([U,null==W?void 0:W.beforeInsideRef]),G=hn([X,null==W?void 0:W.afterInsideRef]);function J(e){return!o&&v&&p?c(xn,{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("["+Qt("portal")+"]"))||[]),r=F?De(F.nodesRef.current,S()):[],i=F&&!p?r.map((e=>{var t;return null==(t=e.context)?void 0:t.elements.floating})):[],l=null==(t=r.find((e=>{var t;return Te((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=p||L?sn(u,!T,T):sn(u);return()=>{c()}}),[o,k,I,p,N,W,L,O,T,F,S,A]),Ve((()=>{if(o||!b($))return;const e=Ae(Oe($));queueMicrotask((()=>{const t=z($),n=P.current,r=("number"==typeof n?t[n]:n.current)||$,o=Ce($,e);C||o||!w||tn(r,{preventScroll:r===$})}))}),[o,w,$,C,z,P]),Ve((()=>{if(o||!$)return;let e=!1;const t=Oe($),n=Ae(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(We(r)||Be(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,yn=yn.filter((e=>e.isConnected)),r&&"body"!==m(r)&&(yn.push(r),yn.length>gn&&(yn=yn.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,an),j&&k&&k.insertAdjacentElement("afterend",l),()=>{R.off("openchange",i);const n=Ae(t),r=Ce(I,n)||F&&Pe(F.nodesRef.current,S()).some((e=>{var t;return Ce(null==(t=e.context)?void 0:t.elements.floating,n)})),o=function(){if("boolean"==typeof D.current){const e=k||bn();return e&&e.isConnected?e:l}return D.current.current||l}();queueMicrotask((()=>{const i=function(e){const t=Je();return ge(e,t)?e:ve(e,t)[0]||e}(o);D.current&&!K.current&&b(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]),Ve((()=>{if(!o&&W)return W.setFocusManagerState({modal:p,closeOnFocusOut:h,open:w,onOpenChange:x,domReference:k}),()=>{W.setFocusManagerState(null)}}),[o,W,p,w,x,h,k]),Ve((()=>{o||$&&wn($,N)}),[o,$,N]);const Q=!o&&O&&(!p||!L)&&(j||p);return u(s,{children:[Q&&c(fn,{"data-type":"inside",ref:Y,onFocus:e=>{if(p){const e=z();tn("reference"===i[0]?e[0]:e[e.length-1])}else if(null!=W&&W.preserveTabOrder&&W.portalNode)if(K.current=!1,tt(e,W.portalNode)){const e=Ze(k);null==e||e.focus()}else{var t;null==(t=W.beforeOutsideRef.current)||t.focus()}}}),!L&&J("start"),r,J("end"),Q&&c(fn,{"data-type":"inside",ref:G,onFocus:e=>{if(p)tn(z()[0]);else if(null!=W&&W.preserveTabOrder&&W.portalNode)if(h&&(K.current=!0),tt(e,W.portalNode)){const e=et(k);null==e||e.focus()}else{var t;null==(t=W.afterOutsideRef.current)||t.focus()}}})]})}let En=0;let kn=()=>{};const In=e.forwardRef((function(e,t){const{lockScroll:n=!1,...r}=e;return Ve((()=>{if(n)return En++,1===En&&(kn=function(){const e=/iP(hone|ad|od)|iOS/.test(ye()),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))}}()),()=>{En--,0===En&&kn()}}),[n]),c("div",{ref:t,...r,style:{position:"fixed",overflow:"auto",top:0,right:0,bottom:0,left:0,...r.style}})})),Sn={pointerdown:"onPointerDown",mousedown:"onMouseDown",click:"onClick"},An={pointerdown:"onPointerDownCapture",mousedown:"onMouseDownCapture",click:"onClickCapture"},Cn=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 Ln(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!=Gt();if("production"!==process.env.NODE_ENV){const e=o.reference;e&&!y(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=zt)&&e.has(o)||(null==(i=zt)||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=qe(((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 Mn(t){void 0===t&&(t={});const{nodeId:n}=t,r=Ln({...t,elements:{reference:null,floating:null,...t.elements}}),o=t.rootContext||r,i=o.elements,[l,u]=e.useState(null),[c,s]=e.useState(null),f=(null==i?void 0:i.domReference)||l,d=e.useRef(null),p=Jt();Ve((()=>{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:s,open:f}=t,[d,p]=e.useState({x:0,y:0,strategy:r,placement:n,middlewareData:{},isPositioned:!1}),[m,v]=e.useState(o);Ct(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!=s,C=Ot(s),L=Ot(i),M=Ot(f),O=e.useCallback((()=>{if(!k.current||!I.current)return;const e={placement:n,strategy:r,middleware:m};L.current&&(e.platform=L.current),St(k.current,I.current,e).then((e=>{const t={...e,isPositioned:!1!==M.current};T.current&&!Ct(S.current,t)&&(S.current=t,a.flushSync((()=>{p(t)})))}))}),[m,n,r,L,M]);At((()=>{!1===f&&S.current.isPositioned&&(S.current.isPositioned=!1,p((e=>({...e,isPositioned:!1}))))}),[f]);const T=e.useRef(!1);At((()=>(T.current=!0,()=>{T.current=!1})),[]),At((()=>{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=Mt(P.floating,d.x),n=Mt(P.floating,d.y);return c?{...e,transform:"translate("+t+"px, "+n+"px)",...Lt(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=y(e)?{getBoundingClientRect:()=>e.getBoundingClientRect(),getClientRects:()=>e.getClientRects(),contextElement:e}:e;s(t),m.refs.setReference(t)}),[m.refs]),h=e.useCallback((e=>{(y(e)||null===e)&&(d.current=e,u(e)),(y(m.refs.reference.current)||null===m.refs.reference.current||null!==e&&!y(e))&&m.refs.setReference(e)}),[m.refs]),g=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:g,elements:b,nodeId:n})),[m,g,b,n,o]);return Ve((()=>{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:g,elements:b})),[m,g,b,w])}function On(e,t,n){const r=new Map,o="item"===n;let i=e;if(o&&e){const{[Dt]:t,[Ft]:n,...r}=e;i=r}return{..."floating"===n&&{tabIndex:-1,[Pt]:""},...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&&[Dt,Ft].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 Tn="Escape";function Nn(e,t,n){switch(e){case"vertical":return t;case"horizontal":return n;default:return t||n}}function Pn(e,t){return Nn(t,e===Vt||e===Kt,e===Wt||e===Bt)}function Dn(e,t,n){return Nn(t,e===Kt,n?e===Wt:e===Bt)||"Enter"===e||" "===e||""===e}function Fn(e,t,n){return Nn(t,n?e===Wt:e===Bt,e===Kt)}function Wn(e,t,n,r){return"both"===t||"horizontal"===t&&r&&r>1?e===Tn:Nn(t,n?e===Bt:e===Wt,e===Vt)}function Bn(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:y=!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||Ut("`useListNavigation` looping must be enabled to allow escaping."),h||Ut("`useListNavigation` must be virtual to allow escaping.")),"vertical"===R&&k>1&&Ut("In grid list navigation mode (`cols` > 1), the `orientation` should",'be either "horizontal" or "both".'));const L=Ke(Ne(i.floating)),M=Gt(),O=Jt();Ve((()=>{t.dataRef.current.orientation=R}),[t,R]);const T=qe((()=>{s(-1===D.current?null:D.current)})),N=Te(i.domReference),P=e.useRef(g),D=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),$=Ke(x),_=Ke(r),z=Ke(I),U=Ke(f),[X,Y]=e.useState(),[G,J]=e.useState(),Q=qe((()=>{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)):tn(e,{sync:q.current,preventScroll:!0})}const t=u.current[D.current],n=j.current;t&&e(t);(q.current?e=>e():requestAnimationFrame)((()=>{const r=u.current[D.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))}))}));Ve((()=>{a&&(r&&i.floating?P.current&&null!=f&&(j.current=!0,D.current=f,T()):K.current&&(D.current=-1,V.current()))}),[a,r,i.floating,f,T]),Ve((()=>{if(a&&r&&i.floating)if(null==c){if(q.current=!1,null!=U.current)return;if(K.current&&(D.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 D.current=null==W.current||Dn(W.current,R,v)||m?_e(u,$.current):ze(u,$.current),W.current=null,T()};t()}}else $e(u,c)||(D.current=c,Q(),j.current=!1)}),[a,r,i.floating,c,U,m,u,R,v,T,Q,$]),Ve((()=>{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=Ae(Oe(i.floating)),o=t.some((e=>e.context&&Ce(e.context.elements.floating,r)));n&&!o&&B.current&&n.focus({preventScroll:!0})}),[a,i.floating,O,M,h]),Ve((()=>{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]),Ve((()=>{V.current=T,H.current=r,K.current=!!i.floating})),Ve((()=>{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&&D.current!==t&&(D.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})},...y&&{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,D.current=-1,T(),h||null==(n=L.current)||n.focus({preventScroll:!0}))}}}}),[r,L,y,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=qe((e=>{if(B.current=!1,q.current=!0,229===e.which)return;if(!_.current&&e.currentTarget===L.current)return;if(m&&Wn(e.key,R,v,k))return Pn(e.key,te())||Fe(e),o(!1,e.nativeEvent,"list-navigation"),void(b(i.domReference)&&(h?null==O||O.events.emit("virtualfocus",i.domReference):i.domReference.focus()));const t=D.current,n=_e(u,x),l=ze(u,x);if(N||("Home"===e.key&&(Fe(e),D.current=n,T()),"End"===e.key&&(Fe(e),D.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&&!Ge(u,e,x))),i=r.reduce(((e,t,n)=>null==t||Ge(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===Ie){if(f&&Fe(n),-1===a)d=s;else if(d=Ue(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}$e(e,d)&&(d=a)}if(n.key===Se&&(f&&Fe(n),-1===a?d=c:(d=Ue(e,{startingIndex:a,amount:l,disabledIndices:u}),o&&a+l>s&&(d=Ue(e,{startingIndex:a%l-l,amount:l,disabledIndices:u}))),$e(e,d)&&(d=a)),"both"===r){const t=F(a/l);n.key===(i?Ee:ke)&&(f&&Fe(n),a%l!=l-1?(d=Ue(e,{startingIndex:a,disabledIndices:u}),o&&je(d,l,t)&&(d=Ue(e,{startingIndex:a-a%l-1,disabledIndices:u}))):o&&(d=Ue(e,{startingIndex:a-a%l-1,disabledIndices:u})),je(d,l,t)&&(d=a)),n.key===(i?ke:Ee)&&(f&&Fe(n),a%l!=0?(d=Ue(e,{startingIndex:a,decrement:!0,disabledIndices:u}),o&&je(d,l,t)&&(d=Ue(e,{startingIndex:a+(l-a%l),decrement:!0,disabledIndices:u}))):o&&(d=Ue(e,{startingIndex:a+(l-a%l),decrement:!0,disabledIndices:u})),je(d,l,t)&&(d=a));const r=F(s/l)===t;$e(e,d)&&(d=o&&r?n.key===(i?ke:Ee)?s:Ue(e,{startingIndex:a-a%l-1,disabledIndices:u}):a)}return d}({current:r.map((e=>null!=e?u.current[e]:null))},{event:e,orientation:R,loop:p,rtl:v,cols:k,disabledIndices:Ye([...x||u.current.map(((e,t)=>Ge(u,t)?t:void 0)),void 0],r),minIndex:o,maxIndex:i,prevIndex:Xe(D.current>l?n:D.current,t,r,k,e.key===Kt?"bl":e.key===(v?Wt:Bt)?"tr":"tl"),stopEvent:!0})];if(null!=c&&(D.current=c,T()),"both"===R)return}if(Pn(e.key,R)){if(Fe(e),r&&!h&&Ae(e.currentTarget.ownerDocument)===e.currentTarget)return D.current=Dn(e.key,R,v)?n:l,void T();Dn(e.key,R,v)?D.current=p?t>=l?d&&t!==u.current.length?-1:n:Ue(u,{startingIndex:t,disabledIndices:x}):Math.min(l,Ue(u,{startingIndex:t,disabledIndices:x})):D.current=p?t<=n?d&&-1!==t?u.current.length:l:Ue(u,{startingIndex:t,decrement:!0,disabledIndices:x}):Math.max(n,Ue(u,{startingIndex:t,decrement:!0,disabledIndices:x})),$e(u,D.current)&&(D.current=-1),T()}})),re=e.useMemo((()=>h&&r&&Z&&{"aria-activedescendant":G||X}),[h,r,Z,G,X]),oe=e.useMemo((()=>({"aria-orientation":"both"===R?void 0:R,...N?{}:re,onKeyDown:ne,onPointerMove(){B.current=!0}})),[re,ne,R,N]),ie=e.useMemo((()=>{function e(e){"auto"===g&&We(e.nativeEvent)&&(P.current=!0)}function t(e){P.current=g,"auto"===g&&Be(e.nativeEvent)&&(P.current=!0)}return{...re,onKeyDown(e){B.current=!1;const t=e.key.startsWith("Arrow"),n=["Home","End"].includes(e.key),i=t||n,l=Fn(e.key,R,v),c=Wn(e.key,R,v,k),s=Fn(e.key,te(),v),a=Pn(e.key,R),d=(m?s:a)||"Enter"===e.key||""===e.key.trim();if(h&&r){const t=null==O?void 0:O.nodesRef.current.find((e=>null==e.parentId)),r=O&&t?function(e,t){let n,r=-1;return function t(o,i){i>r&&(n=o,r=i),Pe(e,o).forEach((e=>{t(e.id,i+1)}))}(t,0),e.find((e=>e.id===n))}(O.nodesRef.current,t.id):null;if(i&&r&&S){const t=new KeyboardEvent("keydown",{key:e.key,bubbles:!0});if(l||c){var p,g;const n=(null==(p=r.context)?void 0:p.elements.domReference)===e.currentTarget,o=c&&!n?null==(g=r.context)?void 0:g.elements.domReference:l?u.current.find((e=>(null==e?void 0:e.id)===X)):null;o&&(Fe(e),o.dispatchEvent(t),J(void 0))}var y;if((a||n)&&r.context)if(r.context.open&&r.parentId&&e.currentTarget!==r.context.elements.domReference)return Fe(e),void(null==(y=r.context.elements.domReference)||y.dispatchEvent(t))}return ne(e)}if(r||w||!t){if(d){const t=Pn(e.key,te());W.current=m&&t?null:e.key}m?s&&(Fe(e),r?(D.current=_e(u,$.current),T()):o(!0,e.nativeEvent,"list-navigation")):a&&(null!=f&&(D.current=f),Fe(e),!r&&w?o(!0,e.nativeEvent,"list-navigation"):ne(e),r&&T())}},onFocus(){r&&!h&&(D.current=-1,T())},onPointerDown:t,onPointerEnter:t,onMouseDown:e,onClick:e}}),[X,re,k,ne,$,g,u,m,T,o,r,w,R,te,v,f,O,h,S]);return e.useMemo((()=>a?{reference:ie,floating:oe,item:ee}:{}),[a,ie,oe,ee])}const Vn=new Map([["select","listbox"],["combobox","listbox"],["label",!1]]);class Kn{constructor(e){this.key=e,this.ref={current:null},this.setRefElement=this.setRefElement.bind(this)}setRefElement(e){this.ref={current:e}}}class Hn extends Kn{constructor(e,t){super(e),this.type="item",this.title=e,this.disabled=t.disabled??!1,this.icon=t.icon??null,this.$onSelect=t.$onSelect,t.$showOn&&(this.$showOn=t.$showOn)}}class qn extends Kn{constructor(e){super("_separator"),this.type="separator",e&&e.$showOn&&(this.$showOn=e.$showOn)}}const jn=r((({className:e,disabled:t,...n},r)=>c("hr",{className:e}))),$n=r((({className:e,label:t,disabled:n,icon:r,...o},i)=>u("button",{...o,className:e,ref:i,role:"menuitem",disabled:n,children:[r,t]}))),_n=r((({items:t,className:r,itemClassName:u,separatorClassName:s},a)=>{const[p]=f(),[m,v]=o(null),[h,g]=o(!1),w=i([]),x=i([]),{refs:R,floatingStyles:E,context:k}=Mn({middleware:[(C={alignmentAxis:4,mainAxis:5},{...Et(C),options:[C,M]}),Nt({fallbackPlacements:["left-start"]}),Tt({padding:10})],onOpenChange:g,open:h,placement:"right-start",strategy:"fixed",whileElementsMounted:Rt});var C,M;const T=function(t,n){var r,o;void 0===n&&(n={});const{open:i,elements:l,floatingId:u}=t,{enabled:c=!0,role:s="dialog"}=n,a=_t(),f=(null==(r=l.domReference)?void 0:r.id)||a,d=e.useMemo((()=>{var e;return(null==(e=Ne(l.floating))?void 0:e.id)||u}),[l.floating,u]),p=null!=(o=Vn.get(s))?o:s,m=null!=Gt(),v=e.useMemo((()=>"tooltip"===p||"label"===s?{["aria-"+("label"===s?"labelledby":"describedby")]:i?d:void 0}:{"aria-expanded":i?"true":"false","aria-haspopup":"alertdialog"===p?"dialog":p,"aria-controls":i?d:void 0,..."listbox"===p&&{role:"combobox"},..."menu"===p&&{id:f},..."menu"===p&&m&&{role:"menuitem"},..."select"===s&&{"aria-autocomplete":"none"},..."combobox"===s&&{"aria-autocomplete":"list"}}),[p,d,m,i,f,s]),h=e.useMemo((()=>{const e={id:d,...p&&{role:p}};return"tooltip"===p||"label"===s?e:{...e,..."menu"===p&&{"aria-labelledby":f}}}),[p,d,f,s]),g=e.useCallback((e=>{let{active:t,selected:n}=e;const r={role:"option",...t&&{id:d+"-fui-option"}};switch(s){case"select":return{...r,"aria-selected":t&&n};case"combobox":return{...r,"aria-selected":n}}return{}}),[d,s]);return e.useMemo((()=>c?{reference:v,floating:h,item:g}:{}),[c,v,h,g])}(k,{role:"menu"}),N=function(t,n){void 0===n&&(n={});const{open:r,onOpenChange:o,elements:i,dataRef:l}=t,{enabled:u=!0,escapeKey:c=!0,outsidePress:s=!0,outsidePressEvent:a="pointerdown",referencePress:f=!1,referencePressEvent:d="pointerdown",ancestorScroll:p=!1,bubbles:m,capture:v}=n,h=Jt(),g=qe("function"==typeof s?s:()=>!1),w="function"==typeof s?g:s,x=e.useRef(!1),R=e.useRef(!1),{escapeKey:E,outsidePress:k}=Cn(m),{escapeKey:C,outsidePress:M}=Cn(v),T=e.useRef(!1),N=qe((e=>{var t;if(!r||!u||!c||"Escape"!==e.key)return;if(T.current)return;const n=null==(t=l.current.floatingContext)?void 0:t.nodeId,i=h?Pe(h.nodesRef.current,n):[];if(!E&&(e.stopPropagation(),i.length>0)){let e=!0;if(i.forEach((t=>{var n;null==(n=t.context)||!n.open||t.context.dataRef.current.__escapeKeyBubbles||(e=!1)})),!e)return}o(!1,function(e){return"nativeEvent"in e}(e)?e.nativeEvent:e,"escape-key")})),P=qe((e=>{var t;const n=()=>{var t;N(e),null==(t=Le(e))||t.removeEventListener("keydown",n)};null==(t=Le(e))||t.addEventListener("keydown",n)})),D=qe((e=>{var t;const n=x.current;x.current=!1;const r=R.current;if(R.current=!1,"click"===a&&r)return;if(n)return;if("function"==typeof w&&!w(e))return;const u=Le(e),c="["+Qt("inert")+"]",s=Oe(i.floating).querySelectorAll(c);let f=y(u)?u:null;for(;f&&!S(f);){const e=L(f);if(S(e)||!y(e))break;f=e}if(s.length&&y(u)&&!u.matches("html,body")&&!Ce(u,i.floating)&&Array.from(s).every((e=>!Ce(f,e))))return;if(b(u)&&B){const t=S(u),n=A(u),r=/auto|scroll/,o=t||r.test(n.overflowX),i=t||r.test(n.overflowY),l=o&&u.clientWidth>0&&u.scrollWidth>u.clientWidth,c=i&&u.clientHeight>0&&u.scrollHeight>u.clientHeight,s="rtl"===n.direction,a=c&&(s?e.offsetX<=u.offsetWidth-u.clientWidth:e.offsetX>u.clientWidth),f=l&&e.offsetY>u.clientHeight;if(a||f)return}const d=null==(t=l.current.floatingContext)?void 0:t.nodeId,p=h&&Pe(h.nodesRef.current,d).some((t=>{var n;return Me(e,null==(n=t.context)?void 0:n.elements.floating)}));if(Me(e,i.floating)||Me(e,i.domReference)||p)return;const m=h?Pe(h.nodesRef.current,d):[];if(m.length>0){let e=!0;if(m.forEach((t=>{var n;null==(n=t.context)||!n.open||t.context.dataRef.current.__outsidePressBubbles||(e=!1)})),!e)return}o(!1,e,"outside-press")})),F=qe((e=>{var t;const n=()=>{var t;D(e),null==(t=Le(e))||t.removeEventListener(a,n)};null==(t=Le(e))||t.addEventListener(a,n)}));e.useEffect((()=>{if(!r||!u)return;l.current.__escapeKeyBubbles=E,l.current.__outsidePressBubbles=k;let e=-1;function t(e){o(!1,e,"ancestor-scroll")}function n(){window.clearTimeout(e),T.current=!0}function s(){e=window.setTimeout((()=>{T.current=!1}),I()?5:0)}const f=Oe(i.floating);c&&(f.addEventListener("keydown",C?P:N,C),f.addEventListener("compositionstart",n),f.addEventListener("compositionend",s)),w&&f.addEventListener(a,M?F:D,M);let d=[];return p&&(y(i.domReference)&&(d=O(i.domReference)),y(i.floating)&&(d=d.concat(O(i.floating))),!y(i.reference)&&i.reference&&i.reference.contextElement&&(d=d.concat(O(i.reference.contextElement)))),d=d.filter((e=>{var t;return e!==(null==(t=f.defaultView)?void 0:t.visualViewport)})),d.forEach((e=>{e.addEventListener("scroll",t,{passive:!0})})),()=>{c&&(f.removeEventListener("keydown",C?P:N,C),f.removeEventListener("compositionstart",n),f.removeEventListener("compositionend",s)),w&&f.removeEventListener(a,M?F:D,M),d.forEach((e=>{e.removeEventListener("scroll",t)})),window.clearTimeout(e)}}),[l,i,c,w,a,r,o,p,u,E,k,N,C,P,D,M,F]),e.useEffect((()=>{x.current=!1}),[w,a]);const W=e.useMemo((()=>({onKeyDown:N,...f&&{[Sn[d]]:e=>{o(!1,e.nativeEvent,"reference-press")},..."click"!==d&&{onClick(e){o(!1,e.nativeEvent,"reference-press")}}}})),[N,o,f,d]),B=e.useMemo((()=>({onKeyDown:N,onMouseDown(){R.current=!0},onMouseUp(){R.current=!0},[An[a]]:()=>{x.current=!0}})),[N,a]);return e.useMemo((()=>u?{reference:W,floating:B}:{}),[u,W,B])}(k),P=Bn(k,{activeIndex:m,listRef:w,onNavigate:v}),D=function(t,n){var r;const{open:o,dataRef:i}=t,{listRef:l,activeIndex:u,onMatch:c,onTypingChange:s,enabled:a=!0,findMatch:f=null,resetMs:d=750,ignoreKeys:p=[],selectedIndex:m=null}=n,v=e.useRef(-1),h=e.useRef(""),g=e.useRef(null!=(r=null!=m?m:u)?r:-1),y=e.useRef(null),b=qe(c),w=qe(s),x=Ke(f),R=Ke(p);Ve((()=>{o&&(Zt(v),y.current=null,h.current="")}),[o]),Ve((()=>{var e;o&&""===h.current&&(g.current=null!=(e=null!=m?m:u)?e:-1)}),[o,m,u]);const E=qe((e=>{e?i.current.typing||(i.current.typing=e,w(e)):i.current.typing&&(i.current.typing=e,w(e))})),k=qe((e=>{function t(e,t,n){const r=x.current?x.current(t,n):t.find((e=>0===(null==e?void 0:e.toLocaleLowerCase().indexOf(n.toLocaleLowerCase()))));return r?e.indexOf(r):-1}const n=l.current;if(h.current.length>0&&" "!==h.current[0]&&(-1===t(n,n,h.current)?E(!1):" "===e.key&&Fe(e)),null==n||R.current.includes(e.key)||1!==e.key.length||e.ctrlKey||e.metaKey||e.altKey)return;o&&" "!==e.key&&(Fe(e),E(!0)),n.every((e=>{var t,n;return!e||(null==(t=e[0])?void 0:t.toLocaleLowerCase())!==(null==(n=e[1])?void 0:n.toLocaleLowerCase())}))&&h.current===e.key&&(h.current="",g.current=y.current),h.current+=e.key,Zt(v),v.current=window.setTimeout((()=>{h.current="",g.current=y.current,E(!1)}),d);const r=g.current,i=t(n,[...n.slice((r||0)+1),...n.slice(0,(r||0)+1)],h.current);-1!==i?(b(i),y.current=i):" "!==e.key&&(h.current="",E(!1))})),I=e.useMemo((()=>({onKeyDown:k})),[k]),S=e.useMemo((()=>({onKeyDown:k,onKeyUp(e){" "===e.key&&E(!1)}})),[k,E]);return e.useMemo((()=>a?{reference:I,floating:S}:{}),[a,I,S])}(k,{activeIndex:m,enabled:h,listRef:x,onMatch:v}),{getFloatingProps:F,getItemProps:W}=function(t){void 0===t&&(t=[]);const n=t.map((e=>null==e?void 0:e.reference)),r=t.map((e=>null==e?void 0:e.floating)),o=t.map((e=>null==e?void 0:e.item)),i=e.useCallback((e=>On(e,t,"reference")),n),l=e.useCallback((e=>On(e,t,"floating")),r),u=e.useCallback((e=>On(e,t,"item")),o);return e.useMemo((()=>({getReferenceProps:i,getFloatingProps:l,getItemProps:u})),[i,l,u])}([T,N,P,D]),[B,V]=o([]);return n((()=>{function e(e){e.preventDefault(),R.setPositionReference({getBoundingClientRect:()=>({bottom:e.clientY,height:0,left:e.clientX,right:e.clientX,top:e.clientY,width:0,x:e.clientX,y:e.clientY})});let n=[];t&&p.read((()=>{const r=d(e.target);r&&(n=t.filter((e=>!e.$showOn||e.$showOn(r))))}));const r=n.map(((e,t)=>"separator"===e.type?{className:s,key:e.key+"-"+t,type:e.type}:{className:u,disabled:e.disabled,icon:e.icon,key:e.key,label:e.title,onClick:()=>p.update((()=>e.$onSelect())),title:e.title,type:e.type}));x.current=r.map((e=>e.key)),V(r),g(!0)}return p.registerRootListener(((t,n)=>{null!==n&&n.removeEventListener("contextmenu",e),null!==t&&t.addEventListener("contextmenu",e)}))}),[t,u,s,R,p]),c(mn,{children:h&&c(In,{lockScroll:!0,children:c(Rn,{context:k,initialFocus:R.floating,children:c("div",{className:r,ref:R.setFloating,style:E,...F(),children:B.map(((e,t)=>"item"===e.type?l($n,{...W({...e,onClick(){e.onClick(),g(!1)},onMouseUp(){e.onClick(),g(!1)},ref(e){w.current[t]=e},tabIndex:m===t?0:-1}),key:e.key}):"separator"===e.type?l(jn,{...W({...e,ref(e){w.current[t]=e},tabIndex:m===t?0:-1}),key:e.key}):void 0))})})})})}));export{Hn as NodeContextMenuOption,_n as NodeContextMenuPlugin,qn as NodeContextMenuSeparator};
|
|
9
|
+
import{useFloating as e,offset as t,flip as n,shift as s,autoUpdate as i,useRole as l,useDismiss as o,useListNavigation as r,useTypeahead as a,useInteractions as c,FloatingPortal as m,FloatingOverlay as d,FloatingFocusManager as h}from"@floating-ui/react";import{useLexicalComposerContext as p}from"@lexical/react/LexicalComposerContext";import{$getNearestNodeFromDOMNode as u}from"lexical";import{forwardRef as f,useState as y,useRef as x,useEffect as g,createElement as b}from"react";import{jsx as k,jsxs as w}from"react/jsx-runtime";class N{constructor(e){this.key=e,this.ref={current:null},this.setRefElement=this.setRefElement.bind(this)}setRefElement(e){this.ref={current:e}}}class $ extends N{constructor(e,t){super(e),this.type="item",this.title=e,this.disabled=t.disabled??!1,this.icon=t.icon??null,this.$onSelect=t.$onSelect,t.$showOn&&(this.$showOn=t.$showOn)}}class C extends N{constructor(e){super("_separator"),this.type="separator",e&&e.$showOn&&(this.$showOn=e.$showOn)}}const v=f((({className:e,disabled:t,...n},s)=>k("hr",{className:e}))),O=f((({className:e,label:t,disabled:n,icon:s,...i},l)=>w("button",{...i,className:e,ref:l,role:"menuitem",disabled:n,children:[s,t]}))),R=f((({items:f,className:w,itemClassName:N,separatorClassName:$},C)=>{const[R]=p(),[E,I]=y(null),[S,L]=y(!1),P=x([]),F=x([]),{refs:M,floatingStyles:X,context:Y}=e({middleware:[t({alignmentAxis:4,mainAxis:5}),n({fallbackPlacements:["left-start"]}),s({padding:10})],onOpenChange:L,open:S,placement:"right-start",strategy:"fixed",whileElementsMounted:i}),A=l(Y,{role:"menu"}),j=o(Y),B=r(Y,{activeIndex:E,listRef:P,onNavigate:I}),D=a(Y,{activeIndex:E,enabled:S,listRef:F,onMatch:I}),{getFloatingProps:U,getItemProps:_}=c([A,j,B,D]),[q,z]=y([]);return g((()=>{function e(e){e.preventDefault(),M.setPositionReference({getBoundingClientRect:()=>({bottom:e.clientY,height:0,left:e.clientX,right:e.clientX,top:e.clientY,width:0,x:e.clientX,y:e.clientY})});let t=[];f&&R.read((()=>{const n=u(e.target);n&&(t=f.filter((e=>!e.$showOn||e.$showOn(n))))}));const n=t.map(((e,t)=>"separator"===e.type?{className:$,key:e.key+"-"+t,type:e.type}:{className:N,disabled:e.disabled,icon:e.icon,key:e.key,label:e.title,onClick:()=>R.update((()=>e.$onSelect())),title:e.title,type:e.type}));F.current=n.map((e=>e.key)),z(n),L(!0)}return R.registerRootListener(((t,n)=>{null!==n&&n.removeEventListener("contextmenu",e),null!==t&&t.addEventListener("contextmenu",e)}))}),[f,N,$,M,R]),k(m,{children:S&&k(d,{lockScroll:!0,children:k(h,{context:Y,initialFocus:M.floating,children:k("div",{className:w,ref:M.setFloating,style:X,...U(),children:q.map(((e,t)=>"item"===e.type?b(O,{..._({...e,onClick(){e.onClick(),L(!1)},onMouseUp(){e.onClick(),L(!1)},ref(e){P.current[t]=e},tabIndex:E===t?0:-1}),key:e.key}):"separator"===e.type?b(v,{..._({...e,ref(e){P.current[t]=e},tabIndex:E===t?0:-1}),key:e.key}):void 0))})})})})}));export{$ as NodeContextMenuOption,R as NodeContextMenuPlugin,C as NodeContextMenuSeparator};
|
|
@@ -172,7 +172,8 @@ function getScrollParent(element, includeHidden) {
|
|
|
172
172
|
function isTriggerVisibleInNearestScrollContainer(targetElement, containerElement) {
|
|
173
173
|
const tRect = targetElement.getBoundingClientRect();
|
|
174
174
|
const cRect = containerElement.getBoundingClientRect();
|
|
175
|
-
|
|
175
|
+
const VISIBILITY_MARGIN_PX = 6;
|
|
176
|
+
return tRect.top >= cRect.top - VISIBILITY_MARGIN_PX && tRect.top <= cRect.bottom + VISIBILITY_MARGIN_PX;
|
|
176
177
|
}
|
|
177
178
|
|
|
178
179
|
// Reposition the menu on scroll, window resize, and element resize.
|
|
@@ -170,7 +170,8 @@ function getScrollParent(element, includeHidden) {
|
|
|
170
170
|
function isTriggerVisibleInNearestScrollContainer(targetElement, containerElement) {
|
|
171
171
|
const tRect = targetElement.getBoundingClientRect();
|
|
172
172
|
const cRect = containerElement.getBoundingClientRect();
|
|
173
|
-
|
|
173
|
+
const VISIBILITY_MARGIN_PX = 6;
|
|
174
|
+
return tRect.top >= cRect.top - VISIBILITY_MARGIN_PX && tRect.top <= cRect.bottom + VISIBILITY_MARGIN_PX;
|
|
174
175
|
}
|
|
175
176
|
|
|
176
177
|
// Reposition the menu on scroll, window resize, and element resize.
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
"use strict";var e=require("@lexical/react/LexicalComposerContext"),t=require("lexical"),n=require("react"),l=require("@lexical/utils"),o=require("react/jsx-runtime");const r="startTransition";const i="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,u=i?n.useLayoutEffect:n.useEffect;const s=e=>{const t=document.getElementById("typeahead-menu");if(!t)return;const n=t.getBoundingClientRect();n.top+n.height>window.innerHeight&&t.scrollIntoView({block:"center"}),n.top<0&&t.scrollIntoView({block:"center"}),e.scrollIntoView({block:"nearest"})};function c(e,t){const n=e.getBoundingClientRect(),l=t.getBoundingClientRect();return n.top
|
|
9
|
+
"use strict";var e=require("@lexical/react/LexicalComposerContext"),t=require("lexical"),n=require("react"),l=require("@lexical/utils"),o=require("react/jsx-runtime");const r="startTransition";const i="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,u=i?n.useLayoutEffect:n.useEffect;const s=e=>{const t=document.getElementById("typeahead-menu");if(!t)return;const n=t.getBoundingClientRect();n.top+n.height>window.innerHeight&&t.scrollIntoView({block:"center"}),n.top<0&&t.scrollIntoView({block:"center"}),e.scrollIntoView({block:"nearest"})};function c(e,t){const n=e.getBoundingClientRect(),l=t.getBoundingClientRect();return n.top>=l.top-6&&n.top<=l.bottom+6}function a(t,l,o,r){const[i]=e.useLexicalComposerContext();n.useEffect((()=>{if(null!=l&&null!=t){const e=i.getRootElement(),t=null!=e?function(e,t){let n=getComputedStyle(e);const l="absolute"===n.position,o=/(auto|scroll)/;if("fixed"===n.position)return document.body;for(let t=e;t=t.parentElement;)if(n=getComputedStyle(t),(!l||"static"!==n.position)&&o.test(n.overflow+n.overflowY+n.overflowX))return t;return document.body}(e):document.body;let n=!1,u=c(l,t);const s=function(){n||(window.requestAnimationFrame((function(){o(),n=!1})),n=!0);const e=c(l,t);e!==u&&(u=e,null!=r&&r(e))},a=new ResizeObserver(o);return window.addEventListener("resize",o),document.addEventListener("scroll",s,{capture:!0,passive:!0}),a.observe(l),()=>{a.unobserve(l),window.removeEventListener("resize",o),document.removeEventListener("scroll",s,!0)}}}),[l,i,r,o,t])}const d=t.createCommand("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function m({close:e,editor:o,anchorElementRef:r,resolution:i,options:c,menuRenderFn:a,onSelectOption:m,shouldSplitNodeWithQuery:f=!1,commandPriority:p=t.COMMAND_PRIORITY_LOW,preselectFirstItem:g=!0}){const[h,C]=n.useState(null),E=i.match&&i.match.matchingString;n.useEffect((()=>{g&&C(0)}),[E,g]);const y=n.useCallback((n=>{o.update((()=>{const l=null!=i.match&&f?function(e){const n=t.$getSelection();if(!t.$isRangeSelection(n)||!n.isCollapsed())return null;const l=n.anchor;if("text"!==l.type)return null;const o=l.getNode();if(!o.isSimpleText())return null;const r=l.offset,i=o.getTextContent().slice(0,r),u=e.replaceableString.length,s=r-function(e,t,n){let l=n;for(let n=l;n<=t.length;n++)e.slice(-n)===t.substring(0,n)&&(l=n);return l}(i,e.matchingString,u);if(s<0)return null;let c;return 0===s?[c]=o.splitText(r):[,c]=o.splitText(s,r),c}(i.match):null;m(n,l,e,i.match?i.match.matchingString:"")}))}),[o,f,i.match,m,e]),b=n.useCallback((e=>{const t=o.getRootElement();null!==t&&(t.setAttribute("aria-activedescendant","typeahead-item-"+e),C(e))}),[o]);n.useEffect((()=>()=>{const e=o.getRootElement();null!==e&&e.removeAttribute("aria-activedescendant")}),[o]),u((()=>{null===c?C(null):null===h&&g&&b(0)}),[c,h,b,g]),n.useEffect((()=>l.mergeRegister(o.registerCommand(d,(({option:e})=>!(!e.ref||null==e.ref.current)&&(s(e.ref.current),!0)),p))),[o,b,p]),n.useEffect((()=>l.mergeRegister(o.registerCommand(t.KEY_ARROW_DOWN_COMMAND,(e=>{const t=e;if(null!==c&&c.length){const e=null===h?0:h!==c.length-1?h+1:0;b(e);const n=c[e];null!=n.ref&&n.ref.current&&o.dispatchCommand(d,{index:e,option:n}),t.preventDefault(),t.stopImmediatePropagation()}return!0}),p),o.registerCommand(t.KEY_ARROW_UP_COMMAND,(e=>{const t=e;if(null!==c&&c.length){const e=null===h?c.length-1:0!==h?h-1:c.length-1;b(e);const n=c[e];null!=n.ref&&n.ref.current&&s(n.ref.current),t.preventDefault(),t.stopImmediatePropagation()}return!0}),p),o.registerCommand(t.KEY_ESCAPE_COMMAND,(t=>{const n=t;return n.preventDefault(),n.stopImmediatePropagation(),e(),!0}),p),o.registerCommand(t.KEY_TAB_COMMAND,(e=>{const t=e;return null!==c&&null!==h&&null!=c[h]&&(t.preventDefault(),t.stopImmediatePropagation(),y(c[h]),!0)}),p),o.registerCommand(t.KEY_ENTER_COMMAND,(e=>null!==c&&null!==h&&null!=c[h]&&(null!==e&&(e.preventDefault(),e.stopImmediatePropagation()),y(c[h]),!0)),p))),[y,e,o,c,h,b,p]);return a(r,n.useMemo((()=>({options:c,selectOptionAndCleanUp:y,selectedIndex:h,setHighlightedIndex:C})),[y,h,c]),i.match?i.match.matchingString:"")}function f(e,t){null!=t&&(e.className=t),e.setAttribute("aria-label","Typeahead menu"),e.setAttribute("role","listbox"),e.style.display="block",e.style.position="absolute"}exports.LexicalNodeMenuPlugin=function({options:l,nodeKey:u,onClose:s,onOpen:c,onSelectOption:d,menuRenderFn:p,anchorClassName:g,commandPriority:h=t.COMMAND_PRIORITY_LOW,parent:C}){const[E]=e.useLexicalComposerContext(),[y,b]=n.useState(null),R=function(t,l,o,r=(i?document.body:void 0),u=!0){const[s]=e.useLexicalComposerContext(),c=i?document.createElement("div"):null,d=n.useRef(c),m=n.useCallback((()=>{if(null===d.current||void 0===r)return;d.current.style.top=d.current.style.bottom;const e=s.getRootElement(),n=d.current,l=n.firstChild;if(null!==e&&null!==t){const{left:i,top:s,width:c,height:a}=t.getRect(),m=d.current.offsetHeight;if(n.style.top=`${s+m+3+(u?window.pageYOffset:0)}px`,n.style.left=`${i+window.pageXOffset}px`,n.style.height=`${a}px`,n.style.width=`${c}px`,null!==l){l.style.top=`${s}`;const t=l.getBoundingClientRect(),o=t.height,r=t.width,c=e.getBoundingClientRect();i+r>c.right&&(n.style.left=`${c.right-r+window.pageXOffset}px`),(s+o>window.innerHeight||s+o>c.bottom)&&s-c.top>o+a&&(n.style.top=`${s-o-a+(u?window.pageYOffset:0)}px`)}n.isConnected||(f(n,o),r.append(n)),n.setAttribute("id","typeahead-menu"),e.setAttribute("aria-controls","typeahead-menu")}}),[s,t,u,o,r]);n.useEffect((()=>{const e=s.getRootElement();return null!==t&&m(),()=>{null!==e&&e.removeAttribute("aria-controls");const t=d.current;null!==t&&t.isConnected&&(t.remove(),t.removeAttribute("id"))}}),[s,m,t]);const p=n.useCallback((e=>{null!==t&&(e||l(null))}),[t,l]);return a(t,d.current,m,p),null!=c&&c===d.current&&(f(c,o),null!=r&&r.append(c)),d}(y,b,g,C),w=n.useCallback((()=>{b(null),null!=s&&null!==y&&s()}),[s,y]),x=n.useCallback((e=>{b(e),null!=c&&null===y&&c(e)}),[c,y]),v=n.useCallback((()=>{u?E.update((()=>{const e=t.$getNodeByKey(u),l=E.getElementByKey(u);var o;null!=e&&null!=l&&null==y&&(o=()=>x({getRect:()=>l.getBoundingClientRect()}),r in n?n[r](o):o())})):null==u&&null!=y&&w()}),[w,E,u,x,y]);return n.useEffect((()=>{v()}),[v,u]),n.useEffect((()=>{if(null!=u)return E.registerUpdateListener((({dirtyElements:e})=>{e.get(u)&&v()}))}),[E,v,u]),null===R.current||null===y||null===E?null:o.jsx(m,{close:w,resolution:y,editor:E,anchorElementRef:R,options:l,menuRenderFn:p,onSelectOption:d,commandPriority:h})},exports.MenuOption=class{constructor(e){this.key=e,this.ref={current:null},this.setRefElement=this.setRefElement.bind(this)}setRefElement(e){this.ref={current:e}}};
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import{useLexicalComposerContext as t}from"@lexical/react/LexicalComposerContext";import{createCommand as e,KEY_ARROW_DOWN_COMMAND as n,KEY_ARROW_UP_COMMAND as o,KEY_ESCAPE_COMMAND as l,KEY_TAB_COMMAND as r,KEY_ENTER_COMMAND as i,COMMAND_PRIORITY_LOW as u,$getSelection as s,$isRangeSelection as c,$getNodeByKey as a}from"lexical";import m,{useLayoutEffect as d,useEffect as p,useState as f,useCallback as g,useMemo as h,useRef as y}from"react";import{mergeRegister as w}from"@lexical/utils";import{jsx as v}from"react/jsx-runtime";const b="startTransition";const C="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,x=C?d:p;class E{constructor(t){this.key=t,this.ref={current:null},this.setRefElement=this.setRefElement.bind(this)}setRefElement(t){this.ref={current:t}}}const R=t=>{const e=document.getElementById("typeahead-menu");if(!e)return;const n=e.getBoundingClientRect();n.top+n.height>window.innerHeight&&e.scrollIntoView({block:"center"}),n.top<0&&e.scrollIntoView({block:"center"}),t.scrollIntoView({block:"nearest"})};function I(t,e){const n=t.getBoundingClientRect(),o=e.getBoundingClientRect();return n.top
|
|
9
|
+
import{useLexicalComposerContext as t}from"@lexical/react/LexicalComposerContext";import{createCommand as e,KEY_ARROW_DOWN_COMMAND as n,KEY_ARROW_UP_COMMAND as o,KEY_ESCAPE_COMMAND as l,KEY_TAB_COMMAND as r,KEY_ENTER_COMMAND as i,COMMAND_PRIORITY_LOW as u,$getSelection as s,$isRangeSelection as c,$getNodeByKey as a}from"lexical";import m,{useLayoutEffect as d,useEffect as p,useState as f,useCallback as g,useMemo as h,useRef as y}from"react";import{mergeRegister as w}from"@lexical/utils";import{jsx as v}from"react/jsx-runtime";const b="startTransition";const C="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,x=C?d:p;class E{constructor(t){this.key=t,this.ref={current:null},this.setRefElement=this.setRefElement.bind(this)}setRefElement(t){this.ref={current:t}}}const R=t=>{const e=document.getElementById("typeahead-menu");if(!e)return;const n=e.getBoundingClientRect();n.top+n.height>window.innerHeight&&e.scrollIntoView({block:"center"}),n.top<0&&e.scrollIntoView({block:"center"}),t.scrollIntoView({block:"nearest"})};function I(t,e){const n=t.getBoundingClientRect(),o=e.getBoundingClientRect();return n.top>=o.top-6&&n.top<=o.bottom+6}function O(e,n,o,l){const[r]=t();p((()=>{if(null!=n&&null!=e){const t=r.getRootElement(),e=null!=t?function(t,e){let n=getComputedStyle(t);const o="absolute"===n.position,l=/(auto|scroll)/;if("fixed"===n.position)return document.body;for(let e=t;e=e.parentElement;)if(n=getComputedStyle(e),(!o||"static"!==n.position)&&l.test(n.overflow+n.overflowY+n.overflowX))return e;return document.body}(t):document.body;let i=!1,u=I(n,e);const s=function(){i||(window.requestAnimationFrame((function(){o(),i=!1})),i=!0);const t=I(n,e);t!==u&&(u=t,null!=l&&l(t))},c=new ResizeObserver(o);return window.addEventListener("resize",o),document.addEventListener("scroll",s,{capture:!0,passive:!0}),c.observe(n),()=>{c.unobserve(n),window.removeEventListener("resize",o),document.removeEventListener("scroll",s,!0)}}}),[n,r,l,o,e])}const A=e("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function S({close:t,editor:e,anchorElementRef:a,resolution:m,options:d,menuRenderFn:y,onSelectOption:v,shouldSplitNodeWithQuery:b=!1,commandPriority:C=u,preselectFirstItem:E=!0}){const[I,O]=f(null),S=m.match&&m.match.matchingString;p((()=>{E&&O(0)}),[S,E]);const P=g((n=>{e.update((()=>{const e=null!=m.match&&b?function(t){const e=s();if(!c(e)||!e.isCollapsed())return null;const n=e.anchor;if("text"!==n.type)return null;const o=n.getNode();if(!o.isSimpleText())return null;const l=n.offset,r=o.getTextContent().slice(0,l),i=t.replaceableString.length,u=l-function(t,e,n){let o=n;for(let n=o;n<=e.length;n++)t.slice(-n)===e.substring(0,n)&&(o=n);return o}(r,t.matchingString,i);if(u<0)return null;let a;return 0===u?[a]=o.splitText(l):[,a]=o.splitText(u,l),a}(m.match):null;v(n,e,t,m.match?m.match.matchingString:"")}))}),[e,b,m.match,v,t]),T=g((t=>{const n=e.getRootElement();null!==n&&(n.setAttribute("aria-activedescendant","typeahead-item-"+t),O(t))}),[e]);p((()=>()=>{const t=e.getRootElement();null!==t&&t.removeAttribute("aria-activedescendant")}),[e]),x((()=>{null===d?O(null):null===I&&E&&T(0)}),[d,I,T,E]),p((()=>w(e.registerCommand(A,(({option:t})=>!(!t.ref||null==t.ref.current)&&(R(t.ref.current),!0)),C))),[e,T,C]),p((()=>w(e.registerCommand(n,(t=>{const n=t;if(null!==d&&d.length){const t=null===I?0:I!==d.length-1?I+1:0;T(t);const o=d[t];null!=o.ref&&o.ref.current&&e.dispatchCommand(A,{index:t,option:o}),n.preventDefault(),n.stopImmediatePropagation()}return!0}),C),e.registerCommand(o,(t=>{const e=t;if(null!==d&&d.length){const t=null===I?d.length-1:0!==I?I-1:d.length-1;T(t);const n=d[t];null!=n.ref&&n.ref.current&&R(n.ref.current),e.preventDefault(),e.stopImmediatePropagation()}return!0}),C),e.registerCommand(l,(e=>{const n=e;return n.preventDefault(),n.stopImmediatePropagation(),t(),!0}),C),e.registerCommand(r,(t=>{const e=t;return null!==d&&null!==I&&null!=d[I]&&(e.preventDefault(),e.stopImmediatePropagation(),P(d[I]),!0)}),C),e.registerCommand(i,(t=>null!==d&&null!==I&&null!=d[I]&&(null!==t&&(t.preventDefault(),t.stopImmediatePropagation()),P(d[I]),!0)),C))),[P,t,e,d,I,T,C]);return y(a,h((()=>({options:d,selectOptionAndCleanUp:P,selectedIndex:I,setHighlightedIndex:O})),[P,I,d]),m.match?m.match.matchingString:"")}function P(t,e){null!=e&&(t.className=e),t.setAttribute("aria-label","Typeahead menu"),t.setAttribute("role","listbox"),t.style.display="block",t.style.position="absolute"}function T({options:e,nodeKey:n,onClose:o,onOpen:l,onSelectOption:r,menuRenderFn:i,anchorClassName:s,commandPriority:c=u,parent:d}){const[h]=t(),[w,x]=f(null),E=function(e,n,o,l=(C?document.body:void 0),r=!0){const[i]=t(),u=C?document.createElement("div"):null,s=y(u),c=g((()=>{if(null===s.current||void 0===l)return;s.current.style.top=s.current.style.bottom;const t=i.getRootElement(),n=s.current,u=n.firstChild;if(null!==t&&null!==e){const{left:i,top:c,width:a,height:m}=e.getRect(),d=s.current.offsetHeight;if(n.style.top=`${c+d+3+(r?window.pageYOffset:0)}px`,n.style.left=`${i+window.pageXOffset}px`,n.style.height=`${m}px`,n.style.width=`${a}px`,null!==u){u.style.top=`${c}`;const e=u.getBoundingClientRect(),o=e.height,l=e.width,s=t.getBoundingClientRect();i+l>s.right&&(n.style.left=`${s.right-l+window.pageXOffset}px`),(c+o>window.innerHeight||c+o>s.bottom)&&c-s.top>o+m&&(n.style.top=`${c-o-m+(r?window.pageYOffset:0)}px`)}n.isConnected||(P(n,o),l.append(n)),n.setAttribute("id","typeahead-menu"),t.setAttribute("aria-controls","typeahead-menu")}}),[i,e,r,o,l]);p((()=>{const t=i.getRootElement();return null!==e&&c(),()=>{null!==t&&t.removeAttribute("aria-controls");const e=s.current;null!==e&&e.isConnected&&(e.remove(),e.removeAttribute("id"))}}),[i,c,e]);const a=g((t=>{null!==e&&(t||n(null))}),[e,n]);return O(e,s.current,c,a),null!=u&&u===s.current&&(P(u,o),null!=l&&l.append(u)),s}(w,x,s,d),R=g((()=>{x(null),null!=o&&null!==w&&o()}),[o,w]),I=g((t=>{x(t),null!=l&&null===w&&l(t)}),[l,w]),A=g((()=>{n?h.update((()=>{const t=a(n),e=h.getElementByKey(n);var o;null!=t&&null!=e&&null==w&&(o=()=>I({getRect:()=>e.getBoundingClientRect()}),b in m?m[b](o):o())})):null==n&&null!=w&&R()}),[R,h,n,I,w]);return p((()=>{A()}),[A,n]),p((()=>{if(null!=n)return h.registerUpdateListener((({dirtyElements:t})=>{t.get(n)&&A()}))}),[h,A,n]),null===E.current||null===w||null===h?null:v(S,{close:R,resolution:w,editor:h,anchorElementRef:E,options:e,menuRenderFn:i,onSelectOption:r,commandPriority:c})}export{T as LexicalNodeMenuPlugin,E as MenuOption};
|
|
@@ -172,7 +172,8 @@ function getScrollParent$1(element, includeHidden) {
|
|
|
172
172
|
function isTriggerVisibleInNearestScrollContainer(targetElement, containerElement) {
|
|
173
173
|
const tRect = targetElement.getBoundingClientRect();
|
|
174
174
|
const cRect = containerElement.getBoundingClientRect();
|
|
175
|
-
|
|
175
|
+
const VISIBILITY_MARGIN_PX = 6;
|
|
176
|
+
return tRect.top >= cRect.top - VISIBILITY_MARGIN_PX && tRect.top <= cRect.bottom + VISIBILITY_MARGIN_PX;
|
|
176
177
|
}
|
|
177
178
|
|
|
178
179
|
// Reposition the menu on scroll, window resize, and element resize.
|
|
@@ -170,7 +170,8 @@ function getScrollParent$1(element, includeHidden) {
|
|
|
170
170
|
function isTriggerVisibleInNearestScrollContainer(targetElement, containerElement) {
|
|
171
171
|
const tRect = targetElement.getBoundingClientRect();
|
|
172
172
|
const cRect = containerElement.getBoundingClientRect();
|
|
173
|
-
|
|
173
|
+
const VISIBILITY_MARGIN_PX = 6;
|
|
174
|
+
return tRect.top >= cRect.top - VISIBILITY_MARGIN_PX && tRect.top <= cRect.bottom + VISIBILITY_MARGIN_PX;
|
|
174
175
|
}
|
|
175
176
|
|
|
176
177
|
// Reposition the menu on scroll, window resize, and element resize.
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
"use strict";var e=require("@lexical/react/LexicalComposerContext"),t=require("lexical"),n=require("react"),o=require("@lexical/utils"),l=require("react/jsx-runtime");const r="startTransition";const i="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,s=i?n.useLayoutEffect:n.useEffect;const u=e=>{const t=document.getElementById("typeahead-menu");if(!t)return;const n=t.getBoundingClientRect();n.top+n.height>window.innerHeight&&t.scrollIntoView({block:"center"}),n.top<0&&t.scrollIntoView({block:"center"}),e.scrollIntoView({block:"nearest"})};function c(e,t){const n=e.getBoundingClientRect(),o=t.getBoundingClientRect();return n.top
|
|
9
|
+
"use strict";var e=require("@lexical/react/LexicalComposerContext"),t=require("lexical"),n=require("react"),o=require("@lexical/utils"),l=require("react/jsx-runtime");const r="startTransition";const i="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,s=i?n.useLayoutEffect:n.useEffect;const u=e=>{const t=document.getElementById("typeahead-menu");if(!t)return;const n=t.getBoundingClientRect();n.top+n.height>window.innerHeight&&t.scrollIntoView({block:"center"}),n.top<0&&t.scrollIntoView({block:"center"}),e.scrollIntoView({block:"nearest"})};function c(e,t){const n=e.getBoundingClientRect(),o=t.getBoundingClientRect();return n.top>=o.top-6&&n.top<=o.bottom+6}function a(t,o,l,r){const[i]=e.useLexicalComposerContext();n.useEffect((()=>{if(null!=o&&null!=t){const e=i.getRootElement(),t=null!=e?function(e,t){let n=getComputedStyle(e);const o="absolute"===n.position,l=/(auto|scroll)/;if("fixed"===n.position)return document.body;for(let t=e;t=t.parentElement;)if(n=getComputedStyle(t),(!o||"static"!==n.position)&&l.test(n.overflow+n.overflowY+n.overflowX))return t;return document.body}(e):document.body;let n=!1,s=c(o,t);const u=function(){n||(window.requestAnimationFrame((function(){l(),n=!1})),n=!0);const e=c(o,t);e!==s&&(s=e,null!=r&&r(e))},a=new ResizeObserver(l);return window.addEventListener("resize",l),document.addEventListener("scroll",u,{capture:!0,passive:!0}),a.observe(o),()=>{a.unobserve(o),window.removeEventListener("resize",l),document.removeEventListener("scroll",u,!0)}}}),[o,i,r,l,t])}const d=t.createCommand("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function f({close:e,editor:l,anchorElementRef:r,resolution:i,options:c,menuRenderFn:a,onSelectOption:f,shouldSplitNodeWithQuery:m=!1,commandPriority:g=t.COMMAND_PRIORITY_LOW,preselectFirstItem:p=!0}){const[h,C]=n.useState(null),E=i.match&&i.match.matchingString;n.useEffect((()=>{p&&C(0)}),[E,p]);const x=n.useCallback((n=>{l.update((()=>{const o=null!=i.match&&m?function(e){const n=t.$getSelection();if(!t.$isRangeSelection(n)||!n.isCollapsed())return null;const o=n.anchor;if("text"!==o.type)return null;const l=o.getNode();if(!l.isSimpleText())return null;const r=o.offset,i=l.getTextContent().slice(0,r),s=e.replaceableString.length,u=r-function(e,t,n){let o=n;for(let n=o;n<=t.length;n++)e.slice(-n)===t.substring(0,n)&&(o=n);return o}(i,e.matchingString,s);if(u<0)return null;let c;return 0===u?[c]=l.splitText(r):[,c]=l.splitText(u,r),c}(i.match):null;f(n,o,e,i.match?i.match.matchingString:"")}))}),[l,m,i.match,f,e]),y=n.useCallback((e=>{const t=l.getRootElement();null!==t&&(t.setAttribute("aria-activedescendant","typeahead-item-"+e),C(e))}),[l]);n.useEffect((()=>()=>{const e=l.getRootElement();null!==e&&e.removeAttribute("aria-activedescendant")}),[l]),s((()=>{null===c?C(null):null===h&&p&&y(0)}),[c,h,y,p]),n.useEffect((()=>o.mergeRegister(l.registerCommand(d,(({option:e})=>!(!e.ref||null==e.ref.current)&&(u(e.ref.current),!0)),g))),[l,y,g]),n.useEffect((()=>o.mergeRegister(l.registerCommand(t.KEY_ARROW_DOWN_COMMAND,(e=>{const t=e;if(null!==c&&c.length){const e=null===h?0:h!==c.length-1?h+1:0;y(e);const n=c[e];null!=n.ref&&n.ref.current&&l.dispatchCommand(d,{index:e,option:n}),t.preventDefault(),t.stopImmediatePropagation()}return!0}),g),l.registerCommand(t.KEY_ARROW_UP_COMMAND,(e=>{const t=e;if(null!==c&&c.length){const e=null===h?c.length-1:0!==h?h-1:c.length-1;y(e);const n=c[e];null!=n.ref&&n.ref.current&&u(n.ref.current),t.preventDefault(),t.stopImmediatePropagation()}return!0}),g),l.registerCommand(t.KEY_ESCAPE_COMMAND,(t=>{const n=t;return n.preventDefault(),n.stopImmediatePropagation(),e(),!0}),g),l.registerCommand(t.KEY_TAB_COMMAND,(e=>{const t=e;return null!==c&&null!==h&&null!=c[h]&&(t.preventDefault(),t.stopImmediatePropagation(),x(c[h]),!0)}),g),l.registerCommand(t.KEY_ENTER_COMMAND,(e=>null!==c&&null!==h&&null!=c[h]&&(null!==e&&(e.preventDefault(),e.stopImmediatePropagation()),x(c[h]),!0)),g))),[x,e,l,c,h,y,g]);return a(r,n.useMemo((()=>({options:c,selectOptionAndCleanUp:x,selectedIndex:h,setHighlightedIndex:C})),[x,h,c]),i.match?i.match.matchingString:"")}function m(e,t){null!=t&&(e.className=t),e.setAttribute("aria-label","Typeahead menu"),e.setAttribute("role","listbox"),e.style.display="block",e.style.position="absolute"}const g="\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'\"~=<>_:;";const p=t.createCommand("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");exports.LexicalTypeaheadMenuPlugin=function({options:o,onQueryChange:s,onSelectOption:u,onOpen:c,onClose:d,menuRenderFn:g,triggerFn:p,anchorClassName:h,commandPriority:C=t.COMMAND_PRIORITY_LOW,parent:E,preselectFirstItem:x=!0,ignoreEntityBoundary:y=!1}){const[O]=e.useLexicalComposerContext(),[b,w]=n.useState(null),R=function(t,o,l,r=(i?document.body:void 0),s=!0){const[u]=e.useLexicalComposerContext(),c=i?document.createElement("div"):null,d=n.useRef(c),f=n.useCallback((()=>{if(null===d.current||void 0===r)return;d.current.style.top=d.current.style.bottom;const e=u.getRootElement(),n=d.current,o=n.firstChild;if(null!==e&&null!==t){const{left:i,top:u,width:c,height:a}=t.getRect(),f=d.current.offsetHeight;if(n.style.top=`${u+f+3+(s?window.pageYOffset:0)}px`,n.style.left=`${i+window.pageXOffset}px`,n.style.height=`${a}px`,n.style.width=`${c}px`,null!==o){o.style.top=`${u}`;const t=o.getBoundingClientRect(),l=t.height,r=t.width,c=e.getBoundingClientRect();i+r>c.right&&(n.style.left=`${c.right-r+window.pageXOffset}px`),(u+l>window.innerHeight||u+l>c.bottom)&&u-c.top>l+a&&(n.style.top=`${u-l-a+(s?window.pageYOffset:0)}px`)}n.isConnected||(m(n,l),r.append(n)),n.setAttribute("id","typeahead-menu"),e.setAttribute("aria-controls","typeahead-menu")}}),[u,t,s,l,r]);n.useEffect((()=>{const e=u.getRootElement();return null!==t&&f(),()=>{null!==e&&e.removeAttribute("aria-controls");const t=d.current;null!==t&&t.isConnected&&(t.remove(),t.removeAttribute("id"))}}),[u,f,t]);const g=n.useCallback((e=>{null!==t&&(e||o(null))}),[t,o]);return a(t,d.current,f,g),null!=c&&c===d.current&&(m(c,l),null!=r&&r.append(c)),d}(b,w,h,E),S=n.useCallback((()=>{w(null),null!=d&&null!==b&&d()}),[d,b]),v=n.useCallback((e=>{w(e),null!=c&&null===b&&c(e)}),[c,b]);return n.useEffect((()=>{const e=O.registerUpdateListener((()=>{O.getEditorState().read((()=>{if(!O.isEditable())return void S();const e=O._window||window,o=e.document.createRange(),l=t.$getSelection(),i=function(e){let n=null;return e.getEditorState().read((()=>{const e=t.$getSelection();t.$isRangeSelection(e)&&(n=function(e){const t=e.anchor;if("text"!==t.type)return null;const n=t.getNode();if(!n.isSimpleText())return null;const o=t.offset;return n.getTextContent().slice(0,o)}(e))})),n}(O);if(!t.$isRangeSelection(l)||!l.isCollapsed()||null===i||null===o)return void S();const u=p(i,O);if(s(u?u.matchingString:null),null!==u&&(y||!function(e,n){return 0===n&&e.getEditorState().read((()=>{const e=t.$getSelection();if(t.$isRangeSelection(e)){const n=e.anchor.getNode().getPreviousSibling();return t.$isTextNode(n)&&n.isTextEntity()}return!1}))}(O,u.leadOffset))){const l=function(e,n,o){const l=t.getDOMSelection(o);if(null===l||!l.isCollapsed)return!1;const r=l.anchorNode,i=e,s=l.anchorOffset;if(null==r||null==s)return!1;try{n.setStart(r,i),n.setEnd(r,s)}catch(e){return!1}return!0}(u.leadOffset,o,e);if(null!==l)return c=()=>v({getRect:()=>o.getBoundingClientRect(),match:u}),void(r in n?n[r](c):c())}var c;S()}))}));return()=>{e()}}),[O,p,s,b,S,v,y]),n.useEffect((()=>O.registerEditableListener((e=>{e||S()}))),[O,S]),null===b||null===O||null===R.current?null:l.jsx(f,{close:S,resolution:b,editor:O,anchorElementRef:R,options:o,menuRenderFn:g,shouldSplitNodeWithQuery:!0,onSelectOption:u,commandPriority:C,preselectFirstItem:x})},exports.MenuOption=class{constructor(e){this.key=e,this.ref={current:null},this.setRefElement=this.setRefElement.bind(this)}setRefElement(e){this.ref={current:e}}},exports.PUNCTUATION=g,exports.SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND=p,exports.getScrollParent=function(e,t){let n=getComputedStyle(e);const o="absolute"===n.position,l=t?/(auto|scroll|hidden)/:/(auto|scroll)/;if("fixed"===n.position)return document.body;for(let t=e;t=t.parentElement;)if(n=getComputedStyle(t),(!o||"static"!==n.position)&&l.test(n.overflow+n.overflowY+n.overflowX))return t;return document.body},exports.useBasicTypeaheadTriggerMatch=function(e,{minLength:t=1,maxLength:o=75,punctuation:l=g,allowWhitespace:r=!1}){return n.useCallback((n=>{const i=new RegExp("(^|\\s|\\()(["+e+"]((?:"+("[^"+e+l+(r?"":"\\s")+"]")+"){0,"+o+"}))$").exec(n);if(null!==i){const e=i[1],n=i[3];if(n.length>=t)return{leadOffset:i.index+e.length,matchingString:n,replaceableString:i[2]}}return null}),[r,e,l,o,t])},exports.useDynamicPositioning=a;
|