reakit
Version:
Toolkit for building accessible rich web apps with React
1 lines • 131 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","react","react-dom"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Reakit={},e.React,e.ReactDOM)}(this,(function(e,t,n){"use strict";function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function u(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?o(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function a(e,t){if(null==e)return{};var n,r,o={},u=Object.keys(e);for(r=0;r<u.length;r++)n=u[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function s(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return i(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?i(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=e[Symbol.iterator]()).next.bind(n)}var l=t.createContext({});function c(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function d(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function f(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?d(Object(n),!0).forEach((function(t){c(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):d(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function v(e,t){if(null==e)return{};var n,r,o={},u=Object.keys(e);for(r=0;r<u.length;r++)n=u[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}function p(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function m(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return p(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?p(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=e[Symbol.iterator]()).next.bind(n)}var b=function(e,n,r){void 0===r&&(r=n.children);var o=t.useContext(l);if(o.useCreateElement)return o.useCreateElement(e,n,r);if("string"==typeof e&&function(e){return"function"==typeof e}(r)){n.children;return r(v(n,["children"]))}return t.createElement(e,n,r)};function g(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function h(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function y(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?h(Object(n),!0).forEach((function(t){g(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):h(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function _(e){return"object"==typeof e&&null!=e}function k(e){var t;if(!_(e))return!1;var n=Object.getPrototypeOf(e);return null==n||(null===(t=n.constructor)||void 0===t?void 0:t.toString())===Object.toString()}function w(e,t){for(var n={},r={},o=0,u=Object.keys(e);o<u.length;o++){var a=u[o];t.indexOf(a)>=0?n[a]=e[a]:r[a]=e[a]}return[n,r]}function I(e,t){if(void 0===t&&(t=[]),!k(e.state))return w(e,t);var n=w(e,[].concat(t,["state"])),r=n[0],o=n[1],u=r.state,a=function(e,t){if(null==e)return{};var n,r,o={},u=Object.keys(e);for(r=0;r<u.length;r++)n=u[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(r,["state"]);return[y(y({},u),a),o]}function C(e,t){if(e===t)return!0;if(!e)return!1;if(!t)return!1;if("object"!=typeof e)return!1;if("object"!=typeof t)return!1;var n=Object.keys(e),r=Object.keys(t),o=n.length;if(r.length!==o)return!1;for(var u=0,a=n;u<a.length;u++){var i=a[u];if(e[i]!==t[i])return!1}return!0}function E(e){return"normalizePropsAreEqualInner"===e.name?e:function(t,n){return k(t.state)&&k(n.state)?e(y(y({},t.state),t),y(y({},n.state),n)):e(t,n)}}function O(e){var n,r=e.as,o=e.useHook,u=e.memo,a=e.propsAreEqual,i=void 0===a?null==o?void 0:o.unstable_propsAreEqual:a,s=e.keys,l=void 0===s?(null==o?void 0:o.__keys)||[]:s,c=e.useCreateElement,d=void 0===c?b:c,p=function(e,t){var n=e.as,u=void 0===n?r:n,a=v(e,["as"]);if(o){var i,s=I(a,l),c=s[0],p=s[1],m=o(c,f({ref:t},p)),b=m.wrapElement,g=v(m,["wrapElement"]),h=(null===(i=u.render)||void 0===i?void 0:i.__keys)||u.__keys,y=h&&I(a,h)[0],_=y?f(f({},g),y):g,k=d(u,_);return b?b(k):k}return d(u,f({ref:t},a))};return n=p,p=t.forwardRef(n),u&&(p=function(e,n){return t.memo(e,n)}(p,i&&E(i))),p.__keys=l,p.unstable_propsAreEqual=E(i||C),p}function x(e,n){t.useDebugValue(e);var r=t.useContext(l);return null!=r[e]?r[e]:n}function S(e){return Array.isArray(e)?e:void 0!==e?[e]:[]}function P(e){var n,r,o=S(e.compose),u=function(n,r){if(e.useOptions&&(n=e.useOptions(n,r)),e.name&&(n=function(e,n,r){void 0===n&&(n={}),void 0===r&&(r={});var o="use"+e+"Options";t.useDebugValue(o);var u=x(o);return u?f(f({},n),u(n,r)):n}(e.name,n,r)),e.compose)for(var u,a=m(o);!(u=a()).done;){n=u.value.__useOptions(n,r)}return n},a=function(n,r,a){if(void 0===n&&(n={}),void 0===r&&(r={}),void 0===a&&(a=!1),a||(n=u(n,r)),e.useProps&&(r=e.useProps(n,r)),e.name&&(r=function(e,n,r){void 0===n&&(n={}),void 0===r&&(r={});var o="use"+e+"Props";t.useDebugValue(o);var u=x(o);return u?u(n,r):r}(e.name,n,r)),e.compose)if(e.useComposeOptions&&(n=e.useComposeOptions(n,r)),e.useComposeProps)r=e.useComposeProps(n,r);else for(var i,s=m(o);!(i=s()).done;){r=(0,i.value)(n,r,!0)}var l={},c=r||{};for(var d in c)void 0!==c[d]&&(l[d]=c[d]);return l};a.__useOptions=u;var i=o.reduce((function(e,t){return e.push.apply(e,t.__keys||[]),e}),[]);return a.__keys=[].concat(i,(null===(n=e.useState)||void 0===n?void 0:n.__keys)||[],e.keys||[]),a.unstable_propsAreEqual=e.propsAreEqual||(null===(r=o[0])||void 0===r?void 0:r.unstable_propsAreEqual)||C,a}var R=P({name:"Box",keys:["unstable_system"],propsAreEqual:function(e,t){var n=e.unstable_system,r=a(e,["unstable_system"]),o=t.unstable_system,u=a(t,["unstable_system"]);return!(n!==o&&!C(n,o))&&C(r,u)}}),A=O({as:"div",useHook:R});function T(e,t){void 0===t&&(t=null),e&&("function"==typeof e?e(t):e.current=t)}function D(e,n){return t.useMemo((function(){return null==e&&null==n?null:function(t){T(e,t),T(n,t)}}),[e,n])}var M,B=["button","color","file","image","reset","submit"];function L(e){if("BUTTON"===e.tagName)return!0;if("INPUT"===e.tagName){var t=e;return-1!==B.indexOf(t.type)}return!1}function j(e){return e?e.ownerDocument||e:document}try{M=window}catch(e){}function H(e){return e&&j(e).defaultView||M}var F=function(){var e=H();return Boolean(void 0!==e&&e.document&&e.document.createElement)}(),V=F?t.useLayoutEffect:t.useEffect;function K(e){var n=t.useRef(e);return V((function(){n.current=e})),n}function W(e){return e.target===e.currentTarget}function G(e){var t=j(e).activeElement;return null!=t&&t.nodeName?t:null}function N(e,t){return e===t||e.contains(t)}function q(e){var t=G(e);if(!t)return!1;if(N(e,t))return!0;var n=t.getAttribute("aria-activedescendant");return!!n&&(n===e.id||!!e.querySelector("#"+n))}function U(e){return!N(e.currentTarget,e.target)}function z(e){return!!F&&-1!==window.navigator.userAgent.indexOf(e)}function X(e,t){return"matches"in e?e.matches(t):"msMatchesSelector"in e?e.msMatchesSelector(t):e.webkitMatchesSelector(t)}function Y(e,t){if("closest"in e)return e.closest(t);do{if(X(e,t))return e;e=e.parentElement||e.parentNode}while(null!==e&&1===e.nodeType);return null}var $="input:not([type='hidden']):not([disabled]), select:not([disabled]), textarea:not([disabled]), a[href], button:not([disabled]), [tabindex], iframe, object, embed, area[href], audio[controls], video[controls], [contenteditable]:not([contenteditable='false'])";function Z(e){return X(e,$)&&function(e){var t=e;return t.offsetWidth>0||t.offsetHeight>0||e.getClientRects().length>0}(e)}function J(e){return Z(e)&&!function(e){return parseInt(e.getAttribute("tabindex")||"0",10)<0}(e)}function Q(e,t){var n=Array.from(e.querySelectorAll($)),r=n.filter(J);return J(e)&&r.unshift(e),!r.length&&t?n:r}function ee(e,t){return Q(e,t)[0]||null}var te=P({name:"Role",keys:["unstable_system"],propsAreEqual:function(e,t){var n=e.unstable_system,r=a(e,["unstable_system"]),o=t.unstable_system,u=a(t,["unstable_system"]);return!(n!==o&&!C(n,o))&&C(r,u)}}),ne=O({as:"div",useHook:te}),re=z("Mac")&&!z("Chrome")&&(z("Safari")||z("Firefox"));function oe(e){!q(e)&&Z(e)&&e.focus()}function ue(e,t,n,r){return e?t&&!n?-1:void 0:t?r:r||0}function ae(e,n){return t.useCallback((function(t){var r;null===(r=e.current)||void 0===r||r.call(e,t),t.defaultPrevented||n&&(t.stopPropagation(),t.preventDefault())}),[e,n])}var ie=P({name:"Tabbable",compose:te,keys:["disabled","focusable"],useOptions:function(e,t){return u({disabled:t.disabled},e)},useProps:function(e,n){var r=n.ref,o=n.tabIndex,i=n.onClickCapture,s=n.onMouseDownCapture,l=n.onMouseDown,c=n.onKeyPressCapture,d=n.style,f=a(n,["ref","tabIndex","onClickCapture","onMouseDownCapture","onMouseDown","onKeyPressCapture","style"]),v=t.useRef(null),p=K(i),m=K(s),b=K(l),g=K(c),h=!!e.disabled&&!e.focusable,y=t.useState(!0),_=y[0],k=y[1],w=t.useState(!0),I=w[0],C=w[1],E=e.disabled?u({pointerEvents:"none"},d):d;V((function(){var e=v.current;e&&(["BUTTON","INPUT","SELECT","TEXTAREA","A"].includes(e.tagName)||k(!1),function(e){return["BUTTON","INPUT","SELECT","TEXTAREA"].includes(e.tagName)}(e)||C(!1))}),[]);var O=ae(p,e.disabled),x=ae(m,e.disabled),S=ae(g,e.disabled),P=t.useCallback((function(e){var t;null===(t=b.current)||void 0===t||t.call(b,e);var n=e.currentTarget;if(!e.defaultPrevented&&re&&!U(e)&&L(n)){var r=requestAnimationFrame((function(){n.removeEventListener("mouseup",o,!0),oe(n)})),o=function(){cancelAnimationFrame(r),oe(n)};n.addEventListener("mouseup",o,{once:!0,capture:!0})}}),[]);return u({ref:D(v,r),style:E,tabIndex:ue(h,_,I,o),disabled:!(!h||!I)||void 0,"aria-disabled":!!e.disabled||void 0,onClickCapture:O,onMouseDownCapture:x,onMouseDown:P,onKeyPressCapture:S},f)}}),se=O({as:"div",useHook:ie});var le=P({name:"Clickable",compose:ie,keys:["unstable_clickOnEnter","unstable_clickOnSpace"],useOptions:function(e){var t=e.unstable_clickOnEnter,n=void 0===t||t,r=e.unstable_clickOnSpace;return u({unstable_clickOnEnter:n,unstable_clickOnSpace:void 0===r||r},a(e,["unstable_clickOnEnter","unstable_clickOnSpace"]))},useProps:function(e,n){var r=n.onKeyDown,o=n.onKeyUp,i=a(n,["onKeyDown","onKeyUp"]),s=t.useState(!1),l=s[0],c=s[1],d=K(r),f=K(o),v=t.useCallback((function(t){var n;if(null===(n=d.current)||void 0===n||n.call(d,t),!t.defaultPrevented&&!e.disabled&&!t.metaKey&&W(t)){var r=e.unstable_clickOnEnter&&"Enter"===t.key,o=e.unstable_clickOnSpace&&" "===t.key;if(r||o){if(function(e){var t=e.currentTarget;return!!e.isTrusted&&(L(t)||"INPUT"===t.tagName||"TEXTAREA"===t.tagName||"A"===t.tagName||"SELECT"===t.tagName)}(t))return;t.preventDefault(),r?t.currentTarget.click():o&&c(!0)}}}),[e.disabled,e.unstable_clickOnEnter,e.unstable_clickOnSpace]),p=t.useCallback((function(t){var n;if(null===(n=f.current)||void 0===n||n.call(f,t),!t.defaultPrevented&&!e.disabled&&!t.metaKey){var r=e.unstable_clickOnSpace&&" "===t.key;l&&r&&(c(!1),t.currentTarget.click())}}),[e.disabled,e.unstable_clickOnSpace,l]);return u({"data-active":l||void 0,onKeyDown:v,onKeyUp:p},i)}}),ce=O({as:"button",memo:!0,useHook:le}),de=P({name:"Button",compose:le,keys:[],useProps:function(e,n){var r=n.ref,o=a(n,["ref"]),i=t.useRef(null),s=t.useState(void 0),l=s[0],c=s[1],d=t.useState("button"),f=d[0],v=d[1];return t.useEffect((function(){var e=i.current;e&&(L(e)||("A"!==e.tagName&&c("button"),v(void 0)))}),[]),u({ref:D(i,r),role:l,type:f},o)}}),fe=O({as:"button",memo:!0,useHook:de});function ve(e,t){return-1===t?e:[].concat(e.slice(0,t),e.slice(t+1))}function pe(e,t,n){if("function"==typeof Event)return new Event(t,n);var r=j(e).createEvent("Event");return r.initEvent(t,null==n?void 0:n.bubbles,null==n?void 0:n.cancelable),r}var me=[].concat(["state","setState"],["value","checked"]);function be(e){return void 0!==e.checked?e.checked:void 0===e.value?!!e.state:-1!==(Array.isArray(e.state)?e.state:[]).indexOf(e.value)}var ge=P({name:"Checkbox",compose:le,keys:me,useOptions:function(e,t){var n=t.value,r=t.checked,o=e.unstable_clickOnEnter,i=void 0!==o&&o,s=a(e,["unstable_clickOnEnter"]);return u({unstable_clickOnEnter:i,value:n,checked:be(u({checked:r},s))},s)},useProps:function(e,n){var r=n.ref,o=n.onChange,i=n.onClick,s=a(n,["ref","onChange","onClick"]),l=t.useRef(null),c=t.useState(!0),d=c[0],f=c[1],v=K(o),p=K(i);t.useEffect((function(){var e=l.current;e&&("INPUT"===e.tagName&&"checkbox"===e.type||f(!1))}),[]),function(e,n){t.useEffect((function(){var t=e.current;t&&("indeterminate"===n.state?t.indeterminate=!0:t.indeterminate&&(t.indeterminate=!1))}),[n.state,e])}(l,e);var m=t.useCallback((function(t){var n=t.currentTarget;if(e.disabled)return t.stopPropagation(),void t.preventDefault();if(v.current&&(d||(n.checked=!n.checked),v.current(t)),e.setState)if(void 0===e.value)e.setState(!e.checked);else{var r=Array.isArray(e.state)?e.state:[],o=r.indexOf(e.value);-1===o?e.setState([].concat(r,[e.value])):e.setState(ve(r,o))}}),[e.disabled,d,e.setState,e.value,e.checked,e.state]),b=t.useCallback((function(e){var t;null===(t=p.current)||void 0===t||t.call(p,e),e.defaultPrevented||d||function(e,t){var n=pe(e,"change");Object.defineProperties(n,{type:{value:"change"},target:{value:e},currentTarget:{value:e}}),null==t||t(n)}(e.currentTarget,m)}),[d,m]);return u({ref:D(l,r),role:d?void 0:"checkbox",type:d?"checkbox":void 0,value:d?e.value:void 0,checked:e.checked,"aria-checked":"indeterminate"===e.state?"mixed":e.checked,onChange:m,onClick:b},s)}}),he=O({as:"input",memo:!0,useHook:ge});function ye(e){return t.useState(e)[0]}function _e(e,n){var r=t.useRef(!1);t.useEffect((function(){if(r.current)return e();r.current=!0}),n)}function ke(e,t,n){return void 0===n&&(n={}),"function"==typeof FocusEvent?new FocusEvent(t,n):pe(e,t,n)}function we(e,t){var n=ke(e,"blur",t),r=e.dispatchEvent(n),o=y(y({},t),{},{bubbles:!0});return e.dispatchEvent(ke(e,"focusout",o)),r}function Ie(e,t,n){return e.dispatchEvent(function(e,t,n){if(void 0===n&&(n={}),"function"==typeof KeyboardEvent)return new KeyboardEvent(t,n);var r=j(e).createEvent("KeyboardEvent");return r.initKeyboardEvent(t,n.bubbles,n.cancelable,H(e),n.key,n.location,n.ctrlKey,n.altKey,n.shiftKey,n.metaKey),r}(e,t,n))}var Ce=F&&"msCrypto"in window;function Ee(e){return Ce?G(e.currentTarget):e.relatedTarget}function Oe(e){for(var t,n=[[]],r=function(){var e=t.value,r=n.find((function(t){return!t[0]||t[0].groupId===e.groupId}));r?r.push(e):n.push([e])},o=s(e);!(t=o()).done;)r();return n}function xe(e){for(var t,n=[],r=s(e);!(t=r()).done;){var o=t.value;n.push.apply(n,o)}return n}function Se(e,t){return t?e.find((function(e){return!e.disabled&&e.id!==t})):e.find((function(e){return!e.disabled}))}function Pe(e){return e.slice().reverse()}function Re(e,t){var n;return t||null===t?t:e.currentId||null===e.currentId?e.currentId:null===(n=Se(e.items||[]))||void 0===n?void 0:n.id}function Ae(e,t){if(t)return null==e?void 0:e.find((function(e){return e.id===t&&!e.disabled}))}var Te=["baseId","unstable_idCountRef","setBaseId","unstable_virtual","rtl","orientation","items","groups","currentId","loop","wrap","shift","unstable_moves","unstable_hasActiveWidget","unstable_includesBaseElement","registerItem","unregisterItem","registerGroup","unregisterGroup","move","next","previous","up","down","first","last","sort","unstable_setVirtual","setRTL","setOrientation","setCurrentId","setLoop","setWrap","setShift","reset","unstable_setIncludesBaseElement","unstable_setHasActiveWidget"],De=Te,Me=De,Be=Me;function Le(e){e.userFocus=!0,e.focus(),e.userFocus=!1}function je(e,t){e.userFocus=t}var He=F&&"msCrypto"in window;function Fe(e,n,r){var o=K(r);return t.useCallback((function(t){var r;if(null===(r=o.current)||void 0===r||r.call(o,t),!t.defaultPrevented&&e&&function(e){return!!W(e)&&!e.metaKey&&"Tab"!==e.key}(t)){var u=null==n?void 0:n.ref.current;u&&(Ie(u,t.type,t)||t.preventDefault(),t.currentTarget.contains(u)&&t.stopPropagation())}}),[e,n])}function Ve(e,t){return null==e?void 0:e.some((function(e){return!!t&&e.ref.current===t}))}var Ke=P({name:"Composite",compose:[ie],keys:Te,useOptions:function(e){return u(u({},e),{},{currentId:Re(e)})},useProps:function(e,n){var r=n.ref,o=n.onFocusCapture,i=n.onFocus,s=n.onBlurCapture,l=n.onKeyDown,c=n.onKeyDownCapture,d=n.onKeyUpCapture,f=a(n,["ref","onFocusCapture","onFocus","onBlurCapture","onKeyDown","onKeyDownCapture","onKeyUpCapture"]),v=t.useRef(null),p=Ae(e.items,e.currentId),m=t.useRef(null),b=K(o),g=K(i),h=K(s),y=K(l),_=function(e){var n=K(e),r=t.useReducer((function(e){return e+1}),0),o=r[0],u=r[1];return t.useEffect((function(){var e,t=null===(e=n.current)||void 0===e?void 0:e.ref.current;o&&t&&Le(t)}),[o]),u}(p),k=He?function(e){var n=t.useRef(null);return t.useEffect((function(){var t=j(e.current),r=function(e){var t=e.target;n.current=t};return t.addEventListener("focus",r,!0),function(){t.removeEventListener("focus",r,!0)}}),[]),n}(v):void 0;t.useEffect((function(){var t=v.current;e.unstable_moves&&!p&&(null==t||t.focus())}),[e.unstable_moves,p]);var w=Fe(e.unstable_virtual,p,c),I=Fe(e.unstable_virtual,p,d),C=t.useCallback((function(t){var n;if(null===(n=b.current)||void 0===n||n.call(b,t),!t.defaultPrevented&&e.unstable_virtual){var r=(null==k?void 0:k.current)||t.relatedTarget,o=Ve(e.items,r);W(t)&&o&&(t.stopPropagation(),m.current=r)}}),[e.unstable_virtual,e.items]),E=t.useCallback((function(t){var n;if(null===(n=g.current)||void 0===n||n.call(g,t),!t.defaultPrevented)if(e.unstable_virtual)W(t)&&_();else if(W(t)){var r;null===(r=e.setCurrentId)||void 0===r||r.call(e,null)}}),[e.unstable_virtual,e.setCurrentId]),O=t.useCallback((function(t){var n;if(null===(n=h.current)||void 0===n||n.call(h,t),!t.defaultPrevented&&e.unstable_virtual){var r=(null==p?void 0:p.ref.current)||null,o=Ee(t),u=Ve(e.items,o);if(W(t)&&u)o===r?m.current&&m.current!==o&&we(m.current,t):r&&we(r,t),t.stopPropagation();else!Ve(e.items,t.target)&&r&&we(r,t)}}),[e.unstable_virtual,e.items,p]),x=t.useCallback((function(t){var n,r;if(null===(n=y.current)||void 0===n||n.call(y,t),!t.defaultPrevented&&null===e.currentId&&W(t)){var o="horizontal"!==e.orientation,u="vertical"!==e.orientation,a=!(null===(r=e.groups)||void 0===r||!r.length),i={ArrowUp:(a||o)&&function(){if(a){var t,n=Se(xe(Pe(Oe(e.items))));if(null!=n&&n.id)null===(t=e.move)||void 0===t||t.call(e,n.id)}else{var r;null===(r=e.last)||void 0===r||r.call(e)}},ArrowRight:(a||u)&&e.first,ArrowDown:(a||o)&&e.first,ArrowLeft:(a||u)&&e.last,Home:e.first,End:e.last,PageUp:e.first,PageDown:e.last}[t.key];i&&(t.preventDefault(),i())}}),[e.currentId,e.orientation,e.groups,e.items,e.move,e.last,e.first]);return u({ref:D(v,r),id:e.baseId,onFocus:E,onFocusCapture:C,onBlurCapture:O,onKeyDownCapture:w,onKeyDown:x,onKeyUpCapture:I,"aria-activedescendant":e.unstable_virtual&&(null==p?void 0:p.id)||void 0},f)},useComposeProps:function(e,t){t=te(e,t,!0);var n=ie(e,t,!0);return e.unstable_virtual||null===e.currentId?u({tabIndex:0},n):u(u({},t),{},{ref:n.ref})}}),We=O({as:"div",useHook:Ke,useCreateElement:function(e,t,n){return b(e,t,n)}}),Ge=["baseId","unstable_idCountRef","unstable_virtual","rtl","orientation","groups","currentId","loop","wrap","shift","unstable_moves","unstable_hasActiveWidget","unstable_includesBaseElement","items","menuRole","inputValue","minValueLength","currentValue","values","limit","matches","list","inline","autoSelect","visible","setBaseId","unregisterItem","registerGroup","unregisterGroup","move","next","previous","up","down","first","last","sort","unstable_setVirtual","setRTL","setOrientation","setCurrentId","setLoop","setWrap","setShift","reset","unstable_setIncludesBaseElement","unstable_setHasActiveWidget","registerItem","setInputValue","setMinValueLength","setValues","setLimit","setList","setInline","setAutoSelect"],Ne=[].concat(Ge,["columns","setColumns"]),qe=[].concat(Ge,["animated","animating","modal","unstable_disclosureRef","unstable_referenceRef","unstable_popoverRef","unstable_arrowRef","unstable_popoverStyles","unstable_arrowStyles","unstable_originalPlacement","unstable_update","placement","show","hide","toggle","setVisible","setAnimated","stopAnimation","setModal","place"]),Ue=[].concat(Ne,qe),ze=[].concat(Ue,["hideOnEsc"]),Xe=Ue,Ye=Xe,$e=[].concat(Ye,["value"]),Ze=Ye,Je=Ze,Qe=Je;function et(e){return e+"-menu"}function tt(e,t){var n=et(e);return t?t+" "+n:n}function nt(e){return e.list&&e.inline?"both":e.list?"list":e.inline?"inline":"none"}function rt(e,t){return!!t&&t.length>e.length&&0===t.toLowerCase().indexOf(e.toLowerCase())}var ot=P({name:"Combobox",compose:Ke,keys:ze,useOptions:function(e){var t=e.menuRole,n=void 0===t?"listbox":t,r=e.hideOnEsc;return u({menuRole:n,hideOnEsc:void 0===r||r},a(e,["menuRole","hideOnEsc"]))},useProps:function(e,n){var r=n.ref,o=n.onKeyDown,i=n.onKeyPress,s=n.onChange,l=n.onClick,c=n.onBlur,d=n["aria-controls"],f=a(n,["ref","onKeyDown","onKeyPress","onChange","onClick","onBlur","aria-controls"]),v=t.useRef(null),p=t.useReducer((function(){return{}}),{}),m=p[0],b=p[1],g=K(o),h=K(i),y=K(s),_=K(l),k=K(c),w=function(e){return t.useMemo((function(){return e.inline?function(e,t,n){if(!t)return!1;var r=e.find((function(e){return!e.disabled}));return n&&(null==r?void 0:r.id)===n}(e.items,e.autoSelect,e.currentId)?rt(e.inputValue,e.currentValue)?e.inputValue+function(e,t){if(!t)return"";var n=t.toLowerCase().indexOf(e.toLowerCase());return t.slice(n+e.length)}(e.inputValue,e.currentValue):e.inputValue:e.currentValue||e.inputValue:e.inputValue}),[e.inline,e.inputValue,e.autoSelect,e.items,e.currentId,e.currentValue])}(e),I=t.useRef(!1);t.useEffect((function(){var t,n;if(e.inline&&(e.autoSelect&&e.currentValue&&e.currentId===(t=e.items,null===(n=t.find((function(e){return!e.disabled})))||void 0===n?void 0:n.id)&&rt(e.inputValue,e.currentValue))){var r=v.current;null==r||r.setSelectionRange(e.inputValue.length,e.currentValue.length)}}),[m,e.inline,e.autoSelect,e.currentValue,e.inputValue,e.currentId,e.items]),_e((function(){e.autoSelect&&e.items.length&&I.current?e.setCurrentId(void 0):e.setCurrentId(null)}),[e.items,e.inputValue,e.autoSelect,e.setCurrentId]);var C=t.useCallback((function(t){var n,r;(null===(n=g.current)||void 0===n||n.call(g,t),I.current=!1,t.defaultPrevented)||"Escape"===t.key&&e.hideOnEsc&&(null===(r=e.hide)||void 0===r||r.call(e))}),[e.hideOnEsc,e.hide]),E=t.useCallback((function(e){var t;null===(t=h.current)||void 0===t||t.call(h,e),I.current=!0}),[]),O=t.useCallback((function(t){var n,r,o,u,a;(null===(n=y.current)||void 0===n||n.call(y,t),t.defaultPrevented)||(null===(r=e.show)||void 0===r||r.call(e),null===(o=e.setInputValue)||void 0===o||o.call(e,t.target.value),b(),e.autoSelect&&I.current?null===(u=e.setCurrentId)||void 0===u||u.call(e,void 0):null===(a=e.setCurrentId)||void 0===a||a.call(e,null))}),[e.show,e.autoSelect,e.setCurrentId,e.setInputValue]),x=t.useCallback((function(t){var n,r;if(null===(n=_.current)||void 0===n||n.call(_,t),!t.defaultPrevented){var o;if(!e.minValueLength||w.length>=e.minValueLength)null===(o=e.show)||void 0===o||o.call(e);null===(r=e.setCurrentId)||void 0===r||r.call(e,null),e.setInputValue(w)}}),[e.show,e.setCurrentId,e.setInputValue,e.minValueLength,w]),S=t.useCallback((function(t){var n;null===(n=k.current)||void 0===n||n.call(k,t),t.defaultPrevented||e.setInputValue(w)}),[e.setInputValue,w]);return u({ref:D(v,D(e.unstable_referenceRef,r)),role:"combobox",autoComplete:"off","aria-controls":tt(e.baseId,d),"aria-haspopup":e.menuRole,"aria-expanded":e.visible,"aria-autocomplete":nt(e),value:w,onKeyDown:C,onKeyPress:E,onChange:O,onClick:x,onBlur:S},f)},useComposeProps:function(e,n){var r=n.onKeyUp,o=n.onKeyDownCapture,i=n.onKeyDown,s=a(n,["onKeyUp","onKeyDownCapture","onKeyDown"]),l=Ke(e,s,!0),c=K(o),d=K(i),f=t.useCallback((function(t){var n,r;if(null===(n=c.current)||void 0===n||n.call(c,t),!t.defaultPrevented){if("grid"!==e.menuRole){if("Home"===t.key)return;if("End"===t.key)return}1!==t.key.length&&(null===(r=l.onKeyDownCapture)||void 0===r||r.call(l,t))}}),[e.menuRole,l.onKeyDownCapture]),v=t.useCallback((function(t){var n,r;if((null===(n=d.current)||void 0===n||n.call(d,t),!t.defaultPrevented)&&(null===e.currentId&&"ArrowLeft"!==t.key&&"ArrowRight"!==t.key&&"Home"!==t.key&&"End"!==t.key)){var o;if(!(t.ctrlKey||t.altKey||t.shiftKey||t.metaKey||"ArrowUp"!==t.key&&"ArrowDown"!==t.key&&1!==t.key.length))null===(o=e.show)||void 0===o||o.call(e);null===(r=l.onKeyDown)||void 0===r||r.call(l,t)}}),[e.currentId,e.show,l.onKeyDown]);return u(u({},l),{},{onKeyDownCapture:f,onKeyDown:v,onKeyUp:r})}}),ut=O({as:"input",memo:!0,useHook:ot});function at(e){try{var t=e instanceof HTMLInputElement&&null!==e.selectionStart,n="TEXTAREA"===e.tagName,r="true"===e.contentEditable;return t||n||r||!1}catch(e){return!1}}function it(e){var t=G(e);if(!t)return!1;if(t===e)return!0;var n=t.getAttribute("aria-activedescendant");return!!n&&n===e.id}function st(e,t){var n=void 0===t?{}:t,r=n.preventScroll,o=n.isActive,u=void 0===o?it:o;return u(e)?-1:(e.focus({preventScroll:r}),u(e)?-1:requestAnimationFrame((function(){e.focus({preventScroll:r})})))}function lt(e){return void 0===e&&(e="id"),(e?e+"-":"")+Math.random().toString(32).substr(2,6)}var ct=t.createContext(lt);function dt(e){var n=e.children,r=e.prefix,o=void 0===r?"id":r,u=t.useRef(0),a=t.useCallback((function(e){return void 0===e&&(e=o),(e?e+"-":"")+ ++u.current}),[o]);return t.createElement(ct.Provider,{value:a},n)}var ft=P({keys:[].concat(["baseId","unstable_idCountRef","setBaseId"],["id"]),useOptions:function(e,n){var r=t.useContext(ct),o=t.useState((function(){return e.unstable_idCountRef?(e.unstable_idCountRef.current+=1,"-"+e.unstable_idCountRef.current):e.baseId?"-"+r(""):""}))[0],a=t.useMemo((function(){return e.baseId||r()}),[e.baseId,r]),i=n.id||e.id||""+a+o;return u(u({},e),{},{id:i})},useProps:function(e,t){return u({id:e.id},t)}}),vt=O({as:"div",useHook:ft});function pt(e,t){if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement){var n,r=Object.getPrototypeOf(e),o=null===(n=Object.getOwnPropertyDescriptor(r,"value"))||void 0===n?void 0:n.set;o&&(o.call(e,t),function(e,t,n){e.dispatchEvent(pe(e,t,n))}(e,"input",{bubbles:!0}))}}function mt(e){return e.querySelector("[data-composite-item-widget]")}var bt=P({name:"CompositeItem",compose:[le,ft],keys:Me,propsAreEqual:function(e,t){if(!t.id||e.id!==t.id)return le.unstable_propsAreEqual(e,t);var n=e.currentId,r=e.unstable_moves,o=a(e,["currentId","unstable_moves"]),u=t.currentId,i=t.unstable_moves,s=a(t,["currentId","unstable_moves"]);if(u!==n){if(t.id===u||t.id===n)return!1}else if(r!==i)return!1;return le.unstable_propsAreEqual(o,s)},useOptions:function(e){return u(u({},e),{},{id:e.id,currentId:Re(e),unstable_clickOnSpace:!e.unstable_hasActiveWidget&&e.unstable_clickOnSpace})},useProps:function(e,n){var r,o=n.ref,i=n.tabIndex,l=void 0===i?0:i,c=n.onMouseDown,d=n.onFocus,f=n.onBlurCapture,v=n.onKeyDown,p=n.onClick,m=a(n,["ref","tabIndex","onMouseDown","onFocus","onBlurCapture","onKeyDown","onClick"]),b=t.useRef(null),g=e.id,h=e.disabled&&!e.focusable,y=e.currentId===g,_=K(y),k=t.useRef(!1),w=function(e){return t.useMemo((function(){var t;return null===(t=e.items)||void 0===t?void 0:t.find((function(t){return e.id&&t.id===e.id}))}),[e.items,e.id])}(e),I=K(c),C=K(d),E=K(f),O=K(v),x=K(p),S=!e.unstable_virtual&&!e.unstable_hasActiveWidget&&y||!(null!==(r=e.items)&&void 0!==r&&r.length);t.useEffect((function(){var t;if(g)return null===(t=e.registerItem)||void 0===t||t.call(e,{id:g,ref:b,disabled:!!h}),function(){var t;null===(t=e.unregisterItem)||void 0===t||t.call(e,g)}}),[g,h,e.registerItem,e.unregisterItem]),t.useEffect((function(){var t=b.current;t&&e.unstable_moves&&_.current&&Le(t)}),[e.unstable_moves]);var P=t.useCallback((function(e){var t;null===(t=I.current)||void 0===t||t.call(I,e),je(e.currentTarget,!0)}),[]),R=t.useCallback((function(t){var n,r,o=!!t.currentTarget.userFocus;if(je(t.currentTarget,!1),null===(n=C.current)||void 0===n||n.call(C,t),!t.defaultPrevented&&!U(t)&&g&&!function(e,t){if(W(e))return!1;for(var n,r=s(t);!(n=r()).done;)if(n.value.ref.current===e.target)return!0;return!1}(t,e.items)&&(null===(r=e.setCurrentId)||void 0===r||r.call(e,g),o&&e.unstable_virtual&&e.baseId&&W(t))){var u=j(t.target).getElementById(e.baseId);u&&(k.current=!0,st(u))}}),[g,e.items,e.setCurrentId,e.unstable_virtual,e.baseId]),A=t.useCallback((function(t){var n;null===(n=E.current)||void 0===n||n.call(E,t),t.defaultPrevented||e.unstable_virtual&&k.current&&(k.current=!1,t.preventDefault(),t.stopPropagation())}),[e.unstable_virtual]),T=t.useCallback((function(t){var n;if(W(t)){var r="horizontal"!==e.orientation,o="vertical"!==e.orientation,u=!(null==w||!w.groupId),a={ArrowUp:(u||r)&&e.up,ArrowRight:(u||o)&&e.next,ArrowDown:(u||r)&&e.down,ArrowLeft:(u||o)&&e.previous,Home:function(){var n,r;!u||t.ctrlKey?null===(n=e.first)||void 0===n||n.call(e):null===(r=e.previous)||void 0===r||r.call(e,!0)},End:function(){var n,r;!u||t.ctrlKey?null===(n=e.last)||void 0===n||n.call(e):null===(r=e.next)||void 0===r||r.call(e,!0)},PageUp:function(){var t,n;u?null===(t=e.up)||void 0===t||t.call(e,!0):null===(n=e.first)||void 0===n||n.call(e)},PageDown:function(){var t,n;u?null===(t=e.down)||void 0===t||t.call(e,!0):null===(n=e.last)||void 0===n||n.call(e)}}[t.key];if(a)return t.preventDefault(),void a();if(null===(n=O.current)||void 0===n||n.call(O,t),!t.defaultPrevented)if(1===t.key.length&&" "!==t.key){var i=mt(t.currentTarget);i&&at(i)&&(i.focus(),pt(i,""))}else if("Delete"===t.key||"Backspace"===t.key){var s=mt(t.currentTarget);s&&at(s)&&(t.preventDefault(),pt(s,""))}}}),[e.orientation,w,e.up,e.next,e.down,e.previous,e.first,e.last]),M=t.useCallback((function(e){var t;if(null===(t=x.current)||void 0===t||t.call(x,e),!e.defaultPrevented){var n=mt(e.currentTarget);n&&!q(n)&&n.focus()}}),[]);return u({ref:D(b,o),id:g,tabIndex:S?l:-1,"aria-selected":!(!e.unstable_virtual||!y)||void 0,onMouseDown:P,onFocus:R,onBlurCapture:A,onKeyDown:T,onClick:M},m)}}),gt=O({as:"button",memo:!0,useHook:bt}),ht=["baseId","unstable_idCountRef","unstable_virtual","rtl","orientation","items","groups","currentId","loop","wrap","shift","unstable_moves","unstable_hasActiveWidget","unstable_includesBaseElement","setBaseId","registerItem","unregisterItem","registerGroup","unregisterGroup","move","next","previous","up","down","first","last","sort","unstable_setVirtual","setRTL","setOrientation","setCurrentId","setLoop","setWrap","setShift","reset","unstable_setIncludesBaseElement","unstable_setHasActiveWidget"],yt=ht,_t=P({name:"GridCell",compose:bt,keys:ht,useProps:function(e,t){return u({role:"gridcell"},t)}}),kt=O({as:"span",memo:!0,useHook:_t});function wt(e,t,n){return n||e+"-"+t.toLowerCase().replace(/[^a-z0-9]/g,"-")}var It=P({name:"ComboboxItem",compose:R,keys:$e,propsAreEqual:function(e,t){if(e.value!==t.value)return!1;if(!(e.value&&t.value&&e.baseId&&t.baseId))return bt.unstable_propsAreEqual(e,t);var n=e.currentValue,r=(e.inputValue,e.matches,a(e,["currentValue","inputValue","matches"])),o=t.currentValue,i=(t.inputValue,t.matches,a(t,["currentValue","inputValue","matches"]));if(n!==o&&(t.value===n||t.value===o))return!1;var s=wt(e.baseId,e.value,e.id),l=wt(t.baseId,t.value,e.id);return bt.unstable_propsAreEqual(u(u({},r),{},{id:s}),u(u({},i),{},{id:l}))},useOptions:function(e){var n=e.disabled&&!e.focusable?void 0:e.value,r=t.useCallback((function(t){var r;e.visible&&(null===(r=e.registerItem)||void 0===r||r.call(e,u(u({},t),{},{value:n})))}),[e.registerItem,e.visible,n]);if(e.id||!e.baseId||!e.value)return u(u({},e),{},{registerItem:r});var o=wt(e.baseId,e.value,e.id);return u(u({},e),{},{registerItem:r,id:o})},useProps:function(e,n){var r=n.onClick,o=a(n,["onClick"]),i=K(r),s=t.useCallback((function(t){var n,r,o;null===(n=i.current)||void 0===n||n.call(i,t),t.defaultPrevented||e.value&&(null===(r=e.hide)||void 0===r||r.call(e),null===(o=e.setInputValue)||void 0===o||o.call(e,e.value))}),[e.hide,e.setInputValue,e.value]);return u({children:e.value,onClick:s,tabIndex:-1},o)}}),Ct=O({as:"span",memo:!0,useHook:It}),Et=P({name:"ComboboxGridCell",compose:[It,_t],keys:Xe}),Ot=O({as:"span",memo:!0,useHook:Et}),xt=P({name:"Group",compose:te,keys:[],useProps:function(e,t){return u({role:"group"},t)}}),St=O({as:"div",useHook:xt}),Pt=P({name:"CompositeGroup",compose:[xt,ft],keys:De,propsAreEqual:function(e,t){if(!t.id||e.id!==t.id)return xt.unstable_propsAreEqual(e,t);var n=e.currentId,r=(e.unstable_moves,a(e,["currentId","unstable_moves"])),o=t.currentId,u=(t.unstable_moves,a(t,["currentId","unstable_moves"]));if(e.items&&t.items){var i=Ae(e.items,n),s=Ae(t.items,o),l=null==i?void 0:i.groupId,c=null==s?void 0:s.groupId;if(t.id===c||t.id===l)return!1}return xt.unstable_propsAreEqual(r,u)},useProps:function(e,n){var r=n.ref,o=a(n,["ref"]),i=t.useRef(null),s=e.id;return V((function(){var t;if(s)return null===(t=e.registerGroup)||void 0===t||t.call(e,{id:s,ref:i}),function(){var t;null===(t=e.unregisterGroup)||void 0===t||t.call(e,s)}}),[s,e.registerGroup,e.unregisterGroup]),u({ref:D(i,r)},o)}}),Rt=O({as:"div",useHook:Pt}),At=P({name:"GridRow",compose:Pt,keys:yt,useProps:function(e,t){return u({role:"row"},t)}}),Tt=O({as:"div",useHook:At}),Dt=P({name:"ComboboxGridRow",compose:At,keys:Ye}),Mt=O({as:"div",useHook:Dt});function Bt(e,t){return function(e){return"function"==typeof e}(e)?e(t):e}function Lt(e){void 0===e&&(e={});var n=ye(e).baseId,r=t.useContext(ct),o=t.useRef(0),u=t.useState((function(){return n||r()}));return{baseId:u[0],setBaseId:u[1],unstable_idCountRef:o}}function jt(e,t){return Boolean(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}function Ht(e,t){return e.findIndex((function(e){return!(!e.ref.current||!t.ref.current)&&jt(t.ref.current,e.ref.current)}))}function Ft(e){for(var t,n=0,r=s(e);!(t=r()).done;){var o=t.value.length;o>n&&(n=o)}return n}function Vt(e){for(var t=Oe(e),n=Ft(t),r=[],o=0;o<n;o+=1)for(var a,i=s(t);!(a=i()).done;){var l=a.value;l[o]&&r.push(u(u({},l[o]),{},{groupId:l[o].groupId?""+o:void 0}))}return r}function Kt(e,t,n){for(var r,o=Ft(e),u=s(e);!(r=u()).done;)for(var a=r.value,i=0;i<o;i+=1){var l=a[i];if(!l||n&&l.disabled){var c=0===i&&n?Se(a):a[i-1];a[i]=c&&t!==(null==c?void 0:c.id)&&n?c:{id:"__EMPTY_ITEM__",disabled:!0,ref:{current:null},groupId:null==c?void 0:c.groupId}}}return e}var Wt={id:null,ref:{current:null}};function Gt(e,t){return e.filter((function(e){return e.groupId===t}))}var Nt={horizontal:"vertical",vertical:"horizontal"};function qt(e,t,n){return n in e?[].concat(e.slice(0,n),[t],e.slice(n)):[].concat(e,[t])}function Ut(e){var t=e.map((function(e,t){return[t,e]})),n=!1;return t.sort((function(e,t){var r=e[0],o=e[1],u=t[0],a=t[1],i=o.ref.current,s=a.ref.current;return i&&s?jt(i,s)?(r>u&&(n=!0),-1):(r<u&&(n=!0),1):0})),n?t.map((function(e){e[0];return e[1]})):e}function zt(e,t){var n=Ut(e);e!==n&&t(n)}function Xt(e,n){var r=t.useRef([]);t.useEffect((function(){for(var t,o=function(e){for(var t,n=e[0],r=e.slice(1),o=null==n||null===(t=n.ref.current)||void 0===t?void 0:t.parentElement,u=function(){var e=o;if(r.every((function(t){return e.contains(t.ref.current)})))return{v:o};o=o.parentElement};o;){var a=u();if("object"==typeof a)return a.v}return j(o).body}(e),u=new IntersectionObserver((function(){!!r.current.length&&zt(e,n),r.current=e}),{root:o}),a=s(e);!(t=a()).done;){var i=t.value;i.ref.current&&u.observe(i.ref.current)}return function(){u.disconnect()}}),[e])}function Yt(e,n){"function"==typeof IntersectionObserver?Xt(e,n):function(e,n){t.useEffect((function(){var t=setTimeout((function(){return zt(e,n)}),250);return function(){return clearTimeout(t)}}))}(e,n)}function $t(e,t){var n=e.unstable_virtual,r=e.rtl,o=e.orientation,a=e.items,i=e.groups,s=e.currentId,l=e.loop,c=e.wrap,d=e.pastIds,f=e.shift,v=e.unstable_moves,p=e.unstable_includesBaseElement,m=e.initialVirtual,b=e.initialRTL,g=e.initialOrientation,h=e.initialCurrentId,y=e.initialLoop,_=e.initialWrap,k=e.initialShift,w=e.hasSetCurrentId;switch(t.type){case"registerGroup":var I=t.group;if(0===i.length)return u(u({},e),{},{groups:[I]});var C=Ht(i,I);return u(u({},e),{},{groups:qt(i,I,C)});case"unregisterGroup":var E=t.id,O=i.filter((function(e){return e.id!==E}));return O.length===i.length?e:u(u({},e),{},{groups:O});case"registerItem":var x,S=t.item,P=i.find((function(e){var t;return null===(t=e.ref.current)||void 0===t?void 0:t.contains(S.ref.current)})),R=u({groupId:null==P?void 0:P.id},S),A=Ht(a,R),T=u(u({},e),{},{items:qt(a,R,A)});return w||v||void 0!==h?T:u(u({},T),{},{currentId:null===(x=Se(T.items))||void 0===x?void 0:x.id});case"unregisterItem":var D=t.id,M=a.filter((function(e){return e.id!==D}));if(M.length===a.length)return e;var B=d.filter((function(e){return e!==D})),L=u(u({},e),{},{pastIds:B,items:M});if(s&&s===D){var j=p?null:Re(u(u({},L),{},{currentId:B[0]}));return u(u({},L),{},{currentId:j})}return L;case"move":var H=t.id;if(void 0===H)return e;var F=d.filter((function(e){return e!==s&&e!==H})),V=s?[s].concat(F):F,K=u(u({},e),{},{pastIds:V});if(null===H)return u(u({},K),{},{unstable_moves:v+1,currentId:Re(K,H)});var W=Ae(a,H);return u(u({},K),{},{unstable_moves:W?v+1:v,currentId:Re(K,null==W?void 0:W.id)});case"next":if(null==s)return $t(e,u(u({},t),{},{type:"first"}));var G=r&&"vertical"!==o,N=G?Pe(a):a,q=N.find((function(e){return e.id===s}));if(!q)return $t(e,u(u({},t),{},{type:"first"}));var U=!!q.groupId,z=N.indexOf(q),X=N.slice(z+1),Y=Gt(X,q.groupId);if(t.allTheWay){var $=Se(G?Gt(N,q.groupId):Pe(Y));return $t(e,u(u({},t),{},{type:"move",id:null==$?void 0:$.id}))}var Z=function(e){return e&&Nt[e]}(U?o||"horizontal":o),J=l&&l!==Z,Q=U&&c&&c!==Z,ee=t.hasNullItem||!U&&J&&p;if(J){var te=Se(function(e,t,n){var r=e.findIndex((function(e){return e.id===t}));return[].concat(e.slice(r+1),n?[Wt]:[],e.slice(0,r))}(Q&&!ee?N:Gt(N,q.groupId),s,ee),s);return $t(e,u(u({},t),{},{type:"move",id:null==te?void 0:te.id}))}if(Q){var ne=Se(ee?Y:X,s),re=ee?(null==ne?void 0:ne.id)||null:null==ne?void 0:ne.id;return $t(e,u(u({},t),{},{type:"move",id:re}))}var oe=Se(Y,s);return $t(e,!oe&&ee?u(u({},t),{},{type:"move",id:null}):u(u({},t),{},{type:"move",id:null==oe?void 0:oe.id}));case"previous":var ue=!!!i.length&&p,ae=$t(u(u({},e),{},{items:Pe(a)}),u(u({},t),{},{type:"next",hasNullItem:ue}));return u(u({},ae),{},{items:a});case"down":var ie=f&&!t.allTheWay,se=Vt(xe(Kt(Oe(a),s,ie))),le=l&&"horizontal"!==l&&p,ce=$t(u(u({},e),{},{orientation:"vertical",items:se}),u(u({},t),{},{type:"next",hasNullItem:le}));return u(u({},ce),{},{orientation:o,items:a});case"up":var de=f&&!t.allTheWay,fe=Vt(Pe(xe(Kt(Oe(a),s,de)))),ve=p,pe=$t(u(u({},e),{},{orientation:"vertical",items:fe}),u(u({},t),{},{type:"next",hasNullItem:ve}));return u(u({},pe),{},{orientation:o,items:a});case"first":var me=Se(a);return $t(e,u(u({},t),{},{type:"move",id:null==me?void 0:me.id}));case"last":var be=$t(u(u({},e),{},{items:Pe(a)}),u(u({},t),{},{type:"first"}));return u(u({},be),{},{items:a});case"sort":return u(u({},e),{},{items:Ut(a),groups:Ut(i)});case"setVirtual":return u(u({},e),{},{unstable_virtual:Bt(t.virtual,n)});case"setRTL":return u(u({},e),{},{rtl:Bt(t.rtl,r)});case"setOrientation":return u(u({},e),{},{orientation:Bt(t.orientation,o)});case"setCurrentId":var ge=Re(u(u({},e),{},{currentId:Bt(t.currentId,s)}));return u(u({},e),{},{currentId:ge,hasSetCurrentId:!0});case"setLoop":return u(u({},e),{},{loop:Bt(t.loop,l)});case"setWrap":return u(u({},e),{},{wrap:Bt(t.wrap,c)});case"setShift":return u(u({},e),{},{shift:Bt(t.shift,f)});case"setIncludesBaseElement":return u(u({},e),{},{unstable_includesBaseElement:Bt(t.includesBaseElement,p)});case"reset":return u(u({},e),{},{unstable_virtual:m,rtl:b,orientation:g,currentId:Re(u(u({},e),{},{currentId:h})),loop:y,wrap:_,shift:k,unstable_moves:0,pastIds:[]});case"setItems":return u(u({},e),{},{items:t.items});default:throw new Error}}function Zt(e){return t.useCallback(e,[])}function Jt(e){void 0===e&&(e={});var n=ye(e),r=n.unstable_virtual,o=void 0!==r&&r,i=n.rtl,s=void 0!==i&&i,l=n.orientation,c=n.currentId,d=n.loop,f=void 0!==d&&d,v=n.wrap,p=void 0!==v&&v,m=n.shift,b=void 0!==m&&m,g=n.unstable_includesBaseElement,h=Lt(a(n,["unstable_virtual","rtl","orientation","currentId","loop","wrap","shift","unstable_includesBaseElement"])),y=t.useReducer($t,{unstable_virtual:o,rtl:s,orientation:l,items:[],groups:[],currentId:c,loop:f,wrap:p,shift:b,unstable_moves:0,pastIds:[],unstable_includesBaseElement:null!=g?g:null===c,initialVirtual:o,initialRTL:s,initialOrientation:l,initialCurrentId:c,initialLoop:f,initialWrap:p,initialShift:b}),_=y[0],k=(_.pastIds,_.initialVirtual,_.initialRTL,_.initialOrientation,_.initialCurrentId,_.initialLoop,_.initialWrap,_.initialShift,_.hasSetCurrentId,a(_,["pastIds","initialVirtual","initialRTL","initialOrientation","initialCurrentId","initialLoop","initialWrap","initialShift","hasSetCurrentId"])),w=y[1],I=t.useState(!1),C=I[0],E=I[1],O=function(){var e=t.useRef(!1);return V((function(){return function(){e.current=!0}}),[]),e}(),x=t.useCallback((function(e){return w({type:"setItems",items:e})}),[]);return Yt(k.items,x),u(u(u({},h),k),{},{unstable_hasActiveWidget:C,unstable_setHasActiveWidget:E,registerItem:Zt((function(e){O.current||w({type:"registerItem",item:e})})),unregisterItem:Zt((function(e){O.current||w({type:"unregisterItem",id:e})})),registerGroup:Zt((function(e){O.current||w({type:"registerGroup",group:e})})),unregisterGroup:Zt((function(e){O.current||w({type:"unregisterGroup",id:e})})),move:Zt((function(e){return w({type:"move",id:e})})),next:Zt((function(e){return w({type:"next",allTheWay:e})})),previous:Zt((function(e){return w({type:"previous",allTheWay:e})})),up:Zt((function(e){return w({type:"up",allTheWay:e})})),down:Zt((function(e){return w({type:"down",allTheWay:e})})),first:Zt((function(){return w({type:"first"})})),last:Zt((function(){return w({type:"last"})})),sort:Zt((function(){return w({type:"sort"})})),unstable_setVirtual:Zt((function(e){return w({type:"setVirtual",virtual:e})})),setRTL:Zt((function(e){return w({type:"setRTL",rtl:e})})),setOrientation:Zt((function(e){return w({type:"setOrientation",orientation:e})})),setCurrentId:Zt((function(e){return w({type:"setCurrentId",currentId:e})})),setLoop:Zt((function(e){return w({type:"setLoop",loop:e})})),setWrap:Zt((function(e){return w({type:"setWrap",wrap:e})})),setShift:Zt((function(e){return w({type:"setShift",shift:e})})),unstable_setIncludesBaseElement:Zt((function(e){return w({type:"setIncludesBaseElement",includesBaseElement:e})})),reset:Zt((function(){return w({type:"reset"})}))})}function Qt(e){return void 0===e&&(e={}),Jt(ye(e))}function en(e,n){var r=void 0===n?{}:n,o=r.inputValue,a=void 0===o?"":o,i=r.minValueLength,l=void 0===i?0:i,c=r.values,d=void 0===c?[]:c,f=r.limit,v=void 0===f?10:f,p=r.list,m=void 0===p?!!d.length:p,b=r.inline,g=void 0!==b&&b,h=r.autoSelect,y=void 0!==h&&h,_=t.useRef({}),k=t.useState(a),w=k[0],I=k[1],C=t.useState(l),E=C[0],O=C[1],x=t.useState(d),S=x[0],P=x[1],R=t.useState(v),A=R[0],T=R[1],D=t.useState(m),M=D[0],B=D[1],L=t.useState(g),j=L[0],H=L[1],F=t.useState(y),V=F[0],K=F[1],W=t.useMemo((function(){return function(e,t,n,r,o,u){if(0===n||e.length<u)return[];var a=!1===n?void 0:n;if(!r)return t.slice(0,a);var i=new RegExp(e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"i"),l=[];if(o){var c=t.find((function(e){return 0===e.search(i)}));c&&l.push(c)}for(var d,f=s(t);!(d=f()).done;){var v=d.value;if(a&&l.length>=a)break;v!==l[0]&&-1!==v.search(i)&&l.push(v)}return l}(w,S,A,M,V,E)}),[w,S,A,M,V,E]),G=t.useMemo((function(){return e.currentId?_.current[e.currentId]:void 0}),[_,e.currentId]),N=t.useMemo((function(){return e.items.forEach((function(e){e.id&&(e.value=_.current[e.id])})),e.items}),[e.items]),q=t.useCallback((function(t){e.registerItem(t),t.id&&(_.current[t.id]=t.value)}),[e.registerItem]),U=t.useCallback((function(t){e.unregisterItem(t),delete _.current[t]}),[e.unregisterItem]);return u(u({},e),{},{menuRole:"listbox",items:N,registerItem:q,unregisterItem:U,visible:!0,inputValue:w,minValueLength:E,currentValue:G,values:S,limit:A,matches:W,list:M,inline:j,autoSelect:V,setInputValue:I,setMinValueLength:O,setValues:P,setLimit:T,setList:B,setInline:H,setAutoSelect:K})}function tn(e){void 0===e&&(e={});var n=ye(e),r=n.columns,o=void 0===r?1:r,i=n.currentId,s=void 0===i?null:i,l=n.loop,c=void 0===l||l,d=a(n,["columns","currentId","loop"]),f=t.useState(o),v=f[0],p=f[1],m=en(Qt(u(u({currentId:s,loop:c},d),{},{unstable_virtual:!0,unstable_includesBaseElement:!0})),d),b=t.useMemo((function(){return function(e,t){for(var n=[],r=0,o=e.length;r<o;r+=t)n.push(e.slice(r,r+t));return n}(m.matches,v)}),[m.matches,v]);return u(u({},m),{},{menuRole:"grid",columns:v,matches:b,setColumns:p})}var nn="top",rn="bottom",on="right",un="left",an="auto",sn=[nn,rn,on,un],ln="start",cn="end",dn="viewport",fn="popper",vn=sn.reduce((function(e,t){return e.concat([t+"-"+ln,t+"-"+cn])}),[]),pn=[].concat(sn,[an]).reduce((function(e,t){return e.concat([t,t+"-"+ln,t+"-"+cn])}),[]),mn=["beforeRead","read","afterRead","beforeMain","main","afterMain","beforeWrite","write","afterWrite"];function bn(e){return e?(e.nodeName||"").toLowerCase():null}function gn(e){if("[object Window]"!==e.toString()){var t=e.ownerDocument;return t&&t.defaultView||window}return e}function hn(e){return e instanceof gn(e).Element||e instanceof Element}function yn(e){return e instanceof gn(e).HTMLElement||e instanceof HTMLElement}function _n(e){return e.split("-")[0]}function kn(e){return{x:e.offsetLeft,y:e.offsetTop,width:e.offsetWidth,height:e.offsetHeight}}function wn(e,t){var n,r=t.getRootNode&&t.getRootNode();if(e.contains(t))return!0;if(r&&((n=r)instanceof gn(n).ShadowRoot||n instanceof ShadowRoot)){var o=t;do{if(o&&e.isSameNode(o))return!0;o=o.parentNode||o.host}while(o)}return!1}function In(e){return gn(e).getComputedStyle(e)}function Cn(e){return["table","td","th"].indexOf(bn(e))>=0}function En(e){return((hn(e)?e.ownerDocument:e.document)||window.document).documentElement}function On(e){return"html"===bn(e)?e:e.assignedSlot||e.parentNode||e.host||En(e)}function xn(e){if(!yn(e)||"fixed"===In(e).position)return null;var t=e.offsetParent;if(t){var n=En(t);if("body"===bn(t)&&"static"===In(t).position&&"static"!==In(n).position)return n}return t}function Sn(e){for(var t=gn(e),n=xn(e);n&&Cn(n)&&"static"===In(n).position;)n=xn(n);return n&&"body"===bn(n)&&"static"===In(n).position?t:n||function(e){for(var t=On(e);yn(t)&&["html","body"].indexOf(bn(t))<0;){var n=In(t);if("none"!==n.transform||"none"!==n.perspective||n.willChange&&"auto"!==n.willChange)return t;t=t.parentNode}return null}(e)||t}function Pn(e){return["top","bottom"].indexOf(e)>=0?"x":"y"}function Rn(e,t,n){return Math.max(e,Math.min(t,n))}function An(e){return Object.assign(Object.assign({},{top:0,right:0,bottom:0,left:0}),e)}function Tn(e,t){return t.reduce((function(t,n){return t[n]=e,t}),{})}var Dn={top:"auto",right:"auto",bottom:"auto",left:"auto"};function Mn(e){var t,n=e.popper,r=e.popperRect,o=e.placement,u=e.offsets,a=e.position,i=e.gpuAcceleration,s=e.adaptive,l=function(e){var t=e.x,n=e.y,r=window.devicePixelRatio||1;return{x:Math.round(t*r)/r||0,y:Math.round(n*r)/r||0}}(u),c=l.x,d=l.y,f=u.hasOwnProperty("x"),v=u.hasOwnProperty("y"),p=un,m=nn,b=window;if(s){var g=Sn(n);g===gn(n)&&(g=En(n)),o===nn&&(m=rn,d-=g.clientHeight-r.height,d*=i?1:-1),o===un&&(p=on,c-=g.clientWidth-r.width,c*=i?1:-1)}var h,y=Object.assign({position:a},s&&Dn);return i?Object.assign(Object.assign({},y),{},((h={})[m]=v?"0":"",h[p]=f?"0":"",h.transform=(b.devicePixelRatio||1)<2?"translate("+c+"px, "+d+"px)":"translate3d("+c+"px, "+d+"px, 0)",h)):Object.assign(Object.assign({},y),{},((t={})[m]=v?d+"px":"",t[p]=f?c+"px":"",t.transform="",t))}var Bn={passive:!0};var Ln={left:"right",right:"left",bottom:"top",top:"bottom"};function jn(e){return e.replace(/left|right|bottom|top/g,(function(e){return Ln[e]}))}var Hn={start:"end",end:"start"};function Fn(e){return e.replace(/start|end/g,(function(e){return Hn[e]}))}function Vn(e){var t=e.getBoundin