import{router as Me}from"@inertiajs/core";import{setupProgress as fe}from"@inertiajs/core";import{createElement as me}from"react";import{createHeadManager as ue,router as _}from"@inertiajs/core";import{createElement as x,useEffect as ce,useMemo as le,useState as de}from"react";import{createContext as ie}from"react";var V=ie(void 0);V.displayName="InertiaHeadContext";var M=V;import{createContext as pe}from"react";var K=pe(void 0);K.displayName="InertiaPageContext";var H=K;function N({children:l,initialPage:p,initialComponent:a,resolveComponent:i,titleCallback:n,onHeadUpdate:F}){let[d,y]=de({component:a||null,page:p,key:null}),u=le(()=>ue(typeof window>"u",n||(c=>c),F||(()=>{})),[]);if(ce(()=>{_.init({initialPage:p,resolveComponent:i,swapComponent:async({component:c,page:e,preserveState:s})=>{y(r=>({component:c,page:e,key:s?r.key:Date.now()}))}}),_.on("navigate",()=>u.forceUpdate())},[]),!d.component)return x(M.Provider,{value:u},x(H.Provider,{value:d.page},null));let f=l||(({Component:c,props:e,key:s})=>{let r=x(c,{key:s,...e});return typeof c.layout=="function"?c.layout(r):Array.isArray(c.layout)?c.layout.concat(r).reverse().reduce((g,T)=>x(T,{children:g,...e})):r});return x(M.Provider,{value:u},x(H.Provider,{value:d.page},f({Component:d.component,key:d.key,props:d.page.props})))}N.displayName="Inertia";async function W({id:l="app",resolve:p,setup:a,title:i,progress:n={},page:F,render:d}){let y=typeof window>"u",u=y?null:document.getElementById(l),f=F||JSON.parse(u.dataset.page),c=r=>Promise.resolve(p(r)).then(g=>g.default||g),e=[],s=await c(f.component).then(r=>a({el:u,App:N,props:{initialPage:f,initialComponent:r,resolveComponent:c,titleCallback:i,onHeadUpdate:y?g=>e=g:null}}));if(!y&&n&&fe(n),y){let r=await d(me("div",{id:l,"data-page":JSON.stringify(f)},s));return{head:e,body:r}}}import q,{useContext as ge,useEffect as ye,useMemo as Pe}from"react";var Te=function({children:l,title:p}){let a=ge(M),i=Pe(()=>a.createProvider(),[a]);ye(()=>()=>{i.disconnect()},[i]);function n(e){return["area","base","br","col","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"].indexOf(e.type)>-1}function F(e){let s=Object.keys(e.props).reduce((r,g)=>{if(["head-key","children","dangerouslySetInnerHTML"].includes(g))return r;let T=e.props[g];return T===""?r+` ${g}`:r+` ${g}="${T}"`},"");return`<${e.type}${s}>`}function d(e){return typeof e.props.children=="string"?e.props.children:e.props.children.reduce((s,r)=>s+y(r),"")}function y(e){let s=F(e);return e.props.children&&(s+=d(e)),e.props.dangerouslySetInnerHTML&&(s+=e.props.dangerouslySetInnerHTML.__html),n(e)||(s+=`</${e.type}>`),s}function u(e){return q.cloneElement(e,{inertia:e.props["head-key"]!==void 0?e.props["head-key"]:""})}function f(e){return y(u(e))}function c(e){let s=q.Children.toArray(e).filter(r=>r).map(r=>f(r));return p&&!s.find(r=>r.startsWith("<title"))&&s.push(`<title inertia>${p}</title>`),s}return i.update(c(l)),null},Se=Te;import{mergeDataIntoQueryString as Fe,router as he,shouldIntercept as ve}from"@inertiajs/core";import{createElement as Ce,forwardRef as ke,useCallback as be}from"react";var C=()=>{},J=ke(({children:l,as:p="a",data:a={},href:i,method:n="get",preserveScroll:F=!1,preserveState:d=null,replace:y=!1,only:u=[],except:f=[],headers:c={},queryStringArrayFormat:e="brackets",onClick:s=C,onCancelToken:r=C,onBefore:g=C,onStart:T=C,onProgress:O=C,onFinish:k=C,onCancel:L=C,onSuccess:R=C,onError:B=C,...I},A)=>{let v=be(E=>{s(E),ve(E)&&(E.preventDefault(),he.visit(i,{data:a,method:n,preserveScroll:F,preserveState:d??n!=="get",replace:y,only:u,except:f,headers:c,onCancelToken:r,onBefore:g,onStart:T,onProgress:O,onFinish:k,onCancel:L,onSuccess:R,onError:B}))},[a,i,n,F,d,y,u,f,c,s,r,g,T,O,k,L,R,B]);p=p.toLowerCase(),n=n.toLowerCase();let[j,U]=Fe(n,i||"",a,e);return i=j,a=U,p==="a"&&n!=="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="${i}" method="${n}" as="button">...</Link>`),Ce(p,{...I,...p==="a"?{href:i}:{},ref:A,onClick:v},l)});J.displayName="InertiaLink";var xe=J;import{router as z}from"@inertiajs/core";import Ae from"lodash.isequal";import{useCallback as S,useEffect as Ee,useRef as $,useState as b}from"react";import{router as Q}from"@inertiajs/core";import{useEffect as Re,useState as Ie}from"react";function w(l,p){let[a,i]=Ie(()=>{let n=Q.restore(p);return n!==void 0?n:l});return Re(()=>{Q.remember(a,p)},[a,p]),[a,i]}function G(l,p){let a=$(null),i=typeof l=="string"?l:null,[n,F]=b((typeof l=="string"?p:l)||{}),d=$(null),y=$(null),[u,f]=i?w(n,`${i}:data`):b(n),[c,e]=i?w({},`${i}:errors`):b({}),[s,r]=b(!1),[g,T]=b(!1),[O,k]=b(null),[L,R]=b(!1),[B,I]=b(!1),A=$(o=>o);Ee(()=>(a.current=!0,()=>{a.current=!1}),[]);let v=S((o,P,t={})=>{let h={...t,onCancelToken:m=>{if(d.current=m,t.onCancelToken)return t.onCancelToken(m)},onBefore:m=>{if(R(!1),I(!1),clearTimeout(y.current),t.onBefore)return t.onBefore(m)},onStart:m=>{if(T(!0),t.onStart)return t.onStart(m)},onProgress:m=>{if(k(m),t.onProgress)return t.onProgress(m)},onSuccess:m=>{if(a.current&&(T(!1),k(null),e({}),r(!1),R(!0),I(!0),y.current=setTimeout(()=>{a.current&&I(!1)},2e3)),t.onSuccess)return t.onSuccess(m)},onError:m=>{if(a.current&&(T(!1),k(null),e(m),r(!0)),t.onError)return t.onError(m)},onCancel:()=>{if(a.current&&(T(!1),k(null)),t.onCancel)return t.onCancel()},onFinish:()=>{if(a.current&&(T(!1),k(null)),d.current=null,t.onFinish)return t.onFinish()}};o==="delete"?z.delete(P,{...h,data:A.current(u)}):z[o](P,A.current(u),h)},[u,e]),j=S((o,P)=>{f(typeof o=="string"?t=>({...t,[o]:P}):typeof o=="function"?t=>o(t):o)},[f]),U=S((o,P)=>{F(typeof o>"u"?()=>u:t=>({...t,...typeof o=="string"?{[o]:P}:o}))},[u,F]),E=S((...o)=>{o.length===0?f(n):f(P=>Object.keys(n).filter(t=>o.includes(t)).reduce((t,h)=>(t[h]=n[h],t),{...P}))},[f,n]),Y=S((o,P)=>{e(t=>{let h={...t,...typeof o=="string"?{[o]:P}:o};return r(Object.keys(h).length>0),h})},[e,r]),Z=S((...o)=>{e(P=>{let t=Object.keys(P).reduce((h,m)=>({...h,...o.length>0&&!o.includes(m)?{[m]:P[m]}:{}}),{});return r(Object.keys(t).length>0),t})},[e,r]),D=o=>(P,t)=>{v(o,P,t)},ee=S(D("get"),[v]),te=S(D("post"),[v]),re=S(D("put"),[v]),oe=S(D("patch"),[v]),ne=S(D("delete"),[v]),ae=S(()=>{d.current&&d.current.cancel()},[]),se=S(o=>{A.current=o},[]);return{data:u,setData:j,isDirty:!Ae(u,n),errors:c,hasErrors:s,processing:g,progress:O,wasSuccessful:L,recentlySuccessful:B,transform:se,setDefaults:U,reset:E,setError:Y,clearErrors:Z,submit:v,get:ee,post:te,put:re,patch:oe,delete:ne,cancel:ae}}import{useContext as De}from"react";function X(){let l=De(H);if(!l)throw new Error("usePage must be used within the Inertia component");return l}var At=Me;export{Se as Head,xe as Link,W as createInertiaApp,At as router,G as useForm,X as usePage,w as useRemember};
//# sourceMappingURL=index.esm.js.map
