var de=(e,t,s)=>{if(!t.has(e))throw TypeError("Cannot "+s)};var i=(e,t,s)=>(de(e,t,"read from private field"),s?s.call(e):t.get(e)),l=(e,t,s)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,s)},c=(e,t,s,r)=>(de(e,t,"write to private field"),r?r.call(e,s):t.set(e,s),s);var re=(e,t,s,r)=>({set _(n){c(e,t,n,s)},get _(){return i(e,t,r)}}),p=(e,t,s)=>(de(e,t,"access private method"),s);import{r as C}from"./auth0-B7BG6KPO.js";import{j as is}from"./mui-material-nHWRByAl.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},t=new Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="f8bc9dde-61f3-483c-b117-ee6edf0ac552",e._sentryDebugIdIdentifier="sentry-dbid-f8bc9dde-61f3-483c-b117-ee6edf0ac552")}catch{}})();var bt=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(){}},Tt=typeof window>"u"||"Deno"in globalThis;function L(){}function Ds(e,t){return typeof e=="function"?e(t):e}function pe(e){return typeof e=="number"&&e>=0&&e!==1/0}function ns(e,t){return Math.max(e+(t||0)-Date.now(),0)}function gt(e,t){return typeof e=="function"?e(t):e}function N(e,t){return typeof e=="function"?e(t):e}function Ue(e,t){const{type:s="all",exact:r,fetchStatus:n,predicate:u,queryKey:a,stale:o}=e;if(a){if(r){if(t.queryHash!==Ie(a,t.options))return!1}else if(!jt(t.queryKey,a))return!1}if(s!=="all"){const f=t.isActive();if(s==="active"&&!f||s==="inactive"&&f)return!1}return!(typeof o=="boolean"&&t.isStale()!==o||n&&n!==t.state.fetchStatus||u&&!u(t))}function je(e,t){const{exact:s,status:r,predicate:n,mutationKey:u}=e;if(u){if(!t.options.mutationKey)return!1;if(s){if(mt(t.options.mutationKey)!==mt(u))return!1}else if(!jt(t.options.mutationKey,u))return!1}return!(r&&t.state.status!==r||n&&!n(t))}function Ie(e,t){return((t==null?void 0:t.queryKeyHashFn)||mt)(e)}function mt(e){return JSON.stringify(e,(t,s)=>ve(s)?Object.keys(s).sort().reduce((r,n)=>(r[n]=s[n],r),{}):s)}function jt(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?!Object.keys(t).some(s=>!jt(e[s],t[s])):!1}function le(e,t){if(e===t)return e;const s=Le(e)&&Le(t);if(s||ve(e)&&ve(t)){const r=s?e:Object.keys(e),n=r.length,u=s?t:Object.keys(t),a=u.length,o=s?[]:{};let f=0;for(let d=0;d<a;d++){const y=s?d:u[d];(!s&&r.includes(y)||s)&&e[y]===void 0&&t[y]===void 0?(o[y]=void 0,f++):(o[y]=le(e[y],t[y]),o[y]===e[y]&&e[y]!==void 0&&f++)}return n===a&&f===n?e:o}return t}function ae(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 Le(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function ve(e){if(!Ke(e))return!1;const t=e.constructor;if(t===void 0)return!0;const s=t.prototype;return!(!Ke(s)||!s.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function Ke(e){return Object.prototype.toString.call(e)==="[object Object]"}function xs(e){return new Promise(t=>{setTimeout(t,e)})}function me(e,t,s){return typeof s.structuralSharing=="function"?s.structuralSharing(e,t):s.structuralSharing!==!1?le(e,t):t}function nr(e){return e}function As(e,t,s=0){const r=[...e,t];return s&&r.length>s?r.slice(1):r}function Is(e,t,s=0){const r=[t,...e];return s&&r.length>s?r.slice(0,-1):r}var as=Symbol();function us(e,t){return!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===as?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}var ut,Z,Ot,$e,qs=($e=class extends bt{constructor(){super();l(this,ut,void 0);l(this,Z,void 0);l(this,Ot,void 0);c(this,Ot,t=>{if(!Tt&&window.addEventListener){const s=()=>t();return window.addEventListener("visibilitychange",s,!1),()=>{window.removeEventListener("visibilitychange",s)}}})}onSubscribe(){i(this,Z)||this.setEventListener(i(this,Ot))}onUnsubscribe(){var t;this.hasListeners()||((t=i(this,Z))==null||t.call(this),c(this,Z,void 0))}setEventListener(t){var s;c(this,Ot,t),(s=i(this,Z))==null||s.call(this),c(this,Z,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){i(this,ut)!==t&&(c(this,ut,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(s=>{s(t)})}isFocused(){var t;return typeof i(this,ut)=="boolean"?i(this,ut):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},ut=new WeakMap,Z=new WeakMap,Ot=new WeakMap,$e),qe=new qs,wt,tt,Rt,Ve,Ts=(Ve=class extends bt{constructor(){super();l(this,wt,!0);l(this,tt,void 0);l(this,Rt,void 0);c(this,Rt,t=>{if(!Tt&&window.addEventListener){const s=()=>t(!0),r=()=>t(!1);return window.addEventListener("online",s,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",s),window.removeEventListener("offline",r)}}})}onSubscribe(){i(this,tt)||this.setEventListener(i(this,Rt))}onUnsubscribe(){var t;this.hasListeners()||((t=i(this,tt))==null||t.call(this),c(this,tt,void 0))}setEventListener(t){var s;c(this,Rt,t),(s=i(this,tt))==null||s.call(this),c(this,tt,t(this.setOnline.bind(this)))}setOnline(t){i(this,wt)!==t&&(c(this,wt,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return i(this,wt)}},wt=new WeakMap,tt=new WeakMap,Rt=new WeakMap,Ve),ue=new Ts;function ks(e){return Math.min(1e3*2**e,3e4)}function os(e){return(e??"online")==="online"?ue.isOnline():!0}var hs=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function ye(e){return e instanceof hs}function cs(e){let t=!1,s=0,r=!1,n,u,a;const o=new Promise((P,E)=>{u=P,a=E}),f=P=>{var E;r||(m(new hs(P)),(E=e.abort)==null||E.call(e))},d=()=>{t=!0},y=()=>{t=!1},h=()=>qe.isFocused()&&(e.networkMode==="always"||ue.isOnline())&&e.canRun(),v=()=>os(e.networkMode)&&e.canRun(),g=P=>{var E;r||(r=!0,(E=e.onSuccess)==null||E.call(e,P),n==null||n(),u(P))},m=P=>{var E;r||(r=!0,(E=e.onError)==null||E.call(e,P),n==null||n(),a(P))},w=()=>new Promise(P=>{var E;n=S=>{(r||h())&&P(S)},(E=e.onPause)==null||E.call(e)}).then(()=>{var P;n=void 0,r||(P=e.onContinue)==null||P.call(e)}),R=()=>{if(r)return;let P;const E=s===0?e.initialPromise:void 0;try{P=E??e.fn()}catch(S){P=Promise.reject(S)}Promise.resolve(P).then(g).catch(S=>{var O;if(r)return;const M=e.retry??(Tt?0:3),x=e.retryDelay??ks,B=typeof x=="function"?x(s,S):x,W=M===!0||typeof M=="number"&&s<M||typeof M=="function"&&M(s,S);if(t||!W){m(S);return}s++,(O=e.onFail)==null||O.call(e,s,S),xs(B).then(()=>h()?void 0:w()).then(()=>{t?m(S):R()})})};return{promise:o,cancel:f,continue:()=>(n==null||n(),o),cancelRetry:d,continueRetry:y,canStart:v,start:()=>(v()?R():w().then(R),o)}}function Us(){let e=[],t=0,s=o=>{o()},r=o=>{o()},n=o=>setTimeout(o,0);const u=o=>{t?e.push(o):n(()=>{s(o)})},a=()=>{const o=e;e=[],o.length&&n(()=>{r(()=>{o.forEach(f=>{s(f)})})})};return{batch:o=>{let f;t++;try{f=o()}finally{t--,t||a()}return f},batchCalls:o=>(...f)=>{u(()=>{o(...f)})},schedule:u,setNotifyFunction:o=>{s=o},setBatchNotifyFunction:o=>{r=o},setScheduler:o=>{n=o}}}var Q=Us(),ot,We,ls=(We=class{constructor(){l(this,ot,void 0)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),pe(this.gcTime)&&c(this,ot,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Tt?1/0:5*60*1e3))}clearGcTimeout(){i(this,ot)&&(clearTimeout(i(this,ot)),c(this,ot,void 0))}},ot=new WeakMap,We),Pt,Ct,j,D,Lt,ht,H,J,Je,js=(Je=class extends ls{constructor(t){super();l(this,H);l(this,Pt,void 0);l(this,Ct,void 0);l(this,j,void 0);l(this,D,void 0);l(this,Lt,void 0);l(this,ht,void 0);c(this,ht,!1),c(this,Lt,t.defaultOptions),this.setOptions(t.options),this.observers=[],c(this,j,t.cache),this.queryKey=t.queryKey,this.queryHash=t.queryHash,c(this,Pt,Ls(this.options)),this.state=t.state??i(this,Pt),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=i(this,D))==null?void 0:t.promise}setOptions(t){this.options={...i(this,Lt),...t},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&i(this,j).remove(this)}setData(t,s){const r=me(this.state.data,t,this.options);return p(this,H,J).call(this,{data:r,type:"success",dataUpdatedAt:s==null?void 0:s.updatedAt,manual:s==null?void 0:s.manual}),r}setState(t,s){p(this,H,J).call(this,{type:"setState",state:t,setStateOptions:s})}cancel(t){var r,n;const s=(r=i(this,D))==null?void 0:r.promise;return(n=i(this,D))==null||n.cancel(t),s?s.then(L).catch(L):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(i(this,Pt))}isActive(){return this.observers.some(t=>N(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0&&!this.isActive()}isStale(){return this.state.isInvalidated?!0:this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0}isStaleByTime(t=0){return this.state.isInvalidated||this.state.data===void 0||!ns(this.state.dataUpdatedAt,t)}onFocus(){var s;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(s=i(this,D))==null||s.continue()}onOnline(){var s;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(s=i(this,D))==null||s.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),i(this,j).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(s=>s!==t),this.observers.length||(i(this,D)&&(i(this,ht)?i(this,D).cancel({revert:!0}):i(this,D).cancelRetry()),this.scheduleGc()),i(this,j).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||p(this,H,J).call(this,{type:"invalidate"})}fetch(t,s){var f,d,y;if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&(s!=null&&s.cancelRefetch))this.cancel({silent:!0});else if(i(this,D))return i(this,D).continueRetry(),i(this,D).promise}if(t&&this.setOptions(t),!this.options.queryFn){const h=this.observers.find(v=>v.options.queryFn);h&&this.setOptions(h.options)}const r=new AbortController,n=h=>{Object.defineProperty(h,"signal",{enumerable:!0,get:()=>(c(this,ht,!0),r.signal)})},u=()=>{const h=us(this.options,s),v={queryKey:this.queryKey,meta:this.meta};return n(v),c(this,ht,!1),this.options.persister?this.options.persister(h,v,this):h(v)},a={fetchOptions:s,options:this.options,queryKey:this.queryKey,state:this.state,fetchFn:u};n(a),(f=this.options.behavior)==null||f.onFetch(a,this),c(this,Ct,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((d=a.fetchOptions)==null?void 0:d.meta))&&p(this,H,J).call(this,{type:"fetch",meta:(y=a.fetchOptions)==null?void 0:y.meta});const o=h=>{var v,g,m,w;ye(h)&&h.silent||p(this,H,J).call(this,{type:"error",error:h}),ye(h)||((g=(v=i(this,j).config).onError)==null||g.call(v,h,this),(w=(m=i(this,j).config).onSettled)==null||w.call(m,this.state.data,h,this)),this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1};return c(this,D,cs({initialPromise:s==null?void 0:s.initialPromise,fn:a.fetchFn,abort:r.abort.bind(r),onSuccess:h=>{var v,g,m,w;if(h===void 0){o(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(h)}catch(R){o(R);return}(g=(v=i(this,j).config).onSuccess)==null||g.call(v,h,this),(w=(m=i(this,j).config).onSettled)==null||w.call(m,h,this.state.error,this),this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1},onError:o,onFail:(h,v)=>{p(this,H,J).call(this,{type:"failed",failureCount:h,error:v})},onPause:()=>{p(this,H,J).call(this,{type:"pause"})},onContinue:()=>{p(this,H,J).call(this,{type:"continue"})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0})),i(this,D).start()}},Pt=new WeakMap,Ct=new WeakMap,j=new WeakMap,D=new WeakMap,Lt=new WeakMap,ht=new WeakMap,H=new WeakSet,J=function(t){const s=r=>{switch(t.type){case"failed":return{...r,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...fs(r.data,this.options),fetchMeta:t.meta??null};case"success":return{...r,data:t.data,dataUpdateCount:r.dataUpdateCount+1,dataUpdatedAt:t.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const n=t.error;return ye(n)&&n.revert&&i(this,Ct)?{...i(this,Ct),fetchStatus:"idle"}:{...r,error:n,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:n,fetchStatus:"idle",status:"error"};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=s(this.state),Q.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),i(this,j).notify({query:this,type:"updated",action:t})})},Je);function fs(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:os(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function Ls(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,s=t!==void 0,r=s?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:s?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:s?"success":"pending",fetchStatus:"idle"}}var G,Xe,Ks=(Xe=class extends bt{constructor(t={}){super();l(this,G,void 0);this.config=t,c(this,G,new Map)}build(t,s,r){const n=s.queryKey,u=s.queryHash??Ie(n,s);let a=this.get(u);return a||(a=new js({cache:this,queryKey:n,queryHash:u,options:t.defaultQueryOptions(s),state:r,defaultOptions:t.getQueryDefaults(n)}),this.add(a)),a}add(t){i(this,G).has(t.queryHash)||(i(this,G).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const s=i(this,G).get(t.queryHash);s&&(t.destroy(),s===t&&i(this,G).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){Q.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return i(this,G).get(t)}getAll(){return[...i(this,G).values()]}find(t){const s={exact:!0,...t};return this.getAll().find(r=>Ue(s,r))}findAll(t={}){const s=this.getAll();return Object.keys(t).length>0?s.filter(r=>Ue(t,r)):s}notify(t){Q.batch(()=>{this.listeners.forEach(s=>{s(t)})})}onFocus(){Q.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){Q.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},G=new WeakMap,Xe),z,A,ct,$,Y,Ye,Hs=(Ye=class extends ls{constructor(t){super();l(this,$);l(this,z,void 0);l(this,A,void 0);l(this,ct,void 0);this.mutationId=t.mutationId,c(this,A,t.mutationCache),c(this,z,[]),this.state=t.state||ds(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){i(this,z).includes(t)||(i(this,z).push(t),this.clearGcTimeout(),i(this,A).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){c(this,z,i(this,z).filter(s=>s!==t)),this.scheduleGc(),i(this,A).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){i(this,z).length||(this.state.status==="pending"?this.scheduleGc():i(this,A).remove(this))}continue(){var t;return((t=i(this,ct))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var n,u,a,o,f,d,y,h,v,g,m,w,R,P,E,S,M,x,B,W;c(this,ct,cs({fn:()=>this.options.mutationFn?this.options.mutationFn(t):Promise.reject(new Error("No mutationFn found")),onFail:(O,K)=>{p(this,$,Y).call(this,{type:"failed",failureCount:O,error:K})},onPause:()=>{p(this,$,Y).call(this,{type:"pause"})},onContinue:()=>{p(this,$,Y).call(this,{type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>i(this,A).canRun(this)}));const s=this.state.status==="pending",r=!i(this,ct).canStart();try{if(!s){p(this,$,Y).call(this,{type:"pending",variables:t,isPaused:r}),await((u=(n=i(this,A).config).onMutate)==null?void 0:u.call(n,t,this));const K=await((o=(a=this.options).onMutate)==null?void 0:o.call(a,t));K!==this.state.context&&p(this,$,Y).call(this,{type:"pending",context:K,variables:t,isPaused:r})}const O=await i(this,ct).start();return await((d=(f=i(this,A).config).onSuccess)==null?void 0:d.call(f,O,t,this.state.context,this)),await((h=(y=this.options).onSuccess)==null?void 0:h.call(y,O,t,this.state.context)),await((g=(v=i(this,A).config).onSettled)==null?void 0:g.call(v,O,null,this.state.variables,this.state.context,this)),await((w=(m=this.options).onSettled)==null?void 0:w.call(m,O,null,t,this.state.context)),p(this,$,Y).call(this,{type:"success",data:O}),O}catch(O){try{throw await((P=(R=i(this,A).config).onError)==null?void 0:P.call(R,O,t,this.state.context,this)),await((S=(E=this.options).onError)==null?void 0:S.call(E,O,t,this.state.context)),await((x=(M=i(this,A).config).onSettled)==null?void 0:x.call(M,void 0,O,this.state.variables,this.state.context,this)),await((W=(B=this.options).onSettled)==null?void 0:W.call(B,void 0,O,t,this.state.context)),O}finally{p(this,$,Y).call(this,{type:"error",error:O})}}finally{i(this,A).runNext(this)}}},z=new WeakMap,A=new WeakMap,ct=new WeakMap,$=new WeakSet,Y=function(t){const s=r=>{switch(t.type){case"failed":return{...r,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...r,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:t.error,failureCount:r.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=s(this.state),Q.batch(()=>{i(this,z).forEach(r=>{r.onMutationUpdate(t)}),i(this,A).notify({mutation:this,type:"updated",action:t})})},Ye);function ds(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var k,Kt,Ze,_s=(Ze=class extends bt{constructor(t={}){super();l(this,k,void 0);l(this,Kt,void 0);this.config=t,c(this,k,new Map),c(this,Kt,Date.now())}build(t,s,r){const n=new Hs({mutationCache:this,mutationId:++re(this,Kt)._,options:t.defaultMutationOptions(s),state:r});return this.add(n),n}add(t){const s=ie(t),r=i(this,k).get(s)??[];r.push(t),i(this,k).set(s,r),this.notify({type:"added",mutation:t})}remove(t){var r;const s=ie(t);if(i(this,k).has(s)){const n=(r=i(this,k).get(s))==null?void 0:r.filter(u=>u!==t);n&&(n.length===0?i(this,k).delete(s):i(this,k).set(s,n))}this.notify({type:"removed",mutation:t})}canRun(t){var r;const s=(r=i(this,k).get(ie(t)))==null?void 0:r.find(n=>n.state.status==="pending");return!s||s===t}runNext(t){var r;const s=(r=i(this,k).get(ie(t)))==null?void 0:r.find(n=>n!==t&&n.state.isPaused);return(s==null?void 0:s.continue())??Promise.resolve()}clear(){Q.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}getAll(){return[...i(this,k).values()].flat()}find(t){const s={exact:!0,...t};return this.getAll().find(r=>je(s,r))}findAll(t={}){return this.getAll().filter(s=>je(t,s))}notify(t){Q.batch(()=>{this.listeners.forEach(s=>{s(t)})})}resumePausedMutations(){const t=this.getAll().filter(s=>s.state.isPaused);return Q.batch(()=>Promise.all(t.map(s=>s.continue().catch(L))))}},k=new WeakMap,Kt=new WeakMap,Ze);function ie(e){var t;return((t=e.options.scope)==null?void 0:t.id)??String(e.mutationId)}function oe(e){return{onFetch:(t,s)=>{var y,h,v,g,m;const r=t.options,n=(v=(h=(y=t.fetchOptions)==null?void 0:y.meta)==null?void 0:h.fetchMore)==null?void 0:v.direction,u=((g=t.state.data)==null?void 0:g.pages)||[],a=((m=t.state.data)==null?void 0:m.pageParams)||[];let o={pages:[],pageParams:[]},f=0;const d=async()=>{let w=!1;const R=S=>{Object.defineProperty(S,"signal",{enumerable:!0,get:()=>(t.signal.aborted?w=!0:t.signal.addEventListener("abort",()=>{w=!0}),t.signal)})},P=us(t.options,t.fetchOptions),E=async(S,M,x)=>{if(w)return Promise.reject();if(M==null&&S.pages.length)return Promise.resolve(S);const B={queryKey:t.queryKey,pageParam:M,direction:x?"backward":"forward",meta:t.options.meta};R(B);const W=await P(B),{maxPages:O}=t.options,K=x?Is:As;return{pages:K(S.pages,W,O),pageParams:K(S.pageParams,M,O)}};if(n&&u.length){const S=n==="backward",M=S?ys:be,x={pages:u,pageParams:a},B=M(r,x);o=await E(x,B,S)}else{const S=e??u.length;do{const M=f===0?a[0]??r.initialPageParam:be(r,o);if(f>0&&M==null)break;o=await E(o,M),f++}while(f<S)}return o};t.options.persister?t.fetchFn=()=>{var w,R;return(R=(w=t.options).persister)==null?void 0:R.call(w,d,{queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},s)}:t.fetchFn=d}}}function be(e,{pages:t,pageParams:s}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,s[r],s):void 0}function ys(e,{pages:t,pageParams:s}){var r;return t.length>0?(r=e.getPreviousPageParam)==null?void 0:r.call(e,t[0],t,s[0],s):void 0}function Ns(e,t){return t?be(e,t)!=null:!1}function Bs(e,t){return!t||!e.getPreviousPageParam?!1:ys(e,t)!=null}var F,et,st,St,Et,rt,Qt,Ft,ts,ar=(ts=class{constructor(e={}){l(this,F,void 0);l(this,et,void 0);l(this,st,void 0);l(this,St,void 0);l(this,Et,void 0);l(this,rt,void 0);l(this,Qt,void 0);l(this,Ft,void 0);c(this,F,e.queryCache||new Ks),c(this,et,e.mutationCache||new _s),c(this,st,e.defaultOptions||{}),c(this,St,new Map),c(this,Et,new Map),c(this,rt,0)}mount(){re(this,rt)._++,i(this,rt)===1&&(c(this,Qt,qe.subscribe(async e=>{e&&(await this.resumePausedMutations(),i(this,F).onFocus())})),c(this,Ft,ue.subscribe(async e=>{e&&(await this.resumePausedMutations(),i(this,F).onOnline())})))}unmount(){var e,t;re(this,rt)._--,i(this,rt)===0&&((e=i(this,Qt))==null||e.call(this),c(this,Qt,void 0),(t=i(this,Ft))==null||t.call(this),c(this,Ft,void 0))}isFetching(e){return i(this,F).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return i(this,et).findAll({...e,status:"pending"}).length}getQueryData(e){var s;const t=this.defaultQueryOptions({queryKey:e});return(s=i(this,F).get(t.queryHash))==null?void 0:s.state.data}ensureQueryData(e){const t=this.getQueryData(e.queryKey);if(t===void 0)return this.fetchQuery(e);{const s=this.defaultQueryOptions(e),r=i(this,F).build(this,s);return e.revalidateIfStale&&r.isStaleByTime(gt(s.staleTime,r))&&this.prefetchQuery(s),Promise.resolve(t)}}getQueriesData(e){return i(this,F).findAll(e).map(({queryKey:t,state:s})=>{const r=s.data;return[t,r]})}setQueryData(e,t,s){const r=this.defaultQueryOptions({queryKey:e}),n=i(this,F).get(r.queryHash),u=n==null?void 0:n.state.data,a=Ds(t,u);if(a!==void 0)return i(this,F).build(this,r).setData(a,{...s,manual:!0})}setQueriesData(e,t,s){return Q.batch(()=>i(this,F).findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,s)]))}getQueryState(e){var s;const t=this.defaultQueryOptions({queryKey:e});return(s=i(this,F).get(t.queryHash))==null?void 0:s.state}removeQueries(e){const t=i(this,F);Q.batch(()=>{t.findAll(e).forEach(s=>{t.remove(s)})})}resetQueries(e,t){const s=i(this,F),r={type:"active",...e};return Q.batch(()=>(s.findAll(e).forEach(n=>{n.reset()}),this.refetchQueries(r,t)))}cancelQueries(e={},t={}){const s={revert:!0,...t},r=Q.batch(()=>i(this,F).findAll(e).map(n=>n.cancel(s)));return Promise.all(r).then(L).catch(L)}invalidateQueries(e={},t={}){return Q.batch(()=>{if(i(this,F).findAll(e).forEach(r=>{r.invalidate()}),e.refetchType==="none")return Promise.resolve();const s={...e,type:e.refetchType??e.type??"active"};return this.refetchQueries(s,t)})}refetchQueries(e={},t){const s={...t,cancelRefetch:(t==null?void 0:t.cancelRefetch)??!0},r=Q.batch(()=>i(this,F).findAll(e).filter(n=>!n.isDisabled()).map(n=>{let u=n.fetch(void 0,s);return s.throwOnError||(u=u.catch(L)),n.state.fetchStatus==="paused"?Promise.resolve():u}));return Promise.all(r).then(L)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const s=i(this,F).build(this,t);return s.isStaleByTime(gt(t.staleTime,s))?s.fetch(t):Promise.resolve(s.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(L).catch(L)}fetchInfiniteQuery(e){return e.behavior=oe(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(L).catch(L)}ensureInfiniteQueryData(e){return e.behavior=oe(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return ue.isOnline()?i(this,et).resumePausedMutations():Promise.resolve()}getQueryCache(){return i(this,F)}getMutationCache(){return i(this,et)}getDefaultOptions(){return i(this,st)}setDefaultOptions(e){c(this,st,e)}setQueryDefaults(e,t){i(this,St).set(mt(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...i(this,St).values()];let s={};return t.forEach(r=>{jt(e,r.queryKey)&&(s={...s,...r.defaultOptions})}),s}setMutationDefaults(e,t){i(this,Et).set(mt(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...i(this,Et).values()];let s={};return t.forEach(r=>{jt(e,r.mutationKey)&&(s={...s,...r.defaultOptions})}),s}defaultQueryOptions(e){if(e._defaulted)return e;const t={...i(this,st).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=Ie(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.enabled!==!0&&t.queryFn===as&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...i(this,st).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){i(this,F).clear(),i(this,et).clear()}},F=new WeakMap,et=new WeakMap,st=new WeakMap,St=new WeakMap,Et=new WeakMap,rt=new WeakMap,Qt=new WeakMap,Ft=new WeakMap,ts),q,b,Ht,I,lt,Mt,V,_t,Dt,xt,ft,dt,it,At,yt,Ut,Nt,ge,Bt,Oe,Gt,we,zt,Re,$t,Pe,Vt,Ce,Wt,Se,he,ps,es,se=(es=class extends bt{constructor(t,s){super();l(this,yt);l(this,Nt);l(this,Bt);l(this,Gt);l(this,zt);l(this,$t);l(this,Vt);l(this,Wt);l(this,he);l(this,q,void 0);l(this,b,void 0);l(this,Ht,void 0);l(this,I,void 0);l(this,lt,void 0);l(this,Mt,void 0);l(this,V,void 0);l(this,_t,void 0);l(this,Dt,void 0);l(this,xt,void 0);l(this,ft,void 0);l(this,dt,void 0);l(this,it,void 0);l(this,At,new Set);this.options=s,c(this,q,t),c(this,V,null),this.bindMethods(),this.setOptions(s)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(i(this,b).addObserver(this),He(i(this,b),this.options)?p(this,yt,Ut).call(this):this.updateResult(),p(this,zt,Re).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Ee(i(this,b),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Ee(i(this,b),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,p(this,$t,Pe).call(this),p(this,Vt,Ce).call(this),i(this,b).removeObserver(this)}setOptions(t,s){const r=this.options,n=i(this,b);if(this.options=i(this,q).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof N(this.options.enabled,i(this,b))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");p(this,Wt,Se).call(this),i(this,b).setOptions(this.options),r._defaulted&&!ae(this.options,r)&&i(this,q).getQueryCache().notify({type:"observerOptionsUpdated",query:i(this,b),observer:this});const u=this.hasListeners();u&&_e(i(this,b),n,this.options,r)&&p(this,yt,Ut).call(this),this.updateResult(s),u&&(i(this,b)!==n||N(this.options.enabled,i(this,b))!==N(r.enabled,i(this,b))||gt(this.options.staleTime,i(this,b))!==gt(r.staleTime,i(this,b)))&&p(this,Nt,ge).call(this);const a=p(this,Bt,Oe).call(this);u&&(i(this,b)!==n||N(this.options.enabled,i(this,b))!==N(r.enabled,i(this,b))||a!==i(this,it))&&p(this,Gt,we).call(this,a)}getOptimisticResult(t){const s=i(this,q).getQueryCache().build(i(this,q),t),r=this.createResult(s,t);return zs(this,r)&&(c(this,I,r),c(this,Mt,this.options),c(this,lt,i(this,b).state)),r}getCurrentResult(){return i(this,I)}trackResult(t,s){const r={};return Object.keys(t).forEach(n=>{Object.defineProperty(r,n,{configurable:!1,enumerable:!0,get:()=>(this.trackProp(n),s==null||s(n),t[n])})}),r}trackProp(t){i(this,At).add(t)}getCurrentQuery(){return i(this,b)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const s=i(this,q).defaultQueryOptions(t),r=i(this,q).getQueryCache().build(i(this,q),s);return r.isFetchingOptimistic=!0,r.fetch().then(()=>this.createResult(r,s))}fetch(t){return p(this,yt,Ut).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),i(this,I)))}createResult(t,s){var W;const r=i(this,b),n=this.options,u=i(this,I),a=i(this,lt),o=i(this,Mt),d=t!==r?t.state:i(this,Ht),{state:y}=t;let h={...y},v=!1,g;if(s._optimisticResults){const O=this.hasListeners(),K=!O&&He(t,s),Ms=O&&_e(t,r,s,n);(K||Ms)&&(h={...h,...fs(y.data,t.options)}),s._optimisticResults==="isRestoring"&&(h.fetchStatus="idle")}let{error:m,errorUpdatedAt:w,status:R}=h;if(s.select&&h.data!==void 0)if(u&&h.data===(a==null?void 0:a.data)&&s.select===i(this,_t))g=i(this,Dt);else try{c(this,_t,s.select),g=s.select(h.data),g=me(u==null?void 0:u.data,g,s),c(this,Dt,g),c(this,V,null)}catch(O){c(this,V,O)}else g=h.data;if(s.placeholderData!==void 0&&g===void 0&&R==="pending"){let O;if(u!=null&&u.isPlaceholderData&&s.placeholderData===(o==null?void 0:o.placeholderData))O=u.data;else if(O=typeof s.placeholderData=="function"?s.placeholderData((W=i(this,xt))==null?void 0:W.state.data,i(this,xt)):s.placeholderData,s.select&&O!==void 0)try{O=s.select(O),c(this,V,null)}catch(K){c(this,V,K)}O!==void 0&&(R="success",g=me(u==null?void 0:u.data,O,s),v=!0)}i(this,V)&&(m=i(this,V),g=i(this,Dt),w=Date.now(),R="error");const P=h.fetchStatus==="fetching",E=R==="pending",S=R==="error",M=E&&P,x=g!==void 0;return{status:R,fetchStatus:h.fetchStatus,isPending:E,isSuccess:R==="success",isError:S,isInitialLoading:M,isLoading:M,data:g,dataUpdatedAt:h.dataUpdatedAt,error:m,errorUpdatedAt:w,failureCount:h.fetchFailureCount,failureReason:h.fetchFailureReason,errorUpdateCount:h.errorUpdateCount,isFetched:h.dataUpdateCount>0||h.errorUpdateCount>0,isFetchedAfterMount:h.dataUpdateCount>d.dataUpdateCount||h.errorUpdateCount>d.errorUpdateCount,isFetching:P,isRefetching:P&&!E,isLoadingError:S&&!x,isPaused:h.fetchStatus==="paused",isPlaceholderData:v,isRefetchError:S&&x,isStale:Te(t,s),refetch:this.refetch}}updateResult(t){const s=i(this,I),r=this.createResult(i(this,b),this.options);if(c(this,lt,i(this,b).state),c(this,Mt,this.options),i(this,lt).data!==void 0&&c(this,xt,i(this,b)),ae(r,s))return;c(this,I,r);const n={},u=()=>{if(!s)return!0;const{notifyOnChangeProps:a}=this.options,o=typeof a=="function"?a():a;if(o==="all"||!o&&!i(this,At).size)return!0;const f=new Set(o??i(this,At));return this.options.throwOnError&&f.add("error"),Object.keys(i(this,I)).some(d=>{const y=d;return i(this,I)[y]!==s[y]&&f.has(y)})};(t==null?void 0:t.listeners)!==!1&&u()&&(n.listeners=!0),p(this,he,ps).call(this,{...n,...t})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&p(this,zt,Re).call(this)}},q=new WeakMap,b=new WeakMap,Ht=new WeakMap,I=new WeakMap,lt=new WeakMap,Mt=new WeakMap,V=new WeakMap,_t=new WeakMap,Dt=new WeakMap,xt=new WeakMap,ft=new WeakMap,dt=new WeakMap,it=new WeakMap,At=new WeakMap,yt=new WeakSet,Ut=function(t){p(this,Wt,Se).call(this);let s=i(this,b).fetch(this.options,t);return t!=null&&t.throwOnError||(s=s.catch(L)),s},Nt=new WeakSet,ge=function(){p(this,$t,Pe).call(this);const t=gt(this.options.staleTime,i(this,b));if(Tt||i(this,I).isStale||!pe(t))return;const r=ns(i(this,I).dataUpdatedAt,t)+1;c(this,ft,setTimeout(()=>{i(this,I).isStale||this.updateResult()},r))},Bt=new WeakSet,Oe=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(i(this,b)):this.options.refetchInterval)??!1},Gt=new WeakSet,we=function(t){p(this,Vt,Ce).call(this),c(this,it,t),!(Tt||N(this.options.enabled,i(this,b))===!1||!pe(i(this,it))||i(this,it)===0)&&c(this,dt,setInterval(()=>{(this.options.refetchIntervalInBackground||qe.isFocused())&&p(this,yt,Ut).call(this)},i(this,it)))},zt=new WeakSet,Re=function(){p(this,Nt,ge).call(this),p(this,Gt,we).call(this,p(this,Bt,Oe).call(this))},$t=new WeakSet,Pe=function(){i(this,ft)&&(clearTimeout(i(this,ft)),c(this,ft,void 0))},Vt=new WeakSet,Ce=function(){i(this,dt)&&(clearInterval(i(this,dt)),c(this,dt,void 0))},Wt=new WeakSet,Se=function(){const t=i(this,q).getQueryCache().build(i(this,q),this.options);if(t===i(this,b))return;const s=i(this,b);c(this,b,t),c(this,Ht,t.state),this.hasListeners()&&(s==null||s.removeObserver(this),t.addObserver(this))},he=new WeakSet,ps=function(t){Q.batch(()=>{t.listeners&&this.listeners.forEach(s=>{s(i(this,I))}),i(this,q).getQueryCache().notify({query:i(this,b),type:"observerResultsUpdated"})})},es);function Gs(e,t){return N(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function He(e,t){return Gs(e,t)||e.state.data!==void 0&&Ee(e,t,t.refetchOnMount)}function Ee(e,t,s){if(N(t.enabled,e)!==!1){const r=typeof s=="function"?s(e):s;return r==="always"||r!==!1&&Te(e,t)}return!1}function _e(e,t,s,r){return(e!==t||N(r.enabled,e)===!1)&&(!s.suspense||e.state.status!=="error")&&Te(e,s)}function Te(e,t){return N(t.enabled,e)!==!1&&e.isStaleByTime(gt(t.staleTime,e))}function zs(e,t){return!ae(e.getCurrentResult(),t)}function Ne(e,t){return e.filter(s=>!t.includes(s))}function $s(e,t,s){const r=e.slice(0);return r[t]=s,r}var pt,_,It,U,vt,Jt,Xt,ce,vs,Yt,Qe,Zt,Fe,te,Me,ss,Vs=(ss=class extends bt{constructor(t,s,r){super();l(this,ce);l(this,Yt);l(this,Zt);l(this,te);l(this,pt,void 0);l(this,_,void 0);l(this,It,void 0);l(this,U,void 0);l(this,vt,void 0);l(this,Jt,void 0);l(this,Xt,void 0);c(this,pt,t),c(this,It,[]),c(this,U,[]),c(this,_,[]),this.setQueries(s)}onSubscribe(){this.listeners.size===1&&i(this,U).forEach(t=>{t.subscribe(s=>{p(this,Zt,Fe).call(this,t,s)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,i(this,U).forEach(t=>{t.destroy()})}setQueries(t,s,r){c(this,It,t),Q.batch(()=>{const n=i(this,U),u=p(this,Yt,Qe).call(this,i(this,It));u.forEach(d=>d.observer.setOptions(d.defaultedQueryOptions,r));const a=u.map(d=>d.observer),o=a.map(d=>d.getCurrentResult()),f=a.some((d,y)=>d!==n[y]);n.length===a.length&&!f||(c(this,U,a),c(this,_,o),this.hasListeners()&&(Ne(n,a).forEach(d=>{d.destroy()}),Ne(a,n).forEach(d=>{d.subscribe(y=>{p(this,Zt,Fe).call(this,d,y)})}),p(this,te,Me).call(this)))})}getCurrentResult(){return i(this,_)}getQueries(){return i(this,U).map(t=>t.getCurrentQuery())}getObservers(){return i(this,U)}getOptimisticResult(t,s){const r=p(this,Yt,Qe).call(this,t),n=r.map(u=>u.observer.getOptimisticResult(u.defaultedQueryOptions));return[n,u=>p(this,ce,vs).call(this,u??n,s),()=>r.map((u,a)=>{const o=n[a];return u.defaultedQueryOptions.notifyOnChangeProps?o:u.observer.trackResult(o,f=>{r.forEach(d=>{d.observer.trackProp(f)})})})]}},pt=new WeakMap,_=new WeakMap,It=new WeakMap,U=new WeakMap,vt=new WeakMap,Jt=new WeakMap,Xt=new WeakMap,ce=new WeakSet,vs=function(t,s){return s?((!i(this,vt)||i(this,_)!==i(this,Xt)||s!==i(this,Jt))&&(c(this,Jt,s),c(this,Xt,i(this,_)),c(this,vt,le(i(this,vt),s(t)))),i(this,vt)):t},Yt=new WeakSet,Qe=function(t){const s=i(this,U),r=new Map(s.map(h=>[h.options.queryHash,h])),n=t.map(h=>i(this,pt).defaultQueryOptions(h)),u=n.flatMap(h=>{const v=r.get(h.queryHash);return v!=null?[{defaultedQueryOptions:h,observer:v}]:[]}),a=new Set(u.map(h=>h.defaultedQueryOptions.queryHash)),o=n.filter(h=>!a.has(h.queryHash)),f=h=>{const v=i(this,pt).defaultQueryOptions(h);return i(this,U).find(m=>m.options.queryHash===v.queryHash)??new se(i(this,pt),v)},d=o.map(h=>({defaultedQueryOptions:h,observer:f(h)})),y=(h,v)=>n.indexOf(h.defaultedQueryOptions)-n.indexOf(v.defaultedQueryOptions);return u.concat(d).sort(y)},Zt=new WeakSet,Fe=function(t,s){const r=i(this,U).indexOf(t);r!==-1&&(c(this,_,$s(i(this,_),r,s)),p(this,te,Me).call(this))},te=new WeakSet,Me=function(){Q.batch(()=>{this.listeners.forEach(t=>{t(i(this,_))})})},ss),ms=class extends se{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e,t){super.setOptions({...e,behavior:oe()},t)}getOptimisticResult(e){return e.behavior=oe(),super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,t){var m,w;const{state:s}=e,r=super.createResult(e,t),{isFetching:n,isRefetching:u,isError:a,isRefetchError:o}=r,f=(w=(m=s.fetchMeta)==null?void 0:m.fetchMore)==null?void 0:w.direction,d=a&&f==="forward",y=n&&f==="forward",h=a&&f==="backward",v=n&&f==="backward";return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:Ns(t,s.data),hasPreviousPage:Bs(t,s.data),isFetchNextPageError:d,isFetchingNextPage:y,isFetchPreviousPageError:h,isFetchingPreviousPage:v,isRefetchError:o&&!d&&!h,isRefetching:u&&!y&&!v}}},nt,at,T,X,qt,ne,ee,De,rs,Ws=(rs=class extends bt{constructor(t,s){super();l(this,qt);l(this,ee);l(this,nt,void 0);l(this,at,void 0);l(this,T,void 0);l(this,X,void 0);c(this,nt,t),this.setOptions(s),this.bindMethods(),p(this,qt,ne).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){var r;const s=this.options;this.options=i(this,nt).defaultMutationOptions(t),ae(this.options,s)||i(this,nt).getMutationCache().notify({type:"observerOptionsUpdated",mutation:i(this,T),observer:this}),s!=null&&s.mutationKey&&this.options.mutationKey&&mt(s.mutationKey)!==mt(this.options.mutationKey)?this.reset():((r=i(this,T))==null?void 0:r.state.status)==="pending"&&i(this,T).setOptions(this.options)}onUnsubscribe(){var t;this.hasListeners()||(t=i(this,T))==null||t.removeObserver(this)}onMutationUpdate(t){p(this,qt,ne).call(this),p(this,ee,De).call(this,t)}getCurrentResult(){return i(this,at)}reset(){var t;(t=i(this,T))==null||t.removeObserver(this),c(this,T,void 0),p(this,qt,ne).call(this),p(this,ee,De).call(this)}mutate(t,s){var r;return c(this,X,s),(r=i(this,T))==null||r.removeObserver(this),c(this,T,i(this,nt).getMutationCache().build(i(this,nt),this.options)),i(this,T).addObserver(this),i(this,T).execute(t)}},nt=new WeakMap,at=new WeakMap,T=new WeakMap,X=new WeakMap,qt=new WeakSet,ne=function(){var s;const t=((s=i(this,T))==null?void 0:s.state)??ds();c(this,at,{...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset})},ee=new WeakSet,De=function(t){Q.batch(()=>{var s,r,n,u,a,o,f,d;if(i(this,X)&&this.hasListeners()){const y=i(this,at).variables,h=i(this,at).context;(t==null?void 0:t.type)==="success"?((r=(s=i(this,X)).onSuccess)==null||r.call(s,t.data,y,h),(u=(n=i(this,X)).onSettled)==null||u.call(n,t.data,null,y,h)):(t==null?void 0:t.type)==="error"&&((o=(a=i(this,X)).onError)==null||o.call(a,t.error,y,h),(d=(f=i(this,X)).onSettled)==null||d.call(f,void 0,t.error,y,h))}this.listeners.forEach(y=>{y(i(this,at))})})},rs),bs=C.createContext(void 0),kt=e=>{const t=C.useContext(bs);if(e)return e;if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},ur=({client:e,children:t})=>(C.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),is.jsx(bs.Provider,{value:e,children:t})),gs=C.createContext(!1),Os=()=>C.useContext(gs);gs.Provider;function ws(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var Rs=C.createContext(ws()),Ps=()=>C.useContext(Rs),or=({children:e})=>{const[t]=C.useState(()=>ws());return is.jsx(Rs.Provider,{value:t,children:typeof e=="function"?e(t):e})};function Cs(e,t){return typeof e=="function"?e(...t):!!e}function Js(){}var Ss=(e,t)=>{(e.suspense||e.throwOnError)&&(t.isReset()||(e.retryOnMount=!1))},Es=e=>{C.useEffect(()=>{e.clearReset()},[e])},Qs=({result:e,errorResetBoundary:t,throwOnError:s,query:r})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&Cs(s,[e.error,r]),ke=(e,t)=>t.state.data===void 0,Fs=e=>{e.suspense&&(typeof e.staleTime!="number"&&(e.staleTime=1e3),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3)))},Xs=(e,t)=>e.isLoading&&e.isFetching&&!t,xe=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,Ae=(e,t,s)=>t.fetchOptimistic(e).catch(()=>{s.clearReset()});function Ys({queries:e,...t},s){const r=kt(s),n=Os(),u=Ps(),a=C.useMemo(()=>e.map(m=>{const w=r.defaultQueryOptions(m);return w._optimisticResults=n?"isRestoring":"optimistic",w}),[e,r,n]);a.forEach(m=>{Fs(m),Ss(m,u)}),Es(u);const[o]=C.useState(()=>new Vs(r,a,t)),[f,d,y]=o.getOptimisticResult(a,t.combine);C.useSyncExternalStore(C.useCallback(m=>n?()=>{}:o.subscribe(Q.batchCalls(m)),[o,n]),()=>o.getCurrentResult(),()=>o.getCurrentResult()),C.useEffect(()=>{o.setQueries(a,t,{listeners:!1})},[a,t,o]);const v=f.some((m,w)=>xe(a[w],m))?f.flatMap((m,w)=>{const R=a[w];if(R){const P=new se(r,R);if(xe(R,m))return Ae(R,P,u);Xs(m,n)&&Ae(R,P,u)}return[]}):[];if(v.length>0)throw Promise.all(v);const g=f.find((m,w)=>{const R=a[w];return R&&Qs({result:m,errorResetBoundary:u,throwOnError:R.throwOnError,query:r.getQueryCache().get(R.queryHash)})});if(g!=null&&g.error)throw g.error;return d(y())}function fe(e,t,s){var d,y,h,v;const r=kt(s),n=Os(),u=Ps(),a=r.defaultQueryOptions(e);(y=(d=r.getDefaultOptions().queries)==null?void 0:d._experimental_beforeQuery)==null||y.call(d,a),a._optimisticResults=n?"isRestoring":"optimistic",Fs(a),Ss(a,u),Es(u);const[o]=C.useState(()=>new t(r,a)),f=o.getOptimisticResult(a);if(C.useSyncExternalStore(C.useCallback(g=>{const m=n?()=>{}:o.subscribe(Q.batchCalls(g));return o.updateResult(),m},[o,n]),()=>o.getCurrentResult(),()=>o.getCurrentResult()),C.useEffect(()=>{o.setOptions(a,{listeners:!1})},[a,o]),xe(a,f))throw Ae(a,o,u);if(Qs({result:f,errorResetBoundary:u,throwOnError:a.throwOnError,query:r.getQueryCache().get(a.queryHash)}))throw f.error;return(v=(h=r.getDefaultOptions().queries)==null?void 0:h._experimental_afterQuery)==null||v.call(h,a,f),a.notifyOnChangeProps?f:o.trackResult(f)}function hr(e,t){return fe(e,se,t)}function cr(e,t){return fe({...e,enabled:!0,suspense:!0,throwOnError:ke,placeholderData:void 0},se,t)}function lr(e,t){return fe({...e,enabled:!0,suspense:!0,throwOnError:ke},ms,t)}function fr(e,t){return Ys({...e,queries:e.queries.map(s=>({...s,suspense:!0,throwOnError:ke,enabled:!0,placeholderData:void 0}))},t)}function dr(e,t){const s=kt(t),r=s.getQueryCache();return C.useSyncExternalStore(C.useCallback(n=>r.subscribe(Q.batchCalls(n)),[r]),()=>s.isFetching(e),()=>s.isFetching(e))}function yr(e,t){const s=kt(t);return Zs({filters:{...e,status:"pending"}},s).length}function Be(e,t){return e.findAll(t.filters).map(s=>t.select?t.select(s):s.state)}function Zs(e={},t){const s=kt(t).getMutationCache(),r=C.useRef(e),n=C.useRef(null);return n.current||(n.current=Be(s,e)),C.useEffect(()=>{r.current=e}),C.useSyncExternalStore(C.useCallback(u=>s.subscribe(()=>{const a=le(n.current,Be(s,r.current));n.current!==a&&(n.current=a,Q.schedule(u))}),[s]),()=>n.current,()=>n.current)}function pr(e,t){const s=kt(t),[r]=C.useState(()=>new Ws(s,e));C.useEffect(()=>{r.setOptions(e)},[r,e]);const n=C.useSyncExternalStore(C.useCallback(a=>r.subscribe(Q.batchCalls(a)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),u=C.useCallback((a,o)=>{r.mutate(a,o).catch(Js)},[r]);if(n.error&&Cs(r.options.throwOnError,[n.error]))throw n.error;return{...n,mutate:u,mutateAsync:n.mutate}}function vr(e,t){return fe(e,ms,t)}var mr=function(){return null};function Ge(e){return Object.assign(Object.create(null),e)}const tr=new Map([["default","_def"],["toScope","_def"]]),ze=e=>{const t={get(s,r,n){const u=Reflect.get(s,r,n);if(typeof u=="function"||typeof u=="object"&&!Array.isArray(u)&&u!=null)return new Proxy(u,t);const a=tr.get(r);if(a){console.warn(`"${String(r)}" is deprecated and will be removed in the next major version of "@lukemorales/query-key-factory". Please use "${a}" instead.`);const o=Reflect.get(s,a,n);return r==="toScope"?()=>o:o}return u}};return new Proxy(e,t)};function br(e,t){const s={_def:[e]};if(t==null)return ze(Ge(s));function r(u,a){return a!=null?Array.isArray(a)?[e,u,...a]:[e,u,a]:[e,u]}const n=er(t).reduce((u,a)=>{const o=t[a];let f;if(typeof o=="function"){const d=(...y)=>{const h=o(...y);return r(a,h)};d._def=[e,a],f=d}else f=o!=null?r(a,o):r(a);return u.set(a,f),u},new Map);return ze(Ge({...Object.fromEntries(n),...s}))}const er=e=>{const t=new Set(Object.keys(e).sort((r,n)=>r.localeCompare(n)));if(t.has("default"))throw new Error('"default" is a key reserved for the query key factory');const s=Array.from(t);if(s.some(r=>r.startsWith("_")))throw new Error('Keys that start with "_" are reserved for the query key factory');return s};export{ar as Q,mr as R,hr as a,cr as b,kt as c,ur as d,vr as e,lr as f,dr as g,or as h,Ys as i,yr as j,nr as k,fr as l,br as n,pr as u};
