@inertiajs/core 2.0.13 → 2.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- function I(r,e){let t;return function(...i){clearTimeout(t),t=setTimeout(()=>r.apply(this,i),e)}}function S(r,e){return document.dispatchEvent(new CustomEvent(`inertia:${r}`,e))}var Z=r=>S("before",{cancelable:!0,detail:{visit:r}}),de=r=>S("error",{detail:{errors:r}}),he=r=>S("exception",{cancelable:!0,detail:{exception:r}}),me=r=>S("finish",{detail:{visit:r}}),fe=r=>S("invalid",{cancelable:!0,detail:{response:r}}),q=r=>S("navigate",{detail:{page:r}}),ge=r=>S("progress",{detail:{progress:r}}),ve=r=>S("start",{detail:{visit:r}}),ye=r=>S("success",{detail:{page:r}}),be=(r,e)=>S("prefetched",{detail:{fetchedAt:Date.now(),response:r.data,visit:e}}),Pe=r=>S("prefetching",{detail:{visit:r}});var m=class{static set(e,t){typeof window<"u"&&window.sessionStorage.setItem(e,JSON.stringify(t))}static get(e){if(typeof window<"u")return JSON.parse(window.sessionStorage.getItem(e)||"null")}static merge(e,t){let i=this.get(e);i===null?this.set(e,t):this.set(e,{...i,...t})}static remove(e){typeof window<"u"&&window.sessionStorage.removeItem(e)}static removeNested(e,t){let i=this.get(e);i!==null&&(delete i[t],this.set(e,i))}static exists(e){try{return this.get(e)!==null}catch{return!1}}static clear(){typeof window<"u"&&window.sessionStorage.clear()}};m.locationVisitKey="inertiaLocationVisit";var we=async r=>{if(typeof window>"u")throw new Error("Unable to encrypt history");let e=Ee(),t=await Re(),i=await We(t);if(!i)throw new Error("Unable to encrypt history");return await Be(e,i,r)},V={key:"historyKey",iv:"historyIv"},Se=async r=>{let e=Ee(),t=await Re();if(!t)throw new Error("Unable to decrypt history");return await Ge(e,t,r)},Be=async(r,e,t)=>{if(typeof window>"u")throw new Error("Unable to encrypt history");if(typeof window.crypto.subtle>"u")return console.warn("Encryption is not supported in this environment. SSL is required."),Promise.resolve(t);let i=new TextEncoder,s=JSON.stringify(t),o=new Uint8Array(s.length*3),u=i.encodeInto(s,o);return window.crypto.subtle.encrypt({name:"AES-GCM",iv:r},e,o.subarray(0,u.written))},Ge=async(r,e,t)=>{if(typeof window.crypto.subtle>"u")return console.warn("Decryption is not supported in this environment. SSL is required."),Promise.resolve(t);let i=await window.crypto.subtle.decrypt({name:"AES-GCM",iv:r},e,t);return JSON.parse(new TextDecoder().decode(i))},Ee=()=>{let r=m.get(V.iv);if(r)return new Uint8Array(r);let e=window.crypto.getRandomValues(new Uint8Array(12));return m.set(V.iv,Array.from(e)),e},Ke=async()=>typeof window.crypto.subtle>"u"?(console.warn("Encryption is not supported in this environment. SSL is required."),Promise.resolve(null)):window.crypto.subtle.generateKey({name:"AES-GCM",length:256},!0,["encrypt","decrypt"]),je=async r=>{if(typeof window.crypto.subtle>"u")return console.warn("Encryption is not supported in this environment. SSL is required."),Promise.resolve();let e=await window.crypto.subtle.exportKey("raw",r);m.set(V.key,Array.from(new Uint8Array(e)))},We=async r=>{if(r)return r;let e=await Ke();return e?(await je(e),e):null},Re=async()=>{let r=m.get(V.key);return r?await window.crypto.subtle.importKey("raw",new Uint8Array(r),{name:"AES-GCM",length:256},!0,["encrypt","decrypt"]):null};var v=class{static save(){l.saveScrollPositions(Array.from(this.regions()).map(e=>({top:e.scrollTop,left:e.scrollLeft})))}static regions(){return document.querySelectorAll("[scroll-region]")}static reset(){typeof window<"u"&&window.scrollTo(0,0),this.regions().forEach(e=>{typeof e.scrollTo=="function"?e.scrollTo(0,0):(e.scrollTop=0,e.scrollLeft=0)}),this.save(),window.location.hash&&setTimeout(()=>document.getElementById(window.location.hash.slice(1))?.scrollIntoView())}static restore(e){this.restoreDocument(),this.regions().forEach((t,i)=>{let s=e[i];s&&(typeof t.scrollTo=="function"?t.scrollTo(s.left,s.top):(t.scrollTop=s.top,t.scrollLeft=s.left))})}static restoreDocument(){let e=l.getDocumentScrollPosition();typeof window<"u"&&window.scrollTo(e.left,e.top)}static onScroll(e){let t=e.target;typeof t.hasAttribute=="function"&&t.hasAttribute("scroll-region")&&this.save()}static onWindowScroll(){l.saveDocumentScrollPosition({top:window.scrollY,left:window.scrollX})}};import{mergeWith as Xe}from"es-toolkit";import*as B from"qs";function $(r){return r instanceof File||r instanceof Blob||r instanceof FileList&&r.length>0||r instanceof FormData&&Array.from(r.values()).some(e=>$(e))||typeof r=="object"&&r!==null&&Object.values(r).some(e=>$(e))}var ee=r=>r instanceof FormData;function te(r,e=new FormData,t=null){r=r||{};for(let i in r)Object.prototype.hasOwnProperty.call(r,i)&&xe(e,Te(t,i),r[i]);return e}function Te(r,e){return r?r+"["+e+"]":e}function xe(r,e,t){if(Array.isArray(t))return Array.from(t.keys()).forEach(i=>xe(r,Te(e,i.toString()),t[i]));if(t instanceof Date)return r.append(e,t.toISOString());if(t instanceof File)return r.append(e,t,t.name);if(t instanceof Blob)return r.append(e,t);if(typeof t=="boolean")return r.append(e,t?"1":"0");if(typeof t=="string")return r.append(e,t);if(typeof t=="number")return r.append(e,`${t}`);if(t==null)return r.append(e,"");te(t,r,e)}function P(r){return new URL(r.toString(),typeof window>"u"?void 0:window.location.toString())}var qe=(r,e,t,i,s)=>{let o=typeof r=="string"?P(r):r;if(($(e)||i)&&!ee(e)&&(e=te(e)),ee(e))return[o,e];let[u,p]=Ce(t,o,e,s);return[P(u),p]};function Ce(r,e,t,i="brackets"){let s=/^[a-z][a-z0-9+.-]*:\/\//i.test(e.toString()),o=s||e.toString().startsWith("/"),u=!o&&!e.toString().startsWith("#")&&!e.toString().startsWith("?"),p=e.toString().includes("?")||r==="get"&&Object.keys(t).length,d=e.toString().includes("#"),a=new URL(e.toString(),"http://localhost");return r==="get"&&Object.keys(t).length&&(a.search=B.stringify(Xe(B.parse(a.search,{ignoreQueryPrefix:!0}),t,(h,c,b,x)=>{c===void 0&&delete x[b]}),{encodeValuesOnly:!0,arrayFormat:i}),t={}),[[s?`${a.protocol}//${a.host}`:"",o?a.pathname:"",u?a.pathname.substring(1):"",p?a.search:"",d?a.hash:""].join(""),t]}function O(r){return r=new URL(r.href),r.hash="",r}var re=(r,e)=>{r.hash&&!e.hash&&O(r).href===e.href&&(e.hash=r.hash)},L=(r,e)=>O(r).href===O(e).href;var ie=class{constructor(){this.componentId={};this.listeners=[];this.isFirstPageLoad=!0;this.cleared=!1}init({initialPage:e,swapComponent:t,resolveComponent:i}){return this.page=e,this.swapComponent=t,this.resolveComponent=i,this}set(e,{replace:t=!1,preserveScroll:i=!1,preserveState:s=!1}={}){this.componentId={};let o=this.componentId;return e.clearHistory&&l.clear(),this.resolve(e.component).then(u=>{if(o!==this.componentId)return;e.rememberedState??(e.rememberedState={});let p=typeof window<"u"?window.location:new URL(e.url);return t=t||L(P(e.url),p),new Promise(d=>{t?l.replaceState(e,()=>d(null)):l.pushState(e,()=>d(null))}).then(()=>{let d=!this.isTheSame(e);return this.page=e,this.cleared=!1,d&&this.fireEventsFor("newComponent"),this.isFirstPageLoad&&this.fireEventsFor("firstLoad"),this.isFirstPageLoad=!1,this.swap({component:u,page:e,preserveState:s}).then(()=>{i||v.reset(),E.fireInternalEvent("loadDeferredProps"),t||q(e)})})})}setQuietly(e,{preserveState:t=!1}={}){return this.resolve(e.component).then(i=>(this.page=e,this.cleared=!1,l.setCurrent(e),this.swap({component:i,page:e,preserveState:t})))}clear(){this.cleared=!0}isCleared(){return this.cleared}get(){return this.page}merge(e){this.page={...this.page,...e}}setUrlHash(e){this.page.url.includes(e)||(this.page.url+=e)}remember(e){this.page.rememberedState=e}swap({component:e,page:t,preserveState:i}){return this.swapComponent({component:e,page:t,preserveState:i})}resolve(e){return Promise.resolve(this.resolveComponent(e))}isTheSame(e){return this.page.component===e.component}on(e,t){return this.listeners.push({event:e,callback:t}),()=>{this.listeners=this.listeners.filter(i=>i.event!==e&&i.callback!==t)}}fireEventsFor(e){this.listeners.filter(t=>t.event===e).forEach(t=>t.callback())}},n=new ie;var F=class{constructor(){this.items=[];this.processingPromise=null}add(e){return this.items.push(e),this.process()}process(){return this.processingPromise??(this.processingPromise=this.processNext().then(()=>{this.processingPromise=null})),this.processingPromise}processNext(){let e=this.items.shift();return e?Promise.resolve(e()).then(()=>this.processNext()):Promise.resolve()}};var U=typeof window>"u",k=new F,Ae=!U&&/CriOS/.test(window.navigator.userAgent),se=class{constructor(){this.rememberedState="rememberedState";this.scrollRegions="scrollRegions";this.preserveUrl=!1;this.current={};this.initialState=null}remember(e,t){this.replaceState({...n.get(),rememberedState:{...n.get()?.rememberedState??{},[t]:e}})}restore(e){if(!U)return this.initialState?.[this.rememberedState]?.[e]}pushState(e,t=null){if(!U){if(this.preserveUrl){t&&t();return}this.current=e,k.add(()=>this.getPageData(e).then(i=>{let s=()=>{this.doPushState({page:i},e.url),t&&t()};Ae?setTimeout(s):s()}))}}getPageData(e){return new Promise(t=>e.encryptHistory?we(e).then(t):t(e))}processQueue(){return k.process()}decrypt(e=null){if(U)return Promise.resolve(e??n.get());let t=e??window.history.state?.page;return this.decryptPageData(t).then(i=>{if(!i)throw new Error("Unable to decrypt history");return this.initialState===null?this.initialState=i??void 0:this.current=i??{},i})}decryptPageData(e){return e instanceof ArrayBuffer?Se(e):Promise.resolve(e)}saveScrollPositions(e){k.add(()=>Promise.resolve().then(()=>{window.history.state?.page&&this.doReplaceState({page:window.history.state.page,scrollRegions:e})}))}saveDocumentScrollPosition(e){k.add(()=>Promise.resolve().then(()=>{window.history.state?.page&&this.doReplaceState({page:window.history.state.page,documentScrollPosition:e})}))}getScrollRegions(){return window.history.state?.scrollRegions||[]}getDocumentScrollPosition(){return window.history.state?.documentScrollPosition||{top:0,left:0}}replaceState(e,t=null){if(n.merge(e),!U){if(this.preserveUrl){t&&t();return}this.current=e,k.add(()=>this.getPageData(e).then(i=>{let s=()=>{this.doReplaceState({page:i},e.url),t&&t()};Ae?setTimeout(s):s()}))}}doReplaceState(e,t){window.history.replaceState({...e,scrollRegions:e.scrollRegions??window.history.state?.scrollRegions,documentScrollPosition:e.documentScrollPosition??window.history.state?.documentScrollPosition},"",t)}doPushState(e,t){window.history.pushState(e,"",t)}getState(e,t){return this.current?.[e]??t}deleteState(e){this.current[e]!==void 0&&(delete this.current[e],this.replaceState(this.current))}hasAnyState(){return!!this.getAllState()}clear(){m.remove(V.key),m.remove(V.iv)}setCurrent(e){this.current=e}isValidState(e){return!!e.page}getAllState(){return this.current}};typeof window<"u"&&window.history.scrollRestoration&&(window.history.scrollRestoration="manual");var l=new se;var ne=class{constructor(){this.internalListeners=[]}init(){typeof window<"u"&&(window.addEventListener("popstate",this.handlePopstateEvent.bind(this)),window.addEventListener("scroll",I(v.onWindowScroll.bind(v),100),!0)),typeof document<"u"&&document.addEventListener("scroll",I(v.onScroll.bind(v),100),!0)}onGlobalEvent(e,t){let i=s=>{let o=t(s);s.cancelable&&!s.defaultPrevented&&o===!1&&s.preventDefault()};return this.registerListener(`inertia:${e}`,i)}on(e,t){return this.internalListeners.push({event:e,listener:t}),()=>{this.internalListeners=this.internalListeners.filter(i=>i.listener!==t)}}onMissingHistoryItem(){n.clear(),this.fireInternalEvent("missingHistoryItem")}fireInternalEvent(e){this.internalListeners.filter(t=>t.event===e).forEach(t=>t.listener())}registerListener(e,t){return document.addEventListener(e,t),()=>document.removeEventListener(e,t)}handlePopstateEvent(e){let t=e.state||null;if(t===null){let i=P(n.get().url);i.hash=window.location.hash,l.replaceState({...n.get(),url:i.href}),v.reset();return}if(!l.isValidState(t))return this.onMissingHistoryItem();l.decrypt(t.page).then(i=>{if(n.get().version!==i.version){this.onMissingHistoryItem();return}n.setQuietly(i,{preserveState:!1}).then(()=>{window.requestAnimationFrame(()=>{v.restore(l.getScrollRegions())}),q(n.get())})}).catch(()=>{this.onMissingHistoryItem()})}},E=new ne;var oe=class{constructor(){this.type=this.resolveType()}resolveType(){return typeof window>"u"?"navigate":window.performance&&window.performance.getEntriesByType&&window.performance.getEntriesByType("navigation").length>0?window.performance.getEntriesByType("navigation")[0].type:"navigate"}get(){return this.type}isBackForward(){return this.type==="back_forward"}isReload(){return this.type==="reload"}},G=new oe;var K=class{static handle(){this.clearRememberedStateOnReload(),[this.handleBackForward,this.handleLocation,this.handleDefault].find(t=>t.bind(this)())}static clearRememberedStateOnReload(){G.isReload()&&l.deleteState(l.rememberedState)}static handleBackForward(){if(!G.isBackForward()||!l.hasAnyState())return!1;let e=l.getScrollRegions();return l.decrypt().then(t=>{n.set(t,{preserveScroll:!0,preserveState:!0}).then(()=>{v.restore(e),q(n.get())})}).catch(()=>{E.onMissingHistoryItem()}),!0}static handleLocation(){if(!m.exists(m.locationVisitKey))return!1;let e=m.get(m.locationVisitKey)||{};return m.remove(m.locationVisitKey),typeof window<"u"&&n.setUrlHash(window.location.hash),l.decrypt(n.get()).then(()=>{let t=l.getState(l.rememberedState,{}),i=l.getScrollRegions();n.remember(t),n.set(n.get(),{preserveScroll:e.preserveScroll,preserveState:!0}).then(()=>{e.preserveScroll&&v.restore(i),q(n.get())})}).catch(()=>{E.onMissingHistoryItem()}),!0}static handleDefault(){typeof window<"u"&&n.setUrlHash(window.location.hash),n.set(n.get(),{preserveScroll:!0,preserveState:!0}).then(()=>{G.isReload()&&v.restore(l.getScrollRegions()),q(n.get())})}};var j=class{constructor(e,t,i){this.id=null;this.throttle=!1;this.keepAlive=!1;this.cbCount=0;this.keepAlive=i.keepAlive??!1,this.cb=t,this.interval=e,(i.autoStart??!0)&&this.start()}stop(){this.id&&clearInterval(this.id)}start(){typeof window>"u"||(this.stop(),this.id=window.setInterval(()=>{(!this.throttle||this.cbCount%10===0)&&this.cb(),this.throttle&&this.cbCount++},this.interval))}isInBackground(e){this.throttle=this.keepAlive?!1:e,this.throttle&&(this.cbCount=0)}};var ae=class{constructor(){this.polls=[];this.setupVisibilityListener()}add(e,t,i){let s=new j(e,t,i);return this.polls.push(s),{stop:()=>s.stop(),start:()=>s.start()}}clear(){this.polls.forEach(e=>e.stop()),this.polls=[]}setupVisibilityListener(){typeof document>"u"||document.addEventListener("visibilitychange",()=>{this.polls.forEach(e=>e.isInBackground(document.hidden))},!1)}},Ve=new ae;import{cloneDeep as ze}from"es-toolkit";var le=(r,e,t)=>{if(r===e)return!0;for(let i in r)if(!t.includes(i)&&r[i]!==e[i]&&!Je(r[i],e[i]))return!1;return!0},Je=(r,e)=>{switch(typeof r){case"object":return le(r,e,[]);case"function":return r.toString()===e.toString();default:return r===e}};var Qe={ms:1,s:1e3,m:6e4,h:36e5,d:864e5},ce=r=>{if(typeof r=="number")return r;for(let[e,t]of Object.entries(Qe))if(r.endsWith(e))return parseFloat(r)*t;return parseInt(r)};var ue=class{constructor(){this.cached=[];this.inFlightRequests=[];this.removalTimers=[];this.currentUseId=null}add(e,t,{cacheFor:i}){if(this.findInFlight(e))return Promise.resolve();let o=this.findCached(e);if(!e.fresh&&o&&o.staleTimestamp>Date.now())return Promise.resolve();let[u,p]=this.extractStaleValues(i),d=new Promise((a,h)=>{t({...e,onCancel:()=>{this.remove(e),e.onCancel(),h()},onError:c=>{this.remove(e),e.onError(c),h()},onPrefetching(c){e.onPrefetching(c)},onPrefetched(c,b){e.onPrefetched(c,b)},onPrefetchResponse(c){a(c)}})}).then(a=>(this.remove(e),this.cached.push({params:{...e},staleTimestamp:Date.now()+u,response:d,singleUse:i===0,timestamp:Date.now(),inFlight:!1}),this.scheduleForRemoval(e,p),this.inFlightRequests=this.inFlightRequests.filter(h=>!this.paramsAreEqual(h.params,e)),a.handlePrefetch(),a));return this.inFlightRequests.push({params:{...e},response:d,staleTimestamp:null,inFlight:!0}),d}removeAll(){this.cached=[],this.removalTimers.forEach(e=>{clearTimeout(e.timer)}),this.removalTimers=[]}remove(e){this.cached=this.cached.filter(t=>!this.paramsAreEqual(t.params,e)),this.clearTimer(e)}extractStaleValues(e){let[t,i]=this.cacheForToStaleAndExpires(e);return[ce(t),ce(i)]}cacheForToStaleAndExpires(e){if(!Array.isArray(e))return[e,e];switch(e.length){case 0:return[0,0];case 1:return[e[0],e[0]];default:return[e[0],e[1]]}}clearTimer(e){let t=this.removalTimers.find(i=>this.paramsAreEqual(i.params,e));t&&(clearTimeout(t.timer),this.removalTimers=this.removalTimers.filter(i=>i!==t))}scheduleForRemoval(e,t){if(!(typeof window>"u")&&(this.clearTimer(e),t>0)){let i=window.setTimeout(()=>this.remove(e),t);this.removalTimers.push({params:e,timer:i})}}get(e){return this.findCached(e)||this.findInFlight(e)}use(e,t){let i=`${t.url.pathname}-${Date.now()}-${Math.random().toString(36).substring(7)}`;return this.currentUseId=i,e.response.then(s=>{if(this.currentUseId===i)return s.mergeParams({...t,onPrefetched:()=>{}}),this.removeSingleUseItems(t),s.handle()})}removeSingleUseItems(e){this.cached=this.cached.filter(t=>this.paramsAreEqual(t.params,e)?!t.singleUse:!0)}findCached(e){return this.cached.find(t=>this.paramsAreEqual(t.params,e))||null}findInFlight(e){return this.inFlightRequests.find(t=>this.paramsAreEqual(t.params,e))||null}withoutPurposePrefetchHeader(e){let t=ze(e);return t.headers.Purpose==="prefetch"&&delete t.headers.Purpose,t}paramsAreEqual(e,t){return le(this.withoutPurposePrefetchHeader(e),this.withoutPurposePrefetchHeader(t),["showProgress","replace","prefetch","onBefore","onStart","onProgress","onFinish","onCancel","onSuccess","onError","onPrefetched","onCancelToken","onPrefetching","async"])}},C=new ue;import{default as Ie}from"axios";var W=class r{constructor(e){this.callbacks=[];if(!e.prefetch)this.params=e;else{let t={onBefore:this.wrapCallback(e,"onBefore"),onStart:this.wrapCallback(e,"onStart"),onProgress:this.wrapCallback(e,"onProgress"),onFinish:this.wrapCallback(e,"onFinish"),onCancel:this.wrapCallback(e,"onCancel"),onSuccess:this.wrapCallback(e,"onSuccess"),onError:this.wrapCallback(e,"onError"),onCancelToken:this.wrapCallback(e,"onCancelToken"),onPrefetched:this.wrapCallback(e,"onPrefetched"),onPrefetching:this.wrapCallback(e,"onPrefetching")};this.params={...e,...t,onPrefetchResponse:e.onPrefetchResponse||(()=>{})}}}static create(e){return new r(e)}data(){return this.params.method==="get"?null:this.params.data}queryParams(){return this.params.method==="get"?this.params.data:{}}isPartial(){return this.params.only.length>0||this.params.except.length>0||this.params.reset.length>0}onCancelToken(e){this.params.onCancelToken({cancel:e})}markAsFinished(){this.params.completed=!0,this.params.cancelled=!1,this.params.interrupted=!1}markAsCancelled({cancelled:e=!0,interrupted:t=!1}){this.params.onCancel(),this.params.completed=!1,this.params.cancelled=e,this.params.interrupted=t}wasCancelledAtAll(){return this.params.cancelled||this.params.interrupted}onFinish(){this.params.onFinish(this.params)}onStart(){this.params.onStart(this.params)}onPrefetching(){this.params.onPrefetching(this.params)}onPrefetchResponse(e){this.params.onPrefetchResponse&&this.params.onPrefetchResponse(e)}all(){return this.params}headers(){let e={...this.params.headers};this.isPartial()&&(e["X-Inertia-Partial-Component"]=n.get().component);let t=this.params.only.concat(this.params.reset);return t.length>0&&(e["X-Inertia-Partial-Data"]=t.join(",")),this.params.except.length>0&&(e["X-Inertia-Partial-Except"]=this.params.except.join(",")),this.params.reset.length>0&&(e["X-Inertia-Reset"]=this.params.reset.join(",")),this.params.errorBag&&this.params.errorBag.length>0&&(e["X-Inertia-Error-Bag"]=this.params.errorBag),e}setPreserveOptions(e){this.params.preserveScroll=this.resolvePreserveOption(this.params.preserveScroll,e),this.params.preserveState=this.resolvePreserveOption(this.params.preserveState,e)}runCallbacks(){this.callbacks.forEach(({name:e,args:t})=>{this.params[e](...t)})}merge(e){this.params={...this.params,...e}}wrapCallback(e,t){return(...i)=>{this.recordCallback(t,i),e[t](...i)}}recordCallback(e,t){this.callbacks.push({name:e,args:t})}resolvePreserveOption(e,t){return typeof e=="function"?e(t):e==="errors"?Object.keys(t.props.errors||{}).length>0:e}};var Fe={modal:null,listener:null,show(r){typeof r=="object"&&(r=`All Inertia requests must receive a valid Inertia response, however a plain JSON response was received.<hr>${JSON.stringify(r)}`);let e=document.createElement("html");e.innerHTML=r,e.querySelectorAll("a").forEach(i=>i.setAttribute("target","_top")),this.modal=document.createElement("div"),this.modal.style.position="fixed",this.modal.style.width="100vw",this.modal.style.height="100vh",this.modal.style.padding="50px",this.modal.style.boxSizing="border-box",this.modal.style.backgroundColor="rgba(0, 0, 0, .6)",this.modal.style.zIndex=2e5,this.modal.addEventListener("click",()=>this.hide());let t=document.createElement("iframe");if(t.style.backgroundColor="white",t.style.borderRadius="5px",t.style.width="100%",t.style.height="100%",this.modal.appendChild(t),document.body.prepend(this.modal),document.body.style.overflow="hidden",!t.contentWindow)throw new Error("iframe not yet ready.");t.contentWindow.document.open(),t.contentWindow.document.write(e.outerHTML),t.contentWindow.document.close(),this.listener=this.hideOnEscape.bind(this),document.addEventListener("keydown",this.listener)},hide(){this.modal.outerHTML="",this.modal=null,document.body.style.overflow="visible",document.removeEventListener("keydown",this.listener)},hideOnEscape(r){r.keyCode===27&&this.hide()}};var _e=new F,H=class r{constructor(e,t,i){this.requestParams=e;this.response=t;this.originatingPage=i}static create(e,t,i){return new r(e,t,i)}async handlePrefetch(){L(this.requestParams.all().url,window.location)&&this.handle()}async handle(){return _e.add(()=>this.process())}async process(){if(this.requestParams.all().prefetch)return this.requestParams.all().prefetch=!1,this.requestParams.all().onPrefetched(this.response,this.requestParams.all()),be(this.response,this.requestParams.all()),Promise.resolve();if(this.requestParams.runCallbacks(),!this.isInertiaResponse())return this.handleNonInertiaResponse();await l.processQueue(),l.preserveUrl=this.requestParams.all().preserveUrl,await this.setPage();let e=n.get().props.errors||{};if(Object.keys(e).length>0){let t=this.getScopedErrors(e);return de(t),this.requestParams.all().onError(t)}ye(n.get()),await this.requestParams.all().onSuccess(n.get()),l.preserveUrl=!1}mergeParams(e){this.requestParams.merge(e)}async handleNonInertiaResponse(){if(this.isLocationVisit()){let t=P(this.getHeader("x-inertia-location"));return re(this.requestParams.all().url,t),this.locationVisit(t)}let e={...this.response,data:this.getDataFromResponse(this.response.data)};if(fe(e))return Fe.show(e.data)}isInertiaResponse(){return this.hasHeader("x-inertia")}hasStatus(e){return this.response.status===e}getHeader(e){return this.response.headers[e]}hasHeader(e){return this.getHeader(e)!==void 0}isLocationVisit(){return this.hasStatus(409)&&this.hasHeader("x-inertia-location")}locationVisit(e){try{if(m.set(m.locationVisitKey,{preserveScroll:this.requestParams.all().preserveScroll===!0}),typeof window>"u")return;L(window.location,e)?window.location.reload():window.location.href=e.href}catch{return!1}}async setPage(){let e=this.getDataFromResponse(this.response.data);return this.shouldSetPage(e)?(this.mergeProps(e),await this.setRememberedState(e),this.requestParams.setPreserveOptions(e),e.url=l.preserveUrl?n.get().url:this.pageUrl(e),n.set(e,{replace:this.requestParams.all().replace,preserveScroll:this.requestParams.all().preserveScroll,preserveState:this.requestParams.all().preserveState})):Promise.resolve()}getDataFromResponse(e){if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return e}}shouldSetPage(e){if(!this.requestParams.all().async||this.originatingPage.component!==e.component)return!0;if(this.originatingPage.component!==n.get().component)return!1;let t=P(this.originatingPage.url),i=P(n.get().url);return t.origin===i.origin&&t.pathname===i.pathname}pageUrl(e){let t=P(e.url);return re(this.requestParams.all().url,t),t.pathname+t.search+t.hash}mergeProps(e){if(!this.requestParams.isPartial()||e.component!==n.get().component)return;let t=e.mergeProps||[],i=e.deepMergeProps||[],s=e.matchPropsOn||[];t.forEach(o=>{let u=e.props[o];Array.isArray(u)?e.props[o]=this.mergeOrMatchItems(n.get().props[o]||[],u,o,s):typeof u=="object"&&u!==null&&(e.props[o]={...n.get().props[o]||[],...u})}),i.forEach(o=>{let u=e.props[o],p=n.get().props[o],d=(a,h,c)=>Array.isArray(h)?this.mergeOrMatchItems(a,h,c,s):typeof h=="object"&&h!==null?Object.keys(h).reduce((b,x)=>(b[x]=d(a?a[x]:void 0,h[x],`${c}.${x}`),b),{...a}):h;e.props[o]=d(p,u,o)}),e.props={...n.get().props,...e.props}}mergeOrMatchItems(e,t,i,s){let o=s.find(a=>a.split(".").slice(0,-1).join(".")===i);if(!o)return[...Array.isArray(e)?e:[],...t];let u=o.split(".").pop()||"",p=Array.isArray(e)?e:[],d=new Map;return p.forEach(a=>{a&&typeof a=="object"&&u in a?d.set(a[u],a):d.set(Symbol(),a)}),t.forEach(a=>{a&&typeof a=="object"&&u in a?d.set(a[u],a):d.set(Symbol(),a)}),Array.from(d.values())}async setRememberedState(e){let t=await l.getState(l.rememberedState,{});this.requestParams.all().preserveState&&t&&e.component===n.get().component&&(e.rememberedState=t)}getScopedErrors(e){return this.requestParams.all().errorBag?e[this.requestParams.all().errorBag||""]||{}:e}};var D=class r{constructor(e,t){this.page=t;this.requestHasFinished=!1;this.requestParams=W.create(e),this.cancelToken=new AbortController}static create(e,t){return new r(e,t)}async send(){this.requestParams.onCancelToken(()=>this.cancel({cancelled:!0})),ve(this.requestParams.all()),this.requestParams.onStart(),this.requestParams.all().prefetch&&(this.requestParams.onPrefetching(),Pe(this.requestParams.all()));let e=this.requestParams.all().prefetch;return Ie({method:this.requestParams.all().method,url:O(this.requestParams.all().url).href,data:this.requestParams.data(),params:this.requestParams.queryParams(),signal:this.cancelToken.signal,headers:this.getHeaders(),onUploadProgress:this.onProgress.bind(this),responseType:"text"}).then(t=>(this.response=H.create(this.requestParams,t,this.page),this.response.handle())).catch(t=>t?.response?(this.response=H.create(this.requestParams,t.response,this.page),this.response.handle()):Promise.reject(t)).catch(t=>{if(!Ie.isCancel(t)&&he(t))return Promise.reject(t)}).finally(()=>{this.finish(),e&&this.response&&this.requestParams.onPrefetchResponse(this.response)})}finish(){this.requestParams.wasCancelledAtAll()||(this.requestParams.markAsFinished(),this.fireFinishEvents())}fireFinishEvents(){this.requestHasFinished||(this.requestHasFinished=!0,me(this.requestParams.all()),this.requestParams.onFinish())}cancel({cancelled:e=!1,interrupted:t=!1}){this.requestHasFinished||(this.cancelToken.abort(),this.requestParams.markAsCancelled({cancelled:e,interrupted:t}),this.fireFinishEvents())}onProgress(e){this.requestParams.data()instanceof FormData&&(e.percentage=e.progress?Math.round(e.progress*100):0,ge(e),this.requestParams.all().onProgress(e))}getHeaders(){let e={...this.requestParams.headers(),Accept:"text/html, application/xhtml+xml","X-Requested-With":"XMLHttpRequest","X-Inertia":!0};return n.get().version&&(e["X-Inertia-Version"]=n.get().version),e}};var M=class{constructor({maxConcurrent:e,interruptible:t}){this.requests=[];this.maxConcurrent=e,this.interruptible=t}send(e){this.requests.push(e),e.send().then(()=>{this.requests=this.requests.filter(t=>t!==e)})}interruptInFlight(){this.cancel({interrupted:!0},!1)}cancelInFlight(){this.cancel({cancelled:!0},!0)}cancel({cancelled:e=!1,interrupted:t=!1}={},i){if(!this.shouldCancel(i))return;this.requests.shift()?.cancel({interrupted:t,cancelled:e})}shouldCancel(e){return e?!0:this.interruptible&&this.requests.length>=this.maxConcurrent}};var X=class{constructor(){this.syncRequestStream=new M({maxConcurrent:1,interruptible:!0});this.asyncRequestStream=new M({maxConcurrent:1/0,interruptible:!1})}init({initialPage:e,resolveComponent:t,swapComponent:i}){n.init({initialPage:e,resolveComponent:t,swapComponent:i}),K.handle(),E.init(),E.on("missingHistoryItem",()=>{typeof window<"u"&&this.visit(window.location.href,{preserveState:!0,preserveScroll:!0,replace:!0})}),E.on("loadDeferredProps",()=>{this.loadDeferredProps()})}get(e,t={},i={}){return this.visit(e,{...i,method:"get",data:t})}post(e,t={},i={}){return this.visit(e,{preserveState:!0,...i,method:"post",data:t})}put(e,t={},i={}){return this.visit(e,{preserveState:!0,...i,method:"put",data:t})}patch(e,t={},i={}){return this.visit(e,{preserveState:!0,...i,method:"patch",data:t})}delete(e,t={}){return this.visit(e,{preserveState:!0,...t,method:"delete"})}reload(e={}){if(!(typeof window>"u"))return this.visit(window.location.href,{...e,preserveScroll:!0,preserveState:!0,async:!0,headers:{...e.headers||{},"Cache-Control":"no-cache"}})}remember(e,t="default"){l.remember(e,t)}restore(e="default"){return l.restore(e)}on(e,t){return typeof window>"u"?()=>{}:E.onGlobalEvent(e,t)}cancel(){this.syncRequestStream.cancelInFlight()}cancelAll(){this.asyncRequestStream.cancelInFlight(),this.syncRequestStream.cancelInFlight()}poll(e,t={},i={}){return Ve.add(e,()=>this.reload(t),{autoStart:i.autoStart??!0,keepAlive:i.keepAlive??!1})}visit(e,t={}){let i=this.getPendingVisit(e,{...t,showProgress:t.showProgress??!t.async}),s=this.getVisitEvents(t);if(s.onBefore(i)===!1||!Z(i))return;let o=i.async?this.asyncRequestStream:this.syncRequestStream;o.interruptInFlight(),!n.isCleared()&&!i.preserveUrl&&v.save();let u={...i,...s},p=C.get(u);p?(J(p.inFlight),C.use(p,u)):(J(!0),o.send(D.create(u,n.get())))}getCached(e,t={}){return C.findCached(this.getPrefetchParams(e,t))}flush(e,t={}){C.remove(this.getPrefetchParams(e,t))}flushAll(){C.removeAll()}getPrefetching(e,t={}){return C.findInFlight(this.getPrefetchParams(e,t))}prefetch(e,t={},{cacheFor:i=3e4}){if(t.method!=="get")throw new Error("Prefetch requests must use the GET method");let s=this.getPendingVisit(e,{...t,async:!0,showProgress:!1,prefetch:!0}),o=s.url.origin+s.url.pathname+s.url.search,u=window.location.origin+window.location.pathname+window.location.search;if(o===u)return;let p=this.getVisitEvents(t);if(p.onBefore(s)===!1||!Z(s))return;Q(),this.asyncRequestStream.interruptInFlight();let d={...s,...p};new Promise(h=>{let c=()=>{n.get()?h():setTimeout(c,50)};c()}).then(()=>{C.add(d,h=>{this.asyncRequestStream.send(D.create(h,n.get()))},{cacheFor:i})})}clearHistory(){l.clear()}decryptHistory(){return l.decrypt()}resolveComponent(e){return n.resolve(e)}replace(e){this.clientVisit(e,{replace:!0})}push(e){this.clientVisit(e)}clientVisit(e,{replace:t=!1}={}){let i=n.get(),s=typeof e.props=="function"?e.props(i.props):e.props??i.props;n.set({...i,...e,props:s},{replace:t,preserveScroll:e.preserveScroll,preserveState:e.preserveState})}getPrefetchParams(e,t){return{...this.getPendingVisit(e,{...t,async:!0,showProgress:!1,prefetch:!0}),...this.getVisitEvents(t)}}getPendingVisit(e,t,i={}){let s={method:"get",data:{},replace:!1,preserveScroll:!1,preserveState:!1,only:[],except:[],headers:{},errorBag:"",forceFormData:!1,queryStringArrayFormat:"brackets",async:!1,showProgress:!0,fresh:!1,reset:[],preserveUrl:!1,prefetch:!1,...t},[o,u]=qe(e,s.data,s.method,s.forceFormData,s.queryStringArrayFormat),p={cancelled:!1,completed:!1,interrupted:!1,...s,...i,url:o,data:u};return p.prefetch&&(p.headers.Purpose="prefetch"),p}getVisitEvents(e){return{onCancelToken:e.onCancelToken||(()=>{}),onBefore:e.onBefore||(()=>{}),onStart:e.onStart||(()=>{}),onProgress:e.onProgress||(()=>{}),onFinish:e.onFinish||(()=>{}),onCancel:e.onCancel||(()=>{}),onSuccess:e.onSuccess||(()=>{}),onError:e.onError||(()=>{}),onPrefetched:e.onPrefetched||(()=>{}),onPrefetching:e.onPrefetching||(()=>{})}}loadDeferredProps(){let e=n.get()?.deferredProps;e&&Object.entries(e).forEach(([t,i])=>{this.reload({only:i})})}};var Ye={buildDOMElement(r){let e=document.createElement("template");e.innerHTML=r;let t=e.content.firstChild;if(!r.startsWith("<script "))return t;let i=document.createElement("script");return i.innerHTML=t.innerHTML,t.getAttributeNames().forEach(s=>{i.setAttribute(s,t.getAttribute(s)||"")}),i},isInertiaManagedElement(r){return r.nodeType===Node.ELEMENT_NODE&&r.getAttribute("inertia")!==null},findMatchingElementIndex(r,e){let t=r.getAttribute("inertia");return t!==null?e.findIndex(i=>i.getAttribute("inertia")===t):-1},update:I(function(r){let e=r.map(i=>this.buildDOMElement(i));Array.from(document.head.childNodes).filter(i=>this.isInertiaManagedElement(i)).forEach(i=>{let s=this.findMatchingElementIndex(i,e);if(s===-1){i?.parentNode?.removeChild(i);return}let o=e.splice(s,1)[0];o&&!i.isEqualNode(o)&&i?.parentNode?.replaceChild(o,i)}),e.forEach(i=>document.head.appendChild(i))},1)};function Oe(r,e,t){let i={},s=0;function o(){let c=s+=1;return i[c]=[],c.toString()}function u(c){c===null||Object.keys(i).indexOf(c)===-1||(delete i[c],h())}function p(c){Object.keys(i).indexOf(c)===-1&&(i[c]=[])}function d(c,b=[]){c!==null&&Object.keys(i).indexOf(c)>-1&&(i[c]=b),h()}function a(){let c=e(""),b={...c?{title:`<title inertia="">${c}</title>`}:{}},x=Object.values(i).reduce((R,T)=>R.concat(T),[]).reduce((R,T)=>{if(T.indexOf("<")===-1)return R;if(T.indexOf("<title ")===0){let N=T.match(/(<title [^>]+>)(.*?)(<\/title>)/);return R.title=N?`${N[1]}${e(N[2])}${N[3]}`:T,R}let pe=T.match(/ inertia="[^"]+"/);return pe?R[pe[0]]=T:R[Object.keys(R).length]=T,R},b);return Object.values(x)}function h(){r?t(a()):Ye.update(a())}return h(),{forceUpdate:h,createProvider:function(){let c=o();return{reconnect:()=>p(c),update:b=>d(c,b),disconnect:()=>u(c)}}}}var f="nprogress",w,g={minimum:.08,easing:"linear",positionUsing:"translate3d",speed:200,trickle:!0,trickleSpeed:200,showSpinner:!0,barSelector:'[role="bar"]',spinnerSelector:'[role="spinner"]',parent:"body",color:"#29d",includeCSS:!0,template:['<div class="bar" role="bar">','<div class="peg"></div>',"</div>",'<div class="spinner" role="spinner">','<div class="spinner-icon"></div>',"</div>"].join("")},A=null,Ze=r=>{Object.assign(g,r),g.includeCSS&&nt(g.color),w=document.createElement("div"),w.id=f,w.innerHTML=g.template},_=r=>{let e=Le();r=Me(r,g.minimum,1),A=r===1?null:r;let t=tt(!e),i=t.querySelector(g.barSelector),s=g.speed,o=g.easing;t.offsetWidth,st(u=>{let p=g.positionUsing==="translate3d"?{transition:`all ${s}ms ${o}`,transform:`translate3d(${z(r)}%,0,0)`}:g.positionUsing==="translate"?{transition:`all ${s}ms ${o}`,transform:`translate(${z(r)}%,0)`}:{marginLeft:`${z(r)}%`};for(let d in p)i.style[d]=p[d];if(r!==1)return setTimeout(u,s);t.style.transition="none",t.style.opacity="1",t.offsetWidth,setTimeout(()=>{t.style.transition=`all ${s}ms linear`,t.style.opacity="0",setTimeout(()=>{De(),t.style.transition="",t.style.opacity="",u()},s)},s)})},Le=()=>typeof A=="number",ke=()=>{A||_(0);let r=function(){setTimeout(function(){A&&(Ue(),r())},g.trickleSpeed)};g.trickle&&r()},et=r=>{!r&&!A||(Ue(.3+.5*Math.random()),_(1))},Ue=r=>{let e=A;if(e===null)return ke();if(!(e>1))return r=typeof r=="number"?r:(()=>{let t={.1:[0,.2],.04:[.2,.5],.02:[.5,.8],.005:[.8,.99]};for(let i in t)if(e>=t[i][0]&&e<t[i][1])return parseFloat(i);return 0})(),_(Me(e+r,0,.994))},tt=r=>{if(rt())return document.getElementById(f);document.documentElement.classList.add(`${f}-busy`);let e=w.querySelector(g.barSelector),t=r?"-100":z(A||0),i=He();return e.style.transition="all 0 linear",e.style.transform=`translate3d(${t}%,0,0)`,g.showSpinner||w.querySelector(g.spinnerSelector)?.remove(),i!==document.body&&i.classList.add(`${f}-custom-parent`),i.appendChild(w),w},He=()=>it(g.parent)?g.parent:document.querySelector(g.parent),De=()=>{document.documentElement.classList.remove(`${f}-busy`),He().classList.remove(`${f}-custom-parent`),w?.remove()},rt=()=>document.getElementById(f)!==null,it=r=>typeof HTMLElement=="object"?r instanceof HTMLElement:r&&typeof r=="object"&&r.nodeType===1&&typeof r.nodeName=="string";function Me(r,e,t){return r<e?e:r>t?t:r}var z=r=>(-1+r)*100,st=(()=>{let r=[],e=()=>{let t=r.shift();t&&t(e)};return t=>{r.push(t),r.length===1&&e()}})(),nt=r=>{let e=document.createElement("style");e.textContent=`
1
+ function I(r,e){let t;return function(...i){clearTimeout(t),t=setTimeout(()=>r.apply(this,i),e)}}function S(r,e){return document.dispatchEvent(new CustomEvent(`inertia:${r}`,e))}var Z=r=>S("before",{cancelable:!0,detail:{visit:r}}),de=r=>S("error",{detail:{errors:r}}),he=r=>S("exception",{cancelable:!0,detail:{exception:r}}),me=r=>S("finish",{detail:{visit:r}}),fe=r=>S("invalid",{cancelable:!0,detail:{response:r}}),q=r=>S("navigate",{detail:{page:r}}),ge=r=>S("progress",{detail:{progress:r}}),ve=r=>S("start",{detail:{visit:r}}),ye=r=>S("success",{detail:{page:r}}),be=(r,e)=>S("prefetched",{detail:{fetchedAt:Date.now(),response:r.data,visit:e}}),Pe=r=>S("prefetching",{detail:{visit:r}});var m=class{static set(e,t){typeof window<"u"&&window.sessionStorage.setItem(e,JSON.stringify(t))}static get(e){if(typeof window<"u")return JSON.parse(window.sessionStorage.getItem(e)||"null")}static merge(e,t){let i=this.get(e);i===null?this.set(e,t):this.set(e,{...i,...t})}static remove(e){typeof window<"u"&&window.sessionStorage.removeItem(e)}static removeNested(e,t){let i=this.get(e);i!==null&&(delete i[t],this.set(e,i))}static exists(e){try{return this.get(e)!==null}catch{return!1}}static clear(){typeof window<"u"&&window.sessionStorage.clear()}};m.locationVisitKey="inertiaLocationVisit";var we=async r=>{if(typeof window>"u")throw new Error("Unable to encrypt history");let e=Ee(),t=await Re(),i=await We(t);if(!i)throw new Error("Unable to encrypt history");return await Be(e,i,r)},V={key:"historyKey",iv:"historyIv"},Se=async r=>{let e=Ee(),t=await Re();if(!t)throw new Error("Unable to decrypt history");return await Ge(e,t,r)},Be=async(r,e,t)=>{if(typeof window>"u")throw new Error("Unable to encrypt history");if(typeof window.crypto.subtle>"u")return console.warn("Encryption is not supported in this environment. SSL is required."),Promise.resolve(t);let i=new TextEncoder,s=JSON.stringify(t),o=new Uint8Array(s.length*3),u=i.encodeInto(s,o);return window.crypto.subtle.encrypt({name:"AES-GCM",iv:r},e,o.subarray(0,u.written))},Ge=async(r,e,t)=>{if(typeof window.crypto.subtle>"u")return console.warn("Decryption is not supported in this environment. SSL is required."),Promise.resolve(t);let i=await window.crypto.subtle.decrypt({name:"AES-GCM",iv:r},e,t);return JSON.parse(new TextDecoder().decode(i))},Ee=()=>{let r=m.get(V.iv);if(r)return new Uint8Array(r);let e=window.crypto.getRandomValues(new Uint8Array(12));return m.set(V.iv,Array.from(e)),e},Ke=async()=>typeof window.crypto.subtle>"u"?(console.warn("Encryption is not supported in this environment. SSL is required."),Promise.resolve(null)):window.crypto.subtle.generateKey({name:"AES-GCM",length:256},!0,["encrypt","decrypt"]),je=async r=>{if(typeof window.crypto.subtle>"u")return console.warn("Encryption is not supported in this environment. SSL is required."),Promise.resolve();let e=await window.crypto.subtle.exportKey("raw",r);m.set(V.key,Array.from(new Uint8Array(e)))},We=async r=>{if(r)return r;let e=await Ke();return e?(await je(e),e):null},Re=async()=>{let r=m.get(V.key);return r?await window.crypto.subtle.importKey("raw",new Uint8Array(r),{name:"AES-GCM",length:256},!0,["encrypt","decrypt"]):null};var v=class{static save(){l.saveScrollPositions(Array.from(this.regions()).map(e=>({top:e.scrollTop,left:e.scrollLeft})))}static regions(){return document.querySelectorAll("[scroll-region]")}static reset(){typeof window<"u"&&window.scrollTo(0,0),this.regions().forEach(e=>{typeof e.scrollTo=="function"?e.scrollTo(0,0):(e.scrollTop=0,e.scrollLeft=0)}),this.save(),window.location.hash&&setTimeout(()=>document.getElementById(window.location.hash.slice(1))?.scrollIntoView())}static restore(e){this.restoreDocument(),this.regions().forEach((t,i)=>{let s=e[i];s&&(typeof t.scrollTo=="function"?t.scrollTo(s.left,s.top):(t.scrollTop=s.top,t.scrollLeft=s.left))})}static restoreDocument(){let e=l.getDocumentScrollPosition();typeof window<"u"&&window.scrollTo(e.left,e.top)}static onScroll(e){let t=e.target;typeof t.hasAttribute=="function"&&t.hasAttribute("scroll-region")&&this.save()}static onWindowScroll(){l.saveDocumentScrollPosition({top:window.scrollY,left:window.scrollX})}};import{mergeWith as Xe}from"es-toolkit";import*as B from"qs";function $(r){return r instanceof File||r instanceof Blob||r instanceof FileList&&r.length>0||r instanceof FormData&&Array.from(r.values()).some(e=>$(e))||typeof r=="object"&&r!==null&&Object.values(r).some(e=>$(e))}var ee=r=>r instanceof FormData;function te(r,e=new FormData,t=null){r=r||{};for(let i in r)Object.prototype.hasOwnProperty.call(r,i)&&xe(e,Te(t,i),r[i]);return e}function Te(r,e){return r?r+"["+e+"]":e}function xe(r,e,t){if(Array.isArray(t))return Array.from(t.keys()).forEach(i=>xe(r,Te(e,i.toString()),t[i]));if(t instanceof Date)return r.append(e,t.toISOString());if(t instanceof File)return r.append(e,t,t.name);if(t instanceof Blob)return r.append(e,t);if(typeof t=="boolean")return r.append(e,t?"1":"0");if(typeof t=="string")return r.append(e,t);if(typeof t=="number")return r.append(e,`${t}`);if(t==null)return r.append(e,"");te(t,r,e)}function P(r){return new URL(r.toString(),typeof window>"u"?void 0:window.location.toString())}var qe=(r,e,t,i,s)=>{let o=typeof r=="string"?P(r):r;if(($(e)||i)&&!ee(e)&&(e=te(e)),ee(e))return[o,e];let[u,p]=Ce(t,o,e,s);return[P(u),p]};function Ce(r,e,t,i="brackets"){let s=/^[a-z][a-z0-9+.-]*:\/\//i.test(e.toString()),o=s||e.toString().startsWith("/"),u=!o&&!e.toString().startsWith("#")&&!e.toString().startsWith("?"),p=e.toString().includes("?")||r==="get"&&Object.keys(t).length,d=e.toString().includes("#"),a=new URL(e.toString(),"http://localhost");return r==="get"&&Object.keys(t).length&&(a.search=B.stringify(Xe(B.parse(a.search,{ignoreQueryPrefix:!0}),t,(h,c,b,x)=>{c===void 0&&delete x[b]}),{encodeValuesOnly:!0,arrayFormat:i}),t={}),[[s?`${a.protocol}//${a.host}`:"",o?a.pathname:"",u?a.pathname.substring(1):"",p?a.search:"",d?a.hash:""].join(""),t]}function O(r){return r=new URL(r.href),r.hash="",r}var re=(r,e)=>{r.hash&&!e.hash&&O(r).href===e.href&&(e.hash=r.hash)},L=(r,e)=>O(r).href===O(e).href;var ie=class{constructor(){this.componentId={};this.listeners=[];this.isFirstPageLoad=!0;this.cleared=!1}init({initialPage:e,swapComponent:t,resolveComponent:i}){return this.page=e,this.swapComponent=t,this.resolveComponent=i,this}set(e,{replace:t=!1,preserveScroll:i=!1,preserveState:s=!1}={}){this.componentId={};let o=this.componentId;return e.clearHistory&&l.clear(),this.resolve(e.component).then(u=>{if(o!==this.componentId)return;e.rememberedState??(e.rememberedState={});let p=typeof window<"u"?window.location:new URL(e.url);return t=t||L(P(e.url),p),new Promise(d=>{t?l.replaceState(e,()=>d(null)):l.pushState(e,()=>d(null))}).then(()=>{let d=!this.isTheSame(e);return this.page=e,this.cleared=!1,d&&this.fireEventsFor("newComponent"),this.isFirstPageLoad&&this.fireEventsFor("firstLoad"),this.isFirstPageLoad=!1,this.swap({component:u,page:e,preserveState:s}).then(()=>{i||v.reset(),E.fireInternalEvent("loadDeferredProps"),t||q(e)})})})}setQuietly(e,{preserveState:t=!1}={}){return this.resolve(e.component).then(i=>(this.page=e,this.cleared=!1,l.setCurrent(e),this.swap({component:i,page:e,preserveState:t})))}clear(){this.cleared=!0}isCleared(){return this.cleared}get(){return this.page}merge(e){this.page={...this.page,...e}}setUrlHash(e){this.page.url.includes(e)||(this.page.url+=e)}remember(e){this.page.rememberedState=e}swap({component:e,page:t,preserveState:i}){return this.swapComponent({component:e,page:t,preserveState:i})}resolve(e){return Promise.resolve(this.resolveComponent(e))}isTheSame(e){return this.page.component===e.component}on(e,t){return this.listeners.push({event:e,callback:t}),()=>{this.listeners=this.listeners.filter(i=>i.event!==e&&i.callback!==t)}}fireEventsFor(e){this.listeners.filter(t=>t.event===e).forEach(t=>t.callback())}},n=new ie;var F=class{constructor(){this.items=[];this.processingPromise=null}add(e){return this.items.push(e),this.process()}process(){return this.processingPromise??(this.processingPromise=this.processNext().then(()=>{this.processingPromise=null})),this.processingPromise}processNext(){let e=this.items.shift();return e?Promise.resolve(e()).then(()=>this.processNext()):Promise.resolve()}};var U=typeof window>"u",k=new F,Ae=!U&&/CriOS/.test(window.navigator.userAgent),se=class{constructor(){this.rememberedState="rememberedState";this.scrollRegions="scrollRegions";this.preserveUrl=!1;this.current={};this.initialState=null}remember(e,t){this.replaceState({...n.get(),rememberedState:{...n.get()?.rememberedState??{},[t]:e}})}restore(e){if(!U)return this.current[this.rememberedState]?this.current[this.rememberedState]?.[e]:this.initialState?.[this.rememberedState]?.[e]}pushState(e,t=null){if(!U){if(this.preserveUrl){t&&t();return}this.current=e,k.add(()=>this.getPageData(e).then(i=>{let s=()=>{this.doPushState({page:i},e.url),t&&t()};Ae?setTimeout(s):s()}))}}getPageData(e){return new Promise(t=>e.encryptHistory?we(e).then(t):t(e))}processQueue(){return k.process()}decrypt(e=null){if(U)return Promise.resolve(e??n.get());let t=e??window.history.state?.page;return this.decryptPageData(t).then(i=>{if(!i)throw new Error("Unable to decrypt history");return this.initialState===null?this.initialState=i??void 0:this.current=i??{},i})}decryptPageData(e){return e instanceof ArrayBuffer?Se(e):Promise.resolve(e)}saveScrollPositions(e){k.add(()=>Promise.resolve().then(()=>{window.history.state?.page&&this.doReplaceState({page:window.history.state.page,scrollRegions:e})}))}saveDocumentScrollPosition(e){k.add(()=>Promise.resolve().then(()=>{window.history.state?.page&&this.doReplaceState({page:window.history.state.page,documentScrollPosition:e})}))}getScrollRegions(){return window.history.state?.scrollRegions||[]}getDocumentScrollPosition(){return window.history.state?.documentScrollPosition||{top:0,left:0}}replaceState(e,t=null){if(n.merge(e),!U){if(this.preserveUrl){t&&t();return}this.current=e,k.add(()=>this.getPageData(e).then(i=>{let s=()=>{this.doReplaceState({page:i},e.url),t&&t()};Ae?setTimeout(s):s()}))}}doReplaceState(e,t){window.history.replaceState({...e,scrollRegions:e.scrollRegions??window.history.state?.scrollRegions,documentScrollPosition:e.documentScrollPosition??window.history.state?.documentScrollPosition},"",t)}doPushState(e,t){window.history.pushState(e,"",t)}getState(e,t){return this.current?.[e]??t}deleteState(e){this.current[e]!==void 0&&(delete this.current[e],this.replaceState(this.current))}hasAnyState(){return!!this.getAllState()}clear(){m.remove(V.key),m.remove(V.iv)}setCurrent(e){this.current=e}isValidState(e){return!!e.page}getAllState(){return this.current}};typeof window<"u"&&window.history.scrollRestoration&&(window.history.scrollRestoration="manual");var l=new se;var ne=class{constructor(){this.internalListeners=[]}init(){typeof window<"u"&&(window.addEventListener("popstate",this.handlePopstateEvent.bind(this)),window.addEventListener("scroll",I(v.onWindowScroll.bind(v),100),!0)),typeof document<"u"&&document.addEventListener("scroll",I(v.onScroll.bind(v),100),!0)}onGlobalEvent(e,t){let i=s=>{let o=t(s);s.cancelable&&!s.defaultPrevented&&o===!1&&s.preventDefault()};return this.registerListener(`inertia:${e}`,i)}on(e,t){return this.internalListeners.push({event:e,listener:t}),()=>{this.internalListeners=this.internalListeners.filter(i=>i.listener!==t)}}onMissingHistoryItem(){n.clear(),this.fireInternalEvent("missingHistoryItem")}fireInternalEvent(e){this.internalListeners.filter(t=>t.event===e).forEach(t=>t.listener())}registerListener(e,t){return document.addEventListener(e,t),()=>document.removeEventListener(e,t)}handlePopstateEvent(e){let t=e.state||null;if(t===null){let i=P(n.get().url);i.hash=window.location.hash,l.replaceState({...n.get(),url:i.href}),v.reset();return}if(!l.isValidState(t))return this.onMissingHistoryItem();l.decrypt(t.page).then(i=>{if(n.get().version!==i.version){this.onMissingHistoryItem();return}n.setQuietly(i,{preserveState:!1}).then(()=>{window.requestAnimationFrame(()=>{v.restore(l.getScrollRegions())}),q(n.get())})}).catch(()=>{this.onMissingHistoryItem()})}},E=new ne;var oe=class{constructor(){this.type=this.resolveType()}resolveType(){return typeof window>"u"?"navigate":window.performance&&window.performance.getEntriesByType&&window.performance.getEntriesByType("navigation").length>0?window.performance.getEntriesByType("navigation")[0].type:"navigate"}get(){return this.type}isBackForward(){return this.type==="back_forward"}isReload(){return this.type==="reload"}},G=new oe;var K=class{static handle(){this.clearRememberedStateOnReload(),[this.handleBackForward,this.handleLocation,this.handleDefault].find(t=>t.bind(this)())}static clearRememberedStateOnReload(){G.isReload()&&l.deleteState(l.rememberedState)}static handleBackForward(){if(!G.isBackForward()||!l.hasAnyState())return!1;let e=l.getScrollRegions();return l.decrypt().then(t=>{n.set(t,{preserveScroll:!0,preserveState:!0}).then(()=>{v.restore(e),q(n.get())})}).catch(()=>{E.onMissingHistoryItem()}),!0}static handleLocation(){if(!m.exists(m.locationVisitKey))return!1;let e=m.get(m.locationVisitKey)||{};return m.remove(m.locationVisitKey),typeof window<"u"&&n.setUrlHash(window.location.hash),l.decrypt(n.get()).then(()=>{let t=l.getState(l.rememberedState,{}),i=l.getScrollRegions();n.remember(t),n.set(n.get(),{preserveScroll:e.preserveScroll,preserveState:!0}).then(()=>{e.preserveScroll&&v.restore(i),q(n.get())})}).catch(()=>{E.onMissingHistoryItem()}),!0}static handleDefault(){typeof window<"u"&&n.setUrlHash(window.location.hash),n.set(n.get(),{preserveScroll:!0,preserveState:!0}).then(()=>{G.isReload()&&v.restore(l.getScrollRegions()),q(n.get())})}};var j=class{constructor(e,t,i){this.id=null;this.throttle=!1;this.keepAlive=!1;this.cbCount=0;this.keepAlive=i.keepAlive??!1,this.cb=t,this.interval=e,(i.autoStart??!0)&&this.start()}stop(){this.id&&clearInterval(this.id)}start(){typeof window>"u"||(this.stop(),this.id=window.setInterval(()=>{(!this.throttle||this.cbCount%10===0)&&this.cb(),this.throttle&&this.cbCount++},this.interval))}isInBackground(e){this.throttle=this.keepAlive?!1:e,this.throttle&&(this.cbCount=0)}};var ae=class{constructor(){this.polls=[];this.setupVisibilityListener()}add(e,t,i){let s=new j(e,t,i);return this.polls.push(s),{stop:()=>s.stop(),start:()=>s.start()}}clear(){this.polls.forEach(e=>e.stop()),this.polls=[]}setupVisibilityListener(){typeof document>"u"||document.addEventListener("visibilitychange",()=>{this.polls.forEach(e=>e.isInBackground(document.hidden))},!1)}},Ve=new ae;import{cloneDeep as ze}from"es-toolkit";var le=(r,e,t)=>{if(r===e)return!0;for(let i in r)if(!t.includes(i)&&r[i]!==e[i]&&!Je(r[i],e[i]))return!1;return!0},Je=(r,e)=>{switch(typeof r){case"object":return le(r,e,[]);case"function":return r.toString()===e.toString();default:return r===e}};var Qe={ms:1,s:1e3,m:6e4,h:36e5,d:864e5},ce=r=>{if(typeof r=="number")return r;for(let[e,t]of Object.entries(Qe))if(r.endsWith(e))return parseFloat(r)*t;return parseInt(r)};var ue=class{constructor(){this.cached=[];this.inFlightRequests=[];this.removalTimers=[];this.currentUseId=null}add(e,t,{cacheFor:i}){if(this.findInFlight(e))return Promise.resolve();let o=this.findCached(e);if(!e.fresh&&o&&o.staleTimestamp>Date.now())return Promise.resolve();let[u,p]=this.extractStaleValues(i),d=new Promise((a,h)=>{t({...e,onCancel:()=>{this.remove(e),e.onCancel(),h()},onError:c=>{this.remove(e),e.onError(c),h()},onPrefetching(c){e.onPrefetching(c)},onPrefetched(c,b){e.onPrefetched(c,b)},onPrefetchResponse(c){a(c)}})}).then(a=>(this.remove(e),this.cached.push({params:{...e},staleTimestamp:Date.now()+u,response:d,singleUse:i===0,timestamp:Date.now(),inFlight:!1}),this.scheduleForRemoval(e,p),this.inFlightRequests=this.inFlightRequests.filter(h=>!this.paramsAreEqual(h.params,e)),a.handlePrefetch(),a));return this.inFlightRequests.push({params:{...e},response:d,staleTimestamp:null,inFlight:!0}),d}removeAll(){this.cached=[],this.removalTimers.forEach(e=>{clearTimeout(e.timer)}),this.removalTimers=[]}remove(e){this.cached=this.cached.filter(t=>!this.paramsAreEqual(t.params,e)),this.clearTimer(e)}extractStaleValues(e){let[t,i]=this.cacheForToStaleAndExpires(e);return[ce(t),ce(i)]}cacheForToStaleAndExpires(e){if(!Array.isArray(e))return[e,e];switch(e.length){case 0:return[0,0];case 1:return[e[0],e[0]];default:return[e[0],e[1]]}}clearTimer(e){let t=this.removalTimers.find(i=>this.paramsAreEqual(i.params,e));t&&(clearTimeout(t.timer),this.removalTimers=this.removalTimers.filter(i=>i!==t))}scheduleForRemoval(e,t){if(!(typeof window>"u")&&(this.clearTimer(e),t>0)){let i=window.setTimeout(()=>this.remove(e),t);this.removalTimers.push({params:e,timer:i})}}get(e){return this.findCached(e)||this.findInFlight(e)}use(e,t){let i=`${t.url.pathname}-${Date.now()}-${Math.random().toString(36).substring(7)}`;return this.currentUseId=i,e.response.then(s=>{if(this.currentUseId===i)return s.mergeParams({...t,onPrefetched:()=>{}}),this.removeSingleUseItems(t),s.handle()})}removeSingleUseItems(e){this.cached=this.cached.filter(t=>this.paramsAreEqual(t.params,e)?!t.singleUse:!0)}findCached(e){return this.cached.find(t=>this.paramsAreEqual(t.params,e))||null}findInFlight(e){return this.inFlightRequests.find(t=>this.paramsAreEqual(t.params,e))||null}withoutPurposePrefetchHeader(e){let t=ze(e);return t.headers.Purpose==="prefetch"&&delete t.headers.Purpose,t}paramsAreEqual(e,t){return le(this.withoutPurposePrefetchHeader(e),this.withoutPurposePrefetchHeader(t),["showProgress","replace","prefetch","onBefore","onStart","onProgress","onFinish","onCancel","onSuccess","onError","onPrefetched","onCancelToken","onPrefetching","async"])}},C=new ue;import{default as Ie}from"axios";var W=class r{constructor(e){this.callbacks=[];if(!e.prefetch)this.params=e;else{let t={onBefore:this.wrapCallback(e,"onBefore"),onStart:this.wrapCallback(e,"onStart"),onProgress:this.wrapCallback(e,"onProgress"),onFinish:this.wrapCallback(e,"onFinish"),onCancel:this.wrapCallback(e,"onCancel"),onSuccess:this.wrapCallback(e,"onSuccess"),onError:this.wrapCallback(e,"onError"),onCancelToken:this.wrapCallback(e,"onCancelToken"),onPrefetched:this.wrapCallback(e,"onPrefetched"),onPrefetching:this.wrapCallback(e,"onPrefetching")};this.params={...e,...t,onPrefetchResponse:e.onPrefetchResponse||(()=>{})}}}static create(e){return new r(e)}data(){return this.params.method==="get"?null:this.params.data}queryParams(){return this.params.method==="get"?this.params.data:{}}isPartial(){return this.params.only.length>0||this.params.except.length>0||this.params.reset.length>0}onCancelToken(e){this.params.onCancelToken({cancel:e})}markAsFinished(){this.params.completed=!0,this.params.cancelled=!1,this.params.interrupted=!1}markAsCancelled({cancelled:e=!0,interrupted:t=!1}){this.params.onCancel(),this.params.completed=!1,this.params.cancelled=e,this.params.interrupted=t}wasCancelledAtAll(){return this.params.cancelled||this.params.interrupted}onFinish(){this.params.onFinish(this.params)}onStart(){this.params.onStart(this.params)}onPrefetching(){this.params.onPrefetching(this.params)}onPrefetchResponse(e){this.params.onPrefetchResponse&&this.params.onPrefetchResponse(e)}all(){return this.params}headers(){let e={...this.params.headers};this.isPartial()&&(e["X-Inertia-Partial-Component"]=n.get().component);let t=this.params.only.concat(this.params.reset);return t.length>0&&(e["X-Inertia-Partial-Data"]=t.join(",")),this.params.except.length>0&&(e["X-Inertia-Partial-Except"]=this.params.except.join(",")),this.params.reset.length>0&&(e["X-Inertia-Reset"]=this.params.reset.join(",")),this.params.errorBag&&this.params.errorBag.length>0&&(e["X-Inertia-Error-Bag"]=this.params.errorBag),e}setPreserveOptions(e){this.params.preserveScroll=this.resolvePreserveOption(this.params.preserveScroll,e),this.params.preserveState=this.resolvePreserveOption(this.params.preserveState,e)}runCallbacks(){this.callbacks.forEach(({name:e,args:t})=>{this.params[e](...t)})}merge(e){this.params={...this.params,...e}}wrapCallback(e,t){return(...i)=>{this.recordCallback(t,i),e[t](...i)}}recordCallback(e,t){this.callbacks.push({name:e,args:t})}resolvePreserveOption(e,t){return typeof e=="function"?e(t):e==="errors"?Object.keys(t.props.errors||{}).length>0:e}};var Fe={modal:null,listener:null,show(r){typeof r=="object"&&(r=`All Inertia requests must receive a valid Inertia response, however a plain JSON response was received.<hr>${JSON.stringify(r)}`);let e=document.createElement("html");e.innerHTML=r,e.querySelectorAll("a").forEach(i=>i.setAttribute("target","_top")),this.modal=document.createElement("div"),this.modal.style.position="fixed",this.modal.style.width="100vw",this.modal.style.height="100vh",this.modal.style.padding="50px",this.modal.style.boxSizing="border-box",this.modal.style.backgroundColor="rgba(0, 0, 0, .6)",this.modal.style.zIndex=2e5,this.modal.addEventListener("click",()=>this.hide());let t=document.createElement("iframe");if(t.style.backgroundColor="white",t.style.borderRadius="5px",t.style.width="100%",t.style.height="100%",this.modal.appendChild(t),document.body.prepend(this.modal),document.body.style.overflow="hidden",!t.contentWindow)throw new Error("iframe not yet ready.");t.contentWindow.document.open(),t.contentWindow.document.write(e.outerHTML),t.contentWindow.document.close(),this.listener=this.hideOnEscape.bind(this),document.addEventListener("keydown",this.listener)},hide(){this.modal.outerHTML="",this.modal=null,document.body.style.overflow="visible",document.removeEventListener("keydown",this.listener)},hideOnEscape(r){r.keyCode===27&&this.hide()}};var _e=new F,H=class r{constructor(e,t,i){this.requestParams=e;this.response=t;this.originatingPage=i}static create(e,t,i){return new r(e,t,i)}async handlePrefetch(){L(this.requestParams.all().url,window.location)&&this.handle()}async handle(){return _e.add(()=>this.process())}async process(){if(this.requestParams.all().prefetch)return this.requestParams.all().prefetch=!1,this.requestParams.all().onPrefetched(this.response,this.requestParams.all()),be(this.response,this.requestParams.all()),Promise.resolve();if(this.requestParams.runCallbacks(),!this.isInertiaResponse())return this.handleNonInertiaResponse();await l.processQueue(),l.preserveUrl=this.requestParams.all().preserveUrl,await this.setPage();let e=n.get().props.errors||{};if(Object.keys(e).length>0){let t=this.getScopedErrors(e);return de(t),this.requestParams.all().onError(t)}ye(n.get()),await this.requestParams.all().onSuccess(n.get()),l.preserveUrl=!1}mergeParams(e){this.requestParams.merge(e)}async handleNonInertiaResponse(){if(this.isLocationVisit()){let t=P(this.getHeader("x-inertia-location"));return re(this.requestParams.all().url,t),this.locationVisit(t)}let e={...this.response,data:this.getDataFromResponse(this.response.data)};if(fe(e))return Fe.show(e.data)}isInertiaResponse(){return this.hasHeader("x-inertia")}hasStatus(e){return this.response.status===e}getHeader(e){return this.response.headers[e]}hasHeader(e){return this.getHeader(e)!==void 0}isLocationVisit(){return this.hasStatus(409)&&this.hasHeader("x-inertia-location")}locationVisit(e){try{if(m.set(m.locationVisitKey,{preserveScroll:this.requestParams.all().preserveScroll===!0}),typeof window>"u")return;L(window.location,e)?window.location.reload():window.location.href=e.href}catch{return!1}}async setPage(){let e=this.getDataFromResponse(this.response.data);return this.shouldSetPage(e)?(this.mergeProps(e),await this.setRememberedState(e),this.requestParams.setPreserveOptions(e),e.url=l.preserveUrl?n.get().url:this.pageUrl(e),n.set(e,{replace:this.requestParams.all().replace,preserveScroll:this.requestParams.all().preserveScroll,preserveState:this.requestParams.all().preserveState})):Promise.resolve()}getDataFromResponse(e){if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return e}}shouldSetPage(e){if(!this.requestParams.all().async||this.originatingPage.component!==e.component)return!0;if(this.originatingPage.component!==n.get().component)return!1;let t=P(this.originatingPage.url),i=P(n.get().url);return t.origin===i.origin&&t.pathname===i.pathname}pageUrl(e){let t=P(e.url);return re(this.requestParams.all().url,t),t.pathname+t.search+t.hash}mergeProps(e){if(!this.requestParams.isPartial()||e.component!==n.get().component)return;let t=e.mergeProps||[],i=e.deepMergeProps||[],s=e.matchPropsOn||[];t.forEach(o=>{let u=e.props[o];Array.isArray(u)?e.props[o]=this.mergeOrMatchItems(n.get().props[o]||[],u,o,s):typeof u=="object"&&u!==null&&(e.props[o]={...n.get().props[o]||[],...u})}),i.forEach(o=>{let u=e.props[o],p=n.get().props[o],d=(a,h,c)=>Array.isArray(h)?this.mergeOrMatchItems(a,h,c,s):typeof h=="object"&&h!==null?Object.keys(h).reduce((b,x)=>(b[x]=d(a?a[x]:void 0,h[x],`${c}.${x}`),b),{...a}):h;e.props[o]=d(p,u,o)}),e.props={...n.get().props,...e.props}}mergeOrMatchItems(e,t,i,s){let o=s.find(a=>a.split(".").slice(0,-1).join(".")===i);if(!o)return[...Array.isArray(e)?e:[],...t];let u=o.split(".").pop()||"",p=Array.isArray(e)?e:[],d=new Map;return p.forEach(a=>{a&&typeof a=="object"&&u in a?d.set(a[u],a):d.set(Symbol(),a)}),t.forEach(a=>{a&&typeof a=="object"&&u in a?d.set(a[u],a):d.set(Symbol(),a)}),Array.from(d.values())}async setRememberedState(e){let t=await l.getState(l.rememberedState,{});this.requestParams.all().preserveState&&t&&e.component===n.get().component&&(e.rememberedState=t)}getScopedErrors(e){return this.requestParams.all().errorBag?e[this.requestParams.all().errorBag||""]||{}:e}};var D=class r{constructor(e,t){this.page=t;this.requestHasFinished=!1;this.requestParams=W.create(e),this.cancelToken=new AbortController}static create(e,t){return new r(e,t)}async send(){this.requestParams.onCancelToken(()=>this.cancel({cancelled:!0})),ve(this.requestParams.all()),this.requestParams.onStart(),this.requestParams.all().prefetch&&(this.requestParams.onPrefetching(),Pe(this.requestParams.all()));let e=this.requestParams.all().prefetch;return Ie({method:this.requestParams.all().method,url:O(this.requestParams.all().url).href,data:this.requestParams.data(),params:this.requestParams.queryParams(),signal:this.cancelToken.signal,headers:this.getHeaders(),onUploadProgress:this.onProgress.bind(this),responseType:"text"}).then(t=>(this.response=H.create(this.requestParams,t,this.page),this.response.handle())).catch(t=>t?.response?(this.response=H.create(this.requestParams,t.response,this.page),this.response.handle()):Promise.reject(t)).catch(t=>{if(!Ie.isCancel(t)&&he(t))return Promise.reject(t)}).finally(()=>{this.finish(),e&&this.response&&this.requestParams.onPrefetchResponse(this.response)})}finish(){this.requestParams.wasCancelledAtAll()||(this.requestParams.markAsFinished(),this.fireFinishEvents())}fireFinishEvents(){this.requestHasFinished||(this.requestHasFinished=!0,me(this.requestParams.all()),this.requestParams.onFinish())}cancel({cancelled:e=!1,interrupted:t=!1}){this.requestHasFinished||(this.cancelToken.abort(),this.requestParams.markAsCancelled({cancelled:e,interrupted:t}),this.fireFinishEvents())}onProgress(e){this.requestParams.data()instanceof FormData&&(e.percentage=e.progress?Math.round(e.progress*100):0,ge(e),this.requestParams.all().onProgress(e))}getHeaders(){let e={...this.requestParams.headers(),Accept:"text/html, application/xhtml+xml","X-Requested-With":"XMLHttpRequest","X-Inertia":!0};return n.get().version&&(e["X-Inertia-Version"]=n.get().version),e}};var M=class{constructor({maxConcurrent:e,interruptible:t}){this.requests=[];this.maxConcurrent=e,this.interruptible=t}send(e){this.requests.push(e),e.send().then(()=>{this.requests=this.requests.filter(t=>t!==e)})}interruptInFlight(){this.cancel({interrupted:!0},!1)}cancelInFlight(){this.cancel({cancelled:!0},!0)}cancel({cancelled:e=!1,interrupted:t=!1}={},i){if(!this.shouldCancel(i))return;this.requests.shift()?.cancel({interrupted:t,cancelled:e})}shouldCancel(e){return e?!0:this.interruptible&&this.requests.length>=this.maxConcurrent}};var X=class{constructor(){this.syncRequestStream=new M({maxConcurrent:1,interruptible:!0});this.asyncRequestStream=new M({maxConcurrent:1/0,interruptible:!1})}init({initialPage:e,resolveComponent:t,swapComponent:i}){n.init({initialPage:e,resolveComponent:t,swapComponent:i}),K.handle(),E.init(),E.on("missingHistoryItem",()=>{typeof window<"u"&&this.visit(window.location.href,{preserveState:!0,preserveScroll:!0,replace:!0})}),E.on("loadDeferredProps",()=>{this.loadDeferredProps()})}get(e,t={},i={}){return this.visit(e,{...i,method:"get",data:t})}post(e,t={},i={}){return this.visit(e,{preserveState:!0,...i,method:"post",data:t})}put(e,t={},i={}){return this.visit(e,{preserveState:!0,...i,method:"put",data:t})}patch(e,t={},i={}){return this.visit(e,{preserveState:!0,...i,method:"patch",data:t})}delete(e,t={}){return this.visit(e,{preserveState:!0,...t,method:"delete"})}reload(e={}){if(!(typeof window>"u"))return this.visit(window.location.href,{...e,preserveScroll:!0,preserveState:!0,async:!0,headers:{...e.headers||{},"Cache-Control":"no-cache"}})}remember(e,t="default"){l.remember(e,t)}restore(e="default"){return l.restore(e)}on(e,t){return typeof window>"u"?()=>{}:E.onGlobalEvent(e,t)}cancel(){this.syncRequestStream.cancelInFlight()}cancelAll(){this.asyncRequestStream.cancelInFlight(),this.syncRequestStream.cancelInFlight()}poll(e,t={},i={}){return Ve.add(e,()=>this.reload(t),{autoStart:i.autoStart??!0,keepAlive:i.keepAlive??!1})}visit(e,t={}){let i=this.getPendingVisit(e,{...t,showProgress:t.showProgress??!t.async}),s=this.getVisitEvents(t);if(s.onBefore(i)===!1||!Z(i))return;let o=i.async?this.asyncRequestStream:this.syncRequestStream;o.interruptInFlight(),!n.isCleared()&&!i.preserveUrl&&v.save();let u={...i,...s},p=C.get(u);p?(J(p.inFlight),C.use(p,u)):(J(!0),o.send(D.create(u,n.get())))}getCached(e,t={}){return C.findCached(this.getPrefetchParams(e,t))}flush(e,t={}){C.remove(this.getPrefetchParams(e,t))}flushAll(){C.removeAll()}getPrefetching(e,t={}){return C.findInFlight(this.getPrefetchParams(e,t))}prefetch(e,t={},{cacheFor:i=3e4}){if(t.method!=="get")throw new Error("Prefetch requests must use the GET method");let s=this.getPendingVisit(e,{...t,async:!0,showProgress:!1,prefetch:!0}),o=s.url.origin+s.url.pathname+s.url.search,u=window.location.origin+window.location.pathname+window.location.search;if(o===u)return;let p=this.getVisitEvents(t);if(p.onBefore(s)===!1||!Z(s))return;Q(),this.asyncRequestStream.interruptInFlight();let d={...s,...p};new Promise(h=>{let c=()=>{n.get()?h():setTimeout(c,50)};c()}).then(()=>{C.add(d,h=>{this.asyncRequestStream.send(D.create(h,n.get()))},{cacheFor:i})})}clearHistory(){l.clear()}decryptHistory(){return l.decrypt()}resolveComponent(e){return n.resolve(e)}replace(e){this.clientVisit(e,{replace:!0})}push(e){this.clientVisit(e)}clientVisit(e,{replace:t=!1}={}){let i=n.get(),s=typeof e.props=="function"?e.props(i.props):e.props??i.props;n.set({...i,...e,props:s},{replace:t,preserveScroll:e.preserveScroll,preserveState:e.preserveState})}getPrefetchParams(e,t){return{...this.getPendingVisit(e,{...t,async:!0,showProgress:!1,prefetch:!0}),...this.getVisitEvents(t)}}getPendingVisit(e,t,i={}){let s={method:"get",data:{},replace:!1,preserveScroll:!1,preserveState:!1,only:[],except:[],headers:{},errorBag:"",forceFormData:!1,queryStringArrayFormat:"brackets",async:!1,showProgress:!0,fresh:!1,reset:[],preserveUrl:!1,prefetch:!1,...t},[o,u]=qe(e,s.data,s.method,s.forceFormData,s.queryStringArrayFormat),p={cancelled:!1,completed:!1,interrupted:!1,...s,...i,url:o,data:u};return p.prefetch&&(p.headers.Purpose="prefetch"),p}getVisitEvents(e){return{onCancelToken:e.onCancelToken||(()=>{}),onBefore:e.onBefore||(()=>{}),onStart:e.onStart||(()=>{}),onProgress:e.onProgress||(()=>{}),onFinish:e.onFinish||(()=>{}),onCancel:e.onCancel||(()=>{}),onSuccess:e.onSuccess||(()=>{}),onError:e.onError||(()=>{}),onPrefetched:e.onPrefetched||(()=>{}),onPrefetching:e.onPrefetching||(()=>{})}}loadDeferredProps(){let e=n.get()?.deferredProps;e&&Object.entries(e).forEach(([t,i])=>{this.reload({only:i})})}};var Ye={buildDOMElement(r){let e=document.createElement("template");e.innerHTML=r;let t=e.content.firstChild;if(!r.startsWith("<script "))return t;let i=document.createElement("script");return i.innerHTML=t.innerHTML,t.getAttributeNames().forEach(s=>{i.setAttribute(s,t.getAttribute(s)||"")}),i},isInertiaManagedElement(r){return r.nodeType===Node.ELEMENT_NODE&&r.getAttribute("inertia")!==null},findMatchingElementIndex(r,e){let t=r.getAttribute("inertia");return t!==null?e.findIndex(i=>i.getAttribute("inertia")===t):-1},update:I(function(r){let e=r.map(i=>this.buildDOMElement(i));Array.from(document.head.childNodes).filter(i=>this.isInertiaManagedElement(i)).forEach(i=>{let s=this.findMatchingElementIndex(i,e);if(s===-1){i?.parentNode?.removeChild(i);return}let o=e.splice(s,1)[0];o&&!i.isEqualNode(o)&&i?.parentNode?.replaceChild(o,i)}),e.forEach(i=>document.head.appendChild(i))},1)};function Oe(r,e,t){let i={},s=0;function o(){let c=s+=1;return i[c]=[],c.toString()}function u(c){c===null||Object.keys(i).indexOf(c)===-1||(delete i[c],h())}function p(c){Object.keys(i).indexOf(c)===-1&&(i[c]=[])}function d(c,b=[]){c!==null&&Object.keys(i).indexOf(c)>-1&&(i[c]=b),h()}function a(){let c=e(""),b={...c?{title:`<title inertia="">${c}</title>`}:{}},x=Object.values(i).reduce((R,T)=>R.concat(T),[]).reduce((R,T)=>{if(T.indexOf("<")===-1)return R;if(T.indexOf("<title ")===0){let N=T.match(/(<title [^>]+>)(.*?)(<\/title>)/);return R.title=N?`${N[1]}${e(N[2])}${N[3]}`:T,R}let pe=T.match(/ inertia="[^"]+"/);return pe?R[pe[0]]=T:R[Object.keys(R).length]=T,R},b);return Object.values(x)}function h(){r?t(a()):Ye.update(a())}return h(),{forceUpdate:h,createProvider:function(){let c=o();return{reconnect:()=>p(c),update:b=>d(c,b),disconnect:()=>u(c)}}}}var f="nprogress",w,g={minimum:.08,easing:"linear",positionUsing:"translate3d",speed:200,trickle:!0,trickleSpeed:200,showSpinner:!0,barSelector:'[role="bar"]',spinnerSelector:'[role="spinner"]',parent:"body",color:"#29d",includeCSS:!0,template:['<div class="bar" role="bar">','<div class="peg"></div>',"</div>",'<div class="spinner" role="spinner">','<div class="spinner-icon"></div>',"</div>"].join("")},A=null,Ze=r=>{Object.assign(g,r),g.includeCSS&&nt(g.color),w=document.createElement("div"),w.id=f,w.innerHTML=g.template},_=r=>{let e=Le();r=Me(r,g.minimum,1),A=r===1?null:r;let t=tt(!e),i=t.querySelector(g.barSelector),s=g.speed,o=g.easing;t.offsetWidth,st(u=>{let p=g.positionUsing==="translate3d"?{transition:`all ${s}ms ${o}`,transform:`translate3d(${z(r)}%,0,0)`}:g.positionUsing==="translate"?{transition:`all ${s}ms ${o}`,transform:`translate(${z(r)}%,0)`}:{marginLeft:`${z(r)}%`};for(let d in p)i.style[d]=p[d];if(r!==1)return setTimeout(u,s);t.style.transition="none",t.style.opacity="1",t.offsetWidth,setTimeout(()=>{t.style.transition=`all ${s}ms linear`,t.style.opacity="0",setTimeout(()=>{De(),t.style.transition="",t.style.opacity="",u()},s)},s)})},Le=()=>typeof A=="number",ke=()=>{A||_(0);let r=function(){setTimeout(function(){A&&(Ue(),r())},g.trickleSpeed)};g.trickle&&r()},et=r=>{!r&&!A||(Ue(.3+.5*Math.random()),_(1))},Ue=r=>{let e=A;if(e===null)return ke();if(!(e>1))return r=typeof r=="number"?r:(()=>{let t={.1:[0,.2],.04:[.2,.5],.02:[.5,.8],.005:[.8,.99]};for(let i in t)if(e>=t[i][0]&&e<t[i][1])return parseFloat(i);return 0})(),_(Me(e+r,0,.994))},tt=r=>{if(rt())return document.getElementById(f);document.documentElement.classList.add(`${f}-busy`);let e=w.querySelector(g.barSelector),t=r?"-100":z(A||0),i=He();return e.style.transition="all 0 linear",e.style.transform=`translate3d(${t}%,0,0)`,g.showSpinner||w.querySelector(g.spinnerSelector)?.remove(),i!==document.body&&i.classList.add(`${f}-custom-parent`),i.appendChild(w),w},He=()=>it(g.parent)?g.parent:document.querySelector(g.parent),De=()=>{document.documentElement.classList.remove(`${f}-busy`),He().classList.remove(`${f}-custom-parent`),w?.remove()},rt=()=>document.getElementById(f)!==null,it=r=>typeof HTMLElement=="object"?r instanceof HTMLElement:r&&typeof r=="object"&&r.nodeType===1&&typeof r.nodeName=="string";function Me(r,e,t){return r<e?e:r>t?t:r}var z=r=>(-1+r)*100,st=(()=>{let r=[],e=()=>{let t=r.shift();t&&t(e)};return t=>{r.push(t),r.length===1&&e()}})(),nt=r=>{let e=document.createElement("style");e.textContent=`
2
2
  #${f} {
3
3
  pointer-events: none;
4
4
  }