@inertiaui/modal-react 0.18.0 → 0.18.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,12 +1,12 @@
1
- (function(C,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("react"),require("react/jsx-runtime"),require("axios"),require("@inertiajs/react"),require("@inertiajs/core")):typeof define=="function"&&define.amd?define(["exports","react","react/jsx-runtime","axios","@inertiajs/react","@inertiajs/core"],s):(C=typeof globalThis<"u"?globalThis:C||self,s(C.InertiaUIModal={},C.React,C.jsxRuntime,C.Axios,C.react,C.core))})(this,function(C,s,T,he,te,Mt){"use strict";var Yn=Object.defineProperty;var Jn=(C,s,T)=>s in C?Yn(C,s,{enumerable:!0,configurable:!0,writable:!0,value:T}):C[s]=T;var q=(C,s,T)=>Jn(C,typeof s!="symbol"?s+"":s,T);function At(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:()=>t[n]})}}return e.default=t,Object.freeze(e)}const ie=At(s),se={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 Lt{constructor(){this.config={},this.reset()}reset(){this.config=JSON.parse(JSON.stringify(se))}put(e,n){if(typeof e=="object"){this.config={type:e.type??se.type,navigate:e.navigate??se.navigate,modal:{...se.modal,...e.modal??{}},slideover:{...se.slideover,...e.slideover??{}}};return}const r=e.split(".");let i=this.config;for(let l=0;l<r.length-1;l++)i=i[r[l]]=i[r[l]]||{};i[r[r.length-1]]=n}get(e){if(typeof e>"u")return this.config;const n=e.split(".");let r=this.config;for(const i of n){if(r[i]===void 0)return null;r=r[i]}return r}}const ve=new Lt,jt=()=>ve.reset(),Dt=(t,e)=>ve.put(t,e),pe=t=>ve.get(t),ne=(t,e)=>ve.get(t?`slideover.${e}`:`modal.${e}`),ze={modifiedElements:[],bodyState:{hasOverflowHidden:!1,hasPointerEventsNone:!1,originalPaddingRight:""},prepare(){const t=window.innerWidth-document.documentElement.clientWidth;this.bodyState.originalPaddingRight=document.body.style.paddingRight;const e=parseInt(window.getComputedStyle(document.body).paddingRight,10);document.body.style.paddingRight=`${e+t}px`,document.body.classList.contains("overflow-hidden")||(document.body.classList.add("overflow-hidden"),this.bodyState.hasOverflowHidden=!0),document.body.classList.contains("pointer-events-none")||(document.body.classList.add("pointer-events-none"),this.bodyState.hasPointerEventsNone=!0),Array.from(document.body.children).forEach(n=>{!n.classList.contains("im-dialog")&&n.getAttribute("aria-hidden")!=="true"&&(n.setAttribute("aria-hidden","true"),this.modifiedElements.push(n))})},cleanup(){this.bodyState.hasOverflowHidden&&(document.body.classList.remove("overflow-hidden"),this.bodyState.hasOverflowHidden=!1),this.bodyState.hasPointerEventsNone&&(document.body.classList.remove("pointer-events-none"),this.bodyState.hasPointerEventsNone=!1),document.body.style.paddingRight=this.bodyState.originalPaddingRight,this.bodyState.originalPaddingRight="",this.modifiedElements.forEach(t=>{t.removeAttribute("aria-hidden")}),this.modifiedElements=[]}};function Me(t="inertiaui_modal_"){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`${t}${crypto.randomUUID()}`:`${t}${Date.now().toString(36)}_${Math.random().toString(36).substr(2,9)}`}function $t(t,e){return Array.isArray(t)?t.filter(n=>!e.includes(n)):Object.keys(t).reduce((n,r)=>(e.includes(r)||(n[r]=t[r]),n),{})}function Ge(t,e){return Array.isArray(t)?t.filter(n=>e.includes(n)):e.reduce((n,r)=>(r in t&&(n[r]=t[r]),n),{})}function Ut(t){return Array.isArray(t)?t.filter(e=>e!==null):Object.keys(t).reduce((e,n)=>(n in t&&t[n]!==null&&(e[n]=t[n]),e),{})}function Wt(t,e=3,n=10){return new Promise((r,i)=>{const l=t();if(l){r(l);return}let a=e*1e3/n;const v=setInterval(()=>{const o=t();o&&(clearInterval(v),r(o)),--a<=0&&(clearInterval(v),i(new Error("Condition not met in time")))},n)})}function le(t){return t?(t=t.replace(/_/g,"-"),t=t.replace(/-+/g,"-"),/[A-Z]/.test(t)?(t=t.replace(/\s+/g,"").replace(/_/g,"").replace(/(?:^|\s|-)+([A-Za-z])/g,(e,n)=>n.toUpperCase()),t=t.replace(/(.)(?=[A-Z])/g,"$1-"),t.toLowerCase()):t):""}const me=s.createContext(null);me.displayName="ModalStackContext";let Ze=null,Ye=null,oe=null,Ae=null,Le=[],re={};const Je=({children:t})=>{const[e,n]=s.useState([]),[r,i]=s.useState({}),l=y=>{n(c=>{const h=y([...c]),p=w=>{var N;return h.length<2?!0:((N=h.map(m=>({id:m.id,shouldRender:m.shouldRender})).reverse().find(m=>m.shouldRender))==null?void 0:N.id)===w};return h.forEach((w,N)=>{h[N].onTopOfStack=p(w.id),h[N].getParentModal=()=>N<1?null:h.slice(0,N).reverse().find(m=>m.isOpen),h[N].getChildModal=()=>N===h.length-1?null:h.slice(N+1).find(m=>m.isOpen)}),h})};s.useEffect(()=>{Le=e},[e]);class a{constructor(c,h,p,w,N){q(this,"show",()=>{l(c=>c.map(h=>(h.id===this.id&&!h.isOpen&&(h.isOpen=!0,h.shouldRender=!0),h)))});q(this,"setOpen",c=>{c?this.show():this.close()});q(this,"close",()=>{l(c=>c.map(h=>{var p;return h.id===this.id&&h.isOpen&&(Object.keys(h.listeners).forEach(w=>{h.off(w)}),h.isOpen=!1,(p=h.onCloseCallback)==null||p.call(h)),h}))});q(this,"afterLeave",()=>{this.isOpen||l(c=>{const h=c.map(p=>{var w;return p.id===this.id&&!p.isOpen&&(p.shouldRender=!1,(w=p.afterLeaveCallback)==null||w.call(p),p.afterLeaveCallback=null),p});return this.index===0?[]:h})});q(this,"on",(c,h)=>{c=le(c),this.listeners[c]=this.listeners[c]??[],this.listeners[c].push(h)});q(this,"off",(c,h)=>{var p;c=le(c),h?this.listeners[c]=((p=this.listeners[c])==null?void 0:p.filter(w=>w!==h))??[]:delete this.listeners[c]});q(this,"emit",(c,...h)=>{var p;(p=this.listeners[le(c)])==null||p.forEach(w=>w(...h))});q(this,"registerEventListenersFromProps",c=>{const h=[];return Object.keys(c).filter(p=>p.startsWith("on")).forEach(p=>{const w=le(p).replace(/^on-/,"");this.on(w,c[p]),h.push(()=>this.off(w,c[p]))}),()=>h.forEach(p=>p())});q(this,"reload",(c={})=>{var p;let h=Object.keys(this.response.props);c.only&&(h=Ge(h,c.only)),c.except&&(h=$t(h,c.except)),(p=this.response)!=null&&p.url&&he.get(this.response.url,{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":h.join(","),"X-InertiaUI-Modal":Me(),"X-InertiaUI-Modal-Use-Router":0,"X-InertiaUI-Modal-Base-Url":oe}}).then(w=>{this.updateProps(w.data.props)})});q(this,"updateProps",c=>{Object.assign(this.props,c),l(h=>h)});if(this.id=h.id??Me(),this.isOpen=!1,this.shouldRender=!1,this.listeners={},this.component=c,this.props=h.props,this.response=h,this.config=p??{},this.onCloseCallback=w,this.afterLeaveCallback=N,re[this.id]){this.config={...this.config,...re[this.id].config??{}};const m=re[this.id].onClose,P=re[this.id].onAfterLeave;m&&(this.onCloseCallback=w?()=>{w(),m()}:m),P&&(this.afterLeaveCallback=N?()=>{N(),P()}:P),delete re[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 v=(y,c={},h=null,p=null)=>Ye(y.component).then(w=>o(w,y,c,h,p)),o=(y,c,h,p,w)=>{const N=new a(y,c,h,p,w);return N.index=e.length,l(m=>[...m,N]),N.show(),N};function b(y,c,h,p){if(!r[y])throw new Error(`The local modal "${y}" has not been registered.`);const w=o(null,{},c,h,p);return w.name=y,r[y].callback(w),w}const g=(y,c={})=>E(y,c.method??"get",c.data??{},c.headers??{},c.config??{},c.onClose,c.onAfterLeave,c.queryStringArrayFormat??"brackets",c.navigate??pe("navigate")).then(h=>{const p=c.listeners??{};return Object.keys(p).forEach(w=>{const N=le(w);h.on(N,p[w])}),h}),E=(y,c,h={},p={},w={},N=null,m=null,P="brackets",j=!1)=>{const B=Me();return new Promise((H,U)=>{if(y.startsWith("#")){H(b(y.substring(1),w,N,m));return}const[W,k]=Mt.mergeDataIntoQueryString(c,y||"",h,P);let u=j&&e.length===0;if(e.length===0&&(oe=typeof window<"u"?window.location.href:""),p={...p,Accept:"text/html, application/xhtml+xml","X-Requested-With":"XMLHttpRequest","X-Inertia":!0,"X-Inertia-Version":Ze,"X-InertiaUI-Modal":B,"X-InertiaUI-Modal-Use-Router":u?1:0,"X-InertiaUI-Modal-Base-Url":oe},u)return Ae=null,re[B]={config:w,onClose:N,onAfterLeave:m},te.router.visit(W,{method:c,data:k,headers:p,preserveScroll:!0,preserveState:!0,onError:U,onFinish:()=>{Wt(()=>Ae).then(H)}});he({url:W,method:c,data:k,headers:p}).then(d=>H(v(d.data,w,N,m))).catch(d=>{U(d)})})},f={stack:e,localModals:r,push:o,pushFromResponseData:v,closeAll:()=>{Le.reverse().forEach(y=>y.close())},reset:()=>l(()=>[]),visit:E,visitModal:g,registerLocalModal:(y,c)=>{i(h=>({...h,[y]:{name:y,callback:c}}))},removeLocalModal:y=>{i(c=>{const h={...c};return delete h[y],h})}};return T.jsx(me.Provider,{value:f,children:t})},ue=()=>{const t=s.useContext(me);if(t===null)throw new Error("useModalStack must be used within a ModalStackProvider");return t},Qe=["closeButton","closeExplicitly","maxWidth","paddingClasses","panelClasses","position","slideover"],Re=t=>{t.initialPage&&(Ze=t.initialPage.version),t.resolveComponent&&(Ye=t.resolveComponent)},Bt=(t,e)=>{Re(e);const n=({Component:r,props:i,key:l})=>{const a=()=>{const v=s.createElement(r,{key:l,...i});return typeof r.layout=="function"?r.layout(v):Array.isArray(r.layout)?r.layout.concat(v).reverse().reduce((b,g)=>s.createElement(g,i,b)):v};return T.jsxs(T.Fragment,{children:[a(),T.jsx(et,{})]})};return T.jsx(Je,{children:T.jsx(t,{...e,children:n})})},et=({children:t})=>{var v;const e=s.useContext(me);let n=!1,r=!1;s.useEffect(()=>te.router.on("start",()=>n=!0),[]),s.useEffect(()=>te.router.on("finish",()=>n=!1),[]),s.useEffect(()=>te.router.on("navigate",function(o){const b=o.detail.page.props._inertiaui_modal;if(!b){r&&e.closeAll();return}r=b,oe=b.baseUrl,e.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&&te.router.visit(b.baseUrl,{preserveScroll:!0,preserveState:!0})}).then(g=>{Ae=g})}),[]);const i=o=>(Le.length&&(o.headers["X-InertiaUI-Modal-Base-Url"]=oe),o);s.useEffect(()=>(he.interceptors.request.use(i),()=>he.interceptors.request.eject(i)),[]);const l=te.usePage(),a=s.useRef();return s.useEffect(()=>{var g,E;const o=(g=l.props)==null?void 0:g._inertiaui_modal,b=a.current;a.current=o,o&&b&&o.component===b.component&&o.url===b.url&&((E=e.stack[0])==null||E.updateProps(o.props??{}))},[(v=l.props)==null?void 0:v._inertiaui_modal]),T.jsxs(T.Fragment,{children:[t,e.stack.length>0&&T.jsx(tt,{index:0})]})},je=s.createContext(null);je.displayName="ModalIndexContext";const De=()=>{const t=s.useContext(je);if(t===void 0)throw new Error("useModalIndex must be used within a ModalIndexProvider");return t},tt=({index:t})=>{const{stack:e}=ue(),n=s.useMemo(()=>e[t],[e,t]);return(n==null?void 0:n.component)&&T.jsx(je.Provider,{value:t,children:T.jsx(n.component,{...n.props,onModalEvent:(...r)=>n.emit(...r)})})},$e=s.forwardRef(({name:t,children:e,onFocus:n=null,onBlur:r=null,onClose:i=null,onSuccess:l=null,...a},v)=>{const o=De(),{stack:b,registerLocalModal:g,removeLocalModal:E}=ue(),[F,S]=s.useState(null),f=s.useMemo(()=>t?F:b[o],[t,F,o,b]),y=s.useMemo(()=>{var m;return(m=b.find(P=>P.shouldRender&&P.index>(f==null?void 0:f.index)))==null?void 0:m.index},[o,b]),c=s.useMemo(()=>(f==null?void 0:f.config.slideover)??a.slideover??pe("type")==="slideover",[a.slideover]),h=s.useMemo(()=>({slideover:c,closeButton:a.closeButton??ne(c,"closeButton"),closeExplicitly:a.closeExplicitly??ne(c,"closeExplicitly"),maxWidth:a.maxWidth??ne(c,"maxWidth"),paddingClasses:a.paddingClasses??ne(c,"paddingClasses"),panelClasses:a.panelClasses??ne(c,"panelClasses"),position:a.position??ne(c,"position"),...f==null?void 0:f.config}),[a,f==null?void 0:f.config]);s.useEffect(()=>{if(t){let m=null;return g(t,P=>{m=P.registerEventListenersFromProps(a),S(P)}),()=>{m==null||m(),m=null,E(t)}}return f.registerEventListenersFromProps(a)},[t]);const p=s.useRef(f);s.useEffect(()=>{p.current=f},[f]),s.useEffect(()=>{f!==null&&(f.isOpen?l==null||l():i==null||i())},[f==null?void 0:f.isOpen]);const[w,N]=s.useState(!1);return s.useEffect(()=>{w&&f!==null&&f.isOpen&&(f.onTopOfStack?n==null||n():r==null||r()),N(!0)},[f==null?void 0:f.onTopOfStack]),s.useImperativeHandle(v,()=>({afterLeave:()=>{var m;return(m=p.current)==null?void 0:m.afterLeave()},close:()=>{var m;return(m=p.current)==null?void 0:m.close()},emit:(...m)=>{var P;return(P=p.current)==null?void 0:P.emit(...m)},getChildModal:()=>{var m;return(m=p.current)==null?void 0:m.getChildModal()},getParentModal:()=>{var m;return(m=p.current)==null?void 0:m.getParentModal()},reload:(...m)=>{var P;return(P=p.current)==null?void 0:P.reload(...m)},setOpen:()=>{var m;return(m=p.current)==null?void 0:m.setOpen()},get id(){var m;return(m=p.current)==null?void 0:m.id},get index(){var m;return(m=p.current)==null?void 0:m.index},get isOpen(){var m;return(m=p.current)==null?void 0:m.isOpen},get config(){var m;return(m=p.current)==null?void 0:m.config},get modalContext(){return p.current},get onTopOfStack(){var m;return(m=p.current)==null?void 0:m.onTopOfStack},get shouldRender(){var m;return(m=p.current)==null?void 0:m.shouldRender}}),[f]),(f==null?void 0:f.shouldRender)&&T.jsxs(T.Fragment,{children:[typeof e=="function"?e({afterLeave:f.afterLeave,close:f.close,config:h,emit:f.emit,getChildModal:f.getChildModal,getParentModal:f.getParentModal,id:f.id,index:f.index,isOpen:f.isOpen,modalContext:f,onTopOfStack:f.onTopOfStack,reload:f.reload,setOpen:f.setOpen,shouldRender:f.shouldRender}):e,y&&T.jsx(tt,{index:y})]})});$e.displayName="HeadlessModal";function nt(t){var e,n,r="";if(typeof t=="string"||typeof t=="number")r+=t;else if(typeof t=="object")if(Array.isArray(t)){var i=t.length;for(e=0;e<i;e++)t[e]&&(n=nt(t[e]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function be(){for(var t,e,n=0,r="",i=arguments.length;n<i;n++)(t=arguments[n])&&(e=nt(t))&&(r&&(r+=" "),r+=e);return r}var Ht=Object.defineProperty,Kt=(t,e,n)=>e in t?Ht(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Ue=(t,e,n)=>(Kt(t,typeof e!="symbol"?e+"":e,n),n);let qt=class{constructor(){Ue(this,"current",this.detect()),Ue(this,"handoffState","pending"),Ue(this,"currentId",0)}set(e){this.current!==e&&(this.handoffState="pending",this.currentId=0,this.current=e)}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"}},ge=new qt;function Xt(t){typeof queueMicrotask=="function"?queueMicrotask(t):Promise.resolve().then(t).catch(e=>setTimeout(()=>{throw e}))}function ye(){let t=[],e={addEventListener(n,r,i,l){return n.addEventListener(r,i,l),e.add(()=>n.removeEventListener(r,i,l))},requestAnimationFrame(...n){let r=requestAnimationFrame(...n);return e.add(()=>cancelAnimationFrame(r))},nextFrame(...n){return e.requestAnimationFrame(()=>e.requestAnimationFrame(...n))},setTimeout(...n){let r=setTimeout(...n);return e.add(()=>clearTimeout(r))},microTask(...n){let r={current:!0};return Xt(()=>{r.current&&n[0]()}),e.add(()=>{r.current=!1})},style(n,r,i){let l=n.style.getPropertyValue(r);return Object.assign(n.style,{[r]:i}),this.add(()=>{Object.assign(n.style,{[r]:l})})},group(n){let r=ye();return n(r),this.add(()=>r.dispose())},add(n){return t.includes(n)||t.push(n),()=>{let r=t.indexOf(n);if(r>=0)for(let i of t.splice(r,1))i()}},dispose(){for(let n of t.splice(0))n()}};return e}function rt(){let[t]=s.useState(ye);return s.useEffect(()=>()=>t.dispose(),[t]),t}let z=(t,e)=>{ge.isServer?s.useEffect(t,e):s.useLayoutEffect(t,e)};function at(t){let e=s.useRef(t);return z(()=>{e.current=t},[t]),e}let _=function(t){let e=at(t);return s.useCallback((...n)=>e.current(...n),[e])};function We(...t){return Array.from(new Set(t.flatMap(e=>typeof e=="string"?e.split(" "):[]))).filter(Boolean).join(" ")}function we(t,e,...n){if(t in e){let i=e[t];return typeof i=="function"?i(...n):i}let r=new Error(`Tried to handle "${t}" but there is no handler defined. Only defined handlers are: ${Object.keys(e).map(i=>`"${i}"`).join(", ")}.`);throw Error.captureStackTrace&&Error.captureStackTrace(r,we),r}var it=(t=>(t[t.None=0]="None",t[t.RenderStrategy=1]="RenderStrategy",t[t.Static=2]="Static",t))(it||{}),G=(t=>(t[t.Unmount=0]="Unmount",t[t.Hidden=1]="Hidden",t))(G||{});function st(){let t=Vt();return s.useCallback(e=>_t({mergeRefs:t,...e}),[t])}function _t({ourProps:t,theirProps:e,slot:n,defaultTag:r,features:i,visible:l=!0,name:a,mergeRefs:v}){v=v??zt;let o=lt(e,t);if(l)return xe(o,n,r,a,v);let b=i??0;if(b&2){let{static:g=!1,...E}=o;if(g)return xe(E,n,r,a,v)}if(b&1){let{unmount:g=!0,...E}=o;return we(g?0:1,{0(){return null},1(){return xe({...E,hidden:!0,style:{display:"none"}},n,r,a,v)}})}return xe(o,n,r,a,v)}function xe(t,e={},n,r,i){let{as:l=n,children:a,refName:v="ref",...o}=He(t,["unmount","static"]),b=t.ref!==void 0?{[v]:t.ref}:{},g=typeof a=="function"?a(e):a;"className"in o&&o.className&&typeof o.className=="function"&&(o.className=o.className(e)),o["aria-labelledby"]&&o["aria-labelledby"]===o.id&&(o["aria-labelledby"]=void 0);let E={};if(e){let F=!1,S=[];for(let[f,y]of Object.entries(e))typeof y=="boolean"&&(F=!0),y===!0&&S.push(f.replace(/([A-Z])/g,c=>`-${c.toLowerCase()}`));if(F){E["data-headlessui-state"]=S.join(" ");for(let f of S)E[`data-${f}`]=""}}if(l===s.Fragment&&(Object.keys(Y(o)).length>0||Object.keys(Y(E)).length>0))if(!s.isValidElement(g)||Array.isArray(g)&&g.length>1){if(Object.keys(Y(o)).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(Y(o)).concat(Object.keys(Y(E))).map(F=>` - ${F}`).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(F=>` - ${F}`).join(`
1
+ (function(I,l){typeof exports=="object"&&typeof module<"u"?l(exports,require("react"),require("react/jsx-runtime"),require("axios"),require("@inertiajs/react"),require("@inertiajs/core")):typeof define=="function"&&define.amd?define(["exports","react","react/jsx-runtime","axios","@inertiajs/react","@inertiajs/core"],l):(I=typeof globalThis<"u"?globalThis:I||self,l(I.InertiaUIModal={},I.React,I.jsxRuntime,I.Axios,I.react,I.core))})(this,function(I,l,N,he,te,Mt){"use strict";var Yn=Object.defineProperty;var Jn=(I,l,N)=>l in I?Yn(I,l,{enumerable:!0,configurable:!0,writable:!0,value:N}):I[l]=N;var _=(I,l,N)=>Jn(I,typeof l!="symbol"?l+"":l,N);function At(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:()=>t[n]})}}return e.default=t,Object.freeze(e)}const ie=At(l),le={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 jt{constructor(){this.config={},this.reset()}reset(){this.config=JSON.parse(JSON.stringify(le))}put(e,n){if(typeof e=="object"){this.config={type:e.type??le.type,navigate:e.navigate??le.navigate,modal:{...le.modal,...e.modal??{}},slideover:{...le.slideover,...e.slideover??{}}};return}const r=e.split(".");let i=this.config;for(let s=0;s<r.length-1;s++)i=i[r[s]]=i[r[s]]||{};i[r[r.length-1]]=n}get(e){if(typeof e>"u")return this.config;const n=e.split(".");let r=this.config;for(const i of n){if(r[i]===void 0)return null;r=r[i]}return r}}const ve=new jt,Lt=()=>ve.reset(),Dt=(t,e)=>ve.put(t,e),me=t=>ve.get(t),ne=(t,e)=>ve.get(t?`slideover.${e}`:`modal.${e}`),ze={modifiedElements:[],bodyState:{hasOverflowHidden:!1,originalPaddingRight:""},prepare(){const t=window.innerWidth-document.documentElement.clientWidth;this.bodyState.originalPaddingRight=document.body.style.paddingRight;const e=parseInt(window.getComputedStyle(document.body).paddingRight,10);document.body.style.paddingRight=`${e+t}px`,document.body.classList.contains("overflow-hidden")||(document.body.classList.add("overflow-hidden"),this.bodyState.hasOverflowHidden=!0),Array.from(document.body.children).forEach(n=>{!n.classList.contains("im-dialog")&&n.getAttribute("aria-hidden")!=="true"&&(n.setAttribute("aria-hidden","true"),this.modifiedElements.push(n))})},cleanup(){this.bodyState.hasOverflowHidden&&(document.body.classList.remove("overflow-hidden"),this.bodyState.hasOverflowHidden=!1),document.body.style.paddingRight=this.bodyState.originalPaddingRight,this.bodyState.originalPaddingRight="",this.modifiedElements.forEach(t=>{t.removeAttribute("aria-hidden")}),this.modifiedElements=[]}};function Me(t="inertiaui_modal_"){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`${t}${crypto.randomUUID()}`:`${t}${Date.now().toString(36)}_${Math.random().toString(36).substr(2,9)}`}function $t(t,e){return Array.isArray(t)?t.filter(n=>!e.includes(n)):Object.keys(t).reduce((n,r)=>(e.includes(r)||(n[r]=t[r]),n),{})}function Ge(t,e){return Array.isArray(t)?t.filter(n=>e.includes(n)):e.reduce((n,r)=>(r in t&&(n[r]=t[r]),n),{})}function Ut(t){return Array.isArray(t)?t.filter(e=>e!==null):Object.keys(t).reduce((e,n)=>(n in t&&t[n]!==null&&(e[n]=t[n]),e),{})}function Wt(t,e=3,n=10){return new Promise((r,i)=>{const s=t();if(s){r(s);return}let a=e*1e3/n;const v=setInterval(()=>{const u=t();u&&(clearInterval(v),r(u)),--a<=0&&(clearInterval(v),i(new Error("Condition not met in time")))},n)})}function se(t){return t?(t=t.replace(/_/g,"-"),t=t.replace(/-+/g,"-"),/[A-Z]/.test(t)?(t=t.replace(/\s+/g,"").replace(/_/g,"").replace(/(?:^|\s|-)+([A-Za-z])/g,(e,n)=>n.toUpperCase()),t=t.replace(/(.)(?=[A-Z])/g,"$1-"),t.toLowerCase()):t):""}const pe=l.createContext(null);pe.displayName="ModalStackContext";let Ze=null,Ye=null,ue=null,Ae=null,je=[],re={};const Je=({children:t})=>{const[e,n]=l.useState([]),[r,i]=l.useState({}),s=y=>{n(c=>{const h=y([...c]),m=w=>{var T;return h.length<2?!0:((T=h.map(p=>({id:p.id,shouldRender:p.shouldRender})).reverse().find(p=>p.shouldRender))==null?void 0:T.id)===w};return h.forEach((w,T)=>{h[T].onTopOfStack=m(w.id),h[T].getParentModal=()=>T<1?null:h.slice(0,T).reverse().find(p=>p.isOpen),h[T].getChildModal=()=>T===h.length-1?null:h.slice(T+1).find(p=>p.isOpen)}),h})};l.useEffect(()=>{je=e},[e]);class a{constructor(c,h,m,w,T){_(this,"show",()=>{s(c=>c.map(h=>(h.id===this.id&&!h.isOpen&&(h.isOpen=!0,h.shouldRender=!0),h)))});_(this,"setOpen",c=>{c?this.show():this.close()});_(this,"close",()=>{s(c=>c.map(h=>{var m;return h.id===this.id&&h.isOpen&&(Object.keys(h.listeners).forEach(w=>{h.off(w)}),h.isOpen=!1,(m=h.onCloseCallback)==null||m.call(h)),h}))});_(this,"afterLeave",()=>{this.isOpen||s(c=>{const h=c.map(m=>{var w;return m.id===this.id&&!m.isOpen&&(m.shouldRender=!1,(w=m.afterLeaveCallback)==null||w.call(m),m.afterLeaveCallback=null),m});return this.index===0?[]:h})});_(this,"on",(c,h)=>{c=se(c),this.listeners[c]=this.listeners[c]??[],this.listeners[c].push(h)});_(this,"off",(c,h)=>{var m;c=se(c),h?this.listeners[c]=((m=this.listeners[c])==null?void 0:m.filter(w=>w!==h))??[]:delete this.listeners[c]});_(this,"emit",(c,...h)=>{var m;(m=this.listeners[se(c)])==null||m.forEach(w=>w(...h))});_(this,"registerEventListenersFromProps",c=>{const h=[];return Object.keys(c).filter(m=>m.startsWith("on")).forEach(m=>{const w=se(m).replace(/^on-/,"");this.on(w,c[m]),h.push(()=>this.off(w,c[m]))}),()=>h.forEach(m=>m())});_(this,"reload",(c={})=>{var m;let h=Object.keys(this.response.props);c.only&&(h=Ge(h,c.only)),c.except&&(h=$t(h,c.except)),(m=this.response)!=null&&m.url&&he.get(this.response.url,{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":h.join(","),"X-InertiaUI-Modal":Me(),"X-InertiaUI-Modal-Use-Router":0,"X-InertiaUI-Modal-Base-Url":ue}}).then(w=>{this.updateProps(w.data.props)})});_(this,"updateProps",c=>{Object.assign(this.props,c),s(h=>h)});if(this.id=h.id??Me(),this.isOpen=!1,this.shouldRender=!1,this.listeners={},this.component=c,this.props=h.props,this.response=h,this.config=m??{},this.onCloseCallback=w,this.afterLeaveCallback=T,re[this.id]){this.config={...this.config,...re[this.id].config??{}};const p=re[this.id].onClose,M=re[this.id].onAfterLeave;p&&(this.onCloseCallback=w?()=>{w(),p()}:p),M&&(this.afterLeaveCallback=T?()=>{T(),M()}:M),delete re[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 v=(y,c={},h=null,m=null)=>Ye(y.component).then(w=>u(w,y,c,h,m)),u=(y,c,h,m,w)=>{const T=new a(y,c,h,m,w);return T.index=e.length,s(p=>[...p,T]),T.show(),T};function b(y,c,h,m){if(!r[y])throw new Error(`The local modal "${y}" has not been registered.`);const w=u(null,{},c,h,m);return w.name=y,r[y].callback(w),w}const g=(y,c={})=>x(y,c.method??"get",c.data??{},c.headers??{},c.config??{},c.onClose,c.onAfterLeave,c.queryStringArrayFormat??"brackets",c.navigate??me("navigate")).then(h=>{const m=c.listeners??{};return Object.keys(m).forEach(w=>{const T=se(w);h.on(T,m[w])}),h}),x=(y,c,h={},m={},w={},T=null,p=null,M="brackets",L=!1)=>{const B=Me();return new Promise((H,U)=>{if(y.startsWith("#")){H(b(y.substring(1),w,T,p));return}const[W,k]=Mt.mergeDataIntoQueryString(c,y||"",h,M);let o=L&&e.length===0;if(e.length===0&&(ue=typeof window<"u"?window.location.href:""),m={...m,Accept:"text/html, application/xhtml+xml","X-Requested-With":"XMLHttpRequest","X-Inertia":!0,"X-Inertia-Version":Ze,"X-InertiaUI-Modal":B,"X-InertiaUI-Modal-Use-Router":o?1:0,"X-InertiaUI-Modal-Base-Url":ue},o)return Ae=null,re[B]={config:w,onClose:T,onAfterLeave:p},te.router.visit(W,{method:c,data:k,headers:m,preserveScroll:!0,preserveState:!0,onError:U,onFinish:()=>{Wt(()=>Ae).then(H)}});he({url:W,method:c,data:k,headers:m}).then(d=>H(v(d.data,w,T,p))).catch(d=>{U(d)})})},f={stack:e,localModals:r,push:u,pushFromResponseData:v,closeAll:()=>{je.reverse().forEach(y=>y.close())},reset:()=>s(()=>[]),visit:x,visitModal:g,registerLocalModal:(y,c)=>{i(h=>({...h,[y]:{name:y,callback:c}}))},removeLocalModal:y=>{i(c=>{const h={...c};return delete h[y],h})}};return N.jsx(pe.Provider,{value:f,children:t})},oe=()=>{const t=l.useContext(pe);if(t===null)throw new Error("useModalStack must be used within a ModalStackProvider");return t},Qe=["closeButton","closeExplicitly","maxWidth","paddingClasses","panelClasses","position","slideover"],Re=t=>{t.initialPage&&(Ze=t.initialPage.version),t.resolveComponent&&(Ye=t.resolveComponent)},Bt=(t,e)=>{Re(e);const n=({Component:r,props:i,key:s})=>{const a=()=>{const v=l.createElement(r,{key:s,...i});return typeof r.layout=="function"?r.layout(v):Array.isArray(r.layout)?r.layout.concat(v).reverse().reduce((b,g)=>l.createElement(g,i,b)):v};return N.jsxs(N.Fragment,{children:[a(),N.jsx(et,{})]})};return N.jsx(Je,{children:N.jsx(t,{...e,children:n})})},et=({children:t})=>{var v;const e=l.useContext(pe);let n=!1,r=!1;l.useEffect(()=>te.router.on("start",()=>n=!0),[]),l.useEffect(()=>te.router.on("finish",()=>n=!1),[]),l.useEffect(()=>te.router.on("navigate",function(u){const b=u.detail.page.props._inertiaui_modal;if(!b){r&&e.closeAll();return}r=b,ue=b.baseUrl,e.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&&te.router.visit(b.baseUrl,{preserveScroll:!0,preserveState:!0})}).then(g=>{Ae=g})}),[]);const i=u=>(je.length&&(u.headers["X-InertiaUI-Modal-Base-Url"]=ue),u);l.useEffect(()=>(he.interceptors.request.use(i),()=>he.interceptors.request.eject(i)),[]);const s=te.usePage(),a=l.useRef();return l.useEffect(()=>{var g,x;const u=(g=s.props)==null?void 0:g._inertiaui_modal,b=a.current;a.current=u,u&&b&&u.component===b.component&&u.url===b.url&&((x=e.stack[0])==null||x.updateProps(u.props??{}))},[(v=s.props)==null?void 0:v._inertiaui_modal]),N.jsxs(N.Fragment,{children:[t,e.stack.length>0&&N.jsx(tt,{index:0})]})},Le=l.createContext(null);Le.displayName="ModalIndexContext";const De=()=>{const t=l.useContext(Le);if(t===void 0)throw new Error("useModalIndex must be used within a ModalIndexProvider");return t},tt=({index:t})=>{const{stack:e}=oe(),n=l.useMemo(()=>e[t],[e,t]);return(n==null?void 0:n.component)&&N.jsx(Le.Provider,{value:t,children:N.jsx(n.component,{...n.props,onModalEvent:(...r)=>n.emit(...r)})})},$e=l.forwardRef(({name:t,children:e,onFocus:n=null,onBlur:r=null,onClose:i=null,onSuccess:s=null,...a},v)=>{const u=De(),{stack:b,registerLocalModal:g,removeLocalModal:x}=oe(),[O,S]=l.useState(null),f=l.useMemo(()=>t?O:b[u],[t,O,u,b]),y=l.useMemo(()=>{var p;return(p=b.find(M=>M.shouldRender&&M.index>(f==null?void 0:f.index)))==null?void 0:p.index},[u,b]),c=l.useMemo(()=>(f==null?void 0:f.config.slideover)??a.slideover??me("type")==="slideover",[a.slideover]),h=l.useMemo(()=>({slideover:c,closeButton:a.closeButton??ne(c,"closeButton"),closeExplicitly:a.closeExplicitly??ne(c,"closeExplicitly"),maxWidth:a.maxWidth??ne(c,"maxWidth"),paddingClasses:a.paddingClasses??ne(c,"paddingClasses"),panelClasses:a.panelClasses??ne(c,"panelClasses"),position:a.position??ne(c,"position"),...f==null?void 0:f.config}),[a,f==null?void 0:f.config]);l.useEffect(()=>{if(t){let p=null;return g(t,M=>{p=M.registerEventListenersFromProps(a),S(M)}),()=>{p==null||p(),p=null,x(t)}}return f.registerEventListenersFromProps(a)},[t]);const m=l.useRef(f);l.useEffect(()=>{m.current=f},[f]),l.useEffect(()=>{f!==null&&(f.isOpen?s==null||s():i==null||i())},[f==null?void 0:f.isOpen]);const[w,T]=l.useState(!1);return l.useEffect(()=>{w&&f!==null&&f.isOpen&&(f.onTopOfStack?n==null||n():r==null||r()),T(!0)},[f==null?void 0:f.onTopOfStack]),l.useImperativeHandle(v,()=>({afterLeave:()=>{var p;return(p=m.current)==null?void 0:p.afterLeave()},close:()=>{var p;return(p=m.current)==null?void 0:p.close()},emit:(...p)=>{var M;return(M=m.current)==null?void 0:M.emit(...p)},getChildModal:()=>{var p;return(p=m.current)==null?void 0:p.getChildModal()},getParentModal:()=>{var p;return(p=m.current)==null?void 0:p.getParentModal()},reload:(...p)=>{var M;return(M=m.current)==null?void 0:M.reload(...p)},setOpen:()=>{var p;return(p=m.current)==null?void 0:p.setOpen()},get id(){var p;return(p=m.current)==null?void 0:p.id},get index(){var p;return(p=m.current)==null?void 0:p.index},get isOpen(){var p;return(p=m.current)==null?void 0:p.isOpen},get config(){var p;return(p=m.current)==null?void 0:p.config},get modalContext(){return m.current},get onTopOfStack(){var p;return(p=m.current)==null?void 0:p.onTopOfStack},get shouldRender(){var p;return(p=m.current)==null?void 0:p.shouldRender}}),[f]),(f==null?void 0:f.shouldRender)&&N.jsxs(N.Fragment,{children:[typeof e=="function"?e({afterLeave:f.afterLeave,close:f.close,config:h,emit:f.emit,getChildModal:f.getChildModal,getParentModal:f.getParentModal,id:f.id,index:f.index,isOpen:f.isOpen,modalContext:f,onTopOfStack:f.onTopOfStack,reload:f.reload,setOpen:f.setOpen,shouldRender:f.shouldRender}):e,y&&N.jsx(tt,{index:y})]})});$e.displayName="HeadlessModal";function nt(t){var e,n,r="";if(typeof t=="string"||typeof t=="number")r+=t;else if(typeof t=="object")if(Array.isArray(t)){var i=t.length;for(e=0;e<i;e++)t[e]&&(n=nt(t[e]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function be(){for(var t,e,n=0,r="",i=arguments.length;n<i;n++)(t=arguments[n])&&(e=nt(t))&&(r&&(r+=" "),r+=e);return r}var Ht=Object.defineProperty,Kt=(t,e,n)=>e in t?Ht(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Ue=(t,e,n)=>(Kt(t,typeof e!="symbol"?e+"":e,n),n);let _t=class{constructor(){Ue(this,"current",this.detect()),Ue(this,"handoffState","pending"),Ue(this,"currentId",0)}set(e){this.current!==e&&(this.handoffState="pending",this.currentId=0,this.current=e)}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"}},ge=new _t;function qt(t){typeof queueMicrotask=="function"?queueMicrotask(t):Promise.resolve().then(t).catch(e=>setTimeout(()=>{throw e}))}function ye(){let t=[],e={addEventListener(n,r,i,s){return n.addEventListener(r,i,s),e.add(()=>n.removeEventListener(r,i,s))},requestAnimationFrame(...n){let r=requestAnimationFrame(...n);return e.add(()=>cancelAnimationFrame(r))},nextFrame(...n){return e.requestAnimationFrame(()=>e.requestAnimationFrame(...n))},setTimeout(...n){let r=setTimeout(...n);return e.add(()=>clearTimeout(r))},microTask(...n){let r={current:!0};return qt(()=>{r.current&&n[0]()}),e.add(()=>{r.current=!1})},style(n,r,i){let s=n.style.getPropertyValue(r);return Object.assign(n.style,{[r]:i}),this.add(()=>{Object.assign(n.style,{[r]:s})})},group(n){let r=ye();return n(r),this.add(()=>r.dispose())},add(n){return t.includes(n)||t.push(n),()=>{let r=t.indexOf(n);if(r>=0)for(let i of t.splice(r,1))i()}},dispose(){for(let n of t.splice(0))n()}};return e}function rt(){let[t]=l.useState(ye);return l.useEffect(()=>()=>t.dispose(),[t]),t}let z=(t,e)=>{ge.isServer?l.useEffect(t,e):l.useLayoutEffect(t,e)};function at(t){let e=l.useRef(t);return z(()=>{e.current=t},[t]),e}let X=function(t){let e=at(t);return l.useCallback((...n)=>e.current(...n),[e])};function We(...t){return Array.from(new Set(t.flatMap(e=>typeof e=="string"?e.split(" "):[]))).filter(Boolean).join(" ")}function we(t,e,...n){if(t in e){let i=e[t];return typeof i=="function"?i(...n):i}let r=new Error(`Tried to handle "${t}" but there is no handler defined. Only defined handlers are: ${Object.keys(e).map(i=>`"${i}"`).join(", ")}.`);throw Error.captureStackTrace&&Error.captureStackTrace(r,we),r}var it=(t=>(t[t.None=0]="None",t[t.RenderStrategy=1]="RenderStrategy",t[t.Static=2]="Static",t))(it||{}),G=(t=>(t[t.Unmount=0]="Unmount",t[t.Hidden=1]="Hidden",t))(G||{});function lt(){let t=Vt();return l.useCallback(e=>Xt({mergeRefs:t,...e}),[t])}function Xt({ourProps:t,theirProps:e,slot:n,defaultTag:r,features:i,visible:s=!0,name:a,mergeRefs:v}){v=v??zt;let u=st(e,t);if(s)return xe(u,n,r,a,v);let b=i??0;if(b&2){let{static:g=!1,...x}=u;if(g)return xe(x,n,r,a,v)}if(b&1){let{unmount:g=!0,...x}=u;return we(g?0:1,{0(){return null},1(){return xe({...x,hidden:!0,style:{display:"none"}},n,r,a,v)}})}return xe(u,n,r,a,v)}function xe(t,e={},n,r,i){let{as:s=n,children:a,refName:v="ref",...u}=He(t,["unmount","static"]),b=t.ref!==void 0?{[v]:t.ref}:{},g=typeof a=="function"?a(e):a;"className"in u&&u.className&&typeof u.className=="function"&&(u.className=u.className(e)),u["aria-labelledby"]&&u["aria-labelledby"]===u.id&&(u["aria-labelledby"]=void 0);let x={};if(e){let O=!1,S=[];for(let[f,y]of Object.entries(e))typeof y=="boolean"&&(O=!0),y===!0&&S.push(f.replace(/([A-Z])/g,c=>`-${c.toLowerCase()}`));if(O){x["data-headlessui-state"]=S.join(" ");for(let f of S)x[`data-${f}`]=""}}if(s===l.Fragment&&(Object.keys(Y(u)).length>0||Object.keys(Y(x)).length>0))if(!l.isValidElement(g)||Array.isArray(g)&&g.length>1){if(Object.keys(Y(u)).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(Y(u)).concat(Object.keys(Y(x))).map(O=>` - ${O}`).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(O=>` - ${O}`).join(`
3
3
  `)].join(`
4
- `))}else{let F=g.props,S=F==null?void 0:F.className,f=typeof S=="function"?(...h)=>We(S(...h),o.className):We(S,o.className),y=f?{className:f}:{},c=lt(g.props,Y(He(o,["ref"])));for(let h in E)h in c&&delete E[h];return s.cloneElement(g,Object.assign({},c,E,b,{ref:i(Gt(g),b.ref)},y))}return s.createElement(l,Object.assign({},He(o,["ref"]),l!==s.Fragment&&b,l!==s.Fragment&&E),g)}function Vt(){let t=s.useRef([]),e=s.useCallback(n=>{for(let r of t.current)r!=null&&(typeof r=="function"?r(n):r.current=n)},[]);return(...n)=>{if(!n.every(r=>r==null))return t.current=n,e}}function zt(...t){return t.every(e=>e==null)?void 0:e=>{for(let n of t)n!=null&&(typeof n=="function"?n(e):n.current=e)}}function lt(...t){if(t.length===0)return{};if(t.length===1)return t[0];let e={},n={};for(let r of t)for(let i in r)i.startsWith("on")&&typeof r[i]=="function"?(n[i]!=null||(n[i]=[]),n[i].push(r[i])):e[i]=r[i];if(e.disabled||e["aria-disabled"])for(let r in n)/^(on(?:Click|Pointer|Mouse|Key)(?:Down|Up|Press)?)$/.test(r)&&(n[r]=[i=>{var l;return(l=i==null?void 0:i.preventDefault)==null?void 0:l.call(i)}]);for(let r in n)Object.assign(e,{[r](i,...l){let a=n[r];for(let v of a){if((i instanceof Event||(i==null?void 0:i.nativeEvent)instanceof Event)&&i.defaultPrevented)return;v(i,...l)}}});return e}function Be(t){var e;return Object.assign(s.forwardRef(t),{displayName:(e=t.displayName)!=null?e:t.name})}function Y(t){let e=Object.assign({},t);for(let n in e)e[n]===void 0&&delete e[n];return e}function He(t,e=[]){let n=Object.assign({},t);for(let r of e)r in n&&delete n[r];return n}function Gt(t){return s.version.split(".")[0]>="19"?t.props.ref:t.ref}let Zt=Symbol();function ot(...t){let e=s.useRef(t);s.useEffect(()=>{e.current=t},[t]);let n=_(r=>{for(let i of e.current)i!=null&&(typeof i=="function"?i(r):i.current=r)});return t.every(r=>r==null||(r==null?void 0:r[Zt]))?void 0:n}function Yt(t=0){let[e,n]=s.useState(t),r=s.useCallback(o=>n(o),[e]),i=s.useCallback(o=>n(b=>b|o),[e]),l=s.useCallback(o=>(e&o)===o,[e]),a=s.useCallback(o=>n(b=>b&~o),[n]),v=s.useCallback(o=>n(b=>b^o),[n]);return{flags:e,setFlag:r,addFlag:i,hasFlag:l,removeFlag:a,toggleFlag:v}}var ut,dt;typeof process<"u"&&typeof globalThis<"u"&&typeof Element<"u"&&((ut=process==null?void 0:process.env)==null?void 0:ut.NODE_ENV)==="test"&&typeof((dt=Element==null?void 0:Element.prototype)==null?void 0:dt.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 Jt=(t=>(t[t.None=0]="None",t[t.Closed=1]="Closed",t[t.Enter=2]="Enter",t[t.Leave=4]="Leave",t))(Jt||{});function Qt(t){let e={};for(let n in t)t[n]===!0&&(e[`data-${n}`]="");return e}function Rt(t,e,n,r){let[i,l]=s.useState(n),{hasFlag:a,addFlag:v,removeFlag:o}=Yt(t&&i?3:0),b=s.useRef(!1),g=s.useRef(!1),E=rt();return z(()=>{var F;if(t){if(n&&l(!0),!e){n&&v(3);return}return(F=r==null?void 0:r.start)==null||F.call(r,n),en(e,{inFlight:b,prepare(){g.current?g.current=!1:g.current=b.current,b.current=!0,!g.current&&(n?(v(3),o(4)):(v(4),o(2)))},run(){g.current?n?(o(3),v(4)):(o(4),v(3)):n?o(1):v(1)},done(){var S;g.current&&typeof e.getAnimations=="function"&&e.getAnimations().length>0||(b.current=!1,o(7),n||l(!1),(S=r==null?void 0:r.end)==null||S.call(r,n))}})}},[t,n,e,E]),t?[i,{closed:a(1),enter:a(2),leave:a(4),transition:a(2)||a(4)}]:[n,{closed:void 0,enter:void 0,leave:void 0,transition:void 0}]}function en(t,{prepare:e,run:n,done:r,inFlight:i}){let l=ye();return nn(t,{prepare:e,inFlight:i}),l.nextFrame(()=>{n(),l.requestAnimationFrame(()=>{l.add(tn(t,r))})}),l.dispose}function tn(t,e){var n,r;let i=ye();if(!t)return i.dispose;let l=!1;i.add(()=>{l=!0});let a=(r=(n=t.getAnimations)==null?void 0:n.call(t).filter(v=>v instanceof CSSTransition))!=null?r:[];return a.length===0?(e(),i.dispose):(Promise.allSettled(a.map(v=>v.finished)).then(()=>{l||e()}),i.dispose)}function nn(t,{inFlight:e,prepare:n}){if(e!=null&&e.current){n();return}let r=t.style.transition;t.style.transition="none",n(),t.offsetHeight,t.style.transition=r}/*!
4
+ `))}else{let O=g.props,S=O==null?void 0:O.className,f=typeof S=="function"?(...h)=>We(S(...h),u.className):We(S,u.className),y=f?{className:f}:{},c=st(g.props,Y(He(u,["ref"])));for(let h in x)h in c&&delete x[h];return l.cloneElement(g,Object.assign({},c,x,b,{ref:i(Gt(g),b.ref)},y))}return l.createElement(s,Object.assign({},He(u,["ref"]),s!==l.Fragment&&b,s!==l.Fragment&&x),g)}function Vt(){let t=l.useRef([]),e=l.useCallback(n=>{for(let r of t.current)r!=null&&(typeof r=="function"?r(n):r.current=n)},[]);return(...n)=>{if(!n.every(r=>r==null))return t.current=n,e}}function zt(...t){return t.every(e=>e==null)?void 0:e=>{for(let n of t)n!=null&&(typeof n=="function"?n(e):n.current=e)}}function st(...t){if(t.length===0)return{};if(t.length===1)return t[0];let e={},n={};for(let r of t)for(let i in r)i.startsWith("on")&&typeof r[i]=="function"?(n[i]!=null||(n[i]=[]),n[i].push(r[i])):e[i]=r[i];if(e.disabled||e["aria-disabled"])for(let r in n)/^(on(?:Click|Pointer|Mouse|Key)(?:Down|Up|Press)?)$/.test(r)&&(n[r]=[i=>{var s;return(s=i==null?void 0:i.preventDefault)==null?void 0:s.call(i)}]);for(let r in n)Object.assign(e,{[r](i,...s){let a=n[r];for(let v of a){if((i instanceof Event||(i==null?void 0:i.nativeEvent)instanceof Event)&&i.defaultPrevented)return;v(i,...s)}}});return e}function Be(t){var e;return Object.assign(l.forwardRef(t),{displayName:(e=t.displayName)!=null?e:t.name})}function Y(t){let e=Object.assign({},t);for(let n in e)e[n]===void 0&&delete e[n];return e}function He(t,e=[]){let n=Object.assign({},t);for(let r of e)r in n&&delete n[r];return n}function Gt(t){return l.version.split(".")[0]>="19"?t.props.ref:t.ref}let Zt=Symbol();function ut(...t){let e=l.useRef(t);l.useEffect(()=>{e.current=t},[t]);let n=X(r=>{for(let i of e.current)i!=null&&(typeof i=="function"?i(r):i.current=r)});return t.every(r=>r==null||(r==null?void 0:r[Zt]))?void 0:n}function Yt(t=0){let[e,n]=l.useState(t),r=l.useCallback(u=>n(u),[e]),i=l.useCallback(u=>n(b=>b|u),[e]),s=l.useCallback(u=>(e&u)===u,[e]),a=l.useCallback(u=>n(b=>b&~u),[n]),v=l.useCallback(u=>n(b=>b^u),[n]);return{flags:e,setFlag:r,addFlag:i,hasFlag:s,removeFlag:a,toggleFlag:v}}var ot,dt;typeof process<"u"&&typeof globalThis<"u"&&typeof Element<"u"&&((ot=process==null?void 0:process.env)==null?void 0:ot.NODE_ENV)==="test"&&typeof((dt=Element==null?void 0:Element.prototype)==null?void 0:dt.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 Jt=(t=>(t[t.None=0]="None",t[t.Closed=1]="Closed",t[t.Enter=2]="Enter",t[t.Leave=4]="Leave",t))(Jt||{});function Qt(t){let e={};for(let n in t)t[n]===!0&&(e[`data-${n}`]="");return e}function Rt(t,e,n,r){let[i,s]=l.useState(n),{hasFlag:a,addFlag:v,removeFlag:u}=Yt(t&&i?3:0),b=l.useRef(!1),g=l.useRef(!1),x=rt();return z(()=>{var O;if(t){if(n&&s(!0),!e){n&&v(3);return}return(O=r==null?void 0:r.start)==null||O.call(r,n),en(e,{inFlight:b,prepare(){g.current?g.current=!1:g.current=b.current,b.current=!0,!g.current&&(n?(v(3),u(4)):(v(4),u(2)))},run(){g.current?n?(u(3),v(4)):(u(4),v(3)):n?u(1):v(1)},done(){var S;g.current&&typeof e.getAnimations=="function"&&e.getAnimations().length>0||(b.current=!1,u(7),n||s(!1),(S=r==null?void 0:r.end)==null||S.call(r,n))}})}},[t,n,e,x]),t?[i,{closed:a(1),enter:a(2),leave:a(4),transition:a(2)||a(4)}]:[n,{closed:void 0,enter:void 0,leave:void 0,transition:void 0}]}function en(t,{prepare:e,run:n,done:r,inFlight:i}){let s=ye();return nn(t,{prepare:e,inFlight:i}),s.nextFrame(()=>{n(),s.requestAnimationFrame(()=>{s.add(tn(t,r))})}),s.dispose}function tn(t,e){var n,r;let i=ye();if(!t)return i.dispose;let s=!1;i.add(()=>{s=!0});let a=(r=(n=t.getAnimations)==null?void 0:n.call(t).filter(v=>v instanceof CSSTransition))!=null?r:[];return a.length===0?(e(),i.dispose):(Promise.allSettled(a.map(v=>v.finished)).then(()=>{s||e()}),i.dispose)}function nn(t,{inFlight:e,prepare:n}){if(e!=null&&e.current){n();return}let r=t.style.transition;t.style.transition="none",n(),t.offsetHeight,t.style.transition=r}/*!
6
6
  * tabbable 6.2.0
7
7
  * @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
8
- */var ct=["input:not([inert])","select:not([inert])","textarea:not([inert])","a[href]:not([inert])","button:not([inert])","[tabindex]:not(slot):not([inert])","audio[controls]:not([inert])","video[controls]:not([inert])",'[contenteditable]:not([contenteditable="false"]):not([inert])',"details>summary:first-of-type:not([inert])","details:not([inert])"],Ee=ct.join(","),ft=typeof Element>"u",J=ft?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,Se=!ft&&Element.prototype.getRootNode?function(t){var e;return t==null||(e=t.getRootNode)===null||e===void 0?void 0:e.call(t)}:function(t){return t==null?void 0:t.ownerDocument},Ne=function t(e,n){var r;n===void 0&&(n=!0);var i=e==null||(r=e.getAttribute)===null||r===void 0?void 0:r.call(e,"inert"),l=i===""||i==="true",a=l||n&&e&&t(e.parentNode);return a},rn=function(e){var n,r=e==null||(n=e.getAttribute)===null||n===void 0?void 0:n.call(e,"contenteditable");return r===""||r==="true"},ht=function(e,n,r){if(Ne(e))return[];var i=Array.prototype.slice.apply(e.querySelectorAll(Ee));return n&&J.call(e,Ee)&&i.unshift(e),i=i.filter(r),i},vt=function t(e,n,r){for(var i=[],l=Array.from(e);l.length;){var a=l.shift();if(!Ne(a,!1))if(a.tagName==="SLOT"){var v=a.assignedElements(),o=v.length?v:a.children,b=t(o,!0,r);r.flatten?i.push.apply(i,b):i.push({scopeParent:a,candidates:b})}else{var g=J.call(a,Ee);g&&r.filter(a)&&(n||!e.includes(a))&&i.push(a);var E=a.shadowRoot||typeof r.getShadowRoot=="function"&&r.getShadowRoot(a),F=!Ne(E,!1)&&(!r.shadowRootFilter||r.shadowRootFilter(a));if(E&&F){var S=t(E===!0?a.children:E.children,!0,r);r.flatten?i.push.apply(i,S):i.push({scopeParent:a,candidates:S})}else l.unshift.apply(l,a.children)}}return i},pt=function(e){return!isNaN(parseInt(e.getAttribute("tabindex"),10))},Q=function(e){if(!e)throw new Error("No node provided");return e.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(e.tagName)||rn(e))&&!pt(e)?0:e.tabIndex},an=function(e,n){var r=Q(e);return r<0&&n&&!pt(e)?0:r},sn=function(e,n){return e.tabIndex===n.tabIndex?e.documentOrder-n.documentOrder:e.tabIndex-n.tabIndex},mt=function(e){return e.tagName==="INPUT"},ln=function(e){return mt(e)&&e.type==="hidden"},on=function(e){var n=e.tagName==="DETAILS"&&Array.prototype.slice.apply(e.children).some(function(r){return r.tagName==="SUMMARY"});return n},un=function(e,n){for(var r=0;r<e.length;r++)if(e[r].checked&&e[r].form===n)return e[r]},dn=function(e){if(!e.name)return!0;var n=e.form||Se(e),r=function(v){return n.querySelectorAll('input[type="radio"][name="'+v+'"]')},i;if(typeof window<"u"&&typeof window.CSS<"u"&&typeof window.CSS.escape=="function")i=r(window.CSS.escape(e.name));else try{i=r(e.name)}catch(a){return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",a.message),!1}var l=un(i,e.form);return!l||l===e},cn=function(e){return mt(e)&&e.type==="radio"},fn=function(e){return cn(e)&&!dn(e)},hn=function(e){var n,r=e&&Se(e),i=(n=r)===null||n===void 0?void 0:n.host,l=!1;if(r&&r!==e){var a,v,o;for(l=!!((a=i)!==null&&a!==void 0&&(v=a.ownerDocument)!==null&&v!==void 0&&v.contains(i)||e!=null&&(o=e.ownerDocument)!==null&&o!==void 0&&o.contains(e));!l&&i;){var b,g,E;r=Se(i),i=(b=r)===null||b===void 0?void 0:b.host,l=!!((g=i)!==null&&g!==void 0&&(E=g.ownerDocument)!==null&&E!==void 0&&E.contains(i))}}return l},bt=function(e){var n=e.getBoundingClientRect(),r=n.width,i=n.height;return r===0&&i===0},vn=function(e,n){var r=n.displayCheck,i=n.getShadowRoot;if(getComputedStyle(e).visibility==="hidden")return!0;var l=J.call(e,"details>summary:first-of-type"),a=l?e.parentElement:e;if(J.call(a,"details:not([open]) *"))return!0;if(!r||r==="full"||r==="legacy-full"){if(typeof i=="function"){for(var v=e;e;){var o=e.parentElement,b=Se(e);if(o&&!o.shadowRoot&&i(o)===!0)return bt(e);e.assignedSlot?e=e.assignedSlot:!o&&b!==e.ownerDocument?e=b.host:e=o}e=v}if(hn(e))return!e.getClientRects().length;if(r!=="legacy-full")return!0}else if(r==="non-zero-area")return bt(e);return!1},pn=function(e){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(e.tagName))for(var n=e.parentElement;n;){if(n.tagName==="FIELDSET"&&n.disabled){for(var r=0;r<n.children.length;r++){var i=n.children.item(r);if(i.tagName==="LEGEND")return J.call(n,"fieldset[disabled] *")?!0:!i.contains(e)}return!0}n=n.parentElement}return!1},Te=function(e,n){return!(n.disabled||Ne(n)||ln(n)||vn(n,e)||on(n)||pn(n))},Ke=function(e,n){return!(fn(n)||Q(n)<0||!Te(e,n))},mn=function(e){var n=parseInt(e.getAttribute("tabindex"),10);return!!(isNaN(n)||n>=0)},bn=function t(e){var n=[],r=[];return e.forEach(function(i,l){var a=!!i.scopeParent,v=a?i.scopeParent:i,o=an(v,a),b=a?t(i.candidates):v;o===0?a?n.push.apply(n,b):n.push(v):r.push({documentOrder:l,tabIndex:o,item:i,isScope:a,content:b})}),r.sort(sn).reduce(function(i,l){return l.isScope?i.push.apply(i,l.content):i.push(l.content),i},[]).concat(n)},gn=function(e,n){n=n||{};var r;return n.getShadowRoot?r=vt([e],n.includeContainer,{filter:Ke.bind(null,n),flatten:!1,getShadowRoot:n.getShadowRoot,shadowRootFilter:mn}):r=ht(e,n.includeContainer,Ke.bind(null,n)),bn(r)},yn=function(e,n){n=n||{};var r;return n.getShadowRoot?r=vt([e],n.includeContainer,{filter:Te.bind(null,n),flatten:!0,getShadowRoot:n.getShadowRoot}):r=ht(e,n.includeContainer,Te.bind(null,n)),r},ae=function(e,n){if(n=n||{},!e)throw new Error("No node provided");return J.call(e,Ee)===!1?!1:Ke(n,e)},wn=ct.concat("iframe").join(","),qe=function(e,n){if(n=n||{},!e)throw new Error("No node provided");return J.call(e,wn)===!1?!1:Te(n,e)};let Xe=s.createContext(null);Xe.displayName="OpenClosedContext";var R=(t=>(t[t.Open=1]="Open",t[t.Closed=2]="Closed",t[t.Closing=4]="Closing",t[t.Opening=8]="Opening",t))(R||{});function gt(){return s.useContext(Xe)}function xn({value:t,children:e}){return s.createElement(Xe.Provider,{value:t},e)}function En(){let t=typeof document>"u";return"useSyncExternalStore"in ie?(e=>e.useSyncExternalStore)(ie)(()=>()=>{},()=>!1,()=>!t):!1}function yt(){let t=En(),[e,n]=ie.useState(ge.isHandoffComplete);return e&&ge.isHandoffComplete===!1&&n(!1),ie.useEffect(()=>{e!==!0&&n(!0)},[e]),ie.useEffect(()=>ge.handoff(),[]),t?!1:e}function Sn(){let t=s.useRef(!1);return z(()=>(t.current=!0,()=>{t.current=!1}),[]),t}function wt(t){var e;return!!(t.enter||t.enterFrom||t.enterTo||t.leave||t.leaveFrom||t.leaveTo)||((e=t.as)!=null?e:Et)!==s.Fragment||s.Children.count(t.children)===1}let Fe=s.createContext(null);Fe.displayName="TransitionContext";var Nn=(t=>(t.Visible="visible",t.Hidden="hidden",t))(Nn||{});function Tn(){let t=s.useContext(Fe);if(t===null)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition /> or <Transition.Root />.");return t}function Fn(){let t=s.useContext(Oe);if(t===null)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition /> or <Transition.Root />.");return t}let Oe=s.createContext(null);Oe.displayName="NestingContext";function ke(t){return"children"in t?ke(t.children):t.current.filter(({el:e})=>e.current!==null).filter(({state:e})=>e==="visible").length>0}function xt(t,e){let n=at(t),r=s.useRef([]),i=Sn(),l=rt(),a=_((S,f=G.Hidden)=>{let y=r.current.findIndex(({el:c})=>c===S);y!==-1&&(we(f,{[G.Unmount](){r.current.splice(y,1)},[G.Hidden](){r.current[y].state="hidden"}}),l.microTask(()=>{var c;!ke(r)&&i.current&&((c=n.current)==null||c.call(n))}))}),v=_(S=>{let f=r.current.find(({el:y})=>y===S);return f?f.state!=="visible"&&(f.state="visible"):r.current.push({el:S,state:"visible"}),()=>a(S,G.Unmount)}),o=s.useRef([]),b=s.useRef(Promise.resolve()),g=s.useRef({enter:[],leave:[]}),E=_((S,f,y)=>{o.current.splice(0),e&&(e.chains.current[f]=e.chains.current[f].filter(([c])=>c!==S)),e==null||e.chains.current[f].push([S,new Promise(c=>{o.current.push(c)})]),e==null||e.chains.current[f].push([S,new Promise(c=>{Promise.all(g.current[f].map(([h,p])=>p)).then(()=>c())})]),f==="enter"?b.current=b.current.then(()=>e==null?void 0:e.wait.current).then(()=>y(f)):y(f)}),F=_((S,f,y)=>{Promise.all(g.current[f].splice(0).map(([c,h])=>h)).then(()=>{var c;(c=o.current.shift())==null||c()}).then(()=>y(f))});return s.useMemo(()=>({children:r,register:v,unregister:a,onStart:E,onStop:F,wait:b,chains:g}),[v,a,r,E,F,g,b])}let Et=s.Fragment,St=it.RenderStrategy;function On(t,e){var n,r;let{transition:i=!0,beforeEnter:l,afterEnter:a,beforeLeave:v,afterLeave:o,enter:b,enterFrom:g,enterTo:E,entered:F,leave:S,leaveFrom:f,leaveTo:y,...c}=t,[h,p]=s.useState(null),w=s.useRef(null),N=wt(t),m=ot(...N?[w,e,p]:e===null?[]:[e]),P=(n=c.unmount)==null||n?G.Unmount:G.Hidden,{show:j,appear:B,initial:H}=Tn(),[U,W]=s.useState(j?"visible":"hidden"),k=Fn(),{register:u,unregister:d}=k;z(()=>u(w),[u,w]),z(()=>{if(P===G.Hidden&&w.current){if(j&&U!=="visible"){W("visible");return}return we(U,{hidden:()=>d(w),visible:()=>u(w)})}},[U,w,u,d,j,P]);let x=yt();z(()=>{if(N&&x&&U==="visible"&&w.current===null)throw new Error("Did you forget to passthrough the `ref` to the actual DOM node?")},[w,U,x,N]);let I=H&&!B,M=B&&j&&H,A=s.useRef(!1),O=xt(()=>{A.current||(W("hidden"),d(w))},k),L=_(ee=>{A.current=!0;let Z=ee?"enter":"leave";O.onStart(w,Z,fe=>{fe==="enter"?l==null||l():fe==="leave"&&(v==null||v())})}),D=_(ee=>{let Z=ee?"enter":"leave";A.current=!1,O.onStop(w,Z,fe=>{fe==="enter"?a==null||a():fe==="leave"&&(o==null||o())}),Z==="leave"&&!ke(O)&&(W("hidden"),d(w))});s.useEffect(()=>{N&&i||(L(j),D(j))},[j,N,i]);let V=!(!i||!N||!x||I),[,$]=Rt(V,h,j,{start:L,end:D}),X=Y({ref:m,className:((r=We(c.className,M&&b,M&&g,$.enter&&b,$.enter&&$.closed&&g,$.enter&&!$.closed&&E,$.leave&&S,$.leave&&!$.closed&&f,$.leave&&$.closed&&y,!$.transition&&j&&F))==null?void 0:r.trim())||void 0,...Qt($)}),K=0;U==="visible"&&(K|=R.Open),U==="hidden"&&(K|=R.Closed),$.enter&&(K|=R.Opening),$.leave&&(K|=R.Closing);let Ie=st();return s.createElement(Oe.Provider,{value:O},s.createElement(xn,{value:K},Ie({ourProps:X,theirProps:c,defaultTag:Et,features:St,visible:U==="visible",name:"Transition.Child"})))}function kn(t,e){let{show:n,appear:r=!1,unmount:i=!0,...l}=t,a=s.useRef(null),v=wt(t),o=ot(...v?[a,e]:e===null?[]:[e]);yt();let b=gt();if(n===void 0&&b!==null&&(n=(b&R.Open)===R.Open),n===void 0)throw new Error("A <Transition /> is used but it is missing a `show={true | false}` prop.");let[g,E]=s.useState(n?"visible":"hidden"),F=xt(()=>{n||E("hidden")}),[S,f]=s.useState(!0),y=s.useRef([n]);z(()=>{S!==!1&&y.current[y.current.length-1]!==n&&(y.current.push(n),f(!1))},[y,n]);let c=s.useMemo(()=>({show:n,appear:r,initial:S}),[n,r,S]);z(()=>{n?E("visible"):!ke(F)&&a.current!==null&&E("hidden")},[n,F]);let h={unmount:i},p=_(()=>{var m;S&&f(!1),(m=t.beforeEnter)==null||m.call(t)}),w=_(()=>{var m;S&&f(!1),(m=t.beforeLeave)==null||m.call(t)}),N=st();return s.createElement(Oe.Provider,{value:F},s.createElement(Fe.Provider,{value:c},N({ourProps:{...h,as:s.Fragment,children:s.createElement(Nt,{ref:o,...h,...l,beforeEnter:p,beforeLeave:w})},theirProps:{},defaultTag:s.Fragment,features:St,visible:g==="visible",name:"Transition"})))}function Cn(t,e){let n=s.useContext(Fe)!==null,r=gt()!==null;return s.createElement(s.Fragment,null,!n&&r?s.createElement(_e,{ref:e,...t}):s.createElement(Nt,{ref:e,...t}))}let _e=Be(kn),Nt=Be(On),Ce=Be(Cn),Pn=Object.assign(_e,{Child:Ce,Root:_e});function Tt({onClick:t}){return T.jsxs("button",{type:"button",className:"im-close-button text-gray-400 hover:text-gray-500",onClick:t,children:[T.jsx("span",{className:"sr-only",children:"Close"}),T.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:T.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})]})}/*!
9
- * focus-trap 7.6.2
8
+ */var ct=["input:not([inert])","select:not([inert])","textarea:not([inert])","a[href]:not([inert])","button:not([inert])","[tabindex]:not(slot):not([inert])","audio[controls]:not([inert])","video[controls]:not([inert])",'[contenteditable]:not([contenteditable="false"]):not([inert])',"details>summary:first-of-type:not([inert])","details:not([inert])"],Ee=ct.join(","),ft=typeof Element>"u",J=ft?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,Se=!ft&&Element.prototype.getRootNode?function(t){var e;return t==null||(e=t.getRootNode)===null||e===void 0?void 0:e.call(t)}:function(t){return t==null?void 0:t.ownerDocument},Te=function t(e,n){var r;n===void 0&&(n=!0);var i=e==null||(r=e.getAttribute)===null||r===void 0?void 0:r.call(e,"inert"),s=i===""||i==="true",a=s||n&&e&&t(e.parentNode);return a},rn=function(e){var n,r=e==null||(n=e.getAttribute)===null||n===void 0?void 0:n.call(e,"contenteditable");return r===""||r==="true"},ht=function(e,n,r){if(Te(e))return[];var i=Array.prototype.slice.apply(e.querySelectorAll(Ee));return n&&J.call(e,Ee)&&i.unshift(e),i=i.filter(r),i},vt=function t(e,n,r){for(var i=[],s=Array.from(e);s.length;){var a=s.shift();if(!Te(a,!1))if(a.tagName==="SLOT"){var v=a.assignedElements(),u=v.length?v:a.children,b=t(u,!0,r);r.flatten?i.push.apply(i,b):i.push({scopeParent:a,candidates:b})}else{var g=J.call(a,Ee);g&&r.filter(a)&&(n||!e.includes(a))&&i.push(a);var x=a.shadowRoot||typeof r.getShadowRoot=="function"&&r.getShadowRoot(a),O=!Te(x,!1)&&(!r.shadowRootFilter||r.shadowRootFilter(a));if(x&&O){var S=t(x===!0?a.children:x.children,!0,r);r.flatten?i.push.apply(i,S):i.push({scopeParent:a,candidates:S})}else s.unshift.apply(s,a.children)}}return i},mt=function(e){return!isNaN(parseInt(e.getAttribute("tabindex"),10))},Q=function(e){if(!e)throw new Error("No node provided");return e.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(e.tagName)||rn(e))&&!mt(e)?0:e.tabIndex},an=function(e,n){var r=Q(e);return r<0&&n&&!mt(e)?0:r},ln=function(e,n){return e.tabIndex===n.tabIndex?e.documentOrder-n.documentOrder:e.tabIndex-n.tabIndex},pt=function(e){return e.tagName==="INPUT"},sn=function(e){return pt(e)&&e.type==="hidden"},un=function(e){var n=e.tagName==="DETAILS"&&Array.prototype.slice.apply(e.children).some(function(r){return r.tagName==="SUMMARY"});return n},on=function(e,n){for(var r=0;r<e.length;r++)if(e[r].checked&&e[r].form===n)return e[r]},dn=function(e){if(!e.name)return!0;var n=e.form||Se(e),r=function(v){return n.querySelectorAll('input[type="radio"][name="'+v+'"]')},i;if(typeof window<"u"&&typeof window.CSS<"u"&&typeof window.CSS.escape=="function")i=r(window.CSS.escape(e.name));else try{i=r(e.name)}catch(a){return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",a.message),!1}var s=on(i,e.form);return!s||s===e},cn=function(e){return pt(e)&&e.type==="radio"},fn=function(e){return cn(e)&&!dn(e)},hn=function(e){var n,r=e&&Se(e),i=(n=r)===null||n===void 0?void 0:n.host,s=!1;if(r&&r!==e){var a,v,u;for(s=!!((a=i)!==null&&a!==void 0&&(v=a.ownerDocument)!==null&&v!==void 0&&v.contains(i)||e!=null&&(u=e.ownerDocument)!==null&&u!==void 0&&u.contains(e));!s&&i;){var b,g,x;r=Se(i),i=(b=r)===null||b===void 0?void 0:b.host,s=!!((g=i)!==null&&g!==void 0&&(x=g.ownerDocument)!==null&&x!==void 0&&x.contains(i))}}return s},bt=function(e){var n=e.getBoundingClientRect(),r=n.width,i=n.height;return r===0&&i===0},vn=function(e,n){var r=n.displayCheck,i=n.getShadowRoot;if(getComputedStyle(e).visibility==="hidden")return!0;var s=J.call(e,"details>summary:first-of-type"),a=s?e.parentElement:e;if(J.call(a,"details:not([open]) *"))return!0;if(!r||r==="full"||r==="legacy-full"){if(typeof i=="function"){for(var v=e;e;){var u=e.parentElement,b=Se(e);if(u&&!u.shadowRoot&&i(u)===!0)return bt(e);e.assignedSlot?e=e.assignedSlot:!u&&b!==e.ownerDocument?e=b.host:e=u}e=v}if(hn(e))return!e.getClientRects().length;if(r!=="legacy-full")return!0}else if(r==="non-zero-area")return bt(e);return!1},mn=function(e){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(e.tagName))for(var n=e.parentElement;n;){if(n.tagName==="FIELDSET"&&n.disabled){for(var r=0;r<n.children.length;r++){var i=n.children.item(r);if(i.tagName==="LEGEND")return J.call(n,"fieldset[disabled] *")?!0:!i.contains(e)}return!0}n=n.parentElement}return!1},Ne=function(e,n){return!(n.disabled||Te(n)||sn(n)||vn(n,e)||un(n)||mn(n))},Ke=function(e,n){return!(fn(n)||Q(n)<0||!Ne(e,n))},pn=function(e){var n=parseInt(e.getAttribute("tabindex"),10);return!!(isNaN(n)||n>=0)},bn=function t(e){var n=[],r=[];return e.forEach(function(i,s){var a=!!i.scopeParent,v=a?i.scopeParent:i,u=an(v,a),b=a?t(i.candidates):v;u===0?a?n.push.apply(n,b):n.push(v):r.push({documentOrder:s,tabIndex:u,item:i,isScope:a,content:b})}),r.sort(ln).reduce(function(i,s){return s.isScope?i.push.apply(i,s.content):i.push(s.content),i},[]).concat(n)},gn=function(e,n){n=n||{};var r;return n.getShadowRoot?r=vt([e],n.includeContainer,{filter:Ke.bind(null,n),flatten:!1,getShadowRoot:n.getShadowRoot,shadowRootFilter:pn}):r=ht(e,n.includeContainer,Ke.bind(null,n)),bn(r)},yn=function(e,n){n=n||{};var r;return n.getShadowRoot?r=vt([e],n.includeContainer,{filter:Ne.bind(null,n),flatten:!0,getShadowRoot:n.getShadowRoot}):r=ht(e,n.includeContainer,Ne.bind(null,n)),r},ae=function(e,n){if(n=n||{},!e)throw new Error("No node provided");return J.call(e,Ee)===!1?!1:Ke(n,e)},wn=ct.concat("iframe").join(","),_e=function(e,n){if(n=n||{},!e)throw new Error("No node provided");return J.call(e,wn)===!1?!1:Ne(n,e)};let qe=l.createContext(null);qe.displayName="OpenClosedContext";var R=(t=>(t[t.Open=1]="Open",t[t.Closed=2]="Closed",t[t.Closing=4]="Closing",t[t.Opening=8]="Opening",t))(R||{});function gt(){return l.useContext(qe)}function xn({value:t,children:e}){return l.createElement(qe.Provider,{value:t},e)}function En(){let t=typeof document>"u";return"useSyncExternalStore"in ie?(e=>e.useSyncExternalStore)(ie)(()=>()=>{},()=>!1,()=>!t):!1}function yt(){let t=En(),[e,n]=ie.useState(ge.isHandoffComplete);return e&&ge.isHandoffComplete===!1&&n(!1),ie.useEffect(()=>{e!==!0&&n(!0)},[e]),ie.useEffect(()=>ge.handoff(),[]),t?!1:e}function Sn(){let t=l.useRef(!1);return z(()=>(t.current=!0,()=>{t.current=!1}),[]),t}function wt(t){var e;return!!(t.enter||t.enterFrom||t.enterTo||t.leave||t.leaveFrom||t.leaveTo)||((e=t.as)!=null?e:Et)!==l.Fragment||l.Children.count(t.children)===1}let Oe=l.createContext(null);Oe.displayName="TransitionContext";var Tn=(t=>(t.Visible="visible",t.Hidden="hidden",t))(Tn||{});function Nn(){let t=l.useContext(Oe);if(t===null)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition /> or <Transition.Root />.");return t}function On(){let t=l.useContext(Fe);if(t===null)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition /> or <Transition.Root />.");return t}let Fe=l.createContext(null);Fe.displayName="NestingContext";function ke(t){return"children"in t?ke(t.children):t.current.filter(({el:e})=>e.current!==null).filter(({state:e})=>e==="visible").length>0}function xt(t,e){let n=at(t),r=l.useRef([]),i=Sn(),s=rt(),a=X((S,f=G.Hidden)=>{let y=r.current.findIndex(({el:c})=>c===S);y!==-1&&(we(f,{[G.Unmount](){r.current.splice(y,1)},[G.Hidden](){r.current[y].state="hidden"}}),s.microTask(()=>{var c;!ke(r)&&i.current&&((c=n.current)==null||c.call(n))}))}),v=X(S=>{let f=r.current.find(({el:y})=>y===S);return f?f.state!=="visible"&&(f.state="visible"):r.current.push({el:S,state:"visible"}),()=>a(S,G.Unmount)}),u=l.useRef([]),b=l.useRef(Promise.resolve()),g=l.useRef({enter:[],leave:[]}),x=X((S,f,y)=>{u.current.splice(0),e&&(e.chains.current[f]=e.chains.current[f].filter(([c])=>c!==S)),e==null||e.chains.current[f].push([S,new Promise(c=>{u.current.push(c)})]),e==null||e.chains.current[f].push([S,new Promise(c=>{Promise.all(g.current[f].map(([h,m])=>m)).then(()=>c())})]),f==="enter"?b.current=b.current.then(()=>e==null?void 0:e.wait.current).then(()=>y(f)):y(f)}),O=X((S,f,y)=>{Promise.all(g.current[f].splice(0).map(([c,h])=>h)).then(()=>{var c;(c=u.current.shift())==null||c()}).then(()=>y(f))});return l.useMemo(()=>({children:r,register:v,unregister:a,onStart:x,onStop:O,wait:b,chains:g}),[v,a,r,x,O,g,b])}let Et=l.Fragment,St=it.RenderStrategy;function Fn(t,e){var n,r;let{transition:i=!0,beforeEnter:s,afterEnter:a,beforeLeave:v,afterLeave:u,enter:b,enterFrom:g,enterTo:x,entered:O,leave:S,leaveFrom:f,leaveTo:y,...c}=t,[h,m]=l.useState(null),w=l.useRef(null),T=wt(t),p=ut(...T?[w,e,m]:e===null?[]:[e]),M=(n=c.unmount)==null||n?G.Unmount:G.Hidden,{show:L,appear:B,initial:H}=Nn(),[U,W]=l.useState(L?"visible":"hidden"),k=On(),{register:o,unregister:d}=k;z(()=>o(w),[o,w]),z(()=>{if(M===G.Hidden&&w.current){if(L&&U!=="visible"){W("visible");return}return we(U,{hidden:()=>d(w),visible:()=>o(w)})}},[U,w,o,d,L,M]);let E=yt();z(()=>{if(T&&E&&U==="visible"&&w.current===null)throw new Error("Did you forget to passthrough the `ref` to the actual DOM node?")},[w,U,E,T]);let C=H&&!B,P=B&&L&&H,A=l.useRef(!1),F=xt(()=>{A.current||(W("hidden"),d(w))},k),j=X(ee=>{A.current=!0;let Z=ee?"enter":"leave";F.onStart(w,Z,fe=>{fe==="enter"?s==null||s():fe==="leave"&&(v==null||v())})}),D=X(ee=>{let Z=ee?"enter":"leave";A.current=!1,F.onStop(w,Z,fe=>{fe==="enter"?a==null||a():fe==="leave"&&(u==null||u())}),Z==="leave"&&!ke(F)&&(W("hidden"),d(w))});l.useEffect(()=>{T&&i||(j(L),D(L))},[L,T,i]);let V=!(!i||!T||!E||C),[,$]=Rt(V,h,L,{start:j,end:D}),q=Y({ref:p,className:((r=We(c.className,P&&b,P&&g,$.enter&&b,$.enter&&$.closed&&g,$.enter&&!$.closed&&x,$.leave&&S,$.leave&&!$.closed&&f,$.leave&&$.closed&&y,!$.transition&&L&&O))==null?void 0:r.trim())||void 0,...Qt($)}),K=0;U==="visible"&&(K|=R.Open),U==="hidden"&&(K|=R.Closed),$.enter&&(K|=R.Opening),$.leave&&(K|=R.Closing);let Ie=lt();return l.createElement(Fe.Provider,{value:F},l.createElement(xn,{value:K},Ie({ourProps:q,theirProps:c,defaultTag:Et,features:St,visible:U==="visible",name:"Transition.Child"})))}function kn(t,e){let{show:n,appear:r=!1,unmount:i=!0,...s}=t,a=l.useRef(null),v=wt(t),u=ut(...v?[a,e]:e===null?[]:[e]);yt();let b=gt();if(n===void 0&&b!==null&&(n=(b&R.Open)===R.Open),n===void 0)throw new Error("A <Transition /> is used but it is missing a `show={true | false}` prop.");let[g,x]=l.useState(n?"visible":"hidden"),O=xt(()=>{n||x("hidden")}),[S,f]=l.useState(!0),y=l.useRef([n]);z(()=>{S!==!1&&y.current[y.current.length-1]!==n&&(y.current.push(n),f(!1))},[y,n]);let c=l.useMemo(()=>({show:n,appear:r,initial:S}),[n,r,S]);z(()=>{n?x("visible"):!ke(O)&&a.current!==null&&x("hidden")},[n,O]);let h={unmount:i},m=X(()=>{var p;S&&f(!1),(p=t.beforeEnter)==null||p.call(t)}),w=X(()=>{var p;S&&f(!1),(p=t.beforeLeave)==null||p.call(t)}),T=lt();return l.createElement(Fe.Provider,{value:O},l.createElement(Oe.Provider,{value:c},T({ourProps:{...h,as:l.Fragment,children:l.createElement(Tt,{ref:u,...h,...s,beforeEnter:m,beforeLeave:w})},theirProps:{},defaultTag:l.Fragment,features:St,visible:g==="visible",name:"Transition"})))}function Cn(t,e){let n=l.useContext(Oe)!==null,r=gt()!==null;return l.createElement(l.Fragment,null,!n&&r?l.createElement(Xe,{ref:e,...t}):l.createElement(Tt,{ref:e,...t}))}let Xe=Be(kn),Tt=Be(Fn),Ce=Be(Cn),Pn=Object.assign(Xe,{Child:Ce,Root:Xe});function Nt({onClick:t}){return N.jsxs("button",{type:"button",className:"im-close-button text-gray-400 hover:text-gray-500",onClick:t,children:[N.jsx("span",{className:"sr-only",children:"Close"}),N.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:N.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})]})}/*!
9
+ * focus-trap 7.6.4
10
10
  * @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
11
- */function Ve(t,e){(e==null||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function In(t){if(Array.isArray(t))return Ve(t)}function Mn(t,e,n){return(e=$n(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function An(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function Ln(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
12
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ft(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Ot(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Ft(Object(n),!0).forEach(function(r){Mn(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Ft(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function jn(t){return In(t)||An(t)||Un(t)||Ln()}function Dn(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function $n(t){var e=Dn(t,"string");return typeof e=="symbol"?e:e+""}function Un(t,e){if(t){if(typeof t=="string")return Ve(t,e);var n={}.toString.call(t).slice(8,-1);return n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set"?Array.from(t):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Ve(t,e):void 0}}var kt={activateTrap:function(e,n){if(e.length>0){var r=e[e.length-1];r!==n&&r.pause()}var i=e.indexOf(n);i===-1||e.splice(i,1),e.push(n)},deactivateTrap:function(e,n){var r=e.indexOf(n);r!==-1&&e.splice(r,1),e.length>0&&e[e.length-1].unpause()}},Wn=function(e){return e.tagName&&e.tagName.toLowerCase()==="input"&&typeof e.select=="function"},Bn=function(e){return(e==null?void 0:e.key)==="Escape"||(e==null?void 0:e.key)==="Esc"||(e==null?void 0:e.keyCode)===27},de=function(e){return(e==null?void 0:e.key)==="Tab"||(e==null?void 0:e.keyCode)===9},Hn=function(e){return de(e)&&!e.shiftKey},Kn=function(e){return de(e)&&e.shiftKey},Ct=function(e){return setTimeout(e,0)},ce=function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return typeof e=="function"?e.apply(void 0,r):e},Pe=function(e){return e.target.shadowRoot&&typeof e.composedPath=="function"?e.composedPath()[0]:e.target},qn=[],Xn=function(e,n){var r=(n==null?void 0:n.document)||document,i=(n==null?void 0:n.trapStack)||qn,l=Ot({returnFocusOnDeactivate:!0,escapeDeactivates:!0,delayInitialFocus:!0,isKeyForward:Hn,isKeyBackward:Kn},n),a={containers:[],containerGroups:[],tabbableGroups:[],nodeFocusedBeforeActivation:null,mostRecentlyFocusedNode:null,active:!1,paused:!1,delayInitialFocusTimer:void 0,recentNavEvent:void 0},v,o=function(u,d,x){return u&&u[d]!==void 0?u[d]:l[x||d]},b=function(u,d){var x=typeof(d==null?void 0:d.composedPath)=="function"?d.composedPath():void 0;return a.containerGroups.findIndex(function(I){var M=I.container,A=I.tabbableNodes;return M.contains(u)||(x==null?void 0:x.includes(M))||A.find(function(O){return O===u})})},g=function(u){var d=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},x=d.hasFallback,I=x===void 0?!1:x,M=d.params,A=M===void 0?[]:M,O=l[u];if(typeof O=="function"&&(O=O.apply(void 0,jn(A))),O===!0&&(O=void 0),!O){if(O===void 0||O===!1)return O;throw new Error("`".concat(u,"` was specified but was not a node, or did not return a node"))}var L=O;if(typeof O=="string"){try{L=r.querySelector(O)}catch(D){throw new Error("`".concat(u,'` appears to be an invalid selector; error="').concat(D.message,'"'))}if(!L&&!I)throw new Error("`".concat(u,"` as selector refers to no known node"))}return L},E=function(){var u=g("initialFocus",{hasFallback:!0});if(u===!1)return!1;if(u===void 0||u&&!qe(u,l.tabbableOptions))if(b(r.activeElement)>=0)u=r.activeElement;else{var d=a.tabbableGroups[0],x=d&&d.firstTabbableNode;u=x||g("fallbackFocus")}else u===null&&(u=g("fallbackFocus"));if(!u)throw new Error("Your focus-trap needs to have at least one focusable element");return u},F=function(){if(a.containerGroups=a.containers.map(function(u){var d=gn(u,l.tabbableOptions),x=yn(u,l.tabbableOptions),I=d.length>0?d[0]:void 0,M=d.length>0?d[d.length-1]:void 0,A=x.find(function(D){return ae(D)}),O=x.slice().reverse().find(function(D){return ae(D)}),L=!!d.find(function(D){return Q(D)>0});return{container:u,tabbableNodes:d,focusableNodes:x,posTabIndexesFound:L,firstTabbableNode:I,lastTabbableNode:M,firstDomTabbableNode:A,lastDomTabbableNode:O,nextTabbableNode:function(V){var $=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,X=d.indexOf(V);return X<0?$?x.slice(x.indexOf(V)+1).find(function(K){return ae(K)}):x.slice(0,x.indexOf(V)).reverse().find(function(K){return ae(K)}):d[X+($?1:-1)]}}}),a.tabbableGroups=a.containerGroups.filter(function(u){return u.tabbableNodes.length>0}),a.tabbableGroups.length<=0&&!g("fallbackFocus"))throw new Error("Your focus-trap must have at least one container with at least one tabbable node in it at all times");if(a.containerGroups.find(function(u){return u.posTabIndexesFound})&&a.containerGroups.length>1)throw new Error("At least one node with a positive tabindex was found in one of your focus-trap's multiple containers. Positive tabindexes are only supported in single-container focus-traps.")},S=function(u){var d=u.activeElement;if(d)return d.shadowRoot&&d.shadowRoot.activeElement!==null?S(d.shadowRoot):d},f=function(u){if(u!==!1&&u!==S(document)){if(!u||!u.focus){f(E());return}u.focus({preventScroll:!!l.preventScroll}),a.mostRecentlyFocusedNode=u,Wn(u)&&u.select()}},y=function(u){var d=g("setReturnFocus",{params:[u]});return d||(d===!1?!1:u)},c=function(u){var d=u.target,x=u.event,I=u.isBackward,M=I===void 0?!1:I;d=d||Pe(x),F();var A=null;if(a.tabbableGroups.length>0){var O=b(d,x),L=O>=0?a.containerGroups[O]:void 0;if(O<0)M?A=a.tabbableGroups[a.tabbableGroups.length-1].lastTabbableNode:A=a.tabbableGroups[0].firstTabbableNode;else if(M){var D=a.tabbableGroups.findIndex(function(ee){var Z=ee.firstTabbableNode;return d===Z});if(D<0&&(L.container===d||qe(d,l.tabbableOptions)&&!ae(d,l.tabbableOptions)&&!L.nextTabbableNode(d,!1))&&(D=O),D>=0){var V=D===0?a.tabbableGroups.length-1:D-1,$=a.tabbableGroups[V];A=Q(d)>=0?$.lastTabbableNode:$.lastDomTabbableNode}else de(x)||(A=L.nextTabbableNode(d,!1))}else{var X=a.tabbableGroups.findIndex(function(ee){var Z=ee.lastTabbableNode;return d===Z});if(X<0&&(L.container===d||qe(d,l.tabbableOptions)&&!ae(d,l.tabbableOptions)&&!L.nextTabbableNode(d))&&(X=O),X>=0){var K=X===a.tabbableGroups.length-1?0:X+1,Ie=a.tabbableGroups[K];A=Q(d)>=0?Ie.firstTabbableNode:Ie.firstDomTabbableNode}else de(x)||(A=L.nextTabbableNode(d))}}else A=g("fallbackFocus");return A},h=function(u){var d=Pe(u);if(!(b(d,u)>=0)){if(ce(l.clickOutsideDeactivates,u)){v.deactivate({returnFocus:l.returnFocusOnDeactivate});return}ce(l.allowOutsideClick,u)||u.preventDefault()}},p=function(u){var d=Pe(u),x=b(d,u)>=0;if(x||d instanceof Document)x&&(a.mostRecentlyFocusedNode=d);else{u.stopImmediatePropagation();var I,M=!0;if(a.mostRecentlyFocusedNode)if(Q(a.mostRecentlyFocusedNode)>0){var A=b(a.mostRecentlyFocusedNode),O=a.containerGroups[A].tabbableNodes;if(O.length>0){var L=O.findIndex(function(D){return D===a.mostRecentlyFocusedNode});L>=0&&(l.isKeyForward(a.recentNavEvent)?L+1<O.length&&(I=O[L+1],M=!1):L-1>=0&&(I=O[L-1],M=!1))}}else a.containerGroups.some(function(D){return D.tabbableNodes.some(function(V){return Q(V)>0})})||(M=!1);else M=!1;M&&(I=c({target:a.mostRecentlyFocusedNode,isBackward:l.isKeyBackward(a.recentNavEvent)})),f(I||a.mostRecentlyFocusedNode||E())}a.recentNavEvent=void 0},w=function(u){var d=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;a.recentNavEvent=u;var x=c({event:u,isBackward:d});x&&(de(u)&&u.preventDefault(),f(x))},N=function(u){(l.isKeyForward(u)||l.isKeyBackward(u))&&w(u,l.isKeyBackward(u))},m=function(u){Bn(u)&&ce(l.escapeDeactivates,u)!==!1&&(u.preventDefault(),v.deactivate())},P=function(u){var d=Pe(u);b(d,u)>=0||ce(l.clickOutsideDeactivates,u)||ce(l.allowOutsideClick,u)||(u.preventDefault(),u.stopImmediatePropagation())},j=function(){if(a.active)return kt.activateTrap(i,v),a.delayInitialFocusTimer=l.delayInitialFocus?Ct(function(){f(E())}):f(E()),r.addEventListener("focusin",p,!0),r.addEventListener("mousedown",h,{capture:!0,passive:!1}),r.addEventListener("touchstart",h,{capture:!0,passive:!1}),r.addEventListener("click",P,{capture:!0,passive:!1}),r.addEventListener("keydown",N,{capture:!0,passive:!1}),r.addEventListener("keydown",m),v},B=function(){if(a.active)return r.removeEventListener("focusin",p,!0),r.removeEventListener("mousedown",h,!0),r.removeEventListener("touchstart",h,!0),r.removeEventListener("click",P,!0),r.removeEventListener("keydown",N,!0),r.removeEventListener("keydown",m),v},H=function(u){var d=u.some(function(x){var I=Array.from(x.removedNodes);return I.some(function(M){return M===a.mostRecentlyFocusedNode})});d&&f(E())},U=typeof window<"u"&&"MutationObserver"in window?new MutationObserver(H):void 0,W=function(){U&&(U.disconnect(),a.active&&!a.paused&&a.containers.map(function(u){U.observe(u,{subtree:!0,childList:!0})}))};return v={get active(){return a.active},get paused(){return a.paused},activate:function(u){if(a.active)return this;var d=o(u,"onActivate"),x=o(u,"onPostActivate"),I=o(u,"checkCanFocusTrap");I||F(),a.active=!0,a.paused=!1,a.nodeFocusedBeforeActivation=r.activeElement,d==null||d();var M=function(){I&&F(),j(),W(),x==null||x()};return I?(I(a.containers.concat()).then(M,M),this):(M(),this)},deactivate:function(u){if(!a.active)return this;var d=Ot({onDeactivate:l.onDeactivate,onPostDeactivate:l.onPostDeactivate,checkCanReturnFocus:l.checkCanReturnFocus},u);clearTimeout(a.delayInitialFocusTimer),a.delayInitialFocusTimer=void 0,B(),a.active=!1,a.paused=!1,W(),kt.deactivateTrap(i,v);var x=o(d,"onDeactivate"),I=o(d,"onPostDeactivate"),M=o(d,"checkCanReturnFocus"),A=o(d,"returnFocus","returnFocusOnDeactivate");x==null||x();var O=function(){Ct(function(){A&&f(y(a.nodeFocusedBeforeActivation)),I==null||I()})};return A&&M?(M(y(a.nodeFocusedBeforeActivation)).then(O,O),this):(O(),this)},pause:function(u){if(a.paused||!a.active)return this;var d=o(u,"onPause"),x=o(u,"onPostPause");return a.paused=!0,d==null||d(),B(),W(),x==null||x(),this},unpause:function(u){if(!a.paused||!a.active)return this;var d=o(u,"onUnpause"),x=o(u,"onPostUnpause");return a.paused=!1,d==null||d(),F(),j(),W(),x==null||x(),this},updateContainerElements:function(u){var d=[].concat(u).filter(Boolean);return a.containers=d.map(function(x){return typeof x=="string"?r.querySelector(x):x}),a.active&&F(),W(),this}},v.updateContainerElements(e),v};function Pt(t,e,n){let r=null;return t&&(r=Xn(t,{clickOutsideDeactivates:!e,escapeDeactivates:!e,onDeactivate:()=>n==null?void 0:n(),fallbackFocus:()=>t}),r.activate()),{deactivate:()=>{r==null||r.deactivate(),r=null},wrapper:t}}const _n=({modalContext:t,config:e,children:n})=>{const[r,i]=s.useState(!1),l=s.useRef(null),[a,v]=s.useState(null);function o(){v(Pt(l.current,e==null?void 0:e.closeExplicitly,()=>t.close())),i(!0)}return s.useEffect(()=>()=>a==null?void 0:a.deactivate(),[a]),T.jsx("div",{className:"im-modal-container fixed inset-0 z-40 overflow-y-auto p-4",children:T.jsx("div",{className:be("im-modal-positioner flex min-h-full justify-center",{"items-start":e.position==="top","items-center":e.position==="center","items-end":e.position==="bottom"}),children:T.jsx(Ce,{as:"div",ref:l,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:o,afterLeave:t.afterLeave,className:be("im-modal-wrapper pointer-events-auto w-full transition duration-300 ease-in-out",t.onTopOfStack?"":"blur-sm",{"sm:max-w-sm":e.maxWidth==="sm","sm:max-w-md":e.maxWidth==="md","sm:max-w-md md:max-w-lg":e.maxWidth==="lg","sm:max-w-md md:max-w-xl":e.maxWidth==="xl","sm:max-w-md md:max-w-xl lg:max-w-2xl":e.maxWidth==="2xl","sm:max-w-md md:max-w-xl lg:max-w-3xl":e.maxWidth==="3xl","sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-4xl":e.maxWidth==="4xl","sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl":e.maxWidth==="5xl","sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl 2xl:max-w-6xl":e.maxWidth==="6xl","sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl 2xl:max-w-7xl":e.maxWidth==="7xl"}),children:T.jsxs("div",{className:`im-modal-content relative ${e.paddingClasses} ${e.panelClasses}`,"data-inertiaui-modal-entered":r,children:[e.closeButton&&T.jsx("div",{className:"absolute right-0 top-0 pr-3 pt-3",children:T.jsx(Tt,{onClick:t.close})}),typeof n=="function"?n({modalContext:t,config:e}):n]})})})})},Vn=({modalContext:t,config:e,children:n})=>{const[r,i]=s.useState(!1),l=s.useRef(null),[a,v]=s.useState(null);function o(){v(Pt(l.current,e==null?void 0:e.closeExplicitly,()=>t.close())),i(!0)}return s.useEffect(()=>()=>a==null?void 0:a.deactivate(),[a]),T.jsx("div",{className:"im-slideover-container fixed inset-0 z-40 overflow-y-auto overflow-x-hidden",children:T.jsx("div",{className:be("im-slideover-positioner flex min-h-full items-center",{"justify-start rtl:justify-end":(e==null?void 0:e.position)==="left","justify-end rtl:justify-start":(e==null?void 0:e.position)==="right"}),children:T.jsx(Ce,{as:"div",ref:l,enterFrom:`opacity-0 ${e.position==="left"?"-translate-x-full":"translate-x-full"}`,enterTo:"opacity-100 translate-x-0",leaveFrom:"opacity-100 translate-x-0",leaveTo:`opacity-0 ${e.position==="left"?"-translate-x-full":"translate-x-full"}`,afterEnter:o,afterLeave:t.afterLeave,className:be("im-slideover-wrapper pointer-events-auto w-full transition duration-300 ease-in-out",t.onTopOfStack?"":"blur-sm",{"sm:max-w-sm":e.maxWidth==="sm","sm:max-w-md":e.maxWidth==="md","sm:max-w-md md:max-w-lg":e.maxWidth==="lg","sm:max-w-md md:max-w-xl":e.maxWidth==="xl","sm:max-w-md md:max-w-xl lg:max-w-2xl":e.maxWidth==="2xl","sm:max-w-md md:max-w-xl lg:max-w-3xl":e.maxWidth==="3xl","sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-4xl":e.maxWidth==="4xl","sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl":e.maxWidth==="5xl","sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl 2xl:max-w-6xl":e.maxWidth==="6xl","sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl 2xl:max-w-7xl":e.maxWidth==="7xl"}),children:T.jsxs("div",{className:`im-slideover-content relative ${e.paddingClasses} ${e.panelClasses}`,"data-inertiaui-modal-entered":r,children:[e.closeButton&&T.jsx("div",{className:"absolute right-0 top-0 pr-3 pt-3",children:T.jsx(Tt,{onClick:t.close})}),typeof n=="function"?n({modalContext:t,config:e}):n]})})})})},It=s.forwardRef(({name:t,children:e,onFocus:n=null,onBlur:r=null,onClose:i=null,onSuccess:l=null,onAfterLeave:a=null,...v},o)=>{const b=E=>typeof e=="function"?e(E):e,g=s.useRef(null);return s.useEffect(()=>{var E;if(((E=g==null?void 0:g.current)==null?void 0:E.index)===0)return ze.prepare(),()=>ze.cleanup()},[g]),s.useImperativeHandle(o,()=>g.current,[g]),T.jsx($e,{ref:g,name:t,onFocus:n,onBlur:r,onClose:i,onSuccess:l,...v,children:({afterLeave:E,close:F,config:S,emit:f,getChildModal:y,getParentModal:c,id:h,index:p,isOpen:w,modalContext:N,onTopOfStack:m,reload:P,setOpen:j,shouldRender:B})=>T.jsx(Pn,{appear:!0,show:w??!1,afterLeave:a,children:T.jsxs("div",{className:"im-dialog relative z-20","data-inertiaui-modal-id":h,"data-inertiaui-modal-index":p,children:[p===0?T.jsx(Ce,{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:m?T.jsx("div",{className:"im-backdrop fixed inset-0 z-30 bg-black/75","aria-hidden":"true"}):T.jsx("div",{})}):null,p>0&&m?T.jsx("div",{className:"im-backdrop fixed inset-0 z-30 bg-black/75"}):null,S.slideover?T.jsx(Vn,{modalContext:N,config:S,children:b({afterLeave:E,close:F,config:S,emit:f,getChildModal:y,getParentModal:c,id:h,index:p,isOpen:w,modalContext:N,onTopOfStack:m,reload:P,setOpen:j,shouldRender:B})}):T.jsx(_n,{modalContext:N,config:S,children:b({afterLeave:E,close:F,config:S,emit:f,getChildModal:y,getParentModal:c,id:h,index:p,isOpen:w,modalContext:N,onTopOfStack:m,reload:P,setOpen:j,shouldRender:B})})]})})})});It.displayName="Modal";const zn=({href:t,method:e="get",data:n={},as:r="a",headers:i={},queryStringArrayFormat:l="brackets",onAfterLeave:a=null,onBlur:v=null,onClose:o=null,onError:b=null,onFocus:g=null,onStart:E=null,onSuccess:F=null,navigate:S=null,children:f,...y})=>{const[c,h]=s.useState(!1),[p,w]=s.useState(null),{stack:N,visit:m}=ue(),P=s.useMemo(()=>S??pe("navigate"),[S]),j={},B={};Object.keys(y).forEach(d=>{Qe.includes(d)||(d.startsWith("on")&&typeof y[d]=="function"?d.toLowerCase()in window?j[d]=y[d]:B[d]=y[d]:j[d]=y[d])});const[H,U]=s.useState(!1);s.useEffect(()=>{p&&(p.onTopOfStack&&H?g==null||g():!p.onTopOfStack&&!H&&(v==null||v()),U(!p.onTopOfStack))},[N]);const W=s.useCallback(()=>{o==null||o()},[o]),k=s.useCallback(()=>{w(null),a==null||a()},[a]),u=s.useCallback(d=>{d==null||d.preventDefault(),!c&&(t.startsWith("#")||(h(!0),E==null||E()),m(t,e,n,i,Ut(Ge(y,Qe)),()=>W(N.length),k,l,P).then(x=>{w(x),x.registerEventListenersFromProps(B),F==null||F()}).catch(x=>{console.error(x),b==null||b(x)}).finally(()=>h(!1)))},[t,e,n,i,l,y,W,k]);return T.jsx(r,{...j,href:t,onClick:u,children:typeof f=="function"?f({loading:c}):f})};function Gn(){return ue().stack[De()]??null}const Zn=t=>e=>(e.default.layout=n=>s.createElement(t,{},n),e);C.HeadlessModal=$e,C.Modal=It,C.ModalLink=zn,C.ModalRoot=et,C.ModalStackProvider=Je,C.getConfig=pe,C.initFromPageProps=Re,C.putConfig=Dt,C.renderApp=Bt,C.resetConfig=jt,C.setPageLayout=Zn,C.useModal=Gn,C.useModalIndex=De,C.useModalStack=ue,Object.defineProperty(C,Symbol.toStringTag,{value:"Module"})});
11
+ */function Ve(t,e){(e==null||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function In(t){if(Array.isArray(t))return Ve(t)}function Mn(t,e,n){return(e=$n(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function An(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function jn(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
12
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ot(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Ft(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Ot(Object(n),!0).forEach(function(r){Mn(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Ot(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Ln(t){return In(t)||An(t)||Un(t)||jn()}function Dn(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function $n(t){var e=Dn(t,"string");return typeof e=="symbol"?e:e+""}function Un(t,e){if(t){if(typeof t=="string")return Ve(t,e);var n={}.toString.call(t).slice(8,-1);return n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set"?Array.from(t):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Ve(t,e):void 0}}var kt={activateTrap:function(e,n){if(e.length>0){var r=e[e.length-1];r!==n&&r._setPausedState(!0)}var i=e.indexOf(n);i===-1||e.splice(i,1),e.push(n)},deactivateTrap:function(e,n){var r=e.indexOf(n);r!==-1&&e.splice(r,1),e.length>0&&!e[e.length-1]._isManuallyPaused()&&e[e.length-1]._setPausedState(!1)}},Wn=function(e){return e.tagName&&e.tagName.toLowerCase()==="input"&&typeof e.select=="function"},Bn=function(e){return(e==null?void 0:e.key)==="Escape"||(e==null?void 0:e.key)==="Esc"||(e==null?void 0:e.keyCode)===27},de=function(e){return(e==null?void 0:e.key)==="Tab"||(e==null?void 0:e.keyCode)===9},Hn=function(e){return de(e)&&!e.shiftKey},Kn=function(e){return de(e)&&e.shiftKey},Ct=function(e){return setTimeout(e,0)},ce=function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return typeof e=="function"?e.apply(void 0,r):e},Pe=function(e){return e.target.shadowRoot&&typeof e.composedPath=="function"?e.composedPath()[0]:e.target},_n=[],qn=function(e,n){var r=(n==null?void 0:n.document)||document,i=(n==null?void 0:n.trapStack)||_n,s=Ft({returnFocusOnDeactivate:!0,escapeDeactivates:!0,delayInitialFocus:!0,isKeyForward:Hn,isKeyBackward:Kn},n),a={containers:[],containerGroups:[],tabbableGroups:[],nodeFocusedBeforeActivation:null,mostRecentlyFocusedNode:null,active:!1,paused:!1,manuallyPaused:!1,delayInitialFocusTimer:void 0,recentNavEvent:void 0},v,u=function(o,d,E){return o&&o[d]!==void 0?o[d]:s[E||d]},b=function(o,d){var E=typeof(d==null?void 0:d.composedPath)=="function"?d.composedPath():void 0;return a.containerGroups.findIndex(function(C){var P=C.container,A=C.tabbableNodes;return P.contains(o)||(E==null?void 0:E.includes(P))||A.find(function(F){return F===o})})},g=function(o){var d=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},E=d.hasFallback,C=E===void 0?!1:E,P=d.params,A=P===void 0?[]:P,F=s[o];if(typeof F=="function"&&(F=F.apply(void 0,Ln(A))),F===!0&&(F=void 0),!F){if(F===void 0||F===!1)return F;throw new Error("`".concat(o,"` was specified but was not a node, or did not return a node"))}var j=F;if(typeof F=="string"){try{j=r.querySelector(F)}catch(D){throw new Error("`".concat(o,'` appears to be an invalid selector; error="').concat(D.message,'"'))}if(!j&&!C)throw new Error("`".concat(o,"` as selector refers to no known node"))}return j},x=function(){var o=g("initialFocus",{hasFallback:!0});if(o===!1)return!1;if(o===void 0||o&&!_e(o,s.tabbableOptions))if(b(r.activeElement)>=0)o=r.activeElement;else{var d=a.tabbableGroups[0],E=d&&d.firstTabbableNode;o=E||g("fallbackFocus")}else o===null&&(o=g("fallbackFocus"));if(!o)throw new Error("Your focus-trap needs to have at least one focusable element");return o},O=function(){if(a.containerGroups=a.containers.map(function(o){var d=gn(o,s.tabbableOptions),E=yn(o,s.tabbableOptions),C=d.length>0?d[0]:void 0,P=d.length>0?d[d.length-1]:void 0,A=E.find(function(D){return ae(D)}),F=E.slice().reverse().find(function(D){return ae(D)}),j=!!d.find(function(D){return Q(D)>0});return{container:o,tabbableNodes:d,focusableNodes:E,posTabIndexesFound:j,firstTabbableNode:C,lastTabbableNode:P,firstDomTabbableNode:A,lastDomTabbableNode:F,nextTabbableNode:function(V){var $=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,q=d.indexOf(V);return q<0?$?E.slice(E.indexOf(V)+1).find(function(K){return ae(K)}):E.slice(0,E.indexOf(V)).reverse().find(function(K){return ae(K)}):d[q+($?1:-1)]}}}),a.tabbableGroups=a.containerGroups.filter(function(o){return o.tabbableNodes.length>0}),a.tabbableGroups.length<=0&&!g("fallbackFocus"))throw new Error("Your focus-trap must have at least one container with at least one tabbable node in it at all times");if(a.containerGroups.find(function(o){return o.posTabIndexesFound})&&a.containerGroups.length>1)throw new Error("At least one node with a positive tabindex was found in one of your focus-trap's multiple containers. Positive tabindexes are only supported in single-container focus-traps.")},S=function(o){var d=o.activeElement;if(d)return d.shadowRoot&&d.shadowRoot.activeElement!==null?S(d.shadowRoot):d},f=function(o){if(o!==!1&&o!==S(document)){if(!o||!o.focus){f(x());return}o.focus({preventScroll:!!s.preventScroll}),a.mostRecentlyFocusedNode=o,Wn(o)&&o.select()}},y=function(o){var d=g("setReturnFocus",{params:[o]});return d||(d===!1?!1:o)},c=function(o){var d=o.target,E=o.event,C=o.isBackward,P=C===void 0?!1:C;d=d||Pe(E),O();var A=null;if(a.tabbableGroups.length>0){var F=b(d,E),j=F>=0?a.containerGroups[F]:void 0;if(F<0)P?A=a.tabbableGroups[a.tabbableGroups.length-1].lastTabbableNode:A=a.tabbableGroups[0].firstTabbableNode;else if(P){var D=a.tabbableGroups.findIndex(function(ee){var Z=ee.firstTabbableNode;return d===Z});if(D<0&&(j.container===d||_e(d,s.tabbableOptions)&&!ae(d,s.tabbableOptions)&&!j.nextTabbableNode(d,!1))&&(D=F),D>=0){var V=D===0?a.tabbableGroups.length-1:D-1,$=a.tabbableGroups[V];A=Q(d)>=0?$.lastTabbableNode:$.lastDomTabbableNode}else de(E)||(A=j.nextTabbableNode(d,!1))}else{var q=a.tabbableGroups.findIndex(function(ee){var Z=ee.lastTabbableNode;return d===Z});if(q<0&&(j.container===d||_e(d,s.tabbableOptions)&&!ae(d,s.tabbableOptions)&&!j.nextTabbableNode(d))&&(q=F),q>=0){var K=q===a.tabbableGroups.length-1?0:q+1,Ie=a.tabbableGroups[K];A=Q(d)>=0?Ie.firstTabbableNode:Ie.firstDomTabbableNode}else de(E)||(A=j.nextTabbableNode(d))}}else A=g("fallbackFocus");return A},h=function(o){var d=Pe(o);if(!(b(d,o)>=0)){if(ce(s.clickOutsideDeactivates,o)){v.deactivate({returnFocus:s.returnFocusOnDeactivate});return}ce(s.allowOutsideClick,o)||o.preventDefault()}},m=function(o){var d=Pe(o),E=b(d,o)>=0;if(E||d instanceof Document)E&&(a.mostRecentlyFocusedNode=d);else{o.stopImmediatePropagation();var C,P=!0;if(a.mostRecentlyFocusedNode)if(Q(a.mostRecentlyFocusedNode)>0){var A=b(a.mostRecentlyFocusedNode),F=a.containerGroups[A].tabbableNodes;if(F.length>0){var j=F.findIndex(function(D){return D===a.mostRecentlyFocusedNode});j>=0&&(s.isKeyForward(a.recentNavEvent)?j+1<F.length&&(C=F[j+1],P=!1):j-1>=0&&(C=F[j-1],P=!1))}}else a.containerGroups.some(function(D){return D.tabbableNodes.some(function(V){return Q(V)>0})})||(P=!1);else P=!1;P&&(C=c({target:a.mostRecentlyFocusedNode,isBackward:s.isKeyBackward(a.recentNavEvent)})),f(C||a.mostRecentlyFocusedNode||x())}a.recentNavEvent=void 0},w=function(o){var d=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;a.recentNavEvent=o;var E=c({event:o,isBackward:d});E&&(de(o)&&o.preventDefault(),f(E))},T=function(o){(s.isKeyForward(o)||s.isKeyBackward(o))&&w(o,s.isKeyBackward(o))},p=function(o){Bn(o)&&ce(s.escapeDeactivates,o)!==!1&&(o.preventDefault(),v.deactivate())},M=function(o){var d=Pe(o);b(d,o)>=0||ce(s.clickOutsideDeactivates,o)||ce(s.allowOutsideClick,o)||(o.preventDefault(),o.stopImmediatePropagation())},L=function(){if(a.active)return kt.activateTrap(i,v),a.delayInitialFocusTimer=s.delayInitialFocus?Ct(function(){f(x())}):f(x()),r.addEventListener("focusin",m,!0),r.addEventListener("mousedown",h,{capture:!0,passive:!1}),r.addEventListener("touchstart",h,{capture:!0,passive:!1}),r.addEventListener("click",M,{capture:!0,passive:!1}),r.addEventListener("keydown",T,{capture:!0,passive:!1}),r.addEventListener("keydown",p),v},B=function(){if(a.active)return r.removeEventListener("focusin",m,!0),r.removeEventListener("mousedown",h,!0),r.removeEventListener("touchstart",h,!0),r.removeEventListener("click",M,!0),r.removeEventListener("keydown",T,!0),r.removeEventListener("keydown",p),v},H=function(o){var d=o.some(function(E){var C=Array.from(E.removedNodes);return C.some(function(P){return P===a.mostRecentlyFocusedNode})});d&&f(x())},U=typeof window<"u"&&"MutationObserver"in window?new MutationObserver(H):void 0,W=function(){U&&(U.disconnect(),a.active&&!a.paused&&a.containers.map(function(o){U.observe(o,{subtree:!0,childList:!0})}))};return v={get active(){return a.active},get paused(){return a.paused},activate:function(o){if(a.active)return this;var d=u(o,"onActivate"),E=u(o,"onPostActivate"),C=u(o,"checkCanFocusTrap");C||O(),a.active=!0,a.paused=!1,a.nodeFocusedBeforeActivation=r.activeElement,d==null||d();var P=function(){C&&O(),L(),W(),E==null||E()};return C?(C(a.containers.concat()).then(P,P),this):(P(),this)},deactivate:function(o){if(!a.active)return this;var d=Ft({onDeactivate:s.onDeactivate,onPostDeactivate:s.onPostDeactivate,checkCanReturnFocus:s.checkCanReturnFocus},o);clearTimeout(a.delayInitialFocusTimer),a.delayInitialFocusTimer=void 0,B(),a.active=!1,a.paused=!1,W(),kt.deactivateTrap(i,v);var E=u(d,"onDeactivate"),C=u(d,"onPostDeactivate"),P=u(d,"checkCanReturnFocus"),A=u(d,"returnFocus","returnFocusOnDeactivate");E==null||E();var F=function(){Ct(function(){A&&f(y(a.nodeFocusedBeforeActivation)),C==null||C()})};return A&&P?(P(y(a.nodeFocusedBeforeActivation)).then(F,F),this):(F(),this)},pause:function(o){return a.active?(a.manuallyPaused=!0,this._setPausedState(!0,o)):this},unpause:function(o){return a.active?(a.manuallyPaused=!1,i[i.length-1]!==this?this:this._setPausedState(!1,o)):this},updateContainerElements:function(o){var d=[].concat(o).filter(Boolean);return a.containers=d.map(function(E){return typeof E=="string"?r.querySelector(E):E}),a.active&&O(),W(),this}},Object.defineProperties(v,{_isManuallyPaused:{value:function(){return a.manuallyPaused}},_setPausedState:{value:function(o,d){if(a.paused===o)return this;if(a.paused=o,o){var E=u(d,"onPause"),C=u(d,"onPostPause");E==null||E(),B(),W(),C==null||C()}else{var P=u(d,"onUnpause"),A=u(d,"onPostUnpause");P==null||P(),O(),L(),W(),A==null||A()}return this}}}),v.updateContainerElements(e),v};function Pt(t,e,n){let r=null;return t&&(r=qn(t,{clickOutsideDeactivates:!e,escapeDeactivates:!e,onDeactivate:()=>n==null?void 0:n(),fallbackFocus:()=>t}),r.activate()),{deactivate:()=>{r==null||r.deactivate(),r=null},wrapper:t}}const Xn=({modalContext:t,config:e,children:n})=>{const[r,i]=l.useState(!1),s=l.useRef(null),[a,v]=l.useState(null);function u(){v(Pt(s.current,e==null?void 0:e.closeExplicitly,()=>t.close())),i(!0)}return l.useEffect(()=>()=>a==null?void 0:a.deactivate(),[a]),N.jsx("div",{className:"im-modal-container fixed inset-0 z-40 overflow-y-auto p-4",children:N.jsx("div",{className:be("im-modal-positioner flex min-h-full justify-center",{"items-start":e.position==="top","items-center":e.position==="center","items-end":e.position==="bottom"}),children:N.jsx(Ce,{as:"div",ref:s,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:u,afterLeave:t.afterLeave,className:be("im-modal-wrapper w-full transition duration-300 ease-in-out",t.onTopOfStack?"":"blur-sm",{"sm:max-w-sm":e.maxWidth==="sm","sm:max-w-md":e.maxWidth==="md","sm:max-w-md md:max-w-lg":e.maxWidth==="lg","sm:max-w-md md:max-w-xl":e.maxWidth==="xl","sm:max-w-md md:max-w-xl lg:max-w-2xl":e.maxWidth==="2xl","sm:max-w-md md:max-w-xl lg:max-w-3xl":e.maxWidth==="3xl","sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-4xl":e.maxWidth==="4xl","sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl":e.maxWidth==="5xl","sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl 2xl:max-w-6xl":e.maxWidth==="6xl","sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl 2xl:max-w-7xl":e.maxWidth==="7xl"}),children:N.jsxs("div",{className:`im-modal-content relative ${e.paddingClasses} ${e.panelClasses}`,"data-inertiaui-modal-entered":r,children:[e.closeButton&&N.jsx("div",{className:"absolute right-0 top-0 pr-3 pt-3",children:N.jsx(Nt,{onClick:t.close})}),typeof n=="function"?n({modalContext:t,config:e}):n]})})})})},Vn=({modalContext:t,config:e,children:n})=>{const[r,i]=l.useState(!1),s=l.useRef(null),[a,v]=l.useState(null);function u(){v(Pt(s.current,e==null?void 0:e.closeExplicitly,()=>t.close())),i(!0)}return l.useEffect(()=>()=>a==null?void 0:a.deactivate(),[a]),N.jsx("div",{className:"im-slideover-container fixed inset-0 z-40 overflow-y-auto overflow-x-hidden",children:N.jsx("div",{className:be("im-slideover-positioner flex min-h-full items-center",{"justify-start rtl:justify-end":(e==null?void 0:e.position)==="left","justify-end rtl:justify-start":(e==null?void 0:e.position)==="right"}),children:N.jsx(Ce,{as:"div",ref:s,enterFrom:`opacity-0 ${e.position==="left"?"-translate-x-full":"translate-x-full"}`,enterTo:"opacity-100 translate-x-0",leaveFrom:"opacity-100 translate-x-0",leaveTo:`opacity-0 ${e.position==="left"?"-translate-x-full":"translate-x-full"}`,afterEnter:u,afterLeave:t.afterLeave,className:be("im-slideover-wrapper w-full transition duration-300 ease-in-out",t.onTopOfStack?"":"blur-sm",{"sm:max-w-sm":e.maxWidth==="sm","sm:max-w-md":e.maxWidth==="md","sm:max-w-md md:max-w-lg":e.maxWidth==="lg","sm:max-w-md md:max-w-xl":e.maxWidth==="xl","sm:max-w-md md:max-w-xl lg:max-w-2xl":e.maxWidth==="2xl","sm:max-w-md md:max-w-xl lg:max-w-3xl":e.maxWidth==="3xl","sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-4xl":e.maxWidth==="4xl","sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl":e.maxWidth==="5xl","sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl 2xl:max-w-6xl":e.maxWidth==="6xl","sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl 2xl:max-w-7xl":e.maxWidth==="7xl"}),children:N.jsxs("div",{className:`im-slideover-content relative ${e.paddingClasses} ${e.panelClasses}`,"data-inertiaui-modal-entered":r,children:[e.closeButton&&N.jsx("div",{className:"absolute right-0 top-0 pr-3 pt-3",children:N.jsx(Nt,{onClick:t.close})}),typeof n=="function"?n({modalContext:t,config:e}):n]})})})})},It=l.forwardRef(({name:t,children:e,onFocus:n=null,onBlur:r=null,onClose:i=null,onSuccess:s=null,onAfterLeave:a=null,...v},u)=>{const b=x=>typeof e=="function"?e(x):e,g=l.useRef(null);return l.useEffect(()=>{var x;if(((x=g==null?void 0:g.current)==null?void 0:x.index)===0)return ze.prepare(),()=>ze.cleanup()},[g]),l.useImperativeHandle(u,()=>g.current,[g]),N.jsx($e,{ref:g,name:t,onFocus:n,onBlur:r,onClose:i,onSuccess:s,...v,children:({afterLeave:x,close:O,config:S,emit:f,getChildModal:y,getParentModal:c,id:h,index:m,isOpen:w,modalContext:T,onTopOfStack:p,reload:M,setOpen:L,shouldRender:B})=>N.jsx(Pn,{appear:!0,show:w??!1,afterLeave:a,children:N.jsxs("div",{className:"im-dialog relative z-20","data-inertiaui-modal-id":h,"data-inertiaui-modal-index":m,children:[m===0?N.jsx(Ce,{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?N.jsx("div",{className:"im-backdrop fixed inset-0 z-30 bg-black/75","aria-hidden":"true"}):N.jsx("div",{})}):null,m>0&&p?N.jsx("div",{className:"im-backdrop fixed inset-0 z-30 bg-black/75"}):null,S.slideover?N.jsx(Vn,{modalContext:T,config:S,children:b({afterLeave:x,close:O,config:S,emit:f,getChildModal:y,getParentModal:c,id:h,index:m,isOpen:w,modalContext:T,onTopOfStack:p,reload:M,setOpen:L,shouldRender:B})}):N.jsx(Xn,{modalContext:T,config:S,children:b({afterLeave:x,close:O,config:S,emit:f,getChildModal:y,getParentModal:c,id:h,index:m,isOpen:w,modalContext:T,onTopOfStack:p,reload:M,setOpen:L,shouldRender:B})})]})})})});It.displayName="Modal";const zn=({href:t,method:e="get",data:n={},as:r="a",headers:i={},queryStringArrayFormat:s="brackets",onAfterLeave:a=null,onBlur:v=null,onClose:u=null,onError:b=null,onFocus:g=null,onStart:x=null,onSuccess:O=null,navigate:S=null,children:f,...y})=>{const[c,h]=l.useState(!1),[m,w]=l.useState(null),{stack:T,visit:p}=oe(),M=l.useMemo(()=>S??me("navigate"),[S]),L={},B={};Object.keys(y).forEach(d=>{Qe.includes(d)||(d.startsWith("on")&&typeof y[d]=="function"?d.toLowerCase()in window?L[d]=y[d]:B[d]=y[d]:L[d]=y[d])});const[H,U]=l.useState(!1);l.useEffect(()=>{m&&(m.onTopOfStack&&H?g==null||g():!m.onTopOfStack&&!H&&(v==null||v()),U(!m.onTopOfStack))},[T]);const W=l.useCallback(()=>{u==null||u()},[u]),k=l.useCallback(()=>{w(null),a==null||a()},[a]),o=l.useCallback(d=>{d==null||d.preventDefault(),!c&&(t.startsWith("#")||(h(!0),x==null||x()),p(t,e,n,i,Ut(Ge(y,Qe)),()=>W(T.length),k,s,M).then(E=>{w(E),E.registerEventListenersFromProps(B),O==null||O()}).catch(E=>{console.error(E),b==null||b(E)}).finally(()=>h(!1)))},[t,e,n,i,s,y,W,k]);return N.jsx(r,{...L,href:t,onClick:o,children:typeof f=="function"?f({loading:c}):f})};function Gn(){return oe().stack[De()]??null}const Zn=t=>e=>(e.default.layout=n=>l.createElement(t,{},n),e);I.HeadlessModal=$e,I.Modal=It,I.ModalLink=zn,I.ModalRoot=et,I.ModalStackProvider=Je,I.getConfig=me,I.initFromPageProps=Re,I.putConfig=Dt,I.renderApp=Bt,I.resetConfig=Lt,I.setPageLayout=Zn,I.useModal=Gn,I.useModalIndex=De,I.useModalStack=oe,Object.defineProperty(I,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@inertiaui/modal-react",
3
3
  "author": "Pascal Baljet <pascal@protone.media>",
4
- "version": "0.18.0",
4
+ "version": "0.18.1",
5
5
  "private": false,
6
6
  "license": "MIT",
7
7
  "type": "module",
@@ -34,22 +34,18 @@ const ModalContent = ({ modalContext, config, children }) => {
34
34
  leaveTo="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
35
35
  afterEnter={afterEnter}
36
36
  afterLeave={modalContext.afterLeave}
37
- className={clsx(
38
- 'im-modal-wrapper pointer-events-auto w-full transition duration-300 ease-in-out',
39
- modalContext.onTopOfStack ? '' : 'blur-sm',
40
- {
41
- 'sm:max-w-sm': config.maxWidth === 'sm',
42
- 'sm:max-w-md': config.maxWidth === 'md',
43
- 'sm:max-w-md md:max-w-lg': config.maxWidth === 'lg',
44
- 'sm:max-w-md md:max-w-xl': config.maxWidth === 'xl',
45
- 'sm:max-w-md md:max-w-xl lg:max-w-2xl': config.maxWidth === '2xl',
46
- 'sm:max-w-md md:max-w-xl lg:max-w-3xl': config.maxWidth === '3xl',
47
- 'sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-4xl': config.maxWidth === '4xl',
48
- 'sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl': config.maxWidth === '5xl',
49
- 'sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl 2xl:max-w-6xl': config.maxWidth === '6xl',
50
- 'sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl 2xl:max-w-7xl': config.maxWidth === '7xl',
51
- },
52
- )}
37
+ className={clsx('im-modal-wrapper w-full transition duration-300 ease-in-out', modalContext.onTopOfStack ? '' : 'blur-sm', {
38
+ 'sm:max-w-sm': config.maxWidth === 'sm',
39
+ 'sm:max-w-md': config.maxWidth === 'md',
40
+ 'sm:max-w-md md:max-w-lg': config.maxWidth === 'lg',
41
+ 'sm:max-w-md md:max-w-xl': config.maxWidth === 'xl',
42
+ 'sm:max-w-md md:max-w-xl lg:max-w-2xl': config.maxWidth === '2xl',
43
+ 'sm:max-w-md md:max-w-xl lg:max-w-3xl': config.maxWidth === '3xl',
44
+ 'sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-4xl': config.maxWidth === '4xl',
45
+ 'sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl': config.maxWidth === '5xl',
46
+ 'sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl 2xl:max-w-6xl': config.maxWidth === '6xl',
47
+ 'sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl 2xl:max-w-7xl': config.maxWidth === '7xl',
48
+ })}
53
49
  >
54
50
  <div
55
51
  className={`im-modal-content relative ${config.paddingClasses} ${config.panelClasses}`}
@@ -33,22 +33,18 @@ const SlideoverContent = ({ modalContext, config, children }) => {
33
33
  leaveTo={`opacity-0 ${config.position === 'left' ? '-translate-x-full' : 'translate-x-full'}`}
34
34
  afterEnter={afterEnter}
35
35
  afterLeave={modalContext.afterLeave}
36
- className={clsx(
37
- 'im-slideover-wrapper pointer-events-auto w-full transition duration-300 ease-in-out',
38
- modalContext.onTopOfStack ? '' : 'blur-sm',
39
- {
40
- 'sm:max-w-sm': config.maxWidth === 'sm',
41
- 'sm:max-w-md': config.maxWidth === 'md',
42
- 'sm:max-w-md md:max-w-lg': config.maxWidth === 'lg',
43
- 'sm:max-w-md md:max-w-xl': config.maxWidth === 'xl',
44
- 'sm:max-w-md md:max-w-xl lg:max-w-2xl': config.maxWidth === '2xl',
45
- 'sm:max-w-md md:max-w-xl lg:max-w-3xl': config.maxWidth === '3xl',
46
- 'sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-4xl': config.maxWidth === '4xl',
47
- 'sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl': config.maxWidth === '5xl',
48
- 'sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl 2xl:max-w-6xl': config.maxWidth === '6xl',
49
- 'sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl 2xl:max-w-7xl': config.maxWidth === '7xl',
50
- },
51
- )}
36
+ className={clsx('im-slideover-wrapper w-full transition duration-300 ease-in-out', modalContext.onTopOfStack ? '' : 'blur-sm', {
37
+ 'sm:max-w-sm': config.maxWidth === 'sm',
38
+ 'sm:max-w-md': config.maxWidth === 'md',
39
+ 'sm:max-w-md md:max-w-lg': config.maxWidth === 'lg',
40
+ 'sm:max-w-md md:max-w-xl': config.maxWidth === 'xl',
41
+ 'sm:max-w-md md:max-w-xl lg:max-w-2xl': config.maxWidth === '2xl',
42
+ 'sm:max-w-md md:max-w-xl lg:max-w-3xl': config.maxWidth === '3xl',
43
+ 'sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-4xl': config.maxWidth === '4xl',
44
+ 'sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl': config.maxWidth === '5xl',
45
+ 'sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl 2xl:max-w-6xl': config.maxWidth === '6xl',
46
+ 'sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl 2xl:max-w-7xl': config.maxWidth === '7xl',
47
+ })}
52
48
  >
53
49
  <div
54
50
  className={`im-slideover-content relative ${config.paddingClasses} ${config.panelClasses}`}