@inertiaui/modal-react 0.21.0 → 1.0.0-beta-2
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.
- package/dist/inertiaui-modal.js +1464 -1228
- package/dist/inertiaui-modal.umd.cjs +20 -4
- package/package.json +1 -1
- package/src/ModalRoot.jsx +47 -16
- package/src/helpers.js +2 -2
|
@@ -1,5 +1,21 @@
|
|
|
1
|
-
(function(S,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):(S=typeof globalThis<"u"?globalThis:S||self,o(S.InertiaUIModal={},S.React,S.jsxRuntime,S.Axios,S.react,S.core,S.ReactDOM))})(this,function(S,o,M,xe,ne,rn,ln){"use strict";var al=Object.defineProperty;var dl=(S,o,M)=>o in S?al(S,o,{enumerable:!0,configurable:!0,writable:!0,value:M}):S[o]=M;var _=(S,o,M)=>dl(S,typeof o!="symbol"?o+"":o,M);function on(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 ae=on(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 sn{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 sn,un=()=>$e.reset(),an=(e,t)=>$e.put(e,t),Me=e=>$e.get(e),re=(e,t)=>$e.get(e?`slideover.${t}`:`modal.${t}`);function dn(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 Ve(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 cn(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 fn(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 mn(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 pn(e,t=3,n=10){return new Promise((r,l)=>{const i=e();if(i){r(i);return}let u=t*1e3/n;const a=setInterval(()=>{const s=e();s&&(clearInterval(a),r(s)),--u<=0&&(clearInterval(a),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 Se=o.createContext(null);Se.displayName="ModalStackContext";let ft=null,mt=null,oe=null,Xe=null,Ye=[],ie={};const pt=({children:e})=>{const[t,n]=o.useState([]),[r,l]=o.useState({}),i=v=>{n(c=>{const d=v([...c]),g=y=>{var h;return d.length<2?!0:((h=d.map($=>({id:$.id,shouldRender:$.shouldRender})).reverse().find($=>$.shouldRender))==null?void 0:h.id)===y};return d.forEach((y,h)=>{d[h].onTopOfStack=g(y.id),d[h].getParentModal=()=>h<1?null:d.slice(0,h).reverse().find($=>$.isOpen),d[h].getChildModal=()=>h===d.length-1?null:d.slice(h+1).find($=>$.isOpen)}),d})};o.useEffect(()=>{Ye=t},[t]);class u{constructor(c,d,g,y,h){_(this,"show",()=>{i(c=>c.map(d=>(d.id===this.id&&!d.isOpen&&(d.isOpen=!0,d.shouldRender=!0),d)))});_(this,"setOpen",c=>{c?this.show():this.close()});_(this,"close",()=>{i(c=>c.map(d=>{var g;return d.id===this.id&&d.isOpen&&(Object.keys(d.listeners).forEach(y=>{d.off(y)}),d.isOpen=!1,(g=d.onCloseCallback)==null||g.call(d)),d}))});_(this,"afterLeave",()=>{this.isOpen||i(c=>{const d=c.map(g=>{var y;return g.id===this.id&&!g.isOpen&&(g.shouldRender=!1,(y=g.afterLeaveCallback)==null||y.call(g),g.afterLeaveCallback=null),g});return this.index===0?[]:d})});_(this,"on",(c,d)=>{c=ce(c),this.listeners[c]=this.listeners[c]??[],this.listeners[c].push(d)});_(this,"off",(c,d)=>{var g;c=ce(c),d?this.listeners[c]=((g=this.listeners[c])==null?void 0:g.filter(y=>y!==d))??[]:delete this.listeners[c]});_(this,"emit",(c,...d)=>{var g;(g=this.listeners[ce(c)])==null||g.forEach(y=>y(...d))});_(this,"registerEventListenersFromProps",c=>{const d=[];return Object.keys(c).filter(g=>g.startsWith("on")).forEach(g=>{const y=ce(g).replace(/^on-/,"");this.on(y,c[g]),d.push(()=>this.off(y,c[g]))}),()=>d.forEach(g=>g())});_(this,"reload",(c={})=>{var h,$;let d=Object.keys(this.response.props);if(c.only&&(d=c.only),c.except&&(d=cn(d,c.except)),!((h=this.response)!=null&&h.url))return;const g=(c.method??"get").toLowerCase(),y=c.data??{};($=c.onStart)==null||$.call(c),xe({url:this.response.url,method:g,data:g==="get"?{}:y,params:g==="get"?y:{},headers:{...c.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":d.join(","),"X-InertiaUI-Modal":Ve(),"X-InertiaUI-Modal-Use-Router":0,"X-InertiaUI-Modal-Base-Url":oe}}).then(C=>{var T;this.updateProps(C.data.props),(T=c.onSuccess)==null||T.call(c,C)}).catch(C=>{var T;(T=c.onError)==null||T.call(c,C)}).finally(()=>{var C;(C=c.onFinish)==null||C.call(c)})});_(this,"updateProps",c=>{Object.assign(this.props,c),i(d=>d)});if(this.id=d.id??Ve(),this.isOpen=!1,this.shouldRender=!1,this.listeners={},this.component=c,this.props=d.props,this.response=d,this.config=g??{},this.onCloseCallback=y,this.afterLeaveCallback=h,ie[this.id]){this.config={...this.config,...ie[this.id].config??{}};const $=ie[this.id].onClose,C=ie[this.id].onAfterLeave;$&&(this.onCloseCallback=y?()=>{y(),$()}:$),C&&(this.afterLeaveCallback=h?()=>{h(),C()}:C),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 a=(v,c={},d=null,g=null)=>mt(v.component).then(y=>p(y,v,c,d,g)),s=v=>{var d,g;const c=(g=(d=v.response)==null?void 0:d.meta)==null?void 0:g.deferredProps;c&&Object.keys(c).forEach(y=>{v.reload({only:c[y]})})},p=(v,c,d,g,y)=>{const h=new u(v,c,d,g,y);return h.index=t.length,i($=>[...$,h]),s(h),h.show(),h};function f(v,c,d,g){if(!r[v])throw new Error(`The local modal "${v}" has not been registered.`);const y=p(null,{},c,d,g);return y.name=v,r[v].callback(y),y}const w=(v,c={})=>b(v,c.method??"get",c.data??{},c.headers??{},c.config??{},c.onClose,c.onAfterLeave,c.queryStringArrayFormat??"brackets",c.navigate??Me("navigate")).then(d=>{const g=c.listeners??{};return Object.keys(g).forEach(y=>{const h=ce(y);d.on(h,g[y])}),d}),b=(v,c,d={},g={},y={},h=null,$=null,C="brackets",T=!1)=>{const q=Ve();return new Promise((F,D)=>{if(v.startsWith("#")){F(f(v.substring(1),y,h,$));return}const[H,W]=rn.mergeDataIntoQueryString(c,v||"",d,C);let O=T&&t.length===0;if(t.length===0&&(oe=typeof window<"u"?window.location.href:""),g={...g,Accept:"text/html, application/xhtml+xml","X-Requested-With":"XMLHttpRequest","X-Inertia":!0,"X-Inertia-Version":ft,"X-InertiaUI-Modal":q,"X-InertiaUI-Modal-Use-Router":O?1:0,"X-InertiaUI-Modal-Base-Url":oe},O)return Xe=null,ie[q]={config:y,onClose:h,onAfterLeave:$},ne.router.visit(H,{method:c,data:W,headers:g,preserveScroll:!0,preserveState:!0,onError:D,onFinish:()=>{pn(()=>Xe).then(F)}});xe({url:H,method:c,data:W,headers:g}).then(N=>F(a(N.data,y,h,$))).catch(N=>{D(N)})})},x={stack:t,localModals:r,push:p,pushFromResponseData:a,length:()=>Ye.length,closeAll:()=>{Ye.reverse().forEach(v=>v.close())},reset:()=>i(()=>[]),visit:b,visitModal:w,registerLocalModal:(v,c)=>{l(d=>({...d,[v]:{name:v,callback:c}}))},removeLocalModal:v=>{l(c=>{const d={...c};return delete d[v],d})}};return M.jsx(Se.Provider,{value:x,children:e})},fe=()=>{const e=o.useContext(Se);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)},hn=(e,t)=>{vt(t);const n=({Component:r,props:l,key:i})=>{const u=()=>{const a=o.createElement(r,{key:i,...l});return typeof r.layout=="function"?r.layout(a):Array.isArray(r.layout)?r.layout.concat(a).reverse().reduce((p,f)=>o.createElement(f,l,p)):a};return M.jsxs(M.Fragment,{children:[u(),M.jsx(gt,{})]})};return M.jsx(pt,{children:M.jsx(e,{...t,children:n})})},gt=({children:e})=>{var s,p;const t=o.useContext(Se),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(f){const w=f.detail.page.props._inertiaui_modal;if(!w){l&&t.closeAll(),oe=null,i=!1;return}l=w,oe=w.baseUrl,t.pushFromResponseData(w,{},()=>{if(!w.baseUrl){console.error("No base url in modal response data so cannot navigate back");return}!r&&window.location.href!==w.baseUrl&&ne.router.visit(w.baseUrl,{preserveScroll:!0,preserveState:!0})}).then(b=>{Xe=b})}),[]);const u=f=>{var w;return f.headers["X-InertiaUI-Modal-Base-Url"]=oe??(i?(w=n.props._inertiaui_modal)==null?void 0:w.baseUrl:null),f};o.useEffect(()=>(xe.interceptors.request.use(u),()=>xe.interceptors.request.eject(u)),[]);const a=o.useRef();return o.useEffect(()=>{var b,E;const f=(b=n.props)==null?void 0:b._inertiaui_modal,w=a.current;a.current=f,f&&w&&f.component===w.component&&dn(f.url,w.url)&&((E=t.stack[0])==null||E.updateProps(f.props??{}))},[(p=n.props)==null?void 0:p._inertiaui_modal]),M.jsxs(M.Fragment,{children:[e,t.stack.length>0&&M.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)&&M.jsx(ze.Provider,{value:e,children:M.jsx(n.component,{...n.props,onModalEvent:(...r)=>n.emit(...r)})})};function Ke(){return fe().stack[Ge()]??null}const Et=({children:e,data:t,fallback:n})=>{if(!t)throw new Error("`<Deferred>` requires a `data` prop to be a string or array of strings");const[r,l]=o.useState(!1),i=Array.isArray(t)?t:[t],u=Ke().props;return o.useEffect(()=>{l(i.every(a=>u[a]!==void 0))},[u,i]),r?e:n};Et.displayName="InertiaModalDeferred";const Ze=o.forwardRef(({name:e,children:t,onFocus:n=null,onBlur:r=null,onClose:l=null,onSuccess:i=null,...u},a)=>{const s=Ge(),{stack:p,registerLocalModal:f,removeLocalModal:w}=fe(),[b,E]=o.useState(null),m=o.useMemo(()=>e?b:p[s],[e,b,s,p]),x=o.useMemo(()=>{var h;return(h=p.find($=>$.shouldRender&&$.index>(m==null?void 0:m.index)))==null?void 0:h.index},[s,p]),v=o.useMemo(()=>(m==null?void 0:m.config.slideover)??u.slideover??Me("type")==="slideover",[u.slideover]),c=o.useMemo(()=>({slideover:v,closeButton:u.closeButton??re(v,"closeButton"),closeExplicitly:u.closeExplicitly??re(v,"closeExplicitly"),maxWidth:u.maxWidth??re(v,"maxWidth"),paddingClasses:u.paddingClasses??re(v,"paddingClasses"),panelClasses:u.panelClasses??re(v,"panelClasses"),position:u.position??re(v,"position"),...m==null?void 0:m.config}),[u,m==null?void 0:m.config]);o.useEffect(()=>{if(e){let h=null;return f(e,$=>{h=$.registerEventListenersFromProps(u),E($)}),()=>{h==null||h(),h=null,w(e)}}return m.registerEventListenersFromProps(u)},[e]);const d=o.useRef(m);o.useEffect(()=>{d.current=m},[m]),o.useEffect(()=>{m!==null&&(m.isOpen?i==null||i():l==null||l())},[m==null?void 0:m.isOpen]);const[g,y]=o.useState(!1);return o.useEffect(()=>{g&&m!==null&&m.isOpen&&(m.onTopOfStack?n==null||n():r==null||r()),y(!0)},[m==null?void 0:m.onTopOfStack]),o.useImperativeHandle(a,()=>({afterLeave:()=>{var h;return(h=d.current)==null?void 0:h.afterLeave()},close:()=>{var h;return(h=d.current)==null?void 0:h.close()},emit:(...h)=>{var $;return($=d.current)==null?void 0:$.emit(...h)},getChildModal:()=>{var h;return(h=d.current)==null?void 0:h.getChildModal()},getParentModal:()=>{var h;return(h=d.current)==null?void 0:h.getParentModal()},reload:(...h)=>{var $;return($=d.current)==null?void 0:$.reload(...h)},setOpen:()=>{var h;return(h=d.current)==null?void 0:h.setOpen()},get id(){var h;return(h=d.current)==null?void 0:h.id},get index(){var h;return(h=d.current)==null?void 0:h.index},get isOpen(){var h;return(h=d.current)==null?void 0:h.isOpen},get config(){var h;return(h=d.current)==null?void 0:h.config},get modalContext(){return d.current},get onTopOfStack(){var h;return(h=d.current)==null?void 0:h.onTopOfStack},get shouldRender(){var h;return(h=d.current)==null?void 0:h.shouldRender}}),[m]),(m==null?void 0:m.shouldRender)&&M.jsxs(M.Fragment,{children:[typeof t=="function"?t({afterLeave:m.afterLeave,close:m.close,config:c,emit:m.emit,getChildModal:m.getChildModal,getParentModal:m.getParentModal,id:m.id,index:m.index,isOpen:m.isOpen,modalContext:m,onTopOfStack:m.onTopOfStack,reload:m.reload,setOpen:m.setOpen,shouldRender:m.shouldRender}):t,x&&M.jsx(wt,{index:x})]})});Ze.displayName="HeadlessModal";function yt(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=yt(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function Ce(){for(var e,t,n=0,r="",l=arguments.length;n<l;n++)(e=arguments[n])&&(t=yt(e))&&(r&&(r+=" "),r+=t);return r}var vn=Object.defineProperty,gn=(e,t,n)=>t in e?vn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Je=(e,t,n)=>(gn(e,typeof t!="symbol"?t+"":t,n),n);let wn=class{constructor(){Je(this,"current",this.detect()),Je(this,"handoffState","pending"),Je(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 wn;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 Pe(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 Pe(()=>{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 Qe(){let[e]=o.useState(z);return o.useEffect(()=>()=>e.dispose(),[e]),e}let k=(e,t)=>{J.isServer?o.useEffect(e,t):o.useLayoutEffect(e,t)};function Q(e){let t=o.useRef(e);return k(()=>{t.current=e},[e]),t}let P=function(e){let t=Q(e);return o.useCallback((...n)=>t.current(...n),[t])},En=o.createContext(void 0);function yn(){return o.useContext(En)}function Re(...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 Te=(e=>(e[e.None=0]="None",e[e.RenderStrategy=1]="RenderStrategy",e[e.Static=2]="Static",e))(Te||{}),K=(e=>(e[e.Unmount=0]="Unmount",e[e.Hidden=1]="Hidden",e))(K||{});function j(){let e=xn();return o.useCallback(t=>bn({mergeRefs:e,...t}),[e])}function bn({ourProps:e,theirProps:t,slot:n,defaultTag:r,features:l,visible:i=!0,name:u,mergeRefs:a}){a=a??$n;let s=bt(t,e);if(i)return Fe(s,n,r,u,a);let p=l??0;if(p&2){let{static:f=!1,...w}=s;if(f)return Fe(w,n,r,u,a)}if(p&1){let{unmount:f=!0,...w}=s;return G(f?0:1,{0(){return null},1(){return Fe({...w,hidden:!0,style:{display:"none"}},n,r,u,a)}})}return Fe(s,n,r,u,a)}function Fe(e,t={},n,r,l){let{as:i=n,children:u,refName:a="ref",...s}=et(e,["unmount","static"]),p=e.ref!==void 0?{[a]:e.ref}:{},f=typeof u=="function"?u(t):u;"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 w={};if(t){let b=!1,E=[];for(let[m,x]of Object.entries(t))typeof x=="boolean"&&(b=!0),x===!0&&E.push(m.replace(/([A-Z])/g,v=>`-${v.toLowerCase()}`));if(b){w["data-headlessui-state"]=E.join(" ");for(let m of E)w[`data-${m}`]=""}}if(i===o.Fragment&&(Object.keys(R(s)).length>0||Object.keys(R(w)).length>0))if(!o.isValidElement(f)||Array.isArray(f)&&f.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(w))).map(b=>` - ${b}`).join(`
|
|
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(
|
|
1
|
+
(function(M,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):(M=typeof globalThis<"u"?globalThis:M||self,o(M.InertiaUIModal={},M.React,M.jsxRuntime,M.Axios,M.react,M.core,M.ReactDOM))})(this,function(M,o,O,Te,ue,Pr,Tr){"use strict";var Kl=Object.defineProperty;var Yl=(M,o,O)=>o in M?Kl(M,o,{enumerable:!0,configurable:!0,writable:!0,value:O}):M[o]=O;var B=(M,o,O)=>Yl(M,typeof o!="symbol"?o+"":o,O);function kr(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const ve=kr(o),ge={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 Fr{constructor(){this.config={},this.reset()}reset(){this.config=JSON.parse(JSON.stringify(ge))}put(t,r){if(typeof t=="object"){this.config={type:t.type??ge.type,navigate:t.navigate??ge.navigate,modal:{...ge.modal,...t.modal??{}},slideover:{...ge.slideover,...t.slideover??{}}};return}const n=t.split(".");let l=this.config;for(let i=0;i<n.length-1;i++)l=l[n[i]]=l[n[i]]||{};l[n[n.length-1]]=r}get(t){if(typeof t>"u")return this.config;const r=t.split(".");let n=this.config;for(const l of r){if(n[l]===void 0)return null;n=n[l]}return n}}const ke=new Fr,Lr=()=>ke.reset(),Ar=(e,t)=>ke.put(e,t),Fe=e=>ke.get(e),ae=(e,t)=>ke.get(e?`slideover.${t}`:`modal.${t}`);function Ir(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 Re(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 de(e){return typeof e=="string"?e.toLowerCase():e}function Nr(e,t,r=!1){return r&&(t=t.map(de)),Array.isArray(e)?e.filter(n=>!t.includes(r?de(n):n)):Object.keys(e).reduce((n,l)=>(t.includes(r?de(l):l)||(n[l]=e[l]),n),{})}function Dr(e,t,r=!1){return r&&(t=t.map(de)),Array.isArray(e)?e.filter(n=>t.includes(r?de(n):n)):Object.keys(e).reduce((n,l)=>(t.includes(r?de(l):l)&&(n[l]=e[l]),n),{})}function jr(e){return Array.isArray(e)?e.filter(t=>t!==null):Object.keys(e).reduce((t,r)=>(r in e&&e[r]!==null&&(t[r]=e[r]),t),{})}function we(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,r)=>r.toUpperCase()),e=e.replace(/(.)(?=[A-Z])/g,"$1-"),e.toLowerCase()):e):""}const Le=o.createContext(null);Le.displayName="ModalStackContext";let St=null,Mt=null,ce=null,Ae={},et=[],fe={};const Ct=({children:e})=>{const[t,r]=o.useState([]),[n,l]=o.useState({}),i=v=>{r(c=>{const f=v([...c]),g=y=>{var p;return f.length<2?!0:((p=f.map(x=>({id:x.id,shouldRender:x.shouldRender})).reverse().find(x=>x.shouldRender))==null?void 0:p.id)===y};return f.forEach((y,p)=>{f[p].onTopOfStack=g(y.id),f[p].getParentModal=()=>p<1?null:f.slice(0,p).reverse().find(x=>x.isOpen),f[p].getChildModal=()=>p===f.length-1?null:f.slice(p+1).find(x=>x.isOpen)}),f})};o.useEffect(()=>{et=t},[t]);class a{constructor(c,f,g,y,p){B(this,"show",()=>{i(c=>c.map(f=>(f.id===this.id&&!f.isOpen&&(f.isOpen=!0,f.shouldRender=!0),f)))});B(this,"setOpen",c=>{c?this.show():this.close()});B(this,"close",()=>{i(c=>{let f=!1;const g=c.map(y=>{var p;return y.id===this.id&&y.isOpen&&(Object.keys(y.listeners).forEach(x=>{y.off(x)}),y.isOpen=!1,(p=y.onCloseCallback)==null||p.call(y),f=!0),y});return f?g:c})});B(this,"afterLeave",()=>{this.isOpen||i(c=>{const f=c.map(g=>{var y;return g.id===this.id&&!g.isOpen&&(g.shouldRender=!1,(y=g.afterLeaveCallback)==null||y.call(g),g.afterLeaveCallback=null),g});return this.index===0?[]:f})});B(this,"on",(c,f)=>{c=we(c),this.listeners[c]=this.listeners[c]??[],this.listeners[c].push(f)});B(this,"off",(c,f)=>{var g;c=we(c),f?this.listeners[c]=((g=this.listeners[c])==null?void 0:g.filter(y=>y!==f))??[]:delete this.listeners[c]});B(this,"emit",(c,...f)=>{var g;(g=this.listeners[we(c)])==null||g.forEach(y=>y(...f))});B(this,"registerEventListenersFromProps",c=>{const f=[];return Object.keys(c).filter(g=>g.startsWith("on")).forEach(g=>{const y=we(g).replace(/^on-/,"");this.on(y,c[g]),f.push(()=>this.off(y,c[g]))}),()=>f.forEach(g=>g())});B(this,"reload",(c={})=>{var p,x;let f=Object.keys(this.response.props);if(c.only&&(f=c.only),c.except&&(f=Nr(f,c.except)),!((p=this.response)!=null&&p.url))return;const g=(c.method??"get").toLowerCase(),y=c.data??{};(x=c.onStart)==null||x.call(c),Te({url:this.response.url,method:g,data:g==="get"?{}:y,params:g==="get"?y:{},headers:{...c.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":f.join(","),"X-InertiaUI-Modal":Re(),"X-InertiaUI-Modal-Use-Router":0,"X-InertiaUI-Modal-Base-Url":ce}}).then(S=>{var L;this.updateProps(S.data.props),(L=c.onSuccess)==null||L.call(c,S)}).catch(S=>{var L;(L=c.onError)==null||L.call(c,S)}).finally(()=>{var S;(S=c.onFinish)==null||S.call(c)})});B(this,"updateProps",c=>{Object.assign(this.props,c),i(f=>f)});if(this.id=f.id??Re(),this.isOpen=!1,this.shouldRender=!1,this.listeners={},this.component=c,this.props=f.props,this.response=f,this.config=g??{},this.onCloseCallback=y,this.afterLeaveCallback=p,fe[this.id]){this.config={...this.config,...fe[this.id].config??{}};const x=fe[this.id].onClose,S=fe[this.id].onAfterLeave;x&&(this.onCloseCallback=y?()=>{y(),x()}:x),S&&(this.afterLeaveCallback=p?()=>{p(),S()}:S),delete fe[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=(v,c={},f=null,g=null)=>Mt(v.component).then(y=>d(y,v,c,f,g)),s=v=>{var f,g;const c=(g=(f=v.response)==null?void 0:f.meta)==null?void 0:g.deferredProps;c&&Object.keys(c).forEach(y=>{v.reload({only:c[y]})})},d=(v,c,f,g,y)=>{const p=new a(v,c,f,g,y);return p.index=t.length,i(x=>[...x,p]),s(p),p.show(),p};function h(v,c,f,g){if(!n[v])throw new Error(`The local modal "${v}" has not been registered.`);const y=d(null,{},c,f,g);return y.name=v,n[v].callback(y),y}const b=(v,c={})=>E(v,c.method??"get",c.data??{},c.headers??{},c.config??{},c.onClose,c.onAfterLeave,c.queryStringArrayFormat??"brackets",c.navigate??Fe("navigate"),c.onStart,c.onSuccess,c.onError).then(f=>{const g=c.listeners??{};return Object.keys(g).forEach(y=>{const p=we(y);f.on(p,g[y])}),f}),E=(v,c,f={},g={},y={},p=null,x=null,S="brackets",L=!1,j=null,k=null,A=null)=>{const H=Re();return new Promise((I,T)=>{if(v.startsWith("#")){I(h(v.substring(1),y,p,x));return}const[_,pe]=Pr.mergeDataIntoQueryString(c,v||"",f,S);let se=L&&t.length===0;if(t.length===0&&(ce=typeof window<"u"?window.location.href:""),g={...g,Accept:"text/html, application/xhtml+xml","X-Requested-With":"XMLHttpRequest","X-Inertia":!0,"X-Inertia-Version":St,"X-InertiaUI-Modal":H,"X-InertiaUI-Modal-Use-Router":se?1:0,"X-InertiaUI-Modal-Base-Url":ce},se)return Ae={},fe[H]={config:y,onClose:p,onAfterLeave:x},ue.router.visit(_,{method:c,data:pe,headers:g,preserveScroll:!0,preserveState:!0,onError(...F){A==null||A(...F),T(...F)},onStart(...F){j==null||j(...F)},onSuccess(...F){k==null||k(...F)},onBefore:()=>{Ae[H]=I}});j==null||j(),Te({url:_,method:c,data:pe,headers:g}).then(F=>{k==null||k(F),I(u(F.data,y,p,x))}).catch((...F)=>{A==null||A(...F),T(...F)})})},$={stack:t,localModals:n,push:d,pushFromResponseData:u,length:()=>et.length,closeAll:()=>{et.reverse().forEach(v=>v.close())},reset:()=>i(()=>[]),visit:E,visitModal:b,registerLocalModal:(v,c)=>{l(f=>({...f,[v]:{name:v,callback:c}}))},removeLocalModal:v=>{l(c=>{const f={...c};return delete f[v],f})},onModalOnBase:v=>{const c=Ae[v.id];c&&(c(v),delete Ae[v.id])}};return O.jsx(Le.Provider,{value:$,children:e})},be=()=>{const e=o.useContext(Le);if(e===null)throw new Error("useModalStack must be used within a ModalStackProvider");return e},Pt=["closeButton","closeExplicitly","maxWidth","paddingClasses","panelClasses","position","slideover"],Tt=e=>{e.initialPage&&(St=e.initialPage.version),e.resolveComponent&&(Mt=e.resolveComponent)},_r=(e,t)=>{Tt(t);const r=({Component:n,props:l,key:i})=>{const a=()=>{const u=o.createElement(n,{key:i,...l});return typeof n.layout=="function"?n.layout(u):Array.isArray(n.layout)?n.layout.concat(u).reverse().reduce((d,h)=>o.createElement(h,l,d)):u};return O.jsxs(O.Fragment,{children:[a(),O.jsx(kt,{})]})};return O.jsx(Ct,{children:O.jsx(e,{...t,children:r})})},kt=({children:e})=>{var s,d;const t=o.useContext(Le),r=ue.usePage();let n=!1,l=!1,i=!!((s=r.props)!=null&&s._inertiaui_modal);o.useEffect(()=>ue.router.on("start",()=>n=!0),[]),o.useEffect(()=>ue.router.on("finish",()=>n=!1),[]),o.useEffect(()=>ue.router.on("navigate",function(h){const b=h.detail.page.props._inertiaui_modal;if(!b){l&&t.closeAll(),ce=null,i=!1;return}l=b,ce=b.baseUrl,t.pushFromResponseData(b,{},()=>{if(!b.baseUrl){console.error("No base url in modal response data so cannot navigate back");return}!n&&window.location.href!==b.baseUrl&&ue.router.visit(b.baseUrl,{preserveScroll:!0,preserveState:!0})}).then(t.onModalOnBase)}),[]);const a=h=>{var b;return h.headers["X-InertiaUI-Modal-Base-Url"]=ce??(i?(b=r.props._inertiaui_modal)==null?void 0:b.baseUrl:null),h};o.useEffect(()=>(Te.interceptors.request.use(a),()=>Te.interceptors.request.eject(a)),[]);const u=o.useRef();return o.useEffect(()=>{var E,w;const h=(E=r.props)==null?void 0:E._inertiaui_modal,b=u.current;u.current=h,h&&b&&h.component===b.component&&Ir(h.url,b.url)&&((w=t.stack[0])==null||w.updateProps(h.props??{}))},[(d=r.props)==null?void 0:d._inertiaui_modal]),O.jsxs(O.Fragment,{children:[e,t.stack.length>0&&O.jsx(Ft,{index:0})]})},tt=o.createContext(null);tt.displayName="ModalIndexContext";const rt=()=>{const e=o.useContext(tt);if(e===void 0)throw new Error("useModalIndex must be used within a ModalIndexProvider");return e},Ft=({index:e})=>{const{stack:t}=be(),r=o.useMemo(()=>t[e],[t,e]);return(r==null?void 0:r.component)&&O.jsx(tt.Provider,{value:e,children:O.jsx(r.component,{...r.props,onModalEvent:(...n)=>r.emit(...n)})})};function nt(){return be().stack[rt()]??null}const Lt=({children:e,data:t,fallback:r})=>{if(!t)throw new Error("`<Deferred>` requires a `data` prop to be a string or array of strings");const[n,l]=o.useState(!1),i=Array.isArray(t)?t:[t],a=nt().props;return o.useEffect(()=>{l(i.every(u=>a[u]!==void 0))},[a,i]),n?e:r};Lt.displayName="InertiaModalDeferred";const lt=o.forwardRef(({name:e,children:t,onFocus:r=null,onBlur:n=null,onClose:l=null,onSuccess:i=null,...a},u)=>{const s=rt(),{stack:d,registerLocalModal:h,removeLocalModal:b}=be(),[E,w]=o.useState(null),m=o.useMemo(()=>e?E:d[s],[e,E,s,d]),$=o.useMemo(()=>{var p;return(p=d.find(x=>x.shouldRender&&x.index>(m==null?void 0:m.index)))==null?void 0:p.index},[s,d]),v=o.useMemo(()=>(m==null?void 0:m.config.slideover)??a.slideover??Fe("type")==="slideover",[a.slideover]),c=o.useMemo(()=>({slideover:v,closeButton:a.closeButton??ae(v,"closeButton"),closeExplicitly:a.closeExplicitly??ae(v,"closeExplicitly"),maxWidth:a.maxWidth??ae(v,"maxWidth"),paddingClasses:a.paddingClasses??ae(v,"paddingClasses"),panelClasses:a.panelClasses??ae(v,"panelClasses"),position:a.position??ae(v,"position"),...m==null?void 0:m.config}),[a,m==null?void 0:m.config]);o.useEffect(()=>{if(e){let p=null;return h(e,x=>{p=x.registerEventListenersFromProps(a),w(x)}),()=>{p==null||p(),p=null,b(e)}}return m.registerEventListenersFromProps(a)},[e]);const f=o.useRef(m);o.useEffect(()=>{f.current=m},[m]),o.useEffect(()=>{m!==null&&(m.isOpen?i==null||i():l==null||l())},[m==null?void 0:m.isOpen]);const[g,y]=o.useState(!1);return o.useEffect(()=>{g&&m!==null&&m.isOpen&&(m.onTopOfStack?r==null||r():n==null||n()),y(!0)},[m==null?void 0:m.onTopOfStack]),o.useImperativeHandle(u,()=>({afterLeave:()=>{var p;return(p=f.current)==null?void 0:p.afterLeave()},close:()=>{var p;return(p=f.current)==null?void 0:p.close()},emit:(...p)=>{var x;return(x=f.current)==null?void 0:x.emit(...p)},getChildModal:()=>{var p;return(p=f.current)==null?void 0:p.getChildModal()},getParentModal:()=>{var p;return(p=f.current)==null?void 0:p.getParentModal()},reload:(...p)=>{var x;return(x=f.current)==null?void 0:x.reload(...p)},setOpen:()=>{var p;return(p=f.current)==null?void 0:p.setOpen()},get id(){var p;return(p=f.current)==null?void 0:p.id},get index(){var p;return(p=f.current)==null?void 0:p.index},get isOpen(){var p;return(p=f.current)==null?void 0:p.isOpen},get config(){var p;return(p=f.current)==null?void 0:p.config},get modalContext(){return f.current},get onTopOfStack(){var p;return(p=f.current)==null?void 0:p.onTopOfStack},get shouldRender(){var p;return(p=f.current)==null?void 0:p.shouldRender}}),[m]),(m==null?void 0:m.shouldRender)&&O.jsxs(O.Fragment,{children:[typeof t=="function"?t({afterLeave:m.afterLeave,close:m.close,config:c,emit:m.emit,getChildModal:m.getChildModal,getParentModal:m.getParentModal,id:m.id,index:m.index,isOpen:m.isOpen,modalContext:m,onTopOfStack:m.onTopOfStack,reload:m.reload,setOpen:m.setOpen,shouldRender:m.shouldRender}):t,$&&O.jsx(Ft,{index:$})]})});lt.displayName="HeadlessModal";function At(e){var t,r,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var l=e.length;for(t=0;t<l;t++)e[t]&&(r=At(e[t]))&&(n&&(n+=" "),n+=r)}else for(r in e)e[r]&&(n&&(n+=" "),n+=r);return n}function Ie(){for(var e,t,r=0,n="",l=arguments.length;r<l;r++)(e=arguments[r])&&(t=At(e))&&(n&&(n+=" "),n+=t);return n}var Wr=Object.defineProperty,Ur=(e,t,r)=>t in e?Wr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ot=(e,t,r)=>(Ur(e,typeof t!="symbol"?t+"":t,r),r);let Hr=class{constructor(){ot(this,"current",this.detect()),ot(this,"handoffState","pending"),ot(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"}},te=new Hr;function Ne(e){var t,r;return te.isServer?null:e?"ownerDocument"in e?e.ownerDocument:"current"in e?(r=(t=e.current)==null?void 0:t.ownerDocument)!=null?r:document:null:document}function De(e){typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e).catch(t=>setTimeout(()=>{throw t}))}function z(){let e=[],t={addEventListener(r,n,l,i){return r.addEventListener(n,l,i),t.add(()=>r.removeEventListener(n,l,i))},requestAnimationFrame(...r){let n=requestAnimationFrame(...r);return t.add(()=>cancelAnimationFrame(n))},nextFrame(...r){return t.requestAnimationFrame(()=>t.requestAnimationFrame(...r))},setTimeout(...r){let n=setTimeout(...r);return t.add(()=>clearTimeout(n))},microTask(...r){let n={current:!0};return De(()=>{n.current&&r[0]()}),t.add(()=>{n.current=!1})},style(r,n,l){let i=r.style.getPropertyValue(n);return Object.assign(r.style,{[n]:l}),this.add(()=>{Object.assign(r.style,{[n]:i})})},group(r){let n=z();return r(n),this.add(()=>n.dispose())},add(r){return e.includes(r)||e.push(r),()=>{let n=e.indexOf(r);if(n>=0)for(let l of e.splice(n,1))l()}},dispose(){for(let r of e.splice(0))r()}};return t}function it(){let[e]=o.useState(z);return o.useEffect(()=>()=>e.dispose(),[e]),e}let N=(e,t)=>{te.isServer?o.useEffect(e,t):o.useLayoutEffect(e,t)};function re(e){let t=o.useRef(e);return N(()=>{t.current=e},[e]),t}let P=function(e){let t=re(e);return o.useCallback((...r)=>t.current(...r),[t])},Vr=o.createContext(void 0);function Br(){return o.useContext(Vr)}function st(...e){return Array.from(new Set(e.flatMap(t=>typeof t=="string"?t.split(" "):[]))).filter(Boolean).join(" ")}function G(e,t,...r){if(e in t){let l=t[e];return typeof l=="function"?l(...r):l}let n=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(n,G),n}var je=(e=>(e[e.None=0]="None",e[e.RenderStrategy=1]="RenderStrategy",e[e.Static=2]="Static",e))(je||{}),Z=(e=>(e[e.Unmount=0]="Unmount",e[e.Hidden=1]="Hidden",e))(Z||{});function W(){let e=Xr();return o.useCallback(t=>qr({mergeRefs:e,...t}),[e])}function qr({ourProps:e,theirProps:t,slot:r,defaultTag:n,features:l,visible:i=!0,name:a,mergeRefs:u}){u=u??zr;let s=It(t,e);if(i)return _e(s,r,n,a,u);let d=l??0;if(d&2){let{static:h=!1,...b}=s;if(h)return _e(b,r,n,a,u)}if(d&1){let{unmount:h=!0,...b}=s;return G(h?0:1,{0(){return null},1(){return _e({...b,hidden:!0,style:{display:"none"}},r,n,a,u)}})}return _e(s,r,n,a,u)}function _e(e,t={},r,n,l){let{as:i=r,children:a,refName:u="ref",...s}=ut(e,["unmount","static"]),d=e.ref!==void 0?{[u]:e.ref}:{},h=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 b={};if(t){let E=!1,w=[];for(let[m,$]of Object.entries(t))typeof $=="boolean"&&(E=!0),$===!0&&w.push(m.replace(/([A-Z])/g,v=>`-${v.toLowerCase()}`));if(E){b["data-headlessui-state"]=w.join(" ");for(let m of w)b[`data-${m}`]=""}}if(i===o.Fragment&&(Object.keys(ne(s)).length>0||Object.keys(ne(b)).length>0))if(!o.isValidElement(h)||Array.isArray(h)&&h.length>1){if(Object.keys(ne(s)).length>0)throw new Error(['Passing props on "Fragment"!',"",`The current component <${n} /> is rendering a "Fragment".`,"However we need to passthrough the following props:",Object.keys(ne(s)).concat(Object.keys(ne(b))).map(E=>` - ${E}`).join(`
|
|
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(E=>` - ${E}`).join(`
|
|
3
3
|
`)].join(`
|
|
4
|
-
`))}else{let b=f.props,E=b==null?void 0:b.className,m=typeof E=="function"?(...c)=>Re(E(...c),s.className):Re(E,s.className),x=m?{className:m}:{},v=bt(f.props,R(et(s,["ref"])));for(let c in w)c in v&&delete w[c];return o.cloneElement(f,Object.assign({},v,w,p,{ref:l(Mn(f),p.ref)},x))}return o.createElement(i,Object.assign({},et(s,["ref"]),i!==o.Fragment&&p,i!==o.Fragment&&w),f)}function xn(){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 $n(...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 bt(...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 u=n[r];for(let a of u){if((l instanceof Event||(l==null?void 0:l.nativeEvent)instanceof Event)&&l.defaultPrevented)return;a(l,...i)}}});return t}function I(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 et(e,t=[]){let n=Object.assign({},e);for(let r of t)r in n&&delete n[r];return n}function Mn(e){return o.version.split(".")[0]>="19"?e.props.ref:e.ref}let Sn="span";var Le=(e=>(e[e.None=1]="None",e[e.Focusable=2]="Focusable",e[e.Hidden=4]="Hidden",e))(Le||{});function Cn(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 j()({ourProps:i,theirProps:l,slot:{},defaultTag:Sn,name:"Hidden"})}let tt=I(Cn),xt=Symbol();function On(e,t=!0){return Object.assign(e,{[xt]:t})}function B(...e){let t=o.useRef(e);o.useEffect(()=>{t.current=e},[e]);let n=P(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[xt]))?void 0:n}let nt=o.createContext(null);nt.displayName="DescriptionContext";function $t(){let e=o.useContext(nt);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,$t),t}return e}function Pn(){let[e,t]=o.useState([]);return[e.length>0?e.join(" "):void 0,o.useMemo(()=>function(n){let r=P(i=>(t(u=>[...u,i]),()=>t(u=>{let a=u.slice(),s=a.indexOf(i);return s!==-1&&a.splice(s,1),a}))),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(nt.Provider,{value:l},n.children)},[t])]}let Tn="p";function Fn(e,t){let n=o.useId(),r=yn(),{id:l=`headlessui-description-${n}`,...i}=e,u=$t(),a=B(t);k(()=>u.register(l),[l,u.register]);let s=r||!1,p=o.useMemo(()=>({...u.slot,disabled:s}),[u.slot,s]),f={ref:a,...u.props,id:l};return j()({ourProps:f,theirProps:i,slot:p,defaultTag:Tn,name:u.name||"Description"})}let Ln=I(Fn),kn=Object.assign(Ln,{});var Mt=(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))(Mt||{});let Nn=o.createContext(()=>{});function In({value:e,children:t}){return o.createElement(Nn.Provider,{value:e},t)}let An=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 St(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 u=t[l].call(n,...i);u&&(n=u,r.forEach(a=>a()))}}}function Ct(e){return o.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getSnapshot)}let Dn=new An(()=>St(()=>[],{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=Dn.get(t),r=o.useId(),l=Ct(n);if(k(()=>{if(e)return n.dispatch("ADD",r),()=>n.dispatch("REMOVE",r)},[n,e]),!e)return!1;let i=l.indexOf(r),u=l.length;return i===-1&&(i=u,u+=1),i===u-1}let rt=new Map,me=new Map;function Ot(e){var t;let n=(t=me.get(e))!=null?t:0;return me.set(e,n+1),n!==0?()=>Pt(e):(rt.set(e,{"aria-hidden":e.getAttribute("aria-hidden"),inert:e.inert}),e.setAttribute("aria-hidden","true"),e.inert=!0,()=>Pt(e))}function Pt(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=rt.get(e);r&&(r["aria-hidden"]===null?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",r["aria-hidden"]),e.inert=r.inert,rt.delete(e))}function jn(e,{allowed:t,disallowed:n}={}){let r=se(e,"inert-others");k(()=>{var l,i;if(!r)return;let u=z();for(let s of(l=n==null?void 0:n())!=null?l:[])s&&u.add(Ot(s));let a=(i=t==null?void 0:t())!=null?i:[];for(let s of a){if(!s)continue;let p=Oe(s);if(!p)continue;let f=s.parentElement;for(;f&&f!==p.body;){for(let w of f.children)a.some(b=>w.contains(b))||u.add(Ot(w));f=f.parentElement}}return u.dispose},[r,t,n])}function Un(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 u=new ResizeObserver(()=>r.current(l));u.observe(l),i.add(()=>u.disconnect())}if(typeof IntersectionObserver<"u"){let u=new IntersectionObserver(()=>r.current(l));u.observe(l),i.add(()=>u.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(","),Hn=["[data-autofocus]"].map(e=>`${e}:not([tabindex='-1'])`).join(",");var X=(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))(X||{}),lt=(e=>(e[e.Error=0]="Error",e[e.Overflow=1]="Overflow",e[e.Success=2]="Success",e[e.Underflow=3]="Underflow",e))(lt||{}),Wn=(e=>(e[e.Previous=-1]="Previous",e[e.Next=1]="Next",e))(Wn||{});function _n(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 Bn(e=document.body){return e==null?[]:Array.from(e.querySelectorAll(Hn)).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 qn(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 Vn=(e=>(e[e.Keyboard=0]="Keyboard",e[e.Mouse=1]="Mouse",e))(Vn||{});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 Xn=["textarea","input"].join(",");function Yn(e){var t,n;return(n=(t=e==null?void 0:e.matches)==null?void 0:t.call(e,Xn))!=null?n:!1}function zn(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 u=l.compareDocumentPosition(i);return u&Node.DOCUMENT_POSITION_FOLLOWING?-1:u&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,u=Array.isArray(e)?n?zn(e):e:t&64?Bn(e):_n(e);l.length>0&&u.length>1&&(u=u.filter(E=>!l.some(m=>m!=null&&"current"in m?(m==null?void 0:m.current)===E:m===E))),r=r??i.activeElement;let a=(()=>{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,u.indexOf(r))-1;if(t&4)return Math.max(0,u.indexOf(r))+1;if(t&8)return u.length-1;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")})(),p=t&32?{preventScroll:!0}:{},f=0,w=u.length,b;do{if(f>=w||f+w<=0)return 0;let E=s+f;if(t&16)E=(E+w)%w;else{if(E<0)return 3;if(E>=w)return 1}b=u[E],b==null||b.focus(p),f+=a}while(b!==i.activeElement);return t&6&&Yn(b)&&b.select(),2}function Ft(){return/iPhone/gi.test(window.navigator.platform)||/Mac/gi.test(window.navigator.platform)&&window.navigator.maxTouchPoints>0}function Gn(){return/Android/gi.test(window.navigator.userAgent)}function Kn(){return Ft()||Gn()}function he(e,t,n,r){let l=Q(n);o.useEffect(()=>{if(!e)return;function i(u){l.current(u)}return document.addEventListener(t,i,r),()=>document.removeEventListener(t,i,r)},[e,t,r])}function Lt(e,t,n,r){let l=Q(n);o.useEffect(()=>{if(!e)return;function i(u){l.current(u)}return window.addEventListener(t,i,r),()=>window.removeEventListener(t,i,r)},[e,t,r])}const kt=30;function Zn(e,t,n){let r=se(e,"outside-click"),l=Q(n),i=o.useCallback(function(s,p){if(s.defaultPrevented)return;let f=p(s);if(f===null||!f.getRootNode().contains(f)||!f.isConnected)return;let w=function b(E){return typeof E=="function"?b(E()):Array.isArray(E)||E instanceof Set?E:[E]}(t);for(let b of w)if(b!==null&&(b.contains(f)||s.composed&&s.composedPath().includes(b)))return;return!qn(f,Tt.Loose)&&f.tabIndex!==-1&&s.preventDefault(),l.current(s,f)},[l,t]),u=o.useRef(null);he(r,"pointerdown",s=>{var p,f;u.current=((f=(p=s.composedPath)==null?void 0:p.call(s))==null?void 0:f[0])||s.target},!0),he(r,"mousedown",s=>{var p,f;u.current=((f=(p=s.composedPath)==null?void 0:p.call(s))==null?void 0:f[0])||s.target},!0),he(r,"click",s=>{Kn()||u.current&&(i(s,()=>u.current),u.current=null)},!0);let a=o.useRef({x:0,y:0});he(r,"touchstart",s=>{a.current.x=s.touches[0].clientX,a.current.y=s.touches[0].clientY},!0),he(r,"touchend",s=>{let p={x:s.changedTouches[0].clientX,y:s.changedTouches[0].clientY};if(!(Math.abs(p.x-a.current.x)>=kt||Math.abs(p.y-a.current.y)>=kt))return i(s,()=>s.target instanceof HTMLElement?s.target:null)},!0),Lt(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 Nt(e,t,n,r){let l=Q(n);o.useEffect(()=>{e=e??window;function i(u){l.current(u)}return e.addEventListener(t,i,r),()=>e.removeEventListener(t,i,r)},[e,t,r])}function Jn(){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 Qn(){return Ft()?{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 a=z();a.style(e.documentElement,"scrollBehavior","auto"),t.add(()=>t.microTask(()=>a.dispose()))}let i=(l=window.scrollY)!=null?l:window.pageYOffset,u=null;t.addEventListener(e,"click",a=>{if(a.target instanceof HTMLElement)try{let s=a.target.closest("a");if(!s)return;let{hash:p}=new URL(s.href),f=e.querySelector(p);f&&!r(f)&&(u=f)}catch{}},!0),t.addEventListener(e,"touchstart",a=>{if(a.target instanceof HTMLElement)if(r(a.target)){let s=a.target;for(;s.parentElement&&r(s.parentElement);)s=s.parentElement;t.style(s,"overscrollBehavior","contain")}else t.style(a.target,"touchAction","none")}),t.addEventListener(e,"touchmove",a=>{if(a.target instanceof HTMLElement){if(a.target.tagName==="INPUT")return;if(r(a.target)){let s=a.target;for(;s.parentElement&&s.dataset.headlessuiPortal!==""&&!(s.scrollHeight>s.clientHeight||s.scrollWidth>s.clientWidth);)s=s.parentElement;s.dataset.headlessuiPortal===""&&a.preventDefault()}else a.preventDefault()}},{passive:!1}),t.add(()=>{var a;let s=(a=window.scrollY)!=null?a:window.pageYOffset;i!==s&&window.scrollTo(0,i),u&&u.isConnected&&(u.scrollIntoView({block:"nearest"}),u=null)})})}}:{}}function Rn(){return{before({doc:e,d:t}){t.style(e.documentElement,"overflow","hidden")}}}function er(e){let t={};for(let n of e)Object.assign(t,n(t));return t}let ee=St(()=>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:er(n)},l=[Qn(),Jn(),Rn()];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 tr(e,t,n=()=>({containers:[]})){let r=Ct(ee),l=t?r.get(t):void 0,i=l?l.count>0:!1;return k(()=>{if(!(!t||!e))return ee.dispatch("PUSH",t,n),()=>ee.dispatch("POP",t,n)},[e,t]),i}function nr(e,t,n=()=>[document.body]){let r=se(e,"scroll-lock");tr(r,t,l=>{var i;return{containers:[...(i=l.containers)!=null?i:[],n]}})}function rr(e=0){let[t,n]=o.useState(e),r=o.useCallback(s=>n(s),[t]),l=o.useCallback(s=>n(p=>p|s),[t]),i=o.useCallback(s=>(t&s)===s,[t]),u=o.useCallback(s=>n(p=>p&~s),[n]),a=o.useCallback(s=>n(p=>p^s),[n]);return{flags:t,setFlag:r,addFlag:l,hasFlag:i,removeFlag:u,toggleFlag:a}}var It,At;typeof process<"u"&&typeof globalThis<"u"&&typeof Element<"u"&&((It=process==null?void 0:process.env)==null?void 0:It.NODE_ENV)==="test"&&typeof((At=Element==null?void 0:Element.prototype)==null?void 0:At.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 lr=(e=>(e[e.None=0]="None",e[e.Closed=1]="Closed",e[e.Enter=2]="Enter",e[e.Leave=4]="Leave",e))(lr||{});function or(e){let t={};for(let n in e)e[n]===!0&&(t[`data-${n}`]="");return t}function ir(e,t,n,r){let[l,i]=o.useState(n),{hasFlag:u,addFlag:a,removeFlag:s}=rr(e&&l?3:0),p=o.useRef(!1),f=o.useRef(!1),w=Qe();return k(()=>{var b;if(e){if(n&&i(!0),!t){n&&a(3);return}return(b=r==null?void 0:r.start)==null||b.call(r,n),sr(t,{inFlight:p,prepare(){f.current?f.current=!1:f.current=p.current,p.current=!0,!f.current&&(n?(a(3),s(4)):(a(4),s(2)))},run(){f.current?n?(s(3),a(4)):(s(4),a(3)):n?s(1):a(1)},done(){var E;f.current&&typeof t.getAnimations=="function"&&t.getAnimations().length>0||(p.current=!1,s(7),n||i(!1),(E=r==null?void 0:r.end)==null||E.call(r,n))}})}},[e,n,t,w]),e?[l,{closed:u(1),enter:u(2),leave:u(4),transition:u(2)||u(4)}]:[n,{closed:void 0,enter:void 0,leave:void 0,transition:void 0}]}function sr(e,{prepare:t,run:n,done:r,inFlight:l}){let i=z();return ar(e,{prepare:t,inFlight:l}),i.nextFrame(()=>{n(),i.requestAnimationFrame(()=>{i.add(ur(e,r))})}),i.dispose}function ur(e,t){var n,r;let l=z();if(!e)return l.dispose;let i=!1;l.add(()=>{i=!0});let u=(r=(n=e.getAnimations)==null?void 0:n.call(e).filter(a=>a instanceof CSSTransition))!=null?r:[];return u.length===0?(t(),l.dispose):(Promise.allSettled(u.map(a=>a.finished)).then(()=>{i||t()}),l.dispose)}function ar(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 ot(e,t){let n=o.useRef([]),r=P(e);o.useEffect(()=>{let l=[...n.current];for(let[i,u]of t.entries())if(n.current[i]!==u){let a=r(t,l);return n.current=t,a}},[r,...t])}let Ne=o.createContext(null);Ne.displayName="OpenClosedContext";var U=(e=>(e[e.Open=1]="Open",e[e.Closed=2]="Closed",e[e.Closing=4]="Closing",e[e.Opening=8]="Opening",e))(U||{});function Ie(){return o.useContext(Ne)}function dr({value:e,children:t}){return o.createElement(Ne.Provider,{value:e},t)}function cr({children:e}){return o.createElement(Ne.Provider,{value:null},e)}function fr(e){function t(){document.readyState!=="loading"&&(e(),document.removeEventListener("DOMContentLoaded",t))}typeof window<"u"&&typeof document<"u"&&(document.addEventListener("DOMContentLoaded",t),t())}let Z=[];fr(()=>{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 Dt(e){let t=P(e),n=o.useRef(!1);o.useEffect(()=>(n.current=!1,()=>{n.current=!0,Pe(()=>{n.current&&t()})}),[t])}function mr(){let e=typeof document>"u";return"useSyncExternalStore"in ae?(t=>t.useSyncExternalStore)(ae)(()=>()=>{},()=>!1,()=>!e):!1}function ge(){let e=mr(),[t,n]=ae.useState(J.isHandoffComplete);return t&&J.isHandoffComplete===!1&&n(!1),ae.useEffect(()=>{t!==!0&&n(!0)},[t]),ae.useEffect(()=>J.handoff(),[]),e?!1:t}let jt=o.createContext(!1);function pr(){return o.useContext(jt)}function Ut(e){return o.createElement(jt.Provider,{value:e.force},e.children)}function hr(e){let t=pr(),n=o.useContext(Wt),r=ve(e),[l,i]=o.useState(()=>{var u;if(!t&&n!==null)return(u=n.current)!=null?u:null;if(J.isServer)return null;let a=r==null?void 0:r.getElementById("headlessui-portal-root");if(a)return a;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 Ht=o.Fragment,vr=I(function(e,t){let n=e,r=o.useRef(null),l=B(On(w=>{r.current=w}),t),i=ve(r),u=hr(r),[a]=o.useState(()=>{var w;return J.isServer?null:(w=i==null?void 0:i.createElement("div"))!=null?w:null}),s=o.useContext(it),p=ge();k(()=>{!u||!a||u.contains(a)||(a.setAttribute("data-headlessui-portal",""),u.appendChild(a))},[u,a]),k(()=>{if(a&&s)return s.register(a)},[s,a]),Dt(()=>{var w;!u||!a||(a instanceof Node&&u.contains(a)&&u.removeChild(a),u.childNodes.length<=0&&((w=u.parentElement)==null||w.removeChild(u)))});let f=j();return p?!u||!a?null:ln.createPortal(f({ourProps:{ref:l},theirProps:n,slot:{},defaultTag:Ht,name:"Portal"}),a):null});function gr(e,t){let n=B(t),{enabled:r=!0,...l}=e,i=j();return r?o.createElement(vr,{...l,ref:n}):i({ourProps:{ref:n},theirProps:l,slot:{},defaultTag:Ht,name:"Portal"})}let wr=o.Fragment,Wt=o.createContext(null);function Er(e,t){let{target:n,...r}=e,l={ref:B(t)},i=j();return o.createElement(Wt.Provider,{value:n},i({ourProps:l,theirProps:r,defaultTag:wr,name:"Popover.Group"}))}let it=o.createContext(null);function yr(){let e=o.useContext(it),t=o.useRef([]),n=P(i=>(t.current.push(i),e&&e.register(i),()=>r(i))),r=P(i=>{let u=t.current.indexOf(i);u!==-1&&t.current.splice(u,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(it.Provider,{value:l},i)},[l])]}let br=I(gr),_t=I(Er),xr=Object.assign(br,{Group:_t});function $r(e,t=typeof document<"u"?document.defaultView:null,n){let r=se(e,"escape");Nt(t,"keydown",l=>{r&&(l.defaultPrevented||l.key===Mt.Escape&&n(l))})}function Mr(){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 k(()=>{if(!t)return;function l(i){r(i.matches)}return t.addEventListener("change",l),()=>t.removeEventListener("change",l)},[t]),n}function Sr({defaultContainers:e=[],portals:t,mainTreeNode:n}={}){let r=ve(n),l=P(()=>{var i,u;let a=[];for(let s of e)s!==null&&(s instanceof HTMLElement?a.push(s):"current"in s&&s.current instanceof HTMLElement&&a.push(s.current));if(t!=null&&t.current)for(let s of t.current)a.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((u=n==null?void 0:n.getRootNode())==null?void 0:u.host))||a.some(p=>s.contains(p))||a.push(s));return a});return{resolveContainers:l,contains:P(i=>l().some(u=>u.contains(i)))}}let Bt=o.createContext(null);function qt({children:e,node:t}){let[n,r]=o.useState(null),l=Vt(t??n);return o.createElement(Bt.Provider,{value:l},e,l===null&&o.createElement(tt,{features:Le.Hidden,ref:i=>{var u,a;if(i){for(let s of(a=(u=Oe(i))==null?void 0:u.querySelectorAll("html > *, body > *"))!=null?a:[])if(s!==document.body&&s!==document.head&&s instanceof HTMLElement&&s!=null&&s.contains(i)){r(s);break}}}}))}function Vt(e=null){var t;return(t=o.useContext(Bt))!=null?t:e}function st(){let e=o.useRef(!1);return k(()=>(e.current=!0,()=>{e.current=!1}),[]),e}var we=(e=>(e[e.Forwards=0]="Forwards",e[e.Backwards=1]="Backwards",e))(we||{});function Cr(){let e=o.useRef(0);return Lt(!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 Or="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 Pr(e,t){let n=o.useRef(null),r=B(n,t),{initialFocus:l,initialFocusFallback:i,containers:u,features:a=15,...s}=e;ge()||(a=0);let p=ve(n);kr(a,{ownerDocument:p});let f=Nr(a,{ownerDocument:p,container:n,initialFocus:l,initialFocusFallback:i});Ir(a,{ownerDocument:p,container:n,containers:u,previousActiveElement:f});let w=Cr(),b=P(d=>{let g=n.current;g&&(y=>y())(()=>{G(w.current,{[we.Forwards]:()=>{pe(g,X.First,{skipElements:[d.relatedTarget,i]})},[we.Backwards]:()=>{pe(g,X.Last,{skipElements:[d.relatedTarget,i]})}})})}),E=se(!!(a&2),"focus-trap#tab-lock"),m=Qe(),x=o.useRef(!1),v={ref:r,onKeyDown(d){d.key=="Tab"&&(x.current=!0,m.requestAnimationFrame(()=>{x.current=!1}))},onBlur(d){if(!(a&4))return;let g=Xt(u);n.current instanceof HTMLElement&&g.add(n.current);let y=d.relatedTarget;y instanceof HTMLElement&&y.dataset.headlessuiFocusGuard!=="true"&&(Yt(g,y)||(x.current?pe(n.current,G(w.current,{[we.Forwards]:()=>X.Next,[we.Backwards]:()=>X.Previous})|X.WrapAround,{relativeTo:d.target}):d.target instanceof HTMLElement&&Y(d.target)))}},c=j();return o.createElement(o.Fragment,null,E&&o.createElement(tt,{as:"button",type:"button","data-headlessui-focus-guard":!0,onFocus:b,features:Le.Focusable}),c({ourProps:v,theirProps:s,defaultTag:Or,name:"FocusTrap"}),E&&o.createElement(tt,{as:"button",type:"button","data-headlessui-focus-guard":!0,onFocus:b,features:Le.Focusable}))}let Tr=I(Pr),Fr=Object.assign(Tr,{features:te});function Lr(e=!0){let t=o.useRef(Z.slice());return ot(([n],[r])=>{r===!0&&n===!1&&Pe(()=>{t.current.splice(0)}),r===!1&&n===!0&&(t.current=Z.slice())},[e,Z,t]),P(()=>{var n;return(n=t.current.find(r=>r!=null&&r.isConnected))!=null?n:null})}function kr(e,{ownerDocument:t}){let n=!!(e&8),r=Lr(n);ot(()=>{n||(t==null?void 0:t.activeElement)===(t==null?void 0:t.body)&&Y(r())},[n]),Dt(()=>{n&&Y(r())})}function Nr(e,{ownerDocument:t,container:n,initialFocus:r,initialFocusFallback:l}){let i=o.useRef(null),u=se(!!(e&1),"focus-trap#initial-focus"),a=st();return ot(()=>{if(e===0)return;if(!u){l!=null&&l.current&&Y(l.current);return}let s=n.current;s&&Pe(()=>{if(!a.current)return;let p=t==null?void 0:t.activeElement;if(r!=null&&r.current){if((r==null?void 0:r.current)===p){i.current=p;return}}else if(s.contains(p)){i.current=p;return}if(r!=null&&r.current)Y(r.current);else{if(e&16){if(pe(s,X.First|X.AutoFocus)!==lt.Error)return}else if(pe(s,X.First)!==lt.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,u,e]),i}function Ir(e,{ownerDocument:t,container:n,containers:r,previousActiveElement:l}){let i=st(),u=!!(e&4);Nt(t==null?void 0:t.defaultView,"focus",a=>{if(!u||!i.current)return;let s=Xt(r);n.current instanceof HTMLElement&&s.add(n.current);let p=l.current;if(!p)return;let f=a.target;f&&f instanceof HTMLElement?Yt(s,f)?(l.current=f,Y(f)):(a.preventDefault(),a.stopPropagation(),Y(p)):Y(l.current)},!0)}function Yt(e,t){for(let n of e)if(n.contains(t))return!0;return!1}function zt(e){var t;return!!(e.enter||e.enterFrom||e.enterTo||e.leave||e.leaveFrom||e.leaveTo)||((t=e.as)!=null?t:Kt)!==o.Fragment||o.Children.count(e.children)===1}let Ae=o.createContext(null);Ae.displayName="TransitionContext";var Ar=(e=>(e.Visible="visible",e.Hidden="hidden",e))(Ar||{});function Dr(){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 jr(){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 Gt(e,t){let n=Q(e),r=o.useRef([]),l=st(),i=Qe(),u=P((E,m=K.Hidden)=>{let x=r.current.findIndex(({el:v})=>v===E);x!==-1&&(G(m,{[K.Unmount](){r.current.splice(x,1)},[K.Hidden](){r.current[x].state="hidden"}}),i.microTask(()=>{var v;!je(r)&&l.current&&((v=n.current)==null||v.call(n))}))}),a=P(E=>{let m=r.current.find(({el:x})=>x===E);return m?m.state!=="visible"&&(m.state="visible"):r.current.push({el:E,state:"visible"}),()=>u(E,K.Unmount)}),s=o.useRef([]),p=o.useRef(Promise.resolve()),f=o.useRef({enter:[],leave:[]}),w=P((E,m,x)=>{s.current.splice(0),t&&(t.chains.current[m]=t.chains.current[m].filter(([v])=>v!==E)),t==null||t.chains.current[m].push([E,new Promise(v=>{s.current.push(v)})]),t==null||t.chains.current[m].push([E,new Promise(v=>{Promise.all(f.current[m].map(([c,d])=>d)).then(()=>v())})]),m==="enter"?p.current=p.current.then(()=>t==null?void 0:t.wait.current).then(()=>x(m)):x(m)}),b=P((E,m,x)=>{Promise.all(f.current[m].splice(0).map(([v,c])=>c)).then(()=>{var v;(v=s.current.shift())==null||v()}).then(()=>x(m))});return o.useMemo(()=>({children:r,register:a,unregister:u,onStart:w,onStop:b,wait:p,chains:f}),[a,u,r,w,b,f,p])}let Kt=o.Fragment,Zt=Te.RenderStrategy;function Ur(e,t){var n,r;let{transition:l=!0,beforeEnter:i,afterEnter:u,beforeLeave:a,afterLeave:s,enter:p,enterFrom:f,enterTo:w,entered:b,leave:E,leaveFrom:m,leaveTo:x,...v}=e,[c,d]=o.useState(null),g=o.useRef(null),y=zt(e),h=B(...y?[g,t,d]:t===null?[]:[t]),$=(n=v.unmount)==null||n?K.Unmount:K.Hidden,{show:C,appear:T,initial:q}=Dr(),[F,D]=o.useState(C?"visible":"hidden"),H=jr(),{register:W,unregister:O}=H;k(()=>W(g),[W,g]),k(()=>{if($===K.Hidden&&g.current){if(C&&F!=="visible"){D("visible");return}return G(F,{hidden:()=>O(g),visible:()=>W(g)})}},[F,g,W,O,C,$]);let N=ge();k(()=>{if(y&&N&&F==="visible"&&g.current===null)throw new Error("Did you forget to passthrough the `ref` to the actual DOM node?")},[g,F,N,y]);let He=q&&!T,We=T&&C&&q,Ee=o.useRef(!1),V=Gt(()=>{Ee.current||(D("hidden"),O(g))},H),_e=P(ct=>{Ee.current=!0;let qe=ct?"enter":"leave";V.onStart(g,qe,be=>{be==="enter"?i==null||i():be==="leave"&&(a==null||a())})}),L=P(ct=>{let qe=ct?"enter":"leave";Ee.current=!1,V.onStop(g,qe,be=>{be==="enter"?u==null||u():be==="leave"&&(s==null||s())}),qe==="leave"&&!je(V)&&(D("hidden"),O(g))});o.useEffect(()=>{y&&l||(_e(C),L(C))},[C,y,l]);let Be=!(!l||!y||!N||He),[,A]=ir(Be,c,C,{start:_e,end:L}),sl=R({ref:h,className:((r=Re(v.className,We&&p,We&&f,A.enter&&p,A.enter&&A.closed&&f,A.enter&&!A.closed&&w,A.leave&&E,A.leave&&!A.closed&&m,A.leave&&A.closed&&x,!A.transition&&C&&b))==null?void 0:r.trim())||void 0,...or(A)}),ye=0;F==="visible"&&(ye|=U.Open),F==="hidden"&&(ye|=U.Closed),A.enter&&(ye|=U.Opening),A.leave&&(ye|=U.Closing);let ul=j();return o.createElement(De.Provider,{value:V},o.createElement(dr,{value:ye},ul({ourProps:sl,theirProps:v,defaultTag:Kt,features:Zt,visible:F==="visible",name:"Transition.Child"})))}function Hr(e,t){let{show:n,appear:r=!1,unmount:l=!0,...i}=e,u=o.useRef(null),a=zt(e),s=B(...a?[u,t]:t===null?[]:[t]);ge();let p=Ie();if(n===void 0&&p!==null&&(n=(p&U.Open)===U.Open),n===void 0)throw new Error("A <Transition /> is used but it is missing a `show={true | false}` prop.");let[f,w]=o.useState(n?"visible":"hidden"),b=Gt(()=>{n||w("hidden")}),[E,m]=o.useState(!0),x=o.useRef([n]);k(()=>{E!==!1&&x.current[x.current.length-1]!==n&&(x.current.push(n),m(!1))},[x,n]);let v=o.useMemo(()=>({show:n,appear:r,initial:E}),[n,r,E]);k(()=>{n?w("visible"):!je(b)&&u.current!==null&&w("hidden")},[n,b]);let c={unmount:l},d=P(()=>{var h;E&&m(!1),(h=e.beforeEnter)==null||h.call(e)}),g=P(()=>{var h;E&&m(!1),(h=e.beforeLeave)==null||h.call(e)}),y=j();return o.createElement(De.Provider,{value:b},o.createElement(Ae.Provider,{value:v},y({ourProps:{...c,as:o.Fragment,children:o.createElement(Jt,{ref:s,...c,...i,beforeEnter:d,beforeLeave:g})},theirProps:{},defaultTag:o.Fragment,features:Zt,visible:f==="visible",name:"Transition"})))}function Wr(e,t){let n=o.useContext(Ae)!==null,r=Ie()!==null;return o.createElement(o.Fragment,null,!n&&r?o.createElement(ut,{ref:t,...e}):o.createElement(Jt,{ref:t,...e}))}let ut=I(Hr),Jt=I(Ur),ue=I(Wr),Qt=Object.assign(ut,{Child:ue,Root:ut});var _r=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(_r||{}),Br=(e=>(e[e.SetTitleId=0]="SetTitleId",e))(Br||{});let qr={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 Vr(e,t){return G(t.type,qr,e,t)}let Rt=I(function(e,t){let n=o.useId(),{id:r=`headlessui-dialog-${n}`,open:l,onClose:i,initialFocus:u,role:a="dialog",autoFocus:s=!0,__demoMode:p=!1,unmount:f=!1,...w}=e,b=o.useRef(!1);a=function(){return a==="dialog"||a==="alertdialog"?a:(b.current||(b.current=!0,console.warn(`Invalid role [${a}] passed to <Dialog />. Only \`dialog\` and and \`alertdialog\` are supported. Using \`dialog\` instead.`)),"dialog")}();let E=Ie();l===void 0&&E!==null&&(l=(E&U.Open)===U.Open);let m=o.useRef(null),x=B(m,t),v=ve(m),c=l?0:1,[d,g]=o.useReducer(Vr,{titleId:null,descriptionId:null,panelRef:o.createRef()}),y=P(()=>i(!1)),h=P(L=>g({type:0,id:L})),$=ge()?c===0:!1,[C,T]=yr(),q={get current(){var L;return(L=d.panelRef.current)!=null?L:m.current}},F=Vt(),{resolveContainers:D}=Sr({mainTreeNode:F,portals:C,defaultContainers:[q]}),H=E!==null?(E&U.Closing)===U.Closing:!1;jn(p||H?!1:$,{allowed:P(()=>{var L,Be;return[(Be=(L=m.current)==null?void 0:L.closest("[data-headlessui-portal]"))!=null?Be:null]}),disallowed:P(()=>{var L;return[(L=F==null?void 0:F.closest("body > *:not(#headlessui-portal-root)"))!=null?L:null]})}),Zn($,D,L=>{L.preventDefault(),y()}),$r($,v==null?void 0:v.defaultView,L=>{L.preventDefault(),L.stopPropagation(),document.activeElement&&"blur"in document.activeElement&&typeof document.activeElement.blur=="function"&&document.activeElement.blur(),y()}),nr(p||H?!1:$,v,D),Un($,m,y);let[W,O]=Pn(),N=o.useMemo(()=>[{dialogState:c,close:y,setTitleId:h,unmount:f},d],[c,d,y,h,f]),He=o.useMemo(()=>({open:c===0}),[c]),We={ref:x,id:r,role:a,tabIndex:-1,"aria-modal":p?void 0:c===0?!0:void 0,"aria-labelledby":d.titleId,"aria-describedby":W,unmount:f},Ee=!Mr(),V=te.None;$&&!p&&(V|=te.RestoreFocus,V|=te.TabLock,s&&(V|=te.AutoFocus),Ee&&(V|=te.InitialFocus));let _e=j();return o.createElement(cr,null,o.createElement(Ut,{force:!0},o.createElement(xr,null,o.createElement(at.Provider,{value:N},o.createElement(_t,{target:m},o.createElement(Ut,{force:!1},o.createElement(O,{slot:He},o.createElement(T,null,o.createElement(Fr,{initialFocus:u,initialFocusFallback:m,containers:D,features:V},o.createElement(In,{value:y},_e({ourProps:We,theirProps:w,slot:He,defaultTag:Xr,features:Yr,visible:c===0,name:"Dialog"})))))))))))}),Xr="div",Yr=Te.RenderStrategy|Te.Static;function zr(e,t){let{transition:n=!1,open:r,...l}=e,i=Ie(),u=e.hasOwnProperty("open")||i!==null,a=e.hasOwnProperty("onClose");if(!u&&!a)throw new Error("You have to provide an `open` and an `onClose` prop to the `Dialog` component.");if(!u)throw new Error("You provided an `onClose` prop to the `Dialog`, but forgot an `open` prop.");if(!a)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(qt,null,o.createElement(Qt,{show:r,transition:n,unmount:l.unmount},o.createElement(Rt,{ref:t,...l}))):o.createElement(qt,null,o.createElement(Rt,{ref:t,open:r,...l}))}let Gr="div";function Kr(e,t){let n=o.useId(),{id:r=`headlessui-dialog-panel-${n}`,transition:l=!1,...i}=e,[{dialogState:u,unmount:a},s]=Ue("Dialog.Panel"),p=B(t,s.panelRef),f=o.useMemo(()=>({open:u===0}),[u]),w=P(v=>{v.stopPropagation()}),b={ref:p,id:r,onClick:w},E=l?ue:o.Fragment,m=l?{unmount:a}:{},x=j();return o.createElement(E,{...m},x({ourProps:b,theirProps:i,slot:f,defaultTag:Gr,name:"Dialog.Panel"}))}let Zr="div";function Jr(e,t){let{transition:n=!1,...r}=e,[{dialogState:l,unmount:i}]=Ue("Dialog.Backdrop"),u=o.useMemo(()=>({open:l===0}),[l]),a={ref:t,"aria-hidden":!0},s=n?ue:o.Fragment,p=n?{unmount:i}:{},f=j();return o.createElement(s,{...p},f({ourProps:a,theirProps:r,slot:u,defaultTag:Zr,name:"Dialog.Backdrop"}))}let Qr="h2";function Rr(e,t){let n=o.useId(),{id:r=`headlessui-dialog-title-${n}`,...l}=e,[{dialogState:i,setTitleId:u}]=Ue("Dialog.Title"),a=B(t);o.useEffect(()=>(u(r),()=>u(null)),[r,u]);let s=o.useMemo(()=>({open:i===0}),[i]),p={ref:a,id:r};return j()({ourProps:p,theirProps:l,slot:s,defaultTag:Qr,name:"Dialog.Title"})}let el=I(zr),dt=I(Kr);I(Jr);let tl=I(Rr),nl=Object.assign(el,{Panel:dt,Title:tl,Description:kn});function en({onClick:e}){return M.jsxs("button",{type:"button",className:"im-close-button text-gray-400 hover:text-gray-500",onClick:e,children:[M.jsx("span",{className:"sr-only",children:"Close"}),M.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:M.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})]})}const rl=({modalContext:e,config:t,children:n})=>{const[r,l]=o.useState(!1);return M.jsx("div",{className:"im-modal-container fixed inset-0 z-40 overflow-y-auto p-4",children:M.jsx("div",{className:Ce("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:M.jsx(ue,{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:Ce("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:M.jsxs(dt,{className:`im-modal-content relative ${t.paddingClasses} ${t.panelClasses}`,"data-inertiaui-modal-entered":r,children:[t.closeButton&&M.jsx("div",{className:"absolute right-0 top-0 pr-3 pt-3",children:M.jsx(en,{onClick:e.close})}),typeof n=="function"?n({modalContext:e,config:t}):n]})})})})},ll=({modalContext:e,config:t,children:n})=>{const[r,l]=o.useState(!1);return M.jsx("div",{className:"im-slideover-container fixed inset-0 z-40 overflow-y-auto overflow-x-hidden",children:M.jsx("div",{className:Ce("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:M.jsx(ue,{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:Ce("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:M.jsxs(dt,{className:`im-slideover-content relative ${t.paddingClasses} ${t.panelClasses}`,"data-inertiaui-modal-entered":r,children:[t.closeButton&&M.jsx("div",{className:"absolute right-0 top-0 pr-3 pt-3",children:M.jsx(en,{onClick:e.close})}),typeof n=="function"?n({modalContext:e,config:t}):n]})})})})},tn=o.forwardRef(({name:e,children:t,onFocus:n=null,onBlur:r=null,onClose:l=null,onSuccess:i=null,onAfterLeave:u=null,...a},s)=>{const p=w=>typeof t=="function"?t(w):t,f=o.useRef(null);return o.useImperativeHandle(s,()=>f.current,[f]),M.jsx(Ze,{ref:f,name:e,onFocus:n,onBlur:r,onClose:l,onSuccess:i,...a,children:({afterLeave:w,close:b,config:E,emit:m,getChildModal:x,getParentModal:v,id:c,index:d,isOpen:g,modalContext:y,onTopOfStack:h,reload:$,setOpen:C,shouldRender:T})=>M.jsx(Qt,{appear:!0,show:g??!1,afterLeave:u,children:M.jsxs(nl,{as:"div",className:"im-dialog relative z-20",onClose:()=>E.closeExplicitly?null:b(),"data-inertiaui-modal-id":c,"data-inertiaui-modal-index":d,children:[d===0?M.jsx(ue,{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:h?M.jsx("div",{className:"im-backdrop fixed inset-0 z-30 bg-black/75","aria-hidden":"true"}):M.jsx("div",{})}):null,d>0&&h?M.jsx("div",{className:"im-backdrop fixed inset-0 z-30 bg-black/75"}):null,E.slideover?M.jsx(ll,{modalContext:y,config:E,children:p({afterLeave:w,close:b,config:E,emit:m,getChildModal:x,getParentModal:v,id:c,index:d,isOpen:g,modalContext:y,onTopOfStack:h,reload:$,setOpen:C,shouldRender:T})}):M.jsx(rl,{modalContext:y,config:E,children:p({afterLeave:w,close:b,config:E,emit:m,getChildModal:x,getParentModal:v,id:c,index:d,isOpen:g,modalContext:y,onTopOfStack:h,reload:$,setOpen:C,shouldRender:T})})]})})})});tn.displayName="Modal";const ol=({href:e,method:t="get",data:n={},as:r="a",headers:l={},queryStringArrayFormat:i="brackets",onAfterLeave:u=null,onBlur:a=null,onClose:s=null,onError:p=null,onFocus:f=null,onStart:w=null,onSuccess:b=null,navigate:E=null,children:m,...x})=>{const[v,c]=o.useState(!1),[d,g]=o.useState(null),{stack:y,visit:h}=fe(),$=o.useMemo(()=>E??Me("navigate"),[E]),C={},T={};Object.keys(x).forEach(O=>{ht.includes(O)||(O.startsWith("on")&&typeof x[O]=="function"?O.toLowerCase()in window?C[O]=x[O]:T[O]=x[O]:C[O]=x[O])});const[q,F]=o.useState(!1);o.useEffect(()=>{d&&(d.onTopOfStack&&q?f==null||f():!d.onTopOfStack&&!q&&(a==null||a()),F(!d.onTopOfStack))},[y]);const D=o.useCallback(()=>{s==null||s()},[s]),H=o.useCallback(()=>{g(null),u==null||u()},[u]),W=o.useCallback(O=>{O==null||O.preventDefault(),!v&&(e.startsWith("#")||(c(!0),w==null||w()),h(e,t,n,l,mn(fn(x,ht)),()=>D(y.length),H,i,$).then(N=>{g(N),N.registerEventListenersFromProps(T),b==null||b()}).catch(N=>{console.error(N),p==null||p(N)}).finally(()=>c(!1)))},[e,t,n,l,i,x,D,H]);return M.jsx(r,{...C,href:e,onClick:W,children:typeof m=="function"?m({loading:v}):m})},nn=({children:e,data:t,params:n,buffer:r,as:l,always:i,fallback:u})=>{i=i??!1,l=l??"div",u=u??null;const[a,s]=o.useState(!1),p=o.useRef(!1),f=o.useRef(!1),w=o.useRef(null),b=Ke(),E=o.useCallback(()=>{if(t)return{only:Array.isArray(t)?t:[t]};if(!n)throw new Error("You must provide either a `data` or `params` prop.");return n},[n,t]);return o.useEffect(()=>{if(!w.current)return;const m=new IntersectionObserver(x=>{if(!x[0].isIntersecting||(!i&&p.current&&m.disconnect(),f.current))return;p.current=!0,f.current=!0;const v=E();b.reload({...v,onStart:c=>{var d;f.current=!0,(d=v.onStart)==null||d.call(v,c)},onFinish:c=>{var d;s(!0),f.current=!1,(d=v.onFinish)==null||d.call(v,c),i||m.disconnect()}})},{rootMargin:`${r||0}px`});return m.observe(w.current),()=>{m.disconnect()}},[w,E,r]),i||!a?o.createElement(l,{props:null,ref:w},a?e:u):a?e:null};nn.displayName="InertiaWhenVisible";const il=e=>t=>(t.default.layout=n=>o.createElement(e,{},n),t);S.Deferred=Et,S.HeadlessModal=Ze,S.Modal=tn,S.ModalLink=ol,S.ModalRoot=gt,S.ModalStackProvider=pt,S.WhenVisible=nn,S.getConfig=Me,S.initFromPageProps=vt,S.putConfig=an,S.renderApp=hn,S.resetConfig=un,S.setPageLayout=il,S.useModal=Ke,S.useModalIndex=Ge,S.useModalStack=fe,Object.defineProperty(S,Symbol.toStringTag,{value:"Module"})});
|
|
4
|
+
`))}else{let E=h.props,w=E==null?void 0:E.className,m=typeof w=="function"?(...c)=>st(w(...c),s.className):st(w,s.className),$=m?{className:m}:{},v=It(h.props,ne(ut(s,["ref"])));for(let c in b)c in v&&delete b[c];return o.cloneElement(h,Object.assign({},v,b,d,{ref:l(Gr(h),d.ref)},$))}return o.createElement(i,Object.assign({},ut(s,["ref"]),i!==o.Fragment&&d,i!==o.Fragment&&b),h)}function Xr(){let e=o.useRef([]),t=o.useCallback(r=>{for(let n of e.current)n!=null&&(typeof n=="function"?n(r):n.current=r)},[]);return(...r)=>{if(!r.every(n=>n==null))return e.current=r,t}}function zr(...e){return e.every(t=>t==null)?void 0:t=>{for(let r of e)r!=null&&(typeof r=="function"?r(t):r.current=t)}}function It(...e){if(e.length===0)return{};if(e.length===1)return e[0];let t={},r={};for(let n of e)for(let l in n)l.startsWith("on")&&typeof n[l]=="function"?(r[l]!=null||(r[l]=[]),r[l].push(n[l])):t[l]=n[l];if(t.disabled||t["aria-disabled"])for(let n in r)/^(on(?:Click|Pointer|Mouse|Key)(?:Down|Up|Press)?)$/.test(n)&&(r[n]=[l=>{var i;return(i=l==null?void 0:l.preventDefault)==null?void 0:i.call(l)}]);for(let n in r)Object.assign(t,{[n](l,...i){let a=r[n];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 D(e){var t;return Object.assign(o.forwardRef(e),{displayName:(t=e.displayName)!=null?t:e.name})}function ne(e){let t=Object.assign({},e);for(let r in t)t[r]===void 0&&delete t[r];return t}function ut(e,t=[]){let r=Object.assign({},e);for(let n of t)n in r&&delete r[n];return r}function Gr(e){return o.version.split(".")[0]>="19"?e.props.ref:e.ref}let Kr="span";var We=(e=>(e[e.None=1]="None",e[e.Focusable=2]="Focusable",e[e.Hidden=4]="Hidden",e))(We||{});function Yr(e,t){var r;let{features:n=1,...l}=e,i={ref:t,"aria-hidden":(n&2)===2?!0:(r=l["aria-hidden"])!=null?r:void 0,hidden:(n&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",...(n&4)===4&&(n&2)!==2&&{display:"none"}}};return W()({ourProps:i,theirProps:l,slot:{},defaultTag:Kr,name:"Hidden"})}let at=D(Yr);function Nt(e){return typeof e!="object"||e===null?!1:"nodeType"in e}function J(e){return Nt(e)&&"tagName"in e}function le(e){return J(e)&&"accessKey"in e}function Q(e){return J(e)&&"tabIndex"in e}function Zr(e){return J(e)&&"style"in e}function Jr(e){return le(e)&&e.nodeName==="IFRAME"}function Qr(e){return le(e)&&e.nodeName==="INPUT"}let Dt=Symbol();function Rr(e,t=!0){return Object.assign(e,{[Dt]:t})}function q(...e){let t=o.useRef(e);o.useEffect(()=>{t.current=e},[e]);let r=P(n=>{for(let l of t.current)l!=null&&(typeof l=="function"?l(n):l.current=n)});return e.every(n=>n==null||(n==null?void 0:n[Dt]))?void 0:r}let dt=o.createContext(null);dt.displayName="DescriptionContext";function jt(){let e=o.useContext(dt);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,jt),t}return e}function en(){let[e,t]=o.useState([]);return[e.length>0?e.join(" "):void 0,o.useMemo(()=>function(r){let n=P(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:n,slot:r.slot,name:r.name,props:r.props,value:r.value}),[n,r.slot,r.name,r.props,r.value]);return o.createElement(dt.Provider,{value:l},r.children)},[t])]}let tn="p";function rn(e,t){let r=o.useId(),n=Br(),{id:l=`headlessui-description-${r}`,...i}=e,a=jt(),u=q(t);N(()=>a.register(l),[l,a.register]);let s=n||!1,d=o.useMemo(()=>({...a.slot,disabled:s}),[a.slot,s]),h={ref:u,...a.props,id:l};return W()({ourProps:h,theirProps:i,slot:d,defaultTag:tn,name:a.name||"Description"})}let nn=D(rn),ln=Object.assign(nn,{});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 on=o.createContext(()=>{});function sn({value:e,children:t}){return o.createElement(on.Provider,{value:e},t)}let Wt=class extends Map{constructor(t){super(),this.factory=t}get(t){let r=super.get(t);return r===void 0&&(r=this.factory(t),this.set(t,r)),r}};var un=Object.defineProperty,an=(e,t,r)=>t in e?un(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,dn=(e,t,r)=>(an(e,t+"",r),r),Ut=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},U=(e,t,r)=>(Ut(e,t,"read from private field"),r?r.call(e):t.get(e)),ct=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},Ht=(e,t,r,n)=>(Ut(e,t,"write to private field"),t.set(e,r),r),X,ye,Ee;let cn=class{constructor(t){ct(this,X,{}),ct(this,ye,new Wt(()=>new Set)),ct(this,Ee,new Set),dn(this,"disposables",z()),Ht(this,X,t)}dispose(){this.disposables.dispose()}get state(){return U(this,X)}subscribe(t,r){let n={selector:t,callback:r,current:t(U(this,X))};return U(this,Ee).add(n),this.disposables.add(()=>{U(this,Ee).delete(n)})}on(t,r){return U(this,ye).get(t).add(r),this.disposables.add(()=>{U(this,ye).get(t).delete(r)})}send(t){let r=this.reduce(U(this,X),t);if(r!==U(this,X)){Ht(this,X,r);for(let n of U(this,Ee)){let l=n.selector(U(this,X));Vt(n.current,l)||(n.current=l,n.callback(l))}for(let n of U(this,ye).get(t.type))n(U(this,X),t)}}};X=new WeakMap,ye=new WeakMap,Ee=new WeakMap;function Vt(e,t){return Object.is(e,t)?!0:typeof e!="object"||e===null||typeof t!="object"||t===null?!1:Array.isArray(e)&&Array.isArray(t)?e.length!==t.length?!1:ft(e[Symbol.iterator](),t[Symbol.iterator]()):e instanceof Map&&t instanceof Map||e instanceof Set&&t instanceof Set?e.size!==t.size?!1:ft(e.entries(),t.entries()):Bt(e)&&Bt(t)?ft(Object.entries(e)[Symbol.iterator](),Object.entries(t)[Symbol.iterator]()):!1}function ft(e,t){do{let r=e.next(),n=t.next();if(r.done&&n.done)return!0;if(r.done||n.done||!Object.is(r.value,n.value))return!1}while(!0)}function Bt(e){if(Object.prototype.toString.call(e)!=="[object Object]")return!1;let t=Object.getPrototypeOf(e);return t===null||Object.getPrototypeOf(t)===null}var fn=Object.defineProperty,mn=(e,t,r)=>t in e?fn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,qt=(e,t,r)=>(mn(e,typeof t!="symbol"?t+"":t,r),r),pn=(e=>(e[e.Push=0]="Push",e[e.Pop=1]="Pop",e))(pn||{});let hn={0(e,t){let r=t.id,n=e.stack,l=e.stack.indexOf(r);if(l!==-1){let i=e.stack.slice();return i.splice(l,1),i.push(r),n=i,{...e,stack:n}}return{...e,stack:[...e.stack,r]}},1(e,t){let r=t.id,n=e.stack.indexOf(r);if(n===-1)return e;let l=e.stack.slice();return l.splice(n,1),{...e,stack:l}}},vn=class Cr extends cn{constructor(){super(...arguments),qt(this,"actions",{push:t=>this.send({type:0,id:t}),pop:t=>this.send({type:1,id:t})}),qt(this,"selectors",{isTop:(t,r)=>t.stack[t.stack.length-1]===r,inStack:(t,r)=>t.stack.includes(r)})}static new(){return new Cr({stack:[]})}reduce(t,r){return G(r.type,hn,t,r)}};const Xt=new Wt(()=>vn.new());var Ue={exports:{}},mt={};/**
|
|
5
|
+
* @license React
|
|
6
|
+
* use-sync-external-store-with-selector.production.js
|
|
7
|
+
*
|
|
8
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
9
|
+
*
|
|
10
|
+
* This source code is licensed under the MIT license found in the
|
|
11
|
+
* LICENSE file in the root directory of this source tree.
|
|
12
|
+
*/var zt;function gn(){if(zt)return mt;zt=1;var e=o;function t(s,d){return s===d&&(s!==0||1/s===1/d)||s!==s&&d!==d}var r=typeof Object.is=="function"?Object.is:t,n=e.useSyncExternalStore,l=e.useRef,i=e.useEffect,a=e.useMemo,u=e.useDebugValue;return mt.useSyncExternalStoreWithSelector=function(s,d,h,b,E){var w=l(null);if(w.current===null){var m={hasValue:!1,value:null};w.current=m}else m=w.current;w=a(function(){function v(p){if(!c){if(c=!0,f=p,p=b(p),E!==void 0&&m.hasValue){var x=m.value;if(E(x,p))return g=x}return g=p}if(x=g,r(f,p))return x;var S=b(p);return E!==void 0&&E(x,S)?(f=p,x):(f=p,g=S)}var c=!1,f,g,y=h===void 0?null:h;return[function(){return v(d())},y===null?void 0:function(){return v(y())}]},[d,h,b,E]);var $=n(s,w[0],w[1]);return i(function(){m.hasValue=!0,m.value=$},[$]),u($),$},mt}var pt={};/**
|
|
13
|
+
* @license React
|
|
14
|
+
* use-sync-external-store-with-selector.development.js
|
|
15
|
+
*
|
|
16
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
17
|
+
*
|
|
18
|
+
* This source code is licensed under the MIT license found in the
|
|
19
|
+
* LICENSE file in the root directory of this source tree.
|
|
20
|
+
*/var Gt;function wn(){return Gt||(Gt=1,process.env.NODE_ENV!=="production"&&function(){function e(s,d){return s===d&&(s!==0||1/s===1/d)||s!==s&&d!==d}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var t=o,r=typeof Object.is=="function"?Object.is:e,n=t.useSyncExternalStore,l=t.useRef,i=t.useEffect,a=t.useMemo,u=t.useDebugValue;pt.useSyncExternalStoreWithSelector=function(s,d,h,b,E){var w=l(null);if(w.current===null){var m={hasValue:!1,value:null};w.current=m}else m=w.current;w=a(function(){function v(p){if(!c){if(c=!0,f=p,p=b(p),E!==void 0&&m.hasValue){var x=m.value;if(E(x,p))return g=x}return g=p}if(x=g,r(f,p))return x;var S=b(p);return E!==void 0&&E(x,S)?(f=p,x):(f=p,g=S)}var c=!1,f,g,y=h===void 0?null:h;return[function(){return v(d())},y===null?void 0:function(){return v(y())}]},[d,h,b,E]);var $=n(s,w[0],w[1]);return i(function(){m.hasValue=!0,m.value=$},[$]),u($),$},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),pt}var Kt;function bn(){return Kt||(Kt=1,process.env.NODE_ENV==="production"?Ue.exports=gn():Ue.exports=wn()),Ue.exports}var yn=bn();function Yt(e,t,r=Vt){return yn.useSyncExternalStoreWithSelector(P(n=>e.subscribe(En,n)),P(()=>e.state),P(()=>e.state),P(t),r)}function En(e){return e}function xe(e,t){let r=o.useId(),n=Xt.get(t),[l,i]=Yt(n,o.useCallback(a=>[n.selectors.isTop(a,r),n.selectors.inStack(a,r)],[n,r]));return N(()=>{if(e)return n.actions.push(r),()=>n.actions.pop(r)},[n,e,r]),e?i?l:!0:!1}let ht=new Map,$e=new Map;function Zt(e){var t;let r=(t=$e.get(e))!=null?t:0;return $e.set(e,r+1),r!==0?()=>Jt(e):(ht.set(e,{"aria-hidden":e.getAttribute("aria-hidden"),inert:e.inert}),e.setAttribute("aria-hidden","true"),e.inert=!0,()=>Jt(e))}function Jt(e){var t;let r=(t=$e.get(e))!=null?t:1;if(r===1?$e.delete(e):$e.set(e,r-1),r!==1)return;let n=ht.get(e);n&&(n["aria-hidden"]===null?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",n["aria-hidden"]),e.inert=n.inert,ht.delete(e))}function xn(e,{allowed:t,disallowed:r}={}){let n=xe(e,"inert-others");N(()=>{var l,i;if(!n)return;let a=z();for(let s of(l=r==null?void 0:r())!=null?l:[])s&&a.add(Zt(s));let u=(i=t==null?void 0:t())!=null?i:[];for(let s of u){if(!s)continue;let d=Ne(s);if(!d)continue;let h=s.parentElement;for(;h&&h!==d.body;){for(let b of h.children)u.some(E=>b.contains(E))||a.add(Zt(b));h=h.parentElement}}return a.dispose},[n,t,r])}function $n(e,t,r){let n=re(l=>{let i=l.getBoundingClientRect();i.x===0&&i.y===0&&i.width===0&&i.height===0&&r()});o.useEffect(()=>{if(!e)return;let l=t===null?null:le(t)?t:t.current;if(!l)return;let i=z();if(typeof ResizeObserver<"u"){let a=new ResizeObserver(()=>n.current(l));a.observe(l),i.add(()=>a.disconnect())}if(typeof IntersectionObserver<"u"){let a=new IntersectionObserver(()=>n.current(l));a.observe(l),i.add(()=>a.disconnect())}return()=>i.dispose()},[t,n,e])}let He=["[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(","),On=["[data-autofocus]"].map(e=>`${e}:not([tabindex='-1'])`).join(",");var K=(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))(K||{}),vt=(e=>(e[e.Error=0]="Error",e[e.Overflow=1]="Overflow",e[e.Success=2]="Success",e[e.Underflow=3]="Underflow",e))(vt||{}),Sn=(e=>(e[e.Previous=-1]="Previous",e[e.Next=1]="Next",e))(Sn||{});function Mn(e=document.body){return e==null?[]:Array.from(e.querySelectorAll(He)).sort((t,r)=>Math.sign((t.tabIndex||Number.MAX_SAFE_INTEGER)-(r.tabIndex||Number.MAX_SAFE_INTEGER)))}function Cn(e=document.body){return e==null?[]:Array.from(e.querySelectorAll(On)).sort((t,r)=>Math.sign((t.tabIndex||Number.MAX_SAFE_INTEGER)-(r.tabIndex||Number.MAX_SAFE_INTEGER)))}var Qt=(e=>(e[e.Strict=0]="Strict",e[e.Loose=1]="Loose",e))(Qt||{});function Pn(e,t=0){var r;return e===((r=Ne(e))==null?void 0:r.body)?!1:G(t,{0(){return e.matches(He)},1(){let n=e;for(;n!==null;){if(n.matches(He))return!0;n=n.parentElement}return!1}})}var Tn=(e=>(e[e.Keyboard=0]="Keyboard",e[e.Mouse=1]="Mouse",e))(Tn||{});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 kn=["textarea","input"].join(",");function Fn(e){var t,r;return(r=(t=e==null?void 0:e.matches)==null?void 0:t.call(e,kn))!=null?r:!1}function Ln(e,t=r=>r){return e.slice().sort((r,n)=>{let l=t(r),i=t(n);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 Oe(e,t,{sorted:r=!0,relativeTo:n=null,skipElements:l=[]}={}){let i=Array.isArray(e)?e.length>0?e[0].ownerDocument:document:e.ownerDocument,a=Array.isArray(e)?r?Ln(e):e:t&64?Cn(e):Mn(e);l.length>0&&a.length>1&&(a=a.filter(w=>!l.some(m=>m!=null&&"current"in m?(m==null?void 0:m.current)===w:m===w))),n=n??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(n))-1;if(t&4)return Math.max(0,a.indexOf(n))+1;if(t&8)return a.length-1;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")})(),d=t&32?{preventScroll:!0}:{},h=0,b=a.length,E;do{if(h>=b||h+b<=0)return 0;let w=s+h;if(t&16)w=(w+b)%b;else{if(w<0)return 3;if(w>=b)return 1}E=a[w],E==null||E.focus(d),h+=u}while(E!==i.activeElement);return t&6&&Fn(E)&&E.select(),2}function Rt(){return/iPhone/gi.test(window.navigator.platform)||/Mac/gi.test(window.navigator.platform)&&window.navigator.maxTouchPoints>0}function An(){return/Android/gi.test(window.navigator.userAgent)}function er(){return Rt()||An()}function Ve(e,t,r,n){let l=re(r);o.useEffect(()=>{if(!e)return;function i(a){l.current(a)}return document.addEventListener(t,i,n),()=>document.removeEventListener(t,i,n)},[e,t,n])}function tr(e,t,r,n){let l=re(r);o.useEffect(()=>{if(!e)return;function i(a){l.current(a)}return window.addEventListener(t,i,n),()=>window.removeEventListener(t,i,n)},[e,t,n])}const rr=30;function In(e,t,r){let n=re(r),l=o.useCallback(function(u,s){if(u.defaultPrevented)return;let d=s(u);if(d===null||!d.getRootNode().contains(d)||!d.isConnected)return;let h=function b(E){return typeof E=="function"?b(E()):Array.isArray(E)||E instanceof Set?E:[E]}(t);for(let b of h)if(b!==null&&(b.contains(d)||u.composed&&u.composedPath().includes(b)))return;return!Pn(d,Qt.Loose)&&d.tabIndex!==-1&&u.preventDefault(),n.current(u,d)},[n,t]),i=o.useRef(null);Ve(e,"pointerdown",u=>{var s,d;er()||(i.current=((d=(s=u.composedPath)==null?void 0:s.call(u))==null?void 0:d[0])||u.target)},!0),Ve(e,"pointerup",u=>{if(er()||!i.current)return;let s=i.current;return i.current=null,l(u,()=>s)},!0);let a=o.useRef({x:0,y:0});Ve(e,"touchstart",u=>{a.current.x=u.touches[0].clientX,a.current.y=u.touches[0].clientY},!0),Ve(e,"touchend",u=>{let s={x:u.changedTouches[0].clientX,y:u.changedTouches[0].clientY};if(!(Math.abs(s.x-a.current.x)>=rr||Math.abs(s.y-a.current.y)>=rr))return l(u,()=>Q(u.target)?u.target:null)},!0),tr(e,"blur",u=>l(u,()=>Jr(window.document.activeElement)?window.document.activeElement:null),!0)}function Be(...e){return o.useMemo(()=>Ne(...e),[...e])}function nr(e,t,r,n){let l=re(r);o.useEffect(()=>{e=e??window;function i(a){l.current(a)}return e.addEventListener(t,i,n),()=>e.removeEventListener(t,i,n)},[e,t,n])}function Nn(e){return o.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getSnapshot)}function Dn(e,t){let r=e(),n=new Set;return{getSnapshot(){return r},subscribe(l){return n.add(l),()=>n.delete(l)},dispatch(l,...i){let a=t[l].call(r,...i);a&&(r=a,n.forEach(u=>u()))}}}function jn(){let e;return{before({doc:t}){var r;let n=t.documentElement,l=(r=t.defaultView)!=null?r:window;e=Math.max(0,l.innerWidth-n.clientWidth)},after({doc:t,d:r}){let n=t.documentElement,l=Math.max(0,n.clientWidth-n.offsetWidth),i=Math.max(0,e-l);r.style(n,"paddingRight",`${i}px`)}}}function _n(){return Rt()?{before({doc:e,d:t,meta:r}){function n(l){return r.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(Q(u.target))try{let s=u.target.closest("a");if(!s)return;let{hash:d}=new URL(s.href),h=e.querySelector(d);Q(h)&&!n(h)&&(a=h)}catch{}},!0),t.addEventListener(e,"touchstart",u=>{if(Q(u.target)&&Zr(u.target))if(n(u.target)){let s=u.target;for(;s.parentElement&&n(s.parentElement);)s=s.parentElement;t.style(s,"overscrollBehavior","contain")}else t.style(u.target,"touchAction","none")}),t.addEventListener(e,"touchmove",u=>{if(Q(u.target)){if(Qr(u.target))return;if(n(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 Wn(){return{before({doc:e,d:t}){t.style(e.documentElement,"overflow","hidden")}}}function Un(e){let t={};for(let r of e)Object.assign(t,r(t));return t}let oe=Dn(()=>new Map,{PUSH(e,t){var r;let n=(r=this.get(e))!=null?r:{doc:e,count:0,d:z(),meta:new Set};return n.count++,n.meta.add(t),this.set(e,n),this},POP(e,t){let r=this.get(e);return r&&(r.count--,r.meta.delete(t)),this},SCROLL_PREVENT({doc:e,d:t,meta:r}){let n={doc:e,d:t,meta:Un(r)},l=[_n(),jn(),Wn()];l.forEach(({before:i})=>i==null?void 0:i(n)),l.forEach(({after:i})=>i==null?void 0:i(n))},SCROLL_ALLOW({d:e}){e.dispose()},TEARDOWN({doc:e}){this.delete(e)}});oe.subscribe(()=>{let e=oe.getSnapshot(),t=new Map;for(let[r]of e)t.set(r,r.documentElement.style.overflow);for(let r of e.values()){let n=t.get(r.doc)==="hidden",l=r.count!==0;(l&&!n||!l&&n)&&oe.dispatch(r.count>0?"SCROLL_PREVENT":"SCROLL_ALLOW",r),r.count===0&&oe.dispatch("TEARDOWN",r)}});function Hn(e,t,r=()=>({containers:[]})){let n=Nn(oe),l=t?n.get(t):void 0,i=l?l.count>0:!1;return N(()=>{if(!(!t||!e))return oe.dispatch("PUSH",t,r),()=>oe.dispatch("POP",t,r)},[e,t]),i}function Vn(e,t,r=()=>[document.body]){let n=xe(e,"scroll-lock");Hn(n,t,l=>{var i;return{containers:[...(i=l.containers)!=null?i:[],r]}})}function Bn(e=0){let[t,r]=o.useState(e),n=o.useCallback(s=>r(s),[t]),l=o.useCallback(s=>r(d=>d|s),[t]),i=o.useCallback(s=>(t&s)===s,[t]),a=o.useCallback(s=>r(d=>d&~s),[r]),u=o.useCallback(s=>r(d=>d^s),[r]);return{flags:t,setFlag:n,addFlag:l,hasFlag:i,removeFlag:a,toggleFlag:u}}var lr,or;typeof process<"u"&&typeof globalThis<"u"&&typeof Element<"u"&&((lr=process==null?void 0:process.env)==null?void 0:lr.NODE_ENV)==="test"&&typeof((or=Element==null?void 0:Element.prototype)==null?void 0:or.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(`
|
|
21
|
+
`)),[]});var qn=(e=>(e[e.None=0]="None",e[e.Closed=1]="Closed",e[e.Enter=2]="Enter",e[e.Leave=4]="Leave",e))(qn||{});function Xn(e){let t={};for(let r in e)e[r]===!0&&(t[`data-${r}`]="");return t}function zn(e,t,r,n){let[l,i]=o.useState(r),{hasFlag:a,addFlag:u,removeFlag:s}=Bn(e&&l?3:0),d=o.useRef(!1),h=o.useRef(!1),b=it();return N(()=>{var E;if(e){if(r&&i(!0),!t){r&&u(3);return}return(E=n==null?void 0:n.start)==null||E.call(n,r),Gn(t,{inFlight:d,prepare(){h.current?h.current=!1:h.current=d.current,d.current=!0,!h.current&&(r?(u(3),s(4)):(u(4),s(2)))},run(){h.current?r?(s(3),u(4)):(s(4),u(3)):r?s(1):u(1)},done(){var w;h.current&&typeof t.getAnimations=="function"&&t.getAnimations().length>0||(d.current=!1,s(7),r||i(!1),(w=n==null?void 0:n.end)==null||w.call(n,r))}})}},[e,r,t,b]),e?[l,{closed:a(1),enter:a(2),leave:a(4),transition:a(2)||a(4)}]:[r,{closed:void 0,enter:void 0,leave:void 0,transition:void 0}]}function Gn(e,{prepare:t,run:r,done:n,inFlight:l}){let i=z();return Yn(e,{prepare:t,inFlight:l}),i.nextFrame(()=>{r(),i.requestAnimationFrame(()=>{i.add(Kn(e,n))})}),i.dispose}function Kn(e,t){var r,n;let l=z();if(!e)return l.dispose;let i=!1;l.add(()=>{i=!0});let a=(n=(r=e.getAnimations)==null?void 0:r.call(e).filter(u=>u instanceof CSSTransition))!=null?n:[];return a.length===0?(t(),l.dispose):(Promise.allSettled(a.map(u=>u.finished)).then(()=>{i||t()}),l.dispose)}function Yn(e,{inFlight:t,prepare:r}){if(t!=null&&t.current){r();return}let n=e.style.transition;e.style.transition="none",r(),e.offsetHeight,e.style.transition=n}function gt(e,t){let r=o.useRef([]),n=P(e);o.useEffect(()=>{let l=[...r.current];for(let[i,a]of t.entries())if(r.current[i]!==a){let u=n(t,l);return r.current=t,u}},[n,...t])}let qe=o.createContext(null);qe.displayName="OpenClosedContext";var V=(e=>(e[e.Open=1]="Open",e[e.Closed=2]="Closed",e[e.Closing=4]="Closing",e[e.Opening=8]="Opening",e))(V||{});function Xe(){return o.useContext(qe)}function Zn({value:e,children:t}){return o.createElement(qe.Provider,{value:e},t)}function Jn({children:e}){return o.createElement(qe.Provider,{value:null},e)}function Qn(e){function t(){document.readyState!=="loading"&&(e(),document.removeEventListener("DOMContentLoaded",t))}typeof window<"u"&&typeof document<"u"&&(document.addEventListener("DOMContentLoaded",t),t())}let R=[];Qn(()=>{function e(t){if(!Q(t.target)||t.target===document.body||R[0]===t.target)return;let r=t.target;r=r.closest(He),R.unshift(r??t.target),R=R.filter(n=>n!=null&&n.isConnected),R.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 ir(e){let t=P(e),r=o.useRef(!1);o.useEffect(()=>(r.current=!1,()=>{r.current=!0,De(()=>{r.current&&t()})}),[t])}function Rn(){let e=typeof document>"u";return"useSyncExternalStore"in ve?(t=>t.useSyncExternalStore)(ve)(()=>()=>{},()=>!1,()=>!e):!1}function Se(){let e=Rn(),[t,r]=ve.useState(te.isHandoffComplete);return t&&te.isHandoffComplete===!1&&r(!1),ve.useEffect(()=>{t!==!0&&r(!0)},[t]),ve.useEffect(()=>te.handoff(),[]),e?!1:t}let sr=o.createContext(!1);function el(){return o.useContext(sr)}function ur(e){return o.createElement(sr.Provider,{value:e.force},e.children)}function tl(e){let t=el(),r=o.useContext(dr),[n,l]=o.useState(()=>{var i;if(!t&&r!==null)return(i=r.current)!=null?i:null;if(te.isServer)return null;let a=e==null?void 0:e.getElementById("headlessui-portal-root");if(a)return a;if(e===null)return null;let u=e.createElement("div");return u.setAttribute("id","headlessui-portal-root"),e.body.appendChild(u)});return o.useEffect(()=>{n!==null&&(e!=null&&e.body.contains(n)||e==null||e.body.appendChild(n))},[n,e]),o.useEffect(()=>{t||r!==null&&l(r.current)},[r,l,t]),n}let ar=o.Fragment,rl=D(function(e,t){let{ownerDocument:r=null,...n}=e,l=o.useRef(null),i=q(Rr(w=>{l.current=w}),t),a=Be(l),u=r??a,s=tl(u),[d]=o.useState(()=>{var w;return te.isServer?null:(w=u==null?void 0:u.createElement("div"))!=null?w:null}),h=o.useContext(wt),b=Se();N(()=>{!s||!d||s.contains(d)||(d.setAttribute("data-headlessui-portal",""),s.appendChild(d))},[s,d]),N(()=>{if(d&&h)return h.register(d)},[h,d]),ir(()=>{var w;!s||!d||(Nt(d)&&s.contains(d)&&s.removeChild(d),s.childNodes.length<=0&&((w=s.parentElement)==null||w.removeChild(s)))});let E=W();return b?!s||!d?null:Tr.createPortal(E({ourProps:{ref:i},theirProps:n,slot:{},defaultTag:ar,name:"Portal"}),d):null});function nl(e,t){let r=q(t),{enabled:n=!0,ownerDocument:l,...i}=e,a=W();return n?o.createElement(rl,{...i,ownerDocument:l,ref:r}):a({ourProps:{ref:r},theirProps:i,slot:{},defaultTag:ar,name:"Portal"})}let ll=o.Fragment,dr=o.createContext(null);function ol(e,t){let{target:r,...n}=e,l={ref:q(t)},i=W();return o.createElement(dr.Provider,{value:r},i({ourProps:l,theirProps:n,defaultTag:ll,name:"Popover.Group"}))}let wt=o.createContext(null);function il(){let e=o.useContext(wt),t=o.useRef([]),r=P(i=>(t.current.push(i),e&&e.register(i),()=>n(i))),n=P(i=>{let a=t.current.indexOf(i);a!==-1&&t.current.splice(a,1),e&&e.unregister(i)}),l=o.useMemo(()=>({register:r,unregister:n,portals:t}),[r,n,t]);return[t,o.useMemo(()=>function({children:i}){return o.createElement(wt.Provider,{value:l},i)},[l])]}let sl=D(nl),cr=D(ol),ul=Object.assign(sl,{Group:cr});function al(e,t=typeof document<"u"?document.defaultView:null,r){let n=xe(e,"escape");nr(t,"keydown",l=>{n&&(l.defaultPrevented||l.key===_t.Escape&&r(l))})}function dl(){var e;let[t]=o.useState(()=>typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia("(pointer: coarse)"):null),[r,n]=o.useState((e=t==null?void 0:t.matches)!=null?e:!1);return N(()=>{if(!t)return;function l(i){n(i.matches)}return t.addEventListener("change",l),()=>t.removeEventListener("change",l)},[t]),r}function cl({defaultContainers:e=[],portals:t,mainTreeNode:r}={}){let n=Be(r),l=P(()=>{var i,a;let u=[];for(let s of e)s!==null&&(J(s)?u.push(s):"current"in s&&J(s.current)&&u.push(s.current));if(t!=null&&t.current)for(let s of t.current)u.push(s);for(let s of(i=n==null?void 0:n.querySelectorAll("html > *, body > *"))!=null?i:[])s!==document.body&&s!==document.head&&J(s)&&s.id!=="headlessui-portal-root"&&(r&&(s.contains(r)||s.contains((a=r==null?void 0:r.getRootNode())==null?void 0:a.host))||u.some(d=>s.contains(d))||u.push(s));return u});return{resolveContainers:l,contains:P(i=>l().some(a=>a.contains(i)))}}let fr=o.createContext(null);function mr({children:e,node:t}){let[r,n]=o.useState(null),l=pr(t??r);return o.createElement(fr.Provider,{value:l},e,l===null&&o.createElement(at,{features:We.Hidden,ref:i=>{var a,u;if(i){for(let s of(u=(a=Ne(i))==null?void 0:a.querySelectorAll("html > *, body > *"))!=null?u:[])if(s!==document.body&&s!==document.head&&J(s)&&s!=null&&s.contains(i)){n(s);break}}}}))}function pr(e=null){var t;return(t=o.useContext(fr))!=null?t:e}function bt(){let e=o.useRef(!1);return N(()=>(e.current=!0,()=>{e.current=!1}),[]),e}var Me=(e=>(e[e.Forwards=0]="Forwards",e[e.Backwards=1]="Backwards",e))(Me||{});function fl(){let e=o.useRef(0);return tr(!0,"keydown",t=>{t.key==="Tab"&&(e.current=t.shiftKey?1:0)},!0),e}function hr(e){if(!e)return new Set;if(typeof e=="function")return new Set(e());let t=new Set;for(let r of e.current)J(r.current)&&t.add(r.current);return t}let ml="div";var ie=(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))(ie||{});function pl(e,t){let r=o.useRef(null),n=q(r,t),{initialFocus:l,initialFocusFallback:i,containers:a,features:u=15,...s}=e;Se()||(u=0);let d=Be(r);wl(u,{ownerDocument:d});let h=bl(u,{ownerDocument:d,container:r,initialFocus:l,initialFocusFallback:i});yl(u,{ownerDocument:d,container:r,containers:a,previousActiveElement:h});let b=fl(),E=P(f=>{if(!le(r.current))return;let g=r.current;(y=>y())(()=>{G(b.current,{[Me.Forwards]:()=>{Oe(g,K.First,{skipElements:[f.relatedTarget,i]})},[Me.Backwards]:()=>{Oe(g,K.Last,{skipElements:[f.relatedTarget,i]})}})})}),w=xe(!!(u&2),"focus-trap#tab-lock"),m=it(),$=o.useRef(!1),v={ref:n,onKeyDown(f){f.key=="Tab"&&($.current=!0,m.requestAnimationFrame(()=>{$.current=!1}))},onBlur(f){if(!(u&4))return;let g=hr(a);le(r.current)&&g.add(r.current);let y=f.relatedTarget;Q(y)&&y.dataset.headlessuiFocusGuard!=="true"&&(vr(g,y)||($.current?Oe(r.current,G(b.current,{[Me.Forwards]:()=>K.Next,[Me.Backwards]:()=>K.Previous})|K.WrapAround,{relativeTo:f.target}):Q(f.target)&&Y(f.target)))}},c=W();return o.createElement(o.Fragment,null,w&&o.createElement(at,{as:"button",type:"button","data-headlessui-focus-guard":!0,onFocus:E,features:We.Focusable}),c({ourProps:v,theirProps:s,defaultTag:ml,name:"FocusTrap"}),w&&o.createElement(at,{as:"button",type:"button","data-headlessui-focus-guard":!0,onFocus:E,features:We.Focusable}))}let hl=D(pl),vl=Object.assign(hl,{features:ie});function gl(e=!0){let t=o.useRef(R.slice());return gt(([r],[n])=>{n===!0&&r===!1&&De(()=>{t.current.splice(0)}),n===!1&&r===!0&&(t.current=R.slice())},[e,R,t]),P(()=>{var r;return(r=t.current.find(n=>n!=null&&n.isConnected))!=null?r:null})}function wl(e,{ownerDocument:t}){let r=!!(e&8),n=gl(r);gt(()=>{r||(t==null?void 0:t.activeElement)===(t==null?void 0:t.body)&&Y(n())},[r]),ir(()=>{r&&Y(n())})}function bl(e,{ownerDocument:t,container:r,initialFocus:n,initialFocusFallback:l}){let i=o.useRef(null),a=xe(!!(e&1),"focus-trap#initial-focus"),u=bt();return gt(()=>{if(e===0)return;if(!a){l!=null&&l.current&&Y(l.current);return}let s=r.current;s&&De(()=>{if(!u.current)return;let d=t==null?void 0:t.activeElement;if(n!=null&&n.current){if((n==null?void 0:n.current)===d){i.current=d;return}}else if(s.contains(d)){i.current=d;return}if(n!=null&&n.current)Y(n.current);else{if(e&16){if(Oe(s,K.First|K.AutoFocus)!==vt.Error)return}else if(Oe(s,K.First)!==vt.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 yl(e,{ownerDocument:t,container:r,containers:n,previousActiveElement:l}){let i=bt(),a=!!(e&4);nr(t==null?void 0:t.defaultView,"focus",u=>{if(!a||!i.current)return;let s=hr(n);le(r.current)&&s.add(r.current);let d=l.current;if(!d)return;let h=u.target;le(h)?vr(s,h)?(l.current=h,Y(h)):(u.preventDefault(),u.stopPropagation(),Y(d)):Y(l.current)},!0)}function vr(e,t){for(let r of e)if(r.contains(t))return!0;return!1}function gr(e){var t;return!!(e.enter||e.enterFrom||e.enterTo||e.leave||e.leaveFrom||e.leaveTo)||((t=e.as)!=null?t:br)!==o.Fragment||o.Children.count(e.children)===1}let ze=o.createContext(null);ze.displayName="TransitionContext";var El=(e=>(e.Visible="visible",e.Hidden="hidden",e))(El||{});function xl(){let e=o.useContext(ze);if(e===null)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition /> or <Transition.Root />.");return e}function $l(){let e=o.useContext(Ge);if(e===null)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition /> or <Transition.Root />.");return e}let Ge=o.createContext(null);Ge.displayName="NestingContext";function Ke(e){return"children"in e?Ke(e.children):e.current.filter(({el:t})=>t.current!==null).filter(({state:t})=>t==="visible").length>0}function wr(e,t){let r=re(e),n=o.useRef([]),l=bt(),i=it(),a=P((w,m=Z.Hidden)=>{let $=n.current.findIndex(({el:v})=>v===w);$!==-1&&(G(m,{[Z.Unmount](){n.current.splice($,1)},[Z.Hidden](){n.current[$].state="hidden"}}),i.microTask(()=>{var v;!Ke(n)&&l.current&&((v=r.current)==null||v.call(r))}))}),u=P(w=>{let m=n.current.find(({el:$})=>$===w);return m?m.state!=="visible"&&(m.state="visible"):n.current.push({el:w,state:"visible"}),()=>a(w,Z.Unmount)}),s=o.useRef([]),d=o.useRef(Promise.resolve()),h=o.useRef({enter:[],leave:[]}),b=P((w,m,$)=>{s.current.splice(0),t&&(t.chains.current[m]=t.chains.current[m].filter(([v])=>v!==w)),t==null||t.chains.current[m].push([w,new Promise(v=>{s.current.push(v)})]),t==null||t.chains.current[m].push([w,new Promise(v=>{Promise.all(h.current[m].map(([c,f])=>f)).then(()=>v())})]),m==="enter"?d.current=d.current.then(()=>t==null?void 0:t.wait.current).then(()=>$(m)):$(m)}),E=P((w,m,$)=>{Promise.all(h.current[m].splice(0).map(([v,c])=>c)).then(()=>{var v;(v=s.current.shift())==null||v()}).then(()=>$(m))});return o.useMemo(()=>({children:n,register:u,unregister:a,onStart:b,onStop:E,wait:d,chains:h}),[u,a,n,b,E,h,d])}let br=o.Fragment,yr=je.RenderStrategy;function Ol(e,t){var r,n;let{transition:l=!0,beforeEnter:i,afterEnter:a,beforeLeave:u,afterLeave:s,enter:d,enterFrom:h,enterTo:b,entered:E,leave:w,leaveFrom:m,leaveTo:$,...v}=e,[c,f]=o.useState(null),g=o.useRef(null),y=gr(e),p=q(...y?[g,t,f]:t===null?[]:[t]),x=(r=v.unmount)==null||r?Z.Unmount:Z.Hidden,{show:S,appear:L,initial:j}=xl(),[k,A]=o.useState(S?"visible":"hidden"),H=$l(),{register:I,unregister:T}=H;N(()=>I(g),[I,g]),N(()=>{if(x===Z.Hidden&&g.current){if(S&&k!=="visible"){A("visible");return}return G(k,{hidden:()=>T(g),visible:()=>I(g)})}},[k,g,I,T,S,x]);let _=Se();N(()=>{if(y&&_&&k==="visible"&&g.current===null)throw new Error("Did you forget to passthrough the `ref` to the actual DOM node?")},[g,k,_,y]);let pe=j&&!L,se=L&&S&&j,F=o.useRef(!1),he=wr(()=>{F.current||(A("hidden"),T(g))},H),Ze=P(Ot=>{F.current=!0;let Qe=Ot?"enter":"leave";he.onStart(g,Qe,Pe=>{Pe==="enter"?i==null||i():Pe==="leave"&&(u==null||u())})}),ee=P(Ot=>{let Qe=Ot?"enter":"leave";F.current=!1,he.onStop(g,Qe,Pe=>{Pe==="enter"?a==null||a():Pe==="leave"&&(s==null||s())}),Qe==="leave"&&!Ke(he)&&(A("hidden"),T(g))});o.useEffect(()=>{y&&l||(Ze(S),ee(S))},[S,y,l]);let $t=!(!l||!y||!_||pe),[,C]=zn($t,c,S,{start:Ze,end:ee}),Je=ne({ref:p,className:((n=st(v.className,se&&d,se&&h,C.enter&&d,C.enter&&C.closed&&h,C.enter&&!C.closed&&b,C.leave&&w,C.leave&&!C.closed&&m,C.leave&&C.closed&&$,!C.transition&&S&&E))==null?void 0:n.trim())||void 0,...Xn(C)}),Ce=0;k==="visible"&&(Ce|=V.Open),k==="hidden"&&(Ce|=V.Closed),S&&k==="hidden"&&(Ce|=V.Opening),!S&&k==="visible"&&(Ce|=V.Closing);let Gl=W();return o.createElement(Ge.Provider,{value:he},o.createElement(Zn,{value:Ce},Gl({ourProps:Je,theirProps:v,defaultTag:br,features:yr,visible:k==="visible",name:"Transition.Child"})))}function Sl(e,t){let{show:r,appear:n=!1,unmount:l=!0,...i}=e,a=o.useRef(null),u=gr(e),s=q(...u?[a,t]:t===null?[]:[t]);Se();let d=Xe();if(r===void 0&&d!==null&&(r=(d&V.Open)===V.Open),r===void 0)throw new Error("A <Transition /> is used but it is missing a `show={true | false}` prop.");let[h,b]=o.useState(r?"visible":"hidden"),E=wr(()=>{r||b("hidden")}),[w,m]=o.useState(!0),$=o.useRef([r]);N(()=>{w!==!1&&$.current[$.current.length-1]!==r&&($.current.push(r),m(!1))},[$,r]);let v=o.useMemo(()=>({show:r,appear:n,initial:w}),[r,n,w]);N(()=>{r?b("visible"):!Ke(E)&&a.current!==null&&b("hidden")},[r,E]);let c={unmount:l},f=P(()=>{var p;w&&m(!1),(p=e.beforeEnter)==null||p.call(e)}),g=P(()=>{var p;w&&m(!1),(p=e.beforeLeave)==null||p.call(e)}),y=W();return o.createElement(Ge.Provider,{value:E},o.createElement(ze.Provider,{value:v},y({ourProps:{...c,as:o.Fragment,children:o.createElement(Er,{ref:s,...c,...i,beforeEnter:f,beforeLeave:g})},theirProps:{},defaultTag:o.Fragment,features:yr,visible:h==="visible",name:"Transition"})))}function Ml(e,t){let r=o.useContext(ze)!==null,n=Xe()!==null;return o.createElement(o.Fragment,null,!r&&n?o.createElement(yt,{ref:t,...e}):o.createElement(Er,{ref:t,...e}))}let yt=D(Sl),Er=D(Ol),me=D(Ml),xr=Object.assign(yt,{Child:me,Root:yt});var Cl=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(Cl||{}),Pl=(e=>(e[e.SetTitleId=0]="SetTitleId",e))(Pl||{});let Tl={0(e,t){return e.titleId===t.id?e:{...e,titleId:t.id}}},Et=o.createContext(null);Et.displayName="DialogContext";function Ye(e){let t=o.useContext(Et);if(t===null){let r=new Error(`<${e} /> is missing a parent <Dialog /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(r,Ye),r}return t}function kl(e,t){return G(t.type,Tl,e,t)}let $r=D(function(e,t){let r=o.useId(),{id:n=`headlessui-dialog-${r}`,open:l,onClose:i,initialFocus:a,role:u="dialog",autoFocus:s=!0,__demoMode:d=!1,unmount:h=!1,...b}=e,E=o.useRef(!1);u=function(){return u==="dialog"||u==="alertdialog"?u:(E.current||(E.current=!0,console.warn(`Invalid role [${u}] passed to <Dialog />. Only \`dialog\` and and \`alertdialog\` are supported. Using \`dialog\` instead.`)),"dialog")}();let w=Xe();l===void 0&&w!==null&&(l=(w&V.Open)===V.Open);let m=o.useRef(null),$=q(m,t),v=Be(m),c=l?0:1,[f,g]=o.useReducer(kl,{titleId:null,descriptionId:null,panelRef:o.createRef()}),y=P(()=>i(!1)),p=P(C=>g({type:0,id:C})),x=Se()?c===0:!1,[S,L]=il(),j={get current(){var C;return(C=f.panelRef.current)!=null?C:m.current}},k=pr(),{resolveContainers:A}=cl({mainTreeNode:k,portals:S,defaultContainers:[j]}),H=w!==null?(w&V.Closing)===V.Closing:!1;xn(d||H?!1:x,{allowed:P(()=>{var C,Je;return[(Je=(C=m.current)==null?void 0:C.closest("[data-headlessui-portal]"))!=null?Je:null]}),disallowed:P(()=>{var C;return[(C=k==null?void 0:k.closest("body > *:not(#headlessui-portal-root)"))!=null?C:null]})});let I=Xt.get(null);N(()=>{if(x)return I.actions.push(n),()=>I.actions.pop(n)},[I,n,x]);let T=Yt(I,o.useCallback(C=>I.selectors.isTop(C,n),[I,n]));In(T,A,C=>{C.preventDefault(),y()}),al(T,v==null?void 0:v.defaultView,C=>{C.preventDefault(),C.stopPropagation(),document.activeElement&&"blur"in document.activeElement&&typeof document.activeElement.blur=="function"&&document.activeElement.blur(),y()}),Vn(d||H?!1:x,v,A),$n(x,m,y);let[_,pe]=en(),se=o.useMemo(()=>[{dialogState:c,close:y,setTitleId:p,unmount:h},f],[c,f,y,p,h]),F=o.useMemo(()=>({open:c===0}),[c]),he={ref:$,id:n,role:u,tabIndex:-1,"aria-modal":d?void 0:c===0?!0:void 0,"aria-labelledby":f.titleId,"aria-describedby":_,unmount:h},Ze=!dl(),ee=ie.None;x&&!d&&(ee|=ie.RestoreFocus,ee|=ie.TabLock,s&&(ee|=ie.AutoFocus),Ze&&(ee|=ie.InitialFocus));let $t=W();return o.createElement(Jn,null,o.createElement(ur,{force:!0},o.createElement(ul,null,o.createElement(Et.Provider,{value:se},o.createElement(cr,{target:m},o.createElement(ur,{force:!1},o.createElement(pe,{slot:F},o.createElement(L,null,o.createElement(vl,{initialFocus:a,initialFocusFallback:m,containers:A,features:ee},o.createElement(sn,{value:y},$t({ourProps:he,theirProps:b,slot:F,defaultTag:Fl,features:Ll,visible:c===0,name:"Dialog"})))))))))))}),Fl="div",Ll=je.RenderStrategy|je.Static;function Al(e,t){let{transition:r=!1,open:n,...l}=e,i=Xe(),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(n!==void 0||r)&&!l.static?o.createElement(mr,null,o.createElement(xr,{show:n,transition:r,unmount:l.unmount},o.createElement($r,{ref:t,...l}))):o.createElement(mr,null,o.createElement($r,{ref:t,open:n,...l}))}let Il="div";function Nl(e,t){let r=o.useId(),{id:n=`headlessui-dialog-panel-${r}`,transition:l=!1,...i}=e,[{dialogState:a,unmount:u},s]=Ye("Dialog.Panel"),d=q(t,s.panelRef),h=o.useMemo(()=>({open:a===0}),[a]),b=P(v=>{v.stopPropagation()}),E={ref:d,id:n,onClick:b},w=l?me:o.Fragment,m=l?{unmount:u}:{},$=W();return o.createElement(w,{...m},$({ourProps:E,theirProps:i,slot:h,defaultTag:Il,name:"Dialog.Panel"}))}let Dl="div";function jl(e,t){let{transition:r=!1,...n}=e,[{dialogState:l,unmount:i}]=Ye("Dialog.Backdrop"),a=o.useMemo(()=>({open:l===0}),[l]),u={ref:t,"aria-hidden":!0},s=r?me:o.Fragment,d=r?{unmount:i}:{},h=W();return o.createElement(s,{...d},h({ourProps:u,theirProps:n,slot:a,defaultTag:Dl,name:"Dialog.Backdrop"}))}let _l="h2";function Wl(e,t){let r=o.useId(),{id:n=`headlessui-dialog-title-${r}`,...l}=e,[{dialogState:i,setTitleId:a}]=Ye("Dialog.Title"),u=q(t);o.useEffect(()=>(a(n),()=>a(null)),[n,a]);let s=o.useMemo(()=>({open:i===0}),[i]),d={ref:u,id:n};return W()({ourProps:d,theirProps:l,slot:s,defaultTag:_l,name:"Dialog.Title"})}let Ul=D(Al),xt=D(Nl);D(jl);let Hl=D(Wl),Vl=Object.assign(Ul,{Panel:xt,Title:Hl,Description:ln});function Or({onClick:e}){return O.jsxs("button",{type:"button",className:"im-close-button text-gray-400 hover:text-gray-500",onClick:e,children:[O.jsx("span",{className:"sr-only",children:"Close"}),O.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:O.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})]})}const Bl=({modalContext:e,config:t,children:r})=>{const[n,l]=o.useState(!1);return O.jsx("div",{className:"im-modal-container fixed inset-0 z-40 overflow-y-auto p-4",children:O.jsx("div",{className:Ie("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:O.jsx(me,{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:Ie("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:O.jsxs(xt,{className:`im-modal-content relative ${t.paddingClasses} ${t.panelClasses}`,"data-inertiaui-modal-entered":n,children:[t.closeButton&&O.jsx("div",{className:"absolute right-0 top-0 pr-3 pt-3",children:O.jsx(Or,{onClick:e.close})}),typeof r=="function"?r({modalContext:e,config:t}):r]})})})})},ql=({modalContext:e,config:t,children:r})=>{const[n,l]=o.useState(!1);return O.jsx("div",{className:"im-slideover-container fixed inset-0 z-40 overflow-y-auto overflow-x-hidden",children:O.jsx("div",{className:Ie("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:O.jsx(me,{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:Ie("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:O.jsxs(xt,{className:`im-slideover-content relative ${t.paddingClasses} ${t.panelClasses}`,"data-inertiaui-modal-entered":n,children:[t.closeButton&&O.jsx("div",{className:"absolute right-0 top-0 pr-3 pt-3",children:O.jsx(Or,{onClick:e.close})}),typeof r=="function"?r({modalContext:e,config:t}):r]})})})})},Sr=o.forwardRef(({name:e,children:t,onFocus:r=null,onBlur:n=null,onClose:l=null,onSuccess:i=null,onAfterLeave:a=null,...u},s)=>{const d=b=>typeof t=="function"?t(b):t,h=o.useRef(null);return o.useImperativeHandle(s,()=>h.current,[h]),O.jsx(lt,{ref:h,name:e,onFocus:r,onBlur:n,onClose:l,onSuccess:i,...u,children:({afterLeave:b,close:E,config:w,emit:m,getChildModal:$,getParentModal:v,id:c,index:f,isOpen:g,modalContext:y,onTopOfStack:p,reload:x,setOpen:S,shouldRender:L})=>O.jsx(xr,{appear:!0,show:g??!1,afterLeave:a,children:O.jsxs(Vl,{as:"div",className:"im-dialog relative z-20",onClose:()=>w.closeExplicitly?null:E(),"data-inertiaui-modal-id":c,"data-inertiaui-modal-index":f,children:[f===0?O.jsx(me,{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:p?O.jsx("div",{className:"im-backdrop fixed inset-0 z-30 bg-black/75","aria-hidden":"true"}):O.jsx("div",{})}):null,f>0&&p?O.jsx("div",{className:"im-backdrop fixed inset-0 z-30 bg-black/75"}):null,w.slideover?O.jsx(ql,{modalContext:y,config:w,children:d({afterLeave:b,close:E,config:w,emit:m,getChildModal:$,getParentModal:v,id:c,index:f,isOpen:g,modalContext:y,onTopOfStack:p,reload:x,setOpen:S,shouldRender:L})}):O.jsx(Bl,{modalContext:y,config:w,children:d({afterLeave:b,close:E,config:w,emit:m,getChildModal:$,getParentModal:v,id:c,index:f,isOpen:g,modalContext:y,onTopOfStack:p,reload:x,setOpen:S,shouldRender:L})})]})})})});Sr.displayName="Modal";const Xl=({href:e,method:t="get",data:r={},as:n="a",headers:l={},queryStringArrayFormat:i="brackets",onAfterLeave:a=null,onBlur:u=null,onClose:s=null,onError:d=null,onFocus:h=null,onStart:b=null,onSuccess:E=null,navigate:w=null,children:m,...$})=>{const[v,c]=o.useState(!1),[f,g]=o.useState(null),{stack:y,visit:p}=be(),x=o.useMemo(()=>w??Fe("navigate"),[w]),S={},L={};Object.keys($).forEach(T=>{Pt.includes(T)||(T.startsWith("on")&&typeof $[T]=="function"?T.toLowerCase()in window?S[T]=$[T]:L[T]=$[T]:S[T]=$[T])});const[j,k]=o.useState(!1);o.useEffect(()=>{f&&(f.onTopOfStack&&j?h==null||h():!f.onTopOfStack&&!j&&(u==null||u()),k(!f.onTopOfStack))},[y]);const A=o.useCallback(()=>{s==null||s()},[s]),H=o.useCallback(()=>{g(null),a==null||a()},[a]),I=o.useCallback(T=>{T==null||T.preventDefault(),!v&&(e.startsWith("#")||(c(!0),b==null||b()),p(e,t,r,l,jr(Dr($,Pt)),()=>A(y.length),H,i,x).then(_=>{g(_),_.registerEventListenersFromProps(L),E==null||E()}).catch(_=>{console.error(_),d==null||d(_)}).finally(()=>c(!1)))},[e,t,r,l,i,$,A,H]);return O.jsx(n,{...S,href:e,onClick:I,children:typeof m=="function"?m({loading:v}):m})},Mr=({children:e,data:t,params:r,buffer:n,as:l,always:i,fallback:a})=>{i=i??!1,l=l??"div",a=a??null;const[u,s]=o.useState(!1),d=o.useRef(!1),h=o.useRef(!1),b=o.useRef(null),E=nt(),w=o.useCallback(()=>{if(t)return{only:Array.isArray(t)?t:[t]};if(!r)throw new Error("You must provide either a `data` or `params` prop.");return r},[r,t]);return o.useEffect(()=>{if(!b.current)return;const m=new IntersectionObserver($=>{if(!$[0].isIntersecting||(!i&&d.current&&m.disconnect(),h.current))return;d.current=!0,h.current=!0;const v=w();E.reload({...v,onStart:c=>{var f;h.current=!0,(f=v.onStart)==null||f.call(v,c)},onFinish:c=>{var f;s(!0),h.current=!1,(f=v.onFinish)==null||f.call(v,c),i||m.disconnect()}})},{rootMargin:`${n||0}px`});return m.observe(b.current),()=>{m.disconnect()}},[b,w,n]),i||!u?o.createElement(l,{props:null,ref:b},u?e:a):u?e:null};Mr.displayName="InertiaWhenVisible";const zl=e=>t=>(t.default.layout=r=>o.createElement(e,{},r),t);M.Deferred=Lt,M.HeadlessModal=lt,M.Modal=Sr,M.ModalLink=Xl,M.ModalRoot=kt,M.ModalStackProvider=Ct,M.WhenVisible=Mr,M.getConfig=Fe,M.initFromPageProps=Tt,M.putConfig=Ar,M.renderApp=_r,M.resetConfig=Lr,M.setPageLayout=zl,M.useModal=nt,M.useModalIndex=rt,M.useModalStack=be,Object.defineProperty(M,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
package/src/ModalRoot.jsx
CHANGED
|
@@ -5,7 +5,6 @@ import { router, usePage } from '@inertiajs/react'
|
|
|
5
5
|
import { mergeDataIntoQueryString } from '@inertiajs/core'
|
|
6
6
|
import { createContext, useContext } from 'react'
|
|
7
7
|
import ModalRenderer from './ModalRenderer'
|
|
8
|
-
import { waitFor } from './helpers'
|
|
9
8
|
import { getConfig } from './config'
|
|
10
9
|
|
|
11
10
|
const ModalStackContext = createContext(null)
|
|
@@ -14,7 +13,7 @@ ModalStackContext.displayName = 'ModalStackContext'
|
|
|
14
13
|
let pageVersion = null
|
|
15
14
|
let resolveComponent = null
|
|
16
15
|
let baseUrl = null
|
|
17
|
-
let
|
|
16
|
+
let baseModalsToWaitFor = {}
|
|
18
17
|
let localStackCopy = []
|
|
19
18
|
let pendingModalUpdates = {}
|
|
20
19
|
|
|
@@ -147,8 +146,10 @@ export const ModalStackProvider = ({ children }) => {
|
|
|
147
146
|
}
|
|
148
147
|
|
|
149
148
|
close = () => {
|
|
150
|
-
updateStack((
|
|
151
|
-
|
|
149
|
+
updateStack((currentStack) => {
|
|
150
|
+
let modalClosed = false
|
|
151
|
+
|
|
152
|
+
const newStack = currentStack.map((modal) => {
|
|
152
153
|
if (modal.id === this.id && modal.isOpen) {
|
|
153
154
|
Object.keys(modal.listeners).forEach((event) => {
|
|
154
155
|
modal.off(event)
|
|
@@ -156,10 +157,13 @@ export const ModalStackProvider = ({ children }) => {
|
|
|
156
157
|
|
|
157
158
|
modal.isOpen = false
|
|
158
159
|
modal.onCloseCallback?.()
|
|
160
|
+
modalClosed = true
|
|
159
161
|
}
|
|
160
162
|
return modal
|
|
161
|
-
})
|
|
162
|
-
|
|
163
|
+
})
|
|
164
|
+
|
|
165
|
+
return modalClosed ? newStack : currentStack
|
|
166
|
+
})
|
|
163
167
|
}
|
|
164
168
|
|
|
165
169
|
afterLeave = () => {
|
|
@@ -321,6 +325,9 @@ export const ModalStackProvider = ({ children }) => {
|
|
|
321
325
|
options.onAfterLeave,
|
|
322
326
|
options.queryStringArrayFormat ?? 'brackets',
|
|
323
327
|
options.navigate ?? getConfig('navigate'),
|
|
328
|
+
options.onStart,
|
|
329
|
+
options.onSuccess,
|
|
330
|
+
options.onError,
|
|
324
331
|
).then((modal) => {
|
|
325
332
|
const listeners = options.listeners ?? {}
|
|
326
333
|
|
|
@@ -343,6 +350,9 @@ export const ModalStackProvider = ({ children }) => {
|
|
|
343
350
|
onAfterLeave = null,
|
|
344
351
|
queryStringArrayFormat = 'brackets',
|
|
345
352
|
useBrowserHistory = false,
|
|
353
|
+
onStart = null,
|
|
354
|
+
onSuccess = null,
|
|
355
|
+
onError = null,
|
|
346
356
|
) => {
|
|
347
357
|
const modalId = generateId()
|
|
348
358
|
|
|
@@ -372,7 +382,7 @@ export const ModalStackProvider = ({ children }) => {
|
|
|
372
382
|
}
|
|
373
383
|
|
|
374
384
|
if (useInertiaRouter) {
|
|
375
|
-
|
|
385
|
+
baseModalsToWaitFor = {}
|
|
376
386
|
|
|
377
387
|
pendingModalUpdates[modalId] = {
|
|
378
388
|
config,
|
|
@@ -387,24 +397,39 @@ export const ModalStackProvider = ({ children }) => {
|
|
|
387
397
|
headers,
|
|
388
398
|
preserveScroll: true,
|
|
389
399
|
preserveState: true,
|
|
390
|
-
onError
|
|
391
|
-
|
|
392
|
-
|
|
400
|
+
onError(...args) {
|
|
401
|
+
onError?.(...args)
|
|
402
|
+
reject(...args)
|
|
403
|
+
},
|
|
404
|
+
onStart(...args) {
|
|
405
|
+
onStart?.(...args)
|
|
406
|
+
},
|
|
407
|
+
onSuccess(...args) {
|
|
408
|
+
onSuccess?.(...args)
|
|
409
|
+
},
|
|
410
|
+
onBefore: () => {
|
|
411
|
+
baseModalsToWaitFor[modalId] = resolve
|
|
393
412
|
},
|
|
394
413
|
})
|
|
395
414
|
}
|
|
396
415
|
|
|
397
416
|
//
|
|
398
417
|
|
|
418
|
+
onStart?.()
|
|
419
|
+
|
|
399
420
|
Axios({
|
|
400
421
|
url,
|
|
401
422
|
method,
|
|
402
423
|
data,
|
|
403
424
|
headers,
|
|
404
425
|
})
|
|
405
|
-
.then((response) =>
|
|
406
|
-
|
|
407
|
-
|
|
426
|
+
.then((response) => {
|
|
427
|
+
onSuccess?.(response)
|
|
428
|
+
resolve(pushFromResponseData(response.data, config, onClose, onAfterLeave))
|
|
429
|
+
})
|
|
430
|
+
.catch((...args) => {
|
|
431
|
+
onError?.(...args)
|
|
432
|
+
reject(...args)
|
|
408
433
|
})
|
|
409
434
|
})
|
|
410
435
|
}
|
|
@@ -438,6 +463,14 @@ export const ModalStackProvider = ({ children }) => {
|
|
|
438
463
|
visitModal,
|
|
439
464
|
registerLocalModal,
|
|
440
465
|
removeLocalModal,
|
|
466
|
+
onModalOnBase: (modalOnBase) => {
|
|
467
|
+
const resolve = baseModalsToWaitFor[modalOnBase.id]
|
|
468
|
+
|
|
469
|
+
if (resolve) {
|
|
470
|
+
resolve(modalOnBase)
|
|
471
|
+
delete baseModalsToWaitFor[modalOnBase.id]
|
|
472
|
+
}
|
|
473
|
+
},
|
|
441
474
|
}
|
|
442
475
|
|
|
443
476
|
return <ModalStackContext.Provider value={value}>{children}</ModalStackContext.Provider>
|
|
@@ -539,9 +572,7 @@ export const ModalRoot = ({ children }) => {
|
|
|
539
572
|
})
|
|
540
573
|
}
|
|
541
574
|
})
|
|
542
|
-
.then(
|
|
543
|
-
newModalOnBase = newModal
|
|
544
|
-
})
|
|
575
|
+
.then(context.onModalOnBase)
|
|
545
576
|
}),
|
|
546
577
|
[],
|
|
547
578
|
)
|
package/src/helpers.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { generateId, sameUrlPath, except, only, rejectNullValues,
|
|
2
|
-
export { generateId, sameUrlPath, except, only, rejectNullValues,
|
|
1
|
+
import { generateId, sameUrlPath, except, only, rejectNullValues, kebabCase } from './../../vue/src/helpers.js'
|
|
2
|
+
export { generateId, sameUrlPath, except, only, rejectNullValues, kebabCase }
|