downshift 6.1.9 → 6.1.10

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.
@@ -1,2 +1,2 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Downshift={},e.React)}(this,(function(e,t){"use strict";var n={exports:{}},i={},o="function"==typeof Symbol&&Symbol.for,r=o?Symbol.for("react.element"):60103,s=o?Symbol.for("react.portal"):60106,u=o?Symbol.for("react.fragment"):60107,l=o?Symbol.for("react.strict_mode"):60108,a=o?Symbol.for("react.profiler"):60114,c=o?Symbol.for("react.provider"):60109,d=o?Symbol.for("react.context"):60110,h=o?Symbol.for("react.async_mode"):60111,p=o?Symbol.for("react.concurrent_mode"):60111,g=o?Symbol.for("react.forward_ref"):60112,m=o?Symbol.for("react.suspense"):60113,f=o?Symbol.for("react.suspense_list"):60120,I=o?Symbol.for("react.memo"):60115,y=o?Symbol.for("react.lazy"):60116,v=o?Symbol.for("react.block"):60121,b=o?Symbol.for("react.fundamental"):60117,x=o?Symbol.for("react.responder"):60118,w=o?Symbol.for("react.scope"):60119;function S(e){if("object"==typeof e&&null!==e){var t=e.$$typeof;switch(t){case r:switch(e=e.type){case h:case p:case u:case a:case l:case m:return e;default:switch(e=e&&e.$$typeof){case d:case g:case y:case I:case c:return e;default:return t}}case s:return t}}}function C(e){return S(e)===p}i.AsyncMode=h,i.ConcurrentMode=p,i.ContextConsumer=d,i.ContextProvider=c,i.Element=r,i.ForwardRef=g,i.Fragment=u,i.Lazy=y,i.Memo=I,i.Portal=s,i.Profiler=a,i.StrictMode=l,i.Suspense=m,i.isAsyncMode=function(e){return C(e)||S(e)===h},i.isConcurrentMode=C,i.isContextConsumer=function(e){return S(e)===d},i.isContextProvider=function(e){return S(e)===c},i.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===r},i.isForwardRef=function(e){return S(e)===g},i.isFragment=function(e){return S(e)===u},i.isLazy=function(e){return S(e)===y},i.isMemo=function(e){return S(e)===I},i.isPortal=function(e){return S(e)===s},i.isProfiler=function(e){return S(e)===a},i.isStrictMode=function(e){return S(e)===l},i.isSuspense=function(e){return S(e)===m},i.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===u||e===p||e===a||e===l||e===m||e===f||"object"==typeof e&&null!==e&&(e.$$typeof===y||e.$$typeof===I||e.$$typeof===c||e.$$typeof===d||e.$$typeof===g||e.$$typeof===b||e.$$typeof===x||e.$$typeof===w||e.$$typeof===v)},i.typeOf=S;function k(){}function M(){}M.resetWarningCache=k;n.exports=function(){function e(e,t,n,i,o,r){if("SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"!==r){var s=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw s.name="Invariant Violation",s}}function t(){return e}e.isRequired=e;var n={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:M,resetWarningCache:k};return n.PropTypes=n,n}();var E=n.exports,O={},D=60103,R=60106,P=60107,T=60108,K=60114,H=60109,F=60110,V=60112,A=60113,N=60120,L=60115,B=60116,_=60121,$=60122,j=60117,U=60129,W=60131;if("function"==typeof Symbol&&Symbol.for){var z=Symbol.for;D=z("react.element"),R=z("react.portal"),P=z("react.fragment"),T=z("react.strict_mode"),K=z("react.profiler"),H=z("react.provider"),F=z("react.context"),V=z("react.forward_ref"),A=z("react.suspense"),N=z("react.suspense_list"),L=z("react.memo"),B=z("react.lazy"),_=z("react.block"),$=z("react.server.block"),j=z("react.fundamental"),U=z("react.debug_trace_mode"),W=z("react.legacy_hidden")}function q(e){if("object"==typeof e&&null!==e){var t=e.$$typeof;switch(t){case D:switch(e=e.type){case P:case K:case T:case A:case N:return e;default:switch(e=e&&e.$$typeof){case F:case V:case B:case L:case H:return e;default:return t}}case R:return t}}}var Y=H,X=D,G=V,J=P,Q=B,Z=L,ee=R,te=K,ne=T,ie=A;function oe(e){return"object"==typeof e&&null!=e&&1===e.nodeType}function re(e,t){return(!t||"hidden"!==e)&&"visible"!==e&&"clip"!==e}function se(e,t){if(e.clientHeight<e.scrollHeight||e.clientWidth<e.scrollWidth){var n=getComputedStyle(e,null);return re(n.overflowY,t)||re(n.overflowX,t)||function(e){var t=function(e){if(!e.ownerDocument||!e.ownerDocument.defaultView)return null;try{return e.ownerDocument.defaultView.frameElement}catch(e){return null}}(e);return!!t&&(t.clientHeight<e.scrollHeight||t.clientWidth<e.scrollWidth)}(e)}return!1}function ue(e,t,n,i,o,r,s,u){return r<e&&s>t||r>e&&s<t?0:r<=e&&u<=n||s>=t&&u>=n?r-e-i:s>t&&u<n||r<e&&u>n?s-t+o:0}O.ContextConsumer=F,O.ContextProvider=Y,O.Element=X,O.ForwardRef=G,O.Fragment=J,O.Lazy=Q,O.Memo=Z,O.Portal=ee,O.Profiler=te,O.StrictMode=ne,O.Suspense=ie,O.isAsyncMode=function(){return!1},O.isConcurrentMode=function(){return!1},O.isContextConsumer=function(e){return q(e)===F},O.isContextProvider=function(e){return q(e)===H},O.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===D},O.isForwardRef=function(e){return q(e)===V},O.isFragment=function(e){return q(e)===P},O.isLazy=function(e){return q(e)===B},O.isMemo=function(e){return q(e)===L},O.isPortal=function(e){return q(e)===R},O.isProfiler=function(e){return q(e)===K},O.isStrictMode=function(e){return q(e)===T},O.isSuspense=function(e){return q(e)===A},O.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===P||e===K||e===U||e===T||e===A||e===N||e===W||"object"==typeof e&&null!==e&&(e.$$typeof===B||e.$$typeof===L||e.$$typeof===H||e.$$typeof===F||e.$$typeof===V||e.$$typeof===j||e.$$typeof===_||e[0]===$)},O.typeOf=q;let le=0;function ae(e){return"function"==typeof e?e:ce}function ce(){}function de(e,t){if(!e)return;const n=function(e,t){var n=window,i=t.scrollMode,o=t.block,r=t.inline,s=t.boundary,u=t.skipOverflowHiddenElements,l="function"==typeof s?s:function(e){return e!==s};if(!oe(e))throw new TypeError("Invalid target");for(var a=document.scrollingElement||document.documentElement,c=[],d=e;oe(d)&&l(d);){if((d=d.parentElement)===a){c.push(d);break}null!=d&&d===document.body&&se(d)&&!se(document.documentElement)||null!=d&&se(d,u)&&c.push(d)}for(var h=n.visualViewport?n.visualViewport.width:innerWidth,p=n.visualViewport?n.visualViewport.height:innerHeight,g=window.scrollX||pageXOffset,m=window.scrollY||pageYOffset,f=e.getBoundingClientRect(),I=f.height,y=f.width,v=f.top,b=f.right,x=f.bottom,w=f.left,S="start"===o||"nearest"===o?v:"end"===o?x:v+I/2,C="center"===r?w+y/2:"end"===r?b:w,k=[],M=0;M<c.length;M++){var E=c[M],O=E.getBoundingClientRect(),D=O.height,R=O.width,P=O.top,T=O.right,K=O.bottom,H=O.left;if("if-needed"===i&&v>=0&&w>=0&&x<=p&&b<=h&&v>=P&&x<=K&&w>=H&&b<=T)return k;var F=getComputedStyle(E),V=parseInt(F.borderLeftWidth,10),A=parseInt(F.borderTopWidth,10),N=parseInt(F.borderRightWidth,10),L=parseInt(F.borderBottomWidth,10),B=0,_=0,$="offsetWidth"in E?E.offsetWidth-E.clientWidth-V-N:0,j="offsetHeight"in E?E.offsetHeight-E.clientHeight-A-L:0;if(a===E)B="start"===o?S:"end"===o?S-p:"nearest"===o?ue(m,m+p,p,A,L,m+S,m+S+I,I):S-p/2,_="start"===r?C:"center"===r?C-h/2:"end"===r?C-h:ue(g,g+h,h,V,N,g+C,g+C+y,y),B=Math.max(0,B+m),_=Math.max(0,_+g);else{B="start"===o?S-P-A:"end"===o?S-K+L+j:"nearest"===o?ue(P,K,D,A,L+j,S,S+I,I):S-(P+D/2)+j/2,_="start"===r?C-H-V:"center"===r?C-(H+R/2)+$/2:"end"===r?C-T+N+$:ue(H,T,R,V,N+$,C,C+y,y);var U=E.scrollLeft,W=E.scrollTop;S+=W-(B=Math.max(0,Math.min(W+B,E.scrollHeight-D+j))),C+=U-(_=Math.max(0,Math.min(U+_,E.scrollWidth-R+$)))}k.push({el:E,top:B,left:_})}return k}(e,{boundary:t,block:"nearest",scrollMode:"if-needed"});n.forEach((e=>{let{el:t,top:n,left:i}=e;t.scrollTop=n,t.scrollLeft=i}))}function he(e,t,n){return e===t||t instanceof n.Node&&e.contains&&e.contains(t)}function pe(e,t){let n;function i(){n&&clearTimeout(n)}function o(){for(var o=arguments.length,r=new Array(o),s=0;s<o;s++)r[s]=arguments[s];i(),n=setTimeout((()=>{n=null,e(...r)}),t)}return o.cancel=i,o}function ge(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(e){for(var n=arguments.length,i=new Array(n>1?n-1:0),o=1;o<n;o++)i[o-1]=arguments[o];return t.some((t=>(t&&t(e,...i),e.preventDownshiftDefault||e.hasOwnProperty("nativeEvent")&&e.nativeEvent.preventDownshiftDefault)))}}function me(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return e=>{t.forEach((t=>{"function"==typeof t?t(e):t&&(t.current=e)}))}}function fe(){return String(le++)}function Ie(e){let{isOpen:t,resultCount:n,previousResultCount:i}=e;return t?n?n!==i?n+" result"+(1===n?" is":"s are")+" available, use up and down arrow keys to navigate. Press Enter key to select.":"":"No results are available.":""}function ye(e,t){return!(e=Array.isArray(e)?e[0]:e)&&t?t:e}const ve=["highlightedIndex","inputValue","isOpen","selectedItem","type"];function be(e){void 0===e&&(e={});const t={};return ve.forEach((n=>{e.hasOwnProperty(n)&&(t[n]=e[n])})),t}function xe(e,t){return Object.keys(e).reduce(((n,i)=>(n[i]=we(t,i)?t[i]:e[i],n)),{})}function we(e,t){return void 0!==e[t]}function Se(e){const{key:t,keyCode:n}=e;return n>=37&&n<=40&&0!==t.indexOf("Arrow")?"Arrow"+t:t}function Ce(e,t,n,i,o){if(void 0===o&&(o=!0),0===n)return-1;const r=n-1;("number"!=typeof t||t<0||t>=n)&&(t=e>0?-1:r+1);let s=t+e;s<0?s=o?r:0:s>r&&(s=o?0:r);const u=ke(e,s,n,i,o);return-1===u?t>=n?-1:t:u}function ke(e,t,n,i,o){const r=i(t);if(!r||!r.hasAttribute("disabled"))return t;if(e>0){for(let e=t+1;e<n;e++)if(!i(e).hasAttribute("disabled"))return e}else for(let e=t-1;e>=0;e--)if(!i(e).hasAttribute("disabled"))return e;return o?e>0?ke(1,0,n,i,!1):ke(-1,n-1,n,i,!1):-1}function Me(e,t,n,i){return void 0===i&&(i=!0),t.some((t=>t&&(he(t,e,n)||i&&he(t,n.document.activeElement,n))))}const Ee=pe((e=>{De(e).textContent=""}),500);function Oe(e,t){const n=De(t);e&&(n.textContent=e,Ee(t))}function De(e){void 0===e&&(e=document);let t=e.getElementById("a11y-status-message");return t||(t=e.createElement("div"),t.setAttribute("id","a11y-status-message"),t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t.setAttribute("aria-relevant","additions text"),Object.assign(t.style,{border:"0",clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:"0",position:"absolute",width:"1px"}),e.body.appendChild(t),t)}var Re=Object.freeze({__proto__:null,unknown:0,mouseUp:1,itemMouseEnter:2,keyDownArrowUp:3,keyDownArrowDown:4,keyDownEscape:5,keyDownEnter:6,keyDownHome:7,keyDownEnd:8,clickItem:9,blurInput:10,changeInput:11,keyDownSpaceButton:12,clickButton:13,blurButton:14,controlledPropUpdatedSelectedItem:15,touchEnd:16});const Pe=(()=>{class e extends t.Component{constructor(e){var t;super(e),t=this,this.id=this.props.id||"downshift-"+fe(),this.menuId=this.props.menuId||this.id+"-menu",this.labelId=this.props.labelId||this.id+"-label",this.inputId=this.props.inputId||this.id+"-input",this.getItemId=this.props.getItemId||(e=>this.id+"-item-"+e),this.input=null,this.items=[],this.itemCount=null,this.previousResultCount=0,this.timeoutIds=[],this.internalSetTimeout=(e,t)=>{const n=setTimeout((()=>{this.timeoutIds=this.timeoutIds.filter((e=>e!==n)),e()}),t);this.timeoutIds.push(n)},this.setItemCount=e=>{this.itemCount=e},this.unsetItemCount=()=>{this.itemCount=null},this.setHighlightedIndex=function(e,n){void 0===e&&(e=t.props.defaultHighlightedIndex),void 0===n&&(n={}),n=be(n),t.internalSetState({highlightedIndex:e,...n})},this.clearSelection=e=>{this.internalSetState({selectedItem:null,inputValue:"",highlightedIndex:this.props.defaultHighlightedIndex,isOpen:this.props.defaultIsOpen},e)},this.selectItem=(e,t,n)=>{t=be(t),this.internalSetState({isOpen:this.props.defaultIsOpen,highlightedIndex:this.props.defaultHighlightedIndex,selectedItem:e,inputValue:this.props.itemToString(e),...t},n)},this.selectItemAtIndex=(e,t,n)=>{const i=this.items[e];null!=i&&this.selectItem(i,t,n)},this.selectHighlightedItem=(e,t)=>this.selectItemAtIndex(this.getState().highlightedIndex,e,t),this.internalSetState=(e,t)=>{let n,i;const o={},r="function"==typeof e;return!r&&e.hasOwnProperty("inputValue")&&this.props.onInputValueChange(e.inputValue,{...this.getStateAndHelpers(),...e}),this.setState((t=>{t=this.getState(t);let s=r?e(t):e;s=this.props.stateReducer(t,s),n=s.hasOwnProperty("selectedItem");const u={};return n&&s.selectedItem!==t.selectedItem&&(i=s.selectedItem),s.type=s.type||0,Object.keys(s).forEach((e=>{t[e]!==s[e]&&(o[e]=s[e]),"type"!==e&&(s[e],we(this.props,e)||(u[e]=s[e]))})),r&&s.hasOwnProperty("inputValue")&&this.props.onInputValueChange(s.inputValue,{...this.getStateAndHelpers(),...s}),u}),(()=>{ae(t)();Object.keys(o).length>1&&this.props.onStateChange(o,this.getStateAndHelpers()),n&&this.props.onSelect(e.selectedItem,this.getStateAndHelpers()),void 0!==i&&this.props.onChange(i,this.getStateAndHelpers()),this.props.onUserAction(o,this.getStateAndHelpers())}))},this.rootRef=e=>this._rootNode=e,this.getRootProps=function(e,n){let{refKey:i="ref",ref:o,...r}=void 0===e?{}:e,{suppressRefError:s=!1}=void 0===n?{}:n;t.getRootProps.called=!0,t.getRootProps.refKey=i,t.getRootProps.suppressRefError=s;const{isOpen:u}=t.getState();return{[i]:me(o,t.rootRef),role:"combobox","aria-expanded":u,"aria-haspopup":"listbox","aria-owns":u?t.menuId:null,"aria-labelledby":t.labelId,...r}},this.keyDownHandlers={ArrowDown(e){if(e.preventDefault(),this.getState().isOpen){const t=e.shiftKey?5:1;this.moveHighlightedIndex(t,{type:4})}else this.internalSetState({isOpen:!0,type:4},(()=>{const e=this.getItemCount();if(e>0){const{highlightedIndex:t}=this.getState(),n=Ce(1,t,e,(e=>this.getItemNodeFromIndex(e)));this.setHighlightedIndex(n,{type:4})}}))},ArrowUp(e){if(e.preventDefault(),this.getState().isOpen){const t=e.shiftKey?-5:-1;this.moveHighlightedIndex(t,{type:3})}else this.internalSetState({isOpen:!0,type:3},(()=>{const e=this.getItemCount();if(e>0){const{highlightedIndex:t}=this.getState(),n=Ce(-1,t,e,(e=>this.getItemNodeFromIndex(e)));this.setHighlightedIndex(n,{type:3})}}))},Enter(e){if(229===e.which)return;const{isOpen:t,highlightedIndex:n}=this.getState();if(t&&null!=n){e.preventDefault();const t=this.items[n],i=this.getItemNodeFromIndex(n);if(null==t||i&&i.hasAttribute("disabled"))return;this.selectHighlightedItem({type:6})}},Escape(e){e.preventDefault(),this.reset({type:5,...!this.state.isOpen&&{selectedItem:null,inputValue:""}})}},this.buttonKeyDownHandlers={...this.keyDownHandlers," "(e){e.preventDefault(),this.toggleMenu({type:12})}},this.inputKeyDownHandlers={...this.keyDownHandlers,Home(e){const{isOpen:t}=this.getState();if(!t)return;e.preventDefault();const n=this.getItemCount();if(n<=0||!t)return;const i=ke(1,0,n,(e=>this.getItemNodeFromIndex(e)),!1);this.setHighlightedIndex(i,{type:7})},End(e){const{isOpen:t}=this.getState();if(!t)return;e.preventDefault();const n=this.getItemCount();if(n<=0||!t)return;const i=ke(-1,n-1,n,(e=>this.getItemNodeFromIndex(e)),!1);this.setHighlightedIndex(i,{type:8})}},this.getToggleButtonProps=function(e){let{onClick:n,onPress:i,onKeyDown:o,onKeyUp:r,onBlur:s,...u}=void 0===e?{}:e;const{isOpen:l}=t.getState(),a={onClick:ge(n,t.buttonHandleClick),onKeyDown:ge(o,t.buttonHandleKeyDown),onKeyUp:ge(r,t.buttonHandleKeyUp),onBlur:ge(s,t.buttonHandleBlur)};return{type:"button",role:"button","aria-label":l?"close menu":"open menu","aria-haspopup":!0,"data-toggle":!0,...u.disabled?{}:a,...u}},this.buttonHandleKeyUp=e=>{e.preventDefault()},this.buttonHandleKeyDown=e=>{const t=Se(e);this.buttonKeyDownHandlers[t]&&this.buttonKeyDownHandlers[t].call(this,e)},this.buttonHandleClick=e=>{e.preventDefault(),this.props.environment.document.activeElement===this.props.environment.document.body&&e.target.focus(),this.internalSetTimeout((()=>this.toggleMenu({type:13})))},this.buttonHandleBlur=e=>{const t=e.target;this.internalSetTimeout((()=>{this.isMouseDown||null!=this.props.environment.document.activeElement&&this.props.environment.document.activeElement.id===this.inputId||this.props.environment.document.activeElement===t||this.reset({type:14})}))},this.getLabelProps=e=>({htmlFor:this.inputId,id:this.labelId,...e}),this.getInputProps=function(e){let n,{onKeyDown:i,onBlur:o,onChange:r,onInput:s,onChangeText:u,...l}=void 0===e?{}:e,a={};n="onChange";const{inputValue:c,isOpen:d,highlightedIndex:h}=t.getState();return l.disabled||(a={onChange:ge(r,s,t.inputHandleChange),onKeyDown:ge(i,t.inputHandleKeyDown),onBlur:ge(o,t.inputHandleBlur)}),{"aria-autocomplete":"list","aria-activedescendant":d&&"number"==typeof h&&h>=0?t.getItemId(h):null,"aria-controls":d?t.menuId:null,"aria-labelledby":t.labelId,autoComplete:"off",value:c,id:t.inputId,...a,...l}},this.inputHandleKeyDown=e=>{const t=Se(e);t&&this.inputKeyDownHandlers[t]&&this.inputKeyDownHandlers[t].call(this,e)},this.inputHandleChange=e=>{this.internalSetState({type:11,isOpen:!0,inputValue:e.target.value,highlightedIndex:this.props.defaultHighlightedIndex})},this.inputHandleBlur=()=>{this.internalSetTimeout((()=>{const e=this.props.environment.document&&!!this.props.environment.document.activeElement&&!!this.props.environment.document.activeElement.dataset&&this.props.environment.document.activeElement.dataset.toggle&&this._rootNode&&this._rootNode.contains(this.props.environment.document.activeElement);this.isMouseDown||e||this.reset({type:10})}))},this.menuRef=e=>{this._menuNode=e},this.getMenuProps=function(e,n){let{refKey:i="ref",ref:o,...r}=void 0===e?{}:e,{suppressRefError:s=!1}=void 0===n?{}:n;return t.getMenuProps.called=!0,t.getMenuProps.refKey=i,t.getMenuProps.suppressRefError=s,{[i]:me(o,t.menuRef),role:"listbox","aria-labelledby":r&&r["aria-label"]?null:t.labelId,id:t.menuId,...r}},this.getItemProps=function(e){let{onMouseMove:n,onMouseDown:i,onClick:o,onPress:r,index:s,item:u,...l}=void 0===e?{}:e;void 0===s?(t.items.push(u),s=t.items.indexOf(u)):t.items[s]=u;const a=o,c={onMouseMove:ge(n,(()=>{s!==t.getState().highlightedIndex&&(t.setHighlightedIndex(s,{type:2}),t.avoidScrolling=!0,t.internalSetTimeout((()=>t.avoidScrolling=!1),250))})),onMouseDown:ge(i,(e=>{e.preventDefault()})),onClick:ge(a,(()=>{t.selectItemAtIndex(s,{type:9})}))},d=l.disabled?{onMouseDown:c.onMouseDown}:c;return{id:t.getItemId(s),role:"option","aria-selected":t.getState().highlightedIndex===s,...d,...l}},this.clearItems=()=>{this.items=[]},this.reset=function(e,n){void 0===e&&(e={}),e=be(e),t.internalSetState((n=>{let{selectedItem:i}=n;return{isOpen:t.props.defaultIsOpen,highlightedIndex:t.props.defaultHighlightedIndex,inputValue:t.props.itemToString(i),...e}}),n)},this.toggleMenu=function(e,n){void 0===e&&(e={}),e=be(e),t.internalSetState((n=>{let{isOpen:i}=n;return{isOpen:!i,...i&&{highlightedIndex:t.props.defaultHighlightedIndex},...e}}),(()=>{const{isOpen:i,highlightedIndex:o}=t.getState();i&&t.getItemCount()>0&&"number"==typeof o&&t.setHighlightedIndex(o,e),ae(n)()}))},this.openMenu=e=>{this.internalSetState({isOpen:!0},e)},this.closeMenu=e=>{this.internalSetState({isOpen:!1},e)},this.updateStatus=pe((()=>{const e=this.getState(),t=this.items[e.highlightedIndex],n=this.getItemCount(),i=this.props.getA11yStatusMessage({itemToString:this.props.itemToString,previousResultCount:this.previousResultCount,resultCount:n,highlightedItem:t,...e});this.previousResultCount=n,Oe(i,this.props.environment.document)}),200);const{defaultHighlightedIndex:n,initialHighlightedIndex:i=n,defaultIsOpen:o,initialIsOpen:r=o,initialInputValue:s="",initialSelectedItem:u=null}=this.props,l=this.getState({highlightedIndex:i,isOpen:r,inputValue:s,selectedItem:u});null!=l.selectedItem&&void 0===this.props.initialInputValue&&(l.inputValue=this.props.itemToString(l.selectedItem)),this.state=l}internalClearTimeouts(){this.timeoutIds.forEach((e=>{clearTimeout(e)})),this.timeoutIds=[]}getState(e){return void 0===e&&(e=this.state),xe(e,this.props)}getItemCount(){let e=this.items.length;return null!=this.itemCount?e=this.itemCount:void 0!==this.props.itemCount&&(e=this.props.itemCount),e}getItemNodeFromIndex(e){return this.props.environment.document.getElementById(this.getItemId(e))}scrollHighlightedItemIntoView(){{const e=this.getItemNodeFromIndex(this.getState().highlightedIndex);this.props.scrollIntoView(e,this._menuNode)}}moveHighlightedIndex(e,t){const n=this.getItemCount(),{highlightedIndex:i}=this.getState();if(n>0){const o=Ce(e,i,n,(e=>this.getItemNodeFromIndex(e)));this.setHighlightedIndex(o,t)}}getStateAndHelpers(){const{highlightedIndex:e,inputValue:t,selectedItem:n,isOpen:i}=this.getState(),{itemToString:o}=this.props,{id:r}=this,{getRootProps:s,getToggleButtonProps:u,getLabelProps:l,getMenuProps:a,getInputProps:c,getItemProps:d,openMenu:h,closeMenu:p,toggleMenu:g,selectItem:m,selectItemAtIndex:f,selectHighlightedItem:I,setHighlightedIndex:y,clearSelection:v,clearItems:b,reset:x,setItemCount:w,unsetItemCount:S,internalSetState:C}=this;return{getRootProps:s,getToggleButtonProps:u,getLabelProps:l,getMenuProps:a,getInputProps:c,getItemProps:d,reset:x,openMenu:h,closeMenu:p,toggleMenu:g,selectItem:m,selectItemAtIndex:f,selectHighlightedItem:I,setHighlightedIndex:y,clearSelection:v,clearItems:b,setItemCount:w,unsetItemCount:S,setState:C,itemToString:o,id:r,highlightedIndex:e,inputValue:t,isOpen:i,selectedItem:n}}componentDidMount(){{const e=()=>{this.isMouseDown=!0},t=e=>{this.isMouseDown=!1;!Me(e.target,[this._rootNode,this._menuNode],this.props.environment)&&this.getState().isOpen&&this.reset({type:1},(()=>this.props.onOuterClick(this.getStateAndHelpers())))},n=()=>{this.isTouchMove=!1},i=()=>{this.isTouchMove=!0},o=e=>{const t=Me(e.target,[this._rootNode,this._menuNode],this.props.environment,!1);this.isTouchMove||t||!this.getState().isOpen||this.reset({type:16},(()=>this.props.onOuterClick(this.getStateAndHelpers())))},{environment:r}=this.props;r.addEventListener("mousedown",e),r.addEventListener("mouseup",t),r.addEventListener("touchstart",n),r.addEventListener("touchmove",i),r.addEventListener("touchend",o),this.cleanup=()=>{this.internalClearTimeouts(),this.updateStatus.cancel(),r.removeEventListener("mousedown",e),r.removeEventListener("mouseup",t),r.removeEventListener("touchstart",n),r.removeEventListener("touchmove",i),r.removeEventListener("touchend",o)}}}shouldScroll(e,t){const{highlightedIndex:n}=void 0===this.props.highlightedIndex?this.getState():this.props,{highlightedIndex:i}=void 0===t.highlightedIndex?e:t;return n&&this.getState().isOpen&&!e.isOpen||n!==i}componentDidUpdate(e,t){we(this.props,"selectedItem")&&this.props.selectedItemChanged(e.selectedItem,this.props.selectedItem)&&this.internalSetState({type:15,inputValue:this.props.itemToString(this.props.selectedItem)}),!this.avoidScrolling&&this.shouldScroll(t,e)&&this.scrollHighlightedItemIntoView(),this.updateStatus()}componentWillUnmount(){this.cleanup()}render(){const e=ye(this.props.children,ce);this.clearItems(),this.getRootProps.called=!1,this.getRootProps.refKey=void 0,this.getRootProps.suppressRefError=void 0,this.getMenuProps.called=!1,this.getMenuProps.refKey=void 0,this.getMenuProps.suppressRefError=void 0,this.getLabelProps.called=!1,this.getInputProps.called=!1;const n=ye(e(this.getStateAndHelpers()));return n?this.getRootProps.called||this.props.suppressRefError?n:function(e){return"string"==typeof e.type}(n)?t.cloneElement(n,this.getRootProps(function(e){return e.props}(n))):void 0:null}}return e.defaultProps={defaultHighlightedIndex:null,defaultIsOpen:!1,getA11yStatusMessage:Ie,itemToString:e=>null==e?"":String(e),onStateChange:ce,onInputValueChange:ce,onUserAction:ce,onChange:ce,onSelect:ce,onOuterClick:ce,selectedItemChanged:(e,t)=>e!==t,environment:"undefined"==typeof window?{}:window,stateReducer:(e,t)=>t,suppressRefError:!1,scrollIntoView:de},e.stateChangeTypes=Re,e})();var Te=Pe;const Ke={highlightedIndex:-1,isOpen:!1,selectedItem:null,inputValue:""};function He(e,t,n){const{props:i,type:o}=e,r={};Object.keys(t).forEach((i=>{!function(e,t,n,i){const{props:o,type:r}=t,s="on"+Be(e)+"Change";o[s]&&void 0!==i[e]&&i[e]!==n[e]&&o[s]({type:r,...i})}(i,e,t,n),n[i]!==t[i]&&(r[i]=n[i])})),i.onStateChange&&Object.keys(r).length&&i.onStateChange({type:o,...r})}const Fe=pe(((e,t)=>{Oe(e(),t)}),200),Ve="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?t.useLayoutEffect:t.useEffect;function Ae(e){let{id:n="downshift-"+fe(),labelId:i,menuId:o,getItemId:r,toggleButtonId:s,inputId:u}=e;return t.useRef({labelId:i||n+"-label",menuId:o||n+"-menu",getItemId:r||(e=>n+"-item-"+e),toggleButtonId:s||n+"-toggle-button",inputId:u||n+"-input"}).current}function Ne(e,t,n){return void 0!==e?e:0===n.length?-1:n.indexOf(t)}function Le(e){return/^\S{1}$/.test(e)}function Be(e){return""+e.slice(0,1).toUpperCase()+e.slice(1)}function _e(e){const n=t.useRef(e);return n.current=e,n}function $e(e,n,i){const o=t.useRef(),r=t.useRef(),s=t.useCallback(((t,n)=>{r.current=n,t=xe(t,n.props);const i=e(t,n);return n.props.stateReducer(t,{...n,changes:i})}),[e]),[u,l]=t.useReducer(s,n),a=_e(i),c=t.useCallback((e=>l({props:a.current,...e})),[a]),d=r.current;return t.useEffect((()=>{d&&o.current&&o.current!==u&&He(d,xe(o.current,d.props),u),o.current=u}),[u,i,d]),[u,c]}function je(e,t,n){const[i,o]=$e(e,t,n);return[xe(i,n),o]}const Ue={itemToString:function(e){return e?String(e):""},stateReducer:function(e,t){return t.changes},getA11ySelectionMessage:function(e){const{selectedItem:t,itemToString:n}=e;return t?n(t)+" has been selected.":""},scrollIntoView:de,circularNavigation:!1,environment:"undefined"==typeof window?{}:window};function We(e,t,n){void 0===n&&(n=Ke);const i=e["default"+Be(t)];return void 0!==i?i:n[t]}function ze(e,t,n){void 0===n&&(n=Ke);const i=e[t];if(void 0!==i)return i;const o=e["initial"+Be(t)];return void 0!==o?o:We(e,t,n)}function qe(e){const t=ze(e,"selectedItem"),n=ze(e,"isOpen"),i=ze(e,"highlightedIndex"),o=ze(e,"inputValue");return{highlightedIndex:i<0&&t&&n?e.items.indexOf(t):i,isOpen:n,selectedItem:t,inputValue:o}}function Ye(e,t,n,i){const{items:o,initialHighlightedIndex:r,defaultHighlightedIndex:s}=e,{selectedItem:u,highlightedIndex:l}=t;return 0===o.length?-1:void 0!==r&&l===r?r:void 0!==s?s:u?0===n?o.indexOf(u):Ce(n,o.indexOf(u),o.length,i,!1):0===n?-1:n<0?o.length-1:0}function Xe(e,n,i,o){const r=t.useRef({isMouseDown:!1,isTouchMove:!1});return t.useEffect((()=>{const t=()=>{r.current.isMouseDown=!0},s=t=>{r.current.isMouseDown=!1,e&&!Me(t.target,n.map((e=>e.current)),i)&&o()},u=()=>{r.current.isTouchMove=!1},l=()=>{r.current.isTouchMove=!0},a=t=>{!e||r.current.isTouchMove||Me(t.target,n.map((e=>e.current)),i,!1)||o()};return i.addEventListener("mousedown",t),i.addEventListener("mouseup",s),i.addEventListener("touchstart",u),i.addEventListener("touchmove",l),i.addEventListener("touchend",a),function(){i.removeEventListener("mousedown",t),i.removeEventListener("mouseup",s),i.removeEventListener("touchstart",u),i.removeEventListener("touchmove",l),i.removeEventListener("touchend",a)}}),[e,i]),r}let Ge=()=>ce;function Je(e,n,i){let{isInitialMount:o,highlightedIndex:r,items:s,environment:u,...l}=i;t.useEffect((()=>{o||Fe((()=>e({highlightedIndex:r,highlightedItem:s[r],resultCount:s.length,...l})),u.document)}),n)}function Qe(e){let{highlightedIndex:n,isOpen:i,itemRefs:o,getItemNodeFromIndex:r,menuElement:s,scrollIntoView:u}=e;const l=t.useRef(!0);return Ve((()=>{n<0||!i||!Object.keys(o.current).length||(!1===l.current?l.current=!0:u(r(n),s))}),[n]),l}let Ze=ce;function et(e,t,n){const{type:i,props:o}=t;let r;switch(i){case n.ItemMouseMove:r={highlightedIndex:t.index};break;case n.MenuMouseLeave:r={highlightedIndex:-1};break;case n.ToggleButtonClick:case n.FunctionToggleMenu:r={isOpen:!e.isOpen,highlightedIndex:e.isOpen?-1:Ye(o,e,0)};break;case n.FunctionOpenMenu:r={isOpen:!0,highlightedIndex:Ye(o,e,0)};break;case n.FunctionCloseMenu:r={isOpen:!1};break;case n.FunctionSetHighlightedIndex:r={highlightedIndex:t.highlightedIndex};break;case n.FunctionSetInputValue:r={inputValue:t.inputValue};break;case n.FunctionReset:r={highlightedIndex:We(o,"highlightedIndex"),isOpen:We(o,"isOpen"),selectedItem:We(o,"selectedItem"),inputValue:We(o,"inputValue")};break;default:throw new Error("Reducer called without proper action type.")}return{...e,...r}}var tt=function(){return tt=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},tt.apply(this,arguments)};function nt(e){for(var t=e.keysSoFar,n=e.highlightedIndex,i=e.items,o=e.itemToString,r=e.getItemNodeFromIndex,s=t.toLowerCase(),u=0;u<i.length;u++){var l=(u+n+1)%i.length,a=i[l];if(void 0!==a&&o(a).toLowerCase().startsWith(s)){var c=r(l);if(!(null==c?void 0:c.hasAttribute("disabled")))return l}}return n}E.array.isRequired,E.func,E.func,E.func,E.bool,E.number,E.number,E.number,E.bool,E.bool,E.bool,E.any,E.any,E.any,E.string,E.string,E.string,E.func,E.string,E.func,E.func,E.func,E.func,E.func,E.shape({addEventListener:E.func,removeEventListener:E.func,document:E.shape({getElementById:E.func,activeElement:E.any,body:E.any})});var it=tt(tt({},Ue),{getA11yStatusMessage:function(e){var t=e.isOpen,n=e.resultCount,i=e.previousResultCount;return t?n?n!==i?"".concat(n," result").concat(1===n?" is":"s are"," available, use up and down arrow keys to navigate. Press Enter or Space Bar keys to select."):"":"No results are available.":""}}),ot=ce;var rt=Object.freeze({__proto__:null,MenuKeyDownArrowDown:0,MenuKeyDownArrowUp:1,MenuKeyDownEscape:2,MenuKeyDownHome:3,MenuKeyDownEnd:4,MenuKeyDownEnter:5,MenuKeyDownSpaceButton:6,MenuKeyDownCharacter:7,MenuBlur:8,MenuMouseLeave:9,ItemMouseMove:10,ItemClick:11,ToggleButtonClick:12,ToggleButtonKeyDownArrowDown:13,ToggleButtonKeyDownArrowUp:14,ToggleButtonKeyDownCharacter:15,FunctionToggleMenu:16,FunctionOpenMenu:17,FunctionCloseMenu:18,FunctionSetHighlightedIndex:19,FunctionSelectItem:20,FunctionSetInputValue:21,FunctionReset:22});function st(e,t){const{type:n,props:i,shiftKey:o}=t;let r;switch(n){case 11:r={isOpen:We(i,"isOpen"),highlightedIndex:We(i,"highlightedIndex"),selectedItem:i.items[t.index]};break;case 15:{const n=t.key,o=""+e.inputValue+n,s=nt({keysSoFar:o,highlightedIndex:e.selectedItem?i.items.indexOf(e.selectedItem):-1,items:i.items,itemToString:i.itemToString,getItemNodeFromIndex:t.getItemNodeFromIndex});r={inputValue:o,...s>=0&&{selectedItem:i.items[s]}}}break;case 13:r={highlightedIndex:Ye(i,e,1,t.getItemNodeFromIndex),isOpen:!0};break;case 14:r={highlightedIndex:Ye(i,e,-1,t.getItemNodeFromIndex),isOpen:!0};break;case 5:case 6:r={isOpen:We(i,"isOpen"),highlightedIndex:We(i,"highlightedIndex"),...e.highlightedIndex>=0&&{selectedItem:i.items[e.highlightedIndex]}};break;case 3:r={highlightedIndex:ke(1,0,i.items.length,t.getItemNodeFromIndex,!1)};break;case 4:r={highlightedIndex:ke(-1,i.items.length-1,i.items.length,t.getItemNodeFromIndex,!1)};break;case 2:case 8:r={isOpen:!1,highlightedIndex:-1};break;case 7:{const n=t.key,o=""+e.inputValue+n,s=nt({keysSoFar:o,highlightedIndex:e.highlightedIndex,items:i.items,itemToString:i.itemToString,getItemNodeFromIndex:t.getItemNodeFromIndex});r={inputValue:o,...s>=0&&{highlightedIndex:s}}}break;case 0:r={highlightedIndex:Ce(o?5:1,e.highlightedIndex,i.items.length,t.getItemNodeFromIndex,i.circularNavigation)};break;case 1:r={highlightedIndex:Ce(o?-5:-1,e.highlightedIndex,i.items.length,t.getItemNodeFromIndex,i.circularNavigation)};break;case 20:r={selectedItem:t.selectedItem};break;default:return et(e,t,rt)}return{...e,...r}}function ut(e){void 0===e&&(e={}),ot();const n={...it,...e},{items:i,scrollIntoView:o,environment:r,initialIsOpen:s,defaultIsOpen:u,itemToString:l,getA11ySelectionMessage:a,getA11yStatusMessage:c}=n,d=qe(n),[h,p]=je(st,d,n),{isOpen:g,highlightedIndex:m,selectedItem:f,inputValue:I}=h,y=t.useRef(null),v=t.useRef(null),b=t.useRef({}),x=t.useRef(!0),w=t.useRef(null),S=Ae(n),C=t.useRef(),k=t.useRef(!0),M=_e({state:h,props:n}),E=t.useCallback((e=>b.current[S.getItemId(e)]),[S]);Je(c,[g,m,I,i],{isInitialMount:k.current,previousResultCount:C.current,items:i,environment:r,itemToString:l,...h}),Je(a,[f],{isInitialMount:k.current,previousResultCount:C.current,items:i,environment:r,itemToString:l,...h});const O=Qe({menuElement:v.current,highlightedIndex:m,isOpen:g,itemRefs:b,scrollIntoView:o,getItemNodeFromIndex:E});t.useEffect((()=>(w.current=pe((e=>{e({type:21,inputValue:""})}),500),()=>{w.current.cancel()})),[]),t.useEffect((()=>{I&&w.current(p)}),[p,I]),Ze({isInitialMount:k.current,props:n,state:h}),t.useEffect((()=>{k.current?(s||u||g)&&v.current&&v.current.focus():g?v.current&&v.current.focus():r.document.activeElement===v.current&&y.current&&(x.current=!1,y.current.focus())}),[g]),t.useEffect((()=>{k.current||(C.current=i.length)}));const D=Xe(g,[v,y],r,(()=>{p({type:8})})),R=Ge();t.useEffect((()=>{k.current=!1}),[]),t.useEffect((()=>{g||(b.current={})}),[g]);const P=t.useMemo((()=>({ArrowDown(e){e.preventDefault(),p({type:13,getItemNodeFromIndex:E,shiftKey:e.shiftKey})},ArrowUp(e){e.preventDefault(),p({type:14,getItemNodeFromIndex:E,shiftKey:e.shiftKey})}})),[p,E]),T=t.useMemo((()=>({ArrowDown(e){e.preventDefault(),p({type:0,getItemNodeFromIndex:E,shiftKey:e.shiftKey})},ArrowUp(e){e.preventDefault(),p({type:1,getItemNodeFromIndex:E,shiftKey:e.shiftKey})},Home(e){e.preventDefault(),p({type:3,getItemNodeFromIndex:E})},End(e){e.preventDefault(),p({type:4,getItemNodeFromIndex:E})},Escape(){p({type:2})},Enter(e){e.preventDefault(),p({type:5})}," "(e){e.preventDefault(),p({type:6})}})),[p,E]),K=t.useCallback((()=>{p({type:16})}),[p]),H=t.useCallback((()=>{p({type:18})}),[p]),F=t.useCallback((()=>{p({type:17})}),[p]),V=t.useCallback((e=>{p({type:19,highlightedIndex:e})}),[p]),A=t.useCallback((e=>{p({type:20,selectedItem:e})}),[p]),N=t.useCallback((()=>{p({type:22})}),[p]),L=t.useCallback((e=>{p({type:21,inputValue:e})}),[p]),B=t.useCallback((e=>({id:S.labelId,htmlFor:S.toggleButtonId,...e})),[S]),_=t.useCallback((function(e,t){let{onMouseLeave:n,refKey:i="ref",onKeyDown:o,onBlur:r,ref:s,...u}=void 0===e?{}:e,{suppressRefError:l=!1}=void 0===t?{}:t;const a=M.current.state;return R("getMenuProps",l,i,v),{[i]:me(s,(e=>{v.current=e})),id:S.menuId,role:"listbox","aria-labelledby":S.labelId,tabIndex:-1,...a.isOpen&&a.highlightedIndex>-1&&{"aria-activedescendant":S.getItemId(a.highlightedIndex)},onMouseLeave:ge(n,(()=>{p({type:9})})),onKeyDown:ge(o,(e=>{const t=Se(e);t&&T[t]?T[t](e):Le(t)&&p({type:7,key:t,getItemNodeFromIndex:E})})),onBlur:ge(r,(()=>{if(!1===x.current)return void(x.current=!0);!D.current.isMouseDown&&p({type:8})})),...u}}),[p,M,T,D,R,S,E]);return{getToggleButtonProps:t.useCallback((function(e,t){let{onClick:n,onKeyDown:i,refKey:o="ref",ref:r,...s}=void 0===e?{}:e,{suppressRefError:u=!1}=void 0===t?{}:t;const l=()=>{p({type:12})},a=e=>{const t=Se(e);t&&P[t]?P[t](e):Le(t)&&p({type:15,key:t,getItemNodeFromIndex:E})},c={[o]:me(r,(e=>{y.current=e})),id:S.toggleButtonId,"aria-haspopup":"listbox","aria-expanded":M.current.state.isOpen,"aria-labelledby":S.labelId+" "+S.toggleButtonId,...s};return s.disabled||(c.onClick=ge(n,l),c.onKeyDown=ge(i,a)),R("getToggleButtonProps",u,o,y),c}),[p,M,P,R,S,E]),getLabelProps:B,getMenuProps:_,getItemProps:t.useCallback((function(e){let{item:t,index:n,onMouseMove:i,onClick:o,refKey:r="ref",ref:s,...u}=void 0===e?{}:e;const{state:l,props:a}=M.current,c=()=>{n!==l.highlightedIndex&&(O.current=!1,p({type:10,index:n}))},d=()=>{p({type:11,index:n})},h=Ne(n,t,a.items);if(h<0)throw new Error("Pass either item or item index in getItemProps!");const g={role:"option","aria-selected":""+(h===l.highlightedIndex),id:S.getItemId(h),[r]:me(s,(e=>{e&&(b.current[S.getItemId(h)]=e)})),...u};return u.disabled||(g.onMouseMove=ge(i,c),g.onClick=ge(o,d)),g}),[p,M,O,S]),toggleMenu:K,openMenu:F,closeMenu:H,setHighlightedIndex:V,selectItem:A,reset:N,setInputValue:L,highlightedIndex:m,isOpen:g,selectedItem:f,inputValue:I}}ut.stateChangeTypes=rt;var lt=Object.freeze({__proto__:null,InputKeyDownArrowDown:0,InputKeyDownArrowUp:1,InputKeyDownEscape:2,InputKeyDownHome:3,InputKeyDownEnd:4,InputKeyDownEnter:5,InputChange:6,InputBlur:7,MenuMouseLeave:8,ItemMouseMove:9,ItemClick:10,ToggleButtonClick:11,FunctionToggleMenu:12,FunctionOpenMenu:13,FunctionCloseMenu:14,FunctionSetHighlightedIndex:15,FunctionSelectItem:16,FunctionSetInputValue:17,FunctionReset:18,ControlledPropUpdatedSelectedItem:19});E.array.isRequired,E.func,E.func,E.func,E.bool,E.number,E.number,E.number,E.bool,E.bool,E.bool,E.any,E.any,E.any,E.string,E.string,E.string,E.string,E.string,E.string,E.func,E.string,E.string,E.func,E.func,E.func,E.func,E.func,E.func,E.shape({addEventListener:E.func,removeEventListener:E.func,document:E.shape({getElementById:E.func,activeElement:E.any,body:E.any})});let at=ce;const ct={...Ue,getA11yStatusMessage:Ie,circularNavigation:!0};function dt(e,t){const{type:n,props:i,shiftKey:o}=t;let r;switch(n){case 10:r={isOpen:We(i,"isOpen"),highlightedIndex:We(i,"highlightedIndex"),selectedItem:i.items[t.index],inputValue:i.itemToString(i.items[t.index])};break;case 0:r=e.isOpen?{highlightedIndex:Ce(o?5:1,e.highlightedIndex,i.items.length,t.getItemNodeFromIndex,i.circularNavigation)}:{highlightedIndex:Ye(i,e,1,t.getItemNodeFromIndex),isOpen:i.items.length>=0};break;case 1:r=e.isOpen?{highlightedIndex:Ce(o?-5:-1,e.highlightedIndex,i.items.length,t.getItemNodeFromIndex,i.circularNavigation)}:{highlightedIndex:Ye(i,e,-1,t.getItemNodeFromIndex),isOpen:i.items.length>=0};break;case 5:r={...e.isOpen&&e.highlightedIndex>=0&&{selectedItem:i.items[e.highlightedIndex],isOpen:We(i,"isOpen"),highlightedIndex:We(i,"highlightedIndex"),inputValue:i.itemToString(i.items[e.highlightedIndex])}};break;case 2:r={isOpen:!1,highlightedIndex:-1,...!e.isOpen&&{selectedItem:null,inputValue:""}};break;case 3:r={highlightedIndex:ke(1,0,i.items.length,t.getItemNodeFromIndex,!1)};break;case 4:r={highlightedIndex:ke(-1,i.items.length-1,i.items.length,t.getItemNodeFromIndex,!1)};break;case 7:r={isOpen:!1,highlightedIndex:-1,...e.highlightedIndex>=0&&t.selectItem&&{selectedItem:i.items[e.highlightedIndex],inputValue:i.itemToString(i.items[e.highlightedIndex])}};break;case 6:r={isOpen:!0,highlightedIndex:We(i,"highlightedIndex"),inputValue:t.inputValue};break;case 16:r={selectedItem:t.selectedItem,inputValue:i.itemToString(t.selectedItem)};break;case 19:r={inputValue:t.inputValue};break;default:return et(e,t,lt)}return{...e,...r}}function ht(e){void 0===e&&(e={}),at();const n={...ct,...e},{initialIsOpen:i,defaultIsOpen:o,items:r,scrollIntoView:s,environment:u,getA11yStatusMessage:l,getA11ySelectionMessage:a,itemToString:c}=n,d=function(e){const t=qe(e),{selectedItem:n}=t;let{inputValue:i}=t;return""===i&&n&&void 0===e.defaultInputValue&&void 0===e.initialInputValue&&void 0===e.inputValue&&(i=e.itemToString(n)),{...t,inputValue:i}}(n),[h,p]=function(e,n,i){const o=t.useRef(),[r,s]=$e(e,n,i);return t.useEffect((()=>{we(i,"selectedItem")&&(o.current!==i.selectedItem&&s({type:19,inputValue:i.itemToString(i.selectedItem)}),o.current=r.selectedItem===o.current?i.selectedItem:r.selectedItem)})),[xe(r,i),s]}(dt,d,n),{isOpen:g,highlightedIndex:m,selectedItem:f,inputValue:I}=h,y=t.useRef(null),v=t.useRef({}),b=t.useRef(null),x=t.useRef(null),w=t.useRef(null),S=t.useRef(!0),C=Ae(n),k=t.useRef(),M=_e({state:h,props:n}),E=t.useCallback((e=>v.current[C.getItemId(e)]),[C]);Je(l,[g,m,I,r],{isInitialMount:S.current,previousResultCount:k.current,items:r,environment:u,itemToString:c,...h}),Je(a,[f],{isInitialMount:S.current,previousResultCount:k.current,items:r,environment:u,itemToString:c,...h});const O=Qe({menuElement:y.current,highlightedIndex:m,isOpen:g,itemRefs:v,scrollIntoView:s,getItemNodeFromIndex:E});Ze({isInitialMount:S.current,props:n,state:h}),t.useEffect((()=>{(i||o||g)&&b.current&&b.current.focus()}),[]),t.useEffect((()=>{S.current||(k.current=r.length)}));const D=Xe(g,[w,y,x],u,(()=>{p({type:7,selectItem:!1})})),R=Ge();t.useEffect((()=>{S.current=!1}),[]),t.useEffect((()=>{g||(v.current={})}),[g]);const P=t.useMemo((()=>({ArrowDown(e){e.preventDefault(),p({type:0,shiftKey:e.shiftKey,getItemNodeFromIndex:E})},ArrowUp(e){e.preventDefault(),p({type:1,shiftKey:e.shiftKey,getItemNodeFromIndex:E})},Home(e){M.current.state.isOpen&&(e.preventDefault(),p({type:3,getItemNodeFromIndex:E}))},End(e){M.current.state.isOpen&&(e.preventDefault(),p({type:4,getItemNodeFromIndex:E}))},Escape(){const e=M.current.state;(e.isOpen||e.inputValue||e.selectedItem||e.highlightedIndex>-1)&&p({type:2})},Enter(e){const t=M.current.state;!t.isOpen||t.highlightedIndex<0||229===e.which||(e.preventDefault(),p({type:5,getItemNodeFromIndex:E}))}})),[p,M,E]),T=t.useCallback((e=>({id:C.labelId,htmlFor:C.inputId,...e})),[C]),K=t.useCallback((function(e,t){let{onMouseLeave:n,refKey:i="ref",ref:o,...r}=void 0===e?{}:e,{suppressRefError:s=!1}=void 0===t?{}:t;return R("getMenuProps",s,i,y),{[i]:me(o,(e=>{y.current=e})),id:C.menuId,role:"listbox","aria-labelledby":C.labelId,onMouseLeave:ge(n,(()=>{p({type:8})})),...r}}),[p,R,C]),H=t.useCallback((function(e){let{item:t,index:n,refKey:i="ref",ref:o,onMouseMove:r,onClick:s,onPress:u,...l}=void 0===e?{}:e;const{props:a,state:c}=M.current,d=Ne(n,t,a.items);if(d<0)throw new Error("Pass either item or item index in getItemProps!");const h=s;return{[i]:me(o,(e=>{e&&(v.current[C.getItemId(d)]=e)})),role:"option","aria-selected":""+(d===c.highlightedIndex),id:C.getItemId(d),...!l.disabled&&{onMouseMove:ge(r,(()=>{n!==c.highlightedIndex&&(O.current=!1,p({type:9,index:n}))})),onClick:ge(h,(()=>{p({type:10,index:n}),b.current&&b.current.focus()}))},...l}}),[p,M,O,C]),F=t.useCallback((function(e){let{onClick:t,onPress:n,refKey:i="ref",ref:o,...r}=void 0===e?{}:e;return{[i]:me(o,(e=>{x.current=e})),id:C.toggleButtonId,tabIndex:-1,...!r.disabled&&{onClick:ge(t,(()=>{p({type:11}),!M.current.state.isOpen&&b.current&&b.current.focus()}))},...r}}),[p,M,C]),V=t.useCallback((function(e,t){let{onKeyDown:n,onChange:i,onInput:o,onBlur:r,onChangeText:s,refKey:u="ref",ref:l,...a}=void 0===e?{}:e,{suppressRefError:c=!1}=void 0===t?{}:t;R("getInputProps",c,u,b);const d=M.current.state,h=e=>{const t=Se(e);t&&P[t]&&P[t](e)},g=e=>{p({type:6,inputValue:e.target.value})},m=()=>{d.isOpen&&!D.current.isMouseDown&&p({type:7,selectItem:!0})};let f={};return a.disabled||(f={onChange:ge(i,o,g),onKeyDown:ge(n,h),onBlur:ge(r,m)}),{[u]:me(l,(e=>{b.current=e})),id:C.inputId,"aria-autocomplete":"list","aria-controls":C.menuId,...d.isOpen&&d.highlightedIndex>-1&&{"aria-activedescendant":C.getItemId(d.highlightedIndex)},"aria-labelledby":C.labelId,autoComplete:"off",value:d.inputValue,...f,...a}}),[p,P,M,D,R,C]),A=t.useCallback((function(e,t){let{refKey:n="ref",ref:i,...o}=void 0===e?{}:e,{suppressRefError:r=!1}=void 0===t?{}:t;return R("getComboboxProps",r,n,w),{[n]:me(i,(e=>{w.current=e})),role:"combobox","aria-haspopup":"listbox","aria-owns":C.menuId,"aria-expanded":M.current.state.isOpen,...o}}),[M,R,C]),N=t.useCallback((()=>{p({type:12})}),[p]),L=t.useCallback((()=>{p({type:14})}),[p]),B=t.useCallback((()=>{p({type:13})}),[p]),_=t.useCallback((e=>{p({type:15,highlightedIndex:e})}),[p]),$=t.useCallback((e=>{p({type:16,selectedItem:e})}),[p]);return{getItemProps:H,getLabelProps:T,getMenuProps:K,getInputProps:V,getComboboxProps:A,getToggleButtonProps:F,toggleMenu:N,openMenu:B,closeMenu:L,setHighlightedIndex:_,setInputValue:t.useCallback((e=>{p({type:17,inputValue:e})}),[p]),selectItem:$,reset:t.useCallback((()=>{p({type:18})}),[p]),highlightedIndex:m,isOpen:g,selectedItem:f,inputValue:I}}ht.stateChangeTypes=lt;const pt={activeIndex:-1,selectedItems:[]};function gt(e,t){return ze(e,t,pt)}function mt(e,t){return We(e,t,pt)}function ft(e){if(e.shiftKey||e.metaKey||e.ctrlKey||e.altKey)return!1;const t=e.target;return!(t instanceof HTMLInputElement&&""!==t.value)||0===t.selectionStart&&0===t.selectionEnd}E.array,E.array,E.array,E.func,E.func,E.func,E.number,E.number,E.number,E.func,E.func,E.string,E.string,E.shape({addEventListener:E.func,removeEventListener:E.func,document:E.shape({getElementById:E.func,activeElement:E.any,body:E.any})});const It={itemToString:Ue.itemToString,stateReducer:Ue.stateReducer,environment:Ue.environment,getA11yRemovalMessage:function(e){const{removedSelectedItem:t,itemToString:n}=e;return n(t)+" has been removed."},keyNavigationNext:"ArrowRight",keyNavigationPrevious:"ArrowLeft"};let yt=ce;var vt=Object.freeze({__proto__:null,SelectedItemClick:0,SelectedItemKeyDownDelete:1,SelectedItemKeyDownBackspace:2,SelectedItemKeyDownNavigationNext:3,SelectedItemKeyDownNavigationPrevious:4,DropdownKeyDownNavigationPrevious:5,DropdownKeyDownBackspace:6,DropdownClick:7,FunctionAddSelectedItem:8,FunctionRemoveSelectedItem:9,FunctionSetSelectedItems:10,FunctionSetActiveIndex:11,FunctionReset:12});function bt(e,t){const{type:n,index:i,props:o,selectedItem:r}=t,{activeIndex:s,selectedItems:u}=e;let l;switch(n){case 0:l={activeIndex:i};break;case 4:l={activeIndex:s-1<0?0:s-1};break;case 3:l={activeIndex:s+1>=u.length?-1:s+1};break;case 2:case 1:{let e=s;1===u.length?e=-1:s===u.length-1&&(e=u.length-2),l={selectedItems:[...u.slice(0,s),...u.slice(s+1)],activeIndex:e};break}case 5:l={activeIndex:u.length-1};break;case 6:l={selectedItems:u.slice(0,u.length-1)};break;case 8:l={selectedItems:[...u,r]};break;case 7:l={activeIndex:-1};break;case 9:{let e=s;const t=u.indexOf(r);t>=0&&(1===u.length?e=-1:t===u.length-1&&(e=u.length-2),l={selectedItems:[...u.slice(0,t),...u.slice(t+1)],activeIndex:e});break}case 10:{const{selectedItems:e}=t;l={selectedItems:e};break}case 11:{const{activeIndex:e}=t;l={activeIndex:e};break}case 12:l={activeIndex:mt(o,"activeIndex"),selectedItems:mt(o,"selectedItems")};break;default:throw new Error("Reducer called without proper action type.")}return{...e,...l}}function xt(e){void 0===e&&(e={}),yt();const n={...It,...e},{getA11yRemovalMessage:i,itemToString:o,environment:r,keyNavigationNext:s,keyNavigationPrevious:u}=n,[l,a]=je(bt,function(e){return{activeIndex:gt(e,"activeIndex"),selectedItems:gt(e,"selectedItems")}}(n),n),{activeIndex:c,selectedItems:d}=l,h=t.useRef(!0),p=t.useRef(null),g=t.useRef(d),m=t.useRef();m.current=[];const f=_e({state:l,props:n});t.useEffect((()=>{if(!h.current){if(d.length<g.current.length){const e=g.current.find((e=>d.indexOf(e)<0));Oe(i({itemToString:o,resultCount:d.length,removedSelectedItem:e,activeIndex:c,activeSelectedItem:d[c]}),r.document)}g.current=d}}),[d.length]),t.useEffect((()=>{h.current||(-1===c&&p.current?p.current.focus():m.current[c]&&m.current[c].focus())}),[c]),Ze({isInitialMount:h.current,props:n,state:l});const I=Ge();t.useEffect((()=>{h.current=!1}),[]);const y=t.useMemo((()=>({[u](){a({type:4})},[s](){a({type:3})},Delete(){a({type:1})},Backspace(){a({type:2})}})),[a,s,u]),v=t.useMemo((()=>({[u](e){ft(e)&&a({type:5})},Backspace(e){ft(e)&&a({type:6})}})),[a,u]);return{getSelectedItemProps:t.useCallback((function(e){let{refKey:t="ref",ref:n,onClick:i,onKeyDown:o,selectedItem:r,index:s,...u}=void 0===e?{}:e;const{state:l}=f.current;if(Ne(s,r,l.selectedItems)<0)throw new Error("Pass either selectedItem or index in getSelectedItemProps!");return{[t]:me(n,(e=>{e&&m.current.push(e)})),tabIndex:s===l.activeIndex?0:-1,onClick:ge(i,(()=>{a({type:0,index:s})})),onKeyDown:ge(o,(e=>{const t=Se(e);t&&y[t]&&y[t](e)})),...u}}),[a,f,y]),getDropdownProps:t.useCallback((function(e,t){let{refKey:n="ref",ref:i,onKeyDown:o,onClick:r,preventKeyAction:s=!1,...u}=void 0===e?{}:e,{suppressRefError:l=!1}=void 0===t?{}:t;return I("getDropdownProps",l,n,p),{[n]:me(i,(e=>{e&&(p.current=e)})),...!s&&{onKeyDown:ge(o,(e=>{const t=Se(e);t&&v[t]&&v[t](e)})),onClick:ge(r,(()=>{a({type:7})}))},...u}}),[a,v,I]),addSelectedItem:t.useCallback((e=>{a({type:8,selectedItem:e})}),[a]),removeSelectedItem:t.useCallback((e=>{a({type:9,selectedItem:e})}),[a]),setSelectedItems:t.useCallback((e=>{a({type:10,selectedItems:e})}),[a]),setActiveIndex:t.useCallback((e=>{a({type:11,activeIndex:e})}),[a]),reset:t.useCallback((()=>{a({type:12})}),[a]),selectedItems:d,activeIndex:c}}xt.stateChangeTypes=vt,e.default=Te,e.resetIdCounter=function(){le=0},e.useCombobox=ht,e.useMultipleSelection=xt,e.useSelect=ut,Object.defineProperty(e,"__esModule",{value:!0})}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Downshift={},e.React)}(this,(function(e,t){"use strict";var n={exports:{}},i={},o="function"==typeof Symbol&&Symbol.for,r=o?Symbol.for("react.element"):60103,s=o?Symbol.for("react.portal"):60106,u=o?Symbol.for("react.fragment"):60107,l=o?Symbol.for("react.strict_mode"):60108,a=o?Symbol.for("react.profiler"):60114,c=o?Symbol.for("react.provider"):60109,d=o?Symbol.for("react.context"):60110,h=o?Symbol.for("react.async_mode"):60111,p=o?Symbol.for("react.concurrent_mode"):60111,g=o?Symbol.for("react.forward_ref"):60112,m=o?Symbol.for("react.suspense"):60113,f=o?Symbol.for("react.suspense_list"):60120,I=o?Symbol.for("react.memo"):60115,y=o?Symbol.for("react.lazy"):60116,v=o?Symbol.for("react.block"):60121,b=o?Symbol.for("react.fundamental"):60117,x=o?Symbol.for("react.responder"):60118,w=o?Symbol.for("react.scope"):60119;function S(e){if("object"==typeof e&&null!==e){var t=e.$$typeof;switch(t){case r:switch(e=e.type){case h:case p:case u:case a:case l:case m:return e;default:switch(e=e&&e.$$typeof){case d:case g:case y:case I:case c:return e;default:return t}}case s:return t}}}function C(e){return S(e)===p}i.AsyncMode=h,i.ConcurrentMode=p,i.ContextConsumer=d,i.ContextProvider=c,i.Element=r,i.ForwardRef=g,i.Fragment=u,i.Lazy=y,i.Memo=I,i.Portal=s,i.Profiler=a,i.StrictMode=l,i.Suspense=m,i.isAsyncMode=function(e){return C(e)||S(e)===h},i.isConcurrentMode=C,i.isContextConsumer=function(e){return S(e)===d},i.isContextProvider=function(e){return S(e)===c},i.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===r},i.isForwardRef=function(e){return S(e)===g},i.isFragment=function(e){return S(e)===u},i.isLazy=function(e){return S(e)===y},i.isMemo=function(e){return S(e)===I},i.isPortal=function(e){return S(e)===s},i.isProfiler=function(e){return S(e)===a},i.isStrictMode=function(e){return S(e)===l},i.isSuspense=function(e){return S(e)===m},i.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===u||e===p||e===a||e===l||e===m||e===f||"object"==typeof e&&null!==e&&(e.$$typeof===y||e.$$typeof===I||e.$$typeof===c||e.$$typeof===d||e.$$typeof===g||e.$$typeof===b||e.$$typeof===x||e.$$typeof===w||e.$$typeof===v)},i.typeOf=S;function k(){}function M(){}M.resetWarningCache=k;n.exports=function(){function e(e,t,n,i,o,r){if("SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"!==r){var s=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw s.name="Invariant Violation",s}}function t(){return e}e.isRequired=e;var n={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:M,resetWarningCache:k};return n.PropTypes=n,n}();var E=n.exports,O={},D=60103,R=60106,P=60107,T=60108,K=60114,H=60109,F=60110,V=60112,$=60113,A=60120,N=60115,L=60116,B=60121,_=60122,j=60117,U=60129,W=60131;if("function"==typeof Symbol&&Symbol.for){var z=Symbol.for;D=z("react.element"),R=z("react.portal"),P=z("react.fragment"),T=z("react.strict_mode"),K=z("react.profiler"),H=z("react.provider"),F=z("react.context"),V=z("react.forward_ref"),$=z("react.suspense"),A=z("react.suspense_list"),N=z("react.memo"),L=z("react.lazy"),B=z("react.block"),_=z("react.server.block"),j=z("react.fundamental"),U=z("react.debug_trace_mode"),W=z("react.legacy_hidden")}function q(e){if("object"==typeof e&&null!==e){var t=e.$$typeof;switch(t){case D:switch(e=e.type){case P:case K:case T:case $:case A:return e;default:switch(e=e&&e.$$typeof){case F:case V:case L:case N:case H:return e;default:return t}}case R:return t}}}var Y=H,X=D,G=V,J=P,Q=L,Z=N,ee=R,te=K,ne=T,ie=$;function oe(e){return"object"==typeof e&&null!=e&&1===e.nodeType}function re(e,t){return(!t||"hidden"!==e)&&"visible"!==e&&"clip"!==e}function se(e,t){if(e.clientHeight<e.scrollHeight||e.clientWidth<e.scrollWidth){var n=getComputedStyle(e,null);return re(n.overflowY,t)||re(n.overflowX,t)||function(e){var t=function(e){if(!e.ownerDocument||!e.ownerDocument.defaultView)return null;try{return e.ownerDocument.defaultView.frameElement}catch(e){return null}}(e);return!!t&&(t.clientHeight<e.scrollHeight||t.clientWidth<e.scrollWidth)}(e)}return!1}function ue(e,t,n,i,o,r,s,u){return r<e&&s>t||r>e&&s<t?0:r<=e&&u<=n||s>=t&&u>=n?r-e-i:s>t&&u<n||r<e&&u>n?s-t+o:0}O.ContextConsumer=F,O.ContextProvider=Y,O.Element=X,O.ForwardRef=G,O.Fragment=J,O.Lazy=Q,O.Memo=Z,O.Portal=ee,O.Profiler=te,O.StrictMode=ne,O.Suspense=ie,O.isAsyncMode=function(){return!1},O.isConcurrentMode=function(){return!1},O.isContextConsumer=function(e){return q(e)===F},O.isContextProvider=function(e){return q(e)===H},O.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===D},O.isForwardRef=function(e){return q(e)===V},O.isFragment=function(e){return q(e)===P},O.isLazy=function(e){return q(e)===L},O.isMemo=function(e){return q(e)===N},O.isPortal=function(e){return q(e)===R},O.isProfiler=function(e){return q(e)===K},O.isStrictMode=function(e){return q(e)===T},O.isSuspense=function(e){return q(e)===$},O.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===P||e===K||e===U||e===T||e===$||e===A||e===W||"object"==typeof e&&null!==e&&(e.$$typeof===L||e.$$typeof===N||e.$$typeof===H||e.$$typeof===F||e.$$typeof===V||e.$$typeof===j||e.$$typeof===B||e[0]===_)},O.typeOf=q;let le=0;function ae(e){return"function"==typeof e?e:ce}function ce(){}function de(e,t){if(!e)return;const n=function(e,t){var n=window,i=t.scrollMode,o=t.block,r=t.inline,s=t.boundary,u=t.skipOverflowHiddenElements,l="function"==typeof s?s:function(e){return e!==s};if(!oe(e))throw new TypeError("Invalid target");for(var a=document.scrollingElement||document.documentElement,c=[],d=e;oe(d)&&l(d);){if((d=d.parentElement)===a){c.push(d);break}null!=d&&d===document.body&&se(d)&&!se(document.documentElement)||null!=d&&se(d,u)&&c.push(d)}for(var h=n.visualViewport?n.visualViewport.width:innerWidth,p=n.visualViewport?n.visualViewport.height:innerHeight,g=window.scrollX||pageXOffset,m=window.scrollY||pageYOffset,f=e.getBoundingClientRect(),I=f.height,y=f.width,v=f.top,b=f.right,x=f.bottom,w=f.left,S="start"===o||"nearest"===o?v:"end"===o?x:v+I/2,C="center"===r?w+y/2:"end"===r?b:w,k=[],M=0;M<c.length;M++){var E=c[M],O=E.getBoundingClientRect(),D=O.height,R=O.width,P=O.top,T=O.right,K=O.bottom,H=O.left;if("if-needed"===i&&v>=0&&w>=0&&x<=p&&b<=h&&v>=P&&x<=K&&w>=H&&b<=T)return k;var F=getComputedStyle(E),V=parseInt(F.borderLeftWidth,10),$=parseInt(F.borderTopWidth,10),A=parseInt(F.borderRightWidth,10),N=parseInt(F.borderBottomWidth,10),L=0,B=0,_="offsetWidth"in E?E.offsetWidth-E.clientWidth-V-A:0,j="offsetHeight"in E?E.offsetHeight-E.clientHeight-$-N:0;if(a===E)L="start"===o?S:"end"===o?S-p:"nearest"===o?ue(m,m+p,p,$,N,m+S,m+S+I,I):S-p/2,B="start"===r?C:"center"===r?C-h/2:"end"===r?C-h:ue(g,g+h,h,V,A,g+C,g+C+y,y),L=Math.max(0,L+m),B=Math.max(0,B+g);else{L="start"===o?S-P-$:"end"===o?S-K+N+j:"nearest"===o?ue(P,K,D,$,N+j,S,S+I,I):S-(P+D/2)+j/2,B="start"===r?C-H-V:"center"===r?C-(H+R/2)+_/2:"end"===r?C-T+A+_:ue(H,T,R,V,A+_,C,C+y,y);var U=E.scrollLeft,W=E.scrollTop;S+=W-(L=Math.max(0,Math.min(W+L,E.scrollHeight-D+j))),C+=U-(B=Math.max(0,Math.min(U+B,E.scrollWidth-R+_)))}k.push({el:E,top:L,left:B})}return k}(e,{boundary:t,block:"nearest",scrollMode:"if-needed"});n.forEach((e=>{let{el:t,top:n,left:i}=e;t.scrollTop=n,t.scrollLeft=i}))}function he(e,t,n){return e===t||t instanceof n.Node&&e.contains&&e.contains(t)}function pe(e,t){let n;function i(){n&&clearTimeout(n)}function o(){for(var o=arguments.length,r=new Array(o),s=0;s<o;s++)r[s]=arguments[s];i(),n=setTimeout((()=>{n=null,e(...r)}),t)}return o.cancel=i,o}function ge(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(e){for(var n=arguments.length,i=new Array(n>1?n-1:0),o=1;o<n;o++)i[o-1]=arguments[o];return t.some((t=>(t&&t(e,...i),e.preventDownshiftDefault||e.hasOwnProperty("nativeEvent")&&e.nativeEvent.preventDownshiftDefault)))}}function me(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return e=>{t.forEach((t=>{"function"==typeof t?t(e):t&&(t.current=e)}))}}function fe(){return String(le++)}function Ie(e){let{isOpen:t,resultCount:n,previousResultCount:i}=e;return t?n?n!==i?`${n} result${1===n?" is":"s are"} available, use up and down arrow keys to navigate. Press Enter key to select.`:"":"No results are available.":""}function ye(e,t){return!(e=Array.isArray(e)?e[0]:e)&&t?t:e}const ve=["highlightedIndex","inputValue","isOpen","selectedItem","type"];function be(e){void 0===e&&(e={});const t={};return ve.forEach((n=>{e.hasOwnProperty(n)&&(t[n]=e[n])})),t}function xe(e,t){return Object.keys(e).reduce(((n,i)=>(n[i]=we(t,i)?t[i]:e[i],n)),{})}function we(e,t){return void 0!==e[t]}function Se(e){const{key:t,keyCode:n}=e;return n>=37&&n<=40&&0!==t.indexOf("Arrow")?`Arrow${t}`:t}function Ce(e,t,n,i,o){if(void 0===o&&(o=!0),0===n)return-1;const r=n-1;("number"!=typeof t||t<0||t>=n)&&(t=e>0?-1:r+1);let s=t+e;s<0?s=o?r:0:s>r&&(s=o?0:r);const u=ke(e,s,n,i,o);return-1===u?t>=n?-1:t:u}function ke(e,t,n,i,o){const r=i(t);if(!r||!r.hasAttribute("disabled"))return t;if(e>0){for(let e=t+1;e<n;e++)if(!i(e).hasAttribute("disabled"))return e}else for(let e=t-1;e>=0;e--)if(!i(e).hasAttribute("disabled"))return e;return o?e>0?ke(1,0,n,i,!1):ke(-1,n-1,n,i,!1):-1}function Me(e,t,n,i){return void 0===i&&(i=!0),t.some((t=>t&&(he(t,e,n)||i&&he(t,n.document.activeElement,n))))}const Ee=pe((e=>{De(e).textContent=""}),500);function Oe(e,t){const n=De(t);e&&(n.textContent=e,Ee(t))}function De(e){void 0===e&&(e=document);let t=e.getElementById("a11y-status-message");return t||(t=e.createElement("div"),t.setAttribute("id","a11y-status-message"),t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t.setAttribute("aria-relevant","additions text"),Object.assign(t.style,{border:"0",clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:"0",position:"absolute",width:"1px"}),e.body.appendChild(t),t)}var Re=Object.freeze({__proto__:null,unknown:0,mouseUp:1,itemMouseEnter:2,keyDownArrowUp:3,keyDownArrowDown:4,keyDownEscape:5,keyDownEnter:6,keyDownHome:7,keyDownEnd:8,clickItem:9,blurInput:10,changeInput:11,keyDownSpaceButton:12,clickButton:13,blurButton:14,controlledPropUpdatedSelectedItem:15,touchEnd:16});const Pe=(()=>{class e extends t.Component{constructor(e){var t;super(e),t=this,this.id=this.props.id||`downshift-${fe()}`,this.menuId=this.props.menuId||`${this.id}-menu`,this.labelId=this.props.labelId||`${this.id}-label`,this.inputId=this.props.inputId||`${this.id}-input`,this.getItemId=this.props.getItemId||(e=>`${this.id}-item-${e}`),this.input=null,this.items=[],this.itemCount=null,this.previousResultCount=0,this.timeoutIds=[],this.internalSetTimeout=(e,t)=>{const n=setTimeout((()=>{this.timeoutIds=this.timeoutIds.filter((e=>e!==n)),e()}),t);this.timeoutIds.push(n)},this.setItemCount=e=>{this.itemCount=e},this.unsetItemCount=()=>{this.itemCount=null},this.setHighlightedIndex=function(e,n){void 0===e&&(e=t.props.defaultHighlightedIndex),void 0===n&&(n={}),n=be(n),t.internalSetState({highlightedIndex:e,...n})},this.clearSelection=e=>{this.internalSetState({selectedItem:null,inputValue:"",highlightedIndex:this.props.defaultHighlightedIndex,isOpen:this.props.defaultIsOpen},e)},this.selectItem=(e,t,n)=>{t=be(t),this.internalSetState({isOpen:this.props.defaultIsOpen,highlightedIndex:this.props.defaultHighlightedIndex,selectedItem:e,inputValue:this.props.itemToString(e),...t},n)},this.selectItemAtIndex=(e,t,n)=>{const i=this.items[e];null!=i&&this.selectItem(i,t,n)},this.selectHighlightedItem=(e,t)=>this.selectItemAtIndex(this.getState().highlightedIndex,e,t),this.internalSetState=(e,t)=>{let n,i;const o={},r="function"==typeof e;return!r&&e.hasOwnProperty("inputValue")&&this.props.onInputValueChange(e.inputValue,{...this.getStateAndHelpers(),...e}),this.setState((t=>{t=this.getState(t);let s=r?e(t):e;s=this.props.stateReducer(t,s),n=s.hasOwnProperty("selectedItem");const u={};return n&&s.selectedItem!==t.selectedItem&&(i=s.selectedItem),s.type=s.type||0,Object.keys(s).forEach((e=>{t[e]!==s[e]&&(o[e]=s[e]),"type"!==e&&(s[e],we(this.props,e)||(u[e]=s[e]))})),r&&s.hasOwnProperty("inputValue")&&this.props.onInputValueChange(s.inputValue,{...this.getStateAndHelpers(),...s}),u}),(()=>{ae(t)();Object.keys(o).length>1&&this.props.onStateChange(o,this.getStateAndHelpers()),n&&this.props.onSelect(e.selectedItem,this.getStateAndHelpers()),void 0!==i&&this.props.onChange(i,this.getStateAndHelpers()),this.props.onUserAction(o,this.getStateAndHelpers())}))},this.rootRef=e=>this._rootNode=e,this.getRootProps=function(e,n){let{refKey:i="ref",ref:o,...r}=void 0===e?{}:e,{suppressRefError:s=!1}=void 0===n?{}:n;t.getRootProps.called=!0,t.getRootProps.refKey=i,t.getRootProps.suppressRefError=s;const{isOpen:u}=t.getState();return{[i]:me(o,t.rootRef),role:"combobox","aria-expanded":u,"aria-haspopup":"listbox","aria-owns":u?t.menuId:null,"aria-labelledby":t.labelId,...r}},this.keyDownHandlers={ArrowDown(e){if(e.preventDefault(),this.getState().isOpen){const t=e.shiftKey?5:1;this.moveHighlightedIndex(t,{type:4})}else this.internalSetState({isOpen:!0,type:4},(()=>{const e=this.getItemCount();if(e>0){const{highlightedIndex:t}=this.getState(),n=Ce(1,t,e,(e=>this.getItemNodeFromIndex(e)));this.setHighlightedIndex(n,{type:4})}}))},ArrowUp(e){if(e.preventDefault(),this.getState().isOpen){const t=e.shiftKey?-5:-1;this.moveHighlightedIndex(t,{type:3})}else this.internalSetState({isOpen:!0,type:3},(()=>{const e=this.getItemCount();if(e>0){const{highlightedIndex:t}=this.getState(),n=Ce(-1,t,e,(e=>this.getItemNodeFromIndex(e)));this.setHighlightedIndex(n,{type:3})}}))},Enter(e){if(229===e.which)return;const{isOpen:t,highlightedIndex:n}=this.getState();if(t&&null!=n){e.preventDefault();const t=this.items[n],i=this.getItemNodeFromIndex(n);if(null==t||i&&i.hasAttribute("disabled"))return;this.selectHighlightedItem({type:6})}},Escape(e){e.preventDefault(),this.reset({type:5,...!this.state.isOpen&&{selectedItem:null,inputValue:""}})}},this.buttonKeyDownHandlers={...this.keyDownHandlers," "(e){e.preventDefault(),this.toggleMenu({type:12})}},this.inputKeyDownHandlers={...this.keyDownHandlers,Home(e){const{isOpen:t}=this.getState();if(!t)return;e.preventDefault();const n=this.getItemCount();if(n<=0||!t)return;const i=ke(1,0,n,(e=>this.getItemNodeFromIndex(e)),!1);this.setHighlightedIndex(i,{type:7})},End(e){const{isOpen:t}=this.getState();if(!t)return;e.preventDefault();const n=this.getItemCount();if(n<=0||!t)return;const i=ke(-1,n-1,n,(e=>this.getItemNodeFromIndex(e)),!1);this.setHighlightedIndex(i,{type:8})}},this.getToggleButtonProps=function(e){let{onClick:n,onPress:i,onKeyDown:o,onKeyUp:r,onBlur:s,...u}=void 0===e?{}:e;const{isOpen:l}=t.getState(),a={onClick:ge(n,t.buttonHandleClick),onKeyDown:ge(o,t.buttonHandleKeyDown),onKeyUp:ge(r,t.buttonHandleKeyUp),onBlur:ge(s,t.buttonHandleBlur)};return{type:"button",role:"button","aria-label":l?"close menu":"open menu","aria-haspopup":!0,"data-toggle":!0,...u.disabled?{}:a,...u}},this.buttonHandleKeyUp=e=>{e.preventDefault()},this.buttonHandleKeyDown=e=>{const t=Se(e);this.buttonKeyDownHandlers[t]&&this.buttonKeyDownHandlers[t].call(this,e)},this.buttonHandleClick=e=>{e.preventDefault(),this.props.environment.document.activeElement===this.props.environment.document.body&&e.target.focus(),this.internalSetTimeout((()=>this.toggleMenu({type:13})))},this.buttonHandleBlur=e=>{const t=e.target;this.internalSetTimeout((()=>{this.isMouseDown||null!=this.props.environment.document.activeElement&&this.props.environment.document.activeElement.id===this.inputId||this.props.environment.document.activeElement===t||this.reset({type:14})}))},this.getLabelProps=e=>({htmlFor:this.inputId,id:this.labelId,...e}),this.getInputProps=function(e){let n,{onKeyDown:i,onBlur:o,onChange:r,onInput:s,onChangeText:u,...l}=void 0===e?{}:e,a={};n="onChange";const{inputValue:c,isOpen:d,highlightedIndex:h}=t.getState();return l.disabled||(a={onChange:ge(r,s,t.inputHandleChange),onKeyDown:ge(i,t.inputHandleKeyDown),onBlur:ge(o,t.inputHandleBlur)}),{"aria-autocomplete":"list","aria-activedescendant":d&&"number"==typeof h&&h>=0?t.getItemId(h):null,"aria-controls":d?t.menuId:null,"aria-labelledby":t.labelId,autoComplete:"off",value:c,id:t.inputId,...a,...l}},this.inputHandleKeyDown=e=>{const t=Se(e);t&&this.inputKeyDownHandlers[t]&&this.inputKeyDownHandlers[t].call(this,e)},this.inputHandleChange=e=>{this.internalSetState({type:11,isOpen:!0,inputValue:e.target.value,highlightedIndex:this.props.defaultHighlightedIndex})},this.inputHandleBlur=()=>{this.internalSetTimeout((()=>{const e=this.props.environment.document&&!!this.props.environment.document.activeElement&&!!this.props.environment.document.activeElement.dataset&&this.props.environment.document.activeElement.dataset.toggle&&this._rootNode&&this._rootNode.contains(this.props.environment.document.activeElement);this.isMouseDown||e||this.reset({type:10})}))},this.menuRef=e=>{this._menuNode=e},this.getMenuProps=function(e,n){let{refKey:i="ref",ref:o,...r}=void 0===e?{}:e,{suppressRefError:s=!1}=void 0===n?{}:n;return t.getMenuProps.called=!0,t.getMenuProps.refKey=i,t.getMenuProps.suppressRefError=s,{[i]:me(o,t.menuRef),role:"listbox","aria-labelledby":r&&r["aria-label"]?null:t.labelId,id:t.menuId,...r}},this.getItemProps=function(e){let{onMouseMove:n,onMouseDown:i,onClick:o,onPress:r,index:s,item:u,...l}=void 0===e?{}:e;void 0===s?(t.items.push(u),s=t.items.indexOf(u)):t.items[s]=u;const a=o,c={onMouseMove:ge(n,(()=>{s!==t.getState().highlightedIndex&&(t.setHighlightedIndex(s,{type:2}),t.avoidScrolling=!0,t.internalSetTimeout((()=>t.avoidScrolling=!1),250))})),onMouseDown:ge(i,(e=>{e.preventDefault()})),onClick:ge(a,(()=>{t.selectItemAtIndex(s,{type:9})}))},d=l.disabled?{onMouseDown:c.onMouseDown}:c;return{id:t.getItemId(s),role:"option","aria-selected":t.getState().highlightedIndex===s,...d,...l}},this.clearItems=()=>{this.items=[]},this.reset=function(e,n){void 0===e&&(e={}),e=be(e),t.internalSetState((n=>{let{selectedItem:i}=n;return{isOpen:t.props.defaultIsOpen,highlightedIndex:t.props.defaultHighlightedIndex,inputValue:t.props.itemToString(i),...e}}),n)},this.toggleMenu=function(e,n){void 0===e&&(e={}),e=be(e),t.internalSetState((n=>{let{isOpen:i}=n;return{isOpen:!i,...i&&{highlightedIndex:t.props.defaultHighlightedIndex},...e}}),(()=>{const{isOpen:i,highlightedIndex:o}=t.getState();i&&t.getItemCount()>0&&"number"==typeof o&&t.setHighlightedIndex(o,e),ae(n)()}))},this.openMenu=e=>{this.internalSetState({isOpen:!0},e)},this.closeMenu=e=>{this.internalSetState({isOpen:!1},e)},this.updateStatus=pe((()=>{const e=this.getState(),t=this.items[e.highlightedIndex],n=this.getItemCount(),i=this.props.getA11yStatusMessage({itemToString:this.props.itemToString,previousResultCount:this.previousResultCount,resultCount:n,highlightedItem:t,...e});this.previousResultCount=n,Oe(i,this.props.environment.document)}),200);const{defaultHighlightedIndex:n,initialHighlightedIndex:i=n,defaultIsOpen:o,initialIsOpen:r=o,initialInputValue:s="",initialSelectedItem:u=null}=this.props,l=this.getState({highlightedIndex:i,isOpen:r,inputValue:s,selectedItem:u});null!=l.selectedItem&&void 0===this.props.initialInputValue&&(l.inputValue=this.props.itemToString(l.selectedItem)),this.state=l}internalClearTimeouts(){this.timeoutIds.forEach((e=>{clearTimeout(e)})),this.timeoutIds=[]}getState(e){return void 0===e&&(e=this.state),xe(e,this.props)}getItemCount(){let e=this.items.length;return null!=this.itemCount?e=this.itemCount:void 0!==this.props.itemCount&&(e=this.props.itemCount),e}getItemNodeFromIndex(e){return this.props.environment.document.getElementById(this.getItemId(e))}scrollHighlightedItemIntoView(){{const e=this.getItemNodeFromIndex(this.getState().highlightedIndex);this.props.scrollIntoView(e,this._menuNode)}}moveHighlightedIndex(e,t){const n=this.getItemCount(),{highlightedIndex:i}=this.getState();if(n>0){const o=Ce(e,i,n,(e=>this.getItemNodeFromIndex(e)));this.setHighlightedIndex(o,t)}}getStateAndHelpers(){const{highlightedIndex:e,inputValue:t,selectedItem:n,isOpen:i}=this.getState(),{itemToString:o}=this.props,{id:r}=this,{getRootProps:s,getToggleButtonProps:u,getLabelProps:l,getMenuProps:a,getInputProps:c,getItemProps:d,openMenu:h,closeMenu:p,toggleMenu:g,selectItem:m,selectItemAtIndex:f,selectHighlightedItem:I,setHighlightedIndex:y,clearSelection:v,clearItems:b,reset:x,setItemCount:w,unsetItemCount:S,internalSetState:C}=this;return{getRootProps:s,getToggleButtonProps:u,getLabelProps:l,getMenuProps:a,getInputProps:c,getItemProps:d,reset:x,openMenu:h,closeMenu:p,toggleMenu:g,selectItem:m,selectItemAtIndex:f,selectHighlightedItem:I,setHighlightedIndex:y,clearSelection:v,clearItems:b,setItemCount:w,unsetItemCount:S,setState:C,itemToString:o,id:r,highlightedIndex:e,inputValue:t,isOpen:i,selectedItem:n}}componentDidMount(){{const e=()=>{this.isMouseDown=!0},t=e=>{this.isMouseDown=!1;!Me(e.target,[this._rootNode,this._menuNode],this.props.environment)&&this.getState().isOpen&&this.reset({type:1},(()=>this.props.onOuterClick(this.getStateAndHelpers())))},n=()=>{this.isTouchMove=!1},i=()=>{this.isTouchMove=!0},o=e=>{const t=Me(e.target,[this._rootNode,this._menuNode],this.props.environment,!1);this.isTouchMove||t||!this.getState().isOpen||this.reset({type:16},(()=>this.props.onOuterClick(this.getStateAndHelpers())))},{environment:r}=this.props;r.addEventListener("mousedown",e),r.addEventListener("mouseup",t),r.addEventListener("touchstart",n),r.addEventListener("touchmove",i),r.addEventListener("touchend",o),this.cleanup=()=>{this.internalClearTimeouts(),this.updateStatus.cancel(),r.removeEventListener("mousedown",e),r.removeEventListener("mouseup",t),r.removeEventListener("touchstart",n),r.removeEventListener("touchmove",i),r.removeEventListener("touchend",o)}}}shouldScroll(e,t){const{highlightedIndex:n}=void 0===this.props.highlightedIndex?this.getState():this.props,{highlightedIndex:i}=void 0===t.highlightedIndex?e:t;return n&&this.getState().isOpen&&!e.isOpen||n!==i}componentDidUpdate(e,t){we(this.props,"selectedItem")&&this.props.selectedItemChanged(e.selectedItem,this.props.selectedItem)&&this.internalSetState({type:15,inputValue:this.props.itemToString(this.props.selectedItem)}),!this.avoidScrolling&&this.shouldScroll(t,e)&&this.scrollHighlightedItemIntoView(),this.updateStatus()}componentWillUnmount(){this.cleanup()}render(){const e=ye(this.props.children,ce);this.clearItems(),this.getRootProps.called=!1,this.getRootProps.refKey=void 0,this.getRootProps.suppressRefError=void 0,this.getMenuProps.called=!1,this.getMenuProps.refKey=void 0,this.getMenuProps.suppressRefError=void 0,this.getLabelProps.called=!1,this.getInputProps.called=!1;const n=ye(e(this.getStateAndHelpers()));return n?this.getRootProps.called||this.props.suppressRefError?n:function(e){return"string"==typeof e.type}(n)?t.cloneElement(n,this.getRootProps(function(e){return e.props}(n))):void 0:null}}return e.defaultProps={defaultHighlightedIndex:null,defaultIsOpen:!1,getA11yStatusMessage:Ie,itemToString:e=>null==e?"":String(e),onStateChange:ce,onInputValueChange:ce,onUserAction:ce,onChange:ce,onSelect:ce,onOuterClick:ce,selectedItemChanged:(e,t)=>e!==t,environment:"undefined"==typeof window?{}:window,stateReducer:(e,t)=>t,suppressRefError:!1,scrollIntoView:de},e.stateChangeTypes=Re,e})();var Te=Pe;const Ke={highlightedIndex:-1,isOpen:!1,selectedItem:null,inputValue:""};function He(e,t,n){const{props:i,type:o}=e,r={};Object.keys(t).forEach((i=>{!function(e,t,n,i){const{props:o,type:r}=t,s=`on${Le(e)}Change`;o[s]&&void 0!==i[e]&&i[e]!==n[e]&&o[s]({type:r,...i})}(i,e,t,n),n[i]!==t[i]&&(r[i]=n[i])})),i.onStateChange&&Object.keys(r).length&&i.onStateChange({type:o,...r})}const Fe=pe(((e,t)=>{Oe(e(),t)}),200),Ve="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?t.useLayoutEffect:t.useEffect;function $e(e){let{id:n=`downshift-${fe()}`,labelId:i,menuId:o,getItemId:r,toggleButtonId:s,inputId:u}=e;return t.useRef({labelId:i||`${n}-label`,menuId:o||`${n}-menu`,getItemId:r||(e=>`${n}-item-${e}`),toggleButtonId:s||`${n}-toggle-button`,inputId:u||`${n}-input`}).current}function Ae(e,t,n){return void 0!==e?e:0===n.length?-1:n.indexOf(t)}function Ne(e){return/^\S{1}$/.test(e)}function Le(e){return`${e.slice(0,1).toUpperCase()}${e.slice(1)}`}function Be(e){const n=t.useRef(e);return n.current=e,n}function _e(e,n,i){const o=t.useRef(),r=t.useRef(),s=t.useCallback(((t,n)=>{r.current=n,t=xe(t,n.props);const i=e(t,n);return n.props.stateReducer(t,{...n,changes:i})}),[e]),[u,l]=t.useReducer(s,n),a=Be(i),c=t.useCallback((e=>l({props:a.current,...e})),[a]),d=r.current;return t.useEffect((()=>{d&&o.current&&o.current!==u&&He(d,xe(o.current,d.props),u),o.current=u}),[u,i,d]),[u,c]}function je(e,t,n){const[i,o]=_e(e,t,n);return[xe(i,n),o]}const Ue={itemToString:function(e){return e?String(e):""},stateReducer:function(e,t){return t.changes},getA11ySelectionMessage:function(e){const{selectedItem:t,itemToString:n}=e;return t?`${n(t)} has been selected.`:""},scrollIntoView:de,circularNavigation:!1,environment:"undefined"==typeof window?{}:window};function We(e,t,n){void 0===n&&(n=Ke);const i=e[`default${Le(t)}`];return void 0!==i?i:n[t]}function ze(e,t,n){void 0===n&&(n=Ke);const i=e[t];if(void 0!==i)return i;const o=e[`initial${Le(t)}`];return void 0!==o?o:We(e,t,n)}function qe(e){const t=ze(e,"selectedItem"),n=ze(e,"isOpen"),i=ze(e,"highlightedIndex"),o=ze(e,"inputValue");return{highlightedIndex:i<0&&t&&n?e.items.indexOf(t):i,isOpen:n,selectedItem:t,inputValue:o}}function Ye(e,t,n,i){const{items:o,initialHighlightedIndex:r,defaultHighlightedIndex:s}=e,{selectedItem:u,highlightedIndex:l}=t;return 0===o.length?-1:void 0!==r&&l===r?r:void 0!==s?s:u?0===n?o.indexOf(u):Ce(n,o.indexOf(u),o.length,i,!1):0===n?-1:n<0?o.length-1:0}function Xe(e,n,i,o){const r=t.useRef({isMouseDown:!1,isTouchMove:!1});return t.useEffect((()=>{const t=()=>{r.current.isMouseDown=!0},s=t=>{r.current.isMouseDown=!1,e&&!Me(t.target,n.map((e=>e.current)),i)&&o()},u=()=>{r.current.isTouchMove=!1},l=()=>{r.current.isTouchMove=!0},a=t=>{!e||r.current.isTouchMove||Me(t.target,n.map((e=>e.current)),i,!1)||o()};return i.addEventListener("mousedown",t),i.addEventListener("mouseup",s),i.addEventListener("touchstart",u),i.addEventListener("touchmove",l),i.addEventListener("touchend",a),function(){i.removeEventListener("mousedown",t),i.removeEventListener("mouseup",s),i.removeEventListener("touchstart",u),i.removeEventListener("touchmove",l),i.removeEventListener("touchend",a)}}),[e,i]),r}let Ge=()=>ce;function Je(e,n,i){let{isInitialMount:o,highlightedIndex:r,items:s,environment:u,...l}=i;t.useEffect((()=>{o||Fe((()=>e({highlightedIndex:r,highlightedItem:s[r],resultCount:s.length,...l})),u.document)}),n)}function Qe(e){let{highlightedIndex:n,isOpen:i,itemRefs:o,getItemNodeFromIndex:r,menuElement:s,scrollIntoView:u}=e;const l=t.useRef(!0);return Ve((()=>{n<0||!i||!Object.keys(o.current).length||(!1===l.current?l.current=!0:u(r(n),s))}),[n]),l}let Ze=ce;function et(e,t,n){const{type:i,props:o}=t;let r;switch(i){case n.ItemMouseMove:r={highlightedIndex:t.index};break;case n.MenuMouseLeave:r={highlightedIndex:-1};break;case n.ToggleButtonClick:case n.FunctionToggleMenu:r={isOpen:!e.isOpen,highlightedIndex:e.isOpen?-1:Ye(o,e,0)};break;case n.FunctionOpenMenu:r={isOpen:!0,highlightedIndex:Ye(o,e,0)};break;case n.FunctionCloseMenu:r={isOpen:!1};break;case n.FunctionSetHighlightedIndex:r={highlightedIndex:t.highlightedIndex};break;case n.FunctionSetInputValue:r={inputValue:t.inputValue};break;case n.FunctionReset:r={highlightedIndex:We(o,"highlightedIndex"),isOpen:We(o,"isOpen"),selectedItem:We(o,"selectedItem"),inputValue:We(o,"inputValue")};break;default:throw new Error("Reducer called without proper action type.")}return{...e,...r}}var tt=function(){return tt=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},tt.apply(this,arguments)};function nt(e){for(var t=e.keysSoFar,n=e.highlightedIndex,i=e.items,o=e.itemToString,r=e.getItemNodeFromIndex,s=t.toLowerCase(),u=0;u<i.length;u++){var l=(u+n+1)%i.length,a=i[l];if(void 0!==a&&o(a).toLowerCase().startsWith(s)){var c=r(l);if(!(null==c?void 0:c.hasAttribute("disabled")))return l}}return n}E.array.isRequired,E.func,E.func,E.func,E.bool,E.number,E.number,E.number,E.bool,E.bool,E.bool,E.any,E.any,E.any,E.string,E.string,E.string,E.func,E.string,E.func,E.func,E.func,E.func,E.func,E.shape({addEventListener:E.func,removeEventListener:E.func,document:E.shape({getElementById:E.func,activeElement:E.any,body:E.any})});var it=tt(tt({},Ue),{getA11yStatusMessage:function(e){var t=e.isOpen,n=e.resultCount,i=e.previousResultCount;return t?n?n!==i?"".concat(n," result").concat(1===n?" is":"s are"," available, use up and down arrow keys to navigate. Press Enter or Space Bar keys to select."):"":"No results are available.":""}}),ot=ce;var rt=Object.freeze({__proto__:null,MenuKeyDownArrowDown:0,MenuKeyDownArrowUp:1,MenuKeyDownEscape:2,MenuKeyDownHome:3,MenuKeyDownEnd:4,MenuKeyDownEnter:5,MenuKeyDownSpaceButton:6,MenuKeyDownCharacter:7,MenuBlur:8,MenuMouseLeave:9,ItemMouseMove:10,ItemClick:11,ToggleButtonClick:12,ToggleButtonKeyDownArrowDown:13,ToggleButtonKeyDownArrowUp:14,ToggleButtonKeyDownCharacter:15,FunctionToggleMenu:16,FunctionOpenMenu:17,FunctionCloseMenu:18,FunctionSetHighlightedIndex:19,FunctionSelectItem:20,FunctionSetInputValue:21,FunctionReset:22});function st(e,t){const{type:n,props:i,shiftKey:o}=t;let r;switch(n){case 11:r={isOpen:We(i,"isOpen"),highlightedIndex:We(i,"highlightedIndex"),selectedItem:i.items[t.index]};break;case 15:{const n=t.key,o=`${e.inputValue}${n}`,s=nt({keysSoFar:o,highlightedIndex:e.selectedItem?i.items.indexOf(e.selectedItem):-1,items:i.items,itemToString:i.itemToString,getItemNodeFromIndex:t.getItemNodeFromIndex});r={inputValue:o,...s>=0&&{selectedItem:i.items[s]}}}break;case 13:r={highlightedIndex:Ye(i,e,1,t.getItemNodeFromIndex),isOpen:!0};break;case 14:r={highlightedIndex:Ye(i,e,-1,t.getItemNodeFromIndex),isOpen:!0};break;case 5:case 6:r={isOpen:We(i,"isOpen"),highlightedIndex:We(i,"highlightedIndex"),...e.highlightedIndex>=0&&{selectedItem:i.items[e.highlightedIndex]}};break;case 3:r={highlightedIndex:ke(1,0,i.items.length,t.getItemNodeFromIndex,!1)};break;case 4:r={highlightedIndex:ke(-1,i.items.length-1,i.items.length,t.getItemNodeFromIndex,!1)};break;case 2:case 8:r={isOpen:!1,highlightedIndex:-1};break;case 7:{const n=t.key,o=`${e.inputValue}${n}`,s=nt({keysSoFar:o,highlightedIndex:e.highlightedIndex,items:i.items,itemToString:i.itemToString,getItemNodeFromIndex:t.getItemNodeFromIndex});r={inputValue:o,...s>=0&&{highlightedIndex:s}}}break;case 0:r={highlightedIndex:Ce(o?5:1,e.highlightedIndex,i.items.length,t.getItemNodeFromIndex,i.circularNavigation)};break;case 1:r={highlightedIndex:Ce(o?-5:-1,e.highlightedIndex,i.items.length,t.getItemNodeFromIndex,i.circularNavigation)};break;case 20:r={selectedItem:t.selectedItem};break;default:return et(e,t,rt)}return{...e,...r}}function ut(e){void 0===e&&(e={}),ot();const n={...it,...e},{items:i,scrollIntoView:o,environment:r,initialIsOpen:s,defaultIsOpen:u,itemToString:l,getA11ySelectionMessage:a,getA11yStatusMessage:c}=n,d=qe(n),[h,p]=je(st,d,n),{isOpen:g,highlightedIndex:m,selectedItem:f,inputValue:I}=h,y=t.useRef(null),v=t.useRef(null),b=t.useRef({}),x=t.useRef(!0),w=t.useRef(null),S=$e(n),C=t.useRef(),k=t.useRef(!0),M=Be({state:h,props:n}),E=t.useCallback((e=>b.current[S.getItemId(e)]),[S]);Je(c,[g,m,I,i],{isInitialMount:k.current,previousResultCount:C.current,items:i,environment:r,itemToString:l,...h}),Je(a,[f],{isInitialMount:k.current,previousResultCount:C.current,items:i,environment:r,itemToString:l,...h});const O=Qe({menuElement:v.current,highlightedIndex:m,isOpen:g,itemRefs:b,scrollIntoView:o,getItemNodeFromIndex:E});t.useEffect((()=>(w.current=pe((e=>{e({type:21,inputValue:""})}),500),()=>{w.current.cancel()})),[]),t.useEffect((()=>{I&&w.current(p)}),[p,I]),Ze({isInitialMount:k.current,props:n,state:h}),t.useEffect((()=>{k.current?(s||u||g)&&v.current&&v.current.focus():g?v.current&&v.current.focus():r.document.activeElement===v.current&&y.current&&(x.current=!1,y.current.focus())}),[g]),t.useEffect((()=>{k.current||(C.current=i.length)}));const D=Xe(g,[v,y],r,(()=>{p({type:8})})),R=Ge();t.useEffect((()=>{k.current=!1}),[]),t.useEffect((()=>{g||(b.current={})}),[g]);const P=t.useMemo((()=>({ArrowDown(e){e.preventDefault(),p({type:13,getItemNodeFromIndex:E,shiftKey:e.shiftKey})},ArrowUp(e){e.preventDefault(),p({type:14,getItemNodeFromIndex:E,shiftKey:e.shiftKey})}})),[p,E]),T=t.useMemo((()=>({ArrowDown(e){e.preventDefault(),p({type:0,getItemNodeFromIndex:E,shiftKey:e.shiftKey})},ArrowUp(e){e.preventDefault(),p({type:1,getItemNodeFromIndex:E,shiftKey:e.shiftKey})},Home(e){e.preventDefault(),p({type:3,getItemNodeFromIndex:E})},End(e){e.preventDefault(),p({type:4,getItemNodeFromIndex:E})},Escape(){p({type:2})},Enter(e){e.preventDefault(),p({type:5})}," "(e){e.preventDefault(),p({type:6})}})),[p,E]),K=t.useCallback((()=>{p({type:16})}),[p]),H=t.useCallback((()=>{p({type:18})}),[p]),F=t.useCallback((()=>{p({type:17})}),[p]),V=t.useCallback((e=>{p({type:19,highlightedIndex:e})}),[p]),$=t.useCallback((e=>{p({type:20,selectedItem:e})}),[p]),A=t.useCallback((()=>{p({type:22})}),[p]),N=t.useCallback((e=>{p({type:21,inputValue:e})}),[p]),L=t.useCallback((e=>({id:S.labelId,htmlFor:S.toggleButtonId,...e})),[S]),B=t.useCallback((function(e,t){let{onMouseLeave:n,refKey:i="ref",onKeyDown:o,onBlur:r,ref:s,...u}=void 0===e?{}:e,{suppressRefError:l=!1}=void 0===t?{}:t;const a=M.current.state;return R("getMenuProps",l,i,v),{[i]:me(s,(e=>{v.current=e})),id:S.menuId,role:"listbox","aria-labelledby":S.labelId,tabIndex:-1,...a.isOpen&&a.highlightedIndex>-1&&{"aria-activedescendant":S.getItemId(a.highlightedIndex)},onMouseLeave:ge(n,(()=>{p({type:9})})),onKeyDown:ge(o,(e=>{const t=Se(e);t&&T[t]?T[t](e):Ne(t)&&p({type:7,key:t,getItemNodeFromIndex:E})})),onBlur:ge(r,(()=>{if(!1===x.current)return void(x.current=!0);!D.current.isMouseDown&&p({type:8})})),...u}}),[p,M,T,D,R,S,E]);return{getToggleButtonProps:t.useCallback((function(e,t){let{onClick:n,onKeyDown:i,refKey:o="ref",ref:r,...s}=void 0===e?{}:e,{suppressRefError:u=!1}=void 0===t?{}:t;const l=()=>{p({type:12})},a=e=>{const t=Se(e);t&&P[t]?P[t](e):Ne(t)&&p({type:15,key:t,getItemNodeFromIndex:E})},c={[o]:me(r,(e=>{y.current=e})),id:S.toggleButtonId,"aria-haspopup":"listbox","aria-expanded":M.current.state.isOpen,"aria-labelledby":`${S.labelId} ${S.toggleButtonId}`,...s};return s.disabled||(c.onClick=ge(n,l),c.onKeyDown=ge(i,a)),R("getToggleButtonProps",u,o,y),c}),[p,M,P,R,S,E]),getLabelProps:L,getMenuProps:B,getItemProps:t.useCallback((function(e){let{item:t,index:n,onMouseMove:i,onClick:o,refKey:r="ref",ref:s,...u}=void 0===e?{}:e;const{state:l,props:a}=M.current,c=()=>{n!==l.highlightedIndex&&(O.current=!1,p({type:10,index:n}))},d=()=>{p({type:11,index:n})},h=Ae(n,t,a.items);if(h<0)throw new Error("Pass either item or item index in getItemProps!");const g={role:"option","aria-selected":`${h===l.highlightedIndex}`,id:S.getItemId(h),[r]:me(s,(e=>{e&&(b.current[S.getItemId(h)]=e)})),...u};return u.disabled||(g.onMouseMove=ge(i,c),g.onClick=ge(o,d)),g}),[p,M,O,S]),toggleMenu:K,openMenu:F,closeMenu:H,setHighlightedIndex:V,selectItem:$,reset:A,setInputValue:N,highlightedIndex:m,isOpen:g,selectedItem:f,inputValue:I}}ut.stateChangeTypes=rt;var lt=Object.freeze({__proto__:null,InputKeyDownArrowDown:0,InputKeyDownArrowUp:1,InputKeyDownEscape:2,InputKeyDownHome:3,InputKeyDownEnd:4,InputKeyDownEnter:5,InputChange:6,InputBlur:7,MenuMouseLeave:8,ItemMouseMove:9,ItemClick:10,ToggleButtonClick:11,FunctionToggleMenu:12,FunctionOpenMenu:13,FunctionCloseMenu:14,FunctionSetHighlightedIndex:15,FunctionSelectItem:16,FunctionSetInputValue:17,FunctionReset:18,ControlledPropUpdatedSelectedItem:19});E.array.isRequired,E.func,E.func,E.func,E.bool,E.number,E.number,E.number,E.bool,E.bool,E.bool,E.any,E.any,E.any,E.string,E.string,E.string,E.string,E.string,E.string,E.func,E.string,E.string,E.func,E.func,E.func,E.func,E.func,E.func,E.shape({addEventListener:E.func,removeEventListener:E.func,document:E.shape({getElementById:E.func,activeElement:E.any,body:E.any})});let at=ce;const ct={...Ue,getA11yStatusMessage:Ie,circularNavigation:!0};function dt(e,t){const{type:n,props:i,shiftKey:o}=t;let r;switch(n){case 10:r={isOpen:We(i,"isOpen"),highlightedIndex:We(i,"highlightedIndex"),selectedItem:i.items[t.index],inputValue:i.itemToString(i.items[t.index])};break;case 0:r=e.isOpen?{highlightedIndex:Ce(o?5:1,e.highlightedIndex,i.items.length,t.getItemNodeFromIndex,i.circularNavigation)}:{highlightedIndex:Ye(i,e,1,t.getItemNodeFromIndex),isOpen:i.items.length>=0};break;case 1:r=e.isOpen?{highlightedIndex:Ce(o?-5:-1,e.highlightedIndex,i.items.length,t.getItemNodeFromIndex,i.circularNavigation)}:{highlightedIndex:Ye(i,e,-1,t.getItemNodeFromIndex),isOpen:i.items.length>=0};break;case 5:r={...e.isOpen&&e.highlightedIndex>=0&&{selectedItem:i.items[e.highlightedIndex],isOpen:We(i,"isOpen"),highlightedIndex:We(i,"highlightedIndex"),inputValue:i.itemToString(i.items[e.highlightedIndex])}};break;case 2:r={isOpen:!1,highlightedIndex:-1,...!e.isOpen&&{selectedItem:null,inputValue:""}};break;case 3:r={highlightedIndex:ke(1,0,i.items.length,t.getItemNodeFromIndex,!1)};break;case 4:r={highlightedIndex:ke(-1,i.items.length-1,i.items.length,t.getItemNodeFromIndex,!1)};break;case 7:r={isOpen:!1,highlightedIndex:-1,...e.highlightedIndex>=0&&t.selectItem&&{selectedItem:i.items[e.highlightedIndex],inputValue:i.itemToString(i.items[e.highlightedIndex])}};break;case 6:r={isOpen:!0,highlightedIndex:We(i,"highlightedIndex"),inputValue:t.inputValue};break;case 16:r={selectedItem:t.selectedItem,inputValue:i.itemToString(t.selectedItem)};break;case 19:r={inputValue:t.inputValue};break;default:return et(e,t,lt)}return{...e,...r}}function ht(e){void 0===e&&(e={}),at();const n={...ct,...e},{initialIsOpen:i,defaultIsOpen:o,items:r,scrollIntoView:s,environment:u,getA11yStatusMessage:l,getA11ySelectionMessage:a,itemToString:c}=n,d=function(e){const t=qe(e),{selectedItem:n}=t;let{inputValue:i}=t;return""===i&&n&&void 0===e.defaultInputValue&&void 0===e.initialInputValue&&void 0===e.inputValue&&(i=e.itemToString(n)),{...t,inputValue:i}}(n),[h,p]=function(e,n,i){const o=t.useRef(),[r,s]=_e(e,n,i);return t.useEffect((()=>{we(i,"selectedItem")&&(o.current!==i.selectedItem&&s({type:19,inputValue:i.itemToString(i.selectedItem)}),o.current=r.selectedItem===o.current?i.selectedItem:r.selectedItem)})),[xe(r,i),s]}(dt,d,n),{isOpen:g,highlightedIndex:m,selectedItem:f,inputValue:I}=h,y=t.useRef(null),v=t.useRef({}),b=t.useRef(null),x=t.useRef(null),w=t.useRef(null),S=t.useRef(!0),C=$e(n),k=t.useRef(),M=Be({state:h,props:n}),E=t.useCallback((e=>v.current[C.getItemId(e)]),[C]);Je(l,[g,m,I,r],{isInitialMount:S.current,previousResultCount:k.current,items:r,environment:u,itemToString:c,...h}),Je(a,[f],{isInitialMount:S.current,previousResultCount:k.current,items:r,environment:u,itemToString:c,...h});const O=Qe({menuElement:y.current,highlightedIndex:m,isOpen:g,itemRefs:v,scrollIntoView:s,getItemNodeFromIndex:E});Ze({isInitialMount:S.current,props:n,state:h}),t.useEffect((()=>{(i||o||g)&&b.current&&b.current.focus()}),[]),t.useEffect((()=>{S.current||(k.current=r.length)}));const D=Xe(g,[w,y,x],u,(()=>{p({type:7,selectItem:!1})})),R=Ge();t.useEffect((()=>{S.current=!1}),[]),t.useEffect((()=>{g||(v.current={})}),[g]);const P=t.useMemo((()=>({ArrowDown(e){e.preventDefault(),p({type:0,shiftKey:e.shiftKey,getItemNodeFromIndex:E})},ArrowUp(e){e.preventDefault(),p({type:1,shiftKey:e.shiftKey,getItemNodeFromIndex:E})},Home(e){M.current.state.isOpen&&(e.preventDefault(),p({type:3,getItemNodeFromIndex:E}))},End(e){M.current.state.isOpen&&(e.preventDefault(),p({type:4,getItemNodeFromIndex:E}))},Escape(e){const t=M.current.state;(t.isOpen||t.inputValue||t.selectedItem||t.highlightedIndex>-1)&&(e.preventDefault(),p({type:2}))},Enter(e){const t=M.current.state;!t.isOpen||t.highlightedIndex<0||229===e.which||(e.preventDefault(),p({type:5,getItemNodeFromIndex:E}))}})),[p,M,E]),T=t.useCallback((e=>({id:C.labelId,htmlFor:C.inputId,...e})),[C]),K=t.useCallback((function(e,t){let{onMouseLeave:n,refKey:i="ref",ref:o,...r}=void 0===e?{}:e,{suppressRefError:s=!1}=void 0===t?{}:t;return R("getMenuProps",s,i,y),{[i]:me(o,(e=>{y.current=e})),id:C.menuId,role:"listbox","aria-labelledby":C.labelId,onMouseLeave:ge(n,(()=>{p({type:8})})),...r}}),[p,R,C]),H=t.useCallback((function(e){let{item:t,index:n,refKey:i="ref",ref:o,onMouseMove:r,onClick:s,onPress:u,...l}=void 0===e?{}:e;const{props:a,state:c}=M.current,d=Ae(n,t,a.items);if(d<0)throw new Error("Pass either item or item index in getItemProps!");const h=s;return{[i]:me(o,(e=>{e&&(v.current[C.getItemId(d)]=e)})),role:"option","aria-selected":`${d===c.highlightedIndex}`,id:C.getItemId(d),...!l.disabled&&{onMouseMove:ge(r,(()=>{n!==c.highlightedIndex&&(O.current=!1,p({type:9,index:n}))})),onClick:ge(h,(()=>{p({type:10,index:n}),b.current&&b.current.focus()}))},...l}}),[p,M,O,C]),F=t.useCallback((function(e){let{onClick:t,onPress:n,refKey:i="ref",ref:o,...r}=void 0===e?{}:e;return{[i]:me(o,(e=>{x.current=e})),id:C.toggleButtonId,tabIndex:-1,...!r.disabled&&{onClick:ge(t,(()=>{p({type:11}),!M.current.state.isOpen&&b.current&&b.current.focus()}))},...r}}),[p,M,C]),V=t.useCallback((function(e,t){let{onKeyDown:n,onChange:i,onInput:o,onBlur:r,onChangeText:s,refKey:u="ref",ref:l,...a}=void 0===e?{}:e,{suppressRefError:c=!1}=void 0===t?{}:t;R("getInputProps",c,u,b);const d=M.current.state,h=e=>{const t=Se(e);t&&P[t]&&P[t](e)},g=e=>{p({type:6,inputValue:e.target.value})},m=()=>{d.isOpen&&!D.current.isMouseDown&&p({type:7,selectItem:!0})};let f={};return a.disabled||(f={onChange:ge(i,o,g),onKeyDown:ge(n,h),onBlur:ge(r,m)}),{[u]:me(l,(e=>{b.current=e})),id:C.inputId,"aria-autocomplete":"list","aria-controls":C.menuId,...d.isOpen&&d.highlightedIndex>-1&&{"aria-activedescendant":C.getItemId(d.highlightedIndex)},"aria-labelledby":C.labelId,autoComplete:"off",value:d.inputValue,...f,...a}}),[p,P,M,D,R,C]),$=t.useCallback((function(e,t){let{refKey:n="ref",ref:i,...o}=void 0===e?{}:e,{suppressRefError:r=!1}=void 0===t?{}:t;return R("getComboboxProps",r,n,w),{[n]:me(i,(e=>{w.current=e})),role:"combobox","aria-haspopup":"listbox","aria-owns":C.menuId,"aria-expanded":M.current.state.isOpen,...o}}),[M,R,C]),A=t.useCallback((()=>{p({type:12})}),[p]),N=t.useCallback((()=>{p({type:14})}),[p]),L=t.useCallback((()=>{p({type:13})}),[p]),B=t.useCallback((e=>{p({type:15,highlightedIndex:e})}),[p]),_=t.useCallback((e=>{p({type:16,selectedItem:e})}),[p]);return{getItemProps:H,getLabelProps:T,getMenuProps:K,getInputProps:V,getComboboxProps:$,getToggleButtonProps:F,toggleMenu:A,openMenu:L,closeMenu:N,setHighlightedIndex:B,setInputValue:t.useCallback((e=>{p({type:17,inputValue:e})}),[p]),selectItem:_,reset:t.useCallback((()=>{p({type:18})}),[p]),highlightedIndex:m,isOpen:g,selectedItem:f,inputValue:I}}ht.stateChangeTypes=lt;const pt={activeIndex:-1,selectedItems:[]};function gt(e,t){return ze(e,t,pt)}function mt(e,t){return We(e,t,pt)}function ft(e){if(e.shiftKey||e.metaKey||e.ctrlKey||e.altKey)return!1;const t=e.target;return!(t instanceof HTMLInputElement&&""!==t.value)||0===t.selectionStart&&0===t.selectionEnd}E.array,E.array,E.array,E.func,E.func,E.func,E.number,E.number,E.number,E.func,E.func,E.string,E.string,E.shape({addEventListener:E.func,removeEventListener:E.func,document:E.shape({getElementById:E.func,activeElement:E.any,body:E.any})});const It={itemToString:Ue.itemToString,stateReducer:Ue.stateReducer,environment:Ue.environment,getA11yRemovalMessage:function(e){const{removedSelectedItem:t,itemToString:n}=e;return`${n(t)} has been removed.`},keyNavigationNext:"ArrowRight",keyNavigationPrevious:"ArrowLeft"};let yt=ce;var vt=Object.freeze({__proto__:null,SelectedItemClick:0,SelectedItemKeyDownDelete:1,SelectedItemKeyDownBackspace:2,SelectedItemKeyDownNavigationNext:3,SelectedItemKeyDownNavigationPrevious:4,DropdownKeyDownNavigationPrevious:5,DropdownKeyDownBackspace:6,DropdownClick:7,FunctionAddSelectedItem:8,FunctionRemoveSelectedItem:9,FunctionSetSelectedItems:10,FunctionSetActiveIndex:11,FunctionReset:12});function bt(e,t){const{type:n,index:i,props:o,selectedItem:r}=t,{activeIndex:s,selectedItems:u}=e;let l;switch(n){case 0:l={activeIndex:i};break;case 4:l={activeIndex:s-1<0?0:s-1};break;case 3:l={activeIndex:s+1>=u.length?-1:s+1};break;case 2:case 1:{let e=s;1===u.length?e=-1:s===u.length-1&&(e=u.length-2),l={selectedItems:[...u.slice(0,s),...u.slice(s+1)],activeIndex:e};break}case 5:l={activeIndex:u.length-1};break;case 6:l={selectedItems:u.slice(0,u.length-1)};break;case 8:l={selectedItems:[...u,r]};break;case 7:l={activeIndex:-1};break;case 9:{let e=s;const t=u.indexOf(r);t>=0&&(1===u.length?e=-1:t===u.length-1&&(e=u.length-2),l={selectedItems:[...u.slice(0,t),...u.slice(t+1)],activeIndex:e});break}case 10:{const{selectedItems:e}=t;l={selectedItems:e};break}case 11:{const{activeIndex:e}=t;l={activeIndex:e};break}case 12:l={activeIndex:mt(o,"activeIndex"),selectedItems:mt(o,"selectedItems")};break;default:throw new Error("Reducer called without proper action type.")}return{...e,...l}}function xt(e){void 0===e&&(e={}),yt();const n={...It,...e},{getA11yRemovalMessage:i,itemToString:o,environment:r,keyNavigationNext:s,keyNavigationPrevious:u}=n,[l,a]=je(bt,function(e){return{activeIndex:gt(e,"activeIndex"),selectedItems:gt(e,"selectedItems")}}(n),n),{activeIndex:c,selectedItems:d}=l,h=t.useRef(!0),p=t.useRef(null),g=t.useRef(d),m=t.useRef();m.current=[];const f=Be({state:l,props:n});t.useEffect((()=>{if(!h.current){if(d.length<g.current.length){const e=g.current.find((e=>d.indexOf(e)<0));Oe(i({itemToString:o,resultCount:d.length,removedSelectedItem:e,activeIndex:c,activeSelectedItem:d[c]}),r.document)}g.current=d}}),[d.length]),t.useEffect((()=>{h.current||(-1===c&&p.current?p.current.focus():m.current[c]&&m.current[c].focus())}),[c]),Ze({isInitialMount:h.current,props:n,state:l});const I=Ge();t.useEffect((()=>{h.current=!1}),[]);const y=t.useMemo((()=>({[u](){a({type:4})},[s](){a({type:3})},Delete(){a({type:1})},Backspace(){a({type:2})}})),[a,s,u]),v=t.useMemo((()=>({[u](e){ft(e)&&a({type:5})},Backspace(e){ft(e)&&a({type:6})}})),[a,u]);return{getSelectedItemProps:t.useCallback((function(e){let{refKey:t="ref",ref:n,onClick:i,onKeyDown:o,selectedItem:r,index:s,...u}=void 0===e?{}:e;const{state:l}=f.current;if(Ae(s,r,l.selectedItems)<0)throw new Error("Pass either selectedItem or index in getSelectedItemProps!");return{[t]:me(n,(e=>{e&&m.current.push(e)})),tabIndex:s===l.activeIndex?0:-1,onClick:ge(i,(()=>{a({type:0,index:s})})),onKeyDown:ge(o,(e=>{const t=Se(e);t&&y[t]&&y[t](e)})),...u}}),[a,f,y]),getDropdownProps:t.useCallback((function(e,t){let{refKey:n="ref",ref:i,onKeyDown:o,onClick:r,preventKeyAction:s=!1,...u}=void 0===e?{}:e,{suppressRefError:l=!1}=void 0===t?{}:t;return I("getDropdownProps",l,n,p),{[n]:me(i,(e=>{e&&(p.current=e)})),...!s&&{onKeyDown:ge(o,(e=>{const t=Se(e);t&&v[t]&&v[t](e)})),onClick:ge(r,(()=>{a({type:7})}))},...u}}),[a,v,I]),addSelectedItem:t.useCallback((e=>{a({type:8,selectedItem:e})}),[a]),removeSelectedItem:t.useCallback((e=>{a({type:9,selectedItem:e})}),[a]),setSelectedItems:t.useCallback((e=>{a({type:10,selectedItems:e})}),[a]),setActiveIndex:t.useCallback((e=>{a({type:11,activeIndex:e})}),[a]),reset:t.useCallback((()=>{a({type:12})}),[a]),selectedItems:d,activeIndex:c}}xt.stateChangeTypes=vt,e.default=Te,e.resetIdCounter=function(){le=0},e.useCombobox=ht,e.useMultipleSelection=xt,e.useSelect=ut,Object.defineProperty(e,"__esModule",{value:!0})}));
2
2
  //# sourceMappingURL=downshift.umd.min.js.map