18 lines
100 KiB
JavaScript
18 lines
100 KiB
JavaScript
var ws=e=>{throw TypeError(e)};var ze=(e,t,s)=>t.has(e)||ws("Cannot "+s);var l=(e,t,s)=>(ze(e,t,"read from private field"),s?s.call(e):t.get(e)),F=(e,t,s)=>t.has(e)?ws("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,s),P=(e,t,s,i)=>(ze(e,t,"write to private field"),i?i.call(e,s):t.set(e,s),s),E=(e,t,s)=>(ze(e,t,"access private method"),s);var Ce=(e,t,s,i)=>({set _(r){P(e,t,r,s)},get _(){return l(e,t,i)}});import{r as C,c as Ii}from"./react-DXd9vB-a.js";import{j as _}from"./mui-v3E5hT34.js";var ve=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(){}},de=typeof window>"u"||"Deno"in globalThis;function ct(){}function Vi(e,t){return typeof e=="function"?e(t):e}function ts(e){return typeof e=="number"&&e>=0&&e!==1/0}function Zs(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Xt(e,t){return typeof e=="function"?e(t):e}function dt(e,t){return typeof e=="function"?e(t):e}function Fs(e,t){const{type:s="all",exact:i,fetchStatus:r,predicate:n,queryKey:o,stale:a}=e;if(o){if(i){if(t.queryHash!==vs(o,t.options))return!1}else if(!Se(t.queryKey,o))return!1}if(s!=="all"){const h=t.isActive();if(s==="active"&&!h||s==="inactive"&&h)return!1}return!(typeof a=="boolean"&&t.isStale()!==a||r&&r!==t.state.fetchStatus||n&&!n(t))}function _s(e,t){const{exact:s,status:i,predicate:r,mutationKey:n}=e;if(n){if(!t.options.mutationKey)return!1;if(s){if(Ht(t.options.mutationKey)!==Ht(n))return!1}else if(!Se(t.options.mutationKey,n))return!1}return!(i&&t.state.status!==i||r&&!r(t))}function vs(e,t){return((t==null?void 0:t.queryKeyHashFn)||Ht)(e)}function Ht(e){return JSON.stringify(e,(t,s)=>es(s)?Object.keys(s).sort().reduce((i,r)=>(i[r]=s[r],i),{}):s)}function Se(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?!Object.keys(t).some(s=>!Se(e[s],t[s])):!1}function ti(e,t){if(e===t)return e;const s=Cs(e)&&Cs(t);if(s||es(e)&&es(t)){const i=s?e:Object.keys(e),r=i.length,n=s?t:Object.keys(t),o=n.length,a=s?[]:{};let h=0;for(let u=0;u<o;u++){const c=s?u:n[u];(!s&&i.includes(c)||s)&&e[c]===void 0&&t[c]===void 0?(a[c]=void 0,h++):(a[c]=ti(e[c],t[c]),a[c]===e[c]&&e[c]!==void 0&&h++)}return r===o&&h===r?e:a}return t}function Te(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const s in e)if(e[s]!==t[s])return!1;return!0}function Cs(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function es(e){if(!Rs(e))return!1;const t=e.constructor;if(t===void 0)return!0;const s=t.prototype;return!(!Rs(s)||!s.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function Rs(e){return Object.prototype.toString.call(e)==="[object Object]"}function ji(e){return new Promise(t=>{setTimeout(t,e)})}function ss(e,t,s){return typeof s.structuralSharing=="function"?s.structuralSharing(e,t):s.structuralSharing!==!1?ti(e,t):t}function Di(e,t,s=0){const i=[...e,t];return s&&i.length>s?i.slice(1):i}function ki(e,t,s=0){const i=[t,...e];return s&&i.length>s?i.slice(0,-1):i}var ei=Symbol();function si(e,t){return!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===ei?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}var $t,Rt,Zt,Ks,Bi=(Ks=class extends ve{constructor(){super();F(this,$t);F(this,Rt);F(this,Zt);P(this,Zt,t=>{if(!de&&window.addEventListener){const s=()=>t();return window.addEventListener("visibilitychange",s,!1),()=>{window.removeEventListener("visibilitychange",s)}}})}onSubscribe(){l(this,Rt)||this.setEventListener(l(this,Zt))}onUnsubscribe(){var t;this.hasListeners()||((t=l(this,Rt))==null||t.call(this),P(this,Rt,void 0))}setEventListener(t){var s;P(this,Zt,t),(s=l(this,Rt))==null||s.call(this),P(this,Rt,t(i=>{typeof i=="boolean"?this.setFocused(i):this.onFocus()}))}setFocused(t){l(this,$t)!==t&&(P(this,$t,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(s=>{s(t)})}isFocused(){var t;return typeof l(this,$t)=="boolean"?l(this,$t):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},$t=new WeakMap,Rt=new WeakMap,Zt=new WeakMap,Ks),ys=new Bi,te,Et,ee,Ns,$i=(Ns=class extends ve{constructor(){super();F(this,te,!0);F(this,Et);F(this,ee);P(this,ee,t=>{if(!de&&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(){l(this,Et)||this.setEventListener(l(this,ee))}onUnsubscribe(){var t;this.hasListeners()||((t=l(this,Et))==null||t.call(this),P(this,Et,void 0))}setEventListener(t){var s;P(this,ee,t),(s=l(this,Et))==null||s.call(this),P(this,Et,t(this.setOnline.bind(this)))}setOnline(t){l(this,te)!==t&&(P(this,te,t),this.listeners.forEach(i=>{i(t)}))}isOnline(){return l(this,te)}},te=new WeakMap,Et=new WeakMap,ee=new WeakMap,Ns),Ie=new $i;function Ui(e){return Math.min(1e3*2**e,3e4)}function ii(e){return(e??"online")==="online"?Ie.isOnline():!0}var ri=class{constructor(e){this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function He(e){return e instanceof ri}function ni(e){let t=!1,s=0,i=!1,r,n,o;const a=new Promise((M,S)=>{n=M,o=S}),h=M=>{var S;i||(v(new ri(M)),(S=e.abort)==null||S.call(e))},u=()=>{t=!0},c=()=>{t=!1},d=()=>ys.isFocused()&&(e.networkMode==="always"||Ie.isOnline())&&e.canRun(),f=()=>ii(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(),o(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??(de?0:3),R=e.retryDelay??Ui,L=typeof R=="function"?R(s,y):R,x=w===!0||typeof w=="number"&&s<w||typeof w=="function"&&w(s,y);if(t||!x){v(y);return}s++,(b=e.onFail)==null||b.call(e,s,y),ji(L).then(()=>d()?void 0:m()).then(()=>{t?v(y):g()})})};return{promise:a,cancel:h,continue:()=>(r==null||r(),a),cancelRetry:u,continueRetry:c,canStart:f,start:()=>(f()?g():m().then(g),a)}}function Qi(){let e=[],t=0,s=f=>{f()},i=f=>{f()},r=f=>setTimeout(f,0);const n=f=>{r=f},o=f=>{let p;t++;try{p=f()}finally{t--,t||u()}return p},a=f=>{t?e.push(f):r(()=>{s(f)})},h=f=>(...p)=>{a(()=>{f(...p)})},u=()=>{const f=e;e=[],f.length&&r(()=>{i(()=>{f.forEach(p=>{s(p)})})})};return{batch:o,batchCalls:h,schedule:a,setNotifyFunction:f=>{s=f},setBatchNotifyFunction:f=>{i=f},setScheduler:n}}var K=Qi(),Ut,qs,oi=(qs=class{constructor(){F(this,Ut)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),ts(this.gcTime)&&P(this,Ut,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(de?1/0:5*60*1e3))}clearGcTimeout(){l(this,Ut)&&(clearTimeout(l(this,Ut)),P(this,Ut,void 0))}},Ut=new WeakMap,qs),se,ie,lt,G,Me,Qt,ht,Mt,zs,Ki=(zs=class extends oi{constructor(t){super();F(this,ht);F(this,se);F(this,ie);F(this,lt);F(this,G);F(this,Me);F(this,Qt);P(this,Qt,!1),P(this,Me,t.defaultOptions),this.setOptions(t.options),this.observers=[],P(this,lt,t.cache),this.queryKey=t.queryKey,this.queryHash=t.queryHash,P(this,se,t.state||Ni(this.options)),this.state=l(this,se),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=l(this,G))==null?void 0:t.promise}setOptions(t){this.options={...l(this,Me),...t},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&l(this,lt).remove(this)}setData(t,s){const i=ss(this.state.data,t,this.options);return E(this,ht,Mt).call(this,{data:i,type:"success",dataUpdatedAt:s==null?void 0:s.updatedAt,manual:s==null?void 0:s.manual}),i}setState(t,s){E(this,ht,Mt).call(this,{type:"setState",state:t,setStateOptions:s})}cancel(t){var i,r;const s=(i=l(this,G))==null?void 0:i.promise;return(r=l(this,G))==null||r.cancel(t),s?s.then(ct).catch(ct):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(l(this,se))}isActive(){return this.observers.some(t=>dt(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||!Zs(this.state.dataUpdatedAt,t)}onFocus(){var s;const t=this.observers.find(i=>i.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(s=l(this,G))==null||s.continue()}onOnline(){var s;const t=this.observers.find(i=>i.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(s=l(this,G))==null||s.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),l(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||(l(this,G)&&(l(this,Qt)?l(this,G).cancel({revert:!0}):l(this,G).cancelRetry()),this.scheduleGc()),l(this,lt).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||E(this,ht,Mt).call(this,{type:"invalidate"})}fetch(t,s){var h,u,c;if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&(s!=null&&s.cancelRefetch))this.cancel({silent:!0});else if(l(this,G))return l(this,G).continueRetry(),l(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,Qt,!0),i.signal)})},n=()=>{const d=si(this.options,s),f={queryKey:this.queryKey,meta:this.meta};return r(f),P(this,Qt,!1),this.options.persister?this.options.persister(d,f,this):d(f)},o={fetchOptions:s,options:this.options,queryKey:this.queryKey,state:this.state,fetchFn:n};r(o),(h=this.options.behavior)==null||h.onFetch(o,this),P(this,ie,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((u=o.fetchOptions)==null?void 0:u.meta))&&E(this,ht,Mt).call(this,{type:"fetch",meta:(c=o.fetchOptions)==null?void 0:c.meta});const a=d=>{var f,p,v,m;He(d)&&d.silent||E(this,ht,Mt).call(this,{type:"error",error:d}),He(d)||((p=(f=l(this,lt).config).onError)==null||p.call(f,d,this),(m=(v=l(this,lt).config).onSettled)==null||m.call(v,this.state.data,d,this)),this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1};return P(this,G,ni({initialPromise:s==null?void 0:s.initialPromise,fn:o.fetchFn,abort:i.abort.bind(i),onSuccess:d=>{var f,p,v,m;if(d===void 0){a(new Error(`${this.queryHash} data is undefined`));return}this.setData(d),(p=(f=l(this,lt).config).onSuccess)==null||p.call(f,d,this),(m=(v=l(this,lt).config).onSettled)==null||m.call(v,d,this.state.error,this),this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1},onError:a,onFail:(d,f)=>{E(this,ht,Mt).call(this,{type:"failed",failureCount:d,error:f})},onPause:()=>{E(this,ht,Mt).call(this,{type:"pause"})},onContinue:()=>{E(this,ht,Mt).call(this,{type:"continue"})},retry:o.options.retry,retryDelay:o.options.retryDelay,networkMode:o.options.networkMode,canRun:()=>!0})),l(this,G).start()}},se=new WeakMap,ie=new WeakMap,lt=new WeakMap,G=new WeakMap,Me=new WeakMap,Qt=new WeakMap,ht=new WeakSet,Mt=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,...ai(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 He(r)&&r.revert&&l(this,ie)?{...l(this,ie),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),K.batch(()=>{this.observers.forEach(i=>{i.onQueryUpdate()}),l(this,lt).notify({query:this,type:"updated",action:t})})},zs);function ai(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:ii(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function Ni(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 vt,Hs,qi=(Hs=class extends ve{constructor(t={}){super();F(this,vt);this.config=t,P(this,vt,new Map)}build(t,s,i){const r=s.queryKey,n=s.queryHash??vs(r,s);let o=this.get(n);return o||(o=new Ki({cache:this,queryKey:r,queryHash:n,options:t.defaultQueryOptions(s),state:i,defaultOptions:t.getQueryDefaults(r)}),this.add(o)),o}add(t){l(this,vt).has(t.queryHash)||(l(this,vt).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const s=l(this,vt).get(t.queryHash);s&&(t.destroy(),s===t&&l(this,vt).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){K.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return l(this,vt).get(t)}getAll(){return[...l(this,vt).values()]}find(t){const s={exact:!0,...t};return this.getAll().find(i=>Fs(s,i))}findAll(t={}){const s=this.getAll();return Object.keys(t).length>0?s.filter(i=>Fs(t,i)):s}notify(t){K.batch(()=>{this.listeners.forEach(s=>{s(t)})})}onFocus(){K.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){K.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},vt=new WeakMap,Hs),yt,J,Kt,gt,Ct,Ws,zi=(Ws=class extends oi{constructor(t){super();F(this,gt);F(this,yt);F(this,J);F(this,Kt);this.mutationId=t.mutationId,P(this,J,t.mutationCache),P(this,yt,[]),this.state=t.state||ui(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){l(this,yt).includes(t)||(l(this,yt).push(t),this.clearGcTimeout(),l(this,J).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){P(this,yt,l(this,yt).filter(s=>s!==t)),this.scheduleGc(),l(this,J).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){l(this,yt).length||(this.state.status==="pending"?this.scheduleGc():l(this,J).remove(this))}continue(){var t;return((t=l(this,Kt))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var r,n,o,a,h,u,c,d,f,p,v,m,g,M,S,y,w,R,L,x;P(this,Kt,ni({fn:()=>this.options.mutationFn?this.options.mutationFn(t):Promise.reject(new Error("No mutationFn found")),onFail:(b,T)=>{E(this,gt,Ct).call(this,{type:"failed",failureCount:b,error:T})},onPause:()=>{E(this,gt,Ct).call(this,{type:"pause"})},onContinue:()=>{E(this,gt,Ct).call(this,{type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>l(this,J).canRun(this)}));const s=this.state.status==="pending",i=!l(this,Kt).canStart();try{if(!s){E(this,gt,Ct).call(this,{type:"pending",variables:t,isPaused:i}),await((n=(r=l(this,J).config).onMutate)==null?void 0:n.call(r,t,this));const T=await((a=(o=this.options).onMutate)==null?void 0:a.call(o,t));T!==this.state.context&&E(this,gt,Ct).call(this,{type:"pending",context:T,variables:t,isPaused:i})}const b=await l(this,Kt).start();return await((u=(h=l(this,J).config).onSuccess)==null?void 0:u.call(h,b,t,this.state.context,this)),await((d=(c=this.options).onSuccess)==null?void 0:d.call(c,b,t,this.state.context)),await((p=(f=l(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)),E(this,gt,Ct).call(this,{type:"success",data:b}),b}catch(b){try{throw await((M=(g=l(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((R=(w=l(this,J).config).onSettled)==null?void 0:R.call(w,void 0,b,this.state.variables,this.state.context,this)),await((x=(L=this.options).onSettled)==null?void 0:x.call(L,void 0,b,t,this.state.context)),b}finally{E(this,gt,Ct).call(this,{type:"error",error:b})}}finally{l(this,J).runNext(this)}}},yt=new WeakMap,J=new WeakMap,Kt=new WeakMap,gt=new WeakSet,Ct=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),K.batch(()=>{l(this,yt).forEach(i=>{i.onMutationUpdate(t)}),l(this,J).notify({mutation:this,type:"updated",action:t})})},Ws);function ui(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var it,Pe,Gs,Hi=(Gs=class extends ve{constructor(t={}){super();F(this,it);F(this,Pe);this.config=t,P(this,it,new Map),P(this,Pe,Date.now())}build(t,s,i){const r=new zi({mutationCache:this,mutationId:++Ce(this,Pe)._,options:t.defaultMutationOptions(s),state:i});return this.add(r),r}add(t){const s=Re(t),i=l(this,it).get(s)??[];i.push(t),l(this,it).set(s,i),this.notify({type:"added",mutation:t})}remove(t){var i;const s=Re(t);if(l(this,it).has(s)){const r=(i=l(this,it).get(s))==null?void 0:i.filter(n=>n!==t);r&&(r.length===0?l(this,it).delete(s):l(this,it).set(s,r))}this.notify({type:"removed",mutation:t})}canRun(t){var i;const s=(i=l(this,it).get(Re(t)))==null?void 0:i.find(r=>r.state.status==="pending");return!s||s===t}runNext(t){var i;const s=(i=l(this,it).get(Re(t)))==null?void 0:i.find(r=>r!==t&&r.state.isPaused);return(s==null?void 0:s.continue())??Promise.resolve()}clear(){K.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}getAll(){return[...l(this,it).values()].flat()}find(t){const s={exact:!0,...t};return this.getAll().find(i=>_s(s,i))}findAll(t={}){return this.getAll().filter(s=>_s(t,s))}notify(t){K.batch(()=>{this.listeners.forEach(s=>{s(t)})})}resumePausedMutations(){const t=this.getAll().filter(s=>s.state.isPaused);return K.batch(()=>Promise.all(t.map(s=>s.continue().catch(ct))))}},it=new WeakMap,Pe=new WeakMap,Gs);function Re(e){var t;return((t=e.options.scope)==null?void 0:t.id)??String(e.mutationId)}function Wi(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,o=((M=t.state.data)==null?void 0:M.pages)||[],a=((S=t.state.data)==null?void 0:S.pageParams)||[],h={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)})},d=si(t.options,t.fetchOptions),f=async(y,w,R)=>{if(u)return Promise.reject();if(w==null&&y.pages.length)return Promise.resolve(y);const L={queryKey:t.queryKey,pageParam:w,direction:R?"backward":"forward",meta:t.options.meta};c(L);const x=await d(L),{maxPages:b}=t.options,T=R?ki:Di;return{pages:T(y.pages,x,b),pageParams:T(y.pageParams,w,b)}};let p;if(n&&o.length){const y=n==="backward",w=y?Gi:Es,R={pages:o,pageParams:a},L=w(r,R);p=await f(R,L,y)}else{p=await f(h,a[0]??r.initialPageParam);const y=e??o.length;for(let w=1;w<y;w++){const R=Es(r,p);p=await f(p,R)}}return p};t.options.persister?t.fetchFn=()=>{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 Es(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 Gi(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,xt,Ot,re,ne,Lt,oe,ae,Js,In=(Js=class{constructor(e={}){F(this,j);F(this,xt);F(this,Ot);F(this,re);F(this,ne);F(this,Lt);F(this,oe);F(this,ae);P(this,j,e.queryCache||new qi),P(this,xt,e.mutationCache||new Hi),P(this,Ot,e.defaultOptions||{}),P(this,re,new Map),P(this,ne,new Map),P(this,Lt,0)}mount(){Ce(this,Lt)._++,l(this,Lt)===1&&(P(this,oe,ys.subscribe(async e=>{e&&(await this.resumePausedMutations(),l(this,j).onFocus())})),P(this,ae,Ie.subscribe(async e=>{e&&(await this.resumePausedMutations(),l(this,j).onOnline())})))}unmount(){var e,t;Ce(this,Lt)._--,l(this,Lt)===0&&((e=l(this,oe))==null||e.call(this),P(this,oe,void 0),(t=l(this,ae))==null||t.call(this),P(this,ae,void 0))}isFetching(e){return l(this,j).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return l(this,xt).findAll({...e,status:"pending"}).length}getQueryData(e){var s;const t=this.defaultQueryOptions({queryKey:e});return(s=l(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=l(this,j).build(this,s);return e.revalidateIfStale&&i.isStaleByTime(Xt(s.staleTime,i))&&this.prefetchQuery(s),Promise.resolve(t)}}getQueriesData(e){return l(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=l(this,j).get(i.queryHash),n=r==null?void 0:r.state.data,o=Vi(t,n);if(o!==void 0)return l(this,j).build(this,i).setData(o,{...s,manual:!0})}setQueriesData(e,t,s){return K.batch(()=>l(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=l(this,j).get(t.queryHash))==null?void 0:s.state}removeQueries(e){const t=l(this,j);K.batch(()=>{t.findAll(e).forEach(s=>{t.remove(s)})})}resetQueries(e,t){const s=l(this,j),i={type:"active",...e};return K.batch(()=>(s.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries(i,t)))}cancelQueries(e={},t={}){const s={revert:!0,...t},i=K.batch(()=>l(this,j).findAll(e).map(r=>r.cancel(s)));return Promise.all(i).then(ct).catch(ct)}invalidateQueries(e={},t={}){return K.batch(()=>{if(l(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=K.batch(()=>l(this,j).findAll(e).filter(r=>!r.isDisabled()).map(r=>{let n=r.fetch(void 0,s);return s.throwOnError||(n=n.catch(ct)),r.state.fetchStatus==="paused"?Promise.resolve():n}));return Promise.all(i).then(ct)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const s=l(this,j).build(this,t);return s.isStaleByTime(Xt(t.staleTime,s))?s.fetch(t):Promise.resolve(s.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(ct).catch(ct)}fetchInfiniteQuery(e){return e.behavior=Wi(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(ct).catch(ct)}resumePausedMutations(){return Ie.isOnline()?l(this,xt).resumePausedMutations():Promise.resolve()}getQueryCache(){return l(this,j)}getMutationCache(){return l(this,xt)}getDefaultOptions(){return l(this,Ot)}setDefaultOptions(e){P(this,Ot,e)}setQueryDefaults(e,t){l(this,re).set(Ht(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...l(this,re).values()];let s={};return t.forEach(i=>{Se(e,i.queryKey)&&(s={...s,...i.defaultOptions})}),s}setMutationDefaults(e,t){l(this,ne).set(Ht(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...l(this,ne).values()];let s={};return t.forEach(i=>{Se(e,i.mutationKey)&&(s={...s,...i.defaultOptions})}),s}defaultQueryOptions(e){if(e._defaulted)return e;const t={...l(this,Ot).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=vs(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===ei&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...l(this,Ot).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){l(this,j).clear(),l(this,xt).clear()}},j=new WeakMap,xt=new WeakMap,Ot=new WeakMap,re=new WeakMap,ne=new WeakMap,Lt=new WeakMap,oe=new WeakMap,ae=new WeakMap,Js),tt,O,we,X,Nt,ue,bt,Fe,le,ce,qt,zt,At,he,A,ye,is,rs,ns,os,as,us,ls,li,Xs,Ji=(Xs=class extends ve{constructor(t,s){super();F(this,A);F(this,tt);F(this,O);F(this,we);F(this,X);F(this,Nt);F(this,ue);F(this,bt);F(this,Fe);F(this,le);F(this,ce);F(this,qt);F(this,zt);F(this,At);F(this,he,new Set);this.options=s,P(this,tt,t),P(this,bt,null),this.bindMethods(),this.setOptions(s)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(l(this,O).addObserver(this),xs(l(this,O),this.options)?E(this,A,ye).call(this):this.updateResult(),E(this,A,os).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return cs(l(this,O),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return cs(l(this,O),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,E(this,A,as).call(this),E(this,A,us).call(this),l(this,O).removeObserver(this)}setOptions(t,s){const i=this.options,r=l(this,O);if(this.options=l(this,tt).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof dt(this.options.enabled,l(this,O))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");E(this,A,ls).call(this),l(this,O).setOptions(this.options),i._defaulted&&!Te(this.options,i)&&l(this,tt).getQueryCache().notify({type:"observerOptionsUpdated",query:l(this,O),observer:this});const n=this.hasListeners();n&&Os(l(this,O),r,this.options,i)&&E(this,A,ye).call(this),this.updateResult(s),n&&(l(this,O)!==r||dt(this.options.enabled,l(this,O))!==dt(i.enabled,l(this,O))||Xt(this.options.staleTime,l(this,O))!==Xt(i.staleTime,l(this,O)))&&E(this,A,is).call(this);const o=E(this,A,rs).call(this);n&&(l(this,O)!==r||dt(this.options.enabled,l(this,O))!==dt(i.enabled,l(this,O))||o!==l(this,At))&&E(this,A,ns).call(this,o)}getOptimisticResult(t){const s=l(this,tt).getQueryCache().build(l(this,tt),t),i=this.createResult(s,t);return Yi(this,i)&&(P(this,X,i),P(this,ue,this.options),P(this,Nt,l(this,O).state)),i}getCurrentResult(){return l(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){l(this,he).add(t)}getCurrentQuery(){return l(this,O)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const s=l(this,tt).defaultQueryOptions(t),i=l(this,tt).getQueryCache().build(l(this,tt),s);return i.isFetchingOptimistic=!0,i.fetch().then(()=>this.createResult(i,s))}fetch(t){return E(this,A,ye).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),l(this,X)))}createResult(t,s){var x;const i=l(this,O),r=this.options,n=l(this,X),o=l(this,Nt),a=l(this,ue),u=t!==i?t.state:l(this,we),{state:c}=t;let d={...c},f=!1,p;if(s._optimisticResults){const b=this.hasListeners(),T=!b&&xs(t,s),N=b&&Os(t,i,s,r);(T||N)&&(d={...d,...ai(c.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===(o==null?void 0:o.data)&&s.select===l(this,Fe))p=l(this,le);else try{P(this,Fe,s.select),p=s.select(d.data),p=ss(n==null?void 0:n.data,p,s),P(this,le,p),P(this,bt,null)}catch(b){P(this,bt,b)}else p=d.data;if(s.placeholderData!==void 0&&p===void 0&&g==="pending"){let b;if(n!=null&&n.isPlaceholderData&&s.placeholderData===(a==null?void 0:a.placeholderData))b=n.data;else if(b=typeof s.placeholderData=="function"?s.placeholderData((x=l(this,ce))==null?void 0:x.state.data,l(this,ce)):s.placeholderData,s.select&&b!==void 0)try{b=s.select(b),P(this,bt,null)}catch(T){P(this,bt,T)}b!==void 0&&(g="success",p=ss(n==null?void 0:n.data,b,s),f=!0)}l(this,bt)&&(v=l(this,bt),p=l(this,le),m=Date.now(),g="error");const M=d.fetchStatus==="fetching",S=g==="pending",y=g==="error",w=S&&M,R=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>u.dataUpdateCount||d.errorUpdateCount>u.errorUpdateCount,isFetching:M,isRefetching:M&&!S,isLoadingError:y&&!R,isPaused:d.fetchStatus==="paused",isPlaceholderData:f,isRefetchError:y&&R,isStale:gs(t,s),refetch:this.refetch}}updateResult(t){const s=l(this,X),i=this.createResult(l(this,O),this.options);if(P(this,Nt,l(this,O).state),P(this,ue,this.options),l(this,Nt).data!==void 0&&P(this,ce,l(this,O)),Te(i,s))return;P(this,X,i);const r={},n=()=>{if(!s)return!0;const{notifyOnChangeProps:o}=this.options,a=typeof o=="function"?o():o;if(a==="all"||!a&&!l(this,he).size)return!0;const h=new Set(a??l(this,he));return this.options.throwOnError&&h.add("error"),Object.keys(l(this,X)).some(u=>{const c=u;return l(this,X)[c]!==s[c]&&h.has(c)})};(t==null?void 0:t.listeners)!==!1&&n()&&(r.listeners=!0),E(this,A,li).call(this,{...r,...t})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&E(this,A,os).call(this)}},tt=new WeakMap,O=new WeakMap,we=new WeakMap,X=new WeakMap,Nt=new WeakMap,ue=new WeakMap,bt=new WeakMap,Fe=new WeakMap,le=new WeakMap,ce=new WeakMap,qt=new WeakMap,zt=new WeakMap,At=new WeakMap,he=new WeakMap,A=new WeakSet,ye=function(t){E(this,A,ls).call(this);let s=l(this,O).fetch(this.options,t);return t!=null&&t.throwOnError||(s=s.catch(ct)),s},is=function(){E(this,A,as).call(this);const t=Xt(this.options.staleTime,l(this,O));if(de||l(this,X).isStale||!ts(t))return;const i=Zs(l(this,X).dataUpdatedAt,t)+1;P(this,qt,setTimeout(()=>{l(this,X).isStale||this.updateResult()},i))},rs=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(l(this,O)):this.options.refetchInterval)??!1},ns=function(t){E(this,A,us).call(this),P(this,At,t),!(de||dt(this.options.enabled,l(this,O))===!1||!ts(l(this,At))||l(this,At)===0)&&P(this,zt,setInterval(()=>{(this.options.refetchIntervalInBackground||ys.isFocused())&&E(this,A,ye).call(this)},l(this,At)))},os=function(){E(this,A,is).call(this),E(this,A,ns).call(this,E(this,A,rs).call(this))},as=function(){l(this,qt)&&(clearTimeout(l(this,qt)),P(this,qt,void 0))},us=function(){l(this,zt)&&(clearInterval(l(this,zt)),P(this,zt,void 0))},ls=function(){const t=l(this,tt).getQueryCache().build(l(this,tt),this.options);if(t===l(this,O))return;const s=l(this,O);P(this,O,t),P(this,we,t.state),this.hasListeners()&&(s==null||s.removeObserver(this),t.addObserver(this))},li=function(t){K.batch(()=>{t.listeners&&this.listeners.forEach(s=>{s(l(this,X))}),l(this,tt).getQueryCache().notify({query:l(this,O),type:"observerResultsUpdated"})})},Xs);function Xi(e,t){return dt(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function xs(e,t){return Xi(e,t)||e.state.data!==void 0&&cs(e,t,t.refetchOnMount)}function cs(e,t,s){if(dt(t.enabled,e)!==!1){const i=typeof s=="function"?s(e):s;return i==="always"||i!==!1&&gs(e,t)}return!1}function Os(e,t,s,i){return(e!==t||dt(i.enabled,e)===!1)&&(!s.suspense||e.state.status!=="error")&&gs(e,s)}function gs(e,t){return dt(t.enabled,e)!==!1&&e.isStaleByTime(Xt(t.staleTime,e))}function Yi(e,t){return!Te(e.getCurrentResult(),t)}var Tt,It,et,Pt,wt,Le,hs,Ys,Zi=(Ys=class extends ve{constructor(t,s){super();F(this,wt);F(this,Tt);F(this,It);F(this,et);F(this,Pt);P(this,Tt,t),this.setOptions(s),this.bindMethods(),E(this,wt,Le).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){var i;const s=this.options;this.options=l(this,Tt).defaultMutationOptions(t),Te(this.options,s)||l(this,Tt).getMutationCache().notify({type:"observerOptionsUpdated",mutation:l(this,et),observer:this}),s!=null&&s.mutationKey&&this.options.mutationKey&&Ht(s.mutationKey)!==Ht(this.options.mutationKey)?this.reset():((i=l(this,et))==null?void 0:i.state.status)==="pending"&&l(this,et).setOptions(this.options)}onUnsubscribe(){var t;this.hasListeners()||(t=l(this,et))==null||t.removeObserver(this)}onMutationUpdate(t){E(this,wt,Le).call(this),E(this,wt,hs).call(this,t)}getCurrentResult(){return l(this,It)}reset(){var t;(t=l(this,et))==null||t.removeObserver(this),P(this,et,void 0),E(this,wt,Le).call(this),E(this,wt,hs).call(this)}mutate(t,s){var i;return P(this,Pt,s),(i=l(this,et))==null||i.removeObserver(this),P(this,et,l(this,Tt).getMutationCache().build(l(this,Tt),this.options)),l(this,et).addObserver(this),l(this,et).execute(t)}},Tt=new WeakMap,It=new WeakMap,et=new WeakMap,Pt=new WeakMap,wt=new WeakSet,Le=function(){var s;const t=((s=l(this,et))==null?void 0:s.state)??ui();P(this,It,{...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset})},hs=function(t){K.batch(()=>{var s,i,r,n,o,a,h,u;if(l(this,Pt)&&this.hasListeners()){const c=l(this,It).variables,d=l(this,It).context;(t==null?void 0:t.type)==="success"?((i=(s=l(this,Pt)).onSuccess)==null||i.call(s,t.data,c,d),(n=(r=l(this,Pt)).onSettled)==null||n.call(r,t.data,null,c,d)):(t==null?void 0:t.type)==="error"&&((a=(o=l(this,Pt)).onError)==null||a.call(o,t.error,c,d),(u=(h=l(this,Pt)).onSettled)==null||u.call(h,void 0,t.error,c,d))}this.listeners.forEach(c=>{c(l(this,It))})})},Ys),ci=C.createContext(void 0),hi=e=>{const t=C.useContext(ci);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},Vn=({client:e,children:t})=>(C.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),_.jsx(ci.Provider,{value:e,children:t})),di=C.createContext(!1),tr=()=>C.useContext(di);di.Provider;function er(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var sr=C.createContext(er()),ir=()=>C.useContext(sr);function fi(e,t){return typeof e=="function"?e(...t):!!e}function rr(){}var nr=(e,t)=>{(e.suspense||e.throwOnError)&&(t.isReset()||(e.retryOnMount=!1))},or=e=>{C.useEffect(()=>{e.clearReset()},[e])},ar=({result:e,errorResetBoundary:t,throwOnError:s,query:i})=>e.isError&&!t.isReset()&&!e.isFetching&&i&&fi(s,[e.error,i]),ur=(e,t)=>t.state.data===void 0,lr=e=>{e.suspense&&typeof e.staleTime!="number"&&(e.staleTime=1e3)},cr=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,hr=(e,t,s)=>t.fetchOptimistic(e).catch(()=>{s.clearReset()});function dr(e,t,s){var u,c,d,f;const i=hi(),r=tr(),n=ir(),o=i.defaultQueryOptions(e);(c=(u=i.getDefaultOptions().queries)==null?void 0:u._experimental_beforeQuery)==null||c.call(u,o),o._optimisticResults=r?"isRestoring":"optimistic",lr(o),nr(o,n),or(n);const[a]=C.useState(()=>new t(i,o)),h=a.getOptimisticResult(o);if(C.useSyncExternalStore(C.useCallback(p=>{const v=r?()=>{}:a.subscribe(K.batchCalls(p));return a.updateResult(),v},[a,r]),()=>a.getCurrentResult(),()=>a.getCurrentResult()),C.useEffect(()=>{a.setOptions(o,{listeners:!1})},[o,a]),cr(o,h))throw hr(o,a,n);if(ar({result:h,errorResetBoundary:n,throwOnError:o.throwOnError,query:i.getQueryCache().get(o.queryHash)}))throw h.error;return(f=(d=i.getDefaultOptions().queries)==null?void 0:d._experimental_afterQuery)==null||f.call(d,o,h),o.notifyOnChangeProps?h:a.trackResult(h)}function jn(e,t){return dr({...e,enabled:!0,suspense:!0,throwOnError:ur,placeholderData:void 0},Ji)}function Dn(e){return e}function kn(e,t){const s=hi(),[i]=C.useState(()=>new Zi(s,e));C.useEffect(()=>{i.setOptions(e)},[i,e]);const r=C.useSyncExternalStore(C.useCallback(o=>i.subscribe(K.batchCalls(o)),[i]),()=>i.getCurrentResult(),()=>i.getCurrentResult()),n=C.useCallback((o,a)=>{i.mutate(o,a).catch(rr)},[i]);if(r.error&&fi(i.options.throwOnError,[r.error]))throw r.error;return{...r,mutate:n,mutateAsync:r.mutate}}const Ls="pushstate",As="popstate",pi="beforeunload",mi=e=>(e.preventDefault(),e.returnValue=""),fr=()=>{removeEventListener(pi,mi,{capture:!0})};function vi(e){let t=e.getLocation();const s=new Set;let i=[];const r=()=>{t=e.getLocation(),s.forEach(o=>o())},n=async(o,a)=>{var h;if(!((a==null?void 0:a.ignoreBlocker)??!1)&&typeof document<"u"&&i.length){for(const c of i)if(!await c()){(h=e.onBlocked)==null||h.call(e,r);return}}o()};return{get location(){return t},subscribers:s,subscribe:o=>(s.add(o),()=>{s.delete(o)}),push:(o,a,h)=>{a=ge(a),n(()=>{e.pushState(o,a),r()},h)},replace:(o,a,h)=>{a=ge(a),n(()=>{e.replaceState(o,a),r()},h)},go:(o,a)=>{n(()=>{e.go(o),r()},a)},back:o=>{n(()=>{e.back(),r()},o)},forward:o=>{n(()=>{e.forward(),r()},o)},createHref:o=>e.createHref(o),block:o=>(i.push(o),i.length===1&&addEventListener(pi,mi,{capture:!0}),()=>{i=i.filter(a=>a!==o),i.length||fr()}),flush:()=>{var o;return(o=e.flush)==null?void 0:o.call(e)},destroy:()=>{var o;return(o=e.destroy)==null?void 0:o.call(e)},notify:r}}function ge(e){return e||(e={}),{...e,key:yi()}}function pr(e){const t=typeof document<"u"?window:void 0,s=t.history.pushState,i=t.history.replaceState,r=m=>m,n=()=>ds(`${t.location.pathname}${t.location.search}${t.location.hash}`,t.history.state);let o=n(),a;const h=()=>o;let u,c;const d=()=>{if(!u)return;(u.isPush?s:i).call(t.history,u.state,"",u.href),u=void 0,c=void 0,a=void 0},f=(m,g,M)=>{const S=r(g);c||(a=o),o=ds(g,M),u={href:S,state:M,isPush:(u==null?void 0:u.isPush)||m==="push"},c||(c=Promise.resolve().then(()=>d()))},p=()=>{o=n(),v.notify()},v=vi({getLocation:h,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(Ls,p),t.removeEventListener(As,p)},onBlocked:m=>{a&&o!==a&&(o=a,m())}});return t.addEventListener(Ls,p),t.addEventListener(As,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 mr(e={initialEntries:["/"]}){const t=e.initialEntries;let s=e.initialIndex??t.length-1,i={key:yi()};return vi({getLocation:()=>ds(t[s],i),pushState:(n,o)=>{i=o,t.splice,s<t.length-1&&t.splice(s+1),t.push(n),s=Math.max(t.length-1,0)},replaceState:(n,o)=>{i=o,t[s]=n},back:()=>{i=ge(i),s=Math.max(s-1,0)},forward:()=>{i=ge(i),s=Math.min(s+1,t.length-1)},go:n=>{i=ge(i),s=Math.min(Math.max(s+n,0),t.length-1)},createHref:n=>n})}function ds(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 yi(){return(Math.random()+1).toString(36).substring(7)}var vr="Invariant failed";function st(e,t){if(!e)throw new Error(vr)}const We=C.createContext(null);function gi(){return typeof document>"u"?We:window.__TSR_ROUTER_CONTEXT__?window.__TSR_ROUTER_CONTEXT__:(window.__TSR_ROUTER_CONTEXT__=We,We)}function jt(e){const t=C.useContext(gi());return e==null||e.warn,t}var bi={exports:{}},Si={},Mi={exports:{}},Pi={};/**
|
|
* @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 fe=C;function yr(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var gr=typeof Object.is=="function"?Object.is:yr,br=fe.useState,Sr=fe.useEffect,Mr=fe.useLayoutEffect,Pr=fe.useDebugValue;function wr(e,t){var s=t(),i=br({inst:{value:s,getSnapshot:t}}),r=i[0].inst,n=i[1];return Mr(function(){r.value=s,r.getSnapshot=t,Ge(r)&&n({inst:r})},[e,s,t]),Sr(function(){return Ge(r)&&n({inst:r}),e(function(){Ge(r)&&n({inst:r})})},[e]),Pr(s),s}function Ge(e){var t=e.getSnapshot;e=e.value;try{var s=t();return!gr(e,s)}catch{return!0}}function Fr(e,t){return t()}var _r=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?Fr:wr;Pi.useSyncExternalStore=fe.useSyncExternalStore!==void 0?fe.useSyncExternalStore:_r;Mi.exports=Pi;var Cr=Mi.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 $e=C,Rr=Cr;function Er(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var xr=typeof Object.is=="function"?Object.is:Er,Or=Rr.useSyncExternalStore,Lr=$e.useRef,Ar=$e.useEffect,Tr=$e.useMemo,Ir=$e.useDebugValue;Si.useSyncExternalStoreWithSelector=function(e,t,s,i,r){var n=Lr(null);if(n.current===null){var o={hasValue:!1,value:null};n.current=o}else o=n.current;n=Tr(function(){function h(p){if(!u){if(u=!0,c=p,p=i(p),r!==void 0&&o.hasValue){var v=o.value;if(r(v,p))return d=v}return d=p}if(v=d,xr(c,p))return v;var m=i(p);return r!==void 0&&r(v,m)?v:(c=p,d=m)}var u=!1,c,d,f=s===void 0?null:s;return[function(){return h(t())},f===null?void 0:function(){return h(f())}]},[t,s,i,r]);var a=Or(e,n[0],n[1]);return Ar(function(){o.hasValue=!0,o.value=a},[a]),Ir(a),a};bi.exports=Si;var Vr=bi.exports;class bs{constructor(t,s){this.listeners=new Set,this._batching=!1,this._flushing=0,this.subscribe=i=>{var r,n;this.listeners.add(i);const o=(n=(r=this.options)==null?void 0:r.onSubscribe)==null?void 0:n.call(r,i,this);return()=>{this.listeners.delete(i),o==null||o()}},this.setState=i=>{var r,n,o;const a=this.state;this.state=(r=this.options)!=null&&r.updateFn?this.options.updateFn(a)(i):i(a),(o=(n=this.options)==null?void 0:n.onUpdate)==null||o.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 Ve(e,t=s=>s){return Vr.useSyncExternalStoreWithSelector(e.subscribe,()=>e.state,()=>e.state,t,jr)}function jr(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<s.length;i++)if(!Object.prototype.hasOwnProperty.call(t,s[i])||!Object.is(e[s[i]],t[s[i]]))return!1;return!0}const rt="__root__";function Dr(e,t){let s,i,r,n="";for(s in e)if((r=e[s])!==void 0)if(Array.isArray(r))for(i=0;i<r.length;i++)n&&(n+="&"),n+=encodeURIComponent(s)+"="+encodeURIComponent(r[i]);else n&&(n+="&"),n+=encodeURIComponent(s)+"="+encodeURIComponent(r);return""+n}function Ts(e){if(!e)return"";const t=decodeURIComponent(e);return t==="false"?!1:t==="true"?!0:+t*0===0&&+t+""===t?+t:t}function kr(e,t){let s,i;const r={},n=e.split("&");for(;s=n.shift();){const o=s.indexOf("=");if(o!==-1){i=s.slice(0,o);const a=s.slice(o+1);r[i]!==void 0?r[i]=[].concat(r[i],Ts(a)):r[i]=Ts(a)}else i=s,r[i]=""}return r}const Br=Ur(JSON.parse),$r=Qr(JSON.stringify,JSON.parse);function Ur(e){return t=>{t.substring(0,1)==="?"&&(t=t.substring(1));const s=kr(t);for(const i in s){const r=s[i];if(typeof r=="string")try{s[i]=e(r)}catch{}}return s}}function Qr(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 o=i[n];typeof o>"u"||o===void 0?delete i[n]:i[n]=s(o)});const r=Dr(i).toString();return r?`?${r}`:""}}function je(e){return e[e.length-1]}function Kr(e){return typeof e=="function"}function Jt(e,t){return Kr(e)?e(t):e}function be(e,t){return t.reduce((s,i)=>(s[i]=e[i],s),{})}function pt(e,t){if(e===t)return e;const s=t,i=Vs(e)&&Vs(s);if(i||De(e)&&De(s)){const r=i?e:Object.keys(e),n=r.length,o=i?s:Object.keys(s),a=o.length,h=i?[]:{};let u=0;for(let c=0;c<a;c++){const d=i?c:o[c];(!i&&r.includes(d)||i)&&e[d]===void 0&&s[d]===void 0?(h[d]=void 0,u++):(h[d]=pt(e[d],s[d]),h[d]===e[d]&&e[d]!==void 0&&u++)}return n===a&&u===n?e:h}return s}function De(e){if(!Is(e))return!1;const t=e.constructor;if(typeof t>"u")return!0;const s=t.prototype;return!(!Is(s)||!s.hasOwnProperty("isPrototypeOf"))}function Is(e){return Object.prototype.toString.call(e)==="[object Object]"}function Vs(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Yt(e,t,s=!1){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(De(e)&&De(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)||!Yt(e[n],t[n],s))}return Array.isArray(e)&&Array.isArray(t)?e.length!==t.length?!1:!e.some((i,r)=>!Yt(i,t[r],s)):!1}const Je=typeof window<"u"?C.useLayoutEffect:C.useEffect;function Gt(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 js(e){const t=C.useRef({value:e,prev:null}),s=t.current.value;return e!==s&&(t.current={value:e,prev:s}),t.current.prev}function Vt(e){return Ue(e.filter(Boolean).join("/"))}function Ue(e){return e.replace(/\/{2,}/g,"/")}function Ss(e){return e==="/"?e:e.replace(/^\/{1,}/,"")}function Bt(e){return e==="/"?e:e.replace(/\/{1,}$/,"")}function Nr(e){return Bt(Ss(e))}function ke(e,t){return e.endsWith("/")&&e!=="/"&&e!==`${t}/`?e.slice(0,-1):e}function qr(e,t,s){return ke(e,s)===ke(t,s)}function zr({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 o=pe(t);const a=pe(s);o.length>1&&((r=je(o))==null?void 0:r.value)==="/"&&o.pop(),a.forEach((u,c)=>{u.value==="/"?c?c===a.length-1&&o.push(u):o=[u]:u.value===".."?o.pop():u.value==="."||o.push(u)}),o.length>1&&(((n=je(o))==null?void 0:n.value)==="/"?i==="never"&&o.pop():i==="always"&&o.push({type:"pathname",value:"/"}));const h=Vt([e,...o.map(u=>u.value)]);return Ue(h)}function pe(e){if(!e)return[];e=Ue(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 Xe({path:e,params:t,leaveWildcards:s,leaveParams:i}){const r=pe(e),n={};for(const[o,a]of Object.entries(t)){const h=typeof a=="string";["*","_splat"].includes(o)?n[o]=h?encodeURI(a):a:n[o]=h?encodeURIComponent(a):a}return Vt(r.map(o=>{if(o.type==="wildcard"){const a=n._splat;return s?`${o.value}${a??""}`:a}if(o.type==="param"){if(i){const a=n[o.value];return`${o.value}${a??""}`}return n[o.value.substring(1)]??"undefined"}return o.value}))}function Ee(e,t,s){const i=Hr(e,t,s);if(!(s.to&&!i))return i??{}}function Ds(e,t){switch(!0){case e==="/":return t;case t===e:return"";case t.length<e.length:return t;case t[e.length]!=="/":return t;case t.startsWith(e):return t.slice(e.length);default:return t}}function Hr(e,t,s){t=Ds(e,t);const i=Ds(e,`${s.to??"$"}`),r=pe(t),n=pe(i);t.startsWith("/")||r.unshift({type:"pathname",value:"/"}),i.startsWith("/")||n.unshift({type:"pathname",value:"/"});const o={};return(()=>{for(let h=0;h<Math.max(r.length,n.length);h++){const u=r[h],c=n[h],d=h>=r.length-1,f=h>=n.length-1;if(c){if(c.type==="wildcard"){if(u!=null&&u.value){const p=decodeURI(Vt(r.slice(h).map(v=>v.value)));return o["*"]=p,o._splat=p,!0}return!1}if(c.type==="pathname"){if(c.value==="/"&&!(u!=null&&u.value))return!0;if(u){if(s.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)!=="$"&&(o[c.value.substring(1)]=decodeURIComponent(u.value))}}if(!d&&f)return o["**"]=Vt(r.slice(h+1).map(p=>p.value)),!!s.fuzzy&&(c==null?void 0:c.value)!=="/"}return!0})()?o:void 0}function Bn(e){if(e.isRedirect=!0,e.statusCode=e.statusCode||e.code||301,e.headers=e.headers||{},e.throw)throw e;return e}function kt(e){return!!(e!=null&&e.isRedirect)}function ks(e){return!!(e!=null&&e.isRedirect)&&e.href}function Ms(e){const t=e.errorComponent??Qe;return _.jsx(Wr,{getResetKey:e.getResetKey,onCatch:e.onCatch,children:({error:s,reset:i})=>s?C.createElement(t,{error:s,reset:i}):e.children})}class Wr extends C.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 Qe({error:e}){const[t,s]=C.useState(!1);return _.jsxs("div",{style:{padding:".5rem",maxWidth:"100%"},children:[_.jsxs("div",{style:{display:"flex",alignItems:"center",gap:".5rem"},children:[_.jsx("strong",{style:{fontSize:"1rem"},children:"Something went wrong!"}),_.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"})]}),_.jsx("div",{style:{height:".25rem"}}),t?_.jsx("div",{children:_.jsx("pre",{style:{fontSize:".7em",border:"1px solid red",borderRadius:".25rem",padding:".3rem",color:"red",overflow:"auto"},children:e.message?_.jsx("code",{children:e.message}):null})}):null]})}function Y(e){const t=jt({warn:(e==null?void 0:e.router)===void 0});return Ve(((e==null?void 0:e.router)||t).__store,e==null?void 0:e.select)}function mt(e){return!!(e!=null&&e.isNotFound)}function Gr(e){const t=Y({select:s=>`not-found-${s.location.pathname}-${s.status}`});return _.jsx(Ms,{getResetKey:()=>t,onCatch:(s,i)=>{var r;if(mt(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 Jr(){return _.jsx("p",{children:"Not Found"})}const Xr=["component","errorComponent","pendingComponent","notFoundComponent"];function $n(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=`/${Nr(s.basepath)}`),(!this.history||this.options.history&&this.options.history!==this.history)&&(this.history=this.options.history??(this.isServer?mr({initialEntries:[this.basepath||"/"]}):pr()),this.latestLocation=this.parseLocation()),this.options.routeTree!==this.routeTree&&(this.routeTree=this.options.routeTree,this.buildRouteTree()),this.__store||(this.__store=new bs(en(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=o=>{o.forEach((a,h)=>{a.init({originalIndex:h});const u=this.routesById[a.id];if(st(!u,`Duplicate routes found with id: ${String(a.id)}`),this.routesById[a.id]=a,!a.isRoot&&a.path){const d=Bt(a.fullPath);(!this.routesByPath[d]||a.fullPath.endsWith("/"))&&(this.routesByPath[d]=a)}const c=a.children;c!=null&&c.length&&i(c)})};i([this.routeTree]);const r=[];Object.values(this.routesById).forEach((o,a)=>{var h;if(o.isRoot||!o.path)return;const u=Ss(o.fullPath),c=pe(u);for(;c.length>1&&((h=c[0])==null?void 0:h.value)==="/";)c.shift();const d=c.map(f=>f.value==="/"?.75:f.type==="param"?.5:f.type==="wildcard"?.25:1);r.push({child:o,trimmed:u,parsed:c,index:a,scores:d})}),this.flatRoutes=r.sort((o,a)=>{const h=Math.min(o.scores.length,a.scores.length);for(let u=0;u<h;u++)if(o.scores[u]!==a.scores[u])return a.scores[u]-o.scores[u];if(o.scores.length!==a.scores.length)return a.scores.length-o.scores.length;for(let u=0;u<h;u++)if(o.parsed[u].value!==a.parsed[u].value)return o.parsed[u].value>a.parsed[u].value?1:-1;return o.index-a.index}).map((o,a)=>(o.child.rank=a,o.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:a,search:h,hash:u,state:c})=>{const d=this.options.parseSearch(h),f=this.options.stringifySearch(d);return{pathname:a,searchStr:f,search:pt(s==null?void 0:s.search,d),hash:u.split("#").reverse()[0]??"",href:`${a}${f}${u}`,state:pt(s==null?void 0:s.state,c)}},r=i(this.history.location),{__tempLocation:n,__tempKey:o}=r.state;if(n&&(!o||o===this.tempLocationKey)){const a=i(n);return a.state.key=r.state.key,delete a.state.__tempLocation,{...a,maskedLocation:r}}return r},this.resolvePathWithBase=(s,i)=>zr({basepath:this.basepath,base:s,to:Ue(i),trailingSlash:this.options.trailingSlash}),this.matchRoutes=(s,i,r)=>{let n={};const o=this.flatRoutes.find(p=>{const v=Ee(this.basepath,Bt(s),{to:p.fullPath,caseSensitive:p.options.caseSensitive??this.options.caseSensitive,fuzzy:!0});return v?(n=v,!0):!1});let a=o||this.routesById[rt];const h=[a];let u=!1;for((o?o.path!=="/"&&n["**"]:Bt(s))&&(this.options.notFoundRoute?h.push(this.options.notFoundRoute):u=!0);a.parentRoute;)a=a.parentRoute,h.unshift(a);const c=(()=>{if(u){if(this.options.notFoundMode!=="root")for(let p=h.length-1;p>=0;p--){const v=h[p];if(v.children)return v.id}return rt}})(),d=h.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 tn(M.message,{cause:M}),r!=null&&r.throwOnError)throw m;return m}}),f=[];return h.forEach((p,v)=>{var m,g,M,S,y,w,R,L,x,b;const T=f[v-1],[N,q]=(()=>{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 Zr(W.message,{cause:W});if(r!=null&&r.throwOnError)throw Z;return[k,Z]}})(),$=((g=(m=p.options).loaderDeps)==null?void 0:g.call(m,{search:N}))??"",I=$?JSON.stringify($):"",Q=Xe({path:p.fullPath,params:n}),z=Xe({path:p.id,params:n,leaveWildcards:!0})+I,H=this.getMatch(z),ft=this.state.matches.find(k=>k.id===z)?"stay":"enter";let D;if(H)D={...H,cause:ft,params:n};else{const k=p.options.loader||p.options.beforeLoad||p.lazyFn?"pending":"success";D={id:z,index:v,routeId:p.id,params:n,pathname:Vt([this.basepath,Q]),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:ft,loaderDeps:$,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:Gt()}}D.status==="success"&&(D.meta=(L=(R=p.options).meta)==null?void 0:L.call(R,{matches:f,match:D,params:D.params,loaderData:D.loaderData}),D.headers=(b=(x=p.options).headers)==null?void 0:b.call(x,{loaderData:D.loaderData})),r!=null&&r.preload||(D.globalNotFound=c===p.id),D.search=pt(D.search,N),D.searchError=q,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={},o)=>{var a,h,u;const c=n._fromLocation!=null?this.matchRoutes(n._fromLocation.pathname,n.fromSearch||n._fromLocation.search):this.state.matches,d=n.from!=null?c.find(I=>Ee(this.basepath,Bt(I.pathname),{to:n.from,caseSensitive:!1,fuzzy:!1})):void 0,f=(d==null?void 0:d.pathname)||this.latestLocation.pathname;st(n.from==null||d!=null,"Could not find match for from: "+n.from);const p=((a=je(c))==null?void 0:a.search)||this.latestLocation.search,v=o==null?void 0:o.filter(I=>c.find(Q=>Q.routeId===I.routeId)),m=this.routesById[(h=v==null?void 0:v.find(I=>I.pathname===f))==null?void 0:h.routeId];let g=n.to?this.resolvePathWithBase(f,`${n.to}`):this.resolvePathWithBase(f,(m==null?void 0:m.to)??f);const M={...(u=je(c))==null?void 0:u.params};let S=(n.params??!0)===!0?M:{...M,...Jt(n.params,M)};Object.keys(S).length>0&&(o==null||o.map(I=>{var Q;const z=this.looseRoutesById[I.routeId];return((Q=z==null?void 0:z.options.params)==null?void 0:Q.stringify)??z.options.stringifyParams}).filter(Boolean).forEach(I=>{S={...S,...I(S)}})),g=Xe({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))??[],R=y.length?y.reduce((I,Q)=>Q(I),p):p,L=n.search===!0?R:n.search?Jt(n.search,R):y.length?R:{},x=w.length?w.reduce((I,Q)=>Q(I),L):L,b=pt(p,x),T=this.options.stringifySearch(b),N=n.hash===!0?this.latestLocation.hash:n.hash?Jt(n.hash,this.latestLocation.hash):void 0,q=N?`#${N}`:"";let $=n.state===!0?this.latestLocation.state:n.state?Jt(n.state,this.latestLocation.state):{};return $=pt(this.latestLocation.state,$),{pathname:g,search:b,searchStr:T,state:$,hash:N??"",href:`${g}${T}${q}`,unmaskOnReload:n.unmaskOnReload}},r=(n={},o)=>{var a;const h=i(n);let u=o?i(o):void 0;if(!u){let v={};const m=(a=this.options.routeMasks)==null?void 0:a.find(g=>{const M=Ee(this.basepath,h.pathname,{to:g.from,caseSensitive:!1,fuzzy:!1});return M?(v=M,!0):!1});if(m){const{from:g,...M}=m;o={...be(s,["from"]),...M,params:v},u=i(o)}}const c=this.matchRoutes(h.pathname,h.search),d=u?this.matchRoutes(u.pathname,u.search):void 0,f=u?i(o,d):void 0,p=i(n,c);return f&&(p.maskedLocation=f),p};return s.mask?r(s,{...be(s,["from"]),...s.mask}):r(s)},this.commitLocation=({viewTransition:s,ignoreBlocker:i,...r})=>{const n=()=>{r.state.key=this.latestLocation.state.key;const h=Yt(r.state,this.latestLocation.state);return delete r.state.key,h},o=this.latestLocation.href===r.href,a=this.commitLocationPromise;if(this.commitLocationPromise=Gt(()=>{a==null||a.resolve()}),o&&n())this.load();else{let{maskedLocation:h,...u}=r;h&&(u={...h,state:{...h.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=s,this.history[r.replace?"replace":"push"](u.href,u.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,...o}={})=>{const a=this.buildLocation(o);return this.commitLocation({...a,viewTransition:r,replace:s,resetScroll:i,ignoreBlocker:n})},this.navigate=({from:s,to:i,__isRedirect:r,...n})=>{const o=String(i);let a;try{new URL(`${o}`),a=!0}catch{}return st(!a),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 o;try{const a=this.latestLocation,h=this.state.resolvedLocation,u=h.href!==a.href;this.cancelMatches();let c;this.__store.batch(()=>{c=this.matchRoutes(a.pathname,a.search),this.__store.setState(d=>({...d,status:"pending",isLoading:!0,location:a,pendingMatches:c,cachedMatches:d.cachedMatches.filter(f=>!c.find(p=>p.id===f.id))}))}),this.state.redirect||this.emit({type:"onBeforeNavigate",fromLocation:h,toLocation:a,pathChanged:u}),this.emit({type:"onBeforeLoad",fromLocation:h,toLocation:a,pathChanged:u}),await this.loadMatches({matches:c,location:a,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(a){ks(a)?(s=a,this.isServer||this.navigate({...a,replace:!0,__isRedirect:!0})):mt(a)&&(i=a),this.__store.setState(h=>({...h,statusCode:s?s.statusCode:i?404:h.matches.some(u=>u.status==="error")?500:200,redirect:s}))}this.latestLoadPromise===r&&((o=this.commitLocationPromise)==null||o.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 o=(r=this.state.pendingMatches)==null?void 0:r.find(u=>u.id===s),a=this.state.matches.find(u=>u.id===s),h=o?"pendingMatches":a?"matches":"cachedMatches";return this.__store.setState(u=>{var c;return{...u,[h]:(c=u[h])==null?void 0:c.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:o=this.updateMatch})=>{let a,h=!1;const u=async()=>{h||(h=!0,await(n==null?void 0:n()))};!this.isServer&&!this.state.matches.length&&u();const c=(d,f)=>{var p,v,m;if(ks(f))throw f;if(kt(f)||mt(f)){if(o(d.id,g=>({...g,status:kt(f)?"redirected":mt(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(),kt(f))throw h=!0,f=this.resolveRedirect({...f,_fromLocation:s}),f;if(mt(f))throw this._handleNotFound(i,f,{updateMatch:o}),f}};try{await new Promise((d,f)=>{(async()=>{var p,v,m;try{const g=(y,w,R)=>{var L,x;const{id:b,routeId:T}=i[y],N=this.looseRoutesById[T];if(w instanceof Promise)throw w;w.routerCode=R,a=a??y,c(this.getMatch(b),w);try{(x=(L=N.options).onError)==null||x.call(L,w)}catch(q){w=q,c(this.getMatch(b),w)}o(b,q=>{var $;return($=q.beforeLoadPromise)==null||$.resolve(),{...q,error:w,status:"error",isFetching:!1,updatedAt:Date.now(),abortController:new AbortController,beforeLoadPromise:void 0}})};for(const[y,{id:w,routeId:R}]of i.entries()){const L=this.getMatch(w);if(L.beforeLoadPromise||L.loaderPromise)await L.beforeLoadPromise;else{try{o(w,B=>({...B,loadPromise:Gt(()=>{var ot;(ot=B.loadPromise)==null||ot.resolve()}),beforeLoadPromise:Gt()}));const x=this.looseRoutesById[R],b=new AbortController,T=(p=i[y-1])==null?void 0:p.id,N=()=>T?this.getMatch(T).context??this.options.context??{}:this.options.context??{},q=x.options.pendingMs??this.options.defaultPendingMs,$=!!(n&&!this.isServer&&!r&&(x.options.loader||x.options.beforeLoad)&&typeof q=="number"&&q!==1/0&&(x.options.pendingComponent??this.options.defaultPendingComponent));let I;$&&(I=setTimeout(()=>{try{u()}catch{}},q));const{paramsError:Q,searchError:z}=this.getMatch(w);Q&&g(y,Q,"PARSE_PARAMS"),z&&g(y,z,"VALIDATE_SEARCH");const H=N();o(w,B=>({...B,isFetching:"beforeLoad",fetchCount:B.fetchCount+1,routeContext:pt(B.routeContext,H),context:pt(B.context,H),abortController:b,pendingTimeout:I}));const{search:ft,params:D,routeContext:k,cause:W}=this.getMatch(w),Z={search:ft,abortController:b,params:D,preload:!!r,context:k,location:s,navigate:B=>this.navigate({...B,_fromLocation:s}),buildLocation:this.buildLocation,cause:r?"preload":W},nt=await((m=(v=x.options).beforeLoad)==null?void 0:m.call(v,Z))??{};(kt(nt)||mt(nt))&&g(y,nt,"BEFORE_LOAD"),o(w,B=>{const ot={...B.routeContext,...nt};return{...B,routeContext:pt(B.routeContext,ot),context:pt(B.context,ot),abortController:b}})}catch(x){g(y,x,"BEFORE_LOAD")}o(w,x=>{var b;return(b=x.beforeLoadPromise)==null||b.resolve(),{...x,beforeLoadPromise:void 0,isFetching:!1}})}}const M=i.slice(0,a),S=[];M.forEach(({id:y,routeId:w},R)=>{S.push((async()=>{const{loaderPromise:L}=this.getMatch(y);if(L)await L;else{const x=S[R-1],b=this.looseRoutesById[w],T=()=>{const{params:k,loaderDeps:W,abortController:Z,context:nt,cause:B}=this.getMatch(y);return{params:k,deps:W,preload:!!r,parentMatchPromise:x,abortController:Z,context:nt,location:s,navigate:ot=>this.navigate({...ot,_fromLocation:s}),cause:r?"preload":B,route:b}},N=Date.now()-this.getMatch(y).updatedAt,q=r?b.options.preloadStaleTime??this.options.defaultPreloadStaleTime??3e4:b.options.staleTime??this.options.defaultStaleTime??0,$=b.options.shouldReload,I=typeof $=="function"?$(T()):$;o(y,k=>({...k,loaderPromise:Gt(),preload:!!r&&!this.state.matches.find(W=>W.id===y)}));const Q=async()=>{var k,W,Z,nt,B,ot,_e,Ft;try{const _t=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(Xr.map(async V=>{const Dt=b.options[V];Dt!=null&&Dt.preload&&await Dt.preload()})));o(y,V=>({...V,isFetching:"loader",componentsPromise:at})),await b._lazyPromise;let ut=await((W=(k=b.options).loader)==null?void 0:W.call(k,T()));this.serializeLoaderData&&(ut=this.serializeLoaderData(ut,{router:this,match:this.getMatch(y)})),c(this.getMatch(y),ut),await _t();const St=(nt=(Z=b.options).meta)==null?void 0:nt.call(Z,{matches:i,match:this.getMatch(y),params:this.getMatch(y).params,loaderData:ut}),U=(ot=(B=b.options).headers)==null?void 0:ot.call(B,{loaderData:ut});o(y,V=>({...V,error:void 0,status:"success",isFetching:!1,updatedAt:Date.now(),loaderData:ut,meta:St,headers:U}))}catch(at){let ut=at;await _t(),c(this.getMatch(y),at);try{(Ft=(_e=b.options).onError)==null||Ft.call(_e,at)}catch(St){ut=St,c(this.getMatch(y),St)}o(y,St=>({...St,error:ut,status:"error",isFetching:!1}))}await this.getMatch(y).componentsPromise}catch(_t){c(this.getMatch(y),_t)}},{status:z,invalid:H}=this.getMatch(y);z==="success"&&(H||(I??N>q))?(async()=>{try{await Q()}catch{}})():z!=="success"&&await Q();const{loaderPromise:ft,loadPromise:D}=this.getMatch(y);ft==null||ft.resolve(),D==null||D.resolve()}o(y,x=>({...x,isFetching:!1,loaderPromise:void 0}))})())}),await Promise.all(S),d()}catch(g){f(g)}})()}),await u()}catch(d){if(kt(d)||mt(d))throw mt(d)&&!r&&await u(),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<n})}))},this.preloadRoute=async s=>{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(a=>[a.id,!0]));this.__store.batch(()=>{r.forEach(a=>{n[a.id]||this.__store.setState(h=>({...h,cachedMatches:[...h.cachedMatches,a]}))})});const o=new Set([...this.state.matches,...this.state.pendingMatches??[]].map(a=>a.id));try{return r=await this.loadMatches({matches:r,location:i,preload:!0,updateMatch:(a,h)=>{o.has(a)?r=r.map(u=>u.id===a?h(u):u):this.updateMatch(a,h)}}),r}catch(a){if(kt(a))return await this.preloadRoute({...a,_fromLocation:i});console.error(a);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 a=((i==null?void 0:i.pending)===void 0?!this.state.isLoading:i.pending)?this.latestLocation:this.state.resolvedLocation,h=Ee(this.basepath,a.pathname,{...i,to:n.pathname});return!h||s.params&&!Yt(h,s.params,!0)?!1:h&&((i==null?void 0:i.includeSearch)??!0)?Yt(a.search,n.search,!0)?h:!1:h},this.dehydrate=()=>{var s;const i=((s=this.options.errorSerializer)==null?void 0:s.serialize)??sn;return{state:{dehydratedMatches:this.state.matches.map(r=>({...be(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)),st(n),this.dehydratedData=n.payload,(r=(i=this.options).hydrate)==null||r.call(i,n.payload);const o=n.router.state,a=this.matchRoutes(this.state.location.pathname,this.state.location.search).map(h=>{const u=o.dehydratedMatches.find(c=>c.id===h.id);return st(u,`Could not find a client-side match for dehydrated match with id: ${h.id}!`),{...h,...u}});this.__store.setState(h=>({...h,matches:a})),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;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(`<script class='tsr-once'>${n}; __TSR__.cleanScripts()<\/script>`)},this._handleNotFound=(s,i,{updateMatch:r=this.updateMatch}={})=>{const n=Object.fromEntries(s.map(h=>[h.routeId,h]));let o=(i.global?this.looseRoutesById[rt]:this.looseRoutesById[i.routeId])||this.looseRoutesById[rt];for(;!o.options.notFoundComponent&&!this.options.defaultNotFoundComponent&&o.id!==rt;)o=o.parentRoute,st(o);const a=n[o.id];st(a,"Could not find match for route: "+o.id),r(a.id,h=>({...h,status:"notFound",error:i,isFetching:!1})),i.routerCode==="BEFORE_LOAD"&&o.parentRoute&&(i.routeId=o.parentRoute.id,this._handleNotFound(s,i,{updateMatch:r}))},this.hasNotFoundMatch=()=>this.__store.state.matches.some(s=>s.status==="notFound"||s.globalNotFound),this.update({defaultPreloadDelay:50,defaultPendingMs:1e3,defaultPendingMinMs:500,context:void 0,...t,stringifySearch:t.stringifySearch??$r,parseSearch:t.parseSearch??Br}),typeof document<"u"&&(window.__TSR__ROUTER__=this)}get state(){return this.__store.state}get looseRoutesById(){return this.routesById}}class Zr extends Error{}class tn extends Error{}function en(e){return{loadedAt:0,isLoading:!1,isTransitioning:!1,status:"idle",resolvedLocation:{...e},location:e,matches:[],pendingMatches:[],cachedMatches:[],statusCode:200}}function sn(e){return e instanceof Error?{name:e.name,message:e.message}:{data:e}}function Bs(e){return!(typeof e=="object"&&e&&"data"in e)||!("__isServerError"in e&&e.__isServerError)||!(typeof e.data=="object"&&e.data)?!1:e.__isServerError===!0}function $s(e){if("name"in e&&"message"in e){const t=new Error(e.message);return t.name=e.name,t}return e.data}const Ke=C.createContext(void 0);function me(e){const t=C.useContext(Ke);return Y({select:i=>{const r=i.matches.find(n=>e.from?e.from===n.routeId:n.id===t);if(st(!((e.shouldThrow??!0)&&!r),`Could not find ${e.from?`an active match from "${e.from}"`:"a nearest match!"}`),r!==void 0)return e.select?e.select(r):r}})}function rn(e){return me({...e,select:t=>typeof e.select=="function"?e.select(t.loaderDeps):t.loaderDeps})}function nn(e){return me({...e,select:t=>typeof e.select=="function"?e.select(t.loaderData):t.loaderData})}function on(e){return me({...e,select:t=>e.select?e.select(t.params):t.params})}function an(e){return me({...e,select:t=>e.select?e.select(t.search):t.search})}function un(e){const t=jt();return C.useCallback(s=>t.navigate({...s}),[t])}class wi{constructor(t){this.init=s=>{var i,r;this.originalIndex=s.originalIndex;const n=this.options,o=!(n!=null&&n.path)&&!(n!=null&&n.id);this.parentRoute=(r=(i=this.options)==null?void 0:i.getParentRoute)==null?void 0:r.call(i),o?this.path=rt:st(this.parentRoute);let a=o?rt:n.path;a&&a!=="/"&&(a=Ss(a));const h=(n==null?void 0:n.id)||a;let u=o?rt:Vt([this.parentRoute.id===rt?"":this.parentRoute.id,h]);a===rt&&(a="/"),u!==rt&&(u=Vt(["/",u]));const c=u===rt?"/":Vt([this.parentRoute.fullPath,a]);this.path=a,this.id=u,this.fullPath=c,this.to=c},this.updateLoader=s=>(Object.assign(this.options,s),this),this.update=s=>(Object.assign(this.options,s),this),this.lazy=s=>(this.lazyFn=s,this),this.useMatch=s=>me({...s,from:this.id}),this.useRouteContext=s=>me({...s,from:this.id,select:i=>s!=null&&s.select?s.select(i.context):i.context}),this.useSearch=s=>an({...s,from:this.id}),this.useParams=s=>on({...s,from:this.id}),this.useLoaderDeps=s=>rn({...s,from:this.id}),this.useLoaderData=s=>nn({...s,from:this.id}),this.useNavigate=()=>un({from:this.id}),this.options=t||{},this.isRoot=!(t!=null&&t.getParentRoute),st(!(t!=null&&t.id&&(t!=null&&t.path))),this.$$typeof=Symbol.for("react.memo")}addChildren(t){return this.children=Array.isArray(t)?t:Object.values(t),this}}function ln(e){return new wi(e)}function Un(){return e=>hn(e)}class cn extends wi{constructor(t){super(t)}addChildren(t){return super.addChildren(t)}}function hn(e){return new cn(e)}function Qn(e){return new dn(e,{silent:!0}).createRoute}class dn{constructor(t,s){this.path=t,this.createRoute=i=>{this.silent;const r=ln(i);return r.isRoot=!1,r},this.silent=s==null?void 0:s.silent}}const fn="Error preloading route! ☝️";function pn(e){const t=jt(),[s,i]=C.useState(!1),{activeProps:r=()=>({className:"active"}),inactiveProps:n=()=>({}),activeOptions:o,hash:a,search:h,params:u,to:c,state:d,mask:f,preload:p,preloadDelay:v,replace:m,startTransition:g,resetScroll:M,viewTransition:S,children:y,target:w,disabled:R,style:L,className:x,onClick:b,onFocus:T,onMouseEnter:N,onMouseLeave:q,onTouchStart:$,ignoreBlocker:I,...Q}=e;let z="internal";try{new URL(`${c}`),z="external"}catch{}const H=t.buildLocation(e),ft=p??t.options.defaultPreload,D=v??t.options.defaultPreloadDelay??0,k=Y({select:U=>{const V=ke(U.location.pathname,t.basepath).split("/"),qe=ke(H.pathname,t.basepath).split("/").every((Ai,Ti)=>Ai===V[Ti]),xi=o!=null&&o.exact?qr(U.location.pathname,H.pathname,t.basepath):qe,Oi=o!=null&&o.includeHash?U.location.hash===H.hash:!0,Li=(o==null?void 0:o.includeSearch)??!0?Yt(U.location.search,H.search,!(o!=null&&o.exact)):!0;return xi&&Oi&&Li}});if(z==="external")return{...Q,type:z,href:c,...y&&{children:y},...w&&{target:w},...R&&{disabled:R},...L&&{style:L},...x&&{className:x},...b&&{onClick:b},...T&&{onFocus:T},...N&&{onMouseEnter:N},...q&&{onMouseLeave:q},...$&&{onTouchStart:$}};const W=U=>{if(!R&&!mn(U)&&!U.defaultPrevented&&(!w||w==="_self")&&U.button===0){U.preventDefault(),Ii.flushSync(()=>{i(!0)});const V=t.subscribe("onResolved",()=>{V(),i(!1)});t.commitLocation({...H,replace:m,resetScroll:M,startTransition:g,viewTransition:S,ignoreBlocker:I})}},Z=()=>{t.preloadRoute(e).catch(U=>{console.warn(U),console.warn(fn)})},nt=U=>{R||ft&&Z()},B=nt,ot=U=>{if(R)return;const V=U.target||{};if(ft){if(V.preloadTimeout)return;V.preloadTimeout=setTimeout(()=>{V.preloadTimeout=null,Z()},D)}},_e=U=>{if(R)return;const V=U.target||{};V.preloadTimeout&&(clearTimeout(V.preloadTimeout),V.preloadTimeout=null)},Ft=U=>V=>{var Dt;(Dt=V.persist)==null||Dt.call(V),U.filter(Boolean).forEach(qe=>{V.defaultPrevented||qe(V)})},_t=k?Jt(r,{})??{}:{},at=k?{}:Jt(n,{}),ut=[x,_t.className,at.className].filter(Boolean).join(" "),St={...L,..._t.style,...at.style};return{..._t,...at,...Q,href:R?void 0:H.maskedLocation?t.history.createHref(H.maskedLocation.href):t.history.createHref(H.href),onClick:Ft([b,W]),onFocus:Ft([T,nt]),onMouseEnter:Ft([N,ot]),onMouseLeave:Ft([q,_e]),onTouchStart:Ft([$,B]),disabled:!!R,target:w,...Object.keys(St).length&&{style:St},...ut&&{className:ut},...R&&{role:"link","aria-disabled":!0},...k&&{"data-status":"active","aria-current":"page"},...s&&{"data-transitioning":"transitioning"}}}const Kn=C.forwardRef((e,t)=>{const{_asChild:s,...i}=e,{type:r,...n}=pn(i),o=typeof i.children=="function"?i.children({isActive:n["data-status"]==="active"}):i.children;return typeof s>"u"&&delete n.disabled,C.createElement(s||"a",{...n,ref:t},o)});function mn(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function vn(){const e=jt(),t=C.useRef({router:e,mounted:!1}),s=Y({select:u=>be(u,["isLoading","location","resolvedLocation","isTransitioning"])}),[i,r]=C.useTransition(),n=Y({select:u=>u.matches.some(c=>c.status==="pending")}),o=js(s.isLoading),a=s.isLoading||i||n,h=js(a);return e.isServer||(e.startReactTransition=r),C.useEffect(()=>{const u=e.history.subscribe(e.load),c=e.buildLocation({to:e.latestLocation.pathname,search:!0,params:!0,hash:!0,state:!0});return Bt(e.latestLocation.href)!==Bt(c.href)&&e.commitLocation({...c,replace:!0}),()=>{u()}},[e,e.history]),Je(()=>{var u;if((u=window.__TSR__)!=null&&u.dehydrated||t.current.router===e&&t.current.mounted)return;t.current={router:e,mounted:!0},(async()=>{try{await e.load()}catch(d){console.error(d)}})()},[e]),Je(()=>{if(o&&!s.isLoading){const u=e.state.location,c=e.state.resolvedLocation,d=c.href!==u.href;e.emit({type:"onLoad",fromLocation:c,toLocation:u,pathChanged:d})}},[o,e,s.isLoading]),Je(()=>{if(h&&!a){const u=e.state.location,c=e.state.resolvedLocation,d=c.href!==u.href;if(e.emit({type:"onResolved",fromLocation:c,toLocation:u,pathChanged:d}),e.__store.setState(f=>({...f,status:"idle",resolvedLocation:f.location})),document.querySelector&&e.state.location.hash!==""){const f=document.getElementById(e.state.location.hash);f&&f.scrollIntoView()}}},[a,h,e]),null}function Ae(e){return _.jsx(_.Fragment,{children:e.children})}function Fi(e,t,s){return t.options.notFoundComponent?_.jsx(t.options.notFoundComponent,{data:s}):e.options.defaultNotFoundComponent?_.jsx(e.options.defaultNotFoundComponent,{data:s}):_.jsx(Jr,{})}function _i({matchId:e}){var t,s;const i=jt(),r=Y({select:m=>{var g;return(g=m.matches.find(M=>M.id===e))==null?void 0:g.routeId}});st(r);const n=i.routesById[r],o=n.options.pendingComponent??i.options.defaultPendingComponent,a=o?_.jsx(o,{}):null,h=n.options.errorComponent??i.options.defaultErrorComponent,u=n.options.onCatch??i.options.defaultOnCatch,c=n.isRoot?n.options.notFoundComponent??((t=i.options.notFoundRoute)==null?void 0:t.options.component):n.options.notFoundComponent,d=(!n.isRoot||n.options.wrapInSuspense)&&(n.options.wrapInSuspense??o??((s=n.options.errorComponent)==null?void 0:s.preload))?C.Suspense:Ae,f=h?Ms:Ae,p=c?Gr:Ae,v=Y({select:m=>m.loadedAt});return _.jsx(Ke.Provider,{value:e,children:_.jsx(d,{fallback:a,children:_.jsx(f,{getResetKey:()=>v,errorComponent:h||Qe,onCatch:(m,g)=>{if(mt(m))throw m;u==null||u(m,g)},children:_.jsx(p,{fallback:m=>{if(!c||m.routeId&&m.routeId!==r||!m.routeId&&!n.isRoot)throw m;return C.createElement(c,m)},children:_.jsx(yn,{matchId:e})})})})})}function yn({matchId:e}){var t,s;const i=jt(),r=Y({select:d=>{var f;return(f=d.matches.find(p=>p.id===e))==null?void 0:f.routeId}}),n=i.routesById[r],o=Y({select:d=>d.matches.findIndex(f=>f.id===e)}),a=Y({select:d=>{const f=d.matches[o];return be(f,["id","status","error","loadPromise","minPendingPromise"])}}),h=(n.options.errorComponent??i.options.defaultErrorComponent)||Qe;if(a.status==="notFound"){let d;return Bs(a.error)?d=(((t=i.options.errorSerializer)==null?void 0:t.deserialize)??$s)(a.error.data):d=a.error,st(mt(d)),Fi(i,n,d)}if(a.status==="redirected")throw st(kt(a.error)),a.loadPromise;if(a.status==="error"){if(i.isServer)return _.jsx(h,{error:a.error,info:{componentStack:""}});throw Bs(a.error)?(((s=i.options.errorSerializer)==null?void 0:s.deserialize)??$s)(a.error.data):a.error}if(a.status==="pending"){const d=n.options.pendingMinMs??i.options.defaultPendingMinMs;if(d&&!a.minPendingPromise&&!i.isServer){const f=Gt();Promise.resolve().then(()=>{i.updateMatch(a.id,p=>({...p,minPendingPromise:f}))}),setTimeout(()=>{f.resolve(),i.updateMatch(a.id,p=>({...p,minPendingPromise:void 0}))},d)}throw a.loadPromise}const u=n.options.component??i.options.defaultComponent,c=u?_.jsx(u,{}):_.jsx(gn,{});return _.jsxs(_.Fragment,{children:[c,i.AfterEachMatch?_.jsx(i.AfterEachMatch,{match:a,matchIndex:o}):null]})}const gn=C.memo(function(){const t=jt(),s=C.useContext(Ke),i=Y({select:u=>{var c;return(c=u.matches.find(d=>d.id===s))==null?void 0:c.routeId}}),r=t.routesById[i],{parentGlobalNotFound:n}=Y({select:u=>{const d=u.matches.find(f=>f.id===s);return st(d),{parentGlobalNotFound:d.globalNotFound}}}),o=Y({select:u=>{var c;const d=u.matches,f=d.findIndex(p=>p.id===s);return(c=d[f+1])==null?void 0:c.id}});if(n)return Fi(t,r,void 0);if(!o)return null;const a=_.jsx(_i,{matchId:o}),h=t.options.defaultPendingComponent?_.jsx(t.options.defaultPendingComponent,{}):null;return s===rt?_.jsx(C.Suspense,{fallback:h,children:a}):a});function bn(){const e=jt(),t=e.options.defaultPendingComponent?_.jsx(e.options.defaultPendingComponent,{}):null,s=e.state.matches.length?Ae:C.Suspense,i=_.jsxs(s,{fallback:t,children:[_.jsx(vn,{}),_.jsx(Sn,{})]});return e.options.InnerWrap?_.jsx(e.options.InnerWrap,{children:i}):i}function Sn(){const e=Y({select:s=>{var i;return(i=s.matches[0])==null?void 0:i.id}}),t=Y({select:s=>s.loadedAt});return _.jsx(Ke.Provider,{value:e,children:_.jsx(Ms,{getResetKey:()=>t,errorComponent:Qe,onCatch:s=>{s.message||s.toString()},children:e?_.jsx(_i,{matchId:e}):null})})}function Mn({router:e,children:t,...s}){e.update({...e.options,...s,context:{...e.options.context,...s.context}});const i=gi(),r=_.jsx(i.Provider,{value:e,children:t});return e.options.Wrap?_.jsx(e.options.Wrap,{children:r}):r}function Nn({router:e,...t}){return _.jsx(Mn,{router:e,...t,children:_.jsx(bn,{})})}var qn=function(){return null};function Ne(e,t){return typeof e=="function"?e(t):e}function Ci(e,t){return Ps(t).reduce((i,r)=>{if(i===null)return null;if(typeof i<"u")return i[r]},e)}function Ye(e,t,s){const i=Ps(t);function r(n){if(!i.length)return Ne(s,n);const o=i.shift();if(typeof o=="string")return typeof n=="object"?(n===null&&(n={}),{...n,[o]:r(n[o])}):{[o]:r()};if(Array.isArray(n)&&o!==void 0){const a=n.slice(0,o);return[...a.length?a:new Array(o),r(n[o]),...n.slice(o+1)]}return[...new Array(o),r()]}return r(e)}function Pn(e,t){const s=Ps(t);function i(r){if(!r)return;if(s.length===1){const o=s[0];if(Array.isArray(r)&&typeof o=="number")return r.filter((u,c)=>c!==o);const{[o]:a,...h}=r;return h}const n=s.shift();if(typeof n=="string"&&typeof r=="object")return{...r,[n]:i(r[n])};if(typeof n=="number"&&Array.isArray(r)){if(n>=r.length)return r;const o=r.slice(0,n);return[...o.length?o:new Array(n),i(r[n]),...r.slice(n+1)]}throw new Error("It seems we have created an infinite loop in deleteBy. ")}return i(e)}const wn=/^(\d*)$/gm,Fn=/\.(\d*)\./gm,_n=/^(\d*)\./gm,Cn=/\.(\d*$)/gm,Rn=/\.{2,}/gm,fs="__int__",xe=`${fs}$1`;function Ps(e){if(typeof e!="string")throw new Error("Path must be a string.");return e.replaceAll("[",".").replaceAll("]","").replace(wn,xe).replace(Fn,`.${xe}.`).replace(_n,`${xe}.`).replace(Cn,`.${xe}`).replace(Rn,".").split(".").map(t=>t.indexOf(fs)===0?parseInt(t.substring(fs.length),10):t)}function En(e){return!(Array.isArray(e)&&e.length===0)}function ps(e,t){const{asyncDebounceMs:s}=t,{onChangeAsync:i,onBlurAsync:r,onSubmitAsync:n,onBlurAsyncDebounceMs:o,onChangeAsyncDebounceMs:a}=t.validators||{},h=s??0,u={cause:"change",validate:i,debounceMs:a??h},c={cause:"blur",validate:r,debounceMs:o??h},d={cause:"submit",validate:n,debounceMs:0},f=p=>({...p,debounceMs:0});switch(e){case"submit":return[f(u),f(c),d];case"blur":return[c];case"change":return[u];case"server":default:return[]}}function ms(e,t){const{onChange:s,onBlur:i,onSubmit:r}=t.validators||{},n={cause:"change",validate:s},o={cause:"blur",validate:i},a={cause:"submit",validate:r},h={cause:"server",validate:()=>{}};switch(e){case"submit":return[n,o,a,h];case"server":return[h];case"blur":return[o,h];case"change":default:return[n,h]}}function Ze(e){return{values:e.values??{},errors:e.errors??[],errorMap:e.errorMap??{},fieldMeta:e.fieldMeta??{},canSubmit:e.canSubmit??!0,isFieldsValid:e.isFieldsValid??!1,isFieldsValidating:e.isFieldsValidating??!1,isFormValid:e.isFormValid??!1,isFormValidating:e.isFormValidating??!1,isSubmitted:e.isSubmitted??!1,isSubmitting:e.isSubmitting??!1,isTouched:e.isTouched??!1,isPristine:e.isPristine??!0,isDirty:e.isDirty??!1,isValid:e.isValid??!1,isValidating:e.isValidating??!1,submissionAttempts:e.submissionAttempts??0,validationMetaMap:e.validationMetaMap??{onChange:void 0,onBlur:void 0,onSubmit:void 0,onMount:void 0,onServer:void 0}}}class xn{constructor(t){var s;this.options={},this.fieldInfo={},this.prevTransformArray=[],this.mount=()=>{const{onMount:i}=this.options.validators||{};if(!i)return;const r=this.runValidator({validate:i,value:{value:this.state.values,formApi:this},type:"validate"});r&&this.store.setState(n=>({...n,errorMap:{...n.errorMap,onMount:r}}))},this.update=i=>{if(!i)return;const r=this.options;this.options=i,this.store.batch(()=>{const n=i.defaultValues&&i.defaultValues!==r.defaultValues&&!this.state.isTouched,o=i.defaultState!==r.defaultState&&!this.state.isTouched;this.store.setState(()=>Ze(Object.assign({},this.state,o?i.defaultState:{},n?{values:i.defaultValues}:{})))})},this.reset=()=>{const{fieldMeta:i}=this.state,r=this.resetFieldMeta(i);this.store.setState(()=>{var n;return Ze({...this.options.defaultState,values:this.options.defaultValues??((n=this.options.defaultState)==null?void 0:n.values),fieldMeta:r})})},this.validateAllFields=async i=>{const r=[];return this.store.batch(()=>{Object.values(this.fieldInfo).forEach(o=>{if(!o.instance)return;const a=o.instance;r.push(Promise.resolve().then(()=>a.validate(i))),o.instance.state.meta.isTouched||o.instance.setMeta(h=>({...h,isTouched:!0}))})}),(await Promise.all(r)).flat()},this.validateArrayFieldsStartingFrom=async(i,r,n)=>{const o=this.getFieldValue(i),a=Array.isArray(o)?Math.max(o.length-1,0):null,h=[`${i}[${r}]`];for(let f=r+1;f<=(a??0);f++)h.push(`${i}[${f}]`);const u=Object.keys(this.fieldInfo).filter(f=>h.some(p=>f.startsWith(p))),c=[];return this.store.batch(()=>{u.forEach(f=>{c.push(Promise.resolve().then(()=>this.validateField(f,n)))})}),(await Promise.all(c)).flat()},this.validateField=(i,r)=>{var n;const o=(n=this.fieldInfo[i])==null?void 0:n.instance;return o?(o.state.meta.isTouched||o.setMeta(a=>({...a,isTouched:!0})),o.validate(r)):[]},this.validateSync=i=>{const r=ms(i,this.options);let n=!1;this.store.batch(()=>{for(const a of r){if(!a.validate)continue;const h=Us(this.runValidator({validate:a.validate,value:{value:this.state.values,formApi:this},type:"validate"})),u=Oe(a.cause);this.state.errorMap[u]!==h&&this.store.setState(c=>({...c,errorMap:{...c.errorMap,[u]:h}})),h&&(n=!0)}});const o=Oe("submit");return this.state.errorMap[o]&&i!=="submit"&&!n&&this.store.setState(a=>({...a,errorMap:{...a.errorMap,[o]:void 0}})),{hasErrored:n}},this.validateAsync=async i=>{const r=ps(i,this.options);this.state.isFormValidating||this.store.setState(a=>({...a,isFormValidating:!0}));const n=[];for(const a of r){if(!a.validate)continue;const h=Oe(a.cause),u=this.state.validationMetaMap[h];u==null||u.lastAbortController.abort();const c=new AbortController;this.state.validationMetaMap[h]={lastAbortController:c},n.push(new Promise(async d=>{let f;try{f=await new Promise((v,m)=>{setTimeout(async()=>{if(c.signal.aborted)return v(void 0);try{v(await this.runValidator({validate:a.validate,value:{value:this.state.values,formApi:this,signal:c.signal},type:"validateAsync"}))}catch(g){m(g)}},a.debounceMs)})}catch(v){f=v}const p=Us(f);this.store.setState(v=>({...v,errorMap:{...v.errorMap,[Oe(i)]:p}})),d(p)}))}let o=[];return n.length&&(o=await Promise.all(n)),this.store.setState(a=>({...a,isFormValidating:!1})),o.filter(Boolean)},this.validate=i=>{const{hasErrored:r}=this.validateSync(i);return r&&!this.options.asyncAlways?this.state.errors:this.validateAsync(i)},this.handleSubmit=async()=>{var i,r,n,o,a,h;if(this.store.setState(c=>({...c,isSubmitted:!1,submissionAttempts:c.submissionAttempts+1})),!this.state.canSubmit)return;this.store.setState(c=>({...c,isSubmitting:!0}));const u=()=>{this.store.setState(c=>({...c,isSubmitting:!1}))};if(await this.validateAllFields("submit"),!this.state.isFieldsValid){u(),(r=(i=this.options).onSubmitInvalid)==null||r.call(i,{value:this.state.values,formApi:this});return}if(await this.validate("submit"),!this.state.isValid){u(),(o=(n=this.options).onSubmitInvalid)==null||o.call(n,{value:this.state.values,formApi:this});return}try{await((h=(a=this.options).onSubmit)==null?void 0:h.call(a,{value:this.state.values,formApi:this})),this.store.batch(()=>{this.store.setState(c=>({...c,isSubmitted:!0})),u()})}catch(c){throw u(),c}},this.getFieldValue=i=>Ci(this.state.values,i),this.getFieldMeta=i=>this.state.fieldMeta[i],this.getFieldInfo=i=>{var r;return(r=this.fieldInfo)[i]||(r[i]={instance:null,validationMetaMap:{onChange:void 0,onBlur:void 0,onSubmit:void 0,onMount:void 0,onServer:void 0}})},this.setFieldMeta=(i,r)=>{this.store.setState(n=>({...n,fieldMeta:{...n.fieldMeta,[i]:Ne(r,n.fieldMeta[i])}}))},this.resetFieldMeta=i=>Object.keys(i).reduce((r,n)=>{const o=n;return r[o]={isValidating:!1,isTouched:!1,isDirty:!1,isPristine:!0,errors:[],errorMap:{}},r},{}),this.setFieldValue=(i,r,n)=>{const o=(n==null?void 0:n.dontUpdateMeta)??!1;this.store.batch(()=>{o||this.setFieldMeta(i,a=>({...a,isTouched:!0,isDirty:!0})),this.store.setState(a=>({...a,values:Ye(a.values,i,r)}))})},this.deleteField=i=>{this.store.setState(r=>{const n={...r};return n.values=Pn(n.values,i),delete n.fieldMeta[i],n}),delete this.fieldInfo[i]},this.pushFieldValue=(i,r,n)=>{this.setFieldValue(i,o=>[...Array.isArray(o)?o:[],r],n),this.validateField(i,"change")},this.insertFieldValue=async(i,r,n,o)=>{this.setFieldValue(i,a=>[...a.slice(0,r),n,...a.slice(r)],o),await this.validateField(i,"change")},this.replaceFieldValue=async(i,r,n,o)=>{this.setFieldValue(i,a=>a.map((h,u)=>u===r?n:h),o),await this.validateField(i,"change"),await this.validateArrayFieldsStartingFrom(i,r,"change")},this.removeFieldValue=async(i,r,n)=>{const o=this.getFieldValue(i),a=Array.isArray(o)?Math.max(o.length-1,0):null;if(this.setFieldValue(i,h=>h.filter((u,c)=>c!==r),n),a!==null){const h=`${i}[${a}]`;Object.keys(this.fieldInfo).filter(c=>c.startsWith(h)).forEach(c=>this.deleteField(c))}await this.validateField(i,"change"),await this.validateArrayFieldsStartingFrom(i,r,"change")},this.swapFieldValues=(i,r,n,o)=>{this.setFieldValue(i,a=>{const h=a[r],u=a[n];return Ye(Ye(a,`${r}`,u),`${n}`,h)},o),this.validateField(i,"change"),this.validateField(`${i}[${r}]`,"change"),this.validateField(`${i}[${n}]`,"change")},this.moveFieldValues=(i,r,n,o)=>{this.setFieldValue(i,a=>(a.splice(n,0,a.splice(r,1)[0]),a),o),this.validateField(i,"change"),this.validateField(`${i}[${r}]`,"change"),this.validateField(`${i}[${n}]`,"change")},this.store=new bs(Ze({...t==null?void 0:t.defaultState,values:(t==null?void 0:t.defaultValues)??((s=t==null?void 0:t.defaultState)==null?void 0:s.values),isFormValid:!0}),{onUpdate:()=>{var i,r;let{state:n}=this.store;const o=Object.values(n.fieldMeta),a=o.some(S=>S==null?void 0:S.isValidating),h=!o.some(S=>(S==null?void 0:S.errorMap)&&En(Object.values(S.errorMap).filter(Boolean))),u=o.some(S=>S==null?void 0:S.isTouched),c=o.some(S=>S==null?void 0:S.isDirty),d=!c,f=a||n.isFormValidating;n.errors=Object.values(n.errorMap).filter(S=>S!==void 0);const p=n.errors.length===0,v=h&&p,m=n.submissionAttempts===0&&!u||!f&&!n.isSubmitting&&v;n={...n,isFieldsValidating:a,isFieldsValid:h,isFormValid:p,isValid:v,canSubmit:m,isTouched:u,isPristine:d,isDirty:c},this.state=n,this.store.state=this.state;const g=((i=this.options.transform)==null?void 0:i.deps)??[];(g.length!==this.prevTransformArray.length||g.some((S,y)=>S!==this.prevTransformArray[y]))&&((r=this.options.transform)==null||r.fn(this),this.store.state=this.state,this.prevTransformArray=g)}}),this.state=this.store.state,this.update(t||{})}runValidator(t){const s=this.options.validatorAdapter;return s&&typeof t.validate!="function"?s()[t.type](t.value,t.validate):t.validate(t.value)}}function Us(e){if(e)return typeof e!="string"?"Invalid Form Values":e}function Oe(e){switch(e){case"submit":return"onSubmit";case"blur":return"onBlur";case"mount":return"onMount";case"server":return"onServer";case"change":default:return"onChange"}}class On{constructor(t){this.options={},this.mount=()=>{const s=this.getInfo();s.instance=this;const i=this.form.store.subscribe(()=>{this.store.batch(()=>{const n=this.getValue(),o=this.getMeta();n!==this.state.value&&this.store.setState(a=>({...a,value:n})),o!==this.state.meta&&this.store.setState(a=>({...a,meta:o}))})});this.update(this.options);const{onMount:r}=this.options.validators||{};if(r){const n=this.runValidator({validate:r,value:{value:this.state.value,fieldApi:this},type:"validate"});n&&this.setMeta(o=>({...o,errorMap:{...o==null?void 0:o.errorMap,onMount:n}}))}return()=>{i()}},this.update=s=>{if(this.state.value===void 0){const i=Ci(s.form.options.defaultValues,s.name);s.defaultValue!==void 0?this.setValue(s.defaultValue,{dontUpdateMeta:!0}):i!==void 0&&this.setValue(i,{dontUpdateMeta:!0})}this._getMeta()===void 0&&this.setMeta(this.state.meta),this.options=s},this.getValue=()=>this.form.getFieldValue(this.name),this.setValue=(s,i)=>{this.form.setFieldValue(this.name,s,i),this.validate("change")},this._getMeta=()=>this.form.getFieldMeta(this.name),this.getMeta=()=>this._getMeta()??{isValidating:!1,isTouched:!1,isDirty:!1,isPristine:!0,errors:[],errorMap:{},...this.options.defaultMeta},this.setMeta=s=>this.form.setFieldMeta(this.name,s),this.getInfo=()=>this.form.getFieldInfo(this.name),this.pushValue=(s,i)=>this.form.pushFieldValue(this.name,s,i),this.insertValue=(s,i,r)=>this.form.insertFieldValue(this.name,s,i,r),this.replaceValue=(s,i,r)=>this.form.replaceFieldValue(this.name,s,i,r),this.removeValue=(s,i)=>this.form.removeFieldValue(this.name,s,i),this.swapValues=(s,i,r)=>this.form.swapFieldValues(this.name,s,i,r),this.moveValue=(s,i,r)=>this.form.moveFieldValues(this.name,s,i,r),this.getLinkedFields=s=>{const i=Object.values(this.form.fieldInfo),r=[];for(const n of i){if(!n.instance)continue;const{onChangeListenTo:o,onBlurListenTo:a}=n.instance.options.validators||{};s==="change"&&(o!=null&&o.includes(this.name))&&r.push(n.instance),s==="blur"&&(a!=null&&a.includes(this.name))&&r.push(n.instance)}return r},this.validateSync=s=>{const i=ms(s,this.options),n=this.getLinkedFields(s).reduce((h,u)=>{const c=ms(s,u.options);return c.forEach(d=>{d.field=u}),h.concat(c)},[]);let o=!1;this.form.store.batch(()=>{const h=(u,c)=>{const d=Qs(u.runValidator({validate:c.validate,value:{value:u.getValue(),fieldApi:u},type:"validate"})),f=Wt(c.cause);u.state.meta.errorMap[f]!==d&&u.setMeta(p=>({...p,errorMap:{...p.errorMap,[Wt(c.cause)]:d}})),d&&(o=!0)};for(const u of i)u.validate&&h(this,u);for(const u of n)u.validate&&h(u.field,u)});const a=Wt("submit");return this.state.meta.errorMap[a]&&s!=="submit"&&!o&&this.setMeta(h=>({...h,errorMap:{...h.errorMap,[a]:void 0}})),{hasErrored:o}},this.validateAsync=async s=>{const i=ps(s,this.options),r=this.getLinkedFields(s),n=r.reduce((c,d)=>{const f=ps(s,d.options);return f.forEach(p=>{p.field=d}),c.concat(f)},[]);this.state.meta.isValidating||this.setMeta(c=>({...c,isValidating:!0}));for(const c of r)c.setMeta(d=>({...d,isValidating:!0}));const o=[],a=[],h=(c,d,f)=>{const p=Wt(d.cause),v=c.getInfo().validationMetaMap[p];v==null||v.lastAbortController.abort();const m=new AbortController;this.getInfo().validationMetaMap[p]={lastAbortController:m},f.push(new Promise(async g=>{let M;try{M=await new Promise((y,w)=>{setTimeout(async()=>{if(m.signal.aborted)return y(void 0);try{y(await this.runValidator({validate:d.validate,value:{value:c.getValue(),fieldApi:c,signal:m.signal},type:"validateAsync"}))}catch(R){w(R)}},d.debounceMs)})}catch(y){M=y}if(m.signal.aborted)return g(void 0);const S=Qs(M);c.setMeta(y=>({...y,errorMap:{...y==null?void 0:y.errorMap,[Wt(s)]:S}})),g(S)}))};for(const c of i)c.validate&&h(this,c,o);for(const c of n)c.validate&&h(c.field,c,a);let u=[];(o.length||a.length)&&(u=await Promise.all(o),await Promise.all(a)),this.setMeta(c=>({...c,isValidating:!1}));for(const c of r)c.setMeta(d=>({...d,isValidating:!1}));return u.filter(Boolean)},this.validate=s=>{var i;if(!this.state.meta.isTouched)return[];try{this.form.validate(s)}catch{}const{hasErrored:r}=this.validateSync(s);return r&&!this.options.asyncAlways?((i=this.getInfo().validationMetaMap[Wt(s)])==null||i.lastAbortController.abort(),this.state.meta.errors):this.validateAsync(s)},this.handleChange=s=>{this.setValue(s)},this.handleBlur=()=>{this.state.meta.isTouched||(this.setMeta(i=>({...i,isTouched:!0})),this.validate("change")),this.validate("blur")},this.form=t.form,this.name=t.name,t.defaultValue!==void 0&&this.form.setFieldValue(this.name,t.defaultValue,{dontUpdateMeta:!0}),this.store=new bs({value:this.getValue(),meta:this._getMeta()??{isValidating:!1,isTouched:!1,isDirty:!1,isPristine:!0,errors:[],errorMap:{},...t.defaultMeta}},{onUpdate:()=>{const s=this.store.state;s.meta.errors=Object.values(s.meta.errorMap).filter(i=>i!==void 0),s.meta.isPristine=!s.meta.isDirty,this.prevState=s,this.state=s}}),this.state=this.store.state,this.prevState=this.state,this.options=t}runValidator(t){const s=[this.form.options.validatorAdapter,this.options.validatorAdapter];for(const i of s)if(i&&typeof t.validate!="function")return i()[t.type](t.value,t.validate);return t.validate(t.value)}}function Qs(e){if(e)return typeof e!="string"?"Invalid Form Values":e}function Wt(e){switch(e){case"submit":return"onSubmit";case"blur":return"onBlur";case"mount":return"onMount";case"server":return"onServer";case"change":default:return"onChange"}}const Be=typeof window<"u"?C.useLayoutEffect:C.useEffect;function Ri(e){const[t]=C.useState(()=>{const i=new On({...e,form:e.form,name:e.name});return i.Field=Ei,i});return Be(t.mount,[t]),Be(()=>{t.update(e)}),Ve(t.store,e.mode==="array"?s=>[s.meta,Object.keys(s.value??[]).length]:void 0),t}const Ei=({children:e,...t})=>{const s=Ri(t);return _.jsx(_.Fragment,{children:Ne(e,s)})};function zn(e){const[t]=C.useState(()=>{const s=new xn(e),i=s;return i.Field=function(n){return _.jsx(Ei,{...n,form:s})},i.useField=r=>Ri({...r,form:s}),i.useStore=r=>Ve(s.store,r),i.Subscribe=r=>Ne(r.children,Ve(s.store,r.selector)),i});return Be(t.mount,[]),t.useStore(s=>s.isSubmitting),Be(()=>{t.update(e)}),t}export{Kn as L,gn as O,In as Q,Nn as R,zn as a,un as b,me as c,Y as d,Un as e,ir as f,hi as g,kn as h,Qn as i,jn as j,$n as k,Vn as l,qn as m,Dn as q,Bn as r,jt as u};
|