@inertiaui/modal-react 0.20.4 → 0.20.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- (function(C,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("react"),require("react/jsx-runtime"),require("axios"),require("@inertiajs/react"),require("@inertiajs/core"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react/jsx-runtime","axios","@inertiajs/react","@inertiajs/core","react-dom"],o):(C=typeof globalThis<"u"?globalThis:C||self,o(C.InertiaUIModal={},C.React,C.jsxRuntime,C.Axios,C.react,C.core,C.ReactDOM))})(this,function(C,o,$,be,ne,tn,nn){"use strict";var sl=Object.defineProperty;var al=(C,o,$)=>o in C?sl(C,o,{enumerable:!0,configurable:!0,writable:!0,value:$}):C[o]=$;var B=(C,o,$)=>al(C,typeof o!="symbol"?o+"":o,$);function rn(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 ue=rn(o),de={type:"modal",navigate:!1,modal:{closeButton:!0,closeExplicitly:!1,maxWidth:"2xl",paddingClasses:"p-4 sm:p-6",panelClasses:"bg-white rounded",position:"center"},slideover:{closeButton:!0,closeExplicitly:!1,maxWidth:"md",paddingClasses:"p-4 sm:p-6",panelClasses:"bg-white min-h-screen",position:"right"}};class ln{constructor(){this.config={},this.reset()}reset(){this.config=JSON.parse(JSON.stringify(de))}put(t,n){if(typeof t=="object"){this.config={type:t.type??de.type,navigate:t.navigate??de.navigate,modal:{...de.modal,...t.modal??{}},slideover:{...de.slideover,...t.slideover??{}}};return}const r=t.split(".");let l=this.config;for(let s=0;s<r.length-1;s++)l=l[r[s]]=l[r[s]]||{};l[r[r.length-1]]=n}get(t){if(typeof t>"u")return this.config;const n=t.split(".");let r=this.config;for(const l of n){if(r[l]===void 0)return null;r=r[l]}return r}}const $e=new ln,on=()=>$e.reset(),sn=(e,t)=>$e.put(e,t),Me=e=>$e.get(e),re=(e,t)=>$e.get(e?`slideover.${t}`:`modal.${t}`);function an(e,t){return e=typeof e=="string"?new URL(e,window.location.origin):e,t=typeof t=="string"?new URL(t,window.location.origin):t,`${e.origin}${e.pathname}`==`${t.origin}${t.pathname}`}function Xe(e="inertiaui_modal_"){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`${e}${crypto.randomUUID()}`:`${e}${Date.now().toString(36)}_${Math.random().toString(36).substr(2,9)}`}function le(e){return typeof e=="string"?e.toLowerCase():e}function un(e,t,n=!1){return n&&(t=t.map(le)),Array.isArray(e)?e.filter(r=>!t.includes(n?le(r):r)):Object.keys(e).reduce((r,l)=>(t.includes(n?le(l):l)||(r[l]=e[l]),r),{})}function ct(e,t,n=!1){return n&&(t=t.map(le)),Array.isArray(e)?e.filter(r=>t.includes(n?le(r):r)):Object.keys(e).reduce((r,l)=>(t.includes(n?le(l):l)&&(r[l]=e[l]),r),{})}function dn(e){return Array.isArray(e)?e.filter(t=>t!==null):Object.keys(e).reduce((t,n)=>(n in e&&e[n]!==null&&(t[n]=e[n]),t),{})}function cn(e,t=3,n=10){return new Promise((r,l)=>{const s=e();if(s){r(s);return}let a=t*1e3/n;const u=setInterval(()=>{const i=e();i&&(clearInterval(u),r(i)),--a<=0&&(clearInterval(u),l(new Error("Condition not met in time")))},n)})}function ce(e){return e?(e=e.replace(/_/g,"-"),e=e.replace(/-+/g,"-"),/[A-Z]/.test(e)?(e=e.replace(/\s+/g,"").replace(/_/g,"").replace(/(?:^|\s|-)+([A-Za-z])/g,(t,n)=>n.toUpperCase()),e=e.replace(/(.)(?=[A-Z])/g,"$1-"),e.toLowerCase()):e):""}const Ce=o.createContext(null);Ce.displayName="ModalStackContext";let ft=null,mt=null,oe=null,Ve=null,Ye=[],ie={};const pt=({children:e})=>{const[t,n]=o.useState([]),[r,l]=o.useState({}),s=w=>{n(d=>{const p=w([...d]),h=g=>{var y;return p.length<2?!0:((y=p.map(v=>({id:v.id,shouldRender:v.shouldRender})).reverse().find(v=>v.shouldRender))==null?void 0:y.id)===g};return p.forEach((g,y)=>{p[y].onTopOfStack=h(g.id),p[y].getParentModal=()=>y<1?null:p.slice(0,y).reverse().find(v=>v.isOpen),p[y].getChildModal=()=>y===p.length-1?null:p.slice(y+1).find(v=>v.isOpen)}),p})};o.useEffect(()=>{Ye=t},[t]);class a{constructor(d,p,h,g,y){B(this,"show",()=>{s(d=>d.map(p=>(p.id===this.id&&!p.isOpen&&(p.isOpen=!0,p.shouldRender=!0),p)))});B(this,"setOpen",d=>{d?this.show():this.close()});B(this,"close",()=>{s(d=>d.map(p=>{var h;return p.id===this.id&&p.isOpen&&(Object.keys(p.listeners).forEach(g=>{p.off(g)}),p.isOpen=!1,(h=p.onCloseCallback)==null||h.call(p)),p}))});B(this,"afterLeave",()=>{this.isOpen||s(d=>{const p=d.map(h=>{var g;return h.id===this.id&&!h.isOpen&&(h.shouldRender=!1,(g=h.afterLeaveCallback)==null||g.call(h),h.afterLeaveCallback=null),h});return this.index===0?[]:p})});B(this,"on",(d,p)=>{d=ce(d),this.listeners[d]=this.listeners[d]??[],this.listeners[d].push(p)});B(this,"off",(d,p)=>{var h;d=ce(d),p?this.listeners[d]=((h=this.listeners[d])==null?void 0:h.filter(g=>g!==p))??[]:delete this.listeners[d]});B(this,"emit",(d,...p)=>{var h;(h=this.listeners[ce(d)])==null||h.forEach(g=>g(...p))});B(this,"registerEventListenersFromProps",d=>{const p=[];return Object.keys(d).filter(h=>h.startsWith("on")).forEach(h=>{const g=ce(h).replace(/^on-/,"");this.on(g,d[h]),p.push(()=>this.off(g,d[h]))}),()=>p.forEach(h=>h())});B(this,"reload",(d={})=>{var y;let p=Object.keys(this.response.props);if(d.only&&(p=ct(p,d.only)),d.except&&(p=un(p,d.except)),!((y=this.response)!=null&&y.url))return;const h=(d.method??"get").toLowerCase(),g=d.data??{};be({url:this.response.url,method:h,data:h==="get"?{}:g,params:h==="get"?g:{},headers:{...d.headers??{},Accept:"text/html, application/xhtml+xml","X-Inertia":!0,"X-Inertia-Partial-Component":this.response.component,"X-Inertia-Version":this.response.version,"X-Inertia-Partial-Data":p.join(","),"X-InertiaUI-Modal":Xe(),"X-InertiaUI-Modal-Use-Router":0,"X-InertiaUI-Modal-Base-Url":oe}}).then(v=>{this.updateProps(v.data.props)})});B(this,"updateProps",d=>{Object.assign(this.props,d),s(p=>p)});if(this.id=p.id??Xe(),this.isOpen=!1,this.shouldRender=!1,this.listeners={},this.component=d,this.props=p.props,this.response=p,this.config=h??{},this.onCloseCallback=g,this.afterLeaveCallback=y,ie[this.id]){this.config={...this.config,...ie[this.id].config??{}};const v=ie[this.id].onClose,M=ie[this.id].onAfterLeave;v&&(this.onCloseCallback=g?()=>{g(),v()}:v),M&&(this.afterLeaveCallback=y?()=>{y(),M()}:M),delete ie[this.id]}this.index=-1,this.getParentModal=()=>null,this.getChildModal=()=>null,this.onTopOfStack=!0}static generateId(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`inertiaui_modal_${crypto.randomUUID()}`:`inertiaui_modal_${Date.now().toString(36)}_${Math.random().toString(36).substr(2,9)}`}}const u=(w,d={},p=null,h=null)=>mt(w.component).then(g=>i(g,w,d,p,h)),i=(w,d,p,h,g)=>{const y=new a(w,d,p,h,g);return y.index=t.length,s(v=>[...v,y]),y.show(),y};function c(w,d,p,h){if(!r[w])throw new Error(`The local modal "${w}" has not been registered.`);const g=i(null,{},d,p,h);return g.name=w,r[w].callback(g),g}const m=(w,d={})=>x(w,d.method??"get",d.data??{},d.headers??{},d.config??{},d.onClose,d.onAfterLeave,d.queryStringArrayFormat??"brackets",d.navigate??Me("navigate")).then(p=>{const h=d.listeners??{};return Object.keys(h).forEach(g=>{const y=ce(g);p.on(y,h[g])}),p}),x=(w,d,p={},h={},g={},y=null,v=null,M="brackets",T=!1)=>{const I=Xe();return new Promise((U,F)=>{if(w.startsWith("#")){U(c(w.substring(1),g,y,v));return}const[A,H]=tn.mergeDataIntoQueryString(d,w||"",p,M);let W=T&&t.length===0;if(t.length===0&&(oe=typeof window<"u"?window.location.href:""),h={...h,Accept:"text/html, application/xhtml+xml","X-Requested-With":"XMLHttpRequest","X-Inertia":!0,"X-Inertia-Version":ft,"X-InertiaUI-Modal":I,"X-InertiaUI-Modal-Use-Router":W?1:0,"X-InertiaUI-Modal-Base-Url":oe},W)return Ve=null,ie[I]={config:g,onClose:y,onAfterLeave:v},ne.router.visit(A,{method:d,data:H,headers:h,preserveScroll:!0,preserveState:!0,onError:F,onFinish:()=>{cn(()=>Ve).then(U)}});be({url:A,method:d,data:H,headers:h}).then(S=>U(u(S.data,g,y,v))).catch(S=>{F(S)})})},f={stack:t,localModals:r,push:i,pushFromResponseData:u,length:()=>Ye.length,closeAll:()=>{Ye.reverse().forEach(w=>w.close())},reset:()=>s(()=>[]),visit:x,visitModal:m,registerLocalModal:(w,d)=>{l(p=>({...p,[w]:{name:w,callback:d}}))},removeLocalModal:w=>{l(d=>{const p={...d};return delete p[w],p})}};return $.jsx(Ce.Provider,{value:f,children:e})},fe=()=>{const e=o.useContext(Ce);if(e===null)throw new Error("useModalStack must be used within a ModalStackProvider");return e},ht=["closeButton","closeExplicitly","maxWidth","paddingClasses","panelClasses","position","slideover"],vt=e=>{e.initialPage&&(ft=e.initialPage.version),e.resolveComponent&&(mt=e.resolveComponent)},fn=(e,t)=>{vt(t);const n=({Component:r,props:l,key:s})=>{const a=()=>{const u=o.createElement(r,{key:s,...l});return typeof r.layout=="function"?r.layout(u):Array.isArray(r.layout)?r.layout.concat(u).reverse().reduce((c,m)=>o.createElement(m,l,c)):u};return $.jsxs($.Fragment,{children:[a(),$.jsx(gt,{})]})};return $.jsx(pt,{children:$.jsx(e,{...t,children:n})})},gt=({children:e})=>{var u;const t=o.useContext(Ce);let n=!1,r=!1;o.useEffect(()=>ne.router.on("start",()=>n=!0),[]),o.useEffect(()=>ne.router.on("finish",()=>n=!1),[]),o.useEffect(()=>ne.router.on("navigate",function(i){const c=i.detail.page.props._inertiaui_modal;if(!c){r&&t.closeAll(),oe=null;return}r=c,oe=c.baseUrl,t.pushFromResponseData(c,{},()=>{if(!c.baseUrl){console.error("No base url in modal response data so cannot navigate back");return}!n&&window.location.href!==c.baseUrl&&ne.router.visit(c.baseUrl,{preserveScroll:!0,preserveState:!0})}).then(m=>{Ve=m})}),[]);const l=i=>(i.headers["X-InertiaUI-Modal-Base-Url"]=oe,i);o.useEffect(()=>(be.interceptors.request.use(l),()=>be.interceptors.request.eject(l)),[]);const s=ne.usePage(),a=o.useRef();return o.useEffect(()=>{var m,x;const i=(m=s.props)==null?void 0:m._inertiaui_modal,c=a.current;a.current=i,i&&c&&i.component===c.component&&an(i.url,c.url)&&((x=t.stack[0])==null||x.updateProps(i.props??{}))},[(u=s.props)==null?void 0:u._inertiaui_modal]),$.jsxs($.Fragment,{children:[e,t.stack.length>0&&$.jsx(wt,{index:0})]})},ze=o.createContext(null);ze.displayName="ModalIndexContext";const Ge=()=>{const e=o.useContext(ze);if(e===void 0)throw new Error("useModalIndex must be used within a ModalIndexProvider");return e},wt=({index:e})=>{const{stack:t}=fe(),n=o.useMemo(()=>t[e],[t,e]);return(n==null?void 0:n.component)&&$.jsx(ze.Provider,{value:e,children:$.jsx(n.component,{...n.props,onModalEvent:(...r)=>n.emit(...r)})})},Ke=o.forwardRef(({name:e,children:t,onFocus:n=null,onBlur:r=null,onClose:l=null,onSuccess:s=null,...a},u)=>{const i=Ge(),{stack:c,registerLocalModal:m,removeLocalModal:x}=fe(),[b,E]=o.useState(null),f=o.useMemo(()=>e?b:c[i],[e,b,i,c]),w=o.useMemo(()=>{var v;return(v=c.find(M=>M.shouldRender&&M.index>(f==null?void 0:f.index)))==null?void 0:v.index},[i,c]),d=o.useMemo(()=>(f==null?void 0:f.config.slideover)??a.slideover??Me("type")==="slideover",[a.slideover]),p=o.useMemo(()=>({slideover:d,closeButton:a.closeButton??re(d,"closeButton"),closeExplicitly:a.closeExplicitly??re(d,"closeExplicitly"),maxWidth:a.maxWidth??re(d,"maxWidth"),paddingClasses:a.paddingClasses??re(d,"paddingClasses"),panelClasses:a.panelClasses??re(d,"panelClasses"),position:a.position??re(d,"position"),...f==null?void 0:f.config}),[a,f==null?void 0:f.config]);o.useEffect(()=>{if(e){let v=null;return m(e,M=>{v=M.registerEventListenersFromProps(a),E(M)}),()=>{v==null||v(),v=null,x(e)}}return f.registerEventListenersFromProps(a)},[e]);const h=o.useRef(f);o.useEffect(()=>{h.current=f},[f]),o.useEffect(()=>{f!==null&&(f.isOpen?s==null||s():l==null||l())},[f==null?void 0:f.isOpen]);const[g,y]=o.useState(!1);return o.useEffect(()=>{g&&f!==null&&f.isOpen&&(f.onTopOfStack?n==null||n():r==null||r()),y(!0)},[f==null?void 0:f.onTopOfStack]),o.useImperativeHandle(u,()=>({afterLeave:()=>{var v;return(v=h.current)==null?void 0:v.afterLeave()},close:()=>{var v;return(v=h.current)==null?void 0:v.close()},emit:(...v)=>{var M;return(M=h.current)==null?void 0:M.emit(...v)},getChildModal:()=>{var v;return(v=h.current)==null?void 0:v.getChildModal()},getParentModal:()=>{var v;return(v=h.current)==null?void 0:v.getParentModal()},reload:(...v)=>{var M;return(M=h.current)==null?void 0:M.reload(...v)},setOpen:()=>{var v;return(v=h.current)==null?void 0:v.setOpen()},get id(){var v;return(v=h.current)==null?void 0:v.id},get index(){var v;return(v=h.current)==null?void 0:v.index},get isOpen(){var v;return(v=h.current)==null?void 0:v.isOpen},get config(){var v;return(v=h.current)==null?void 0:v.config},get modalContext(){return h.current},get onTopOfStack(){var v;return(v=h.current)==null?void 0:v.onTopOfStack},get shouldRender(){var v;return(v=h.current)==null?void 0:v.shouldRender}}),[f]),(f==null?void 0:f.shouldRender)&&$.jsxs($.Fragment,{children:[typeof t=="function"?t({afterLeave:f.afterLeave,close:f.close,config:p,emit:f.emit,getChildModal:f.getChildModal,getParentModal:f.getParentModal,id:f.id,index:f.index,isOpen:f.isOpen,modalContext:f,onTopOfStack:f.onTopOfStack,reload:f.reload,setOpen:f.setOpen,shouldRender:f.shouldRender}):t,w&&$.jsx(wt,{index:w})]})});Ke.displayName="HeadlessModal";function Et(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var l=e.length;for(t=0;t<l;t++)e[t]&&(n=Et(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function Se(){for(var e,t,n=0,r="",l=arguments.length;n<l;n++)(e=arguments[n])&&(t=Et(e))&&(r&&(r+=" "),r+=t);return r}var mn=Object.defineProperty,pn=(e,t,n)=>t in e?mn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ze=(e,t,n)=>(pn(e,typeof t!="symbol"?t+"":t,n),n);let hn=class{constructor(){Ze(this,"current",this.detect()),Ze(this,"handoffState","pending"),Ze(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"}},J=new hn;function Oe(e){return J.isServer?null:e instanceof Node?e.ownerDocument:e!=null&&e.hasOwnProperty("current")&&e.current instanceof Node?e.current.ownerDocument:document}function Te(e){typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e).catch(t=>setTimeout(()=>{throw t}))}function z(){let e=[],t={addEventListener(n,r,l,s){return n.addEventListener(r,l,s),t.add(()=>n.removeEventListener(r,l,s))},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 Te(()=>{r.current&&n[0]()}),t.add(()=>{r.current=!1})},style(n,r,l){let s=n.style.getPropertyValue(r);return Object.assign(n.style,{[r]:l}),this.add(()=>{Object.assign(n.style,{[r]:s})})},group(n){let r=z();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 l of e.splice(r,1))l()}},dispose(){for(let n of e.splice(0))n()}};return t}function Je(){let[e]=o.useState(z);return o.useEffect(()=>()=>e.dispose(),[e]),e}let L=(e,t)=>{J.isServer?o.useEffect(e,t):o.useLayoutEffect(e,t)};function Q(e){let t=o.useRef(e);return L(()=>{t.current=e},[e]),t}let O=function(e){let t=Q(e);return o.useCallback((...n)=>t.current(...n),[t])},vn=o.createContext(void 0);function gn(){return o.useContext(vn)}function Qe(...e){return Array.from(new Set(e.flatMap(t=>typeof t=="string"?t.split(" "):[]))).filter(Boolean).join(" ")}function G(e,t,...n){if(e in t){let l=t[e];return typeof l=="function"?l(...n):l}let r=new Error(`Tried to handle "${e}" but there is no handler defined. Only defined handlers are: ${Object.keys(t).map(l=>`"${l}"`).join(", ")}.`);throw Error.captureStackTrace&&Error.captureStackTrace(r,G),r}var Pe=(e=>(e[e.None=0]="None",e[e.RenderStrategy=1]="RenderStrategy",e[e.Static=2]="Static",e))(Pe||{}),K=(e=>(e[e.Unmount=0]="Unmount",e[e.Hidden=1]="Hidden",e))(K||{});function D(){let e=En();return o.useCallback(t=>wn({mergeRefs:e,...t}),[e])}function wn({ourProps:e,theirProps:t,slot:n,defaultTag:r,features:l,visible:s=!0,name:a,mergeRefs:u}){u=u??xn;let i=xt(t,e);if(s)return Fe(i,n,r,a,u);let c=l??0;if(c&2){let{static:m=!1,...x}=i;if(m)return Fe(x,n,r,a,u)}if(c&1){let{unmount:m=!0,...x}=i;return G(m?0:1,{0(){return null},1(){return Fe({...x,hidden:!0,style:{display:"none"}},n,r,a,u)}})}return Fe(i,n,r,a,u)}function Fe(e,t={},n,r,l){let{as:s=n,children:a,refName:u="ref",...i}=Re(e,["unmount","static"]),c=e.ref!==void 0?{[u]:e.ref}:{},m=typeof a=="function"?a(t):a;"className"in i&&i.className&&typeof i.className=="function"&&(i.className=i.className(t)),i["aria-labelledby"]&&i["aria-labelledby"]===i.id&&(i["aria-labelledby"]=void 0);let x={};if(t){let b=!1,E=[];for(let[f,w]of Object.entries(t))typeof w=="boolean"&&(b=!0),w===!0&&E.push(f.replace(/([A-Z])/g,d=>`-${d.toLowerCase()}`));if(b){x["data-headlessui-state"]=E.join(" ");for(let f of E)x[`data-${f}`]=""}}if(s===o.Fragment&&(Object.keys(R(i)).length>0||Object.keys(R(x)).length>0))if(!o.isValidElement(m)||Array.isArray(m)&&m.length>1){if(Object.keys(R(i)).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(R(i)).concat(Object.keys(R(x))).map(b=>` - ${b}`).join(`
1
+ (function(C,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("react"),require("react/jsx-runtime"),require("axios"),require("@inertiajs/react"),require("@inertiajs/core"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react/jsx-runtime","axios","@inertiajs/react","@inertiajs/core","react-dom"],o):(C=typeof globalThis<"u"?globalThis:C||self,o(C.InertiaUIModal={},C.React,C.jsxRuntime,C.Axios,C.react,C.core,C.ReactDOM))})(this,function(C,o,$,ye,ne,tn,nn){"use strict";var sl=Object.defineProperty;var al=(C,o,$)=>o in C?sl(C,o,{enumerable:!0,configurable:!0,writable:!0,value:$}):C[o]=$;var B=(C,o,$)=>al(C,typeof o!="symbol"?o+"":o,$);function rn(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 ue=rn(o),de={type:"modal",navigate:!1,modal:{closeButton:!0,closeExplicitly:!1,maxWidth:"2xl",paddingClasses:"p-4 sm:p-6",panelClasses:"bg-white rounded",position:"center"},slideover:{closeButton:!0,closeExplicitly:!1,maxWidth:"md",paddingClasses:"p-4 sm:p-6",panelClasses:"bg-white min-h-screen",position:"right"}};class ln{constructor(){this.config={},this.reset()}reset(){this.config=JSON.parse(JSON.stringify(de))}put(t,n){if(typeof t=="object"){this.config={type:t.type??de.type,navigate:t.navigate??de.navigate,modal:{...de.modal,...t.modal??{}},slideover:{...de.slideover,...t.slideover??{}}};return}const r=t.split(".");let l=this.config;for(let i=0;i<r.length-1;i++)l=l[r[i]]=l[r[i]]||{};l[r[r.length-1]]=n}get(t){if(typeof t>"u")return this.config;const n=t.split(".");let r=this.config;for(const l of n){if(r[l]===void 0)return null;r=r[l]}return r}}const $e=new ln,on=()=>$e.reset(),sn=(e,t)=>$e.put(e,t),Me=e=>$e.get(e),re=(e,t)=>$e.get(e?`slideover.${t}`:`modal.${t}`);function an(e,t){return e=typeof e=="string"?new URL(e,window.location.origin):e,t=typeof t=="string"?new URL(t,window.location.origin):t,`${e.origin}${e.pathname}`==`${t.origin}${t.pathname}`}function Xe(e="inertiaui_modal_"){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`${e}${crypto.randomUUID()}`:`${e}${Date.now().toString(36)}_${Math.random().toString(36).substr(2,9)}`}function le(e){return typeof e=="string"?e.toLowerCase():e}function un(e,t,n=!1){return n&&(t=t.map(le)),Array.isArray(e)?e.filter(r=>!t.includes(n?le(r):r)):Object.keys(e).reduce((r,l)=>(t.includes(n?le(l):l)||(r[l]=e[l]),r),{})}function ct(e,t,n=!1){return n&&(t=t.map(le)),Array.isArray(e)?e.filter(r=>t.includes(n?le(r):r)):Object.keys(e).reduce((r,l)=>(t.includes(n?le(l):l)&&(r[l]=e[l]),r),{})}function dn(e){return Array.isArray(e)?e.filter(t=>t!==null):Object.keys(e).reduce((t,n)=>(n in e&&e[n]!==null&&(t[n]=e[n]),t),{})}function cn(e,t=3,n=10){return new Promise((r,l)=>{const i=e();if(i){r(i);return}let a=t*1e3/n;const u=setInterval(()=>{const s=e();s&&(clearInterval(u),r(s)),--a<=0&&(clearInterval(u),l(new Error("Condition not met in time")))},n)})}function ce(e){return e?(e=e.replace(/_/g,"-"),e=e.replace(/-+/g,"-"),/[A-Z]/.test(e)?(e=e.replace(/\s+/g,"").replace(/_/g,"").replace(/(?:^|\s|-)+([A-Za-z])/g,(t,n)=>n.toUpperCase()),e=e.replace(/(.)(?=[A-Z])/g,"$1-"),e.toLowerCase()):e):""}const Ce=o.createContext(null);Ce.displayName="ModalStackContext";let ft=null,mt=null,oe=null,Ve=null,Ye=[],ie={};const pt=({children:e})=>{const[t,n]=o.useState([]),[r,l]=o.useState({}),i=x=>{n(d=>{const m=x([...d]),p=E=>{var y;return m.length<2?!0:((y=m.map(v=>({id:v.id,shouldRender:v.shouldRender})).reverse().find(v=>v.shouldRender))==null?void 0:y.id)===E};return m.forEach((E,y)=>{m[y].onTopOfStack=p(E.id),m[y].getParentModal=()=>y<1?null:m.slice(0,y).reverse().find(v=>v.isOpen),m[y].getChildModal=()=>y===m.length-1?null:m.slice(y+1).find(v=>v.isOpen)}),m})};o.useEffect(()=>{Ye=t},[t]);class a{constructor(d,m,p,E,y){B(this,"show",()=>{i(d=>d.map(m=>(m.id===this.id&&!m.isOpen&&(m.isOpen=!0,m.shouldRender=!0),m)))});B(this,"setOpen",d=>{d?this.show():this.close()});B(this,"close",()=>{i(d=>d.map(m=>{var p;return m.id===this.id&&m.isOpen&&(Object.keys(m.listeners).forEach(E=>{m.off(E)}),m.isOpen=!1,(p=m.onCloseCallback)==null||p.call(m)),m}))});B(this,"afterLeave",()=>{this.isOpen||i(d=>{const m=d.map(p=>{var E;return p.id===this.id&&!p.isOpen&&(p.shouldRender=!1,(E=p.afterLeaveCallback)==null||E.call(p),p.afterLeaveCallback=null),p});return this.index===0?[]:m})});B(this,"on",(d,m)=>{d=ce(d),this.listeners[d]=this.listeners[d]??[],this.listeners[d].push(m)});B(this,"off",(d,m)=>{var p;d=ce(d),m?this.listeners[d]=((p=this.listeners[d])==null?void 0:p.filter(E=>E!==m))??[]:delete this.listeners[d]});B(this,"emit",(d,...m)=>{var p;(p=this.listeners[ce(d)])==null||p.forEach(E=>E(...m))});B(this,"registerEventListenersFromProps",d=>{const m=[];return Object.keys(d).filter(p=>p.startsWith("on")).forEach(p=>{const E=ce(p).replace(/^on-/,"");this.on(E,d[p]),m.push(()=>this.off(E,d[p]))}),()=>m.forEach(p=>p())});B(this,"reload",(d={})=>{var y;let m=Object.keys(this.response.props);if(d.only&&(m=ct(m,d.only)),d.except&&(m=un(m,d.except)),!((y=this.response)!=null&&y.url))return;const p=(d.method??"get").toLowerCase(),E=d.data??{};ye({url:this.response.url,method:p,data:p==="get"?{}:E,params:p==="get"?E:{},headers:{...d.headers??{},Accept:"text/html, application/xhtml+xml","X-Inertia":!0,"X-Inertia-Partial-Component":this.response.component,"X-Inertia-Version":this.response.version,"X-Inertia-Partial-Data":m.join(","),"X-InertiaUI-Modal":Xe(),"X-InertiaUI-Modal-Use-Router":0,"X-InertiaUI-Modal-Base-Url":oe}}).then(v=>{this.updateProps(v.data.props)})});B(this,"updateProps",d=>{Object.assign(this.props,d),i(m=>m)});if(this.id=m.id??Xe(),this.isOpen=!1,this.shouldRender=!1,this.listeners={},this.component=d,this.props=m.props,this.response=m,this.config=p??{},this.onCloseCallback=E,this.afterLeaveCallback=y,ie[this.id]){this.config={...this.config,...ie[this.id].config??{}};const v=ie[this.id].onClose,M=ie[this.id].onAfterLeave;v&&(this.onCloseCallback=E?()=>{E(),v()}:v),M&&(this.afterLeaveCallback=y?()=>{y(),M()}:M),delete ie[this.id]}this.index=-1,this.getParentModal=()=>null,this.getChildModal=()=>null,this.onTopOfStack=!0}static generateId(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`inertiaui_modal_${crypto.randomUUID()}`:`inertiaui_modal_${Date.now().toString(36)}_${Math.random().toString(36).substr(2,9)}`}}const u=(x,d={},m=null,p=null)=>mt(x.component).then(E=>s(E,x,d,m,p)),s=(x,d,m,p,E)=>{const y=new a(x,d,m,p,E);return y.index=t.length,i(v=>[...v,y]),y.show(),y};function h(x,d,m,p){if(!r[x])throw new Error(`The local modal "${x}" has not been registered.`);const E=s(null,{},d,m,p);return E.name=x,r[x].callback(E),E}const c=(x,d={})=>g(x,d.method??"get",d.data??{},d.headers??{},d.config??{},d.onClose,d.onAfterLeave,d.queryStringArrayFormat??"brackets",d.navigate??Me("navigate")).then(m=>{const p=d.listeners??{};return Object.keys(p).forEach(E=>{const y=ce(E);m.on(y,p[E])}),m}),g=(x,d,m={},p={},E={},y=null,v=null,M="brackets",T=!1)=>{const I=Xe();return new Promise((U,F)=>{if(x.startsWith("#")){U(h(x.substring(1),E,y,v));return}const[A,H]=tn.mergeDataIntoQueryString(d,x||"",m,M);let W=T&&t.length===0;if(t.length===0&&(oe=typeof window<"u"?window.location.href:""),p={...p,Accept:"text/html, application/xhtml+xml","X-Requested-With":"XMLHttpRequest","X-Inertia":!0,"X-Inertia-Version":ft,"X-InertiaUI-Modal":I,"X-InertiaUI-Modal-Use-Router":W?1:0,"X-InertiaUI-Modal-Base-Url":oe},W)return Ve=null,ie[I]={config:E,onClose:y,onAfterLeave:v},ne.router.visit(A,{method:d,data:H,headers:p,preserveScroll:!0,preserveState:!0,onError:F,onFinish:()=>{cn(()=>Ve).then(U)}});ye({url:A,method:d,data:H,headers:p}).then(S=>U(u(S.data,E,y,v))).catch(S=>{F(S)})})},f={stack:t,localModals:r,push:s,pushFromResponseData:u,length:()=>Ye.length,closeAll:()=>{Ye.reverse().forEach(x=>x.close())},reset:()=>i(()=>[]),visit:g,visitModal:c,registerLocalModal:(x,d)=>{l(m=>({...m,[x]:{name:x,callback:d}}))},removeLocalModal:x=>{l(d=>{const m={...d};return delete m[x],m})}};return $.jsx(Ce.Provider,{value:f,children:e})},fe=()=>{const e=o.useContext(Ce);if(e===null)throw new Error("useModalStack must be used within a ModalStackProvider");return e},ht=["closeButton","closeExplicitly","maxWidth","paddingClasses","panelClasses","position","slideover"],vt=e=>{e.initialPage&&(ft=e.initialPage.version),e.resolveComponent&&(mt=e.resolveComponent)},fn=(e,t)=>{vt(t);const n=({Component:r,props:l,key:i})=>{const a=()=>{const u=o.createElement(r,{key:i,...l});return typeof r.layout=="function"?r.layout(u):Array.isArray(r.layout)?r.layout.concat(u).reverse().reduce((h,c)=>o.createElement(c,l,h)):u};return $.jsxs($.Fragment,{children:[a(),$.jsx(gt,{})]})};return $.jsx(pt,{children:$.jsx(e,{...t,children:n})})},gt=({children:e})=>{var s,h;const t=o.useContext(Ce),n=ne.usePage();let r=!1,l=!1,i=!!((s=n.props)!=null&&s._inertiaui_modal);o.useEffect(()=>ne.router.on("start",()=>r=!0),[]),o.useEffect(()=>ne.router.on("finish",()=>r=!1),[]),o.useEffect(()=>ne.router.on("navigate",function(c){const g=c.detail.page.props._inertiaui_modal;if(!g){l&&t.closeAll(),oe=null,i=!1;return}l=g,oe=g.baseUrl,t.pushFromResponseData(g,{},()=>{if(!g.baseUrl){console.error("No base url in modal response data so cannot navigate back");return}!r&&window.location.href!==g.baseUrl&&ne.router.visit(g.baseUrl,{preserveScroll:!0,preserveState:!0})}).then(b=>{Ve=b})}),[]);const a=c=>{var g;return c.headers["X-InertiaUI-Modal-Base-Url"]=oe??(i?(g=n.props._inertiaui_modal)==null?void 0:g.baseUrl:null),c};o.useEffect(()=>(ye.interceptors.request.use(a),()=>ye.interceptors.request.eject(a)),[]);const u=o.useRef();return o.useEffect(()=>{var b,w;const c=(b=n.props)==null?void 0:b._inertiaui_modal,g=u.current;u.current=c,c&&g&&c.component===g.component&&an(c.url,g.url)&&((w=t.stack[0])==null||w.updateProps(c.props??{}))},[(h=n.props)==null?void 0:h._inertiaui_modal]),$.jsxs($.Fragment,{children:[e,t.stack.length>0&&$.jsx(wt,{index:0})]})},ze=o.createContext(null);ze.displayName="ModalIndexContext";const Ge=()=>{const e=o.useContext(ze);if(e===void 0)throw new Error("useModalIndex must be used within a ModalIndexProvider");return e},wt=({index:e})=>{const{stack:t}=fe(),n=o.useMemo(()=>t[e],[t,e]);return(n==null?void 0:n.component)&&$.jsx(ze.Provider,{value:e,children:$.jsx(n.component,{...n.props,onModalEvent:(...r)=>n.emit(...r)})})},Ke=o.forwardRef(({name:e,children:t,onFocus:n=null,onBlur:r=null,onClose:l=null,onSuccess:i=null,...a},u)=>{const s=Ge(),{stack:h,registerLocalModal:c,removeLocalModal:g}=fe(),[b,w]=o.useState(null),f=o.useMemo(()=>e?b:h[s],[e,b,s,h]),x=o.useMemo(()=>{var v;return(v=h.find(M=>M.shouldRender&&M.index>(f==null?void 0:f.index)))==null?void 0:v.index},[s,h]),d=o.useMemo(()=>(f==null?void 0:f.config.slideover)??a.slideover??Me("type")==="slideover",[a.slideover]),m=o.useMemo(()=>({slideover:d,closeButton:a.closeButton??re(d,"closeButton"),closeExplicitly:a.closeExplicitly??re(d,"closeExplicitly"),maxWidth:a.maxWidth??re(d,"maxWidth"),paddingClasses:a.paddingClasses??re(d,"paddingClasses"),panelClasses:a.panelClasses??re(d,"panelClasses"),position:a.position??re(d,"position"),...f==null?void 0:f.config}),[a,f==null?void 0:f.config]);o.useEffect(()=>{if(e){let v=null;return c(e,M=>{v=M.registerEventListenersFromProps(a),w(M)}),()=>{v==null||v(),v=null,g(e)}}return f.registerEventListenersFromProps(a)},[e]);const p=o.useRef(f);o.useEffect(()=>{p.current=f},[f]),o.useEffect(()=>{f!==null&&(f.isOpen?i==null||i():l==null||l())},[f==null?void 0:f.isOpen]);const[E,y]=o.useState(!1);return o.useEffect(()=>{E&&f!==null&&f.isOpen&&(f.onTopOfStack?n==null||n():r==null||r()),y(!0)},[f==null?void 0:f.onTopOfStack]),o.useImperativeHandle(u,()=>({afterLeave:()=>{var v;return(v=p.current)==null?void 0:v.afterLeave()},close:()=>{var v;return(v=p.current)==null?void 0:v.close()},emit:(...v)=>{var M;return(M=p.current)==null?void 0:M.emit(...v)},getChildModal:()=>{var v;return(v=p.current)==null?void 0:v.getChildModal()},getParentModal:()=>{var v;return(v=p.current)==null?void 0:v.getParentModal()},reload:(...v)=>{var M;return(M=p.current)==null?void 0:M.reload(...v)},setOpen:()=>{var v;return(v=p.current)==null?void 0:v.setOpen()},get id(){var v;return(v=p.current)==null?void 0:v.id},get index(){var v;return(v=p.current)==null?void 0:v.index},get isOpen(){var v;return(v=p.current)==null?void 0:v.isOpen},get config(){var v;return(v=p.current)==null?void 0:v.config},get modalContext(){return p.current},get onTopOfStack(){var v;return(v=p.current)==null?void 0:v.onTopOfStack},get shouldRender(){var v;return(v=p.current)==null?void 0:v.shouldRender}}),[f]),(f==null?void 0:f.shouldRender)&&$.jsxs($.Fragment,{children:[typeof t=="function"?t({afterLeave:f.afterLeave,close:f.close,config:m,emit:f.emit,getChildModal:f.getChildModal,getParentModal:f.getParentModal,id:f.id,index:f.index,isOpen:f.isOpen,modalContext:f,onTopOfStack:f.onTopOfStack,reload:f.reload,setOpen:f.setOpen,shouldRender:f.shouldRender}):t,x&&$.jsx(wt,{index:x})]})});Ke.displayName="HeadlessModal";function Et(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var l=e.length;for(t=0;t<l;t++)e[t]&&(n=Et(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function Se(){for(var e,t,n=0,r="",l=arguments.length;n<l;n++)(e=arguments[n])&&(t=Et(e))&&(r&&(r+=" "),r+=t);return r}var mn=Object.defineProperty,pn=(e,t,n)=>t in e?mn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ze=(e,t,n)=>(pn(e,typeof t!="symbol"?t+"":t,n),n);let hn=class{constructor(){Ze(this,"current",this.detect()),Ze(this,"handoffState","pending"),Ze(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"}},J=new hn;function Oe(e){return J.isServer?null:e instanceof Node?e.ownerDocument:e!=null&&e.hasOwnProperty("current")&&e.current instanceof Node?e.current.ownerDocument:document}function Te(e){typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e).catch(t=>setTimeout(()=>{throw t}))}function z(){let e=[],t={addEventListener(n,r,l,i){return n.addEventListener(r,l,i),t.add(()=>n.removeEventListener(r,l,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 Te(()=>{r.current&&n[0]()}),t.add(()=>{r.current=!1})},style(n,r,l){let i=n.style.getPropertyValue(r);return Object.assign(n.style,{[r]:l}),this.add(()=>{Object.assign(n.style,{[r]:i})})},group(n){let r=z();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 l of e.splice(r,1))l()}},dispose(){for(let n of e.splice(0))n()}};return t}function Je(){let[e]=o.useState(z);return o.useEffect(()=>()=>e.dispose(),[e]),e}let L=(e,t)=>{J.isServer?o.useEffect(e,t):o.useLayoutEffect(e,t)};function Q(e){let t=o.useRef(e);return L(()=>{t.current=e},[e]),t}let O=function(e){let t=Q(e);return o.useCallback((...n)=>t.current(...n),[t])},vn=o.createContext(void 0);function gn(){return o.useContext(vn)}function Qe(...e){return Array.from(new Set(e.flatMap(t=>typeof t=="string"?t.split(" "):[]))).filter(Boolean).join(" ")}function G(e,t,...n){if(e in t){let l=t[e];return typeof l=="function"?l(...n):l}let r=new Error(`Tried to handle "${e}" but there is no handler defined. Only defined handlers are: ${Object.keys(t).map(l=>`"${l}"`).join(", ")}.`);throw Error.captureStackTrace&&Error.captureStackTrace(r,G),r}var Pe=(e=>(e[e.None=0]="None",e[e.RenderStrategy=1]="RenderStrategy",e[e.Static=2]="Static",e))(Pe||{}),K=(e=>(e[e.Unmount=0]="Unmount",e[e.Hidden=1]="Hidden",e))(K||{});function D(){let e=En();return o.useCallback(t=>wn({mergeRefs:e,...t}),[e])}function wn({ourProps:e,theirProps:t,slot:n,defaultTag:r,features:l,visible:i=!0,name:a,mergeRefs:u}){u=u??xn;let s=xt(t,e);if(i)return Fe(s,n,r,a,u);let h=l??0;if(h&2){let{static:c=!1,...g}=s;if(c)return Fe(g,n,r,a,u)}if(h&1){let{unmount:c=!0,...g}=s;return G(c?0:1,{0(){return null},1(){return Fe({...g,hidden:!0,style:{display:"none"}},n,r,a,u)}})}return Fe(s,n,r,a,u)}function Fe(e,t={},n,r,l){let{as:i=n,children:a,refName:u="ref",...s}=Re(e,["unmount","static"]),h=e.ref!==void 0?{[u]:e.ref}:{},c=typeof a=="function"?a(t):a;"className"in s&&s.className&&typeof s.className=="function"&&(s.className=s.className(t)),s["aria-labelledby"]&&s["aria-labelledby"]===s.id&&(s["aria-labelledby"]=void 0);let g={};if(t){let b=!1,w=[];for(let[f,x]of Object.entries(t))typeof x=="boolean"&&(b=!0),x===!0&&w.push(f.replace(/([A-Z])/g,d=>`-${d.toLowerCase()}`));if(b){g["data-headlessui-state"]=w.join(" ");for(let f of w)g[`data-${f}`]=""}}if(i===o.Fragment&&(Object.keys(R(s)).length>0||Object.keys(R(g)).length>0))if(!o.isValidElement(c)||Array.isArray(c)&&c.length>1){if(Object.keys(R(s)).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(R(s)).concat(Object.keys(R(g))).map(b=>` - ${b}`).join(`
2
2
  `),"","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(b=>` - ${b}`).join(`
3
3
  `)].join(`
4
- `))}else{let b=m.props,E=b==null?void 0:b.className,f=typeof E=="function"?(...p)=>Qe(E(...p),i.className):Qe(E,i.className),w=f?{className:f}:{},d=xt(m.props,R(Re(i,["ref"])));for(let p in x)p in d&&delete x[p];return o.cloneElement(m,Object.assign({},d,x,c,{ref:l(yn(m),c.ref)},w))}return o.createElement(s,Object.assign({},Re(i,["ref"]),s!==o.Fragment&&c,s!==o.Fragment&&x),m)}function En(){let e=o.useRef([]),t=o.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 xn(...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 xt(...e){if(e.length===0)return{};if(e.length===1)return e[0];let t={},n={};for(let r of e)for(let l in r)l.startsWith("on")&&typeof r[l]=="function"?(n[l]!=null||(n[l]=[]),n[l].push(r[l])):t[l]=r[l];if(t.disabled||t["aria-disabled"])for(let r in n)/^(on(?:Click|Pointer|Mouse|Key)(?:Down|Up|Press)?)$/.test(r)&&(n[r]=[l=>{var s;return(s=l==null?void 0:l.preventDefault)==null?void 0:s.call(l)}]);for(let r in n)Object.assign(t,{[r](l,...s){let a=n[r];for(let u of a){if((l instanceof Event||(l==null?void 0:l.nativeEvent)instanceof Event)&&l.defaultPrevented)return;u(l,...s)}}});return t}function k(e){var t;return Object.assign(o.forwardRef(e),{displayName:(t=e.displayName)!=null?t:e.name})}function R(e){let t=Object.assign({},e);for(let n in t)t[n]===void 0&&delete t[n];return t}function Re(e,t=[]){let n=Object.assign({},e);for(let r of t)r in n&&delete n[r];return n}function yn(e){return o.version.split(".")[0]>="19"?e.props.ref:e.ref}let bn="span";var Le=(e=>(e[e.None=1]="None",e[e.Focusable=2]="Focusable",e[e.Hidden=4]="Hidden",e))(Le||{});function $n(e,t){var n;let{features:r=1,...l}=e,s={ref:t,"aria-hidden":(r&2)===2?!0:(n=l["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 D()({ourProps:s,theirProps:l,slot:{},defaultTag:bn,name:"Hidden"})}let et=k($n),yt=Symbol();function Mn(e,t=!0){return Object.assign(e,{[yt]:t})}function q(...e){let t=o.useRef(e);o.useEffect(()=>{t.current=e},[e]);let n=O(r=>{for(let l of t.current)l!=null&&(typeof l=="function"?l(r):l.current=r)});return e.every(r=>r==null||(r==null?void 0:r[yt]))?void 0:n}let tt=o.createContext(null);tt.displayName="DescriptionContext";function bt(){let e=o.useContext(tt);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,bt),t}return e}function Cn(){let[e,t]=o.useState([]);return[e.length>0?e.join(" "):void 0,o.useMemo(()=>function(n){let r=O(s=>(t(a=>[...a,s]),()=>t(a=>{let u=a.slice(),i=u.indexOf(s);return i!==-1&&u.splice(i,1),u}))),l=o.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 o.createElement(tt.Provider,{value:l},n.children)},[t])]}let Sn="p";function On(e,t){let n=o.useId(),r=gn(),{id:l=`headlessui-description-${n}`,...s}=e,a=bt(),u=q(t);L(()=>a.register(l),[l,a.register]);let i=r||!1,c=o.useMemo(()=>({...a.slot,disabled:i}),[a.slot,i]),m={ref:u,...a.props,id:l};return D()({ourProps:m,theirProps:s,slot:c,defaultTag:Sn,name:a.name||"Description"})}let Tn=k(On),Pn=Object.assign(Tn,{});var $t=(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))($t||{});let Fn=o.createContext(()=>{});function Ln({value:e,children:t}){return o.createElement(Fn.Provider,{value:e},t)}let kn=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 Mt(e,t){let n=e(),r=new Set;return{getSnapshot(){return n},subscribe(l){return r.add(l),()=>r.delete(l)},dispatch(l,...s){let a=t[l].call(n,...s);a&&(n=a,r.forEach(u=>u()))}}}function Ct(e){return o.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getSnapshot)}let Nn=new kn(()=>Mt(()=>[],{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 se(e,t){let n=Nn.get(t),r=o.useId(),l=Ct(n);if(L(()=>{if(e)return n.dispatch("ADD",r),()=>n.dispatch("REMOVE",r)},[n,e]),!e)return!1;let s=l.indexOf(r),a=l.length;return s===-1&&(s=a,a+=1),s===a-1}let nt=new Map,me=new Map;function St(e){var t;let n=(t=me.get(e))!=null?t:0;return me.set(e,n+1),n!==0?()=>Ot(e):(nt.set(e,{"aria-hidden":e.getAttribute("aria-hidden"),inert:e.inert}),e.setAttribute("aria-hidden","true"),e.inert=!0,()=>Ot(e))}function Ot(e){var t;let n=(t=me.get(e))!=null?t:1;if(n===1?me.delete(e):me.set(e,n-1),n!==1)return;let r=nt.get(e);r&&(r["aria-hidden"]===null?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",r["aria-hidden"]),e.inert=r.inert,nt.delete(e))}function In(e,{allowed:t,disallowed:n}={}){let r=se(e,"inert-others");L(()=>{var l,s;if(!r)return;let a=z();for(let i of(l=n==null?void 0:n())!=null?l:[])i&&a.add(St(i));let u=(s=t==null?void 0:t())!=null?s:[];for(let i of u){if(!i)continue;let c=Oe(i);if(!c)continue;let m=i.parentElement;for(;m&&m!==c.body;){for(let x of m.children)u.some(b=>x.contains(b))||a.add(St(x));m=m.parentElement}}return a.dispose},[r,t,n])}function An(e,t,n){let r=Q(l=>{let s=l.getBoundingClientRect();s.x===0&&s.y===0&&s.width===0&&s.height===0&&n()});o.useEffect(()=>{if(!e)return;let l=t===null?null:t instanceof HTMLElement?t:t.current;if(!l)return;let s=z();if(typeof ResizeObserver<"u"){let a=new ResizeObserver(()=>r.current(l));a.observe(l),s.add(()=>a.disconnect())}if(typeof IntersectionObserver<"u"){let a=new IntersectionObserver(()=>r.current(l));a.observe(l),s.add(()=>a.disconnect())}return()=>s.dispose()},[t,r,e])}let ke=["[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(","),Dn=["[data-autofocus]"].map(e=>`${e}:not([tabindex='-1'])`).join(",");var V=(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))(V||{}),rt=(e=>(e[e.Error=0]="Error",e[e.Overflow=1]="Overflow",e[e.Success=2]="Success",e[e.Underflow=3]="Underflow",e))(rt||{}),jn=(e=>(e[e.Previous=-1]="Previous",e[e.Next=1]="Next",e))(jn||{});function Un(e=document.body){return e==null?[]:Array.from(e.querySelectorAll(ke)).sort((t,n)=>Math.sign((t.tabIndex||Number.MAX_SAFE_INTEGER)-(n.tabIndex||Number.MAX_SAFE_INTEGER)))}function Hn(e=document.body){return e==null?[]:Array.from(e.querySelectorAll(Dn)).sort((t,n)=>Math.sign((t.tabIndex||Number.MAX_SAFE_INTEGER)-(n.tabIndex||Number.MAX_SAFE_INTEGER)))}var Tt=(e=>(e[e.Strict=0]="Strict",e[e.Loose=1]="Loose",e))(Tt||{});function Wn(e,t=0){var n;return e===((n=Oe(e))==null?void 0:n.body)?!1:G(t,{0(){return e.matches(ke)},1(){let r=e;for(;r!==null;){if(r.matches(ke))return!0;r=r.parentElement}return!1}})}var _n=(e=>(e[e.Keyboard=0]="Keyboard",e[e.Mouse=1]="Mouse",e))(_n||{});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 Y(e){e==null||e.focus({preventScroll:!0})}let Bn=["textarea","input"].join(",");function qn(e){var t,n;return(n=(t=e==null?void 0:e.matches)==null?void 0:t.call(e,Bn))!=null?n:!1}function Xn(e,t=n=>n){return e.slice().sort((n,r)=>{let l=t(n),s=t(r);if(l===null||s===null)return 0;let a=l.compareDocumentPosition(s);return a&Node.DOCUMENT_POSITION_FOLLOWING?-1:a&Node.DOCUMENT_POSITION_PRECEDING?1:0})}function pe(e,t,{sorted:n=!0,relativeTo:r=null,skipElements:l=[]}={}){let s=Array.isArray(e)?e.length>0?e[0].ownerDocument:document:e.ownerDocument,a=Array.isArray(e)?n?Xn(e):e:t&64?Hn(e):Un(e);l.length>0&&a.length>1&&(a=a.filter(E=>!l.some(f=>f!=null&&"current"in f?(f==null?void 0:f.current)===E:f===E))),r=r??s.activeElement;let u=(()=>{if(t&5)return 1;if(t&10)return-1;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")})(),i=(()=>{if(t&1)return 0;if(t&2)return Math.max(0,a.indexOf(r))-1;if(t&4)return Math.max(0,a.indexOf(r))+1;if(t&8)return a.length-1;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")})(),c=t&32?{preventScroll:!0}:{},m=0,x=a.length,b;do{if(m>=x||m+x<=0)return 0;let E=i+m;if(t&16)E=(E+x)%x;else{if(E<0)return 3;if(E>=x)return 1}b=a[E],b==null||b.focus(c),m+=u}while(b!==s.activeElement);return t&6&&qn(b)&&b.select(),2}function Pt(){return/iPhone/gi.test(window.navigator.platform)||/Mac/gi.test(window.navigator.platform)&&window.navigator.maxTouchPoints>0}function Vn(){return/Android/gi.test(window.navigator.userAgent)}function Yn(){return Pt()||Vn()}function he(e,t,n,r){let l=Q(n);o.useEffect(()=>{if(!e)return;function s(a){l.current(a)}return document.addEventListener(t,s,r),()=>document.removeEventListener(t,s,r)},[e,t,r])}function Ft(e,t,n,r){let l=Q(n);o.useEffect(()=>{if(!e)return;function s(a){l.current(a)}return window.addEventListener(t,s,r),()=>window.removeEventListener(t,s,r)},[e,t,r])}const Lt=30;function zn(e,t,n){let r=se(e,"outside-click"),l=Q(n),s=o.useCallback(function(i,c){if(i.defaultPrevented)return;let m=c(i);if(m===null||!m.getRootNode().contains(m)||!m.isConnected)return;let x=function b(E){return typeof E=="function"?b(E()):Array.isArray(E)||E instanceof Set?E:[E]}(t);for(let b of x)if(b!==null&&(b.contains(m)||i.composed&&i.composedPath().includes(b)))return;return!Wn(m,Tt.Loose)&&m.tabIndex!==-1&&i.preventDefault(),l.current(i,m)},[l,t]),a=o.useRef(null);he(r,"pointerdown",i=>{var c,m;a.current=((m=(c=i.composedPath)==null?void 0:c.call(i))==null?void 0:m[0])||i.target},!0),he(r,"mousedown",i=>{var c,m;a.current=((m=(c=i.composedPath)==null?void 0:c.call(i))==null?void 0:m[0])||i.target},!0),he(r,"click",i=>{Yn()||a.current&&(s(i,()=>a.current),a.current=null)},!0);let u=o.useRef({x:0,y:0});he(r,"touchstart",i=>{u.current.x=i.touches[0].clientX,u.current.y=i.touches[0].clientY},!0),he(r,"touchend",i=>{let c={x:i.changedTouches[0].clientX,y:i.changedTouches[0].clientY};if(!(Math.abs(c.x-u.current.x)>=Lt||Math.abs(c.y-u.current.y)>=Lt))return s(i,()=>i.target instanceof HTMLElement?i.target:null)},!0),Ft(r,"blur",i=>s(i,()=>window.document.activeElement instanceof HTMLIFrameElement?window.document.activeElement:null),!0)}function ve(...e){return o.useMemo(()=>Oe(...e),[...e])}function kt(e,t,n,r){let l=Q(n);o.useEffect(()=>{e=e??window;function s(a){l.current(a)}return e.addEventListener(t,s,r),()=>e.removeEventListener(t,s,r)},[e,t,r])}function Gn(){let e;return{before({doc:t}){var n;let r=t.documentElement,l=(n=t.defaultView)!=null?n:window;e=Math.max(0,l.innerWidth-r.clientWidth)},after({doc:t,d:n}){let r=t.documentElement,l=Math.max(0,r.clientWidth-r.offsetWidth),s=Math.max(0,e-l);n.style(r,"paddingRight",`${s}px`)}}}function Kn(){return Pt()?{before({doc:e,d:t,meta:n}){function r(l){return n.containers.flatMap(s=>s()).some(s=>s.contains(l))}t.microTask(()=>{var l;if(window.getComputedStyle(e.documentElement).scrollBehavior!=="auto"){let u=z();u.style(e.documentElement,"scrollBehavior","auto"),t.add(()=>t.microTask(()=>u.dispose()))}let s=(l=window.scrollY)!=null?l:window.pageYOffset,a=null;t.addEventListener(e,"click",u=>{if(u.target instanceof HTMLElement)try{let i=u.target.closest("a");if(!i)return;let{hash:c}=new URL(i.href),m=e.querySelector(c);m&&!r(m)&&(a=m)}catch{}},!0),t.addEventListener(e,"touchstart",u=>{if(u.target instanceof HTMLElement)if(r(u.target)){let i=u.target;for(;i.parentElement&&r(i.parentElement);)i=i.parentElement;t.style(i,"overscrollBehavior","contain")}else t.style(u.target,"touchAction","none")}),t.addEventListener(e,"touchmove",u=>{if(u.target instanceof HTMLElement){if(u.target.tagName==="INPUT")return;if(r(u.target)){let i=u.target;for(;i.parentElement&&i.dataset.headlessuiPortal!==""&&!(i.scrollHeight>i.clientHeight||i.scrollWidth>i.clientWidth);)i=i.parentElement;i.dataset.headlessuiPortal===""&&u.preventDefault()}else u.preventDefault()}},{passive:!1}),t.add(()=>{var u;let i=(u=window.scrollY)!=null?u:window.pageYOffset;s!==i&&window.scrollTo(0,s),a&&a.isConnected&&(a.scrollIntoView({block:"nearest"}),a=null)})})}}:{}}function Zn(){return{before({doc:e,d:t}){t.style(e.documentElement,"overflow","hidden")}}}function Jn(e){let t={};for(let n of e)Object.assign(t,n(t));return t}let ee=Mt(()=>new Map,{PUSH(e,t){var n;let r=(n=this.get(e))!=null?n:{doc:e,count:0,d:z(),meta:new Set};return r.count++,r.meta.add(t),this.set(e,r),this},POP(e,t){let n=this.get(e);return n&&(n.count--,n.meta.delete(t)),this},SCROLL_PREVENT({doc:e,d:t,meta:n}){let r={doc:e,d:t,meta:Jn(n)},l=[Kn(),Gn(),Zn()];l.forEach(({before:s})=>s==null?void 0:s(r)),l.forEach(({after:s})=>s==null?void 0:s(r))},SCROLL_ALLOW({d:e}){e.dispose()},TEARDOWN({doc:e}){this.delete(e)}});ee.subscribe(()=>{let e=ee.getSnapshot(),t=new Map;for(let[n]of e)t.set(n,n.documentElement.style.overflow);for(let n of e.values()){let r=t.get(n.doc)==="hidden",l=n.count!==0;(l&&!r||!l&&r)&&ee.dispatch(n.count>0?"SCROLL_PREVENT":"SCROLL_ALLOW",n),n.count===0&&ee.dispatch("TEARDOWN",n)}});function Qn(e,t,n=()=>({containers:[]})){let r=Ct(ee),l=t?r.get(t):void 0,s=l?l.count>0:!1;return L(()=>{if(!(!t||!e))return ee.dispatch("PUSH",t,n),()=>ee.dispatch("POP",t,n)},[e,t]),s}function Rn(e,t,n=()=>[document.body]){let r=se(e,"scroll-lock");Qn(r,t,l=>{var s;return{containers:[...(s=l.containers)!=null?s:[],n]}})}function er(e=0){let[t,n]=o.useState(e),r=o.useCallback(i=>n(i),[t]),l=o.useCallback(i=>n(c=>c|i),[t]),s=o.useCallback(i=>(t&i)===i,[t]),a=o.useCallback(i=>n(c=>c&~i),[n]),u=o.useCallback(i=>n(c=>c^i),[n]);return{flags:t,setFlag:r,addFlag:l,hasFlag:s,removeFlag:a,toggleFlag:u}}var Nt,It;typeof process<"u"&&typeof globalThis<"u"&&typeof Element<"u"&&((Nt=process==null?void 0:process.env)==null?void 0:Nt.NODE_ENV)==="test"&&typeof((It=Element==null?void 0:Element.prototype)==null?void 0:It.getAnimations)>"u"&&(Element.prototype.getAnimations=function(){return console.warn(["Headless UI has polyfilled `Element.prototype.getAnimations` for your tests.","Please install a proper polyfill e.g. `jsdom-testing-mocks`, to silence these warnings.","","Example usage:","```js","import { mockAnimationsApi } from 'jsdom-testing-mocks'","mockAnimationsApi()","```"].join(`
5
- `)),[]});var tr=(e=>(e[e.None=0]="None",e[e.Closed=1]="Closed",e[e.Enter=2]="Enter",e[e.Leave=4]="Leave",e))(tr||{});function nr(e){let t={};for(let n in e)e[n]===!0&&(t[`data-${n}`]="");return t}function rr(e,t,n,r){let[l,s]=o.useState(n),{hasFlag:a,addFlag:u,removeFlag:i}=er(e&&l?3:0),c=o.useRef(!1),m=o.useRef(!1),x=Je();return L(()=>{var b;if(e){if(n&&s(!0),!t){n&&u(3);return}return(b=r==null?void 0:r.start)==null||b.call(r,n),lr(t,{inFlight:c,prepare(){m.current?m.current=!1:m.current=c.current,c.current=!0,!m.current&&(n?(u(3),i(4)):(u(4),i(2)))},run(){m.current?n?(i(3),u(4)):(i(4),u(3)):n?i(1):u(1)},done(){var E;m.current&&typeof t.getAnimations=="function"&&t.getAnimations().length>0||(c.current=!1,i(7),n||s(!1),(E=r==null?void 0:r.end)==null||E.call(r,n))}})}},[e,n,t,x]),e?[l,{closed:a(1),enter:a(2),leave:a(4),transition:a(2)||a(4)}]:[n,{closed:void 0,enter:void 0,leave:void 0,transition:void 0}]}function lr(e,{prepare:t,run:n,done:r,inFlight:l}){let s=z();return ir(e,{prepare:t,inFlight:l}),s.nextFrame(()=>{n(),s.requestAnimationFrame(()=>{s.add(or(e,r))})}),s.dispose}function or(e,t){var n,r;let l=z();if(!e)return l.dispose;let s=!1;l.add(()=>{s=!0});let a=(r=(n=e.getAnimations)==null?void 0:n.call(e).filter(u=>u instanceof CSSTransition))!=null?r:[];return a.length===0?(t(),l.dispose):(Promise.allSettled(a.map(u=>u.finished)).then(()=>{s||t()}),l.dispose)}function ir(e,{inFlight:t,prepare:n}){if(t!=null&&t.current){n();return}let r=e.style.transition;e.style.transition="none",n(),e.offsetHeight,e.style.transition=r}function lt(e,t){let n=o.useRef([]),r=O(e);o.useEffect(()=>{let l=[...n.current];for(let[s,a]of t.entries())if(n.current[s]!==a){let u=r(t,l);return n.current=t,u}},[r,...t])}let Ne=o.createContext(null);Ne.displayName="OpenClosedContext";var j=(e=>(e[e.Open=1]="Open",e[e.Closed=2]="Closed",e[e.Closing=4]="Closing",e[e.Opening=8]="Opening",e))(j||{});function Ie(){return o.useContext(Ne)}function sr({value:e,children:t}){return o.createElement(Ne.Provider,{value:e},t)}function ar({children:e}){return o.createElement(Ne.Provider,{value:null},e)}function ur(e){function t(){document.readyState!=="loading"&&(e(),document.removeEventListener("DOMContentLoaded",t))}typeof window<"u"&&typeof document<"u"&&(document.addEventListener("DOMContentLoaded",t),t())}let Z=[];ur(()=>{function e(t){if(!(t.target instanceof HTMLElement)||t.target===document.body||Z[0]===t.target)return;let n=t.target;n=n.closest(ke),Z.unshift(n??t.target),Z=Z.filter(r=>r!=null&&r.isConnected),Z.splice(10)}window.addEventListener("click",e,{capture:!0}),window.addEventListener("mousedown",e,{capture:!0}),window.addEventListener("focus",e,{capture:!0}),document.body.addEventListener("click",e,{capture:!0}),document.body.addEventListener("mousedown",e,{capture:!0}),document.body.addEventListener("focus",e,{capture:!0})});function At(e){let t=O(e),n=o.useRef(!1);o.useEffect(()=>(n.current=!1,()=>{n.current=!0,Te(()=>{n.current&&t()})}),[t])}function dr(){let e=typeof document>"u";return"useSyncExternalStore"in ue?(t=>t.useSyncExternalStore)(ue)(()=>()=>{},()=>!1,()=>!e):!1}function ge(){let e=dr(),[t,n]=ue.useState(J.isHandoffComplete);return t&&J.isHandoffComplete===!1&&n(!1),ue.useEffect(()=>{t!==!0&&n(!0)},[t]),ue.useEffect(()=>J.handoff(),[]),e?!1:t}let Dt=o.createContext(!1);function cr(){return o.useContext(Dt)}function jt(e){return o.createElement(Dt.Provider,{value:e.force},e.children)}function fr(e){let t=cr(),n=o.useContext(Ht),r=ve(e),[l,s]=o.useState(()=>{var a;if(!t&&n!==null)return(a=n.current)!=null?a:null;if(J.isServer)return null;let u=r==null?void 0:r.getElementById("headlessui-portal-root");if(u)return u;if(r===null)return null;let i=r.createElement("div");return i.setAttribute("id","headlessui-portal-root"),r.body.appendChild(i)});return o.useEffect(()=>{l!==null&&(r!=null&&r.body.contains(l)||r==null||r.body.appendChild(l))},[l,r]),o.useEffect(()=>{t||n!==null&&s(n.current)},[n,s,t]),l}let Ut=o.Fragment,mr=k(function(e,t){let n=e,r=o.useRef(null),l=q(Mn(x=>{r.current=x}),t),s=ve(r),a=fr(r),[u]=o.useState(()=>{var x;return J.isServer?null:(x=s==null?void 0:s.createElement("div"))!=null?x:null}),i=o.useContext(ot),c=ge();L(()=>{!a||!u||a.contains(u)||(u.setAttribute("data-headlessui-portal",""),a.appendChild(u))},[a,u]),L(()=>{if(u&&i)return i.register(u)},[i,u]),At(()=>{var x;!a||!u||(u instanceof Node&&a.contains(u)&&a.removeChild(u),a.childNodes.length<=0&&((x=a.parentElement)==null||x.removeChild(a)))});let m=D();return c?!a||!u?null:nn.createPortal(m({ourProps:{ref:l},theirProps:n,slot:{},defaultTag:Ut,name:"Portal"}),u):null});function pr(e,t){let n=q(t),{enabled:r=!0,...l}=e,s=D();return r?o.createElement(mr,{...l,ref:n}):s({ourProps:{ref:n},theirProps:l,slot:{},defaultTag:Ut,name:"Portal"})}let hr=o.Fragment,Ht=o.createContext(null);function vr(e,t){let{target:n,...r}=e,l={ref:q(t)},s=D();return o.createElement(Ht.Provider,{value:n},s({ourProps:l,theirProps:r,defaultTag:hr,name:"Popover.Group"}))}let ot=o.createContext(null);function gr(){let e=o.useContext(ot),t=o.useRef([]),n=O(s=>(t.current.push(s),e&&e.register(s),()=>r(s))),r=O(s=>{let a=t.current.indexOf(s);a!==-1&&t.current.splice(a,1),e&&e.unregister(s)}),l=o.useMemo(()=>({register:n,unregister:r,portals:t}),[n,r,t]);return[t,o.useMemo(()=>function({children:s}){return o.createElement(ot.Provider,{value:l},s)},[l])]}let wr=k(pr),Wt=k(vr),Er=Object.assign(wr,{Group:Wt});function xr(e,t=typeof document<"u"?document.defaultView:null,n){let r=se(e,"escape");kt(t,"keydown",l=>{r&&(l.defaultPrevented||l.key===$t.Escape&&n(l))})}function yr(){var e;let[t]=o.useState(()=>typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia("(pointer: coarse)"):null),[n,r]=o.useState((e=t==null?void 0:t.matches)!=null?e:!1);return L(()=>{if(!t)return;function l(s){r(s.matches)}return t.addEventListener("change",l),()=>t.removeEventListener("change",l)},[t]),n}function br({defaultContainers:e=[],portals:t,mainTreeNode:n}={}){let r=ve(n),l=O(()=>{var s,a;let u=[];for(let i of e)i!==null&&(i instanceof HTMLElement?u.push(i):"current"in i&&i.current instanceof HTMLElement&&u.push(i.current));if(t!=null&&t.current)for(let i of t.current)u.push(i);for(let i of(s=r==null?void 0:r.querySelectorAll("html > *, body > *"))!=null?s:[])i!==document.body&&i!==document.head&&i instanceof HTMLElement&&i.id!=="headlessui-portal-root"&&(n&&(i.contains(n)||i.contains((a=n==null?void 0:n.getRootNode())==null?void 0:a.host))||u.some(c=>i.contains(c))||u.push(i));return u});return{resolveContainers:l,contains:O(s=>l().some(a=>a.contains(s)))}}let _t=o.createContext(null);function Bt({children:e,node:t}){let[n,r]=o.useState(null),l=qt(t??n);return o.createElement(_t.Provider,{value:l},e,l===null&&o.createElement(et,{features:Le.Hidden,ref:s=>{var a,u;if(s){for(let i of(u=(a=Oe(s))==null?void 0:a.querySelectorAll("html > *, body > *"))!=null?u:[])if(i!==document.body&&i!==document.head&&i instanceof HTMLElement&&i!=null&&i.contains(s)){r(i);break}}}}))}function qt(e=null){var t;return(t=o.useContext(_t))!=null?t:e}function it(){let e=o.useRef(!1);return L(()=>(e.current=!0,()=>{e.current=!1}),[]),e}var we=(e=>(e[e.Forwards=0]="Forwards",e[e.Backwards=1]="Backwards",e))(we||{});function $r(){let e=o.useRef(0);return Ft(!0,"keydown",t=>{t.key==="Tab"&&(e.current=t.shiftKey?1:0)},!0),e}function Xt(e){if(!e)return new Set;if(typeof e=="function")return new Set(e());let t=new Set;for(let n of e.current)n.current instanceof HTMLElement&&t.add(n.current);return t}let Mr="div";var te=(e=>(e[e.None=0]="None",e[e.InitialFocus=1]="InitialFocus",e[e.TabLock=2]="TabLock",e[e.FocusLock=4]="FocusLock",e[e.RestoreFocus=8]="RestoreFocus",e[e.AutoFocus=16]="AutoFocus",e))(te||{});function Cr(e,t){let n=o.useRef(null),r=q(n,t),{initialFocus:l,initialFocusFallback:s,containers:a,features:u=15,...i}=e;ge()||(u=0);let c=ve(n);Pr(u,{ownerDocument:c});let m=Fr(u,{ownerDocument:c,container:n,initialFocus:l,initialFocusFallback:s});Lr(u,{ownerDocument:c,container:n,containers:a,previousActiveElement:m});let x=$r(),b=O(h=>{let g=n.current;g&&(y=>y())(()=>{G(x.current,{[we.Forwards]:()=>{pe(g,V.First,{skipElements:[h.relatedTarget,s]})},[we.Backwards]:()=>{pe(g,V.Last,{skipElements:[h.relatedTarget,s]})}})})}),E=se(!!(u&2),"focus-trap#tab-lock"),f=Je(),w=o.useRef(!1),d={ref:r,onKeyDown(h){h.key=="Tab"&&(w.current=!0,f.requestAnimationFrame(()=>{w.current=!1}))},onBlur(h){if(!(u&4))return;let g=Xt(a);n.current instanceof HTMLElement&&g.add(n.current);let y=h.relatedTarget;y instanceof HTMLElement&&y.dataset.headlessuiFocusGuard!=="true"&&(Vt(g,y)||(w.current?pe(n.current,G(x.current,{[we.Forwards]:()=>V.Next,[we.Backwards]:()=>V.Previous})|V.WrapAround,{relativeTo:h.target}):h.target instanceof HTMLElement&&Y(h.target)))}},p=D();return o.createElement(o.Fragment,null,E&&o.createElement(et,{as:"button",type:"button","data-headlessui-focus-guard":!0,onFocus:b,features:Le.Focusable}),p({ourProps:d,theirProps:i,defaultTag:Mr,name:"FocusTrap"}),E&&o.createElement(et,{as:"button",type:"button","data-headlessui-focus-guard":!0,onFocus:b,features:Le.Focusable}))}let Sr=k(Cr),Or=Object.assign(Sr,{features:te});function Tr(e=!0){let t=o.useRef(Z.slice());return lt(([n],[r])=>{r===!0&&n===!1&&Te(()=>{t.current.splice(0)}),r===!1&&n===!0&&(t.current=Z.slice())},[e,Z,t]),O(()=>{var n;return(n=t.current.find(r=>r!=null&&r.isConnected))!=null?n:null})}function Pr(e,{ownerDocument:t}){let n=!!(e&8),r=Tr(n);lt(()=>{n||(t==null?void 0:t.activeElement)===(t==null?void 0:t.body)&&Y(r())},[n]),At(()=>{n&&Y(r())})}function Fr(e,{ownerDocument:t,container:n,initialFocus:r,initialFocusFallback:l}){let s=o.useRef(null),a=se(!!(e&1),"focus-trap#initial-focus"),u=it();return lt(()=>{if(e===0)return;if(!a){l!=null&&l.current&&Y(l.current);return}let i=n.current;i&&Te(()=>{if(!u.current)return;let c=t==null?void 0:t.activeElement;if(r!=null&&r.current){if((r==null?void 0:r.current)===c){s.current=c;return}}else if(i.contains(c)){s.current=c;return}if(r!=null&&r.current)Y(r.current);else{if(e&16){if(pe(i,V.First|V.AutoFocus)!==rt.Error)return}else if(pe(i,V.First)!==rt.Error)return;if(l!=null&&l.current&&(Y(l.current),(t==null?void 0:t.activeElement)===l.current))return;console.warn("There are no focusable elements inside the <FocusTrap />")}s.current=t==null?void 0:t.activeElement})},[l,a,e]),s}function Lr(e,{ownerDocument:t,container:n,containers:r,previousActiveElement:l}){let s=it(),a=!!(e&4);kt(t==null?void 0:t.defaultView,"focus",u=>{if(!a||!s.current)return;let i=Xt(r);n.current instanceof HTMLElement&&i.add(n.current);let c=l.current;if(!c)return;let m=u.target;m&&m instanceof HTMLElement?Vt(i,m)?(l.current=m,Y(m)):(u.preventDefault(),u.stopPropagation(),Y(c)):Y(l.current)},!0)}function Vt(e,t){for(let n of e)if(n.contains(t))return!0;return!1}function Yt(e){var t;return!!(e.enter||e.enterFrom||e.enterTo||e.leave||e.leaveFrom||e.leaveTo)||((t=e.as)!=null?t:Gt)!==o.Fragment||o.Children.count(e.children)===1}let Ae=o.createContext(null);Ae.displayName="TransitionContext";var kr=(e=>(e.Visible="visible",e.Hidden="hidden",e))(kr||{});function Nr(){let e=o.useContext(Ae);if(e===null)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition /> or <Transition.Root />.");return e}function Ir(){let e=o.useContext(De);if(e===null)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition /> or <Transition.Root />.");return e}let De=o.createContext(null);De.displayName="NestingContext";function je(e){return"children"in e?je(e.children):e.current.filter(({el:t})=>t.current!==null).filter(({state:t})=>t==="visible").length>0}function zt(e,t){let n=Q(e),r=o.useRef([]),l=it(),s=Je(),a=O((E,f=K.Hidden)=>{let w=r.current.findIndex(({el:d})=>d===E);w!==-1&&(G(f,{[K.Unmount](){r.current.splice(w,1)},[K.Hidden](){r.current[w].state="hidden"}}),s.microTask(()=>{var d;!je(r)&&l.current&&((d=n.current)==null||d.call(n))}))}),u=O(E=>{let f=r.current.find(({el:w})=>w===E);return f?f.state!=="visible"&&(f.state="visible"):r.current.push({el:E,state:"visible"}),()=>a(E,K.Unmount)}),i=o.useRef([]),c=o.useRef(Promise.resolve()),m=o.useRef({enter:[],leave:[]}),x=O((E,f,w)=>{i.current.splice(0),t&&(t.chains.current[f]=t.chains.current[f].filter(([d])=>d!==E)),t==null||t.chains.current[f].push([E,new Promise(d=>{i.current.push(d)})]),t==null||t.chains.current[f].push([E,new Promise(d=>{Promise.all(m.current[f].map(([p,h])=>h)).then(()=>d())})]),f==="enter"?c.current=c.current.then(()=>t==null?void 0:t.wait.current).then(()=>w(f)):w(f)}),b=O((E,f,w)=>{Promise.all(m.current[f].splice(0).map(([d,p])=>p)).then(()=>{var d;(d=i.current.shift())==null||d()}).then(()=>w(f))});return o.useMemo(()=>({children:r,register:u,unregister:a,onStart:x,onStop:b,wait:c,chains:m}),[u,a,r,x,b,m,c])}let Gt=o.Fragment,Kt=Pe.RenderStrategy;function Ar(e,t){var n,r;let{transition:l=!0,beforeEnter:s,afterEnter:a,beforeLeave:u,afterLeave:i,enter:c,enterFrom:m,enterTo:x,entered:b,leave:E,leaveFrom:f,leaveTo:w,...d}=e,[p,h]=o.useState(null),g=o.useRef(null),y=Yt(e),v=q(...y?[g,t,h]:t===null?[]:[t]),M=(n=d.unmount)==null||n?K.Unmount:K.Hidden,{show:T,appear:I,initial:U}=Nr(),[F,A]=o.useState(T?"visible":"hidden"),H=Ir(),{register:W,unregister:S}=H;L(()=>W(g),[W,g]),L(()=>{if(M===K.Hidden&&g.current){if(T&&F!=="visible"){A("visible");return}return G(F,{hidden:()=>S(g),visible:()=>W(g)})}},[F,g,W,S,T,M]);let _=ge();L(()=>{if(y&&_&&F==="visible"&&g.current===null)throw new Error("Did you forget to passthrough the `ref` to the actual DOM node?")},[g,F,_,y]);let He=U&&!I,We=I&&T&&U,Ee=o.useRef(!1),X=zt(()=>{Ee.current||(A("hidden"),S(g))},H),_e=O(dt=>{Ee.current=!0;let qe=dt?"enter":"leave";X.onStart(g,qe,ye=>{ye==="enter"?s==null||s():ye==="leave"&&(u==null||u())})}),P=O(dt=>{let qe=dt?"enter":"leave";Ee.current=!1,X.onStop(g,qe,ye=>{ye==="enter"?a==null||a():ye==="leave"&&(i==null||i())}),qe==="leave"&&!je(X)&&(A("hidden"),S(g))});o.useEffect(()=>{y&&l||(_e(T),P(T))},[T,y,l]);let Be=!(!l||!y||!_||He),[,N]=rr(Be,p,T,{start:_e,end:P}),ol=R({ref:v,className:((r=Qe(d.className,We&&c,We&&m,N.enter&&c,N.enter&&N.closed&&m,N.enter&&!N.closed&&x,N.leave&&E,N.leave&&!N.closed&&f,N.leave&&N.closed&&w,!N.transition&&T&&b))==null?void 0:r.trim())||void 0,...nr(N)}),xe=0;F==="visible"&&(xe|=j.Open),F==="hidden"&&(xe|=j.Closed),N.enter&&(xe|=j.Opening),N.leave&&(xe|=j.Closing);let il=D();return o.createElement(De.Provider,{value:X},o.createElement(sr,{value:xe},il({ourProps:ol,theirProps:d,defaultTag:Gt,features:Kt,visible:F==="visible",name:"Transition.Child"})))}function Dr(e,t){let{show:n,appear:r=!1,unmount:l=!0,...s}=e,a=o.useRef(null),u=Yt(e),i=q(...u?[a,t]:t===null?[]:[t]);ge();let c=Ie();if(n===void 0&&c!==null&&(n=(c&j.Open)===j.Open),n===void 0)throw new Error("A <Transition /> is used but it is missing a `show={true | false}` prop.");let[m,x]=o.useState(n?"visible":"hidden"),b=zt(()=>{n||x("hidden")}),[E,f]=o.useState(!0),w=o.useRef([n]);L(()=>{E!==!1&&w.current[w.current.length-1]!==n&&(w.current.push(n),f(!1))},[w,n]);let d=o.useMemo(()=>({show:n,appear:r,initial:E}),[n,r,E]);L(()=>{n?x("visible"):!je(b)&&a.current!==null&&x("hidden")},[n,b]);let p={unmount:l},h=O(()=>{var v;E&&f(!1),(v=e.beforeEnter)==null||v.call(e)}),g=O(()=>{var v;E&&f(!1),(v=e.beforeLeave)==null||v.call(e)}),y=D();return o.createElement(De.Provider,{value:b},o.createElement(Ae.Provider,{value:d},y({ourProps:{...p,as:o.Fragment,children:o.createElement(Zt,{ref:i,...p,...s,beforeEnter:h,beforeLeave:g})},theirProps:{},defaultTag:o.Fragment,features:Kt,visible:m==="visible",name:"Transition"})))}function jr(e,t){let n=o.useContext(Ae)!==null,r=Ie()!==null;return o.createElement(o.Fragment,null,!n&&r?o.createElement(st,{ref:t,...e}):o.createElement(Zt,{ref:t,...e}))}let st=k(Dr),Zt=k(Ar),ae=k(jr),Jt=Object.assign(st,{Child:ae,Root:st});var Ur=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(Ur||{}),Hr=(e=>(e[e.SetTitleId=0]="SetTitleId",e))(Hr||{});let Wr={0(e,t){return e.titleId===t.id?e:{...e,titleId:t.id}}},at=o.createContext(null);at.displayName="DialogContext";function Ue(e){let t=o.useContext(at);if(t===null){let n=new Error(`<${e} /> is missing a parent <Dialog /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(n,Ue),n}return t}function _r(e,t){return G(t.type,Wr,e,t)}let Qt=k(function(e,t){let n=o.useId(),{id:r=`headlessui-dialog-${n}`,open:l,onClose:s,initialFocus:a,role:u="dialog",autoFocus:i=!0,__demoMode:c=!1,unmount:m=!1,...x}=e,b=o.useRef(!1);u=function(){return u==="dialog"||u==="alertdialog"?u:(b.current||(b.current=!0,console.warn(`Invalid role [${u}] passed to <Dialog />. Only \`dialog\` and and \`alertdialog\` are supported. Using \`dialog\` instead.`)),"dialog")}();let E=Ie();l===void 0&&E!==null&&(l=(E&j.Open)===j.Open);let f=o.useRef(null),w=q(f,t),d=ve(f),p=l?0:1,[h,g]=o.useReducer(_r,{titleId:null,descriptionId:null,panelRef:o.createRef()}),y=O(()=>s(!1)),v=O(P=>g({type:0,id:P})),M=ge()?p===0:!1,[T,I]=gr(),U={get current(){var P;return(P=h.panelRef.current)!=null?P:f.current}},F=qt(),{resolveContainers:A}=br({mainTreeNode:F,portals:T,defaultContainers:[U]}),H=E!==null?(E&j.Closing)===j.Closing:!1;In(c||H?!1:M,{allowed:O(()=>{var P,Be;return[(Be=(P=f.current)==null?void 0:P.closest("[data-headlessui-portal]"))!=null?Be:null]}),disallowed:O(()=>{var P;return[(P=F==null?void 0:F.closest("body > *:not(#headlessui-portal-root)"))!=null?P:null]})}),zn(M,A,P=>{P.preventDefault(),y()}),xr(M,d==null?void 0:d.defaultView,P=>{P.preventDefault(),P.stopPropagation(),document.activeElement&&"blur"in document.activeElement&&typeof document.activeElement.blur=="function"&&document.activeElement.blur(),y()}),Rn(c||H?!1:M,d,A),An(M,f,y);let[W,S]=Cn(),_=o.useMemo(()=>[{dialogState:p,close:y,setTitleId:v,unmount:m},h],[p,h,y,v,m]),He=o.useMemo(()=>({open:p===0}),[p]),We={ref:w,id:r,role:u,tabIndex:-1,"aria-modal":c?void 0:p===0?!0:void 0,"aria-labelledby":h.titleId,"aria-describedby":W,unmount:m},Ee=!yr(),X=te.None;M&&!c&&(X|=te.RestoreFocus,X|=te.TabLock,i&&(X|=te.AutoFocus),Ee&&(X|=te.InitialFocus));let _e=D();return o.createElement(ar,null,o.createElement(jt,{force:!0},o.createElement(Er,null,o.createElement(at.Provider,{value:_},o.createElement(Wt,{target:f},o.createElement(jt,{force:!1},o.createElement(S,{slot:He},o.createElement(I,null,o.createElement(Or,{initialFocus:a,initialFocusFallback:f,containers:A,features:X},o.createElement(Ln,{value:y},_e({ourProps:We,theirProps:x,slot:He,defaultTag:Br,features:qr,visible:p===0,name:"Dialog"})))))))))))}),Br="div",qr=Pe.RenderStrategy|Pe.Static;function Xr(e,t){let{transition:n=!1,open:r,...l}=e,s=Ie(),a=e.hasOwnProperty("open")||s!==null,u=e.hasOwnProperty("onClose");if(!a&&!u)throw new Error("You have to provide an `open` and an `onClose` prop to the `Dialog` component.");if(!a)throw new Error("You provided an `onClose` prop to the `Dialog`, but forgot an `open` prop.");if(!u)throw new Error("You provided an `open` prop to the `Dialog`, but forgot an `onClose` prop.");if(!s&&typeof e.open!="boolean")throw new Error(`You provided an \`open\` prop to the \`Dialog\`, but the value is not a boolean. Received: ${e.open}`);if(typeof e.onClose!="function")throw new Error(`You provided an \`onClose\` prop to the \`Dialog\`, but the value is not a function. Received: ${e.onClose}`);return(r!==void 0||n)&&!l.static?o.createElement(Bt,null,o.createElement(Jt,{show:r,transition:n,unmount:l.unmount},o.createElement(Qt,{ref:t,...l}))):o.createElement(Bt,null,o.createElement(Qt,{ref:t,open:r,...l}))}let Vr="div";function Yr(e,t){let n=o.useId(),{id:r=`headlessui-dialog-panel-${n}`,transition:l=!1,...s}=e,[{dialogState:a,unmount:u},i]=Ue("Dialog.Panel"),c=q(t,i.panelRef),m=o.useMemo(()=>({open:a===0}),[a]),x=O(d=>{d.stopPropagation()}),b={ref:c,id:r,onClick:x},E=l?ae:o.Fragment,f=l?{unmount:u}:{},w=D();return o.createElement(E,{...f},w({ourProps:b,theirProps:s,slot:m,defaultTag:Vr,name:"Dialog.Panel"}))}let zr="div";function Gr(e,t){let{transition:n=!1,...r}=e,[{dialogState:l,unmount:s}]=Ue("Dialog.Backdrop"),a=o.useMemo(()=>({open:l===0}),[l]),u={ref:t,"aria-hidden":!0},i=n?ae:o.Fragment,c=n?{unmount:s}:{},m=D();return o.createElement(i,{...c},m({ourProps:u,theirProps:r,slot:a,defaultTag:zr,name:"Dialog.Backdrop"}))}let Kr="h2";function Zr(e,t){let n=o.useId(),{id:r=`headlessui-dialog-title-${n}`,...l}=e,[{dialogState:s,setTitleId:a}]=Ue("Dialog.Title"),u=q(t);o.useEffect(()=>(a(r),()=>a(null)),[r,a]);let i=o.useMemo(()=>({open:s===0}),[s]),c={ref:u,id:r};return D()({ourProps:c,theirProps:l,slot:i,defaultTag:Kr,name:"Dialog.Title"})}let Jr=k(Xr),ut=k(Yr);k(Gr);let Qr=k(Zr),Rr=Object.assign(Jr,{Panel:ut,Title:Qr,Description:Pn});function Rt({onClick:e}){return $.jsxs("button",{type:"button",className:"im-close-button text-gray-400 hover:text-gray-500",onClick:e,children:[$.jsx("span",{className:"sr-only",children:"Close"}),$.jsx("svg",{className:"size-6",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"2",stroke:"currentColor","aria-hidden":"true",children:$.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})]})}const el=({modalContext:e,config:t,children:n})=>{const[r,l]=o.useState(!1);return $.jsx("div",{className:"im-modal-container fixed inset-0 z-40 overflow-y-auto p-4",children:$.jsx("div",{className:Se("im-modal-positioner flex min-h-full justify-center",{"items-start":t.position==="top","items-center":t.position==="center","items-end":t.position==="bottom"}),children:$.jsx(ae,{as:"div",enterFrom:"opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",enterTo:"opacity-100 translate-y-0 sm:scale-100",leaveFrom:"opacity-100 translate-y-0 sm:scale-100",leaveTo:"opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",afterEnter:()=>l(!0),afterLeave:e.afterLeave,className:Se("im-modal-wrapper w-full transition duration-300 ease-in-out",e.onTopOfStack?"":"blur-sm",{"sm:max-w-sm":t.maxWidth==="sm","sm:max-w-md":t.maxWidth==="md","sm:max-w-md md:max-w-lg":t.maxWidth==="lg","sm:max-w-md md:max-w-xl":t.maxWidth==="xl","sm:max-w-md md:max-w-xl lg:max-w-2xl":t.maxWidth==="2xl","sm:max-w-md md:max-w-xl lg:max-w-3xl":t.maxWidth==="3xl","sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-4xl":t.maxWidth==="4xl","sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl":t.maxWidth==="5xl","sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl 2xl:max-w-6xl":t.maxWidth==="6xl","sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl 2xl:max-w-7xl":t.maxWidth==="7xl"}),children:$.jsxs(ut,{className:`im-modal-content relative ${t.paddingClasses} ${t.panelClasses}`,"data-inertiaui-modal-entered":r,children:[t.closeButton&&$.jsx("div",{className:"absolute right-0 top-0 pr-3 pt-3",children:$.jsx(Rt,{onClick:e.close})}),typeof n=="function"?n({modalContext:e,config:t}):n]})})})})},tl=({modalContext:e,config:t,children:n})=>{const[r,l]=o.useState(!1);return $.jsx("div",{className:"im-slideover-container fixed inset-0 z-40 overflow-y-auto overflow-x-hidden",children:$.jsx("div",{className:Se("im-slideover-positioner flex min-h-full items-center",{"justify-start rtl:justify-end":(t==null?void 0:t.position)==="left","justify-end rtl:justify-start":(t==null?void 0:t.position)==="right"}),children:$.jsx(ae,{as:"div",enterFrom:`opacity-0 ${t.position==="left"?"-translate-x-full":"translate-x-full"}`,enterTo:"opacity-100 translate-x-0",leaveFrom:"opacity-100 translate-x-0",leaveTo:`opacity-0 ${t.position==="left"?"-translate-x-full":"translate-x-full"}`,afterEnter:()=>l(!0),afterLeave:e.afterLeave,className:Se("im-slideover-wrapper w-full transition duration-300 ease-in-out",e.onTopOfStack?"":"blur-sm",{"sm:max-w-sm":t.maxWidth==="sm","sm:max-w-md":t.maxWidth==="md","sm:max-w-md md:max-w-lg":t.maxWidth==="lg","sm:max-w-md md:max-w-xl":t.maxWidth==="xl","sm:max-w-md md:max-w-xl lg:max-w-2xl":t.maxWidth==="2xl","sm:max-w-md md:max-w-xl lg:max-w-3xl":t.maxWidth==="3xl","sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-4xl":t.maxWidth==="4xl","sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl":t.maxWidth==="5xl","sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl 2xl:max-w-6xl":t.maxWidth==="6xl","sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl 2xl:max-w-7xl":t.maxWidth==="7xl"}),children:$.jsxs(ut,{className:`im-slideover-content relative ${t.paddingClasses} ${t.panelClasses}`,"data-inertiaui-modal-entered":r,children:[t.closeButton&&$.jsx("div",{className:"absolute right-0 top-0 pr-3 pt-3",children:$.jsx(Rt,{onClick:e.close})}),typeof n=="function"?n({modalContext:e,config:t}):n]})})})})},en=o.forwardRef(({name:e,children:t,onFocus:n=null,onBlur:r=null,onClose:l=null,onSuccess:s=null,onAfterLeave:a=null,...u},i)=>{const c=x=>typeof t=="function"?t(x):t,m=o.useRef(null);return o.useImperativeHandle(i,()=>m.current,[m]),$.jsx(Ke,{ref:m,name:e,onFocus:n,onBlur:r,onClose:l,onSuccess:s,...u,children:({afterLeave:x,close:b,config:E,emit:f,getChildModal:w,getParentModal:d,id:p,index:h,isOpen:g,modalContext:y,onTopOfStack:v,reload:M,setOpen:T,shouldRender:I})=>$.jsx(Jt,{appear:!0,show:g??!1,afterLeave:a,children:$.jsxs(Rr,{as:"div",className:"im-dialog relative z-20",onClose:()=>E.closeExplicitly?null:b(),"data-inertiaui-modal-id":p,"data-inertiaui-modal-index":h,children:[h===0?$.jsx(ae,{enter:"transition transform ease-in-out duration-300",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"transition transform ease-in-out duration-300",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:v?$.jsx("div",{className:"im-backdrop fixed inset-0 z-30 bg-black/75","aria-hidden":"true"}):$.jsx("div",{})}):null,h>0&&v?$.jsx("div",{className:"im-backdrop fixed inset-0 z-30 bg-black/75"}):null,E.slideover?$.jsx(tl,{modalContext:y,config:E,children:c({afterLeave:x,close:b,config:E,emit:f,getChildModal:w,getParentModal:d,id:p,index:h,isOpen:g,modalContext:y,onTopOfStack:v,reload:M,setOpen:T,shouldRender:I})}):$.jsx(el,{modalContext:y,config:E,children:c({afterLeave:x,close:b,config:E,emit:f,getChildModal:w,getParentModal:d,id:p,index:h,isOpen:g,modalContext:y,onTopOfStack:v,reload:M,setOpen:T,shouldRender:I})})]})})})});en.displayName="Modal";const nl=({href:e,method:t="get",data:n={},as:r="a",headers:l={},queryStringArrayFormat:s="brackets",onAfterLeave:a=null,onBlur:u=null,onClose:i=null,onError:c=null,onFocus:m=null,onStart:x=null,onSuccess:b=null,navigate:E=null,children:f,...w})=>{const[d,p]=o.useState(!1),[h,g]=o.useState(null),{stack:y,visit:v}=fe(),M=o.useMemo(()=>E??Me("navigate"),[E]),T={},I={};Object.keys(w).forEach(S=>{ht.includes(S)||(S.startsWith("on")&&typeof w[S]=="function"?S.toLowerCase()in window?T[S]=w[S]:I[S]=w[S]:T[S]=w[S])});const[U,F]=o.useState(!1);o.useEffect(()=>{h&&(h.onTopOfStack&&U?m==null||m():!h.onTopOfStack&&!U&&(u==null||u()),F(!h.onTopOfStack))},[y]);const A=o.useCallback(()=>{i==null||i()},[i]),H=o.useCallback(()=>{g(null),a==null||a()},[a]),W=o.useCallback(S=>{S==null||S.preventDefault(),!d&&(e.startsWith("#")||(p(!0),x==null||x()),v(e,t,n,l,dn(ct(w,ht)),()=>A(y.length),H,s,M).then(_=>{g(_),_.registerEventListenersFromProps(I),b==null||b()}).catch(_=>{console.error(_),c==null||c(_)}).finally(()=>p(!1)))},[e,t,n,l,s,w,A,H]);return $.jsx(r,{...T,href:e,onClick:W,children:typeof f=="function"?f({loading:d}):f})};function rl(){return fe().stack[Ge()]??null}const ll=e=>t=>(t.default.layout=n=>o.createElement(e,{},n),t);C.HeadlessModal=Ke,C.Modal=en,C.ModalLink=nl,C.ModalRoot=gt,C.ModalStackProvider=pt,C.getConfig=Me,C.initFromPageProps=vt,C.putConfig=sn,C.renderApp=fn,C.resetConfig=on,C.setPageLayout=ll,C.useModal=rl,C.useModalIndex=Ge,C.useModalStack=fe,Object.defineProperty(C,Symbol.toStringTag,{value:"Module"})});
4
+ `))}else{let b=c.props,w=b==null?void 0:b.className,f=typeof w=="function"?(...m)=>Qe(w(...m),s.className):Qe(w,s.className),x=f?{className:f}:{},d=xt(c.props,R(Re(s,["ref"])));for(let m in g)m in d&&delete g[m];return o.cloneElement(c,Object.assign({},d,g,h,{ref:l(bn(c),h.ref)},x))}return o.createElement(i,Object.assign({},Re(s,["ref"]),i!==o.Fragment&&h,i!==o.Fragment&&g),c)}function En(){let e=o.useRef([]),t=o.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 xn(...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 xt(...e){if(e.length===0)return{};if(e.length===1)return e[0];let t={},n={};for(let r of e)for(let l in r)l.startsWith("on")&&typeof r[l]=="function"?(n[l]!=null||(n[l]=[]),n[l].push(r[l])):t[l]=r[l];if(t.disabled||t["aria-disabled"])for(let r in n)/^(on(?:Click|Pointer|Mouse|Key)(?:Down|Up|Press)?)$/.test(r)&&(n[r]=[l=>{var i;return(i=l==null?void 0:l.preventDefault)==null?void 0:i.call(l)}]);for(let r in n)Object.assign(t,{[r](l,...i){let a=n[r];for(let u of a){if((l instanceof Event||(l==null?void 0:l.nativeEvent)instanceof Event)&&l.defaultPrevented)return;u(l,...i)}}});return t}function k(e){var t;return Object.assign(o.forwardRef(e),{displayName:(t=e.displayName)!=null?t:e.name})}function R(e){let t=Object.assign({},e);for(let n in t)t[n]===void 0&&delete t[n];return t}function Re(e,t=[]){let n=Object.assign({},e);for(let r of t)r in n&&delete n[r];return n}function bn(e){return o.version.split(".")[0]>="19"?e.props.ref:e.ref}let yn="span";var Le=(e=>(e[e.None=1]="None",e[e.Focusable=2]="Focusable",e[e.Hidden=4]="Hidden",e))(Le||{});function $n(e,t){var n;let{features:r=1,...l}=e,i={ref:t,"aria-hidden":(r&2)===2?!0:(n=l["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 D()({ourProps:i,theirProps:l,slot:{},defaultTag:yn,name:"Hidden"})}let et=k($n),bt=Symbol();function Mn(e,t=!0){return Object.assign(e,{[bt]:t})}function q(...e){let t=o.useRef(e);o.useEffect(()=>{t.current=e},[e]);let n=O(r=>{for(let l of t.current)l!=null&&(typeof l=="function"?l(r):l.current=r)});return e.every(r=>r==null||(r==null?void 0:r[bt]))?void 0:n}let tt=o.createContext(null);tt.displayName="DescriptionContext";function yt(){let e=o.useContext(tt);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,yt),t}return e}function Cn(){let[e,t]=o.useState([]);return[e.length>0?e.join(" "):void 0,o.useMemo(()=>function(n){let r=O(i=>(t(a=>[...a,i]),()=>t(a=>{let u=a.slice(),s=u.indexOf(i);return s!==-1&&u.splice(s,1),u}))),l=o.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 o.createElement(tt.Provider,{value:l},n.children)},[t])]}let Sn="p";function On(e,t){let n=o.useId(),r=gn(),{id:l=`headlessui-description-${n}`,...i}=e,a=yt(),u=q(t);L(()=>a.register(l),[l,a.register]);let s=r||!1,h=o.useMemo(()=>({...a.slot,disabled:s}),[a.slot,s]),c={ref:u,...a.props,id:l};return D()({ourProps:c,theirProps:i,slot:h,defaultTag:Sn,name:a.name||"Description"})}let Tn=k(On),Pn=Object.assign(Tn,{});var $t=(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))($t||{});let Fn=o.createContext(()=>{});function Ln({value:e,children:t}){return o.createElement(Fn.Provider,{value:e},t)}let kn=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 Mt(e,t){let n=e(),r=new Set;return{getSnapshot(){return n},subscribe(l){return r.add(l),()=>r.delete(l)},dispatch(l,...i){let a=t[l].call(n,...i);a&&(n=a,r.forEach(u=>u()))}}}function Ct(e){return o.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getSnapshot)}let Nn=new kn(()=>Mt(()=>[],{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 se(e,t){let n=Nn.get(t),r=o.useId(),l=Ct(n);if(L(()=>{if(e)return n.dispatch("ADD",r),()=>n.dispatch("REMOVE",r)},[n,e]),!e)return!1;let i=l.indexOf(r),a=l.length;return i===-1&&(i=a,a+=1),i===a-1}let nt=new Map,me=new Map;function St(e){var t;let n=(t=me.get(e))!=null?t:0;return me.set(e,n+1),n!==0?()=>Ot(e):(nt.set(e,{"aria-hidden":e.getAttribute("aria-hidden"),inert:e.inert}),e.setAttribute("aria-hidden","true"),e.inert=!0,()=>Ot(e))}function Ot(e){var t;let n=(t=me.get(e))!=null?t:1;if(n===1?me.delete(e):me.set(e,n-1),n!==1)return;let r=nt.get(e);r&&(r["aria-hidden"]===null?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",r["aria-hidden"]),e.inert=r.inert,nt.delete(e))}function In(e,{allowed:t,disallowed:n}={}){let r=se(e,"inert-others");L(()=>{var l,i;if(!r)return;let a=z();for(let s of(l=n==null?void 0:n())!=null?l:[])s&&a.add(St(s));let u=(i=t==null?void 0:t())!=null?i:[];for(let s of u){if(!s)continue;let h=Oe(s);if(!h)continue;let c=s.parentElement;for(;c&&c!==h.body;){for(let g of c.children)u.some(b=>g.contains(b))||a.add(St(g));c=c.parentElement}}return a.dispose},[r,t,n])}function An(e,t,n){let r=Q(l=>{let i=l.getBoundingClientRect();i.x===0&&i.y===0&&i.width===0&&i.height===0&&n()});o.useEffect(()=>{if(!e)return;let l=t===null?null:t instanceof HTMLElement?t:t.current;if(!l)return;let i=z();if(typeof ResizeObserver<"u"){let a=new ResizeObserver(()=>r.current(l));a.observe(l),i.add(()=>a.disconnect())}if(typeof IntersectionObserver<"u"){let a=new IntersectionObserver(()=>r.current(l));a.observe(l),i.add(()=>a.disconnect())}return()=>i.dispose()},[t,r,e])}let ke=["[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(","),Dn=["[data-autofocus]"].map(e=>`${e}:not([tabindex='-1'])`).join(",");var V=(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))(V||{}),rt=(e=>(e[e.Error=0]="Error",e[e.Overflow=1]="Overflow",e[e.Success=2]="Success",e[e.Underflow=3]="Underflow",e))(rt||{}),jn=(e=>(e[e.Previous=-1]="Previous",e[e.Next=1]="Next",e))(jn||{});function Un(e=document.body){return e==null?[]:Array.from(e.querySelectorAll(ke)).sort((t,n)=>Math.sign((t.tabIndex||Number.MAX_SAFE_INTEGER)-(n.tabIndex||Number.MAX_SAFE_INTEGER)))}function Hn(e=document.body){return e==null?[]:Array.from(e.querySelectorAll(Dn)).sort((t,n)=>Math.sign((t.tabIndex||Number.MAX_SAFE_INTEGER)-(n.tabIndex||Number.MAX_SAFE_INTEGER)))}var Tt=(e=>(e[e.Strict=0]="Strict",e[e.Loose=1]="Loose",e))(Tt||{});function Wn(e,t=0){var n;return e===((n=Oe(e))==null?void 0:n.body)?!1:G(t,{0(){return e.matches(ke)},1(){let r=e;for(;r!==null;){if(r.matches(ke))return!0;r=r.parentElement}return!1}})}var _n=(e=>(e[e.Keyboard=0]="Keyboard",e[e.Mouse=1]="Mouse",e))(_n||{});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 Y(e){e==null||e.focus({preventScroll:!0})}let Bn=["textarea","input"].join(",");function qn(e){var t,n;return(n=(t=e==null?void 0:e.matches)==null?void 0:t.call(e,Bn))!=null?n:!1}function Xn(e,t=n=>n){return e.slice().sort((n,r)=>{let l=t(n),i=t(r);if(l===null||i===null)return 0;let a=l.compareDocumentPosition(i);return a&Node.DOCUMENT_POSITION_FOLLOWING?-1:a&Node.DOCUMENT_POSITION_PRECEDING?1:0})}function pe(e,t,{sorted:n=!0,relativeTo:r=null,skipElements:l=[]}={}){let i=Array.isArray(e)?e.length>0?e[0].ownerDocument:document:e.ownerDocument,a=Array.isArray(e)?n?Xn(e):e:t&64?Hn(e):Un(e);l.length>0&&a.length>1&&(a=a.filter(w=>!l.some(f=>f!=null&&"current"in f?(f==null?void 0:f.current)===w:f===w))),r=r??i.activeElement;let u=(()=>{if(t&5)return 1;if(t&10)return-1;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")})(),s=(()=>{if(t&1)return 0;if(t&2)return Math.max(0,a.indexOf(r))-1;if(t&4)return Math.max(0,a.indexOf(r))+1;if(t&8)return a.length-1;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")})(),h=t&32?{preventScroll:!0}:{},c=0,g=a.length,b;do{if(c>=g||c+g<=0)return 0;let w=s+c;if(t&16)w=(w+g)%g;else{if(w<0)return 3;if(w>=g)return 1}b=a[w],b==null||b.focus(h),c+=u}while(b!==i.activeElement);return t&6&&qn(b)&&b.select(),2}function Pt(){return/iPhone/gi.test(window.navigator.platform)||/Mac/gi.test(window.navigator.platform)&&window.navigator.maxTouchPoints>0}function Vn(){return/Android/gi.test(window.navigator.userAgent)}function Yn(){return Pt()||Vn()}function he(e,t,n,r){let l=Q(n);o.useEffect(()=>{if(!e)return;function i(a){l.current(a)}return document.addEventListener(t,i,r),()=>document.removeEventListener(t,i,r)},[e,t,r])}function Ft(e,t,n,r){let l=Q(n);o.useEffect(()=>{if(!e)return;function i(a){l.current(a)}return window.addEventListener(t,i,r),()=>window.removeEventListener(t,i,r)},[e,t,r])}const Lt=30;function zn(e,t,n){let r=se(e,"outside-click"),l=Q(n),i=o.useCallback(function(s,h){if(s.defaultPrevented)return;let c=h(s);if(c===null||!c.getRootNode().contains(c)||!c.isConnected)return;let g=function b(w){return typeof w=="function"?b(w()):Array.isArray(w)||w instanceof Set?w:[w]}(t);for(let b of g)if(b!==null&&(b.contains(c)||s.composed&&s.composedPath().includes(b)))return;return!Wn(c,Tt.Loose)&&c.tabIndex!==-1&&s.preventDefault(),l.current(s,c)},[l,t]),a=o.useRef(null);he(r,"pointerdown",s=>{var h,c;a.current=((c=(h=s.composedPath)==null?void 0:h.call(s))==null?void 0:c[0])||s.target},!0),he(r,"mousedown",s=>{var h,c;a.current=((c=(h=s.composedPath)==null?void 0:h.call(s))==null?void 0:c[0])||s.target},!0),he(r,"click",s=>{Yn()||a.current&&(i(s,()=>a.current),a.current=null)},!0);let u=o.useRef({x:0,y:0});he(r,"touchstart",s=>{u.current.x=s.touches[0].clientX,u.current.y=s.touches[0].clientY},!0),he(r,"touchend",s=>{let h={x:s.changedTouches[0].clientX,y:s.changedTouches[0].clientY};if(!(Math.abs(h.x-u.current.x)>=Lt||Math.abs(h.y-u.current.y)>=Lt))return i(s,()=>s.target instanceof HTMLElement?s.target:null)},!0),Ft(r,"blur",s=>i(s,()=>window.document.activeElement instanceof HTMLIFrameElement?window.document.activeElement:null),!0)}function ve(...e){return o.useMemo(()=>Oe(...e),[...e])}function kt(e,t,n,r){let l=Q(n);o.useEffect(()=>{e=e??window;function i(a){l.current(a)}return e.addEventListener(t,i,r),()=>e.removeEventListener(t,i,r)},[e,t,r])}function Gn(){let e;return{before({doc:t}){var n;let r=t.documentElement,l=(n=t.defaultView)!=null?n:window;e=Math.max(0,l.innerWidth-r.clientWidth)},after({doc:t,d:n}){let r=t.documentElement,l=Math.max(0,r.clientWidth-r.offsetWidth),i=Math.max(0,e-l);n.style(r,"paddingRight",`${i}px`)}}}function Kn(){return Pt()?{before({doc:e,d:t,meta:n}){function r(l){return n.containers.flatMap(i=>i()).some(i=>i.contains(l))}t.microTask(()=>{var l;if(window.getComputedStyle(e.documentElement).scrollBehavior!=="auto"){let u=z();u.style(e.documentElement,"scrollBehavior","auto"),t.add(()=>t.microTask(()=>u.dispose()))}let i=(l=window.scrollY)!=null?l:window.pageYOffset,a=null;t.addEventListener(e,"click",u=>{if(u.target instanceof HTMLElement)try{let s=u.target.closest("a");if(!s)return;let{hash:h}=new URL(s.href),c=e.querySelector(h);c&&!r(c)&&(a=c)}catch{}},!0),t.addEventListener(e,"touchstart",u=>{if(u.target instanceof HTMLElement)if(r(u.target)){let s=u.target;for(;s.parentElement&&r(s.parentElement);)s=s.parentElement;t.style(s,"overscrollBehavior","contain")}else t.style(u.target,"touchAction","none")}),t.addEventListener(e,"touchmove",u=>{if(u.target instanceof HTMLElement){if(u.target.tagName==="INPUT")return;if(r(u.target)){let s=u.target;for(;s.parentElement&&s.dataset.headlessuiPortal!==""&&!(s.scrollHeight>s.clientHeight||s.scrollWidth>s.clientWidth);)s=s.parentElement;s.dataset.headlessuiPortal===""&&u.preventDefault()}else u.preventDefault()}},{passive:!1}),t.add(()=>{var u;let s=(u=window.scrollY)!=null?u:window.pageYOffset;i!==s&&window.scrollTo(0,i),a&&a.isConnected&&(a.scrollIntoView({block:"nearest"}),a=null)})})}}:{}}function Zn(){return{before({doc:e,d:t}){t.style(e.documentElement,"overflow","hidden")}}}function Jn(e){let t={};for(let n of e)Object.assign(t,n(t));return t}let ee=Mt(()=>new Map,{PUSH(e,t){var n;let r=(n=this.get(e))!=null?n:{doc:e,count:0,d:z(),meta:new Set};return r.count++,r.meta.add(t),this.set(e,r),this},POP(e,t){let n=this.get(e);return n&&(n.count--,n.meta.delete(t)),this},SCROLL_PREVENT({doc:e,d:t,meta:n}){let r={doc:e,d:t,meta:Jn(n)},l=[Kn(),Gn(),Zn()];l.forEach(({before:i})=>i==null?void 0:i(r)),l.forEach(({after:i})=>i==null?void 0:i(r))},SCROLL_ALLOW({d:e}){e.dispose()},TEARDOWN({doc:e}){this.delete(e)}});ee.subscribe(()=>{let e=ee.getSnapshot(),t=new Map;for(let[n]of e)t.set(n,n.documentElement.style.overflow);for(let n of e.values()){let r=t.get(n.doc)==="hidden",l=n.count!==0;(l&&!r||!l&&r)&&ee.dispatch(n.count>0?"SCROLL_PREVENT":"SCROLL_ALLOW",n),n.count===0&&ee.dispatch("TEARDOWN",n)}});function Qn(e,t,n=()=>({containers:[]})){let r=Ct(ee),l=t?r.get(t):void 0,i=l?l.count>0:!1;return L(()=>{if(!(!t||!e))return ee.dispatch("PUSH",t,n),()=>ee.dispatch("POP",t,n)},[e,t]),i}function Rn(e,t,n=()=>[document.body]){let r=se(e,"scroll-lock");Qn(r,t,l=>{var i;return{containers:[...(i=l.containers)!=null?i:[],n]}})}function er(e=0){let[t,n]=o.useState(e),r=o.useCallback(s=>n(s),[t]),l=o.useCallback(s=>n(h=>h|s),[t]),i=o.useCallback(s=>(t&s)===s,[t]),a=o.useCallback(s=>n(h=>h&~s),[n]),u=o.useCallback(s=>n(h=>h^s),[n]);return{flags:t,setFlag:r,addFlag:l,hasFlag:i,removeFlag:a,toggleFlag:u}}var Nt,It;typeof process<"u"&&typeof globalThis<"u"&&typeof Element<"u"&&((Nt=process==null?void 0:process.env)==null?void 0:Nt.NODE_ENV)==="test"&&typeof((It=Element==null?void 0:Element.prototype)==null?void 0:It.getAnimations)>"u"&&(Element.prototype.getAnimations=function(){return console.warn(["Headless UI has polyfilled `Element.prototype.getAnimations` for your tests.","Please install a proper polyfill e.g. `jsdom-testing-mocks`, to silence these warnings.","","Example usage:","```js","import { mockAnimationsApi } from 'jsdom-testing-mocks'","mockAnimationsApi()","```"].join(`
5
+ `)),[]});var tr=(e=>(e[e.None=0]="None",e[e.Closed=1]="Closed",e[e.Enter=2]="Enter",e[e.Leave=4]="Leave",e))(tr||{});function nr(e){let t={};for(let n in e)e[n]===!0&&(t[`data-${n}`]="");return t}function rr(e,t,n,r){let[l,i]=o.useState(n),{hasFlag:a,addFlag:u,removeFlag:s}=er(e&&l?3:0),h=o.useRef(!1),c=o.useRef(!1),g=Je();return L(()=>{var b;if(e){if(n&&i(!0),!t){n&&u(3);return}return(b=r==null?void 0:r.start)==null||b.call(r,n),lr(t,{inFlight:h,prepare(){c.current?c.current=!1:c.current=h.current,h.current=!0,!c.current&&(n?(u(3),s(4)):(u(4),s(2)))},run(){c.current?n?(s(3),u(4)):(s(4),u(3)):n?s(1):u(1)},done(){var w;c.current&&typeof t.getAnimations=="function"&&t.getAnimations().length>0||(h.current=!1,s(7),n||i(!1),(w=r==null?void 0:r.end)==null||w.call(r,n))}})}},[e,n,t,g]),e?[l,{closed:a(1),enter:a(2),leave:a(4),transition:a(2)||a(4)}]:[n,{closed:void 0,enter:void 0,leave:void 0,transition:void 0}]}function lr(e,{prepare:t,run:n,done:r,inFlight:l}){let i=z();return ir(e,{prepare:t,inFlight:l}),i.nextFrame(()=>{n(),i.requestAnimationFrame(()=>{i.add(or(e,r))})}),i.dispose}function or(e,t){var n,r;let l=z();if(!e)return l.dispose;let i=!1;l.add(()=>{i=!0});let a=(r=(n=e.getAnimations)==null?void 0:n.call(e).filter(u=>u instanceof CSSTransition))!=null?r:[];return a.length===0?(t(),l.dispose):(Promise.allSettled(a.map(u=>u.finished)).then(()=>{i||t()}),l.dispose)}function ir(e,{inFlight:t,prepare:n}){if(t!=null&&t.current){n();return}let r=e.style.transition;e.style.transition="none",n(),e.offsetHeight,e.style.transition=r}function lt(e,t){let n=o.useRef([]),r=O(e);o.useEffect(()=>{let l=[...n.current];for(let[i,a]of t.entries())if(n.current[i]!==a){let u=r(t,l);return n.current=t,u}},[r,...t])}let Ne=o.createContext(null);Ne.displayName="OpenClosedContext";var j=(e=>(e[e.Open=1]="Open",e[e.Closed=2]="Closed",e[e.Closing=4]="Closing",e[e.Opening=8]="Opening",e))(j||{});function Ie(){return o.useContext(Ne)}function sr({value:e,children:t}){return o.createElement(Ne.Provider,{value:e},t)}function ar({children:e}){return o.createElement(Ne.Provider,{value:null},e)}function ur(e){function t(){document.readyState!=="loading"&&(e(),document.removeEventListener("DOMContentLoaded",t))}typeof window<"u"&&typeof document<"u"&&(document.addEventListener("DOMContentLoaded",t),t())}let Z=[];ur(()=>{function e(t){if(!(t.target instanceof HTMLElement)||t.target===document.body||Z[0]===t.target)return;let n=t.target;n=n.closest(ke),Z.unshift(n??t.target),Z=Z.filter(r=>r!=null&&r.isConnected),Z.splice(10)}window.addEventListener("click",e,{capture:!0}),window.addEventListener("mousedown",e,{capture:!0}),window.addEventListener("focus",e,{capture:!0}),document.body.addEventListener("click",e,{capture:!0}),document.body.addEventListener("mousedown",e,{capture:!0}),document.body.addEventListener("focus",e,{capture:!0})});function At(e){let t=O(e),n=o.useRef(!1);o.useEffect(()=>(n.current=!1,()=>{n.current=!0,Te(()=>{n.current&&t()})}),[t])}function dr(){let e=typeof document>"u";return"useSyncExternalStore"in ue?(t=>t.useSyncExternalStore)(ue)(()=>()=>{},()=>!1,()=>!e):!1}function ge(){let e=dr(),[t,n]=ue.useState(J.isHandoffComplete);return t&&J.isHandoffComplete===!1&&n(!1),ue.useEffect(()=>{t!==!0&&n(!0)},[t]),ue.useEffect(()=>J.handoff(),[]),e?!1:t}let Dt=o.createContext(!1);function cr(){return o.useContext(Dt)}function jt(e){return o.createElement(Dt.Provider,{value:e.force},e.children)}function fr(e){let t=cr(),n=o.useContext(Ht),r=ve(e),[l,i]=o.useState(()=>{var a;if(!t&&n!==null)return(a=n.current)!=null?a:null;if(J.isServer)return null;let u=r==null?void 0:r.getElementById("headlessui-portal-root");if(u)return u;if(r===null)return null;let s=r.createElement("div");return s.setAttribute("id","headlessui-portal-root"),r.body.appendChild(s)});return o.useEffect(()=>{l!==null&&(r!=null&&r.body.contains(l)||r==null||r.body.appendChild(l))},[l,r]),o.useEffect(()=>{t||n!==null&&i(n.current)},[n,i,t]),l}let Ut=o.Fragment,mr=k(function(e,t){let n=e,r=o.useRef(null),l=q(Mn(g=>{r.current=g}),t),i=ve(r),a=fr(r),[u]=o.useState(()=>{var g;return J.isServer?null:(g=i==null?void 0:i.createElement("div"))!=null?g:null}),s=o.useContext(ot),h=ge();L(()=>{!a||!u||a.contains(u)||(u.setAttribute("data-headlessui-portal",""),a.appendChild(u))},[a,u]),L(()=>{if(u&&s)return s.register(u)},[s,u]),At(()=>{var g;!a||!u||(u instanceof Node&&a.contains(u)&&a.removeChild(u),a.childNodes.length<=0&&((g=a.parentElement)==null||g.removeChild(a)))});let c=D();return h?!a||!u?null:nn.createPortal(c({ourProps:{ref:l},theirProps:n,slot:{},defaultTag:Ut,name:"Portal"}),u):null});function pr(e,t){let n=q(t),{enabled:r=!0,...l}=e,i=D();return r?o.createElement(mr,{...l,ref:n}):i({ourProps:{ref:n},theirProps:l,slot:{},defaultTag:Ut,name:"Portal"})}let hr=o.Fragment,Ht=o.createContext(null);function vr(e,t){let{target:n,...r}=e,l={ref:q(t)},i=D();return o.createElement(Ht.Provider,{value:n},i({ourProps:l,theirProps:r,defaultTag:hr,name:"Popover.Group"}))}let ot=o.createContext(null);function gr(){let e=o.useContext(ot),t=o.useRef([]),n=O(i=>(t.current.push(i),e&&e.register(i),()=>r(i))),r=O(i=>{let a=t.current.indexOf(i);a!==-1&&t.current.splice(a,1),e&&e.unregister(i)}),l=o.useMemo(()=>({register:n,unregister:r,portals:t}),[n,r,t]);return[t,o.useMemo(()=>function({children:i}){return o.createElement(ot.Provider,{value:l},i)},[l])]}let wr=k(pr),Wt=k(vr),Er=Object.assign(wr,{Group:Wt});function xr(e,t=typeof document<"u"?document.defaultView:null,n){let r=se(e,"escape");kt(t,"keydown",l=>{r&&(l.defaultPrevented||l.key===$t.Escape&&n(l))})}function br(){var e;let[t]=o.useState(()=>typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia("(pointer: coarse)"):null),[n,r]=o.useState((e=t==null?void 0:t.matches)!=null?e:!1);return L(()=>{if(!t)return;function l(i){r(i.matches)}return t.addEventListener("change",l),()=>t.removeEventListener("change",l)},[t]),n}function yr({defaultContainers:e=[],portals:t,mainTreeNode:n}={}){let r=ve(n),l=O(()=>{var i,a;let u=[];for(let s of e)s!==null&&(s instanceof HTMLElement?u.push(s):"current"in s&&s.current instanceof HTMLElement&&u.push(s.current));if(t!=null&&t.current)for(let s of t.current)u.push(s);for(let s of(i=r==null?void 0:r.querySelectorAll("html > *, body > *"))!=null?i:[])s!==document.body&&s!==document.head&&s instanceof HTMLElement&&s.id!=="headlessui-portal-root"&&(n&&(s.contains(n)||s.contains((a=n==null?void 0:n.getRootNode())==null?void 0:a.host))||u.some(h=>s.contains(h))||u.push(s));return u});return{resolveContainers:l,contains:O(i=>l().some(a=>a.contains(i)))}}let _t=o.createContext(null);function Bt({children:e,node:t}){let[n,r]=o.useState(null),l=qt(t??n);return o.createElement(_t.Provider,{value:l},e,l===null&&o.createElement(et,{features:Le.Hidden,ref:i=>{var a,u;if(i){for(let s of(u=(a=Oe(i))==null?void 0:a.querySelectorAll("html > *, body > *"))!=null?u:[])if(s!==document.body&&s!==document.head&&s instanceof HTMLElement&&s!=null&&s.contains(i)){r(s);break}}}}))}function qt(e=null){var t;return(t=o.useContext(_t))!=null?t:e}function it(){let e=o.useRef(!1);return L(()=>(e.current=!0,()=>{e.current=!1}),[]),e}var we=(e=>(e[e.Forwards=0]="Forwards",e[e.Backwards=1]="Backwards",e))(we||{});function $r(){let e=o.useRef(0);return Ft(!0,"keydown",t=>{t.key==="Tab"&&(e.current=t.shiftKey?1:0)},!0),e}function Xt(e){if(!e)return new Set;if(typeof e=="function")return new Set(e());let t=new Set;for(let n of e.current)n.current instanceof HTMLElement&&t.add(n.current);return t}let Mr="div";var te=(e=>(e[e.None=0]="None",e[e.InitialFocus=1]="InitialFocus",e[e.TabLock=2]="TabLock",e[e.FocusLock=4]="FocusLock",e[e.RestoreFocus=8]="RestoreFocus",e[e.AutoFocus=16]="AutoFocus",e))(te||{});function Cr(e,t){let n=o.useRef(null),r=q(n,t),{initialFocus:l,initialFocusFallback:i,containers:a,features:u=15,...s}=e;ge()||(u=0);let h=ve(n);Pr(u,{ownerDocument:h});let c=Fr(u,{ownerDocument:h,container:n,initialFocus:l,initialFocusFallback:i});Lr(u,{ownerDocument:h,container:n,containers:a,previousActiveElement:c});let g=$r(),b=O(p=>{let E=n.current;E&&(y=>y())(()=>{G(g.current,{[we.Forwards]:()=>{pe(E,V.First,{skipElements:[p.relatedTarget,i]})},[we.Backwards]:()=>{pe(E,V.Last,{skipElements:[p.relatedTarget,i]})}})})}),w=se(!!(u&2),"focus-trap#tab-lock"),f=Je(),x=o.useRef(!1),d={ref:r,onKeyDown(p){p.key=="Tab"&&(x.current=!0,f.requestAnimationFrame(()=>{x.current=!1}))},onBlur(p){if(!(u&4))return;let E=Xt(a);n.current instanceof HTMLElement&&E.add(n.current);let y=p.relatedTarget;y instanceof HTMLElement&&y.dataset.headlessuiFocusGuard!=="true"&&(Vt(E,y)||(x.current?pe(n.current,G(g.current,{[we.Forwards]:()=>V.Next,[we.Backwards]:()=>V.Previous})|V.WrapAround,{relativeTo:p.target}):p.target instanceof HTMLElement&&Y(p.target)))}},m=D();return o.createElement(o.Fragment,null,w&&o.createElement(et,{as:"button",type:"button","data-headlessui-focus-guard":!0,onFocus:b,features:Le.Focusable}),m({ourProps:d,theirProps:s,defaultTag:Mr,name:"FocusTrap"}),w&&o.createElement(et,{as:"button",type:"button","data-headlessui-focus-guard":!0,onFocus:b,features:Le.Focusable}))}let Sr=k(Cr),Or=Object.assign(Sr,{features:te});function Tr(e=!0){let t=o.useRef(Z.slice());return lt(([n],[r])=>{r===!0&&n===!1&&Te(()=>{t.current.splice(0)}),r===!1&&n===!0&&(t.current=Z.slice())},[e,Z,t]),O(()=>{var n;return(n=t.current.find(r=>r!=null&&r.isConnected))!=null?n:null})}function Pr(e,{ownerDocument:t}){let n=!!(e&8),r=Tr(n);lt(()=>{n||(t==null?void 0:t.activeElement)===(t==null?void 0:t.body)&&Y(r())},[n]),At(()=>{n&&Y(r())})}function Fr(e,{ownerDocument:t,container:n,initialFocus:r,initialFocusFallback:l}){let i=o.useRef(null),a=se(!!(e&1),"focus-trap#initial-focus"),u=it();return lt(()=>{if(e===0)return;if(!a){l!=null&&l.current&&Y(l.current);return}let s=n.current;s&&Te(()=>{if(!u.current)return;let h=t==null?void 0:t.activeElement;if(r!=null&&r.current){if((r==null?void 0:r.current)===h){i.current=h;return}}else if(s.contains(h)){i.current=h;return}if(r!=null&&r.current)Y(r.current);else{if(e&16){if(pe(s,V.First|V.AutoFocus)!==rt.Error)return}else if(pe(s,V.First)!==rt.Error)return;if(l!=null&&l.current&&(Y(l.current),(t==null?void 0:t.activeElement)===l.current))return;console.warn("There are no focusable elements inside the <FocusTrap />")}i.current=t==null?void 0:t.activeElement})},[l,a,e]),i}function Lr(e,{ownerDocument:t,container:n,containers:r,previousActiveElement:l}){let i=it(),a=!!(e&4);kt(t==null?void 0:t.defaultView,"focus",u=>{if(!a||!i.current)return;let s=Xt(r);n.current instanceof HTMLElement&&s.add(n.current);let h=l.current;if(!h)return;let c=u.target;c&&c instanceof HTMLElement?Vt(s,c)?(l.current=c,Y(c)):(u.preventDefault(),u.stopPropagation(),Y(h)):Y(l.current)},!0)}function Vt(e,t){for(let n of e)if(n.contains(t))return!0;return!1}function Yt(e){var t;return!!(e.enter||e.enterFrom||e.enterTo||e.leave||e.leaveFrom||e.leaveTo)||((t=e.as)!=null?t:Gt)!==o.Fragment||o.Children.count(e.children)===1}let Ae=o.createContext(null);Ae.displayName="TransitionContext";var kr=(e=>(e.Visible="visible",e.Hidden="hidden",e))(kr||{});function Nr(){let e=o.useContext(Ae);if(e===null)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition /> or <Transition.Root />.");return e}function Ir(){let e=o.useContext(De);if(e===null)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition /> or <Transition.Root />.");return e}let De=o.createContext(null);De.displayName="NestingContext";function je(e){return"children"in e?je(e.children):e.current.filter(({el:t})=>t.current!==null).filter(({state:t})=>t==="visible").length>0}function zt(e,t){let n=Q(e),r=o.useRef([]),l=it(),i=Je(),a=O((w,f=K.Hidden)=>{let x=r.current.findIndex(({el:d})=>d===w);x!==-1&&(G(f,{[K.Unmount](){r.current.splice(x,1)},[K.Hidden](){r.current[x].state="hidden"}}),i.microTask(()=>{var d;!je(r)&&l.current&&((d=n.current)==null||d.call(n))}))}),u=O(w=>{let f=r.current.find(({el:x})=>x===w);return f?f.state!=="visible"&&(f.state="visible"):r.current.push({el:w,state:"visible"}),()=>a(w,K.Unmount)}),s=o.useRef([]),h=o.useRef(Promise.resolve()),c=o.useRef({enter:[],leave:[]}),g=O((w,f,x)=>{s.current.splice(0),t&&(t.chains.current[f]=t.chains.current[f].filter(([d])=>d!==w)),t==null||t.chains.current[f].push([w,new Promise(d=>{s.current.push(d)})]),t==null||t.chains.current[f].push([w,new Promise(d=>{Promise.all(c.current[f].map(([m,p])=>p)).then(()=>d())})]),f==="enter"?h.current=h.current.then(()=>t==null?void 0:t.wait.current).then(()=>x(f)):x(f)}),b=O((w,f,x)=>{Promise.all(c.current[f].splice(0).map(([d,m])=>m)).then(()=>{var d;(d=s.current.shift())==null||d()}).then(()=>x(f))});return o.useMemo(()=>({children:r,register:u,unregister:a,onStart:g,onStop:b,wait:h,chains:c}),[u,a,r,g,b,c,h])}let Gt=o.Fragment,Kt=Pe.RenderStrategy;function Ar(e,t){var n,r;let{transition:l=!0,beforeEnter:i,afterEnter:a,beforeLeave:u,afterLeave:s,enter:h,enterFrom:c,enterTo:g,entered:b,leave:w,leaveFrom:f,leaveTo:x,...d}=e,[m,p]=o.useState(null),E=o.useRef(null),y=Yt(e),v=q(...y?[E,t,p]:t===null?[]:[t]),M=(n=d.unmount)==null||n?K.Unmount:K.Hidden,{show:T,appear:I,initial:U}=Nr(),[F,A]=o.useState(T?"visible":"hidden"),H=Ir(),{register:W,unregister:S}=H;L(()=>W(E),[W,E]),L(()=>{if(M===K.Hidden&&E.current){if(T&&F!=="visible"){A("visible");return}return G(F,{hidden:()=>S(E),visible:()=>W(E)})}},[F,E,W,S,T,M]);let _=ge();L(()=>{if(y&&_&&F==="visible"&&E.current===null)throw new Error("Did you forget to passthrough the `ref` to the actual DOM node?")},[E,F,_,y]);let He=U&&!I,We=I&&T&&U,Ee=o.useRef(!1),X=zt(()=>{Ee.current||(A("hidden"),S(E))},H),_e=O(dt=>{Ee.current=!0;let qe=dt?"enter":"leave";X.onStart(E,qe,be=>{be==="enter"?i==null||i():be==="leave"&&(u==null||u())})}),P=O(dt=>{let qe=dt?"enter":"leave";Ee.current=!1,X.onStop(E,qe,be=>{be==="enter"?a==null||a():be==="leave"&&(s==null||s())}),qe==="leave"&&!je(X)&&(A("hidden"),S(E))});o.useEffect(()=>{y&&l||(_e(T),P(T))},[T,y,l]);let Be=!(!l||!y||!_||He),[,N]=rr(Be,m,T,{start:_e,end:P}),ol=R({ref:v,className:((r=Qe(d.className,We&&h,We&&c,N.enter&&h,N.enter&&N.closed&&c,N.enter&&!N.closed&&g,N.leave&&w,N.leave&&!N.closed&&f,N.leave&&N.closed&&x,!N.transition&&T&&b))==null?void 0:r.trim())||void 0,...nr(N)}),xe=0;F==="visible"&&(xe|=j.Open),F==="hidden"&&(xe|=j.Closed),N.enter&&(xe|=j.Opening),N.leave&&(xe|=j.Closing);let il=D();return o.createElement(De.Provider,{value:X},o.createElement(sr,{value:xe},il({ourProps:ol,theirProps:d,defaultTag:Gt,features:Kt,visible:F==="visible",name:"Transition.Child"})))}function Dr(e,t){let{show:n,appear:r=!1,unmount:l=!0,...i}=e,a=o.useRef(null),u=Yt(e),s=q(...u?[a,t]:t===null?[]:[t]);ge();let h=Ie();if(n===void 0&&h!==null&&(n=(h&j.Open)===j.Open),n===void 0)throw new Error("A <Transition /> is used but it is missing a `show={true | false}` prop.");let[c,g]=o.useState(n?"visible":"hidden"),b=zt(()=>{n||g("hidden")}),[w,f]=o.useState(!0),x=o.useRef([n]);L(()=>{w!==!1&&x.current[x.current.length-1]!==n&&(x.current.push(n),f(!1))},[x,n]);let d=o.useMemo(()=>({show:n,appear:r,initial:w}),[n,r,w]);L(()=>{n?g("visible"):!je(b)&&a.current!==null&&g("hidden")},[n,b]);let m={unmount:l},p=O(()=>{var v;w&&f(!1),(v=e.beforeEnter)==null||v.call(e)}),E=O(()=>{var v;w&&f(!1),(v=e.beforeLeave)==null||v.call(e)}),y=D();return o.createElement(De.Provider,{value:b},o.createElement(Ae.Provider,{value:d},y({ourProps:{...m,as:o.Fragment,children:o.createElement(Zt,{ref:s,...m,...i,beforeEnter:p,beforeLeave:E})},theirProps:{},defaultTag:o.Fragment,features:Kt,visible:c==="visible",name:"Transition"})))}function jr(e,t){let n=o.useContext(Ae)!==null,r=Ie()!==null;return o.createElement(o.Fragment,null,!n&&r?o.createElement(st,{ref:t,...e}):o.createElement(Zt,{ref:t,...e}))}let st=k(Dr),Zt=k(Ar),ae=k(jr),Jt=Object.assign(st,{Child:ae,Root:st});var Ur=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(Ur||{}),Hr=(e=>(e[e.SetTitleId=0]="SetTitleId",e))(Hr||{});let Wr={0(e,t){return e.titleId===t.id?e:{...e,titleId:t.id}}},at=o.createContext(null);at.displayName="DialogContext";function Ue(e){let t=o.useContext(at);if(t===null){let n=new Error(`<${e} /> is missing a parent <Dialog /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(n,Ue),n}return t}function _r(e,t){return G(t.type,Wr,e,t)}let Qt=k(function(e,t){let n=o.useId(),{id:r=`headlessui-dialog-${n}`,open:l,onClose:i,initialFocus:a,role:u="dialog",autoFocus:s=!0,__demoMode:h=!1,unmount:c=!1,...g}=e,b=o.useRef(!1);u=function(){return u==="dialog"||u==="alertdialog"?u:(b.current||(b.current=!0,console.warn(`Invalid role [${u}] passed to <Dialog />. Only \`dialog\` and and \`alertdialog\` are supported. Using \`dialog\` instead.`)),"dialog")}();let w=Ie();l===void 0&&w!==null&&(l=(w&j.Open)===j.Open);let f=o.useRef(null),x=q(f,t),d=ve(f),m=l?0:1,[p,E]=o.useReducer(_r,{titleId:null,descriptionId:null,panelRef:o.createRef()}),y=O(()=>i(!1)),v=O(P=>E({type:0,id:P})),M=ge()?m===0:!1,[T,I]=gr(),U={get current(){var P;return(P=p.panelRef.current)!=null?P:f.current}},F=qt(),{resolveContainers:A}=yr({mainTreeNode:F,portals:T,defaultContainers:[U]}),H=w!==null?(w&j.Closing)===j.Closing:!1;In(h||H?!1:M,{allowed:O(()=>{var P,Be;return[(Be=(P=f.current)==null?void 0:P.closest("[data-headlessui-portal]"))!=null?Be:null]}),disallowed:O(()=>{var P;return[(P=F==null?void 0:F.closest("body > *:not(#headlessui-portal-root)"))!=null?P:null]})}),zn(M,A,P=>{P.preventDefault(),y()}),xr(M,d==null?void 0:d.defaultView,P=>{P.preventDefault(),P.stopPropagation(),document.activeElement&&"blur"in document.activeElement&&typeof document.activeElement.blur=="function"&&document.activeElement.blur(),y()}),Rn(h||H?!1:M,d,A),An(M,f,y);let[W,S]=Cn(),_=o.useMemo(()=>[{dialogState:m,close:y,setTitleId:v,unmount:c},p],[m,p,y,v,c]),He=o.useMemo(()=>({open:m===0}),[m]),We={ref:x,id:r,role:u,tabIndex:-1,"aria-modal":h?void 0:m===0?!0:void 0,"aria-labelledby":p.titleId,"aria-describedby":W,unmount:c},Ee=!br(),X=te.None;M&&!h&&(X|=te.RestoreFocus,X|=te.TabLock,s&&(X|=te.AutoFocus),Ee&&(X|=te.InitialFocus));let _e=D();return o.createElement(ar,null,o.createElement(jt,{force:!0},o.createElement(Er,null,o.createElement(at.Provider,{value:_},o.createElement(Wt,{target:f},o.createElement(jt,{force:!1},o.createElement(S,{slot:He},o.createElement(I,null,o.createElement(Or,{initialFocus:a,initialFocusFallback:f,containers:A,features:X},o.createElement(Ln,{value:y},_e({ourProps:We,theirProps:g,slot:He,defaultTag:Br,features:qr,visible:m===0,name:"Dialog"})))))))))))}),Br="div",qr=Pe.RenderStrategy|Pe.Static;function Xr(e,t){let{transition:n=!1,open:r,...l}=e,i=Ie(),a=e.hasOwnProperty("open")||i!==null,u=e.hasOwnProperty("onClose");if(!a&&!u)throw new Error("You have to provide an `open` and an `onClose` prop to the `Dialog` component.");if(!a)throw new Error("You provided an `onClose` prop to the `Dialog`, but forgot an `open` prop.");if(!u)throw new Error("You provided an `open` prop to the `Dialog`, but forgot an `onClose` prop.");if(!i&&typeof e.open!="boolean")throw new Error(`You provided an \`open\` prop to the \`Dialog\`, but the value is not a boolean. Received: ${e.open}`);if(typeof e.onClose!="function")throw new Error(`You provided an \`onClose\` prop to the \`Dialog\`, but the value is not a function. Received: ${e.onClose}`);return(r!==void 0||n)&&!l.static?o.createElement(Bt,null,o.createElement(Jt,{show:r,transition:n,unmount:l.unmount},o.createElement(Qt,{ref:t,...l}))):o.createElement(Bt,null,o.createElement(Qt,{ref:t,open:r,...l}))}let Vr="div";function Yr(e,t){let n=o.useId(),{id:r=`headlessui-dialog-panel-${n}`,transition:l=!1,...i}=e,[{dialogState:a,unmount:u},s]=Ue("Dialog.Panel"),h=q(t,s.panelRef),c=o.useMemo(()=>({open:a===0}),[a]),g=O(d=>{d.stopPropagation()}),b={ref:h,id:r,onClick:g},w=l?ae:o.Fragment,f=l?{unmount:u}:{},x=D();return o.createElement(w,{...f},x({ourProps:b,theirProps:i,slot:c,defaultTag:Vr,name:"Dialog.Panel"}))}let zr="div";function Gr(e,t){let{transition:n=!1,...r}=e,[{dialogState:l,unmount:i}]=Ue("Dialog.Backdrop"),a=o.useMemo(()=>({open:l===0}),[l]),u={ref:t,"aria-hidden":!0},s=n?ae:o.Fragment,h=n?{unmount:i}:{},c=D();return o.createElement(s,{...h},c({ourProps:u,theirProps:r,slot:a,defaultTag:zr,name:"Dialog.Backdrop"}))}let Kr="h2";function Zr(e,t){let n=o.useId(),{id:r=`headlessui-dialog-title-${n}`,...l}=e,[{dialogState:i,setTitleId:a}]=Ue("Dialog.Title"),u=q(t);o.useEffect(()=>(a(r),()=>a(null)),[r,a]);let s=o.useMemo(()=>({open:i===0}),[i]),h={ref:u,id:r};return D()({ourProps:h,theirProps:l,slot:s,defaultTag:Kr,name:"Dialog.Title"})}let Jr=k(Xr),ut=k(Yr);k(Gr);let Qr=k(Zr),Rr=Object.assign(Jr,{Panel:ut,Title:Qr,Description:Pn});function Rt({onClick:e}){return $.jsxs("button",{type:"button",className:"im-close-button text-gray-400 hover:text-gray-500",onClick:e,children:[$.jsx("span",{className:"sr-only",children:"Close"}),$.jsx("svg",{className:"size-6",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"2",stroke:"currentColor","aria-hidden":"true",children:$.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})]})}const el=({modalContext:e,config:t,children:n})=>{const[r,l]=o.useState(!1);return $.jsx("div",{className:"im-modal-container fixed inset-0 z-40 overflow-y-auto p-4",children:$.jsx("div",{className:Se("im-modal-positioner flex min-h-full justify-center",{"items-start":t.position==="top","items-center":t.position==="center","items-end":t.position==="bottom"}),children:$.jsx(ae,{as:"div",enterFrom:"opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",enterTo:"opacity-100 translate-y-0 sm:scale-100",leaveFrom:"opacity-100 translate-y-0 sm:scale-100",leaveTo:"opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",afterEnter:()=>l(!0),afterLeave:e.afterLeave,className:Se("im-modal-wrapper w-full transition duration-300 ease-in-out",e.onTopOfStack?"":"blur-sm",{"sm:max-w-sm":t.maxWidth==="sm","sm:max-w-md":t.maxWidth==="md","sm:max-w-md md:max-w-lg":t.maxWidth==="lg","sm:max-w-md md:max-w-xl":t.maxWidth==="xl","sm:max-w-md md:max-w-xl lg:max-w-2xl":t.maxWidth==="2xl","sm:max-w-md md:max-w-xl lg:max-w-3xl":t.maxWidth==="3xl","sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-4xl":t.maxWidth==="4xl","sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl":t.maxWidth==="5xl","sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl 2xl:max-w-6xl":t.maxWidth==="6xl","sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl 2xl:max-w-7xl":t.maxWidth==="7xl"}),children:$.jsxs(ut,{className:`im-modal-content relative ${t.paddingClasses} ${t.panelClasses}`,"data-inertiaui-modal-entered":r,children:[t.closeButton&&$.jsx("div",{className:"absolute right-0 top-0 pr-3 pt-3",children:$.jsx(Rt,{onClick:e.close})}),typeof n=="function"?n({modalContext:e,config:t}):n]})})})})},tl=({modalContext:e,config:t,children:n})=>{const[r,l]=o.useState(!1);return $.jsx("div",{className:"im-slideover-container fixed inset-0 z-40 overflow-y-auto overflow-x-hidden",children:$.jsx("div",{className:Se("im-slideover-positioner flex min-h-full items-center",{"justify-start rtl:justify-end":(t==null?void 0:t.position)==="left","justify-end rtl:justify-start":(t==null?void 0:t.position)==="right"}),children:$.jsx(ae,{as:"div",enterFrom:`opacity-0 ${t.position==="left"?"-translate-x-full":"translate-x-full"}`,enterTo:"opacity-100 translate-x-0",leaveFrom:"opacity-100 translate-x-0",leaveTo:`opacity-0 ${t.position==="left"?"-translate-x-full":"translate-x-full"}`,afterEnter:()=>l(!0),afterLeave:e.afterLeave,className:Se("im-slideover-wrapper w-full transition duration-300 ease-in-out",e.onTopOfStack?"":"blur-sm",{"sm:max-w-sm":t.maxWidth==="sm","sm:max-w-md":t.maxWidth==="md","sm:max-w-md md:max-w-lg":t.maxWidth==="lg","sm:max-w-md md:max-w-xl":t.maxWidth==="xl","sm:max-w-md md:max-w-xl lg:max-w-2xl":t.maxWidth==="2xl","sm:max-w-md md:max-w-xl lg:max-w-3xl":t.maxWidth==="3xl","sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-4xl":t.maxWidth==="4xl","sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl":t.maxWidth==="5xl","sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl 2xl:max-w-6xl":t.maxWidth==="6xl","sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl 2xl:max-w-7xl":t.maxWidth==="7xl"}),children:$.jsxs(ut,{className:`im-slideover-content relative ${t.paddingClasses} ${t.panelClasses}`,"data-inertiaui-modal-entered":r,children:[t.closeButton&&$.jsx("div",{className:"absolute right-0 top-0 pr-3 pt-3",children:$.jsx(Rt,{onClick:e.close})}),typeof n=="function"?n({modalContext:e,config:t}):n]})})})})},en=o.forwardRef(({name:e,children:t,onFocus:n=null,onBlur:r=null,onClose:l=null,onSuccess:i=null,onAfterLeave:a=null,...u},s)=>{const h=g=>typeof t=="function"?t(g):t,c=o.useRef(null);return o.useImperativeHandle(s,()=>c.current,[c]),$.jsx(Ke,{ref:c,name:e,onFocus:n,onBlur:r,onClose:l,onSuccess:i,...u,children:({afterLeave:g,close:b,config:w,emit:f,getChildModal:x,getParentModal:d,id:m,index:p,isOpen:E,modalContext:y,onTopOfStack:v,reload:M,setOpen:T,shouldRender:I})=>$.jsx(Jt,{appear:!0,show:E??!1,afterLeave:a,children:$.jsxs(Rr,{as:"div",className:"im-dialog relative z-20",onClose:()=>w.closeExplicitly?null:b(),"data-inertiaui-modal-id":m,"data-inertiaui-modal-index":p,children:[p===0?$.jsx(ae,{enter:"transition transform ease-in-out duration-300",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"transition transform ease-in-out duration-300",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:v?$.jsx("div",{className:"im-backdrop fixed inset-0 z-30 bg-black/75","aria-hidden":"true"}):$.jsx("div",{})}):null,p>0&&v?$.jsx("div",{className:"im-backdrop fixed inset-0 z-30 bg-black/75"}):null,w.slideover?$.jsx(tl,{modalContext:y,config:w,children:h({afterLeave:g,close:b,config:w,emit:f,getChildModal:x,getParentModal:d,id:m,index:p,isOpen:E,modalContext:y,onTopOfStack:v,reload:M,setOpen:T,shouldRender:I})}):$.jsx(el,{modalContext:y,config:w,children:h({afterLeave:g,close:b,config:w,emit:f,getChildModal:x,getParentModal:d,id:m,index:p,isOpen:E,modalContext:y,onTopOfStack:v,reload:M,setOpen:T,shouldRender:I})})]})})})});en.displayName="Modal";const nl=({href:e,method:t="get",data:n={},as:r="a",headers:l={},queryStringArrayFormat:i="brackets",onAfterLeave:a=null,onBlur:u=null,onClose:s=null,onError:h=null,onFocus:c=null,onStart:g=null,onSuccess:b=null,navigate:w=null,children:f,...x})=>{const[d,m]=o.useState(!1),[p,E]=o.useState(null),{stack:y,visit:v}=fe(),M=o.useMemo(()=>w??Me("navigate"),[w]),T={},I={};Object.keys(x).forEach(S=>{ht.includes(S)||(S.startsWith("on")&&typeof x[S]=="function"?S.toLowerCase()in window?T[S]=x[S]:I[S]=x[S]:T[S]=x[S])});const[U,F]=o.useState(!1);o.useEffect(()=>{p&&(p.onTopOfStack&&U?c==null||c():!p.onTopOfStack&&!U&&(u==null||u()),F(!p.onTopOfStack))},[y]);const A=o.useCallback(()=>{s==null||s()},[s]),H=o.useCallback(()=>{E(null),a==null||a()},[a]),W=o.useCallback(S=>{S==null||S.preventDefault(),!d&&(e.startsWith("#")||(m(!0),g==null||g()),v(e,t,n,l,dn(ct(x,ht)),()=>A(y.length),H,i,M).then(_=>{E(_),_.registerEventListenersFromProps(I),b==null||b()}).catch(_=>{console.error(_),h==null||h(_)}).finally(()=>m(!1)))},[e,t,n,l,i,x,A,H]);return $.jsx(r,{...T,href:e,onClick:W,children:typeof f=="function"?f({loading:d}):f})};function rl(){return fe().stack[Ge()]??null}const ll=e=>t=>(t.default.layout=n=>o.createElement(e,{},n),t);C.HeadlessModal=Ke,C.Modal=en,C.ModalLink=nl,C.ModalRoot=gt,C.ModalStackProvider=pt,C.getConfig=Me,C.initFromPageProps=vt,C.putConfig=sn,C.renderApp=fn,C.resetConfig=on,C.setPageLayout=ll,C.useModal=rl,C.useModalIndex=Ge,C.useModalStack=fe,Object.defineProperty(C,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@inertiaui/modal-react",
3
3
  "author": "Pascal Baljet <pascal@protone.media>",
4
- "version": "0.20.4",
4
+ "version": "0.20.5",
5
5
  "private": false,
6
6
  "license": "MIT",
7
7
  "type": "module",
@@ -51,4 +51,4 @@
51
51
  "react": "^18.2.0||^19.0.0",
52
52
  "react-dom": "^18.2.0||^19.0.0"
53
53
  }
