diff --git a/exam/classes/Models/Post/Post.php b/exam/classes/Models/Post/Post.php index 82fdbba..22915f9 100644 --- a/exam/classes/Models/Post/Post.php +++ b/exam/classes/Models/Post/Post.php @@ -126,7 +126,7 @@ class Post implements JsonSerializable $stmt->bindValue(":ID", $this->id); try { if (!$stmt->execute()) throw ApiError::failedUpdate(["content"]); - } catch (Exception) { + } catch (Exception $e) { throw ApiError::failedUpdate(["content"]); } } diff --git a/exam/dist/assets/index-BJXidBC9.js b/exam/dist/assets/index-BJXidBC9.js new file mode 100644 index 0000000..545484b --- /dev/null +++ b/exam/dist/assets/index-BJXidBC9.js @@ -0,0 +1,193 @@ +var vb=Object.defineProperty;var Ph=e=>{throw TypeError(e)};var yb=(e,t,n)=>t in e?vb(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Eh=(e,t,n)=>yb(e,typeof t!="symbol"?t+"":t,n),yc=(e,t,n)=>t.has(e)||Ph("Cannot "+n);var M=(e,t,n)=>(yc(e,t,"read from private field"),n?n.call(e):t.get(e)),ne=(e,t,n)=>t.has(e)?Ph("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),K=(e,t,n,r)=>(yc(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),ce=(e,t,n)=>(yc(e,t,"access private method"),n);var ma=(e,t,n,r)=>({set _(o){K(e,t,o,n)},get _(){return M(e,t,r)}});function Qv(e,t){for(var n=0;nr[o]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))r(o);new MutationObserver(o=>{for(const i of o)if(i.type==="childList")for(const s of i.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&r(s)}).observe(document,{childList:!0,subtree:!0});function n(o){const i={};return o.integrity&&(i.integrity=o.integrity),o.referrerPolicy&&(i.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?i.credentials="include":o.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(o){if(o.ep)return;o.ep=!0;const i=n(o);fetch(o.href,i)}})();var us=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ru(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Tr(e){if(e.__esModule)return e;var t=e.default;if(typeof t=="function"){var n=function r(){return this instanceof r?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach(function(r){var o=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(n,r,o.get?o:{enumerable:!0,get:function(){return e[r]}})}),n}var Gv={exports:{}},ou={},Xv={exports:{}},se={};/** + * @license React + * react.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var ra=Symbol.for("react.element"),xb=Symbol.for("react.portal"),bb=Symbol.for("react.fragment"),Sb=Symbol.for("react.strict_mode"),wb=Symbol.for("react.profiler"),Cb=Symbol.for("react.provider"),kb=Symbol.for("react.context"),Pb=Symbol.for("react.forward_ref"),Eb=Symbol.for("react.suspense"),Rb=Symbol.for("react.memo"),Ob=Symbol.for("react.lazy"),Rh=Symbol.iterator;function $b(e){return e===null||typeof e!="object"?null:(e=Rh&&e[Rh]||e["@@iterator"],typeof e=="function"?e:null)}var Yv={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Jv=Object.assign,Zv={};function Oi(e,t,n){this.props=e,this.context=t,this.refs=Zv,this.updater=n||Yv}Oi.prototype.isReactComponent={};Oi.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};Oi.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function ey(){}ey.prototype=Oi.prototype;function Kf(e,t,n){this.props=e,this.context=t,this.refs=Zv,this.updater=n||Yv}var qf=Kf.prototype=new ey;qf.constructor=Kf;Jv(qf,Oi.prototype);qf.isPureReactComponent=!0;var Oh=Array.isArray,ty=Object.prototype.hasOwnProperty,Qf={current:null},ny={key:!0,ref:!0,__self:!0,__source:!0};function ry(e,t,n){var r,o={},i=null,s=null;if(t!=null)for(r in t.ref!==void 0&&(s=t.ref),t.key!==void 0&&(i=""+t.key),t)ty.call(t,r)&&!ny.hasOwnProperty(r)&&(o[r]=t[r]);var a=arguments.length-2;if(a===1)o.children=n;else if(1{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},fi=typeof window>"u"||"Deno"in globalThis;function Qt(){}function zb(e,t){return typeof e=="function"?e(t):e}function hd(e){return typeof e=="number"&&e>=0&&e!==1/0}function sy(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Uo(e,t){return typeof e=="function"?e(t):e}function hn(e,t){return typeof e=="function"?e(t):e}function Mh(e,t){const{type:n="all",exact:r,fetchStatus:o,predicate:i,queryKey:s,stale:a}=e;if(s){if(r){if(t.queryHash!==Xf(s,t.options))return!1}else if(!Es(t.queryKey,s))return!1}if(n!=="all"){const l=t.isActive();if(n==="active"&&!l||n==="inactive"&&l)return!1}return!(typeof a=="boolean"&&t.isStale()!==a||o&&o!==t.state.fetchStatus||i&&!i(t))}function Th(e,t){const{exact:n,status:r,predicate:o,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(n){if(Ps(t.options.mutationKey)!==Ps(i))return!1}else if(!Es(t.options.mutationKey,i))return!1}return!(r&&t.state.status!==r||o&&!o(t))}function Xf(e,t){return((t==null?void 0:t.queryKeyHashFn)||Ps)(e)}function Ps(e){return JSON.stringify(e,(t,n)=>gd(n)?Object.keys(n).sort().reduce((r,o)=>(r[o]=n[o],r),{}):n)}function Es(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?!Object.keys(t).some(n=>!Es(e[n],t[n])):!1}function ay(e,t){if(e===t)return e;const n=_h(e)&&_h(t);if(n||gd(e)&&gd(t)){const r=n?e:Object.keys(e),o=r.length,i=n?t:Object.keys(t),s=i.length,a=n?[]:{};let l=0;for(let u=0;u{setTimeout(t,e)})}function vd(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?ay(e,t):t}function Ub(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function Vb(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var ly=Symbol();function uy(e,t){return!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===ly?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}var qr,dr,Zo,Dv,Hb=(Dv=class extends oa{constructor(){super();ne(this,qr);ne(this,dr);ne(this,Zo);K(this,Zo,t=>{if(!fi&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){M(this,dr)||this.setEventListener(M(this,Zo))}onUnsubscribe(){var t;this.hasListeners()||((t=M(this,dr))==null||t.call(this),K(this,dr,void 0))}setEventListener(t){var n;K(this,Zo,t),(n=M(this,dr))==null||n.call(this),K(this,dr,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){M(this,qr)!==t&&(K(this,qr,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(t)})}isFocused(){var t;return typeof M(this,qr)=="boolean"?M(this,qr):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},qr=new WeakMap,dr=new WeakMap,Zo=new WeakMap,Dv),Yf=new Hb,ei,fr,ti,zv,Wb=(zv=class extends oa{constructor(){super();ne(this,ei,!0);ne(this,fr);ne(this,ti);K(this,ti,t=>{if(!fi&&window.addEventListener){const n=()=>t(!0),r=()=>t(!1);return window.addEventListener("online",n,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",r)}}})}onSubscribe(){M(this,fr)||this.setEventListener(M(this,ti))}onUnsubscribe(){var t;this.hasListeners()||((t=M(this,fr))==null||t.call(this),K(this,fr,void 0))}setEventListener(t){var n;K(this,ti,t),(n=M(this,fr))==null||n.call(this),K(this,fr,t(this.setOnline.bind(this)))}setOnline(t){M(this,ei)!==t&&(K(this,ei,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return M(this,ei)}},ei=new WeakMap,fr=new WeakMap,ti=new WeakMap,zv),fl=new Wb;function Kb(e){return Math.min(1e3*2**e,3e4)}function cy(e){return(e??"online")==="online"?fl.isOnline():!0}var dy=class{constructor(e){this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function bc(e){return e instanceof dy}function fy(e){let t=!1,n=0,r=!1,o,i,s;const a=new Promise((h,p)=>{i=h,s=p}),l=h=>{var p;r||(v(new dy(h)),(p=e.abort)==null||p.call(e))},u=()=>{t=!0},c=()=>{t=!1},f=()=>Yf.isFocused()&&(e.networkMode==="always"||fl.isOnline())&&e.canRun(),d=()=>cy(e.networkMode)&&e.canRun(),m=h=>{var p;r||(r=!0,(p=e.onSuccess)==null||p.call(e,h),o==null||o(),i(h))},v=h=>{var p;r||(r=!0,(p=e.onError)==null||p.call(e,h),o==null||o(),s(h))},g=()=>new Promise(h=>{var p;o=y=>{(r||f())&&h(y)},(p=e.onPause)==null||p.call(e)}).then(()=>{var h;o=void 0,r||(h=e.onContinue)==null||h.call(e)}),x=()=>{if(r)return;let h;const p=n===0?e.initialPromise:void 0;try{h=p??e.fn()}catch(y){h=Promise.reject(y)}Promise.resolve(h).then(m).catch(y=>{var E;if(r)return;const b=e.retry??(fi?0:3),C=e.retryDelay??Kb,O=typeof C=="function"?C(n,y):C,k=b===!0||typeof b=="number"&&nf()?void 0:g()).then(()=>{t?v(y):x()})})};return{promise:a,cancel:l,continue:()=>(o==null||o(),a),cancelRetry:u,continueRetry:c,canStart:d,start:()=>(d()?x():g().then(x),a)}}function qb(){let e=[],t=0,n=d=>{d()},r=d=>{d()},o=d=>setTimeout(d,0);const i=d=>{o=d},s=d=>{let m;t++;try{m=d()}finally{t--,t||u()}return m},a=d=>{t?e.push(d):o(()=>{n(d)})},l=d=>(...m)=>{a(()=>{d(...m)})},u=()=>{const d=e;e=[],d.length&&o(()=>{r(()=>{d.forEach(m=>{n(m)})})})};return{batch:s,batchCalls:l,schedule:a,setNotifyFunction:d=>{n=d},setBatchNotifyFunction:d=>{r=d},setScheduler:i}}var rt=qb(),Qr,Bv,py=(Bv=class{constructor(){ne(this,Qr)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),hd(this.gcTime)&&K(this,Qr,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(fi?1/0:5*60*1e3))}clearGcTimeout(){M(this,Qr)&&(clearTimeout(M(this,Qr)),K(this,Qr,void 0))}},Qr=new WeakMap,Bv),ni,ri,qt,ut,Zs,Gr,fn,Un,Uv,Qb=(Uv=class extends py{constructor(t){super();ne(this,fn);ne(this,ni);ne(this,ri);ne(this,qt);ne(this,ut);ne(this,Zs);ne(this,Gr);K(this,Gr,!1),K(this,Zs,t.defaultOptions),this.setOptions(t.options),this.observers=[],K(this,qt,t.cache),this.queryKey=t.queryKey,this.queryHash=t.queryHash,K(this,ni,t.state||Gb(this.options)),this.state=M(this,ni),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=M(this,ut))==null?void 0:t.promise}setOptions(t){this.options={...M(this,Zs),...t},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&M(this,qt).remove(this)}setData(t,n){const r=vd(this.state.data,t,this.options);return ce(this,fn,Un).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t,n){ce(this,fn,Un).call(this,{type:"setState",state:t,setStateOptions:n})}cancel(t){var r,o;const n=(r=M(this,ut))==null?void 0:r.promise;return(o=M(this,ut))==null||o.cancel(t),n?n.then(Qt).catch(Qt):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(M(this,ni))}isActive(){return this.observers.some(t=>hn(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||!sy(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=M(this,ut))==null||n.continue()}onOnline(){var n;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=M(this,ut))==null||n.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),M(this,qt).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(n=>n!==t),this.observers.length||(M(this,ut)&&(M(this,Gr)?M(this,ut).cancel({revert:!0}):M(this,ut).cancelRetry()),this.scheduleGc()),M(this,qt).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||ce(this,fn,Un).call(this,{type:"invalidate"})}fetch(t,n){var l,u,c;if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(M(this,ut))return M(this,ut).continueRetry(),M(this,ut).promise}if(t&&this.setOptions(t),!this.options.queryFn){const f=this.observers.find(d=>d.options.queryFn);f&&this.setOptions(f.options)}const r=new AbortController,o=f=>{Object.defineProperty(f,"signal",{enumerable:!0,get:()=>(K(this,Gr,!0),r.signal)})},i=()=>{const f=uy(this.options,n),d={queryKey:this.queryKey,meta:this.meta};return o(d),K(this,Gr,!1),this.options.persister?this.options.persister(f,d,this):f(d)},s={fetchOptions:n,options:this.options,queryKey:this.queryKey,state:this.state,fetchFn:i};o(s),(l=this.options.behavior)==null||l.onFetch(s,this),K(this,ri,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((u=s.fetchOptions)==null?void 0:u.meta))&&ce(this,fn,Un).call(this,{type:"fetch",meta:(c=s.fetchOptions)==null?void 0:c.meta});const a=f=>{var d,m,v,g;bc(f)&&f.silent||ce(this,fn,Un).call(this,{type:"error",error:f}),bc(f)||((m=(d=M(this,qt).config).onError)==null||m.call(d,f,this),(g=(v=M(this,qt).config).onSettled)==null||g.call(v,this.state.data,f,this)),this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1};return K(this,ut,fy({initialPromise:n==null?void 0:n.initialPromise,fn:s.fetchFn,abort:r.abort.bind(r),onSuccess:f=>{var d,m,v,g;if(f===void 0){a(new Error(`${this.queryHash} data is undefined`));return}this.setData(f),(m=(d=M(this,qt).config).onSuccess)==null||m.call(d,f,this),(g=(v=M(this,qt).config).onSettled)==null||g.call(v,f,this.state.error,this),this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1},onError:a,onFail:(f,d)=>{ce(this,fn,Un).call(this,{type:"failed",failureCount:f,error:d})},onPause:()=>{ce(this,fn,Un).call(this,{type:"pause"})},onContinue:()=>{ce(this,fn,Un).call(this,{type:"continue"})},retry:s.options.retry,retryDelay:s.options.retryDelay,networkMode:s.options.networkMode,canRun:()=>!0})),M(this,ut).start()}},ni=new WeakMap,ri=new WeakMap,qt=new WeakMap,ut=new WeakMap,Zs=new WeakMap,Gr=new WeakMap,fn=new WeakSet,Un=function(t){const n=r=>{switch(t.type){case"failed":return{...r,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...hy(r.data,this.options),fetchMeta:t.meta??null};case"success":return{...r,data:t.data,dataUpdateCount:r.dataUpdateCount+1,dataUpdatedAt:t.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const o=t.error;return bc(o)&&o.revert&&M(this,ri)?{...M(this,ri),fetchStatus:"idle"}:{...r,error:o,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:o,fetchStatus:"idle",status:"error"};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=n(this.state),rt.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),M(this,qt).notify({query:this,type:"updated",action:t})})},Uv);function hy(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:cy(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function Gb(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var En,Vv,Xb=(Vv=class extends oa{constructor(t={}){super();ne(this,En);this.config=t,K(this,En,new Map)}build(t,n,r){const o=n.queryKey,i=n.queryHash??Xf(o,n);let s=this.get(i);return s||(s=new Qb({cache:this,queryKey:o,queryHash:i,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(o)}),this.add(s)),s}add(t){M(this,En).has(t.queryHash)||(M(this,En).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=M(this,En).get(t.queryHash);n&&(t.destroy(),n===t&&M(this,En).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){rt.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return M(this,En).get(t)}getAll(){return[...M(this,En).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>Mh(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>Mh(t,r)):n}notify(t){rt.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){rt.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){rt.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},En=new WeakMap,Vv),Rn,mt,Xr,On,ir,Hv,Yb=(Hv=class extends py{constructor(t){super();ne(this,On);ne(this,Rn);ne(this,mt);ne(this,Xr);this.mutationId=t.mutationId,K(this,mt,t.mutationCache),K(this,Rn,[]),this.state=t.state||Jb(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){M(this,Rn).includes(t)||(M(this,Rn).push(t),this.clearGcTimeout(),M(this,mt).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){K(this,Rn,M(this,Rn).filter(n=>n!==t)),this.scheduleGc(),M(this,mt).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){M(this,Rn).length||(this.state.status==="pending"?this.scheduleGc():M(this,mt).remove(this))}continue(){var t;return((t=M(this,Xr))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var o,i,s,a,l,u,c,f,d,m,v,g,x,h,p,y,b,C,O,k;K(this,Xr,fy({fn:()=>this.options.mutationFn?this.options.mutationFn(t):Promise.reject(new Error("No mutationFn found")),onFail:(E,_)=>{ce(this,On,ir).call(this,{type:"failed",failureCount:E,error:_})},onPause:()=>{ce(this,On,ir).call(this,{type:"pause"})},onContinue:()=>{ce(this,On,ir).call(this,{type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>M(this,mt).canRun(this)}));const n=this.state.status==="pending",r=!M(this,Xr).canStart();try{if(!n){ce(this,On,ir).call(this,{type:"pending",variables:t,isPaused:r}),await((i=(o=M(this,mt).config).onMutate)==null?void 0:i.call(o,t,this));const _=await((a=(s=this.options).onMutate)==null?void 0:a.call(s,t));_!==this.state.context&&ce(this,On,ir).call(this,{type:"pending",context:_,variables:t,isPaused:r})}const E=await M(this,Xr).start();return await((u=(l=M(this,mt).config).onSuccess)==null?void 0:u.call(l,E,t,this.state.context,this)),await((f=(c=this.options).onSuccess)==null?void 0:f.call(c,E,t,this.state.context)),await((m=(d=M(this,mt).config).onSettled)==null?void 0:m.call(d,E,null,this.state.variables,this.state.context,this)),await((g=(v=this.options).onSettled)==null?void 0:g.call(v,E,null,t,this.state.context)),ce(this,On,ir).call(this,{type:"success",data:E}),E}catch(E){try{throw await((h=(x=M(this,mt).config).onError)==null?void 0:h.call(x,E,t,this.state.context,this)),await((y=(p=this.options).onError)==null?void 0:y.call(p,E,t,this.state.context)),await((C=(b=M(this,mt).config).onSettled)==null?void 0:C.call(b,void 0,E,this.state.variables,this.state.context,this)),await((k=(O=this.options).onSettled)==null?void 0:k.call(O,void 0,E,t,this.state.context)),E}finally{ce(this,On,ir).call(this,{type:"error",error:E})}}finally{M(this,mt).runNext(this)}}},Rn=new WeakMap,mt=new WeakMap,Xr=new WeakMap,On=new WeakSet,ir=function(t){const n=r=>{switch(t.type){case"failed":return{...r,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,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{...r,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:t.error,failureCount:r.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=n(this.state),rt.batch(()=>{M(this,Rn).forEach(r=>{r.onMutationUpdate(t)}),M(this,mt).notify({mutation:this,type:"updated",action:t})})},Hv);function Jb(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Lt,ea,Wv,Zb=(Wv=class extends oa{constructor(t={}){super();ne(this,Lt);ne(this,ea);this.config=t,K(this,Lt,new Map),K(this,ea,Date.now())}build(t,n,r){const o=new Yb({mutationCache:this,mutationId:++ma(this,ea)._,options:t.defaultMutationOptions(n),state:r});return this.add(o),o}add(t){const n=va(t),r=M(this,Lt).get(n)??[];r.push(t),M(this,Lt).set(n,r),this.notify({type:"added",mutation:t})}remove(t){var r;const n=va(t);if(M(this,Lt).has(n)){const o=(r=M(this,Lt).get(n))==null?void 0:r.filter(i=>i!==t);o&&(o.length===0?M(this,Lt).delete(n):M(this,Lt).set(n,o))}this.notify({type:"removed",mutation:t})}canRun(t){var r;const n=(r=M(this,Lt).get(va(t)))==null?void 0:r.find(o=>o.state.status==="pending");return!n||n===t}runNext(t){var r;const n=(r=M(this,Lt).get(va(t)))==null?void 0:r.find(o=>o!==t&&o.state.isPaused);return(n==null?void 0:n.continue())??Promise.resolve()}clear(){rt.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}getAll(){return[...M(this,Lt).values()].flat()}find(t){const n={exact:!0,...t};return this.getAll().find(r=>Th(n,r))}findAll(t={}){return this.getAll().filter(n=>Th(t,n))}notify(t){rt.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return rt.batch(()=>Promise.all(t.map(n=>n.continue().catch(Qt))))}},Lt=new WeakMap,ea=new WeakMap,Wv);function va(e){var t;return((t=e.options.scope)==null?void 0:t.id)??String(e.mutationId)}function eS(e){return{onFetch:(t,n)=>{const r=async()=>{var v,g,x,h,p;const o=t.options,i=(x=(g=(v=t.fetchOptions)==null?void 0:v.meta)==null?void 0:g.fetchMore)==null?void 0:x.direction,s=((h=t.state.data)==null?void 0:h.pages)||[],a=((p=t.state.data)==null?void 0:p.pageParams)||[],l={pages:[],pageParams:[]};let u=!1;const c=y=>{Object.defineProperty(y,"signal",{enumerable:!0,get:()=>(t.signal.aborted?u=!0:t.signal.addEventListener("abort",()=>{u=!0}),t.signal)})},f=uy(t.options,t.fetchOptions),d=async(y,b,C)=>{if(u)return Promise.reject();if(b==null&&y.pages.length)return Promise.resolve(y);const O={queryKey:t.queryKey,pageParam:b,direction:C?"backward":"forward",meta:t.options.meta};c(O);const k=await f(O),{maxPages:E}=t.options,_=C?Vb:Ub;return{pages:_(y.pages,k,E),pageParams:_(y.pageParams,b,E)}};let m;if(i&&s.length){const y=i==="backward",b=y?tS:Ih,C={pages:s,pageParams:a},O=b(o,C);m=await d(C,O,y)}else{m=await d(l,a[0]??o.initialPageParam);const y=e??s.length;for(let b=1;b{var o,i;return(i=(o=t.options).persister)==null?void 0:i.call(o,r,{queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=r}}}function Ih(e,{pages:t,pageParams:n}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function tS(e,{pages:t,pageParams:n}){var r;return t.length>0?(r=e.getPreviousPageParam)==null?void 0:r.call(e,t[0],t,n[0],n):void 0}var ze,pr,hr,oi,ii,mr,si,ai,Kv,nS=(Kv=class{constructor(e={}){ne(this,ze);ne(this,pr);ne(this,hr);ne(this,oi);ne(this,ii);ne(this,mr);ne(this,si);ne(this,ai);K(this,ze,e.queryCache||new Xb),K(this,pr,e.mutationCache||new Zb),K(this,hr,e.defaultOptions||{}),K(this,oi,new Map),K(this,ii,new Map),K(this,mr,0)}mount(){ma(this,mr)._++,M(this,mr)===1&&(K(this,si,Yf.subscribe(async e=>{e&&(await this.resumePausedMutations(),M(this,ze).onFocus())})),K(this,ai,fl.subscribe(async e=>{e&&(await this.resumePausedMutations(),M(this,ze).onOnline())})))}unmount(){var e,t;ma(this,mr)._--,M(this,mr)===0&&((e=M(this,si))==null||e.call(this),K(this,si,void 0),(t=M(this,ai))==null||t.call(this),K(this,ai,void 0))}isFetching(e){return M(this,ze).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return M(this,pr).findAll({...e,status:"pending"}).length}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=M(this,ze).get(t.queryHash))==null?void 0:n.state.data}ensureQueryData(e){const t=this.getQueryData(e.queryKey);if(t===void 0)return this.fetchQuery(e);{const n=this.defaultQueryOptions(e),r=M(this,ze).build(this,n);return e.revalidateIfStale&&r.isStaleByTime(Uo(n.staleTime,r))&&this.prefetchQuery(n),Promise.resolve(t)}}getQueriesData(e){return M(this,ze).findAll(e).map(({queryKey:t,state:n})=>{const r=n.data;return[t,r]})}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),o=M(this,ze).get(r.queryHash),i=o==null?void 0:o.state.data,s=zb(t,i);if(s!==void 0)return M(this,ze).build(this,r).setData(s,{...n,manual:!0})}setQueriesData(e,t,n){return rt.batch(()=>M(this,ze).findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=M(this,ze).get(t.queryHash))==null?void 0:n.state}removeQueries(e){const t=M(this,ze);rt.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=M(this,ze),r={type:"active",...e};return rt.batch(()=>(n.findAll(e).forEach(o=>{o.reset()}),this.refetchQueries(r,t)))}cancelQueries(e={},t={}){const n={revert:!0,...t},r=rt.batch(()=>M(this,ze).findAll(e).map(o=>o.cancel(n)));return Promise.all(r).then(Qt).catch(Qt)}invalidateQueries(e={},t={}){return rt.batch(()=>{if(M(this,ze).findAll(e).forEach(r=>{r.invalidate()}),e.refetchType==="none")return Promise.resolve();const n={...e,type:e.refetchType??e.type??"active"};return this.refetchQueries(n,t)})}refetchQueries(e={},t){const n={...t,cancelRefetch:(t==null?void 0:t.cancelRefetch)??!0},r=rt.batch(()=>M(this,ze).findAll(e).filter(o=>!o.isDisabled()).map(o=>{let i=o.fetch(void 0,n);return n.throwOnError||(i=i.catch(Qt)),o.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(r).then(Qt)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=M(this,ze).build(this,t);return n.isStaleByTime(Uo(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Qt).catch(Qt)}fetchInfiniteQuery(e){return e.behavior=eS(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Qt).catch(Qt)}resumePausedMutations(){return fl.isOnline()?M(this,pr).resumePausedMutations():Promise.resolve()}getQueryCache(){return M(this,ze)}getMutationCache(){return M(this,pr)}getDefaultOptions(){return M(this,hr)}setDefaultOptions(e){K(this,hr,e)}setQueryDefaults(e,t){M(this,oi).set(Ps(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...M(this,oi).values()];let n={};return t.forEach(r=>{Es(e,r.queryKey)&&(n={...n,...r.defaultOptions})}),n}setMutationDefaults(e,t){M(this,ii).set(Ps(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...M(this,ii).values()];let n={};return t.forEach(r=>{Es(e,r.mutationKey)&&(n={...n,...r.defaultOptions})}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...M(this,hr).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=Xf(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===ly&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...M(this,hr).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){M(this,ze).clear(),M(this,pr).clear()}},ze=new WeakMap,pr=new WeakMap,hr=new WeakMap,oi=new WeakMap,ii=new WeakMap,mr=new WeakMap,si=new WeakMap,ai=new WeakMap,Kv),kt,de,ta,gt,Yr,li,$n,na,ui,ci,Jr,Zr,gr,di,ye,rs,yd,xd,bd,Sd,wd,Cd,kd,my,qv,rS=(qv=class extends oa{constructor(t,n){super();ne(this,ye);ne(this,kt);ne(this,de);ne(this,ta);ne(this,gt);ne(this,Yr);ne(this,li);ne(this,$n);ne(this,na);ne(this,ui);ne(this,ci);ne(this,Jr);ne(this,Zr);ne(this,gr);ne(this,di,new Set);this.options=n,K(this,kt,t),K(this,$n,null),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(M(this,de).addObserver(this),Fh(M(this,de),this.options)?ce(this,ye,rs).call(this):this.updateResult(),ce(this,ye,Sd).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Pd(M(this,de),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Pd(M(this,de),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,ce(this,ye,wd).call(this),ce(this,ye,Cd).call(this),M(this,de).removeObserver(this)}setOptions(t,n){const r=this.options,o=M(this,de);if(this.options=M(this,kt).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof hn(this.options.enabled,M(this,de))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");ce(this,ye,kd).call(this),M(this,de).setOptions(this.options),r._defaulted&&!md(this.options,r)&&M(this,kt).getQueryCache().notify({type:"observerOptionsUpdated",query:M(this,de),observer:this});const i=this.hasListeners();i&&Nh(M(this,de),o,this.options,r)&&ce(this,ye,rs).call(this),this.updateResult(n),i&&(M(this,de)!==o||hn(this.options.enabled,M(this,de))!==hn(r.enabled,M(this,de))||Uo(this.options.staleTime,M(this,de))!==Uo(r.staleTime,M(this,de)))&&ce(this,ye,yd).call(this);const s=ce(this,ye,xd).call(this);i&&(M(this,de)!==o||hn(this.options.enabled,M(this,de))!==hn(r.enabled,M(this,de))||s!==M(this,gr))&&ce(this,ye,bd).call(this,s)}getOptimisticResult(t){const n=M(this,kt).getQueryCache().build(M(this,kt),t),r=this.createResult(n,t);return iS(this,r)&&(K(this,gt,r),K(this,li,this.options),K(this,Yr,M(this,de).state)),r}getCurrentResult(){return M(this,gt)}trackResult(t,n){const r={};return Object.keys(t).forEach(o=>{Object.defineProperty(r,o,{configurable:!1,enumerable:!0,get:()=>(this.trackProp(o),n==null||n(o),t[o])})}),r}trackProp(t){M(this,di).add(t)}getCurrentQuery(){return M(this,de)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=M(this,kt).defaultQueryOptions(t),r=M(this,kt).getQueryCache().build(M(this,kt),n);return r.isFetchingOptimistic=!0,r.fetch().then(()=>this.createResult(r,n))}fetch(t){return ce(this,ye,rs).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),M(this,gt)))}createResult(t,n){var k;const r=M(this,de),o=this.options,i=M(this,gt),s=M(this,Yr),a=M(this,li),u=t!==r?t.state:M(this,ta),{state:c}=t;let f={...c},d=!1,m;if(n._optimisticResults){const E=this.hasListeners(),_=!E&&Fh(t,n),L=E&&Nh(t,r,n,o);(_||L)&&(f={...f,...hy(c.data,t.options)}),n._optimisticResults==="isRestoring"&&(f.fetchStatus="idle")}let{error:v,errorUpdatedAt:g,status:x}=f;if(n.select&&f.data!==void 0)if(i&&f.data===(s==null?void 0:s.data)&&n.select===M(this,na))m=M(this,ui);else try{K(this,na,n.select),m=n.select(f.data),m=vd(i==null?void 0:i.data,m,n),K(this,ui,m),K(this,$n,null)}catch(E){K(this,$n,E)}else m=f.data;if(n.placeholderData!==void 0&&m===void 0&&x==="pending"){let E;if(i!=null&&i.isPlaceholderData&&n.placeholderData===(a==null?void 0:a.placeholderData))E=i.data;else if(E=typeof n.placeholderData=="function"?n.placeholderData((k=M(this,ci))==null?void 0:k.state.data,M(this,ci)):n.placeholderData,n.select&&E!==void 0)try{E=n.select(E),K(this,$n,null)}catch(_){K(this,$n,_)}E!==void 0&&(x="success",m=vd(i==null?void 0:i.data,E,n),d=!0)}M(this,$n)&&(v=M(this,$n),m=M(this,ui),g=Date.now(),x="error");const h=f.fetchStatus==="fetching",p=x==="pending",y=x==="error",b=p&&h,C=m!==void 0;return{status:x,fetchStatus:f.fetchStatus,isPending:p,isSuccess:x==="success",isError:y,isInitialLoading:b,isLoading:b,data:m,dataUpdatedAt:f.dataUpdatedAt,error:v,errorUpdatedAt:g,failureCount:f.fetchFailureCount,failureReason:f.fetchFailureReason,errorUpdateCount:f.errorUpdateCount,isFetched:f.dataUpdateCount>0||f.errorUpdateCount>0,isFetchedAfterMount:f.dataUpdateCount>u.dataUpdateCount||f.errorUpdateCount>u.errorUpdateCount,isFetching:h,isRefetching:h&&!p,isLoadingError:y&&!C,isPaused:f.fetchStatus==="paused",isPlaceholderData:d,isRefetchError:y&&C,isStale:Jf(t,n),refetch:this.refetch}}updateResult(t){const n=M(this,gt),r=this.createResult(M(this,de),this.options);if(K(this,Yr,M(this,de).state),K(this,li,this.options),M(this,Yr).data!==void 0&&K(this,ci,M(this,de)),md(r,n))return;K(this,gt,r);const o={},i=()=>{if(!n)return!0;const{notifyOnChangeProps:s}=this.options,a=typeof s=="function"?s():s;if(a==="all"||!a&&!M(this,di).size)return!0;const l=new Set(a??M(this,di));return this.options.throwOnError&&l.add("error"),Object.keys(M(this,gt)).some(u=>{const c=u;return M(this,gt)[c]!==n[c]&&l.has(c)})};(t==null?void 0:t.listeners)!==!1&&i()&&(o.listeners=!0),ce(this,ye,my).call(this,{...o,...t})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&ce(this,ye,Sd).call(this)}},kt=new WeakMap,de=new WeakMap,ta=new WeakMap,gt=new WeakMap,Yr=new WeakMap,li=new WeakMap,$n=new WeakMap,na=new WeakMap,ui=new WeakMap,ci=new WeakMap,Jr=new WeakMap,Zr=new WeakMap,gr=new WeakMap,di=new WeakMap,ye=new WeakSet,rs=function(t){ce(this,ye,kd).call(this);let n=M(this,de).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(Qt)),n},yd=function(){ce(this,ye,wd).call(this);const t=Uo(this.options.staleTime,M(this,de));if(fi||M(this,gt).isStale||!hd(t))return;const r=sy(M(this,gt).dataUpdatedAt,t)+1;K(this,Jr,setTimeout(()=>{M(this,gt).isStale||this.updateResult()},r))},xd=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(M(this,de)):this.options.refetchInterval)??!1},bd=function(t){ce(this,ye,Cd).call(this),K(this,gr,t),!(fi||hn(this.options.enabled,M(this,de))===!1||!hd(M(this,gr))||M(this,gr)===0)&&K(this,Zr,setInterval(()=>{(this.options.refetchIntervalInBackground||Yf.isFocused())&&ce(this,ye,rs).call(this)},M(this,gr)))},Sd=function(){ce(this,ye,yd).call(this),ce(this,ye,bd).call(this,ce(this,ye,xd).call(this))},wd=function(){M(this,Jr)&&(clearTimeout(M(this,Jr)),K(this,Jr,void 0))},Cd=function(){M(this,Zr)&&(clearInterval(M(this,Zr)),K(this,Zr,void 0))},kd=function(){const t=M(this,kt).getQueryCache().build(M(this,kt),this.options);if(t===M(this,de))return;const n=M(this,de);K(this,de,t),K(this,ta,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},my=function(t){rt.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(M(this,gt))}),M(this,kt).getQueryCache().notify({query:M(this,de),type:"observerResultsUpdated"})})},qv);function oS(e,t){return hn(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function Fh(e,t){return oS(e,t)||e.state.data!==void 0&&Pd(e,t,t.refetchOnMount)}function Pd(e,t,n){if(hn(t.enabled,e)!==!1){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&Jf(e,t)}return!1}function Nh(e,t,n,r){return(e!==t||hn(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&Jf(e,n)}function Jf(e,t){return hn(t.enabled,e)!==!1&&e.isStaleByTime(Uo(t.staleTime,e))}function iS(e,t){return!md(e.getCurrentResult(),t)}var gy=S.createContext(void 0),sS=e=>{const t=S.useContext(gy);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},aS=({client:e,children:t})=>(S.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),P.jsx(gy.Provider,{value:e,children:t})),vy=S.createContext(!1),lS=()=>S.useContext(vy);vy.Provider;function uS(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var cS=S.createContext(uS()),dS=()=>S.useContext(cS);function fS(e,t){return typeof e=="function"?e(...t):!!e}var pS=(e,t)=>{(e.suspense||e.throwOnError)&&(t.isReset()||(e.retryOnMount=!1))},hS=e=>{S.useEffect(()=>{e.clearReset()},[e])},mS=({result:e,errorResetBoundary:t,throwOnError:n,query:r})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&fS(n,[e.error,r]),gS=(e,t)=>t.state.data===void 0,vS=e=>{e.suspense&&typeof e.staleTime!="number"&&(e.staleTime=1e3)},yS=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,xS=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function bS(e,t,n){var u,c,f,d;const r=sS(),o=lS(),i=dS(),s=r.defaultQueryOptions(e);(c=(u=r.getDefaultOptions().queries)==null?void 0:u._experimental_beforeQuery)==null||c.call(u,s),s._optimisticResults=o?"isRestoring":"optimistic",vS(s),pS(s,i),hS(i);const[a]=S.useState(()=>new t(r,s)),l=a.getOptimisticResult(s);if(S.useSyncExternalStore(S.useCallback(m=>{const v=o?()=>{}:a.subscribe(rt.batchCalls(m));return a.updateResult(),v},[a,o]),()=>a.getCurrentResult(),()=>a.getCurrentResult()),S.useEffect(()=>{a.setOptions(s,{listeners:!1})},[s,a]),yS(s,l))throw xS(s,a,i);if(mS({result:l,errorResetBoundary:i,throwOnError:s.throwOnError,query:r.getQueryCache().get(s.queryHash)}))throw l.error;return(d=(f=r.getDefaultOptions().queries)==null?void 0:f._experimental_afterQuery)==null||d.call(f,s,l),s.notifyOnChangeProps?l:a.trackResult(l)}function SS(e,t){return bS({...e,enabled:!0,suspense:!0,throwOnError:gS,placeholderData:void 0},rS)}const Ah="pushstate",jh="popstate",yy="beforeunload",xy=e=>(e.preventDefault(),e.returnValue=""),wS=()=>{removeEventListener(yy,xy,{capture:!0})};function by(e){let t=e.getLocation();const n=new Set;let r=[];const o=()=>{t=e.getLocation(),n.forEach(s=>s())},i=async(s,a)=>{var l;if(!((a==null?void 0:a.ignoreBlocker)??!1)&&typeof document<"u"&&r.length){for(const c of r)if(!await c()){(l=e.onBlocked)==null||l.call(e,o);return}}s()};return{get location(){return t},subscribers:n,subscribe:s=>(n.add(s),()=>{n.delete(s)}),push:(s,a,l)=>{a=cs(a),i(()=>{e.pushState(s,a),o()},l)},replace:(s,a,l)=>{a=cs(a),i(()=>{e.replaceState(s,a),o()},l)},go:(s,a)=>{i(()=>{e.go(s),o()},a)},back:s=>{i(()=>{e.back(),o()},s)},forward:s=>{i(()=>{e.forward(),o()},s)},createHref:s=>e.createHref(s),block:s=>(r.push(s),r.length===1&&addEventListener(yy,xy,{capture:!0}),()=>{r=r.filter(a=>a!==s),r.length||wS()}),flush:()=>{var s;return(s=e.flush)==null?void 0:s.call(e)},destroy:()=>{var s;return(s=e.destroy)==null?void 0:s.call(e)},notify:o}}function cs(e){return e||(e={}),{...e,key:Sy()}}function CS(e){const t=typeof document<"u"?window:void 0,n=t.history.pushState,r=t.history.replaceState,o=g=>g,i=()=>Ed(`${t.location.pathname}${t.location.search}${t.location.hash}`,t.history.state);let s=i(),a;const l=()=>s;let u,c;const f=()=>{if(!u)return;(u.isPush?n:r).call(t.history,u.state,"",u.href),u=void 0,c=void 0,a=void 0},d=(g,x,h)=>{const p=o(x);c||(a=s),s=Ed(x,h),u={href:p,state:h,isPush:(u==null?void 0:u.isPush)||g==="push"},c||(c=Promise.resolve().then(()=>f()))},m=()=>{s=i(),v.notify()},v=by({getLocation:l,pushState:(g,x)=>d("push",g,x),replaceState:(g,x)=>d("replace",g,x),back:()=>t.history.back(),forward:()=>t.history.forward(),go:g=>t.history.go(g),createHref:g=>o(g),flush:f,destroy:()=>{t.history.pushState=n,t.history.replaceState=r,t.removeEventListener(Ah,m),t.removeEventListener(jh,m)},onBlocked:g=>{a&&s!==a&&(s=a,g())}});return t.addEventListener(Ah,m),t.addEventListener(jh,m),t.history.pushState=function(...g){const x=n.apply(t.history,g);return m(),x},t.history.replaceState=function(...g){const x=r.apply(t.history,g);return m(),x},v}function kS(e={initialEntries:["/"]}){const t=e.initialEntries;let n=e.initialIndex??t.length-1,r={key:Sy()};return by({getLocation:()=>Ed(t[n],r),pushState:(i,s)=>{r=s,t.splice,n{r=s,t[n]=i},back:()=>{r=cs(r),n=Math.max(n-1,0)},forward:()=>{r=cs(r),n=Math.min(n+1,t.length-1)},go:i=>{r=cs(r),n=Math.min(Math.max(n+i,0),t.length-1)},createHref:i=>i})}function Ed(e,t){const n=e.indexOf("#"),r=e.indexOf("?");return{href:e,pathname:e.substring(0,n>0?r>0?Math.min(n,r):n:r>0?r:e.length),hash:n>-1?e.substring(n):"",search:r>-1?e.slice(r,n===-1?void 0:n):"",state:t||{}}}function Sy(){return(Math.random()+1).toString(36).substring(7)}var PS="Invariant failed";function Pt(e,t){if(!e)throw new Error(PS)}const Sc=S.createContext(null);function wy(){return typeof document>"u"?Sc:window.__TSR_ROUTER_CONTEXT__?window.__TSR_ROUTER_CONTEXT__:(window.__TSR_ROUTER_CONTEXT__=Sc,Sc)}function An(e){const t=S.useContext(wy());return e==null||e.warn,t}var Cy={exports:{}},ky={},Py={exports:{}},Ey={};/** + * @license React + * use-sync-external-store-shim.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var pi=S;function ES(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var RS=typeof Object.is=="function"?Object.is:ES,OS=pi.useState,$S=pi.useEffect,MS=pi.useLayoutEffect,TS=pi.useDebugValue;function _S(e,t){var n=t(),r=OS({inst:{value:n,getSnapshot:t}}),o=r[0].inst,i=r[1];return MS(function(){o.value=n,o.getSnapshot=t,wc(o)&&i({inst:o})},[e,n,t]),$S(function(){return wc(o)&&i({inst:o}),e(function(){wc(o)&&i({inst:o})})},[e]),TS(n),n}function wc(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!RS(e,n)}catch{return!0}}function LS(e,t){return t()}var IS=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?LS:_S;Ey.useSyncExternalStore=pi.useSyncExternalStore!==void 0?pi.useSyncExternalStore:IS;Py.exports=Ey;var FS=Py.exports;/** + * @license React + * use-sync-external-store-shim/with-selector.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var iu=S,NS=FS;function AS(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var jS=typeof Object.is=="function"?Object.is:AS,DS=NS.useSyncExternalStore,zS=iu.useRef,BS=iu.useEffect,US=iu.useMemo,VS=iu.useDebugValue;ky.useSyncExternalStoreWithSelector=function(e,t,n,r,o){var i=zS(null);if(i.current===null){var s={hasValue:!1,value:null};i.current=s}else s=i.current;i=US(function(){function l(m){if(!u){if(u=!0,c=m,m=r(m),o!==void 0&&s.hasValue){var v=s.value;if(o(v,m))return f=v}return f=m}if(v=f,jS(c,m))return v;var g=r(m);return o!==void 0&&o(v,g)?v:(c=m,f=g)}var u=!1,c,f,d=n===void 0?null:n;return[function(){return l(t())},d===null?void 0:function(){return l(d())}]},[t,n,r,o]);var a=DS(e,i[0],i[1]);return BS(function(){s.hasValue=!0,s.value=a},[a]),VS(a),a};Cy.exports=ky;var HS=Cy.exports;class Zf{constructor(t,n){this.listeners=new Set,this._batching=!1,this._flushing=0,this.subscribe=r=>{var o,i;this.listeners.add(r);const s=(i=(o=this.options)==null?void 0:o.onSubscribe)==null?void 0:i.call(o,r,this);return()=>{this.listeners.delete(r),s==null||s()}},this.setState=r=>{var o,i,s;const a=this.state;this.state=(o=this.options)!=null&&o.updateFn?this.options.updateFn(a)(r):r(a),(s=(i=this.options)==null?void 0:i.onUpdate)==null||s.call(i),this._flush()},this._flush=()=>{if(this._batching)return;const r=++this._flushing;this.listeners.forEach(o=>{this._flushing===r&&o()})},this.batch=r=>{if(this._batching)return r();this._batching=!0,r(),this._batching=!1,this._flush()},this.state=t,this.options=n}}function pl(e,t=n=>n){return HS.useSyncExternalStoreWithSelector(e.subscribe,()=>e.state,()=>e.state,t,WS)}function WS(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r=0;r{t.substring(0,1)==="?"&&(t=t.substring(1));const n=qS(t);for(const r in n){const o=n[r];if(typeof o=="string")try{n[r]=e(o)}catch{}}return n}}function YS(e,t){function n(r){if(typeof r=="object"&&r!==null)try{return e(r)}catch{}else if(typeof r=="string"&&typeof t=="function")try{return t(r),e(r)}catch{}return r}return r=>{r={...r},Object.keys(r).forEach(i=>{const s=r[i];typeof s>"u"||s===void 0?delete r[i]:r[i]=n(s)});const o=KS(r).toString();return o?`?${o}`:""}}function hl(e){return e[e.length-1]}function JS(e){return typeof e=="function"}function $o(e,t){return JS(e)?e(t):e}function ds(e,t){return t.reduce((n,r)=>(n[r]=e[r],n),{})}function Cn(e,t){if(e===t)return e;const n=t,r=Bh(e)&&Bh(n);if(r||ml(e)&&ml(n)){const o=r?e:Object.keys(e),i=o.length,s=r?n:Object.keys(n),a=s.length,l=r?[]:{};let u=0;for(let c=0;c"u")return!0;const n=t.prototype;return!(!zh(n)||!n.hasOwnProperty("isPrototypeOf"))}function zh(e){return Object.prototype.toString.call(e)==="[object Object]"}function Bh(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Vo(e,t,n=!1){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(ml(e)&&ml(t)){const r=Object.keys(e).filter(i=>e[i]!==void 0),o=Object.keys(t).filter(i=>t[i]!==void 0);return!n&&r.length!==o.length?!1:!o.some(i=>!(i in e)||!Vo(e[i],t[i],n))}return Array.isArray(e)&&Array.isArray(t)?e.length!==t.length?!1:!e.some((r,o)=>!Vo(r,t[o],n)):!1}const Cc=typeof window<"u"?S.useLayoutEffect:S.useEffect;function Ro(e){let t,n;const r=new Promise((o,i)=>{t=o,n=i});return r.status="pending",r.resolve=o=>{r.status="resolved",r.value=o,t(o),e==null||e(o)},r.reject=o=>{r.status="rejected",n(o)},r}function Uh(e){const t=S.useRef({value:e,prev:null}),n=t.current.value;return e!==n&&(t.current={value:e,prev:n}),t.current.prev}function xr(e){return su(e.filter(Boolean).join("/"))}function su(e){return e.replace(/\/{2,}/g,"/")}function ep(e){return e==="/"?e:e.replace(/^\/{1,}/,"")}function Br(e){return e==="/"?e:e.replace(/\/{1,}$/,"")}function ZS(e){return Br(ep(e))}function gl(e,t){return e.endsWith("/")&&e!=="/"&&e!==`${t}/`?e.slice(0,-1):e}function ew(e,t,n){return gl(e,n)===gl(t,n)}function tw({basepath:e,base:t,to:n,trailingSlash:r="never"}){var o,i;t=t.replace(new RegExp(`^${e}`),"/"),n=n.replace(new RegExp(`^${e}`),"/");let s=hi(t);const a=hi(n);s.length>1&&((o=hl(s))==null?void 0:o.value)==="/"&&s.pop(),a.forEach((u,c)=>{u.value==="/"?c?c===a.length-1&&s.push(u):s=[u]:u.value===".."?s.pop():u.value==="."||s.push(u)}),s.length>1&&(((i=hl(s))==null?void 0:i.value)==="/"?r==="never"&&s.pop():r==="always"&&s.push({type:"pathname",value:"/"}));const l=xr([e,...s.map(u=>u.value)]);return su(l)}function hi(e){if(!e)return[];e=su(e);const t=[];if(e.slice(0,1)==="/"&&(e=e.substring(1),t.push({type:"pathname",value:"/"})),!e)return t;const n=e.split("/").filter(Boolean);return t.push(...n.map(r=>r==="$"||r==="*"?{type:"wildcard",value:r}:r.charAt(0)==="$"?{type:"param",value:r}:{type:"pathname",value:decodeURIComponent(r)})),e.slice(-1)==="/"&&(e=e.substring(1),t.push({type:"pathname",value:"/"})),t}function kc({path:e,params:t,leaveWildcards:n,leaveParams:r}){const o=hi(e),i={};for(const[s,a]of Object.entries(t)){const l=typeof a=="string";["*","_splat"].includes(s)?i[s]=l?encodeURI(a):a:i[s]=l?encodeURIComponent(a):a}return xr(o.map(s=>{if(s.type==="wildcard"){const a=i._splat;return n?`${s.value}${a??""}`:a}if(s.type==="param"){if(r){const a=i[s.value];return`${s.value}${a??""}`}return i[s.value.substring(1)]??"undefined"}return s.value}))}function ya(e,t,n){const r=nw(e,t,n);if(!(n.to&&!r))return r??{}}function Vh(e,t){switch(!0){case e==="/":return t;case t===e:return"";case t.length{for(let l=0;l=o.length-1,d=l>=i.length-1;if(c){if(c.type==="wildcard"){if(u!=null&&u.value){const m=decodeURI(xr(o.slice(l).map(v=>v.value)));return s["*"]=m,s._splat=m,!0}return!1}if(c.type==="pathname"){if(c.value==="/"&&!(u!=null&&u.value))return!0;if(u){if(n.caseSensitive){if(c.value!==u.value)return!1}else if(c.value.toLowerCase()!==u.value.toLowerCase())return!1}}if(!u)return!1;if(c.type==="param"){if(u.value==="/")return!1;u.value.charAt(0)!=="$"&&(s[c.value.substring(1)]=decodeURIComponent(u.value))}}if(!f&&d)return s["**"]=xr(o.slice(l+1).map(m=>m.value)),!!n.fuzzy&&(c==null?void 0:c.value)!=="/"}return!0})()?s:void 0}function Nr(e){return!!(e!=null&&e.isRedirect)}function Hh(e){return!!(e!=null&&e.isRedirect)&&e.href}function tp(e){const t=e.errorComponent??au;return P.jsx(rw,{getResetKey:e.getResetKey,onCatch:e.onCatch,children:({error:n,reset:r})=>n?S.createElement(t,{error:n,reset:r}):e.children})}class rw extends S.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,n){n.error&&n.resetKey!==this.state.resetKey&&this.reset()}componentDidCatch(t,n){this.props.onCatch&&this.props.onCatch(t,n)}render(){return this.props.children({error:this.state.resetKey!==this.props.getResetKey()?null:this.state.error,reset:()=>{this.reset()}})}}function au({error:e}){const[t,n]=S.useState(!1);return P.jsxs("div",{style:{padding:".5rem",maxWidth:"100%"},children:[P.jsxs("div",{style:{display:"flex",alignItems:"center",gap:".5rem"},children:[P.jsx("strong",{style:{fontSize:"1rem"},children:"Something went wrong!"}),P.jsx("button",{style:{appearance:"none",fontSize:".6em",border:"1px solid currentColor",padding:".1rem .2rem",fontWeight:"bold",borderRadius:".25rem"},onClick:()=>n(r=>!r),children:t?"Hide Error":"Show Error"})]}),P.jsx("div",{style:{height:".25rem"}}),t?P.jsx("div",{children:P.jsx("pre",{style:{fontSize:".7em",border:"1px solid red",borderRadius:".25rem",padding:".3rem",color:"red",overflow:"auto"},children:e.message?P.jsx("code",{children:e.message}):null})}):null]})}function dt(e){const t=An({warn:(e==null?void 0:e.router)===void 0});return pl(((e==null?void 0:e.router)||t).__store,e==null?void 0:e.select)}function Pn(e){return!!(e!=null&&e.isNotFound)}function ow(e){const t=dt({select:n=>`not-found-${n.location.pathname}-${n.status}`});return P.jsx(tp,{getResetKey:()=>t,onCatch:(n,r)=>{var o;if(Pn(n))(o=e.onCatch)==null||o.call(e,n,r);else throw n},errorComponent:({error:n})=>{var r;return(r=e.fallback)==null?void 0:r.call(e,n)},children:e.children})}function iw(){return P.jsx("p",{children:"Not Found"})}const sw=["component","errorComponent","pendingComponent","notFoundComponent"];function aw(e){return new lw(e)}class lw{constructor(t){this.tempLocationKey=`${Math.round(Math.random()*1e7)}`,this.resetNextScroll=!0,this.shouldViewTransition=void 0,this.subscribers=new Set,this.startReactTransition=n=>n(),this.update=n=>{n.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 r=this.options;this.options={...this.options,...n},this.isServer=this.options.isServer??typeof document>"u",(!this.basepath||n.basepath&&n.basepath!==r.basepath)&&(n.basepath===void 0||n.basepath===""||n.basepath==="/"?this.basepath="/":this.basepath=`/${ZS(n.basepath)}`),(!this.history||this.options.history&&this.options.history!==this.history)&&(this.history=this.options.history??(this.isServer?kS({initialEntries:[this.basepath||"/"]}):CS()),this.latestLocation=this.parseLocation()),this.options.routeTree!==this.routeTree&&(this.routeTree=this.options.routeTree,this.buildRouteTree()),this.__store||(this.__store=new Zf(dw(this.latestLocation),{onUpdate:()=>{this.__store.state={...this.state,cachedMatches:this.state.cachedMatches.filter(o=>!["redirected"].includes(o.status))}}}))},this.buildRouteTree=()=>{this.routesById={},this.routesByPath={};const n=this.options.notFoundRoute;n&&(n.init({originalIndex:99999999999}),this.routesById[n.id]=n);const r=s=>{s.forEach((a,l)=>{a.init({originalIndex:l});const u=this.routesById[a.id];if(Pt(!u,`Duplicate routes found with id: ${String(a.id)}`),this.routesById[a.id]=a,!a.isRoot&&a.path){const f=Br(a.fullPath);(!this.routesByPath[f]||a.fullPath.endsWith("/"))&&(this.routesByPath[f]=a)}const c=a.children;c!=null&&c.length&&r(c)})};r([this.routeTree]);const o=[];Object.values(this.routesById).forEach((s,a)=>{var l;if(s.isRoot||!s.path)return;const u=ep(s.fullPath),c=hi(u);for(;c.length>1&&((l=c[0])==null?void 0:l.value)==="/";)c.shift();const f=c.map(d=>d.value==="/"?.75:d.type==="param"?.5:d.type==="wildcard"?.25:1);o.push({child:s,trimmed:u,parsed:c,index:a,scores:f})}),this.flatRoutes=o.sort((s,a)=>{const l=Math.min(s.scores.length,a.scores.length);for(let u=0;ua.parsed[u].value?1:-1;return s.index-a.index}).map((s,a)=>(s.child.rank=a,s.child))},this.subscribe=(n,r)=>{const o={eventType:n,fn:r};return this.subscribers.add(o),()=>{this.subscribers.delete(o)}},this.emit=n=>{this.subscribers.forEach(r=>{r.eventType===n.type&&r.fn(n)})},this.parseLocation=n=>{const r=({pathname:a,search:l,hash:u,state:c})=>{const f=this.options.parseSearch(l),d=this.options.stringifySearch(f);return{pathname:a,searchStr:d,search:Cn(n==null?void 0:n.search,f),hash:u.split("#").reverse()[0]??"",href:`${a}${d}${u}`,state:Cn(n==null?void 0:n.state,c)}},o=r(this.history.location),{__tempLocation:i,__tempKey:s}=o.state;if(i&&(!s||s===this.tempLocationKey)){const a=r(i);return a.state.key=o.state.key,delete a.state.__tempLocation,{...a,maskedLocation:o}}return o},this.resolvePathWithBase=(n,r)=>tw({basepath:this.basepath,base:n,to:su(r),trailingSlash:this.options.trailingSlash}),this.matchRoutes=(n,r,o)=>{let i={};const s=this.flatRoutes.find(m=>{const v=ya(this.basepath,Br(n),{to:m.fullPath,caseSensitive:m.options.caseSensitive??this.options.caseSensitive,fuzzy:!0});return v?(i=v,!0):!1});let a=s||this.routesById[Ft];const l=[a];let u=!1;for((s?s.path!=="/"&&i["**"]:Br(n))&&(this.options.notFoundRoute?l.push(this.options.notFoundRoute):u=!0);a.parentRoute;)a=a.parentRoute,l.unshift(a);const c=(()=>{if(u){if(this.options.notFoundMode!=="root")for(let m=l.length-1;m>=0;m--){const v=l[m];if(v.children)return v.id}return Ft}})(),f=l.map(m=>{var v;let g;const x=((v=m.options.params)==null?void 0:v.parse)??m.options.parseParams;if(x)try{const h=x(i);Object.assign(i,h)}catch(h){if(g=new cw(h.message,{cause:h}),o!=null&&o.throwOnError)throw g;return g}}),d=[];return l.forEach((m,v)=>{var g,x,h,p,y,b,C,O,k,E;const _=d[v-1],[L,A]=(()=>{const I=(_==null?void 0:_.search)??r;try{const F=typeof m.options.validateSearch=="object"?m.options.validateSearch.parse:m.options.validateSearch,Q=(F==null?void 0:F(I))??{};return[{...I,...Q},void 0]}catch(F){const Q=new uw(F.message,{cause:F});if(o!=null&&o.throwOnError)throw Q;return[I,Q]}})(),j=((x=(g=m.options).loaderDeps)==null?void 0:x.call(g,{search:L}))??"",z=j?JSON.stringify(j):"",D=kc({path:m.fullPath,params:i}),R=kc({path:m.id,params:i,leaveWildcards:!0})+z,T=this.getMatch(R),N=this.state.matches.find(I=>I.id===R)?"stay":"enter";let $;if(T)$={...T,cause:N,params:i};else{const I=m.options.loader||m.options.beforeLoad||m.lazyFn?"pending":"success";$={id:R,index:v,routeId:m.id,params:i,pathname:xr([this.basepath,D]),updatedAt:Date.now(),search:{},searchError:void 0,status:I,isFetching:!1,error:void 0,paramsError:f[v],routeContext:void 0,context:void 0,abortController:new AbortController,fetchCount:0,cause:N,loaderDeps:j,invalid:!1,preload:!1,links:(p=(h=m.options).links)==null?void 0:p.call(h),scripts:(b=(y=m.options).scripts)==null?void 0:b.call(y),staticData:m.options.staticData||{},loadPromise:Ro()}}$.status==="success"&&($.meta=(O=(C=m.options).meta)==null?void 0:O.call(C,{matches:d,match:$,params:$.params,loaderData:$.loaderData}),$.headers=(E=(k=m.options).headers)==null?void 0:E.call(k,{loaderData:$.loaderData})),o!=null&&o.preload||($.globalNotFound=c===m.id),$.search=Cn($.search,L),$.searchError=A,d.push($)}),d},this.cancelMatch=n=>{const r=this.getMatch(n);r&&(r.abortController.abort(),clearTimeout(r.pendingTimeout))},this.cancelMatches=()=>{var n;(n=this.state.pendingMatches)==null||n.forEach(r=>{this.cancelMatch(r.id)})},this.buildLocation=n=>{const r=(i={},s)=>{var a,l,u;const c=i._fromLocation!=null?this.matchRoutes(i._fromLocation.pathname,i.fromSearch||i._fromLocation.search):this.state.matches,f=i.from!=null?c.find(z=>ya(this.basepath,Br(z.pathname),{to:i.from,caseSensitive:!1,fuzzy:!1})):void 0,d=(f==null?void 0:f.pathname)||this.latestLocation.pathname;Pt(i.from==null||f!=null,"Could not find match for from: "+i.from);const m=((a=hl(c))==null?void 0:a.search)||this.latestLocation.search,v=s==null?void 0:s.filter(z=>c.find(D=>D.routeId===z.routeId)),g=this.routesById[(l=v==null?void 0:v.find(z=>z.pathname===d))==null?void 0:l.routeId];let x=i.to?this.resolvePathWithBase(d,`${i.to}`):this.resolvePathWithBase(d,(g==null?void 0:g.to)??d);const h={...(u=hl(c))==null?void 0:u.params};let p=(i.params??!0)===!0?h:{...h,...$o(i.params,h)};Object.keys(p).length>0&&(s==null||s.map(z=>{var D;const R=this.looseRoutesById[z.routeId];return((D=R==null?void 0:R.options.params)==null?void 0:D.stringify)??R.options.stringifyParams}).filter(Boolean).forEach(z=>{p={...p,...z(p)}})),x=kc({path:x,params:p??{},leaveWildcards:!1,leaveParams:n.leaveParams});const y=(v==null?void 0:v.map(z=>this.looseRoutesById[z.routeId].options.preSearchFilters??[]).flat().filter(Boolean))??[],b=(v==null?void 0:v.map(z=>this.looseRoutesById[z.routeId].options.postSearchFilters??[]).flat().filter(Boolean))??[],C=y.length?y.reduce((z,D)=>D(z),m):m,O=i.search===!0?C:i.search?$o(i.search,C):y.length?C:{},k=b.length?b.reduce((z,D)=>D(z),O):O,E=Cn(m,k),_=this.options.stringifySearch(E),L=i.hash===!0?this.latestLocation.hash:i.hash?$o(i.hash,this.latestLocation.hash):void 0,A=L?`#${L}`:"";let j=i.state===!0?this.latestLocation.state:i.state?$o(i.state,this.latestLocation.state):{};return j=Cn(this.latestLocation.state,j),{pathname:x,search:E,searchStr:_,state:j,hash:L??"",href:`${x}${_}${A}`,unmaskOnReload:i.unmaskOnReload}},o=(i={},s)=>{var a;const l=r(i);let u=s?r(s):void 0;if(!u){let v={};const g=(a=this.options.routeMasks)==null?void 0:a.find(x=>{const h=ya(this.basepath,l.pathname,{to:x.from,caseSensitive:!1,fuzzy:!1});return h?(v=h,!0):!1});if(g){const{from:x,...h}=g;s={...ds(n,["from"]),...h,params:v},u=r(s)}}const c=this.matchRoutes(l.pathname,l.search),f=u?this.matchRoutes(u.pathname,u.search):void 0,d=u?r(s,f):void 0,m=r(i,c);return d&&(m.maskedLocation=d),m};return n.mask?o(n,{...ds(n,["from"]),...n.mask}):o(n)},this.commitLocation=({viewTransition:n,ignoreBlocker:r,...o})=>{const i=()=>{o.state.key=this.latestLocation.state.key;const l=Vo(o.state,this.latestLocation.state);return delete o.state.key,l},s=this.latestLocation.href===o.href,a=this.commitLocationPromise;if(this.commitLocationPromise=Ro(()=>{a==null||a.resolve()}),s&&i())this.load();else{let{maskedLocation:l,...u}=o;l&&(u={...l,state:{...l.state,__tempKey:void 0,__tempLocation:{...u,search:u.searchStr,state:{...u.state,__tempKey:void 0,__tempLocation:void 0,key:void 0}}}},(u.unmaskOnReload??this.options.unmaskOnReload??!1)&&(u.state.__tempKey=this.tempLocationKey)),this.shouldViewTransition=n,this.history[o.replace?"replace":"push"](u.href,u.state,{ignoreBlocker:r})}return this.resetNextScroll=o.resetScroll??!0,this.history.subscribers.size||this.load(),this.commitLocationPromise},this.buildAndCommitLocation=({replace:n,resetScroll:r,viewTransition:o,ignoreBlocker:i,...s}={})=>{const a=this.buildLocation(s);return this.commitLocation({...a,viewTransition:o,replace:n,resetScroll:r,ignoreBlocker:i})},this.navigate=({from:n,to:r,__isRedirect:o,...i})=>{const s=String(r);let a;try{new URL(`${s}`),a=!0}catch{}return Pt(!a),this.buildAndCommitLocation({...i,from:n,to:r})},this.load=async()=>{this.latestLocation=this.parseLocation(this.latestLocation),this.__store.setState(i=>({...i,loadedAt:Date.now()}));let n,r;const o=new Promise(i=>{this.startReactTransition(async()=>{var s;try{const a=this.latestLocation,l=this.state.resolvedLocation,u=l.href!==a.href;this.cancelMatches();let c;this.__store.batch(()=>{c=this.matchRoutes(a.pathname,a.search),this.__store.setState(f=>({...f,status:"pending",isLoading:!0,location:a,pendingMatches:c,cachedMatches:f.cachedMatches.filter(d=>!c.find(m=>m.id===d.id))}))}),this.state.redirect||this.emit({type:"onBeforeNavigate",fromLocation:l,toLocation:a,pathChanged:u}),this.emit({type:"onBeforeLoad",fromLocation:l,toLocation:a,pathChanged:u}),await this.loadMatches({matches:c,location:a,onReady:async()=>{this.startViewTransition(async()=>{let f,d,m;this.__store.batch(()=>{this.__store.setState(v=>{const g=v.matches,x=v.pendingMatches||v.matches;return f=g.filter(h=>!x.find(p=>p.id===h.id)),d=x.filter(h=>!g.find(p=>p.id===h.id)),m=g.filter(h=>x.find(p=>p.id===h.id)),{...v,isLoading:!1,matches:x,pendingMatches:void 0,cachedMatches:[...v.cachedMatches,...f.filter(h=>h.status!=="error")]}}),this.cleanCache()}),[[f,"onLeave"],[d,"onEnter"],[m,"onStay"]].forEach(([v,g])=>{v.forEach(x=>{var h,p;(p=(h=this.looseRoutesById[x.routeId].options)[g])==null||p.call(h,x)})})})}})}catch(a){Hh(a)?(n=a,this.isServer||this.navigate({...a,replace:!0,__isRedirect:!0})):Pn(a)&&(r=a),this.__store.setState(l=>({...l,statusCode:n?n.statusCode:r?404:l.matches.some(u=>u.status==="error")?500:200,redirect:n}))}this.latestLoadPromise===o&&((s=this.commitLocationPromise)==null||s.resolve(),this.latestLoadPromise=void 0,this.commitLocationPromise=void 0),i()})});for(this.latestLoadPromise=o,await o;this.latestLoadPromise&&o!==this.latestLoadPromise;)await this.latestLoadPromise},this.startViewTransition=n=>{var r,o;const i=this.shouldViewTransition??this.options.defaultViewTransition;delete this.shouldViewTransition,(o=(r=i&&typeof document<"u"?document:void 0)==null?void 0:r.startViewTransition)!=null&&o.call(r,n)||n()},this.updateMatch=(n,r)=>{var o;let i;const s=(o=this.state.pendingMatches)==null?void 0:o.find(u=>u.id===n),a=this.state.matches.find(u=>u.id===n),l=s?"pendingMatches":a?"matches":"cachedMatches";return this.__store.setState(u=>{var c;return{...u,[l]:(c=u[l])==null?void 0:c.map(f=>f.id===n?i=r(f):f)}}),i},this.getMatch=n=>[...this.state.cachedMatches,...this.state.pendingMatches??[],...this.state.matches].find(r=>r.id===n),this.loadMatches=async({location:n,matches:r,preload:o,onReady:i,updateMatch:s=this.updateMatch})=>{let a,l=!1;const u=async()=>{l||(l=!0,await(i==null?void 0:i()))};!this.isServer&&!this.state.matches.length&&u();const c=(f,d)=>{var m,v,g;if(Hh(d))throw d;if(Nr(d)||Pn(d)){if(s(f.id,x=>({...x,status:Nr(d)?"redirected":Pn(d)?"notFound":"error",isFetching:!1,error:d,beforeLoadPromise:void 0,loaderPromise:void 0})),d.routeId||(d.routeId=f.routeId),(m=f.beforeLoadPromise)==null||m.resolve(),(v=f.loaderPromise)==null||v.resolve(),(g=f.loadPromise)==null||g.resolve(),Nr(d))throw l=!0,d=this.resolveRedirect({...d,_fromLocation:n}),d;if(Pn(d))throw this._handleNotFound(r,d,{updateMatch:s}),d}};try{await new Promise((f,d)=>{(async()=>{var m,v,g;try{const x=(y,b,C)=>{var O,k;const{id:E,routeId:_}=r[y],L=this.looseRoutesById[_];if(b instanceof Promise)throw b;b.routerCode=C,a=a??y,c(this.getMatch(E),b);try{(k=(O=L.options).onError)==null||k.call(O,b)}catch(A){b=A,c(this.getMatch(E),b)}s(E,A=>{var j;return(j=A.beforeLoadPromise)==null||j.resolve(),{...A,error:b,status:"error",isFetching:!1,updatedAt:Date.now(),abortController:new AbortController,beforeLoadPromise:void 0}})};for(const[y,{id:b,routeId:C}]of r.entries()){const O=this.getMatch(b);if(O.beforeLoadPromise||O.loaderPromise)await O.beforeLoadPromise;else{try{s(b,W=>({...W,loadPromise:Ro(()=>{var q;(q=W.loadPromise)==null||q.resolve()}),beforeLoadPromise:Ro()}));const k=this.looseRoutesById[C],E=new AbortController,_=(m=r[y-1])==null?void 0:m.id,L=()=>_?this.getMatch(_).context??this.options.context??{}:this.options.context??{},A=k.options.pendingMs??this.options.defaultPendingMs,j=!!(i&&!this.isServer&&!o&&(k.options.loader||k.options.beforeLoad)&&typeof A=="number"&&A!==1/0&&(k.options.pendingComponent??this.options.defaultPendingComponent));let z;j&&(z=setTimeout(()=>{try{u()}catch{}},A));const{paramsError:D,searchError:R}=this.getMatch(b);D&&x(y,D,"PARSE_PARAMS"),R&&x(y,R,"VALIDATE_SEARCH");const T=L();s(b,W=>({...W,isFetching:"beforeLoad",fetchCount:W.fetchCount+1,routeContext:Cn(W.routeContext,T),context:Cn(W.context,T),abortController:E,pendingTimeout:z}));const{search:N,params:$,routeContext:I,cause:F}=this.getMatch(b),Q={search:N,abortController:E,params:$,preload:!!o,context:I,location:n,navigate:W=>this.navigate({...W,_fromLocation:n}),buildLocation:this.buildLocation,cause:o?"preload":F},X=await((g=(v=k.options).beforeLoad)==null?void 0:g.call(v,Q))??{};(Nr(X)||Pn(X))&&x(y,X,"BEFORE_LOAD"),s(b,W=>{const q={...W.routeContext,...X};return{...W,routeContext:Cn(W.routeContext,q),context:Cn(W.context,q),abortController:E}})}catch(k){x(y,k,"BEFORE_LOAD")}s(b,k=>{var E;return(E=k.beforeLoadPromise)==null||E.resolve(),{...k,beforeLoadPromise:void 0,isFetching:!1}})}}const h=r.slice(0,a),p=[];h.forEach(({id:y,routeId:b},C)=>{p.push((async()=>{const{loaderPromise:O}=this.getMatch(y);if(O)await O;else{const k=p[C-1],E=this.looseRoutesById[b],_=()=>{const{params:I,loaderDeps:F,abortController:Q,context:X,cause:W}=this.getMatch(y);return{params:I,deps:F,preload:!!o,parentMatchPromise:k,abortController:Q,context:X,location:n,navigate:q=>this.navigate({...q,_fromLocation:n}),cause:o?"preload":W,route:E}},L=Date.now()-this.getMatch(y).updatedAt,A=o?E.options.preloadStaleTime??this.options.defaultPreloadStaleTime??3e4:E.options.staleTime??this.options.defaultStaleTime??0,j=E.options.shouldReload,z=typeof j=="function"?j(_()):j;s(y,I=>({...I,loaderPromise:Ro(),preload:!!o&&!this.state.matches.find(F=>F.id===y)}));const D=async()=>{var I,F,Q,X,W,q,pe,oe;try{const we=async()=>{const Ce=this.getMatch(y);Ce.minPendingPromise&&await Ce.minPendingPromise};try{E._lazyPromise=E._lazyPromise||(E.lazyFn?E.lazyFn().then(ee=>{Object.assign(E.options,ee.options)}):Promise.resolve());const Ce=this.getMatch(y).componentsPromise||E._lazyPromise.then(()=>Promise.all(sw.map(async ee=>{const re=E.options[ee];re!=null&&re.preload&&await re.preload()})));s(y,ee=>({...ee,isFetching:"loader",componentsPromise:Ce})),await E._lazyPromise;let fe=await((F=(I=E.options).loader)==null?void 0:F.call(I,_()));this.serializeLoaderData&&(fe=this.serializeLoaderData(fe,{router:this,match:this.getMatch(y)})),c(this.getMatch(y),fe),await we();const Me=(X=(Q=E.options).meta)==null?void 0:X.call(Q,{matches:r,match:this.getMatch(y),params:this.getMatch(y).params,loaderData:fe}),Y=(q=(W=E.options).headers)==null?void 0:q.call(W,{loaderData:fe});s(y,ee=>({...ee,error:void 0,status:"success",isFetching:!1,updatedAt:Date.now(),loaderData:fe,meta:Me,headers:Y}))}catch(Ce){let fe=Ce;await we(),c(this.getMatch(y),Ce);try{(oe=(pe=E.options).onError)==null||oe.call(pe,Ce)}catch(Me){fe=Me,c(this.getMatch(y),Me)}s(y,Me=>({...Me,error:fe,status:"error",isFetching:!1}))}await this.getMatch(y).componentsPromise}catch(we){c(this.getMatch(y),we)}},{status:R,invalid:T}=this.getMatch(y);R==="success"&&(T||(z??L>A))?(async()=>{try{await D()}catch{}})():R!=="success"&&await D();const{loaderPromise:N,loadPromise:$}=this.getMatch(y);N==null||N.resolve(),$==null||$.resolve()}s(y,k=>({...k,isFetching:!1,loaderPromise:void 0}))})())}),await Promise.all(p),f()}catch(x){d(x)}})()}),await u()}catch(f){if(Nr(f)||Pn(f))throw Pn(f)&&!o&&await u(),f}return r},this.invalidate=()=>{const n=r=>({...r,invalid:!0,...r.status==="error"?{status:"pending",error:void 0}:{}});return this.__store.setState(r=>{var o;return{...r,matches:r.matches.map(n),cachedMatches:r.cachedMatches.map(n),pendingMatches:(o=r.pendingMatches)==null?void 0:o.map(n)}}),this.load()},this.resolveRedirect=n=>{const r=n;return r.href||(r.href=this.buildLocation(r).href),r},this.cleanCache=()=>{this.__store.setState(n=>({...n,cachedMatches:n.cachedMatches.filter(r=>{const o=this.looseRoutesById[r.routeId];if(!o.options.loader)return!1;const i=(r.preload?o.options.preloadGcTime??this.options.defaultPreloadGcTime:o.options.gcTime??this.options.defaultGcTime)??5*60*1e3;return r.status!=="error"&&Date.now()-r.updatedAt{const r=this.buildLocation(n);let o=this.matchRoutes(r.pathname,r.search,{throwOnError:!0,preload:!0});const i=Object.fromEntries([...this.state.matches,...this.state.pendingMatches??[],...this.state.cachedMatches].map(a=>[a.id,!0]));this.__store.batch(()=>{o.forEach(a=>{i[a.id]||this.__store.setState(l=>({...l,cachedMatches:[...l.cachedMatches,a]}))})});const s=new Set([...this.state.matches,...this.state.pendingMatches??[]].map(a=>a.id));try{return o=await this.loadMatches({matches:o,location:r,preload:!0,updateMatch:(a,l)=>{s.has(a)?o=o.map(u=>u.id===a?l(u):u):this.updateMatch(a,l)}}),o}catch(a){if(Nr(a))return await this.preloadRoute({...a,_fromLocation:r});console.error(a);return}},this.matchRoute=(n,r)=>{const o={...n,to:n.to?this.resolvePathWithBase(n.from||"",n.to):void 0,params:n.params||{},leaveParams:!0},i=this.buildLocation(o);if(r!=null&&r.pending&&this.state.status!=="pending")return!1;const a=((r==null?void 0:r.pending)===void 0?!this.state.isLoading:r.pending)?this.latestLocation:this.state.resolvedLocation,l=ya(this.basepath,a.pathname,{...r,to:i.pathname});return!l||n.params&&!Vo(l,n.params,!0)?!1:l&&((r==null?void 0:r.includeSearch)??!0)?Vo(a.search,i.search,!0)?l:!1:l},this.dehydrate=()=>{var n;const r=((n=this.options.errorSerializer)==null?void 0:n.serialize)??fw;return{state:{dehydratedMatches:this.state.matches.map(o=>({...ds(o,["id","status","updatedAt"]),error:o.error?{data:r(o.error),__isServerError:!0}:void 0}))},manifest:this.manifest}},this.hydrate=()=>{var n,r,o;let i;typeof document<"u"&&(i=this.options.transformer.parse((n=window.__TSR__)==null?void 0:n.dehydrated)),Pt(i),this.dehydratedData=i.payload,(o=(r=this.options).hydrate)==null||o.call(r,i.payload);const s=i.router.state,a=this.matchRoutes(this.state.location.pathname,this.state.location.search).map(l=>{const u=s.dehydratedMatches.find(c=>c.id===l.id);return Pt(u,`Could not find a client-side match for dehydrated match with id: ${l.id}!`),{...l,...u}});this.__store.setState(l=>({...l,matches:a})),this.manifest=i.router.manifest},this.injectedHtml=[],this.injectHtml=n=>{const r=()=>(this.injectedHtml=this.injectedHtml.filter(o=>o!==r),n);this.injectedHtml.push(r)},this.streamedKeys=new Set,this.getStreamedValue=n=>{var r;if(this.isServer)return;const o=(r=window.__TSR__)==null?void 0:r.streamedValues[n];if(o)return o.parsed||(o.parsed=this.options.transformer.parse(o.value)),o.parsed},this.streamValue=(n,r)=>{var o;this.streamedKeys.has(n),this.streamedKeys.add(n);const i=`__TSR__.streamedValues['${n}'] = { value: ${(o=this.serializer)==null?void 0:o.call(this,this.options.transformer.stringify(r))}}`;this.injectHtml(` + +
diff --git a/exam/react/src/routes/__root.tsx b/exam/react/src/routes/__root.tsx index 7c25d2a..194f836 100644 --- a/exam/react/src/routes/__root.tsx +++ b/exam/react/src/routes/__root.tsx @@ -6,19 +6,21 @@ import Api from '../api/Api'; import Header from '../components/Header/Header'; import useGuestBookStore from '../store/store'; -export const Route = createRootRouteWithContext<{ queryClient: QueryClient }>()({ - component: () => { - //FIXME: REAUTH HERE - const token = useGuestBookStore((state) => state.token); - Api.token = token; +const Root = () => { + //FIXME: REAUTH HERE + const token = useGuestBookStore((state) => state.token); + Api.token = token; - return ( - <> -
- - - {process.env.NODE_ENV === 'development' && } - - ); - }, + return ( + <> +
+ + + {process.env.NODE_ENV === 'development' && } + + ); +}; + +export const Route = createRootRouteWithContext<{ queryClient: QueryClient }>()({ + component: Root, }); diff --git a/exam/react/src/utils/errors.ts b/exam/react/src/utils/errors.ts index aed71b2..56646a9 100644 --- a/exam/react/src/utils/errors.ts +++ b/exam/react/src/utils/errors.ts @@ -7,10 +7,11 @@ import { TFunction } from 'i18next'; * @param t Optional translation function, defautls to pass through * @returns Translated error or inputs if t as unspecified */ -//eslint-disable-next-line @typescript-eslint/no-explicit-any const handleError = ( + //eslint-disable-next-line @typescript-eslint/no-explicit-any error: any, context?: string, + //eslint-disable-next-line @typescript-eslint/no-explicit-any t: TFunction<'translation', undefined> | ((..._in: any) => any) = (..._in: any) => _in ): string => { if (!error) return t('', {});