UNPKG

hello-csv

Version:

A modern CSV importer written in Preact

7 lines 283 kB
(function(de,$e){typeof exports=="object"&&typeof module<"u"?$e(exports,require("react-dom/client"),require("react"),require("react/jsx-runtime"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react-dom/client","react","react/jsx-runtime","react-dom"],$e):(de=typeof globalThis<"u"?globalThis:de||self,$e(de["hello-csv"]={},de.client,de.React,de.jsxRuntime,de.ReactDOM))})(this,function(de,$e,d,p,Fe){"use strict";var Jg=Object.defineProperty;var Qg=(de,$e,d)=>$e in de?Jg(de,$e,{enumerable:!0,configurable:!0,writable:!0,value:d}):de[$e]=d;var ge=(de,$e,d)=>Qg(de,typeof $e!="symbol"?$e+"":$e,d);function qr(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const $=qr(d),en=qr(Fe);function Kr(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(n=Kr(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function Xs(){for(var e,t,n=0,r="",o=arguments.length;n<o;n++)(e=arguments[n])&&(t=Kr(e))&&(r&&(r+=" "),r+=t);return r}const Yr=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Xr=Xs,rt=(e,t)=>n=>{var r;if((t==null?void 0:t.variants)==null)return Xr(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:o,defaultVariants:i}=t,s=Object.keys(o).map(u=>{const c=n==null?void 0:n[u],g=i==null?void 0:i[u];if(c===null)return null;const h=Yr(c)||Yr(g);return o[u][h]}),l=n&&Object.entries(n).reduce((u,c)=>{let[g,h]=c;return h===void 0||(u[g]=h),u},{}),a=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((u,c)=>{let{class:g,className:h,...f}=c;return Object.entries(f).every(m=>{let[v,b]=m;return Array.isArray(b)?b.includes({...i,...l}[v]):{...i,...l}[v]===b})?[...u,g,h]:u},[]);return Xr(e,s,a,n==null?void 0:n.class,n==null?void 0:n.className)},Zs=rt("text-center inline-block font-semibold px-3 py-2 rounded-md text-sm",{variants:{variant:{primary:"shadow-xs bg-hello-csv-primary text-white",secondary:"bg-white text-hello-csv-primary ring-1 shadow-xs ring-bg-hello-csv-primary ring-inset",tertiary:"bg-white text-gray-900 ring-1 shadow-xs ring-hello-csv-tertiary ring-inset",success:"shadow-xs bg-hello-csv-success text-white",danger:"shadow-xs bg-hello-csv-danger text-white"},withFullWidth:{true:"w-full",false:""},disabled:{true:"opacity-50 cursor-not-allowed pointer-events-none",false:"cursor-pointer"}},compoundVariants:[{variant:"primary",disabled:!1,className:"hover:bg-hello-csv-primary-light focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-hello-csv-primary"},{variant:"secondary",disabled:!1,className:"hover:opacity-80 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-hello-csv-secondary"},{variant:"tertiary",disabled:!1,className:"hover:bg-hello-csv-tertiary-light"},{variant:"success",disabled:!1,className:"hover:opacity-80 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-hello-csv-success"},{variant:"danger",disabled:!1,className:"hover:bg-hello-csv-danger-light focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-hello-csv-danger"}],defaultVariants:{withFullWidth:!1,variant:"primary",disabled:!1}});function Te({children:e,variant:t,disabled:n,onClick:r,withFullWidth:o}){const i=Zs({variant:t,disabled:n,withFullWidth:o});return p.jsx("div",{role:"button",tabIndex:0,className:i,onClick:r,"aria-disabled":n,children:e})}const Js=rt("overflow-hidden rounded-md border border-gray-200",{variants:{variant:{default:"bg-white",muted:"bg-hello-csv-muted"},withPadding:{true:"px-4 py-5 sm:p-6",false:""}},defaultVariants:{variant:"default",withPadding:!0}}),Zr=d.forwardRef(({children:e,className:t,variant:n,withPadding:r=!0},o)=>{const i=Js({variant:n,withPadding:r});return p.jsx("div",{ref:o,className:`${i} ${t}`,children:e})});function Jr({checked:e,setChecked:t,label:n}){const r=d.useId();return p.jsxs("div",{className:"flex gap-3",children:[p.jsx("div",{className:"flex h-6 shrink-0 items-center",children:p.jsxs("div",{className:"group grid size-4 grid-cols-1",children:[p.jsx("input",{checked:e,onChange:o=>t(o.target.checked),id:r,type:"checkbox",className:"checked:border-hello-csv-primary checked:bg-hello-csv-primary indeterminate:border-hello-csv-primary indeterminate:bg-hello-csv-primary focus-visible:outline-hello-csv-hello-csv-primary col-start-1 row-start-1 appearance-none rounded-sm border border-gray-300 bg-white focus-visible:outline-2 focus-visible:outline-offset-2 disabled:border-gray-300 disabled:bg-gray-100 disabled:checked:bg-gray-100 forced-colors:appearance-auto"}),p.jsxs("svg",{fill:"none",viewBox:"0 0 14 14",className:"pointer-events-none col-start-1 row-start-1 size-3.5 self-center justify-self-center stroke-white group-has-disabled:stroke-gray-950/25",children:[p.jsx("path",{d:"M3 8L6 11L11 3.5",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:"opacity-0 group-has-checked:opacity-100"}),p.jsx("path",{d:"M3 7H11",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:"opacity-0 group-has-indeterminate:opacity-100"})]})]})}),n&&p.jsx("div",{className:"text-sm/6",children:p.jsx("label",{htmlFor:r,className:"font-medium text-gray-900",children:n})})]})}let Qs=!1;function An(){return Qs}const Qr=typeof document<"u"?d.useLayoutEffect:()=>{};function el(e){const t=d.useRef(null);return Qr(()=>{t.current=e},[e]),d.useCallback((...n)=>{const r=t.current;return r==null?void 0:r(...n)},[])}const Ue=e=>{var t;return(t=e==null?void 0:e.ownerDocument)!==null&&t!==void 0?t:document},ot=e=>e&&"window"in e&&e.window===e?e:Ue(e).defaultView||window;function tl(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&typeof e.nodeType=="number"}function nl(e){return tl(e)&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&"host"in e}function eo(e,t){if(!An())return t&&e?e.contains(t):!1;if(!e||!t)return!1;let n=t;for(;n!==null;){if(n===e)return!0;n.tagName==="SLOT"&&n.assignedSlot?n=n.assignedSlot.parentNode:nl(n)?n=n.host:n=n.parentNode}return!1}const kn=(e=document)=>{var t;if(!An())return e.activeElement;let n=e.activeElement;for(;n&&"shadowRoot"in n&&(!((t=n.shadowRoot)===null||t===void 0)&&t.activeElement);)n=n.shadowRoot.activeElement;return n};function to(e){return An()&&e.target.shadowRoot&&e.composedPath?e.composedPath()[0]:e.target}function rl(e){var t;return typeof window>"u"||window.navigator==null?!1:((t=window.navigator.userAgentData)===null||t===void 0?void 0:t.brands.some(n=>e.test(n.brand)))||e.test(window.navigator.userAgent)}function ol(e){var t;return typeof window<"u"&&window.navigator!=null?e.test(((t=window.navigator.userAgentData)===null||t===void 0?void 0:t.platform)||window.navigator.platform):!1}function no(e){let t=null;return()=>(t==null&&(t=e()),t)}const il=no(function(){return ol(/^Mac/i)}),sl=no(function(){return rl(/Android/i)});function ro(){let e=d.useRef(new Map),t=d.useCallback((o,i,s,l)=>{let a=l!=null&&l.once?(...u)=>{e.current.delete(s),s(...u)}:s;e.current.set(s,{type:i,eventTarget:o,fn:a,options:l}),o.addEventListener(i,a,l)},[]),n=d.useCallback((o,i,s,l)=>{var a;let u=((a=e.current.get(s))===null||a===void 0?void 0:a.fn)||s;o.removeEventListener(i,u,l),e.current.delete(s)},[]),r=d.useCallback(()=>{e.current.forEach((o,i)=>{n(o.eventTarget,o.type,i,o.options)})},[n]);return d.useEffect(()=>r,[r]),{addGlobalListener:t,removeGlobalListener:n,removeAllGlobalListeners:r}}function ll(e){return e.mozInputSource===0&&e.isTrusted?!0:sl()&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function oo(e){let t=e;return t.nativeEvent=e,t.isDefaultPrevented=()=>t.defaultPrevented,t.isPropagationStopped=()=>t.cancelBubble,t.persist=()=>{},t}function al(e,t){Object.defineProperty(e,"target",{value:t}),Object.defineProperty(e,"currentTarget",{value:t})}function io(e){let t=d.useRef({isFocused:!1,observer:null});Qr(()=>{const r=t.current;return()=>{r.observer&&(r.observer.disconnect(),r.observer=null)}},[]);let n=el(r=>{e==null||e(r)});return d.useCallback(r=>{if(r.target instanceof HTMLButtonElement||r.target instanceof HTMLInputElement||r.target instanceof HTMLTextAreaElement||r.target instanceof HTMLSelectElement){t.current.isFocused=!0;let o=r.target,i=s=>{if(t.current.isFocused=!1,o.disabled){let l=oo(s);n(l)}t.current.observer&&(t.current.observer.disconnect(),t.current.observer=null)};o.addEventListener("focusout",i,{once:!0}),t.current.observer=new MutationObserver(()=>{if(t.current.isFocused&&o.disabled){var s;(s=t.current.observer)===null||s===void 0||s.disconnect();let l=o===document.activeElement?null:document.activeElement;o.dispatchEvent(new FocusEvent("blur",{relatedTarget:l})),o.dispatchEvent(new FocusEvent("focusout",{bubbles:!0,relatedTarget:l}))}}),t.current.observer.observe(o,{attributes:!0,attributeFilter:["disabled"]})}},[n])}let ul=!1,Mt=null,Nn=new Set,Ft=new Map,it=!1,Dn=!1;const cl={Tab:!0,Escape:!0};function Ln(e,t){for(let n of Nn)n(e,t)}function dl(e){return!(e.metaKey||!il()&&e.altKey||e.ctrlKey||e.key==="Control"||e.key==="Shift"||e.key==="Meta")}function tn(e){it=!0,dl(e)&&(Mt="keyboard",Ln("keyboard",e))}function gt(e){Mt="pointer",(e.type==="mousedown"||e.type==="pointerdown")&&(it=!0,Ln("pointer",e))}function so(e){ll(e)&&(it=!0,Mt="virtual")}function lo(e){e.target===window||e.target===document||ul||!e.isTrusted||(!it&&!Dn&&(Mt="virtual",Ln("virtual",e)),it=!1,Dn=!1)}function ao(){it=!1,Dn=!0}function Vn(e){if(typeof window>"u"||Ft.get(ot(e)))return;const t=ot(e),n=Ue(e);let r=t.HTMLElement.prototype.focus;t.HTMLElement.prototype.focus=function(){it=!0,r.apply(this,arguments)},n.addEventListener("keydown",tn,!0),n.addEventListener("keyup",tn,!0),n.addEventListener("click",so,!0),t.addEventListener("focus",lo,!0),t.addEventListener("blur",ao,!1),typeof PointerEvent<"u"&&(n.addEventListener("pointerdown",gt,!0),n.addEventListener("pointermove",gt,!0),n.addEventListener("pointerup",gt,!0)),t.addEventListener("beforeunload",()=>{uo(e)},{once:!0}),Ft.set(t,{focus:r})}const uo=(e,t)=>{const n=ot(e),r=Ue(e);t&&r.removeEventListener("DOMContentLoaded",t),Ft.has(n)&&(n.HTMLElement.prototype.focus=Ft.get(n).focus,r.removeEventListener("keydown",tn,!0),r.removeEventListener("keyup",tn,!0),r.removeEventListener("click",so,!0),n.removeEventListener("focus",lo,!0),n.removeEventListener("blur",ao,!1),typeof PointerEvent<"u"&&(r.removeEventListener("pointerdown",gt,!0),r.removeEventListener("pointermove",gt,!0),r.removeEventListener("pointerup",gt,!0)),Ft.delete(n))};function fl(e){const t=Ue(e);let n;return t.readyState!=="loading"?Vn(e):(n=()=>{Vn(e)},t.addEventListener("DOMContentLoaded",n)),()=>uo(e,n)}typeof document<"u"&&fl();function co(){return Mt!=="pointer"}const pl=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]);function gl(e,t,n){let r=Ue(n==null?void 0:n.target);const o=typeof window<"u"?ot(n==null?void 0:n.target).HTMLInputElement:HTMLInputElement,i=typeof window<"u"?ot(n==null?void 0:n.target).HTMLTextAreaElement:HTMLTextAreaElement,s=typeof window<"u"?ot(n==null?void 0:n.target).HTMLElement:HTMLElement,l=typeof window<"u"?ot(n==null?void 0:n.target).KeyboardEvent:KeyboardEvent;return e=e||r.activeElement instanceof o&&!pl.has(r.activeElement.type)||r.activeElement instanceof i||r.activeElement instanceof s&&r.activeElement.isContentEditable,!(e&&t==="keyboard"&&n instanceof l&&!cl[n.key])}function ml(e,t,n){Vn(),d.useEffect(()=>{let r=(o,i)=>{gl(!!(n!=null&&n.isTextInput),o,i)&&e(co())};return Nn.add(r),()=>{Nn.delete(r)}},t)}function hl(e){let{isDisabled:t,onFocus:n,onBlur:r,onFocusChange:o}=e;const i=d.useCallback(a=>{if(a.target===a.currentTarget)return r&&r(a),o&&o(!1),!0},[r,o]),s=io(i),l=d.useCallback(a=>{const u=Ue(a.target),c=u?kn(u):kn();a.target===a.currentTarget&&c===to(a.nativeEvent)&&(n&&n(a),o&&o(!0),s(a))},[o,n,s]);return{focusProps:{onFocus:!t&&(n||o||r)?l:void 0,onBlur:!t&&(r||o)?i:void 0}}}function vl(e){let{isDisabled:t,onBlurWithin:n,onFocusWithin:r,onFocusWithinChange:o}=e,i=d.useRef({isFocusWithin:!1}),{addGlobalListener:s,removeAllGlobalListeners:l}=ro(),a=d.useCallback(g=>{g.currentTarget.contains(g.target)&&i.current.isFocusWithin&&!g.currentTarget.contains(g.relatedTarget)&&(i.current.isFocusWithin=!1,l(),n&&n(g),o&&o(!1))},[n,o,i,l]),u=io(a),c=d.useCallback(g=>{if(!g.currentTarget.contains(g.target))return;const h=Ue(g.target),f=kn(h);if(!i.current.isFocusWithin&&f===to(g.nativeEvent)){r&&r(g),o&&o(!0),i.current.isFocusWithin=!0,u(g);let m=g.currentTarget;s(h,"focus",v=>{if(i.current.isFocusWithin&&!eo(m,v.target)){let b=new h.defaultView.FocusEvent("blur",{relatedTarget:v.target});al(b,m);let C=oo(b);a(C)}},{capture:!0})}},[r,o,u,s,a]);return t?{focusWithinProps:{onFocus:void 0,onBlur:void 0}}:{focusWithinProps:{onFocus:c,onBlur:a}}}let Rn=!1,Hn=0;function wl(){Rn=!0,setTimeout(()=>{Rn=!1},50)}function fo(e){e.pointerType==="touch"&&wl()}function bl(){if(!(typeof document>"u"))return typeof PointerEvent<"u"&&document.addEventListener("pointerup",fo),Hn++,()=>{Hn--,!(Hn>0)&&typeof PointerEvent<"u"&&document.removeEventListener("pointerup",fo)}}function po(e){let{onHoverStart:t,onHoverChange:n,onHoverEnd:r,isDisabled:o}=e,[i,s]=d.useState(!1),l=d.useRef({isHovered:!1,ignoreEmulatedMouseEvents:!1,pointerType:"",target:null}).current;d.useEffect(bl,[]);let{addGlobalListener:a,removeAllGlobalListeners:u}=ro(),{hoverProps:c,triggerHoverEnd:g}=d.useMemo(()=>{let h=(v,b)=>{if(l.pointerType=b,o||b==="touch"||l.isHovered||!v.currentTarget.contains(v.target))return;l.isHovered=!0;let C=v.currentTarget;l.target=C,a(Ue(v.target),"pointerover",E=>{l.isHovered&&l.target&&!eo(l.target,E.target)&&f(E,E.pointerType)},{capture:!0}),t&&t({type:"hoverstart",target:C,pointerType:b}),n&&n(!0),s(!0)},f=(v,b)=>{let C=l.target;l.pointerType="",l.target=null,!(b==="touch"||!l.isHovered||!C)&&(l.isHovered=!1,u(),r&&r({type:"hoverend",target:C,pointerType:b}),n&&n(!1),s(!1))},m={};return typeof PointerEvent<"u"&&(m.onPointerEnter=v=>{Rn&&v.pointerType==="mouse"||h(v,v.pointerType)},m.onPointerLeave=v=>{!o&&v.currentTarget.contains(v.target)&&f(v,v.pointerType)}),{hoverProps:m,triggerHoverEnd:f}},[t,n,r,o,l,a,u]);return d.useEffect(()=>{o&&g({currentTarget:l.target},l.pointerType)},[o]),{hoverProps:c,isHovered:i}}function go(e={}){let{autoFocus:t=!1,isTextInput:n,within:r}=e,o=d.useRef({isFocused:!1,isFocusVisible:t||co()}),[i,s]=d.useState(!1),[l,a]=d.useState(()=>o.current.isFocused&&o.current.isFocusVisible),u=d.useCallback(()=>a(o.current.isFocused&&o.current.isFocusVisible),[]),c=d.useCallback(f=>{o.current.isFocused=f,s(f),u()},[u]);ml(f=>{o.current.isFocusVisible=f,u()},[],{isTextInput:n});let{focusProps:g}=hl({isDisabled:r,onFocusChange:c}),{focusWithinProps:h}=vl({isDisabled:!r,onFocusWithinChange:c});return{isFocused:i,isFocusVisible:l,focusProps:r?h:g}}var yl=Object.defineProperty,xl=(e,t,n)=>t in e?yl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,zn=(e,t,n)=>(xl(e,typeof t!="symbol"?t+"":t,n),n);let Sl=class{constructor(){zn(this,"current",this.detect()),zn(this,"handoffState","pending"),zn(this,"currentId",0)}set(t){this.current!==t&&(this.handoffState="pending",this.currentId=0,this.current=t)}reset(){this.set(this.detect())}nextId(){return++this.currentId}get isServer(){return this.current==="server"}get isClient(){return this.current==="client"}detect(){return typeof window>"u"||typeof document>"u"?"server":"client"}handoff(){this.handoffState==="pending"&&(this.handoffState="complete")}get isHandoffComplete(){return this.handoffState==="complete"}},st=new Sl;function mt(e){return st.isServer?null:e instanceof Node?e.ownerDocument:e!=null&&e.hasOwnProperty("current")&&e.current instanceof Node?e.current.ownerDocument:document}function nn(e){typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e).catch(t=>setTimeout(()=>{throw t}))}function Ae(){let e=[],t={addEventListener(n,r,o,i){return n.addEventListener(r,o,i),t.add(()=>n.removeEventListener(r,o,i))},requestAnimationFrame(...n){let r=requestAnimationFrame(...n);return t.add(()=>cancelAnimationFrame(r))},nextFrame(...n){return t.requestAnimationFrame(()=>t.requestAnimationFrame(...n))},setTimeout(...n){let r=setTimeout(...n);return t.add(()=>clearTimeout(r))},microTask(...n){let r={current:!0};return nn(()=>{r.current&&n[0]()}),t.add(()=>{r.current=!1})},style(n,r,o){let i=n.style.getPropertyValue(r);return Object.assign(n.style,{[r]:o}),this.add(()=>{Object.assign(n.style,{[r]:i})})},group(n){let r=Ae();return n(r),this.add(()=>r.dispose())},add(n){return e.includes(n)||e.push(n),()=>{let r=e.indexOf(n);if(r>=0)for(let o of e.splice(r,1))o()}},dispose(){for(let n of e.splice(0))n()}};return t}function lt(){let[e]=d.useState(Ae);return d.useEffect(()=>()=>e.dispose(),[e]),e}let re=(e,t)=>{st.isServer?d.useEffect(e,t):d.useLayoutEffect(e,t)};function qe(e){let t=d.useRef(e);return re(()=>{t.current=e},[e]),t}let z=function(e){let t=qe(e);return d.useCallback((...n)=>t.current(...n),[t])};function Cl(e){let t=e.width/2,n=e.height/2;return{top:e.clientY-n,right:e.clientX+t,bottom:e.clientY+n,left:e.clientX-t}}function El(e,t){return!(!e||!t||e.right<t.left||e.left>t.right||e.bottom<t.top||e.top>t.bottom)}function $l({disabled:e=!1}={}){let t=d.useRef(null),[n,r]=d.useState(!1),o=lt(),i=z(()=>{t.current=null,r(!1),o.dispose()}),s=z(l=>{if(o.dispose(),t.current===null){t.current=l.currentTarget,r(!0);{let a=mt(l.currentTarget);o.addEventListener(a,"pointerup",i,!1),o.addEventListener(a,"pointermove",u=>{if(t.current){let c=Cl(u);r(El(c,t.current.getBoundingClientRect()))}},!1),o.addEventListener(a,"pointercancel",i,!1)}}});return{pressed:n,pressProps:e?{}:{onPointerDown:s,onPointerUp:i,onClick:i}}}let _l=d.createContext(void 0);function Bn(){return d.useContext(_l)}function jn(...e){return Array.from(new Set(e.flatMap(t=>typeof t=="string"?t.split(" "):[]))).filter(Boolean).join(" ")}function Ce(e,t,...n){if(e in t){let o=t[e];return typeof o=="function"?o(...n):o}let r=new Error(`Tried to handle "${e}" but there is no handler defined. Only defined handlers are: ${Object.keys(t).map(o=>`"${o}"`).join(", ")}.`);throw Error.captureStackTrace&&Error.captureStackTrace(r,Ce),r}var ht=(e=>(e[e.None=0]="None",e[e.RenderStrategy=1]="RenderStrategy",e[e.Static=2]="Static",e))(ht||{}),Ke=(e=>(e[e.Unmount=0]="Unmount",e[e.Hidden=1]="Hidden",e))(Ke||{});function fe(){let e=Tl();return d.useCallback(t=>Il({mergeRefs:e,...t}),[e])}function Il({ourProps:e,theirProps:t,slot:n,defaultTag:r,features:o,visible:i=!0,name:s,mergeRefs:l}){l=l??Ml;let a=mo(t,e);if(i)return rn(a,n,r,s,l);let u=o??0;if(u&2){let{static:c=!1,...g}=a;if(c)return rn(g,n,r,s,l)}if(u&1){let{unmount:c=!0,...g}=a;return Ce(c?0:1,{0(){return null},1(){return rn({...g,hidden:!0,style:{display:"none"}},n,r,s,l)}})}return rn(a,n,r,s,l)}function rn(e,t={},n,r,o){let{as:i=n,children:s,refName:l="ref",...a}=Wn(e,["unmount","static"]),u=e.ref!==void 0?{[l]:e.ref}:{},c=typeof s=="function"?s(t):s;"className"in a&&a.className&&typeof a.className=="function"&&(a.className=a.className(t)),a["aria-labelledby"]&&a["aria-labelledby"]===a.id&&(a["aria-labelledby"]=void 0);let g={};if(t){let h=!1,f=[];for(let[m,v]of Object.entries(t))typeof v=="boolean"&&(h=!0),v===!0&&f.push(m.replace(/([A-Z])/g,b=>`-${b.toLowerCase()}`));if(h){g["data-headlessui-state"]=f.join(" ");for(let m of f)g[`data-${m}`]=""}}if(i===d.Fragment&&(Object.keys(Ye(a)).length>0||Object.keys(Ye(g)).length>0))if(!d.isValidElement(c)||Array.isArray(c)&&c.length>1){if(Object.keys(Ye(a)).length>0)throw new Error(['Passing props on "Fragment"!',"",`The current component <${r} /> is rendering a "Fragment".`,"However we need to passthrough the following props:",Object.keys(Ye(a)).concat(Object.keys(Ye(g))).map(h=>` - ${h}`).join(` `),"","You can apply a few solutions:",['Add an `as="..."` prop, to ensure that we render an actual element instead of a "Fragment".',"Render a single element as the child so that we can forward the props onto that element."].map(h=>` - ${h}`).join(` `)].join(` `))}else{let h=c.props,f=h==null?void 0:h.className,m=typeof f=="function"?(...C)=>jn(f(...C),a.className):jn(f,a.className),v=m?{className:m}:{},b=mo(c.props,Ye(Wn(a,["ref"])));for(let C in g)C in b&&delete g[C];return d.cloneElement(c,Object.assign({},b,g,u,{ref:o(Fl(c),u.ref)},v))}return d.createElement(i,Object.assign({},Wn(a,["ref"]),i!==d.Fragment&&u,i!==d.Fragment&&g),c)}function Tl(){let e=d.useRef([]),t=d.useCallback(n=>{for(let r of e.current)r!=null&&(typeof r=="function"?r(n):r.current=n)},[]);return(...n)=>{if(!n.every(r=>r==null))return e.current=n,t}}function Ml(...e){return e.every(t=>t==null)?void 0:t=>{for(let n of e)n!=null&&(typeof n=="function"?n(t):n.current=t)}}function mo(...e){if(e.length===0)return{};if(e.length===1)return e[0];let t={},n={};for(let r of e)for(let o in r)o.startsWith("on")&&typeof r[o]=="function"?(n[o]!=null||(n[o]=[]),n[o].push(r[o])):t[o]=r[o];if(t.disabled||t["aria-disabled"])for(let r in n)/^(on(?:Click|Pointer|Mouse|Key)(?:Down|Up|Press)?)$/.test(r)&&(n[r]=[o=>{var i;return(i=o==null?void 0:o.preventDefault)==null?void 0:i.call(o)}]);for(let r in n)Object.assign(t,{[r](o,...i){let s=n[r];for(let l of s){if((o instanceof Event||(o==null?void 0:o.nativeEvent)instanceof Event)&&o.defaultPrevented)return;l(o,...i)}}});return t}function Gn(...e){if(e.length===0)return{};if(e.length===1)return e[0];let t={},n={};for(let r of e)for(let o in r)o.startsWith("on")&&typeof r[o]=="function"?(n[o]!=null||(n[o]=[]),n[o].push(r[o])):t[o]=r[o];for(let r in n)Object.assign(t,{[r](...o){let i=n[r];for(let s of i)s==null||s(...o)}});return t}function ue(e){var t;return Object.assign(d.forwardRef(e),{displayName:(t=e.displayName)!=null?t:e.name})}function Ye(e){let t=Object.assign({},e);for(let n in t)t[n]===void 0&&delete t[n];return t}function Wn(e,t=[]){let n=Object.assign({},e);for(let r of t)r in n&&delete n[r];return n}function Fl(e){return d.version.split(".")[0]>="19"?e.props.ref:e.ref}function Ol(e,t,n){let[r,o]=d.useState(n),i=e!==void 0,s=d.useRef(i),l=d.useRef(!1),a=d.useRef(!1);return i&&!s.current&&!l.current?(l.current=!0,s.current=i,console.error("A component is changing from uncontrolled to controlled. This may be caused by the value changing from undefined to a defined value, which should not happen.")):!i&&s.current&&!a.current&&(a.current=!0,s.current=i,console.error("A component is changing from controlled to uncontrolled. This may be caused by the value changing from a defined value to undefined, which should not happen.")),[i?e:r,z(u=>(i||o(u),t==null?void 0:t(u)))]}function Pl(e){let[t]=d.useState(e);return t}function ho(e={},t=null,n=[]){for(let[r,o]of Object.entries(e))wo(n,vo(t,r),o);return n}function vo(e,t){return e?e+"["+t+"]":t}function wo(e,t,n){if(Array.isArray(n))for(let[r,o]of n.entries())wo(e,vo(t,r.toString()),o);else n instanceof Date?e.push([t,n.toISOString()]):typeof n=="boolean"?e.push([t,n?"1":"0"]):typeof n=="string"?e.push([t,n]):typeof n=="number"?e.push([t,`${n}`]):n==null?e.push([t,""]):ho(n,t,e)}let Al="span";var vt=(e=>(e[e.None=1]="None",e[e.Focusable=2]="Focusable",e[e.Hidden=4]="Hidden",e))(vt||{});function kl(e,t){var n;let{features:r=1,...o}=e,i={ref:t,"aria-hidden":(r&2)===2?!0:(n=o["aria-hidden"])!=null?n:void 0,hidden:(r&4)===4?!0:void 0,style:{position:"fixed",top:1,left:1,width:1,height:0,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0",...(r&4)===4&&(r&2)!==2&&{display:"none"}}};return fe()({ourProps:i,theirProps:o,slot:{},defaultTag:Al,name:"Hidden"})}let Ot=ue(kl),Nl=d.createContext(null);function Dl({children:e}){let t=d.useContext(Nl);if(!t)return d.createElement(d.Fragment,null,e);let{target:n}=t;return n?Fe.createPortal(d.createElement(d.Fragment,null,e),n):null}function Ll({data:e,form:t,disabled:n,onReset:r,overrides:o}){let[i,s]=d.useState(null),l=lt();return d.useEffect(()=>{if(r&&i)return l.addEventListener(i,"reset",r)},[i,t,r]),d.createElement(Dl,null,d.createElement(Vl,{setForm:s,formId:t}),ho(e).map(([a,u])=>d.createElement(Ot,{features:vt.Hidden,...Ye({key:a,as:"input",type:"hidden",hidden:!0,readOnly:!0,form:t,disabled:n,name:a,value:u,...o})})))}function Vl({setForm:e,formId:t}){return d.useEffect(()=>{if(t){let n=document.getElementById(t);n&&e(n)}},[e,t]),t?null:d.createElement(Ot,{features:vt.Hidden,as:"input",type:"hidden",hidden:!0,readOnly:!0,ref:n=>{if(!n)return;let r=n.closest("form");r&&e(r)}})}let Rl=d.createContext(void 0);function bo(){return d.useContext(Rl)}function Hl(e){let t=e.parentElement,n=null;for(;t&&!(t instanceof HTMLFieldSetElement);)t instanceof HTMLLegendElement&&(n=t),t=t.parentElement;let r=(t==null?void 0:t.getAttribute("disabled"))==="";return r&&zl(n)?!1:r}function zl(e){if(!e)return!1;let t=e.previousElementSibling;for(;t!==null;){if(t instanceof HTMLLegendElement)return!1;t=t.previousElementSibling}return!0}let yo=Symbol();function Bl(e,t=!0){return Object.assign(e,{[yo]:t})}function ye(...e){let t=d.useRef(e);d.useEffect(()=>{t.current=e},[e]);let n=z(r=>{for(let o of t.current)o!=null&&(typeof o=="function"?o(r):o.current=r)});return e.every(r=>r==null||(r==null?void 0:r[yo]))?void 0:n}let on=d.createContext(null);on.displayName="DescriptionContext";function xo(){let e=d.useContext(on);if(e===null){let t=new Error("You used a <Description /> component, but it is not inside a relevant parent.");throw Error.captureStackTrace&&Error.captureStackTrace(t,xo),t}return e}function jl(){var e,t;return(t=(e=d.useContext(on))==null?void 0:e.value)!=null?t:void 0}function Gl(){let[e,t]=d.useState([]);return[e.length>0?e.join(" "):void 0,d.useMemo(()=>function(n){let r=z(i=>(t(s=>[...s,i]),()=>t(s=>{let l=s.slice(),a=l.indexOf(i);return a!==-1&&l.splice(a,1),l}))),o=d.useMemo(()=>({register:r,slot:n.slot,name:n.name,props:n.props,value:n.value}),[r,n.slot,n.name,n.props,n.value]);return d.createElement(on.Provider,{value:o},n.children)},[t])]}let Wl="p";function Ul(e,t){let n=d.useId(),r=Bn(),{id:o=`headlessui-description-${n}`,...i}=e,s=xo(),l=ye(t);re(()=>s.register(o),[o,s.register]);let a=r||!1,u=d.useMemo(()=>({...s.slot,disabled:a}),[s.slot,a]),c={ref:l,...s.props,id:o};return fe()({ourProps:c,theirProps:i,slot:u,defaultTag:Wl,name:s.name||"Description"})}let ql=ue(Ul),Kl=Object.assign(ql,{});var me=(e=>(e.Space=" ",e.Enter="Enter",e.Escape="Escape",e.Backspace="Backspace",e.Delete="Delete",e.ArrowLeft="ArrowLeft",e.ArrowUp="ArrowUp",e.ArrowRight="ArrowRight",e.ArrowDown="ArrowDown",e.Home="Home",e.End="End",e.PageUp="PageUp",e.PageDown="PageDown",e.Tab="Tab",e))(me||{});let sn=d.createContext(null);sn.displayName="LabelContext";function So(){let e=d.useContext(sn);if(e===null){let t=new Error("You used a <Label /> component, but it is not inside a relevant parent.");throw Error.captureStackTrace&&Error.captureStackTrace(t,So),t}return e}function ln(e){var t,n,r;let o=(n=(t=d.useContext(sn))==null?void 0:t.value)!=null?n:void 0;return((r=e==null?void 0:e.length)!=null?r:0)>0?[o,...e].filter(Boolean).join(" "):o}function Yl({inherit:e=!1}={}){let t=ln(),[n,r]=d.useState([]),o=e?[t,...n].filter(Boolean):n;return[o.length>0?o.join(" "):void 0,d.useMemo(()=>function(i){let s=z(a=>(r(u=>[...u,a]),()=>r(u=>{let c=u.slice(),g=c.indexOf(a);return g!==-1&&c.splice(g,1),c}))),l=d.useMemo(()=>({register:s,slot:i.slot,name:i.name,props:i.props,value:i.value}),[s,i.slot,i.name,i.props,i.value]);return d.createElement(sn.Provider,{value:l},i.children)},[r])]}let Xl="label";function Zl(e,t){var n;let r=d.useId(),o=So(),i=bo(),s=Bn(),{id:l=`headlessui-label-${r}`,htmlFor:a=i??((n=o.props)==null?void 0:n.htmlFor),passive:u=!1,...c}=e,g=ye(t);re(()=>o.register(l),[l,o.register]);let h=z(b=>{let C=b.currentTarget;if(C instanceof HTMLLabelElement&&b.preventDefault(),o.props&&"onClick"in o.props&&typeof o.props.onClick=="function"&&o.props.onClick(b),C instanceof HTMLLabelElement){let E=document.getElementById(C.htmlFor);if(E){let S=E.getAttribute("disabled");if(S==="true"||S==="")return;let _=E.getAttribute("aria-disabled");if(_==="true"||_==="")return;(E instanceof HTMLInputElement&&(E.type==="radio"||E.type==="checkbox")||E.role==="radio"||E.role==="checkbox"||E.role==="switch")&&E.click(),E.focus({preventScroll:!0})}}}),f=s||!1,m=d.useMemo(()=>({...o.slot,disabled:f}),[o.slot,f]),v={ref:g,...o.props,id:l,htmlFor:a,onClick:h};return u&&("onClick"in v&&(delete v.htmlFor,delete v.onClick),"onClick"in c&&delete c.onClick),fe()({ourProps:v,theirProps:c,slot:m,defaultTag:a?Xl:"div",name:o.name||"Label"})}let Jl=ue(Zl),Ql=Object.assign(Jl,{}),ea=d.createContext(()=>{});function ta({value:e,children:t}){return d.createElement(ea.Provider,{value:e},t)}function wt(e,t,n){let r=n.initialDeps??[],o;function i(){var s,l,a,u;let c;n.key&&((s=n.debug)!=null&&s.call(n))&&(c=Date.now());const g=e();if(!(g.length!==r.length||g.some((m,v)=>r[v]!==m)))return o;r=g;let f;if(n.key&&((l=n.debug)!=null&&l.call(n))&&(f=Date.now()),o=t(...g),n.key&&((a=n.debug)!=null&&a.call(n))){const m=Math.round((Date.now()-c)*100)/100,v=Math.round((Date.now()-f)*100)/100,b=v/16,C=(E,S)=>{for(E=String(E);E.length<S;)E=" "+E;return E};console.info(`%c⏱ ${C(v,5)} /${C(m,5)} ms`,` font-size: .6rem; font-weight: bold; color: hsl(${Math.max(0,Math.min(120-120*b,120))}deg 100% 31%);`,n==null?void 0:n.key)}return(u=n==null?void 0:n.onChange)==null||u.call(n,o),o}return i.updateDeps=s=>{r=s},i}function Co(e,t){if(e===void 0)throw new Error("Unexpected undefined");return e}const na=(e,t)=>Math.abs(e-t)<=1,ra=(e,t,n)=>{let r;return function(...o){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,o),n)}};var Pt={NODE_ENV:"production"};const Eo=e=>{const{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},oa=e=>e,ia=e=>{const t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1),r=[];for(let o=t;o<=n;o++)r.push(o);return r},sa=(e,t)=>{const n=e.scrollElement;if(!n)return;const r=e.targetWindow;if(!r)return;const o=s=>{const{width:l,height:a}=s;t({width:Math.round(l),height:Math.round(a)})};if(o(Eo(n)),!r.ResizeObserver)return()=>{};const i=new r.ResizeObserver(s=>{const l=()=>{const a=s[0];if(a!=null&&a.borderBoxSize){const u=a.borderBoxSize[0];if(u){o({width:u.inlineSize,height:u.blockSize});return}}o(Eo(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(l):l()});return i.observe(n,{box:"border-box"}),()=>{i.unobserve(n)}},$o={passive:!0},_o=typeof window>"u"?!0:"onscrollend"in window,la=(e,t)=>{const n=e.scrollElement;if(!n)return;const r=e.targetWindow;if(!r)return;let o=0;const i=e.options.useScrollendEvent&&_o?()=>{}:ra(r,()=>{t(o,!1)},e.options.isScrollingResetDelay),s=c=>()=>{const{horizontal:g,isRtl:h}=e.options;o=g?n.scrollLeft*(h&&-1||1):n.scrollTop,i(),t(o,c)},l=s(!0),a=s(!1);a(),n.addEventListener("scroll",l,$o);const u=e.options.useScrollendEvent&&_o;return u&&n.addEventListener("scrollend",a,$o),()=>{n.removeEventListener("scroll",l),u&&n.removeEventListener("scrollend",a)}},aa=(e,t,n)=>{if(t!=null&&t.borderBoxSize){const r=t.borderBoxSize[0];if(r)return Math.round(r[n.options.horizontal?"inlineSize":"blockSize"])}return e[n.options.horizontal?"offsetWidth":"offsetHeight"]},ua=(e,{adjustments:t=0,behavior:n},r)=>{var o,i;const s=e+t;(i=(o=r.scrollElement)==null?void 0:o.scrollTo)==null||i.call(o,{[r.options.horizontal?"left":"top"]:s,behavior:n})};class ca{constructor(t){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollToIndexTimeoutId=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.pendingMeasuredCacheIndexes=[],this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.observer=(()=>{let n=null;const r=()=>n||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:n=new this.targetWindow.ResizeObserver(o=>{o.forEach(i=>{const s=()=>{this._measureElement(i.target,i)};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(s):s()})}));return{disconnect:()=>{var o;(o=r())==null||o.disconnect(),n=null},observe:o=>{var i;return(i=r())==null?void 0:i.observe(o,{box:"border-box"})},unobserve:o=>{var i;return(i=r())==null?void 0:i.unobserve(o)}}})(),this.range=null,this.setOptions=n=>{Object.entries(n).forEach(([r,o])=>{typeof o>"u"&&delete n[r]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:oa,rangeExtractor:ia,onChange:()=>{},measureElement:aa,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...n}},this.notify=n=>{var r,o;(o=(r=this.options).onChange)==null||o.call(r,this,n)},this.maybeNotify=wt(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),n=>{this.notify(n)},{key:Pt.NODE_ENV!=="production",debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(n=>n()),this.unsubs=[],this.observer.disconnect(),this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var n;const r=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==r){if(this.cleanup(),!r){this.maybeNotify();return}this.scrollElement=r,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((n=this.scrollElement)==null?void 0:n.window)??null,this.elementsCache.forEach(o=>{this.observer.observe(o)}),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0}),this.unsubs.push(this.options.observeElementRect(this,o=>{this.scrollRect=o,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(o,i)=>{this.scrollAdjustments=0,this.scrollDirection=i?this.getScrollOffset()<o?"forward":"backward":null,this.scrollOffset=o,this.isScrolling=i,this.maybeNotify()}))}},this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(n,r)=>{const o=new Map,i=new Map;for(let s=r-1;s>=0;s--){const l=n[s];if(o.has(l.lane))continue;const a=i.get(l.lane);if(a==null||l.end>a.end?i.set(l.lane,l):l.end<a.end&&o.set(l.lane,!0),o.size===this.options.lanes)break}return i.size===this.options.lanes?Array.from(i.values()).sort((s,l)=>s.end===l.end?s.index-l.index:s.end-l.end)[0]:void 0},this.getMeasurementOptions=wt(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled],(n,r,o,i,s)=>(this.pendingMeasuredCacheIndexes=[],{count:n,paddingStart:r,scrollMargin:o,getItemKey:i,enabled:s}),{key:!1}),this.getMeasurements=wt(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:n,paddingStart:r,scrollMargin:o,getItemKey:i,enabled:s},l)=>{if(!s)return this.measurementsCache=[],this.itemSizeCache.clear(),[];this.measurementsCache.length===0&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(c=>{this.itemSizeCache.set(c.key,c.size)}));const a=this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[];const u=this.measurementsCache.slice(0,a);for(let c=a;c<n;c++){const g=i(c),h=this.options.lanes===1?u[c-1]:this.getFurthestMeasurement(u,c),f=h?h.end+this.options.gap:r+o,m=l.get(g),v=typeof m=="number"?m:this.options.estimateSize(c),b=f+v,C=h?h.lane:c%this.options.lanes;u[c]={index:c,start:f,size:v,end:b,key:g,lane:C}}return this.measurementsCache=u,u},{key:Pt.NODE_ENV!=="production",debug:()=>this.options.debug}),this.calculateRange=wt(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(n,r,o,i)=>this.range=n.length>0&&r>0?da({measurements:n,outerSize:r,scrollOffset:o,lanes:i}):null,{key:Pt.NODE_ENV!=="production",debug:()=>this.options.debug}),this.getVirtualIndexes=wt(()=>{let n=null,r=null;const o=this.calculateRange();return o&&(n=o.startIndex,r=o.endIndex),this.maybeNotify.updateDeps([this.isScrolling,n,r]),[this.options.rangeExtractor,this.options.overscan,this.options.count,n,r]},(n,r,o,i,s)=>i===null||s===null?[]:n({startIndex:i,endIndex:s,overscan:r,count:o}),{key:Pt.NODE_ENV!=="production",debug:()=>this.options.debug}),this.indexFromElement=n=>{const r=this.options.indexAttribute,o=n.getAttribute(r);return o?parseInt(o,10):(console.warn(`Missing attribute name '${r}={index}' on measured element.`),-1)},this._measureElement=(n,r)=>{const o=this.indexFromElement(n),i=this.measurementsCache[o];if(!i)return;const s=i.key,l=this.elementsCache.get(s);l!==n&&(l&&this.observer.unobserve(l),this.observer.observe(n),this.elementsCache.set(s,n)),n.isConnected&&this.resizeItem(o,this.options.measureElement(n,r,this))},this.resizeItem=(n,r)=>{const o=this.measurementsCache[n];if(!o)return;const i=this.itemSizeCache.get(o.key)??o.size,s=r-i;s!==0&&((this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(o,s,this):o.start<this.getScrollOffset()+this.scrollAdjustments)&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=s,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(o.index),this.itemSizeCache=new Map(this.itemSizeCache.set(o.key,r)),this.notify(!1))},this.measureElement=n=>{if(!n){this.elementsCache.forEach((r,o)=>{r.isConnected||(this.observer.unobserve(r),this.elementsCache.delete(o))});return}this._measureElement(n,void 0)},this.getVirtualItems=wt(()=>[this.getVirtualIndexes(),this.getMeasurements()],(n,r)=>{const o=[];for(let i=0,s=n.length;i<s;i++){const l=n[i],a=r[l];o.push(a)}return o},{key:Pt.NODE_ENV!=="production",debug:()=>this.options.debug}),this.getVirtualItemForOffset=n=>{const r=this.getMeasurements();if(r.length!==0)return Co(r[Io(0,r.length-1,o=>Co(r[o]).start,n)])},this.getOffsetForAlignment=(n,r,o=0)=>{const i=this.getSize(),s=this.getScrollOffset();r==="auto"&&(r=n>=s+i?"end":"start"),r==="center"?n+=(o-i)/2:r==="end"&&(n-=i);const l=this.getTotalSize()-i;return Math.max(Math.min(l,n),0)},this.getOffsetForIndex=(n,r="auto")=>{n=Math.max(0,Math.min(n,this.options.count-1));const o=this.measurementsCache[n];if(!o)return;const i=this.getSize(),s=this.getScrollOffset();if(r==="auto")if(o.end>=s+i-this.options.scrollPaddingEnd)r="end";else if(o.start<=s+this.options.scrollPaddingStart)r="start";else return[s,r];const l=r==="end"?o.end+this.options.scrollPaddingEnd:o.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(l,r,o.size),r]},this.isDynamicMode=()=>this.elementsCache.size>0,this.cancelScrollToIndex=()=>{this.scrollToIndexTimeoutId!==null&&this.targetWindow&&(this.targetWindow.clearTimeout(this.scrollToIndexTimeoutId),this.scrollToIndexTimeoutId=null)},this.scrollToOffset=(n,{align:r="start",behavior:o}={})=>{this.cancelScrollToIndex(),o==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getOffsetForAlignment(n,r),{adjustments:void 0,behavior:o})},this.scrollToIndex=(n,{align:r="auto",behavior:o}={})=>{n=Math.max(0,Math.min(n,this.options.count-1)),this.cancelScrollToIndex(),o==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size.");const i=this.getOffsetForIndex(n,r);if(!i)return;const[s,l]=i;this._scrollToOffset(s,{adjustments:void 0,behavior:o}),o!=="smooth"&&this.isDynamicMode()&&this.targetWindow&&(this.scrollToIndexTimeoutId=this.targetWindow.setTimeout(()=>{if(this.scrollToIndexTimeoutId=null,this.elementsCache.has(this.options.getItemKey(n))){const u=this.getOffsetForIndex(n,l);if(!u)return;const[c]=u,g=this.getScrollOffset();na(c,g)||this.scrollToIndex(n,{align:l,behavior:o})}else this.scrollToIndex(n,{align:l,behavior:o})}))},this.scrollBy=(n,{behavior:r}={})=>{this.cancelScrollToIndex(),r==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getScrollOffset()+n,{adjustments:void 0,behavior:r})},this.getTotalSize=()=>{var n;const r=this.getMeasurements();let o;if(r.length===0)o=this.options.paddingStart;else if(this.options.lanes===1)o=((n=r[r.length-1])==null?void 0:n.end)??0;else{const i=Array(this.options.lanes).fill(null);let s=r.length-1;for(;s>=0&&i.some(l=>l===null);){const l=r[s];i[l.lane]===null&&(i[l.lane]=l.end),s--}o=Math.max(...i.filter(l=>l!==null))}return Math.max(o-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(n,{adjustments:r,behavior:o})=>{this.options.scrollToFn(n,{behavior:o,adjustments:r},this)},this.measure=()=>{this.itemSizeCache=new Map,this.notify(!1)},this.setOptions(t)}}const Io=(e,t,n,r)=>{for(;e<=t;){const o=(e+t)/2|0,i=n(o);if(i<r)e=o+1;else if(i>r)t=o-1;else return o}return e>0?e-1:0};function da({measurements:e,outerSize:t,scrollOffset:n,lanes:r}){const o=e.length-1,i=a=>e[a].start;if(e.length<=r)return{startIndex:0,endIndex:o};let s=Io(0,o,i,n),l=s;if(r===1)for(;l<o&&e[l].end<n+t;)l++;else if(r>1){const a=Array(r).fill(0);for(;l<o&&a.some(c=>c<n+t);){const c=e[l];a[c.lane]=c.end,l++}const u=Array(r).fill(n+t);for(;s>=0&&u.some(c=>c>=n);){const c=e[s];u[c.lane]=c.start,s--}s=Math.max(0,s-s%r),l=Math.min(o,l+(r-1-l%r))}return{startIndex:s,endIndex:l}}const To=typeof document<"u"?$.useLayoutEffect:$.useEffect;function fa(e){const t=$.useReducer(()=>({}),{})[1],n={...e,onChange:(o,i)=>{var s;i?Fe.flushSync(t):t(),(s=e.onChange)==null||s.call(e,o,i)}},[r]=$.useState(()=>new ca(n));return r.setOptions(n),To(()=>r._didMount(),[]),To(()=>r._willUpdate()),r}function Mo(e){return fa({observeElementRect:sa,observeElementOffset:la,scrollToFn:ua,...e})}function pa(e,t){return e!==null&&t!==null&&typeof e=="object"&&typeof t=="object"&&"id"in e&&"id"in t?e.id===t.id:e===t}function ga(e=pa){return d.useCallback((t,n)=>{if(typeof e=="string"){let r=e;return(t==null?void 0:t[r])===(n==null?void 0:n[r])}return e(t,n)},[e])}function ma(e){if(e===null)return{width:0,height:0};let{width:t,height:n}=e.getBoundingClientRect();return{width:t,height:n}}function Fo(e,t=!1){let[n,r]=d.useReducer(()=>({}),{}),o=d.useMemo(()=>ma(e),[e,n]);return re(()=>{if(!e)return;let i=new ResizeObserver(r);return i.observe(e),()=>{i.disconnect()}},[e]),t?{width:`${o.width}px`,height:`${o.height}px`}:o}let ha=class extends Map{constructor(t){super(),this.factory=t}get(t){let n=super.get(t);return n===void 0&&(n=this.factory(t),this.set(t,n)),n}};function Oo(e,t){let n=e(),r=new Set;return{getSnapshot(){return n},subscribe(o){return r.add(o),()=>r.delete(o)},dispatch(o,...i){let s=t[o].call(n,...i);s&&(n=s,r.forEach(l=>l()))}}}function Po(e){return d.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getSnapshot)}let va=new ha(()=>Oo(()=>[],{ADD(e){return this.includes(e)?this:[...this,e]},REMOVE(e){let t=this.indexOf(e);if(t===-1)return this;let n=this.slice();return n.splice(t,1),n}}));function bt(e,t){let n=va.get(t),r=d.useId(),o=Po(n);if(re(()=>{if(e)return n.dispatch("ADD",r),()=>n.dispatch("REMOVE",r)},[n,e]),!e)return!1;let i=o.indexOf(r),s=o.length;return i===-1&&(i=s,s+=1),i===s-1}let Un=new Map,At=new Map;function Ao(e){var t;let n=(t=At.get(e))!=null?t:0;return At.set(e,n+1),n!==0?()=>ko(e):(Un.set(e,{"aria-hidden":e.getAttribute("aria-hidden"),inert:e.inert}),e.setAttribute("aria-hidden","true"),e.inert=!0,()=>ko(e))}function ko(e){var t;let n=(t=At.get(e))!=null?t:1;if(n===1?At.delete(e):At.set(e,n-1),n!==1)return;let r=Un.get(e);r&&(r["aria-hidden"]===null?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",r["aria-hidden"]),e.inert=r.inert,Un.delete(e))}function No(e,{allowed:t,disallowed:n}={}){let r=bt(e,"inert-others");re(()=>{var o,i;if(!r)return;let s=Ae();for(let a of(o=n==null?void 0:n())!=null?o:[])a&&s.add(Ao(a));let l=(i=t==null?void 0:t())!=null?i:[];for(let a of l){if(!a)continue;let u=mt(a);if(!u)continue;let c=a.parentElement;for(;c&&c!==u.body;){for(let g of c.children)l.some(h=>g.contains(h))||s.add(Ao(g));c=c.parentElement}}return s.dispose},[r,t,n])}function Do(e,t,n){let r=qe(o=>{let i=o.getBoundingClientRect();i.x===0&&i.y===0&&i.width===0&&i.height===0&&n()});d.useEffect(()=>{if(!e)return;let o=t===null?null:t instanceof HTMLElement?t:t.current;if(!o)return;let i=Ae();if(typeof ResizeObserver<"u"){let s=new ResizeObserver(()=>r.current(o));s.observe(o),i.add(()=>s.disconnect())}if(typeof IntersectionObserver<"u"){let s=new IntersectionObserver(()=>r.current(o));s.observe(o),i.add(()=>s.disconnect())}return()=>i.dispose()},[t,r,e])}let an=["[contentEditable=true]","[tabindex]","a[href]","area[href]","button:not([disabled])","iframe","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].map(e=>`${e}:not([tabindex='-1'])`).join(","),wa=["[data-autofocus]"].map(e=>`${e}:not([tabindex='-1'])`).join(",");var ze=(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",e[e.AutoFocus=64]="AutoFocus",e))(ze||{}),qn=(e=>(e[e.Error=0]="Error",e[e.Overflow=1]="Overflow",e[e.Success=2]="Success",e[e.Underflow=3]="Underflow",e))(qn||{}),ba=(e=>(e[e.Previous=-1]="Previous",e[e.Next=1]="Next",e))(ba||{});function ya(e=document.body){return e==null?[]:Array.from(e.querySelectorAll(an)).sort((t,n)=>Math.sign((t.tabIndex||Number.MAX_SAFE_INTEGER)-(n.tabIndex||Number.MAX_SAFE_INTEGER)))}function xa(e=document.body){return e==null?[]:Array.from(e.querySelectorAll(wa)).sort((t,n)=>Math.sign((t.tabIndex||Number.MAX_SAFE_INTEGER)-(n.tabIndex||Number.MAX_SAFE_INTEGER)))}var Lo=(e=>(e[e.Strict=0]="Strict",e[e.Loose=1]="Loose",e))(Lo||{});function Sa(e,t=0){var n;return e===((n=mt(e))==null?void 0:n.body)?!1:Ce(t,{0(){return e.matches(an)},1(){let r=e;for(;r!==null;){if(r.matches(an))return!0;r=r.parentElement}return!1}})}var Ca=(e=>(e[e.Keyboard=0]="Keyboard",e[e.Mouse=1]="Mouse",e))(Ca||{});typeof window<"u"&&typeof document<"u"&&(document.addEventListener("keydown",e=>{e.metaKey||e.altKey||e.ctrlKey||(document.documentElement.dataset.headlessuiFocusVisible="")},!0),document.addEventListener("click",e=>{e.detail===1?delete document.documentElement.dataset.headlessuiFocusVisible:e.detail===0&&(document.documentElement.dataset.headlessuiFocusVisible="")},!0));function Be(e){e==null||e.focus({preventScroll:!0})}let Ea=["textarea","input"].join(",");function $a(e){var t,n;return(n=(t=e==null?void 0:e.matches)==null?void 0:t.call(e,Ea))!=null?n:!1}function Vo(e,t=n=>n){return e.slice().sort((n,r)=>{let o=t(n),i=t(r);if(o===null||i===null)return 0;let s=o.compareDocumentPosition(i);return s&Node.DOCUMENT_POSITION_FOLLOWING?-1:s&Node.DOCUMENT_POSITION_PRECEDING?1:0})}function kt(e,t,{sorted:n=!0,relativeTo:r=null,skipElements:o=[]}={}){let i=Array.isArray(e)?e.length>0?e[0].ownerDocument:document:e.ownerDocument,s=Array.isArray(e)?n?Vo(e):e:t&64?xa(e):ya(e);o.length>0&&s.length>1&&(s=s.filter(f=>!o.some(m=>m!=null&&"current"in m?(m==null?void 0:m.current)===f:m===f))),r=r??i.activeElement;let l=(()=>{if(t&5)return 1;if(t&10)return-1;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")})(),a=(()=>{if(t&1)return 0;if(t&2)return Math.max(0,s.indexOf(r))-1;if(t&4)return Math.max(0,s.indexOf(r))+1;if(t&8)return s.length-1;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")})(),u=t&32?{preventScroll:!0}:{},c=0,g=s.length,h;do{if(c>=g||c+g<=0)return 0;let f=a+c;if(t&16)f=(f+g)%g;else{if(f<0)return 3;if(f>=g)return 1}h=s[f],h==null||h.focus(u),c+=l}while(h!==i.activeElement);return t&6&&$a(h)&&h.select(),2}function Ro(){return/iPhone/gi.test(window.navigator.platform)||/Mac/gi.test(window.navigator.platform)&&window.navigator.maxTouchPoints>0}function _a(){return/Android/gi.test(window.navigator.userAgent)}function Ho(){return Ro()||_a()}function Nt(e,t,n,r){let o=qe(n);d.useEffect(()=>{if(!e)return;function i(s){o.current(s)}return document.addEventListener(t,i,r),()=>document.removeEventListener(t,i,r)},[e,t,r])}function zo(e,t,n,r){let o=qe(n);d.useEffect(()=>{if(!e)return;function i(s){o.current(s)}return window.addEventListener(t,i,r),()=>window.removeEventListener(t,i,r)},[e,t,r])}const Bo=30;function jo(e,t,n){let r=bt(e,"outside-click"),o=qe(n),i=d.useCallback(function(a,u){if(a.defaultPrevented)return;let c=u(a);if(c===null||!c.getRootNode().contains(c)||!c.isConnected)return;let g=function h(f){return typeof f=="function"?h(f()):Array.isArray(f)||f instanceof Set?f:[f]}(t);for(let h of g)if(h!==null&&(h.contains(c)||a.composed&&a.composedPath().includes(h)))return;return!Sa(c,Lo.Loose)&&c.tabIndex!==-1&&a.preventDefault(),o.current(a,c)},[o,t]),s=d.useRef(null);Nt(r,"pointerdown",a=>{var u,c;s.current=((c=(u=a.composedPath)==null?void 0:u.call(a))==null?void 0:c[0])||a.target},!0),Nt(r,"mousedown",a=>{var u,c;s.current=((c=(u=a.composedPath)==null?void 0:u.call(a))==null?void 0:c[0])||a.target},!0),Nt(r,"click",a=>{Ho()||s.current&&(i(a,()=>s.current),s.current=null)},!0);let l=d.useRef({x:0,y:0});Nt(r,"touchstart",a=>{l.current