db-studio 1.7.9 → 1.7.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. package/dist/core-dist/assets/_pathlessLayout-DtaYfYwJ.js +2 -0
  2. package/dist/core-dist/assets/{_queryId-k0QvsBGf.js → _queryId-BuwY4WmY.js} +1 -1
  3. package/dist/core-dist/assets/{_table-cCBv5kB-.js → _table-D8MYcfMf.js} +1 -1
  4. package/dist/core-dist/assets/_table-dqCYe5jr.js +10 -0
  5. package/dist/core-dist/assets/{cdoe-editor-IGx3GQWB.js → cdoe-editor-DT99U124.js} +1 -1
  6. package/dist/core-dist/assets/{chat-sidebar-D2GaNd69.js → chat-sidebar-_z_c1b34.js} +1 -1
  7. package/dist/core-dist/assets/{dist-v6aWpqmu.js → dist-DZQDOYlI.js} +1 -1
  8. package/dist/core-dist/assets/{dist-ZzQZZhtF.js → dist-lZgQTehN.js} +1 -1
  9. package/dist/core-dist/assets/{index-BtQYs6UF.js → index-D9Wxg2ot.js} +3 -3
  10. package/dist/core-dist/assets/index-fMzwkmHJ.css +2 -0
  11. package/dist/core-dist/assets/{queries.store-BtuppsNj.js → queries.store-D-hvraJW.js} +1 -1
  12. package/dist/core-dist/assets/{runner-VSPg2lHo.js → runner-D2QKCRKR.js} +1 -1
  13. package/dist/core-dist/assets/{runner-tab-BQH-lTnK.js → runner-tab-BgDrAAsO.js} +3 -3
  14. package/dist/core-dist/assets/{scroll-area-BnT9xy-y.js → scroll-area-XVOss7Ty.js} +1 -1
  15. package/dist/core-dist/assets/tanstack-CJpNvQIy.js +9 -0
  16. package/dist/core-dist/assets/{tooltip-B3DXDN3Y.js → tooltip-CFEia1PZ.js} +1 -1
  17. package/dist/core-dist/assets/use-delete-column-B78zy_1_.js +1 -0
  18. package/dist/core-dist/assets/{use-rate-limit-BenJo7Lk.js → use-rate-limit-FcN06qzk.js} +1 -1
  19. package/dist/core-dist/index.html +3 -3
  20. package/dist/index.js +86 -86
  21. package/dist/index.js.map +1 -1
  22. package/package.json +2 -2
  23. package/dist/core-dist/assets/_pathlessLayout-Dh-wnEbU.js +0 -2
  24. package/dist/core-dist/assets/_table-BuJCKd_h.js +0 -10
  25. package/dist/core-dist/assets/index-Dv6o03bL.css +0 -2
  26. package/dist/core-dist/assets/tanstack-DyfKDo5s.js +0 -9
  27. package/dist/core-dist/assets/use-delete-column-B-oY2CU8.js +0 -1
