@headlessui/react
Advanced tools
Comparing version 0.3.1-7c43e53 to 0.3.1-7c43e54
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,n,t,r,o=require("react"),u=(e=o)&&"object"==typeof e&&"default"in e?e.default:e,i=require("react-dom");function a(){return(a=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)}function c(e,n){if(null==e)return{};var t,r,o={},u=Object.keys(e);for(r=0;r<u.length;r++)n.indexOf(t=u[r])>=0||(o[t]=e[t]);return o}function l(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function s(e,n){var t;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(t=function(e,n){if(e){if("string"==typeof e)return l(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?l(e,void 0):void 0}}(e))||n&&e&&"number"==typeof e.length){t&&(e=t);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(t=e[Symbol.iterator]()).next.bind(t)}function d(e,n){if(e in n){for(var t=n[e],r=arguments.length,o=new Array(r>2?r-2:0),u=2;u<r;u++)o[u-2]=arguments[u];return"function"==typeof t?t.apply(void 0,o):t}var i=new Error('Tried to handle "'+e+'" but there is no handler defined. Only defined handlers are: '+Object.keys(n).map((function(e){return'"'+e+'"'})).join(", ")+".");throw Error.captureStackTrace&&Error.captureStackTrace(i,d),i}function f(e,r,o,u,i){if(void 0===i&&(i=!0),i)return p(e,r,o);var l=null!=u?u:n.None;if(l&n.Static){var s=e.static,f=void 0!==s&&s,v=c(e,["static"]);if(f)return p(v,r,o)}if(l&n.RenderStrategy){var m,b=e.unmount,y=void 0===b||b,h=c(e,["unmount"]);return d(y?t.Unmount:t.Hidden,((m={})[t.Unmount]=function(){return null},m[t.Hidden]=function(){return p(a({},h,{hidden:!0,style:{display:"none"}}),r,o)},m))}return p(e,r,o)}function p(e,n,t){var r,u=m(e,["unmount","static"]),i=u.as,a=void 0===i?t:i,l=u.children,d=u.refName,f=void 0===d?"ref":d,v=c(u,["as","children","refName"]),b=void 0!==e.ref?((r={})[f]=e.ref,r):{},y="function"==typeof l?l(n):l;if(v.className&&"function"==typeof v.className&&(v.className=v.className(n)),a===o.Fragment&&Object.keys(v).length>0){if(Array.isArray(y)&&y.length>1){var h=new Error("You should only render 1 child");throw Error.captureStackTrace&&Error.captureStackTrace(h,p),h}if(!o.isValidElement(y)){var S=new Error('You should render an element as a child. Did you forget the as="..." prop?');throw Error.captureStackTrace&&Error.captureStackTrace(S,p),S}return o.cloneElement(y,Object.assign({},function(e,n,t){for(var r,o=Object.assign({},e),u=function(){var t,u=r.value;void 0!==e[u]&&void 0!==n[u]&&Object.assign(o,((t={})[u]=function(t){t.defaultPrevented||e[u](t),t.defaultPrevented||n[u](t)},t))},i=s(["onClick"]);!(r=i()).done;)u();return o}(function(e){var n=Object.assign({},e);for(var t in n)void 0===n[t]&&delete n[t];return n}(m(v,["ref"])),y.props),b))}return o.createElement(a,Object.assign({},m(v,["ref"]),a!==o.Fragment&&b),y)}function v(e){var n;return Object.assign(o.forwardRef(e),{displayName:null!=(n=e.displayName)?n:e.name})}function m(e,n){void 0===n&&(n=[]);for(var t,r=Object.assign({},e),o=s(n);!(t=o()).done;){var u=t.value;u in r&&delete r[u]}return r}function b(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];var r=o.useRef(n);return o.useEffect((function(){r.current=n}),[n]),o.useCallback((function(e){for(var n,t=s(r.current);!(n=t()).done;){var o=n.value;null!=o&&("function"==typeof o?o(e):o.current=e)}}),[r])}function y(e){for(var n,t,r=e.parentElement,o=null;r&&!(r instanceof HTMLFieldSetElement);)r instanceof HTMLLegendElement&&(o=r),r=r.parentElement;var u=null!=(n=""===(null==(t=r)?void 0:t.getAttribute("disabled")))&&n;return(!u||!function(e){if(!e)return!1;for(var n=e.previousElementSibling;null!==n;){if(n instanceof HTMLLegendElement)return!1;n=n.previousElementSibling}return!0}(o))&&u}!function(e){e[e.None=0]="None",e[e.RenderStrategy=1]="RenderStrategy",e[e.Static=2]="Static"}(n||(n={})),function(e){e[e.Unmount=0]="Unmount",e[e.Hidden=1]="Hidden"}(t||(t={})),function(e){e.Space=" ",e.Enter="Enter",e.Escape="Escape",e.Backspace="Backspace",e.ArrowUp="ArrowUp",e.ArrowDown="ArrowDown",e.Home="Home",e.End="End",e.PageUp="PageUp",e.PageDown="PageDown",e.Tab="Tab"}(r||(r={}));var h="undefined"!=typeof window?o.useLayoutEffect:o.useEffect,S={serverHandoffComplete:!1},g=0;function E(){return++g}function w(){var e=o.useState(S.serverHandoffComplete?E:null),n=e[0],t=e[1];return h((function(){null===n&&t(E())}),[n]),o.useEffect((function(){!1===S.serverHandoffComplete&&(S.serverHandoffComplete=!0)}),[]),null!=n?""+n:void 0}var x,C,I,O,k=["[contentEditable=true]","[tabindex]","a[href]","area[href]","button:not([disabled])","iframe","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].map((function(e){return e+":not([tabindex='-1'])"})).join(",");function P(e){return void 0===e&&(e=document.body),null==e?[]:Array.from(e.querySelectorAll(k))}function R(e,n){var t;return void 0===n&&(n=O.Strict),e!==document.body&&d(n,((t={})[O.Strict]=function(){return e.matches(k)},t[O.Loose]=function(){for(var n=e;null!==n;){if(n.matches(k))return!0;n=n.parentElement}return!1},t))}function T(e){null==e||e.focus({preventScroll:!0})}function D(e,n){var t=Array.isArray(e)?e:P(e),r=document.activeElement,o=function(){if(n&(x.First|x.Next))return I.Next;if(n&(x.Previous|x.Last))return I.Previous;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")}(),u=function(){if(n&x.First)return 0;if(n&x.Previous)return Math.max(0,t.indexOf(r))-1;if(n&x.Next)return Math.max(0,t.indexOf(r))+1;if(n&x.Last)return t.length-1;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")}(),i=n&x.NoScroll?{preventScroll:!0}:{},a=0,c=t.length,l=void 0;do{var s;if(a>=c||a+c<=0)return C.Error;var d=u+a;if(n&x.WrapAround)d=(d+c)%c;else{if(d<0)return C.Underflow;if(d>=c)return C.Overflow}null==(s=l=t[d])||s.focus(i),a+=o}while(l!==document.activeElement);return C.Success}function L(e,n){for(var t,r=s(e);!(t=r()).done;)if(t.value.contains(n))return!0;return!1}function F(e,n,t){void 0===n&&(n=!0),void 0===t&&(t={});var u=o.useRef("undefined"!=typeof window?document.activeElement:null),i=o.useRef(null),a=o.useRef(!1);h((function(){var r,o;if(n&&1===e.current.size){a.current=!0;var c,l=document.activeElement;if(null==(r=t.initialFocus)?void 0:r.current){if((null==(c=t.initialFocus)?void 0:c.current)===l)return}else if(L(e.current,l))return;if(u.current=l,null==(o=t.initialFocus)?void 0:o.current)T(t.initialFocus.current);else{for(var d,f=!1,p=s(e.current);!(d=p()).done;)if(D(d.value,x.First)===C.Success){f=!0;break}if(!f)throw new Error("There are no focusable elements inside the <FocusTrap />")}return i.current=document.activeElement,function(){a.current=!1,T(u.current),u.current=null,i.current=null}}}),[n,e,a,t.initialFocus]),h((function(){if(n)return window.addEventListener("keydown",t),function(){return window.removeEventListener("keydown",t)};function t(n){if(n.key===r.Tab&&document.activeElement&&1===e.current.size){n.preventDefault();for(var t,o=s(e.current);!(t=o()).done;)if(D(t.value,(n.shiftKey?x.Previous:x.Next)|x.WrapAround)===C.Success){i.current=document.activeElement;break}}}}),[n,e]),h((function(){if(n&&1===e.current.size)return window.addEventListener("focus",t,!0),function(){return window.removeEventListener("focus",t,!0)};function t(n){var t=i.current;if(t&&a.current){var r=n.target;r&&r instanceof HTMLElement?L(e.current,r)?(i.current=r,T(r)):(n.preventDefault(),n.stopPropagation(),T(t)):T(i.current)}}}),[n,a,e])}!function(e){e[e.First=1]="First",e[e.Previous=2]="Previous",e[e.Next=4]="Next",e[e.Last=8]="Last",e[e.WrapAround=16]="WrapAround",e[e.NoScroll=32]="NoScroll"}(x||(x={})),function(e){e[e.Error=0]="Error",e[e.Overflow=1]="Overflow",e[e.Success=2]="Success",e[e.Underflow=3]="Underflow"}(C||(C={})),function(e){e[e.Previous=-1]="Previous",e[e.Next=1]="Next"}(I||(I={})),function(e){e[e.Strict=0]="Strict",e[e.Loose=1]="Loose"}(O||(O={}));var M=new Set,A=new Map;function N(e){e.setAttribute("aria-hidden","true"),e.inert=!0}function j(e){var n=A.get(e);n&&(null===n["aria-hidden"]?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",n["aria-hidden"]),e.inert=n.inert)}var U,G=o.createContext((function(){}));function H(){return o.useContext(G)}function B(e){var n=e.children,t=e.onUpdate,r=H(),i=o.useCallback((function(){for(var e=arguments.length,n=new Array(e),o=0;o<e;o++)n[o]=arguments[o];null==t||t.apply(void 0,n),r.apply(void 0,n)}),[r,t]);return u.createElement(G.Provider,{value:i},n)}G.displayName="StackContext",function(e){e[e.AddElement=0]="AddElement",e[e.RemoveElement=1]="RemoveElement"}(U||(U={}));var V,Q,K,W=o.Fragment;function q(e){var n=o.useState((function(){if("undefined"==typeof window)return null;var e=document.getElementById("headlessui-portal-root");if(e)return e;var n=document.createElement("div");return n.setAttribute("id","headlessui-portal-root"),document.body.appendChild(n)}))[0],t=o.useState((function(){return"undefined"==typeof window?null:document.createElement("div")}))[0];return function(e){var n=H();h((function(){if(e)return n(U.AddElement,e),function(){return n(U.RemoveElement,e)}}),[e])}(t),h((function(){if(n&&t)return console.log({target:n,element:t}),n.appendChild(t),function(){n&&t&&(console.log({target:n,element:t}),n.removeChild(t),n.childNodes.length<=0&&document.body.removeChild(n))}}),[n,t]),u.createElement(B,null,n&&t?i.createPortal(f(e,{},W),t):null)}!function(e){e[e.Open=0]="Open",e[e.Closed=1]="Closed"}(Q||(Q={})),function(e){e[e.SetTitleId=0]="SetTitleId",e[e.SetDescriptionId=1]="SetDescriptionId"}(K||(K={}));var z=((V={})[K.SetTitleId]=function(e,n){return e.titleId===n.id?e:a({},e,{titleId:n.id})},V[K.SetDescriptionId]=function(e,n){return e.descriptionId===n.id?e:a({},e,{descriptionId:n.id})},V),Y=o.createContext(null);function _(e){var n=o.useContext(Y);if(null===n){var t=new Error("<"+e+" /> is missing a parent <"+ne.displayName+" /> component.");throw Error.captureStackTrace&&Error.captureStackTrace(t,_),t}return n}function J(e,n){return d(n.type,z,e,n)}Y.displayName="DialogContext";var $,X,Z,ee=n.RenderStrategy|n.Static,ne=Object.assign(v((function(e,n){var t=e.open,i=e.onClose,l=e.initialFocus,p=c(e,["open","onClose","initialFocus"]),v=o.useRef(new Set),m=o.useRef(null),y=b(m,n),S=e.hasOwnProperty("open"),g=e.hasOwnProperty("onClose");if(!S&&!g)throw new Error("You have to provide an `open` and an `onClose` prop to the `Dialog` component.");if(!S)throw new Error("You provided an `onClose` prop to the `Dialog`, but forgot an `open` prop.");if(!g)throw new Error("You provided an `open` prop to the `Dialog`, but forgot an `onClose` prop.");if("boolean"!=typeof t)throw new Error("You provided an `open` prop to the `Dialog`, but the value is not a boolean. Received: "+t);if("function"!=typeof i)throw new Error("You provided an `onClose` prop to the `Dialog`, but the value is not a function. Received: "+i);var E=t?Q.Open:Q.Closed,x=o.useReducer(J,{titleId:null,descriptionId:null}),C=x[0],I=x[1],O=o.useCallback((function(){return i(!1)}),[i]),k=o.useCallback((function(e){return I({type:K.SetTitleId,id:e})}),[I]),P=o.useCallback((function(e){return I({type:K.SetDescriptionId,id:e})}),[I]);o.useEffect((function(){function e(e){E===Q.Open&&1===v.current.size&&(L(v.current,e.target)||O())}return window.addEventListener("mousedown",e),function(){return window.removeEventListener("mousedown",e)}}),[E,v,O]),o.useEffect((function(){function e(e){e.key===r.Escape&&E===Q.Open&&(v.current.size>1||O())}return window.addEventListener("keydown",e),function(){return window.removeEventListener("keydown",e)}}),[O,E]),o.useEffect((function(){if(E===Q.Open){var e=document.documentElement.style.overflow,n=document.documentElement.style.paddingRight,t=window.innerWidth-document.documentElement.clientWidth;return document.documentElement.style.overflow="hidden",document.documentElement.style.paddingRight=t+"px",function(){document.documentElement.style.overflow=e,document.documentElement.style.paddingRight=n}}}),[E]),o.useEffect((function(){if(E===Q.Open&&m.current){var e=new IntersectionObserver((function(e){for(var n,t=s(e);!(n=t()).done;){var r=n.value;0===r.boundingClientRect.x&&0===r.boundingClientRect.y&&0===r.boundingClientRect.width&&0===r.boundingClientRect.height&&O()}}));return e.observe(m.current),function(){return e.disconnect()}}}),[E,m,O]);var R=!!e.static||E===Q.Open;F(v,R,{initialFocus:l}),function(e,n){void 0===n&&(n=!0),h((function(){if(n&&e.current){var t=e.current;M.add(t);for(var r,o=s(A.keys());!(r=o()).done;){var u=r.value;u.contains(t)&&(j(u),A.delete(u))}return document.querySelectorAll("body > *").forEach((function(e){if(e instanceof HTMLElement){for(var n,t=s(M);!(n=t()).done;)if(e.contains(n.value))return;1===M.size&&(A.set(e,{"aria-hidden":e.getAttribute("aria-hidden"),inert:e.inert}),N(e))}})),function(){if(M.delete(t),M.size>0)document.querySelectorAll("body > *").forEach((function(e){if(e instanceof HTMLElement&&!A.has(e)){for(var n,t=s(M);!(n=t()).done;)if(e.contains(n.value))return;A.set(e,{"aria-hidden":e.getAttribute("aria-hidden"),inert:e.inert}),N(e)}}));else for(var e,n=s(A.keys());!(e=n()).done;){var r=e.value;j(r),A.delete(r)}}}}),[n])}(m,R);var T="headlessui-dialog-"+w(),D=o.useMemo((function(){return[{dialogState:E,close:O,setTitleId:k,setDescriptionId:P},C]}),[E,C,O,k,P]),G=o.useMemo((function(){return{open:E===Q.Open}}),[E]);return u.createElement(B,{onUpdate:function(e,n){var t;return d(e,((t={})[U.AddElement]=function(){v.current.add(n)},t[U.RemoveElement]=function(){v.current.delete(n)},t))}},u.createElement(q,null,u.createElement(Y.Provider,{value:D},f(a({},p,{ref:y,id:T,role:"dialog","aria-modal":E===Q.Open||void 0,"aria-labelledby":C.titleId,"aria-describedby":C.descriptionId}),G,"div",ee,E===Q.Open))))})),{Overlay:v((function e(n,t){var r=_([ne.displayName,e.name].join("."))[0],u=r.dialogState,i=r.close,c=b(t),l="headlessui-dialog-overlay-"+w(),s=o.useCallback((function(e){if(y(e.currentTarget))return e.preventDefault();i()}),[i]),d=o.useMemo((function(){return{open:u===Q.Open}}),[u]);return f(a({},n,{ref:c,id:l,"aria-hidden":!0,onClick:s}),d,"div")})),Title:function e(n){var t=_([ne.displayName,e.name].join("."))[0],r=t.dialogState,u=t.setTitleId,i="headlessui-dialog-title-"+w();o.useEffect((function(){return u(i),function(){return u(null)}}),[i,u]);var c=o.useMemo((function(){return{open:r===Q.Open}}),[r]);return f(a({},n,{id:i}),c,"h2")},Description:function e(n){var t=_([ne.displayName,e.name].join("."))[0],r=t.dialogState,u=t.setDescriptionId,i="headlessui-dialog-description-"+w();o.useEffect((function(){return u(i),function(){return u(null)}}),[i,u]);var c=o.useMemo((function(){return{open:r===Q.Open}}),[r]);return f(a({},n,{id:i}),c,"p")}});!function(e){e[e.Open=0]="Open",e[e.Closed=1]="Closed"}(X||(X={})),function(e){e[e.ToggleDisclosure=0]="ToggleDisclosure",e[e.SetButtonId=1]="SetButtonId",e[e.SetPanelId=2]="SetPanelId",e[e.LinkPanel=3]="LinkPanel",e[e.UnlinkPanel=4]="UnlinkPanel"}(Z||(Z={}));var te=(($={})[Z.ToggleDisclosure]=function(e){var n;return a({},e,{disclosureState:d(e.disclosureState,(n={},n[X.Open]=X.Closed,n[X.Closed]=X.Open,n))})},$[Z.LinkPanel]=function(e){return!0===e.linkedPanel?e:a({},e,{linkedPanel:!0})},$[Z.UnlinkPanel]=function(e){return!1===e.linkedPanel?e:a({},e,{linkedPanel:!1})},$[Z.SetButtonId]=function(e,n){return e.buttonId===n.buttonId?e:a({},e,{buttonId:n.buttonId})},$[Z.SetPanelId]=function(e,n){return e.panelId===n.panelId?e:a({},e,{panelId:n.panelId})},$),re=o.createContext(null);function oe(e){var n=o.useContext(re);if(null===n){var t=new Error("<"+e+" /> is missing a parent <"+ae.name+" /> component.");throw Error.captureStackTrace&&Error.captureStackTrace(t,oe),t}return n}function ue(e,n){return d(n.type,te,e,n)}re.displayName="DisclosureContext";var ie=o.Fragment;function ae(e){var n="headlessui-disclosure-button-"+w(),t="headlessui-disclosure-panel-"+w(),r=o.useReducer(ue,{disclosureState:X.Closed,linkedPanel:!1,buttonId:n,panelId:t}),i=r[0].disclosureState,a=r[1];o.useEffect((function(){return a({type:Z.SetButtonId,buttonId:n})}),[n,a]),o.useEffect((function(){return a({type:Z.SetPanelId,panelId:t})}),[t,a]);var c=o.useMemo((function(){return{open:i===X.Open}}),[i]);return u.createElement(re.Provider,{value:r},f(e,c,ie))}var ce,le,se,de,fe=v((function e(n,t){var u=oe([ae.name,e.name].join(".")),i=u[0],c=u[1],l=b(t),s=o.useCallback((function(e){switch(e.key){case r.Space:case r.Enter:e.preventDefault(),c({type:Z.ToggleDisclosure})}}),[c]),d=o.useCallback((function(e){y(e.currentTarget)||n.disabled||c({type:Z.ToggleDisclosure})}),[c,n.disabled]),p=o.useMemo((function(){return{open:i.disclosureState===X.Open}}),[i]);return f(a({},n,{ref:l,id:i.buttonId,type:"button","aria-expanded":i.disclosureState===X.Open||void 0,"aria-controls":i.linkedPanel?i.panelId:void 0,onKeyDown:s,onClick:d}),p,"button")})),pe=n.RenderStrategy|n.Static,ve=v((function e(n,t){var r=oe([ae.name,e.name].join(".")),u=r[0],i=r[1],c=b(t,(function(){u.linkedPanel||i({type:Z.LinkPanel})}));o.useEffect((function(){return function(){return i({type:Z.UnlinkPanel})}}),[i]),o.useEffect((function(){var e;u.disclosureState!==X.Closed||null!=(e=n.unmount)&&!e||i({type:Z.UnlinkPanel})}),[u.disclosureState,n.unmount,i]);var l=o.useMemo((function(){return{open:u.disclosureState===X.Open}}),[u]);return f(a({},n,{ref:c,id:u.panelId}),l,"div",pe,u.disclosureState===X.Open)}));function me(){var e=[],n={requestAnimationFrame:function(e){function n(){return e.apply(this,arguments)}return n.toString=function(){return e.toString()},n}((function(){var e=requestAnimationFrame.apply(void 0,arguments);n.add((function(){return cancelAnimationFrame(e)}))})),nextFrame:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];n.requestAnimationFrame((function(){n.requestAnimationFrame.apply(n,t)}))},setTimeout:function(e){function n(){return e.apply(this,arguments)}return n.toString=function(){return e.toString()},n}((function(){var e=setTimeout.apply(void 0,arguments);n.add((function(){return clearTimeout(e)}))})),add:function(n){e.push(n)},dispose:function(){for(var n,t=s(e.splice(0));!(n=t()).done;)(0,n.value)()}};return n}function be(){var e=o.useState(me)[0];return o.useEffect((function(){return function(){return e.dispose()}}),[e]),e}function ye(e,n){var t=o.useState(e),r=t[0],u=t[1],i=o.useRef(e);return h((function(){i.current=e}),[e]),h((function(){return u(i.current)}),[i,u].concat(n)),r}function he(e,n){var t=n.resolveItems();if(t.length<=0)return null;var r=n.resolveActiveIndex(),o=null!=r?r:-1,u=function(){switch(e.focus){case ce.First:return t.findIndex((function(e){return!n.resolveDisabled(e)}));case ce.Previous:var r=t.slice().reverse().findIndex((function(e,t,r){return!(-1!==o&&r.length-t-1>=o||n.resolveDisabled(e))}));return-1===r?r:t.length-1-r;case ce.Next:return t.findIndex((function(e,t){return!(t<=o||n.resolveDisabled(e))}));case ce.Last:var u=t.slice().reverse().findIndex((function(e){return!n.resolveDisabled(e)}));return-1===u?u:t.length-1-u;case ce.Specific:return t.findIndex((function(t){return n.resolveId(t)===e.id}));case ce.Nothing:return null;default:!function(e){throw new Error("Unexpected object: "+e)}(e)}}();return-1===u?r:u}ae.Button=fe,ae.Panel=ve,function(e){e[e.First=0]="First",e[e.Previous=1]="Previous",e[e.Next=2]="Next",e[e.Last=3]="Last",e[e.Specific=4]="Specific",e[e.Nothing=5]="Nothing"}(ce||(ce={})),function(e){e[e.Open=0]="Open",e[e.Closed=1]="Closed"}(se||(se={})),function(e){e[e.OpenListbox=0]="OpenListbox",e[e.CloseListbox=1]="CloseListbox",e[e.SetDisabled=2]="SetDisabled",e[e.GoToOption=3]="GoToOption",e[e.Search=4]="Search",e[e.ClearSearch=5]="ClearSearch",e[e.RegisterOption=6]="RegisterOption",e[e.UnregisterOption=7]="UnregisterOption"}(de||(de={}));var Se=((le={})[de.CloseListbox]=function(e){return e.disabled||e.listboxState===se.Closed?e:a({},e,{activeOptionIndex:null,listboxState:se.Closed})},le[de.OpenListbox]=function(e){return e.disabled||e.listboxState===se.Open?e:a({},e,{listboxState:se.Open})},le[de.SetDisabled]=function(e,n){return e.disabled===n.disabled?e:a({},e,{disabled:n.disabled})},le[de.GoToOption]=function(e,n){if(e.disabled)return e;if(e.listboxState===se.Closed)return e;var t=he(n,{resolveItems:function(){return e.options},resolveActiveIndex:function(){return e.activeOptionIndex},resolveId:function(e){return e.id},resolveDisabled:function(e){return e.dataRef.current.disabled}});return""===e.searchQuery&&e.activeOptionIndex===t?e:a({},e,{searchQuery:"",activeOptionIndex:t})},le[de.Search]=function(e,n){if(e.disabled)return e;if(e.listboxState===se.Closed)return e;var t=e.searchQuery+n.value,r=e.options.findIndex((function(e){var n;return!e.dataRef.current.disabled&&(null==(n=e.dataRef.current.textValue)?void 0:n.startsWith(t))}));return a({},e,-1===r||r===e.activeOptionIndex?{searchQuery:t}:{searchQuery:t,activeOptionIndex:r})},le[de.ClearSearch]=function(e){return e.disabled||e.listboxState===se.Closed||""===e.searchQuery?e:a({},e,{searchQuery:""})},le[de.RegisterOption]=function(e,n){return a({},e,{options:[].concat(e.options,[{id:n.id,dataRef:n.dataRef}])})},le[de.UnregisterOption]=function(e,n){var t=e.options.slice(),r=null!==e.activeOptionIndex?t[e.activeOptionIndex]:null,o=t.findIndex((function(e){return e.id===n.id}));return-1!==o&&t.splice(o,1),a({},e,{options:t,activeOptionIndex:o===e.activeOptionIndex||null===r?null:t.indexOf(r)})},le),ge=o.createContext(null);function Ee(e){var n=o.useContext(ge);if(null===n){var t=new Error("<"+e+" /> is missing a parent <"+Ce.name+" /> component.");throw Error.captureStackTrace&&Error.captureStackTrace(t,Ee),t}return n}function we(e,n){return d(n.type,Se,e,n)}ge.displayName="ListboxContext";var xe=o.Fragment;function Ce(e){var n=e.value,t=e.onChange,r=e.disabled,i=void 0!==r&&r,a=c(e,["value","onChange","disabled"]),l=o.useReducer(we,{listboxState:se.Closed,propsRef:{current:{value:n,onChange:t}},labelRef:o.createRef(),buttonRef:o.createRef(),optionsRef:o.createRef(),disabled:i,options:[],searchQuery:"",activeOptionIndex:null}),s=l[0],d=s.listboxState,p=s.propsRef,v=s.optionsRef,m=s.buttonRef,b=l[1];h((function(){p.current.value=n}),[n,p]),h((function(){p.current.onChange=t}),[t,p]),h((function(){return b({type:de.SetDisabled,disabled:i})}),[i]),o.useEffect((function(){function e(e){var n,t,r,o=e.target;d===se.Open&&((null==(n=m.current)?void 0:n.contains(o))||(null==(t=v.current)?void 0:t.contains(o))||(b({type:de.CloseListbox}),R(o,O.Loose)||(e.preventDefault(),null==(r=m.current)||r.focus())))}return window.addEventListener("mousedown",e),function(){return window.removeEventListener("mousedown",e)}}),[d,m,v,b]);var y=o.useMemo((function(){return{open:d===se.Open,disabled:i}}),[d,i]);return u.createElement(ge.Provider,{value:l},f(a,y,xe))}var Ie,Oe,ke,Pe=v((function e(n,t){var u,i=Ee([Ce.name,e.name].join(".")),c=i[0],l=i[1],s=b(c.buttonRef,t),d="headlessui-listbox-button-"+w(),p=be(),v=o.useCallback((function(e){switch(e.key){case r.Space:case r.Enter:case r.ArrowDown:e.preventDefault(),l({type:de.OpenListbox}),p.nextFrame((function(){c.propsRef.current.value||l({type:de.GoToOption,focus:ce.First})}));break;case r.ArrowUp:e.preventDefault(),l({type:de.OpenListbox}),p.nextFrame((function(){c.propsRef.current.value||l({type:de.GoToOption,focus:ce.Last})}))}}),[l,c,p]),m=o.useCallback((function(e){if(y(e.currentTarget))return e.preventDefault();c.listboxState===se.Open?(l({type:de.CloseListbox}),p.nextFrame((function(){var e;return null==(e=c.buttonRef.current)?void 0:e.focus({preventScroll:!0})}))):(e.preventDefault(),l({type:de.OpenListbox}))}),[l,p,c]),h=ye((function(){if(c.labelRef.current)return[c.labelRef.current.id,d].join(" ")}),[c.labelRef.current,d]),S=o.useMemo((function(){return{open:c.listboxState===se.Open,disabled:c.disabled}}),[c]);return f(a({},n,{ref:s,id:d,type:"button","aria-haspopup":!0,"aria-controls":null==(u=c.optionsRef.current)?void 0:u.id,"aria-expanded":c.listboxState===se.Open||void 0,"aria-labelledby":h,disabled:c.disabled,onKeyDown:v,onClick:m}),S,"button")})),Re=n.RenderStrategy|n.Static,Te=v((function e(n,t){var u,i=Ee([Ce.name,e.name].join(".")),c=i[0],l=i[1],s=b(c.optionsRef,t),d="headlessui-listbox-options-"+w(),p=be(),v=be();h((function(){var e=c.optionsRef.current;e&&c.listboxState===se.Open&&e!==document.activeElement&&e.focus({preventScroll:!0})}),[c.listboxState,c.optionsRef]);var m=o.useCallback((function(e){switch(v.dispose(),e.key){case r.Space:if(""!==c.searchQuery)return e.preventDefault(),e.stopPropagation(),l({type:de.Search,value:e.key});case r.Enter:e.preventDefault(),e.stopPropagation(),l({type:de.CloseListbox}),null!==c.activeOptionIndex&&c.propsRef.current.onChange(c.options[c.activeOptionIndex].dataRef.current.value),me().nextFrame((function(){var e;return null==(e=c.buttonRef.current)?void 0:e.focus({preventScroll:!0})}));break;case r.ArrowDown:return e.preventDefault(),e.stopPropagation(),l({type:de.GoToOption,focus:ce.Next});case r.ArrowUp:return e.preventDefault(),e.stopPropagation(),l({type:de.GoToOption,focus:ce.Previous});case r.Home:case r.PageUp:return e.preventDefault(),e.stopPropagation(),l({type:de.GoToOption,focus:ce.First});case r.End:case r.PageDown:return e.preventDefault(),e.stopPropagation(),l({type:de.GoToOption,focus:ce.Last});case r.Escape:return e.preventDefault(),e.stopPropagation(),l({type:de.CloseListbox}),p.nextFrame((function(){var e;return null==(e=c.buttonRef.current)?void 0:e.focus({preventScroll:!0})}));case r.Tab:e.preventDefault(),e.stopPropagation();break;default:1===e.key.length&&(l({type:de.Search,value:e.key}),v.setTimeout((function(){return l({type:de.ClearSearch})}),350))}}),[p,l,v,c]),y=ye((function(){var e,n,t;return null!=(e=null==(n=c.labelRef.current)?void 0:n.id)?e:null==(t=c.buttonRef.current)?void 0:t.id}),[c.labelRef.current,c.buttonRef.current]),S=o.useMemo((function(){return{open:c.listboxState===se.Open}}),[c]);return f(a({},n,{"aria-activedescendant":null===c.activeOptionIndex||null==(u=c.options[c.activeOptionIndex])?void 0:u.id,"aria-labelledby":y,id:d,onKeyDown:m,role:"listbox",tabIndex:0,ref:s}),S,"ul",Re,c.listboxState===se.Open)}));Ce.Button=Pe,Ce.Label=function e(n){var t=Ee([Ce.name,e.name].join("."))[0],r="headlessui-listbox-label-"+w(),u=o.useCallback((function(){var e;return null==(e=t.buttonRef.current)?void 0:e.focus({preventScroll:!0})}),[t.buttonRef]),i=o.useMemo((function(){return{open:t.listboxState===se.Open,disabled:t.disabled}}),[t]);return f(a({},n,{ref:t.labelRef,id:r,onClick:u}),i,"label")},Ce.Options=Te,Ce.Option=function e(n){var t=n.disabled,r=void 0!==t&&t,u=n.value,i=c(n,["disabled","value"]),l=Ee([Ce.name,e.name].join(".")),s=l[0],d=l[1],p="headlessui-listbox-option-"+w(),v=null!==s.activeOptionIndex&&s.options[s.activeOptionIndex].id===p,m=s.propsRef.current.value===u,b=o.useRef({disabled:r,value:u});h((function(){b.current.disabled=r}),[b,r]),h((function(){b.current.value=u}),[b,u]),h((function(){var e,n;b.current.textValue=null==(e=document.getElementById(p))||null==(n=e.textContent)?void 0:n.toLowerCase()}),[b,p]);var y=o.useCallback((function(){return s.propsRef.current.onChange(u)}),[s.propsRef,u]);h((function(){return d({type:de.RegisterOption,id:p,dataRef:b}),function(){return d({type:de.UnregisterOption,id:p})}}),[b,p]),h((function(){var e;s.listboxState===se.Open&&m&&(d({type:de.GoToOption,focus:ce.Specific,id:p}),null==(e=document.getElementById(p))||null==e.focus||e.focus())}),[s.listboxState]),h((function(){if(s.listboxState===se.Open&&v){var e=me();return e.nextFrame((function(){var e;return null==(e=document.getElementById(p))||null==e.scrollIntoView?void 0:e.scrollIntoView({block:"nearest"})})),e.dispose}}),[p,v,s.listboxState]);var S=o.useCallback((function(e){if(r)return e.preventDefault();y(),d({type:de.CloseListbox}),me().nextFrame((function(){var e;return null==(e=s.buttonRef.current)?void 0:e.focus({preventScroll:!0})}))}),[d,s.buttonRef,r,y]),g=o.useCallback((function(){if(r)return d({type:de.GoToOption,focus:ce.Nothing});d({type:de.GoToOption,focus:ce.Specific,id:p})}),[r,p,d]),E=o.useCallback((function(){r||v||d({type:de.GoToOption,focus:ce.Specific,id:p})}),[r,v,p,d]),x=o.useCallback((function(){r||v&&d({type:de.GoToOption,focus:ce.Nothing})}),[r,v,d]),C=o.useMemo((function(){return{active:v,selected:m,disabled:r}}),[v,m,r]);return f(a({},i,{id:p,role:"option",tabIndex:-1,"aria-disabled":!0===r||void 0,"aria-selected":!0===m||void 0,onClick:S,onFocus:g,onPointerMove:E,onMouseMove:E,onPointerLeave:x,onMouseLeave:x}),C,"li")},function(e){e[e.Open=0]="Open",e[e.Closed=1]="Closed"}(Oe||(Oe={})),function(e){e[e.OpenMenu=0]="OpenMenu",e[e.CloseMenu=1]="CloseMenu",e[e.GoToItem=2]="GoToItem",e[e.Search=3]="Search",e[e.ClearSearch=4]="ClearSearch",e[e.RegisterItem=5]="RegisterItem",e[e.UnregisterItem=6]="UnregisterItem"}(ke||(ke={}));var De=((Ie={})[ke.CloseMenu]=function(e){return e.menuState===Oe.Closed?e:a({},e,{activeItemIndex:null,menuState:Oe.Closed})},Ie[ke.OpenMenu]=function(e){return e.menuState===Oe.Open?e:a({},e,{menuState:Oe.Open})},Ie[ke.GoToItem]=function(e,n){var t=he(n,{resolveItems:function(){return e.items},resolveActiveIndex:function(){return e.activeItemIndex},resolveId:function(e){return e.id},resolveDisabled:function(e){return e.dataRef.current.disabled}});return""===e.searchQuery&&e.activeItemIndex===t?e:a({},e,{searchQuery:"",activeItemIndex:t})},Ie[ke.Search]=function(e,n){var t=e.searchQuery+n.value,r=e.items.findIndex((function(e){var n;return(null==(n=e.dataRef.current.textValue)?void 0:n.startsWith(t))&&!e.dataRef.current.disabled}));return a({},e,-1===r||r===e.activeItemIndex?{searchQuery:t}:{searchQuery:t,activeItemIndex:r})},Ie[ke.ClearSearch]=function(e){return""===e.searchQuery?e:a({},e,{searchQuery:""})},Ie[ke.RegisterItem]=function(e,n){return a({},e,{items:[].concat(e.items,[{id:n.id,dataRef:n.dataRef}])})},Ie[ke.UnregisterItem]=function(e,n){var t=e.items.slice(),r=null!==e.activeItemIndex?t[e.activeItemIndex]:null,o=t.findIndex((function(e){return e.id===n.id}));return-1!==o&&t.splice(o,1),a({},e,{items:t,activeItemIndex:o===e.activeItemIndex||null===r?null:t.indexOf(r)})},Ie),Le=o.createContext(null);function Fe(e){var n=o.useContext(Le);if(null===n){var t=new Error("<"+e+" /> is missing a parent <"+Ne.name+" /> component.");throw Error.captureStackTrace&&Error.captureStackTrace(t,Fe),t}return n}function Me(e,n){return d(n.type,De,e,n)}Le.displayName="MenuContext";var Ae=o.Fragment;function Ne(e){var n=o.useReducer(Me,{menuState:Oe.Closed,buttonRef:o.createRef(),itemsRef:o.createRef(),items:[],searchQuery:"",activeItemIndex:null}),t=n[0],r=t.menuState,i=t.itemsRef,a=t.buttonRef,c=n[1];o.useEffect((function(){function e(e){var n,t,o,u=e.target;r===Oe.Open&&((null==(n=a.current)?void 0:n.contains(u))||(null==(t=i.current)?void 0:t.contains(u))||(c({type:ke.CloseMenu}),R(u,O.Loose)||(e.preventDefault(),null==(o=a.current)||o.focus())))}return window.addEventListener("mousedown",e),function(){return window.removeEventListener("mousedown",e)}}),[r,a,i,c]);var l=o.useMemo((function(){return{open:r===Oe.Open}}),[r]);return u.createElement(Le.Provider,{value:n},f(e,l,Ae))}var je,Ue,Ge,He=v((function e(n,t){var u,i=Fe([Ne.name,e.name].join(".")),c=i[0],l=i[1],s=b(c.buttonRef,t),d="headlessui-menu-button-"+w(),p=be(),v=o.useCallback((function(e){switch(e.key){case r.Space:case r.Enter:case r.ArrowDown:e.preventDefault(),e.stopPropagation(),l({type:ke.OpenMenu}),p.nextFrame((function(){return l({type:ke.GoToItem,focus:ce.First})}));break;case r.ArrowUp:e.preventDefault(),e.stopPropagation(),l({type:ke.OpenMenu}),p.nextFrame((function(){return l({type:ke.GoToItem,focus:ce.Last})}))}}),[l,p]),m=o.useCallback((function(e){if(y(e.currentTarget))return e.preventDefault();n.disabled||(c.menuState===Oe.Open?(l({type:ke.CloseMenu}),p.nextFrame((function(){var e;return null==(e=c.buttonRef.current)?void 0:e.focus({preventScroll:!0})}))):(e.preventDefault(),e.stopPropagation(),l({type:ke.OpenMenu})))}),[l,p,c,n.disabled]),h=o.useMemo((function(){return{open:c.menuState===Oe.Open}}),[c]);return f(a({},n,{ref:s,id:d,type:"button","aria-haspopup":!0,"aria-controls":null==(u=c.itemsRef.current)?void 0:u.id,"aria-expanded":c.menuState===Oe.Open||void 0,onKeyDown:v,onClick:m}),h,"button")})),Be=n.RenderStrategy|n.Static,Ve=v((function e(n,t){var u,i,c=Fe([Ne.name,e.name].join(".")),l=c[0],s=c[1],d=b(l.itemsRef,t),p="headlessui-menu-items-"+w(),v=be();o.useEffect((function(){var e=l.itemsRef.current;e&&l.menuState===Oe.Open&&e!==document.activeElement&&e.focus({preventScroll:!0})}),[l.menuState,l.itemsRef]),h((function(){var e=l.itemsRef.current;if(e&&l.menuState===Oe.Open)for(var n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:function(e){return"menuitem"===e.getAttribute("role")?NodeFilter.FILTER_REJECT:e.hasAttribute("role")?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT}});n.nextNode();)n.currentNode.setAttribute("role","none")}),[l.menuState,l.itemsRef]);var m=o.useCallback((function(e){switch(v.dispose(),e.key){case r.Space:if(""!==l.searchQuery)return e.preventDefault(),e.stopPropagation(),s({type:ke.Search,value:e.key});case r.Enter:var n;e.preventDefault(),e.stopPropagation(),s({type:ke.CloseMenu}),null!==l.activeItemIndex&&(null==(n=document.getElementById(l.items[l.activeItemIndex].id))||n.click()),me().nextFrame((function(){var e;return null==(e=l.buttonRef.current)?void 0:e.focus({preventScroll:!0})}));break;case r.ArrowDown:return e.preventDefault(),e.stopPropagation(),s({type:ke.GoToItem,focus:ce.Next});case r.ArrowUp:return e.preventDefault(),e.stopPropagation(),s({type:ke.GoToItem,focus:ce.Previous});case r.Home:case r.PageUp:return e.preventDefault(),e.stopPropagation(),s({type:ke.GoToItem,focus:ce.First});case r.End:case r.PageDown:return e.preventDefault(),e.stopPropagation(),s({type:ke.GoToItem,focus:ce.Last});case r.Escape:e.preventDefault(),e.stopPropagation(),s({type:ke.CloseMenu}),me().nextFrame((function(){var e;return null==(e=l.buttonRef.current)?void 0:e.focus({preventScroll:!0})}));break;case r.Tab:e.preventDefault(),e.stopPropagation();break;default:1===e.key.length&&(s({type:ke.Search,value:e.key}),v.setTimeout((function(){return s({type:ke.ClearSearch})}),350))}}),[s,v,l]),y=o.useMemo((function(){return{open:l.menuState===Oe.Open}}),[l]);return f(a({},n,{"aria-activedescendant":null===l.activeItemIndex||null==(u=l.items[l.activeItemIndex])?void 0:u.id,"aria-labelledby":null==(i=l.buttonRef.current)?void 0:i.id,id:p,onKeyDown:m,role:"menu",tabIndex:0,ref:d}),y,"div",Be,l.menuState===Oe.Open)})),Qe=o.Fragment;Ne.Button=He,Ne.Items=Ve,Ne.Item=function e(n){var t=n.disabled,r=void 0!==t&&t,u=n.onClick,i=c(n,["disabled","onClick"]),l=Fe([Ne.name,e.name].join(".")),s=l[0],d=l[1],p="headlessui-menu-item-"+w(),v=null!==s.activeItemIndex&&s.items[s.activeItemIndex].id===p;h((function(){if(s.menuState===Oe.Open&&v){var e=me();return e.nextFrame((function(){var e;return null==(e=document.getElementById(p))||null==e.scrollIntoView?void 0:e.scrollIntoView({block:"nearest"})})),e.dispose}}),[p,v,s.menuState]);var m=o.useRef({disabled:r});h((function(){m.current.disabled=r}),[m,r]),h((function(){var e,n;m.current.textValue=null==(e=document.getElementById(p))||null==(n=e.textContent)?void 0:n.toLowerCase()}),[m,p]),h((function(){return d({type:ke.RegisterItem,id:p,dataRef:m}),function(){return d({type:ke.UnregisterItem,id:p})}}),[m,p]);var b=o.useCallback((function(e){return r?e.preventDefault():(d({type:ke.CloseMenu}),me().nextFrame((function(){var e;return null==(e=s.buttonRef.current)?void 0:e.focus({preventScroll:!0})})),u?u(e):void 0)}),[d,s.buttonRef,r,u]),y=o.useCallback((function(){if(r)return d({type:ke.GoToItem,focus:ce.Nothing});d({type:ke.GoToItem,focus:ce.Specific,id:p})}),[r,p,d]),S=o.useCallback((function(){r||v||d({type:ke.GoToItem,focus:ce.Specific,id:p})}),[r,v,p,d]),g=o.useCallback((function(){r||v&&d({type:ke.GoToItem,focus:ce.Nothing})}),[r,v,d]),E=o.useMemo((function(){return{active:v,disabled:r}}),[v,r]);return f(a({},i,{id:p,role:"menuitem",tabIndex:-1,"aria-disabled":!0===r||void 0,onClick:b,onFocus:y,onPointerMove:S,onMouseMove:S,onPointerLeave:g,onMouseLeave:g}),E,Qe)},function(e){e[e.Open=0]="Open",e[e.Closed=1]="Closed"}(Ue||(Ue={})),function(e){e[e.TogglePopover=0]="TogglePopover",e[e.ClosePopover=1]="ClosePopover",e[e.SetButton=2]="SetButton",e[e.SetButtonId=3]="SetButtonId",e[e.SetPanel=4]="SetPanel",e[e.SetPanelId=5]="SetPanelId"}(Ge||(Ge={}));var Ke=((je={})[Ge.TogglePopover]=function(e){var n;return a({},e,{popoverState:d(e.popoverState,(n={},n[Ue.Open]=Ue.Closed,n[Ue.Closed]=Ue.Open,n))})},je[Ge.ClosePopover]=function(e){return e.popoverState===Ue.Closed?e:a({},e,{popoverState:Ue.Closed})},je[Ge.SetButton]=function(e,n){return e.button===n.button?e:a({},e,{button:n.button})},je[Ge.SetButtonId]=function(e,n){return e.buttonId===n.buttonId?e:a({},e,{buttonId:n.buttonId})},je[Ge.SetPanel]=function(e,n){return e.panel===n.panel?e:a({},e,{panel:n.panel})},je[Ge.SetPanelId]=function(e,n){return e.panelId===n.panelId?e:a({},e,{panelId:n.panelId})},je),We=o.createContext(null);function qe(e){var n=o.useContext(We);if(null===n){var t=new Error("<"+e+" /> is missing a parent <"+$e.name+" /> component.");throw Error.captureStackTrace&&Error.captureStackTrace(t,qe),t}return n}We.displayName="PopoverContext";var ze=o.createContext(null);function Ye(){return o.useContext(ze)}ze.displayName="PopoverGroupContext";var _e=o.createContext(null);function Je(e,n){return d(n.type,Ke,e,n)}function $e(e){var n="headlessui-popover-button-"+w(),t="headlessui-popover-panel-"+w(),r=o.useReducer(Je,{popoverState:Ue.Closed,linkedPanel:!1,button:null,buttonId:n,panel:null,panelId:t}),i=r[0],a=i.popoverState,c=i.button,l=i.panel,s=r[1];o.useEffect((function(){return s({type:Ge.SetButtonId,buttonId:n})}),[n,s]),o.useEffect((function(){return s({type:Ge.SetPanelId,panelId:t})}),[t,s]);var d=o.useMemo((function(){return{buttonId:n,panelId:t,close:function(){return s({type:Ge.ClosePopover})}}}),[n,t,s]),p=Ye(),v=null==p?void 0:p.registerPopover,m=o.useCallback((function(){var e;return null!=(e=null==p?void 0:p.isFocusWithinPopoverGroup())?e:(null==c?void 0:c.contains(document.activeElement))||(null==l?void 0:l.contains(document.activeElement))}),[p,c,l]);o.useEffect((function(){return null==v?void 0:v(d)}),[v,d]),o.useEffect((function(){if(a===Ue.Open)return window.addEventListener("focus",e,!0),function(){return window.removeEventListener("focus",e,!0)};function e(){m()||c&&l&&s({type:Ge.ClosePopover})}}),[a,m,p,c,l,s]),o.useEffect((function(){function e(e){var n=e.target;a===Ue.Open&&((null==c?void 0:c.contains(n))||(null==l?void 0:l.contains(n))||(s({type:Ge.ClosePopover}),R(n,O.Loose)||(e.preventDefault(),null==c||c.focus())))}return window.addEventListener("mousedown",e),function(){return window.removeEventListener("mousedown",e)}}),[a,c,l,s]);var b=o.useMemo((function(){return{open:a===Ue.Open}}),[a]);return u.createElement(We.Provider,{value:r},f(e,b,"div"))}_e.displayName="PopoverPanelContext";var Xe=v((function e(n,t){var u=qe([$e.name,e.name].join(".")),i=u[0],c=u[1],l=o.useRef(null),s=Ye(),d=null==s?void 0:s.closeOthers,p=o.useContext(_e),v=null!==p&&p===i.panelId,m=b(l,t,v?null:function(e){return c({type:Ge.SetButton,button:e})}),h=o.useRef(null),S=o.useRef("undefined"==typeof window?null:document.activeElement);o.useEffect((function(){function e(){S.current=h.current,h.current=document.activeElement}return window.addEventListener("focus",e,!0),function(){return window.removeEventListener("focus",e,!0)}}),[S,h]);var g=o.useCallback((function(e){var n;if(v){if(i.popoverState===Ue.Closed)return;switch(e.key){case r.Space:case r.Enter:e.preventDefault(),e.stopPropagation(),c({type:Ge.ClosePopover}),null==(n=i.button)||n.focus()}}else switch(e.key){case r.Space:case r.Enter:e.preventDefault(),e.stopPropagation(),i.popoverState===Ue.Closed&&(null==d||d(i.buttonId)),c({type:Ge.TogglePopover});break;case r.Escape:if(i.popoverState!==Ue.Open)return null==d?void 0:d(i.buttonId);if(!l.current)return;if(!l.current.contains(document.activeElement))return;c({type:Ge.ClosePopover});break;case r.Tab:if(i.popoverState!==Ue.Open)return;if(!i.panel)return;if(!i.button)return;if(e.shiftKey){var t;if(!S.current)return;if(null==(t=i.button)?void 0:t.contains(S.current))return;if(i.panel.contains(S.current))return;var o=P(),u=o.indexOf(S.current);if(o.indexOf(i.button)>u)return;e.preventDefault(),e.stopPropagation(),D(i.panel,x.Last)}else e.preventDefault(),e.stopPropagation(),D(i.panel,x.First)}}),[c,i.popoverState,i.buttonId,i.button,i.panel,l,d,v]),E=o.useCallback((function(e){var n;if(!v&&i.popoverState===Ue.Open&&i.panel&&i.button)switch(e.key){case r.Tab:if(!S.current)return;if(null==(n=i.button)?void 0:n.contains(S.current))return;if(i.panel.contains(S.current))return;var t=P(),o=t.indexOf(S.current);if(t.indexOf(i.button)>o)return;e.preventDefault(),e.stopPropagation(),D(i.panel,x.Last)}}),[i.popoverState,i.panel,i.button,v]),w=o.useCallback((function(e){var t;y(e.currentTarget)||n.disabled||(v?(c({type:Ge.ClosePopover}),null==(t=i.button)||t.focus()):(i.popoverState===Ue.Closed&&(null==d||d(i.buttonId)),c({type:Ge.TogglePopover})))}),[c,i.button,i.popoverState,i.buttonId,n.disabled,d,v]),C=o.useMemo((function(){return{open:i.popoverState===Ue.Open}}),[i]);return f(a({},n,v?{type:"button",onKeyDown:g,onClick:w}:{ref:m,id:i.buttonId,type:"button","aria-expanded":i.popoverState===Ue.Open||void 0,"aria-controls":i.panel?i.panelId:void 0,onKeyDown:g,onKeyUp:E,onClick:w}),C,"button")})),Ze=v((function e(n,t){var r=qe([$e.name,e.name].join(".")),u=r[0].popoverState,i=r[1],c=b(t),l="headlessui-popover-overlay-"+w(),s=o.useCallback((function(e){if(y(e.currentTarget))return e.preventDefault();i({type:Ge.ClosePopover})}),[i]),d=o.useMemo((function(){return{open:u===Ue.Open}}),[u]);return f(a({},n,{ref:c,id:l,"aria-hidden":!0,onClick:s}),d,"div")})),en=n.RenderStrategy|n.Static,nn=v((function e(n,t){var i=n.focus,l=void 0!==i&&i,s=c(n,["focus"]),d=qe([$e.name,e.name].join(".")),p=d[0],v=d[1],m=o.useRef(null),y=b(m,t,(function(e){v({type:Ge.SetPanel,panel:e})})),h=o.useCallback((function(e){var n;switch(e.key){case r.Escape:if(p.popoverState!==Ue.Open)return;if(!m.current)return;if(!m.current.contains(document.activeElement))return;e.preventDefault(),v({type:Ge.ClosePopover}),null==(n=p.button)||n.focus()}}),[p,m,v]);o.useEffect((function(){return function(){return v({type:Ge.SetPanel,panel:null})}}),[v]),o.useEffect((function(){var e;p.popoverState!==Ue.Closed||null!=(e=n.unmount)&&!e||v({type:Ge.SetPanel,panel:null})}),[p.popoverState,n.unmount,v]),o.useEffect((function(){if(l&&p.popoverState===Ue.Open&&m.current){var e=document.activeElement;m.current.contains(e)||D(m.current,x.First)}}),[l,m,p.popoverState]),o.useEffect((function(){if(p.popoverState===Ue.Open&&m.current)return window.addEventListener("keydown",e),function(){return window.removeEventListener("keydown",e)};function e(e){if(e.key===r.Tab&&document.activeElement&&m.current&&m.current.contains(document.activeElement)){e.preventDefault();var n,t=D(m.current,e.shiftKey?x.Previous:x.Next);if(t===C.Underflow)return null==(n=p.button)?void 0:n.focus();if(t===C.Overflow){if(!p.button)return;var o=P(),u=o.indexOf(p.button);D(o.splice(u+1).filter((function(e){var n;return!(null==(n=m.current)?void 0:n.contains(e))})),x.First)===C.Error&&D(document.body,x.First)}}}}),[l,m,p.popoverState,p.button]),o.useEffect((function(){if(l&&p.popoverState===Ue.Open&&m.current)return window.addEventListener("focus",e,!0),function(){return window.removeEventListener("focus",e,!0)};function e(){var e;(null==(e=m.current)?void 0:e.contains(document.activeElement))||v({type:Ge.ClosePopover})}}),[l,p.popoverState,v]);var S=o.useMemo((function(){return{open:p.popoverState===Ue.Open}}),[p]);return u.createElement(_e.Provider,{value:p.panelId},f(a({},s,{ref:y,id:p.panelId,onKeyDown:h}),S,"div",en,p.popoverState===Ue.Open))}));$e.Button=Xe,$e.Overlay=Ze,$e.Panel=nn,$e.Group=function(e){var n=o.useRef(null),t=o.useState([]),r=t[0],i=t[1],c=o.useCallback((function(e){i((function(n){var t=n.indexOf(e);if(-1!==t){var r=n.slice();return r.splice(t,1),r}return n}))}),[i]),l=o.useCallback((function(e){return i((function(n){return[].concat(n,[e])})),function(){return c(e)}}),[i,c]),d=o.useCallback((function(){var e,t=document.activeElement;return!!(null==(e=n.current)?void 0:e.contains(t))||r.some((function(e){var n,r;return(null==(n=document.getElementById(e.buttonId))?void 0:n.contains(t))||(null==(r=document.getElementById(e.panelId))?void 0:r.contains(t))}))}),[n,r]),p=o.useCallback((function(e){for(var n,t=s(r);!(n=t()).done;){var o=n.value;o.buttonId!==e&&o.close()}}),[r]),v=o.useMemo((function(){return{registerPopover:l,unregisterPopover:c,isFocusWithinPopoverGroup:d,closeOthers:p}}),[l,c,d,p]),m=o.useMemo((function(){return{}}),[]);return u.createElement(ze.Provider,{value:v},f(a({},e,{ref:n}),m,"div"))};var tn=o.createContext(null);function rn(e){var n=o.useContext(tn);if(null===n){var t=new Error("<"+e+" /> is missing a parent <Switch.Group /> component.");throw Error.captureStackTrace&&Error.captureStackTrace(t,rn),t}return n}tn.displayName="GroupContext";var on,un=o.Fragment;function an(e){var n,t,u=e.checked,i=e.onChange,l=c(e,["checked","onChange"]),s="headlessui-switch-"+w(),d=o.useContext(tn),p=o.useCallback((function(){return i(!u)}),[i,u]),v=o.useCallback((function(e){if(y(e.currentTarget))return e.preventDefault();e.preventDefault(),p()}),[p]),m=o.useCallback((function(e){e.key!==r.Tab&&e.preventDefault(),e.key===r.Space&&p()}),[p]),b=o.useCallback((function(e){return e.preventDefault()}),[]),h=o.useMemo((function(){return{checked:u}}),[u]),S={id:s,ref:null===d?void 0:d.setSwitch,role:"switch",tabIndex:0,"aria-checked":u,"aria-labelledby":null==d||null==(n=d.label)?void 0:n.id,"aria-describedby":null==d||null==(t=d.description)?void 0:t.id,onClick:v,onKeyUp:m,onKeyPress:b};return"button"===l.as&&Object.assign(S,{type:"button"}),f(a({},l,S),h,"button")}function cn(){var e=o.useRef(!0);return o.useEffect((function(){e.current=!1}),[]),e.current}function ln(e){for(var n,t=arguments.length,r=new Array(t>1?t-1:0),o=1;o<t;o++)r[o-1]=arguments[o];e&&r.length>0&&(n=e.classList).add.apply(n,r)}function sn(e){for(var n,t=arguments.length,r=new Array(t>1?t-1:0),o=1;o<t;o++)r[o-1]=arguments[o];e&&r.length>0&&(n=e.classList).remove.apply(n,r)}function dn(e,n,t,r,o){var u=me(),i=void 0!==o?function(e){var n={called:!1};return function(){if(!n.called)return n.called=!0,e.apply(void 0,arguments)}}(o):function(){};return ln.apply(void 0,[e].concat(n,t)),u.nextFrame((function(){sn.apply(void 0,[e].concat(t)),ln.apply(void 0,[e].concat(r)),u.add(function(e,n){var t=me();if(!e)return t.dispose;var r=getComputedStyle(e),o=[r.transitionDuration,r.transitionDelay].map((function(e){var n=e.split(",").filter(Boolean).map((function(e){return e.includes("ms")?parseFloat(e):1e3*parseFloat(e)})).sort((function(e,n){return n-e}))[0];return void 0===n?0:n})),u=o[0];return 0!==u?t.setTimeout((function(){n(on.Finished)}),u+o[1]):n(on.Finished),t.add((function(){return n(on.Cancelled)})),t.dispose}(e,(function(t){return sn.apply(void 0,[e].concat(r,n)),i(t)})))})),u.add((function(){return sn.apply(void 0,[e].concat(n,t,r))})),u.add((function(){return i(on.Cancelled)})),u.dispose}function fn(e){return void 0===e&&(e=""),o.useMemo((function(){return e.split(" ").filter((function(e){return e.trim().length>1}))}),[e])}an.Group=function(e){var n=o.useState(null),t=n[0],r=n[1],i=o.useState(null),a=i[0],c=i[1],l=o.useState(null),s=l[0],d=l[1],p=o.useMemo((function(){return{switch:t,setSwitch:r,label:a,setLabel:c,description:s,setDescription:d}}),[t,r,a,c,s,d]);return u.createElement(tn.Provider,{value:p},f(e,{},un))},an.Label=function e(n){var t=rn([an.name,e.name].join(".")),r="headlessui-switch-label-"+w(),u=o.useCallback((function(){t.switch&&(t.switch.click(),t.switch.focus({preventScroll:!0}))}),[t.switch]);return f(a({},n,{ref:t.setLabel,id:r,onClick:u}),{},"label")},an.Description=function e(n){var t=rn([an.name,e.name].join(".")),r="headlessui-switch-description-"+w();return f(a({},n,{ref:t.setDescription,id:r}),{},"p")},function(e){e.Finished="finished",e.Cancelled="cancelled"}(on||(on={}));var pn,vn=o.createContext(null);vn.displayName="TransitionContext",function(e){e.Visible="visible",e.Hidden="hidden"}(pn||(pn={}));var mn=o.createContext(null);function bn(e){return"children"in e?bn(e.children):e.current.filter((function(e){return e.state===pn.Visible})).length>0}function yn(e){var n=o.useRef(e),r=o.useRef([]),u=function(){var e=o.useRef(!0);return o.useEffect((function(){return function(){e.current=!1}}),[]),e}();o.useEffect((function(){n.current=e}),[e]);var i=o.useCallback((function(e,o){var i;void 0===o&&(o=t.Hidden);var a=r.current.findIndex((function(n){return n.id===e}));-1!==a&&(d(o,((i={})[t.Unmount]=function(){r.current.splice(a,1)},i[t.Hidden]=function(){r.current[a].state=pn.Hidden},i)),!bn(r)&&u.current&&(null==n.current||n.current()))}),[n,u,r]),a=o.useCallback((function(e){var n=r.current.find((function(n){return n.id===e}));return n?n.state!==pn.Visible&&(n.state=pn.Visible):r.current.push({id:e,state:pn.Visible}),function(){return i(e,t.Unmount)}}),[r,i]);return o.useMemo((function(){return{children:r,register:a,unregister:i}}),[a,i,r])}function hn(){}mn.displayName="NestingContext";var Sn=["beforeEnter","afterEnter","beforeLeave","afterLeave"];function gn(e){for(var n,t={},r=s(Sn);!(n=r()).done;){var o,u=n.value;t[u]=null!=(o=e[u])?o:hn}return t}var En=n.RenderStrategy;function wn(e){var n=e.beforeEnter,r=e.afterEnter,i=e.beforeLeave,l=e.afterLeave,s=e.enter,p=e.enterFrom,v=e.enterTo,m=e.leave,b=e.leaveFrom,y=e.leaveTo,S=c(e,["beforeEnter","afterEnter","beforeLeave","afterLeave","enter","enterFrom","enterTo","leave","leaveFrom","leaveTo"]),g=o.useRef(null),E=o.useState(pn.Visible),x=E[0],C=E[1],I=S.unmount?t.Unmount:t.Hidden,O=function(){var e=o.useContext(vn);if(null===e)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition />.");return e}(),k=O.show,P=O.appear,R=function(){var e=o.useContext(mn);if(null===e)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition />.");return e}(),T=R.register,D=R.unregister,L=cn(),F=w(),M=o.useRef(!1),A=yn((function(){M.current||(C(pn.Hidden),D(F),V.current.afterLeave())}));h((function(){if(F)return T(F)}),[T,F]),h((function(){var e;I===t.Hidden&&F&&(k&&x!==pn.Visible?C(pn.Visible):d(x,((e={})[pn.Hidden]=function(){return D(F)},e[pn.Visible]=function(){return T(F)},e)))}),[x,F,T,D,k,I]);var N=fn(s),j=fn(p),U=fn(v),G=fn(m),H=fn(b),B=fn(y),V=function(e){var n=o.useRef(gn(e));return o.useEffect((function(){n.current=gn(e)}),[e]),n}({beforeEnter:n,afterEnter:r,beforeLeave:i,afterLeave:l});o.useEffect((function(){if(x===pn.Visible&&null===g.current)throw new Error("Did you forget to passthrough the `ref` to the actual DOM node?")}),[g,x]);var Q=L&&!P;return h((function(){var e=g.current;if(e&&!Q)return M.current=!0,k&&V.current.beforeEnter(),k||V.current.beforeLeave(),k?dn(e,N,j,U,(function(e){M.current=!1,e===on.Finished&&V.current.afterEnter()})):dn(e,G,H,B,(function(e){M.current=!1,e===on.Finished&&(bn(A)||(C(pn.Hidden),D(F),V.current.afterLeave()))}))}),[V,F,M,D,A,g,Q,k,N,j,U,G,H,B]),u.createElement(mn.Provider,{value:A},f(a({},S,{ref:g}),{},"div",En,x===pn.Visible))}function xn(e){var n=e.show,t=e.appear,r=void 0!==t&&t,i=e.unmount,l=c(e,["show","appear","unmount"]);if(![!0,!1].includes(n))throw new Error("A <Transition /> is used but it is missing a `show={true | false}` prop.");var s=o.useState(n?pn.Visible:pn.Hidden),d=s[0],p=s[1],v=yn((function(){p(pn.Hidden)})),m=cn(),b=o.useMemo((function(){return{show:n,appear:r||!m}}),[n,r,m]);o.useEffect((function(){n?p(pn.Visible):bn(v)||p(pn.Hidden)}),[n,v]);var y={unmount:i};return u.createElement(mn.Provider,{value:v},u.createElement(vn.Provider,{value:b},f(a({},y,{as:o.Fragment,children:u.createElement(wn,Object.assign({},y,l))}),{},o.Fragment,En,d===pn.Visible)))}xn.Child=wn,exports.Dialog=ne,exports.Disclosure=ae,exports.FocusTrap=function(e){var n=o.useRef(new Set),t=e.initialFocus,r=c(e,["initialFocus"]);return F(n,!0,{initialFocus:t}),f(a({},r,{ref:function(e){e&&n.current.add(e)}}),{},"div")},exports.Listbox=Ce,exports.Menu=Ne,exports.Popover=$e,exports.Portal=q,exports.Switch=an,exports.Transition=xn; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,n,t,r,o=require("react"),u=(e=o)&&"object"==typeof e&&"default"in e?e.default:e,i=require("react-dom");function a(){return(a=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)}function c(e,n){if(null==e)return{};var t,r,o={},u=Object.keys(e);for(r=0;r<u.length;r++)n.indexOf(t=u[r])>=0||(o[t]=e[t]);return o}function l(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function s(e,n){var t;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(t=function(e,n){if(e){if("string"==typeof e)return l(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?l(e,void 0):void 0}}(e))||n&&e&&"number"==typeof e.length){t&&(e=t);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(t=e[Symbol.iterator]()).next.bind(t)}function d(e,n){if(e in n){for(var t=n[e],r=arguments.length,o=new Array(r>2?r-2:0),u=2;u<r;u++)o[u-2]=arguments[u];return"function"==typeof t?t.apply(void 0,o):t}var i=new Error('Tried to handle "'+e+'" but there is no handler defined. Only defined handlers are: '+Object.keys(n).map((function(e){return'"'+e+'"'})).join(", ")+".");throw Error.captureStackTrace&&Error.captureStackTrace(i,d),i}function f(e,r,o,u,i){if(void 0===i&&(i=!0),i)return p(e,r,o);var l=null!=u?u:n.None;if(l&n.Static){var s=e.static,f=void 0!==s&&s,v=c(e,["static"]);if(f)return p(v,r,o)}if(l&n.RenderStrategy){var m,b=e.unmount,y=void 0===b||b,h=c(e,["unmount"]);return d(y?t.Unmount:t.Hidden,((m={})[t.Unmount]=function(){return null},m[t.Hidden]=function(){return p(a({},h,{hidden:!0,style:{display:"none"}}),r,o)},m))}return p(e,r,o)}function p(e,n,t){var r,u=m(e,["unmount","static"]),i=u.as,a=void 0===i?t:i,l=u.children,d=u.refName,f=void 0===d?"ref":d,v=c(u,["as","children","refName"]),b=void 0!==e.ref?((r={})[f]=e.ref,r):{},y="function"==typeof l?l(n):l;if(v.className&&"function"==typeof v.className&&(v.className=v.className(n)),a===o.Fragment&&Object.keys(v).length>0){if(Array.isArray(y)&&y.length>1){var h=new Error("You should only render 1 child");throw Error.captureStackTrace&&Error.captureStackTrace(h,p),h}if(!o.isValidElement(y)){var S=new Error('You should render an element as a child. Did you forget the as="..." prop?');throw Error.captureStackTrace&&Error.captureStackTrace(S,p),S}return o.cloneElement(y,Object.assign({},function(e,n,t){for(var r,o=Object.assign({},e),u=function(){var t,u=r.value;void 0!==e[u]&&void 0!==n[u]&&Object.assign(o,((t={})[u]=function(t){t.defaultPrevented||e[u](t),t.defaultPrevented||n[u](t)},t))},i=s(["onClick"]);!(r=i()).done;)u();return o}(function(e){var n=Object.assign({},e);for(var t in n)void 0===n[t]&&delete n[t];return n}(m(v,["ref"])),y.props),b))}return o.createElement(a,Object.assign({},m(v,["ref"]),a!==o.Fragment&&b),y)}function v(e){var n;return Object.assign(o.forwardRef(e),{displayName:null!=(n=e.displayName)?n:e.name})}function m(e,n){void 0===n&&(n=[]);for(var t,r=Object.assign({},e),o=s(n);!(t=o()).done;){var u=t.value;u in r&&delete r[u]}return r}function b(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];var r=o.useRef(n);return o.useEffect((function(){r.current=n}),[n]),o.useCallback((function(e){for(var n,t=s(r.current);!(n=t()).done;){var o=n.value;null!=o&&("function"==typeof o?o(e):o.current=e)}}),[r])}function y(e){for(var n,t,r=e.parentElement,o=null;r&&!(r instanceof HTMLFieldSetElement);)r instanceof HTMLLegendElement&&(o=r),r=r.parentElement;var u=null!=(n=""===(null==(t=r)?void 0:t.getAttribute("disabled")))&&n;return(!u||!function(e){if(!e)return!1;for(var n=e.previousElementSibling;null!==n;){if(n instanceof HTMLLegendElement)return!1;n=n.previousElementSibling}return!0}(o))&&u}!function(e){e[e.None=0]="None",e[e.RenderStrategy=1]="RenderStrategy",e[e.Static=2]="Static"}(n||(n={})),function(e){e[e.Unmount=0]="Unmount",e[e.Hidden=1]="Hidden"}(t||(t={})),function(e){e.Space=" ",e.Enter="Enter",e.Escape="Escape",e.Backspace="Backspace",e.ArrowUp="ArrowUp",e.ArrowDown="ArrowDown",e.Home="Home",e.End="End",e.PageUp="PageUp",e.PageDown="PageDown",e.Tab="Tab"}(r||(r={}));var h="undefined"!=typeof window?o.useLayoutEffect:o.useEffect,S={serverHandoffComplete:!1},g=0;function E(){return++g}function w(){var e=o.useState(S.serverHandoffComplete?E:null),n=e[0],t=e[1];return h((function(){null===n&&t(E())}),[n]),o.useEffect((function(){!1===S.serverHandoffComplete&&(S.serverHandoffComplete=!0)}),[]),null!=n?""+n:void 0}var x,C,I,O,k=["[contentEditable=true]","[tabindex]","a[href]","area[href]","button:not([disabled])","iframe","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].map((function(e){return e+":not([tabindex='-1'])"})).join(",");function P(e){return void 0===e&&(e=document.body),null==e?[]:Array.from(e.querySelectorAll(k))}function R(e,n){var t;return void 0===n&&(n=O.Strict),e!==document.body&&d(n,((t={})[O.Strict]=function(){return e.matches(k)},t[O.Loose]=function(){for(var n=e;null!==n;){if(n.matches(k))return!0;n=n.parentElement}return!1},t))}function T(e){null==e||e.focus({preventScroll:!0})}function D(e,n){var t=Array.isArray(e)?e:P(e),r=document.activeElement,o=function(){if(n&(x.First|x.Next))return I.Next;if(n&(x.Previous|x.Last))return I.Previous;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")}(),u=function(){if(n&x.First)return 0;if(n&x.Previous)return Math.max(0,t.indexOf(r))-1;if(n&x.Next)return Math.max(0,t.indexOf(r))+1;if(n&x.Last)return t.length-1;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")}(),i=n&x.NoScroll?{preventScroll:!0}:{},a=0,c=t.length,l=void 0;do{var s;if(a>=c||a+c<=0)return C.Error;var d=u+a;if(n&x.WrapAround)d=(d+c)%c;else{if(d<0)return C.Underflow;if(d>=c)return C.Overflow}null==(s=l=t[d])||s.focus(i),a+=o}while(l!==document.activeElement);return C.Success}function L(e,n){for(var t,r=s(e);!(t=r()).done;)if(t.value.contains(n))return!0;return!1}function F(e,n,t){void 0===n&&(n=!0),void 0===t&&(t={});var u=o.useRef("undefined"!=typeof window?document.activeElement:null),i=o.useRef(null),a=o.useRef(!1);h((function(){var r,o;if(n&&1===e.current.size){a.current=!0;var c,l=document.activeElement;if(null==(r=t.initialFocus)?void 0:r.current){if((null==(c=t.initialFocus)?void 0:c.current)===l)return}else if(L(e.current,l))return;if(u.current=l,null==(o=t.initialFocus)?void 0:o.current)T(t.initialFocus.current);else{for(var d,f=!1,p=s(e.current);!(d=p()).done;)if(D(d.value,x.First)===C.Success){f=!0;break}if(!f)throw new Error("There are no focusable elements inside the <FocusTrap />")}return i.current=document.activeElement,function(){a.current=!1,T(u.current),u.current=null,i.current=null}}}),[n,e,a,t.initialFocus]),h((function(){if(n)return window.addEventListener("keydown",t),function(){return window.removeEventListener("keydown",t)};function t(n){if(n.key===r.Tab&&document.activeElement&&1===e.current.size){n.preventDefault();for(var t,o=s(e.current);!(t=o()).done;)if(D(t.value,(n.shiftKey?x.Previous:x.Next)|x.WrapAround)===C.Success){i.current=document.activeElement;break}}}}),[n,e]),h((function(){if(n&&1===e.current.size)return window.addEventListener("focus",t,!0),function(){return window.removeEventListener("focus",t,!0)};function t(n){var t=i.current;if(t&&a.current){var r=n.target;r&&r instanceof HTMLElement?L(e.current,r)?(i.current=r,T(r)):(n.preventDefault(),n.stopPropagation(),T(t)):T(i.current)}}}),[n,a,e])}!function(e){e[e.First=1]="First",e[e.Previous=2]="Previous",e[e.Next=4]="Next",e[e.Last=8]="Last",e[e.WrapAround=16]="WrapAround",e[e.NoScroll=32]="NoScroll"}(x||(x={})),function(e){e[e.Error=0]="Error",e[e.Overflow=1]="Overflow",e[e.Success=2]="Success",e[e.Underflow=3]="Underflow"}(C||(C={})),function(e){e[e.Previous=-1]="Previous",e[e.Next=1]="Next"}(I||(I={})),function(e){e[e.Strict=0]="Strict",e[e.Loose=1]="Loose"}(O||(O={}));var M=new Set,A=new Map;function N(e){e.setAttribute("aria-hidden","true"),e.inert=!0}function j(e){var n=A.get(e);n&&(null===n["aria-hidden"]?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",n["aria-hidden"]),e.inert=n.inert)}var U,G=o.createContext((function(){}));function H(){return o.useContext(G)}function B(e){var n=e.children,t=e.onUpdate,r=H(),i=o.useCallback((function(){for(var e=arguments.length,n=new Array(e),o=0;o<e;o++)n[o]=arguments[o];null==t||t.apply(void 0,n),r.apply(void 0,n)}),[r,t]);return u.createElement(G.Provider,{value:i},n)}G.displayName="StackContext",function(e){e[e.AddElement=0]="AddElement",e[e.RemoveElement=1]="RemoveElement"}(U||(U={}));var V,Q,K,W=o.Fragment;function q(e){var n=o.useState((function(){if("undefined"==typeof window)return null;var e=document.getElementById("headlessui-portal-root");if(e)return e;var n=document.createElement("div");return n.setAttribute("id","headlessui-portal-root"),document.body.appendChild(n)}))[0],t=o.useState((function(){return"undefined"==typeof window?null:document.createElement("div")}))[0];return function(e){var n=H();h((function(){if(e)return n(U.AddElement,e),function(){return n(U.RemoveElement,e)}}),[e])}(t),h((function(){if(n&&t)return n.appendChild(t),function(){var e;n&&t&&(n.removeChild(t),n.childNodes.length<=0&&(null==(e=n.parentElement)||e.removeChild(n)))}}),[n,t]),u.createElement(B,null,n&&t?i.createPortal(f(e,{},W),t):null)}!function(e){e[e.Open=0]="Open",e[e.Closed=1]="Closed"}(Q||(Q={})),function(e){e[e.SetTitleId=0]="SetTitleId",e[e.SetDescriptionId=1]="SetDescriptionId"}(K||(K={}));var z=((V={})[K.SetTitleId]=function(e,n){return e.titleId===n.id?e:a({},e,{titleId:n.id})},V[K.SetDescriptionId]=function(e,n){return e.descriptionId===n.id?e:a({},e,{descriptionId:n.id})},V),Y=o.createContext(null);function _(e){var n=o.useContext(Y);if(null===n){var t=new Error("<"+e+" /> is missing a parent <"+ne.displayName+" /> component.");throw Error.captureStackTrace&&Error.captureStackTrace(t,_),t}return n}function J(e,n){return d(n.type,z,e,n)}Y.displayName="DialogContext";var $,X,Z,ee=n.RenderStrategy|n.Static,ne=Object.assign(v((function(e,n){var t=e.open,i=e.onClose,l=e.initialFocus,p=c(e,["open","onClose","initialFocus"]),v=o.useRef(new Set),m=o.useRef(null),y=b(m,n),S=e.hasOwnProperty("open"),g=e.hasOwnProperty("onClose");if(!S&&!g)throw new Error("You have to provide an `open` and an `onClose` prop to the `Dialog` component.");if(!S)throw new Error("You provided an `onClose` prop to the `Dialog`, but forgot an `open` prop.");if(!g)throw new Error("You provided an `open` prop to the `Dialog`, but forgot an `onClose` prop.");if("boolean"!=typeof t)throw new Error("You provided an `open` prop to the `Dialog`, but the value is not a boolean. Received: "+t);if("function"!=typeof i)throw new Error("You provided an `onClose` prop to the `Dialog`, but the value is not a function. Received: "+i);var E=t?Q.Open:Q.Closed,x=o.useReducer(J,{titleId:null,descriptionId:null}),C=x[0],I=x[1],O=o.useCallback((function(){return i(!1)}),[i]),k=o.useCallback((function(e){return I({type:K.SetTitleId,id:e})}),[I]),P=o.useCallback((function(e){return I({type:K.SetDescriptionId,id:e})}),[I]);o.useEffect((function(){function e(e){E===Q.Open&&1===v.current.size&&(L(v.current,e.target)||O())}return window.addEventListener("mousedown",e),function(){return window.removeEventListener("mousedown",e)}}),[E,v,O]),o.useEffect((function(){function e(e){e.key===r.Escape&&E===Q.Open&&(v.current.size>1||O())}return window.addEventListener("keydown",e),function(){return window.removeEventListener("keydown",e)}}),[O,E]),o.useEffect((function(){if(E===Q.Open){var e=document.documentElement.style.overflow,n=document.documentElement.style.paddingRight,t=window.innerWidth-document.documentElement.clientWidth;return document.documentElement.style.overflow="hidden",document.documentElement.style.paddingRight=t+"px",function(){document.documentElement.style.overflow=e,document.documentElement.style.paddingRight=n}}}),[E]),o.useEffect((function(){if(E===Q.Open&&m.current){var e=new IntersectionObserver((function(e){for(var n,t=s(e);!(n=t()).done;){var r=n.value;0===r.boundingClientRect.x&&0===r.boundingClientRect.y&&0===r.boundingClientRect.width&&0===r.boundingClientRect.height&&O()}}));return e.observe(m.current),function(){return e.disconnect()}}}),[E,m,O]);var R=!!e.static||E===Q.Open;F(v,R,{initialFocus:l}),function(e,n){void 0===n&&(n=!0),h((function(){if(n&&e.current){var t=e.current;M.add(t);for(var r,o=s(A.keys());!(r=o()).done;){var u=r.value;u.contains(t)&&(j(u),A.delete(u))}return document.querySelectorAll("body > *").forEach((function(e){if(e instanceof HTMLElement){for(var n,t=s(M);!(n=t()).done;)if(e.contains(n.value))return;1===M.size&&(A.set(e,{"aria-hidden":e.getAttribute("aria-hidden"),inert:e.inert}),N(e))}})),function(){if(M.delete(t),M.size>0)document.querySelectorAll("body > *").forEach((function(e){if(e instanceof HTMLElement&&!A.has(e)){for(var n,t=s(M);!(n=t()).done;)if(e.contains(n.value))return;A.set(e,{"aria-hidden":e.getAttribute("aria-hidden"),inert:e.inert}),N(e)}}));else for(var e,n=s(A.keys());!(e=n()).done;){var r=e.value;j(r),A.delete(r)}}}}),[n])}(m,R);var T="headlessui-dialog-"+w(),D=o.useMemo((function(){return[{dialogState:E,close:O,setTitleId:k,setDescriptionId:P},C]}),[E,C,O,k,P]),G=o.useMemo((function(){return{open:E===Q.Open}}),[E]);return u.createElement(B,{onUpdate:function(e,n){var t;return d(e,((t={})[U.AddElement]=function(){v.current.add(n)},t[U.RemoveElement]=function(){v.current.delete(n)},t))}},u.createElement(q,null,u.createElement(Y.Provider,{value:D},f(a({},p,{ref:y,id:T,role:"dialog","aria-modal":E===Q.Open||void 0,"aria-labelledby":C.titleId,"aria-describedby":C.descriptionId}),G,"div",ee,E===Q.Open))))})),{Overlay:v((function e(n,t){var r=_([ne.displayName,e.name].join("."))[0],u=r.dialogState,i=r.close,c=b(t),l="headlessui-dialog-overlay-"+w(),s=o.useCallback((function(e){if(y(e.currentTarget))return e.preventDefault();i()}),[i]),d=o.useMemo((function(){return{open:u===Q.Open}}),[u]);return f(a({},n,{ref:c,id:l,"aria-hidden":!0,onClick:s}),d,"div")})),Title:function e(n){var t=_([ne.displayName,e.name].join("."))[0],r=t.dialogState,u=t.setTitleId,i="headlessui-dialog-title-"+w();o.useEffect((function(){return u(i),function(){return u(null)}}),[i,u]);var c=o.useMemo((function(){return{open:r===Q.Open}}),[r]);return f(a({},n,{id:i}),c,"h2")},Description:function e(n){var t=_([ne.displayName,e.name].join("."))[0],r=t.dialogState,u=t.setDescriptionId,i="headlessui-dialog-description-"+w();o.useEffect((function(){return u(i),function(){return u(null)}}),[i,u]);var c=o.useMemo((function(){return{open:r===Q.Open}}),[r]);return f(a({},n,{id:i}),c,"p")}});!function(e){e[e.Open=0]="Open",e[e.Closed=1]="Closed"}(X||(X={})),function(e){e[e.ToggleDisclosure=0]="ToggleDisclosure",e[e.SetButtonId=1]="SetButtonId",e[e.SetPanelId=2]="SetPanelId",e[e.LinkPanel=3]="LinkPanel",e[e.UnlinkPanel=4]="UnlinkPanel"}(Z||(Z={}));var te=(($={})[Z.ToggleDisclosure]=function(e){var n;return a({},e,{disclosureState:d(e.disclosureState,(n={},n[X.Open]=X.Closed,n[X.Closed]=X.Open,n))})},$[Z.LinkPanel]=function(e){return!0===e.linkedPanel?e:a({},e,{linkedPanel:!0})},$[Z.UnlinkPanel]=function(e){return!1===e.linkedPanel?e:a({},e,{linkedPanel:!1})},$[Z.SetButtonId]=function(e,n){return e.buttonId===n.buttonId?e:a({},e,{buttonId:n.buttonId})},$[Z.SetPanelId]=function(e,n){return e.panelId===n.panelId?e:a({},e,{panelId:n.panelId})},$),re=o.createContext(null);function oe(e){var n=o.useContext(re);if(null===n){var t=new Error("<"+e+" /> is missing a parent <"+ae.name+" /> component.");throw Error.captureStackTrace&&Error.captureStackTrace(t,oe),t}return n}function ue(e,n){return d(n.type,te,e,n)}re.displayName="DisclosureContext";var ie=o.Fragment;function ae(e){var n="headlessui-disclosure-button-"+w(),t="headlessui-disclosure-panel-"+w(),r=o.useReducer(ue,{disclosureState:X.Closed,linkedPanel:!1,buttonId:n,panelId:t}),i=r[0].disclosureState,a=r[1];o.useEffect((function(){return a({type:Z.SetButtonId,buttonId:n})}),[n,a]),o.useEffect((function(){return a({type:Z.SetPanelId,panelId:t})}),[t,a]);var c=o.useMemo((function(){return{open:i===X.Open}}),[i]);return u.createElement(re.Provider,{value:r},f(e,c,ie))}var ce,le,se,de,fe=v((function e(n,t){var u=oe([ae.name,e.name].join(".")),i=u[0],c=u[1],l=b(t),s=o.useCallback((function(e){switch(e.key){case r.Space:case r.Enter:e.preventDefault(),c({type:Z.ToggleDisclosure})}}),[c]),d=o.useCallback((function(e){y(e.currentTarget)||n.disabled||c({type:Z.ToggleDisclosure})}),[c,n.disabled]),p=o.useMemo((function(){return{open:i.disclosureState===X.Open}}),[i]);return f(a({},n,{ref:l,id:i.buttonId,type:"button","aria-expanded":i.disclosureState===X.Open||void 0,"aria-controls":i.linkedPanel?i.panelId:void 0,onKeyDown:s,onClick:d}),p,"button")})),pe=n.RenderStrategy|n.Static,ve=v((function e(n,t){var r=oe([ae.name,e.name].join(".")),u=r[0],i=r[1],c=b(t,(function(){u.linkedPanel||i({type:Z.LinkPanel})}));o.useEffect((function(){return function(){return i({type:Z.UnlinkPanel})}}),[i]),o.useEffect((function(){var e;u.disclosureState!==X.Closed||null!=(e=n.unmount)&&!e||i({type:Z.UnlinkPanel})}),[u.disclosureState,n.unmount,i]);var l=o.useMemo((function(){return{open:u.disclosureState===X.Open}}),[u]);return f(a({},n,{ref:c,id:u.panelId}),l,"div",pe,u.disclosureState===X.Open)}));function me(){var e=[],n={requestAnimationFrame:function(e){function n(){return e.apply(this,arguments)}return n.toString=function(){return e.toString()},n}((function(){var e=requestAnimationFrame.apply(void 0,arguments);n.add((function(){return cancelAnimationFrame(e)}))})),nextFrame:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];n.requestAnimationFrame((function(){n.requestAnimationFrame.apply(n,t)}))},setTimeout:function(e){function n(){return e.apply(this,arguments)}return n.toString=function(){return e.toString()},n}((function(){var e=setTimeout.apply(void 0,arguments);n.add((function(){return clearTimeout(e)}))})),add:function(n){e.push(n)},dispose:function(){for(var n,t=s(e.splice(0));!(n=t()).done;)(0,n.value)()}};return n}function be(){var e=o.useState(me)[0];return o.useEffect((function(){return function(){return e.dispose()}}),[e]),e}function ye(e,n){var t=o.useState(e),r=t[0],u=t[1],i=o.useRef(e);return h((function(){i.current=e}),[e]),h((function(){return u(i.current)}),[i,u].concat(n)),r}function he(e,n){var t=n.resolveItems();if(t.length<=0)return null;var r=n.resolveActiveIndex(),o=null!=r?r:-1,u=function(){switch(e.focus){case ce.First:return t.findIndex((function(e){return!n.resolveDisabled(e)}));case ce.Previous:var r=t.slice().reverse().findIndex((function(e,t,r){return!(-1!==o&&r.length-t-1>=o||n.resolveDisabled(e))}));return-1===r?r:t.length-1-r;case ce.Next:return t.findIndex((function(e,t){return!(t<=o||n.resolveDisabled(e))}));case ce.Last:var u=t.slice().reverse().findIndex((function(e){return!n.resolveDisabled(e)}));return-1===u?u:t.length-1-u;case ce.Specific:return t.findIndex((function(t){return n.resolveId(t)===e.id}));case ce.Nothing:return null;default:!function(e){throw new Error("Unexpected object: "+e)}(e)}}();return-1===u?r:u}ae.Button=fe,ae.Panel=ve,function(e){e[e.First=0]="First",e[e.Previous=1]="Previous",e[e.Next=2]="Next",e[e.Last=3]="Last",e[e.Specific=4]="Specific",e[e.Nothing=5]="Nothing"}(ce||(ce={})),function(e){e[e.Open=0]="Open",e[e.Closed=1]="Closed"}(se||(se={})),function(e){e[e.OpenListbox=0]="OpenListbox",e[e.CloseListbox=1]="CloseListbox",e[e.SetDisabled=2]="SetDisabled",e[e.GoToOption=3]="GoToOption",e[e.Search=4]="Search",e[e.ClearSearch=5]="ClearSearch",e[e.RegisterOption=6]="RegisterOption",e[e.UnregisterOption=7]="UnregisterOption"}(de||(de={}));var Se=((le={})[de.CloseListbox]=function(e){return e.disabled||e.listboxState===se.Closed?e:a({},e,{activeOptionIndex:null,listboxState:se.Closed})},le[de.OpenListbox]=function(e){return e.disabled||e.listboxState===se.Open?e:a({},e,{listboxState:se.Open})},le[de.SetDisabled]=function(e,n){return e.disabled===n.disabled?e:a({},e,{disabled:n.disabled})},le[de.GoToOption]=function(e,n){if(e.disabled)return e;if(e.listboxState===se.Closed)return e;var t=he(n,{resolveItems:function(){return e.options},resolveActiveIndex:function(){return e.activeOptionIndex},resolveId:function(e){return e.id},resolveDisabled:function(e){return e.dataRef.current.disabled}});return""===e.searchQuery&&e.activeOptionIndex===t?e:a({},e,{searchQuery:"",activeOptionIndex:t})},le[de.Search]=function(e,n){if(e.disabled)return e;if(e.listboxState===se.Closed)return e;var t=e.searchQuery+n.value,r=e.options.findIndex((function(e){var n;return!e.dataRef.current.disabled&&(null==(n=e.dataRef.current.textValue)?void 0:n.startsWith(t))}));return a({},e,-1===r||r===e.activeOptionIndex?{searchQuery:t}:{searchQuery:t,activeOptionIndex:r})},le[de.ClearSearch]=function(e){return e.disabled||e.listboxState===se.Closed||""===e.searchQuery?e:a({},e,{searchQuery:""})},le[de.RegisterOption]=function(e,n){return a({},e,{options:[].concat(e.options,[{id:n.id,dataRef:n.dataRef}])})},le[de.UnregisterOption]=function(e,n){var t=e.options.slice(),r=null!==e.activeOptionIndex?t[e.activeOptionIndex]:null,o=t.findIndex((function(e){return e.id===n.id}));return-1!==o&&t.splice(o,1),a({},e,{options:t,activeOptionIndex:o===e.activeOptionIndex||null===r?null:t.indexOf(r)})},le),ge=o.createContext(null);function Ee(e){var n=o.useContext(ge);if(null===n){var t=new Error("<"+e+" /> is missing a parent <"+Ce.name+" /> component.");throw Error.captureStackTrace&&Error.captureStackTrace(t,Ee),t}return n}function we(e,n){return d(n.type,Se,e,n)}ge.displayName="ListboxContext";var xe=o.Fragment;function Ce(e){var n=e.value,t=e.onChange,r=e.disabled,i=void 0!==r&&r,a=c(e,["value","onChange","disabled"]),l=o.useReducer(we,{listboxState:se.Closed,propsRef:{current:{value:n,onChange:t}},labelRef:o.createRef(),buttonRef:o.createRef(),optionsRef:o.createRef(),disabled:i,options:[],searchQuery:"",activeOptionIndex:null}),s=l[0],d=s.listboxState,p=s.propsRef,v=s.optionsRef,m=s.buttonRef,b=l[1];h((function(){p.current.value=n}),[n,p]),h((function(){p.current.onChange=t}),[t,p]),h((function(){return b({type:de.SetDisabled,disabled:i})}),[i]),o.useEffect((function(){function e(e){var n,t,r,o=e.target;d===se.Open&&((null==(n=m.current)?void 0:n.contains(o))||(null==(t=v.current)?void 0:t.contains(o))||(b({type:de.CloseListbox}),R(o,O.Loose)||(e.preventDefault(),null==(r=m.current)||r.focus())))}return window.addEventListener("mousedown",e),function(){return window.removeEventListener("mousedown",e)}}),[d,m,v,b]);var y=o.useMemo((function(){return{open:d===se.Open,disabled:i}}),[d,i]);return u.createElement(ge.Provider,{value:l},f(a,y,xe))}var Ie,Oe,ke,Pe=v((function e(n,t){var u,i=Ee([Ce.name,e.name].join(".")),c=i[0],l=i[1],s=b(c.buttonRef,t),d="headlessui-listbox-button-"+w(),p=be(),v=o.useCallback((function(e){switch(e.key){case r.Space:case r.Enter:case r.ArrowDown:e.preventDefault(),l({type:de.OpenListbox}),p.nextFrame((function(){c.propsRef.current.value||l({type:de.GoToOption,focus:ce.First})}));break;case r.ArrowUp:e.preventDefault(),l({type:de.OpenListbox}),p.nextFrame((function(){c.propsRef.current.value||l({type:de.GoToOption,focus:ce.Last})}))}}),[l,c,p]),m=o.useCallback((function(e){if(y(e.currentTarget))return e.preventDefault();c.listboxState===se.Open?(l({type:de.CloseListbox}),p.nextFrame((function(){var e;return null==(e=c.buttonRef.current)?void 0:e.focus({preventScroll:!0})}))):(e.preventDefault(),l({type:de.OpenListbox}))}),[l,p,c]),h=ye((function(){if(c.labelRef.current)return[c.labelRef.current.id,d].join(" ")}),[c.labelRef.current,d]),S=o.useMemo((function(){return{open:c.listboxState===se.Open,disabled:c.disabled}}),[c]);return f(a({},n,{ref:s,id:d,type:"button","aria-haspopup":!0,"aria-controls":null==(u=c.optionsRef.current)?void 0:u.id,"aria-expanded":c.listboxState===se.Open||void 0,"aria-labelledby":h,disabled:c.disabled,onKeyDown:v,onClick:m}),S,"button")})),Re=n.RenderStrategy|n.Static,Te=v((function e(n,t){var u,i=Ee([Ce.name,e.name].join(".")),c=i[0],l=i[1],s=b(c.optionsRef,t),d="headlessui-listbox-options-"+w(),p=be(),v=be();h((function(){var e=c.optionsRef.current;e&&c.listboxState===se.Open&&e!==document.activeElement&&e.focus({preventScroll:!0})}),[c.listboxState,c.optionsRef]);var m=o.useCallback((function(e){switch(v.dispose(),e.key){case r.Space:if(""!==c.searchQuery)return e.preventDefault(),e.stopPropagation(),l({type:de.Search,value:e.key});case r.Enter:e.preventDefault(),e.stopPropagation(),l({type:de.CloseListbox}),null!==c.activeOptionIndex&&c.propsRef.current.onChange(c.options[c.activeOptionIndex].dataRef.current.value),me().nextFrame((function(){var e;return null==(e=c.buttonRef.current)?void 0:e.focus({preventScroll:!0})}));break;case r.ArrowDown:return e.preventDefault(),e.stopPropagation(),l({type:de.GoToOption,focus:ce.Next});case r.ArrowUp:return e.preventDefault(),e.stopPropagation(),l({type:de.GoToOption,focus:ce.Previous});case r.Home:case r.PageUp:return e.preventDefault(),e.stopPropagation(),l({type:de.GoToOption,focus:ce.First});case r.End:case r.PageDown:return e.preventDefault(),e.stopPropagation(),l({type:de.GoToOption,focus:ce.Last});case r.Escape:return e.preventDefault(),e.stopPropagation(),l({type:de.CloseListbox}),p.nextFrame((function(){var e;return null==(e=c.buttonRef.current)?void 0:e.focus({preventScroll:!0})}));case r.Tab:e.preventDefault(),e.stopPropagation();break;default:1===e.key.length&&(l({type:de.Search,value:e.key}),v.setTimeout((function(){return l({type:de.ClearSearch})}),350))}}),[p,l,v,c]),y=ye((function(){var e,n,t;return null!=(e=null==(n=c.labelRef.current)?void 0:n.id)?e:null==(t=c.buttonRef.current)?void 0:t.id}),[c.labelRef.current,c.buttonRef.current]),S=o.useMemo((function(){return{open:c.listboxState===se.Open}}),[c]);return f(a({},n,{"aria-activedescendant":null===c.activeOptionIndex||null==(u=c.options[c.activeOptionIndex])?void 0:u.id,"aria-labelledby":y,id:d,onKeyDown:m,role:"listbox",tabIndex:0,ref:s}),S,"ul",Re,c.listboxState===se.Open)}));Ce.Button=Pe,Ce.Label=function e(n){var t=Ee([Ce.name,e.name].join("."))[0],r="headlessui-listbox-label-"+w(),u=o.useCallback((function(){var e;return null==(e=t.buttonRef.current)?void 0:e.focus({preventScroll:!0})}),[t.buttonRef]),i=o.useMemo((function(){return{open:t.listboxState===se.Open,disabled:t.disabled}}),[t]);return f(a({},n,{ref:t.labelRef,id:r,onClick:u}),i,"label")},Ce.Options=Te,Ce.Option=function e(n){var t=n.disabled,r=void 0!==t&&t,u=n.value,i=c(n,["disabled","value"]),l=Ee([Ce.name,e.name].join(".")),s=l[0],d=l[1],p="headlessui-listbox-option-"+w(),v=null!==s.activeOptionIndex&&s.options[s.activeOptionIndex].id===p,m=s.propsRef.current.value===u,b=o.useRef({disabled:r,value:u});h((function(){b.current.disabled=r}),[b,r]),h((function(){b.current.value=u}),[b,u]),h((function(){var e,n;b.current.textValue=null==(e=document.getElementById(p))||null==(n=e.textContent)?void 0:n.toLowerCase()}),[b,p]);var y=o.useCallback((function(){return s.propsRef.current.onChange(u)}),[s.propsRef,u]);h((function(){return d({type:de.RegisterOption,id:p,dataRef:b}),function(){return d({type:de.UnregisterOption,id:p})}}),[b,p]),h((function(){var e;s.listboxState===se.Open&&m&&(d({type:de.GoToOption,focus:ce.Specific,id:p}),null==(e=document.getElementById(p))||null==e.focus||e.focus())}),[s.listboxState]),h((function(){if(s.listboxState===se.Open&&v){var e=me();return e.nextFrame((function(){var e;return null==(e=document.getElementById(p))||null==e.scrollIntoView?void 0:e.scrollIntoView({block:"nearest"})})),e.dispose}}),[p,v,s.listboxState]);var S=o.useCallback((function(e){if(r)return e.preventDefault();y(),d({type:de.CloseListbox}),me().nextFrame((function(){var e;return null==(e=s.buttonRef.current)?void 0:e.focus({preventScroll:!0})}))}),[d,s.buttonRef,r,y]),g=o.useCallback((function(){if(r)return d({type:de.GoToOption,focus:ce.Nothing});d({type:de.GoToOption,focus:ce.Specific,id:p})}),[r,p,d]),E=o.useCallback((function(){r||v||d({type:de.GoToOption,focus:ce.Specific,id:p})}),[r,v,p,d]),x=o.useCallback((function(){r||v&&d({type:de.GoToOption,focus:ce.Nothing})}),[r,v,d]),C=o.useMemo((function(){return{active:v,selected:m,disabled:r}}),[v,m,r]);return f(a({},i,{id:p,role:"option",tabIndex:-1,"aria-disabled":!0===r||void 0,"aria-selected":!0===m||void 0,onClick:S,onFocus:g,onPointerMove:E,onMouseMove:E,onPointerLeave:x,onMouseLeave:x}),C,"li")},function(e){e[e.Open=0]="Open",e[e.Closed=1]="Closed"}(Oe||(Oe={})),function(e){e[e.OpenMenu=0]="OpenMenu",e[e.CloseMenu=1]="CloseMenu",e[e.GoToItem=2]="GoToItem",e[e.Search=3]="Search",e[e.ClearSearch=4]="ClearSearch",e[e.RegisterItem=5]="RegisterItem",e[e.UnregisterItem=6]="UnregisterItem"}(ke||(ke={}));var De=((Ie={})[ke.CloseMenu]=function(e){return e.menuState===Oe.Closed?e:a({},e,{activeItemIndex:null,menuState:Oe.Closed})},Ie[ke.OpenMenu]=function(e){return e.menuState===Oe.Open?e:a({},e,{menuState:Oe.Open})},Ie[ke.GoToItem]=function(e,n){var t=he(n,{resolveItems:function(){return e.items},resolveActiveIndex:function(){return e.activeItemIndex},resolveId:function(e){return e.id},resolveDisabled:function(e){return e.dataRef.current.disabled}});return""===e.searchQuery&&e.activeItemIndex===t?e:a({},e,{searchQuery:"",activeItemIndex:t})},Ie[ke.Search]=function(e,n){var t=e.searchQuery+n.value,r=e.items.findIndex((function(e){var n;return(null==(n=e.dataRef.current.textValue)?void 0:n.startsWith(t))&&!e.dataRef.current.disabled}));return a({},e,-1===r||r===e.activeItemIndex?{searchQuery:t}:{searchQuery:t,activeItemIndex:r})},Ie[ke.ClearSearch]=function(e){return""===e.searchQuery?e:a({},e,{searchQuery:""})},Ie[ke.RegisterItem]=function(e,n){return a({},e,{items:[].concat(e.items,[{id:n.id,dataRef:n.dataRef}])})},Ie[ke.UnregisterItem]=function(e,n){var t=e.items.slice(),r=null!==e.activeItemIndex?t[e.activeItemIndex]:null,o=t.findIndex((function(e){return e.id===n.id}));return-1!==o&&t.splice(o,1),a({},e,{items:t,activeItemIndex:o===e.activeItemIndex||null===r?null:t.indexOf(r)})},Ie),Le=o.createContext(null);function Fe(e){var n=o.useContext(Le);if(null===n){var t=new Error("<"+e+" /> is missing a parent <"+Ne.name+" /> component.");throw Error.captureStackTrace&&Error.captureStackTrace(t,Fe),t}return n}function Me(e,n){return d(n.type,De,e,n)}Le.displayName="MenuContext";var Ae=o.Fragment;function Ne(e){var n=o.useReducer(Me,{menuState:Oe.Closed,buttonRef:o.createRef(),itemsRef:o.createRef(),items:[],searchQuery:"",activeItemIndex:null}),t=n[0],r=t.menuState,i=t.itemsRef,a=t.buttonRef,c=n[1];o.useEffect((function(){function e(e){var n,t,o,u=e.target;r===Oe.Open&&((null==(n=a.current)?void 0:n.contains(u))||(null==(t=i.current)?void 0:t.contains(u))||(c({type:ke.CloseMenu}),R(u,O.Loose)||(e.preventDefault(),null==(o=a.current)||o.focus())))}return window.addEventListener("mousedown",e),function(){return window.removeEventListener("mousedown",e)}}),[r,a,i,c]);var l=o.useMemo((function(){return{open:r===Oe.Open}}),[r]);return u.createElement(Le.Provider,{value:n},f(e,l,Ae))}var je,Ue,Ge,He=v((function e(n,t){var u,i=Fe([Ne.name,e.name].join(".")),c=i[0],l=i[1],s=b(c.buttonRef,t),d="headlessui-menu-button-"+w(),p=be(),v=o.useCallback((function(e){switch(e.key){case r.Space:case r.Enter:case r.ArrowDown:e.preventDefault(),e.stopPropagation(),l({type:ke.OpenMenu}),p.nextFrame((function(){return l({type:ke.GoToItem,focus:ce.First})}));break;case r.ArrowUp:e.preventDefault(),e.stopPropagation(),l({type:ke.OpenMenu}),p.nextFrame((function(){return l({type:ke.GoToItem,focus:ce.Last})}))}}),[l,p]),m=o.useCallback((function(e){if(y(e.currentTarget))return e.preventDefault();n.disabled||(c.menuState===Oe.Open?(l({type:ke.CloseMenu}),p.nextFrame((function(){var e;return null==(e=c.buttonRef.current)?void 0:e.focus({preventScroll:!0})}))):(e.preventDefault(),e.stopPropagation(),l({type:ke.OpenMenu})))}),[l,p,c,n.disabled]),h=o.useMemo((function(){return{open:c.menuState===Oe.Open}}),[c]);return f(a({},n,{ref:s,id:d,type:"button","aria-haspopup":!0,"aria-controls":null==(u=c.itemsRef.current)?void 0:u.id,"aria-expanded":c.menuState===Oe.Open||void 0,onKeyDown:v,onClick:m}),h,"button")})),Be=n.RenderStrategy|n.Static,Ve=v((function e(n,t){var u,i,c=Fe([Ne.name,e.name].join(".")),l=c[0],s=c[1],d=b(l.itemsRef,t),p="headlessui-menu-items-"+w(),v=be();o.useEffect((function(){var e=l.itemsRef.current;e&&l.menuState===Oe.Open&&e!==document.activeElement&&e.focus({preventScroll:!0})}),[l.menuState,l.itemsRef]),h((function(){var e=l.itemsRef.current;if(e&&l.menuState===Oe.Open)for(var n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:function(e){return"menuitem"===e.getAttribute("role")?NodeFilter.FILTER_REJECT:e.hasAttribute("role")?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT}});n.nextNode();)n.currentNode.setAttribute("role","none")}),[l.menuState,l.itemsRef]);var m=o.useCallback((function(e){switch(v.dispose(),e.key){case r.Space:if(""!==l.searchQuery)return e.preventDefault(),e.stopPropagation(),s({type:ke.Search,value:e.key});case r.Enter:var n;e.preventDefault(),e.stopPropagation(),s({type:ke.CloseMenu}),null!==l.activeItemIndex&&(null==(n=document.getElementById(l.items[l.activeItemIndex].id))||n.click()),me().nextFrame((function(){var e;return null==(e=l.buttonRef.current)?void 0:e.focus({preventScroll:!0})}));break;case r.ArrowDown:return e.preventDefault(),e.stopPropagation(),s({type:ke.GoToItem,focus:ce.Next});case r.ArrowUp:return e.preventDefault(),e.stopPropagation(),s({type:ke.GoToItem,focus:ce.Previous});case r.Home:case r.PageUp:return e.preventDefault(),e.stopPropagation(),s({type:ke.GoToItem,focus:ce.First});case r.End:case r.PageDown:return e.preventDefault(),e.stopPropagation(),s({type:ke.GoToItem,focus:ce.Last});case r.Escape:e.preventDefault(),e.stopPropagation(),s({type:ke.CloseMenu}),me().nextFrame((function(){var e;return null==(e=l.buttonRef.current)?void 0:e.focus({preventScroll:!0})}));break;case r.Tab:e.preventDefault(),e.stopPropagation();break;default:1===e.key.length&&(s({type:ke.Search,value:e.key}),v.setTimeout((function(){return s({type:ke.ClearSearch})}),350))}}),[s,v,l]),y=o.useMemo((function(){return{open:l.menuState===Oe.Open}}),[l]);return f(a({},n,{"aria-activedescendant":null===l.activeItemIndex||null==(u=l.items[l.activeItemIndex])?void 0:u.id,"aria-labelledby":null==(i=l.buttonRef.current)?void 0:i.id,id:p,onKeyDown:m,role:"menu",tabIndex:0,ref:d}),y,"div",Be,l.menuState===Oe.Open)})),Qe=o.Fragment;Ne.Button=He,Ne.Items=Ve,Ne.Item=function e(n){var t=n.disabled,r=void 0!==t&&t,u=n.onClick,i=c(n,["disabled","onClick"]),l=Fe([Ne.name,e.name].join(".")),s=l[0],d=l[1],p="headlessui-menu-item-"+w(),v=null!==s.activeItemIndex&&s.items[s.activeItemIndex].id===p;h((function(){if(s.menuState===Oe.Open&&v){var e=me();return e.nextFrame((function(){var e;return null==(e=document.getElementById(p))||null==e.scrollIntoView?void 0:e.scrollIntoView({block:"nearest"})})),e.dispose}}),[p,v,s.menuState]);var m=o.useRef({disabled:r});h((function(){m.current.disabled=r}),[m,r]),h((function(){var e,n;m.current.textValue=null==(e=document.getElementById(p))||null==(n=e.textContent)?void 0:n.toLowerCase()}),[m,p]),h((function(){return d({type:ke.RegisterItem,id:p,dataRef:m}),function(){return d({type:ke.UnregisterItem,id:p})}}),[m,p]);var b=o.useCallback((function(e){return r?e.preventDefault():(d({type:ke.CloseMenu}),me().nextFrame((function(){var e;return null==(e=s.buttonRef.current)?void 0:e.focus({preventScroll:!0})})),u?u(e):void 0)}),[d,s.buttonRef,r,u]),y=o.useCallback((function(){if(r)return d({type:ke.GoToItem,focus:ce.Nothing});d({type:ke.GoToItem,focus:ce.Specific,id:p})}),[r,p,d]),S=o.useCallback((function(){r||v||d({type:ke.GoToItem,focus:ce.Specific,id:p})}),[r,v,p,d]),g=o.useCallback((function(){r||v&&d({type:ke.GoToItem,focus:ce.Nothing})}),[r,v,d]),E=o.useMemo((function(){return{active:v,disabled:r}}),[v,r]);return f(a({},i,{id:p,role:"menuitem",tabIndex:-1,"aria-disabled":!0===r||void 0,onClick:b,onFocus:y,onPointerMove:S,onMouseMove:S,onPointerLeave:g,onMouseLeave:g}),E,Qe)},function(e){e[e.Open=0]="Open",e[e.Closed=1]="Closed"}(Ue||(Ue={})),function(e){e[e.TogglePopover=0]="TogglePopover",e[e.ClosePopover=1]="ClosePopover",e[e.SetButton=2]="SetButton",e[e.SetButtonId=3]="SetButtonId",e[e.SetPanel=4]="SetPanel",e[e.SetPanelId=5]="SetPanelId"}(Ge||(Ge={}));var Ke=((je={})[Ge.TogglePopover]=function(e){var n;return a({},e,{popoverState:d(e.popoverState,(n={},n[Ue.Open]=Ue.Closed,n[Ue.Closed]=Ue.Open,n))})},je[Ge.ClosePopover]=function(e){return e.popoverState===Ue.Closed?e:a({},e,{popoverState:Ue.Closed})},je[Ge.SetButton]=function(e,n){return e.button===n.button?e:a({},e,{button:n.button})},je[Ge.SetButtonId]=function(e,n){return e.buttonId===n.buttonId?e:a({},e,{buttonId:n.buttonId})},je[Ge.SetPanel]=function(e,n){return e.panel===n.panel?e:a({},e,{panel:n.panel})},je[Ge.SetPanelId]=function(e,n){return e.panelId===n.panelId?e:a({},e,{panelId:n.panelId})},je),We=o.createContext(null);function qe(e){var n=o.useContext(We);if(null===n){var t=new Error("<"+e+" /> is missing a parent <"+$e.name+" /> component.");throw Error.captureStackTrace&&Error.captureStackTrace(t,qe),t}return n}We.displayName="PopoverContext";var ze=o.createContext(null);function Ye(){return o.useContext(ze)}ze.displayName="PopoverGroupContext";var _e=o.createContext(null);function Je(e,n){return d(n.type,Ke,e,n)}function $e(e){var n="headlessui-popover-button-"+w(),t="headlessui-popover-panel-"+w(),r=o.useReducer(Je,{popoverState:Ue.Closed,linkedPanel:!1,button:null,buttonId:n,panel:null,panelId:t}),i=r[0],a=i.popoverState,c=i.button,l=i.panel,s=r[1];o.useEffect((function(){return s({type:Ge.SetButtonId,buttonId:n})}),[n,s]),o.useEffect((function(){return s({type:Ge.SetPanelId,panelId:t})}),[t,s]);var d=o.useMemo((function(){return{buttonId:n,panelId:t,close:function(){return s({type:Ge.ClosePopover})}}}),[n,t,s]),p=Ye(),v=null==p?void 0:p.registerPopover,m=o.useCallback((function(){var e;return null!=(e=null==p?void 0:p.isFocusWithinPopoverGroup())?e:(null==c?void 0:c.contains(document.activeElement))||(null==l?void 0:l.contains(document.activeElement))}),[p,c,l]);o.useEffect((function(){return null==v?void 0:v(d)}),[v,d]),o.useEffect((function(){if(a===Ue.Open)return window.addEventListener("focus",e,!0),function(){return window.removeEventListener("focus",e,!0)};function e(){m()||c&&l&&s({type:Ge.ClosePopover})}}),[a,m,p,c,l,s]),o.useEffect((function(){function e(e){var n=e.target;a===Ue.Open&&((null==c?void 0:c.contains(n))||(null==l?void 0:l.contains(n))||(s({type:Ge.ClosePopover}),R(n,O.Loose)||(e.preventDefault(),null==c||c.focus())))}return window.addEventListener("mousedown",e),function(){return window.removeEventListener("mousedown",e)}}),[a,c,l,s]);var b=o.useMemo((function(){return{open:a===Ue.Open}}),[a]);return u.createElement(We.Provider,{value:r},f(e,b,"div"))}_e.displayName="PopoverPanelContext";var Xe=v((function e(n,t){var u=qe([$e.name,e.name].join(".")),i=u[0],c=u[1],l=o.useRef(null),s=Ye(),d=null==s?void 0:s.closeOthers,p=o.useContext(_e),v=null!==p&&p===i.panelId,m=b(l,t,v?null:function(e){return c({type:Ge.SetButton,button:e})}),h=o.useRef(null),S=o.useRef("undefined"==typeof window?null:document.activeElement);o.useEffect((function(){function e(){S.current=h.current,h.current=document.activeElement}return window.addEventListener("focus",e,!0),function(){return window.removeEventListener("focus",e,!0)}}),[S,h]);var g=o.useCallback((function(e){var n;if(v){if(i.popoverState===Ue.Closed)return;switch(e.key){case r.Space:case r.Enter:e.preventDefault(),e.stopPropagation(),c({type:Ge.ClosePopover}),null==(n=i.button)||n.focus()}}else switch(e.key){case r.Space:case r.Enter:e.preventDefault(),e.stopPropagation(),i.popoverState===Ue.Closed&&(null==d||d(i.buttonId)),c({type:Ge.TogglePopover});break;case r.Escape:if(i.popoverState!==Ue.Open)return null==d?void 0:d(i.buttonId);if(!l.current)return;if(!l.current.contains(document.activeElement))return;c({type:Ge.ClosePopover});break;case r.Tab:if(i.popoverState!==Ue.Open)return;if(!i.panel)return;if(!i.button)return;if(e.shiftKey){var t;if(!S.current)return;if(null==(t=i.button)?void 0:t.contains(S.current))return;if(i.panel.contains(S.current))return;var o=P(),u=o.indexOf(S.current);if(o.indexOf(i.button)>u)return;e.preventDefault(),e.stopPropagation(),D(i.panel,x.Last)}else e.preventDefault(),e.stopPropagation(),D(i.panel,x.First)}}),[c,i.popoverState,i.buttonId,i.button,i.panel,l,d,v]),E=o.useCallback((function(e){var n;if(!v&&i.popoverState===Ue.Open&&i.panel&&i.button)switch(e.key){case r.Tab:if(!S.current)return;if(null==(n=i.button)?void 0:n.contains(S.current))return;if(i.panel.contains(S.current))return;var t=P(),o=t.indexOf(S.current);if(t.indexOf(i.button)>o)return;e.preventDefault(),e.stopPropagation(),D(i.panel,x.Last)}}),[i.popoverState,i.panel,i.button,v]),w=o.useCallback((function(e){var t;y(e.currentTarget)||n.disabled||(v?(c({type:Ge.ClosePopover}),null==(t=i.button)||t.focus()):(i.popoverState===Ue.Closed&&(null==d||d(i.buttonId)),c({type:Ge.TogglePopover})))}),[c,i.button,i.popoverState,i.buttonId,n.disabled,d,v]),C=o.useMemo((function(){return{open:i.popoverState===Ue.Open}}),[i]);return f(a({},n,v?{type:"button",onKeyDown:g,onClick:w}:{ref:m,id:i.buttonId,type:"button","aria-expanded":i.popoverState===Ue.Open||void 0,"aria-controls":i.panel?i.panelId:void 0,onKeyDown:g,onKeyUp:E,onClick:w}),C,"button")})),Ze=v((function e(n,t){var r=qe([$e.name,e.name].join(".")),u=r[0].popoverState,i=r[1],c=b(t),l="headlessui-popover-overlay-"+w(),s=o.useCallback((function(e){if(y(e.currentTarget))return e.preventDefault();i({type:Ge.ClosePopover})}),[i]),d=o.useMemo((function(){return{open:u===Ue.Open}}),[u]);return f(a({},n,{ref:c,id:l,"aria-hidden":!0,onClick:s}),d,"div")})),en=n.RenderStrategy|n.Static,nn=v((function e(n,t){var i=n.focus,l=void 0!==i&&i,s=c(n,["focus"]),d=qe([$e.name,e.name].join(".")),p=d[0],v=d[1],m=o.useRef(null),y=b(m,t,(function(e){v({type:Ge.SetPanel,panel:e})})),h=o.useCallback((function(e){var n;switch(e.key){case r.Escape:if(p.popoverState!==Ue.Open)return;if(!m.current)return;if(!m.current.contains(document.activeElement))return;e.preventDefault(),v({type:Ge.ClosePopover}),null==(n=p.button)||n.focus()}}),[p,m,v]);o.useEffect((function(){return function(){return v({type:Ge.SetPanel,panel:null})}}),[v]),o.useEffect((function(){var e;p.popoverState!==Ue.Closed||null!=(e=n.unmount)&&!e||v({type:Ge.SetPanel,panel:null})}),[p.popoverState,n.unmount,v]),o.useEffect((function(){if(l&&p.popoverState===Ue.Open&&m.current){var e=document.activeElement;m.current.contains(e)||D(m.current,x.First)}}),[l,m,p.popoverState]),o.useEffect((function(){if(p.popoverState===Ue.Open&&m.current)return window.addEventListener("keydown",e),function(){return window.removeEventListener("keydown",e)};function e(e){if(e.key===r.Tab&&document.activeElement&&m.current&&m.current.contains(document.activeElement)){e.preventDefault();var n,t=D(m.current,e.shiftKey?x.Previous:x.Next);if(t===C.Underflow)return null==(n=p.button)?void 0:n.focus();if(t===C.Overflow){if(!p.button)return;var o=P(),u=o.indexOf(p.button);D(o.splice(u+1).filter((function(e){var n;return!(null==(n=m.current)?void 0:n.contains(e))})),x.First)===C.Error&&D(document.body,x.First)}}}}),[l,m,p.popoverState,p.button]),o.useEffect((function(){if(l&&p.popoverState===Ue.Open&&m.current)return window.addEventListener("focus",e,!0),function(){return window.removeEventListener("focus",e,!0)};function e(){var e;(null==(e=m.current)?void 0:e.contains(document.activeElement))||v({type:Ge.ClosePopover})}}),[l,p.popoverState,v]);var S=o.useMemo((function(){return{open:p.popoverState===Ue.Open}}),[p]);return u.createElement(_e.Provider,{value:p.panelId},f(a({},s,{ref:y,id:p.panelId,onKeyDown:h}),S,"div",en,p.popoverState===Ue.Open))}));$e.Button=Xe,$e.Overlay=Ze,$e.Panel=nn,$e.Group=function(e){var n=o.useRef(null),t=o.useState([]),r=t[0],i=t[1],c=o.useCallback((function(e){i((function(n){var t=n.indexOf(e);if(-1!==t){var r=n.slice();return r.splice(t,1),r}return n}))}),[i]),l=o.useCallback((function(e){return i((function(n){return[].concat(n,[e])})),function(){return c(e)}}),[i,c]),d=o.useCallback((function(){var e,t=document.activeElement;return!!(null==(e=n.current)?void 0:e.contains(t))||r.some((function(e){var n,r;return(null==(n=document.getElementById(e.buttonId))?void 0:n.contains(t))||(null==(r=document.getElementById(e.panelId))?void 0:r.contains(t))}))}),[n,r]),p=o.useCallback((function(e){for(var n,t=s(r);!(n=t()).done;){var o=n.value;o.buttonId!==e&&o.close()}}),[r]),v=o.useMemo((function(){return{registerPopover:l,unregisterPopover:c,isFocusWithinPopoverGroup:d,closeOthers:p}}),[l,c,d,p]),m=o.useMemo((function(){return{}}),[]);return u.createElement(ze.Provider,{value:v},f(a({},e,{ref:n}),m,"div"))};var tn=o.createContext(null);function rn(e){var n=o.useContext(tn);if(null===n){var t=new Error("<"+e+" /> is missing a parent <Switch.Group /> component.");throw Error.captureStackTrace&&Error.captureStackTrace(t,rn),t}return n}tn.displayName="GroupContext";var on,un=o.Fragment;function an(e){var n,t,u=e.checked,i=e.onChange,l=c(e,["checked","onChange"]),s="headlessui-switch-"+w(),d=o.useContext(tn),p=o.useCallback((function(){return i(!u)}),[i,u]),v=o.useCallback((function(e){if(y(e.currentTarget))return e.preventDefault();e.preventDefault(),p()}),[p]),m=o.useCallback((function(e){e.key!==r.Tab&&e.preventDefault(),e.key===r.Space&&p()}),[p]),b=o.useCallback((function(e){return e.preventDefault()}),[]),h=o.useMemo((function(){return{checked:u}}),[u]),S={id:s,ref:null===d?void 0:d.setSwitch,role:"switch",tabIndex:0,"aria-checked":u,"aria-labelledby":null==d||null==(n=d.label)?void 0:n.id,"aria-describedby":null==d||null==(t=d.description)?void 0:t.id,onClick:v,onKeyUp:m,onKeyPress:b};return"button"===l.as&&Object.assign(S,{type:"button"}),f(a({},l,S),h,"button")}function cn(){var e=o.useRef(!0);return o.useEffect((function(){e.current=!1}),[]),e.current}function ln(e){for(var n,t=arguments.length,r=new Array(t>1?t-1:0),o=1;o<t;o++)r[o-1]=arguments[o];e&&r.length>0&&(n=e.classList).add.apply(n,r)}function sn(e){for(var n,t=arguments.length,r=new Array(t>1?t-1:0),o=1;o<t;o++)r[o-1]=arguments[o];e&&r.length>0&&(n=e.classList).remove.apply(n,r)}function dn(e,n,t,r,o){var u=me(),i=void 0!==o?function(e){var n={called:!1};return function(){if(!n.called)return n.called=!0,e.apply(void 0,arguments)}}(o):function(){};return ln.apply(void 0,[e].concat(n,t)),u.nextFrame((function(){sn.apply(void 0,[e].concat(t)),ln.apply(void 0,[e].concat(r)),u.add(function(e,n){var t=me();if(!e)return t.dispose;var r=getComputedStyle(e),o=[r.transitionDuration,r.transitionDelay].map((function(e){var n=e.split(",").filter(Boolean).map((function(e){return e.includes("ms")?parseFloat(e):1e3*parseFloat(e)})).sort((function(e,n){return n-e}))[0];return void 0===n?0:n})),u=o[0];return 0!==u?t.setTimeout((function(){n(on.Finished)}),u+o[1]):n(on.Finished),t.add((function(){return n(on.Cancelled)})),t.dispose}(e,(function(t){return sn.apply(void 0,[e].concat(r,n)),i(t)})))})),u.add((function(){return sn.apply(void 0,[e].concat(n,t,r))})),u.add((function(){return i(on.Cancelled)})),u.dispose}function fn(e){return void 0===e&&(e=""),o.useMemo((function(){return e.split(" ").filter((function(e){return e.trim().length>1}))}),[e])}an.Group=function(e){var n=o.useState(null),t=n[0],r=n[1],i=o.useState(null),a=i[0],c=i[1],l=o.useState(null),s=l[0],d=l[1],p=o.useMemo((function(){return{switch:t,setSwitch:r,label:a,setLabel:c,description:s,setDescription:d}}),[t,r,a,c,s,d]);return u.createElement(tn.Provider,{value:p},f(e,{},un))},an.Label=function e(n){var t=rn([an.name,e.name].join(".")),r="headlessui-switch-label-"+w(),u=o.useCallback((function(){t.switch&&(t.switch.click(),t.switch.focus({preventScroll:!0}))}),[t.switch]);return f(a({},n,{ref:t.setLabel,id:r,onClick:u}),{},"label")},an.Description=function e(n){var t=rn([an.name,e.name].join(".")),r="headlessui-switch-description-"+w();return f(a({},n,{ref:t.setDescription,id:r}),{},"p")},function(e){e.Finished="finished",e.Cancelled="cancelled"}(on||(on={}));var pn,vn=o.createContext(null);vn.displayName="TransitionContext",function(e){e.Visible="visible",e.Hidden="hidden"}(pn||(pn={}));var mn=o.createContext(null);function bn(e){return"children"in e?bn(e.children):e.current.filter((function(e){return e.state===pn.Visible})).length>0}function yn(e){var n=o.useRef(e),r=o.useRef([]),u=function(){var e=o.useRef(!0);return o.useEffect((function(){return function(){e.current=!1}}),[]),e}();o.useEffect((function(){n.current=e}),[e]);var i=o.useCallback((function(e,o){var i;void 0===o&&(o=t.Hidden);var a=r.current.findIndex((function(n){return n.id===e}));-1!==a&&(d(o,((i={})[t.Unmount]=function(){r.current.splice(a,1)},i[t.Hidden]=function(){r.current[a].state=pn.Hidden},i)),!bn(r)&&u.current&&(null==n.current||n.current()))}),[n,u,r]),a=o.useCallback((function(e){var n=r.current.find((function(n){return n.id===e}));return n?n.state!==pn.Visible&&(n.state=pn.Visible):r.current.push({id:e,state:pn.Visible}),function(){return i(e,t.Unmount)}}),[r,i]);return o.useMemo((function(){return{children:r,register:a,unregister:i}}),[a,i,r])}function hn(){}mn.displayName="NestingContext";var Sn=["beforeEnter","afterEnter","beforeLeave","afterLeave"];function gn(e){for(var n,t={},r=s(Sn);!(n=r()).done;){var o,u=n.value;t[u]=null!=(o=e[u])?o:hn}return t}var En=n.RenderStrategy;function wn(e){var n=e.beforeEnter,r=e.afterEnter,i=e.beforeLeave,l=e.afterLeave,s=e.enter,p=e.enterFrom,v=e.enterTo,m=e.leave,b=e.leaveFrom,y=e.leaveTo,S=c(e,["beforeEnter","afterEnter","beforeLeave","afterLeave","enter","enterFrom","enterTo","leave","leaveFrom","leaveTo"]),g=o.useRef(null),E=o.useState(pn.Visible),x=E[0],C=E[1],I=S.unmount?t.Unmount:t.Hidden,O=function(){var e=o.useContext(vn);if(null===e)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition />.");return e}(),k=O.show,P=O.appear,R=function(){var e=o.useContext(mn);if(null===e)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition />.");return e}(),T=R.register,D=R.unregister,L=cn(),F=w(),M=o.useRef(!1),A=yn((function(){M.current||(C(pn.Hidden),D(F),V.current.afterLeave())}));h((function(){if(F)return T(F)}),[T,F]),h((function(){var e;I===t.Hidden&&F&&(k&&x!==pn.Visible?C(pn.Visible):d(x,((e={})[pn.Hidden]=function(){return D(F)},e[pn.Visible]=function(){return T(F)},e)))}),[x,F,T,D,k,I]);var N=fn(s),j=fn(p),U=fn(v),G=fn(m),H=fn(b),B=fn(y),V=function(e){var n=o.useRef(gn(e));return o.useEffect((function(){n.current=gn(e)}),[e]),n}({beforeEnter:n,afterEnter:r,beforeLeave:i,afterLeave:l});o.useEffect((function(){if(x===pn.Visible&&null===g.current)throw new Error("Did you forget to passthrough the `ref` to the actual DOM node?")}),[g,x]);var Q=L&&!P;return h((function(){var e=g.current;if(e&&!Q)return M.current=!0,k&&V.current.beforeEnter(),k||V.current.beforeLeave(),k?dn(e,N,j,U,(function(e){M.current=!1,e===on.Finished&&V.current.afterEnter()})):dn(e,G,H,B,(function(e){M.current=!1,e===on.Finished&&(bn(A)||(C(pn.Hidden),D(F),V.current.afterLeave()))}))}),[V,F,M,D,A,g,Q,k,N,j,U,G,H,B]),u.createElement(mn.Provider,{value:A},f(a({},S,{ref:g}),{},"div",En,x===pn.Visible))}function xn(e){var n=e.show,t=e.appear,r=void 0!==t&&t,i=e.unmount,l=c(e,["show","appear","unmount"]);if(![!0,!1].includes(n))throw new Error("A <Transition /> is used but it is missing a `show={true | false}` prop.");var s=o.useState(n?pn.Visible:pn.Hidden),d=s[0],p=s[1],v=yn((function(){p(pn.Hidden)})),m=cn(),b=o.useMemo((function(){return{show:n,appear:r||!m}}),[n,r,m]);o.useEffect((function(){n?p(pn.Visible):bn(v)||p(pn.Hidden)}),[n,v]);var y={unmount:i};return u.createElement(mn.Provider,{value:v},u.createElement(vn.Provider,{value:b},f(a({},y,{as:o.Fragment,children:u.createElement(wn,Object.assign({},y,l))}),{},o.Fragment,En,d===pn.Visible)))}xn.Child=wn,exports.Dialog=ne,exports.Disclosure=ae,exports.FocusTrap=function(e){var n=o.useRef(new Set),t=e.initialFocus,r=c(e,["initialFocus"]);return F(n,!0,{initialFocus:t}),f(a({},r,{ref:function(e){e&&n.current.add(e)}}),{},"div")},exports.Listbox=Ce,exports.Menu=Ne,exports.Popover=$e,exports.Portal=q,exports.Switch=an,exports.Transition=xn; | ||
//# sourceMappingURL=headlessui.cjs.production.min.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","react","react-dom"],n):n((e=e||self).headlessui={},e.React,e.reactDom)}(this,(function(e,n,t){"use strict";var r,o,u,i="default"in n?n.default:n;function a(){return(a=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)}function c(e,n){if(null==e)return{};var t,r,o={},u=Object.keys(e);for(r=0;r<u.length;r++)n.indexOf(t=u[r])>=0||(o[t]=e[t]);return o}function l(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function s(e,n){var t;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(t=function(e,n){if(e){if("string"==typeof e)return l(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?l(e,void 0):void 0}}(e))||n&&e&&"number"==typeof e.length){t&&(e=t);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(t=e[Symbol.iterator]()).next.bind(t)}function d(e,n){if(e in n){for(var t=n[e],r=arguments.length,o=new Array(r>2?r-2:0),u=2;u<r;u++)o[u-2]=arguments[u];return"function"==typeof t?t.apply(void 0,o):t}var i=new Error('Tried to handle "'+e+'" but there is no handler defined. Only defined handlers are: '+Object.keys(n).map((function(e){return'"'+e+'"'})).join(", ")+".");throw Error.captureStackTrace&&Error.captureStackTrace(i,d),i}function f(e,n,t,u,i){if(void 0===i&&(i=!0),i)return p(e,n,t);var l=null!=u?u:r.None;if(l&r.Static){var s=e.static,f=void 0!==s&&s,v=c(e,["static"]);if(f)return p(v,n,t)}if(l&r.RenderStrategy){var m,b=e.unmount,y=void 0===b||b,h=c(e,["unmount"]);return d(y?o.Unmount:o.Hidden,((m={})[o.Unmount]=function(){return null},m[o.Hidden]=function(){return p(a({},h,{hidden:!0,style:{display:"none"}}),n,t)},m))}return p(e,n,t)}function p(e,t,r){var o,u=m(e,["unmount","static"]),i=u.as,a=void 0===i?r:i,l=u.children,d=u.refName,f=void 0===d?"ref":d,v=c(u,["as","children","refName"]),b=void 0!==e.ref?((o={})[f]=e.ref,o):{},y="function"==typeof l?l(t):l;if(v.className&&"function"==typeof v.className&&(v.className=v.className(t)),a===n.Fragment&&Object.keys(v).length>0){if(Array.isArray(y)&&y.length>1){var h=new Error("You should only render 1 child");throw Error.captureStackTrace&&Error.captureStackTrace(h,p),h}if(!n.isValidElement(y)){var S=new Error('You should render an element as a child. Did you forget the as="..." prop?');throw Error.captureStackTrace&&Error.captureStackTrace(S,p),S}return n.cloneElement(y,Object.assign({},function(e,n,t){for(var r,o=Object.assign({},e),u=function(){var t,u=r.value;void 0!==e[u]&&void 0!==n[u]&&Object.assign(o,((t={})[u]=function(t){t.defaultPrevented||e[u](t),t.defaultPrevented||n[u](t)},t))},i=s(["onClick"]);!(r=i()).done;)u();return o}(function(e){var n=Object.assign({},e);for(var t in n)void 0===n[t]&&delete n[t];return n}(m(v,["ref"])),y.props),b))}return n.createElement(a,Object.assign({},m(v,["ref"]),a!==n.Fragment&&b),y)}function v(e){var t;return Object.assign(n.forwardRef(e),{displayName:null!=(t=e.displayName)?t:e.name})}function m(e,n){void 0===n&&(n=[]);for(var t,r=Object.assign({},e),o=s(n);!(t=o()).done;){var u=t.value;u in r&&delete r[u]}return r}function b(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var o=n.useRef(t);return n.useEffect((function(){o.current=t}),[t]),n.useCallback((function(e){for(var n,t=s(o.current);!(n=t()).done;){var r=n.value;null!=r&&("function"==typeof r?r(e):r.current=e)}}),[o])}function y(e){for(var n,t,r=e.parentElement,o=null;r&&!(r instanceof HTMLFieldSetElement);)r instanceof HTMLLegendElement&&(o=r),r=r.parentElement;var u=null!=(n=""===(null==(t=r)?void 0:t.getAttribute("disabled")))&&n;return(!u||!function(e){if(!e)return!1;for(var n=e.previousElementSibling;null!==n;){if(n instanceof HTMLLegendElement)return!1;n=n.previousElementSibling}return!0}(o))&&u}!function(e){e[e.None=0]="None",e[e.RenderStrategy=1]="RenderStrategy",e[e.Static=2]="Static"}(r||(r={})),function(e){e[e.Unmount=0]="Unmount",e[e.Hidden=1]="Hidden"}(o||(o={})),function(e){e.Space=" ",e.Enter="Enter",e.Escape="Escape",e.Backspace="Backspace",e.ArrowUp="ArrowUp",e.ArrowDown="ArrowDown",e.Home="Home",e.End="End",e.PageUp="PageUp",e.PageDown="PageDown",e.Tab="Tab"}(u||(u={}));var h="undefined"!=typeof window?n.useLayoutEffect:n.useEffect,S={serverHandoffComplete:!1},g=0;function E(){return++g}function w(){var e=n.useState(S.serverHandoffComplete?E:null),t=e[0],r=e[1];return h((function(){null===t&&r(E())}),[t]),n.useEffect((function(){!1===S.serverHandoffComplete&&(S.serverHandoffComplete=!0)}),[]),null!=t?""+t:void 0}var C,I,x,O,k=["[contentEditable=true]","[tabindex]","a[href]","area[href]","button:not([disabled])","iframe","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].map((function(e){return e+":not([tabindex='-1'])"})).join(",");function P(e){return void 0===e&&(e=document.body),null==e?[]:Array.from(e.querySelectorAll(k))}function R(e,n){var t;return void 0===n&&(n=O.Strict),e!==document.body&&d(n,((t={})[O.Strict]=function(){return e.matches(k)},t[O.Loose]=function(){for(var n=e;null!==n;){if(n.matches(k))return!0;n=n.parentElement}return!1},t))}function T(e){null==e||e.focus({preventScroll:!0})}function D(e,n){var t=Array.isArray(e)?e:P(e),r=document.activeElement,o=function(){if(n&(C.First|C.Next))return x.Next;if(n&(C.Previous|C.Last))return x.Previous;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")}(),u=function(){if(n&C.First)return 0;if(n&C.Previous)return Math.max(0,t.indexOf(r))-1;if(n&C.Next)return Math.max(0,t.indexOf(r))+1;if(n&C.Last)return t.length-1;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")}(),i=n&C.NoScroll?{preventScroll:!0}:{},a=0,c=t.length,l=void 0;do{var s;if(a>=c||a+c<=0)return I.Error;var d=u+a;if(n&C.WrapAround)d=(d+c)%c;else{if(d<0)return I.Underflow;if(d>=c)return I.Overflow}null==(s=l=t[d])||s.focus(i),a+=o}while(l!==document.activeElement);return I.Success}function L(e,n){for(var t,r=s(e);!(t=r()).done;)if(t.value.contains(n))return!0;return!1}function F(e,t,r){void 0===t&&(t=!0),void 0===r&&(r={});var o=n.useRef("undefined"!=typeof window?document.activeElement:null),i=n.useRef(null),a=n.useRef(!1);h((function(){var n,u;if(t&&1===e.current.size){a.current=!0;var c,l=document.activeElement;if(null==(n=r.initialFocus)?void 0:n.current){if((null==(c=r.initialFocus)?void 0:c.current)===l)return}else if(L(e.current,l))return;if(o.current=l,null==(u=r.initialFocus)?void 0:u.current)T(r.initialFocus.current);else{for(var d,f=!1,p=s(e.current);!(d=p()).done;)if(D(d.value,C.First)===I.Success){f=!0;break}if(!f)throw new Error("There are no focusable elements inside the <FocusTrap />")}return i.current=document.activeElement,function(){a.current=!1,T(o.current),o.current=null,i.current=null}}}),[t,e,a,r.initialFocus]),h((function(){if(t)return window.addEventListener("keydown",n),function(){return window.removeEventListener("keydown",n)};function n(n){if(n.key===u.Tab&&document.activeElement&&1===e.current.size){n.preventDefault();for(var t,r=s(e.current);!(t=r()).done;)if(D(t.value,(n.shiftKey?C.Previous:C.Next)|C.WrapAround)===I.Success){i.current=document.activeElement;break}}}}),[t,e]),h((function(){if(t&&1===e.current.size)return window.addEventListener("focus",n,!0),function(){return window.removeEventListener("focus",n,!0)};function n(n){var t=i.current;if(t&&a.current){var r=n.target;r&&r instanceof HTMLElement?L(e.current,r)?(i.current=r,T(r)):(n.preventDefault(),n.stopPropagation(),T(t)):T(i.current)}}}),[t,a,e])}!function(e){e[e.First=1]="First",e[e.Previous=2]="Previous",e[e.Next=4]="Next",e[e.Last=8]="Last",e[e.WrapAround=16]="WrapAround",e[e.NoScroll=32]="NoScroll"}(C||(C={})),function(e){e[e.Error=0]="Error",e[e.Overflow=1]="Overflow",e[e.Success=2]="Success",e[e.Underflow=3]="Underflow"}(I||(I={})),function(e){e[e.Previous=-1]="Previous",e[e.Next=1]="Next"}(x||(x={})),function(e){e[e.Strict=0]="Strict",e[e.Loose=1]="Loose"}(O||(O={}));var M=new Set,A=new Map;function N(e){e.setAttribute("aria-hidden","true"),e.inert=!0}function j(e){var n=A.get(e);n&&(null===n["aria-hidden"]?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",n["aria-hidden"]),e.inert=n.inert)}var U,G=n.createContext((function(){}));function H(){return n.useContext(G)}function B(e){var t=e.children,r=e.onUpdate,o=H(),u=n.useCallback((function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];null==r||r.apply(void 0,n),o.apply(void 0,n)}),[o,r]);return i.createElement(G.Provider,{value:u},t)}G.displayName="StackContext",function(e){e[e.AddElement=0]="AddElement",e[e.RemoveElement=1]="RemoveElement"}(U||(U={}));var V,Q,K,W=n.Fragment;function q(e){var r=n.useState((function(){if("undefined"==typeof window)return null;var e=document.getElementById("headlessui-portal-root");if(e)return e;var n=document.createElement("div");return n.setAttribute("id","headlessui-portal-root"),document.body.appendChild(n)}))[0],o=n.useState((function(){return"undefined"==typeof window?null:document.createElement("div")}))[0];return function(e){var n=H();h((function(){if(e)return n(U.AddElement,e),function(){return n(U.RemoveElement,e)}}),[e])}(o),h((function(){if(r&&o)return console.log({target:r,element:o}),r.appendChild(o),function(){r&&o&&(console.log({target:r,element:o}),r.removeChild(o),r.childNodes.length<=0&&document.body.removeChild(r))}}),[r,o]),i.createElement(B,null,r&&o?t.createPortal(f(e,{},W),o):null)}!function(e){e[e.Open=0]="Open",e[e.Closed=1]="Closed"}(Q||(Q={})),function(e){e[e.SetTitleId=0]="SetTitleId",e[e.SetDescriptionId=1]="SetDescriptionId"}(K||(K={}));var z=((V={})[K.SetTitleId]=function(e,n){return e.titleId===n.id?e:a({},e,{titleId:n.id})},V[K.SetDescriptionId]=function(e,n){return e.descriptionId===n.id?e:a({},e,{descriptionId:n.id})},V),Y=n.createContext(null);function _(e){var t=n.useContext(Y);if(null===t){var r=new Error("<"+e+" /> is missing a parent <"+ne.displayName+" /> component.");throw Error.captureStackTrace&&Error.captureStackTrace(r,_),r}return t}function J(e,n){return d(n.type,z,e,n)}Y.displayName="DialogContext";var $,X,Z,ee=r.RenderStrategy|r.Static,ne=Object.assign(v((function(e,t){var r=e.open,o=e.onClose,l=e.initialFocus,p=c(e,["open","onClose","initialFocus"]),v=n.useRef(new Set),m=n.useRef(null),y=b(m,t),S=e.hasOwnProperty("open"),g=e.hasOwnProperty("onClose");if(!S&&!g)throw new Error("You have to provide an `open` and an `onClose` prop to the `Dialog` component.");if(!S)throw new Error("You provided an `onClose` prop to the `Dialog`, but forgot an `open` prop.");if(!g)throw new Error("You provided an `open` prop to the `Dialog`, but forgot an `onClose` prop.");if("boolean"!=typeof r)throw new Error("You provided an `open` prop to the `Dialog`, but the value is not a boolean. Received: "+r);if("function"!=typeof o)throw new Error("You provided an `onClose` prop to the `Dialog`, but the value is not a function. Received: "+o);var E=r?Q.Open:Q.Closed,C=n.useReducer(J,{titleId:null,descriptionId:null}),I=C[0],x=C[1],O=n.useCallback((function(){return o(!1)}),[o]),k=n.useCallback((function(e){return x({type:K.SetTitleId,id:e})}),[x]),P=n.useCallback((function(e){return x({type:K.SetDescriptionId,id:e})}),[x]);n.useEffect((function(){function e(e){E===Q.Open&&1===v.current.size&&(L(v.current,e.target)||O())}return window.addEventListener("mousedown",e),function(){return window.removeEventListener("mousedown",e)}}),[E,v,O]),n.useEffect((function(){function e(e){e.key===u.Escape&&E===Q.Open&&(v.current.size>1||O())}return window.addEventListener("keydown",e),function(){return window.removeEventListener("keydown",e)}}),[O,E]),n.useEffect((function(){if(E===Q.Open){var e=document.documentElement.style.overflow,n=document.documentElement.style.paddingRight,t=window.innerWidth-document.documentElement.clientWidth;return document.documentElement.style.overflow="hidden",document.documentElement.style.paddingRight=t+"px",function(){document.documentElement.style.overflow=e,document.documentElement.style.paddingRight=n}}}),[E]),n.useEffect((function(){if(E===Q.Open&&m.current){var e=new IntersectionObserver((function(e){for(var n,t=s(e);!(n=t()).done;){var r=n.value;0===r.boundingClientRect.x&&0===r.boundingClientRect.y&&0===r.boundingClientRect.width&&0===r.boundingClientRect.height&&O()}}));return e.observe(m.current),function(){return e.disconnect()}}}),[E,m,O]);var R=!!e.static||E===Q.Open;F(v,R,{initialFocus:l}),function(e,n){void 0===n&&(n=!0),h((function(){if(n&&e.current){var t=e.current;M.add(t);for(var r,o=s(A.keys());!(r=o()).done;){var u=r.value;u.contains(t)&&(j(u),A.delete(u))}return document.querySelectorAll("body > *").forEach((function(e){if(e instanceof HTMLElement){for(var n,t=s(M);!(n=t()).done;)if(e.contains(n.value))return;1===M.size&&(A.set(e,{"aria-hidden":e.getAttribute("aria-hidden"),inert:e.inert}),N(e))}})),function(){if(M.delete(t),M.size>0)document.querySelectorAll("body > *").forEach((function(e){if(e instanceof HTMLElement&&!A.has(e)){for(var n,t=s(M);!(n=t()).done;)if(e.contains(n.value))return;A.set(e,{"aria-hidden":e.getAttribute("aria-hidden"),inert:e.inert}),N(e)}}));else for(var e,n=s(A.keys());!(e=n()).done;){var r=e.value;j(r),A.delete(r)}}}}),[n])}(m,R);var T="headlessui-dialog-"+w(),D=n.useMemo((function(){return[{dialogState:E,close:O,setTitleId:k,setDescriptionId:P},I]}),[E,I,O,k,P]),G=n.useMemo((function(){return{open:E===Q.Open}}),[E]);return i.createElement(B,{onUpdate:function(e,n){var t;return d(e,((t={})[U.AddElement]=function(){v.current.add(n)},t[U.RemoveElement]=function(){v.current.delete(n)},t))}},i.createElement(q,null,i.createElement(Y.Provider,{value:D},f(a({},p,{ref:y,id:T,role:"dialog","aria-modal":E===Q.Open||void 0,"aria-labelledby":I.titleId,"aria-describedby":I.descriptionId}),G,"div",ee,E===Q.Open))))})),{Overlay:v((function e(t,r){var o=_([ne.displayName,e.name].join("."))[0],u=o.dialogState,i=o.close,c=b(r),l="headlessui-dialog-overlay-"+w(),s=n.useCallback((function(e){if(y(e.currentTarget))return e.preventDefault();i()}),[i]),d=n.useMemo((function(){return{open:u===Q.Open}}),[u]);return f(a({},t,{ref:c,id:l,"aria-hidden":!0,onClick:s}),d,"div")})),Title:function e(t){var r=_([ne.displayName,e.name].join("."))[0],o=r.dialogState,u=r.setTitleId,i="headlessui-dialog-title-"+w();n.useEffect((function(){return u(i),function(){return u(null)}}),[i,u]);var c=n.useMemo((function(){return{open:o===Q.Open}}),[o]);return f(a({},t,{id:i}),c,"h2")},Description:function e(t){var r=_([ne.displayName,e.name].join("."))[0],o=r.dialogState,u=r.setDescriptionId,i="headlessui-dialog-description-"+w();n.useEffect((function(){return u(i),function(){return u(null)}}),[i,u]);var c=n.useMemo((function(){return{open:o===Q.Open}}),[o]);return f(a({},t,{id:i}),c,"p")}});!function(e){e[e.Open=0]="Open",e[e.Closed=1]="Closed"}(X||(X={})),function(e){e[e.ToggleDisclosure=0]="ToggleDisclosure",e[e.SetButtonId=1]="SetButtonId",e[e.SetPanelId=2]="SetPanelId",e[e.LinkPanel=3]="LinkPanel",e[e.UnlinkPanel=4]="UnlinkPanel"}(Z||(Z={}));var te=(($={})[Z.ToggleDisclosure]=function(e){var n;return a({},e,{disclosureState:d(e.disclosureState,(n={},n[X.Open]=X.Closed,n[X.Closed]=X.Open,n))})},$[Z.LinkPanel]=function(e){return!0===e.linkedPanel?e:a({},e,{linkedPanel:!0})},$[Z.UnlinkPanel]=function(e){return!1===e.linkedPanel?e:a({},e,{linkedPanel:!1})},$[Z.SetButtonId]=function(e,n){return e.buttonId===n.buttonId?e:a({},e,{buttonId:n.buttonId})},$[Z.SetPanelId]=function(e,n){return e.panelId===n.panelId?e:a({},e,{panelId:n.panelId})},$),re=n.createContext(null);function oe(e){var t=n.useContext(re);if(null===t){var r=new Error("<"+e+" /> is missing a parent <"+ae.name+" /> component.");throw Error.captureStackTrace&&Error.captureStackTrace(r,oe),r}return t}function ue(e,n){return d(n.type,te,e,n)}re.displayName="DisclosureContext";var ie=n.Fragment;function ae(e){var t="headlessui-disclosure-button-"+w(),r="headlessui-disclosure-panel-"+w(),o=n.useReducer(ue,{disclosureState:X.Closed,linkedPanel:!1,buttonId:t,panelId:r}),u=o[0].disclosureState,a=o[1];n.useEffect((function(){return a({type:Z.SetButtonId,buttonId:t})}),[t,a]),n.useEffect((function(){return a({type:Z.SetPanelId,panelId:r})}),[r,a]);var c=n.useMemo((function(){return{open:u===X.Open}}),[u]);return i.createElement(re.Provider,{value:o},f(e,c,ie))}var ce,le,se,de,fe=v((function e(t,r){var o=oe([ae.name,e.name].join(".")),i=o[0],c=o[1],l=b(r),s=n.useCallback((function(e){switch(e.key){case u.Space:case u.Enter:e.preventDefault(),c({type:Z.ToggleDisclosure})}}),[c]),d=n.useCallback((function(e){y(e.currentTarget)||t.disabled||c({type:Z.ToggleDisclosure})}),[c,t.disabled]),p=n.useMemo((function(){return{open:i.disclosureState===X.Open}}),[i]);return f(a({},t,{ref:l,id:i.buttonId,type:"button","aria-expanded":i.disclosureState===X.Open||void 0,"aria-controls":i.linkedPanel?i.panelId:void 0,onKeyDown:s,onClick:d}),p,"button")})),pe=r.RenderStrategy|r.Static,ve=v((function e(t,r){var o=oe([ae.name,e.name].join(".")),u=o[0],i=o[1],c=b(r,(function(){u.linkedPanel||i({type:Z.LinkPanel})}));n.useEffect((function(){return function(){return i({type:Z.UnlinkPanel})}}),[i]),n.useEffect((function(){var e;u.disclosureState!==X.Closed||null!=(e=t.unmount)&&!e||i({type:Z.UnlinkPanel})}),[u.disclosureState,t.unmount,i]);var l=n.useMemo((function(){return{open:u.disclosureState===X.Open}}),[u]);return f(a({},t,{ref:c,id:u.panelId}),l,"div",pe,u.disclosureState===X.Open)}));function me(){var e=[],n={requestAnimationFrame:function(e){function n(){return e.apply(this,arguments)}return n.toString=function(){return e.toString()},n}((function(){var e=requestAnimationFrame.apply(void 0,arguments);n.add((function(){return cancelAnimationFrame(e)}))})),nextFrame:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];n.requestAnimationFrame((function(){n.requestAnimationFrame.apply(n,t)}))},setTimeout:function(e){function n(){return e.apply(this,arguments)}return n.toString=function(){return e.toString()},n}((function(){var e=setTimeout.apply(void 0,arguments);n.add((function(){return clearTimeout(e)}))})),add:function(n){e.push(n)},dispose:function(){for(var n,t=s(e.splice(0));!(n=t()).done;)(0,n.value)()}};return n}function be(){var e=n.useState(me)[0];return n.useEffect((function(){return function(){return e.dispose()}}),[e]),e}function ye(e,t){var r=n.useState(e),o=r[0],u=r[1],i=n.useRef(e);return h((function(){i.current=e}),[e]),h((function(){return u(i.current)}),[i,u].concat(t)),o}function he(e,n){var t=n.resolveItems();if(t.length<=0)return null;var r=n.resolveActiveIndex(),o=null!=r?r:-1,u=function(){switch(e.focus){case ce.First:return t.findIndex((function(e){return!n.resolveDisabled(e)}));case ce.Previous:var r=t.slice().reverse().findIndex((function(e,t,r){return!(-1!==o&&r.length-t-1>=o||n.resolveDisabled(e))}));return-1===r?r:t.length-1-r;case ce.Next:return t.findIndex((function(e,t){return!(t<=o||n.resolveDisabled(e))}));case ce.Last:var u=t.slice().reverse().findIndex((function(e){return!n.resolveDisabled(e)}));return-1===u?u:t.length-1-u;case ce.Specific:return t.findIndex((function(t){return n.resolveId(t)===e.id}));case ce.Nothing:return null;default:!function(e){throw new Error("Unexpected object: "+e)}(e)}}();return-1===u?r:u}ae.Button=fe,ae.Panel=ve,function(e){e[e.First=0]="First",e[e.Previous=1]="Previous",e[e.Next=2]="Next",e[e.Last=3]="Last",e[e.Specific=4]="Specific",e[e.Nothing=5]="Nothing"}(ce||(ce={})),function(e){e[e.Open=0]="Open",e[e.Closed=1]="Closed"}(se||(se={})),function(e){e[e.OpenListbox=0]="OpenListbox",e[e.CloseListbox=1]="CloseListbox",e[e.SetDisabled=2]="SetDisabled",e[e.GoToOption=3]="GoToOption",e[e.Search=4]="Search",e[e.ClearSearch=5]="ClearSearch",e[e.RegisterOption=6]="RegisterOption",e[e.UnregisterOption=7]="UnregisterOption"}(de||(de={}));var Se=((le={})[de.CloseListbox]=function(e){return e.disabled||e.listboxState===se.Closed?e:a({},e,{activeOptionIndex:null,listboxState:se.Closed})},le[de.OpenListbox]=function(e){return e.disabled||e.listboxState===se.Open?e:a({},e,{listboxState:se.Open})},le[de.SetDisabled]=function(e,n){return e.disabled===n.disabled?e:a({},e,{disabled:n.disabled})},le[de.GoToOption]=function(e,n){if(e.disabled)return e;if(e.listboxState===se.Closed)return e;var t=he(n,{resolveItems:function(){return e.options},resolveActiveIndex:function(){return e.activeOptionIndex},resolveId:function(e){return e.id},resolveDisabled:function(e){return e.dataRef.current.disabled}});return""===e.searchQuery&&e.activeOptionIndex===t?e:a({},e,{searchQuery:"",activeOptionIndex:t})},le[de.Search]=function(e,n){if(e.disabled)return e;if(e.listboxState===se.Closed)return e;var t=e.searchQuery+n.value,r=e.options.findIndex((function(e){var n;return!e.dataRef.current.disabled&&(null==(n=e.dataRef.current.textValue)?void 0:n.startsWith(t))}));return a({},e,-1===r||r===e.activeOptionIndex?{searchQuery:t}:{searchQuery:t,activeOptionIndex:r})},le[de.ClearSearch]=function(e){return e.disabled||e.listboxState===se.Closed||""===e.searchQuery?e:a({},e,{searchQuery:""})},le[de.RegisterOption]=function(e,n){return a({},e,{options:[].concat(e.options,[{id:n.id,dataRef:n.dataRef}])})},le[de.UnregisterOption]=function(e,n){var t=e.options.slice(),r=null!==e.activeOptionIndex?t[e.activeOptionIndex]:null,o=t.findIndex((function(e){return e.id===n.id}));return-1!==o&&t.splice(o,1),a({},e,{options:t,activeOptionIndex:o===e.activeOptionIndex||null===r?null:t.indexOf(r)})},le),ge=n.createContext(null);function Ee(e){var t=n.useContext(ge);if(null===t){var r=new Error("<"+e+" /> is missing a parent <"+Ie.name+" /> component.");throw Error.captureStackTrace&&Error.captureStackTrace(r,Ee),r}return t}function we(e,n){return d(n.type,Se,e,n)}ge.displayName="ListboxContext";var Ce=n.Fragment;function Ie(e){var t=e.value,r=e.onChange,o=e.disabled,u=void 0!==o&&o,a=c(e,["value","onChange","disabled"]),l=n.useReducer(we,{listboxState:se.Closed,propsRef:{current:{value:t,onChange:r}},labelRef:n.createRef(),buttonRef:n.createRef(),optionsRef:n.createRef(),disabled:u,options:[],searchQuery:"",activeOptionIndex:null}),s=l[0],d=s.listboxState,p=s.propsRef,v=s.optionsRef,m=s.buttonRef,b=l[1];h((function(){p.current.value=t}),[t,p]),h((function(){p.current.onChange=r}),[r,p]),h((function(){return b({type:de.SetDisabled,disabled:u})}),[u]),n.useEffect((function(){function e(e){var n,t,r,o=e.target;d===se.Open&&((null==(n=m.current)?void 0:n.contains(o))||(null==(t=v.current)?void 0:t.contains(o))||(b({type:de.CloseListbox}),R(o,O.Loose)||(e.preventDefault(),null==(r=m.current)||r.focus())))}return window.addEventListener("mousedown",e),function(){return window.removeEventListener("mousedown",e)}}),[d,m,v,b]);var y=n.useMemo((function(){return{open:d===se.Open,disabled:u}}),[d,u]);return i.createElement(ge.Provider,{value:l},f(a,y,Ce))}var xe,Oe,ke,Pe=v((function e(t,r){var o,i=Ee([Ie.name,e.name].join(".")),c=i[0],l=i[1],s=b(c.buttonRef,r),d="headlessui-listbox-button-"+w(),p=be(),v=n.useCallback((function(e){switch(e.key){case u.Space:case u.Enter:case u.ArrowDown:e.preventDefault(),l({type:de.OpenListbox}),p.nextFrame((function(){c.propsRef.current.value||l({type:de.GoToOption,focus:ce.First})}));break;case u.ArrowUp:e.preventDefault(),l({type:de.OpenListbox}),p.nextFrame((function(){c.propsRef.current.value||l({type:de.GoToOption,focus:ce.Last})}))}}),[l,c,p]),m=n.useCallback((function(e){if(y(e.currentTarget))return e.preventDefault();c.listboxState===se.Open?(l({type:de.CloseListbox}),p.nextFrame((function(){var e;return null==(e=c.buttonRef.current)?void 0:e.focus({preventScroll:!0})}))):(e.preventDefault(),l({type:de.OpenListbox}))}),[l,p,c]),h=ye((function(){if(c.labelRef.current)return[c.labelRef.current.id,d].join(" ")}),[c.labelRef.current,d]),S=n.useMemo((function(){return{open:c.listboxState===se.Open,disabled:c.disabled}}),[c]);return f(a({},t,{ref:s,id:d,type:"button","aria-haspopup":!0,"aria-controls":null==(o=c.optionsRef.current)?void 0:o.id,"aria-expanded":c.listboxState===se.Open||void 0,"aria-labelledby":h,disabled:c.disabled,onKeyDown:v,onClick:m}),S,"button")})),Re=r.RenderStrategy|r.Static,Te=v((function e(t,r){var o,i=Ee([Ie.name,e.name].join(".")),c=i[0],l=i[1],s=b(c.optionsRef,r),d="headlessui-listbox-options-"+w(),p=be(),v=be();h((function(){var e=c.optionsRef.current;e&&c.listboxState===se.Open&&e!==document.activeElement&&e.focus({preventScroll:!0})}),[c.listboxState,c.optionsRef]);var m=n.useCallback((function(e){switch(v.dispose(),e.key){case u.Space:if(""!==c.searchQuery)return e.preventDefault(),e.stopPropagation(),l({type:de.Search,value:e.key});case u.Enter:e.preventDefault(),e.stopPropagation(),l({type:de.CloseListbox}),null!==c.activeOptionIndex&&c.propsRef.current.onChange(c.options[c.activeOptionIndex].dataRef.current.value),me().nextFrame((function(){var e;return null==(e=c.buttonRef.current)?void 0:e.focus({preventScroll:!0})}));break;case u.ArrowDown:return e.preventDefault(),e.stopPropagation(),l({type:de.GoToOption,focus:ce.Next});case u.ArrowUp:return e.preventDefault(),e.stopPropagation(),l({type:de.GoToOption,focus:ce.Previous});case u.Home:case u.PageUp:return e.preventDefault(),e.stopPropagation(),l({type:de.GoToOption,focus:ce.First});case u.End:case u.PageDown:return e.preventDefault(),e.stopPropagation(),l({type:de.GoToOption,focus:ce.Last});case u.Escape:return e.preventDefault(),e.stopPropagation(),l({type:de.CloseListbox}),p.nextFrame((function(){var e;return null==(e=c.buttonRef.current)?void 0:e.focus({preventScroll:!0})}));case u.Tab:e.preventDefault(),e.stopPropagation();break;default:1===e.key.length&&(l({type:de.Search,value:e.key}),v.setTimeout((function(){return l({type:de.ClearSearch})}),350))}}),[p,l,v,c]),y=ye((function(){var e,n,t;return null!=(e=null==(n=c.labelRef.current)?void 0:n.id)?e:null==(t=c.buttonRef.current)?void 0:t.id}),[c.labelRef.current,c.buttonRef.current]),S=n.useMemo((function(){return{open:c.listboxState===se.Open}}),[c]);return f(a({},t,{"aria-activedescendant":null===c.activeOptionIndex||null==(o=c.options[c.activeOptionIndex])?void 0:o.id,"aria-labelledby":y,id:d,onKeyDown:m,role:"listbox",tabIndex:0,ref:s}),S,"ul",Re,c.listboxState===se.Open)}));Ie.Button=Pe,Ie.Label=function e(t){var r=Ee([Ie.name,e.name].join("."))[0],o="headlessui-listbox-label-"+w(),u=n.useCallback((function(){var e;return null==(e=r.buttonRef.current)?void 0:e.focus({preventScroll:!0})}),[r.buttonRef]),i=n.useMemo((function(){return{open:r.listboxState===se.Open,disabled:r.disabled}}),[r]);return f(a({},t,{ref:r.labelRef,id:o,onClick:u}),i,"label")},Ie.Options=Te,Ie.Option=function e(t){var r=t.disabled,o=void 0!==r&&r,u=t.value,i=c(t,["disabled","value"]),l=Ee([Ie.name,e.name].join(".")),s=l[0],d=l[1],p="headlessui-listbox-option-"+w(),v=null!==s.activeOptionIndex&&s.options[s.activeOptionIndex].id===p,m=s.propsRef.current.value===u,b=n.useRef({disabled:o,value:u});h((function(){b.current.disabled=o}),[b,o]),h((function(){b.current.value=u}),[b,u]),h((function(){var e,n;b.current.textValue=null==(e=document.getElementById(p))||null==(n=e.textContent)?void 0:n.toLowerCase()}),[b,p]);var y=n.useCallback((function(){return s.propsRef.current.onChange(u)}),[s.propsRef,u]);h((function(){return d({type:de.RegisterOption,id:p,dataRef:b}),function(){return d({type:de.UnregisterOption,id:p})}}),[b,p]),h((function(){var e;s.listboxState===se.Open&&m&&(d({type:de.GoToOption,focus:ce.Specific,id:p}),null==(e=document.getElementById(p))||null==e.focus||e.focus())}),[s.listboxState]),h((function(){if(s.listboxState===se.Open&&v){var e=me();return e.nextFrame((function(){var e;return null==(e=document.getElementById(p))||null==e.scrollIntoView?void 0:e.scrollIntoView({block:"nearest"})})),e.dispose}}),[p,v,s.listboxState]);var S=n.useCallback((function(e){if(o)return e.preventDefault();y(),d({type:de.CloseListbox}),me().nextFrame((function(){var e;return null==(e=s.buttonRef.current)?void 0:e.focus({preventScroll:!0})}))}),[d,s.buttonRef,o,y]),g=n.useCallback((function(){if(o)return d({type:de.GoToOption,focus:ce.Nothing});d({type:de.GoToOption,focus:ce.Specific,id:p})}),[o,p,d]),E=n.useCallback((function(){o||v||d({type:de.GoToOption,focus:ce.Specific,id:p})}),[o,v,p,d]),C=n.useCallback((function(){o||v&&d({type:de.GoToOption,focus:ce.Nothing})}),[o,v,d]),I=n.useMemo((function(){return{active:v,selected:m,disabled:o}}),[v,m,o]);return f(a({},i,{id:p,role:"option",tabIndex:-1,"aria-disabled":!0===o||void 0,"aria-selected":!0===m||void 0,onClick:S,onFocus:g,onPointerMove:E,onMouseMove:E,onPointerLeave:C,onMouseLeave:C}),I,"li")},function(e){e[e.Open=0]="Open",e[e.Closed=1]="Closed"}(Oe||(Oe={})),function(e){e[e.OpenMenu=0]="OpenMenu",e[e.CloseMenu=1]="CloseMenu",e[e.GoToItem=2]="GoToItem",e[e.Search=3]="Search",e[e.ClearSearch=4]="ClearSearch",e[e.RegisterItem=5]="RegisterItem",e[e.UnregisterItem=6]="UnregisterItem"}(ke||(ke={}));var De=((xe={})[ke.CloseMenu]=function(e){return e.menuState===Oe.Closed?e:a({},e,{activeItemIndex:null,menuState:Oe.Closed})},xe[ke.OpenMenu]=function(e){return e.menuState===Oe.Open?e:a({},e,{menuState:Oe.Open})},xe[ke.GoToItem]=function(e,n){var t=he(n,{resolveItems:function(){return e.items},resolveActiveIndex:function(){return e.activeItemIndex},resolveId:function(e){return e.id},resolveDisabled:function(e){return e.dataRef.current.disabled}});return""===e.searchQuery&&e.activeItemIndex===t?e:a({},e,{searchQuery:"",activeItemIndex:t})},xe[ke.Search]=function(e,n){var t=e.searchQuery+n.value,r=e.items.findIndex((function(e){var n;return(null==(n=e.dataRef.current.textValue)?void 0:n.startsWith(t))&&!e.dataRef.current.disabled}));return a({},e,-1===r||r===e.activeItemIndex?{searchQuery:t}:{searchQuery:t,activeItemIndex:r})},xe[ke.ClearSearch]=function(e){return""===e.searchQuery?e:a({},e,{searchQuery:""})},xe[ke.RegisterItem]=function(e,n){return a({},e,{items:[].concat(e.items,[{id:n.id,dataRef:n.dataRef}])})},xe[ke.UnregisterItem]=function(e,n){var t=e.items.slice(),r=null!==e.activeItemIndex?t[e.activeItemIndex]:null,o=t.findIndex((function(e){return e.id===n.id}));return-1!==o&&t.splice(o,1),a({},e,{items:t,activeItemIndex:o===e.activeItemIndex||null===r?null:t.indexOf(r)})},xe),Le=n.createContext(null);function Fe(e){var t=n.useContext(Le);if(null===t){var r=new Error("<"+e+" /> is missing a parent <"+Ne.name+" /> component.");throw Error.captureStackTrace&&Error.captureStackTrace(r,Fe),r}return t}function Me(e,n){return d(n.type,De,e,n)}Le.displayName="MenuContext";var Ae=n.Fragment;function Ne(e){var t=n.useReducer(Me,{menuState:Oe.Closed,buttonRef:n.createRef(),itemsRef:n.createRef(),items:[],searchQuery:"",activeItemIndex:null}),r=t[0],o=r.menuState,u=r.itemsRef,a=r.buttonRef,c=t[1];n.useEffect((function(){function e(e){var n,t,r,i=e.target;o===Oe.Open&&((null==(n=a.current)?void 0:n.contains(i))||(null==(t=u.current)?void 0:t.contains(i))||(c({type:ke.CloseMenu}),R(i,O.Loose)||(e.preventDefault(),null==(r=a.current)||r.focus())))}return window.addEventListener("mousedown",e),function(){return window.removeEventListener("mousedown",e)}}),[o,a,u,c]);var l=n.useMemo((function(){return{open:o===Oe.Open}}),[o]);return i.createElement(Le.Provider,{value:t},f(e,l,Ae))}var je,Ue,Ge,He=v((function e(t,r){var o,i=Fe([Ne.name,e.name].join(".")),c=i[0],l=i[1],s=b(c.buttonRef,r),d="headlessui-menu-button-"+w(),p=be(),v=n.useCallback((function(e){switch(e.key){case u.Space:case u.Enter:case u.ArrowDown:e.preventDefault(),e.stopPropagation(),l({type:ke.OpenMenu}),p.nextFrame((function(){return l({type:ke.GoToItem,focus:ce.First})}));break;case u.ArrowUp:e.preventDefault(),e.stopPropagation(),l({type:ke.OpenMenu}),p.nextFrame((function(){return l({type:ke.GoToItem,focus:ce.Last})}))}}),[l,p]),m=n.useCallback((function(e){if(y(e.currentTarget))return e.preventDefault();t.disabled||(c.menuState===Oe.Open?(l({type:ke.CloseMenu}),p.nextFrame((function(){var e;return null==(e=c.buttonRef.current)?void 0:e.focus({preventScroll:!0})}))):(e.preventDefault(),e.stopPropagation(),l({type:ke.OpenMenu})))}),[l,p,c,t.disabled]),h=n.useMemo((function(){return{open:c.menuState===Oe.Open}}),[c]);return f(a({},t,{ref:s,id:d,type:"button","aria-haspopup":!0,"aria-controls":null==(o=c.itemsRef.current)?void 0:o.id,"aria-expanded":c.menuState===Oe.Open||void 0,onKeyDown:v,onClick:m}),h,"button")})),Be=r.RenderStrategy|r.Static,Ve=v((function e(t,r){var o,i,c=Fe([Ne.name,e.name].join(".")),l=c[0],s=c[1],d=b(l.itemsRef,r),p="headlessui-menu-items-"+w(),v=be();n.useEffect((function(){var e=l.itemsRef.current;e&&l.menuState===Oe.Open&&e!==document.activeElement&&e.focus({preventScroll:!0})}),[l.menuState,l.itemsRef]),h((function(){var e=l.itemsRef.current;if(e&&l.menuState===Oe.Open)for(var n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:function(e){return"menuitem"===e.getAttribute("role")?NodeFilter.FILTER_REJECT:e.hasAttribute("role")?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT}});n.nextNode();)n.currentNode.setAttribute("role","none")}),[l.menuState,l.itemsRef]);var m=n.useCallback((function(e){switch(v.dispose(),e.key){case u.Space:if(""!==l.searchQuery)return e.preventDefault(),e.stopPropagation(),s({type:ke.Search,value:e.key});case u.Enter:var n;e.preventDefault(),e.stopPropagation(),s({type:ke.CloseMenu}),null!==l.activeItemIndex&&(null==(n=document.getElementById(l.items[l.activeItemIndex].id))||n.click()),me().nextFrame((function(){var e;return null==(e=l.buttonRef.current)?void 0:e.focus({preventScroll:!0})}));break;case u.ArrowDown:return e.preventDefault(),e.stopPropagation(),s({type:ke.GoToItem,focus:ce.Next});case u.ArrowUp:return e.preventDefault(),e.stopPropagation(),s({type:ke.GoToItem,focus:ce.Previous});case u.Home:case u.PageUp:return e.preventDefault(),e.stopPropagation(),s({type:ke.GoToItem,focus:ce.First});case u.End:case u.PageDown:return e.preventDefault(),e.stopPropagation(),s({type:ke.GoToItem,focus:ce.Last});case u.Escape:e.preventDefault(),e.stopPropagation(),s({type:ke.CloseMenu}),me().nextFrame((function(){var e;return null==(e=l.buttonRef.current)?void 0:e.focus({preventScroll:!0})}));break;case u.Tab:e.preventDefault(),e.stopPropagation();break;default:1===e.key.length&&(s({type:ke.Search,value:e.key}),v.setTimeout((function(){return s({type:ke.ClearSearch})}),350))}}),[s,v,l]),y=n.useMemo((function(){return{open:l.menuState===Oe.Open}}),[l]);return f(a({},t,{"aria-activedescendant":null===l.activeItemIndex||null==(o=l.items[l.activeItemIndex])?void 0:o.id,"aria-labelledby":null==(i=l.buttonRef.current)?void 0:i.id,id:p,onKeyDown:m,role:"menu",tabIndex:0,ref:d}),y,"div",Be,l.menuState===Oe.Open)})),Qe=n.Fragment;Ne.Button=He,Ne.Items=Ve,Ne.Item=function e(t){var r=t.disabled,o=void 0!==r&&r,u=t.onClick,i=c(t,["disabled","onClick"]),l=Fe([Ne.name,e.name].join(".")),s=l[0],d=l[1],p="headlessui-menu-item-"+w(),v=null!==s.activeItemIndex&&s.items[s.activeItemIndex].id===p;h((function(){if(s.menuState===Oe.Open&&v){var e=me();return e.nextFrame((function(){var e;return null==(e=document.getElementById(p))||null==e.scrollIntoView?void 0:e.scrollIntoView({block:"nearest"})})),e.dispose}}),[p,v,s.menuState]);var m=n.useRef({disabled:o});h((function(){m.current.disabled=o}),[m,o]),h((function(){var e,n;m.current.textValue=null==(e=document.getElementById(p))||null==(n=e.textContent)?void 0:n.toLowerCase()}),[m,p]),h((function(){return d({type:ke.RegisterItem,id:p,dataRef:m}),function(){return d({type:ke.UnregisterItem,id:p})}}),[m,p]);var b=n.useCallback((function(e){return o?e.preventDefault():(d({type:ke.CloseMenu}),me().nextFrame((function(){var e;return null==(e=s.buttonRef.current)?void 0:e.focus({preventScroll:!0})})),u?u(e):void 0)}),[d,s.buttonRef,o,u]),y=n.useCallback((function(){if(o)return d({type:ke.GoToItem,focus:ce.Nothing});d({type:ke.GoToItem,focus:ce.Specific,id:p})}),[o,p,d]),S=n.useCallback((function(){o||v||d({type:ke.GoToItem,focus:ce.Specific,id:p})}),[o,v,p,d]),g=n.useCallback((function(){o||v&&d({type:ke.GoToItem,focus:ce.Nothing})}),[o,v,d]),E=n.useMemo((function(){return{active:v,disabled:o}}),[v,o]);return f(a({},i,{id:p,role:"menuitem",tabIndex:-1,"aria-disabled":!0===o||void 0,onClick:b,onFocus:y,onPointerMove:S,onMouseMove:S,onPointerLeave:g,onMouseLeave:g}),E,Qe)},function(e){e[e.Open=0]="Open",e[e.Closed=1]="Closed"}(Ue||(Ue={})),function(e){e[e.TogglePopover=0]="TogglePopover",e[e.ClosePopover=1]="ClosePopover",e[e.SetButton=2]="SetButton",e[e.SetButtonId=3]="SetButtonId",e[e.SetPanel=4]="SetPanel",e[e.SetPanelId=5]="SetPanelId"}(Ge||(Ge={}));var Ke=((je={})[Ge.TogglePopover]=function(e){var n;return a({},e,{popoverState:d(e.popoverState,(n={},n[Ue.Open]=Ue.Closed,n[Ue.Closed]=Ue.Open,n))})},je[Ge.ClosePopover]=function(e){return e.popoverState===Ue.Closed?e:a({},e,{popoverState:Ue.Closed})},je[Ge.SetButton]=function(e,n){return e.button===n.button?e:a({},e,{button:n.button})},je[Ge.SetButtonId]=function(e,n){return e.buttonId===n.buttonId?e:a({},e,{buttonId:n.buttonId})},je[Ge.SetPanel]=function(e,n){return e.panel===n.panel?e:a({},e,{panel:n.panel})},je[Ge.SetPanelId]=function(e,n){return e.panelId===n.panelId?e:a({},e,{panelId:n.panelId})},je),We=n.createContext(null);function qe(e){var t=n.useContext(We);if(null===t){var r=new Error("<"+e+" /> is missing a parent <"+$e.name+" /> component.");throw Error.captureStackTrace&&Error.captureStackTrace(r,qe),r}return t}We.displayName="PopoverContext";var ze=n.createContext(null);function Ye(){return n.useContext(ze)}ze.displayName="PopoverGroupContext";var _e=n.createContext(null);function Je(e,n){return d(n.type,Ke,e,n)}function $e(e){var t="headlessui-popover-button-"+w(),r="headlessui-popover-panel-"+w(),o=n.useReducer(Je,{popoverState:Ue.Closed,linkedPanel:!1,button:null,buttonId:t,panel:null,panelId:r}),u=o[0],a=u.popoverState,c=u.button,l=u.panel,s=o[1];n.useEffect((function(){return s({type:Ge.SetButtonId,buttonId:t})}),[t,s]),n.useEffect((function(){return s({type:Ge.SetPanelId,panelId:r})}),[r,s]);var d=n.useMemo((function(){return{buttonId:t,panelId:r,close:function(){return s({type:Ge.ClosePopover})}}}),[t,r,s]),p=Ye(),v=null==p?void 0:p.registerPopover,m=n.useCallback((function(){var e;return null!=(e=null==p?void 0:p.isFocusWithinPopoverGroup())?e:(null==c?void 0:c.contains(document.activeElement))||(null==l?void 0:l.contains(document.activeElement))}),[p,c,l]);n.useEffect((function(){return null==v?void 0:v(d)}),[v,d]),n.useEffect((function(){if(a===Ue.Open)return window.addEventListener("focus",e,!0),function(){return window.removeEventListener("focus",e,!0)};function e(){m()||c&&l&&s({type:Ge.ClosePopover})}}),[a,m,p,c,l,s]),n.useEffect((function(){function e(e){var n=e.target;a===Ue.Open&&((null==c?void 0:c.contains(n))||(null==l?void 0:l.contains(n))||(s({type:Ge.ClosePopover}),R(n,O.Loose)||(e.preventDefault(),null==c||c.focus())))}return window.addEventListener("mousedown",e),function(){return window.removeEventListener("mousedown",e)}}),[a,c,l,s]);var b=n.useMemo((function(){return{open:a===Ue.Open}}),[a]);return i.createElement(We.Provider,{value:o},f(e,b,"div"))}_e.displayName="PopoverPanelContext";var Xe=v((function e(t,r){var o=qe([$e.name,e.name].join(".")),i=o[0],c=o[1],l=n.useRef(null),s=Ye(),d=null==s?void 0:s.closeOthers,p=n.useContext(_e),v=null!==p&&p===i.panelId,m=b(l,r,v?null:function(e){return c({type:Ge.SetButton,button:e})}),h=n.useRef(null),S=n.useRef("undefined"==typeof window?null:document.activeElement);n.useEffect((function(){function e(){S.current=h.current,h.current=document.activeElement}return window.addEventListener("focus",e,!0),function(){return window.removeEventListener("focus",e,!0)}}),[S,h]);var g=n.useCallback((function(e){var n;if(v){if(i.popoverState===Ue.Closed)return;switch(e.key){case u.Space:case u.Enter:e.preventDefault(),e.stopPropagation(),c({type:Ge.ClosePopover}),null==(n=i.button)||n.focus()}}else switch(e.key){case u.Space:case u.Enter:e.preventDefault(),e.stopPropagation(),i.popoverState===Ue.Closed&&(null==d||d(i.buttonId)),c({type:Ge.TogglePopover});break;case u.Escape:if(i.popoverState!==Ue.Open)return null==d?void 0:d(i.buttonId);if(!l.current)return;if(!l.current.contains(document.activeElement))return;c({type:Ge.ClosePopover});break;case u.Tab:if(i.popoverState!==Ue.Open)return;if(!i.panel)return;if(!i.button)return;if(e.shiftKey){var t;if(!S.current)return;if(null==(t=i.button)?void 0:t.contains(S.current))return;if(i.panel.contains(S.current))return;var r=P(),o=r.indexOf(S.current);if(r.indexOf(i.button)>o)return;e.preventDefault(),e.stopPropagation(),D(i.panel,C.Last)}else e.preventDefault(),e.stopPropagation(),D(i.panel,C.First)}}),[c,i.popoverState,i.buttonId,i.button,i.panel,l,d,v]),E=n.useCallback((function(e){var n;if(!v&&i.popoverState===Ue.Open&&i.panel&&i.button)switch(e.key){case u.Tab:if(!S.current)return;if(null==(n=i.button)?void 0:n.contains(S.current))return;if(i.panel.contains(S.current))return;var t=P(),r=t.indexOf(S.current);if(t.indexOf(i.button)>r)return;e.preventDefault(),e.stopPropagation(),D(i.panel,C.Last)}}),[i.popoverState,i.panel,i.button,v]),w=n.useCallback((function(e){var n;y(e.currentTarget)||t.disabled||(v?(c({type:Ge.ClosePopover}),null==(n=i.button)||n.focus()):(i.popoverState===Ue.Closed&&(null==d||d(i.buttonId)),c({type:Ge.TogglePopover})))}),[c,i.button,i.popoverState,i.buttonId,t.disabled,d,v]),I=n.useMemo((function(){return{open:i.popoverState===Ue.Open}}),[i]);return f(a({},t,v?{type:"button",onKeyDown:g,onClick:w}:{ref:m,id:i.buttonId,type:"button","aria-expanded":i.popoverState===Ue.Open||void 0,"aria-controls":i.panel?i.panelId:void 0,onKeyDown:g,onKeyUp:E,onClick:w}),I,"button")})),Ze=v((function e(t,r){var o=qe([$e.name,e.name].join(".")),u=o[0].popoverState,i=o[1],c=b(r),l="headlessui-popover-overlay-"+w(),s=n.useCallback((function(e){if(y(e.currentTarget))return e.preventDefault();i({type:Ge.ClosePopover})}),[i]),d=n.useMemo((function(){return{open:u===Ue.Open}}),[u]);return f(a({},t,{ref:c,id:l,"aria-hidden":!0,onClick:s}),d,"div")})),en=r.RenderStrategy|r.Static,nn=v((function e(t,r){var o=t.focus,l=void 0!==o&&o,s=c(t,["focus"]),d=qe([$e.name,e.name].join(".")),p=d[0],v=d[1],m=n.useRef(null),y=b(m,r,(function(e){v({type:Ge.SetPanel,panel:e})})),h=n.useCallback((function(e){var n;switch(e.key){case u.Escape:if(p.popoverState!==Ue.Open)return;if(!m.current)return;if(!m.current.contains(document.activeElement))return;e.preventDefault(),v({type:Ge.ClosePopover}),null==(n=p.button)||n.focus()}}),[p,m,v]);n.useEffect((function(){return function(){return v({type:Ge.SetPanel,panel:null})}}),[v]),n.useEffect((function(){var e;p.popoverState!==Ue.Closed||null!=(e=t.unmount)&&!e||v({type:Ge.SetPanel,panel:null})}),[p.popoverState,t.unmount,v]),n.useEffect((function(){if(l&&p.popoverState===Ue.Open&&m.current){var e=document.activeElement;m.current.contains(e)||D(m.current,C.First)}}),[l,m,p.popoverState]),n.useEffect((function(){if(p.popoverState===Ue.Open&&m.current)return window.addEventListener("keydown",e),function(){return window.removeEventListener("keydown",e)};function e(e){if(e.key===u.Tab&&document.activeElement&&m.current&&m.current.contains(document.activeElement)){e.preventDefault();var n,t=D(m.current,e.shiftKey?C.Previous:C.Next);if(t===I.Underflow)return null==(n=p.button)?void 0:n.focus();if(t===I.Overflow){if(!p.button)return;var r=P(),o=r.indexOf(p.button);D(r.splice(o+1).filter((function(e){var n;return!(null==(n=m.current)?void 0:n.contains(e))})),C.First)===I.Error&&D(document.body,C.First)}}}}),[l,m,p.popoverState,p.button]),n.useEffect((function(){if(l&&p.popoverState===Ue.Open&&m.current)return window.addEventListener("focus",e,!0),function(){return window.removeEventListener("focus",e,!0)};function e(){var e;(null==(e=m.current)?void 0:e.contains(document.activeElement))||v({type:Ge.ClosePopover})}}),[l,p.popoverState,v]);var S=n.useMemo((function(){return{open:p.popoverState===Ue.Open}}),[p]);return i.createElement(_e.Provider,{value:p.panelId},f(a({},s,{ref:y,id:p.panelId,onKeyDown:h}),S,"div",en,p.popoverState===Ue.Open))}));$e.Button=Xe,$e.Overlay=Ze,$e.Panel=nn,$e.Group=function(e){var t=n.useRef(null),r=n.useState([]),o=r[0],u=r[1],c=n.useCallback((function(e){u((function(n){var t=n.indexOf(e);if(-1!==t){var r=n.slice();return r.splice(t,1),r}return n}))}),[u]),l=n.useCallback((function(e){return u((function(n){return[].concat(n,[e])})),function(){return c(e)}}),[u,c]),d=n.useCallback((function(){var e,n=document.activeElement;return!!(null==(e=t.current)?void 0:e.contains(n))||o.some((function(e){var t,r;return(null==(t=document.getElementById(e.buttonId))?void 0:t.contains(n))||(null==(r=document.getElementById(e.panelId))?void 0:r.contains(n))}))}),[t,o]),p=n.useCallback((function(e){for(var n,t=s(o);!(n=t()).done;){var r=n.value;r.buttonId!==e&&r.close()}}),[o]),v=n.useMemo((function(){return{registerPopover:l,unregisterPopover:c,isFocusWithinPopoverGroup:d,closeOthers:p}}),[l,c,d,p]),m=n.useMemo((function(){return{}}),[]);return i.createElement(ze.Provider,{value:v},f(a({},e,{ref:t}),m,"div"))};var tn=n.createContext(null);function rn(e){var t=n.useContext(tn);if(null===t){var r=new Error("<"+e+" /> is missing a parent <Switch.Group /> component.");throw Error.captureStackTrace&&Error.captureStackTrace(r,rn),r}return t}tn.displayName="GroupContext";var on,un=n.Fragment;function an(e){var t,r,o=e.checked,i=e.onChange,l=c(e,["checked","onChange"]),s="headlessui-switch-"+w(),d=n.useContext(tn),p=n.useCallback((function(){return i(!o)}),[i,o]),v=n.useCallback((function(e){if(y(e.currentTarget))return e.preventDefault();e.preventDefault(),p()}),[p]),m=n.useCallback((function(e){e.key!==u.Tab&&e.preventDefault(),e.key===u.Space&&p()}),[p]),b=n.useCallback((function(e){return e.preventDefault()}),[]),h=n.useMemo((function(){return{checked:o}}),[o]),S={id:s,ref:null===d?void 0:d.setSwitch,role:"switch",tabIndex:0,"aria-checked":o,"aria-labelledby":null==d||null==(t=d.label)?void 0:t.id,"aria-describedby":null==d||null==(r=d.description)?void 0:r.id,onClick:v,onKeyUp:m,onKeyPress:b};return"button"===l.as&&Object.assign(S,{type:"button"}),f(a({},l,S),h,"button")}function cn(){var e=n.useRef(!0);return n.useEffect((function(){e.current=!1}),[]),e.current}function ln(e){for(var n,t=arguments.length,r=new Array(t>1?t-1:0),o=1;o<t;o++)r[o-1]=arguments[o];e&&r.length>0&&(n=e.classList).add.apply(n,r)}function sn(e){for(var n,t=arguments.length,r=new Array(t>1?t-1:0),o=1;o<t;o++)r[o-1]=arguments[o];e&&r.length>0&&(n=e.classList).remove.apply(n,r)}function dn(e,n,t,r,o){var u=me(),i=void 0!==o?function(e){var n={called:!1};return function(){if(!n.called)return n.called=!0,e.apply(void 0,arguments)}}(o):function(){};return ln.apply(void 0,[e].concat(n,t)),u.nextFrame((function(){sn.apply(void 0,[e].concat(t)),ln.apply(void 0,[e].concat(r)),u.add(function(e,n){var t=me();if(!e)return t.dispose;var r=getComputedStyle(e),o=[r.transitionDuration,r.transitionDelay].map((function(e){var n=e.split(",").filter(Boolean).map((function(e){return e.includes("ms")?parseFloat(e):1e3*parseFloat(e)})).sort((function(e,n){return n-e}))[0];return void 0===n?0:n})),u=o[0];return 0!==u?t.setTimeout((function(){n(on.Finished)}),u+o[1]):n(on.Finished),t.add((function(){return n(on.Cancelled)})),t.dispose}(e,(function(t){return sn.apply(void 0,[e].concat(r,n)),i(t)})))})),u.add((function(){return sn.apply(void 0,[e].concat(n,t,r))})),u.add((function(){return i(on.Cancelled)})),u.dispose}function fn(e){return void 0===e&&(e=""),n.useMemo((function(){return e.split(" ").filter((function(e){return e.trim().length>1}))}),[e])}an.Group=function(e){var t=n.useState(null),r=t[0],o=t[1],u=n.useState(null),a=u[0],c=u[1],l=n.useState(null),s=l[0],d=l[1],p=n.useMemo((function(){return{switch:r,setSwitch:o,label:a,setLabel:c,description:s,setDescription:d}}),[r,o,a,c,s,d]);return i.createElement(tn.Provider,{value:p},f(e,{},un))},an.Label=function e(t){var r=rn([an.name,e.name].join(".")),o="headlessui-switch-label-"+w(),u=n.useCallback((function(){r.switch&&(r.switch.click(),r.switch.focus({preventScroll:!0}))}),[r.switch]);return f(a({},t,{ref:r.setLabel,id:o,onClick:u}),{},"label")},an.Description=function e(n){var t=rn([an.name,e.name].join(".")),r="headlessui-switch-description-"+w();return f(a({},n,{ref:t.setDescription,id:r}),{},"p")},function(e){e.Finished="finished",e.Cancelled="cancelled"}(on||(on={}));var pn,vn=n.createContext(null);vn.displayName="TransitionContext",function(e){e.Visible="visible",e.Hidden="hidden"}(pn||(pn={}));var mn=n.createContext(null);function bn(e){return"children"in e?bn(e.children):e.current.filter((function(e){return e.state===pn.Visible})).length>0}function yn(e){var t=n.useRef(e),r=n.useRef([]),u=function(){var e=n.useRef(!0);return n.useEffect((function(){return function(){e.current=!1}}),[]),e}();n.useEffect((function(){t.current=e}),[e]);var i=n.useCallback((function(e,n){var i;void 0===n&&(n=o.Hidden);var a=r.current.findIndex((function(n){return n.id===e}));-1!==a&&(d(n,((i={})[o.Unmount]=function(){r.current.splice(a,1)},i[o.Hidden]=function(){r.current[a].state=pn.Hidden},i)),!bn(r)&&u.current&&(null==t.current||t.current()))}),[t,u,r]),a=n.useCallback((function(e){var n=r.current.find((function(n){return n.id===e}));return n?n.state!==pn.Visible&&(n.state=pn.Visible):r.current.push({id:e,state:pn.Visible}),function(){return i(e,o.Unmount)}}),[r,i]);return n.useMemo((function(){return{children:r,register:a,unregister:i}}),[a,i,r])}function hn(){}mn.displayName="NestingContext";var Sn=["beforeEnter","afterEnter","beforeLeave","afterLeave"];function gn(e){for(var n,t={},r=s(Sn);!(n=r()).done;){var o,u=n.value;t[u]=null!=(o=e[u])?o:hn}return t}var En=r.RenderStrategy;function wn(e){var t=e.beforeEnter,r=e.afterEnter,u=e.beforeLeave,l=e.afterLeave,s=e.enter,p=e.enterFrom,v=e.enterTo,m=e.leave,b=e.leaveFrom,y=e.leaveTo,S=c(e,["beforeEnter","afterEnter","beforeLeave","afterLeave","enter","enterFrom","enterTo","leave","leaveFrom","leaveTo"]),g=n.useRef(null),E=n.useState(pn.Visible),C=E[0],I=E[1],x=S.unmount?o.Unmount:o.Hidden,O=function(){var e=n.useContext(vn);if(null===e)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition />.");return e}(),k=O.show,P=O.appear,R=function(){var e=n.useContext(mn);if(null===e)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition />.");return e}(),T=R.register,D=R.unregister,L=cn(),F=w(),M=n.useRef(!1),A=yn((function(){M.current||(I(pn.Hidden),D(F),V.current.afterLeave())}));h((function(){if(F)return T(F)}),[T,F]),h((function(){var e;x===o.Hidden&&F&&(k&&C!==pn.Visible?I(pn.Visible):d(C,((e={})[pn.Hidden]=function(){return D(F)},e[pn.Visible]=function(){return T(F)},e)))}),[C,F,T,D,k,x]);var N=fn(s),j=fn(p),U=fn(v),G=fn(m),H=fn(b),B=fn(y),V=function(e){var t=n.useRef(gn(e));return n.useEffect((function(){t.current=gn(e)}),[e]),t}({beforeEnter:t,afterEnter:r,beforeLeave:u,afterLeave:l});n.useEffect((function(){if(C===pn.Visible&&null===g.current)throw new Error("Did you forget to passthrough the `ref` to the actual DOM node?")}),[g,C]);var Q=L&&!P;return h((function(){var e=g.current;if(e&&!Q)return M.current=!0,k&&V.current.beforeEnter(),k||V.current.beforeLeave(),k?dn(e,N,j,U,(function(e){M.current=!1,e===on.Finished&&V.current.afterEnter()})):dn(e,G,H,B,(function(e){M.current=!1,e===on.Finished&&(bn(A)||(I(pn.Hidden),D(F),V.current.afterLeave()))}))}),[V,F,M,D,A,g,Q,k,N,j,U,G,H,B]),i.createElement(mn.Provider,{value:A},f(a({},S,{ref:g}),{},"div",En,C===pn.Visible))}function Cn(e){var t=e.show,r=e.appear,o=void 0!==r&&r,u=e.unmount,l=c(e,["show","appear","unmount"]);if(![!0,!1].includes(t))throw new Error("A <Transition /> is used but it is missing a `show={true | false}` prop.");var s=n.useState(t?pn.Visible:pn.Hidden),d=s[0],p=s[1],v=yn((function(){p(pn.Hidden)})),m=cn(),b=n.useMemo((function(){return{show:t,appear:o||!m}}),[t,o,m]);n.useEffect((function(){t?p(pn.Visible):bn(v)||p(pn.Hidden)}),[t,v]);var y={unmount:u};return i.createElement(mn.Provider,{value:v},i.createElement(vn.Provider,{value:b},f(a({},y,{as:n.Fragment,children:i.createElement(wn,Object.assign({},y,l))}),{},n.Fragment,En,d===pn.Visible)))}Cn.Child=wn,e.Dialog=ne,e.Disclosure=ae,e.FocusTrap=function(e){var t=n.useRef(new Set),r=e.initialFocus,o=c(e,["initialFocus"]);return F(t,!0,{initialFocus:r}),f(a({},o,{ref:function(e){e&&t.current.add(e)}}),{},"div")},e.Listbox=Ie,e.Menu=Ne,e.Popover=$e,e.Portal=q,e.Switch=an,e.Transition=Cn,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","react","react-dom"],n):n((e=e||self).headlessui={},e.React,e.reactDom)}(this,(function(e,n,t){"use strict";var r,o,u,i="default"in n?n.default:n;function a(){return(a=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)}function c(e,n){if(null==e)return{};var t,r,o={},u=Object.keys(e);for(r=0;r<u.length;r++)n.indexOf(t=u[r])>=0||(o[t]=e[t]);return o}function l(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function s(e,n){var t;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(t=function(e,n){if(e){if("string"==typeof e)return l(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?l(e,void 0):void 0}}(e))||n&&e&&"number"==typeof e.length){t&&(e=t);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(t=e[Symbol.iterator]()).next.bind(t)}function d(e,n){if(e in n){for(var t=n[e],r=arguments.length,o=new Array(r>2?r-2:0),u=2;u<r;u++)o[u-2]=arguments[u];return"function"==typeof t?t.apply(void 0,o):t}var i=new Error('Tried to handle "'+e+'" but there is no handler defined. Only defined handlers are: '+Object.keys(n).map((function(e){return'"'+e+'"'})).join(", ")+".");throw Error.captureStackTrace&&Error.captureStackTrace(i,d),i}function f(e,n,t,u,i){if(void 0===i&&(i=!0),i)return p(e,n,t);var l=null!=u?u:r.None;if(l&r.Static){var s=e.static,f=void 0!==s&&s,v=c(e,["static"]);if(f)return p(v,n,t)}if(l&r.RenderStrategy){var m,b=e.unmount,y=void 0===b||b,h=c(e,["unmount"]);return d(y?o.Unmount:o.Hidden,((m={})[o.Unmount]=function(){return null},m[o.Hidden]=function(){return p(a({},h,{hidden:!0,style:{display:"none"}}),n,t)},m))}return p(e,n,t)}function p(e,t,r){var o,u=m(e,["unmount","static"]),i=u.as,a=void 0===i?r:i,l=u.children,d=u.refName,f=void 0===d?"ref":d,v=c(u,["as","children","refName"]),b=void 0!==e.ref?((o={})[f]=e.ref,o):{},y="function"==typeof l?l(t):l;if(v.className&&"function"==typeof v.className&&(v.className=v.className(t)),a===n.Fragment&&Object.keys(v).length>0){if(Array.isArray(y)&&y.length>1){var h=new Error("You should only render 1 child");throw Error.captureStackTrace&&Error.captureStackTrace(h,p),h}if(!n.isValidElement(y)){var S=new Error('You should render an element as a child. Did you forget the as="..." prop?');throw Error.captureStackTrace&&Error.captureStackTrace(S,p),S}return n.cloneElement(y,Object.assign({},function(e,n,t){for(var r,o=Object.assign({},e),u=function(){var t,u=r.value;void 0!==e[u]&&void 0!==n[u]&&Object.assign(o,((t={})[u]=function(t){t.defaultPrevented||e[u](t),t.defaultPrevented||n[u](t)},t))},i=s(["onClick"]);!(r=i()).done;)u();return o}(function(e){var n=Object.assign({},e);for(var t in n)void 0===n[t]&&delete n[t];return n}(m(v,["ref"])),y.props),b))}return n.createElement(a,Object.assign({},m(v,["ref"]),a!==n.Fragment&&b),y)}function v(e){var t;return Object.assign(n.forwardRef(e),{displayName:null!=(t=e.displayName)?t:e.name})}function m(e,n){void 0===n&&(n=[]);for(var t,r=Object.assign({},e),o=s(n);!(t=o()).done;){var u=t.value;u in r&&delete r[u]}return r}function b(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var o=n.useRef(t);return n.useEffect((function(){o.current=t}),[t]),n.useCallback((function(e){for(var n,t=s(o.current);!(n=t()).done;){var r=n.value;null!=r&&("function"==typeof r?r(e):r.current=e)}}),[o])}function y(e){for(var n,t,r=e.parentElement,o=null;r&&!(r instanceof HTMLFieldSetElement);)r instanceof HTMLLegendElement&&(o=r),r=r.parentElement;var u=null!=(n=""===(null==(t=r)?void 0:t.getAttribute("disabled")))&&n;return(!u||!function(e){if(!e)return!1;for(var n=e.previousElementSibling;null!==n;){if(n instanceof HTMLLegendElement)return!1;n=n.previousElementSibling}return!0}(o))&&u}!function(e){e[e.None=0]="None",e[e.RenderStrategy=1]="RenderStrategy",e[e.Static=2]="Static"}(r||(r={})),function(e){e[e.Unmount=0]="Unmount",e[e.Hidden=1]="Hidden"}(o||(o={})),function(e){e.Space=" ",e.Enter="Enter",e.Escape="Escape",e.Backspace="Backspace",e.ArrowUp="ArrowUp",e.ArrowDown="ArrowDown",e.Home="Home",e.End="End",e.PageUp="PageUp",e.PageDown="PageDown",e.Tab="Tab"}(u||(u={}));var h="undefined"!=typeof window?n.useLayoutEffect:n.useEffect,S={serverHandoffComplete:!1},g=0;function E(){return++g}function w(){var e=n.useState(S.serverHandoffComplete?E:null),t=e[0],r=e[1];return h((function(){null===t&&r(E())}),[t]),n.useEffect((function(){!1===S.serverHandoffComplete&&(S.serverHandoffComplete=!0)}),[]),null!=t?""+t:void 0}var C,I,x,O,k=["[contentEditable=true]","[tabindex]","a[href]","area[href]","button:not([disabled])","iframe","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].map((function(e){return e+":not([tabindex='-1'])"})).join(",");function P(e){return void 0===e&&(e=document.body),null==e?[]:Array.from(e.querySelectorAll(k))}function R(e,n){var t;return void 0===n&&(n=O.Strict),e!==document.body&&d(n,((t={})[O.Strict]=function(){return e.matches(k)},t[O.Loose]=function(){for(var n=e;null!==n;){if(n.matches(k))return!0;n=n.parentElement}return!1},t))}function T(e){null==e||e.focus({preventScroll:!0})}function D(e,n){var t=Array.isArray(e)?e:P(e),r=document.activeElement,o=function(){if(n&(C.First|C.Next))return x.Next;if(n&(C.Previous|C.Last))return x.Previous;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")}(),u=function(){if(n&C.First)return 0;if(n&C.Previous)return Math.max(0,t.indexOf(r))-1;if(n&C.Next)return Math.max(0,t.indexOf(r))+1;if(n&C.Last)return t.length-1;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")}(),i=n&C.NoScroll?{preventScroll:!0}:{},a=0,c=t.length,l=void 0;do{var s;if(a>=c||a+c<=0)return I.Error;var d=u+a;if(n&C.WrapAround)d=(d+c)%c;else{if(d<0)return I.Underflow;if(d>=c)return I.Overflow}null==(s=l=t[d])||s.focus(i),a+=o}while(l!==document.activeElement);return I.Success}function L(e,n){for(var t,r=s(e);!(t=r()).done;)if(t.value.contains(n))return!0;return!1}function F(e,t,r){void 0===t&&(t=!0),void 0===r&&(r={});var o=n.useRef("undefined"!=typeof window?document.activeElement:null),i=n.useRef(null),a=n.useRef(!1);h((function(){var n,u;if(t&&1===e.current.size){a.current=!0;var c,l=document.activeElement;if(null==(n=r.initialFocus)?void 0:n.current){if((null==(c=r.initialFocus)?void 0:c.current)===l)return}else if(L(e.current,l))return;if(o.current=l,null==(u=r.initialFocus)?void 0:u.current)T(r.initialFocus.current);else{for(var d,f=!1,p=s(e.current);!(d=p()).done;)if(D(d.value,C.First)===I.Success){f=!0;break}if(!f)throw new Error("There are no focusable elements inside the <FocusTrap />")}return i.current=document.activeElement,function(){a.current=!1,T(o.current),o.current=null,i.current=null}}}),[t,e,a,r.initialFocus]),h((function(){if(t)return window.addEventListener("keydown",n),function(){return window.removeEventListener("keydown",n)};function n(n){if(n.key===u.Tab&&document.activeElement&&1===e.current.size){n.preventDefault();for(var t,r=s(e.current);!(t=r()).done;)if(D(t.value,(n.shiftKey?C.Previous:C.Next)|C.WrapAround)===I.Success){i.current=document.activeElement;break}}}}),[t,e]),h((function(){if(t&&1===e.current.size)return window.addEventListener("focus",n,!0),function(){return window.removeEventListener("focus",n,!0)};function n(n){var t=i.current;if(t&&a.current){var r=n.target;r&&r instanceof HTMLElement?L(e.current,r)?(i.current=r,T(r)):(n.preventDefault(),n.stopPropagation(),T(t)):T(i.current)}}}),[t,a,e])}!function(e){e[e.First=1]="First",e[e.Previous=2]="Previous",e[e.Next=4]="Next",e[e.Last=8]="Last",e[e.WrapAround=16]="WrapAround",e[e.NoScroll=32]="NoScroll"}(C||(C={})),function(e){e[e.Error=0]="Error",e[e.Overflow=1]="Overflow",e[e.Success=2]="Success",e[e.Underflow=3]="Underflow"}(I||(I={})),function(e){e[e.Previous=-1]="Previous",e[e.Next=1]="Next"}(x||(x={})),function(e){e[e.Strict=0]="Strict",e[e.Loose=1]="Loose"}(O||(O={}));var M=new Set,A=new Map;function N(e){e.setAttribute("aria-hidden","true"),e.inert=!0}function j(e){var n=A.get(e);n&&(null===n["aria-hidden"]?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",n["aria-hidden"]),e.inert=n.inert)}var U,G=n.createContext((function(){}));function H(){return n.useContext(G)}function B(e){var t=e.children,r=e.onUpdate,o=H(),u=n.useCallback((function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];null==r||r.apply(void 0,n),o.apply(void 0,n)}),[o,r]);return i.createElement(G.Provider,{value:u},t)}G.displayName="StackContext",function(e){e[e.AddElement=0]="AddElement",e[e.RemoveElement=1]="RemoveElement"}(U||(U={}));var V,Q,K,W=n.Fragment;function q(e){var r=n.useState((function(){if("undefined"==typeof window)return null;var e=document.getElementById("headlessui-portal-root");if(e)return e;var n=document.createElement("div");return n.setAttribute("id","headlessui-portal-root"),document.body.appendChild(n)}))[0],o=n.useState((function(){return"undefined"==typeof window?null:document.createElement("div")}))[0];return function(e){var n=H();h((function(){if(e)return n(U.AddElement,e),function(){return n(U.RemoveElement,e)}}),[e])}(o),h((function(){if(r&&o)return r.appendChild(o),function(){var e;r&&o&&(r.removeChild(o),r.childNodes.length<=0&&(null==(e=r.parentElement)||e.removeChild(r)))}}),[r,o]),i.createElement(B,null,r&&o?t.createPortal(f(e,{},W),o):null)}!function(e){e[e.Open=0]="Open",e[e.Closed=1]="Closed"}(Q||(Q={})),function(e){e[e.SetTitleId=0]="SetTitleId",e[e.SetDescriptionId=1]="SetDescriptionId"}(K||(K={}));var z=((V={})[K.SetTitleId]=function(e,n){return e.titleId===n.id?e:a({},e,{titleId:n.id})},V[K.SetDescriptionId]=function(e,n){return e.descriptionId===n.id?e:a({},e,{descriptionId:n.id})},V),Y=n.createContext(null);function _(e){var t=n.useContext(Y);if(null===t){var r=new Error("<"+e+" /> is missing a parent <"+ne.displayName+" /> component.");throw Error.captureStackTrace&&Error.captureStackTrace(r,_),r}return t}function J(e,n){return d(n.type,z,e,n)}Y.displayName="DialogContext";var $,X,Z,ee=r.RenderStrategy|r.Static,ne=Object.assign(v((function(e,t){var r=e.open,o=e.onClose,l=e.initialFocus,p=c(e,["open","onClose","initialFocus"]),v=n.useRef(new Set),m=n.useRef(null),y=b(m,t),S=e.hasOwnProperty("open"),g=e.hasOwnProperty("onClose");if(!S&&!g)throw new Error("You have to provide an `open` and an `onClose` prop to the `Dialog` component.");if(!S)throw new Error("You provided an `onClose` prop to the `Dialog`, but forgot an `open` prop.");if(!g)throw new Error("You provided an `open` prop to the `Dialog`, but forgot an `onClose` prop.");if("boolean"!=typeof r)throw new Error("You provided an `open` prop to the `Dialog`, but the value is not a boolean. Received: "+r);if("function"!=typeof o)throw new Error("You provided an `onClose` prop to the `Dialog`, but the value is not a function. Received: "+o);var E=r?Q.Open:Q.Closed,C=n.useReducer(J,{titleId:null,descriptionId:null}),I=C[0],x=C[1],O=n.useCallback((function(){return o(!1)}),[o]),k=n.useCallback((function(e){return x({type:K.SetTitleId,id:e})}),[x]),P=n.useCallback((function(e){return x({type:K.SetDescriptionId,id:e})}),[x]);n.useEffect((function(){function e(e){E===Q.Open&&1===v.current.size&&(L(v.current,e.target)||O())}return window.addEventListener("mousedown",e),function(){return window.removeEventListener("mousedown",e)}}),[E,v,O]),n.useEffect((function(){function e(e){e.key===u.Escape&&E===Q.Open&&(v.current.size>1||O())}return window.addEventListener("keydown",e),function(){return window.removeEventListener("keydown",e)}}),[O,E]),n.useEffect((function(){if(E===Q.Open){var e=document.documentElement.style.overflow,n=document.documentElement.style.paddingRight,t=window.innerWidth-document.documentElement.clientWidth;return document.documentElement.style.overflow="hidden",document.documentElement.style.paddingRight=t+"px",function(){document.documentElement.style.overflow=e,document.documentElement.style.paddingRight=n}}}),[E]),n.useEffect((function(){if(E===Q.Open&&m.current){var e=new IntersectionObserver((function(e){for(var n,t=s(e);!(n=t()).done;){var r=n.value;0===r.boundingClientRect.x&&0===r.boundingClientRect.y&&0===r.boundingClientRect.width&&0===r.boundingClientRect.height&&O()}}));return e.observe(m.current),function(){return e.disconnect()}}}),[E,m,O]);var R=!!e.static||E===Q.Open;F(v,R,{initialFocus:l}),function(e,n){void 0===n&&(n=!0),h((function(){if(n&&e.current){var t=e.current;M.add(t);for(var r,o=s(A.keys());!(r=o()).done;){var u=r.value;u.contains(t)&&(j(u),A.delete(u))}return document.querySelectorAll("body > *").forEach((function(e){if(e instanceof HTMLElement){for(var n,t=s(M);!(n=t()).done;)if(e.contains(n.value))return;1===M.size&&(A.set(e,{"aria-hidden":e.getAttribute("aria-hidden"),inert:e.inert}),N(e))}})),function(){if(M.delete(t),M.size>0)document.querySelectorAll("body > *").forEach((function(e){if(e instanceof HTMLElement&&!A.has(e)){for(var n,t=s(M);!(n=t()).done;)if(e.contains(n.value))return;A.set(e,{"aria-hidden":e.getAttribute("aria-hidden"),inert:e.inert}),N(e)}}));else for(var e,n=s(A.keys());!(e=n()).done;){var r=e.value;j(r),A.delete(r)}}}}),[n])}(m,R);var T="headlessui-dialog-"+w(),D=n.useMemo((function(){return[{dialogState:E,close:O,setTitleId:k,setDescriptionId:P},I]}),[E,I,O,k,P]),G=n.useMemo((function(){return{open:E===Q.Open}}),[E]);return i.createElement(B,{onUpdate:function(e,n){var t;return d(e,((t={})[U.AddElement]=function(){v.current.add(n)},t[U.RemoveElement]=function(){v.current.delete(n)},t))}},i.createElement(q,null,i.createElement(Y.Provider,{value:D},f(a({},p,{ref:y,id:T,role:"dialog","aria-modal":E===Q.Open||void 0,"aria-labelledby":I.titleId,"aria-describedby":I.descriptionId}),G,"div",ee,E===Q.Open))))})),{Overlay:v((function e(t,r){var o=_([ne.displayName,e.name].join("."))[0],u=o.dialogState,i=o.close,c=b(r),l="headlessui-dialog-overlay-"+w(),s=n.useCallback((function(e){if(y(e.currentTarget))return e.preventDefault();i()}),[i]),d=n.useMemo((function(){return{open:u===Q.Open}}),[u]);return f(a({},t,{ref:c,id:l,"aria-hidden":!0,onClick:s}),d,"div")})),Title:function e(t){var r=_([ne.displayName,e.name].join("."))[0],o=r.dialogState,u=r.setTitleId,i="headlessui-dialog-title-"+w();n.useEffect((function(){return u(i),function(){return u(null)}}),[i,u]);var c=n.useMemo((function(){return{open:o===Q.Open}}),[o]);return f(a({},t,{id:i}),c,"h2")},Description:function e(t){var r=_([ne.displayName,e.name].join("."))[0],o=r.dialogState,u=r.setDescriptionId,i="headlessui-dialog-description-"+w();n.useEffect((function(){return u(i),function(){return u(null)}}),[i,u]);var c=n.useMemo((function(){return{open:o===Q.Open}}),[o]);return f(a({},t,{id:i}),c,"p")}});!function(e){e[e.Open=0]="Open",e[e.Closed=1]="Closed"}(X||(X={})),function(e){e[e.ToggleDisclosure=0]="ToggleDisclosure",e[e.SetButtonId=1]="SetButtonId",e[e.SetPanelId=2]="SetPanelId",e[e.LinkPanel=3]="LinkPanel",e[e.UnlinkPanel=4]="UnlinkPanel"}(Z||(Z={}));var te=(($={})[Z.ToggleDisclosure]=function(e){var n;return a({},e,{disclosureState:d(e.disclosureState,(n={},n[X.Open]=X.Closed,n[X.Closed]=X.Open,n))})},$[Z.LinkPanel]=function(e){return!0===e.linkedPanel?e:a({},e,{linkedPanel:!0})},$[Z.UnlinkPanel]=function(e){return!1===e.linkedPanel?e:a({},e,{linkedPanel:!1})},$[Z.SetButtonId]=function(e,n){return e.buttonId===n.buttonId?e:a({},e,{buttonId:n.buttonId})},$[Z.SetPanelId]=function(e,n){return e.panelId===n.panelId?e:a({},e,{panelId:n.panelId})},$),re=n.createContext(null);function oe(e){var t=n.useContext(re);if(null===t){var r=new Error("<"+e+" /> is missing a parent <"+ae.name+" /> component.");throw Error.captureStackTrace&&Error.captureStackTrace(r,oe),r}return t}function ue(e,n){return d(n.type,te,e,n)}re.displayName="DisclosureContext";var ie=n.Fragment;function ae(e){var t="headlessui-disclosure-button-"+w(),r="headlessui-disclosure-panel-"+w(),o=n.useReducer(ue,{disclosureState:X.Closed,linkedPanel:!1,buttonId:t,panelId:r}),u=o[0].disclosureState,a=o[1];n.useEffect((function(){return a({type:Z.SetButtonId,buttonId:t})}),[t,a]),n.useEffect((function(){return a({type:Z.SetPanelId,panelId:r})}),[r,a]);var c=n.useMemo((function(){return{open:u===X.Open}}),[u]);return i.createElement(re.Provider,{value:o},f(e,c,ie))}var ce,le,se,de,fe=v((function e(t,r){var o=oe([ae.name,e.name].join(".")),i=o[0],c=o[1],l=b(r),s=n.useCallback((function(e){switch(e.key){case u.Space:case u.Enter:e.preventDefault(),c({type:Z.ToggleDisclosure})}}),[c]),d=n.useCallback((function(e){y(e.currentTarget)||t.disabled||c({type:Z.ToggleDisclosure})}),[c,t.disabled]),p=n.useMemo((function(){return{open:i.disclosureState===X.Open}}),[i]);return f(a({},t,{ref:l,id:i.buttonId,type:"button","aria-expanded":i.disclosureState===X.Open||void 0,"aria-controls":i.linkedPanel?i.panelId:void 0,onKeyDown:s,onClick:d}),p,"button")})),pe=r.RenderStrategy|r.Static,ve=v((function e(t,r){var o=oe([ae.name,e.name].join(".")),u=o[0],i=o[1],c=b(r,(function(){u.linkedPanel||i({type:Z.LinkPanel})}));n.useEffect((function(){return function(){return i({type:Z.UnlinkPanel})}}),[i]),n.useEffect((function(){var e;u.disclosureState!==X.Closed||null!=(e=t.unmount)&&!e||i({type:Z.UnlinkPanel})}),[u.disclosureState,t.unmount,i]);var l=n.useMemo((function(){return{open:u.disclosureState===X.Open}}),[u]);return f(a({},t,{ref:c,id:u.panelId}),l,"div",pe,u.disclosureState===X.Open)}));function me(){var e=[],n={requestAnimationFrame:function(e){function n(){return e.apply(this,arguments)}return n.toString=function(){return e.toString()},n}((function(){var e=requestAnimationFrame.apply(void 0,arguments);n.add((function(){return cancelAnimationFrame(e)}))})),nextFrame:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];n.requestAnimationFrame((function(){n.requestAnimationFrame.apply(n,t)}))},setTimeout:function(e){function n(){return e.apply(this,arguments)}return n.toString=function(){return e.toString()},n}((function(){var e=setTimeout.apply(void 0,arguments);n.add((function(){return clearTimeout(e)}))})),add:function(n){e.push(n)},dispose:function(){for(var n,t=s(e.splice(0));!(n=t()).done;)(0,n.value)()}};return n}function be(){var e=n.useState(me)[0];return n.useEffect((function(){return function(){return e.dispose()}}),[e]),e}function ye(e,t){var r=n.useState(e),o=r[0],u=r[1],i=n.useRef(e);return h((function(){i.current=e}),[e]),h((function(){return u(i.current)}),[i,u].concat(t)),o}function he(e,n){var t=n.resolveItems();if(t.length<=0)return null;var r=n.resolveActiveIndex(),o=null!=r?r:-1,u=function(){switch(e.focus){case ce.First:return t.findIndex((function(e){return!n.resolveDisabled(e)}));case ce.Previous:var r=t.slice().reverse().findIndex((function(e,t,r){return!(-1!==o&&r.length-t-1>=o||n.resolveDisabled(e))}));return-1===r?r:t.length-1-r;case ce.Next:return t.findIndex((function(e,t){return!(t<=o||n.resolveDisabled(e))}));case ce.Last:var u=t.slice().reverse().findIndex((function(e){return!n.resolveDisabled(e)}));return-1===u?u:t.length-1-u;case ce.Specific:return t.findIndex((function(t){return n.resolveId(t)===e.id}));case ce.Nothing:return null;default:!function(e){throw new Error("Unexpected object: "+e)}(e)}}();return-1===u?r:u}ae.Button=fe,ae.Panel=ve,function(e){e[e.First=0]="First",e[e.Previous=1]="Previous",e[e.Next=2]="Next",e[e.Last=3]="Last",e[e.Specific=4]="Specific",e[e.Nothing=5]="Nothing"}(ce||(ce={})),function(e){e[e.Open=0]="Open",e[e.Closed=1]="Closed"}(se||(se={})),function(e){e[e.OpenListbox=0]="OpenListbox",e[e.CloseListbox=1]="CloseListbox",e[e.SetDisabled=2]="SetDisabled",e[e.GoToOption=3]="GoToOption",e[e.Search=4]="Search",e[e.ClearSearch=5]="ClearSearch",e[e.RegisterOption=6]="RegisterOption",e[e.UnregisterOption=7]="UnregisterOption"}(de||(de={}));var Se=((le={})[de.CloseListbox]=function(e){return e.disabled||e.listboxState===se.Closed?e:a({},e,{activeOptionIndex:null,listboxState:se.Closed})},le[de.OpenListbox]=function(e){return e.disabled||e.listboxState===se.Open?e:a({},e,{listboxState:se.Open})},le[de.SetDisabled]=function(e,n){return e.disabled===n.disabled?e:a({},e,{disabled:n.disabled})},le[de.GoToOption]=function(e,n){if(e.disabled)return e;if(e.listboxState===se.Closed)return e;var t=he(n,{resolveItems:function(){return e.options},resolveActiveIndex:function(){return e.activeOptionIndex},resolveId:function(e){return e.id},resolveDisabled:function(e){return e.dataRef.current.disabled}});return""===e.searchQuery&&e.activeOptionIndex===t?e:a({},e,{searchQuery:"",activeOptionIndex:t})},le[de.Search]=function(e,n){if(e.disabled)return e;if(e.listboxState===se.Closed)return e;var t=e.searchQuery+n.value,r=e.options.findIndex((function(e){var n;return!e.dataRef.current.disabled&&(null==(n=e.dataRef.current.textValue)?void 0:n.startsWith(t))}));return a({},e,-1===r||r===e.activeOptionIndex?{searchQuery:t}:{searchQuery:t,activeOptionIndex:r})},le[de.ClearSearch]=function(e){return e.disabled||e.listboxState===se.Closed||""===e.searchQuery?e:a({},e,{searchQuery:""})},le[de.RegisterOption]=function(e,n){return a({},e,{options:[].concat(e.options,[{id:n.id,dataRef:n.dataRef}])})},le[de.UnregisterOption]=function(e,n){var t=e.options.slice(),r=null!==e.activeOptionIndex?t[e.activeOptionIndex]:null,o=t.findIndex((function(e){return e.id===n.id}));return-1!==o&&t.splice(o,1),a({},e,{options:t,activeOptionIndex:o===e.activeOptionIndex||null===r?null:t.indexOf(r)})},le),ge=n.createContext(null);function Ee(e){var t=n.useContext(ge);if(null===t){var r=new Error("<"+e+" /> is missing a parent <"+Ie.name+" /> component.");throw Error.captureStackTrace&&Error.captureStackTrace(r,Ee),r}return t}function we(e,n){return d(n.type,Se,e,n)}ge.displayName="ListboxContext";var Ce=n.Fragment;function Ie(e){var t=e.value,r=e.onChange,o=e.disabled,u=void 0!==o&&o,a=c(e,["value","onChange","disabled"]),l=n.useReducer(we,{listboxState:se.Closed,propsRef:{current:{value:t,onChange:r}},labelRef:n.createRef(),buttonRef:n.createRef(),optionsRef:n.createRef(),disabled:u,options:[],searchQuery:"",activeOptionIndex:null}),s=l[0],d=s.listboxState,p=s.propsRef,v=s.optionsRef,m=s.buttonRef,b=l[1];h((function(){p.current.value=t}),[t,p]),h((function(){p.current.onChange=r}),[r,p]),h((function(){return b({type:de.SetDisabled,disabled:u})}),[u]),n.useEffect((function(){function e(e){var n,t,r,o=e.target;d===se.Open&&((null==(n=m.current)?void 0:n.contains(o))||(null==(t=v.current)?void 0:t.contains(o))||(b({type:de.CloseListbox}),R(o,O.Loose)||(e.preventDefault(),null==(r=m.current)||r.focus())))}return window.addEventListener("mousedown",e),function(){return window.removeEventListener("mousedown",e)}}),[d,m,v,b]);var y=n.useMemo((function(){return{open:d===se.Open,disabled:u}}),[d,u]);return i.createElement(ge.Provider,{value:l},f(a,y,Ce))}var xe,Oe,ke,Pe=v((function e(t,r){var o,i=Ee([Ie.name,e.name].join(".")),c=i[0],l=i[1],s=b(c.buttonRef,r),d="headlessui-listbox-button-"+w(),p=be(),v=n.useCallback((function(e){switch(e.key){case u.Space:case u.Enter:case u.ArrowDown:e.preventDefault(),l({type:de.OpenListbox}),p.nextFrame((function(){c.propsRef.current.value||l({type:de.GoToOption,focus:ce.First})}));break;case u.ArrowUp:e.preventDefault(),l({type:de.OpenListbox}),p.nextFrame((function(){c.propsRef.current.value||l({type:de.GoToOption,focus:ce.Last})}))}}),[l,c,p]),m=n.useCallback((function(e){if(y(e.currentTarget))return e.preventDefault();c.listboxState===se.Open?(l({type:de.CloseListbox}),p.nextFrame((function(){var e;return null==(e=c.buttonRef.current)?void 0:e.focus({preventScroll:!0})}))):(e.preventDefault(),l({type:de.OpenListbox}))}),[l,p,c]),h=ye((function(){if(c.labelRef.current)return[c.labelRef.current.id,d].join(" ")}),[c.labelRef.current,d]),S=n.useMemo((function(){return{open:c.listboxState===se.Open,disabled:c.disabled}}),[c]);return f(a({},t,{ref:s,id:d,type:"button","aria-haspopup":!0,"aria-controls":null==(o=c.optionsRef.current)?void 0:o.id,"aria-expanded":c.listboxState===se.Open||void 0,"aria-labelledby":h,disabled:c.disabled,onKeyDown:v,onClick:m}),S,"button")})),Re=r.RenderStrategy|r.Static,Te=v((function e(t,r){var o,i=Ee([Ie.name,e.name].join(".")),c=i[0],l=i[1],s=b(c.optionsRef,r),d="headlessui-listbox-options-"+w(),p=be(),v=be();h((function(){var e=c.optionsRef.current;e&&c.listboxState===se.Open&&e!==document.activeElement&&e.focus({preventScroll:!0})}),[c.listboxState,c.optionsRef]);var m=n.useCallback((function(e){switch(v.dispose(),e.key){case u.Space:if(""!==c.searchQuery)return e.preventDefault(),e.stopPropagation(),l({type:de.Search,value:e.key});case u.Enter:e.preventDefault(),e.stopPropagation(),l({type:de.CloseListbox}),null!==c.activeOptionIndex&&c.propsRef.current.onChange(c.options[c.activeOptionIndex].dataRef.current.value),me().nextFrame((function(){var e;return null==(e=c.buttonRef.current)?void 0:e.focus({preventScroll:!0})}));break;case u.ArrowDown:return e.preventDefault(),e.stopPropagation(),l({type:de.GoToOption,focus:ce.Next});case u.ArrowUp:return e.preventDefault(),e.stopPropagation(),l({type:de.GoToOption,focus:ce.Previous});case u.Home:case u.PageUp:return e.preventDefault(),e.stopPropagation(),l({type:de.GoToOption,focus:ce.First});case u.End:case u.PageDown:return e.preventDefault(),e.stopPropagation(),l({type:de.GoToOption,focus:ce.Last});case u.Escape:return e.preventDefault(),e.stopPropagation(),l({type:de.CloseListbox}),p.nextFrame((function(){var e;return null==(e=c.buttonRef.current)?void 0:e.focus({preventScroll:!0})}));case u.Tab:e.preventDefault(),e.stopPropagation();break;default:1===e.key.length&&(l({type:de.Search,value:e.key}),v.setTimeout((function(){return l({type:de.ClearSearch})}),350))}}),[p,l,v,c]),y=ye((function(){var e,n,t;return null!=(e=null==(n=c.labelRef.current)?void 0:n.id)?e:null==(t=c.buttonRef.current)?void 0:t.id}),[c.labelRef.current,c.buttonRef.current]),S=n.useMemo((function(){return{open:c.listboxState===se.Open}}),[c]);return f(a({},t,{"aria-activedescendant":null===c.activeOptionIndex||null==(o=c.options[c.activeOptionIndex])?void 0:o.id,"aria-labelledby":y,id:d,onKeyDown:m,role:"listbox",tabIndex:0,ref:s}),S,"ul",Re,c.listboxState===se.Open)}));Ie.Button=Pe,Ie.Label=function e(t){var r=Ee([Ie.name,e.name].join("."))[0],o="headlessui-listbox-label-"+w(),u=n.useCallback((function(){var e;return null==(e=r.buttonRef.current)?void 0:e.focus({preventScroll:!0})}),[r.buttonRef]),i=n.useMemo((function(){return{open:r.listboxState===se.Open,disabled:r.disabled}}),[r]);return f(a({},t,{ref:r.labelRef,id:o,onClick:u}),i,"label")},Ie.Options=Te,Ie.Option=function e(t){var r=t.disabled,o=void 0!==r&&r,u=t.value,i=c(t,["disabled","value"]),l=Ee([Ie.name,e.name].join(".")),s=l[0],d=l[1],p="headlessui-listbox-option-"+w(),v=null!==s.activeOptionIndex&&s.options[s.activeOptionIndex].id===p,m=s.propsRef.current.value===u,b=n.useRef({disabled:o,value:u});h((function(){b.current.disabled=o}),[b,o]),h((function(){b.current.value=u}),[b,u]),h((function(){var e,n;b.current.textValue=null==(e=document.getElementById(p))||null==(n=e.textContent)?void 0:n.toLowerCase()}),[b,p]);var y=n.useCallback((function(){return s.propsRef.current.onChange(u)}),[s.propsRef,u]);h((function(){return d({type:de.RegisterOption,id:p,dataRef:b}),function(){return d({type:de.UnregisterOption,id:p})}}),[b,p]),h((function(){var e;s.listboxState===se.Open&&m&&(d({type:de.GoToOption,focus:ce.Specific,id:p}),null==(e=document.getElementById(p))||null==e.focus||e.focus())}),[s.listboxState]),h((function(){if(s.listboxState===se.Open&&v){var e=me();return e.nextFrame((function(){var e;return null==(e=document.getElementById(p))||null==e.scrollIntoView?void 0:e.scrollIntoView({block:"nearest"})})),e.dispose}}),[p,v,s.listboxState]);var S=n.useCallback((function(e){if(o)return e.preventDefault();y(),d({type:de.CloseListbox}),me().nextFrame((function(){var e;return null==(e=s.buttonRef.current)?void 0:e.focus({preventScroll:!0})}))}),[d,s.buttonRef,o,y]),g=n.useCallback((function(){if(o)return d({type:de.GoToOption,focus:ce.Nothing});d({type:de.GoToOption,focus:ce.Specific,id:p})}),[o,p,d]),E=n.useCallback((function(){o||v||d({type:de.GoToOption,focus:ce.Specific,id:p})}),[o,v,p,d]),C=n.useCallback((function(){o||v&&d({type:de.GoToOption,focus:ce.Nothing})}),[o,v,d]),I=n.useMemo((function(){return{active:v,selected:m,disabled:o}}),[v,m,o]);return f(a({},i,{id:p,role:"option",tabIndex:-1,"aria-disabled":!0===o||void 0,"aria-selected":!0===m||void 0,onClick:S,onFocus:g,onPointerMove:E,onMouseMove:E,onPointerLeave:C,onMouseLeave:C}),I,"li")},function(e){e[e.Open=0]="Open",e[e.Closed=1]="Closed"}(Oe||(Oe={})),function(e){e[e.OpenMenu=0]="OpenMenu",e[e.CloseMenu=1]="CloseMenu",e[e.GoToItem=2]="GoToItem",e[e.Search=3]="Search",e[e.ClearSearch=4]="ClearSearch",e[e.RegisterItem=5]="RegisterItem",e[e.UnregisterItem=6]="UnregisterItem"}(ke||(ke={}));var De=((xe={})[ke.CloseMenu]=function(e){return e.menuState===Oe.Closed?e:a({},e,{activeItemIndex:null,menuState:Oe.Closed})},xe[ke.OpenMenu]=function(e){return e.menuState===Oe.Open?e:a({},e,{menuState:Oe.Open})},xe[ke.GoToItem]=function(e,n){var t=he(n,{resolveItems:function(){return e.items},resolveActiveIndex:function(){return e.activeItemIndex},resolveId:function(e){return e.id},resolveDisabled:function(e){return e.dataRef.current.disabled}});return""===e.searchQuery&&e.activeItemIndex===t?e:a({},e,{searchQuery:"",activeItemIndex:t})},xe[ke.Search]=function(e,n){var t=e.searchQuery+n.value,r=e.items.findIndex((function(e){var n;return(null==(n=e.dataRef.current.textValue)?void 0:n.startsWith(t))&&!e.dataRef.current.disabled}));return a({},e,-1===r||r===e.activeItemIndex?{searchQuery:t}:{searchQuery:t,activeItemIndex:r})},xe[ke.ClearSearch]=function(e){return""===e.searchQuery?e:a({},e,{searchQuery:""})},xe[ke.RegisterItem]=function(e,n){return a({},e,{items:[].concat(e.items,[{id:n.id,dataRef:n.dataRef}])})},xe[ke.UnregisterItem]=function(e,n){var t=e.items.slice(),r=null!==e.activeItemIndex?t[e.activeItemIndex]:null,o=t.findIndex((function(e){return e.id===n.id}));return-1!==o&&t.splice(o,1),a({},e,{items:t,activeItemIndex:o===e.activeItemIndex||null===r?null:t.indexOf(r)})},xe),Le=n.createContext(null);function Fe(e){var t=n.useContext(Le);if(null===t){var r=new Error("<"+e+" /> is missing a parent <"+Ne.name+" /> component.");throw Error.captureStackTrace&&Error.captureStackTrace(r,Fe),r}return t}function Me(e,n){return d(n.type,De,e,n)}Le.displayName="MenuContext";var Ae=n.Fragment;function Ne(e){var t=n.useReducer(Me,{menuState:Oe.Closed,buttonRef:n.createRef(),itemsRef:n.createRef(),items:[],searchQuery:"",activeItemIndex:null}),r=t[0],o=r.menuState,u=r.itemsRef,a=r.buttonRef,c=t[1];n.useEffect((function(){function e(e){var n,t,r,i=e.target;o===Oe.Open&&((null==(n=a.current)?void 0:n.contains(i))||(null==(t=u.current)?void 0:t.contains(i))||(c({type:ke.CloseMenu}),R(i,O.Loose)||(e.preventDefault(),null==(r=a.current)||r.focus())))}return window.addEventListener("mousedown",e),function(){return window.removeEventListener("mousedown",e)}}),[o,a,u,c]);var l=n.useMemo((function(){return{open:o===Oe.Open}}),[o]);return i.createElement(Le.Provider,{value:t},f(e,l,Ae))}var je,Ue,Ge,He=v((function e(t,r){var o,i=Fe([Ne.name,e.name].join(".")),c=i[0],l=i[1],s=b(c.buttonRef,r),d="headlessui-menu-button-"+w(),p=be(),v=n.useCallback((function(e){switch(e.key){case u.Space:case u.Enter:case u.ArrowDown:e.preventDefault(),e.stopPropagation(),l({type:ke.OpenMenu}),p.nextFrame((function(){return l({type:ke.GoToItem,focus:ce.First})}));break;case u.ArrowUp:e.preventDefault(),e.stopPropagation(),l({type:ke.OpenMenu}),p.nextFrame((function(){return l({type:ke.GoToItem,focus:ce.Last})}))}}),[l,p]),m=n.useCallback((function(e){if(y(e.currentTarget))return e.preventDefault();t.disabled||(c.menuState===Oe.Open?(l({type:ke.CloseMenu}),p.nextFrame((function(){var e;return null==(e=c.buttonRef.current)?void 0:e.focus({preventScroll:!0})}))):(e.preventDefault(),e.stopPropagation(),l({type:ke.OpenMenu})))}),[l,p,c,t.disabled]),h=n.useMemo((function(){return{open:c.menuState===Oe.Open}}),[c]);return f(a({},t,{ref:s,id:d,type:"button","aria-haspopup":!0,"aria-controls":null==(o=c.itemsRef.current)?void 0:o.id,"aria-expanded":c.menuState===Oe.Open||void 0,onKeyDown:v,onClick:m}),h,"button")})),Be=r.RenderStrategy|r.Static,Ve=v((function e(t,r){var o,i,c=Fe([Ne.name,e.name].join(".")),l=c[0],s=c[1],d=b(l.itemsRef,r),p="headlessui-menu-items-"+w(),v=be();n.useEffect((function(){var e=l.itemsRef.current;e&&l.menuState===Oe.Open&&e!==document.activeElement&&e.focus({preventScroll:!0})}),[l.menuState,l.itemsRef]),h((function(){var e=l.itemsRef.current;if(e&&l.menuState===Oe.Open)for(var n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:function(e){return"menuitem"===e.getAttribute("role")?NodeFilter.FILTER_REJECT:e.hasAttribute("role")?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT}});n.nextNode();)n.currentNode.setAttribute("role","none")}),[l.menuState,l.itemsRef]);var m=n.useCallback((function(e){switch(v.dispose(),e.key){case u.Space:if(""!==l.searchQuery)return e.preventDefault(),e.stopPropagation(),s({type:ke.Search,value:e.key});case u.Enter:var n;e.preventDefault(),e.stopPropagation(),s({type:ke.CloseMenu}),null!==l.activeItemIndex&&(null==(n=document.getElementById(l.items[l.activeItemIndex].id))||n.click()),me().nextFrame((function(){var e;return null==(e=l.buttonRef.current)?void 0:e.focus({preventScroll:!0})}));break;case u.ArrowDown:return e.preventDefault(),e.stopPropagation(),s({type:ke.GoToItem,focus:ce.Next});case u.ArrowUp:return e.preventDefault(),e.stopPropagation(),s({type:ke.GoToItem,focus:ce.Previous});case u.Home:case u.PageUp:return e.preventDefault(),e.stopPropagation(),s({type:ke.GoToItem,focus:ce.First});case u.End:case u.PageDown:return e.preventDefault(),e.stopPropagation(),s({type:ke.GoToItem,focus:ce.Last});case u.Escape:e.preventDefault(),e.stopPropagation(),s({type:ke.CloseMenu}),me().nextFrame((function(){var e;return null==(e=l.buttonRef.current)?void 0:e.focus({preventScroll:!0})}));break;case u.Tab:e.preventDefault(),e.stopPropagation();break;default:1===e.key.length&&(s({type:ke.Search,value:e.key}),v.setTimeout((function(){return s({type:ke.ClearSearch})}),350))}}),[s,v,l]),y=n.useMemo((function(){return{open:l.menuState===Oe.Open}}),[l]);return f(a({},t,{"aria-activedescendant":null===l.activeItemIndex||null==(o=l.items[l.activeItemIndex])?void 0:o.id,"aria-labelledby":null==(i=l.buttonRef.current)?void 0:i.id,id:p,onKeyDown:m,role:"menu",tabIndex:0,ref:d}),y,"div",Be,l.menuState===Oe.Open)})),Qe=n.Fragment;Ne.Button=He,Ne.Items=Ve,Ne.Item=function e(t){var r=t.disabled,o=void 0!==r&&r,u=t.onClick,i=c(t,["disabled","onClick"]),l=Fe([Ne.name,e.name].join(".")),s=l[0],d=l[1],p="headlessui-menu-item-"+w(),v=null!==s.activeItemIndex&&s.items[s.activeItemIndex].id===p;h((function(){if(s.menuState===Oe.Open&&v){var e=me();return e.nextFrame((function(){var e;return null==(e=document.getElementById(p))||null==e.scrollIntoView?void 0:e.scrollIntoView({block:"nearest"})})),e.dispose}}),[p,v,s.menuState]);var m=n.useRef({disabled:o});h((function(){m.current.disabled=o}),[m,o]),h((function(){var e,n;m.current.textValue=null==(e=document.getElementById(p))||null==(n=e.textContent)?void 0:n.toLowerCase()}),[m,p]),h((function(){return d({type:ke.RegisterItem,id:p,dataRef:m}),function(){return d({type:ke.UnregisterItem,id:p})}}),[m,p]);var b=n.useCallback((function(e){return o?e.preventDefault():(d({type:ke.CloseMenu}),me().nextFrame((function(){var e;return null==(e=s.buttonRef.current)?void 0:e.focus({preventScroll:!0})})),u?u(e):void 0)}),[d,s.buttonRef,o,u]),y=n.useCallback((function(){if(o)return d({type:ke.GoToItem,focus:ce.Nothing});d({type:ke.GoToItem,focus:ce.Specific,id:p})}),[o,p,d]),S=n.useCallback((function(){o||v||d({type:ke.GoToItem,focus:ce.Specific,id:p})}),[o,v,p,d]),g=n.useCallback((function(){o||v&&d({type:ke.GoToItem,focus:ce.Nothing})}),[o,v,d]),E=n.useMemo((function(){return{active:v,disabled:o}}),[v,o]);return f(a({},i,{id:p,role:"menuitem",tabIndex:-1,"aria-disabled":!0===o||void 0,onClick:b,onFocus:y,onPointerMove:S,onMouseMove:S,onPointerLeave:g,onMouseLeave:g}),E,Qe)},function(e){e[e.Open=0]="Open",e[e.Closed=1]="Closed"}(Ue||(Ue={})),function(e){e[e.TogglePopover=0]="TogglePopover",e[e.ClosePopover=1]="ClosePopover",e[e.SetButton=2]="SetButton",e[e.SetButtonId=3]="SetButtonId",e[e.SetPanel=4]="SetPanel",e[e.SetPanelId=5]="SetPanelId"}(Ge||(Ge={}));var Ke=((je={})[Ge.TogglePopover]=function(e){var n;return a({},e,{popoverState:d(e.popoverState,(n={},n[Ue.Open]=Ue.Closed,n[Ue.Closed]=Ue.Open,n))})},je[Ge.ClosePopover]=function(e){return e.popoverState===Ue.Closed?e:a({},e,{popoverState:Ue.Closed})},je[Ge.SetButton]=function(e,n){return e.button===n.button?e:a({},e,{button:n.button})},je[Ge.SetButtonId]=function(e,n){return e.buttonId===n.buttonId?e:a({},e,{buttonId:n.buttonId})},je[Ge.SetPanel]=function(e,n){return e.panel===n.panel?e:a({},e,{panel:n.panel})},je[Ge.SetPanelId]=function(e,n){return e.panelId===n.panelId?e:a({},e,{panelId:n.panelId})},je),We=n.createContext(null);function qe(e){var t=n.useContext(We);if(null===t){var r=new Error("<"+e+" /> is missing a parent <"+$e.name+" /> component.");throw Error.captureStackTrace&&Error.captureStackTrace(r,qe),r}return t}We.displayName="PopoverContext";var ze=n.createContext(null);function Ye(){return n.useContext(ze)}ze.displayName="PopoverGroupContext";var _e=n.createContext(null);function Je(e,n){return d(n.type,Ke,e,n)}function $e(e){var t="headlessui-popover-button-"+w(),r="headlessui-popover-panel-"+w(),o=n.useReducer(Je,{popoverState:Ue.Closed,linkedPanel:!1,button:null,buttonId:t,panel:null,panelId:r}),u=o[0],a=u.popoverState,c=u.button,l=u.panel,s=o[1];n.useEffect((function(){return s({type:Ge.SetButtonId,buttonId:t})}),[t,s]),n.useEffect((function(){return s({type:Ge.SetPanelId,panelId:r})}),[r,s]);var d=n.useMemo((function(){return{buttonId:t,panelId:r,close:function(){return s({type:Ge.ClosePopover})}}}),[t,r,s]),p=Ye(),v=null==p?void 0:p.registerPopover,m=n.useCallback((function(){var e;return null!=(e=null==p?void 0:p.isFocusWithinPopoverGroup())?e:(null==c?void 0:c.contains(document.activeElement))||(null==l?void 0:l.contains(document.activeElement))}),[p,c,l]);n.useEffect((function(){return null==v?void 0:v(d)}),[v,d]),n.useEffect((function(){if(a===Ue.Open)return window.addEventListener("focus",e,!0),function(){return window.removeEventListener("focus",e,!0)};function e(){m()||c&&l&&s({type:Ge.ClosePopover})}}),[a,m,p,c,l,s]),n.useEffect((function(){function e(e){var n=e.target;a===Ue.Open&&((null==c?void 0:c.contains(n))||(null==l?void 0:l.contains(n))||(s({type:Ge.ClosePopover}),R(n,O.Loose)||(e.preventDefault(),null==c||c.focus())))}return window.addEventListener("mousedown",e),function(){return window.removeEventListener("mousedown",e)}}),[a,c,l,s]);var b=n.useMemo((function(){return{open:a===Ue.Open}}),[a]);return i.createElement(We.Provider,{value:o},f(e,b,"div"))}_e.displayName="PopoverPanelContext";var Xe=v((function e(t,r){var o=qe([$e.name,e.name].join(".")),i=o[0],c=o[1],l=n.useRef(null),s=Ye(),d=null==s?void 0:s.closeOthers,p=n.useContext(_e),v=null!==p&&p===i.panelId,m=b(l,r,v?null:function(e){return c({type:Ge.SetButton,button:e})}),h=n.useRef(null),S=n.useRef("undefined"==typeof window?null:document.activeElement);n.useEffect((function(){function e(){S.current=h.current,h.current=document.activeElement}return window.addEventListener("focus",e,!0),function(){return window.removeEventListener("focus",e,!0)}}),[S,h]);var g=n.useCallback((function(e){var n;if(v){if(i.popoverState===Ue.Closed)return;switch(e.key){case u.Space:case u.Enter:e.preventDefault(),e.stopPropagation(),c({type:Ge.ClosePopover}),null==(n=i.button)||n.focus()}}else switch(e.key){case u.Space:case u.Enter:e.preventDefault(),e.stopPropagation(),i.popoverState===Ue.Closed&&(null==d||d(i.buttonId)),c({type:Ge.TogglePopover});break;case u.Escape:if(i.popoverState!==Ue.Open)return null==d?void 0:d(i.buttonId);if(!l.current)return;if(!l.current.contains(document.activeElement))return;c({type:Ge.ClosePopover});break;case u.Tab:if(i.popoverState!==Ue.Open)return;if(!i.panel)return;if(!i.button)return;if(e.shiftKey){var t;if(!S.current)return;if(null==(t=i.button)?void 0:t.contains(S.current))return;if(i.panel.contains(S.current))return;var r=P(),o=r.indexOf(S.current);if(r.indexOf(i.button)>o)return;e.preventDefault(),e.stopPropagation(),D(i.panel,C.Last)}else e.preventDefault(),e.stopPropagation(),D(i.panel,C.First)}}),[c,i.popoverState,i.buttonId,i.button,i.panel,l,d,v]),E=n.useCallback((function(e){var n;if(!v&&i.popoverState===Ue.Open&&i.panel&&i.button)switch(e.key){case u.Tab:if(!S.current)return;if(null==(n=i.button)?void 0:n.contains(S.current))return;if(i.panel.contains(S.current))return;var t=P(),r=t.indexOf(S.current);if(t.indexOf(i.button)>r)return;e.preventDefault(),e.stopPropagation(),D(i.panel,C.Last)}}),[i.popoverState,i.panel,i.button,v]),w=n.useCallback((function(e){var n;y(e.currentTarget)||t.disabled||(v?(c({type:Ge.ClosePopover}),null==(n=i.button)||n.focus()):(i.popoverState===Ue.Closed&&(null==d||d(i.buttonId)),c({type:Ge.TogglePopover})))}),[c,i.button,i.popoverState,i.buttonId,t.disabled,d,v]),I=n.useMemo((function(){return{open:i.popoverState===Ue.Open}}),[i]);return f(a({},t,v?{type:"button",onKeyDown:g,onClick:w}:{ref:m,id:i.buttonId,type:"button","aria-expanded":i.popoverState===Ue.Open||void 0,"aria-controls":i.panel?i.panelId:void 0,onKeyDown:g,onKeyUp:E,onClick:w}),I,"button")})),Ze=v((function e(t,r){var o=qe([$e.name,e.name].join(".")),u=o[0].popoverState,i=o[1],c=b(r),l="headlessui-popover-overlay-"+w(),s=n.useCallback((function(e){if(y(e.currentTarget))return e.preventDefault();i({type:Ge.ClosePopover})}),[i]),d=n.useMemo((function(){return{open:u===Ue.Open}}),[u]);return f(a({},t,{ref:c,id:l,"aria-hidden":!0,onClick:s}),d,"div")})),en=r.RenderStrategy|r.Static,nn=v((function e(t,r){var o=t.focus,l=void 0!==o&&o,s=c(t,["focus"]),d=qe([$e.name,e.name].join(".")),p=d[0],v=d[1],m=n.useRef(null),y=b(m,r,(function(e){v({type:Ge.SetPanel,panel:e})})),h=n.useCallback((function(e){var n;switch(e.key){case u.Escape:if(p.popoverState!==Ue.Open)return;if(!m.current)return;if(!m.current.contains(document.activeElement))return;e.preventDefault(),v({type:Ge.ClosePopover}),null==(n=p.button)||n.focus()}}),[p,m,v]);n.useEffect((function(){return function(){return v({type:Ge.SetPanel,panel:null})}}),[v]),n.useEffect((function(){var e;p.popoverState!==Ue.Closed||null!=(e=t.unmount)&&!e||v({type:Ge.SetPanel,panel:null})}),[p.popoverState,t.unmount,v]),n.useEffect((function(){if(l&&p.popoverState===Ue.Open&&m.current){var e=document.activeElement;m.current.contains(e)||D(m.current,C.First)}}),[l,m,p.popoverState]),n.useEffect((function(){if(p.popoverState===Ue.Open&&m.current)return window.addEventListener("keydown",e),function(){return window.removeEventListener("keydown",e)};function e(e){if(e.key===u.Tab&&document.activeElement&&m.current&&m.current.contains(document.activeElement)){e.preventDefault();var n,t=D(m.current,e.shiftKey?C.Previous:C.Next);if(t===I.Underflow)return null==(n=p.button)?void 0:n.focus();if(t===I.Overflow){if(!p.button)return;var r=P(),o=r.indexOf(p.button);D(r.splice(o+1).filter((function(e){var n;return!(null==(n=m.current)?void 0:n.contains(e))})),C.First)===I.Error&&D(document.body,C.First)}}}}),[l,m,p.popoverState,p.button]),n.useEffect((function(){if(l&&p.popoverState===Ue.Open&&m.current)return window.addEventListener("focus",e,!0),function(){return window.removeEventListener("focus",e,!0)};function e(){var e;(null==(e=m.current)?void 0:e.contains(document.activeElement))||v({type:Ge.ClosePopover})}}),[l,p.popoverState,v]);var S=n.useMemo((function(){return{open:p.popoverState===Ue.Open}}),[p]);return i.createElement(_e.Provider,{value:p.panelId},f(a({},s,{ref:y,id:p.panelId,onKeyDown:h}),S,"div",en,p.popoverState===Ue.Open))}));$e.Button=Xe,$e.Overlay=Ze,$e.Panel=nn,$e.Group=function(e){var t=n.useRef(null),r=n.useState([]),o=r[0],u=r[1],c=n.useCallback((function(e){u((function(n){var t=n.indexOf(e);if(-1!==t){var r=n.slice();return r.splice(t,1),r}return n}))}),[u]),l=n.useCallback((function(e){return u((function(n){return[].concat(n,[e])})),function(){return c(e)}}),[u,c]),d=n.useCallback((function(){var e,n=document.activeElement;return!!(null==(e=t.current)?void 0:e.contains(n))||o.some((function(e){var t,r;return(null==(t=document.getElementById(e.buttonId))?void 0:t.contains(n))||(null==(r=document.getElementById(e.panelId))?void 0:r.contains(n))}))}),[t,o]),p=n.useCallback((function(e){for(var n,t=s(o);!(n=t()).done;){var r=n.value;r.buttonId!==e&&r.close()}}),[o]),v=n.useMemo((function(){return{registerPopover:l,unregisterPopover:c,isFocusWithinPopoverGroup:d,closeOthers:p}}),[l,c,d,p]),m=n.useMemo((function(){return{}}),[]);return i.createElement(ze.Provider,{value:v},f(a({},e,{ref:t}),m,"div"))};var tn=n.createContext(null);function rn(e){var t=n.useContext(tn);if(null===t){var r=new Error("<"+e+" /> is missing a parent <Switch.Group /> component.");throw Error.captureStackTrace&&Error.captureStackTrace(r,rn),r}return t}tn.displayName="GroupContext";var on,un=n.Fragment;function an(e){var t,r,o=e.checked,i=e.onChange,l=c(e,["checked","onChange"]),s="headlessui-switch-"+w(),d=n.useContext(tn),p=n.useCallback((function(){return i(!o)}),[i,o]),v=n.useCallback((function(e){if(y(e.currentTarget))return e.preventDefault();e.preventDefault(),p()}),[p]),m=n.useCallback((function(e){e.key!==u.Tab&&e.preventDefault(),e.key===u.Space&&p()}),[p]),b=n.useCallback((function(e){return e.preventDefault()}),[]),h=n.useMemo((function(){return{checked:o}}),[o]),S={id:s,ref:null===d?void 0:d.setSwitch,role:"switch",tabIndex:0,"aria-checked":o,"aria-labelledby":null==d||null==(t=d.label)?void 0:t.id,"aria-describedby":null==d||null==(r=d.description)?void 0:r.id,onClick:v,onKeyUp:m,onKeyPress:b};return"button"===l.as&&Object.assign(S,{type:"button"}),f(a({},l,S),h,"button")}function cn(){var e=n.useRef(!0);return n.useEffect((function(){e.current=!1}),[]),e.current}function ln(e){for(var n,t=arguments.length,r=new Array(t>1?t-1:0),o=1;o<t;o++)r[o-1]=arguments[o];e&&r.length>0&&(n=e.classList).add.apply(n,r)}function sn(e){for(var n,t=arguments.length,r=new Array(t>1?t-1:0),o=1;o<t;o++)r[o-1]=arguments[o];e&&r.length>0&&(n=e.classList).remove.apply(n,r)}function dn(e,n,t,r,o){var u=me(),i=void 0!==o?function(e){var n={called:!1};return function(){if(!n.called)return n.called=!0,e.apply(void 0,arguments)}}(o):function(){};return ln.apply(void 0,[e].concat(n,t)),u.nextFrame((function(){sn.apply(void 0,[e].concat(t)),ln.apply(void 0,[e].concat(r)),u.add(function(e,n){var t=me();if(!e)return t.dispose;var r=getComputedStyle(e),o=[r.transitionDuration,r.transitionDelay].map((function(e){var n=e.split(",").filter(Boolean).map((function(e){return e.includes("ms")?parseFloat(e):1e3*parseFloat(e)})).sort((function(e,n){return n-e}))[0];return void 0===n?0:n})),u=o[0];return 0!==u?t.setTimeout((function(){n(on.Finished)}),u+o[1]):n(on.Finished),t.add((function(){return n(on.Cancelled)})),t.dispose}(e,(function(t){return sn.apply(void 0,[e].concat(r,n)),i(t)})))})),u.add((function(){return sn.apply(void 0,[e].concat(n,t,r))})),u.add((function(){return i(on.Cancelled)})),u.dispose}function fn(e){return void 0===e&&(e=""),n.useMemo((function(){return e.split(" ").filter((function(e){return e.trim().length>1}))}),[e])}an.Group=function(e){var t=n.useState(null),r=t[0],o=t[1],u=n.useState(null),a=u[0],c=u[1],l=n.useState(null),s=l[0],d=l[1],p=n.useMemo((function(){return{switch:r,setSwitch:o,label:a,setLabel:c,description:s,setDescription:d}}),[r,o,a,c,s,d]);return i.createElement(tn.Provider,{value:p},f(e,{},un))},an.Label=function e(t){var r=rn([an.name,e.name].join(".")),o="headlessui-switch-label-"+w(),u=n.useCallback((function(){r.switch&&(r.switch.click(),r.switch.focus({preventScroll:!0}))}),[r.switch]);return f(a({},t,{ref:r.setLabel,id:o,onClick:u}),{},"label")},an.Description=function e(n){var t=rn([an.name,e.name].join(".")),r="headlessui-switch-description-"+w();return f(a({},n,{ref:t.setDescription,id:r}),{},"p")},function(e){e.Finished="finished",e.Cancelled="cancelled"}(on||(on={}));var pn,vn=n.createContext(null);vn.displayName="TransitionContext",function(e){e.Visible="visible",e.Hidden="hidden"}(pn||(pn={}));var mn=n.createContext(null);function bn(e){return"children"in e?bn(e.children):e.current.filter((function(e){return e.state===pn.Visible})).length>0}function yn(e){var t=n.useRef(e),r=n.useRef([]),u=function(){var e=n.useRef(!0);return n.useEffect((function(){return function(){e.current=!1}}),[]),e}();n.useEffect((function(){t.current=e}),[e]);var i=n.useCallback((function(e,n){var i;void 0===n&&(n=o.Hidden);var a=r.current.findIndex((function(n){return n.id===e}));-1!==a&&(d(n,((i={})[o.Unmount]=function(){r.current.splice(a,1)},i[o.Hidden]=function(){r.current[a].state=pn.Hidden},i)),!bn(r)&&u.current&&(null==t.current||t.current()))}),[t,u,r]),a=n.useCallback((function(e){var n=r.current.find((function(n){return n.id===e}));return n?n.state!==pn.Visible&&(n.state=pn.Visible):r.current.push({id:e,state:pn.Visible}),function(){return i(e,o.Unmount)}}),[r,i]);return n.useMemo((function(){return{children:r,register:a,unregister:i}}),[a,i,r])}function hn(){}mn.displayName="NestingContext";var Sn=["beforeEnter","afterEnter","beforeLeave","afterLeave"];function gn(e){for(var n,t={},r=s(Sn);!(n=r()).done;){var o,u=n.value;t[u]=null!=(o=e[u])?o:hn}return t}var En=r.RenderStrategy;function wn(e){var t=e.beforeEnter,r=e.afterEnter,u=e.beforeLeave,l=e.afterLeave,s=e.enter,p=e.enterFrom,v=e.enterTo,m=e.leave,b=e.leaveFrom,y=e.leaveTo,S=c(e,["beforeEnter","afterEnter","beforeLeave","afterLeave","enter","enterFrom","enterTo","leave","leaveFrom","leaveTo"]),g=n.useRef(null),E=n.useState(pn.Visible),C=E[0],I=E[1],x=S.unmount?o.Unmount:o.Hidden,O=function(){var e=n.useContext(vn);if(null===e)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition />.");return e}(),k=O.show,P=O.appear,R=function(){var e=n.useContext(mn);if(null===e)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition />.");return e}(),T=R.register,D=R.unregister,L=cn(),F=w(),M=n.useRef(!1),A=yn((function(){M.current||(I(pn.Hidden),D(F),V.current.afterLeave())}));h((function(){if(F)return T(F)}),[T,F]),h((function(){var e;x===o.Hidden&&F&&(k&&C!==pn.Visible?I(pn.Visible):d(C,((e={})[pn.Hidden]=function(){return D(F)},e[pn.Visible]=function(){return T(F)},e)))}),[C,F,T,D,k,x]);var N=fn(s),j=fn(p),U=fn(v),G=fn(m),H=fn(b),B=fn(y),V=function(e){var t=n.useRef(gn(e));return n.useEffect((function(){t.current=gn(e)}),[e]),t}({beforeEnter:t,afterEnter:r,beforeLeave:u,afterLeave:l});n.useEffect((function(){if(C===pn.Visible&&null===g.current)throw new Error("Did you forget to passthrough the `ref` to the actual DOM node?")}),[g,C]);var Q=L&&!P;return h((function(){var e=g.current;if(e&&!Q)return M.current=!0,k&&V.current.beforeEnter(),k||V.current.beforeLeave(),k?dn(e,N,j,U,(function(e){M.current=!1,e===on.Finished&&V.current.afterEnter()})):dn(e,G,H,B,(function(e){M.current=!1,e===on.Finished&&(bn(A)||(I(pn.Hidden),D(F),V.current.afterLeave()))}))}),[V,F,M,D,A,g,Q,k,N,j,U,G,H,B]),i.createElement(mn.Provider,{value:A},f(a({},S,{ref:g}),{},"div",En,C===pn.Visible))}function Cn(e){var t=e.show,r=e.appear,o=void 0!==r&&r,u=e.unmount,l=c(e,["show","appear","unmount"]);if(![!0,!1].includes(t))throw new Error("A <Transition /> is used but it is missing a `show={true | false}` prop.");var s=n.useState(t?pn.Visible:pn.Hidden),d=s[0],p=s[1],v=yn((function(){p(pn.Hidden)})),m=cn(),b=n.useMemo((function(){return{show:t,appear:o||!m}}),[t,o,m]);n.useEffect((function(){t?p(pn.Visible):bn(v)||p(pn.Hidden)}),[t,v]);var y={unmount:u};return i.createElement(mn.Provider,{value:v},i.createElement(vn.Provider,{value:b},f(a({},y,{as:n.Fragment,children:i.createElement(wn,Object.assign({},y,l))}),{},n.Fragment,En,d===pn.Visible)))}Cn.Child=wn,e.Dialog=ne,e.Disclosure=ae,e.FocusTrap=function(e){var t=n.useRef(new Set),r=e.initialFocus,o=c(e,["initialFocus"]);return F(t,!0,{initialFocus:r}),f(a({},o,{ref:function(e){e&&t.current.add(e)}}),{},"div")},e.Listbox=Ie,e.Menu=Ne,e.Popover=$e,e.Portal=q,e.Switch=an,e.Transition=Cn,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=headlessui.umd.production.min.js.map |
{ | ||
"name": "@headlessui/react", | ||
"version": "0.3.1-7c43e53", | ||
"version": "0.3.1-7c43e54", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "typings": "dist/index.d.ts", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1775518
11816