import{router as Se}from"@inertiajs/core";import{setupProgress as Z}from"@inertiajs/core";import{createElement as ee}from"react";import{createHeadManager as z,router as $}from"@inertiajs/core";import{createElement as R,useEffect as G,useMemo as X,useState as Y}from"react";import{createContext as J}from"react";var B=J(void 0);B.displayName="InertiaHeadContext";var A=B;import{createContext as Q}from"react";var N=Q(void 0);N.displayName="InertiaPageContext";var E=N;function M({children:l,initialPage:c,initialComponent:s,resolveComponent:p,titleCallback:a,onHeadUpdate:S}){let[d,P]=Y({component:s||null,page:c,key:null}),u=X(()=>z(typeof window>"u",a||(f=>f),S||(()=>{})),[]);if(G(()=>{$.init({initialPage:c,resolveComponent:p,swapComponent:async({component:f,page:e,preserveState:i})=>{P(r=>({component:f,page:e,key:i?r.key:Date.now()}))}}),$.on("navigate",()=>u.forceUpdate())},[]),!d.component)return R(A.Provider,{value:u},R(E.Provider,{value:d.page},null));let g=l||(({Component:f,props:e,key:i})=>{let r=R(f,{key:i,...e});return typeof f.layout=="function"?f.layout(r):Array.isArray(f.layout)?f.layout.concat(r).reverse().reduce((y,T)=>R(T,{children:y,...e})):r});return R(A.Provider,{value:u},R(E.Provider,{value:d.page},g({Component:d.component,key:d.key,props:d.page.props})))}M.displayName="Inertia";async function U({id:l="app",resolve:c,setup:s,title:p,progress:a={},page:S,render:d}){let P=typeof window>"u",u=P?null:document.getElementById(l),g=S||JSON.parse(u.dataset.page),f=r=>Promise.resolve(c(r)).then(y=>y.default||y),e=[],i=await f(g.component).then(r=>s({el:u,App:M,props:{initialPage:g,initialComponent:r,resolveComponent:f,titleCallback:p,onHeadUpdate:P?y=>e=y:null}}));if(!P&&a&&Z(a),P){let r=await d(ee("div",{id:l,"data-page":JSON.stringify(g)},i));return{head:e,body:r}}}import V,{useContext as te,useEffect as re,useMemo as oe}from"react";var ne=function({children:l,title:c}){let s=te(A),p=oe(()=>s.createProvider(),[s]);re(()=>()=>{p.disconnect()},[p]);function a(e){return["area","base","br","col","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"].indexOf(e.type)>-1}function S(e){let i=Object.keys(e.props).reduce((r,y)=>{if(["head-key","children","dangerouslySetInnerHTML"].includes(y))return r;let T=e.props[y];return T===""?r+` ${y}`:r+` ${y}="${T}"`},"");return`<${e.type}${i}>`}function d(e){return typeof e.props.children=="string"?e.props.children:e.props.children.reduce((i,r)=>i+P(r),"")}function P(e){let i=S(e);return e.props.children&&(i+=d(e)),e.props.dangerouslySetInnerHTML&&(i+=e.props.dangerouslySetInnerHTML.__html),a(e)||(i+=`</${e.type}>`),i}function u(e){return V.cloneElement(e,{inertia:e.props["head-key"]!==void 0?e.props["head-key"]:""})}function g(e){return P(u(e))}function f(e){let i=V.Children.toArray(e).filter(r=>r).map(r=>g(r));return c&&!i.find(r=>r.startsWith("<title"))&&i.push(`<title inertia>${c}</title>`),i}return p.update(f(l)),null},ae=ne;import{mergeDataIntoQueryString as se,router as ie,shouldIntercept as pe}from"@inertiajs/core";import{createElement as ue,forwardRef as ce,useCallback as le}from"react";var k=()=>{},j=ce(({children:l,as:c="a",data:s={},href:p,method:a="get",preserveScroll:S=!1,preserveState:d=null,replace:P=!1,only:u=[],headers:g={},queryStringArrayFormat:f="brackets",onClick:e=k,onCancelToken:i=k,onBefore:r=k,onStart:y=k,onProgress:T=k,onFinish:H=k,onCancel:F=k,onSuccess:L=k,onError:b=k,...O},x)=>{let I=le(o=>{e(o),pe(o)&&(o.preventDefault(),ie.visit(p,{data:s,method:a,preserveScroll:S,preserveState:d??a!=="get",replace:P,only:u,headers:g,onCancelToken:i,onBefore:r,onStart:y,onProgress:T,onFinish:H,onCancel:F,onSuccess:L,onError:b}))},[s,p,a,S,d,P,u,g,e,i,r,y,T,H,F,L,b]);c=c.toLowerCase(),a=a.toLowerCase();let[h,t]=se(a,p||"",s,f);return p=h,s=t,c==="a"&&a!=="get"&&console.warn(`Creating POST/PUT/PATCH/DELETE <a> links is discouraged as it causes "Open Link in New Tab/Window" accessibility issues.

Please specify a more appropriate element using the "as" attribute. For example:

<Link href="${p}" method="${a}" as="button">...</Link>`),ue(c,{...O,...c==="a"?{href:p}:{},ref:x,onClick:I},l)});j.displayName="InertiaLink";var de=j;import{router as _}from"@inertiajs/core";import ge from"lodash.isequal";import{useCallback as ye,useEffect as Pe,useRef as D,useState as v}from"react";import{router as K}from"@inertiajs/core";import{useEffect as fe,useState as me}from"react";function w(l,c){let[s,p]=me(()=>{let a=K.restore(c);return a!==void 0?a:l});return fe(()=>{K.remember(s,c)},[s,c]),[s,p]}function W(l,c){let s=D(null),p=typeof l=="string"?l:null,[a,S]=v((typeof l=="string"?c:l)||{}),d=D(null),P=D(null),[u,g]=p?w(a,`${p}:data`):v(a),[f,e]=p?w({},`${p}:errors`):v({}),[i,r]=v(!1),[y,T]=v(!1),[H,F]=v(null),[L,b]=v(!1),[O,x]=v(!1),I=t=>t;Pe(()=>(s.current=!0,()=>{s.current=!1}),[]);let h=ye((t,o,n={})=>{let C={...n,onCancelToken:m=>{if(d.current=m,n.onCancelToken)return n.onCancelToken(m)},onBefore:m=>{if(b(!1),x(!1),clearTimeout(P.current),n.onBefore)return n.onBefore(m)},onStart:m=>{if(T(!0),n.onStart)return n.onStart(m)},onProgress:m=>{if(F(m),n.onProgress)return n.onProgress(m)},onSuccess:m=>{if(s.current&&(T(!1),F(null),e({}),r(!1),b(!0),x(!0),P.current=setTimeout(()=>{s.current&&x(!1)},2e3)),n.onSuccess)return n.onSuccess(m)},onError:m=>{if(s.current&&(T(!1),F(null),e(m),r(!0)),n.onError)return n.onError(m)},onCancel:()=>{if(s.current&&(T(!1),F(null)),n.onCancel)return n.onCancel()},onFinish:()=>{if(s.current&&(T(!1),F(null)),d.current=null,n.onFinish)return n.onFinish()}};t==="delete"?_.delete(o,{...C,data:I(u)}):_[t](o,I(u),C)},[u,e]);return{data:u,setData(t,o){g(typeof t=="string"?{...u,[t]:o}:typeof t=="function"?n=>t(n):t)},isDirty:!ge(u,a),errors:f,hasErrors:i,processing:y,progress:H,wasSuccessful:L,recentlySuccessful:O,transform(t){I=t},setDefaults(t,o){S(typeof t>"u"?()=>u:n=>({...n,...typeof t=="string"?{[t]:o}:t}))},reset(...t){t.length===0?g(a):g(Object.keys(a).filter(o=>t.includes(o)).reduce((o,n)=>(o[n]=a[n],o),{...u}))},setError(t,o){e(n=>{let C={...n,...typeof t=="string"?{[t]:o}:t};return r(Object.keys(C).length>0),C})},clearErrors(...t){e(o=>{let n=Object.keys(o).reduce((C,m)=>({...C,...t.length>0&&!t.includes(m)?{[m]:o[m]}:{}}),{});return r(Object.keys(n).length>0),n})},submit:h,get(t,o){h("get",t,o)},post(t,o){h("post",t,o)},put(t,o){h("put",t,o)},patch(t,o){h("patch",t,o)},delete(t,o){h("delete",t,o)},cancel(){d.current&&d.current.cancel()}}}import{useContext as Te}from"react";function q(){let l=Te(E);if(!l)throw new Error("usePage must be used within the Inertia component");return l}var gt=Se;export{ae as Head,de as Link,U as createInertiaApp,gt as router,W as useForm,q as usePage,w as useRemember};
//# sourceMappingURL=index.esm.js.map