@@ -1,9 +0,0 @@
1
- import{r as Bn,t as $e}from"./rolldown-runtime-Bnw7wDfq.js";import{nt as fs}from"./icons-BywMJ5og.js";import{Dt as Nr,Ot as Vr}from"./radix-ui-C0u6gLux.js";var Ne=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(){}},Br={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},zr=class{#t=Br;#e=!1;setTimeoutProvider(e){this.#t=e}setTimeout(e,t){return this.#t.setTimeout(e,t)}clearTimeout(e){this.#t.clearTimeout(e)}setInterval(e,t){return this.#t.setInterval(e,t)}clearInterval(e){this.#t.clearInterval(e)}},Ce=new zr;function Hr(e){setTimeout(e,0)}var Pe=typeof window>"u"||"Deno"in globalThis;function j(){}function Ur(e,t){return typeof e=="function"?e(t):e}function Yt(e){return typeof e=="number"&&e>=0&&e!==1/0}function zn(e,t){return Math.max(e+(t||0)-Date.now(),0)}function de(e,t){return typeof e=="function"?e(t):e}function Z(e,t){return typeof e=="function"?e(t):e}function Bs(e,t){const{type:s="all",exact:n,fetchStatus:r,predicate:i,queryKey:o,stale:a}=e;if(o){if(n){if(t.queryHash!==gs(o,t.options))return!1}else if(!Xe(t.queryKey,o))return!1}if(s!=="all"){const u=t.isActive();if(s==="active"&&!u||s==="inactive"&&u)return!1}return!(typeof a=="boolean"&&t.isStale()!==a||r&&r!==t.state.fetchStatus||i&&!i(t))}function zs(e,t){const{exact:s,status:n,predicate:r,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(s){if(Me(t.options.mutationKey)!==Me(i))return!1}else if(!Xe(t.options.mutationKey,i))return!1}return!(n&&t.state.status!==n||r&&!r(t))}function gs(e,t){return(t?.queryKeyHashFn||Me)(e)}function Me(e){return JSON.stringify(e,(t,s)=>Xt(s)?Object.keys(s).sort().reduce((n,r)=>(n[r]=s[r],n),{}):s)}function Xe(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(s=>Xe(e[s],t[s])):!1}var jr=Object.prototype.hasOwnProperty;function Hn(e,t,s=0){if(e===t)return e;if(s>500)return t;const n=Hs(e)&&Hs(t);if(!n&&!(Xt(e)&&Xt(t)))return t;const r=(n?e:Object.keys(e)).length,i=n?t:Object.keys(t),o=i.length,a=n?new Array(o):{};let u=0;for(let l=0;l<o;l++){const h=n?l:i[l],d=e[h],c=t[h];if(d===c){a[h]=d,(n?l<r:jr.call(e,h))&&u++;continue}if(d===null||c===null||typeof d!="object"||typeof c!="object"){a[h]=c;continue}const f=Hn(d,c,s+1);a[h]=f,f===d&&u++}return r===o&&u===r?e:a}function vt(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 Hs(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Xt(e){if(!Us(e))return!1;const t=e.constructor;if(t===void 0)return!0;const s=t.prototype;return!(!Us(s)||!s.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function Us(e){return Object.prototype.toString.call(e)==="[object Object]"}function Gr(e){return new Promise(t=>{Ce.setTimeout(t,e)})}function Zt(e,t,s){return typeof s.structuralSharing=="function"?s.structuralSharing(e,t):s.structuralSharing!==!1?Hn(e,t):t}function qr(e,t,s=0){const n=[...e,t];return s&&n.length>s?n.slice(1):n}function Wr(e,t,s=0){const n=[t,...e];return s&&n.length>s?n.slice(0,-1):n}var ps=Symbol();function Un(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===ps?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function ms(e,t){return typeof e=="function"?e(...t):!!e}function Kr(e,t,s){let n=!1,r;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(r??=t(),n||(n=!0,r.aborted?s():r.addEventListener("abort",s,{once:!0})),r)}),e}var Qr=class extends Ne{#t;#e;#s;constructor(){super(),this.#s=e=>{if(!Pe&&window.addEventListener){const t=()=>e();return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}}}onSubscribe(){this.#e||this.setEventListener(this.#s)}onUnsubscribe(){this.hasListeners()||(this.#e?.(),this.#e=void 0)}setEventListener(e){this.#s=e,this.#e?.(),this.#e=e(t=>{typeof t=="boolean"?this.setFocused(t):this.onFocus()})}setFocused(e){this.#t!==e&&(this.#t=e,this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#t=="boolean"?this.#t:globalThis.document?.visibilityState!=="hidden"}},vs=new Qr;function es(){let e,t;const s=new Promise((r,i)=>{e=r,t=i});s.status="pending",s.catch(()=>{});function n(r){Object.assign(s,r),delete s.resolve,delete s.reject}return s.resolve=r=>{n({status:"fulfilled",value:r}),e(r)},s.reject=r=>{n({status:"rejected",reason:r}),t(r)},s}function Ol(e){return e.state.status==="success"}var Jr=Hr;function Yr(){let e=[],t=0,s=a=>{a()},n=a=>{a()},r=Jr;const i=a=>{t?e.push(a):r(()=>{s(a)})},o=()=>{const a=e;e=[],a.length&&r(()=>{n(()=>{a.forEach(u=>{s(u)})})})};return{batch:a=>{let u;t++;try{u=a()}finally{t--,t||o()}return u},batchCalls:a=>(...u)=>{i(()=>{a(...u)})},schedule:i,setNotifyFunction:a=>{s=a},setBatchNotifyFunction:a=>{n=a},setScheduler:a=>{r=a}}}var $=Yr(),Xr=class extends Ne{#t=!0;#e;#s;constructor(){super(),this.#s=e=>{if(!Pe&&window.addEventListener){const t=()=>e(!0),s=()=>e(!1);return window.addEventListener("online",t,!1),window.addEventListener("offline",s,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",s)}}}}onSubscribe(){this.#e||this.setEventListener(this.#s)}onUnsubscribe(){this.hasListeners()||(this.#e?.(),this.#e=void 0)}setEventListener(e){this.#s=e,this.#e?.(),this.#e=e(this.setOnline.bind(this))}setOnline(e){this.#t!==e&&(this.#t=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#t}},St=new Xr;function Zr(e){return Math.min(1e3*2**e,3e4)}function jn(e){return(e??"online")==="online"?St.isOnline():!0}var ts=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};function Gn(e){let t=!1,s=0,n;const r=es(),i=()=>r.status!=="pending",o=p=>{if(!i()){const v=new ts(p);c(v),e.onCancel?.(v)}},a=()=>{t=!0},u=()=>{t=!1},l=()=>vs.isFocused()&&(e.networkMode==="always"||St.isOnline())&&e.canRun(),h=()=>jn(e.networkMode)&&e.canRun(),d=p=>{i()||(n?.(),r.resolve(p))},c=p=>{i()||(n?.(),r.reject(p))},f=()=>new Promise(p=>{n=v=>{(i()||l())&&p(v)},e.onPause?.()}).then(()=>{n=void 0,i()||e.onContinue?.()}),g=()=>{if(i())return;let p;const v=s===0?e.initialPromise:void 0;try{p=v??e.fn()}catch(m){p=Promise.reject(m)}Promise.resolve(p).then(d).catch(m=>{if(i())return;const y=e.retry??(Pe?0:3),C=e.retryDelay??Zr,S=typeof C=="function"?C(s,m):C,w=y===!0||typeof y=="number"&&s<y||typeof y=="function"&&y(s,m);if(t||!w){c(m);return}s++,e.onFail?.(s,m),Gr(S).then(()=>l()?void 0:f()).then(()=>{t?c(m):g()})})};return{promise:r,status:()=>r.status,cancel:o,continue:()=>(n?.(),r),cancelRetry:a,continueRetry:u,canStart:h,start:()=>(h()?g():f().then(g),r)}}var qn=class{#t;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Yt(this.gcTime)&&(this.#t=Ce.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Pe?1/0:300*1e3))}clearGcTimeout(){this.#t&&(Ce.clearTimeout(this.#t),this.#t=void 0)}},ei=class extends qn{#t;#e;#s;#r;#n;#a;#i;constructor(e){super(),this.#i=!1,this.#a=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#r=e.client,this.#s=this.#r.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#t=Gs(this.options),this.state=e.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#n?.promise}setOptions(e){if(this.options={...this.#a,...e},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const t=Gs(this.options);t.data!==void 0&&(this.setState(js(t.data,t.dataUpdatedAt)),this.#t=t)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#s.remove(this)}setData(e,t){const s=Zt(this.state.data,e,this.options);return this.#o({data:s,type:"success",dataUpdatedAt:t?.updatedAt,manual:t?.manual}),s}setState(e,t){this.#o({type:"setState",state:e,setStateOptions:t})}cancel(e){const t=this.#n?.promise;return this.#n?.cancel(e),t?t.then(j).catch(j):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#t)}isActive(){return this.observers.some(e=>Z(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===ps||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>de(e.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e==="static"?!1:this.state.isInvalidated?!0:!zn(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#n?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#n?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#s.notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#n&&(this.#i?this.#n.cancel({revert:!0}):this.#n.cancelRetry()),this.scheduleGc()),this.#s.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#o({type:"invalidate"})}async fetch(e,t){if(this.state.fetchStatus!=="idle"&&this.#n?.status()!=="rejected"){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#n)return this.#n.continueRetry(),this.#n.promise}if(e&&this.setOptions(e),!this.options.queryFn){const a=this.observers.find(u=>u.options.queryFn);a&&this.setOptions(a.options)}const s=new AbortController,n=a=>{Object.defineProperty(a,"signal",{enumerable:!0,get:()=>(this.#i=!0,s.signal)})},r=()=>{const a=Un(this.options,t),l=(()=>{const h={client:this.#r,queryKey:this.queryKey,meta:this.meta};return n(h),h})();return this.#i=!1,this.options.persister?this.options.persister(a,l,this):a(l)},o=(()=>{const a={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#r,state:this.state,fetchFn:r};return n(a),a})();this.options.behavior?.onFetch(o,this),this.#e=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==o.fetchOptions?.meta)&&this.#o({type:"fetch",meta:o.fetchOptions?.meta}),this.#n=Gn({initialPromise:t?.initialPromise,fn:o.fetchFn,onCancel:a=>{a instanceof ts&&a.revert&&this.setState({...this.#e,fetchStatus:"idle"}),s.abort()},onFail:(a,u)=>{this.#o({type:"failed",failureCount:a,error:u})},onPause:()=>{this.#o({type:"pause"})},onContinue:()=>{this.#o({type:"continue"})},retry:o.options.retry,retryDelay:o.options.retryDelay,networkMode:o.options.networkMode,canRun:()=>!0});try{const a=await this.#n.start();if(a===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(a),this.#s.config.onSuccess?.(a,this),this.#s.config.onSettled?.(a,this.state.error,this),a}catch(a){if(a instanceof ts){if(a.silent)return this.#n.promise;if(a.revert){if(this.state.data===void 0)throw a;return this.state.data}}throw this.#o({type:"error",error:a}),this.#s.config.onError?.(a,this),this.#s.config.onSettled?.(this.state.data,a,this),a}finally{this.scheduleGc()}}#o(e){const t=s=>{switch(e.type){case"failed":return{...s,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...s,fetchStatus:"paused"};case"continue":return{...s,fetchStatus:"fetching"};case"fetch":return{...s,...Wn(s.data,this.options),fetchMeta:e.meta??null};case"success":const n={...s,...js(e.data,e.dataUpdatedAt),dataUpdateCount:s.dataUpdateCount+1,...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#e=e.manual?n:void 0,n;case"error":const r=e.error;return{...s,error:r,errorUpdateCount:s.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:s.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...s,isInvalidated:!0};case"setState":return{...s,...e.state}}};this.state=t(this.state),$.batch(()=>{this.observers.forEach(s=>{s.onQueryUpdate()}),this.#s.notify({query:this,type:"updated",action:e})})}};function Wn(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:jn(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function js(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function Gs(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,s=t!==void 0,n=s?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:s?n??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:s?"success":"pending",fetchStatus:"idle"}}var ti=class extends Ne{constructor(e,t){super(),this.options=t,this.#t=e,this.#o=null,this.#i=es(),this.bindMethods(),this.setOptions(t)}#t;#e=void 0;#s=void 0;#r=void 0;#n;#a;#i;#o;#g;#p;#u;#c;#l;#d;#h=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#e.addObserver(this),qs(this.#e,this.options)?this.#f():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return ss(this.#e,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return ss(this.#e,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#C(),this.#R(),this.#e.removeObserver(this)}setOptions(e){const t=this.options,s=this.#e;if(this.options=this.#t.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Z(this.options.enabled,this.#e)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#w(),this.#e.setOptions(this.options),t._defaulted&&!vt(this.options,t)&&this.#t.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#e,observer:this});const n=this.hasListeners();n&&Ws(this.#e,s,this.options,t)&&this.#f(),this.updateResult(),n&&(this.#e!==s||Z(this.options.enabled,this.#e)!==Z(t.enabled,this.#e)||de(this.options.staleTime,this.#e)!==de(t.staleTime,this.#e))&&this.#m();const r=this.#v();n&&(this.#e!==s||Z(this.options.enabled,this.#e)!==Z(t.enabled,this.#e)||r!==this.#d)&&this.#S(r)}getOptimisticResult(e){const t=this.#t.getQueryCache().build(this.#t,e),s=this.createResult(t,e);return ni(this,s)&&(this.#r=s,this.#a=this.options,this.#n=this.#e.state),s}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(s,n)=>(this.trackProp(n),t?.(n),n==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&this.#i.status==="pending"&&this.#i.reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(s,n))})}trackProp(e){this.#h.add(e)}getCurrentQuery(){return this.#e}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const t=this.#t.defaultQueryOptions(e),s=this.#t.getQueryCache().build(this.#t,t);return s.fetch().then(()=>this.createResult(s,t))}fetch(e){return this.#f({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#f(e){this.#w();let t=this.#e.fetch(this.options,e);return e?.throwOnError||(t=t.catch(j)),t}#m(){this.#C();const e=de(this.options.staleTime,this.#e);if(Pe||this.#r.isStale||!Yt(e))return;const t=zn(this.#r.dataUpdatedAt,e)+1;this.#c=Ce.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#v(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#e):this.options.refetchInterval)??!1}#S(e){this.#R(),this.#d=e,!(Pe||Z(this.options.enabled,this.#e)===!1||!Yt(this.#d)||this.#d===0)&&(this.#l=Ce.setInterval(()=>{(this.options.refetchIntervalInBackground||vs.isFocused())&&this.#f()},this.#d))}#y(){this.#m(),this.#S(this.#v())}#C(){this.#c&&(Ce.clearTimeout(this.#c),this.#c=void 0)}#R(){this.#l&&(Ce.clearInterval(this.#l),this.#l=void 0)}createResult(e,t){const s=this.#e,n=this.options,r=this.#r,i=this.#n,o=this.#a,a=e!==s?e.state:this.#s,{state:u}=e;let l={...u},h=!1,d;if(t._optimisticResults){const P=this.hasListeners(),b=!P&&qs(e,t),I=P&&Ws(e,s,t,n);(b||I)&&(l={...l,...Wn(u.data,e.options)}),t._optimisticResults==="isRestoring"&&(l.fetchStatus="idle")}let{error:c,errorUpdatedAt:f,status:g}=l;d=l.data;let p=!1;if(t.placeholderData!==void 0&&d===void 0&&g==="pending"){let P;r?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(P=r.data,p=!0):P=typeof t.placeholderData=="function"?t.placeholderData(this.#u?.state.data,this.#u):t.placeholderData,P!==void 0&&(g="success",d=Zt(r?.data,P,t),h=!0)}if(t.select&&d!==void 0&&!p)if(r&&d===i?.data&&t.select===this.#g)d=this.#p;else try{this.#g=t.select,d=t.select(d),d=Zt(r?.data,d,t),this.#p=d,this.#o=null}catch(P){this.#o=P}this.#o&&(c=this.#o,d=this.#p,f=Date.now(),g="error");const v=l.fetchStatus==="fetching",m=g==="pending",y=g==="error",C=m&&v,S=d!==void 0,w={status:g,fetchStatus:l.fetchStatus,isPending:m,isSuccess:g==="success",isError:y,isInitialLoading:C,isLoading:C,data:d,dataUpdatedAt:l.dataUpdatedAt,error:c,errorUpdatedAt:f,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:l.dataUpdateCount>0||l.errorUpdateCount>0,isFetchedAfterMount:l.dataUpdateCount>a.dataUpdateCount||l.errorUpdateCount>a.errorUpdateCount,isFetching:v,isRefetching:v&&!m,isLoadingError:y&&!S,isPaused:l.fetchStatus==="paused",isPlaceholderData:h,isRefetchError:y&&S,isStale:Ss(e,t),refetch:this.refetch,promise:this.#i,isEnabled:Z(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){const P=w.data!==void 0,b=w.status==="error"&&!P,I=M=>{b?M.reject(w.error):P&&M.resolve(w.data)},_=()=>{I(this.#i=w.promise=es())},x=this.#i;switch(x.status){case"pending":e.queryHash===s.queryHash&&I(x);break;case"fulfilled":(b||w.data!==x.value)&&_();break;case"rejected":(!b||w.error!==x.reason)&&_();break}}return w}updateResult(){const e=this.#r,t=this.createResult(this.#e,this.options);if(this.#n=this.#e.state,this.#a=this.options,this.#n.data!==void 0&&(this.#u=this.#e),vt(t,e))return;this.#r=t;const s=()=>{if(!e)return!0;const{notifyOnChangeProps:n}=this.options,r=typeof n=="function"?n():n;if(r==="all"||!r&&!this.#h.size)return!0;const i=new Set(r??this.#h);return this.options.throwOnError&&i.add("error"),Object.keys(this.#r).some(o=>{const a=o;return this.#r[a]!==e[a]&&i.has(a)})};this.#b({listeners:s()})}#w(){const e=this.#t.getQueryCache().build(this.#t,this.options);if(e===this.#e)return;const t=this.#e;this.#e=e,this.#s=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#b(e){$.batch(()=>{e.listeners&&this.listeners.forEach(t=>{t(this.#r)}),this.#t.getQueryCache().notify({query:this.#e,type:"observerResultsUpdated"})})}};function si(e,t){return Z(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function qs(e,t){return si(e,t)||e.state.data!==void 0&&ss(e,t,t.refetchOnMount)}function ss(e,t,s){if(Z(t.enabled,e)!==!1&&de(t.staleTime,e)!=="static"){const n=typeof s=="function"?s(e):s;return n==="always"||n!==!1&&Ss(e,t)}return!1}function Ws(e,t,s,n){return(e!==t||Z(n.enabled,e)===!1)&&(!s.suspense||e.state.status!=="error")&&Ss(e,s)}function Ss(e,t){return Z(t.enabled,e)!==!1&&e.isStaleByTime(de(t.staleTime,e))}function ni(e,t){return!vt(e.getCurrentResult(),t)}function Ks(e){return{onFetch:(t,s)=>{const n=t.options,r=t.fetchOptions?.meta?.fetchMore?.direction,i=t.state.data?.pages||[],o=t.state.data?.pageParams||[];let a={pages:[],pageParams:[]},u=0;const l=async()=>{let h=!1;const d=g=>{Kr(g,()=>t.signal,()=>h=!0)},c=Un(t.options,t.fetchOptions),f=async(g,p,v)=>{if(h)return Promise.reject();if(p==null&&g.pages.length)return Promise.resolve(g);const y=await c((()=>{const w={client:t.client,queryKey:t.queryKey,pageParam:p,direction:v?"backward":"forward",meta:t.options.meta};return d(w),w})()),{maxPages:C}=t.options,S=v?Wr:qr;return{pages:S(g.pages,y,C),pageParams:S(g.pageParams,p,C)}};if(r&&i.length){const g=r==="backward",p=g?ri:Qs,v={pages:i,pageParams:o};a=await f(v,p(n,v),g)}else{const g=e??i.length;do{const p=u===0?o[0]??n.initialPageParam:Qs(n,a);if(u>0&&p==null)break;a=await f(a,p),u++}while(u<g)}return a};t.options.persister?t.fetchFn=()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},s):t.fetchFn=l}}}function Qs(e,{pages:t,pageParams:s}){const n=t.length-1;return t.length>0?e.getNextPageParam(t[n],t,s[n],s):void 0}function ri(e,{pages:t,pageParams:s}){return t.length>0?e.getPreviousPageParam?.(t[0],t,s[0],s):void 0}var ii=class extends qn{#t;#e;#s;#r;constructor(e){super(),this.#t=e.client,this.mutationId=e.mutationId,this.#s=e.mutationCache,this.#e=[],this.state=e.state||Kn(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#e.includes(e)||(this.#e.push(e),this.clearGcTimeout(),this.#s.notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){this.#e=this.#e.filter(t=>t!==e),this.scheduleGc(),this.#s.notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){this.#e.length||(this.state.status==="pending"?this.scheduleGc():this.#s.remove(this))}continue(){return this.#r?.continue()??this.execute(this.state.variables)}async execute(e){const t=()=>{this.#n({type:"continue"})},s={client:this.#t,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#r=Gn({fn:()=>this.options.mutationFn?this.options.mutationFn(e,s):Promise.reject(new Error("No mutationFn found")),onFail:(i,o)=>{this.#n({type:"failed",failureCount:i,error:o})},onPause:()=>{this.#n({type:"pause"})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#s.canRun(this)});const n=this.state.status==="pending",r=!this.#r.canStart();try{if(n)t();else{this.#n({type:"pending",variables:e,isPaused:r}),await this.#s.config.onMutate?.(e,this,s);const o=await this.options.onMutate?.(e,s);o!==this.state.context&&this.#n({type:"pending",context:o,variables:e,isPaused:r})}const i=await this.#r.start();return await this.#s.config.onSuccess?.(i,e,this.state.context,this,s),await this.options.onSuccess?.(i,e,this.state.context,s),await this.#s.config.onSettled?.(i,null,this.state.variables,this.state.context,this,s),await this.options.onSettled?.(i,null,e,this.state.context,s),this.#n({type:"success",data:i}),i}catch(i){try{await this.#s.config.onError?.(i,e,this.state.context,this,s)}catch(o){Promise.reject(o)}try{await this.options.onError?.(i,e,this.state.context,s)}catch(o){Promise.reject(o)}try{await this.#s.config.onSettled?.(void 0,i,this.state.variables,this.state.context,this,s)}catch(o){Promise.reject(o)}try{await this.options.onSettled?.(void 0,i,e,this.state.context,s)}catch(o){Promise.reject(o)}throw this.#n({type:"error",error:i}),i}finally{this.#s.runNext(this)}}#n(e){const t=s=>{switch(e.type){case"failed":return{...s,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...s,isPaused:!0};case"continue":return{...s,isPaused:!1};case"pending":return{...s,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...s,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...s,data:void 0,error:e.error,failureCount:s.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=t(this.state),$.batch(()=>{this.#e.forEach(s=>{s.onMutationUpdate(e)}),this.#s.notify({mutation:this,type:"updated",action:e})})}};function Kn(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var oi=class extends Ne{constructor(e={}){super(),this.config=e,this.#t=new Set,this.#e=new Map,this.#s=0}#t;#e;#s;build(e,t,s){const n=new ii({client:e,mutationCache:this,mutationId:++this.#s,options:e.defaultMutationOptions(t),state:s});return this.add(n),n}add(e){this.#t.add(e);const t=ot(e);if(typeof t=="string"){const s=this.#e.get(t);s?s.push(e):this.#e.set(t,[e])}this.notify({type:"added",mutation:e})}remove(e){if(this.#t.delete(e)){const t=ot(e);if(typeof t=="string"){const s=this.#e.get(t);if(s)if(s.length>1){const n=s.indexOf(e);n!==-1&&s.splice(n,1)}else s[0]===e&&this.#e.delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){const t=ot(e);if(typeof t=="string"){const s=this.#e.get(t)?.find(n=>n.state.status==="pending");return!s||s===e}else return!0}runNext(e){const t=ot(e);return typeof t=="string"?this.#e.get(t)?.find(s=>s!==e&&s.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){$.batch(()=>{this.#t.forEach(e=>{this.notify({type:"removed",mutation:e})}),this.#t.clear(),this.#e.clear()})}getAll(){return Array.from(this.#t)}find(e){const t={exact:!0,...e};return this.getAll().find(s=>zs(t,s))}findAll(e={}){return this.getAll().filter(t=>zs(e,t))}notify(e){$.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){const e=this.getAll().filter(t=>t.state.isPaused);return $.batch(()=>Promise.all(e.map(t=>t.continue().catch(j))))}};function ot(e){return e.options.scope?.id}var ai=class extends Ne{#t;#e=void 0;#s;#r;constructor(e,t){super(),this.#t=e,this.setOptions(t),this.bindMethods(),this.#n()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){const t=this.options;this.options=this.#t.defaultMutationOptions(e),vt(this.options,t)||this.#t.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#s,observer:this}),t?.mutationKey&&this.options.mutationKey&&Me(t.mutationKey)!==Me(this.options.mutationKey)?this.reset():this.#s?.state.status==="pending"&&this.#s.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#s?.removeObserver(this)}onMutationUpdate(e){this.#n(),this.#a(e)}getCurrentResult(){return this.#e}reset(){this.#s?.removeObserver(this),this.#s=void 0,this.#n(),this.#a()}mutate(e,t){return this.#r=t,this.#s?.removeObserver(this),this.#s=this.#t.getMutationCache().build(this.#t,this.options),this.#s.addObserver(this),this.#s.execute(e)}#n(){const e=this.#s?.state??Kn();this.#e={...e,isPending:e.status==="pending",isSuccess:e.status==="success",isError:e.status==="error",isIdle:e.status==="idle",mutate:this.mutate,reset:this.reset}}#a(e){$.batch(()=>{if(this.#r&&this.hasListeners()){const t=this.#e.variables,s=this.#e.context,n={client:this.#t,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type==="success"){try{this.#r.onSuccess?.(e.data,t,s,n)}catch(r){Promise.reject(r)}try{this.#r.onSettled?.(e.data,null,t,s,n)}catch(r){Promise.reject(r)}}else if(e?.type==="error"){try{this.#r.onError?.(e.error,t,s,n)}catch(r){Promise.reject(r)}try{this.#r.onSettled?.(void 0,e.error,t,s,n)}catch(r){Promise.reject(r)}}}this.listeners.forEach(t=>{t(this.#e)})})}},li=class extends Ne{constructor(e={}){super(),this.config=e,this.#t=new Map}#t;build(e,t,s){const n=t.queryKey,r=t.queryHash??gs(n,t);let i=this.get(r);return i||(i=new ei({client:e,queryKey:n,queryHash:r,options:e.defaultQueryOptions(t),state:s,defaultOptions:e.getQueryDefaults(n)}),this.add(i)),i}add(e){this.#t.has(e.queryHash)||(this.#t.set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const t=this.#t.get(e.queryHash);t&&(e.destroy(),t===e&&this.#t.delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){$.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#t.get(e)}getAll(){return[...this.#t.values()]}find(e){const t={exact:!0,...e};return this.getAll().find(s=>Bs(t,s))}findAll(e={}){const t=this.getAll();return Object.keys(e).length>0?t.filter(s=>Bs(e,s)):t}notify(e){$.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){$.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){$.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},Fl=class{#t;#e;#s;#r;#n;#a;#i;#o;constructor(e={}){this.#t=e.queryCache||new li,this.#e=e.mutationCache||new oi,this.#s=e.defaultOptions||{},this.#r=new Map,this.#n=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#i=vs.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#t.onFocus())}),this.#o=St.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#t.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#i?.(),this.#i=void 0,this.#o?.(),this.#o=void 0)}isFetching(e){return this.#t.findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return this.#e.findAll({...e,status:"pending"}).length}getQueryData(e){const t=this.defaultQueryOptions({queryKey:e});return this.#t.get(t.queryHash)?.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),s=this.#t.build(this,t),n=s.state.data;return n===void 0?this.fetchQuery(e):(e.revalidateIfStale&&s.isStaleByTime(de(t.staleTime,s))&&this.prefetchQuery(t),Promise.resolve(n))}getQueriesData(e){return this.#t.findAll(e).map(({queryKey:t,state:s})=>[t,s.data])}setQueryData(e,t,s){const n=this.defaultQueryOptions({queryKey:e}),r=this.#t.get(n.queryHash)?.state.data,i=Ur(t,r);if(i!==void 0)return this.#t.build(this,n).setData(i,{...s,manual:!0})}setQueriesData(e,t,s){return $.batch(()=>this.#t.findAll(e).map(({queryKey:n})=>[n,this.setQueryData(n,t,s)]))}getQueryState(e){const t=this.defaultQueryOptions({queryKey:e});return this.#t.get(t.queryHash)?.state}removeQueries(e){const t=this.#t;$.batch(()=>{t.findAll(e).forEach(s=>{t.remove(s)})})}resetQueries(e,t){const s=this.#t;return $.batch(()=>(s.findAll(e).forEach(n=>{n.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const s={revert:!0,...t},n=$.batch(()=>this.#t.findAll(e).map(r=>r.cancel(s)));return Promise.all(n).then(j).catch(j)}invalidateQueries(e,t={}){return $.batch(()=>(this.#t.findAll(e).forEach(s=>{s.invalidate()}),e?.refetchType==="none"?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??"active"},t)))}refetchQueries(e,t={}){const s={...t,cancelRefetch:t.cancelRefetch??!0},n=$.batch(()=>this.#t.findAll(e).filter(r=>!r.isDisabled()&&!r.isStatic()).map(r=>{let i=r.fetch(void 0,s);return s.throwOnError||(i=i.catch(j)),r.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(n).then(j)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const s=this.#t.build(this,t);return s.isStaleByTime(de(t.staleTime,s))?s.fetch(t):Promise.resolve(s.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(j).catch(j)}fetchInfiniteQuery(e){return e.behavior=Ks(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(j).catch(j)}ensureInfiniteQueryData(e){return e.behavior=Ks(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return St.isOnline()?this.#e.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#t}getMutationCache(){return this.#e}getDefaultOptions(){return this.#s}setDefaultOptions(e){this.#s=e}setQueryDefaults(e,t){this.#r.set(Me(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...this.#r.values()],s={};return t.forEach(n=>{Xe(e,n.queryKey)&&Object.assign(s,n.defaultOptions)}),s}setMutationDefaults(e,t){this.#n.set(Me(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...this.#n.values()],s={};return t.forEach(n=>{Xe(e,n.mutationKey)&&Object.assign(s,n.defaultOptions)}),s}defaultQueryOptions(e){if(e._defaulted)return e;const t={...this.#s.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=gs(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.queryFn===ps&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#s.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#t.clear(),this.#e.clear()}},R=Bn(fs(),1),E=Vr(),Qn=R.createContext(void 0),Jn=e=>{const t=R.useContext(Qn);if(e)return e;if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},Al=({client:e,children:t})=>(R.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,E.jsx)(Qn.Provider,{value:e,children:t})),Yn=R.createContext(!1),ui=()=>R.useContext(Yn),kl=Yn.Provider;function ci(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var di=R.createContext(ci()),hi=()=>R.useContext(di),fi=(e,t,s)=>{const n=s?.state.error&&typeof e.throwOnError=="function"?ms(e.throwOnError,[s.state.error,s]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||n)&&(t.isReset()||(e.retryOnMount=!1))},gi=e=>{R.useEffect(()=>{e.clearReset()},[e])},pi=({result:e,errorResetBoundary:t,throwOnError:s,query:n,suspense:r})=>e.isError&&!t.isReset()&&!e.isFetching&&n&&(r&&e.data===void 0||ms(s,[e.error,n])),mi=e=>{if(e.suspense){const s=r=>r==="static"?r:Math.max(r??1e3,1e3),n=e.staleTime;e.staleTime=typeof n=="function"?(...r)=>s(n(...r)):s(n),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},vi=(e,t)=>e.isLoading&&e.isFetching&&!t,Si=(e,t)=>e?.suspense&&t.isPending,Js=(e,t,s)=>t.fetchOptimistic(e).catch(()=>{s.clearReset()});function yi(e,t,s){const n=ui(),r=hi(),i=Jn(s),o=i.defaultQueryOptions(e);i.getDefaultOptions().queries?._experimental_beforeQuery?.(o);const a=i.getQueryCache().get(o.queryHash);o._optimisticResults=n?"isRestoring":"optimistic",mi(o),fi(o,r,a),gi(r);const u=!i.getQueryCache().get(o.queryHash),[l]=R.useState(()=>new t(i,o)),h=l.getOptimisticResult(o),d=!n&&e.subscribed!==!1;if(R.useSyncExternalStore(R.useCallback(c=>{const f=d?l.subscribe($.batchCalls(c)):j;return l.updateResult(),f},[l,d]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),R.useEffect(()=>{l.setOptions(o)},[o,l]),Si(o,h))throw Js(o,l,r);if(pi({result:h,errorResetBoundary:r,throwOnError:o.throwOnError,query:a,suspense:o.suspense}))throw h.error;return i.getDefaultOptions().queries?._experimental_afterQuery?.(o,h),o.experimental_prefetchInRender&&!Pe&&vi(h,n)&&(u?Js(o,l,r):a?.promise)?.catch(j).finally(()=>{l.updateResult()}),o.notifyOnChangeProps?h:l.trackResult(h)}function Dl(e,t){return yi(e,ti,t)}function $l(e,t){const s=Jn(t),[n]=R.useState(()=>new ai(s,e));R.useEffect(()=>{n.setOptions(e)},[n,e]);const r=R.useSyncExternalStore(R.useCallback(o=>n.subscribe($.batchCalls(o)),[n]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),i=R.useCallback((o,a)=>{n.mutate(o,a).catch(j)},[n]);if(r.error&&ms(n.options.throwOnError,[r.error]))throw r.error;return{...r,mutate:i,mutateAsync:r.mutate}}var Ys=R.use,Je=typeof window<"u"?R.useLayoutEffect:R.useEffect;function Ft(e){const t=R.useRef({value:e,prev:null}),s=t.current.value;return e!==s&&(t.current={value:e,prev:s}),t.current.prev}function Ci(e,t,s={},n={}){R.useEffect(()=>{if(!e.current||n.disabled||typeof IntersectionObserver!="function")return;const r=new IntersectionObserver(([i])=>{t(i)},s);return r.observe(e.current),()=>{r.disconnect()}},[t,s,n.disabled,e])}function Ri(e){const t=R.useRef(null);return R.useImperativeHandle(e,()=>t.current,[]),t}function Ze(e){return e[e.length-1]}function wi(e){return typeof e=="function"}function ne(e,t){return wi(e)?e(t):e}var bi=Object.prototype.hasOwnProperty,Xs=Object.prototype.propertyIsEnumerable,Pi=()=>Object.create(null),Se=(e,t)=>le(e,t,Pi);function le(e,t,s=()=>({}),n=0){if(e===t)return e;if(n>500)return t;const r=t,i=tn(e)&&tn(r);if(!i&&!(ke(e)&&ke(r)))return r;const o=i?e:Zs(e);if(!o)return r;const a=i?r:Zs(r);if(!a)return r;const u=o.length,l=a.length,h=i?new Array(l):s();let d=0;for(let c=0;c<l;c++){const f=i?c:a[c],g=e[f],p=r[f];if(g===p){h[f]=g,(i?c<u:bi.call(e,f))&&d++;continue}if(g===null||p===null||typeof g!="object"||typeof p!="object"){h[f]=p;continue}const v=le(g,p,s,n+1);h[f]=v,v===g&&d++}return u===l&&d===u?e:h}function Zs(e){const t=Object.getOwnPropertyNames(e);for(const r of t)if(!Xs.call(e,r))return!1;const s=Object.getOwnPropertySymbols(e);if(s.length===0)return t;const n=t;for(const r of s){if(!Xs.call(e,r))return!1;n.push(r)}return n}function ke(e){if(!en(e))return!1;const t=e.constructor;if(typeof t>"u")return!0;const s=t.prototype;return!(!en(s)||!s.hasOwnProperty("isPrototypeOf"))}function en(e){return Object.prototype.toString.call(e)==="[object Object]"}function tn(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function he(e,t,s){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let n=0,r=e.length;n<r;n++)if(!he(e[n],t[n],s))return!1;return!0}if(ke(e)&&ke(t)){const n=s?.ignoreUndefined??!0;if(s?.partial){for(const o in t)if((!n||t[o]!==void 0)&&!he(e[o],t[o],s))return!1;return!0}let r=0;if(!n)r=Object.keys(e).length;else for(const o in e)e[o]!==void 0&&r++;let i=0;for(const o in t)if((!n||t[o]!==void 0)&&(i++,i>r||!he(e[o],t[o],s)))return!1;return r===i}return!1}function De(e){let t,s;const n=new Promise((r,i)=>{t=r,s=i});return n.status="pending",n.resolve=r=>{n.status="resolved",n.value=r,t(r),e?.(r)},n.reject=r=>{n.status="rejected",s(r)},n}function Mi(e){return typeof e?.message!="string"?!1:e.message.startsWith("Failed to fetch dynamically imported module")||e.message.startsWith("error loading dynamically imported module")||e.message.startsWith("Importing a module script failed")}function et(e){return!!(e&&typeof e=="object"&&typeof e.then=="function")}function _i(e){return e.replace(/[\x00-\x1f\x7f]/g,"")}function sn(e){let t;try{t=decodeURI(e)}catch{t=e.replaceAll(/%[0-9A-F]{2}/gi,s=>{try{return decodeURI(s)}catch{return s}})}return _i(t)}var Ii=["http:","https:","mailto:","tel:"];function ye(e,t){if(!e)return!1;try{const s=new URL(e);return!t.has(s.protocol)}catch{return!1}}function je(e){if(!e)return{path:e,handledProtocolRelativeURL:!1};if(!/[%\\\x00-\x1f\x7f]/.test(e)&&!e.startsWith("//"))return{path:e,handledProtocolRelativeURL:!1};const t=/%25|%5C/gi;let s=0,n="",r;for(;(r=t.exec(e))!==null;)n+=sn(e.slice(s,r.index))+r[0],s=t.lastIndex;n=n+sn(s?e.slice(s):e);let i=!1;return n.startsWith("//")&&(i=!0,n="/"+n.replace(/^\/+/,"")),{path:n,handledProtocolRelativeURL:i}}function xi(e){return/\s|[^\u0000-\u007F]/.test(e)?e.replace(/\s|[^\u0000-\u007F]/gu,encodeURIComponent):e}function Ei(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let s=0;s<e.length;s++)if(e[s]!==t[s])return!1;return!0}function ie(){throw new Error("Invariant failed")}function tt(e){const t=new Map;let s,n;const r=i=>{i.next&&(i.prev?(i.prev.next=i.next,i.next.prev=i.prev,i.next=void 0,n&&(n.next=i,i.prev=n)):(i.next.prev=void 0,s=i.next,i.next=void 0,n&&(i.prev=n,n.next=i)),n=i)};return{get(i){const o=t.get(i);if(o)return r(o),o.value},set(i,o){if(t.size>=e&&s){const u=s;t.delete(u.key),u.next&&(s=u.next,u.next.prev=void 0),u===n&&(n=void 0)}const a=t.get(i);if(a)a.value=o,r(a);else{const u={key:i,value:o,prev:n};n&&(n.next=u),n=u,s||(s=u),t.set(i,u)}},clear(){t.clear(),s=void 0,n=void 0}}}var Re=4,Xn=5;function Li(e){const t=e.indexOf("{");if(t===-1)return null;const s=e.indexOf("}",t);return s===-1||t+1>=e.length?null:[t,s]}function ys(e,t,s=new Uint16Array(6)){const n=e.indexOf("/",t),r=n===-1?e.length:n,i=e.substring(t,r);if(!i||!i.includes("$"))return s[0]=0,s[1]=t,s[2]=t,s[3]=r,s[4]=r,s[5]=r,s;if(i==="$"){const a=e.length;return s[0]=2,s[1]=t,s[2]=t,s[3]=a,s[4]=a,s[5]=a,s}if(i.charCodeAt(0)===36)return s[0]=1,s[1]=t,s[2]=t+1,s[3]=r,s[4]=r,s[5]=r,s;const o=Li(i);if(o){const[a,u]=o,l=i.charCodeAt(a+1);if(l===45){if(a+2<i.length&&i.charCodeAt(a+2)===36){const h=a+3,d=u;if(h<d)return s[0]=3,s[1]=t+a,s[2]=t+h,s[3]=t+d,s[4]=t+u+1,s[5]=r,s}}else if(l===36){const h=a+1,d=a+2;return d===u?(s[0]=2,s[1]=t+a,s[2]=t+h,s[3]=t+d,s[4]=t+u+1,s[5]=e.length,s):(s[0]=1,s[1]=t+a,s[2]=t+d,s[3]=t+u,s[4]=t+u+1,s[5]=r,s)}}return s[0]=0,s[1]=t,s[2]=t,s[3]=r,s[4]=r,s[5]=r,s}function bt(e,t,s,n,r,i,o){o?.(s);let a=n;{const u=s.fullPath??s.from,l=u.length,h=s.options?.caseSensitive??e,d=!!(s.options?.params?.parse&&s.options?.skipRouteOnParseError?.params);for(;a<l;){const f=ys(u,a,t);let g;const p=a,v=f[5];switch(a=v+1,i++,f[0]){case 0:{const m=u.substring(f[2],f[3]);if(h){const y=r.static?.get(m);if(y)g=y;else{r.static??=new Map;const C=we(s.fullPath??s.from);C.parent=r,C.depth=i,g=C,r.static.set(m,C)}}else{const y=m.toLowerCase(),C=r.staticInsensitive?.get(y);if(C)g=C;else{r.staticInsensitive??=new Map;const S=we(s.fullPath??s.from);S.parent=r,S.depth=i,g=S,r.staticInsensitive.set(y,S)}}break}case 1:{const m=u.substring(p,f[1]),y=u.substring(f[4],v),C=h&&!!(m||y),S=m?C?m:m.toLowerCase():void 0,w=y?C?y:y.toLowerCase():void 0,P=!d&&r.dynamic?.find(b=>!b.skipOnParamError&&b.caseSensitive===C&&b.prefix===S&&b.suffix===w);if(P)g=P;else{const b=kt(1,s.fullPath??s.from,C,S,w);g=b,b.depth=i,b.parent=r,r.dynamic??=[],r.dynamic.push(b)}break}case 3:{const m=u.substring(p,f[1]),y=u.substring(f[4],v),C=h&&!!(m||y),S=m?C?m:m.toLowerCase():void 0,w=y?C?y:y.toLowerCase():void 0,P=!d&&r.optional?.find(b=>!b.skipOnParamError&&b.caseSensitive===C&&b.prefix===S&&b.suffix===w);if(P)g=P;else{const b=kt(3,s.fullPath??s.from,C,S,w);g=b,b.parent=r,b.depth=i,r.optional??=[],r.optional.push(b)}break}case 2:{const m=u.substring(p,f[1]),y=u.substring(f[4],v),C=h&&!!(m||y),S=m?C?m:m.toLowerCase():void 0,w=y?C?y:y.toLowerCase():void 0,P=kt(2,s.fullPath??s.from,C,S,w);g=P,P.parent=r,P.depth=i,r.wildcard??=[],r.wildcard.push(P)}}r=g}if(d&&s.children&&!s.isRoot&&s.id&&s.id.charCodeAt(s.id.lastIndexOf("/")+1)===95){const f=we(s.fullPath??s.from);f.kind=Xn,f.parent=r,i++,f.depth=i,r.pathless??=[],r.pathless.push(f),r=f}const c=(s.path||!s.children)&&!s.isRoot;if(c&&u.endsWith("/")){const f=we(s.fullPath??s.from);f.kind=Re,f.parent=r,i++,f.depth=i,r.index=f,r=f}r.parse=s.options?.params?.parse??null,r.skipOnParamError=d,r.parsingPriority=s.options?.skipRouteOnParseError?.priority??0,c&&!r.route&&(r.route=s,r.fullPath=s.fullPath??s.from)}if(s.children)for(const u of s.children)bt(e,t,u,a,r,i,o)}function At(e,t){if(e.skipOnParamError&&!t.skipOnParamError)return-1;if(!e.skipOnParamError&&t.skipOnParamError)return 1;if(e.skipOnParamError&&t.skipOnParamError&&(e.parsingPriority||t.parsingPriority))return t.parsingPriority-e.parsingPriority;if(e.prefix&&t.prefix&&e.prefix!==t.prefix){if(e.prefix.startsWith(t.prefix))return-1;if(t.prefix.startsWith(e.prefix))return 1}if(e.suffix&&t.suffix&&e.suffix!==t.suffix){if(e.suffix.endsWith(t.suffix))return-1;if(t.suffix.endsWith(e.suffix))return 1}return e.prefix&&!t.prefix?-1:!e.prefix&&t.prefix?1:e.suffix&&!t.suffix?-1:!e.suffix&&t.suffix?1:e.caseSensitive&&!t.caseSensitive?-1:!e.caseSensitive&&t.caseSensitive?1:0}function ae(e){if(e.pathless)for(const t of e.pathless)ae(t);if(e.static)for(const t of e.static.values())ae(t);if(e.staticInsensitive)for(const t of e.staticInsensitive.values())ae(t);if(e.dynamic?.length){e.dynamic.sort(At);for(const t of e.dynamic)ae(t)}if(e.optional?.length){e.optional.sort(At);for(const t of e.optional)ae(t)}if(e.wildcard?.length){e.wildcard.sort(At);for(const t of e.wildcard)ae(t)}}function we(e){return{kind:0,depth:0,pathless:null,index:null,static:null,staticInsensitive:null,dynamic:null,optional:null,wildcard:null,route:null,fullPath:e,parent:null,parse:null,skipOnParamError:!1,parsingPriority:0}}function kt(e,t,s,n,r){return{kind:e,depth:0,pathless:null,index:null,static:null,staticInsensitive:null,dynamic:null,optional:null,wildcard:null,route:null,fullPath:t,parent:null,parse:null,skipOnParamError:!1,parsingPriority:0,caseSensitive:s,prefix:n,suffix:r}}function Ti(e,t){const s=we("/"),n=new Uint16Array(6);for(const r of e)bt(!1,n,r,1,s,0);ae(s),t.masksTree=s,t.flatCache=tt(1e3)}function Oi(e,t){e||="/";const s=t.flatCache.get(e);if(s)return s;const n=Cs(e,t.masksTree);return t.flatCache.set(e,n),n}function Fi(e,t,s,n,r){e||="/",n||="/";const i=t?`case\0${e}`:e;let o=r.singleCache.get(i);return o||(o=we("/"),bt(t,new Uint16Array(6),{from:e},1,o,0),r.singleCache.set(i,o)),Cs(n,o,s)}function Ai(e,t,s=!1){const n=s?e:`nofuzz\0${e}`,r=t.matchCache.get(n);if(r!==void 0)return r;e||="/";let i;try{i=Cs(e,t.segmentTree,s)}catch(o){if(o instanceof URIError)i=null;else throw o}return i&&(i.branch=$i(i.route)),t.matchCache.set(n,i),i}function ki(e){return e==="/"?e:e.replace(/\/{1,}$/,"")}function Di(e,t=!1,s){const n=we(e.fullPath),r=new Uint16Array(6),i={},o={};let a=0;return bt(t,r,e,1,n,0,u=>{if(s?.(u,a),u.id in i&&ie(),i[u.id]=u,a!==0&&u.path){const l=ki(u.fullPath);(!o[l]||u.fullPath.endsWith("/"))&&(o[l]=u)}a++}),ae(n),{processedTree:{segmentTree:n,singleCache:tt(1e3),matchCache:tt(1e3),flatCache:null,masksTree:null},routesById:i,routesByPath:o}}function Cs(e,t,s=!1){const n=e.split("/"),r=Vi(e,n,t,s);if(!r)return null;const[i]=Zn(e,n,r);return{route:r.node.route,rawParams:i,parsedParams:r.parsedParams}}function Zn(e,t,s){const n=Ni(s.node);let r=null;const i=Object.create(null);let o=s.extract?.part??0,a=s.extract?.node??0,u=s.extract?.path??0,l=s.extract?.segment??0;for(;a<n.length;o++,a++,u++,l++){const h=n[a];if(h.kind===Re)break;if(h.kind===Xn){l--,o--,u--;continue}const d=t[o],c=u;if(d&&(u+=d.length),h.kind===1){r??=s.node.fullPath.split("/");const f=r[l],g=h.prefix?.length??0;if(f.charCodeAt(g)===123){const p=h.suffix?.length??0,v=f.substring(g+2,f.length-p-1),m=d.substring(g,d.length-p);i[v]=decodeURIComponent(m)}else{const p=f.substring(1);i[p]=decodeURIComponent(d)}}else if(h.kind===3){if(s.skipped&1<<a){o--,u=c-1;continue}r??=s.node.fullPath.split("/");const f=r[l],g=h.prefix?.length??0,p=h.suffix?.length??0,v=f.substring(g+3,f.length-p-1),m=h.suffix||h.prefix?d.substring(g,d.length-p):d;m&&(i[v]=decodeURIComponent(m))}else if(h.kind===2){const f=h,g=e.substring(c+(f.prefix?.length??0),e.length-(f.suffix?.length??0)),p=decodeURIComponent(g);i["*"]=p,i._splat=p;break}}return s.rawParams&&Object.assign(i,s.rawParams),[i,{part:o,node:a,path:u,segment:l}]}function $i(e){const t=[e];for(;e.parentRoute;)e=e.parentRoute,t.push(e);return t.reverse(),t}function Ni(e){const t=Array(e.depth+1);do t[e.depth]=e,e=e.parent;while(e);return t}function Vi(e,t,s,n){if(e==="/"&&s.index)return{node:s.index,skipped:0};const r=!Ze(t),i=r&&e!=="/",o=t.length-(r?1:0),a=[{node:s,index:1,skipped:0,depth:1,statics:1,dynamics:0,optionals:0}];let u=null,l=null,h=null;for(;a.length;){const d=a.pop(),{node:c,index:f,skipped:g,depth:p,statics:v,dynamics:m,optionals:y}=d;let{extract:C,rawParams:S,parsedParams:w}=d;if(c.skipOnParamError){if(!Dt(e,t,d))continue;S=d.rawParams,C=d.extract,w=d.parsedParams}n&&c.route&&c.kind!==Re&&Ge(l,d)&&(l=d);const P=f===o;if(P&&(c.route&&!i&&Ge(h,d)&&(h=d),!c.optional&&!c.wildcard&&!c.index&&!c.pathless))continue;const b=P?void 0:t[f];let I;if(P&&c.index){const _={node:c.index,index:f,skipped:g,depth:p+1,statics:v,dynamics:m,optionals:y,extract:C,rawParams:S,parsedParams:w};let x=!0;if(c.index.skipOnParamError&&(Dt(e,t,_)||(x=!1)),x){if(v===o&&!m&&!y&&!g)return _;Ge(h,_)&&(h=_)}}if(c.wildcard&&Ge(u,d))for(const _ of c.wildcard){const{prefix:x,suffix:M}=_;if(x&&(P||!(_.caseSensitive?b:I??=b.toLowerCase()).startsWith(x)))continue;if(M){if(P)continue;const F=t.slice(f).join("/").slice(-M.length);if((_.caseSensitive?F:F.toLowerCase())!==M)continue}const k={node:_,index:o,skipped:g,depth:p,statics:v,dynamics:m,optionals:y,extract:C,rawParams:S,parsedParams:w};if(!(_.skipOnParamError&&!Dt(e,t,k))){u=k;break}}if(c.optional){const _=g|1<<p,x=p+1;for(let M=c.optional.length-1;M>=0;M--){const k=c.optional[M];a.push({node:k,index:f,skipped:_,depth:x,statics:v,dynamics:m,optionals:y,extract:C,rawParams:S,parsedParams:w})}if(!P)for(let M=c.optional.length-1;M>=0;M--){const k=c.optional[M],{prefix:F,suffix:J}=k;if(F||J){const B=k.caseSensitive?b:I??=b.toLowerCase();if(F&&!B.startsWith(F)||J&&!B.endsWith(J))continue}a.push({node:k,index:f+1,skipped:g,depth:x,statics:v,dynamics:m,optionals:y+1,extract:C,rawParams:S,parsedParams:w})}}if(!P&&c.dynamic&&b)for(let _=c.dynamic.length-1;_>=0;_--){const x=c.dynamic[_],{prefix:M,suffix:k}=x;if(M||k){const F=x.caseSensitive?b:I??=b.toLowerCase();if(M&&!F.startsWith(M)||k&&!F.endsWith(k))continue}a.push({node:x,index:f+1,skipped:g,depth:p+1,statics:v,dynamics:m+1,optionals:y,extract:C,rawParams:S,parsedParams:w})}if(!P&&c.staticInsensitive){const _=c.staticInsensitive.get(I??=b.toLowerCase());_&&a.push({node:_,index:f+1,skipped:g,depth:p+1,statics:v+1,dynamics:m,optionals:y,extract:C,rawParams:S,parsedParams:w})}if(!P&&c.static){const _=c.static.get(b);_&&a.push({node:_,index:f+1,skipped:g,depth:p+1,statics:v+1,dynamics:m,optionals:y,extract:C,rawParams:S,parsedParams:w})}if(c.pathless){const _=p+1;for(let x=c.pathless.length-1;x>=0;x--){const M=c.pathless[x];a.push({node:M,index:f,skipped:g,depth:_,statics:v,dynamics:m,optionals:y,extract:C,rawParams:S,parsedParams:w})}}}if(h&&u)return Ge(u,h)?h:u;if(h)return h;if(u)return u;if(n&&l){let d=l.index;for(let f=0;f<l.index;f++)d+=t[f].length;const c=d===e.length?"/":e.slice(d);return l.rawParams??=Object.create(null),l.rawParams["**"]=decodeURIComponent(c),l}return null}function Dt(e,t,s){try{const[n,r]=Zn(e,t,s);s.rawParams=n,s.extract=r;const i=s.node.parse(n);return s.parsedParams=Object.assign(Object.create(null),s.parsedParams,i),!0}catch{return null}}function Ge(e,t){return e?t.statics>e.statics||t.statics===e.statics&&(t.dynamics>e.dynamics||t.dynamics===e.dynamics&&(t.optionals>e.optionals||t.optionals===e.optionals&&((t.node.kind===Re)>(e.node.kind===Re)||t.node.kind===Re==(e.node.kind===Re)&&t.depth>e.depth))):!0}function ht(e){return Rs(e.filter(t=>t!==void 0).join("/"))}function Rs(e){return e.replace(/\/{2,}/g,"/")}function er(e){return e==="/"?e:e.replace(/^\/{1,}/,"")}function fe(e){const t=e.length;return t>1&&e[t-1]==="/"?e.replace(/\/{1,}$/,""):e}function tr(e){return fe(er(e))}function Fe(e,t){return e?.endsWith("/")&&e!=="/"&&e!==`${t}/`?e.slice(0,-1):e}function nn(e,t,s){return Fe(e,s)===Fe(t,s)}function Bi({base:e,to:t,trailingSlash:s="never",cache:n}){const r=t.startsWith("/"),i=!r&&t===".";let o;if(n){o=r?t:i?e:e+"\0"+t;const d=n.get(o);if(d)return d}let a;if(i)a=e.split("/");else if(r)a=t.split("/");else{for(a=e.split("/");a.length>1&&Ze(a)==="";)a.pop();const d=t.split("/");for(let c=0,f=d.length;c<f;c++){const g=d[c];g===""?c?c===f-1&&a.push(g):a=[g]:g===".."?a.pop():g==="."||a.push(g)}}a.length>1&&(Ze(a)===""?s==="never"&&a.pop():s==="always"&&a.push(""));let u,l="";for(let d=0;d<a.length;d++){d>0&&(l+="/");const c=a[d];if(!c)continue;u=ys(c,0,u);const f=u[0];if(f===0){l+=c;continue}const g=u[5],p=c.substring(0,u[1]),v=c.substring(u[4],g),m=c.substring(u[2],u[3]);f===1?l+=p||v?`${p}{$${m}}${v}`:`$${m}`:f===2?l+=p||v?`${p}{$}${v}`:"$":l+=`${p}{-$${m}}${v}`}l=Rs(l);const h=l||"/";return o&&n&&n.set(o,h),h}function zi(e){const t=new Map(e.map(r=>[encodeURIComponent(r),r])),s=Array.from(t.keys()).map(r=>r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|"),n=new RegExp(s,"g");return r=>r.replace(n,i=>t.get(i)??i)}function $t(e,t,s){const n=t[e];return typeof n!="string"?n:e==="_splat"?/^[a-zA-Z0-9\-._~!/]*$/.test(n)?n:n.split("/").map(r=>on(r,s)).join("/"):on(n,s)}function rn({path:e,params:t,decoder:s,...n}){let r=!1;const i=Object.create(null);if(!e||e==="/")return{interpolatedPath:"/",usedParams:i,isMissingParams:r};if(!e.includes("$"))return{interpolatedPath:e,usedParams:i,isMissingParams:r};const o=e.length;let a=0,u,l="";for(;a<o;){const h=a;u=ys(e,h,u);const d=u[5];if(a=d+1,h===d)continue;const c=u[0];if(c===0){l+="/"+e.substring(h,d);continue}if(c===2){const f=t._splat;i._splat=f,i["*"]=f;const g=e.substring(h,u[1]),p=e.substring(u[4],d);if(!f){r=!0,(g||p)&&(l+="/"+g+p);continue}const v=$t("_splat",t,s);l+="/"+g+v+p;continue}if(c===1){const f=e.substring(u[2],u[3]);!r&&!(f in t)&&(r=!0),i[f]=t[f];const g=e.substring(h,u[1]),p=e.substring(u[4],d),v=$t(f,t,s)??"undefined";l+="/"+g+v+p;continue}if(c===3){const f=e.substring(u[2],u[3]),g=t[f];if(g==null)continue;i[f]=g;const p=e.substring(h,u[1]),v=e.substring(u[4],d),m=$t(f,t,s)??"";l+="/"+p+m+v;continue}}return e.endsWith("/")&&(l+="/"),{usedParams:i,interpolatedPath:l||"/",isMissingParams:r}}function on(e,t){const s=encodeURIComponent(e);return t?.(s)??s}function H(e){return e?.isNotFound===!0}function Hi(){try{return typeof window<"u"&&typeof window.sessionStorage=="object"?window.sessionStorage:void 0}catch{return}}var Ui="tsr-scroll-restoration-v1_3";function ji(){const e=Hi();if(!e)return null;let t={};try{const n=JSON.parse(e.getItem("tsr-scroll-restoration-v1_3")||"{}");ke(n)&&(t=n)}catch{}return{get state(){return t},set:n=>{t=ne(n,t)||t},persist:()=>{try{e.setItem(Ui,JSON.stringify(t))}catch{}}}}var an=ji(),Gi=e=>e.state.__TSR_key||e.href;function qi(e){const t=[];let s;for(;s=e.parentNode;)t.push(`${e.tagName}:nth-child(${Array.prototype.indexOf.call(s.children,e)+1})`),e=s;return`${t.reverse().join(" > ")}`.toLowerCase()}var at=!1,qe="window",ln="data-scroll-restoration-id";function Wi(e,t){if(!an)return;const s=an;if((t??e.options.scrollRestoration??!1)&&(e.isScrollRestoring=!0),e.isScrollRestorationSetup||!s)return;e.isScrollRestorationSetup=!0,at=!1;const n=e.options.getScrollRestorationKey||Gi,r=new Map;window.history.scrollRestoration="manual";const i=a=>{if(!(at||!e.isScrollRestoring))if(a.target===document||a.target===window)r.set(qe,{scrollX:window.scrollX||0,scrollY:window.scrollY||0});else{const u=a.target;r.set(u,{scrollX:u.scrollLeft||0,scrollY:u.scrollTop||0})}},o=a=>{if(!e.isScrollRestoring||!a||r.size===0||!s)return;const u=s.state[a]||={};for(const[l,h]of r){let d;if(l===qe)d=qe;else if(l.isConnected){const c=l.getAttribute(ln);d=c?`[${ln}="${c}"]`:qi(l)}d&&(u[d]=h)}};document.addEventListener("scroll",i,!0),e.subscribe("onBeforeLoad",a=>{o(a.fromLocation?n(a.fromLocation):void 0),r.clear()}),window.addEventListener("pagehide",()=>{o(n(e.stores.resolvedLocation.get()??e.stores.location.get())),s.persist()}),e.subscribe("onRendered",a=>{const u=n(a.toLocation),l=e.options.scrollRestorationBehavior,h=e.options.scrollToTopSelectors;if(r.clear(),!e.resetNextScroll){e.resetNextScroll=!0;return}if(!(typeof e.options.scrollRestoration=="function"&&!e.options.scrollRestoration({location:e.latestLocation}))){at=!0;try{const d=e.isScrollRestoring?s.state[u]:void 0;let c=!1;if(d)for(const f in d){const g=d[f];if(!ke(g))continue;const{scrollX:p,scrollY:v}=g;if(!(!Number.isFinite(p)||!Number.isFinite(v))){if(f===qe)window.scrollTo({top:v,left:p,behavior:l}),c=!0;else if(f){let m;try{m=document.querySelector(f)}catch{continue}m&&(m.scrollLeft=p,m.scrollTop=v,c=!0)}}}if(!c){const f=e.history.location.hash.slice(1);if(f){const g=window.history.state?.__hashScrollIntoViewOptions??!0;if(g){const p=document.getElementById(f);p&&p.scrollIntoView(g)}}else{const g={top:0,left:0,behavior:l};if(window.scrollTo(g),h)for(const p of h){if(p===qe)continue;const v=typeof p=="function"?p():document.querySelector(p);v&&v.scrollTo(g)}}}}finally{at=!1}e.isScrollRestoring&&s.set(d=>(d[u]||={},d))}})}function Ki(e,t=String){const s=new URLSearchParams;for(const n in e){const r=e[n];r!==void 0&&s.set(n,t(r))}return s.toString()}function Nt(e){return e?e==="false"?!1:e==="true"?!0:+e*0===0&&+e+""===e?+e:e:""}function Qi(e){const t=new URLSearchParams(e),s=Object.create(null);for(const[n,r]of t.entries()){const i=s[n];i==null?s[n]=Nt(r):Array.isArray(i)?i.push(Nt(r)):s[n]=[i,Nt(r)]}return s}var Ji=Xi(JSON.parse),Yi=Zi(JSON.stringify,JSON.parse);function Xi(e){return t=>{t[0]==="?"&&(t=t.substring(1));const s=Qi(t);for(const n in s){const r=s[n];if(typeof r=="string")try{s[n]=e(r)}catch{}}return s}}function Zi(e,t){const s=typeof t=="function";function n(r){if(typeof r=="object"&&r!==null)try{return e(r)}catch{}else if(s&&typeof r=="string")try{return t(r),e(r)}catch{}return r}return r=>{const i=Ki(r,n);return i?`?${i}`:""}}var ft="__root__";function eo(e){if(e.statusCode=e.statusCode||e.code||307,!e._builtLocation&&!e.reloadDocument&&typeof e.href=="string")try{new URL(e.href),e.reloadDocument=!0}catch{}const t=new Headers(e.headers);e.href&&t.get("Location")===null&&t.set("Location",e.href);const s=new Response(null,{status:e.statusCode,headers:t});if(s.options=e,e.throw)throw s;return s}function W(e){return e instanceof Response&&!!e.options}function to(e){return{input:({url:t})=>{for(const s of e)t=ns(s,t);return t},output:({url:t})=>{for(let s=e.length-1;s>=0;s--)t=sr(e[s],t);return t}}}function so(e){const t=tr(e.basepath),s=`/${t}`,n=`${s}/`,r=e.caseSensitive?s:s.toLowerCase(),i=e.caseSensitive?n:n.toLowerCase();return{input:({url:o})=>{const a=e.caseSensitive?o.pathname:o.pathname.toLowerCase();return a===r?o.pathname="/":a.startsWith(i)&&(o.pathname=o.pathname.slice(s.length)),o},output:({url:o})=>(o.pathname=ht(["/",t,o.pathname]),o)}}function ns(e,t){const s=e?.input?.({url:t});if(s){if(typeof s=="string")return new URL(s);if(s instanceof URL)return s}return t}function sr(e,t){const s=e?.output?.({url:t});if(s){if(typeof s=="string")return new URL(s);if(s instanceof URL)return s}return t}function no(e,t){const{createMutableStore:s,createReadonlyStore:n,batch:r,init:i}=t,o=new Map,a=new Map,u=new Map,l=s(e.status),h=s(e.loadedAt),d=s(e.isLoading),c=s(e.isTransitioning),f=s(e.location),g=s(e.resolvedLocation),p=s(e.statusCode),v=s(e.redirect),m=s([]),y=s([]),C=s([]),S=n(()=>Vt(o,m.get())),w=n(()=>Vt(a,y.get())),P=n(()=>Vt(u,C.get())),b=n(()=>m.get()[0]),I=n(()=>m.get().some(Y=>o.get(Y)?.get().status==="pending")),_=n(()=>({locationHref:f.get().href,resolvedLocationHref:g.get()?.href,status:l.get()})),x=n(()=>({status:l.get(),loadedAt:h.get(),isLoading:d.get(),isTransitioning:c.get(),matches:S.get(),location:f.get(),resolvedLocation:g.get(),statusCode:p.get(),redirect:v.get()})),M=tt(64);function k(Y){let Ve=M.get(Y);return Ve||(Ve=n(()=>{const xs=m.get();for(const Es of xs){const nt=o.get(Es);if(nt&&nt.routeId===Y)return nt.get()}}),M.set(Y,Ve)),Ve}const F={status:l,loadedAt:h,isLoading:d,isTransitioning:c,location:f,resolvedLocation:g,statusCode:p,redirect:v,matchesId:m,pendingIds:y,cachedIds:C,matches:S,pendingMatches:w,cachedMatches:P,firstId:b,hasPending:I,matchRouteDeps:_,matchStores:o,pendingMatchStores:a,cachedMatchStores:u,__store:x,getRouteMatchStore:k,setMatches:J,setPending:B,setCached:oe};J(e.matches),i?.(F);function J(Y){Bt(Y,o,m,s,r)}function B(Y){Bt(Y,a,y,s,r)}function oe(Y){Bt(Y,u,C,s,r)}return F}function Vt(e,t){const s=[];for(const n of t){const r=e.get(n);r&&s.push(r.get())}return s}function Bt(e,t,s,n,r){const i=e.map(a=>a.id),o=new Set(i);r(()=>{for(const a of t.keys())o.has(a)||t.delete(a);for(const a of e){const u=t.get(a.id);if(!u){const l=n(a);l.routeId=a.routeId,t.set(a.id,l);continue}u.routeId=a.routeId,u.get()!==a&&u.set(a)}Ei(s.get(),i)||s.set(i)})}var rs=e=>{if(!e.rendered)return e.rendered=!0,e.onReady?.()},ro=e=>e.stores.matchesId.get().some(t=>e.stores.matchStores.get(t)?.get()._forcePending),Pt=(e,t)=>!!(e.preload&&!e.router.stores.matchStores.has(t)),be=(e,t,s=!0)=>{const n={...e.router.options.context??{}},r=s?t:t-1;for(let i=0;i<=r;i++){const o=e.matches[i];if(!o)continue;const a=e.router.getMatch(o.id);a&&Object.assign(n,a.__routeContext,a.__beforeLoadContext)}return n},un=(e,t)=>{if(!e.matches.length)return;const s=t.routeId,n=e.matches.findIndex(o=>o.routeId===e.router.routeTree.id),r=n>=0?n:0;let i=s?e.matches.findIndex(o=>o.routeId===s):e.firstBadMatchIndex??e.matches.length-1;i<0&&(i=r);for(let o=i;o>=0;o--){const a=e.matches[o];if(e.router.looseRoutesById[a.routeId].options.notFoundComponent)return o}return s?i:r},ue=(e,t,s)=>{if(!(!W(s)&&!H(s)))throw W(s)&&s.redirectHandled&&!s.options.reloadDocument||(t&&(t._nonReactive.beforeLoadPromise?.resolve(),t._nonReactive.loaderPromise?.resolve(),t._nonReactive.beforeLoadPromise=void 0,t._nonReactive.loaderPromise=void 0,t._nonReactive.error=s,e.updateMatch(t.id,n=>({...n,status:W(s)?"redirected":H(s)?"notFound":n.status==="pending"?"success":n.status,context:be(e,t.index),isFetching:!1,error:s})),H(s)&&!s.routeId&&(s.routeId=t.routeId),t._nonReactive.loadPromise?.resolve()),W(s)&&(e.rendered=!0,s.options._fromLocation=e.location,s.redirectHandled=!0,s=e.router.resolveRedirect(s))),s},nr=(e,t)=>{const s=e.router.getMatch(t);return!!(!s||s._nonReactive.dehydrated)},cn=(e,t,s)=>{const n=be(e,s);e.updateMatch(t,r=>({...r,context:n}))},We=(e,t,s,n)=>{const{id:r,routeId:i}=e.matches[t],o=e.router.looseRoutesById[i];if(s instanceof Promise)throw s;s.routerCode=n,e.firstBadMatchIndex??=t,ue(e,e.router.getMatch(r),s);try{o.options.onError?.(s)}catch(a){s=a,ue(e,e.router.getMatch(r),s)}e.updateMatch(r,a=>(a._nonReactive.beforeLoadPromise?.resolve(),a._nonReactive.beforeLoadPromise=void 0,a._nonReactive.loadPromise?.resolve(),{...a,error:s,status:"error",isFetching:!1,updatedAt:Date.now(),abortController:new AbortController})),!e.preload&&!W(s)&&!H(s)&&(e.serialError??=s)};var rr=(e,t,s,n)=>{if(n._nonReactive.pendingTimeout!==void 0)return;const r=s.options.pendingMs??e.router.options.defaultPendingMs;if(e.onReady&&!Pt(e,t)&&(s.options.loader||s.options.beforeLoad||or(s))&&typeof r=="number"&&r!==1/0&&(s.options.pendingComponent??e.router.options?.defaultPendingComponent)){const i=setTimeout(()=>{rs(e)},r);n._nonReactive.pendingTimeout=i}},io=(e,t,s)=>{const n=e.router.getMatch(t);if(!n._nonReactive.beforeLoadPromise&&!n._nonReactive.loaderPromise)return;rr(e,t,s,n);const r=()=>{const i=e.router.getMatch(t);i.preload&&(i.status==="redirected"||i.status==="notFound")&&ue(e,i,i.error)};return n._nonReactive.beforeLoadPromise?n._nonReactive.beforeLoadPromise.then(r):r()},oo=(e,t,s,n)=>{const r=e.router.getMatch(t);let i=r._nonReactive.loadPromise;r._nonReactive.loadPromise=De(()=>{i?.resolve(),i=void 0});const{paramsError:o,searchError:a}=r;o&&We(e,s,o,"PARSE_PARAMS"),a&&We(e,s,a,"VALIDATE_SEARCH"),rr(e,t,n,r);const u=new AbortController;let l=!1;const h=()=>{l||(l=!0,e.updateMatch(t,S=>({...S,isFetching:"beforeLoad",fetchCount:S.fetchCount+1,abortController:u})))},d=()=>{r._nonReactive.beforeLoadPromise?.resolve(),r._nonReactive.beforeLoadPromise=void 0,e.updateMatch(t,S=>({...S,isFetching:!1}))};if(!n.options.beforeLoad){e.router.batch(()=>{h(),d()});return}r._nonReactive.beforeLoadPromise=De();const c={...be(e,s,!1),...r.__routeContext},{search:f,params:g,cause:p}=r,v=Pt(e,t),m={search:f,abortController:u,params:g,preload:v,context:c,location:e.location,navigate:S=>e.router.navigate({...S,_fromLocation:e.location}),buildLocation:e.router.buildLocation,cause:v?"preload":p,matches:e.matches,routeId:n.id,...e.router.options.additionalContext},y=S=>{if(S===void 0){e.router.batch(()=>{h(),d()});return}(W(S)||H(S))&&(h(),We(e,s,S,"BEFORE_LOAD")),e.router.batch(()=>{h(),e.updateMatch(t,w=>({...w,__beforeLoadContext:S})),d()})};let C;try{if(C=n.options.beforeLoad(m),et(C))return h(),C.catch(S=>{We(e,s,S,"BEFORE_LOAD")}).then(y)}catch(S){h(),We(e,s,S,"BEFORE_LOAD")}y(C)},ao=(e,t)=>{const{id:s,routeId:n}=e.matches[t],r=e.router.looseRoutesById[n],i=()=>a(),o=()=>oo(e,s,t,r),a=()=>{if(nr(e,s))return;const u=io(e,s,r);return et(u)?u.then(o):o()};return i()},lo=(e,t,s)=>{const n=e.router.getMatch(t);if(!n||!s.options.head&&!s.options.scripts&&!s.options.headers)return;const r={ssr:e.router.options.ssr,matches:e.matches,match:n,params:n.params,loaderData:n.loaderData};return Promise.all([s.options.head?.(r),s.options.scripts?.(r),s.options.headers?.(r)]).then(([i,o,a])=>({meta:i?.meta,links:i?.links,headScripts:i?.scripts,headers:a,scripts:o,styles:i?.styles}))},ir=(e,t,s,n,r)=>{const i=t[n-1],{params:o,loaderDeps:a,abortController:u,cause:l}=e.router.getMatch(s),h=be(e,n),d=Pt(e,s);return{params:o,deps:a,preload:!!d,parentMatchPromise:i,abortController:u,context:h,location:e.location,navigate:c=>e.router.navigate({...c,_fromLocation:e.location}),cause:d?"preload":l,route:r,...e.router.options.additionalContext}},dn=async(e,t,s,n,r)=>{try{const i=e.router.getMatch(s);try{st(r);const o=r.options.loader,a=typeof o=="function"?o:o?.handler,u=a?.(ir(e,t,s,n,r)),l=!!a&&et(u);if((l||r._lazyPromise||r._componentsPromise||r.options.head||r.options.scripts||r.options.headers||i._nonReactive.minPendingPromise)&&e.updateMatch(s,d=>({...d,isFetching:"loader"})),a){const d=l?await u:u;ue(e,e.router.getMatch(s),d),d!==void 0&&e.updateMatch(s,c=>({...c,loaderData:d}))}r._lazyPromise&&await r._lazyPromise;const h=i._nonReactive.minPendingPromise;h&&await h,r._componentsPromise&&await r._componentsPromise,e.updateMatch(s,d=>({...d,error:void 0,context:be(e,n),status:"success",isFetching:!1,updatedAt:Date.now()}))}catch(o){let a=o;if(a?.name==="AbortError"){if(i.abortController.signal.aborted){i._nonReactive.loaderPromise?.resolve(),i._nonReactive.loaderPromise=void 0;return}e.updateMatch(s,l=>({...l,status:l.status==="pending"?"success":l.status,isFetching:!1,context:be(e,n)}));return}const u=i._nonReactive.minPendingPromise;u&&await u,H(o)&&await r.options.notFoundComponent?.preload?.(),ue(e,e.router.getMatch(s),o);try{r.options.onError?.(o)}catch(l){a=l,ue(e,e.router.getMatch(s),l)}!W(a)&&!H(a)&&await st(r,["errorComponent"]),e.updateMatch(s,l=>({...l,error:a,context:be(e,n),status:"error",isFetching:!1}))}}catch(i){const o=e.router.getMatch(s);o&&(o._nonReactive.loaderPromise=void 0),ue(e,o,i)}},uo=async(e,t,s)=>{async function n(f,g,p,v,m){const y=Date.now()-g.updatedAt,C=f?m.options.preloadStaleTime??e.router.options.defaultPreloadStaleTime??3e4:m.options.staleTime??e.router.options.defaultStaleTime??0,S=m.options.shouldReload,w=typeof S=="function"?S(ir(e,t,r,s,m)):S,{status:P,invalid:b}=v,I=y>=C&&(!!e.forceStaleReload||v.cause==="enter"||p!==void 0&&p!==v.id);o=P==="success"&&(b||(w??I)),f&&m.options.preload===!1||(o&&!e.sync&&h?(a=!0,(async()=>{try{await dn(e,t,r,s,m);const _=e.router.getMatch(r);_._nonReactive.loaderPromise?.resolve(),_._nonReactive.loadPromise?.resolve(),_._nonReactive.loaderPromise=void 0,_._nonReactive.loadPromise=void 0}catch(_){W(_)&&await e.router.navigate(_.options)}})()):P!=="success"||o?await dn(e,t,r,s,m):cn(e,r,s))}const{id:r,routeId:i}=e.matches[s];let o=!1,a=!1;const u=e.router.looseRoutesById[i],l=u.options.loader,h=((typeof l=="function"?void 0:l?.staleReloadMode)??e.router.options.defaultStaleReloadMode)!=="blocking";if(nr(e,r)){if(!e.router.getMatch(r))return e.matches[s];cn(e,r,s)}else{const f=e.router.getMatch(r),g=e.router.stores.matchesId.get()[s],p=(g&&e.router.stores.matchStores.get(g)||null)?.routeId===i?g:e.router.stores.matches.get().find(m=>m.routeId===i)?.id,v=Pt(e,r);if(f._nonReactive.loaderPromise){if(f.status==="success"&&!e.sync&&!f.preload&&h)return f;await f._nonReactive.loaderPromise;const m=e.router.getMatch(r),y=m._nonReactive.error||m.error;y&&ue(e,m,y),m.status==="pending"&&await n(v,f,p,m,u)}else{const m=v&&!e.router.stores.matchStores.has(r),y=e.router.getMatch(r);y._nonReactive.loaderPromise=De(),m!==y.preload&&e.updateMatch(r,C=>({...C,preload:m})),await n(v,f,p,y,u)}}const d=e.router.getMatch(r);a||(d._nonReactive.loaderPromise?.resolve(),d._nonReactive.loadPromise?.resolve(),d._nonReactive.loadPromise=void 0),clearTimeout(d._nonReactive.pendingTimeout),d._nonReactive.pendingTimeout=void 0,a||(d._nonReactive.loaderPromise=void 0),d._nonReactive.dehydrated=void 0;const c=a?d.isFetching:!1;return c!==d.isFetching||d.invalid!==!1?(e.updateMatch(r,f=>({...f,isFetching:c,invalid:!1})),e.router.getMatch(r)):d};async function hn(e){const t=e,s=[];ro(t.router)&&rs(t);let n;for(let c=0;c<t.matches.length;c++){try{const f=ao(t,c);et(f)&&await f}catch(f){if(W(f))throw f;if(H(f))n=f;else if(!t.preload)throw f;break}if(t.serialError||t.firstBadMatchIndex!=null)break}const r=t.firstBadMatchIndex??t.matches.length,i=n&&!t.preload?un(t,n):void 0,o=n&&t.preload?0:i!==void 0?Math.min(i+1,r):r;let a,u;for(let c=0;c<o;c++)s.push(uo(t,s,c));try{await Promise.all(s)}catch{const c=await Promise.allSettled(s);for(const f of c){if(f.status!=="rejected")continue;const g=f.reason;if(W(g))throw g;H(g)?a??=g:u??=g}if(u!==void 0)throw u}const l=a??(n&&!t.preload?n:void 0);let h=t.firstBadMatchIndex!==void 0?t.firstBadMatchIndex:t.matches.length-1;if(!l&&n&&t.preload)return t.matches;if(l){const c=un(t,l);c===void 0&&ie();const f=t.matches[c],g=t.router.looseRoutesById[f.routeId],p=t.router.options?.defaultNotFoundComponent;!g.options.notFoundComponent&&p&&(g.options.notFoundComponent=p),l.routeId=f.routeId;const v=f.routeId===t.router.routeTree.id;t.updateMatch(f.id,m=>({...m,...v?{status:"success",globalNotFound:!0,error:void 0}:{status:"notFound",error:l},isFetching:!1})),h=c,await st(g,["notFoundComponent"])}else if(!t.preload){const c=t.matches[0];c.globalNotFound||t.router.getMatch(c.id)?.globalNotFound&&t.updateMatch(c.id,f=>({...f,globalNotFound:!1,error:void 0}))}if(t.serialError&&t.firstBadMatchIndex!==void 0){const c=t.router.looseRoutesById[t.matches[t.firstBadMatchIndex].routeId];await st(c,["errorComponent"])}for(let c=0;c<=h;c++){const{id:f,routeId:g}=t.matches[c],p=t.router.looseRoutesById[g];try{const v=lo(t,f,p);if(v){const m=await v;t.updateMatch(f,y=>({...y,...m}))}}catch(v){console.error(`Error executing head for route ${g}:`,v)}}const d=rs(t);if(et(d)&&await d,l)throw l;if(t.serialError&&!t.preload&&!t.onReady)throw t.serialError;return t.matches}function fn(e,t){const s=t.map(n=>e.options[n]?.preload?.()).filter(Boolean);if(s.length!==0)return Promise.all(s)}function st(e,t=gt){!e._lazyLoaded&&e._lazyPromise===void 0&&(e.lazyFn?e._lazyPromise=e.lazyFn().then(n=>{const{id:r,...i}=n.options;Object.assign(e.options,i),e._lazyLoaded=!0,e._lazyPromise=void 0}):e._lazyLoaded=!0);const s=()=>e._componentsLoaded?void 0:t===gt?(()=>{if(e._componentsPromise===void 0){const n=fn(e,gt);n?e._componentsPromise=n.then(()=>{e._componentsLoaded=!0,e._componentsPromise=void 0}):e._componentsLoaded=!0}return e._componentsPromise})():fn(e,t);return e._lazyPromise?e._lazyPromise.then(s):s()}function or(e){for(const t of gt)if(e.options[t]?.preload)return!0;return!1}var gt=["component","errorComponent","pendingComponent","notFoundComponent"],ge="__TSR_index",gn="popstate",pn="beforeunload";function co(e){let t=e.getLocation();const s=new Set,n=o=>{t=e.getLocation(),s.forEach(a=>a({location:t,action:o}))},r=o=>{e.notifyOnIndexChange??!0?n(o):t=e.getLocation()},i=async({task:o,navigateOpts:a,...u})=>{if(a?.ignoreBlocker??!1){o();return}const l=e.getBlockers?.()??[],h=u.type==="PUSH"||u.type==="REPLACE";if(typeof document<"u"&&l.length&&h)for(const d of l){const c=yt(u.path,u.state);if(await d.blockerFn({currentLocation:t,nextLocation:c,action:u.type})){e.onBlocked?.();return}}o()};return{get location(){return t},get length(){return e.getLength()},subscribers:s,subscribe:o=>(s.add(o),()=>{s.delete(o)}),push:(o,a,u)=>{const l=t.state[ge];a=mn(l+1,a),i({task:()=>{e.pushState(o,a),n({type:"PUSH"})},navigateOpts:u,type:"PUSH",path:o,state:a})},replace:(o,a,u)=>{const l=t.state[ge];a=mn(l,a),i({task:()=>{e.replaceState(o,a),n({type:"REPLACE"})},navigateOpts:u,type:"REPLACE",path:o,state:a})},go:(o,a)=>{i({task:()=>{e.go(o),r({type:"GO",index:o})},navigateOpts:a,type:"GO"})},back:o=>{i({task:()=>{e.back(o?.ignoreBlocker??!1),r({type:"BACK"})},navigateOpts:o,type:"BACK"})},forward:o=>{i({task:()=>{e.forward(o?.ignoreBlocker??!1),r({type:"FORWARD"})},navigateOpts:o,type:"FORWARD"})},canGoBack:()=>t.state[ge]!==0,createHref:o=>e.createHref(o),block:o=>{if(!e.setBlockers)return()=>{};const a=e.getBlockers?.()??[];return e.setBlockers([...a,o]),()=>{const u=e.getBlockers?.()??[];e.setBlockers?.(u.filter(l=>l!==o))}},flush:()=>e.flush?.(),destroy:()=>e.destroy?.(),notify:n}}function mn(e,t){t||(t={});const s=ws();return{...t,key:s,__TSR_key:s,[ge]:e}}function ho(e){const t=e?.window??(typeof document<"u"?window:void 0),s=t.history.pushState,n=t.history.replaceState;let r=[];const i=()=>r,o=I=>r=I,a=e?.createHref??(I=>I),u=e?.parseLocation??(()=>yt(`${t.location.pathname}${t.location.search}${t.location.hash}`,t.history.state));if(!t.history.state?.__TSR_key&&!t.history.state?.key){const I=ws();t.history.replaceState({[ge]:0,key:I,__TSR_key:I},"")}let l=u(),h,d=!1,c=!1,f=!1,g=!1;const p=()=>l;let v,m;const y=()=>{v&&(b._ignoreSubscribers=!0,(v.isPush?t.history.pushState:t.history.replaceState)(v.state,"",v.href),b._ignoreSubscribers=!1,v=void 0,m=void 0,h=void 0)},C=(I,_,x)=>{const M=a(_);m||(h=l),l=yt(_,x),v={href:M,state:x,isPush:v?.isPush||I==="push"},m||(m=Promise.resolve().then(()=>y()))},S=I=>{l=u(),b.notify({type:I})},w=async()=>{if(c){c=!1;return}const I=u(),_=I.state[ge]-l.state[ge],x=_===1,M=_===-1,k=!x&&!M||d;d=!1;const F=k?"GO":M?"BACK":"FORWARD",J=k?{type:"GO",index:_}:{type:M?"BACK":"FORWARD"};if(f)f=!1;else{const B=i();if(typeof document<"u"&&B.length){for(const oe of B)if(await oe.blockerFn({currentLocation:l,nextLocation:I,action:F})){c=!0,t.history.go(1),b.notify(J);return}}}l=u(),b.notify(J)},P=I=>{if(g){g=!1;return}let _=!1;const x=i();if(typeof document<"u"&&x.length)for(const M of x){const k=M.enableBeforeUnload??!0;if(k===!0){_=!0;break}if(typeof k=="function"&&k()===!0){_=!0;break}}if(_)return I.preventDefault(),I.returnValue=""},b=co({getLocation:p,getLength:()=>t.history.length,pushState:(I,_)=>C("push",I,_),replaceState:(I,_)=>C("replace",I,_),back:I=>(I&&(f=!0),g=!0,t.history.back()),forward:I=>{I&&(f=!0),g=!0,t.history.forward()},go:I=>{d=!0,t.history.go(I)},createHref:I=>a(I),flush:y,destroy:()=>{t.history.pushState=s,t.history.replaceState=n,t.removeEventListener(pn,P,{capture:!0}),t.removeEventListener(gn,w)},onBlocked:()=>{h&&l!==h&&(l=h)},getBlockers:i,setBlockers:o,notifyOnIndexChange:!1});return t.addEventListener(pn,P,{capture:!0}),t.addEventListener(gn,w),t.history.pushState=function(...I){const _=s.apply(t.history,I);return b._ignoreSubscribers||S("PUSH"),_},t.history.replaceState=function(...I){const _=n.apply(t.history,I);return b._ignoreSubscribers||S("REPLACE"),_},b}function fo(e){let t=e.replace(/[\x00-\x1f\x7f]/g,"");return t.startsWith("//")&&(t="/"+t.replace(/^\/+/,"")),t}function yt(e,t){const s=fo(e),n=s.indexOf("#"),r=s.indexOf("?"),i=ws();return{href:s,pathname:s.substring(0,n>0?r>0?Math.min(n,r):n:r>0?r:s.length),hash:n>-1?s.substring(n):"",search:r>-1?s.slice(r,n===-1?void 0:n):"",state:t||{[ge]:0,key:i,__TSR_key:i}}}function ws(){return(Math.random()+1).toString(36).substring(7)}function Ae(e,t){const s=t,n=e;return{fromLocation:s,toLocation:n,pathChanged:s?.pathname!==n.pathname,hrefChanged:s?.href!==n.href,hashChanged:s?.hash!==n.hash}}var go=class{constructor(e,t){this.tempLocationKey=`${Math.round(Math.random()*1e7)}`,this.resetNextScroll=!0,this.shouldViewTransition=void 0,this.isViewTransitionTypesSupported=void 0,this.subscribers=new Set,this.isScrollRestoring=!1,this.isScrollRestorationSetup=!1,this.startTransition=s=>s(),this.update=s=>{const n=this.options,r=this.basepath??n?.basepath??"/",i=this.basepath===void 0,o=n?.rewrite;if(this.options={...n,...s},this.isServer=this.options.isServer??typeof document>"u",this.protocolAllowlist=new Set(this.options.protocolAllowlist),this.options.pathParamsAllowedCharacters&&(this.pathParamsDecoder=zi(this.options.pathParamsAllowedCharacters)),(!this.history||this.options.history&&this.options.history!==this.history)&&(this.options.history?this.history=this.options.history:this.history=ho()),this.origin=this.options.origin,this.origin||(window?.origin&&window.origin!=="null"?this.origin=window.origin:this.origin="http://localhost"),this.history&&this.updateLatestLocation(),this.options.routeTree!==this.routeTree){this.routeTree=this.options.routeTree;let h;this.resolvePathCache=tt(1e3),h=this.buildRouteTree(),this.setRoutes(h)}if(!this.stores&&this.latestLocation){const h=this.getStoreConfig(this);this.batch=h.batch,this.stores=no(mo(this.latestLocation),h),Wi(this)}let a=!1;const u=this.options.basepath??"/",l=this.options.rewrite;if(i||r!==u||o!==l){this.basepath=u;const h=[],d=tr(u);d&&d!=="/"&&h.push(so({basepath:u})),l&&h.push(l),this.rewrite=h.length===0?void 0:h.length===1?h[0]:to(h),this.history&&this.updateLatestLocation(),a=!0}a&&this.stores&&this.stores.location.set(this.latestLocation),typeof window<"u"&&"CSS"in window&&typeof window.CSS?.supports=="function"&&(this.isViewTransitionTypesSupported=window.CSS.supports("selector(:active-view-transition-type(a)"))},this.updateLatestLocation=()=>{this.latestLocation=this.parseLocation(this.history.location,this.latestLocation)},this.buildRouteTree=()=>{const s=Di(this.routeTree,this.options.caseSensitive,(n,r)=>{n.init({originalIndex:r})});return this.options.routeMasks&&Ti(this.options.routeMasks,s.processedTree),s},this.subscribe=(s,n)=>{const r={eventType:s,fn:n};return this.subscribers.add(r),()=>{this.subscribers.delete(r)}},this.emit=s=>{this.subscribers.forEach(n=>{n.eventType===s.type&&n.fn(s)})},this.parseLocation=(s,n)=>{const r=({pathname:u,search:l,hash:h,href:d,state:c})=>{if(!this.rewrite&&!/[ \x00-\x1f\x7f\u0080-\uffff]/.test(u)){const m=this.options.parseSearch(l),y=this.options.stringifySearch(m);return{href:u+y+h,publicHref:u+y+h,pathname:je(u).path,external:!1,searchStr:y,search:Se(n?.search,m),hash:je(h.slice(1)).path,state:le(n?.state,c)}}const f=new URL(d,this.origin),g=ns(this.rewrite,f),p=this.options.parseSearch(g.search),v=this.options.stringifySearch(p);return g.search=v,{href:g.href.replace(g.origin,""),publicHref:d,pathname:je(g.pathname).path,external:!!this.rewrite&&g.origin!==this.origin,searchStr:v,search:Se(n?.search,p),hash:je(g.hash.slice(1)).path,state:le(n?.state,c)}},i=r(s),{__tempLocation:o,__tempKey:a}=i.state;if(o&&(!a||a===this.tempLocationKey)){const u=r(o);return u.state.key=i.state.key,u.state.__TSR_key=i.state.__TSR_key,delete u.state.__tempLocation,{...u,maskedLocation:i}}return i},this.resolvePathWithBase=(s,n)=>Bi({base:s,to:Rs(n),trailingSlash:this.options.trailingSlash,cache:this.resolvePathCache}),this.matchRoutes=(s,n,r)=>typeof s=="string"?this.matchRoutesInternal({pathname:s,search:n},r):this.matchRoutesInternal(s,n),this.getMatchedRoutes=s=>vo({pathname:s,routesById:this.routesById,processedTree:this.processedTree}),this.cancelMatch=s=>{const n=this.getMatch(s);n&&(n.abortController.abort(),clearTimeout(n._nonReactive.pendingTimeout),n._nonReactive.pendingTimeout=void 0)},this.cancelMatches=()=>{this.stores.pendingIds.get().forEach(s=>{this.cancelMatch(s)}),this.stores.matchesId.get().forEach(s=>{if(this.stores.pendingMatchStores.has(s))return;const n=this.stores.matchStores.get(s)?.get();n&&(n.status==="pending"||n.isFetching==="loader")&&this.cancelMatch(s)})},this.buildLocation=s=>{const n=(i={})=>{const o=i._fromLocation||this.pendingBuiltLocation||this.latestLocation,a=this.matchRoutesLightweight(o);i.from;const u=i.unsafeRelative==="path"?o.pathname:i.from??a.fullPath,l=this.resolvePathWithBase(u,"."),h=a.search,d=Object.assign(Object.create(null),a.params),c=i.to?this.resolvePathWithBase(l,`${i.to}`):this.resolvePathWithBase(l,"."),f=i.params===!1||i.params===null?Object.create(null):(i.params??!0)===!0?d:Object.assign(d,ne(i.params,d)),g=this.getMatchedRoutes(c);let p=g.matchedRoutes;if((!g.foundRoute||g.foundRoute.path!=="/"&&g.routeParams["**"])&&this.options.notFoundRoute&&(p=[...p,this.options.notFoundRoute]),Object.keys(f).length>0)for(const x of p){const M=x.options.params?.stringify??x.options.stringifyParams;if(M)try{Object.assign(f,M(f))}catch{}}const v=s.leaveParams?c:je(rn({path:c,params:f,decoder:this.pathParamsDecoder,server:this.isServer}).interpolatedPath).path;let m=h;if(s._includeValidateSearch&&this.options.search?.strict){const x={};p.forEach(M=>{if(M.options.validateSearch)try{Object.assign(x,pt(M.options.validateSearch,{...x,...m}))}catch{}}),m=x}m=So({search:m,dest:i,destRoutes:p,_includeValidateSearch:s._includeValidateSearch}),m=Se(h,m);const y=this.options.stringifySearch(m),C=i.hash===!0?o.hash:i.hash?ne(i.hash,o.hash):void 0,S=C?`#${C}`:"";let w=i.state===!0?o.state:i.state?ne(i.state,o.state):{};w=le(o.state,w);const P=`${v}${y}${S}`;let b,I,_=!1;if(this.rewrite){const x=new URL(P,this.origin),M=sr(this.rewrite,x);b=x.href.replace(x.origin,""),M.origin!==this.origin?(I=M.href,_=!0):I=M.pathname+M.search+M.hash}else b=xi(P),I=b;return{publicHref:I,href:b,pathname:v,search:m,searchStr:y,state:w,hash:C??"",external:_,unmaskOnReload:i.unmaskOnReload}},r=(i={},o)=>{const a=n(i);let u=o?n(o):void 0;if(!u){const l=Object.create(null);if(this.options.routeMasks){const h=Oi(a.pathname,this.processedTree);if(h){Object.assign(l,h.rawParams);const{from:d,params:c,...f}=h.route,g=c===!1||c===null?Object.create(null):(c??!0)===!0?l:Object.assign(l,ne(c,l));o={from:s.from,...f,params:g},u=n(o)}}}return u&&(a.maskedLocation=u),a};return s.mask?r(s,{from:s.from,...s.mask}):r(s)},this.commitLocation=async({viewTransition:s,ignoreBlocker:n,...r})=>{const i=()=>{const u=["key","__TSR_key","__TSR_index","__hashScrollIntoViewOptions"];u.forEach(h=>{r.state[h]=this.latestLocation.state[h]});const l=he(r.state,this.latestLocation.state);return u.forEach(h=>{delete r.state[h]}),l},o=fe(this.latestLocation.href)===fe(r.href);let a=this.commitLocationPromise;if(this.commitLocationPromise=De(()=>{a?.resolve(),a=void 0}),o&&i())this.load();else{let{maskedLocation:u,hashScrollIntoView:l,...h}=r;u&&(h={...u,state:{...u.state,__tempKey:void 0,__tempLocation:{...h,search:h.searchStr,state:{...h.state,__tempKey:void 0,__tempLocation:void 0,__TSR_key:void 0,key:void 0}}}},(h.unmaskOnReload??this.options.unmaskOnReload??!1)&&(h.state.__tempKey=this.tempLocationKey)),h.state.__hashScrollIntoViewOptions=l??this.options.defaultHashScrollIntoView??!0,this.shouldViewTransition=s,this.history[r.replace?"replace":"push"](h.publicHref,h.state,{ignoreBlocker:n})}return this.resetNextScroll=r.resetScroll??!0,this.history.subscribers.size||this.load(),this.commitLocationPromise},this.buildAndCommitLocation=({replace:s,resetScroll:n,hashScrollIntoView:r,viewTransition:i,ignoreBlocker:o,href:a,...u}={})=>{if(a){const d=this.history.location.state.__TSR_index,c=yt(a,{__TSR_index:s?d:d+1}),f=new URL(c.pathname,this.origin);u.to=ns(this.rewrite,f).pathname,u.search=this.options.parseSearch(c.search),u.hash=c.hash.slice(1)}const l=this.buildLocation({...u,_includeValidateSearch:!0});this.pendingBuiltLocation=l;const h=this.commitLocation({...l,viewTransition:i,replace:s,resetScroll:n,hashScrollIntoView:r,ignoreBlocker:o});return Promise.resolve().then(()=>{this.pendingBuiltLocation===l&&(this.pendingBuiltLocation=void 0)}),h},this.navigate=async({to:s,reloadDocument:n,href:r,publicHref:i,...o})=>{let a=!1;if(r)try{new URL(`${r}`),a=!0}catch{}if(a&&!n&&(n=!0),n){if(s!==void 0||!r){const l=this.buildLocation({to:s,...o});r=r??l.publicHref,i=i??l.publicHref}const u=!a&&i?i:r;if(ye(u,this.protocolAllowlist))return Promise.resolve();if(!o.ignoreBlocker){const l=this.history.getBlockers?.()??[];for(const h of l)if(h?.blockerFn&&await h.blockerFn({currentLocation:this.latestLocation,nextLocation:this.latestLocation,action:"PUSH"}))return Promise.resolve()}return o.replace?window.location.replace(u):window.location.href=u,Promise.resolve()}return this.buildAndCommitLocation({...o,href:r,to:s,_isNavigate:!0})},this.beforeLoad=()=>{this.cancelMatches(),this.updateLatestLocation();const s=this.matchRoutes(this.latestLocation),n=this.stores.cachedMatches.get().filter(r=>!s.some(i=>i.id===r.id));this.batch(()=>{this.stores.status.set("pending"),this.stores.statusCode.set(200),this.stores.isLoading.set(!0),this.stores.location.set(this.latestLocation),this.stores.setPending(s),this.stores.setCached(n)})},this.load=async s=>{let n,r,i;const o=this.stores.resolvedLocation.get()??this.stores.location.get();for(i=new Promise(u=>{this.startTransition(async()=>{try{this.beforeLoad();const l=this.latestLocation,h=Ae(l,this.stores.resolvedLocation.get());this.stores.redirect.get()||this.emit({type:"onBeforeNavigate",...h}),this.emit({type:"onBeforeLoad",...h}),await hn({router:this,sync:s?.sync,forceStaleReload:o.href===l.href,matches:this.stores.pendingMatches.get(),location:l,updateMatch:this.updateMatch,onReady:async()=>{this.startTransition(()=>{this.startViewTransition(async()=>{let d=null,c=null,f=null,g=null;this.batch(()=>{const p=this.stores.pendingMatches.get(),v=p.length,m=this.stores.matches.get();d=v?m.filter(S=>!this.stores.pendingMatchStores.has(S.id)):null;const y=new Set;for(const S of this.stores.pendingMatchStores.values())S.routeId&&y.add(S.routeId);const C=new Set;for(const S of this.stores.matchStores.values())S.routeId&&C.add(S.routeId);c=v?m.filter(S=>!y.has(S.routeId)):null,f=v?p.filter(S=>!C.has(S.routeId)):null,g=v?p.filter(S=>C.has(S.routeId)):m,this.stores.isLoading.set(!1),this.stores.loadedAt.set(Date.now()),v&&(this.stores.setMatches(p),this.stores.setPending([]),this.stores.setCached([...this.stores.cachedMatches.get(),...d.filter(S=>S.status!=="error"&&S.status!=="notFound"&&S.status!=="redirected")]),this.clearExpiredCache())});for(const[p,v]of[[c,"onLeave"],[f,"onEnter"],[g,"onStay"]])if(p)for(const m of p)this.looseRoutesById[m.routeId].options[v]?.(m)})})}})}catch(l){W(l)?(n=l,this.navigate({...n.options,replace:!0,ignoreBlocker:!0})):H(l)&&(r=l);const h=n?n.status:r?404:this.stores.matches.get().some(d=>d.status==="error")?500:200;this.batch(()=>{this.stores.statusCode.set(h),this.stores.redirect.set(n)})}this.latestLoadPromise===i&&(this.commitLocationPromise?.resolve(),this.latestLoadPromise=void 0,this.commitLocationPromise=void 0),u()})}),this.latestLoadPromise=i,await i;this.latestLoadPromise&&i!==this.latestLoadPromise;)await this.latestLoadPromise;let a;this.hasNotFoundMatch()?a=404:this.stores.matches.get().some(u=>u.status==="error")&&(a=500),a!==void 0&&this.stores.statusCode.set(a)},this.startViewTransition=s=>{const n=this.shouldViewTransition??this.options.defaultViewTransition;if(this.shouldViewTransition=void 0,n&&typeof document<"u"&&"startViewTransition"in document&&typeof document.startViewTransition=="function"){let r;if(typeof n=="object"&&this.isViewTransitionTypesSupported){const i=this.latestLocation,o=this.stores.resolvedLocation.get(),a=typeof n.types=="function"?n.types(Ae(i,o)):n.types;if(a===!1){s();return}r={update:s,types:a}}else r=s;document.startViewTransition(r)}else s()},this.updateMatch=(s,n)=>{this.startTransition(()=>{const r=this.stores.pendingMatchStores.get(s);if(r){r.set(n);return}const i=this.stores.matchStores.get(s);if(i){i.set(n);return}const o=this.stores.cachedMatchStores.get(s);if(o){const a=n(o.get());a.status==="redirected"?this.stores.cachedMatchStores.delete(s)&&this.stores.cachedIds.set(u=>u.filter(l=>l!==s)):o.set(a)}})},this.getMatch=s=>this.stores.cachedMatchStores.get(s)?.get()??this.stores.pendingMatchStores.get(s)?.get()??this.stores.matchStores.get(s)?.get(),this.invalidate=s=>{const n=r=>s?.filter?.(r)??!0?{...r,invalid:!0,...s?.forcePending||r.status==="error"||r.status==="notFound"?{status:"pending",error:void 0}:void 0}:r;return this.batch(()=>{this.stores.setMatches(this.stores.matches.get().map(n)),this.stores.setCached(this.stores.cachedMatches.get().map(n)),this.stores.setPending(this.stores.pendingMatches.get().map(n))}),this.shouldViewTransition=!1,this.load({sync:s?.sync})},this.getParsedLocationHref=s=>s.publicHref||"/",this.resolveRedirect=s=>{const n=s.headers.get("Location");if(!s.options.href||s.options._builtLocation){const r=s.options._builtLocation??this.buildLocation(s.options),i=this.getParsedLocationHref(r);s.options.href=i,s.headers.set("Location",i)}else if(n)try{const r=new URL(n);if(this.origin&&r.origin===this.origin){const i=r.pathname+r.search+r.hash;s.options.href=i,s.headers.set("Location",i)}}catch{}if(s.options.href&&!s.options._builtLocation&&ye(s.options.href,this.protocolAllowlist))throw new Error("Redirect blocked: unsafe protocol");return s.headers.get("Location")||s.headers.set("Location",s.options.href),s},this.clearCache=s=>{const n=s?.filter;n!==void 0?this.stores.setCached(this.stores.cachedMatches.get().filter(r=>!n(r))):this.stores.setCached([])},this.clearExpiredCache=()=>{const s=Date.now(),n=r=>{const i=this.looseRoutesById[r.routeId];if(!i.options.loader)return!0;const o=(r.preload?i.options.preloadGcTime??this.options.defaultPreloadGcTime:i.options.gcTime??this.options.defaultGcTime)??300*1e3;return r.status==="error"?!0:s-r.updatedAt>=o};this.clearCache({filter:n})},this.loadRouteChunk=st,this.preloadRoute=async s=>{const n=s._builtLocation??this.buildLocation(s);let r=this.matchRoutes(n,{throwOnError:!0,preload:!0,dest:s});const i=new Set([...this.stores.matchesId.get(),...this.stores.pendingIds.get()]),o=new Set([...i,...this.stores.cachedIds.get()]),a=r.filter(u=>!o.has(u.id));if(a.length){const u=this.stores.cachedMatches.get();this.stores.setCached([...u,...a])}try{return r=await hn({router:this,matches:r,location:n,preload:!0,updateMatch:(u,l)=>{i.has(u)?r=r.map(h=>h.id===u?l(h):h):this.updateMatch(u,l)}}),r}catch(u){if(W(u))return u.options.reloadDocument?void 0:await this.preloadRoute({...u.options,_fromLocation:n});H(u)||console.error(u);return}},this.matchRoute=(s,n)=>{const r={...s,to:s.to?this.resolvePathWithBase(s.from||"",s.to):void 0,params:s.params||{},leaveParams:!0},i=this.buildLocation(r);if(n?.pending&&this.stores.status.get()!=="pending")return!1;const o=(n?.pending===void 0?!this.stores.isLoading.get():n.pending)?this.latestLocation:this.stores.resolvedLocation.get()||this.stores.location.get(),a=Fi(i.pathname,n?.caseSensitive??!1,n?.fuzzy??!1,o.pathname,this.processedTree);return!a||s.params&&!he(a.rawParams,s.params,{partial:!0})?!1:n?.includeSearch??!0?he(o.search,i.search,{partial:!0})?a.rawParams:!1:a.rawParams},this.hasNotFoundMatch=()=>this.stores.matches.get().some(s=>s.status==="notFound"||s.globalNotFound),this.getStoreConfig=t,this.update({defaultPreloadDelay:50,defaultPendingMs:1e3,defaultPendingMinMs:500,context:void 0,...e,caseSensitive:e.caseSensitive??!1,notFoundMode:e.notFoundMode??"fuzzy",stringifySearch:e.stringifySearch??Yi,parseSearch:e.parseSearch??Ji,protocolAllowlist:e.protocolAllowlist??Ii}),typeof document<"u"&&(self.__TSR_ROUTER__=this)}isShell(){return!!this.options.isShell}isPrerendering(){return!!this.options.isPrerendering}get state(){return this.stores.__store.get()}setRoutes({routesById:e,routesByPath:t,processedTree:s}){this.routesById=e,this.routesByPath=t,this.processedTree=s;const n=this.options.notFoundRoute;n&&(n.init({originalIndex:99999999999}),this.routesById[n.id]=n)}get looseRoutesById(){return this.routesById}getParentContext(e){return e?.id?e.context??this.options.context??void 0:this.options.context??void 0}matchRoutesInternal(e,t){const s=this.getMatchedRoutes(e.pathname),{foundRoute:n,routeParams:r,parsedParams:i}=s;let{matchedRoutes:o}=s,a=!1;(n?n.path!=="/"&&r["**"]:fe(e.pathname))&&(this.options.notFoundRoute?o=[...o,this.options.notFoundRoute]:a=!0);const u=a?Co(this.options.notFoundMode,o):void 0,l=new Array(o.length),h=new Map;for(const d of this.stores.matchStores.values())d.routeId&&h.set(d.routeId,d.get());for(let d=0;d<o.length;d++){const c=o[d],f=l[d-1];let g,p,v;{const F=f?.search??e.search,J=f?._strictSearch??void 0;try{const B=pt(c.options.validateSearch,{...F})??void 0;g={...F,...B},p={...J,...B},v=void 0}catch(B){let oe=B;if(B instanceof Ct||(oe=new Ct(B.message,{cause:B})),t?.throwOnError)throw oe;g=F,p={},v=oe}}const m=c.options.loaderDeps?.({search:g})??"",y=m?JSON.stringify(m):"",{interpolatedPath:C,usedParams:S}=rn({path:c.fullPath,params:r,decoder:this.pathParamsDecoder,server:this.isServer}),w=c.id+C+y,P=this.getMatch(w),b=h.get(c.id),I=P?._strictParams??S;let _;if(!P)try{vn(c,S,i,I)}catch(F){if(H(F)||W(F)?_=F:_=new po(F.message,{cause:F}),t?.throwOnError)throw _}Object.assign(r,I);const x=b?"stay":"enter";let M;if(P)M={...P,cause:x,params:b?.params??r,_strictParams:I,search:Se(b?b.search:P.search,g),_strictSearch:p};else{const F=c.options.loader||c.options.beforeLoad||c.lazyFn||or(c)?"pending":"success";M={id:w,ssr:c.options.ssr,index:d,routeId:c.id,params:b?.params??r,_strictParams:I,pathname:C,updatedAt:Date.now(),search:b?Se(b.search,g):g,_strictSearch:p,searchError:void 0,status:F,isFetching:!1,error:void 0,paramsError:_,__routeContext:void 0,_nonReactive:{loadPromise:De()},__beforeLoadContext:void 0,context:{},abortController:new AbortController,fetchCount:0,cause:x,loaderDeps:b?le(b.loaderDeps,m):m,invalid:!1,preload:!1,links:void 0,scripts:void 0,headScripts:void 0,meta:void 0,staticData:c.options.staticData||{},fullPath:c.fullPath}}t?.preload||(M.globalNotFound=u===c.id),M.searchError=v;const k=this.getParentContext(f);M.context={...k,...M.__routeContext,...M.__beforeLoadContext},l[d]=M}for(let d=0;d<l.length;d++){const c=l[d],f=this.looseRoutesById[c.routeId],g=this.getMatch(c.id),p=h.get(c.routeId);if(c.params=p?Se(p.params,r):r,!g){const v=l[d-1],m=this.getParentContext(v);if(f.options.context){const y={deps:c.loaderDeps,params:c.params,context:m??{},location:e,navigate:C=>this.navigate({...C,_fromLocation:e}),buildLocation:this.buildLocation,cause:c.cause,abortController:c.abortController,preload:!!c.preload,matches:l,routeId:f.id};c.__routeContext=f.options.context(y)??void 0}c.context={...m,...c.__routeContext,...c.__beforeLoadContext}}}return l}matchRoutesLightweight(e){const{matchedRoutes:t,routeParams:s,parsedParams:n}=this.getMatchedRoutes(e.pathname),r=Ze(t),i={...e.search};for(const h of t)try{Object.assign(i,pt(h.options.validateSearch,i))}catch{}const o=Ze(this.stores.matchesId.get()),a=o&&this.stores.matchStores.get(o)?.get(),u=a&&a.routeId===r.id&&a.pathname===e.pathname;let l;if(u)l=a.params;else{const h=Object.assign(Object.create(null),s);for(const d of t)try{vn(d,s,n??{},h)}catch{}l=h}return{matchedRoutes:t,fullPath:r.fullPath,search:i,params:l}}},Ct=class extends Error{},po=class extends Error{};function mo(e){return{loadedAt:0,isLoading:!1,isTransitioning:!1,status:"idle",resolvedLocation:void 0,location:e,matches:[],statusCode:200}}function pt(e,t){if(e==null)return{};if("~standard"in e){const s=e["~standard"].validate(t);if(s instanceof Promise)throw new Ct("Async validation not supported");if(s.issues)throw new Ct(JSON.stringify(s.issues,void 0,2),{cause:s});return s.value}return"parse"in e?e.parse(t):typeof e=="function"?e(t):{}}function vo({pathname:e,routesById:t,processedTree:s}){const n=Object.create(null),r=fe(e);let i,o;const a=Ai(r,s,!0);return a&&(i=a.route,Object.assign(n,a.rawParams),o=Object.assign(Object.create(null),a.parsedParams)),{matchedRoutes:a?.branch||[t.__root__],routeParams:n,foundRoute:i,parsedParams:o}}function So({search:e,dest:t,destRoutes:s,_includeValidateSearch:n}){return yo(s)(e,t,n??!1)}function yo(e){const t={dest:null,_includeValidateSearch:!1,middlewares:[]};for(const r of e){if("search"in r.options)r.options.search?.middlewares&&t.middlewares.push(...r.options.search.middlewares);else if(r.options.preSearchFilters||r.options.postSearchFilters){const i=({search:o,next:a})=>{let u=o;"preSearchFilters"in r.options&&r.options.preSearchFilters&&(u=r.options.preSearchFilters.reduce((h,d)=>d(h),o));const l=a(u);return"postSearchFilters"in r.options&&r.options.postSearchFilters?r.options.postSearchFilters.reduce((h,d)=>d(h),l):l};t.middlewares.push(i)}if(r.options.validateSearch){const i=({search:o,next:a})=>{const u=a(o);if(!t._includeValidateSearch)return u;try{return{...u,...pt(r.options.validateSearch,u)??void 0}}catch{return u}};t.middlewares.push(i)}}const s=({search:r})=>{const i=t.dest;return i.search?i.search===!0?r:ne(i.search,r):{}};t.middlewares.push(s);const n=(r,i,o)=>{if(r>=o.length)return i;const a=o[r];return a({search:i,next:l=>n(r+1,l,o)})};return function(i,o,a){return t.dest=o,t._includeValidateSearch=a,n(0,i,t.middlewares)}}function Co(e,t){if(e!=="root")for(let s=t.length-1;s>=0;s--){const n=t[s];if(n.children)return n.id}return ft}function vn(e,t,s,n){const r=e.options.params?.parse??e.options.parseParams;if(r)if(e.options.skipRouteOnParseError)for(const i in t)i in s&&(n[i]=s[i]);else{const i=r(n);Object.assign(n,i)}}var Ro="Error preloading route! ☝️",ar=class{get to(){return this._to}get id(){return this._id}get path(){return this._path}get fullPath(){return this._fullPath}constructor(e){if(this.init=t=>{this.originalIndex=t.originalIndex;const s=this.options,n=!s?.path&&!s?.id;this.parentRoute=this.options.getParentRoute?.(),n?this._path=ft:this.parentRoute||ie();let r=n?ft:s?.path;r&&r!=="/"&&(r=er(r));const i=s?.id||r;let o=n?ft:ht([this.parentRoute.id==="__root__"?"":this.parentRoute.id,i]);r==="__root__"&&(r="/"),o!=="__root__"&&(o=ht(["/",o]));const a=o==="__root__"?"/":ht([this.parentRoute.fullPath,r]);this._path=r,this._id=o,this._fullPath=a,this._to=fe(a)},this.addChildren=t=>this._addFileChildren(t),this._addFileChildren=t=>(Array.isArray(t)&&(this.children=t),typeof t=="object"&&t!==null&&(this.children=Object.values(t)),this),this._addFileTypes=()=>this,this.updateLoader=t=>(Object.assign(this.options,t),this),this.update=t=>(Object.assign(this.options,t),this),this.lazy=t=>(this.lazyFn=t,this),this.redirect=t=>eo({from:this.fullPath,...t}),this.options=e||{},this.isRoot=!e?.getParentRoute,e?.id&&e?.path)throw new Error("Route cannot have both an 'id' and a 'path' option.")}},wo=class extends ar{constructor(e){super(e)}};function bo(e){if(typeof document<"u"&&document.querySelector){const t=e.stores.location.get(),s=t.state.__hashScrollIntoViewOptions??!0;if(s&&t.hash!==""){const n=document.getElementById(t.hash);n&&n.scrollIntoView(s)}}}function bs(e){const t=e.errorComponent??Ps;return(0,E.jsx)(Po,{getResetKey:e.getResetKey,onCatch:e.onCatch,children:({error:s,reset:n})=>s?R.createElement(t,{error:s,reset:n}):e.children})}var Po=class extends R.Component{constructor(...e){super(...e),this.state={error:null}}static getDerivedStateFromProps(e,t){const s=e.getResetKey();return t.error&&t.resetKey!==s?{resetKey:s,error:null}:{resetKey:s}}static getDerivedStateFromError(e){return{error:e}}reset(){this.setState({error:null})}componentDidCatch(e,t){this.props.onCatch&&this.props.onCatch(e,t)}render(){return this.props.children({error:this.state.error,reset:()=>{this.reset()}})}};function Ps({error:e}){const[t,s]=R.useState(!1);return(0,E.jsxs)("div",{style:{padding:".5rem",maxWidth:"100%"},children:[(0,E.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:".5rem"},children:[(0,E.jsx)("strong",{style:{fontSize:"1rem"},children:"Something went wrong!"}),(0,E.jsx)("button",{style:{appearance:"none",fontSize:".6em",border:"1px solid currentColor",padding:".1rem .2rem",fontWeight:"bold",borderRadius:".25rem"},onClick:()=>s(n=>!n),children:t?"Hide Error":"Show Error"})]}),(0,E.jsx)("div",{style:{height:".25rem"}}),t?(0,E.jsx)("div",{children:(0,E.jsx)("pre",{style:{fontSize:".7em",border:"1px solid red",borderRadius:".25rem",padding:".3rem",color:"red",overflow:"auto"},children:e.message?(0,E.jsx)("code",{children:e.message}):null})}):null]})}function Mo({children:e,fallback:t=null}){return lr()?(0,E.jsx)(R.Fragment,{children:e}):(0,E.jsx)(R.Fragment,{children:t})}function lr(){return R.useSyncExternalStore(_o,()=>!0,()=>!1)}function _o(){return()=>{}}var ur=R.createContext(null);function ee(e){return R.useContext(ur)}var Mt=R.createContext(void 0),Io=R.createContext(void 0),D=(e=>(e[e.None=0]="None",e[e.Mutable=1]="Mutable",e[e.Watching=2]="Watching",e[e.RecursedCheck=4]="RecursedCheck",e[e.Recursed=8]="Recursed",e[e.Dirty=16]="Dirty",e[e.Pending=32]="Pending",e))(D||{});function xo({update:e,notify:t,unwatched:s}){return{link:n,unlink:r,propagate:i,checkDirty:o,shallowPropagate:a};function n(l,h,d){const c=h.depsTail;if(c!==void 0&&c.dep===l)return;const f=c!==void 0?c.nextDep:h.deps;if(f!==void 0&&f.dep===l){f.version=d,h.depsTail=f;return}const g=l.subsTail;if(g!==void 0&&g.version===d&&g.sub===h)return;const p=h.depsTail=l.subsTail={version:d,dep:l,sub:h,prevDep:c,nextDep:f,prevSub:g,nextSub:void 0};f!==void 0&&(f.prevDep=p),c!==void 0?c.nextDep=p:h.deps=p,g!==void 0?g.nextSub=p:l.subs=p}function r(l,h=l.sub){const d=l.dep,c=l.prevDep,f=l.nextDep,g=l.nextSub,p=l.prevSub;return f!==void 0?f.prevDep=c:h.depsTail=c,c!==void 0?c.nextDep=f:h.deps=f,g!==void 0?g.prevSub=p:d.subsTail=p,p!==void 0?p.nextSub=g:(d.subs=g)===void 0&&s(d),f}function i(l){let h=l.nextSub,d;e:do{const c=l.sub;let f=c.flags;if(f&60?f&12?f&4?!(f&48)&&u(l,c)?(c.flags=f|40,f&=1):f=0:c.flags=f&-9|32:f=0:c.flags=f|32,f&2&&t(c),f&1){const g=c.subs;if(g!==void 0){const p=(l=g).nextSub;p!==void 0&&(d={value:h,prev:d},h=p);continue}}if((l=h)!==void 0){h=l.nextSub;continue}for(;d!==void 0;)if(l=d.value,d=d.prev,l!==void 0){h=l.nextSub;continue e}break}while(!0)}function o(l,h){let d,c=0,f=!1;e:do{const g=l.dep,p=g.flags;if(h.flags&16)f=!0;else if((p&17)===17){if(e(g)){const v=g.subs;v.nextSub!==void 0&&a(v),f=!0}}else if((p&33)===33){(l.nextSub!==void 0||l.prevSub!==void 0)&&(d={value:l,prev:d}),l=g.deps,h=g,++c;continue}if(!f){const v=l.nextDep;if(v!==void 0){l=v;continue}}for(;c--;){const v=h.subs,m=v.nextSub!==void 0;if(m?(l=d.value,d=d.prev):l=v,f){if(e(h)){m&&a(v),h=l.sub;continue}f=!1}else h.flags&=-33;h=l.sub;const y=l.nextDep;if(y!==void 0){l=y;continue e}}return f}while(!0)}function a(l){do{const h=l.sub,d=h.flags;(d&48)===32&&(h.flags=d|16,(d&6)===2&&t(h))}while((l=l.nextSub)!==void 0)}function u(l,h){let d=h.depsTail;for(;d!==void 0;){if(d===l)return!0;d=d.prevDep}return!1}}function Eo(e,t,s){const n=typeof e=="object",r=n?e:void 0;return{next:(n?e.next:e)?.bind(r),error:(n?e.error:t)?.bind(r),complete:(n?e.complete:s)?.bind(r)}}var is=[],mt=0,{link:Sn,unlink:Lo,propagate:To,checkDirty:cr,shallowPropagate:yn}=xo({update(e){return e._update()},notify(e){is[os++]=e,e.flags&=~D.Watching},unwatched(e){e.depsTail!==void 0&&(e.depsTail=void 0,e.flags=D.Mutable|D.Dirty,Rt(e))}}),lt=0,os=0,se,as=0;function dr(e){try{++as,e()}finally{--as||hr()}}function Rt(e){const t=e.depsTail;let s=t!==void 0?t.nextDep:e.deps;for(;s!==void 0;)s=Lo(s,e)}function hr(){if(!(as>0)){for(;lt<os;){const e=is[lt];is[lt++]=void 0,e.notify()}lt=0,os=0}}function Cn(e,t){const s=typeof e=="function",n=e,r={_snapshot:s?void 0:e,subs:void 0,subsTail:void 0,deps:void 0,depsTail:void 0,flags:s?D.None:D.Mutable,get(){return se!==void 0&&Sn(r,se,mt),r._snapshot},subscribe(i){const o=Eo(i),a={current:!1},u=Oo(()=>{r.get(),a.current?o.next?.(r._snapshot):a.current=!0});return{unsubscribe:()=>{u.stop()}}},_update(i){const o=se,a=t?.compare??Object.is;if(s)se=r,++mt,r.depsTail=void 0;else if(i===void 0)return!1;s&&(r.flags=D.Mutable|D.RecursedCheck);try{const u=r._snapshot,l=typeof i=="function"?i(u):i===void 0&&s?n(u):i;return u===void 0||!a(u,l)?(r._snapshot=l,!0):!1}finally{se=o,s&&(r.flags&=~D.RecursedCheck),Rt(r)}}};return s?(r.flags=D.Mutable|D.Dirty,r.get=function(){const i=r.flags;if(i&D.Dirty||i&D.Pending&&cr(r.deps,r)){if(r._update()){const o=r.subs;o!==void 0&&yn(o)}}else i&D.Pending&&(r.flags=i&~D.Pending);return se!==void 0&&Sn(r,se,mt),r._snapshot}):r.set=function(i){if(r._update(i)){const o=r.subs;o!==void 0&&(To(o),yn(o),hr())}},r}function Oo(e){const t=()=>{const n=se;se=s,++mt,s.depsTail=void 0,s.flags=D.Watching|D.RecursedCheck;try{return e()}finally{se=n,s.flags&=~D.RecursedCheck,Rt(s)}},s={deps:void 0,depsTail:void 0,subs:void 0,subsTail:void 0,flags:D.Watching|D.RecursedCheck,notify(){const n=this.flags;n&D.Dirty||n&D.Pending&&cr(this.deps,this)?t():this.flags=D.Watching},stop(){this.flags=D.None,this.depsTail=void 0,Rt(this)}};return t(),s}var Fo=$e((e=>{var t=fs();function s(c,f){return c===f&&(c!==0||1/c===1/f)||c!==c&&f!==f}var n=typeof Object.is=="function"?Object.is:s,r=t.useState,i=t.useEffect,o=t.useLayoutEffect,a=t.useDebugValue;function u(c,f){var g=f(),p=r({inst:{value:g,getSnapshot:f}}),v=p[0].inst,m=p[1];return o(function(){v.value=g,v.getSnapshot=f,l(v)&&m({inst:v})},[c,g,f]),i(function(){return l(v)&&m({inst:v}),c(function(){l(v)&&m({inst:v})})},[c]),a(g),g}function l(c){var f=c.getSnapshot;c=c.value;try{var g=f();return!n(c,g)}catch{return!0}}function h(c,f){return f()}var d=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?h:u;e.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:d})),Ao=$e(((e,t)=>{t.exports=Fo()})),ko=$e((e=>{var t=fs(),s=Ao();function n(h,d){return h===d&&(h!==0||1/h===1/d)||h!==h&&d!==d}var r=typeof Object.is=="function"?Object.is:n,i=s.useSyncExternalStore,o=t.useRef,a=t.useEffect,u=t.useMemo,l=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(h,d,c,f,g){var p=o(null);if(p.current===null){var v={hasValue:!1,value:null};p.current=v}else v=p.current;p=u(function(){function y(b){if(!C){if(C=!0,S=b,b=f(b),g!==void 0&&v.hasValue){var I=v.value;if(g(I,b))return w=I}return w=b}if(I=w,r(S,b))return I;var _=f(b);return g!==void 0&&g(I,_)?(S=b,I):(S=b,w=_)}var C=!1,S,w,P=c===void 0?null:c;return[function(){return y(d())},P===null?void 0:function(){return y(P())}]},[d,c,f,g]);var m=i(h,p[0],p[1]);return a(function(){v.hasValue=!0,v.value=m},[m]),l(m),m}})),Do=$e(((e,t)=>{t.exports=ko()})),$o=Do();function No(e,t){return e===t}function K(e,t,s=No){const n=(0,R.useCallback)(i=>{if(!e)return()=>{};const{unsubscribe:o}=e.subscribe(i);return o},[e]),r=(0,R.useCallback)(()=>e?.get(),[e]);return(0,$o.useSyncExternalStoreWithSelector)(n,r,r,t,s)}var Vo={get:()=>{},subscribe:()=>({unsubscribe:()=>{}})};function _e(e){const t=ee(),s=R.useContext(e.from?Io:Mt),n=e.from??s,r=n?e.from?t.stores.getRouteMatchStore(n):t.stores.matchStores.get(n):void 0,i=R.useRef(void 0);return K(r??Vo,o=>{if((e.shouldThrow??!0)&&!o&&ie(),o===void 0)return;const a=e.select?e.select(o):o;if(e.structuralSharing??t.options.defaultStructuralSharing){const u=le(i.current,a);return i.current=u,u}return a})}function fr(e){return _e({from:e.from,strict:e.strict,structuralSharing:e.structuralSharing,select:t=>e.select?e.select(t.loaderData):t.loaderData})}function gr(e){const{select:t,...s}=e;return _e({...s,select:n=>t?t(n.loaderDeps):n.loaderDeps})}function pr(e){return _e({from:e.from,shouldThrow:e.shouldThrow,structuralSharing:e.structuralSharing,strict:e.strict,select:t=>{const s=e.strict===!1?t.params:t._strictParams;return e.select?e.select(s):s}})}function mr(e){return _e({from:e.from,strict:e.strict,shouldThrow:e.shouldThrow,structuralSharing:e.structuralSharing,select:t=>e.select?e.select(t.search):t.search})}function vr(e){const t=ee();return R.useCallback(s=>t.navigate({...s,from:s.from??e?.from}),[e?.from,t])}function Sr(e){return _e({...e,select:t=>e.select?e.select(t.context):t.context})}var yr=Bn(Nr(),1);function Bo(e,t){const s=ee(),n=Ri(t),r=!1,{activeProps:i,inactiveProps:o,activeOptions:a,to:u,preload:l,preloadDelay:h,preloadIntentProximity:d,hashScrollIntoView:c,replace:f,startTransition:g,resetScroll:p,viewTransition:v,children:m,target:y,disabled:C,style:S,className:w,onClick:P,onBlur:b,onFocus:I,onMouseEnter:_,onMouseLeave:x,onTouchStart:M,ignoreBlocker:k,params:F,search:J,hash:B,state:oe,mask:Y,reloadDocument:Ve,unsafeRelative:xs,from:Es,_fromLocation:nt,...Ie}=e;if(r){const A=Mn(u);if(typeof u=="string"&&!A&&u.indexOf(":")>-1)try{return new URL(u),ye(u,s.protocolAllowlist)?{...Ie,ref:n,href:void 0,...m&&{children:m},...y&&{target:y},...C&&{disabled:C},...S&&{style:S},...w&&{className:w}}:{...Ie,ref:n,href:u,...m&&{children:m},...y&&{target:y},...C&&{disabled:C},...S&&{style:S},...w&&{className:w}}}catch{}const O=s.buildLocation({...e,from:e.from}),X=Pn(O.maskedLocation?O.maskedLocation.publicHref:O.publicHref,O.maskedLocation?O.maskedLocation.external:O.external,s.history,C),Ue=(()=>{if(X?.external)return ye(X.href,s.protocolAllowlist)?void 0:X.href;if(!A&&typeof u=="string"&&u.indexOf(":")>-1)try{return new URL(u),ye(u,s.protocolAllowlist)?void 0:u}catch{}})(),Lt=(()=>{if(Ue)return!1;const N=s.stores.location.get(),G=a?.exact??!1;if(G){if(!nn(N.pathname,O.pathname,s.basepath))return!1}else{const V=Fe(N.pathname,s.basepath),q=Fe(O.pathname,s.basepath);if(!(V.startsWith(q)&&(V.length===q.length||V[q.length]==="/")))return!1}if((a?.includeSearch??!0)&&N.search!==O.search){const V=!N.search||typeof N.search=="object"&&Object.keys(N.search).length===0,q=!O.search||typeof O.search=="object"&&Object.keys(O.search).length===0;if(!(V&&q)&&!he(N.search,O.search,{partial:!G,ignoreUndefined:!a?.explicitUndefined}))return!1}return!a?.includeHash})();if(Ue)return{...Ie,ref:n,href:Ue,...m&&{children:m},...y&&{target:y},...C&&{disabled:C},...S&&{style:S},...w&&{className:w}};const Tt=Lt?ne(i,{})??Rn:Ee,Ot=Lt?Ee:ne(o,{})??Ee,Ns=(()=>{const N=S,G=Tt.style,V=Ot.style;if(!(!N&&!G&&!V))return N&&!G&&!V?N:!N&&G&&!V?G:!N&&!G&&V?V:{...N,...G,...V}})(),Vs=(()=>{const N=w,G=Tt.className,V=Ot.className;if(!N&&!G&&!V)return"";let q="";return N&&(q=N),G&&(q=q?`${q} ${G}`:G),V&&(q=q?`${q} ${V}`:V),q})();return{...Ie,...Tt,...Ot,href:X?.href,ref:n,disabled:!!C,target:y,...Ns&&{style:Ns},...Vs&&{className:Vs},...C&&wn,...Lt&&bn}}const It=lr(),Be=R.useMemo(()=>e,[s,e.from,e._fromLocation,e.hash,e.to,e.search,e.params,e.state,e.mask,e.unsafeRelative]),me=K(s.stores.location,A=>A,(A,O)=>A.href===O.href),U=R.useMemo(()=>{const A={_fromLocation:me,...Be};return s.buildLocation(A)},[s,me,Be]),Ls=U.maskedLocation?U.maskedLocation.publicHref:U.publicHref,Ts=U.maskedLocation?U.maskedLocation.external:U.external,ze=R.useMemo(()=>Pn(Ls,Ts,s.history,C),[C,Ts,Ls,s.history]),He=R.useMemo(()=>{if(ze?.external)return ye(ze.href,s.protocolAllowlist)?void 0:ze.href;if(!Mn(u)&&!(typeof u!="string"||u.indexOf(":")===-1))try{return new URL(u),ye(u,s.protocolAllowlist)?void 0:u}catch{}},[u,ze,s.protocolAllowlist]),xt=R.useMemo(()=>{if(He)return!1;if(a?.exact){if(!nn(me.pathname,U.pathname,s.basepath))return!1}else{const A=Fe(me.pathname,s.basepath),O=Fe(U.pathname,s.basepath);if(!(A.startsWith(O)&&(A.length===O.length||A[O.length]==="/")))return!1}return(a?.includeSearch??!0)&&!he(me.search,U.search,{partial:!a?.exact,ignoreUndefined:!a?.explicitUndefined})?!1:a?.includeHash?It&&me.hash===U.hash:!0},[a?.exact,a?.explicitUndefined,a?.includeHash,a?.includeSearch,me,He,It,U.hash,U.pathname,U.search,s.basepath]),rt=xt?ne(i,{})??Rn:Ee,it=xt?Ee:ne(o,{})??Ee,Os=[w,rt.className,it.className].filter(Boolean).join(" "),Fs=(S||rt.style||it.style)&&{...S,...rt.style,...it.style},[kr,As]=R.useState(!1),ks=R.useRef(!1),xe=e.reloadDocument||He?!1:l??s.options.defaultPreload,Et=h??s.options.defaultPreloadDelay??0,ve=R.useCallback(()=>{s.preloadRoute({...Be,_builtLocation:U}).catch(A=>{console.warn(A),console.warn(Ro)})},[s,Be,U]);Ci(n,R.useCallback(A=>{A?.isIntersecting&&ve()},[ve]),Ho,{disabled:!!C||xe!=="viewport"}),R.useEffect(()=>{ks.current||!C&&xe==="render"&&(ve(),ks.current=!0)},[C,ve,xe]);const Dr=A=>{const O=A.currentTarget.getAttribute("target"),X=y!==void 0?y:O;if(!C&&!Uo(A)&&!A.defaultPrevented&&(!X||X==="_self")&&A.button===0){A.preventDefault(),(0,yr.flushSync)(()=>{As(!0)});const Ue=s.subscribe("onResolved",()=>{Ue(),As(!1)});s.navigate({...Be,replace:f,resetScroll:p,hashScrollIntoView:c,startTransition:g,viewTransition:v,ignoreBlocker:k})}};if(He)return{...Ie,ref:n,href:He,...m&&{children:m},...y&&{target:y},...C&&{disabled:C},...S&&{style:S},...w&&{className:w},...P&&{onClick:P},...b&&{onBlur:b},...I&&{onFocus:I},..._&&{onMouseEnter:_},...x&&{onMouseLeave:x},...M&&{onTouchStart:M}};const Ds=A=>{if(C||xe!=="intent")return;if(!Et){ve();return}const O=A.currentTarget;if(Ke.has(O))return;const X=setTimeout(()=>{Ke.delete(O),ve()},Et);Ke.set(O,X)},$r=A=>{C||xe!=="intent"||ve()},$s=A=>{if(C||!xe||!Et)return;const O=A.currentTarget,X=Ke.get(O);X&&(clearTimeout(X),Ke.delete(O))};return{...Ie,...rt,...it,href:ze?.href,ref:n,onClick:Le([P,Dr]),onBlur:Le([b,$s]),onFocus:Le([I,Ds]),onMouseEnter:Le([_,Ds]),onMouseLeave:Le([x,$s]),onTouchStart:Le([M,$r]),disabled:!!C,target:y,...Fs&&{style:Fs},...Os&&{className:Os},...C&&wn,...xt&&bn,...It&&kr&&zo}}var Ee={},Rn={className:"active"},wn={role:"link","aria-disabled":!0},bn={"data-status":"active","aria-current":"page"},zo={"data-transitioning":"transitioning"},Ke=new WeakMap,Ho={rootMargin:"100px"},Le=e=>t=>{for(const s of e)if(s){if(t.defaultPrevented)return;s(t)}};function Pn(e,t,s,n){if(!n)return t?{href:e,external:!0}:{href:s.createHref(e)||"/",external:!1}}function Mn(e){if(typeof e!="string")return!1;const t=e.charCodeAt(0);return t===47?e.charCodeAt(1)!==47:t===46}var Cr=R.forwardRef((e,t)=>{const{_asChild:s,...n}=e,{type:r,...i}=Bo(n,t),o=typeof n.children=="function"?n.children({isActive:i["data-status"]==="active"}):n.children;if(!s){const{disabled:a,...u}=i;return R.createElement("a",u,o)}return R.createElement(s,i,o)});function Uo(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}var jo=class extends ar{constructor(e){super(e),this.useMatch=t=>_e({select:t?.select,from:this.id,structuralSharing:t?.structuralSharing}),this.useRouteContext=t=>Sr({...t,from:this.id}),this.useSearch=t=>mr({select:t?.select,structuralSharing:t?.structuralSharing,from:this.id}),this.useParams=t=>pr({select:t?.select,structuralSharing:t?.structuralSharing,from:this.id}),this.useLoaderDeps=t=>gr({...t,from:this.id}),this.useLoaderData=t=>fr({...t,from:this.id}),this.useNavigate=()=>vr({from:this.fullPath}),this.Link=R.forwardRef((t,s)=>(0,E.jsx)(Cr,{ref:s,from:this.fullPath,...t}))}};function Go(e){return new jo(e)}var qo=class extends wo{constructor(e){super(e),this.useMatch=t=>_e({select:t?.select,from:this.id,structuralSharing:t?.structuralSharing}),this.useRouteContext=t=>Sr({...t,from:this.id}),this.useSearch=t=>mr({select:t?.select,structuralSharing:t?.structuralSharing,from:this.id}),this.useParams=t=>pr({select:t?.select,structuralSharing:t?.structuralSharing,from:this.id}),this.useLoaderDeps=t=>gr({...t,from:this.id}),this.useLoaderData=t=>fr({...t,from:this.id}),this.useNavigate=()=>vr({from:this.fullPath}),this.Link=R.forwardRef((t,s)=>(0,E.jsx)(Cr,{ref:s,from:this.fullPath,...t}))}};function Nl(e){return new qo(e)}function Vl(e){return new Wo(e,{silent:!0}).createRoute}var Wo=class{constructor(e,t){this.path=e,this.createRoute=s=>{const n=Go(s);return n.isRoot=!1,n},this.silent=t?.silent}};function Bl(e,t){let s,n,r,i;const o=()=>(s||(s=e().then(u=>{s=void 0,n=u[t??"default"]}).catch(u=>{if(r=u,Mi(r)&&r instanceof Error&&typeof window<"u"&&typeof sessionStorage<"u"){const l=`tanstack_router_reload:${r.message}`;sessionStorage.getItem(l)||(sessionStorage.setItem(l,"1"),i=!0)}})),s),a=function(l){if(i)throw window.location.reload(),new Promise(()=>{});if(r)throw r;if(!n)if(Ys)Ys(o());else throw o();return R.createElement(n,l)};return a.preload=o,a}function Ko(e){const t=ee(),s=`not-found-${K(t.stores.location,n=>n.pathname)}-${K(t.stores.status,n=>n)}`;return(0,E.jsx)(bs,{getResetKey:()=>s,onCatch:(n,r)=>{if(H(n))e.onCatch?.(n,r);else throw n},errorComponent:({error:n})=>{if(H(n))return e.fallback?.(n);throw n},children:e.children})}function Qo(){return(0,E.jsx)("p",{children:"Not Found"})}function Oe(e){return(0,E.jsx)(E.Fragment,{children:e.children})}function Rr(e,t,s){return t.options.notFoundComponent?(0,E.jsx)(t.options.notFoundComponent,{...s}):e.options.defaultNotFoundComponent?(0,E.jsx)(e.options.defaultNotFoundComponent,{...s}):(0,E.jsx)(Qo,{})}var wr=R.memo(function({matchId:t}){const s=ee(),n=s.stores.matchStores.get(t);n||ie();const r=K(s.stores.loadedAt,o=>o),i=K(n,o=>o);return(0,E.jsx)(Jo,{router:s,matchId:t,resetKey:r,matchState:R.useMemo(()=>{const o=i.routeId,a=s.routesById[o].parentRoute?.id;return{routeId:o,ssr:i.ssr,_displayPending:i._displayPending,parentRouteId:a}},[i._displayPending,i.routeId,i.ssr,s.routesById])})});function Jo({router:e,matchId:t,resetKey:s,matchState:n}){const r=e.routesById[n.routeId],i=r.options.pendingComponent??e.options.defaultPendingComponent,o=i?(0,E.jsx)(i,{}):null,a=r.options.errorComponent??e.options.defaultErrorComponent,u=r.options.onCatch??e.options.defaultOnCatch,l=r.isRoot?r.options.notFoundComponent??e.options.notFoundRoute?.options.component:r.options.notFoundComponent,h=n.ssr===!1||n.ssr==="data-only",d=(!r.isRoot||r.options.wrapInSuspense||h)&&(r.options.wrapInSuspense??i??(r.options.errorComponent?.preload||h))?R.Suspense:Oe,c=a?bs:Oe,f=l?Ko:Oe;return(0,E.jsxs)(r.isRoot?r.options.shellComponent??Oe:Oe,{children:[(0,E.jsx)(Mt.Provider,{value:t,children:(0,E.jsx)(d,{fallback:o,children:(0,E.jsx)(c,{getResetKey:()=>s,errorComponent:a||Ps,onCatch:(g,p)=>{if(H(g))throw g.routeId??=n.routeId,g;u?.(g,p)},children:(0,E.jsx)(f,{fallback:g=>{if(g.routeId??=n.routeId,!l||g.routeId&&g.routeId!==n.routeId||!g.routeId&&!r.isRoot)throw g;return R.createElement(l,g)},children:h||n._displayPending?(0,E.jsx)(Mo,{fallback:o,children:(0,E.jsx)(_n,{matchId:t})}):(0,E.jsx)(_n,{matchId:t})})})})}),n.parentRouteId==="__root__"?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(Yo,{resetKey:s}),(e.options.scrollRestoration,null)]}):null]})}function Yo({resetKey:e}){const t=ee(),s=R.useRef(void 0);return Je(()=>{const n=t.latestLocation.href;(s.current===void 0||s.current!==n)&&(t.emit({type:"onRendered",...Ae(t.stores.location.get(),t.stores.resolvedLocation.get())}),s.current=n)},[t.latestLocation.state.__TSR_key,e,t]),null}var _n=R.memo(function({matchId:t}){const s=ee(),n=(h,d)=>s.getMatch(h.id)?._nonReactive[d]??h._nonReactive[d],r=s.stores.matchStores.get(t);r||ie();const i=K(r,h=>h),o=i.routeId,a=s.routesById[o],u=R.useMemo(()=>{const h=(s.routesById[o].options.remountDeps??s.options.defaultRemountDeps)?.({routeId:o,loaderDeps:i.loaderDeps,params:i._strictParams,search:i._strictSearch});return h?JSON.stringify(h):void 0},[o,i.loaderDeps,i._strictParams,i._strictSearch,s.options.defaultRemountDeps,s.routesById]),l=R.useMemo(()=>{const h=a.options.component??s.options.defaultComponent;return h?(0,E.jsx)(h,{},u):(0,E.jsx)(Xo,{})},[u,a.options.component,s.options.defaultComponent]);if(i._displayPending)throw n(i,"displayPendingPromise");if(i._forcePending)throw n(i,"minPendingPromise");if(i.status==="pending"){const h=a.options.pendingMinMs??s.options.defaultPendingMinMs;if(h){const d=s.getMatch(i.id);if(d&&!d._nonReactive.minPendingPromise){const c=De();d._nonReactive.minPendingPromise=c,setTimeout(()=>{c.resolve(),d._nonReactive.minPendingPromise=void 0},h)}}throw n(i,"loadPromise")}if(i.status==="notFound")return H(i.error)||ie(),Rr(s,a,i.error);if(i.status==="redirected")throw W(i.error)||ie(),n(i,"loadPromise");if(i.status==="error")throw i.error;return l}),Xo=R.memo(function(){const t=ee(),s=R.useContext(Mt);let n,r=!1,i;{const l=s?t.stores.matchStores.get(s):void 0;[n,r]=K(l,h=>[h?.routeId,h?.globalNotFound??!1]),i=K(t.stores.matchesId,h=>h[h.findIndex(d=>d===s)+1])}const o=n?t.routesById[n]:void 0,a=t.options.defaultPendingComponent?(0,E.jsx)(t.options.defaultPendingComponent,{}):null;if(r)return o||ie(),Rr(t,o,void 0);if(!i)return null;const u=(0,E.jsx)(wr,{matchId:i});return n==="__root__"?(0,E.jsx)(R.Suspense,{fallback:a,children:u}):u});function Zo(){const e=ee(),t=R.useRef({router:e,mounted:!1}),[s,n]=R.useState(!1),r=K(e.stores.isLoading,d=>d),i=K(e.stores.hasPending,d=>d),o=Ft(r),a=r||s||i,u=Ft(a),l=r||i,h=Ft(l);return e.startTransition=d=>{n(!0),R.startTransition(()=>{d(),n(!1)})},R.useEffect(()=>{const d=e.history.subscribe(e.load),c=e.buildLocation({to:e.latestLocation.pathname,search:!0,params:!0,hash:!0,state:!0,_includeValidateSearch:!0});return fe(e.latestLocation.publicHref)!==fe(c.publicHref)&&e.commitLocation({...c,replace:!0}),()=>{d()}},[e,e.history]),Je(()=>{if(typeof window<"u"&&e.ssr||t.current.router===e&&t.current.mounted)return;t.current={router:e,mounted:!0},(async()=>{try{await e.load()}catch(c){console.error(c)}})()},[e]),Je(()=>{o&&!r&&e.emit({type:"onLoad",...Ae(e.stores.location.get(),e.stores.resolvedLocation.get())})},[o,e,r]),Je(()=>{h&&!l&&e.emit({type:"onBeforeRouteMount",...Ae(e.stores.location.get(),e.stores.resolvedLocation.get())})},[l,h,e]),Je(()=>{if(u&&!a){const d=Ae(e.stores.location.get(),e.stores.resolvedLocation.get());e.emit({type:"onResolved",...d}),dr(()=>{e.stores.status.set("idle"),e.stores.resolvedLocation.set(e.stores.location.get())}),d.hrefChanged&&bo(e)}},[a,u,e]),null}function ea(){const e=ee(),t=e.routesById.__root__.options.pendingComponent??e.options.defaultPendingComponent,s=t?(0,E.jsx)(t,{}):null,n=(0,E.jsxs)(typeof document<"u"&&e.ssr?Oe:R.Suspense,{fallback:s,children:[(0,E.jsx)(Zo,{}),(0,E.jsx)(ta,{})]});return e.options.InnerWrap?(0,E.jsx)(e.options.InnerWrap,{children:n}):n}function ta(){const e=ee(),t=!1,s=t?e.stores.firstId.get():K(e.stores.firstId,i=>i),n=t?e.stores.loadedAt.get():K(e.stores.loadedAt,i=>i),r=s?(0,E.jsx)(wr,{matchId:s}):null;return(0,E.jsx)(Mt.Provider,{value:s,children:e.options.disableGlobalCatchBoundary?r:(0,E.jsx)(bs,{getResetKey:()=>n,errorComponent:Ps,onCatch:void 0,children:r})})}var sa=e=>({createMutableStore:Cn,createReadonlyStore:Cn,batch:dr}),zl=e=>new na(e),na=class extends go{constructor(e){super(e,sa)}};function ra({router:e,children:t,...s}){Object.keys(s).length>0&&e.update({...e.options,...s,context:{...e.options.context,...s.context}});const n=(0,E.jsx)(ur.Provider,{value:e,children:t});return e.options.Wrap?(0,E.jsx)(e.options.Wrap,{children:n}):n}function Hl({router:e,...t}){return(0,E.jsx)(ra,{router:e,...t,children:(0,E.jsx)(ea,{})})}function Ul(e){const t=ee(),s=(0,R.useRef)(void 0);return K(t.stores.location,n=>{const r=e?.select?e.select(n):n;if(e?.structuralSharing??t.options.defaultStructuralSharing){const i=le(s.current,r);return s.current=i,i}return r})}var ia=class{#t=!0;#e;#s;#r;#n;#a;#i;#o;#g=0;#p=5;#u=!1;#c=!1;#l=null;#d=()=>{this.debugLog("Connected to event bus"),this.#a=!0,this.#u=!1,this.debugLog("Emitting queued events",this.#n),this.#n.forEach(e=>this.emitEventToBus(e)),this.#n=[],this.stopConnectLoop(),this.#s().removeEventListener("tanstack-connect-success",this.#d)};#h=()=>{if(this.#g<this.#p){this.#g++,this.dispatchCustomEvent("tanstack-connect",{});return}this.#s().removeEventListener("tanstack-connect",this.#h),this.#c=!0,this.debugLog("Max retries reached, giving up on connection"),this.stopConnectLoop()};#f=()=>{this.#u||(this.#u=!0,this.#s().addEventListener("tanstack-connect-success",this.#d),this.#h())};constructor({pluginId:e,debug:t=!1,enabled:s=!0,reconnectEveryMs:n=300}){this.#e=e,this.#t=s,this.#s=this.getGlobalTarget,this.#r=t,this.debugLog(" Initializing event subscription for plugin",this.#e),this.#n=[],this.#a=!1,this.#c=!1,this.#i=null,this.#o=n}startConnectLoop(){this.#i!==null||this.#a||(this.debugLog(`Starting connect loop (every ${this.#o}ms)`),this.#i=setInterval(this.#h,this.#o))}stopConnectLoop(){this.#u=!1,this.#i!==null&&(clearInterval(this.#i),this.#i=null,this.#n=[],this.debugLog("Stopped connect loop"))}debugLog(...e){this.#r&&console.log(`🌴 [tanstack-devtools:${this.#e}-plugin]`,...e)}getGlobalTarget(){if(typeof globalThis<"u"&&globalThis.__TANSTACK_EVENT_TARGET__)return this.debugLog("Using global event target"),globalThis.__TANSTACK_EVENT_TARGET__;if(typeof window<"u"&&typeof window.addEventListener<"u")return this.debugLog("Using window as event target"),window;const e=typeof EventTarget<"u"?new EventTarget:void 0;return typeof e>"u"||typeof e.addEventListener>"u"?(this.debugLog("No event mechanism available, running in non-web environment"),{addEventListener:()=>{},removeEventListener:()=>{},dispatchEvent:()=>!1}):(this.debugLog("Using new EventTarget as fallback"),e)}getPluginId(){return this.#e}dispatchCustomEventShim(e,t){try{const s=new Event(e,{detail:t});this.#s().dispatchEvent(s)}catch{this.debugLog("Failed to dispatch shim event")}}dispatchCustomEvent(e,t){try{this.#s().dispatchEvent(new CustomEvent(e,{detail:t}))}catch{this.dispatchCustomEventShim(e,t)}}emitEventToBus(e){this.debugLog("Emitting event to client bus",e),this.dispatchCustomEvent("tanstack-dispatch-event",e)}createEventPayload(e,t){return{type:`${this.#e}:${e}`,payload:t,pluginId:this.#e}}emit(e,t){if(!this.#t){this.debugLog("Event bus client is disabled, not emitting event",e,t);return}if(this.#l&&(this.debugLog("Emitting event to internal event target",e,t),this.#l.dispatchEvent(new CustomEvent(`${this.#e}:${e}`,{detail:this.createEventPayload(e,t)}))),this.#c){this.debugLog("Previously failed to connect, not emitting to bus");return}if(!this.#a){this.debugLog("Bus not available, will be pushed as soon as connected"),this.#n.push(this.createEventPayload(e,t)),typeof CustomEvent<"u"&&!this.#u&&(this.#f(),this.startConnectLoop());return}return this.emitEventToBus(this.createEventPayload(e,t))}on(e,t,s){const n=s?.withEventTarget??!1,r=`${this.#e}:${e}`;if(n&&(this.#l||(this.#l=new EventTarget),this.#l.addEventListener(r,o=>{t(o.detail)})),!this.#t)return this.debugLog("Event bus client is disabled, not registering event",r),()=>{};const i=o=>{this.debugLog("Received event from bus",o.detail),t(o.detail)};return this.#s().addEventListener(r,i),this.debugLog("Registered event to bus",r),()=>{n&&this.#l?.removeEventListener(r,i),this.#s().removeEventListener(r,i)}}onAll(e){if(!this.#t)return this.debugLog("Event bus client is disabled, not registering event"),()=>{};const t=s=>{const n=s.detail;e(n)};return this.#s().addEventListener("tanstack-devtools-global",t),()=>this.#s().removeEventListener("tanstack-devtools-global",t)}onAllPluginEvents(e){if(!this.#t)return this.debugLog("Event bus client is disabled, not registering event"),()=>{};const t=s=>{const n=s.detail;this.#e&&n.pluginId!==this.#e||e(n)};return this.#s().addEventListener("tanstack-devtools-global",t),()=>this.#s().removeEventListener("tanstack-devtools-global",t)}},oa=class extends ia{constructor(){super({pluginId:"tanstack-ai-devtools"})}},In=new oa;function aa(e){return e.type==="text"||e.type==="image"||e.type==="audio"||e.type==="video"||e.type==="document"}function br(e){return e.length===0?null:e.every(t=>t.type==="text")?e.map(t=>t.content).join("")||null:e}function xn(e){return e===null?"":typeof e=="string"?e:e.filter(t=>t.type==="text").map(t=>t.content).join("")}function la(e){return e.role==="system"?[]:e.role!=="assistant"?[ua(e)]:da(e)}function ua(e){const t=[];for(const s of e.parts)aa(s)&&t.push(s);return{role:e.role,content:br(t)}}function En(){return{contentParts:[],toolCalls:[]}}function ca(e){return e.state==="input-complete"||e.state==="approval-responded"||e.output!==void 0}function da(e){const t=[];let s=En();const n=new Set;function r(){const i=br(s.contentParts),o=i!==null,a=s.toolCalls.length>0;(o||a)&&t.push({role:"assistant",content:i,...a&&{toolCalls:s.toolCalls}}),s=En()}for(const i of e.parts)switch(i.type){case"text":case"image":case"audio":case"video":case"document":s.contentParts.push(i);break;case"tool-call":ca(i)&&s.toolCalls.push({id:i.id,type:"function",function:{name:i.name,arguments:i.arguments}});break;case"tool-result":r(),(i.state==="complete"||i.state==="error")&&!n.has(i.toolCallId)&&(t.push({role:"tool",content:i.content,toolCallId:i.toolCallId}),n.add(i.toolCallId));break}r();for(const i of e.parts)if(i.type==="tool-call"&&(i.output!==void 0&&!n.has(i.id)&&(t.push({role:"tool",content:JSON.stringify(i.output),toolCallId:i.id}),n.add(i.id)),i.output===void 0&&i.state==="approval-responded"&&i.approval?.approved!==void 0&&!n.has(i.id))){const o=i.approval.approved;t.push({role:"tool",content:JSON.stringify({approved:o,...o&&{pendingExecution:!0},message:o?"User approved this action":"User denied this action"}),toolCallId:i.id}),n.add(i.id)}return t.length===0&&t.push({role:"assistant",content:null}),t}function ha(e,t){const s=[];if(e.role==="tool"&&e.toolCallId)s.push({type:"tool-result",toolCallId:e.toolCallId,content:xn(e.content),state:"complete"});else if(Array.isArray(e.content))for(const n of e.content)s.push(n);else{const n=xn(e.content);n&&s.push({type:"text",content:n})}if(e.toolCalls&&e.toolCalls.length>0)for(const n of e.toolCalls)s.push({type:"tool-call",id:n.id,name:n.function.name,arguments:n.function.arguments,state:"input-complete"});return{id:t||wt(),role:e.role==="tool"?"assistant":e.role,parts:s}}function fa(e,t){return"parts"in e?{...e,id:e.id||t(),createdAt:e.createdAt||new Date}:{...ha(e,t()),createdAt:new Date}}function wt(){return`msg-${Date.now()}-${Math.random().toString(36).substring(7)}`}var Ln=$e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Allow=e.ALL=e.COLLECTION=e.ATOM=e.SPECIAL=e.INF=e._INFINITY=e.INFINITY=e.NAN=e.BOOL=e.NULL=e.OBJ=e.ARR=e.NUM=e.STR=void 0,e.STR=1,e.NUM=2,e.ARR=4,e.OBJ=8,e.NULL=16,e.BOOL=32,e.NAN=64,e.INFINITY=128,e._INFINITY=256,e.INF=e.INFINITY|e._INFINITY,e.SPECIAL=e.NULL|e.BOOL|e.INF|e.NAN,e.ATOM=e.STR|e.NUM|e.SPECIAL,e.COLLECTION=e.ARR|e.OBJ,e.ALL=e.ATOM|e.COLLECTION,e.Allow={STR:e.STR,NUM:e.NUM,ARR:e.ARR,OBJ:e.OBJ,NULL:e.NULL,BOOL:e.BOOL,NAN:e.NAN,INFINITY:e.INFINITY,_INFINITY:e._INFINITY,INF:e.INF,SPECIAL:e.SPECIAL,ATOM:e.ATOM,COLLECTION:e.COLLECTION,ALL:e.ALL},e.default=e.Allow})),ga=$e((e=>{var t=e&&e.__createBinding||(Object.create?(function(l,h,d,c){c===void 0&&(c=d);var f=Object.getOwnPropertyDescriptor(h,d);(!f||("get"in f?!h.__esModule:f.writable||f.configurable))&&(f={enumerable:!0,get:function(){return h[d]}}),Object.defineProperty(l,c,f)}):(function(l,h,d,c){c===void 0&&(c=d),l[c]=h[d]})),s=e&&e.__exportStar||function(l,h){for(var d in l)d!=="default"&&!Object.prototype.hasOwnProperty.call(h,d)&&t(h,l,d)};Object.defineProperty(e,"__esModule",{value:!0}),e.Allow=e.MalformedJSON=e.PartialJSON=e.parseJSON=e.parse=void 0;var n=Ln();Object.defineProperty(e,"Allow",{enumerable:!0,get:function(){return n.Allow}}),s(Ln(),e);var r=class extends Error{};e.PartialJSON=r;var i=class extends Error{};e.MalformedJSON=i;function o(l,h=n.Allow.ALL){if(typeof l!="string")throw new TypeError(`expecting str, got ${typeof l}`);if(!l.trim())throw new Error(`${l} is empty`);return a(l.trim(),h)}e.parseJSON=o;var a=(l,h)=>{const d=l.length;let c=0;const f=w=>{throw new r(`${w} at position ${c}`)},g=w=>{throw new i(`${w} at position ${c}`)},p=()=>(S(),c>=d&&f("Unexpected end of input"),l[c]==='"'?v():l[c]==="{"?m():l[c]==="["?y():l.substring(c,c+4)==="null"||n.Allow.NULL&h&&d-c<4&&"null".startsWith(l.substring(c))?(c+=4,null):l.substring(c,c+4)==="true"||n.Allow.BOOL&h&&d-c<4&&"true".startsWith(l.substring(c))?(c+=4,!0):l.substring(c,c+5)==="false"||n.Allow.BOOL&h&&d-c<5&&"false".startsWith(l.substring(c))?(c+=5,!1):l.substring(c,c+8)==="Infinity"||n.Allow.INFINITY&h&&d-c<8&&"Infinity".startsWith(l.substring(c))?(c+=8,1/0):l.substring(c,c+9)==="-Infinity"||n.Allow._INFINITY&h&&1<d-c&&d-c<9&&"-Infinity".startsWith(l.substring(c))?(c+=9,-1/0):l.substring(c,c+3)==="NaN"||n.Allow.NAN&h&&d-c<3&&"NaN".startsWith(l.substring(c))?(c+=3,NaN):C()),v=()=>{const w=c;let P=!1;for(c++;c<d&&(l[c]!=='"'||P&&l[c-1]==="\\");)P=l[c]==="\\"?!P:!1,c++;if(l.charAt(c)=='"')try{return JSON.parse(l.substring(w,++c-Number(P)))}catch(b){g(String(b))}else if(n.Allow.STR&h)try{return JSON.parse(l.substring(w,c-Number(P))+'"')}catch{return JSON.parse(l.substring(w,l.lastIndexOf("\\"))+'"')}f("Unterminated string literal")},m=()=>{c++,S();const w={};try{for(;l[c]!=="}";){if(S(),c>=d&&n.Allow.OBJ&h)return w;const P=v();S(),c++;try{w[P]=p()}catch(b){if(n.Allow.OBJ&h)return w;throw b}S(),l[c]===","&&c++}}catch{if(n.Allow.OBJ&h)return w;f("Expected '}' at end of object")}return c++,w},y=()=>{c++;const w=[];try{for(;l[c]!=="]";)w.push(p()),S(),l[c]===","&&c++}catch{if(n.Allow.ARR&h)return w;f("Expected ']' at end of array")}return c++,w},C=()=>{if(c===0){l==="-"&&g("Not sure what '-' is");try{return JSON.parse(l)}catch(P){if(n.Allow.NUM&h)try{return JSON.parse(l.substring(0,l.lastIndexOf("e")))}catch{}g(String(P))}}const w=c;for(l[c]==="-"&&c++;l[c]&&",]}".indexOf(l[c])===-1;)c++;c==d&&!(n.Allow.NUM&h)&&f("Unterminated number literal");try{return JSON.parse(l.substring(w,c))}catch{l.substring(w,c)==="-"&&f("Not sure what '-' is");try{return JSON.parse(l.substring(w,l.lastIndexOf("e")))}catch(b){g(String(b))}}},S=()=>{for(;c<d&&`
2
- \r `.includes(l[c]);)c++};return p()},u=o;e.parse=u})),pa=ga(),ma=class{parse(e){if(!(!e||e.trim()===""))try{return(0,pa.parse)(e)}catch{return}}},va=new ma;function Sa(e,t,s){return e.map(n=>{if(n.id!==t)return n;const r=[...n.parts],i=r.length>0?r[r.length-1]:null;return i&&i.type==="text"?r[r.length-1]={type:"text",content:s}:r.push({type:"text",content:s}),{...n,parts:r}})}function zt(e,t,s){return e.map(n=>{if(n.id!==t)return n;const r=[...n.parts],i=r.find(a=>a.type==="tool-call"&&a.id===s.id),o={type:"tool-call",id:s.id,name:s.name,arguments:s.arguments,state:s.state,...i?.approval&&{approval:{...i.approval}},...i?.output!==void 0&&{output:i.output}};return i?r[r.indexOf(i)]=o:r.push(o),{...n,parts:r}})}function Ht(e,t,s,n,r,i){return e.map(o=>{if(o.id!==t)return o;const a=[...o.parts],u=a.findIndex(h=>h.type==="tool-result"&&h.toolCallId===s),l={type:"tool-result",toolCallId:s,content:n,state:r,...i&&{error:i}};return u>=0?a[u]=l:a.push(l),{...o,parts:a}})}function ya(e,t,s,n){return e.map(r=>{if(r.id!==t)return r;const i=[...r.parts],o=i.find(a=>a.type==="tool-call"&&a.id===s);return o&&(o.state="approval-requested",o.approval={id:n,needsApproval:!0}),{...r,parts:i}})}function Ut(e,t,s,n,r){return e.map(i=>{const o=[...i.parts],a=o.find(u=>u.type==="tool-call"&&u.id===t);return a&&(a.output=r?{error:r}:s,n?a.state=n:a.state="input-complete"),{...i,parts:o}})}function Ca(e,t,s){return e.map(n=>{const r=[...n.parts],i=r.find(o=>o.type==="tool-call"&&o.approval?.id===t);return i&&i.approval&&(i.approval.approved=s,i.state="approval-responded"),{...n,parts:r}})}function Tn(e,t,s){return e.map(n=>{if(n.id!==t)return n;const r=[...n.parts],i=r.findIndex(a=>a.type==="thinking"),o={type:"thinking",content:s};return i>=0?r[i]=o:r.push(o),{...n,parts:r}})}var Ra=class{shouldEmit(e,t){return!0}},wa=class Pr{constructor(t={}){this.messages=[],this.messageStates=new Map,this.activeMessageIds=new Set,this.toolCallToMessage=new Map,this.pendingManualMessageId=null,this.activeRuns=new Set,this.finishReason=null,this.hasError=!1,this.isDone=!1,this.recording=null,this.recordingStartTime=0,this.chunkStrategy=t.chunkStrategy||new Ra,this.events=t.events||{},this.jsonParser=t.jsonParser||va,this.recordingEnabled=t.recording??!1,t.initialMessages&&(this.messages=[...t.initialMessages])}setMessages(t){this.messages=[...t],this.emitMessagesChange()}addUserMessage(t,s){const n=typeof t=="string"?[{type:"text",content:t}]:t.map(i=>i),r={id:s??wt(),role:"user",parts:n,createdAt:new Date};return this.messages=[...this.messages,r],this.emitMessagesChange(),r}prepareAssistantMessage(){this.resetStreamState()}startAssistantMessage(t){this.prepareAssistantMessage();const{messageId:s}=this.ensureAssistantMessage(t);return this.pendingManualMessageId=s,s}getCurrentAssistantMessageId(){let t=null;for(const[s,n]of this.messageStates)n.role==="assistant"&&(t=s);return t}addToolResult(t,s,n){const r=this.messages.find(u=>u.parts.some(l=>l.type==="tool-call"&&l.id===t));if(!r){console.warn(`[StreamProcessor] Could not find message with tool call ${t}`);return}let i=Ut(this.messages,t,s,n?"input-complete":void 0,n);const o=typeof s=="string"?s:JSON.stringify(s),a=n?"error":"complete";i=Ht(i,r.id,t,o,a,n),this.messages=i,this.emitMessagesChange()}addToolApprovalResponse(t,s){this.messages=Ca(this.messages,t,s),this.emitMessagesChange()}toModelMessages(){const t=[];for(const s of this.messages)t.push(...la(s));return t}getMessages(){return this.messages}areAllToolsComplete(){const t=this.messages.findLast(r=>r.role==="assistant");if(!t)return!0;const s=t.parts.filter(r=>r.type==="tool-call");if(s.length===0)return!0;const n=new Set(t.parts.filter(r=>r.type==="tool-result").map(r=>r.toolCallId));return s.every(r=>r.state==="approval-responded"||r.output!==void 0&&!r.approval||n.has(r.id))}removeMessagesAfter(t){this.messages=this.messages.slice(0,t+1),this.emitMessagesChange()}clearMessages(){this.messages=[],this.messageStates.clear(),this.activeMessageIds.clear(),this.toolCallToMessage.clear(),this.pendingManualMessageId=null,this.emitMessagesChange()}async process(t){this.resetStreamState(),this.recordingEnabled&&this.startRecording();for await(const s of t)this.processChunk(s);return this.finalizeStream(),this.recording&&(this.recording.result=this.getResult()),this.getResult()}processChunk(t){switch(this.recording&&this.recording.chunks.push({chunk:t,timestamp:Date.now(),index:this.recording.chunks.length}),t.type){case"TEXT_MESSAGE_START":this.handleTextMessageStartEvent(t);break;case"TEXT_MESSAGE_CONTENT":this.handleTextMessageContentEvent(t);break;case"TEXT_MESSAGE_END":this.handleTextMessageEndEvent(t);break;case"TOOL_CALL_START":this.handleToolCallStartEvent(t);break;case"TOOL_CALL_ARGS":this.handleToolCallArgsEvent(t);break;case"TOOL_CALL_END":this.handleToolCallEndEvent(t);break;case"RUN_FINISHED":this.handleRunFinishedEvent(t);break;case"RUN_ERROR":this.handleRunErrorEvent(t);break;case"STEP_FINISHED":this.handleStepFinishedEvent(t);break;case"MESSAGES_SNAPSHOT":this.handleMessagesSnapshotEvent(t);break;case"CUSTOM":this.handleCustomEvent(t);break;case"RUN_STARTED":this.handleRunStartedEvent(t);break;case"REASONING_START":case"REASONING_MESSAGE_START":case"REASONING_MESSAGE_END":case"REASONING_END":break;case"REASONING_MESSAGE_CONTENT":this.handleReasoningMessageContentEvent(t);break;case"TOOL_CALL_RESULT":this.handleToolCallResultEvent(t);break}}createMessageState(t,s){const n={id:t,role:s,totalTextContent:"",currentSegmentText:"",lastEmittedText:"",thinkingContent:"",hasSeenReasoningEvents:!1,toolCalls:new Map,toolCallOrder:[],hasToolCallsSinceTextStart:!1,isComplete:!1};return this.messageStates.set(t,n),n}getMessageState(t){return this.messageStates.get(t)}getActiveAssistantMessageId(){const t=Array.from(this.activeMessageIds);for(let s=t.length-1;s>=0;s--){const n=t[s],r=this.messageStates.get(n);if(r&&r.role==="assistant")return n}return null}ensureAssistantMessage(t){if(t){const o=this.getMessageState(t);if(o)return{messageId:t,state:o}}const s=this.getActiveAssistantMessageId();if(s)return{messageId:s,state:this.getMessageState(s)};if(t){const o=this.messages.find(a=>a.id===t);if(o){const a=this.createMessageState(t,o.role);this.activeMessageIds.add(t);const u=o.parts.length>0?o.parts[o.parts.length-1]:null;return u&&u.type==="text"&&(a.currentSegmentText=u.content,a.lastEmittedText=u.content,a.totalTextContent=u.content),{messageId:t,state:a}}}const n=t||wt(),r={id:n,role:"assistant",parts:[],createdAt:new Date};this.messages=[...this.messages,r];const i=this.createMessageState(n,"assistant");return this.activeMessageIds.add(n),this.pendingManualMessageId=n,this.events.onStreamStart?.(),this.emitMessagesChange(),{messageId:n,state:i}}handleTextMessageStartEvent(t){const{messageId:s,role:n}=t,r=n==="user"||n==="system"?n:"assistant";if(this.pendingManualMessageId){const o=this.pendingManualMessageId;if(this.pendingManualMessageId=null,o!==s){this.messages=this.messages.map(u=>u.id===o?{...u,id:s}:u);const a=this.messageStates.get(o);a&&(a.id=s,this.messageStates.delete(o),this.messageStates.set(s,a)),this.activeMessageIds.delete(o),this.activeMessageIds.add(s)}this.messageStates.has(s)||(this.createMessageState(s,r),this.activeMessageIds.add(s)),this.emitMessagesChange();return}if(this.messages.find(o=>o.id===s)){if(this.activeMessageIds.add(s),!this.messageStates.has(s))this.createMessageState(s,r);else{const o=this.messageStates.get(s);o.hasToolCallsSinceTextStart&&(o.currentSegmentText!==o.lastEmittedText&&this.emitTextUpdateForMessage(s),o.currentSegmentText="",o.lastEmittedText="",o.hasToolCallsSinceTextStart=!1)}return}const i={id:s,role:r,parts:[],createdAt:new Date};this.messages=[...this.messages,i],this.createMessageState(s,r),this.activeMessageIds.add(s),this.events.onStreamStart?.(),this.emitMessagesChange()}handleTextMessageEndEvent(t){const{messageId:s}=t,n=this.getMessageState(s);n&&(n.isComplete||(n.currentSegmentText!==n.lastEmittedText&&this.emitTextUpdateForMessage(s),this.completeAllToolCallsForMessage(s)))}handleMessagesSnapshotEvent(t){this.resetStreamState(),this.messages=[...t.messages],this.emitMessagesChange()}handleTextMessageContentEvent(t){const{messageId:s,state:n}=this.ensureAssistantMessage(t.messageId);this.completeAllToolCallsForMessage(s);const r=n.currentSegmentText;n.hasToolCallsSinceTextStart&&r.length>0&&this.isNewTextSegment(t,r)&&(r!==n.lastEmittedText&&this.emitTextUpdateForMessage(s),n.currentSegmentText="",n.lastEmittedText="",n.hasToolCallsSinceTextStart=!1);const i=n.currentSegmentText;let o=i;const a=t.delta||"";a!==""?o=i+a:t.content!==void 0&&t.content!==""&&(t.content.startsWith(i)?o=t.content:i.startsWith(t.content)?o=i:o=i+t.content);const u=o.slice(i.length);n.currentSegmentText=o,n.totalTextContent+=u;const l=t.delta||t.content||"";this.chunkStrategy.shouldEmit(l,n.currentSegmentText)&&n.currentSegmentText!==n.lastEmittedText&&this.emitTextUpdateForMessage(s)}handleToolCallStartEvent(t){const s=t.parentMessageId??this.getActiveAssistantMessageId(),{messageId:n,state:r}=this.ensureAssistantMessage(s??void 0);r.hasToolCallsSinceTextStart=!0;const i=t.toolCallId;if(!r.toolCalls.get(i)){const o="awaiting-input",a=t.toolCallName,u={id:t.toolCallId,name:a,arguments:"",state:o,parsedArguments:void 0,index:t.index??r.toolCalls.size};r.toolCalls.set(i,u),r.toolCallOrder.push(i),this.toolCallToMessage.set(i,n),this.messages=zt(this.messages,n,{id:t.toolCallId,name:a,arguments:"",state:o}),this.emitMessagesChange(),this.events.onToolCallStateChange?.(n,t.toolCallId,o,"")}}handleToolCallArgsEvent(t){const s=t.toolCallId,n=this.toolCallToMessage.get(s);if(!n)return;const r=this.getMessageState(n);if(!r)return;const i=r.toolCalls.get(s);if(!i)return;const o=i.state==="awaiting-input";i.arguments+=t.delta||"",o&&t.delta&&(i.state="input-streaming"),i.parsedArguments=this.jsonParser.parse(i.arguments),this.messages=zt(this.messages,n,{id:i.id,name:i.name,arguments:i.arguments,state:i.state}),this.emitMessagesChange(),this.events.onToolCallStateChange?.(n,i.id,i.state,i.arguments)}handleToolCallEndEvent(t){const s=this.toolCallToMessage.get(t.toolCallId);if(!s)return;const n=this.getMessageState(s);if(!n)return;const r=n.toolCalls.get(t.toolCallId);if(r&&r.state!=="input-complete"){t.input!==void 0&&!r.arguments&&(r.arguments=JSON.stringify(t.input));const i=n.toolCallOrder.indexOf(t.toolCallId);this.completeToolCall(s,i,r),t.input!==void 0&&(r.parsedArguments=t.input)}if(t.result){let i;try{i=JSON.parse(t.result)}catch{i=t.result}this.messages=Ut(this.messages,t.toolCallId,i);const o="complete";this.messages=Ht(this.messages,s,t.toolCallId,t.result,o),this.emitMessagesChange()}}handleToolCallResultEvent(t){const s=this.toolCallToMessage.get(t.toolCallId);if(!s)return;let n;try{n=JSON.parse(t.content)}catch{n=t.content}this.messages=Ut(this.messages,t.toolCallId,n);const r="complete";this.messages=Ht(this.messages,s,t.toolCallId,t.content,r),this.emitMessagesChange()}handleRunStartedEvent(t){this.activeRuns.add(t.runId)}handleRunFinishedEvent(t){this.finishReason=t.finishReason??null,this.activeRuns.delete(t.runId),this.activeRuns.size===0&&(this.isDone=!0,this.completeAllToolCalls(),this.finalizeStream())}handleRunErrorEvent(t){this.hasError=!0;const s=t.runId;s?this.activeRuns.delete(s):this.activeRuns.clear(),this.ensureAssistantMessage();const n=t.message||t.error?.message||"An error occurred";this.events.onError?.(new Error(n))}handleStepFinishedEvent(t){const{messageId:s,state:n}=this.ensureAssistantMessage(this.getActiveAssistantMessageId()??void 0);if(n.hasSeenReasoningEvents)return;const r=n.thinkingContent;let i=r;t.delta&&t.delta!==""?i=r+t.delta:t.content&&t.content!==""&&(t.content.startsWith(r)?i=t.content:r.startsWith(t.content)?i=r:i=r+t.content),n.thinkingContent=i,this.messages=Tn(this.messages,s,n.thinkingContent),this.emitMessagesChange(),this.events.onThinkingUpdate?.(s,n.thinkingContent)}handleReasoningMessageContentEvent(t){const{messageId:s,state:n}=this.ensureAssistantMessage(this.getActiveAssistantMessageId()??void 0);n.hasSeenReasoningEvents=!0;const r=t.delta||"";n.thinkingContent=n.thinkingContent+r,this.messages=Tn(this.messages,s,n.thinkingContent),this.emitMessagesChange(),this.events.onThinkingUpdate?.(s,n.thinkingContent)}handleCustomEvent(t){const s=this.getActiveAssistantMessageId();if(t.name==="tool-input-available"&&t.value){const{toolCallId:n,toolName:r,input:i}=t.value;this.events.onToolCall?.({toolCallId:n,toolName:r,input:i});return}if(t.name==="approval-requested"&&t.value){const{toolCallId:n,toolName:r,input:i,approval:o}=t.value,a=s??this.toolCallToMessage.get(n);a&&(this.messages=ya(this.messages,a,n,o.id),this.emitMessagesChange()),this.events.onApprovalRequest?.({toolCallId:n,toolName:r,input:i,approvalId:o.id});return}if(this.events.onCustomEvent){const n=t.value&&typeof t.value=="object"?t.value.toolCallId:void 0;this.events.onCustomEvent(t.name,t.value,{toolCallId:n})}}isNewTextSegment(t,s){return t.content!==void 0&&(t.content.length<s.length||!t.content.startsWith(s)&&!s.startsWith(t.content))}completeAllToolCalls(){for(const t of this.activeMessageIds)this.completeAllToolCallsForMessage(t)}completeAllToolCallsForMessage(t){const s=this.getMessageState(t);s&&s.toolCalls.forEach((n,r)=>{if(n.state!=="input-complete"){const i=s.toolCallOrder.indexOf(r);this.completeToolCall(t,i,n)}})}completeToolCall(t,s,n){n.state="input-complete",n.parsedArguments=this.jsonParser.parse(n.arguments),this.messages=zt(this.messages,t,{id:n.id,name:n.name,arguments:n.arguments,state:"input-complete"}),this.emitMessagesChange(),this.events.onToolCallStateChange?.(t,n.id,"input-complete",n.arguments)}emitTextUpdateForMessage(t){const s=this.getMessageState(t);s&&(s.lastEmittedText=s.currentSegmentText,this.messages=Sa(this.messages,t,s.currentSegmentText),this.emitMessagesChange(),this.events.onTextUpdate?.(t,s.currentSegmentText))}emitMessagesChange(){this.events.onMessagesChange?.([...this.messages])}finalizeStream(){let t;for(const s of this.activeMessageIds){const n=this.getMessageState(s);if(!n)continue;this.completeAllToolCallsForMessage(s),n.currentSegmentText!==n.lastEmittedText&&this.emitTextUpdateForMessage(s),n.isComplete=!0;const r=this.messages.find(i=>i.id===s);r&&r.role==="assistant"&&(t=r)}if(this.activeMessageIds.clear(),t&&!this.hasError&&this.isWhitespaceOnlyMessage(t)){this.messages=this.messages.filter(s=>s.id!==t.id),this.emitMessagesChange();return}t&&this.events.onStreamEnd?.(t)}getCompletedToolCalls(){const t=[];for(const s of this.messageStates.values())for(const n of s.toolCalls.values())n.state==="input-complete"&&t.push({id:n.id,type:"function",function:{name:n.name,arguments:n.arguments}});return t}getResult(){const t=this.getCompletedToolCalls();let s="",n="";for(const r of this.messageStates.values())s+=r.totalTextContent,n+=r.thinkingContent;return{content:s,thinking:n||void 0,toolCalls:t.length>0?t:void 0,finishReason:this.finishReason}}getState(){let t="",s="";const n=new Map,r=[];for(const i of this.messageStates.values()){t+=i.totalTextContent,s+=i.thinkingContent;for(const[o,a]of i.toolCalls)n.set(o,a);r.push(...i.toolCallOrder)}return{content:t,thinking:s,toolCalls:n,toolCallOrder:r,finishReason:this.finishReason,done:this.isDone}}startRecording(){this.recordingEnabled=!0,this.recordingStartTime=Date.now(),this.recording={version:"1.0",timestamp:this.recordingStartTime,chunks:[]}}getRecording(){return this.recording}resetStreamState(){this.messageStates.clear(),this.activeMessageIds.clear(),this.activeRuns.clear(),this.toolCallToMessage.clear(),this.pendingManualMessageId=null,this.finishReason=null,this.hasError=!1,this.isDone=!1,this.chunkStrategy.reset?.()}reset(){this.resetStreamState(),this.messages=[]}isWhitespaceOnlyMessage(t){return t.parts.length===0?!1:t.parts.every(s=>s.type==="text"&&s.content.trim()==="")}static async replay(t,s){return new Pr(s).process(ba(t))}};function ba(e){return{async*[Symbol.asyncIterator](){for(const{chunk:t}of e.chunks)yield t}}}var Pa=class{constructor(e){this.clientId=e}clientCreated(e){this.emitEvent("client:created",{initialMessageCount:e})}loadingChanged(e){this.emitEvent("client:loading:changed",{isLoading:e})}errorChanged(e){this.emitEvent("client:error:changed",{error:e})}textUpdated(e,t,s){this.emitEvent("text:chunk:content",{streamId:e,messageId:t,content:s})}toolCallStateChanged(e,t,s,n,r,i){this.emitEvent("tools:call:updated",{streamId:e,messageId:t,toolCallId:s,toolName:n,state:r,arguments:i})}thinkingUpdated(e,t,s,n){this.emitEvent("text:chunk:thinking",{streamId:e,messageId:t,content:s,delta:n})}approvalRequested(e,t,s,n,r,i){this.emitEvent("tools:approval:requested",{streamId:e,messageId:t,toolCallId:s,toolName:n,input:r,approvalId:i})}messageAppended(e,t){const s=e.parts.filter(n=>n.type==="text").map(n=>n.content).join(" ");this.emitEvent("text:message:created",{streamId:t,messageId:e.id,role:e.role,content:s,parts:e.parts})}messageSent(e,t){const s=typeof t=="string"?t:t.filter(n=>n.type==="text").map(n=>n.content).join("");this.emitEvent("text:message:created",{messageId:e,role:"user",content:s,...Array.isArray(t)&&{parts:t}}),this.emitEvent("text:message:user",{messageId:e,role:"user",content:s,...Array.isArray(t)&&{parts:t}})}reloaded(e){this.emitEvent("client:reloaded",{fromMessageIndex:e})}stopped(){this.emitEvent("client:stopped")}messagesCleared(){this.emitEvent("client:messages:cleared")}toolResultAdded(e,t,s,n){this.emitEvent("tools:result:added",{toolCallId:e,toolName:t,output:s,state:n})}toolApprovalResponded(e,t,s){this.emitEvent("tools:approval:responded",{approvalId:e,toolCallId:t,approved:s})}},Ma=class extends Pa{emitEvent(e,t){e.startsWith("client:")||e.startsWith("tools:")||e.startsWith("text:")?In.emit(e,{...t,clientId:this.clientId,source:"client",timestamp:Date.now()}):In.emit(e,{...t,timestamp:Date.now()})}};function _a(e){if(!e)return{};if(e instanceof Headers){const t={};return e.forEach((s,n)=>{t[n]=s}),t}return e}async function*Ia(e,t){try{const s=new TextDecoder;let n="";for(;!t?.aborted;){const{done:r,value:i}=await e.read();if(r)break;n+=s.decode(i,{stream:!0});const o=n.split(`
3
- `);n=o.pop()||"";for(const a of o)a.trim()&&(yield a)}n.trim()&&(yield n)}finally{e.releaseLock()}}function On(e){if(!e)throw new Error("Connection adapter is required");const t="connect"in e,s="subscribe"in e,n="send"in e;if(t&&(s||n))throw new Error("Connection adapter must provide either connect or both subscribe and send, not both modes");if(s&&n)return{subscribe:e.subscribe.bind(e),send:e.send.bind(e)};if(!t)throw new Error("Connection adapter must provide either connect or both subscribe and send");let r=[],i=[];function o(a){const u=i.shift();u?u(a):r.push(a)}return{subscribe(a){const u=r.splice(0),l=[];return r=u,i=l,(async function*(){for(;!a?.aborted;){let h;u.length>0?h=u.shift():h=await new Promise(d=>{const c=()=>d(null);l.push(f=>{a?.removeEventListener("abort",c),d(f)}),a?.addEventListener("abort",c,{once:!0})}),h!==null&&(yield h)}})()},async send(a,u,l){let h=!1;try{const d=e.connect(a,u,l);for await(const c of d)(c.type==="RUN_FINISHED"||c.type==="RUN_ERROR")&&(h=!0),o(c);!l?.aborted&&!h&&o({type:"RUN_FINISHED",runId:`run-${Date.now()}`,model:"connect-wrapper",timestamp:Date.now(),finishReason:"stop"})}catch(d){throw!l?.aborted&&!h&&o({type:"RUN_ERROR",timestamp:Date.now(),message:d instanceof Error?d.message:"Unknown error in connect()",error:{message:d instanceof Error?d.message:"Unknown error in connect()"}}),d}}}}function jl(e,t={}){return{async*connect(s,n,r){const i=typeof e=="function"?e():e,o=typeof t=="function"?await t():t,a={"Content-Type":"application/json",..._a(o.headers)},u={messages:s,data:n,...o.body},l=await(o.fetchClient??fetch)(i,{method:"POST",headers:a,body:JSON.stringify(u),credentials:o.credentials||"same-origin",signal:r||o.signal});if(!l.ok)throw new Error(`HTTP error! status: ${l.status} ${l.statusText}`);const h=l.body?.getReader();if(!h)throw new Error("Response body is not readable");for await(const d of Ia(h,r)){const c=d.startsWith("data: ")?d.slice(6):d;if(c==="[DONE]"){console.warn("[@tanstack/ai-client] Received [DONE] sentinel. This is deprecated — upgrade your @tanstack/ai server package. RUN_FINISHED is the stream terminator.");continue}try{yield JSON.parse(c)}catch{console.warn("Failed to parse SSE chunk:",c)}}}}}var xa=class{constructor(e){if(this.body={},this.pendingMessageBody=void 0,this.isLoading=!1,this.isSubscribed=!1,this.error=void 0,this.status="ready",this.connectionStatus="disconnected",this.abortController=null,this.currentStreamId=null,this.currentMessageId=null,this.postStreamActions=[],this.pendingToolExecutions=new Map,this.continuationPending=!1,this.subscriptionAbortController=null,this.processingResolve=null,this.errorReportedGeneration=null,this.streamGeneration=0,this.continuationSkipped=!1,this.sessionGenerating=!1,this.activeRunIds=new Set,this.uniqueId=e.id||this.generateUniqueId("chat"),this.body=e.body||{},this.connection=On(e.connection),this.events=new Ma(this.uniqueId),this.clientToolsRef={current:new Map},e.tools)for(const t of e.tools)this.clientToolsRef.current.set(t.name,t);this.callbacksRef={current:{onResponse:e.onResponse||(()=>{}),onChunk:e.onChunk||(()=>{}),onFinish:e.onFinish||(()=>{}),onError:e.onError||(()=>{}),onMessagesChange:e.onMessagesChange||(()=>{}),onLoadingChange:e.onLoadingChange||(()=>{}),onErrorChange:e.onErrorChange||(()=>{}),onStatusChange:e.onStatusChange||(()=>{}),onSubscriptionChange:e.onSubscriptionChange||(()=>{}),onConnectionStatusChange:e.onConnectionStatusChange||(()=>{}),onSessionGeneratingChange:e.onSessionGeneratingChange||(()=>{}),onCustomEvent:e.onCustomEvent||(()=>{})}},this.processor=new wa({chunkStrategy:e.streamProcessor?.chunkStrategy,initialMessages:e.initialMessages,events:{onMessagesChange:t=>{this.callbacksRef.current.onMessagesChange(t)},onStreamStart:()=>{this.setStatus("streaming");const t=this.processor.getCurrentAssistantMessageId();if(!t)return;const s=this.processor.getMessages().find(n=>n.id===t);s&&(this.currentMessageId=s.id,this.events.messageAppended(s,this.currentStreamId||void 0))},onStreamEnd:t=>{this.callbacksRef.current.onFinish(t),this.setStatus("ready"),this.resolveProcessing()},onError:t=>{this.reportStreamError(t)},onTextUpdate:(t,s)=>{this.currentStreamId&&this.events.textUpdated(this.currentStreamId,t,s)},onThinkingUpdate:(t,s)=>{this.currentStreamId&&this.events.thinkingUpdated(this.currentStreamId,t,s)},onToolCallStateChange:(t,s,n,r)=>{const i=this.processor.getMessages().find(o=>o.id===t)?.parts.find(o=>o.type==="tool-call"&&o.id===s)?.name||"unknown";this.currentStreamId&&this.events.toolCallStateChanged(this.currentStreamId,t,s,i,n,r)},onToolCall:t=>{const s=this.clientToolsRef.current.get(t.toolName)?.execute;if(s){const n=(async()=>{try{const r=await s(t.input);await this.addToolResult({toolCallId:t.toolCallId,tool:t.toolName,output:r,state:"output-available"})}catch(r){await this.addToolResult({toolCallId:t.toolCallId,tool:t.toolName,output:null,state:"output-error",errorText:r.message})}finally{this.pendingToolExecutions.delete(t.toolCallId)}})();this.pendingToolExecutions.set(t.toolCallId,n)}},onApprovalRequest:t=>{this.currentStreamId&&this.events.approvalRequested(this.currentStreamId,this.currentMessageId||"",t.toolCallId,t.toolName,t.input,t.approvalId)},onCustomEvent:(t,s,n)=>{this.callbacksRef.current.onCustomEvent(t,s,n)}}}),this.events.clientCreated(this.processor.getMessages().length)}generateUniqueId(e){return`${e}-${Date.now()}-${Math.random().toString(36).substring(7)}`}setIsLoading(e){this.isLoading=e,this.callbacksRef.current.onLoadingChange(e),this.events.loadingChanged(e)}setStatus(e){this.status=e,this.callbacksRef.current.onStatusChange(e)}setIsSubscribed(e){this.isSubscribed=e,this.callbacksRef.current.onSubscriptionChange(e)}setConnectionStatus(e){this.connectionStatus=e,this.callbacksRef.current.onConnectionStatusChange(e)}setSessionGenerating(e){this.sessionGenerating!==e&&(this.sessionGenerating=e,this.callbacksRef.current.onSessionGeneratingChange(e))}resetSessionGenerating(){this.activeRunIds.clear(),this.setSessionGenerating(!1)}setError(e){this.error=e,this.callbacksRef.current.onErrorChange(e),this.events.errorChanged(e?.message||null)}abortSubscriptionLoop(){this.subscriptionAbortController?.abort(),this.subscriptionAbortController=null}resolveProcessing(){this.processingResolve?.(),this.processingResolve=null}cancelInFlightStream(e){this.abortController?.abort(),this.abortController=null,e?.abortSubscription&&this.abortSubscriptionLoop(),this.resolveProcessing(),this.setIsLoading(!1),e?.setReadyStatus&&this.setStatus("ready")}reportStreamError(e){const t=this.errorReportedGeneration===this.streamGeneration;this.setError(e),(this.isLoading||this.status==="submitted"||this.status==="streaming")&&this.setStatus("error"),t||(this.errorReportedGeneration=this.streamGeneration,this.callbacksRef.current.onError(e))}startSubscription(){this.subscriptionAbortController=new AbortController;const e=this.subscriptionAbortController.signal;this.consumeSubscription(e).catch(t=>{t instanceof Error&&t.name!=="AbortError"&&(this.setConnectionStatus("error"),this.resetSessionGenerating(),this.setIsSubscribed(!1),this.reportStreamError(t)),this.resolveProcessing()}).finally(()=>{this.subscriptionAbortController?.signal===e&&(this.subscriptionAbortController=null,!e.aborted&&this.isSubscribed&&(this.setIsSubscribed(!1),this.connectionStatus!=="error"&&this.setConnectionStatus("disconnected")))})}async consumeSubscription(e){const t=this.connection.subscribe(e);for await(const s of t){if(e.aborted)break;if(this.connectionStatus==="connecting"&&this.setConnectionStatus("connected"),this.callbacksRef.current.onChunk(s),this.processor.processChunk(s),s.type==="RUN_STARTED"&&(this.activeRunIds.add(s.runId),this.setSessionGenerating(!0)),s.type==="RUN_FINISHED"||s.type==="RUN_ERROR"){const n=s.type==="RUN_FINISHED"?s.runId:void 0;n?this.activeRunIds.delete(n):s.type==="RUN_ERROR"&&this.activeRunIds.clear(),this.setSessionGenerating(this.activeRunIds.size>0),this.resolveProcessing()}await new Promise(n=>setTimeout(n,0))}}ensureSubscription(){if(!this.isSubscribed){this.subscribe();return}(!this.subscriptionAbortController||this.subscriptionAbortController.signal.aborted)&&this.subscribe({restart:!0})}waitForProcessing(){return this.resolveProcessing(),new Promise(e=>{this.processingResolve=e})}async sendMessage(e,t){if(typeof e=="string"&&!e.trim()||this.isLoading)return;const s=this.normalizeMessageInput(e);this.pendingMessageBody=t;const n=this.processor.addUserMessage(s.content,s.id);this.events.messageSent(n.id,s.content),await this.streamResponse()}normalizeMessageInput(e){return typeof e=="string"?{content:e.trim()}:{content:e.content,id:e.id}}async append(e){const t=fa(e,wt);if(t.role==="system")return;const s=t;this.events.messageAppended(s);const n=this.processor.getMessages();if(this.processor.setMessages([...n,s]),this.isLoading){this.queuePostStreamAction(async()=>{await this.streamResponse()});return}await this.streamResponse()}async streamResponse(){if(this.isLoading)return!1;const e=++this.streamGeneration;this.setIsLoading(!0),this.setStatus("submitted"),this.setError(void 0),this.errorReportedGeneration=null,this.abortController=new AbortController,this.pendingToolExecutions.clear();let t=!1;try{const s=this.processor.getMessages();await this.callbacksRef.current.onResponse();const n={...this.body,...this.pendingMessageBody,conversationId:this.uniqueId};this.pendingMessageBody=void 0,this.currentStreamId=this.generateUniqueId("stream"),this.currentMessageId=null,this.processor.prepareAssistantMessage(),this.ensureSubscription();const r=this.waitForProcessing();if(await this.connection.send(s,n,this.abortController.signal),await r,e!==this.streamGeneration||this.status==="error")return!1;this.pendingToolExecutions.size>0&&await Promise.all(this.pendingToolExecutions.values()),this.processor.finalizeStream(),t=!0}catch(s){if(s instanceof Error){if(s.name==="AbortError")return!1;e===this.streamGeneration&&this.reportStreamError(s)}}finally{if(e===this.streamGeneration&&(this.currentStreamId=null,this.currentMessageId=null,this.abortController=null,this.setIsLoading(!1),this.pendingMessageBody=void 0,await this.drainPostStreamActions(),t)){const s=this.processor.getMessages().at(-1)?.parts.at(-1),{finishReason:n}=this.processor.getState();if(s?.type==="tool-result"&&n!=="stop"&&this.shouldAutoSend())try{await this.checkForContinuation()}catch(r){console.error("Failed to continue flow after tool result:",r)}}}return t}subscribe(e){const t=e?.restart===!0;this.isSubscribed&&!t||(this.isSubscribed&&t&&this.abortSubscriptionLoop(),this.setIsSubscribed(!0),this.setConnectionStatus("connecting"),this.startSubscription())}unsubscribe(){this.cancelInFlightStream({setReadyStatus:!0,abortSubscription:!0}),this.resetSessionGenerating(),this.setIsSubscribed(!1),this.setConnectionStatus("disconnected")}async reload(){const e=this.processor.getMessages();if(e.length===0)return;const t=e.findLastIndex(s=>s.role==="user");t!==-1&&(this.isLoading&&this.cancelInFlightStream(),this.events.reloaded(t),this.processor.removeMessagesAfter(t),await this.streamResponse())}stop(){this.cancelInFlightStream({setReadyStatus:!0}),this.events.stopped()}clear(){this.processor.clearMessages(),this.setError(void 0),this.events.messagesCleared()}async addToolResult(e){if(this.events.toolResultAdded(e.toolCallId,e.tool,e.output,e.state||"output-available"),this.processor.addToolResult(e.toolCallId,e.output,e.errorText),this.isLoading){this.queuePostStreamAction(()=>this.checkForContinuation());return}await this.checkForContinuation()}async addToolApprovalResponse(e){const t=this.processor.getMessages();let s;for(const n of t){const r=n.parts.find(i=>i.type==="tool-call"&&i.approval?.id===e.id);if(r){s=r.id;break}}if(s&&this.events.toolApprovalResponded(e.id,s,e.approved),this.processor.addToolApprovalResponse(e.id,e.approved),this.isLoading){this.queuePostStreamAction(()=>this.checkForContinuation());return}await this.checkForContinuation()}queuePostStreamAction(e){this.postStreamActions.push(e)}async drainPostStreamActions(){for(;this.postStreamActions.length>0;)await this.postStreamActions.shift()()}async checkForContinuation(){if(this.continuationPending||this.isLoading){this.continuationSkipped=!0;return}if(this.shouldAutoSend()){this.continuationPending=!0,this.continuationSkipped=!1;let e=!1;try{e=await this.streamResponse()}finally{this.continuationPending=!1}this.continuationSkipped&&e&&(this.continuationSkipped=!1,await this.checkForContinuation())}}shouldAutoSend(){return this.processor.areAllToolsComplete()}getMessages(){return this.processor.getMessages()}getIsLoading(){return this.isLoading}getStatus(){return this.status}getIsSubscribed(){return this.isSubscribed}getConnectionStatus(){return this.connectionStatus}getSessionGenerating(){return this.sessionGenerating}getError(){return this.error}setMessagesManually(e){this.processor.setMessages(e)}updateOptions(e){if(e.connection!==void 0){const t=this.isSubscribed;this.isLoading?this.cancelInFlightStream({setReadyStatus:!0,abortSubscription:!0}):t&&this.abortSubscriptionLoop(),this.resetSessionGenerating(),this.setIsSubscribed(!1),this.setConnectionStatus("disconnected"),this.connection=On(e.connection),t&&this.subscribe()}if(e.body!==void 0&&(this.body=e.body),e.tools!==void 0){this.clientToolsRef.current=new Map;for(const t of e.tools)this.clientToolsRef.current.set(t.name,t)}e.onResponse!==void 0&&(this.callbacksRef.current.onResponse=e.onResponse),e.onChunk!==void 0&&(this.callbacksRef.current.onChunk=e.onChunk),e.onFinish!==void 0&&(this.callbacksRef.current.onFinish=e.onFinish),e.onError!==void 0&&(this.callbacksRef.current.onError=e.onError),e.onSubscriptionChange!==void 0&&(this.callbacksRef.current.onSubscriptionChange=e.onSubscriptionChange),e.onConnectionStatusChange!==void 0&&(this.callbacksRef.current.onConnectionStatusChange=e.onConnectionStatusChange),e.onSessionGeneratingChange!==void 0&&(this.callbacksRef.current.onSessionGeneratingChange=e.onSessionGeneratingChange),e.onCustomEvent!==void 0&&(this.callbacksRef.current.onCustomEvent=e.onCustomEvent)}};function Gl(e){const t=(0,R.useId)(),s=e.id||t,[n,r]=(0,R.useState)(e.initialMessages||[]),[i,o]=(0,R.useState)(!1),[a,u]=(0,R.useState)(void 0),[l,h]=(0,R.useState)("ready"),[d,c]=(0,R.useState)(!1),[f,g]=(0,R.useState)("disconnected"),[p,v]=(0,R.useState)(!1),m=(0,R.useRef)(e.initialMessages||[]),y=(0,R.useRef)(!0);m.current=n;const C=(0,R.useRef)(e);C.current=e;const S=(0,R.useMemo)(()=>{const x=y.current?e.initialMessages||[]:m.current;return y.current=!1,new xa({connection:C.current.connection,id:s,initialMessages:x,body:C.current.body,onResponse:C.current.onResponse,onChunk:C.current.onChunk,onFinish:M=>{C.current.onFinish?.(M)},onError:M=>{C.current.onError?.(M)},tools:C.current.tools,onCustomEvent:C.current.onCustomEvent,streamProcessor:e.streamProcessor,onMessagesChange:M=>{r(M)},onLoadingChange:M=>{o(M)},onErrorChange:M=>{u(M)},onStatusChange:M=>{h(M)},onSubscriptionChange:M=>{c(M)},onConnectionStatusChange:M=>{g(M)},onSessionGeneratingChange:M=>{v(M)}})},[s]);(0,R.useEffect)(()=>{S.updateOptions({body:e.body})},[S,e.body]),(0,R.useEffect)(()=>{e.initialMessages&&e.initialMessages.length>0&&n.length===0&&S.setMessagesManually(e.initialMessages)},[]),(0,R.useEffect)(()=>{e.live?S.subscribe():S.unsubscribe()},[S,e.live]),(0,R.useEffect)(()=>()=>{e.live?S.unsubscribe():S.stop()},[S,e.live]);const w=(0,R.useCallback)(async x=>{await S.sendMessage(x)},[S]),P=(0,R.useCallback)(async x=>{await S.append(x)},[S]),b=(0,R.useCallback)(async()=>{await S.reload()},[S]),I=(0,R.useCallback)(()=>{S.stop()},[S]),_=(0,R.useCallback)(()=>{S.clear()},[S]);return{messages:n,sendMessage:w,append:P,reload:b,stop:I,isLoading:i,error:a,status:l,isSubscribed:d,connectionStatus:f,sessionGenerating:p,setMessages:(0,R.useCallback)(x=>{S.setMessagesManually(x)},[S]),clear:_,addToolResult:(0,R.useCallback)(async x=>{await S.addToolResult(x)},[S]),addToolApprovalResponse:(0,R.useCallback)(async x=>{await S.addToolApprovalResponse(x)},[S])}}var ql=new Uint8Array(128).fill(128);function ce(e,t){return typeof e=="function"?e(t):e}function Q(e,t){return s=>{t.setState(n=>({...n,[e]:ce(s,n[e])}))}}function _t(e){return e instanceof Function}function Ea(e){return Array.isArray(e)&&e.every(t=>typeof t=="number")}function La(e,t){const s=[],n=r=>{r.forEach(i=>{s.push(i);const o=t(i);o!=null&&o.length&&n(o)})};return n(e),s}function L(e,t,s){let n=[],r;return i=>{let o;s.key&&s.debug&&(o=Date.now());const a=e(i);if(!(a.length!==n.length||a.some((l,h)=>n[h]!==l)))return r;n=a;let u;if(s.key&&s.debug&&(u=Date.now()),r=t(...a),s==null||s.onChange==null||s.onChange(r),s.key&&s.debug&&s!=null&&s.debug()){const l=Math.round((Date.now()-o)*100)/100,h=Math.round((Date.now()-u)*100)/100,d=h/16,c=(f,g)=>{for(f=String(f);f.length<g;)f=" "+f;return f};console.info(`%c⏱ ${c(h,5)} /${c(l,5)} ms`,`
4
- font-size: .6rem;
5
- font-weight: bold;
6
- color: hsl(${Math.max(0,Math.min(120-120*d,120))}deg 100% 31%);`,s?.key)}return r}}function T(e,t,s,n){return{debug:()=>{var r;return(r=e?.debugAll)!=null?r:e[t]},key:!1,onChange:n}}function Ta(e,t,s,n){const r=()=>{var o;return(o=i.getValue())!=null?o:e.options.renderFallbackValue},i={id:`${t.id}_${s.id}`,row:t,column:s,getValue:()=>t.getValue(n),renderValue:r,getContext:L(()=>[e,s,t,i],(o,a,u,l)=>({table:o,column:a,row:u,cell:l,getValue:l.getValue,renderValue:l.renderValue}),T(e.options,"debugCells","cell.getContext"))};return e._features.forEach(o=>{o.createCell==null||o.createCell(i,s,t,e)},{}),i}function Oa(e,t,s,n){var r,i;const o={...e._getDefaultColumnDef(),...t},a=o.accessorKey;let u=(r=(i=o.id)!=null?i:a?typeof String.prototype.replaceAll=="function"?a.replaceAll(".","_"):a.replace(/\./g,"_"):void 0)!=null?r:typeof o.header=="string"?o.header:void 0,l;if(o.accessorFn?l=o.accessorFn:a&&(a.includes(".")?l=d=>{let c=d;for(const g of a.split(".")){var f;c=(f=c)==null?void 0:f[g]}return c}:l=d=>d[o.accessorKey]),!u)throw new Error;let h={id:`${String(u)}`,accessorFn:l,parent:n,depth:s,columnDef:o,columns:[],getFlatColumns:L(()=>[!0],()=>{var d;return[h,...(d=h.columns)==null?void 0:d.flatMap(c=>c.getFlatColumns())]},T(e.options,"debugColumns","column.getFlatColumns")),getLeafColumns:L(()=>[e._getOrderColumnsFn()],d=>{var c;return(c=h.columns)!=null&&c.length?d(h.columns.flatMap(f=>f.getLeafColumns())):[h]},T(e.options,"debugColumns","column.getLeafColumns"))};for(const d of e._features)d.createColumn==null||d.createColumn(h,e);return h}var z="debugHeaders";function Fn(e,t,s){var n;let r={id:(n=s.id)!=null?n:t.id,column:t,index:s.index,isPlaceholder:!!s.isPlaceholder,placeholderId:s.placeholderId,depth:s.depth,subHeaders:[],colSpan:0,rowSpan:0,headerGroup:null,getLeafHeaders:()=>{const i=[],o=a=>{a.subHeaders&&a.subHeaders.length&&a.subHeaders.map(o),i.push(a)};return o(r),i},getContext:()=>({table:e,header:r,column:t})};return e._features.forEach(i=>{i.createHeader==null||i.createHeader(r,e)}),r}var Fa={createTable:e=>{e.getHeaderGroups=L(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(t,s,n,r)=>{var i,o;const a=(i=n?.map(h=>s.find(d=>d.id===h)).filter(Boolean))!=null?i:[],u=(o=r?.map(h=>s.find(d=>d.id===h)).filter(Boolean))!=null?o:[],l=s.filter(h=>!(n!=null&&n.includes(h.id))&&!(r!=null&&r.includes(h.id)));return ut(t,[...a,...l,...u],e)},T(e.options,z,"getHeaderGroups")),e.getCenterHeaderGroups=L(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(t,s,n,r)=>(s=s.filter(i=>!(n!=null&&n.includes(i.id))&&!(r!=null&&r.includes(i.id))),ut(t,s,e,"center")),T(e.options,z,"getCenterHeaderGroups")),e.getLeftHeaderGroups=L(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left],(t,s,n)=>{var r;return ut(t,(r=n?.map(i=>s.find(o=>o.id===i)).filter(Boolean))!=null?r:[],e,"left")},T(e.options,z,"getLeftHeaderGroups")),e.getRightHeaderGroups=L(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.right],(t,s,n)=>{var r;return ut(t,(r=n?.map(i=>s.find(o=>o.id===i)).filter(Boolean))!=null?r:[],e,"right")},T(e.options,z,"getRightHeaderGroups")),e.getFooterGroups=L(()=>[e.getHeaderGroups()],t=>[...t].reverse(),T(e.options,z,"getFooterGroups")),e.getLeftFooterGroups=L(()=>[e.getLeftHeaderGroups()],t=>[...t].reverse(),T(e.options,z,"getLeftFooterGroups")),e.getCenterFooterGroups=L(()=>[e.getCenterHeaderGroups()],t=>[...t].reverse(),T(e.options,z,"getCenterFooterGroups")),e.getRightFooterGroups=L(()=>[e.getRightHeaderGroups()],t=>[...t].reverse(),T(e.options,z,"getRightFooterGroups")),e.getFlatHeaders=L(()=>[e.getHeaderGroups()],t=>t.map(s=>s.headers).flat(),T(e.options,z,"getFlatHeaders")),e.getLeftFlatHeaders=L(()=>[e.getLeftHeaderGroups()],t=>t.map(s=>s.headers).flat(),T(e.options,z,"getLeftFlatHeaders")),e.getCenterFlatHeaders=L(()=>[e.getCenterHeaderGroups()],t=>t.map(s=>s.headers).flat(),T(e.options,z,"getCenterFlatHeaders")),e.getRightFlatHeaders=L(()=>[e.getRightHeaderGroups()],t=>t.map(s=>s.headers).flat(),T(e.options,z,"getRightFlatHeaders")),e.getCenterLeafHeaders=L(()=>[e.getCenterFlatHeaders()],t=>t.filter(s=>{var n;return!((n=s.subHeaders)!=null&&n.length)}),T(e.options,z,"getCenterLeafHeaders")),e.getLeftLeafHeaders=L(()=>[e.getLeftFlatHeaders()],t=>t.filter(s=>{var n;return!((n=s.subHeaders)!=null&&n.length)}),T(e.options,z,"getLeftLeafHeaders")),e.getRightLeafHeaders=L(()=>[e.getRightFlatHeaders()],t=>t.filter(s=>{var n;return!((n=s.subHeaders)!=null&&n.length)}),T(e.options,z,"getRightLeafHeaders")),e.getLeafHeaders=L(()=>[e.getLeftHeaderGroups(),e.getCenterHeaderGroups(),e.getRightHeaderGroups()],(t,s,n)=>{var r,i,o,a,u,l;return[...(r=(i=t[0])==null?void 0:i.headers)!=null?r:[],...(o=(a=s[0])==null?void 0:a.headers)!=null?o:[],...(u=(l=n[0])==null?void 0:l.headers)!=null?u:[]].map(h=>h.getLeafHeaders()).flat()},T(e.options,z,"getLeafHeaders"))}};function ut(e,t,s,n){var r,i;let o=0;const a=function(d,c){c===void 0&&(c=1),o=Math.max(o,c),d.filter(f=>f.getIsVisible()).forEach(f=>{var g;(g=f.columns)!=null&&g.length&&a(f.columns,c+1)},0)};a(e);let u=[];const l=(d,c)=>{const f={depth:c,id:[n,`${c}`].filter(Boolean).join("_"),headers:[]},g=[];d.forEach(p=>{const v=[...g].reverse()[0],m=p.column.depth===f.depth;let y,C=!1;if(m&&p.column.parent?y=p.column.parent:(y=p.column,C=!0),v&&v?.column===y)v.subHeaders.push(p);else{const S=Fn(s,y,{id:[n,c,y.id,p?.id].filter(Boolean).join("_"),isPlaceholder:C,placeholderId:C?`${g.filter(w=>w.column===y).length}`:void 0,depth:c,index:g.length});S.subHeaders.push(p),g.push(S)}f.headers.push(p),p.headerGroup=f}),u.push(f),c>0&&l(g,c-1)};l(t.map((d,c)=>Fn(s,d,{depth:o,index:c})),o-1),u.reverse();const h=d=>d.filter(c=>c.column.getIsVisible()).map(c=>{let f=0,g=0,p=[0];c.subHeaders&&c.subHeaders.length?(p=[],h(c.subHeaders).forEach(m=>{let{colSpan:y,rowSpan:C}=m;f+=y,p.push(C)})):f=1;const v=Math.min(...p);return g=g+v,c.colSpan=f,c.rowSpan=g,{colSpan:f,rowSpan:g}});return h((r=(i=u[0])==null?void 0:i.headers)!=null?r:[]),u}var Aa=(e,t,s,n,r,i,o)=>{let a={id:t,index:n,original:s,depth:r,parentId:o,_valuesCache:{},_uniqueValuesCache:{},getValue:u=>{if(a._valuesCache.hasOwnProperty(u))return a._valuesCache[u];const l=e.getColumn(u);if(l!=null&&l.accessorFn)return a._valuesCache[u]=l.accessorFn(a.original,n),a._valuesCache[u]},getUniqueValues:u=>{if(a._uniqueValuesCache.hasOwnProperty(u))return a._uniqueValuesCache[u];const l=e.getColumn(u);if(l!=null&&l.accessorFn)return l.columnDef.getUniqueValues?(a._uniqueValuesCache[u]=l.columnDef.getUniqueValues(a.original,n),a._uniqueValuesCache[u]):(a._uniqueValuesCache[u]=[a.getValue(u)],a._uniqueValuesCache[u])},renderValue:u=>{var l;return(l=a.getValue(u))!=null?l:e.options.renderFallbackValue},subRows:i??[],getLeafRows:()=>La(a.subRows,u=>u.subRows),getParentRow:()=>a.parentId?e.getRow(a.parentId,!0):void 0,getParentRows:()=>{let u=[],l=a;for(;;){const h=l.getParentRow();if(!h)break;u.push(h),l=h}return u.reverse()},getAllCells:L(()=>[e.getAllLeafColumns()],u=>u.map(l=>Ta(e,a,l,l.id)),T(e.options,"debugRows","getAllCells")),_getAllCellsByColumnId:L(()=>[a.getAllCells()],u=>u.reduce((l,h)=>(l[h.column.id]=h,l),{}),T(e.options,"debugRows","getAllCellsByColumnId"))};for(let u=0;u<e._features.length;u++){const l=e._features[u];l==null||l.createRow==null||l.createRow(a,e)}return a},ka={createColumn:(e,t)=>{e._getFacetedRowModel=t.options.getFacetedRowModel&&t.options.getFacetedRowModel(t,e.id),e.getFacetedRowModel=()=>e._getFacetedRowModel?e._getFacetedRowModel():t.getPreFilteredRowModel(),e._getFacetedUniqueValues=t.options.getFacetedUniqueValues&&t.options.getFacetedUniqueValues(t,e.id),e.getFacetedUniqueValues=()=>e._getFacetedUniqueValues?e._getFacetedUniqueValues():new Map,e._getFacetedMinMaxValues=t.options.getFacetedMinMaxValues&&t.options.getFacetedMinMaxValues(t,e.id),e.getFacetedMinMaxValues=()=>{if(e._getFacetedMinMaxValues)return e._getFacetedMinMaxValues()}}},Mr=(e,t,s)=>{var n,r;const i=s==null||(n=s.toString())==null?void 0:n.toLowerCase();return!!(!((r=e.getValue(t))==null||(r=r.toString())==null||(r=r.toLowerCase())==null)&&r.includes(i))};Mr.autoRemove=e=>te(e);var _r=(e,t,s)=>{var n;return!!(!((n=e.getValue(t))==null||(n=n.toString())==null)&&n.includes(s))};_r.autoRemove=e=>te(e);var Ir=(e,t,s)=>{var n;return((n=e.getValue(t))==null||(n=n.toString())==null?void 0:n.toLowerCase())===s?.toLowerCase()};Ir.autoRemove=e=>te(e);var xr=(e,t,s)=>{var n;return(n=e.getValue(t))==null?void 0:n.includes(s)};xr.autoRemove=e=>te(e);var Er=(e,t,s)=>!s.some(n=>{var r;return!((r=e.getValue(t))!=null&&r.includes(n))});Er.autoRemove=e=>te(e)||!(e!=null&&e.length);var Lr=(e,t,s)=>s.some(n=>{var r;return(r=e.getValue(t))==null?void 0:r.includes(n)});Lr.autoRemove=e=>te(e)||!(e!=null&&e.length);var Tr=(e,t,s)=>e.getValue(t)===s;Tr.autoRemove=e=>te(e);var Or=(e,t,s)=>e.getValue(t)==s;Or.autoRemove=e=>te(e);var Ms=(e,t,s)=>{let[n,r]=s;const i=e.getValue(t);return i>=n&&i<=r};Ms.resolveFilterValue=e=>{let[t,s]=e,n=typeof t!="number"?parseFloat(t):t,r=typeof s!="number"?parseFloat(s):s,i=t===null||Number.isNaN(n)?-1/0:n,o=s===null||Number.isNaN(r)?1/0:r;if(i>o){const a=i;i=o,o=a}return[i,o]};Ms.autoRemove=e=>te(e)||te(e[0])&&te(e[1]);var re={includesString:Mr,includesStringSensitive:_r,equalsString:Ir,arrIncludes:xr,arrIncludesAll:Er,arrIncludesSome:Lr,equals:Tr,weakEquals:Or,inNumberRange:Ms};function te(e){return e==null||e===""}var Da={getDefaultColumnDef:()=>({filterFn:"auto"}),getInitialState:e=>({columnFilters:[],...e}),getDefaultOptions:e=>({onColumnFiltersChange:Q("columnFilters",e),filterFromLeafRows:!1,maxLeafRowFilterDepth:100}),createColumn:(e,t)=>{e.getAutoFilterFn=()=>{const s=t.getCoreRowModel().flatRows[0],n=s?.getValue(e.id);return typeof n=="string"?re.includesString:typeof n=="number"?re.inNumberRange:typeof n=="boolean"||n!==null&&typeof n=="object"?re.equals:Array.isArray(n)?re.arrIncludes:re.weakEquals},e.getFilterFn=()=>{var s,n;return _t(e.columnDef.filterFn)?e.columnDef.filterFn:e.columnDef.filterFn==="auto"?e.getAutoFilterFn():(s=(n=t.options.filterFns)==null?void 0:n[e.columnDef.filterFn])!=null?s:re[e.columnDef.filterFn]},e.getCanFilter=()=>{var s,n,r;return((s=e.columnDef.enableColumnFilter)!=null?s:!0)&&((n=t.options.enableColumnFilters)!=null?n:!0)&&((r=t.options.enableFilters)!=null?r:!0)&&!!e.accessorFn},e.getIsFiltered=()=>e.getFilterIndex()>-1,e.getFilterValue=()=>{var s;return(s=t.getState().columnFilters)==null||(s=s.find(n=>n.id===e.id))==null?void 0:s.value},e.getFilterIndex=()=>{var s,n;return(s=(n=t.getState().columnFilters)==null?void 0:n.findIndex(r=>r.id===e.id))!=null?s:-1},e.setFilterValue=s=>{t.setColumnFilters(n=>{const r=e.getFilterFn(),i=n?.find(h=>h.id===e.id),o=ce(s,i?i.value:void 0);if(An(r,o,e)){var a;return(a=n?.filter(h=>h.id!==e.id))!=null?a:[]}const u={id:e.id,value:o};if(i){var l;return(l=n?.map(h=>h.id===e.id?u:h))!=null?l:[]}return n!=null&&n.length?[...n,u]:[u]})}},createRow:(e,t)=>{e.columnFilters={},e.columnFiltersMeta={}},createTable:e=>{e.setColumnFilters=t=>{const s=e.getAllLeafColumns(),n=r=>{var i;return(i=ce(t,r))==null?void 0:i.filter(o=>{const a=s.find(u=>u.id===o.id);return!(a&&An(a.getFilterFn(),o.value,a))})};e.options.onColumnFiltersChange==null||e.options.onColumnFiltersChange(n)},e.resetColumnFilters=t=>{var s,n;e.setColumnFilters(t?[]:(s=(n=e.initialState)==null?void 0:n.columnFilters)!=null?s:[])},e.getPreFilteredRowModel=()=>e.getCoreRowModel(),e.getFilteredRowModel=()=>(!e._getFilteredRowModel&&e.options.getFilteredRowModel&&(e._getFilteredRowModel=e.options.getFilteredRowModel(e)),e.options.manualFiltering||!e._getFilteredRowModel?e.getPreFilteredRowModel():e._getFilteredRowModel())}};function An(e,t,s){return(e&&e.autoRemove?e.autoRemove(t,s):!1)||typeof t>"u"||typeof t=="string"&&!t}var $a=(e,t,s)=>s.reduce((n,r)=>{const i=r.getValue(e);return n+(typeof i=="number"?i:0)},0),Na=(e,t,s)=>{let n;return s.forEach(r=>{const i=r.getValue(e);i!=null&&(n>i||n===void 0&&i>=i)&&(n=i)}),n},Va=(e,t,s)=>{let n;return s.forEach(r=>{const i=r.getValue(e);i!=null&&(n<i||n===void 0&&i>=i)&&(n=i)}),n},Ba=(e,t,s)=>{let n,r;return s.forEach(i=>{const o=i.getValue(e);o!=null&&(n===void 0?o>=o&&(n=r=o):(n>o&&(n=o),r<o&&(r=o)))}),[n,r]},za=(e,t)=>{let s=0,n=0;if(t.forEach(r=>{let i=r.getValue(e);i!=null&&(i=+i)>=i&&(++s,n+=i)}),s)return n/s},Ha=(e,t)=>{if(!t.length)return;const s=t.map(i=>i.getValue(e));if(!Ea(s))return;if(s.length===1)return s[0];const n=Math.floor(s.length/2),r=s.sort((i,o)=>i-o);return s.length%2!==0?r[n]:(r[n-1]+r[n])/2},Ua=(e,t)=>Array.from(new Set(t.map(s=>s.getValue(e))).values()),ja=(e,t)=>new Set(t.map(s=>s.getValue(e))).size,Ga=(e,t)=>t.length,jt={sum:$a,min:Na,max:Va,extent:Ba,mean:za,median:Ha,unique:Ua,uniqueCount:ja,count:Ga},qa={getDefaultColumnDef:()=>({aggregatedCell:e=>{var t,s;return(t=(s=e.getValue())==null||s.toString==null?void 0:s.toString())!=null?t:null},aggregationFn:"auto"}),getInitialState:e=>({grouping:[],...e}),getDefaultOptions:e=>({onGroupingChange:Q("grouping",e),groupedColumnMode:"reorder"}),createColumn:(e,t)=>{e.toggleGrouping=()=>{t.setGrouping(s=>s!=null&&s.includes(e.id)?s.filter(n=>n!==e.id):[...s??[],e.id])},e.getCanGroup=()=>{var s,n;return((s=e.columnDef.enableGrouping)!=null?s:!0)&&((n=t.options.enableGrouping)!=null?n:!0)&&(!!e.accessorFn||!!e.columnDef.getGroupingValue)},e.getIsGrouped=()=>{var s;return(s=t.getState().grouping)==null?void 0:s.includes(e.id)},e.getGroupedIndex=()=>{var s;return(s=t.getState().grouping)==null?void 0:s.indexOf(e.id)},e.getToggleGroupingHandler=()=>{const s=e.getCanGroup();return()=>{s&&e.toggleGrouping()}},e.getAutoAggregationFn=()=>{const s=t.getCoreRowModel().flatRows[0],n=s?.getValue(e.id);if(typeof n=="number")return jt.sum;if(Object.prototype.toString.call(n)==="[object Date]")return jt.extent},e.getAggregationFn=()=>{var s,n;if(!e)throw new Error;return _t(e.columnDef.aggregationFn)?e.columnDef.aggregationFn:e.columnDef.aggregationFn==="auto"?e.getAutoAggregationFn():(s=(n=t.options.aggregationFns)==null?void 0:n[e.columnDef.aggregationFn])!=null?s:jt[e.columnDef.aggregationFn]}},createTable:e=>{e.setGrouping=t=>e.options.onGroupingChange==null?void 0:e.options.onGroupingChange(t),e.resetGrouping=t=>{var s,n;e.setGrouping(t?[]:(s=(n=e.initialState)==null?void 0:n.grouping)!=null?s:[])},e.getPreGroupedRowModel=()=>e.getFilteredRowModel(),e.getGroupedRowModel=()=>(!e._getGroupedRowModel&&e.options.getGroupedRowModel&&(e._getGroupedRowModel=e.options.getGroupedRowModel(e)),e.options.manualGrouping||!e._getGroupedRowModel?e.getPreGroupedRowModel():e._getGroupedRowModel())},createRow:(e,t)=>{e.getIsGrouped=()=>!!e.groupingColumnId,e.getGroupingValue=s=>{if(e._groupingValuesCache.hasOwnProperty(s))return e._groupingValuesCache[s];const n=t.getColumn(s);return n!=null&&n.columnDef.getGroupingValue?(e._groupingValuesCache[s]=n.columnDef.getGroupingValue(e.original),e._groupingValuesCache[s]):e.getValue(s)},e._groupingValuesCache={}},createCell:(e,t,s,n)=>{e.getIsGrouped=()=>t.getIsGrouped()&&t.id===s.groupingColumnId,e.getIsPlaceholder=()=>!e.getIsGrouped()&&t.getIsGrouped(),e.getIsAggregated=()=>{var r;return!e.getIsGrouped()&&!e.getIsPlaceholder()&&!!((r=s.subRows)!=null&&r.length)}}};function Wa(e,t,s){if(!(t!=null&&t.length)||!s)return e;const n=e.filter(r=>!t.includes(r.id));return s==="remove"?n:[...t.map(r=>e.find(i=>i.id===r)).filter(Boolean),...n]}var Ka={getInitialState:e=>({columnOrder:[],...e}),getDefaultOptions:e=>({onColumnOrderChange:Q("columnOrder",e)}),createColumn:(e,t)=>{e.getIndex=L(s=>[Ye(t,s)],s=>s.findIndex(n=>n.id===e.id),T(t.options,"debugColumns","getIndex")),e.getIsFirstColumn=s=>{var n;return((n=Ye(t,s)[0])==null?void 0:n.id)===e.id},e.getIsLastColumn=s=>{var n;const r=Ye(t,s);return((n=r[r.length-1])==null?void 0:n.id)===e.id}},createTable:e=>{e.setColumnOrder=t=>e.options.onColumnOrderChange==null?void 0:e.options.onColumnOrderChange(t),e.resetColumnOrder=t=>{var s;e.setColumnOrder(t?[]:(s=e.initialState.columnOrder)!=null?s:[])},e._getOrderColumnsFn=L(()=>[e.getState().columnOrder,e.getState().grouping,e.options.groupedColumnMode],(t,s,n)=>r=>{let i=[];if(!(t!=null&&t.length))i=r;else{const o=[...t],a=[...r];for(;a.length&&o.length;){const u=o.shift(),l=a.findIndex(h=>h.id===u);l>-1&&i.push(a.splice(l,1)[0])}i=[...i,...a]}return Wa(i,s,n)},T(e.options,"debugTable","_getOrderColumnsFn"))}},Gt=()=>({left:[],right:[]}),Qa={getInitialState:e=>({columnPinning:Gt(),...e}),getDefaultOptions:e=>({onColumnPinningChange:Q("columnPinning",e)}),createColumn:(e,t)=>{e.pin=s=>{const n=e.getLeafColumns().map(r=>r.id).filter(Boolean);t.setColumnPinning(r=>{var i,o;if(s==="right"){var a,u;return{left:((a=r?.left)!=null?a:[]).filter(d=>!(n!=null&&n.includes(d))),right:[...((u=r?.right)!=null?u:[]).filter(d=>!(n!=null&&n.includes(d))),...n]}}if(s==="left"){var l,h;return{left:[...((l=r?.left)!=null?l:[]).filter(d=>!(n!=null&&n.includes(d))),...n],right:((h=r?.right)!=null?h:[]).filter(d=>!(n!=null&&n.includes(d)))}}return{left:((i=r?.left)!=null?i:[]).filter(d=>!(n!=null&&n.includes(d))),right:((o=r?.right)!=null?o:[]).filter(d=>!(n!=null&&n.includes(d)))}})},e.getCanPin=()=>e.getLeafColumns().some(s=>{var n,r,i;return((n=s.columnDef.enablePinning)!=null?n:!0)&&((r=(i=t.options.enableColumnPinning)!=null?i:t.options.enablePinning)!=null?r:!0)}),e.getIsPinned=()=>{const s=e.getLeafColumns().map(a=>a.id),{left:n,right:r}=t.getState().columnPinning,i=s.some(a=>n?.includes(a)),o=s.some(a=>r?.includes(a));return i?"left":o?"right":!1},e.getPinnedIndex=()=>{var s,n;const r=e.getIsPinned();return r?(s=(n=t.getState().columnPinning)==null||(n=n[r])==null?void 0:n.indexOf(e.id))!=null?s:-1:0}},createRow:(e,t)=>{e.getCenterVisibleCells=L(()=>[e._getAllVisibleCells(),t.getState().columnPinning.left,t.getState().columnPinning.right],(s,n,r)=>{const i=[...n??[],...r??[]];return s.filter(o=>!i.includes(o.column.id))},T(t.options,"debugRows","getCenterVisibleCells")),e.getLeftVisibleCells=L(()=>[e._getAllVisibleCells(),t.getState().columnPinning.left],(s,n)=>(n??[]).map(r=>s.find(i=>i.column.id===r)).filter(Boolean).map(r=>({...r,position:"left"})),T(t.options,"debugRows","getLeftVisibleCells")),e.getRightVisibleCells=L(()=>[e._getAllVisibleCells(),t.getState().columnPinning.right],(s,n)=>(n??[]).map(r=>s.find(i=>i.column.id===r)).filter(Boolean).map(r=>({...r,position:"right"})),T(t.options,"debugRows","getRightVisibleCells"))},createTable:e=>{e.setColumnPinning=t=>e.options.onColumnPinningChange==null?void 0:e.options.onColumnPinningChange(t),e.resetColumnPinning=t=>{var s,n;return e.setColumnPinning(t?Gt():(s=(n=e.initialState)==null?void 0:n.columnPinning)!=null?s:Gt())},e.getIsSomeColumnsPinned=t=>{var s;const n=e.getState().columnPinning;if(!t){var r,i;return!!((r=n.left)!=null&&r.length||(i=n.right)!=null&&i.length)}return!!((s=n[t])!=null&&s.length)},e.getLeftLeafColumns=L(()=>[e.getAllLeafColumns(),e.getState().columnPinning.left],(t,s)=>(s??[]).map(n=>t.find(r=>r.id===n)).filter(Boolean),T(e.options,"debugColumns","getLeftLeafColumns")),e.getRightLeafColumns=L(()=>[e.getAllLeafColumns(),e.getState().columnPinning.right],(t,s)=>(s??[]).map(n=>t.find(r=>r.id===n)).filter(Boolean),T(e.options,"debugColumns","getRightLeafColumns")),e.getCenterLeafColumns=L(()=>[e.getAllLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(t,s,n)=>{const r=[...s??[],...n??[]];return t.filter(i=>!r.includes(i.id))},T(e.options,"debugColumns","getCenterLeafColumns"))}};function Ja(e){return e||(typeof document<"u"?document:null)}var ct={size:150,minSize:20,maxSize:Number.MAX_SAFE_INTEGER},qt=()=>({startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,isResizingColumn:!1,columnSizingStart:[]}),Ya={getDefaultColumnDef:()=>ct,getInitialState:e=>({columnSizing:{},columnSizingInfo:qt(),...e}),getDefaultOptions:e=>({columnResizeMode:"onEnd",columnResizeDirection:"ltr",onColumnSizingChange:Q("columnSizing",e),onColumnSizingInfoChange:Q("columnSizingInfo",e)}),createColumn:(e,t)=>{e.getSize=()=>{var s,n,r;const i=t.getState().columnSizing[e.id];return Math.min(Math.max((s=e.columnDef.minSize)!=null?s:ct.minSize,(n=i??e.columnDef.size)!=null?n:ct.size),(r=e.columnDef.maxSize)!=null?r:ct.maxSize)},e.getStart=L(s=>[s,Ye(t,s),t.getState().columnSizing],(s,n)=>n.slice(0,e.getIndex(s)).reduce((r,i)=>r+i.getSize(),0),T(t.options,"debugColumns","getStart")),e.getAfter=L(s=>[s,Ye(t,s),t.getState().columnSizing],(s,n)=>n.slice(e.getIndex(s)+1).reduce((r,i)=>r+i.getSize(),0),T(t.options,"debugColumns","getAfter")),e.resetSize=()=>{t.setColumnSizing(s=>{let{[e.id]:n,...r}=s;return r})},e.getCanResize=()=>{var s,n;return((s=e.columnDef.enableResizing)!=null?s:!0)&&((n=t.options.enableColumnResizing)!=null?n:!0)},e.getIsResizing=()=>t.getState().columnSizingInfo.isResizingColumn===e.id},createHeader:(e,t)=>{e.getSize=()=>{let s=0;const n=r=>{if(r.subHeaders.length)r.subHeaders.forEach(n);else{var i;s+=(i=r.column.getSize())!=null?i:0}};return n(e),s},e.getStart=()=>{if(e.index>0){const s=e.headerGroup.headers[e.index-1];return s.getStart()+s.getSize()}return 0},e.getResizeHandler=s=>{const n=t.getColumn(e.column.id),r=n?.getCanResize();return i=>{if(!n||!r||(i.persist==null||i.persist(),Wt(i)&&i.touches&&i.touches.length>1))return;const o=e.getSize(),a=e?e.getLeafHeaders().map(m=>[m.column.id,m.column.getSize()]):[[n.id,n.getSize()]],u=Wt(i)?Math.round(i.touches[0].clientX):i.clientX,l={},h=(m,y)=>{typeof y=="number"&&(t.setColumnSizingInfo(C=>{var S,w;const P=t.options.columnResizeDirection==="rtl"?-1:1,b=(y-((S=C?.startOffset)!=null?S:0))*P,I=Math.max(b/((w=C?.startSize)!=null?w:0),-.999999);return C.columnSizingStart.forEach(_=>{let[x,M]=_;l[x]=Math.round(Math.max(M+M*I,0)*100)/100}),{...C,deltaOffset:b,deltaPercentage:I}}),(t.options.columnResizeMode==="onChange"||m==="end")&&t.setColumnSizing(C=>({...C,...l})))},d=m=>h("move",m),c=m=>{h("end",m),t.setColumnSizingInfo(y=>({...y,isResizingColumn:!1,startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,columnSizingStart:[]}))},f=Ja(s),g={moveHandler:m=>d(m.clientX),upHandler:m=>{f?.removeEventListener("mousemove",g.moveHandler),f?.removeEventListener("mouseup",g.upHandler),c(m.clientX)}},p={moveHandler:m=>(m.cancelable&&(m.preventDefault(),m.stopPropagation()),d(m.touches[0].clientX),!1),upHandler:m=>{var y;f?.removeEventListener("touchmove",p.moveHandler),f?.removeEventListener("touchend",p.upHandler),m.cancelable&&(m.preventDefault(),m.stopPropagation()),c((y=m.touches[0])==null?void 0:y.clientX)}},v=Xa()?{passive:!1}:!1;Wt(i)?(f?.addEventListener("touchmove",p.moveHandler,v),f?.addEventListener("touchend",p.upHandler,v)):(f?.addEventListener("mousemove",g.moveHandler,v),f?.addEventListener("mouseup",g.upHandler,v)),t.setColumnSizingInfo(m=>({...m,startOffset:u,startSize:o,deltaOffset:0,deltaPercentage:0,columnSizingStart:a,isResizingColumn:n.id}))}}},createTable:e=>{e.setColumnSizing=t=>e.options.onColumnSizingChange==null?void 0:e.options.onColumnSizingChange(t),e.setColumnSizingInfo=t=>e.options.onColumnSizingInfoChange==null?void 0:e.options.onColumnSizingInfoChange(t),e.resetColumnSizing=t=>{var s;e.setColumnSizing(t?{}:(s=e.initialState.columnSizing)!=null?s:{})},e.resetHeaderSizeInfo=t=>{var s;e.setColumnSizingInfo(t?qt():(s=e.initialState.columnSizingInfo)!=null?s:qt())},e.getTotalSize=()=>{var t,s;return(t=(s=e.getHeaderGroups()[0])==null?void 0:s.headers.reduce((n,r)=>n+r.getSize(),0))!=null?t:0},e.getLeftTotalSize=()=>{var t,s;return(t=(s=e.getLeftHeaderGroups()[0])==null?void 0:s.headers.reduce((n,r)=>n+r.getSize(),0))!=null?t:0},e.getCenterTotalSize=()=>{var t,s;return(t=(s=e.getCenterHeaderGroups()[0])==null?void 0:s.headers.reduce((n,r)=>n+r.getSize(),0))!=null?t:0},e.getRightTotalSize=()=>{var t,s;return(t=(s=e.getRightHeaderGroups()[0])==null?void 0:s.headers.reduce((n,r)=>n+r.getSize(),0))!=null?t:0}}},dt=null;function Xa(){if(typeof dt=="boolean")return dt;let e=!1;try{const t={get passive(){return e=!0,!1}},s=()=>{};window.addEventListener("test",s,t),window.removeEventListener("test",s)}catch{e=!1}return dt=e,dt}function Wt(e){return e.type==="touchstart"}var Za={getInitialState:e=>({columnVisibility:{},...e}),getDefaultOptions:e=>({onColumnVisibilityChange:Q("columnVisibility",e)}),createColumn:(e,t)=>{e.toggleVisibility=s=>{e.getCanHide()&&t.setColumnVisibility(n=>({...n,[e.id]:s??!e.getIsVisible()}))},e.getIsVisible=()=>{var s,n;const r=e.columns;return(s=r.length?r.some(i=>i.getIsVisible()):(n=t.getState().columnVisibility)==null?void 0:n[e.id])!=null?s:!0},e.getCanHide=()=>{var s,n;return((s=e.columnDef.enableHiding)!=null?s:!0)&&((n=t.options.enableHiding)!=null?n:!0)},e.getToggleVisibilityHandler=()=>s=>{e.toggleVisibility==null||e.toggleVisibility(s.target.checked)}},createRow:(e,t)=>{e._getAllVisibleCells=L(()=>[e.getAllCells(),t.getState().columnVisibility],s=>s.filter(n=>n.column.getIsVisible()),T(t.options,"debugRows","_getAllVisibleCells")),e.getVisibleCells=L(()=>[e.getLeftVisibleCells(),e.getCenterVisibleCells(),e.getRightVisibleCells()],(s,n,r)=>[...s,...n,...r],T(t.options,"debugRows","getVisibleCells"))},createTable:e=>{const t=(s,n)=>L(()=>[n(),n().filter(r=>r.getIsVisible()).map(r=>r.id).join("_")],r=>r.filter(i=>i.getIsVisible==null?void 0:i.getIsVisible()),T(e.options,"debugColumns",s));e.getVisibleFlatColumns=t("getVisibleFlatColumns",()=>e.getAllFlatColumns()),e.getVisibleLeafColumns=t("getVisibleLeafColumns",()=>e.getAllLeafColumns()),e.getLeftVisibleLeafColumns=t("getLeftVisibleLeafColumns",()=>e.getLeftLeafColumns()),e.getRightVisibleLeafColumns=t("getRightVisibleLeafColumns",()=>e.getRightLeafColumns()),e.getCenterVisibleLeafColumns=t("getCenterVisibleLeafColumns",()=>e.getCenterLeafColumns()),e.setColumnVisibility=s=>e.options.onColumnVisibilityChange==null?void 0:e.options.onColumnVisibilityChange(s),e.resetColumnVisibility=s=>{var n;e.setColumnVisibility(s?{}:(n=e.initialState.columnVisibility)!=null?n:{})},e.toggleAllColumnsVisible=s=>{var n;s=(n=s)!=null?n:!e.getIsAllColumnsVisible(),e.setColumnVisibility(e.getAllLeafColumns().reduce((r,i)=>({...r,[i.id]:s||!(i.getCanHide!=null&&i.getCanHide())}),{}))},e.getIsAllColumnsVisible=()=>!e.getAllLeafColumns().some(s=>!(s.getIsVisible!=null&&s.getIsVisible())),e.getIsSomeColumnsVisible=()=>e.getAllLeafColumns().some(s=>s.getIsVisible==null?void 0:s.getIsVisible()),e.getToggleAllColumnsVisibilityHandler=()=>s=>{var n;e.toggleAllColumnsVisible((n=s.target)==null?void 0:n.checked)}}};function Ye(e,t){return t?t==="center"?e.getCenterVisibleLeafColumns():t==="left"?e.getLeftVisibleLeafColumns():e.getRightVisibleLeafColumns():e.getVisibleLeafColumns()}var el={createTable:e=>{e._getGlobalFacetedRowModel=e.options.getFacetedRowModel&&e.options.getFacetedRowModel(e,"__global__"),e.getGlobalFacetedRowModel=()=>e.options.manualFiltering||!e._getGlobalFacetedRowModel?e.getPreFilteredRowModel():e._getGlobalFacetedRowModel(),e._getGlobalFacetedUniqueValues=e.options.getFacetedUniqueValues&&e.options.getFacetedUniqueValues(e,"__global__"),e.getGlobalFacetedUniqueValues=()=>e._getGlobalFacetedUniqueValues?e._getGlobalFacetedUniqueValues():new Map,e._getGlobalFacetedMinMaxValues=e.options.getFacetedMinMaxValues&&e.options.getFacetedMinMaxValues(e,"__global__"),e.getGlobalFacetedMinMaxValues=()=>{if(e._getGlobalFacetedMinMaxValues)return e._getGlobalFacetedMinMaxValues()}}},tl={getInitialState:e=>({globalFilter:void 0,...e}),getDefaultOptions:e=>({onGlobalFilterChange:Q("globalFilter",e),globalFilterFn:"auto",getColumnCanGlobalFilter:t=>{var s;const n=(s=e.getCoreRowModel().flatRows[0])==null||(s=s._getAllCellsByColumnId()[t.id])==null?void 0:s.getValue();return typeof n=="string"||typeof n=="number"}}),createColumn:(e,t)=>{e.getCanGlobalFilter=()=>{var s,n,r,i;return((s=e.columnDef.enableGlobalFilter)!=null?s:!0)&&((n=t.options.enableGlobalFilter)!=null?n:!0)&&((r=t.options.enableFilters)!=null?r:!0)&&((i=t.options.getColumnCanGlobalFilter==null?void 0:t.options.getColumnCanGlobalFilter(e))!=null?i:!0)&&!!e.accessorFn}},createTable:e=>{e.getGlobalAutoFilterFn=()=>re.includesString,e.getGlobalFilterFn=()=>{var t,s;const{globalFilterFn:n}=e.options;return _t(n)?n:n==="auto"?e.getGlobalAutoFilterFn():(t=(s=e.options.filterFns)==null?void 0:s[n])!=null?t:re[n]},e.setGlobalFilter=t=>{e.options.onGlobalFilterChange==null||e.options.onGlobalFilterChange(t)},e.resetGlobalFilter=t=>{e.setGlobalFilter(t?void 0:e.initialState.globalFilter)}}},sl={getInitialState:e=>({expanded:{},...e}),getDefaultOptions:e=>({onExpandedChange:Q("expanded",e),paginateExpandedRows:!0}),createTable:e=>{let t=!1,s=!1;e._autoResetExpanded=()=>{var n,r;if(!t){e._queue(()=>{t=!0});return}if((n=(r=e.options.autoResetAll)!=null?r:e.options.autoResetExpanded)!=null?n:!e.options.manualExpanding){if(s)return;s=!0,e._queue(()=>{e.resetExpanded(),s=!1})}},e.setExpanded=n=>e.options.onExpandedChange==null?void 0:e.options.onExpandedChange(n),e.toggleAllRowsExpanded=n=>{n??!e.getIsAllRowsExpanded()?e.setExpanded(!0):e.setExpanded({})},e.resetExpanded=n=>{var r,i;e.setExpanded(n?{}:(r=(i=e.initialState)==null?void 0:i.expanded)!=null?r:{})},e.getCanSomeRowsExpand=()=>e.getPrePaginationRowModel().flatRows.some(n=>n.getCanExpand()),e.getToggleAllRowsExpandedHandler=()=>n=>{n.persist==null||n.persist(),e.toggleAllRowsExpanded()},e.getIsSomeRowsExpanded=()=>{const n=e.getState().expanded;return n===!0||Object.values(n).some(Boolean)},e.getIsAllRowsExpanded=()=>{const n=e.getState().expanded;return typeof n=="boolean"?n===!0:!(!Object.keys(n).length||e.getRowModel().flatRows.some(r=>!r.getIsExpanded()))},e.getExpandedDepth=()=>{let n=0;return(e.getState().expanded===!0?Object.keys(e.getRowModel().rowsById):Object.keys(e.getState().expanded)).forEach(r=>{const i=r.split(".");n=Math.max(n,i.length)}),n},e.getPreExpandedRowModel=()=>e.getSortedRowModel(),e.getExpandedRowModel=()=>(!e._getExpandedRowModel&&e.options.getExpandedRowModel&&(e._getExpandedRowModel=e.options.getExpandedRowModel(e)),e.options.manualExpanding||!e._getExpandedRowModel?e.getPreExpandedRowModel():e._getExpandedRowModel())},createRow:(e,t)=>{e.toggleExpanded=s=>{t.setExpanded(n=>{var r;const i=n===!0?!0:!!(n!=null&&n[e.id]);let o={};if(n===!0?Object.keys(t.getRowModel().rowsById).forEach(a=>{o[a]=!0}):o=n,s=(r=s)!=null?r:!i,!i&&s)return{...o,[e.id]:!0};if(i&&!s){const{[e.id]:a,...u}=o;return u}return n})},e.getIsExpanded=()=>{var s;const n=t.getState().expanded;return!!((s=t.options.getIsRowExpanded==null?void 0:t.options.getIsRowExpanded(e))!=null?s:n===!0||n?.[e.id])},e.getCanExpand=()=>{var s,n,r;return(s=t.options.getRowCanExpand==null?void 0:t.options.getRowCanExpand(e))!=null?s:((n=t.options.enableExpanding)!=null?n:!0)&&!!((r=e.subRows)!=null&&r.length)},e.getIsAllParentsExpanded=()=>{let s=!0,n=e;for(;s&&n.parentId;)n=t.getRow(n.parentId,!0),s=n.getIsExpanded();return s},e.getToggleExpandedHandler=()=>{const s=e.getCanExpand();return()=>{s&&e.toggleExpanded()}}}},ls=0,us=10,Kt=()=>({pageIndex:ls,pageSize:us}),nl={getInitialState:e=>({...e,pagination:{...Kt(),...e?.pagination}}),getDefaultOptions:e=>({onPaginationChange:Q("pagination",e)}),createTable:e=>{let t=!1,s=!1;e._autoResetPageIndex=()=>{var n,r;if(!t){e._queue(()=>{t=!0});return}if((n=(r=e.options.autoResetAll)!=null?r:e.options.autoResetPageIndex)!=null?n:!e.options.manualPagination){if(s)return;s=!0,e._queue(()=>{e.resetPageIndex(),s=!1})}},e.setPagination=n=>{const r=i=>ce(n,i);return e.options.onPaginationChange==null?void 0:e.options.onPaginationChange(r)},e.resetPagination=n=>{var r;e.setPagination(n?Kt():(r=e.initialState.pagination)!=null?r:Kt())},e.setPageIndex=n=>{e.setPagination(r=>{let i=ce(n,r.pageIndex);const o=typeof e.options.pageCount>"u"||e.options.pageCount===-1?Number.MAX_SAFE_INTEGER:e.options.pageCount-1;return i=Math.max(0,Math.min(i,o)),{...r,pageIndex:i}})},e.resetPageIndex=n=>{var r,i;e.setPageIndex(n?ls:(r=(i=e.initialState)==null||(i=i.pagination)==null?void 0:i.pageIndex)!=null?r:ls)},e.resetPageSize=n=>{var r,i;e.setPageSize(n?us:(r=(i=e.initialState)==null||(i=i.pagination)==null?void 0:i.pageSize)!=null?r:us)},e.setPageSize=n=>{e.setPagination(r=>{const i=Math.max(1,ce(n,r.pageSize)),o=r.pageSize*r.pageIndex,a=Math.floor(o/i);return{...r,pageIndex:a,pageSize:i}})},e.setPageCount=n=>e.setPagination(r=>{var i;let o=ce(n,(i=e.options.pageCount)!=null?i:-1);return typeof o=="number"&&(o=Math.max(-1,o)),{...r,pageCount:o}}),e.getPageOptions=L(()=>[e.getPageCount()],n=>{let r=[];return n&&n>0&&(r=[...new Array(n)].fill(null).map((i,o)=>o)),r},T(e.options,"debugTable","getPageOptions")),e.getCanPreviousPage=()=>e.getState().pagination.pageIndex>0,e.getCanNextPage=()=>{const{pageIndex:n}=e.getState().pagination,r=e.getPageCount();return r===-1?!0:r===0?!1:n<r-1},e.previousPage=()=>e.setPageIndex(n=>n-1),e.nextPage=()=>e.setPageIndex(n=>n+1),e.firstPage=()=>e.setPageIndex(0),e.lastPage=()=>e.setPageIndex(e.getPageCount()-1),e.getPrePaginationRowModel=()=>e.getExpandedRowModel(),e.getPaginationRowModel=()=>(!e._getPaginationRowModel&&e.options.getPaginationRowModel&&(e._getPaginationRowModel=e.options.getPaginationRowModel(e)),e.options.manualPagination||!e._getPaginationRowModel?e.getPrePaginationRowModel():e._getPaginationRowModel()),e.getPageCount=()=>{var n;return(n=e.options.pageCount)!=null?n:Math.ceil(e.getRowCount()/e.getState().pagination.pageSize)},e.getRowCount=()=>{var n;return(n=e.options.rowCount)!=null?n:e.getPrePaginationRowModel().rows.length}}},Qt=()=>({top:[],bottom:[]}),rl={getInitialState:e=>({rowPinning:Qt(),...e}),getDefaultOptions:e=>({onRowPinningChange:Q("rowPinning",e)}),createRow:(e,t)=>{e.pin=(s,n,r)=>{const i=n?e.getLeafRows().map(u=>{let{id:l}=u;return l}):[],o=r?e.getParentRows().map(u=>{let{id:l}=u;return l}):[],a=new Set([...o,e.id,...i]);t.setRowPinning(u=>{var l,h;if(s==="bottom"){var d,c;return{top:((d=u?.top)!=null?d:[]).filter(p=>!(a!=null&&a.has(p))),bottom:[...((c=u?.bottom)!=null?c:[]).filter(p=>!(a!=null&&a.has(p))),...Array.from(a)]}}if(s==="top"){var f,g;return{top:[...((f=u?.top)!=null?f:[]).filter(p=>!(a!=null&&a.has(p))),...Array.from(a)],bottom:((g=u?.bottom)!=null?g:[]).filter(p=>!(a!=null&&a.has(p)))}}return{top:((l=u?.top)!=null?l:[]).filter(p=>!(a!=null&&a.has(p))),bottom:((h=u?.bottom)!=null?h:[]).filter(p=>!(a!=null&&a.has(p)))}})},e.getCanPin=()=>{var s;const{enableRowPinning:n,enablePinning:r}=t.options;return typeof n=="function"?n(e):(s=n??r)!=null?s:!0},e.getIsPinned=()=>{const s=[e.id],{top:n,bottom:r}=t.getState().rowPinning,i=s.some(a=>n?.includes(a)),o=s.some(a=>r?.includes(a));return i?"top":o?"bottom":!1},e.getPinnedIndex=()=>{var s,n;const r=e.getIsPinned();if(!r)return-1;const i=(s=r==="top"?t.getTopRows():t.getBottomRows())==null?void 0:s.map(o=>{let{id:a}=o;return a});return(n=i?.indexOf(e.id))!=null?n:-1}},createTable:e=>{e.setRowPinning=t=>e.options.onRowPinningChange==null?void 0:e.options.onRowPinningChange(t),e.resetRowPinning=t=>{var s,n;return e.setRowPinning(t?Qt():(s=(n=e.initialState)==null?void 0:n.rowPinning)!=null?s:Qt())},e.getIsSomeRowsPinned=t=>{var s;const n=e.getState().rowPinning;if(!t){var r,i;return!!((r=n.top)!=null&&r.length||(i=n.bottom)!=null&&i.length)}return!!((s=n[t])!=null&&s.length)},e._getPinnedRows=(t,s,n)=>{var r;return((r=e.options.keepPinnedRows)==null||r?(s??[]).map(i=>{const o=e.getRow(i,!0);return o.getIsAllParentsExpanded()?o:null}):(s??[]).map(i=>t.find(o=>o.id===i))).filter(Boolean).map(i=>({...i,position:n}))},e.getTopRows=L(()=>[e.getRowModel().rows,e.getState().rowPinning.top],(t,s)=>e._getPinnedRows(t,s,"top"),T(e.options,"debugRows","getTopRows")),e.getBottomRows=L(()=>[e.getRowModel().rows,e.getState().rowPinning.bottom],(t,s)=>e._getPinnedRows(t,s,"bottom"),T(e.options,"debugRows","getBottomRows")),e.getCenterRows=L(()=>[e.getRowModel().rows,e.getState().rowPinning.top,e.getState().rowPinning.bottom],(t,s,n)=>{const r=new Set([...s??[],...n??[]]);return t.filter(i=>!r.has(i.id))},T(e.options,"debugRows","getCenterRows"))}},il={getInitialState:e=>({rowSelection:{},...e}),getDefaultOptions:e=>({onRowSelectionChange:Q("rowSelection",e),enableRowSelection:!0,enableMultiRowSelection:!0,enableSubRowSelection:!0}),createTable:e=>{e.setRowSelection=t=>e.options.onRowSelectionChange==null?void 0:e.options.onRowSelectionChange(t),e.resetRowSelection=t=>{var s;return e.setRowSelection(t?{}:(s=e.initialState.rowSelection)!=null?s:{})},e.toggleAllRowsSelected=t=>{e.setRowSelection(s=>{t=typeof t<"u"?t:!e.getIsAllRowsSelected();const n={...s},r=e.getPreGroupedRowModel().flatRows;return t?r.forEach(i=>{i.getCanSelect()&&(n[i.id]=!0)}):r.forEach(i=>{delete n[i.id]}),n})},e.toggleAllPageRowsSelected=t=>e.setRowSelection(s=>{const n=typeof t<"u"?t:!e.getIsAllPageRowsSelected(),r={...s};return e.getRowModel().rows.forEach(i=>{cs(r,i.id,n,!0,e)}),r}),e.getPreSelectedRowModel=()=>e.getCoreRowModel(),e.getSelectedRowModel=L(()=>[e.getState().rowSelection,e.getCoreRowModel()],(t,s)=>Object.keys(t).length?Jt(e,s):{rows:[],flatRows:[],rowsById:{}},T(e.options,"debugTable","getSelectedRowModel")),e.getFilteredSelectedRowModel=L(()=>[e.getState().rowSelection,e.getFilteredRowModel()],(t,s)=>Object.keys(t).length?Jt(e,s):{rows:[],flatRows:[],rowsById:{}},T(e.options,"debugTable","getFilteredSelectedRowModel")),e.getGroupedSelectedRowModel=L(()=>[e.getState().rowSelection,e.getSortedRowModel()],(t,s)=>Object.keys(t).length?Jt(e,s):{rows:[],flatRows:[],rowsById:{}},T(e.options,"debugTable","getGroupedSelectedRowModel")),e.getIsAllRowsSelected=()=>{const t=e.getFilteredRowModel().flatRows,{rowSelection:s}=e.getState();let n=!!(t.length&&Object.keys(s).length);return n&&t.some(r=>r.getCanSelect()&&!s[r.id])&&(n=!1),n},e.getIsAllPageRowsSelected=()=>{const t=e.getPaginationRowModel().flatRows.filter(r=>r.getCanSelect()),{rowSelection:s}=e.getState();let n=!!t.length;return n&&t.some(r=>!s[r.id])&&(n=!1),n},e.getIsSomeRowsSelected=()=>{var t;const s=Object.keys((t=e.getState().rowSelection)!=null?t:{}).length;return s>0&&s<e.getFilteredRowModel().flatRows.length},e.getIsSomePageRowsSelected=()=>{const t=e.getPaginationRowModel().flatRows;return e.getIsAllPageRowsSelected()?!1:t.filter(s=>s.getCanSelect()).some(s=>s.getIsSelected()||s.getIsSomeSelected())},e.getToggleAllRowsSelectedHandler=()=>t=>{e.toggleAllRowsSelected(t.target.checked)},e.getToggleAllPageRowsSelectedHandler=()=>t=>{e.toggleAllPageRowsSelected(t.target.checked)}},createRow:(e,t)=>{e.toggleSelected=(s,n)=>{const r=e.getIsSelected();t.setRowSelection(i=>{var o;if(s=typeof s<"u"?s:!r,e.getCanSelect()&&r===s)return i;const a={...i};return cs(a,e.id,s,(o=n?.selectChildren)!=null?o:!0,t),a})},e.getIsSelected=()=>{const{rowSelection:s}=t.getState();return _s(e,s)},e.getIsSomeSelected=()=>{const{rowSelection:s}=t.getState();return ds(e,s)==="some"},e.getIsAllSubRowsSelected=()=>{const{rowSelection:s}=t.getState();return ds(e,s)==="all"},e.getCanSelect=()=>{var s;return typeof t.options.enableRowSelection=="function"?t.options.enableRowSelection(e):(s=t.options.enableRowSelection)!=null?s:!0},e.getCanSelectSubRows=()=>{var s;return typeof t.options.enableSubRowSelection=="function"?t.options.enableSubRowSelection(e):(s=t.options.enableSubRowSelection)!=null?s:!0},e.getCanMultiSelect=()=>{var s;return typeof t.options.enableMultiRowSelection=="function"?t.options.enableMultiRowSelection(e):(s=t.options.enableMultiRowSelection)!=null?s:!0},e.getToggleSelectedHandler=()=>{const s=e.getCanSelect();return n=>{var r;s&&e.toggleSelected((r=n.target)==null?void 0:r.checked)}}}},cs=(e,t,s,n,r)=>{var i;const o=r.getRow(t,!0);s?(o.getCanMultiSelect()||Object.keys(e).forEach(a=>delete e[a]),o.getCanSelect()&&(e[t]=!0)):delete e[t],n&&(i=o.subRows)!=null&&i.length&&o.getCanSelectSubRows()&&o.subRows.forEach(a=>cs(e,a.id,s,n,r))};function Jt(e,t){const s=e.getState().rowSelection,n=[],r={},i=function(o,a){return o.map(u=>{var l;const h=_s(u,s);if(h&&(n.push(u),r[u.id]=u),(l=u.subRows)!=null&&l.length&&(u={...u,subRows:i(u.subRows)}),h)return u}).filter(Boolean)};return{rows:i(t.rows),flatRows:n,rowsById:r}}function _s(e,t){var s;return(s=t[e.id])!=null?s:!1}function ds(e,t,s){var n;if(!((n=e.subRows)!=null&&n.length))return!1;let r=!0,i=!1;return e.subRows.forEach(o=>{if(!(i&&!r)&&(o.getCanSelect()&&(_s(o,t)?i=!0:r=!1),o.subRows&&o.subRows.length)){const a=ds(o,t);a==="all"?i=!0:(a==="some"&&(i=!0),r=!1)}}),r?"all":i?"some":!1}var hs=/([0-9]+)/gm,ol=(e,t,s)=>Fr(pe(e.getValue(s)).toLowerCase(),pe(t.getValue(s)).toLowerCase()),al=(e,t,s)=>Fr(pe(e.getValue(s)),pe(t.getValue(s))),ll=(e,t,s)=>Is(pe(e.getValue(s)).toLowerCase(),pe(t.getValue(s)).toLowerCase()),ul=(e,t,s)=>Is(pe(e.getValue(s)),pe(t.getValue(s))),cl=(e,t,s)=>{const n=e.getValue(s),r=t.getValue(s);return n>r?1:n<r?-1:0},dl=(e,t,s)=>Is(e.getValue(s),t.getValue(s));function Is(e,t){return e===t?0:e>t?1:-1}function pe(e){return typeof e=="number"?isNaN(e)||e===1/0||e===-1/0?"":String(e):typeof e=="string"?e:""}function Fr(e,t){const s=e.split(hs).filter(Boolean),n=t.split(hs).filter(Boolean);for(;s.length&&n.length;){const r=s.shift(),i=n.shift(),o=parseInt(r,10),a=parseInt(i,10),u=[o,a].sort();if(isNaN(u[0])){if(r>i)return 1;if(i>r)return-1;continue}if(isNaN(u[1]))return isNaN(o)?-1:1;if(o>a)return 1;if(a>o)return-1}return s.length-n.length}var Qe={alphanumeric:ol,alphanumericCaseSensitive:al,text:ll,textCaseSensitive:ul,datetime:cl,basic:dl},hl={getInitialState:e=>({sorting:[],...e}),getDefaultColumnDef:()=>({sortingFn:"auto",sortUndefined:1}),getDefaultOptions:e=>({onSortingChange:Q("sorting",e),isMultiSortEvent:t=>t.shiftKey}),createColumn:(e,t)=>{e.getAutoSortingFn=()=>{const s=t.getFilteredRowModel().flatRows.slice(10);let n=!1;for(const r of s){const i=r?.getValue(e.id);if(Object.prototype.toString.call(i)==="[object Date]")return Qe.datetime;if(typeof i=="string"&&(n=!0,i.split(hs).length>1))return Qe.alphanumeric}return n?Qe.text:Qe.basic},e.getAutoSortDir=()=>{const s=t.getFilteredRowModel().flatRows[0];return typeof s?.getValue(e.id)=="string"?"asc":"desc"},e.getSortingFn=()=>{var s,n;if(!e)throw new Error;return _t(e.columnDef.sortingFn)?e.columnDef.sortingFn:e.columnDef.sortingFn==="auto"?e.getAutoSortingFn():(s=(n=t.options.sortingFns)==null?void 0:n[e.columnDef.sortingFn])!=null?s:Qe[e.columnDef.sortingFn]},e.toggleSorting=(s,n)=>{const r=e.getNextSortingOrder(),i=typeof s<"u"&&s!==null;t.setSorting(o=>{const a=o?.find(f=>f.id===e.id),u=o?.findIndex(f=>f.id===e.id);let l=[],h,d=i?s:r==="desc";if(o!=null&&o.length&&e.getCanMultiSort()&&n?a?h="toggle":h="add":o!=null&&o.length&&u!==o.length-1?h="replace":a?h="toggle":h="replace",h==="toggle"&&(i||r||(h="remove")),h==="add"){var c;l=[...o,{id:e.id,desc:d}],l.splice(0,l.length-((c=t.options.maxMultiSortColCount)!=null?c:Number.MAX_SAFE_INTEGER))}else h==="toggle"?l=o.map(f=>f.id===e.id?{...f,desc:d}:f):h==="remove"?l=o.filter(f=>f.id!==e.id):l=[{id:e.id,desc:d}];return l})},e.getFirstSortDir=()=>{var s,n;return((s=(n=e.columnDef.sortDescFirst)!=null?n:t.options.sortDescFirst)!=null?s:e.getAutoSortDir()==="desc")?"desc":"asc"},e.getNextSortingOrder=s=>{var n,r;const i=e.getFirstSortDir(),o=e.getIsSorted();return o?o!==i&&((n=t.options.enableSortingRemoval)==null||n)&&(!(s&&(r=t.options.enableMultiRemove)!=null)||r)?!1:o==="desc"?"asc":"desc":i},e.getCanSort=()=>{var s,n;return((s=e.columnDef.enableSorting)!=null?s:!0)&&((n=t.options.enableSorting)!=null?n:!0)&&!!e.accessorFn},e.getCanMultiSort=()=>{var s,n;return(s=(n=e.columnDef.enableMultiSort)!=null?n:t.options.enableMultiSort)!=null?s:!!e.accessorFn},e.getIsSorted=()=>{var s;const n=(s=t.getState().sorting)==null?void 0:s.find(r=>r.id===e.id);return n?n.desc?"desc":"asc":!1},e.getSortIndex=()=>{var s,n;return(s=(n=t.getState().sorting)==null?void 0:n.findIndex(r=>r.id===e.id))!=null?s:-1},e.clearSorting=()=>{t.setSorting(s=>s!=null&&s.length?s.filter(n=>n.id!==e.id):[])},e.getToggleSortingHandler=()=>{const s=e.getCanSort();return n=>{s&&(n.persist==null||n.persist(),e.toggleSorting==null||e.toggleSorting(void 0,e.getCanMultiSort()?t.options.isMultiSortEvent==null?void 0:t.options.isMultiSortEvent(n):!1))}}},createTable:e=>{e.setSorting=t=>e.options.onSortingChange==null?void 0:e.options.onSortingChange(t),e.resetSorting=t=>{var s,n;e.setSorting(t?[]:(s=(n=e.initialState)==null?void 0:n.sorting)!=null?s:[])},e.getPreSortedRowModel=()=>e.getGroupedRowModel(),e.getSortedRowModel=()=>(!e._getSortedRowModel&&e.options.getSortedRowModel&&(e._getSortedRowModel=e.options.getSortedRowModel(e)),e.options.manualSorting||!e._getSortedRowModel?e.getPreSortedRowModel():e._getSortedRowModel())}},fl=[Fa,Za,Ka,Qa,ka,Da,el,tl,hl,qa,sl,nl,rl,il,Ya];function gl(e){var t,s;const n=[...fl,...(t=e._features)!=null?t:[]];let r={_features:n};const i=r._features.reduce((d,c)=>Object.assign(d,c.getDefaultOptions==null?void 0:c.getDefaultOptions(r)),{}),o=d=>r.options.mergeOptions?r.options.mergeOptions(i,d):{...i,...d};let a={...(s=e.initialState)!=null?s:{}};r._features.forEach(d=>{var c;a=(c=d.getInitialState==null?void 0:d.getInitialState(a))!=null?c:a});const u=[];let l=!1;const h={_features:n,options:{...i,...e},initialState:a,_queue:d=>{u.push(d),l||(l=!0,Promise.resolve().then(()=>{for(;u.length;)u.shift()();l=!1}).catch(c=>setTimeout(()=>{throw c})))},reset:()=>{r.setState(r.initialState)},setOptions:d=>{r.options=o(ce(d,r.options))},getState:()=>r.options.state,setState:d=>{r.options.onStateChange==null||r.options.onStateChange(d)},_getRowId:(d,c,f)=>{var g;return(g=r.options.getRowId==null?void 0:r.options.getRowId(d,c,f))!=null?g:`${f?[f.id,c].join("."):c}`},getCoreRowModel:()=>(r._getCoreRowModel||(r._getCoreRowModel=r.options.getCoreRowModel(r)),r._getCoreRowModel()),getRowModel:()=>r.getPaginationRowModel(),getRow:(d,c)=>{let f=(c?r.getPrePaginationRowModel():r.getRowModel()).rowsById[d];if(!f&&(f=r.getCoreRowModel().rowsById[d],!f))throw new Error;return f},_getDefaultColumnDef:L(()=>[r.options.defaultColumn],d=>{var c;return d=(c=d)!=null?c:{},{header:f=>{const g=f.header.column.columnDef;return g.accessorKey?g.accessorKey:g.accessorFn?g.id:null},cell:f=>{var g,p;return(g=(p=f.renderValue())==null||p.toString==null?void 0:p.toString())!=null?g:null},...r._features.reduce((f,g)=>Object.assign(f,g.getDefaultColumnDef==null?void 0:g.getDefaultColumnDef()),{}),...d}},T(e,"debugColumns","_getDefaultColumnDef")),_getColumnDefs:()=>r.options.columns,getAllColumns:L(()=>[r._getColumnDefs()],d=>{const c=function(f,g,p){return p===void 0&&(p=0),f.map(v=>{const m=Oa(r,v,p,g),y=v;return m.columns=y.columns?c(y.columns,m,p+1):[],m})};return c(d)},T(e,"debugColumns","getAllColumns")),getAllFlatColumns:L(()=>[r.getAllColumns()],d=>d.flatMap(c=>c.getFlatColumns()),T(e,"debugColumns","getAllFlatColumns")),_getAllFlatColumnsById:L(()=>[r.getAllFlatColumns()],d=>d.reduce((c,f)=>(c[f.id]=f,c),{}),T(e,"debugColumns","getAllFlatColumnsById")),getAllLeafColumns:L(()=>[r.getAllColumns(),r._getOrderColumnsFn()],(d,c)=>c(d.flatMap(f=>f.getLeafColumns())),T(e,"debugColumns","getAllLeafColumns")),getColumn:d=>r._getAllFlatColumnsById()[d]};Object.assign(r,h);for(let d=0;d<r._features.length;d++){const c=r._features[d];c==null||c.createTable==null||c.createTable(r)}return r}function Wl(){return e=>L(()=>[e.options.data],t=>{const s={rows:[],flatRows:[],rowsById:{}},n=function(r,i,o){i===void 0&&(i=0);const a=[];for(let l=0;l<r.length;l++){const h=Aa(e,e._getRowId(r[l],l,o),r[l],l,i,void 0,o?.id);if(s.flatRows.push(h),s.rowsById[h.id]=h,a.push(h),e.options.getSubRows){var u;h.originalSubRows=e.options.getSubRows(r[l],l),(u=h.originalSubRows)!=null&&u.length&&(h.subRows=n(h.originalSubRows,i+1,h))}}return a};return s.rows=n(t),s},T(e.options,"debugTable","getRowModel",()=>e._autoResetPageIndex()))}function Kl(){return e=>L(()=>[e.getState().sorting,e.getPreSortedRowModel()],(t,s)=>{if(!s.rows.length||!(t!=null&&t.length))return s;const n=e.getState().sorting,r=[],i=n.filter(u=>{var l;return(l=e.getColumn(u.id))==null?void 0:l.getCanSort()}),o={};i.forEach(u=>{const l=e.getColumn(u.id);l&&(o[u.id]={sortUndefined:l.columnDef.sortUndefined,invertSorting:l.columnDef.invertSorting,sortingFn:l.getSortingFn()})});const a=u=>{const l=u.map(h=>({...h}));return l.sort((h,d)=>{for(let f=0;f<i.length;f+=1){var c;const g=i[f],p=o[g.id],v=p.sortUndefined,m=(c=g?.desc)!=null?c:!1;let y=0;if(v){const C=h.getValue(g.id),S=d.getValue(g.id),w=C===void 0,P=S===void 0;if(w||P){if(v==="first")return w?-1:1;if(v==="last")return w?1:-1;y=w&&P?0:w?v:-v}}if(y===0&&(y=p.sortingFn(h,d,g.id)),y!==0)return m&&(y*=-1),p.invertSorting&&(y*=-1),y}return h.index-d.index}),l.forEach(h=>{var d;r.push(h),(d=h.subRows)!=null&&d.length&&(h.subRows=a(h.subRows))}),l};return{rows:a(s.rows),flatRows:r,rowsById:s.rowsById}},T(e.options,"debugTable","getSortedRowModel",()=>e._autoResetPageIndex()))}function Ql(e,t){return e?pl(e)?R.createElement(e,t):e:null}function pl(e){return ml(e)||typeof e=="function"||vl(e)}function ml(e){return typeof e=="function"&&(()=>{const t=Object.getPrototypeOf(e);return t.prototype&&t.prototype.isReactComponent})()}function vl(e){return typeof e=="object"&&typeof e.$$typeof=="symbol"&&["react.memo","react.forward_ref"].includes(e.$$typeof.description)}function Jl(e){const t={state:{},onStateChange:()=>{},renderFallbackValue:null,...e},[s]=R.useState(()=>({current:gl(t)})),[n,r]=R.useState(()=>s.current.initialState);return s.current.setOptions(i=>({...i,...e,state:{...n,...e.state},onStateChange:o=>{r(o),e.onStateChange==null||e.onStateChange(o)}})),s.current}function Te(e,t,s){let n=s.initialDeps??[],r,i=!0;function o(){var a,u,l;let h;s.key&&((a=s.debug)!=null&&a.call(s))&&(h=Date.now());const d=e();if(!(d.length!==n.length||d.some((f,g)=>n[g]!==f)))return r;n=d;let c;if(s.key&&((u=s.debug)!=null&&u.call(s))&&(c=Date.now()),r=t(...d),s.key&&((l=s.debug)!=null&&l.call(s))){const f=Math.round((Date.now()-h)*100)/100,g=Math.round((Date.now()-c)*100)/100,p=g/16,v=(m,y)=>{for(m=String(m);m.length<y;)m=" "+m;return m};console.info(`%c⏱ ${v(g,5)} /${v(f,5)} ms`,`
7
- font-size: .6rem;
8
- font-weight: bold;
9
- color: hsl(${Math.max(0,Math.min(120-120*p,120))}deg 100% 31%);`,s?.key)}return s?.onChange&&!(i&&s.skipInitialOnChange)&&s.onChange(r),i=!1,r}return o.updateDeps=a=>{n=a},o}function kn(e,t){if(e===void 0)throw new Error(`Unexpected undefined${t?`: ${t}`:""}`);return e}var Sl=(e,t)=>Math.abs(e-t)<1.01,yl=(e,t,s)=>{let n;return function(...r){e.clearTimeout(n),n=e.setTimeout(()=>t.apply(this,r),s)}},Dn=e=>{const{offsetWidth:t,offsetHeight:s}=e;return{width:t,height:s}},Cl=e=>e,Rl=e=>{const t=Math.max(e.startIndex-e.overscan,0),s=Math.min(e.endIndex+e.overscan,e.count-1),n=[];for(let r=t;r<=s;r++)n.push(r);return n},wl=(e,t)=>{const s=e.scrollElement;if(!s)return;const n=e.targetWindow;if(!n)return;const r=o=>{const{width:a,height:u}=o;t({width:Math.round(a),height:Math.round(u)})};if(r(Dn(s)),!n.ResizeObserver)return()=>{};const i=new n.ResizeObserver(o=>{const a=()=>{const u=o[0];if(u?.borderBoxSize){const l=u.borderBoxSize[0];if(l){r({width:l.inlineSize,height:l.blockSize});return}}r(Dn(s))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()});return i.observe(s,{box:"border-box"}),()=>{i.unobserve(s)}},$n={passive:!0},Nn=typeof window>"u"?!0:"onscrollend"in window,bl=(e,t)=>{const s=e.scrollElement;if(!s)return;const n=e.targetWindow;if(!n)return;let r=0;const i=e.options.useScrollendEvent&&Nn?()=>{}:yl(n,()=>{t(r,!1)},e.options.isScrollingResetDelay),o=h=>()=>{const{horizontal:d,isRtl:c}=e.options;r=d?s.scrollLeft*(c&&-1||1):s.scrollTop,i(),t(r,h)},a=o(!0),u=o(!1);s.addEventListener("scroll",a,$n);const l=e.options.useScrollendEvent&&Nn;return l&&s.addEventListener("scrollend",u,$n),()=>{s.removeEventListener("scroll",a),l&&s.removeEventListener("scrollend",u)}},Pl=(e,t,s)=>{if(t?.borderBoxSize){const n=t.borderBoxSize[0];if(n)return Math.round(n[s.options.horizontal?"inlineSize":"blockSize"])}return e[s.options.horizontal?"offsetWidth":"offsetHeight"]},Ml=(e,{adjustments:t=0,behavior:s},n)=>{var r,i;const o=e+t;(i=(r=n.scrollElement)==null?void 0:r.scrollTo)==null||i.call(r,{[n.options.horizontal?"left":"top"]:o,behavior:s})},_l=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.currentScrollToIndex=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.observer=(()=>{let t=null;const s=()=>t||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:t=new this.targetWindow.ResizeObserver(n=>{n.forEach(r=>{const i=()=>{this._measureElement(r.target,r)};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(i):i()})}));return{disconnect:()=>{var n;(n=s())==null||n.disconnect(),t=null},observe:n=>{var r;return(r=s())==null?void 0:r.observe(n,{box:"border-box"})},unobserve:n=>{var r;return(r=s())==null?void 0:r.unobserve(n)}}})(),this.range=null,this.setOptions=t=>{Object.entries(t).forEach(([s,n])=>{typeof n>"u"&&delete t[s]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Cl,rangeExtractor:Rl,onChange:()=>{},measureElement:Pl,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...t}},this.notify=t=>{var s,n;(n=(s=this.options).onChange)==null||n.call(s,this,t)},this.maybeNotify=Te(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),t=>{this.notify(t)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(t=>t()),this.unsubs=[],this.observer.disconnect(),this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var t;const s=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==s){if(this.cleanup(),!s){this.maybeNotify();return}this.scrollElement=s,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((t=this.scrollElement)==null?void 0:t.window)??null,this.elementsCache.forEach(n=>{this.observer.observe(n)}),this.unsubs.push(this.options.observeElementRect(this,n=>{this.scrollRect=n,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(n,r)=>{this.scrollAdjustments=0,this.scrollDirection=r?this.getScrollOffset()<n?"forward":"backward":null,this.scrollOffset=n,this.isScrolling=r,this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(t,s)=>{const n=new Map,r=new Map;for(let i=s-1;i>=0;i--){const o=t[i];if(n.has(o.lane))continue;const a=r.get(o.lane);if(a==null||o.end>a.end?r.set(o.lane,o):o.end<a.end&&n.set(o.lane,!0),n.size===this.options.lanes)break}return r.size===this.options.lanes?Array.from(r.values()).sort((i,o)=>i.end===o.end?i.index-o.index:i.end-o.end)[0]:void 0},this.getMeasurementOptions=Te(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes],(t,s,n,r,i,o)=>(this.prevLanes!==void 0&&this.prevLanes!==o&&(this.lanesChangedFlag=!0),this.prevLanes=o,this.pendingMeasuredCacheIndexes=[],{count:t,paddingStart:s,scrollMargin:n,getItemKey:r,enabled:i,lanes:o}),{key:!1}),this.getMeasurements=Te(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:t,paddingStart:s,scrollMargin:n,getItemKey:r,enabled:i,lanes:o},a)=>{if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>t)for(const d of this.laneAssignments.keys())d>=t&&this.laneAssignments.delete(d);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(d=>{this.itemSizeCache.set(d.key,d.size)}));const u=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===t&&(this.lanesSettling=!1);const l=this.measurementsCache.slice(0,u),h=new Array(o).fill(void 0);for(let d=0;d<u;d++){const c=l[d];c&&(h[c.lane]=d)}for(let d=u;d<t;d++){const c=r(d),f=this.laneAssignments.get(d);let g,p;if(f!==void 0&&this.options.lanes>1){g=f;const C=h[g],S=C!==void 0?l[C]:void 0;p=S?S.end+this.options.gap:s+n}else{const C=this.options.lanes===1?l[d-1]:this.getFurthestMeasurement(l,d);p=C?C.end+this.options.gap:s+n,g=C?C.lane:d%this.options.lanes,this.options.lanes>1&&this.laneAssignments.set(d,g)}const v=a.get(c),m=typeof v=="number"?v:this.options.estimateSize(d),y=p+m;l[d]={index:d,start:p,size:m,end:y,key:c,lane:g},h[g]=d}return this.measurementsCache=l,l},{key:!1,debug:()=>this.options.debug}),this.calculateRange=Te(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(t,s,n,r)=>this.range=t.length>0&&s>0?Il({measurements:t,outerSize:s,scrollOffset:n,lanes:r}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=Te(()=>{let t=null,s=null;const n=this.calculateRange();return n&&(t=n.startIndex,s=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,t,s]),[this.options.rangeExtractor,this.options.overscan,this.options.count,t,s]},(t,s,n,r,i)=>r===null||i===null?[]:t({startIndex:r,endIndex:i,overscan:s,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=t=>{const s=this.options.indexAttribute,n=t.getAttribute(s);return n?parseInt(n,10):(console.warn(`Missing attribute name '${s}={index}' on measured element.`),-1)},this._measureElement=(t,s)=>{const n=this.indexFromElement(t),r=this.measurementsCache[n];if(!r)return;const i=r.key,o=this.elementsCache.get(i);o!==t&&(o&&this.observer.unobserve(o),this.observer.observe(t),this.elementsCache.set(i,t)),t.isConnected&&this.resizeItem(n,this.options.measureElement(t,s,this))},this.resizeItem=(t,s)=>{const n=this.measurementsCache[t];if(!n)return;const r=s-(this.itemSizeCache.get(n.key)??n.size);r!==0&&((this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(n,r,this):n.start<this.getScrollOffset()+this.scrollAdjustments)&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=r,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(n.index),this.itemSizeCache=new Map(this.itemSizeCache.set(n.key,s)),this.notify(!1))},this.measureElement=t=>{if(!t){this.elementsCache.forEach((s,n)=>{s.isConnected||(this.observer.unobserve(s),this.elementsCache.delete(n))});return}this._measureElement(t,void 0)},this.getVirtualItems=Te(()=>[this.getVirtualIndexes(),this.getMeasurements()],(t,s)=>{const n=[];for(let r=0,i=t.length;r<i;r++){const o=s[t[r]];n.push(o)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=t=>{const s=this.getMeasurements();if(s.length!==0)return kn(s[Ar(0,s.length-1,n=>kn(s[n]).start,t)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const t=this.scrollElement.document.documentElement;return this.options.horizontal?t.scrollWidth-this.scrollElement.innerWidth:t.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(t,s,n=0)=>{if(!this.scrollElement)return 0;const r=this.getSize(),i=this.getScrollOffset();s==="auto"&&(s=t>=i+r?"end":"start"),s==="center"?t+=(n-r)/2:s==="end"&&(t-=r);const o=this.getMaxScrollOffset();return Math.max(Math.min(o,t),0)},this.getOffsetForIndex=(t,s="auto")=>{t=Math.max(0,Math.min(t,this.options.count-1));const n=this.measurementsCache[t];if(!n)return;const r=this.getSize(),i=this.getScrollOffset();if(s==="auto")if(n.end>=i+r-this.options.scrollPaddingEnd)s="end";else if(n.start<=i+this.options.scrollPaddingStart)s="start";else return[i,s];if(s==="end"&&t===this.options.count-1)return[this.getMaxScrollOffset(),s];const o=s==="end"?n.end+this.options.scrollPaddingEnd:n.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(o,s,n.size),s]},this.isDynamicMode=()=>this.elementsCache.size>0,this.scrollToOffset=(t,{align:s="start",behavior:n}={})=>{n==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getOffsetForAlignment(t,s),{adjustments:void 0,behavior:n})},this.scrollToIndex=(t,{align:s="auto",behavior:n}={})=>{n==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),t=Math.max(0,Math.min(t,this.options.count-1)),this.currentScrollToIndex=t;let r=0;const i=10,o=u=>{if(!this.targetWindow)return;const l=this.getOffsetForIndex(t,u);if(!l){console.warn("Failed to get offset for index:",t);return}const[h,d]=l;this._scrollToOffset(h,{adjustments:void 0,behavior:n}),this.targetWindow.requestAnimationFrame(()=>{const c=()=>{if(this.currentScrollToIndex!==t)return;const f=this.getScrollOffset(),g=this.getOffsetForIndex(t,d);if(!g){console.warn("Failed to get offset for index:",t);return}Sl(g[0],f)||a(d)};this.isDynamicMode()?this.targetWindow.requestAnimationFrame(c):c()})},a=u=>{this.targetWindow&&this.currentScrollToIndex===t&&(r++,r<i?this.targetWindow.requestAnimationFrame(()=>o(u)):console.warn(`Failed to scroll to index ${t} after ${i} attempts.`))};o(s)},this.scrollBy=(t,{behavior:s}={})=>{s==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getScrollOffset()+t,{adjustments:void 0,behavior:s})},this.getTotalSize=()=>{var t;const s=this.getMeasurements();let n;if(s.length===0)n=this.options.paddingStart;else if(this.options.lanes===1)n=((t=s[s.length-1])==null?void 0:t.end)??0;else{const r=Array(this.options.lanes).fill(null);let i=s.length-1;for(;i>=0&&r.some(o=>o===null);){const o=s[i];r[o.lane]===null&&(r[o.lane]=o.end),i--}n=Math.max(...r.filter(o=>o!==null))}return Math.max(n-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(t,{adjustments:s,behavior:n})=>{this.options.scrollToFn(t,{behavior:n,adjustments:s},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(e)}},Ar=(e,t,s,n)=>{for(;e<=t;){const r=(e+t)/2|0,i=s(r);if(i<n)e=r+1;else if(i>n)t=r-1;else return r}return e>0?e-1:0};function Il({measurements:e,outerSize:t,scrollOffset:s,lanes:n}){const r=e.length-1,i=u=>e[u].start;if(e.length<=n)return{startIndex:0,endIndex:r};let o=Ar(0,r,i,s),a=o;if(n===1)for(;a<r&&e[a].end<s+t;)a++;else if(n>1){const u=Array(n).fill(0);for(;a<r&&u.some(h=>h<s+t);){const h=e[a];u[h.lane]=h.end,a++}const l=Array(n).fill(s+t);for(;o>=0&&l.some(h=>h>=s);){const h=e[o];l[h.lane]=h.start,o--}o=Math.max(0,o-o%n),a=Math.min(r,a+(n-1-a%n))}return{startIndex:o,endIndex:a}}var Vn=typeof document<"u"?R.useLayoutEffect:R.useEffect;function xl({useFlushSync:e=!0,...t}){const s=R.useReducer(()=>({}),{})[1],n={...t,onChange:(i,o)=>{var a;e&&o?(0,yr.flushSync)(s):s(),(a=t.onChange)==null||a.call(t,i,o)}},[r]=R.useState(()=>new _l(n));return r.setOptions(n),Vn(()=>r._didMount(),[]),Vn(()=>r._willUpdate()),r}function Yl(e){return xl({observeElementRect:wl,observeElementOffset:bl,scrollToFn:Ml,...e})}export{Ol as C,Fl as S,pr as _,Kl as a,Al as b,Ul as c,Xo as d,Bl as f,vr as g,Cr as h,Wl as i,Hl as l,Nl as m,Ql as n,Gl as o,Vl as p,Jl as r,jl as s,Yl as t,zl as u,$l as v,Jn as x,Dl as y};