54
- }
54
+ }
package/src/ModalRoot.jsx CHANGED
@@ -479,9 +479,11 @@ export const renderApp = (App, pageProps) => {
479
479
 
480
480
  export const ModalRoot = ({ children }) => {
481
481
  const context = useContext(ModalStackContext)
482
+ const $page = usePage()
482
483
 
483
484
  let isNavigating = false
484
485
  let previousModalOnBase = false
486
+ let initialModalStillOpened = $page.props?._inertiaui_modal ? true : false
485
487
 
486
488
  useEffect(() => router.on('start', () => (isNavigating = true)), [])
487
489
  useEffect(() => router.on('finish', () => (isNavigating = false)), [])
@@ -493,6 +495,7 @@ export const ModalRoot = ({ children }) => {
493
495
  if (!modalOnBase) {
494
496
  previousModalOnBase && context.closeAll()
495
497
  baseUrl = null
498
+ initialModalStillOpened = false
496
499
  return
497
500
  }
498
501
 
@@ -522,7 +525,7 @@ export const ModalRoot = ({ children }) => {
522
525
  const axiosRequestInterceptor = (config) => {
523
526
  // A Modal is opened on top of a base route, so we need to pass this base route
524
527
  // so it can redirect back with the back() helper method...
525
- config.headers['X-InertiaUI-Modal-Base-Url'] = baseUrl
528
+ config.headers['X-InertiaUI-Modal-Base-Url'] = baseUrl ?? (initialModalStillOpened ? $page.props._inertiaui_modal?.baseUrl : null)
526
529
 
527
530
  return config
528
531
  }
@@ -532,7 +535,6 @@ export const ModalRoot = ({ children }) => {
532
535
  return () => Axios.interceptors.request.eject(axiosRequestInterceptor)
533
536
  }, [])
534
537
 
535
- const $page = usePage()
536
538
  const previousModalRef = useRef()
537
539
 
538
540
  useEffect(() => {