var ps=e=>{throw TypeError(e)};var ke=(e,t,s)=>t.has(e)||ps("Cannot "+s);var h=(e,t,s)=>(ke(e,t,"read from private field"),s?s.call(e):t.get(e)),_=(e,t,s)=>t.has(e)?ps("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,s),P=(e,t,s,i)=>(ke(e,t,"write to private field"),i?i.call(e,s):t.set(e,s),s),L=(e,t,s)=>(ke(e,t,"access private method"),s);var Se=(e,t,s,i)=>({set _(r){P(e,t,r,s)},get _(){return h(e,t,i)}});import{a as R,C as F,L as Ae,N as yi,O as et,I as gi}from"./vendor_1_react-CXEjNhpI.js";var ge=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},ae=typeof window>"u"||"Deno"in globalThis;function ut(){}function bi(e,t){return typeof e=="function"?e(t):e}function qe(e){return typeof e=="number"&&e>=0&&e!==1/0}function Ks(e,t){return Math.max(e+(t||0)-Date.now(),0)}function qt(e,t){return typeof e=="function"?e(t):e}function ht(e,t){return typeof e=="function"?e(t):e}function ms(e,t){const{type:s="all",exact:i,fetchStatus:r,predicate:n,queryKey:a,stale:o}=e;if(a){if(i){if(t.queryHash!==os(a,t.options))return!1}else if(!fe(t.queryKey,a))return!1}if(s!=="all"){const c=t.isActive();if(s==="active"&&!c||s==="inactive"&&c)return!1}return!(typeof o=="boolean"&&t.isStale()!==o||r&&r!==t.state.fetchStatus||n&&!n(t))}function vs(e,t){const{exact:s,status:i,predicate:r,mutationKey:n}=e;if(n){if(!t.options.mutationKey)return!1;if(s){if(de(t.options.mutationKey)!==de(n))return!1}else if(!fe(t.options.mutationKey,n))return!1}return!(i&&t.state.status!==i||r&&!r(t))}function os(e,t){return((t==null?void 0:t.queryKeyHashFn)||de)(e)}function de(e){return JSON.stringify(e,(t,s)=>He(s)?Object.keys(s).sort().reduce((i,r)=>(i[r]=s[r],i),{}):s)}function fe(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?!Object.keys(t).some(s=>!fe(e[s],t[s])):!1}function Ns(e,t){if(e===t)return e;const s=ys(e)&&ys(t);if(s||He(e)&&He(t)){const i=s?e:Object.keys(e),r=i.length,n=s?t:Object.keys(t),a=n.length,o=s?[]:{};let c=0;for(let l=0;l{setTimeout(t,e)})}function We(e,t,s){return typeof s.structuralSharing=="function"?s.structuralSharing(e,t):s.structuralSharing!==!1?Ns(e,t):t}function Mi(e,t,s=0){const i=[...e,t];return s&&i.length>s?i.slice(1):i}function Pi(e,t,s=0){const i=[t,...e];return s&&i.length>s?i.slice(0,-1):i}var qs=Symbol();function zs(e,t){return!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===qs?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}var Vt,Ft,Ht,Is,wi=(Is=class extends ge{constructor(){super();_(this,Vt);_(this,Ft);_(this,Ht);P(this,Ht,t=>{if(!ae&&window.addEventListener){const s=()=>t();return window.addEventListener("visibilitychange",s,!1),()=>{window.removeEventListener("visibilitychange",s)}}})}onSubscribe(){h(this,Ft)||this.setEventListener(h(this,Ht))}onUnsubscribe(){var t;this.hasListeners()||((t=h(this,Ft))==null||t.call(this),P(this,Ft,void 0))}setEventListener(t){var s;P(this,Ht,t),(s=h(this,Ft))==null||s.call(this),P(this,Ft,t(i=>{typeof i=="boolean"?this.setFocused(i):this.onFocus()}))}setFocused(t){h(this,Vt)!==t&&(P(this,Vt,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(s=>{s(t)})}isFocused(){var t;return typeof h(this,Vt)=="boolean"?h(this,Vt):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},Vt=new WeakMap,Ft=new WeakMap,Ht=new WeakMap,Is),ls=new wi,Wt,_t,Gt,Vs,Fi=(Vs=class extends ge{constructor(){super();_(this,Wt,!0);_(this,_t);_(this,Gt);P(this,Gt,t=>{if(!ae&&window.addEventListener){const s=()=>t(!0),i=()=>t(!1);return window.addEventListener("online",s,!1),window.addEventListener("offline",i,!1),()=>{window.removeEventListener("online",s),window.removeEventListener("offline",i)}}})}onSubscribe(){h(this,_t)||this.setEventListener(h(this,Gt))}onUnsubscribe(){var t;this.hasListeners()||((t=h(this,_t))==null||t.call(this),P(this,_t,void 0))}setEventListener(t){var s;P(this,Gt,t),(s=h(this,_t))==null||s.call(this),P(this,_t,t(this.setOnline.bind(this)))}setOnline(t){h(this,Wt)!==t&&(P(this,Wt,t),this.listeners.forEach(i=>{i(t)}))}isOnline(){return h(this,Wt)}},Wt=new WeakMap,_t=new WeakMap,Gt=new WeakMap,Vs),Ce=new Fi;function _i(e){return Math.min(1e3*2**e,3e4)}function Hs(e){return(e??"online")==="online"?Ce.isOnline():!0}var Ws=class{constructor(e){this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function Be(e){return e instanceof Ws}function Gs(e){let t=!1,s=0,i=!1,r,n,a;const o=new Promise((M,S)=>{n=M,a=S}),c=M=>{var S;i||(v(new Ws(M)),(S=e.abort)==null||S.call(e))},l=()=>{t=!0},u=()=>{t=!1},d=()=>ls.isFocused()&&(e.networkMode==="always"||Ce.isOnline())&&e.canRun(),f=()=>Hs(e.networkMode)&&e.canRun(),p=M=>{var S;i||(i=!0,(S=e.onSuccess)==null||S.call(e,M),r==null||r(),n(M))},v=M=>{var S;i||(i=!0,(S=e.onError)==null||S.call(e,M),r==null||r(),a(M))},m=()=>new Promise(M=>{var S;r=y=>{(i||d())&&M(y)},(S=e.onPause)==null||S.call(e)}).then(()=>{var M;r=void 0,i||(M=e.onContinue)==null||M.call(e)}),g=()=>{if(i)return;let M;const S=s===0?e.initialPromise:void 0;try{M=S??e.fn()}catch(y){M=Promise.reject(y)}Promise.resolve(M).then(p).catch(y=>{var b;if(i)return;const w=e.retry??(ae?0:3),C=e.retryDelay??_i,O=typeof C=="function"?C(s,y):C,E=w===!0||typeof w=="number"&&sd()?void 0:m()).then(()=>{t?v(y):g()})})};return{promise:o,cancel:c,continue:()=>(r==null||r(),o),cancelRetry:l,continueRetry:u,canStart:f,start:()=>(f()?g():m().then(g),o)}}function Ci(){let e=[],t=0,s=f=>{f()},i=f=>{f()},r=f=>setTimeout(f,0);const n=f=>{r=f},a=f=>{let p;t++;try{p=f()}finally{t--,t||l()}return p},o=f=>{t?e.push(f):r(()=>{s(f)})},c=f=>(...p)=>{o(()=>{f(...p)})},l=()=>{const f=e;e=[],f.length&&r(()=>{i(()=>{f.forEach(p=>{s(p)})})})};return{batch:a,batchCalls:c,schedule:o,setNotifyFunction:f=>{s=f},setBatchNotifyFunction:f=>{i=f},setScheduler:n}}var z=Ci(),jt,js,Js=(js=class{constructor(){_(this,jt)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),qe(this.gcTime)&&P(this,jt,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(ae?1/0:5*60*1e3))}clearGcTimeout(){h(this,jt)&&(clearTimeout(h(this,jt)),P(this,jt,void 0))}},jt=new WeakMap,js),Jt,Xt,lt,G,pe,Dt,ct,St,Ds,Ri=(Ds=class extends Js{constructor(t){super();_(this,ct);_(this,Jt);_(this,Xt);_(this,lt);_(this,G);_(this,pe);_(this,Dt);P(this,Dt,!1),P(this,pe,t.defaultOptions),this.setOptions(t.options),this.observers=[],P(this,lt,t.cache),this.queryKey=t.queryKey,this.queryHash=t.queryHash,P(this,Jt,t.state||Ei(this.options)),this.state=h(this,Jt),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=h(this,G))==null?void 0:t.promise}setOptions(t){this.options={...h(this,pe),...t},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&h(this,lt).remove(this)}setData(t,s){const i=We(this.state.data,t,this.options);return L(this,ct,St).call(this,{data:i,type:"success",dataUpdatedAt:s==null?void 0:s.updatedAt,manual:s==null?void 0:s.manual}),i}setState(t,s){L(this,ct,St).call(this,{type:"setState",state:t,setStateOptions:s})}cancel(t){var i,r;const s=(i=h(this,G))==null?void 0:i.promise;return(r=h(this,G))==null||r.cancel(t),s?s.then(ut).catch(ut):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(h(this,Jt))}isActive(){return this.observers.some(t=>ht(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0&&!this.isActive()}isStale(){return this.state.isInvalidated?!0:this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0}isStaleByTime(t=0){return this.state.isInvalidated||this.state.data===void 0||!Ks(this.state.dataUpdatedAt,t)}onFocus(){var s;const t=this.observers.find(i=>i.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(s=h(this,G))==null||s.continue()}onOnline(){var s;const t=this.observers.find(i=>i.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(s=h(this,G))==null||s.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),h(this,lt).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(s=>s!==t),this.observers.length||(h(this,G)&&(h(this,Dt)?h(this,G).cancel({revert:!0}):h(this,G).cancelRetry()),this.scheduleGc()),h(this,lt).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||L(this,ct,St).call(this,{type:"invalidate"})}fetch(t,s){var c,l,u;if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&(s!=null&&s.cancelRefetch))this.cancel({silent:!0});else if(h(this,G))return h(this,G).continueRetry(),h(this,G).promise}if(t&&this.setOptions(t),!this.options.queryFn){const d=this.observers.find(f=>f.options.queryFn);d&&this.setOptions(d.options)}const i=new AbortController,r=d=>{Object.defineProperty(d,"signal",{enumerable:!0,get:()=>(P(this,Dt,!0),i.signal)})},n=()=>{const d=zs(this.options,s),f={queryKey:this.queryKey,meta:this.meta};return r(f),P(this,Dt,!1),this.options.persister?this.options.persister(d,f,this):d(f)},a={fetchOptions:s,options:this.options,queryKey:this.queryKey,state:this.state,fetchFn:n};r(a),(c=this.options.behavior)==null||c.onFetch(a,this),P(this,Xt,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((l=a.fetchOptions)==null?void 0:l.meta))&&L(this,ct,St).call(this,{type:"fetch",meta:(u=a.fetchOptions)==null?void 0:u.meta});const o=d=>{var f,p,v,m;Be(d)&&d.silent||L(this,ct,St).call(this,{type:"error",error:d}),Be(d)||((p=(f=h(this,lt).config).onError)==null||p.call(f,d,this),(m=(v=h(this,lt).config).onSettled)==null||m.call(v,this.state.data,d,this)),this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1};return P(this,G,Gs({initialPromise:s==null?void 0:s.initialPromise,fn:a.fetchFn,abort:i.abort.bind(i),onSuccess:d=>{var f,p,v,m;if(d===void 0){o(new Error(`${this.queryHash} data is undefined`));return}this.setData(d),(p=(f=h(this,lt).config).onSuccess)==null||p.call(f,d,this),(m=(v=h(this,lt).config).onSettled)==null||m.call(v,d,this.state.error,this),this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1},onError:o,onFail:(d,f)=>{L(this,ct,St).call(this,{type:"failed",failureCount:d,error:f})},onPause:()=>{L(this,ct,St).call(this,{type:"pause"})},onContinue:()=>{L(this,ct,St).call(this,{type:"continue"})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0})),h(this,G).start()}},Jt=new WeakMap,Xt=new WeakMap,lt=new WeakMap,G=new WeakMap,pe=new WeakMap,Dt=new WeakMap,ct=new WeakSet,St=function(t){const s=i=>{switch(t.type){case"failed":return{...i,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...i,fetchStatus:"paused"};case"continue":return{...i,fetchStatus:"fetching"};case"fetch":return{...i,...Xs(i.data,this.options),fetchMeta:t.meta??null};case"success":return{...i,data:t.data,dataUpdateCount:i.dataUpdateCount+1,dataUpdatedAt:t.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const r=t.error;return Be(r)&&r.revert&&h(this,Xt)?{...h(this,Xt),fetchStatus:"idle"}:{...i,error:r,errorUpdateCount:i.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:i.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:"idle",status:"error"};case"invalidate":return{...i,isInvalidated:!0};case"setState":return{...i,...t.state}}};this.state=s(this.state),z.batch(()=>{this.observers.forEach(i=>{i.onQueryUpdate()}),h(this,lt).notify({query:this,type:"updated",action:t})})},Ds);function Xs(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Hs(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function Ei(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,s=t!==void 0,i=s?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:s?i??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:s?"success":"pending",fetchStatus:"idle"}}var mt,ks,Li=(ks=class extends ge{constructor(t={}){super();_(this,mt);this.config=t,P(this,mt,new Map)}build(t,s,i){const r=s.queryKey,n=s.queryHash??os(r,s);let a=this.get(n);return a||(a=new Ri({cache:this,queryKey:r,queryHash:n,options:t.defaultQueryOptions(s),state:i,defaultOptions:t.getQueryDefaults(r)}),this.add(a)),a}add(t){h(this,mt).has(t.queryHash)||(h(this,mt).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const s=h(this,mt).get(t.queryHash);s&&(t.destroy(),s===t&&h(this,mt).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){z.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return h(this,mt).get(t)}getAll(){return[...h(this,mt).values()]}find(t){const s={exact:!0,...t};return this.getAll().find(i=>ms(s,i))}findAll(t={}){const s=this.getAll();return Object.keys(t).length>0?s.filter(i=>ms(t,i)):s}notify(t){z.batch(()=>{this.listeners.forEach(s=>{s(t)})})}onFocus(){z.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){z.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},mt=new WeakMap,ks),vt,J,kt,yt,wt,Bs,xi=(Bs=class extends Js{constructor(t){super();_(this,yt);_(this,vt);_(this,J);_(this,kt);this.mutationId=t.mutationId,P(this,J,t.mutationCache),P(this,vt,[]),this.state=t.state||Oi(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){h(this,vt).includes(t)||(h(this,vt).push(t),this.clearGcTimeout(),h(this,J).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){P(this,vt,h(this,vt).filter(s=>s!==t)),this.scheduleGc(),h(this,J).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){h(this,vt).length||(this.state.status==="pending"?this.scheduleGc():h(this,J).remove(this))}continue(){var t;return((t=h(this,kt))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var r,n,a,o,c,l,u,d,f,p,v,m,g,M,S,y,w,C,O,E;P(this,kt,Gs({fn:()=>this.options.mutationFn?this.options.mutationFn(t):Promise.reject(new Error("No mutationFn found")),onFail:(b,T)=>{L(this,yt,wt).call(this,{type:"failed",failureCount:b,error:T})},onPause:()=>{L(this,yt,wt).call(this,{type:"pause"})},onContinue:()=>{L(this,yt,wt).call(this,{type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>h(this,J).canRun(this)}));const s=this.state.status==="pending",i=!h(this,kt).canStart();try{if(!s){L(this,yt,wt).call(this,{type:"pending",variables:t,isPaused:i}),await((n=(r=h(this,J).config).onMutate)==null?void 0:n.call(r,t,this));const T=await((o=(a=this.options).onMutate)==null?void 0:o.call(a,t));T!==this.state.context&&L(this,yt,wt).call(this,{type:"pending",context:T,variables:t,isPaused:i})}const b=await h(this,kt).start();return await((l=(c=h(this,J).config).onSuccess)==null?void 0:l.call(c,b,t,this.state.context,this)),await((d=(u=this.options).onSuccess)==null?void 0:d.call(u,b,t,this.state.context)),await((p=(f=h(this,J).config).onSettled)==null?void 0:p.call(f,b,null,this.state.variables,this.state.context,this)),await((m=(v=this.options).onSettled)==null?void 0:m.call(v,b,null,t,this.state.context)),L(this,yt,wt).call(this,{type:"success",data:b}),b}catch(b){try{throw await((M=(g=h(this,J).config).onError)==null?void 0:M.call(g,b,t,this.state.context,this)),await((y=(S=this.options).onError)==null?void 0:y.call(S,b,t,this.state.context)),await((C=(w=h(this,J).config).onSettled)==null?void 0:C.call(w,void 0,b,this.state.variables,this.state.context,this)),await((E=(O=this.options).onSettled)==null?void 0:E.call(O,void 0,b,t,this.state.context)),b}finally{L(this,yt,wt).call(this,{type:"error",error:b})}}finally{h(this,J).runNext(this)}}},vt=new WeakMap,J=new WeakMap,kt=new WeakMap,yt=new WeakSet,wt=function(t){const s=i=>{switch(t.type){case"failed":return{...i,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...i,isPaused:!0};case"continue":return{...i,isPaused:!1};case"pending":return{...i,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...i,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...i,data:void 0,error:t.error,failureCount:i.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=s(this.state),z.batch(()=>{h(this,vt).forEach(i=>{i.onMutationUpdate(t)}),h(this,J).notify({mutation:this,type:"updated",action:t})})},Bs);function Oi(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var st,me,Qs,Ai=(Qs=class extends ge{constructor(t={}){super();_(this,st);_(this,me);this.config=t,P(this,st,new Map),P(this,me,Date.now())}build(t,s,i){const r=new xi({mutationCache:this,mutationId:++Se(this,me)._,options:t.defaultMutationOptions(s),state:i});return this.add(r),r}add(t){const s=Me(t),i=h(this,st).get(s)??[];i.push(t),h(this,st).set(s,i),this.notify({type:"added",mutation:t})}remove(t){var i;const s=Me(t);if(h(this,st).has(s)){const r=(i=h(this,st).get(s))==null?void 0:i.filter(n=>n!==t);r&&(r.length===0?h(this,st).delete(s):h(this,st).set(s,r))}this.notify({type:"removed",mutation:t})}canRun(t){var i;const s=(i=h(this,st).get(Me(t)))==null?void 0:i.find(r=>r.state.status==="pending");return!s||s===t}runNext(t){var i;const s=(i=h(this,st).get(Me(t)))==null?void 0:i.find(r=>r!==t&&r.state.isPaused);return(s==null?void 0:s.continue())??Promise.resolve()}clear(){z.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}getAll(){return[...h(this,st).values()].flat()}find(t){const s={exact:!0,...t};return this.getAll().find(i=>vs(s,i))}findAll(t={}){return this.getAll().filter(s=>vs(t,s))}notify(t){z.batch(()=>{this.listeners.forEach(s=>{s(t)})})}resumePausedMutations(){const t=this.getAll().filter(s=>s.state.isPaused);return z.batch(()=>Promise.all(t.map(s=>s.continue().catch(ut))))}},st=new WeakMap,me=new WeakMap,Qs);function Me(e){var t;return((t=e.options.scope)==null?void 0:t.id)??String(e.mutationId)}function Ti(e){return{onFetch:(t,s)=>{const i=async()=>{var v,m,g,M,S;const r=t.options,n=(g=(m=(v=t.fetchOptions)==null?void 0:v.meta)==null?void 0:m.fetchMore)==null?void 0:g.direction,a=((M=t.state.data)==null?void 0:M.pages)||[],o=((S=t.state.data)==null?void 0:S.pageParams)||[],c={pages:[],pageParams:[]};let l=!1;const u=y=>{Object.defineProperty(y,"signal",{enumerable:!0,get:()=>(t.signal.aborted?l=!0:t.signal.addEventListener("abort",()=>{l=!0}),t.signal)})},d=zs(t.options,t.fetchOptions),f=async(y,w,C)=>{if(l)return Promise.reject();if(w==null&&y.pages.length)return Promise.resolve(y);const O={queryKey:t.queryKey,pageParam:w,direction:C?"backward":"forward",meta:t.options.meta};u(O);const E=await d(O),{maxPages:b}=t.options,T=C?Pi:Mi;return{pages:T(y.pages,E,b),pageParams:T(y.pageParams,w,b)}};let p;if(n&&a.length){const y=n==="backward",w=y?Ii:bs,C={pages:a,pageParams:o},O=w(r,C);p=await f(C,O,y)}else{p=await f(c,o[0]??r.initialPageParam);const y=e??a.length;for(let w=1;w{var r,n;return(n=(r=t.options).persister)==null?void 0:n.call(r,i,{queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},s)}:t.fetchFn=i}}}function bs(e,{pages:t,pageParams:s}){const i=t.length-1;return t.length>0?e.getNextPageParam(t[i],t,s[i],s):void 0}function Ii(e,{pages:t,pageParams:s}){var i;return t.length>0?(i=e.getPreviousPageParam)==null?void 0:i.call(e,t[0],t,s[0],s):void 0}var j,Ct,Rt,Yt,Zt,Et,te,ee,$s,Xr=($s=class{constructor(e={}){_(this,j);_(this,Ct);_(this,Rt);_(this,Yt);_(this,Zt);_(this,Et);_(this,te);_(this,ee);P(this,j,e.queryCache||new Li),P(this,Ct,e.mutationCache||new Ai),P(this,Rt,e.defaultOptions||{}),P(this,Yt,new Map),P(this,Zt,new Map),P(this,Et,0)}mount(){Se(this,Et)._++,h(this,Et)===1&&(P(this,te,ls.subscribe(async e=>{e&&(await this.resumePausedMutations(),h(this,j).onFocus())})),P(this,ee,Ce.subscribe(async e=>{e&&(await this.resumePausedMutations(),h(this,j).onOnline())})))}unmount(){var e,t;Se(this,Et)._--,h(this,Et)===0&&((e=h(this,te))==null||e.call(this),P(this,te,void 0),(t=h(this,ee))==null||t.call(this),P(this,ee,void 0))}isFetching(e){return h(this,j).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return h(this,Ct).findAll({...e,status:"pending"}).length}getQueryData(e){var s;const t=this.defaultQueryOptions({queryKey:e});return(s=h(this,j).get(t.queryHash))==null?void 0:s.state.data}ensureQueryData(e){const t=this.getQueryData(e.queryKey);if(t===void 0)return this.fetchQuery(e);{const s=this.defaultQueryOptions(e),i=h(this,j).build(this,s);return e.revalidateIfStale&&i.isStaleByTime(qt(s.staleTime,i))&&this.prefetchQuery(s),Promise.resolve(t)}}getQueriesData(e){return h(this,j).findAll(e).map(({queryKey:t,state:s})=>{const i=s.data;return[t,i]})}setQueryData(e,t,s){const i=this.defaultQueryOptions({queryKey:e}),r=h(this,j).get(i.queryHash),n=r==null?void 0:r.state.data,a=bi(t,n);if(a!==void 0)return h(this,j).build(this,i).setData(a,{...s,manual:!0})}setQueriesData(e,t,s){return z.batch(()=>h(this,j).findAll(e).map(({queryKey:i})=>[i,this.setQueryData(i,t,s)]))}getQueryState(e){var s;const t=this.defaultQueryOptions({queryKey:e});return(s=h(this,j).get(t.queryHash))==null?void 0:s.state}removeQueries(e){const t=h(this,j);z.batch(()=>{t.findAll(e).forEach(s=>{t.remove(s)})})}resetQueries(e,t){const s=h(this,j),i={type:"active",...e};return z.batch(()=>(s.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries(i,t)))}cancelQueries(e={},t={}){const s={revert:!0,...t},i=z.batch(()=>h(this,j).findAll(e).map(r=>r.cancel(s)));return Promise.all(i).then(ut).catch(ut)}invalidateQueries(e={},t={}){return z.batch(()=>{if(h(this,j).findAll(e).forEach(i=>{i.invalidate()}),e.refetchType==="none")return Promise.resolve();const s={...e,type:e.refetchType??e.type??"active"};return this.refetchQueries(s,t)})}refetchQueries(e={},t){const s={...t,cancelRefetch:(t==null?void 0:t.cancelRefetch)??!0},i=z.batch(()=>h(this,j).findAll(e).filter(r=>!r.isDisabled()).map(r=>{let n=r.fetch(void 0,s);return s.throwOnError||(n=n.catch(ut)),r.state.fetchStatus==="paused"?Promise.resolve():n}));return Promise.all(i).then(ut)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const s=h(this,j).build(this,t);return s.isStaleByTime(qt(t.staleTime,s))?s.fetch(t):Promise.resolve(s.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(ut).catch(ut)}fetchInfiniteQuery(e){return e.behavior=Ti(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(ut).catch(ut)}resumePausedMutations(){return Ce.isOnline()?h(this,Ct).resumePausedMutations():Promise.resolve()}getQueryCache(){return h(this,j)}getMutationCache(){return h(this,Ct)}getDefaultOptions(){return h(this,Rt)}setDefaultOptions(e){P(this,Rt,e)}setQueryDefaults(e,t){h(this,Yt).set(de(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...h(this,Yt).values()];let s={};return t.forEach(i=>{fe(e,i.queryKey)&&(s={...s,...i.defaultOptions})}),s}setMutationDefaults(e,t){h(this,Zt).set(de(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...h(this,Zt).values()];let s={};return t.forEach(i=>{fe(e,i.mutationKey)&&(s={...s,...i.defaultOptions})}),s}defaultQueryOptions(e){if(e._defaulted)return e;const t={...h(this,Rt).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=os(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.enabled!==!0&&t.queryFn===qs&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...h(this,Rt).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){h(this,j).clear(),h(this,Ct).clear()}},j=new WeakMap,Ct=new WeakMap,Rt=new WeakMap,Yt=new WeakMap,Zt=new WeakMap,Et=new WeakMap,te=new WeakMap,ee=new WeakMap,$s),tt,x,ve,X,Bt,se,gt,ye,ie,re,Qt,$t,Lt,ne,A,ue,Ge,Je,Xe,Ye,Ze,ts,es,Ys,Us,Vi=(Us=class extends ge{constructor(t,s){super();_(this,A);_(this,tt);_(this,x);_(this,ve);_(this,X);_(this,Bt);_(this,se);_(this,gt);_(this,ye);_(this,ie);_(this,re);_(this,Qt);_(this,$t);_(this,Lt);_(this,ne,new Set);this.options=s,P(this,tt,t),P(this,gt,null),this.bindMethods(),this.setOptions(s)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(h(this,x).addObserver(this),Ss(h(this,x),this.options)?L(this,A,ue).call(this):this.updateResult(),L(this,A,Ye).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return ss(h(this,x),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return ss(h(this,x),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,L(this,A,Ze).call(this),L(this,A,ts).call(this),h(this,x).removeObserver(this)}setOptions(t,s){const i=this.options,r=h(this,x);if(this.options=h(this,tt).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof ht(this.options.enabled,h(this,x))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");L(this,A,es).call(this),h(this,x).setOptions(this.options),i._defaulted&&!ze(this.options,i)&&h(this,tt).getQueryCache().notify({type:"observerOptionsUpdated",query:h(this,x),observer:this});const n=this.hasListeners();n&&Ms(h(this,x),r,this.options,i)&&L(this,A,ue).call(this),this.updateResult(s),n&&(h(this,x)!==r||ht(this.options.enabled,h(this,x))!==ht(i.enabled,h(this,x))||qt(this.options.staleTime,h(this,x))!==qt(i.staleTime,h(this,x)))&&L(this,A,Ge).call(this);const a=L(this,A,Je).call(this);n&&(h(this,x)!==r||ht(this.options.enabled,h(this,x))!==ht(i.enabled,h(this,x))||a!==h(this,Lt))&&L(this,A,Xe).call(this,a)}getOptimisticResult(t){const s=h(this,tt).getQueryCache().build(h(this,tt),t),i=this.createResult(s,t);return Di(this,i)&&(P(this,X,i),P(this,se,this.options),P(this,Bt,h(this,x).state)),i}getCurrentResult(){return h(this,X)}trackResult(t,s){const i={};return Object.keys(t).forEach(r=>{Object.defineProperty(i,r,{configurable:!1,enumerable:!0,get:()=>(this.trackProp(r),s==null||s(r),t[r])})}),i}trackProp(t){h(this,ne).add(t)}getCurrentQuery(){return h(this,x)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const s=h(this,tt).defaultQueryOptions(t),i=h(this,tt).getQueryCache().build(h(this,tt),s);return i.isFetchingOptimistic=!0,i.fetch().then(()=>this.createResult(i,s))}fetch(t){return L(this,A,ue).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),h(this,X)))}createResult(t,s){var E;const i=h(this,x),r=this.options,n=h(this,X),a=h(this,Bt),o=h(this,se),l=t!==i?t.state:h(this,ve),{state:u}=t;let d={...u},f=!1,p;if(s._optimisticResults){const b=this.hasListeners(),T=!b&&Ss(t,s),K=b&&Ms(t,i,s,r);(T||K)&&(d={...d,...Xs(u.data,t.options)}),s._optimisticResults==="isRestoring"&&(d.fetchStatus="idle")}let{error:v,errorUpdatedAt:m,status:g}=d;if(s.select&&d.data!==void 0)if(n&&d.data===(a==null?void 0:a.data)&&s.select===h(this,ye))p=h(this,ie);else try{P(this,ye,s.select),p=s.select(d.data),p=We(n==null?void 0:n.data,p,s),P(this,ie,p),P(this,gt,null)}catch(b){P(this,gt,b)}else p=d.data;if(s.placeholderData!==void 0&&p===void 0&&g==="pending"){let b;if(n!=null&&n.isPlaceholderData&&s.placeholderData===(o==null?void 0:o.placeholderData))b=n.data;else if(b=typeof s.placeholderData=="function"?s.placeholderData((E=h(this,re))==null?void 0:E.state.data,h(this,re)):s.placeholderData,s.select&&b!==void 0)try{b=s.select(b),P(this,gt,null)}catch(T){P(this,gt,T)}b!==void 0&&(g="success",p=We(n==null?void 0:n.data,b,s),f=!0)}h(this,gt)&&(v=h(this,gt),p=h(this,ie),m=Date.now(),g="error");const M=d.fetchStatus==="fetching",S=g==="pending",y=g==="error",w=S&&M,C=p!==void 0;return{status:g,fetchStatus:d.fetchStatus,isPending:S,isSuccess:g==="success",isError:y,isInitialLoading:w,isLoading:w,data:p,dataUpdatedAt:d.dataUpdatedAt,error:v,errorUpdatedAt:m,failureCount:d.fetchFailureCount,failureReason:d.fetchFailureReason,errorUpdateCount:d.errorUpdateCount,isFetched:d.dataUpdateCount>0||d.errorUpdateCount>0,isFetchedAfterMount:d.dataUpdateCount>l.dataUpdateCount||d.errorUpdateCount>l.errorUpdateCount,isFetching:M,isRefetching:M&&!S,isLoadingError:y&&!C,isPaused:d.fetchStatus==="paused",isPlaceholderData:f,isRefetchError:y&&C,isStale:us(t,s),refetch:this.refetch}}updateResult(t){const s=h(this,X),i=this.createResult(h(this,x),this.options);if(P(this,Bt,h(this,x).state),P(this,se,this.options),h(this,Bt).data!==void 0&&P(this,re,h(this,x)),ze(i,s))return;P(this,X,i);const r={},n=()=>{if(!s)return!0;const{notifyOnChangeProps:a}=this.options,o=typeof a=="function"?a():a;if(o==="all"||!o&&!h(this,ne).size)return!0;const c=new Set(o??h(this,ne));return this.options.throwOnError&&c.add("error"),Object.keys(h(this,X)).some(l=>{const u=l;return h(this,X)[u]!==s[u]&&c.has(u)})};(t==null?void 0:t.listeners)!==!1&&n()&&(r.listeners=!0),L(this,A,Ys).call(this,{...r,...t})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&L(this,A,Ye).call(this)}},tt=new WeakMap,x=new WeakMap,ve=new WeakMap,X=new WeakMap,Bt=new WeakMap,se=new WeakMap,gt=new WeakMap,ye=new WeakMap,ie=new WeakMap,re=new WeakMap,Qt=new WeakMap,$t=new WeakMap,Lt=new WeakMap,ne=new WeakMap,A=new WeakSet,ue=function(t){L(this,A,es).call(this);let s=h(this,x).fetch(this.options,t);return t!=null&&t.throwOnError||(s=s.catch(ut)),s},Ge=function(){L(this,A,Ze).call(this);const t=qt(this.options.staleTime,h(this,x));if(ae||h(this,X).isStale||!qe(t))return;const i=Ks(h(this,X).dataUpdatedAt,t)+1;P(this,Qt,setTimeout(()=>{h(this,X).isStale||this.updateResult()},i))},Je=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(h(this,x)):this.options.refetchInterval)??!1},Xe=function(t){L(this,A,ts).call(this),P(this,Lt,t),!(ae||ht(this.options.enabled,h(this,x))===!1||!qe(h(this,Lt))||h(this,Lt)===0)&&P(this,$t,setInterval(()=>{(this.options.refetchIntervalInBackground||ls.isFocused())&&L(this,A,ue).call(this)},h(this,Lt)))},Ye=function(){L(this,A,Ge).call(this),L(this,A,Xe).call(this,L(this,A,Je).call(this))},Ze=function(){h(this,Qt)&&(clearTimeout(h(this,Qt)),P(this,Qt,void 0))},ts=function(){h(this,$t)&&(clearInterval(h(this,$t)),P(this,$t,void 0))},es=function(){const t=h(this,tt).getQueryCache().build(h(this,tt),this.options);if(t===h(this,x))return;const s=h(this,x);P(this,x,t),P(this,ve,t.state),this.hasListeners()&&(s==null||s.removeObserver(this),t.addObserver(this))},Ys=function(t){z.batch(()=>{t.listeners&&this.listeners.forEach(s=>{s(h(this,X))}),h(this,tt).getQueryCache().notify({query:h(this,x),type:"observerResultsUpdated"})})},Us);function ji(e,t){return ht(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function Ss(e,t){return ji(e,t)||e.state.data!==void 0&&ss(e,t,t.refetchOnMount)}function ss(e,t,s){if(ht(t.enabled,e)!==!1){const i=typeof s=="function"?s(e):s;return i==="always"||i!==!1&&us(e,t)}return!1}function Ms(e,t,s,i){return(e!==t||ht(i.enabled,e)===!1)&&(!s.suspense||e.state.status!=="error")&&us(e,s)}function us(e,t){return ht(t.enabled,e)!==!1&&e.isStaleByTime(qt(t.staleTime,e))}function Di(e,t){return!ze(e.getCurrentResult(),t)}var Zs=R.createContext(void 0),ki=e=>{const t=R.useContext(Zs);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},Yr=({client:e,children:t})=>(R.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),F.jsx(Zs.Provider,{value:e,children:t})),ti=R.createContext(!1),Bi=()=>R.useContext(ti);ti.Provider;function Qi(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var $i=R.createContext(Qi()),Ui=()=>R.useContext($i);function Ki(e,t){return typeof e=="function"?e(...t):!!e}var Ni=(e,t)=>{(e.suspense||e.throwOnError)&&(t.isReset()||(e.retryOnMount=!1))},qi=e=>{R.useEffect(()=>{e.clearReset()},[e])},zi=({result:e,errorResetBoundary:t,throwOnError:s,query:i})=>e.isError&&!t.isReset()&&!e.isFetching&&i&&Ki(s,[e.error,i]),Hi=(e,t)=>t.state.data===void 0,Wi=e=>{e.suspense&&typeof e.staleTime!="number"&&(e.staleTime=1e3)},Gi=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,Ji=(e,t,s)=>t.fetchOptimistic(e).catch(()=>{s.clearReset()});function Xi(e,t,s){var l,u,d,f;const i=ki(),r=Bi(),n=Ui(),a=i.defaultQueryOptions(e);(u=(l=i.getDefaultOptions().queries)==null?void 0:l._experimental_beforeQuery)==null||u.call(l,a),a._optimisticResults=r?"isRestoring":"optimistic",Wi(a),Ni(a,n),qi(n);const[o]=R.useState(()=>new t(i,a)),c=o.getOptimisticResult(a);if(R.useSyncExternalStore(R.useCallback(p=>{const v=r?()=>{}:o.subscribe(z.batchCalls(p));return o.updateResult(),v},[o,r]),()=>o.getCurrentResult(),()=>o.getCurrentResult()),R.useEffect(()=>{o.setOptions(a,{listeners:!1})},[a,o]),Gi(a,c))throw Ji(a,o,n);if(zi({result:c,errorResetBoundary:n,throwOnError:a.throwOnError,query:i.getQueryCache().get(a.queryHash)}))throw c.error;return(f=(d=i.getDefaultOptions().queries)==null?void 0:d._experimental_afterQuery)==null||f.call(d,a,c),a.notifyOnChangeProps?c:o.trackResult(c)}function Zr(e,t){return Xi({...e,enabled:!0,suspense:!0,throwOnError:Hi,placeholderData:void 0},Vi)}function tn(e){return e}const Ps="pushstate",ws="popstate",ei="beforeunload",si=e=>(e.preventDefault(),e.returnValue=""),Yi=()=>{removeEventListener(ei,si,{capture:!0})};function ii(e){let t=e.getLocation();const s=new Set;let i=[];const r=()=>{t=e.getLocation(),s.forEach(a=>a())},n=async(a,o)=>{var c;if(!((o==null?void 0:o.ignoreBlocker)??!1)&&typeof document<"u"&&i.length){for(const u of i)if(!await u()){(c=e.onBlocked)==null||c.call(e,r);return}}a()};return{get location(){return t},subscribers:s,subscribe:a=>(s.add(a),()=>{s.delete(a)}),push:(a,o,c)=>{o=ce(o),n(()=>{e.pushState(a,o),r()},c)},replace:(a,o,c)=>{o=ce(o),n(()=>{e.replaceState(a,o),r()},c)},go:(a,o)=>{n(()=>{e.go(a),r()},o)},back:a=>{n(()=>{e.back(),r()},a)},forward:a=>{n(()=>{e.forward(),r()},a)},createHref:a=>e.createHref(a),block:a=>(i.push(a),i.length===1&&addEventListener(ei,si,{capture:!0}),()=>{i=i.filter(o=>o!==a),i.length||Yi()}),flush:()=>{var a;return(a=e.flush)==null?void 0:a.call(e)},destroy:()=>{var a;return(a=e.destroy)==null?void 0:a.call(e)},notify:r}}function ce(e){return e||(e={}),{...e,key:ri()}}function Zi(e){const t=typeof document<"u"?window:void 0,s=t.history.pushState,i=t.history.replaceState,r=m=>m,n=()=>is(`${t.location.pathname}${t.location.search}${t.location.hash}`,t.history.state);let a=n(),o;const c=()=>a;let l,u;const d=()=>{if(!l)return;(l.isPush?s:i).call(t.history,l.state,"",l.href),l=void 0,u=void 0,o=void 0},f=(m,g,M)=>{const S=r(g);u||(o=a),a=is(g,M),l={href:S,state:M,isPush:(l==null?void 0:l.isPush)||m==="push"},u||(u=Promise.resolve().then(()=>d()))},p=()=>{a=n(),v.notify()},v=ii({getLocation:c,pushState:(m,g)=>f("push",m,g),replaceState:(m,g)=>f("replace",m,g),back:()=>t.history.back(),forward:()=>t.history.forward(),go:m=>t.history.go(m),createHref:m=>r(m),flush:d,destroy:()=>{t.history.pushState=s,t.history.replaceState=i,t.removeEventListener(Ps,p),t.removeEventListener(ws,p)},onBlocked:m=>{o&&a!==o&&(a=o,m())}});return t.addEventListener(Ps,p),t.addEventListener(ws,p),t.history.pushState=function(...m){const g=s.apply(t.history,m);return p(),g},t.history.replaceState=function(...m){const g=i.apply(t.history,m);return p(),g},v}function tr(e={initialEntries:["/"]}){const t=e.initialEntries;let s=e.initialIndex??t.length-1,i={key:ri()};return ii({getLocation:()=>is(t[s],i),pushState:(n,a)=>{i=a,t.splice,s{i=a,t[s]=n},back:()=>{i=ce(i),s=Math.max(s-1,0)},forward:()=>{i=ce(i),s=Math.min(s+1,t.length-1)},go:n=>{i=ce(i),s=Math.min(Math.max(s+n,0),t.length-1)},createHref:n=>n})}function is(e,t){const s=e.indexOf("#"),i=e.indexOf("?");return{href:e,pathname:e.substring(0,s>0?i>0?Math.min(s,i):s:i>0?i:e.length),hash:s>-1?e.substring(s):"",search:i>-1?e.slice(i,s===-1?void 0:s):"",state:t||{}}}function ri(){return(Math.random()+1).toString(36).substring(7)}const Qe=R.createContext(null);function ni(){return typeof document>"u"?Qe:window.__TSR_ROUTER_CONTEXT__?window.__TSR_ROUTER_CONTEXT__:(window.__TSR_ROUTER_CONTEXT__=Qe,Qe)}function Ot(e){const t=R.useContext(ni());return Ae(!(((e==null?void 0:e.warn)??!0)&&!t)),t}class cs{constructor(t,s){this.listeners=new Set,this._batching=!1,this._flushing=0,this.subscribe=i=>{var r,n;this.listeners.add(i);const a=(n=(r=this.options)==null?void 0:r.onSubscribe)==null?void 0:n.call(r,i,this);return()=>{this.listeners.delete(i),a==null||a()}},this.setState=i=>{var r,n,a;const o=this.state;this.state=(r=this.options)!=null&&r.updateFn?this.options.updateFn(o)(i):i(o),(a=(n=this.options)==null?void 0:n.onUpdate)==null||a.call(n),this._flush()},this._flush=()=>{if(this._batching)return;const i=++this._flushing;this.listeners.forEach(r=>{this._flushing===i&&r()})},this.batch=i=>{if(this._batching)return i();this._batching=!0,i(),this._batching=!1,this._flush()},this.state=t,this.options=s}}function Re(e,t=s=>s){return yi.useSyncExternalStoreWithSelector(e.subscribe,()=>e.state,()=>e.state,t,er)}function er(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;const s=Object.keys(e);if(s.length!==Object.keys(t).length)return!1;for(let i=0;i{t.substring(0,1)==="?"&&(t=t.substring(1));const s=ir(t);for(const i in s){const r=s[i];if(typeof r=="string")try{s[i]=e(r)}catch{}}return s}}function or(e,t){function s(i){if(typeof i=="object"&&i!==null)try{return e(i)}catch{}else if(typeof i=="string"&&typeof t=="function")try{return t(i),e(i)}catch{}return i}return i=>{i={...i},Object.keys(i).forEach(n=>{const a=i[n];typeof a>"u"||a===void 0?delete i[n]:i[n]=s(a)});const r=sr(i).toString();return r?`?${r}`:""}}function Ee(e){return e[e.length-1]}function lr(e){return typeof e=="function"}function Nt(e,t){return lr(e)?e(t):e}function he(e,t){return t.reduce((s,i)=>(s[i]=e[i],s),{})}function ft(e,t){if(e===t)return e;const s=t,i=Cs(e)&&Cs(s);if(i||Le(e)&&Le(s)){const r=i?e:Object.keys(e),n=r.length,a=i?s:Object.keys(s),o=a.length,c=i?[]:{};let l=0;for(let u=0;u"u")return!0;const s=t.prototype;return!(!_s(s)||!s.hasOwnProperty("isPrototypeOf"))}function _s(e){return Object.prototype.toString.call(e)==="[object Object]"}function Cs(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function zt(e,t,s=!1){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(Le(e)&&Le(t)){const i=Object.keys(e).filter(n=>e[n]!==void 0),r=Object.keys(t).filter(n=>t[n]!==void 0);return!s&&i.length!==r.length?!1:!r.some(n=>!(n in e)||!zt(e[n],t[n],s))}return Array.isArray(e)&&Array.isArray(t)?e.length!==t.length?!1:!e.some((i,r)=>!zt(i,t[r],s)):!1}const $e=typeof window<"u"?R.useLayoutEffect:R.useEffect;function Kt(e){let t,s;const i=new Promise((r,n)=>{t=r,s=n});return i.status="pending",i.resolve=r=>{i.status="resolved",i.value=r,t(r),e==null||e(r)},i.reject=r=>{i.status="rejected",s(r)},i}function Rs(e){const t=R.useRef({value:e,prev:null}),s=t.current.value;return e!==s&&(t.current={value:e,prev:s}),t.current.prev}function xt(e){return Te(e.filter(Boolean).join("/"))}function Te(e){return e.replace(/\/{2,}/g,"/")}function hs(e){return e==="/"?e:e.replace(/^\/{1,}/,"")}function It(e){return e==="/"?e:e.replace(/\/{1,}$/,"")}function ur(e){return It(hs(e))}function xe(e,t){return e.endsWith("/")&&e!=="/"&&e!==`${t}/`?e.slice(0,-1):e}function cr(e,t,s){return xe(e,s)===xe(t,s)}function hr({basepath:e,base:t,to:s,trailingSlash:i="never"}){var r,n;t=t.replace(new RegExp(`^${e}`),"/"),s=s.replace(new RegExp(`^${e}`),"/");let a=oe(t);const o=oe(s);a.length>1&&((r=Ee(a))==null?void 0:r.value)==="/"&&a.pop(),o.forEach((l,u)=>{l.value==="/"?u?u===o.length-1&&a.push(l):a=[l]:l.value===".."?a.pop():l.value==="."||a.push(l)}),a.length>1&&(((n=Ee(a))==null?void 0:n.value)==="/"?i==="never"&&a.pop():i==="always"&&a.push({type:"pathname",value:"/"}));const c=xt([e,...a.map(l=>l.value)]);return Te(c)}function oe(e){if(!e)return[];e=Te(e);const t=[];if(e.slice(0,1)==="/"&&(e=e.substring(1),t.push({type:"pathname",value:"/"})),!e)return t;const s=e.split("/").filter(Boolean);return t.push(...s.map(i=>i==="$"||i==="*"?{type:"wildcard",value:i}:i.charAt(0)==="$"?{type:"param",value:i}:{type:"pathname",value:decodeURIComponent(i)})),e.slice(-1)==="/"&&(e=e.substring(1),t.push({type:"pathname",value:"/"})),t}function Ue({path:e,params:t,leaveWildcards:s,leaveParams:i}){const r=oe(e),n={};for(const[a,o]of Object.entries(t)){const c=typeof o=="string";["*","_splat"].includes(a)?n[a]=c?encodeURI(o):o:n[a]=c?encodeURIComponent(o):o}return xt(r.map(a=>{if(a.type==="wildcard"){const o=n._splat;return s?`${a.value}${o??""}`:o}if(a.type==="param"){if(i){const o=n[a.value];return`${a.value}${o??""}`}return n[a.value.substring(1)]??"undefined"}return a.value}))}function Pe(e,t,s){const i=dr(e,t,s);if(!(s.to&&!i))return i??{}}function Es(e,t){switch(!0){case e==="/":return t;case t===e:return"";case t.length{for(let c=0;c=r.length-1,f=c>=n.length-1;if(u){if(u.type==="wildcard"){if(l!=null&&l.value){const p=decodeURI(xt(r.slice(c).map(v=>v.value)));return a["*"]=p,a._splat=p,!0}return!1}if(u.type==="pathname"){if(u.value==="/"&&!(l!=null&&l.value))return!0;if(l){if(s.caseSensitive){if(u.value!==l.value)return!1}else if(u.value.toLowerCase()!==l.value.toLowerCase())return!1}}if(!l)return!1;if(u.type==="param"){if(l.value==="/")return!1;l.value.charAt(0)!=="$"&&(a[u.value.substring(1)]=decodeURIComponent(l.value))}}if(!d&&f)return a["**"]=xt(r.slice(c+1).map(p=>p.value)),!!s.fuzzy&&(u==null?void 0:u.value)!=="/"}return!0})()?a:void 0}function en(e){if(e.isRedirect=!0,e.statusCode=e.statusCode||e.code||301,e.headers=e.headers||{},e.throw)throw e;return e}function Tt(e){return!!(e!=null&&e.isRedirect)}function Ls(e){return!!(e!=null&&e.isRedirect)&&e.href}function ds(e){const t=e.errorComponent??Ie;return F.jsx(fr,{getResetKey:e.getResetKey,onCatch:e.onCatch,children:({error:s,reset:i})=>s?R.createElement(t,{error:s,reset:i}):e.children})}class fr extends R.Component{constructor(){super(...arguments),this.state={error:null}}static getDerivedStateFromProps(t){return{resetKey:t.getResetKey()}}static getDerivedStateFromError(t){return{error:t}}reset(){this.setState({error:null})}componentDidUpdate(t,s){s.error&&s.resetKey!==this.state.resetKey&&this.reset()}componentDidCatch(t,s){this.props.onCatch&&this.props.onCatch(t,s)}render(){return this.props.children({error:this.state.resetKey!==this.props.getResetKey()?null:this.state.error,reset:()=>{this.reset()}})}}function Ie({error:e}){const[t,s]=R.useState(!1);return F.jsxs("div",{style:{padding:".5rem",maxWidth:"100%"},children:[F.jsxs("div",{style:{display:"flex",alignItems:"center",gap:".5rem"},children:[F.jsx("strong",{style:{fontSize:"1rem"},children:"Something went wrong!"}),F.jsx("button",{style:{appearance:"none",fontSize:".6em",border:"1px solid currentColor",padding:".1rem .2rem",fontWeight:"bold",borderRadius:".25rem"},onClick:()=>s(i=>!i),children:t?"Hide Error":"Show Error"})]}),F.jsx("div",{style:{height:".25rem"}}),t?F.jsx("div",{children:F.jsx("pre",{style:{fontSize:".7em",border:"1px solid red",borderRadius:".25rem",padding:".3rem",color:"red",overflow:"auto"},children:e.message?F.jsx("code",{children:e.message}):null})}):null]})}function Y(e){const t=Ot({warn:(e==null?void 0:e.router)===void 0});return Re(((e==null?void 0:e.router)||t).__store,e==null?void 0:e.select)}function pt(e){return!!(e!=null&&e.isNotFound)}function pr(e){const t=Y({select:s=>`not-found-${s.location.pathname}-${s.status}`});return F.jsx(ds,{getResetKey:()=>t,onCatch:(s,i)=>{var r;if(pt(s))(r=e.onCatch)==null||r.call(e,s,i);else throw s},errorComponent:({error:s})=>{var i;return(i=e.fallback)==null?void 0:i.call(e,s)},children:e.children})}function mr(){return F.jsx("p",{children:"Not Found"})}const vr=["component","errorComponent","pendingComponent","notFoundComponent"];function sn(e){return new yr(e)}class yr{constructor(t){this.tempLocationKey=`${Math.round(Math.random()*1e7)}`,this.resetNextScroll=!0,this.shouldViewTransition=void 0,this.subscribers=new Set,this.startReactTransition=s=>s(),this.update=s=>{s.notFoundRoute&&console.warn("The notFoundRoute API is deprecated and will be removed in the next major version. See https://tanstack.com/router/v1/docs/guide/not-found-errors#migrating-from-notfoundroute for more info.");const i=this.options;this.options={...this.options,...s},this.isServer=this.options.isServer??typeof document>"u",(!this.basepath||s.basepath&&s.basepath!==i.basepath)&&(s.basepath===void 0||s.basepath===""||s.basepath==="/"?this.basepath="/":this.basepath=`/${ur(s.basepath)}`),(!this.history||this.options.history&&this.options.history!==this.history)&&(this.history=this.options.history??(this.isServer?tr({initialEntries:[this.basepath||"/"]}):Zi()),this.latestLocation=this.parseLocation()),this.options.routeTree!==this.routeTree&&(this.routeTree=this.options.routeTree,this.buildRouteTree()),this.__store||(this.__store=new cs(Sr(this.latestLocation),{onUpdate:()=>{this.__store.state={...this.state,cachedMatches:this.state.cachedMatches.filter(r=>!["redirected"].includes(r.status))}}}))},this.buildRouteTree=()=>{this.routesById={},this.routesByPath={};const s=this.options.notFoundRoute;s&&(s.init({originalIndex:99999999999}),this.routesById[s.id]=s);const i=a=>{a.forEach((o,c)=>{o.init({originalIndex:c});const l=this.routesById[o.id];if(et(!l,`Duplicate routes found with id: ${String(o.id)}`),this.routesById[o.id]=o,!o.isRoot&&o.path){const d=It(o.fullPath);(!this.routesByPath[d]||o.fullPath.endsWith("/"))&&(this.routesByPath[d]=o)}const u=o.children;u!=null&&u.length&&i(u)})};i([this.routeTree]);const r=[];Object.values(this.routesById).forEach((a,o)=>{var c;if(a.isRoot||!a.path)return;const l=hs(a.fullPath),u=oe(l);for(;u.length>1&&((c=u[0])==null?void 0:c.value)==="/";)u.shift();const d=u.map(f=>f.value==="/"?.75:f.type==="param"?.5:f.type==="wildcard"?.25:1);r.push({child:a,trimmed:l,parsed:u,index:o,scores:d})}),this.flatRoutes=r.sort((a,o)=>{const c=Math.min(a.scores.length,o.scores.length);for(let l=0;lo.parsed[l].value?1:-1;return a.index-o.index}).map((a,o)=>(a.child.rank=o,a.child))},this.subscribe=(s,i)=>{const r={eventType:s,fn:i};return this.subscribers.add(r),()=>{this.subscribers.delete(r)}},this.emit=s=>{this.subscribers.forEach(i=>{i.eventType===s.type&&i.fn(s)})},this.parseLocation=s=>{const i=({pathname:o,search:c,hash:l,state:u})=>{const d=this.options.parseSearch(c),f=this.options.stringifySearch(d);return{pathname:o,searchStr:f,search:ft(s==null?void 0:s.search,d),hash:l.split("#").reverse()[0]??"",href:`${o}${f}${l}`,state:ft(s==null?void 0:s.state,u)}},r=i(this.history.location),{__tempLocation:n,__tempKey:a}=r.state;if(n&&(!a||a===this.tempLocationKey)){const o=i(n);return o.state.key=r.state.key,delete o.state.__tempLocation,{...o,maskedLocation:r}}return r},this.resolvePathWithBase=(s,i)=>hr({basepath:this.basepath,base:s,to:Te(i),trailingSlash:this.options.trailingSlash}),this.matchRoutes=(s,i,r)=>{let n={};const a=this.flatRoutes.find(p=>{const v=Pe(this.basepath,It(s),{to:p.fullPath,caseSensitive:p.options.caseSensitive??this.options.caseSensitive,fuzzy:!0});return v?(n=v,!0):!1});let o=a||this.routesById[it];const c=[o];let l=!1;for((a?a.path!=="/"&&n["**"]:It(s))&&(this.options.notFoundRoute?c.push(this.options.notFoundRoute):l=!0);o.parentRoute;)o=o.parentRoute,c.unshift(o);const u=(()=>{if(l){if(this.options.notFoundMode!=="root")for(let p=c.length-1;p>=0;p--){const v=c[p];if(v.children)return v.id}return it}})(),d=c.map(p=>{var v;let m;const g=((v=p.options.params)==null?void 0:v.parse)??p.options.parseParams;if(g)try{const M=g(n);Object.assign(n,M)}catch(M){if(m=new br(M.message,{cause:M}),r!=null&&r.throwOnError)throw m;return m}}),f=[];return c.forEach((p,v)=>{var m,g,M,S,y,w,C,O,E,b;const T=f[v-1],[K,N]=(()=>{const k=(T==null?void 0:T.search)??i;try{const W=typeof p.options.validateSearch=="object"?p.options.validateSearch.parse:p.options.validateSearch,Z=(W==null?void 0:W(k))??{};return[{...k,...Z},void 0]}catch(W){const Z=new gr(W.message,{cause:W});if(r!=null&&r.throwOnError)throw Z;return[k,Z]}})(),Q=((g=(m=p.options).loaderDeps)==null?void 0:g.call(m,{search:K}))??"",I=Q?JSON.stringify(Q):"",U=Ue({path:p.fullPath,params:n}),q=Ue({path:p.id,params:n,leaveWildcards:!0})+I,H=this.getMatch(q),dt=this.state.matches.find(k=>k.id===q)?"stay":"enter";let D;if(H)D={...H,cause:dt,params:n};else{const k=p.options.loader||p.options.beforeLoad||p.lazyFn?"pending":"success";D={id:q,index:v,routeId:p.id,params:n,pathname:xt([this.basepath,U]),updatedAt:Date.now(),search:{},searchError:void 0,status:k,isFetching:!1,error:void 0,paramsError:d[v],routeContext:void 0,context:void 0,abortController:new AbortController,fetchCount:0,cause:dt,loaderDeps:Q,invalid:!1,preload:!1,links:(S=(M=p.options).links)==null?void 0:S.call(M),scripts:(w=(y=p.options).scripts)==null?void 0:w.call(y),staticData:p.options.staticData||{},loadPromise:Kt()}}D.status==="success"&&(D.meta=(O=(C=p.options).meta)==null?void 0:O.call(C,{matches:f,match:D,params:D.params,loaderData:D.loaderData}),D.headers=(b=(E=p.options).headers)==null?void 0:b.call(E,{loaderData:D.loaderData})),r!=null&&r.preload||(D.globalNotFound=u===p.id),D.search=ft(D.search,K),D.searchError=N,f.push(D)}),f},this.cancelMatch=s=>{const i=this.getMatch(s);i&&(i.abortController.abort(),clearTimeout(i.pendingTimeout))},this.cancelMatches=()=>{var s;(s=this.state.pendingMatches)==null||s.forEach(i=>{this.cancelMatch(i.id)})},this.buildLocation=s=>{const i=(n={},a)=>{var o,c,l;const u=n._fromLocation!=null?this.matchRoutes(n._fromLocation.pathname,n.fromSearch||n._fromLocation.search):this.state.matches,d=n.from!=null?u.find(I=>Pe(this.basepath,It(I.pathname),{to:n.from,caseSensitive:!1,fuzzy:!1})):void 0,f=(d==null?void 0:d.pathname)||this.latestLocation.pathname;et(n.from==null||d!=null,"Could not find match for from: "+n.from);const p=((o=Ee(u))==null?void 0:o.search)||this.latestLocation.search,v=a==null?void 0:a.filter(I=>u.find(U=>U.routeId===I.routeId)),m=this.routesById[(c=v==null?void 0:v.find(I=>I.pathname===f))==null?void 0:c.routeId];let g=n.to?this.resolvePathWithBase(f,`${n.to}`):this.resolvePathWithBase(f,(m==null?void 0:m.to)??f);const M={...(l=Ee(u))==null?void 0:l.params};let S=(n.params??!0)===!0?M:{...M,...Nt(n.params,M)};Object.keys(S).length>0&&(a==null||a.map(I=>{var U;const q=this.looseRoutesById[I.routeId];return((U=q==null?void 0:q.options.params)==null?void 0:U.stringify)??q.options.stringifyParams}).filter(Boolean).forEach(I=>{S={...S,...I(S)}})),g=Ue({path:g,params:S??{},leaveWildcards:!1,leaveParams:s.leaveParams});const y=(v==null?void 0:v.map(I=>this.looseRoutesById[I.routeId].options.preSearchFilters??[]).flat().filter(Boolean))??[],w=(v==null?void 0:v.map(I=>this.looseRoutesById[I.routeId].options.postSearchFilters??[]).flat().filter(Boolean))??[],C=y.length?y.reduce((I,U)=>U(I),p):p,O=n.search===!0?C:n.search?Nt(n.search,C):y.length?C:{},E=w.length?w.reduce((I,U)=>U(I),O):O,b=ft(p,E),T=this.options.stringifySearch(b),K=n.hash===!0?this.latestLocation.hash:n.hash?Nt(n.hash,this.latestLocation.hash):void 0,N=K?`#${K}`:"";let Q=n.state===!0?this.latestLocation.state:n.state?Nt(n.state,this.latestLocation.state):{};return Q=ft(this.latestLocation.state,Q),{pathname:g,search:b,searchStr:T,state:Q,hash:K??"",href:`${g}${T}${N}`,unmaskOnReload:n.unmaskOnReload}},r=(n={},a)=>{var o;const c=i(n);let l=a?i(a):void 0;if(!l){let v={};const m=(o=this.options.routeMasks)==null?void 0:o.find(g=>{const M=Pe(this.basepath,c.pathname,{to:g.from,caseSensitive:!1,fuzzy:!1});return M?(v=M,!0):!1});if(m){const{from:g,...M}=m;a={...he(s,["from"]),...M,params:v},l=i(a)}}const u=this.matchRoutes(c.pathname,c.search),d=l?this.matchRoutes(l.pathname,l.search):void 0,f=l?i(a,d):void 0,p=i(n,u);return f&&(p.maskedLocation=f),p};return s.mask?r(s,{...he(s,["from"]),...s.mask}):r(s)},this.commitLocation=({viewTransition:s,ignoreBlocker:i,...r})=>{const n=()=>{r.state.key=this.latestLocation.state.key;const c=zt(r.state,this.latestLocation.state);return delete r.state.key,c},a=this.latestLocation.href===r.href,o=this.commitLocationPromise;if(this.commitLocationPromise=Kt(()=>{o==null||o.resolve()}),a&&n())this.load();else{let{maskedLocation:c,...l}=r;c&&(l={...c,state:{...c.state,__tempKey:void 0,__tempLocation:{...l,search:l.searchStr,state:{...l.state,__tempKey:void 0,__tempLocation:void 0,key:void 0}}}},(l.unmaskOnReload??this.options.unmaskOnReload??!1)&&(l.state.__tempKey=this.tempLocationKey)),this.shouldViewTransition=s,this.history[r.replace?"replace":"push"](l.href,l.state,{ignoreBlocker:i})}return this.resetNextScroll=r.resetScroll??!0,this.history.subscribers.size||this.load(),this.commitLocationPromise},this.buildAndCommitLocation=({replace:s,resetScroll:i,viewTransition:r,ignoreBlocker:n,...a}={})=>{const o=this.buildLocation(a);return this.commitLocation({...o,viewTransition:r,replace:s,resetScroll:i,ignoreBlocker:n})},this.navigate=({from:s,to:i,__isRedirect:r,...n})=>{const a=String(i);let o;try{new URL(`${a}`),o=!0}catch{}return et(!o),this.buildAndCommitLocation({...n,from:s,to:i})},this.load=async()=>{this.latestLocation=this.parseLocation(this.latestLocation),this.__store.setState(n=>({...n,loadedAt:Date.now()}));let s,i;const r=new Promise(n=>{this.startReactTransition(async()=>{var a;try{const o=this.latestLocation,c=this.state.resolvedLocation,l=c.href!==o.href;this.cancelMatches();let u;this.__store.batch(()=>{u=this.matchRoutes(o.pathname,o.search),this.__store.setState(d=>({...d,status:"pending",isLoading:!0,location:o,pendingMatches:u,cachedMatches:d.cachedMatches.filter(f=>!u.find(p=>p.id===f.id))}))}),this.state.redirect||this.emit({type:"onBeforeNavigate",fromLocation:c,toLocation:o,pathChanged:l}),this.emit({type:"onBeforeLoad",fromLocation:c,toLocation:o,pathChanged:l}),await this.loadMatches({matches:u,location:o,onReady:async()=>{this.startViewTransition(async()=>{let d,f,p;this.__store.batch(()=>{this.__store.setState(v=>{const m=v.matches,g=v.pendingMatches||v.matches;return d=m.filter(M=>!g.find(S=>S.id===M.id)),f=g.filter(M=>!m.find(S=>S.id===M.id)),p=m.filter(M=>g.find(S=>S.id===M.id)),{...v,isLoading:!1,matches:g,pendingMatches:void 0,cachedMatches:[...v.cachedMatches,...d.filter(M=>M.status!=="error")]}}),this.cleanCache()}),[[d,"onLeave"],[f,"onEnter"],[p,"onStay"]].forEach(([v,m])=>{v.forEach(g=>{var M,S;(S=(M=this.looseRoutesById[g.routeId].options)[m])==null||S.call(M,g)})})})}})}catch(o){Ls(o)?(s=o,this.isServer||this.navigate({...o,replace:!0,__isRedirect:!0})):pt(o)&&(i=o),this.__store.setState(c=>({...c,statusCode:s?s.statusCode:i?404:c.matches.some(l=>l.status==="error")?500:200,redirect:s}))}this.latestLoadPromise===r&&((a=this.commitLocationPromise)==null||a.resolve(),this.latestLoadPromise=void 0,this.commitLocationPromise=void 0),n()})});for(this.latestLoadPromise=r,await r;this.latestLoadPromise&&r!==this.latestLoadPromise;)await this.latestLoadPromise},this.startViewTransition=s=>{var i,r;const n=this.shouldViewTransition??this.options.defaultViewTransition;delete this.shouldViewTransition,(r=(i=n&&typeof document<"u"?document:void 0)==null?void 0:i.startViewTransition)!=null&&r.call(i,s)||s()},this.updateMatch=(s,i)=>{var r;let n;const a=(r=this.state.pendingMatches)==null?void 0:r.find(l=>l.id===s),o=this.state.matches.find(l=>l.id===s),c=a?"pendingMatches":o?"matches":"cachedMatches";return this.__store.setState(l=>{var u;return{...l,[c]:(u=l[c])==null?void 0:u.map(d=>d.id===s?n=i(d):d)}}),n},this.getMatch=s=>[...this.state.cachedMatches,...this.state.pendingMatches??[],...this.state.matches].find(i=>i.id===s),this.loadMatches=async({location:s,matches:i,preload:r,onReady:n,updateMatch:a=this.updateMatch})=>{let o,c=!1;const l=async()=>{c||(c=!0,await(n==null?void 0:n()))};!this.isServer&&!this.state.matches.length&&l();const u=(d,f)=>{var p,v,m;if(Ls(f))throw f;if(Tt(f)||pt(f)){if(a(d.id,g=>({...g,status:Tt(f)?"redirected":pt(f)?"notFound":"error",isFetching:!1,error:f,beforeLoadPromise:void 0,loaderPromise:void 0})),f.routeId||(f.routeId=d.routeId),(p=d.beforeLoadPromise)==null||p.resolve(),(v=d.loaderPromise)==null||v.resolve(),(m=d.loadPromise)==null||m.resolve(),Tt(f))throw c=!0,f=this.resolveRedirect({...f,_fromLocation:s}),f;if(pt(f))throw this._handleNotFound(i,f,{updateMatch:a}),f}};try{await new Promise((d,f)=>{(async()=>{var p,v,m;try{const g=(y,w,C)=>{var O,E;const{id:b,routeId:T}=i[y],K=this.looseRoutesById[T];if(w instanceof Promise)throw w;w.routerCode=C,o=o??y,u(this.getMatch(b),w);try{(E=(O=K.options).onError)==null||E.call(O,w)}catch(N){w=N,u(this.getMatch(b),w)}a(b,N=>{var Q;return(Q=N.beforeLoadPromise)==null||Q.resolve(),{...N,error:w,status:"error",isFetching:!1,updatedAt:Date.now(),abortController:new AbortController,beforeLoadPromise:void 0}})};for(const[y,{id:w,routeId:C}]of i.entries()){const O=this.getMatch(w);if(O.beforeLoadPromise||O.loaderPromise)await O.beforeLoadPromise;else{try{a(w,B=>({...B,loadPromise:Kt(()=>{var nt;(nt=B.loadPromise)==null||nt.resolve()}),beforeLoadPromise:Kt()}));const E=this.looseRoutesById[C],b=new AbortController,T=(p=i[y-1])==null?void 0:p.id,K=()=>T?this.getMatch(T).context??this.options.context??{}:this.options.context??{},N=E.options.pendingMs??this.options.defaultPendingMs,Q=!!(n&&!this.isServer&&!r&&(E.options.loader||E.options.beforeLoad)&&typeof N=="number"&&N!==1/0&&(E.options.pendingComponent??this.options.defaultPendingComponent));let I;Q&&(I=setTimeout(()=>{try{l()}catch{}},N));const{paramsError:U,searchError:q}=this.getMatch(w);U&&g(y,U,"PARSE_PARAMS"),q&&g(y,q,"VALIDATE_SEARCH");const H=K();a(w,B=>({...B,isFetching:"beforeLoad",fetchCount:B.fetchCount+1,routeContext:ft(B.routeContext,H),context:ft(B.context,H),abortController:b,pendingTimeout:I}));const{search:dt,params:D,routeContext:k,cause:W}=this.getMatch(w),Z={search:dt,abortController:b,params:D,preload:!!r,context:k,location:s,navigate:B=>this.navigate({...B,_fromLocation:s}),buildLocation:this.buildLocation,cause:r?"preload":W},rt=await((m=(v=E.options).beforeLoad)==null?void 0:m.call(v,Z))??{};(Tt(rt)||pt(rt))&&g(y,rt,"BEFORE_LOAD"),a(w,B=>{const nt={...B.routeContext,...rt};return{...B,routeContext:ft(B.routeContext,nt),context:ft(B.context,nt),abortController:b}})}catch(E){g(y,E,"BEFORE_LOAD")}a(w,E=>{var b;return(b=E.beforeLoadPromise)==null||b.resolve(),{...E,beforeLoadPromise:void 0,isFetching:!1}})}}const M=i.slice(0,o),S=[];M.forEach(({id:y,routeId:w},C)=>{S.push((async()=>{const{loaderPromise:O}=this.getMatch(y);if(O)await O;else{const E=S[C-1],b=this.looseRoutesById[w],T=()=>{const{params:k,loaderDeps:W,abortController:Z,context:rt,cause:B}=this.getMatch(y);return{params:k,deps:W,preload:!!r,parentMatchPromise:E,abortController:Z,context:rt,location:s,navigate:nt=>this.navigate({...nt,_fromLocation:s}),cause:r?"preload":B,route:b}},K=Date.now()-this.getMatch(y).updatedAt,N=r?b.options.preloadStaleTime??this.options.defaultPreloadStaleTime??3e4:b.options.staleTime??this.options.defaultStaleTime??0,Q=b.options.shouldReload,I=typeof Q=="function"?Q(T()):Q;a(y,k=>({...k,loaderPromise:Kt(),preload:!!r&&!this.state.matches.find(W=>W.id===y)}));const U=async()=>{var k,W,Z,rt,B,nt,be,Mt;try{const Pt=async()=>{const at=this.getMatch(y);at.minPendingPromise&&await at.minPendingPromise};try{b._lazyPromise=b._lazyPromise||(b.lazyFn?b.lazyFn().then(V=>{Object.assign(b.options,V.options)}):Promise.resolve());const at=this.getMatch(y).componentsPromise||b._lazyPromise.then(()=>Promise.all(vr.map(async V=>{const At=b.options[V];At!=null&&At.preload&&await At.preload()})));a(y,V=>({...V,isFetching:"loader",componentsPromise:at})),await b._lazyPromise;let ot=await((W=(k=b.options).loader)==null?void 0:W.call(k,T()));this.serializeLoaderData&&(ot=this.serializeLoaderData(ot,{router:this,match:this.getMatch(y)})),u(this.getMatch(y),ot),await Pt();const bt=(rt=(Z=b.options).meta)==null?void 0:rt.call(Z,{matches:i,match:this.getMatch(y),params:this.getMatch(y).params,loaderData:ot}),$=(nt=(B=b.options).headers)==null?void 0:nt.call(B,{loaderData:ot});a(y,V=>({...V,error:void 0,status:"success",isFetching:!1,updatedAt:Date.now(),loaderData:ot,meta:bt,headers:$}))}catch(at){let ot=at;await Pt(),u(this.getMatch(y),at);try{(Mt=(be=b.options).onError)==null||Mt.call(be,at)}catch(bt){ot=bt,u(this.getMatch(y),bt)}a(y,bt=>({...bt,error:ot,status:"error",isFetching:!1}))}await this.getMatch(y).componentsPromise}catch(Pt){u(this.getMatch(y),Pt)}},{status:q,invalid:H}=this.getMatch(y);q==="success"&&(H||(I??K>N))?(async()=>{try{await U()}catch{}})():q!=="success"&&await U();const{loaderPromise:dt,loadPromise:D}=this.getMatch(y);dt==null||dt.resolve(),D==null||D.resolve()}a(y,E=>({...E,isFetching:!1,loaderPromise:void 0}))})())}),await Promise.all(S),d()}catch(g){f(g)}})()}),await l()}catch(d){if(Tt(d)||pt(d))throw pt(d)&&!r&&await l(),d}return i},this.invalidate=()=>{const s=i=>({...i,invalid:!0,...i.status==="error"?{status:"pending",error:void 0}:{}});return this.__store.setState(i=>{var r;return{...i,matches:i.matches.map(s),cachedMatches:i.cachedMatches.map(s),pendingMatches:(r=i.pendingMatches)==null?void 0:r.map(s)}}),this.load()},this.resolveRedirect=s=>{const i=s;return i.href||(i.href=this.buildLocation(i).href),i},this.cleanCache=()=>{this.__store.setState(s=>({...s,cachedMatches:s.cachedMatches.filter(i=>{const r=this.looseRoutesById[i.routeId];if(!r.options.loader)return!1;const n=(i.preload?r.options.preloadGcTime??this.options.defaultPreloadGcTime:r.options.gcTime??this.options.defaultGcTime)??5*60*1e3;return i.status!=="error"&&Date.now()-i.updatedAt{const i=this.buildLocation(s);let r=this.matchRoutes(i.pathname,i.search,{throwOnError:!0,preload:!0});const n=Object.fromEntries([...this.state.matches,...this.state.pendingMatches??[],...this.state.cachedMatches].map(o=>[o.id,!0]));this.__store.batch(()=>{r.forEach(o=>{n[o.id]||this.__store.setState(c=>({...c,cachedMatches:[...c.cachedMatches,o]}))})});const a=new Set([...this.state.matches,...this.state.pendingMatches??[]].map(o=>o.id));try{return r=await this.loadMatches({matches:r,location:i,preload:!0,updateMatch:(o,c)=>{a.has(o)?r=r.map(l=>l.id===o?c(l):l):this.updateMatch(o,c)}}),r}catch(o){if(Tt(o))return await this.preloadRoute({...o,_fromLocation:i});console.error(o);return}},this.matchRoute=(s,i)=>{const r={...s,to:s.to?this.resolvePathWithBase(s.from||"",s.to):void 0,params:s.params||{},leaveParams:!0},n=this.buildLocation(r);if(i!=null&&i.pending&&this.state.status!=="pending")return!1;const o=((i==null?void 0:i.pending)===void 0?!this.state.isLoading:i.pending)?this.latestLocation:this.state.resolvedLocation,c=Pe(this.basepath,o.pathname,{...i,to:n.pathname});return!c||s.params&&!zt(c,s.params,!0)?!1:c&&((i==null?void 0:i.includeSearch)??!0)?zt(o.search,n.search,!0)?c:!1:c},this.dehydrate=()=>{var s;const i=((s=this.options.errorSerializer)==null?void 0:s.serialize)??Mr;return{state:{dehydratedMatches:this.state.matches.map(r=>({...he(r,["id","status","updatedAt"]),error:r.error?{data:i(r.error),__isServerError:!0}:void 0}))},manifest:this.manifest}},this.hydrate=()=>{var s,i,r;let n;typeof document<"u"&&(n=this.options.transformer.parse((s=window.__TSR__)==null?void 0:s.dehydrated)),et(n),this.dehydratedData=n.payload,(r=(i=this.options).hydrate)==null||r.call(i,n.payload);const a=n.router.state,o=this.matchRoutes(this.state.location.pathname,this.state.location.search).map(c=>{const l=a.dehydratedMatches.find(u=>u.id===c.id);return et(l,`Could not find a client-side match for dehydrated match with id: ${c.id}!`),{...c,...l}});this.__store.setState(c=>({...c,matches:o})),this.manifest=n.router.manifest},this.injectedHtml=[],this.injectHtml=s=>{const i=()=>(this.injectedHtml=this.injectedHtml.filter(r=>r!==i),s);this.injectedHtml.push(i)},this.streamedKeys=new Set,this.getStreamedValue=s=>{var i;if(this.isServer)return;const r=(i=window.__TSR__)==null?void 0:i.streamedValues[s];if(r)return r.parsed||(r.parsed=this.options.transformer.parse(r.value)),r.parsed},this.streamValue=(s,i)=>{var r;Ae(!this.streamedKeys.has(s)),this.streamedKeys.add(s);const n=`__TSR__.streamedValues['${s}'] = { value: ${(r=this.serializer)==null?void 0:r.call(this,this.options.transformer.stringify(i))}}`;this.injectHtml(`