@inertiajs/core
Advanced tools
Comparing version 2.0.0-beta.3 to 2.0.0
@@ -1,2 +0,2 @@ | ||
function L(r,e){let t;return function(...i){clearTimeout(t),t=setTimeout(()=>r.apply(this,i),e)}}function P(r,e){return document.dispatchEvent(new CustomEvent(`inertia:${r}`,e))}var X=r=>P("before",{cancelable:!0,detail:{visit:r}}),ue=r=>P("error",{detail:{errors:r}}),pe=r=>P("exception",{cancelable:!0,detail:{exception:r}}),de=r=>P("finish",{detail:{visit:r}}),he=r=>P("invalid",{cancelable:!0,detail:{response:r}}),R=r=>P("navigate",{detail:{page:r}}),me=r=>P("progress",{detail:{progress:r}}),fe=r=>P("start",{detail:{visit:r}}),ge=r=>P("success",{detail:{page:r}}),ve=(r,e)=>P("prefetched",{detail:{fetchedAt:Date.now(),response:r.data,visit:e}}),be=r=>P("prefetching",{detail:{visit:r}});var u=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()}};u.locationVisitKey="inertiaLocationVisit";var ye=async r=>{if(typeof window>"u")throw new Error("Unable to encrypt history");let e=we(),t=await Se(),i=await Ke(t);if(!i)throw new Error("Unable to encrypt history");return await Ne(e,i,r)},C={key:"historyKey",iv:"historyIv"},Pe=async r=>{let e=we(),t=await Se();if(!t)throw new Error("Unable to decrypt history");return await $e(e,t,r)},Ne=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),a=new Uint8Array(s.length*3),c=i.encodeInto(s,a);return window.crypto.subtle.encrypt({name:"AES-GCM",iv:r},e,a.subarray(0,c.written))},$e=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))},we=()=>{let r=u.get(C.iv);if(r)return new Uint8Array(r);let e=window.crypto.getRandomValues(new Uint8Array(12));return u.set(C.iv,Array.from(e)),e},Ge=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"]),Be=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);u.set(C.key,Array.from(new Uint8Array(e)))},Ke=async r=>{if(r)return r;let e=await Ge();return e?(await Be(e),e):null},Se=async()=>{let r=u.get(C.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(e){o.replaceState({...e,scrollRegions:Array.from(this.regions()).map(t=>({top:t.scrollTop,left:t.scrollLeft}))})}static regions(){return document.querySelectorAll("[scroll-region]")}static reset(e){typeof window<"u"&&window.scrollTo(0,0),this.regions().forEach(t=>{typeof t.scrollTo=="function"?t.scrollTo(0,0):(t.scrollTop=0,t.scrollLeft=0)}),this.save(e),window.location.hash&&setTimeout(()=>document.getElementById(window.location.hash.slice(1))?.scrollIntoView())}static restore(e){e.scrollRegions&&this.regions().forEach((t,i)=>{let s=e.scrollRegions[i];s&&(typeof t.scrollTo=="function"?t.scrollTo(s.left,s.top):(t.scrollTop=s.top,t.scrollLeft=s.left))})}static onScroll(e){let t=e.target;typeof t.hasAttribute=="function"&&t.hasAttribute("scroll-region")&&this.save(n.get())}};import je from"deepmerge";import*as D from"qs";function H(r){return r instanceof File||r instanceof Blob||r instanceof FileList&&r.length>0||r instanceof FormData&&Array.from(r.values()).some(e=>H(e))||typeof r=="object"&&r!==null&&Object.values(r).some(e=>H(e))}var z=r=>r instanceof FormData;function _(r,e=new FormData,t=null){r=r||{};for(let i in r)Object.prototype.hasOwnProperty.call(r,i)&&Re(e,Ee(t,i),r[i]);return e}function Ee(r,e){return r?r+"["+e+"]":e}function Re(r,e,t){if(Array.isArray(t))return Array.from(t.keys()).forEach(i=>Re(r,Ee(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,"");_(t,r,e)}function y(r){return new URL(r.toString(),typeof window>"u"?void 0:window.location.toString())}var xe=(r,e,t,i,s)=>{let a=typeof r=="string"?y(r):r;if((H(e)||i)&&!z(e)&&(e=_(e)),z(e))return[a,e];let[c,d]=qe(t,a,e,s);return[y(c),d]};function qe(r,e,t,i="brackets"){let s=/^https?:\/\//.test(e.toString()),a=s||e.toString().startsWith("/"),c=!a&&!e.toString().startsWith("#")&&!e.toString().startsWith("?"),d=e.toString().includes("?")||r==="get"&&Object.keys(t).length,m=e.toString().includes("#"),h=new URL(e.toString(),"http://localhost");return r==="get"&&Object.keys(t).length&&(h.search=D.stringify(je(D.parse(h.search,{ignoreQueryPrefix:!0}),t),{encodeValuesOnly:!0,arrayFormat:i}),t={}),[[s?`${h.protocol}//${h.host}`:"",a?h.pathname:"",c?h.pathname.substring(1):"",d?h.search:"",m?h.hash:""].join(""),t]}function F(r){return r=new URL(r.href),r.hash="",r}var Y=(r,e)=>{r.hash&&!e.hash&&F(r).href===e.href&&(e.hash=r.hash)},k=(r,e)=>F(r).href===F(e).href;var Z=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 a=this.componentId;return e.clearHistory&&o.clear(),this.resolve(e.component).then(c=>{if(a!==this.componentId)return;e.scrollRegions??(e.scrollRegions=[]),e.rememberedState??(e.rememberedState={});let d=typeof window<"u"?window.location:new URL(e.url);return t=t||k(y(e.url),d),new Promise(m=>{t?o.replaceState(e,()=>m(null)):o.pushState(e,()=>m(null))}).then(()=>{let m=!this.isTheSame(e);return this.page=e,this.cleared=!1,m&&this.fireEventsFor("newComponent"),this.isFirstPageLoad&&this.fireEventsFor("firstLoad"),this.isFirstPageLoad=!1,this.swap({component:c,page:e,preserveState:s}).then(()=>{i||v.reset(e),w.fireInternalEvent("loadDeferredProps"),t||R(e)})})})}setQuietly(e,{preserveState:t=!1}={}){return this.resolve(e.component).then(i=>(this.page=e,this.cleared=!1,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+=e}remember(e){this.page.rememberedState=e}scrollRegions(e){this.page.scrollRegions=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 Z;var M=typeof window>"u",ee=class{constructor(){this.rememberedState="rememberedState";this.scrollRegions="scrollRegions";this.preserveUrl=!1;this.current={};this.queue=[];this.initialState=null}remember(e,t){this.replaceState({...n.get(),rememberedState:{...n.get()?.rememberedState??{},[t]:e}})}restore(e){if(!M)return this.initialState?.[this.rememberedState]?.[e]}pushState(e,t=null){M||this.preserveUrl||(this.current=e,this.addToQueue(()=>this.getPageData(e).then(i=>{window.history.pushState({page:i,timestamp:Date.now()},"",e.url),t&&t()})))}getPageData(e){return new Promise(t=>e.encryptHistory?ye(e).then(t):t(e))}processQueue(){let e=this.queue.shift();return e?e().then(()=>this.processQueue()):Promise.resolve()}decrypt(e=null){if(M)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?Pe(e):Promise.resolve(e)}replaceState(e,t=null){n.merge(e),!(M||this.preserveUrl)&&(this.current=e,this.addToQueue(()=>this.getPageData(e).then(i=>{window.history.replaceState({page:i,timestamp:Date.now()},"",e.url),t&&t()})))}addToQueue(e){this.queue.push(e),this.processQueue()}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(){u.remove(C.key),u.remove(C.iv)}isValidState(e){return!!e.page}getAllState(){return this.current}},o=new ee;var te=class{constructor(){this.internalListeners=[]}init(){typeof window<"u"&&window.addEventListener("popstate",this.handlePopstateEvent.bind(this)),typeof document<"u"&&document.addEventListener("scroll",L(v.onScroll.bind(v),100),!0)}onGlobalEvent(e,t){let i=s=>{let a=t(s);s.cancelable&&!s.defaultPrevented&&a===!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=y(n.get().url);i.hash=window.location.hash,o.replaceState({...n.get(),url:i.href}),v.reset(n.get());return}if(o.isValidState(t)){o.decrypt(t.page).then(i=>{n.setQuietly(i,{preserveState:!1}).then(()=>{v.restore(n.get()),R(n.get())})}).catch(()=>{this.onMissingHistoryItem()});return}this.onMissingHistoryItem()}},w=new te;var re=class{constructor(){typeof window<"u"&&window?.performance.getEntriesByType("navigation").length>0?this.type=window.performance.getEntriesByType("navigation")[0].type:this.type="navigate"}get(){return this.type}isBackForward(){return this.type==="back_forward"}isReload(){return this.type==="reload"}},ie=new re;var N=class{static handle(){this.clearRememberedStateOnReload(),[this.handleBackForward,this.handleLocation,this.handleDefault].find(t=>t.bind(this)())}static clearRememberedStateOnReload(){ie.isReload()&&o.deleteState(o.rememberedState)}static handleBackForward(){return!ie.isBackForward()||!o.hasAnyState()?!1:(o.decrypt().then(e=>{n.set(e,{preserveScroll:!0,preserveState:!0}).then(()=>{v.restore(n.get()),R(n.get())})}).catch(()=>{w.onMissingHistoryItem()}),!0)}static handleLocation(){if(!u.exists(u.locationVisitKey))return!1;let e=u.get(u.locationVisitKey)||{};return u.remove(u.locationVisitKey),typeof window<"u"&&n.setUrlHash(window.location.hash),o.decrypt().then(()=>{let t=o.getState(o.rememberedState,{}),i=o.getState(o.scrollRegions,[]);n.remember(t),n.scrollRegions(i),n.set(n.get(),{preserveScroll:e.preserveScroll,preserveState:!0}).then(()=>{e.preserveScroll&&v.restore(n.get()),R(n.get())})}).catch(()=>{w.onMissingHistoryItem()}),!0}static handleDefault(){typeof window<"u"&&n.setUrlHash(window.location.hash),n.set(n.get(),{preserveState:!0}).then(()=>{R(n.get())})}};var $=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 se=class{constructor(){this.polls=[];this.setupVisibilityListener()}add(e,t,i){let s=new $(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)}},Ce=new se;var ne=(r,e,t)=>{if(r===e)return!0;for(let i in r)if(!t.includes(i)&&r[i]!==e[i]&&!We(r[i],e[i]))return!1;return!0},We=(r,e)=>{switch(typeof r){case"object":return ne(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},oe=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 ae=class{constructor(){this.cached=[];this.inFlightRequests=[];this.removalTimers=[];this.currentUseId=null}add(e,t,{cacheFor:i}){if(this.findInFlight(e))return Promise.resolve();let a=this.findCached(e);if(!e.fresh&&a&&a.staleTimestamp>Date.now())return Promise.resolve();let[c,d]=this.extractStaleValues(i),m=new Promise((h,l)=>{t({...e,onCancel:()=>{this.remove(e),e.onCancel(),l()},onError:g=>{this.remove(e),e.onError(g),l()},onPrefetching(g){e.onPrefetching(g)},onPrefetched(g,J){e.onPrefetched(g,J)},onPrefetchResponse(g){h(g)}})}).then(h=>(this.remove(e),this.cached.push({params:{...e},staleTimestamp:Date.now()+c,response:m,singleUse:i===0,timestamp:Date.now(),inFlight:!1}),this.scheduleForRemoval(e,d),this.inFlightRequests=this.inFlightRequests.filter(l=>!this.paramsAreEqual(l.params,e)),h.handlePrefetch(),h));return this.inFlightRequests.push({params:{...e},response:m,staleTimestamp:null,inFlight:!0}),m}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[oe(t),oe(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}paramsAreEqual(e,t){return ne(e,t,["showProgress","replace","prefetch","onBefore","onStart","onProgress","onFinish","onCancel","onSuccess","onError","onPrefetched","onCancelToken","onPrefetching","async"])}},x=new ae;import{default as Fe}from"axios";var V=class{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 V(e)}data(){return this.params.method==="get"?{}: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 Te={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 le=class{constructor(){this.queue=[];this.processing=!1}add(e){this.queue.push(e)}async process(){return this.processing||(this.processing=!0,await this.processQueue(),this.processing=!1),Promise.resolve()}async processQueue(){let e=this.queue.shift();return e?(await e.process(),this.processQueue()):Promise.resolve()}},Ae=new le,T=class{constructor(e,t,i){this.requestParams=e;this.response=t;this.originatingPage=i}static create(e,t,i){return new T(e,t,i)}async handlePrefetch(){k(this.requestParams.all().url,window.location)&&this.handle()}async handle(){return Ae.add(this),Ae.process()}async process(){if(this.requestParams.all().prefetch)return this.requestParams.all().prefetch=!1,this.requestParams.all().onPrefetched(this.response,this.requestParams.all()),ve(this.response,this.requestParams.all()),Promise.resolve();if(this.requestParams.runCallbacks(),!this.isInertiaResponse())return this.handleNonInertiaResponse();await o.processQueue(),o.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 ue(t),this.requestParams.all().onError(t)}ge(n.get()),await this.requestParams.all().onSuccess(n.get()),o.preserveUrl=!1}mergeParams(e){this.requestParams.merge(e)}async handleNonInertiaResponse(){if(this.isLocationVisit()){let t=y(this.getHeader("x-inertia-location"));return Y(this.requestParams.all().url,t),this.locationVisit(t)}let e={...this.response,data:this.getDataFromResponse(this.response.data)};if(he(e))return Te.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(u.set(u.locationVisitKey,{preserveScroll:this.requestParams.all().preserveScroll===!0}),typeof window>"u")return;k(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=o.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=y(this.originatingPage.url),i=y(n.get().url);return t.origin===i.origin&&t.pathname===i.pathname}pageUrl(e){let t=y(e.url);return Y(this.requestParams.all().url,t),t.href.split(t.host).pop()}mergeProps(e){this.requestParams.isPartial()&&e.component===n.get().component&&((e.mergeProps||[]).forEach(i=>{let s=e.props[i];Array.isArray(s)?e.props[i]=[...n.get().props[i]||[],...s]:typeof s=="object"&&(e.props[i]={...n.get().props[i]||[],...s})}),e.props={...n.get().props,...e.props})}async setRememberedState(e){let t=await o.getState(o.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 A=class{constructor(e,t){this.page=t;this.requestHasFinished=!1;this.requestParams=V.create(e),this.cancelToken=new AbortController}static create(e,t){return new A(e,t)}async send(){this.requestParams.onCancelToken(()=>this.cancel({cancelled:!0})),fe(this.requestParams.all()),this.requestParams.onStart(),this.requestParams.all().prefetch&&(this.requestParams.onPrefetching(),be(this.requestParams.all()));let e=this.requestParams.all().prefetch;return Fe({method:this.requestParams.all().method,url:F(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=T.create(this.requestParams,t,this.page),this.response.handle())).catch(t=>t?.response?(this.response=T.create(this.requestParams,t.response,this.page),this.response.handle()):Promise.reject(t)).catch(t=>{if(!Fe.isCancel(t)&&pe(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,de(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,me(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 O=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 G=class{constructor(){this.syncRequestStream=new O({maxConcurrent:1,interruptible:!0});this.asyncRequestStream=new O({maxConcurrent:1/0,interruptible:!1})}init({initialPage:e,resolveComponent:t,swapComponent:i}){n.init({initialPage:e,resolveComponent:t,swapComponent:i}),N.handle(),w.init(),w.on("missingHistoryItem",()=>{typeof window<"u"&&this.visit(window.location.href,{preserveState:!0,preserveScroll:!0,replace:!0})}),w.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"){o.remember(e,t)}restore(e="default"){return o.restore(e)}on(e,t){return w.onGlobalEvent(e,t)}cancel(){this.syncRequestStream.cancelInFlight()}cancelAll(){this.asyncRequestStream.cancelInFlight(),this.syncRequestStream.cancelInFlight()}poll(e,t={},i={}){return Ce.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||!X(i))return;let a=i.async?this.asyncRequestStream:this.syncRequestStream;a.interruptInFlight(),!n.isCleared()&&!i.preserveUrl&&v.save(n.get());let c={...i,...s},d=x.get(c);d?(B(d.inFlight),x.use(d,c)):(B(!0),a.send(A.create(c,n.get())))}getCached(e,t={}){return x.findCached(this.getPrefetchParams(e,t))}flush(e,t={}){x.remove(this.getPrefetchParams(e,t))}flushAll(){x.removeAll()}getPrefetching(e,t={}){return x.findInFlight(this.getPrefetchParams(e,t))}prefetch(e,t={},{cacheFor:i}){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}),a=s.url.origin+s.url.pathname+s.url.search,c=window.location.origin+window.location.pathname+window.location.search;if(a===c)return;let d=this.getVisitEvents(t);if(d.onBefore(s)===!1||!X(s))return;K(),this.asyncRequestStream.interruptInFlight();let m={...s,...d};(()=>new Promise(l=>{let g=()=>{n.get()?l():setTimeout(g,50)};g()}))().then(()=>{x.add(m,l=>{this.asyncRequestStream.send(A.create(l,n.get()))},{cacheFor:i})})}clearHistory(){o.clear()}decryptHistory(){return o.decrypt()}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},[a,c]=xe(e,s.data,s.method,s.forceFormData,s.queryStringArrayFormat);return{cancelled:!1,completed:!1,interrupted:!1,...s,...i,url:a,data:c}}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 Je={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:L(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 a=e.splice(s,1)[0];a&&!i.isEqualNode(a)&&i?.parentNode?.replaceChild(a,i)}),e.forEach(i=>document.head.appendChild(i))},1)};function Ve(r,e,t){let i={},s=0;function a(){let l=s+=1;return i[l]=[],l.toString()}function c(l){l===null||Object.keys(i).indexOf(l)===-1||(delete i[l],h())}function d(l,g=[]){l!==null&&Object.keys(i).indexOf(l)>-1&&(i[l]=g),h()}function m(){let l=e(""),g={...l?{title:`<title inertia="">${l}</title>`}:{}},J=Object.values(i).reduce((S,E)=>S.concat(E),[]).reduce((S,E)=>{if(E.indexOf("<")===-1)return S;if(E.indexOf("<title ")===0){let U=E.match(/(<title [^>]+>)(.*?)(<\/title>)/);return S.title=U?`${U[1]}${e(U[2])}${U[3]}`:E,S}let ce=E.match(/ inertia="[^"]+"/);return ce?S[ce[0]]=E:S[Object.keys(S).length]=E,S},g);return Object.values(J)}function h(){r?t(m()):Je.update(m())}return h(),{forceUpdate:h,createProvider:function(){let l=a();return{update:g=>d(l,g),disconnect:()=>c(l)}}}}var p="nprogress",f={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("")},q=null,Xe=r=>{Object.assign(f,r),f.includeCSS&&tt(f.color)},W=r=>{let e=Ie();r=He(r,f.minimum,1),q=r===1?null:r;let t=_e(!e),i=t.querySelector(f.barSelector),s=f.speed,a=f.easing;t.offsetWidth,et(c=>{let d=(()=>f.positionUsing==="translate3d"?{transition:`all ${s}ms ${a}`,transform:`translate3d(${j(r)}%,0,0)`}:f.positionUsing==="translate"?{transition:`all ${s}ms ${a}`,transform:`translate(${j(r)}%,0)`}:{marginLeft:`${j(r)}%`})();for(let m in d)i.style[m]=d[m];if(r!==1)return setTimeout(c,s);t.style.transition="none",t.style.opacity="1",t.offsetWidth,setTimeout(()=>{t.style.transition=`all ${s}ms linear`,t.style.opacity="0",setTimeout(()=>{Ue(),c()},s)},s)})},Ie=()=>typeof q=="number",Le=()=>{q||W(0);let r=function(){setTimeout(function(){q&&(ke(),r())},f.trickleSpeed)};f.trickle&&r()},ze=r=>{!r&&!q||(ke(.3+.5*Math.random()),W(1))},ke=r=>{let e=q;if(e===null)return Le();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})(),W(He(e+r,0,.994))},_e=r=>{if(Ye())return document.getElementById(p);document.documentElement.classList.add(`${p}-busy`);let e=document.createElement("div");e.id=p,e.innerHTML=f.template;let t=e.querySelector(f.barSelector),i=r?"-100":j(q||0),s=Oe();return t.style.transition="all 0 linear",t.style.transform=`translate3d(${i}%,0,0)`,f.showSpinner||e.querySelector(f.spinnerSelector)?.remove(),s!==document.body&&s.classList.add(`${p}-custom-parent`),s.appendChild(e),e},Oe=()=>Ze(f.parent)?f.parent:document.querySelector(f.parent),Ue=()=>{document.documentElement.classList.remove(`${p}-busy`),Oe().classList.remove(`${p}-custom-parent`),document.getElementById(p)?.remove()},Ye=()=>document.getElementById(p)!==null,Ze=r=>typeof HTMLElement=="object"?r instanceof HTMLElement:r&&typeof r=="object"&&r.nodeType===1&&typeof r.nodeName=="string";function He(r,e,t){return r<e?e:r>t?t:r}var j=r=>(-1+r)*100,et=(()=>{let r=[],e=()=>{let t=r.shift();t&&t(e)};return t=>{r.push(t),r.length===1&&e()}})(),tt=r=>{let e=document.createElement("style");e.textContent=` | ||
function L(r,e){let t;return function(...i){clearTimeout(t),t=setTimeout(()=>r.apply(this,i),e)}}function P(r,e){return document.dispatchEvent(new CustomEvent(`inertia:${r}`,e))}var X=r=>P("before",{cancelable:!0,detail:{visit:r}}),ue=r=>P("error",{detail:{errors:r}}),pe=r=>P("exception",{cancelable:!0,detail:{exception:r}}),de=r=>P("finish",{detail:{visit:r}}),he=r=>P("invalid",{cancelable:!0,detail:{response:r}}),R=r=>P("navigate",{detail:{page:r}}),me=r=>P("progress",{detail:{progress:r}}),fe=r=>P("start",{detail:{visit:r}}),ge=r=>P("success",{detail:{page:r}}),ve=(r,e)=>P("prefetched",{detail:{fetchedAt:Date.now(),response:r.data,visit:e}}),be=r=>P("prefetching",{detail:{visit:r}});var u=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()}};u.locationVisitKey="inertiaLocationVisit";var ye=async r=>{if(typeof window>"u")throw new Error("Unable to encrypt history");let e=we(),t=await Se(),i=await Ke(t);if(!i)throw new Error("Unable to encrypt history");return await Ne(e,i,r)},C={key:"historyKey",iv:"historyIv"},Pe=async r=>{let e=we(),t=await Se();if(!t)throw new Error("Unable to decrypt history");return await $e(e,t,r)},Ne=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),a=new Uint8Array(s.length*3),c=i.encodeInto(s,a);return window.crypto.subtle.encrypt({name:"AES-GCM",iv:r},e,a.subarray(0,c.written))},$e=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))},we=()=>{let r=u.get(C.iv);if(r)return new Uint8Array(r);let e=window.crypto.getRandomValues(new Uint8Array(12));return u.set(C.iv,Array.from(e)),e},Ge=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"]),Be=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);u.set(C.key,Array.from(new Uint8Array(e)))},Ke=async r=>{if(r)return r;let e=await Ge();return e?(await Be(e),e):null},Se=async()=>{let r=u.get(C.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(e){o.replaceState({...e,scrollRegions:Array.from(this.regions()).map(t=>({top:t.scrollTop,left:t.scrollLeft}))})}static regions(){return document.querySelectorAll("[scroll-region]")}static reset(e){typeof window<"u"&&window.scrollTo(0,0),this.regions().forEach(t=>{typeof t.scrollTo=="function"?t.scrollTo(0,0):(t.scrollTop=0,t.scrollLeft=0)}),this.save(e),window.location.hash&&setTimeout(()=>document.getElementById(window.location.hash.slice(1))?.scrollIntoView())}static restore(e){e.scrollRegions&&this.regions().forEach((t,i)=>{let s=e.scrollRegions[i];s&&(typeof t.scrollTo=="function"?t.scrollTo(s.left,s.top):(t.scrollTop=s.top,t.scrollLeft=s.left))})}static onScroll(e){let t=e.target;typeof t.hasAttribute=="function"&&t.hasAttribute("scroll-region")&&this.save(n.get())}};import je from"deepmerge";import*as D from"qs";function H(r){return r instanceof File||r instanceof Blob||r instanceof FileList&&r.length>0||r instanceof FormData&&Array.from(r.values()).some(e=>H(e))||typeof r=="object"&&r!==null&&Object.values(r).some(e=>H(e))}var z=r=>r instanceof FormData;function _(r,e=new FormData,t=null){r=r||{};for(let i in r)Object.prototype.hasOwnProperty.call(r,i)&&Re(e,Ee(t,i),r[i]);return e}function Ee(r,e){return r?r+"["+e+"]":e}function Re(r,e,t){if(Array.isArray(t))return Array.from(t.keys()).forEach(i=>Re(r,Ee(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,"");_(t,r,e)}function y(r){return new URL(r.toString(),typeof window>"u"?void 0:window.location.toString())}var xe=(r,e,t,i,s)=>{let a=typeof r=="string"?y(r):r;if((H(e)||i)&&!z(e)&&(e=_(e)),z(e))return[a,e];let[c,d]=qe(t,a,e,s);return[y(c),d]};function qe(r,e,t,i="brackets"){let s=/^https?:\/\//.test(e.toString()),a=s||e.toString().startsWith("/"),c=!a&&!e.toString().startsWith("#")&&!e.toString().startsWith("?"),d=e.toString().includes("?")||r==="get"&&Object.keys(t).length,m=e.toString().includes("#"),h=new URL(e.toString(),"http://localhost");return r==="get"&&Object.keys(t).length&&(h.search=D.stringify(je(D.parse(h.search,{ignoreQueryPrefix:!0}),t),{encodeValuesOnly:!0,arrayFormat:i}),t={}),[[s?`${h.protocol}//${h.host}`:"",a?h.pathname:"",c?h.pathname.substring(1):"",d?h.search:"",m?h.hash:""].join(""),t]}function V(r){return r=new URL(r.href),r.hash="",r}var Y=(r,e)=>{r.hash&&!e.hash&&V(r).href===e.href&&(e.hash=r.hash)},k=(r,e)=>V(r).href===V(e).href;var Z=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 a=this.componentId;return e.clearHistory&&o.clear(),this.resolve(e.component).then(c=>{if(a!==this.componentId)return;e.scrollRegions??(e.scrollRegions=[]),e.rememberedState??(e.rememberedState={});let d=typeof window<"u"?window.location:new URL(e.url);return t=t||k(y(e.url),d),new Promise(m=>{t?o.replaceState(e,()=>m(null)):o.pushState(e,()=>m(null))}).then(()=>{let m=!this.isTheSame(e);return this.page=e,this.cleared=!1,m&&this.fireEventsFor("newComponent"),this.isFirstPageLoad&&this.fireEventsFor("firstLoad"),this.isFirstPageLoad=!1,this.swap({component:c,page:e,preserveState:s}).then(()=>{i||v.reset(e),w.fireInternalEvent("loadDeferredProps"),t||R(e)})})})}setQuietly(e,{preserveState:t=!1}={}){return this.resolve(e.component).then(i=>(this.page=e,this.cleared=!1,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+=e}remember(e){this.page.rememberedState=e}scrollRegions(e){this.page.scrollRegions=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 Z;var M=typeof window>"u",ee=class{constructor(){this.rememberedState="rememberedState";this.scrollRegions="scrollRegions";this.preserveUrl=!1;this.current={};this.queue=[];this.initialState=null}remember(e,t){this.replaceState({...n.get(),rememberedState:{...n.get()?.rememberedState??{},[t]:e}})}restore(e){if(!M)return this.initialState?.[this.rememberedState]?.[e]}pushState(e,t=null){M||this.preserveUrl||(this.current=e,this.addToQueue(()=>this.getPageData(e).then(i=>{window.history.pushState({page:i,timestamp:Date.now()},"",e.url),t&&t()})))}getPageData(e){return new Promise(t=>e.encryptHistory?ye(e).then(t):t(e))}processQueue(){let e=this.queue.shift();return e?e().then(()=>this.processQueue()):Promise.resolve()}decrypt(e=null){if(M)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?Pe(e):Promise.resolve(e)}replaceState(e,t=null){n.merge(e),!(M||this.preserveUrl)&&(this.current=e,this.addToQueue(()=>this.getPageData(e).then(i=>{window.history.replaceState({page:i,timestamp:Date.now()},"",e.url),t&&t()})))}addToQueue(e){this.queue.push(e),this.processQueue()}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(){u.remove(C.key),u.remove(C.iv)}isValidState(e){return!!e.page}getAllState(){return this.current}},o=new ee;var te=class{constructor(){this.internalListeners=[]}init(){typeof window<"u"&&window.addEventListener("popstate",this.handlePopstateEvent.bind(this)),typeof document<"u"&&document.addEventListener("scroll",L(v.onScroll.bind(v),100),!0)}onGlobalEvent(e,t){let i=s=>{let a=t(s);s.cancelable&&!s.defaultPrevented&&a===!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=y(n.get().url);i.hash=window.location.hash,o.replaceState({...n.get(),url:i.href}),v.reset(n.get());return}if(o.isValidState(t)){o.decrypt(t.page).then(i=>{n.setQuietly(i,{preserveState:!1}).then(()=>{v.restore(n.get()),R(n.get())})}).catch(()=>{this.onMissingHistoryItem()});return}this.onMissingHistoryItem()}},w=new te;var re=class{constructor(){typeof window<"u"&&window?.performance.getEntriesByType("navigation").length>0?this.type=window.performance.getEntriesByType("navigation")[0].type:this.type="navigate"}get(){return this.type}isBackForward(){return this.type==="back_forward"}isReload(){return this.type==="reload"}},ie=new re;var N=class{static handle(){this.clearRememberedStateOnReload(),[this.handleBackForward,this.handleLocation,this.handleDefault].find(t=>t.bind(this)())}static clearRememberedStateOnReload(){ie.isReload()&&o.deleteState(o.rememberedState)}static handleBackForward(){return!ie.isBackForward()||!o.hasAnyState()?!1:(o.decrypt().then(e=>{n.set(e,{preserveScroll:!0,preserveState:!0}).then(()=>{v.restore(n.get()),R(n.get())})}).catch(()=>{w.onMissingHistoryItem()}),!0)}static handleLocation(){if(!u.exists(u.locationVisitKey))return!1;let e=u.get(u.locationVisitKey)||{};return u.remove(u.locationVisitKey),typeof window<"u"&&n.setUrlHash(window.location.hash),o.decrypt().then(()=>{let t=o.getState(o.rememberedState,{}),i=o.getState(o.scrollRegions,[]);n.remember(t),n.scrollRegions(i),n.set(n.get(),{preserveScroll:e.preserveScroll,preserveState:!0}).then(()=>{e.preserveScroll&&v.restore(n.get()),R(n.get())})}).catch(()=>{w.onMissingHistoryItem()}),!0}static handleDefault(){typeof window<"u"&&n.setUrlHash(window.location.hash),n.set(n.get(),{preserveState:!0}).then(()=>{R(n.get())})}};var $=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 se=class{constructor(){this.polls=[];this.setupVisibilityListener()}add(e,t,i){let s=new $(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)}},Ce=new se;var ne=(r,e,t)=>{if(r===e)return!0;for(let i in r)if(!t.includes(i)&&r[i]!==e[i]&&!We(r[i],e[i]))return!1;return!0},We=(r,e)=>{switch(typeof r){case"object":return ne(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},oe=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 ae=class{constructor(){this.cached=[];this.inFlightRequests=[];this.removalTimers=[];this.currentUseId=null}add(e,t,{cacheFor:i}){if(this.findInFlight(e))return Promise.resolve();let a=this.findCached(e);if(!e.fresh&&a&&a.staleTimestamp>Date.now())return Promise.resolve();let[c,d]=this.extractStaleValues(i),m=new Promise((h,l)=>{t({...e,onCancel:()=>{this.remove(e),e.onCancel(),l()},onError:g=>{this.remove(e),e.onError(g),l()},onPrefetching(g){e.onPrefetching(g)},onPrefetched(g,J){e.onPrefetched(g,J)},onPrefetchResponse(g){h(g)}})}).then(h=>(this.remove(e),this.cached.push({params:{...e},staleTimestamp:Date.now()+c,response:m,singleUse:i===0,timestamp:Date.now(),inFlight:!1}),this.scheduleForRemoval(e,d),this.inFlightRequests=this.inFlightRequests.filter(l=>!this.paramsAreEqual(l.params,e)),h.handlePrefetch(),h));return this.inFlightRequests.push({params:{...e},response:m,staleTimestamp:null,inFlight:!0}),m}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[oe(t),oe(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}paramsAreEqual(e,t){return ne(e,t,["showProgress","replace","prefetch","onBefore","onStart","onProgress","onFinish","onCancel","onSuccess","onError","onPrefetched","onCancelToken","onPrefetching","async"])}},x=new ae;import{default as Ve}from"axios";var F=class{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 F(e)}data(){return this.params.method==="get"?{}: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 Te={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 le=class{constructor(){this.queue=[];this.processing=!1}add(e){this.queue.push(e)}async process(){return this.processing||(this.processing=!0,await this.processQueue(),this.processing=!1),Promise.resolve()}async processQueue(){let e=this.queue.shift();return e?(await e.process(),this.processQueue()):Promise.resolve()}},Ae=new le,T=class{constructor(e,t,i){this.requestParams=e;this.response=t;this.originatingPage=i}static create(e,t,i){return new T(e,t,i)}async handlePrefetch(){k(this.requestParams.all().url,window.location)&&this.handle()}async handle(){return Ae.add(this),Ae.process()}async process(){if(this.requestParams.all().prefetch)return this.requestParams.all().prefetch=!1,this.requestParams.all().onPrefetched(this.response,this.requestParams.all()),ve(this.response,this.requestParams.all()),Promise.resolve();if(this.requestParams.runCallbacks(),!this.isInertiaResponse())return this.handleNonInertiaResponse();await o.processQueue(),o.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 ue(t),this.requestParams.all().onError(t)}ge(n.get()),await this.requestParams.all().onSuccess(n.get()),o.preserveUrl=!1}mergeParams(e){this.requestParams.merge(e)}async handleNonInertiaResponse(){if(this.isLocationVisit()){let t=y(this.getHeader("x-inertia-location"));return Y(this.requestParams.all().url,t),this.locationVisit(t)}let e={...this.response,data:this.getDataFromResponse(this.response.data)};if(he(e))return Te.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(u.set(u.locationVisitKey,{preserveScroll:this.requestParams.all().preserveScroll===!0}),typeof window>"u")return;k(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=o.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=y(this.originatingPage.url),i=y(n.get().url);return t.origin===i.origin&&t.pathname===i.pathname}pageUrl(e){let t=y(e.url);return Y(this.requestParams.all().url,t),t.href.split(t.host).pop()}mergeProps(e){this.requestParams.isPartial()&&e.component===n.get().component&&((e.mergeProps||[]).forEach(i=>{let s=e.props[i];Array.isArray(s)?e.props[i]=[...n.get().props[i]||[],...s]:typeof s=="object"&&(e.props[i]={...n.get().props[i]||[],...s})}),e.props={...n.get().props,...e.props})}async setRememberedState(e){let t=await o.getState(o.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 A=class{constructor(e,t){this.page=t;this.requestHasFinished=!1;this.requestParams=F.create(e),this.cancelToken=new AbortController}static create(e,t){return new A(e,t)}async send(){this.requestParams.onCancelToken(()=>this.cancel({cancelled:!0})),fe(this.requestParams.all()),this.requestParams.onStart(),this.requestParams.all().prefetch&&(this.requestParams.onPrefetching(),be(this.requestParams.all()));let e=this.requestParams.all().prefetch;return Ve({method:this.requestParams.all().method,url:V(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=T.create(this.requestParams,t,this.page),this.response.handle())).catch(t=>t?.response?(this.response=T.create(this.requestParams,t.response,this.page),this.response.handle()):Promise.reject(t)).catch(t=>{if(!Ve.isCancel(t)&&pe(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,de(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,me(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 O=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 G=class{constructor(){this.syncRequestStream=new O({maxConcurrent:1,interruptible:!0});this.asyncRequestStream=new O({maxConcurrent:1/0,interruptible:!1})}init({initialPage:e,resolveComponent:t,swapComponent:i}){n.init({initialPage:e,resolveComponent:t,swapComponent:i}),N.handle(),w.init(),w.on("missingHistoryItem",()=>{typeof window<"u"&&this.visit(window.location.href,{preserveState:!0,preserveScroll:!0,replace:!0})}),w.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"){o.remember(e,t)}restore(e="default"){return o.restore(e)}on(e,t){return w.onGlobalEvent(e,t)}cancel(){this.syncRequestStream.cancelInFlight()}cancelAll(){this.asyncRequestStream.cancelInFlight(),this.syncRequestStream.cancelInFlight()}poll(e,t={},i={}){return Ce.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||!X(i))return;let a=i.async?this.asyncRequestStream:this.syncRequestStream;a.interruptInFlight(),!n.isCleared()&&!i.preserveUrl&&v.save(n.get());let c={...i,...s},d=x.get(c);d?(B(d.inFlight),x.use(d,c)):(B(!0),a.send(A.create(c,n.get())))}getCached(e,t={}){return x.findCached(this.getPrefetchParams(e,t))}flush(e,t={}){x.remove(this.getPrefetchParams(e,t))}flushAll(){x.removeAll()}getPrefetching(e,t={}){return x.findInFlight(this.getPrefetchParams(e,t))}prefetch(e,t={},{cacheFor:i}){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}),a=s.url.origin+s.url.pathname+s.url.search,c=window.location.origin+window.location.pathname+window.location.search;if(a===c)return;let d=this.getVisitEvents(t);if(d.onBefore(s)===!1||!X(s))return;K(),this.asyncRequestStream.interruptInFlight();let m={...s,...d};(()=>new Promise(l=>{let g=()=>{n.get()?l():setTimeout(g,50)};g()}))().then(()=>{x.add(m,l=>{this.asyncRequestStream.send(A.create(l,n.get()))},{cacheFor:i})})}clearHistory(){o.clear()}decryptHistory(){return o.decrypt()}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},[a,c]=xe(e,s.data,s.method,s.forceFormData,s.queryStringArrayFormat);return{cancelled:!1,completed:!1,interrupted:!1,...s,...i,url:a,data:c}}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 Je={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:L(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 a=e.splice(s,1)[0];a&&!i.isEqualNode(a)&&i?.parentNode?.replaceChild(a,i)}),e.forEach(i=>document.head.appendChild(i))},1)};function Fe(r,e,t){let i={},s=0;function a(){let l=s+=1;return i[l]=[],l.toString()}function c(l){l===null||Object.keys(i).indexOf(l)===-1||(delete i[l],h())}function d(l,g=[]){l!==null&&Object.keys(i).indexOf(l)>-1&&(i[l]=g),h()}function m(){let l=e(""),g={...l?{title:`<title inertia="">${l}</title>`}:{}},J=Object.values(i).reduce((S,E)=>S.concat(E),[]).reduce((S,E)=>{if(E.indexOf("<")===-1)return S;if(E.indexOf("<title ")===0){let U=E.match(/(<title [^>]+>)(.*?)(<\/title>)/);return S.title=U?`${U[1]}${e(U[2])}${U[3]}`:E,S}let ce=E.match(/ inertia="[^"]+"/);return ce?S[ce[0]]=E:S[Object.keys(S).length]=E,S},g);return Object.values(J)}function h(){r?t(m()):Je.update(m())}return h(),{forceUpdate:h,createProvider:function(){let l=a();return{update:g=>d(l,g),disconnect:()=>c(l)}}}}var p="nprogress",f={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("")},q=null,Xe=r=>{Object.assign(f,r),f.includeCSS&&tt(f.color)},W=r=>{let e=Ie();r=He(r,f.minimum,1),q=r===1?null:r;let t=_e(!e),i=t.querySelector(f.barSelector),s=f.speed,a=f.easing;t.offsetWidth,et(c=>{let d=(()=>f.positionUsing==="translate3d"?{transition:`all ${s}ms ${a}`,transform:`translate3d(${j(r)}%,0,0)`}:f.positionUsing==="translate"?{transition:`all ${s}ms ${a}`,transform:`translate(${j(r)}%,0)`}:{marginLeft:`${j(r)}%`})();for(let m in d)i.style[m]=d[m];if(r!==1)return setTimeout(c,s);t.style.transition="none",t.style.opacity="1",t.offsetWidth,setTimeout(()=>{t.style.transition=`all ${s}ms linear`,t.style.opacity="0",setTimeout(()=>{Ue(),c()},s)},s)})},Ie=()=>typeof q=="number",Le=()=>{q||W(0);let r=function(){setTimeout(function(){q&&(ke(),r())},f.trickleSpeed)};f.trickle&&r()},ze=r=>{!r&&!q||(ke(.3+.5*Math.random()),W(1))},ke=r=>{let e=q;if(e===null)return Le();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})(),W(He(e+r,0,.994))},_e=r=>{if(Ye())return document.getElementById(p);document.documentElement.classList.add(`${p}-busy`);let e=document.createElement("div");e.id=p,e.innerHTML=f.template;let t=e.querySelector(f.barSelector),i=r?"-100":j(q||0),s=Oe();return t.style.transition="all 0 linear",t.style.transform=`translate3d(${i}%,0,0)`,f.showSpinner||e.querySelector(f.spinnerSelector)?.remove(),s!==document.body&&s.classList.add(`${p}-custom-parent`),s.appendChild(e),e},Oe=()=>Ze(f.parent)?f.parent:document.querySelector(f.parent),Ue=()=>{document.documentElement.classList.remove(`${p}-busy`),Oe().classList.remove(`${p}-custom-parent`),document.getElementById(p)?.remove()},Ye=()=>document.getElementById(p)!==null,Ze=r=>typeof HTMLElement=="object"?r instanceof HTMLElement:r&&typeof r=="object"&&r.nodeType===1&&typeof r.nodeName=="string";function He(r,e,t){return r<e?e:r>t?t:r}var j=r=>(-1+r)*100,et=(()=>{let r=[],e=()=>{let t=r.shift();t&&t(e)};return t=>{r.push(t),r.length===1&&e()}})(),tt=r=>{let e=document.createElement("style");e.textContent=` | ||
#${p} { | ||
@@ -65,5 +65,5 @@ pointer-events: none; | ||
} | ||
`,document.head.appendChild(e)},I=(()=>{if(typeof document>"u")return null;let r=document.createElement("style");return r.innerHTML=`#${p} { display: none; }`,r})(),rt=()=>{if(I&&document.head.contains(I))return document.head.removeChild(I)},it=()=>{I&&!document.head.contains(I)&&document.head.appendChild(I)},b={configure:Xe,isStarted:Ie,done:ze,set:W,remove:Ue,start:Le,status:q,show:rt,hide:it};var Q=0,B=(r=!1)=>{Q=Math.max(0,Q-1),(r||Q===0)&&b.show()},K=()=>{Q++,b.hide()};function st(r){document.addEventListener("inertia:start",e=>nt(e,r)),document.addEventListener("inertia:progress",ot)}function nt(r,e){r.detail.visit.showProgress||K();let t=setTimeout(()=>b.start(),e);document.addEventListener("inertia:finish",i=>at(i,t),{once:!0})}function ot(r){b.isStarted()&&r.detail.progress?.percentage&&b.set(Math.max(b.status,r.detail.progress.percentage/100*.9))}function at(r,e){clearTimeout(e),b.isStarted()&&(r.detail.visit.completed?b.done():r.detail.visit.interrupted?b.set(0):r.detail.visit.cancelled&&(b.done(),b.remove()))}function De({delay:r=250,color:e="#29d",includeCSS:t=!0,showSpinner:i=!1}={}){st(r),b.configure({showSpinner:i,includeCSS:t,color:e})}function Me(r){let e=r.currentTarget.tagName.toLowerCase()==="a";return!(r.target&&(r?.target).isContentEditable||r.defaultPrevented||e&&r.which>1||e&&r.altKey||e&&r.ctrlKey||e&&r.metaKey||e&&r.shiftKey||e&&"button"in r&&r.button!==0)}var Gr=new G;export{Ve as createHeadManager,K as hideProgress,y as hrefToUrl,qe as mergeDataIntoQueryString,B as revealProgress,Gr as router,De as setupProgress,Me as shouldIntercept,F as urlWithoutHash}; | ||
`,document.head.appendChild(e)},I=(()=>{if(typeof document>"u")return null;let r=document.createElement("style");return r.innerHTML=`#${p} { display: none; }`,r})(),rt=()=>{if(I&&document.head.contains(I))return document.head.removeChild(I)},it=()=>{I&&!document.head.contains(I)&&document.head.appendChild(I)},b={configure:Xe,isStarted:Ie,done:ze,set:W,remove:Ue,start:Le,status:q,show:rt,hide:it};var Q=0,B=(r=!1)=>{Q=Math.max(0,Q-1),(r||Q===0)&&b.show()},K=()=>{Q++,b.hide()};function st(r){document.addEventListener("inertia:start",e=>nt(e,r)),document.addEventListener("inertia:progress",ot)}function nt(r,e){r.detail.visit.showProgress||K();let t=setTimeout(()=>b.start(),e);document.addEventListener("inertia:finish",i=>at(i,t),{once:!0})}function ot(r){b.isStarted()&&r.detail.progress?.percentage&&b.set(Math.max(b.status,r.detail.progress.percentage/100*.9))}function at(r,e){clearTimeout(e),b.isStarted()&&(r.detail.visit.completed?b.done():r.detail.visit.interrupted?b.set(0):r.detail.visit.cancelled&&(b.done(),b.remove()))}function De({delay:r=250,color:e="#29d",includeCSS:t=!0,showSpinner:i=!1}={}){st(r),b.configure({showSpinner:i,includeCSS:t,color:e})}function Me(r){let e=r.currentTarget.tagName.toLowerCase()==="a";return!(r.target&&(r?.target).isContentEditable||r.defaultPrevented||e&&r.which>1||e&&r.altKey||e&&r.ctrlKey||e&&r.metaKey||e&&r.shiftKey||e&&"button"in r&&r.button!==0)}var Gr=new G;export{Fe as createHeadManager,K as hideProgress,y as hrefToUrl,qe as mergeDataIntoQueryString,B as revealProgress,Gr as router,De as setupProgress,Me as shouldIntercept,V as urlWithoutHash}; | ||
/* NProgress, (c) 2013, 2014 Rico Sta. Cruz - http://ricostacruz.com/nprogress | ||
* @license MIT */ | ||
//# sourceMappingURL=index.esm.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict";var Ke=Object.create;var M=Object.defineProperty;var je=Object.getOwnPropertyDescriptor;var We=Object.getOwnPropertyNames;var Qe=Object.getPrototypeOf,Je=Object.prototype.hasOwnProperty;var Xe=(r,e)=>{for(var t in e)M(r,t,{get:e[t],enumerable:!0})},ve=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of We(e))!Je.call(r,s)&&s!==t&&M(r,s,{get:()=>e[s],enumerable:!(i=je(e,s))||i.enumerable});return r};var z=(r,e,t)=>(t=r!=null?Ke(Qe(r)):{},ve(e||!r||!r.__esModule?M(t,"default",{value:r,enumerable:!0}):t,r)),ze=r=>ve(M({},"__esModule",{value:!0}),r);var yt={};Xe(yt,{createHeadManager:()=>he,hideProgress:()=>H,hrefToUrl:()=>b,mergeDataIntoQueryString:()=>ee,revealProgress:()=>U,router:()=>bt,setupProgress:()=>me,shouldIntercept:()=>fe,urlWithoutHash:()=>T});module.exports=ze(yt);function L(r,e){let t;return function(...i){clearTimeout(t),t=setTimeout(()=>r.apply(this,i),e)}}function P(r,e){return document.dispatchEvent(new CustomEvent(`inertia:${r}`,e))}var _=r=>P("before",{cancelable:!0,detail:{visit:r}}),be=r=>P("error",{detail:{errors:r}}),ye=r=>P("exception",{cancelable:!0,detail:{exception:r}}),Pe=r=>P("finish",{detail:{visit:r}}),we=r=>P("invalid",{cancelable:!0,detail:{response:r}}),R=r=>P("navigate",{detail:{page:r}}),Se=r=>P("progress",{detail:{progress:r}}),Ee=r=>P("start",{detail:{visit:r}}),Re=r=>P("success",{detail:{page:r}}),xe=(r,e)=>P("prefetched",{detail:{fetchedAt:Date.now(),response:r.data,visit:e}}),qe=r=>P("prefetching",{detail:{visit:r}});var u=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()}};u.locationVisitKey="inertiaLocationVisit";var Ce=async r=>{if(typeof window>"u")throw new Error("Unable to encrypt history");let e=Ae(),t=await Fe(),i=await tt(t);if(!i)throw new Error("Unable to encrypt history");return await _e(e,i,r)},C={key:"historyKey",iv:"historyIv"},Te=async r=>{let e=Ae(),t=await Fe();if(!t)throw new Error("Unable to decrypt history");return await Ye(e,t,r)},_e=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),a=new Uint8Array(s.length*3),c=i.encodeInto(s,a);return window.crypto.subtle.encrypt({name:"AES-GCM",iv:r},e,a.subarray(0,c.written))},Ye=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))},Ae=()=>{let r=u.get(C.iv);if(r)return new Uint8Array(r);let e=window.crypto.getRandomValues(new Uint8Array(12));return u.set(C.iv,Array.from(e)),e},Ze=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"]),et=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);u.set(C.key,Array.from(new Uint8Array(e)))},tt=async r=>{if(r)return r;let e=await Ze();return e?(await et(e),e):null},Fe=async()=>{let r=u.get(C.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(e){o.replaceState({...e,scrollRegions:Array.from(this.regions()).map(t=>({top:t.scrollTop,left:t.scrollLeft}))})}static regions(){return document.querySelectorAll("[scroll-region]")}static reset(e){typeof window<"u"&&window.scrollTo(0,0),this.regions().forEach(t=>{typeof t.scrollTo=="function"?t.scrollTo(0,0):(t.scrollTop=0,t.scrollLeft=0)}),this.save(e),window.location.hash&&setTimeout(()=>document.getElementById(window.location.hash.slice(1))?.scrollIntoView())}static restore(e){e.scrollRegions&&this.regions().forEach((t,i)=>{let s=e.scrollRegions[i];s&&(typeof t.scrollTo=="function"?t.scrollTo(s.left,s.top):(t.scrollTop=s.top,t.scrollLeft=s.left))})}static onScroll(e){let t=e.target;typeof t.hasAttribute=="function"&&t.hasAttribute("scroll-region")&&this.save(n.get())}};var Le=z(require("deepmerge"),1),$=z(require("qs"),1);function N(r){return r instanceof File||r instanceof Blob||r instanceof FileList&&r.length>0||r instanceof FormData&&Array.from(r.values()).some(e=>N(e))||typeof r=="object"&&r!==null&&Object.values(r).some(e=>N(e))}var Y=r=>r instanceof FormData;function Z(r,e=new FormData,t=null){r=r||{};for(let i in r)Object.prototype.hasOwnProperty.call(r,i)&&Ie(e,Ve(t,i),r[i]);return e}function Ve(r,e){return r?r+"["+e+"]":e}function Ie(r,e,t){if(Array.isArray(t))return Array.from(t.keys()).forEach(i=>Ie(r,Ve(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,"");Z(t,r,e)}function b(r){return new URL(r.toString(),typeof window>"u"?void 0:window.location.toString())}var ke=(r,e,t,i,s)=>{let a=typeof r=="string"?b(r):r;if((N(e)||i)&&!Y(e)&&(e=Z(e)),Y(e))return[a,e];let[c,d]=ee(t,a,e,s);return[b(c),d]};function ee(r,e,t,i="brackets"){let s=/^https?:\/\//.test(e.toString()),a=s||e.toString().startsWith("/"),c=!a&&!e.toString().startsWith("#")&&!e.toString().startsWith("?"),d=e.toString().includes("?")||r==="get"&&Object.keys(t).length,m=e.toString().includes("#"),h=new URL(e.toString(),"http://localhost");return r==="get"&&Object.keys(t).length&&(h.search=$.stringify((0,Le.default)($.parse(h.search,{ignoreQueryPrefix:!0}),t),{encodeValuesOnly:!0,arrayFormat:i}),t={}),[[s?`${h.protocol}//${h.host}`:"",a?h.pathname:"",c?h.pathname.substring(1):"",d?h.search:"",m?h.hash:""].join(""),t]}function T(r){return r=new URL(r.href),r.hash="",r}var te=(r,e)=>{r.hash&&!e.hash&&T(r).href===e.href&&(e.hash=r.hash)},k=(r,e)=>T(r).href===T(e).href;var re=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 a=this.componentId;return e.clearHistory&&o.clear(),this.resolve(e.component).then(c=>{if(a!==this.componentId)return;e.scrollRegions??(e.scrollRegions=[]),e.rememberedState??(e.rememberedState={});let d=typeof window<"u"?window.location:new URL(e.url);return t=t||k(b(e.url),d),new Promise(m=>{t?o.replaceState(e,()=>m(null)):o.pushState(e,()=>m(null))}).then(()=>{let m=!this.isTheSame(e);return this.page=e,this.cleared=!1,m&&this.fireEventsFor("newComponent"),this.isFirstPageLoad&&this.fireEventsFor("firstLoad"),this.isFirstPageLoad=!1,this.swap({component:c,page:e,preserveState:s}).then(()=>{i||v.reset(e),w.fireInternalEvent("loadDeferredProps"),t||R(e)})})})}setQuietly(e,{preserveState:t=!1}={}){return this.resolve(e.component).then(i=>(this.page=e,this.cleared=!1,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+=e}remember(e){this.page.rememberedState=e}scrollRegions(e){this.page.scrollRegions=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 re;var G=typeof window>"u",ie=class{constructor(){this.rememberedState="rememberedState";this.scrollRegions="scrollRegions";this.preserveUrl=!1;this.current={};this.queue=[];this.initialState=null}remember(e,t){this.replaceState({...n.get(),rememberedState:{...n.get()?.rememberedState??{},[t]:e}})}restore(e){if(!G)return this.initialState?.[this.rememberedState]?.[e]}pushState(e,t=null){G||this.preserveUrl||(this.current=e,this.addToQueue(()=>this.getPageData(e).then(i=>{window.history.pushState({page:i,timestamp:Date.now()},"",e.url),t&&t()})))}getPageData(e){return new Promise(t=>e.encryptHistory?Ce(e).then(t):t(e))}processQueue(){let e=this.queue.shift();return e?e().then(()=>this.processQueue()):Promise.resolve()}decrypt(e=null){if(G)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?Te(e):Promise.resolve(e)}replaceState(e,t=null){n.merge(e),!(G||this.preserveUrl)&&(this.current=e,this.addToQueue(()=>this.getPageData(e).then(i=>{window.history.replaceState({page:i,timestamp:Date.now()},"",e.url),t&&t()})))}addToQueue(e){this.queue.push(e),this.processQueue()}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(){u.remove(C.key),u.remove(C.iv)}isValidState(e){return!!e.page}getAllState(){return this.current}},o=new ie;var se=class{constructor(){this.internalListeners=[]}init(){typeof window<"u"&&window.addEventListener("popstate",this.handlePopstateEvent.bind(this)),typeof document<"u"&&document.addEventListener("scroll",L(v.onScroll.bind(v),100),!0)}onGlobalEvent(e,t){let i=s=>{let a=t(s);s.cancelable&&!s.defaultPrevented&&a===!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=b(n.get().url);i.hash=window.location.hash,o.replaceState({...n.get(),url:i.href}),v.reset(n.get());return}if(o.isValidState(t)){o.decrypt(t.page).then(i=>{n.setQuietly(i,{preserveState:!1}).then(()=>{v.restore(n.get()),R(n.get())})}).catch(()=>{this.onMissingHistoryItem()});return}this.onMissingHistoryItem()}},w=new se;var ne=class{constructor(){typeof window<"u"&&window?.performance.getEntriesByType("navigation").length>0?this.type=window.performance.getEntriesByType("navigation")[0].type:this.type="navigate"}get(){return this.type}isBackForward(){return this.type==="back_forward"}isReload(){return this.type==="reload"}},oe=new ne;var B=class{static handle(){this.clearRememberedStateOnReload(),[this.handleBackForward,this.handleLocation,this.handleDefault].find(t=>t.bind(this)())}static clearRememberedStateOnReload(){oe.isReload()&&o.deleteState(o.rememberedState)}static handleBackForward(){return!oe.isBackForward()||!o.hasAnyState()?!1:(o.decrypt().then(e=>{n.set(e,{preserveScroll:!0,preserveState:!0}).then(()=>{v.restore(n.get()),R(n.get())})}).catch(()=>{w.onMissingHistoryItem()}),!0)}static handleLocation(){if(!u.exists(u.locationVisitKey))return!1;let e=u.get(u.locationVisitKey)||{};return u.remove(u.locationVisitKey),typeof window<"u"&&n.setUrlHash(window.location.hash),o.decrypt().then(()=>{let t=o.getState(o.rememberedState,{}),i=o.getState(o.scrollRegions,[]);n.remember(t),n.scrollRegions(i),n.set(n.get(),{preserveScroll:e.preserveScroll,preserveState:!0}).then(()=>{e.preserveScroll&&v.restore(n.get()),R(n.get())})}).catch(()=>{w.onMissingHistoryItem()}),!0}static handleDefault(){typeof window<"u"&&n.setUrlHash(window.location.hash),n.set(n.get(),{preserveState:!0}).then(()=>{R(n.get())})}};var K=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 K(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)}},Oe=new ae;var le=(r,e,t)=>{if(r===e)return!0;for(let i in r)if(!t.includes(i)&&r[i]!==e[i]&&!rt(r[i],e[i]))return!1;return!0},rt=(r,e)=>{switch(typeof r){case"object":return le(r,e,[]);case"function":return r.toString()===e.toString();default:return r===e}};var it={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(it))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 a=this.findCached(e);if(!e.fresh&&a&&a.staleTimestamp>Date.now())return Promise.resolve();let[c,d]=this.extractStaleValues(i),m=new Promise((h,l)=>{t({...e,onCancel:()=>{this.remove(e),e.onCancel(),l()},onError:g=>{this.remove(e),e.onError(g),l()},onPrefetching(g){e.onPrefetching(g)},onPrefetched(g,X){e.onPrefetched(g,X)},onPrefetchResponse(g){h(g)}})}).then(h=>(this.remove(e),this.cached.push({params:{...e},staleTimestamp:Date.now()+c,response:m,singleUse:i===0,timestamp:Date.now(),inFlight:!1}),this.scheduleForRemoval(e,d),this.inFlightRequests=this.inFlightRequests.filter(l=>!this.paramsAreEqual(l.params,e)),h.handlePrefetch(),h));return this.inFlightRequests.push({params:{...e},response:m,staleTimestamp:null,inFlight:!0}),m}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}paramsAreEqual(e,t){return le(e,t,["showProgress","replace","prefetch","onBefore","onStart","onProgress","onFinish","onCancel","onSuccess","onError","onPrefetched","onCancelToken","onPrefetching","async"])}},x=new ue;var de=z(require("axios"),1);var V=class{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 V(e)}data(){return this.params.method==="get"?{}: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 Ue={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 pe=class{constructor(){this.queue=[];this.processing=!1}add(e){this.queue.push(e)}async process(){return this.processing||(this.processing=!0,await this.processQueue(),this.processing=!1),Promise.resolve()}async processQueue(){let e=this.queue.shift();return e?(await e.process(),this.processQueue()):Promise.resolve()}},He=new pe,A=class{constructor(e,t,i){this.requestParams=e;this.response=t;this.originatingPage=i}static create(e,t,i){return new A(e,t,i)}async handlePrefetch(){k(this.requestParams.all().url,window.location)&&this.handle()}async handle(){return He.add(this),He.process()}async process(){if(this.requestParams.all().prefetch)return this.requestParams.all().prefetch=!1,this.requestParams.all().onPrefetched(this.response,this.requestParams.all()),xe(this.response,this.requestParams.all()),Promise.resolve();if(this.requestParams.runCallbacks(),!this.isInertiaResponse())return this.handleNonInertiaResponse();await o.processQueue(),o.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 be(t),this.requestParams.all().onError(t)}Re(n.get()),await this.requestParams.all().onSuccess(n.get()),o.preserveUrl=!1}mergeParams(e){this.requestParams.merge(e)}async handleNonInertiaResponse(){if(this.isLocationVisit()){let t=b(this.getHeader("x-inertia-location"));return te(this.requestParams.all().url,t),this.locationVisit(t)}let e={...this.response,data:this.getDataFromResponse(this.response.data)};if(we(e))return Ue.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(u.set(u.locationVisitKey,{preserveScroll:this.requestParams.all().preserveScroll===!0}),typeof window>"u")return;k(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=o.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=b(this.originatingPage.url),i=b(n.get().url);return t.origin===i.origin&&t.pathname===i.pathname}pageUrl(e){let t=b(e.url);return te(this.requestParams.all().url,t),t.href.split(t.host).pop()}mergeProps(e){this.requestParams.isPartial()&&e.component===n.get().component&&((e.mergeProps||[]).forEach(i=>{let s=e.props[i];Array.isArray(s)?e.props[i]=[...n.get().props[i]||[],...s]:typeof s=="object"&&(e.props[i]={...n.get().props[i]||[],...s})}),e.props={...n.get().props,...e.props})}async setRememberedState(e){let t=await o.getState(o.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 F=class{constructor(e,t){this.page=t;this.requestHasFinished=!1;this.requestParams=V.create(e),this.cancelToken=new AbortController}static create(e,t){return new F(e,t)}async send(){this.requestParams.onCancelToken(()=>this.cancel({cancelled:!0})),Ee(this.requestParams.all()),this.requestParams.onStart(),this.requestParams.all().prefetch&&(this.requestParams.onPrefetching(),qe(this.requestParams.all()));let e=this.requestParams.all().prefetch;return(0,de.default)({method:this.requestParams.all().method,url:T(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=A.create(this.requestParams,t,this.page),this.response.handle())).catch(t=>t?.response?(this.response=A.create(this.requestParams,t.response,this.page),this.response.handle()):Promise.reject(t)).catch(t=>{if(!de.default.isCancel(t)&&ye(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,Pe(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,Se(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 O=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 j=class{constructor(){this.syncRequestStream=new O({maxConcurrent:1,interruptible:!0});this.asyncRequestStream=new O({maxConcurrent:1/0,interruptible:!1})}init({initialPage:e,resolveComponent:t,swapComponent:i}){n.init({initialPage:e,resolveComponent:t,swapComponent:i}),B.handle(),w.init(),w.on("missingHistoryItem",()=>{typeof window<"u"&&this.visit(window.location.href,{preserveState:!0,preserveScroll:!0,replace:!0})}),w.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"){o.remember(e,t)}restore(e="default"){return o.restore(e)}on(e,t){return w.onGlobalEvent(e,t)}cancel(){this.syncRequestStream.cancelInFlight()}cancelAll(){this.asyncRequestStream.cancelInFlight(),this.syncRequestStream.cancelInFlight()}poll(e,t={},i={}){return Oe.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||!_(i))return;let a=i.async?this.asyncRequestStream:this.syncRequestStream;a.interruptInFlight(),!n.isCleared()&&!i.preserveUrl&&v.save(n.get());let c={...i,...s},d=x.get(c);d?(U(d.inFlight),x.use(d,c)):(U(!0),a.send(F.create(c,n.get())))}getCached(e,t={}){return x.findCached(this.getPrefetchParams(e,t))}flush(e,t={}){x.remove(this.getPrefetchParams(e,t))}flushAll(){x.removeAll()}getPrefetching(e,t={}){return x.findInFlight(this.getPrefetchParams(e,t))}prefetch(e,t={},{cacheFor:i}){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}),a=s.url.origin+s.url.pathname+s.url.search,c=window.location.origin+window.location.pathname+window.location.search;if(a===c)return;let d=this.getVisitEvents(t);if(d.onBefore(s)===!1||!_(s))return;H(),this.asyncRequestStream.interruptInFlight();let m={...s,...d};(()=>new Promise(l=>{let g=()=>{n.get()?l():setTimeout(g,50)};g()}))().then(()=>{x.add(m,l=>{this.asyncRequestStream.send(F.create(l,n.get()))},{cacheFor:i})})}clearHistory(){o.clear()}decryptHistory(){return o.decrypt()}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},[a,c]=ke(e,s.data,s.method,s.forceFormData,s.queryStringArrayFormat);return{cancelled:!1,completed:!1,interrupted:!1,...s,...i,url:a,data:c}}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 st={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:L(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 a=e.splice(s,1)[0];a&&!i.isEqualNode(a)&&i?.parentNode?.replaceChild(a,i)}),e.forEach(i=>document.head.appendChild(i))},1)};function he(r,e,t){let i={},s=0;function a(){let l=s+=1;return i[l]=[],l.toString()}function c(l){l===null||Object.keys(i).indexOf(l)===-1||(delete i[l],h())}function d(l,g=[]){l!==null&&Object.keys(i).indexOf(l)>-1&&(i[l]=g),h()}function m(){let l=e(""),g={...l?{title:`<title inertia="">${l}</title>`}:{}},X=Object.values(i).reduce((S,E)=>S.concat(E),[]).reduce((S,E)=>{if(E.indexOf("<")===-1)return S;if(E.indexOf("<title ")===0){let D=E.match(/(<title [^>]+>)(.*?)(<\/title>)/);return S.title=D?`${D[1]}${e(D[2])}${D[3]}`:E,S}let ge=E.match(/ inertia="[^"]+"/);return ge?S[ge[0]]=E:S[Object.keys(S).length]=E,S},g);return Object.values(X)}function h(){r?t(m()):st.update(m())}return h(),{forceUpdate:h,createProvider:function(){let l=a();return{update:g=>d(l,g),disconnect:()=>c(l)}}}}var p="nprogress",f={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("")},q=null,nt=r=>{Object.assign(f,r),f.includeCSS&&pt(f.color)},Q=r=>{let e=De();r=Be(r,f.minimum,1),q=r===1?null:r;let t=at(!e),i=t.querySelector(f.barSelector),s=f.speed,a=f.easing;t.offsetWidth,ut(c=>{let d=(()=>f.positionUsing==="translate3d"?{transition:`all ${s}ms ${a}`,transform:`translate3d(${W(r)}%,0,0)`}:f.positionUsing==="translate"?{transition:`all ${s}ms ${a}`,transform:`translate(${W(r)}%,0)`}:{marginLeft:`${W(r)}%`})();for(let m in d)i.style[m]=d[m];if(r!==1)return setTimeout(c,s);t.style.transition="none",t.style.opacity="1",t.offsetWidth,setTimeout(()=>{t.style.transition=`all ${s}ms linear`,t.style.opacity="0",setTimeout(()=>{Ge(),c()},s)},s)})},De=()=>typeof q=="number",Me=()=>{q||Q(0);let r=function(){setTimeout(function(){q&&(Ne(),r())},f.trickleSpeed)};f.trickle&&r()},ot=r=>{!r&&!q||(Ne(.3+.5*Math.random()),Q(1))},Ne=r=>{let e=q;if(e===null)return Me();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})(),Q(Be(e+r,0,.994))},at=r=>{if(lt())return document.getElementById(p);document.documentElement.classList.add(`${p}-busy`);let e=document.createElement("div");e.id=p,e.innerHTML=f.template;let t=e.querySelector(f.barSelector),i=r?"-100":W(q||0),s=$e();return t.style.transition="all 0 linear",t.style.transform=`translate3d(${i}%,0,0)`,f.showSpinner||e.querySelector(f.spinnerSelector)?.remove(),s!==document.body&&s.classList.add(`${p}-custom-parent`),s.appendChild(e),e},$e=()=>ct(f.parent)?f.parent:document.querySelector(f.parent),Ge=()=>{document.documentElement.classList.remove(`${p}-busy`),$e().classList.remove(`${p}-custom-parent`),document.getElementById(p)?.remove()},lt=()=>document.getElementById(p)!==null,ct=r=>typeof HTMLElement=="object"?r instanceof HTMLElement:r&&typeof r=="object"&&r.nodeType===1&&typeof r.nodeName=="string";function Be(r,e,t){return r<e?e:r>t?t:r}var W=r=>(-1+r)*100,ut=(()=>{let r=[],e=()=>{let t=r.shift();t&&t(e)};return t=>{r.push(t),r.length===1&&e()}})(),pt=r=>{let e=document.createElement("style");e.textContent=` | ||
"use strict";var Ke=Object.create;var M=Object.defineProperty;var je=Object.getOwnPropertyDescriptor;var We=Object.getOwnPropertyNames;var Qe=Object.getPrototypeOf,Je=Object.prototype.hasOwnProperty;var Xe=(r,e)=>{for(var t in e)M(r,t,{get:e[t],enumerable:!0})},ve=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of We(e))!Je.call(r,s)&&s!==t&&M(r,s,{get:()=>e[s],enumerable:!(i=je(e,s))||i.enumerable});return r};var z=(r,e,t)=>(t=r!=null?Ke(Qe(r)):{},ve(e||!r||!r.__esModule?M(t,"default",{value:r,enumerable:!0}):t,r)),ze=r=>ve(M({},"__esModule",{value:!0}),r);var yt={};Xe(yt,{createHeadManager:()=>he,hideProgress:()=>H,hrefToUrl:()=>b,mergeDataIntoQueryString:()=>ee,revealProgress:()=>U,router:()=>bt,setupProgress:()=>me,shouldIntercept:()=>fe,urlWithoutHash:()=>T});module.exports=ze(yt);function L(r,e){let t;return function(...i){clearTimeout(t),t=setTimeout(()=>r.apply(this,i),e)}}function P(r,e){return document.dispatchEvent(new CustomEvent(`inertia:${r}`,e))}var _=r=>P("before",{cancelable:!0,detail:{visit:r}}),be=r=>P("error",{detail:{errors:r}}),ye=r=>P("exception",{cancelable:!0,detail:{exception:r}}),Pe=r=>P("finish",{detail:{visit:r}}),we=r=>P("invalid",{cancelable:!0,detail:{response:r}}),R=r=>P("navigate",{detail:{page:r}}),Se=r=>P("progress",{detail:{progress:r}}),Ee=r=>P("start",{detail:{visit:r}}),Re=r=>P("success",{detail:{page:r}}),xe=(r,e)=>P("prefetched",{detail:{fetchedAt:Date.now(),response:r.data,visit:e}}),qe=r=>P("prefetching",{detail:{visit:r}});var u=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()}};u.locationVisitKey="inertiaLocationVisit";var Ce=async r=>{if(typeof window>"u")throw new Error("Unable to encrypt history");let e=Ae(),t=await Ve(),i=await tt(t);if(!i)throw new Error("Unable to encrypt history");return await _e(e,i,r)},C={key:"historyKey",iv:"historyIv"},Te=async r=>{let e=Ae(),t=await Ve();if(!t)throw new Error("Unable to decrypt history");return await Ye(e,t,r)},_e=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),a=new Uint8Array(s.length*3),c=i.encodeInto(s,a);return window.crypto.subtle.encrypt({name:"AES-GCM",iv:r},e,a.subarray(0,c.written))},Ye=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))},Ae=()=>{let r=u.get(C.iv);if(r)return new Uint8Array(r);let e=window.crypto.getRandomValues(new Uint8Array(12));return u.set(C.iv,Array.from(e)),e},Ze=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"]),et=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);u.set(C.key,Array.from(new Uint8Array(e)))},tt=async r=>{if(r)return r;let e=await Ze();return e?(await et(e),e):null},Ve=async()=>{let r=u.get(C.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(e){o.replaceState({...e,scrollRegions:Array.from(this.regions()).map(t=>({top:t.scrollTop,left:t.scrollLeft}))})}static regions(){return document.querySelectorAll("[scroll-region]")}static reset(e){typeof window<"u"&&window.scrollTo(0,0),this.regions().forEach(t=>{typeof t.scrollTo=="function"?t.scrollTo(0,0):(t.scrollTop=0,t.scrollLeft=0)}),this.save(e),window.location.hash&&setTimeout(()=>document.getElementById(window.location.hash.slice(1))?.scrollIntoView())}static restore(e){e.scrollRegions&&this.regions().forEach((t,i)=>{let s=e.scrollRegions[i];s&&(typeof t.scrollTo=="function"?t.scrollTo(s.left,s.top):(t.scrollTop=s.top,t.scrollLeft=s.left))})}static onScroll(e){let t=e.target;typeof t.hasAttribute=="function"&&t.hasAttribute("scroll-region")&&this.save(n.get())}};var Le=z(require("deepmerge"),1),$=z(require("qs"),1);function N(r){return r instanceof File||r instanceof Blob||r instanceof FileList&&r.length>0||r instanceof FormData&&Array.from(r.values()).some(e=>N(e))||typeof r=="object"&&r!==null&&Object.values(r).some(e=>N(e))}var Y=r=>r instanceof FormData;function Z(r,e=new FormData,t=null){r=r||{};for(let i in r)Object.prototype.hasOwnProperty.call(r,i)&&Ie(e,Fe(t,i),r[i]);return e}function Fe(r,e){return r?r+"["+e+"]":e}function Ie(r,e,t){if(Array.isArray(t))return Array.from(t.keys()).forEach(i=>Ie(r,Fe(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,"");Z(t,r,e)}function b(r){return new URL(r.toString(),typeof window>"u"?void 0:window.location.toString())}var ke=(r,e,t,i,s)=>{let a=typeof r=="string"?b(r):r;if((N(e)||i)&&!Y(e)&&(e=Z(e)),Y(e))return[a,e];let[c,d]=ee(t,a,e,s);return[b(c),d]};function ee(r,e,t,i="brackets"){let s=/^https?:\/\//.test(e.toString()),a=s||e.toString().startsWith("/"),c=!a&&!e.toString().startsWith("#")&&!e.toString().startsWith("?"),d=e.toString().includes("?")||r==="get"&&Object.keys(t).length,m=e.toString().includes("#"),h=new URL(e.toString(),"http://localhost");return r==="get"&&Object.keys(t).length&&(h.search=$.stringify((0,Le.default)($.parse(h.search,{ignoreQueryPrefix:!0}),t),{encodeValuesOnly:!0,arrayFormat:i}),t={}),[[s?`${h.protocol}//${h.host}`:"",a?h.pathname:"",c?h.pathname.substring(1):"",d?h.search:"",m?h.hash:""].join(""),t]}function T(r){return r=new URL(r.href),r.hash="",r}var te=(r,e)=>{r.hash&&!e.hash&&T(r).href===e.href&&(e.hash=r.hash)},k=(r,e)=>T(r).href===T(e).href;var re=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 a=this.componentId;return e.clearHistory&&o.clear(),this.resolve(e.component).then(c=>{if(a!==this.componentId)return;e.scrollRegions??(e.scrollRegions=[]),e.rememberedState??(e.rememberedState={});let d=typeof window<"u"?window.location:new URL(e.url);return t=t||k(b(e.url),d),new Promise(m=>{t?o.replaceState(e,()=>m(null)):o.pushState(e,()=>m(null))}).then(()=>{let m=!this.isTheSame(e);return this.page=e,this.cleared=!1,m&&this.fireEventsFor("newComponent"),this.isFirstPageLoad&&this.fireEventsFor("firstLoad"),this.isFirstPageLoad=!1,this.swap({component:c,page:e,preserveState:s}).then(()=>{i||v.reset(e),w.fireInternalEvent("loadDeferredProps"),t||R(e)})})})}setQuietly(e,{preserveState:t=!1}={}){return this.resolve(e.component).then(i=>(this.page=e,this.cleared=!1,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+=e}remember(e){this.page.rememberedState=e}scrollRegions(e){this.page.scrollRegions=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 re;var G=typeof window>"u",ie=class{constructor(){this.rememberedState="rememberedState";this.scrollRegions="scrollRegions";this.preserveUrl=!1;this.current={};this.queue=[];this.initialState=null}remember(e,t){this.replaceState({...n.get(),rememberedState:{...n.get()?.rememberedState??{},[t]:e}})}restore(e){if(!G)return this.initialState?.[this.rememberedState]?.[e]}pushState(e,t=null){G||this.preserveUrl||(this.current=e,this.addToQueue(()=>this.getPageData(e).then(i=>{window.history.pushState({page:i,timestamp:Date.now()},"",e.url),t&&t()})))}getPageData(e){return new Promise(t=>e.encryptHistory?Ce(e).then(t):t(e))}processQueue(){let e=this.queue.shift();return e?e().then(()=>this.processQueue()):Promise.resolve()}decrypt(e=null){if(G)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?Te(e):Promise.resolve(e)}replaceState(e,t=null){n.merge(e),!(G||this.preserveUrl)&&(this.current=e,this.addToQueue(()=>this.getPageData(e).then(i=>{window.history.replaceState({page:i,timestamp:Date.now()},"",e.url),t&&t()})))}addToQueue(e){this.queue.push(e),this.processQueue()}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(){u.remove(C.key),u.remove(C.iv)}isValidState(e){return!!e.page}getAllState(){return this.current}},o=new ie;var se=class{constructor(){this.internalListeners=[]}init(){typeof window<"u"&&window.addEventListener("popstate",this.handlePopstateEvent.bind(this)),typeof document<"u"&&document.addEventListener("scroll",L(v.onScroll.bind(v),100),!0)}onGlobalEvent(e,t){let i=s=>{let a=t(s);s.cancelable&&!s.defaultPrevented&&a===!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=b(n.get().url);i.hash=window.location.hash,o.replaceState({...n.get(),url:i.href}),v.reset(n.get());return}if(o.isValidState(t)){o.decrypt(t.page).then(i=>{n.setQuietly(i,{preserveState:!1}).then(()=>{v.restore(n.get()),R(n.get())})}).catch(()=>{this.onMissingHistoryItem()});return}this.onMissingHistoryItem()}},w=new se;var ne=class{constructor(){typeof window<"u"&&window?.performance.getEntriesByType("navigation").length>0?this.type=window.performance.getEntriesByType("navigation")[0].type:this.type="navigate"}get(){return this.type}isBackForward(){return this.type==="back_forward"}isReload(){return this.type==="reload"}},oe=new ne;var B=class{static handle(){this.clearRememberedStateOnReload(),[this.handleBackForward,this.handleLocation,this.handleDefault].find(t=>t.bind(this)())}static clearRememberedStateOnReload(){oe.isReload()&&o.deleteState(o.rememberedState)}static handleBackForward(){return!oe.isBackForward()||!o.hasAnyState()?!1:(o.decrypt().then(e=>{n.set(e,{preserveScroll:!0,preserveState:!0}).then(()=>{v.restore(n.get()),R(n.get())})}).catch(()=>{w.onMissingHistoryItem()}),!0)}static handleLocation(){if(!u.exists(u.locationVisitKey))return!1;let e=u.get(u.locationVisitKey)||{};return u.remove(u.locationVisitKey),typeof window<"u"&&n.setUrlHash(window.location.hash),o.decrypt().then(()=>{let t=o.getState(o.rememberedState,{}),i=o.getState(o.scrollRegions,[]);n.remember(t),n.scrollRegions(i),n.set(n.get(),{preserveScroll:e.preserveScroll,preserveState:!0}).then(()=>{e.preserveScroll&&v.restore(n.get()),R(n.get())})}).catch(()=>{w.onMissingHistoryItem()}),!0}static handleDefault(){typeof window<"u"&&n.setUrlHash(window.location.hash),n.set(n.get(),{preserveState:!0}).then(()=>{R(n.get())})}};var K=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 K(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)}},Oe=new ae;var le=(r,e,t)=>{if(r===e)return!0;for(let i in r)if(!t.includes(i)&&r[i]!==e[i]&&!rt(r[i],e[i]))return!1;return!0},rt=(r,e)=>{switch(typeof r){case"object":return le(r,e,[]);case"function":return r.toString()===e.toString();default:return r===e}};var it={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(it))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 a=this.findCached(e);if(!e.fresh&&a&&a.staleTimestamp>Date.now())return Promise.resolve();let[c,d]=this.extractStaleValues(i),m=new Promise((h,l)=>{t({...e,onCancel:()=>{this.remove(e),e.onCancel(),l()},onError:g=>{this.remove(e),e.onError(g),l()},onPrefetching(g){e.onPrefetching(g)},onPrefetched(g,X){e.onPrefetched(g,X)},onPrefetchResponse(g){h(g)}})}).then(h=>(this.remove(e),this.cached.push({params:{...e},staleTimestamp:Date.now()+c,response:m,singleUse:i===0,timestamp:Date.now(),inFlight:!1}),this.scheduleForRemoval(e,d),this.inFlightRequests=this.inFlightRequests.filter(l=>!this.paramsAreEqual(l.params,e)),h.handlePrefetch(),h));return this.inFlightRequests.push({params:{...e},response:m,staleTimestamp:null,inFlight:!0}),m}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}paramsAreEqual(e,t){return le(e,t,["showProgress","replace","prefetch","onBefore","onStart","onProgress","onFinish","onCancel","onSuccess","onError","onPrefetched","onCancelToken","onPrefetching","async"])}},x=new ue;var de=z(require("axios"),1);var F=class{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 F(e)}data(){return this.params.method==="get"?{}: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 Ue={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 pe=class{constructor(){this.queue=[];this.processing=!1}add(e){this.queue.push(e)}async process(){return this.processing||(this.processing=!0,await this.processQueue(),this.processing=!1),Promise.resolve()}async processQueue(){let e=this.queue.shift();return e?(await e.process(),this.processQueue()):Promise.resolve()}},He=new pe,A=class{constructor(e,t,i){this.requestParams=e;this.response=t;this.originatingPage=i}static create(e,t,i){return new A(e,t,i)}async handlePrefetch(){k(this.requestParams.all().url,window.location)&&this.handle()}async handle(){return He.add(this),He.process()}async process(){if(this.requestParams.all().prefetch)return this.requestParams.all().prefetch=!1,this.requestParams.all().onPrefetched(this.response,this.requestParams.all()),xe(this.response,this.requestParams.all()),Promise.resolve();if(this.requestParams.runCallbacks(),!this.isInertiaResponse())return this.handleNonInertiaResponse();await o.processQueue(),o.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 be(t),this.requestParams.all().onError(t)}Re(n.get()),await this.requestParams.all().onSuccess(n.get()),o.preserveUrl=!1}mergeParams(e){this.requestParams.merge(e)}async handleNonInertiaResponse(){if(this.isLocationVisit()){let t=b(this.getHeader("x-inertia-location"));return te(this.requestParams.all().url,t),this.locationVisit(t)}let e={...this.response,data:this.getDataFromResponse(this.response.data)};if(we(e))return Ue.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(u.set(u.locationVisitKey,{preserveScroll:this.requestParams.all().preserveScroll===!0}),typeof window>"u")return;k(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=o.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=b(this.originatingPage.url),i=b(n.get().url);return t.origin===i.origin&&t.pathname===i.pathname}pageUrl(e){let t=b(e.url);return te(this.requestParams.all().url,t),t.href.split(t.host).pop()}mergeProps(e){this.requestParams.isPartial()&&e.component===n.get().component&&((e.mergeProps||[]).forEach(i=>{let s=e.props[i];Array.isArray(s)?e.props[i]=[...n.get().props[i]||[],...s]:typeof s=="object"&&(e.props[i]={...n.get().props[i]||[],...s})}),e.props={...n.get().props,...e.props})}async setRememberedState(e){let t=await o.getState(o.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 V=class{constructor(e,t){this.page=t;this.requestHasFinished=!1;this.requestParams=F.create(e),this.cancelToken=new AbortController}static create(e,t){return new V(e,t)}async send(){this.requestParams.onCancelToken(()=>this.cancel({cancelled:!0})),Ee(this.requestParams.all()),this.requestParams.onStart(),this.requestParams.all().prefetch&&(this.requestParams.onPrefetching(),qe(this.requestParams.all()));let e=this.requestParams.all().prefetch;return(0,de.default)({method:this.requestParams.all().method,url:T(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=A.create(this.requestParams,t,this.page),this.response.handle())).catch(t=>t?.response?(this.response=A.create(this.requestParams,t.response,this.page),this.response.handle()):Promise.reject(t)).catch(t=>{if(!de.default.isCancel(t)&&ye(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,Pe(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,Se(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 O=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 j=class{constructor(){this.syncRequestStream=new O({maxConcurrent:1,interruptible:!0});this.asyncRequestStream=new O({maxConcurrent:1/0,interruptible:!1})}init({initialPage:e,resolveComponent:t,swapComponent:i}){n.init({initialPage:e,resolveComponent:t,swapComponent:i}),B.handle(),w.init(),w.on("missingHistoryItem",()=>{typeof window<"u"&&this.visit(window.location.href,{preserveState:!0,preserveScroll:!0,replace:!0})}),w.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"){o.remember(e,t)}restore(e="default"){return o.restore(e)}on(e,t){return w.onGlobalEvent(e,t)}cancel(){this.syncRequestStream.cancelInFlight()}cancelAll(){this.asyncRequestStream.cancelInFlight(),this.syncRequestStream.cancelInFlight()}poll(e,t={},i={}){return Oe.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||!_(i))return;let a=i.async?this.asyncRequestStream:this.syncRequestStream;a.interruptInFlight(),!n.isCleared()&&!i.preserveUrl&&v.save(n.get());let c={...i,...s},d=x.get(c);d?(U(d.inFlight),x.use(d,c)):(U(!0),a.send(V.create(c,n.get())))}getCached(e,t={}){return x.findCached(this.getPrefetchParams(e,t))}flush(e,t={}){x.remove(this.getPrefetchParams(e,t))}flushAll(){x.removeAll()}getPrefetching(e,t={}){return x.findInFlight(this.getPrefetchParams(e,t))}prefetch(e,t={},{cacheFor:i}){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}),a=s.url.origin+s.url.pathname+s.url.search,c=window.location.origin+window.location.pathname+window.location.search;if(a===c)return;let d=this.getVisitEvents(t);if(d.onBefore(s)===!1||!_(s))return;H(),this.asyncRequestStream.interruptInFlight();let m={...s,...d};(()=>new Promise(l=>{let g=()=>{n.get()?l():setTimeout(g,50)};g()}))().then(()=>{x.add(m,l=>{this.asyncRequestStream.send(V.create(l,n.get()))},{cacheFor:i})})}clearHistory(){o.clear()}decryptHistory(){return o.decrypt()}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},[a,c]=ke(e,s.data,s.method,s.forceFormData,s.queryStringArrayFormat);return{cancelled:!1,completed:!1,interrupted:!1,...s,...i,url:a,data:c}}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 st={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:L(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 a=e.splice(s,1)[0];a&&!i.isEqualNode(a)&&i?.parentNode?.replaceChild(a,i)}),e.forEach(i=>document.head.appendChild(i))},1)};function he(r,e,t){let i={},s=0;function a(){let l=s+=1;return i[l]=[],l.toString()}function c(l){l===null||Object.keys(i).indexOf(l)===-1||(delete i[l],h())}function d(l,g=[]){l!==null&&Object.keys(i).indexOf(l)>-1&&(i[l]=g),h()}function m(){let l=e(""),g={...l?{title:`<title inertia="">${l}</title>`}:{}},X=Object.values(i).reduce((S,E)=>S.concat(E),[]).reduce((S,E)=>{if(E.indexOf("<")===-1)return S;if(E.indexOf("<title ")===0){let D=E.match(/(<title [^>]+>)(.*?)(<\/title>)/);return S.title=D?`${D[1]}${e(D[2])}${D[3]}`:E,S}let ge=E.match(/ inertia="[^"]+"/);return ge?S[ge[0]]=E:S[Object.keys(S).length]=E,S},g);return Object.values(X)}function h(){r?t(m()):st.update(m())}return h(),{forceUpdate:h,createProvider:function(){let l=a();return{update:g=>d(l,g),disconnect:()=>c(l)}}}}var p="nprogress",f={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("")},q=null,nt=r=>{Object.assign(f,r),f.includeCSS&&pt(f.color)},Q=r=>{let e=De();r=Be(r,f.minimum,1),q=r===1?null:r;let t=at(!e),i=t.querySelector(f.barSelector),s=f.speed,a=f.easing;t.offsetWidth,ut(c=>{let d=(()=>f.positionUsing==="translate3d"?{transition:`all ${s}ms ${a}`,transform:`translate3d(${W(r)}%,0,0)`}:f.positionUsing==="translate"?{transition:`all ${s}ms ${a}`,transform:`translate(${W(r)}%,0)`}:{marginLeft:`${W(r)}%`})();for(let m in d)i.style[m]=d[m];if(r!==1)return setTimeout(c,s);t.style.transition="none",t.style.opacity="1",t.offsetWidth,setTimeout(()=>{t.style.transition=`all ${s}ms linear`,t.style.opacity="0",setTimeout(()=>{Ge(),c()},s)},s)})},De=()=>typeof q=="number",Me=()=>{q||Q(0);let r=function(){setTimeout(function(){q&&(Ne(),r())},f.trickleSpeed)};f.trickle&&r()},ot=r=>{!r&&!q||(Ne(.3+.5*Math.random()),Q(1))},Ne=r=>{let e=q;if(e===null)return Me();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})(),Q(Be(e+r,0,.994))},at=r=>{if(lt())return document.getElementById(p);document.documentElement.classList.add(`${p}-busy`);let e=document.createElement("div");e.id=p,e.innerHTML=f.template;let t=e.querySelector(f.barSelector),i=r?"-100":W(q||0),s=$e();return t.style.transition="all 0 linear",t.style.transform=`translate3d(${i}%,0,0)`,f.showSpinner||e.querySelector(f.spinnerSelector)?.remove(),s!==document.body&&s.classList.add(`${p}-custom-parent`),s.appendChild(e),e},$e=()=>ct(f.parent)?f.parent:document.querySelector(f.parent),Ge=()=>{document.documentElement.classList.remove(`${p}-busy`),$e().classList.remove(`${p}-custom-parent`),document.getElementById(p)?.remove()},lt=()=>document.getElementById(p)!==null,ct=r=>typeof HTMLElement=="object"?r instanceof HTMLElement:r&&typeof r=="object"&&r.nodeType===1&&typeof r.nodeName=="string";function Be(r,e,t){return r<e?e:r>t?t:r}var W=r=>(-1+r)*100,ut=(()=>{let r=[],e=()=>{let t=r.shift();t&&t(e)};return t=>{r.push(t),r.length===1&&e()}})(),pt=r=>{let e=document.createElement("style");e.textContent=` | ||
#${p} { | ||
@@ -3,0 +3,0 @@ pointer-events: none; |
{ | ||
"name": "@inertiajs/core", | ||
"version": "2.0.0-beta.3", | ||
"version": "2.0.0", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "description": "A framework for creating server-driven single page apps.", |
import { RequestStream } from './requestStream'; | ||
import { ActiveVisit, GlobalEvent, GlobalEventNames, GlobalEventResult, InFlightPrefetch, Page, PendingVisit, PendingVisitOptions, PollOptions, PrefetchedResponse, PrefetchOptions, ReloadOptions, RequestPayload, RouterInitParams, Visit, VisitCallbacks, VisitHelperOptions, VisitOptions } from './types'; | ||
import { ActiveVisit, ClientSideVisitOptions, GlobalEvent, GlobalEventNames, GlobalEventResult, InFlightPrefetch, Page, PendingVisit, PendingVisitOptions, PollOptions, PrefetchedResponse, PrefetchOptions, ReloadOptions, RequestPayload, RouterInitParams, Visit, VisitCallbacks, VisitHelperOptions, VisitOptions } from './types'; | ||
export declare class Router { | ||
@@ -30,2 +30,7 @@ protected syncRequestStream: RequestStream; | ||
decryptHistory(): Promise<Page>; | ||
replace(params: ClientSideVisitOptions): void; | ||
push(params: ClientSideVisitOptions): void; | ||
protected clientVisit(params: ClientSideVisitOptions, { replace }?: { | ||
replace?: boolean; | ||
}): void; | ||
protected getPrefetchParams(href: string | URL, options: VisitOptions): ActiveVisit; | ||
@@ -32,0 +37,0 @@ protected getPendingVisit(href: string | URL, options: VisitOptions, pendingVisitOptions?: Partial<PendingVisitOptions>): PendingVisit; |
@@ -38,2 +38,11 @@ import { AxiosProgressEvent, AxiosResponse } from 'axios'; | ||
} | ||
export interface ClientSideVisitOptions { | ||
component?: Page['component']; | ||
url?: Page['url']; | ||
props?: ((props: Page['props']) => Page['props']) | Page['props']; | ||
clearHistory?: Page['clearHistory']; | ||
encryptHistory?: Page['encryptHistory']; | ||
preserveScroll?: VisitOptions['preserveScroll']; | ||
preserveState?: VisitOptions['preserveState']; | ||
} | ||
export type PageResolver = (name: string) => Component; | ||
@@ -40,0 +49,0 @@ export type PageHandler = ({ component, page, preserveState, }: { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
379172
1061
2
2