reactjrx 1.97.0 → 1.99.0

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 (91) hide show
  1. package/dist/index.cjs +1 -1
  2. package/dist/index.d.ts +1 -7
  3. package/dist/index.js +426 -427
  4. package/dist/lib/binding/types.d.ts +0 -1
  5. package/dist/lib/binding/useBehaviorSubject.d.ts +0 -1
  6. package/dist/lib/binding/useObservableState.d.ts +0 -1
  7. package/dist/lib/binding/useObserve.d.ts +0 -1
  8. package/dist/lib/binding/useSubject.d.ts +2 -3
  9. package/dist/lib/binding/useSubscribe.d.ts +0 -1
  10. package/dist/lib/binding/useSubscribeEffect.d.ts +0 -1
  11. package/dist/lib/queries/client/QueryClient.d.ts +0 -1
  12. package/dist/lib/queries/client/focusManager.d.ts +0 -1
  13. package/dist/lib/queries/client/keys/hashKey.d.ts +0 -1
  14. package/dist/lib/queries/client/keys/matchKey.d.ts +1 -2
  15. package/dist/lib/queries/client/keys/partialMatchKey.d.ts +0 -1
  16. package/dist/lib/queries/client/mutations/cache/MutationCache.d.ts +0 -1
  17. package/dist/lib/queries/client/mutations/cache/types.d.ts +0 -1
  18. package/dist/lib/queries/client/mutations/mutation/Mutation.d.ts +0 -1
  19. package/dist/lib/queries/client/mutations/mutation/delayWhenNetworkOnline.d.ts +1 -2
  20. package/dist/lib/queries/client/mutations/mutation/executeMutation.d.ts +0 -1
  21. package/dist/lib/queries/client/mutations/mutation/observeUntilFinished.d.ts +0 -1
  22. package/dist/lib/queries/client/mutations/mutation/types.d.ts +0 -1
  23. package/dist/lib/queries/client/mutations/mutation/waitForNetworkOnError.d.ts +2 -3
  24. package/dist/lib/queries/client/mutations/observers/MutationObserver.d.ts +0 -1
  25. package/dist/lib/queries/client/mutations/observers/types.d.ts +0 -1
  26. package/dist/lib/queries/client/mutations/runner/MutationRunner.d.ts +0 -1
  27. package/dist/lib/queries/client/mutations/types.d.ts +0 -1
  28. package/dist/lib/queries/client/mutations/utils/defaultMutationState.d.ts +0 -1
  29. package/dist/lib/queries/client/mutations/utils/distinctUntilStateChanged.d.ts +0 -1
  30. package/dist/lib/queries/client/mutations/utils/filters.d.ts +0 -1
  31. package/dist/lib/queries/client/onlineManager.d.ts +0 -1
  32. package/dist/lib/queries/client/queries/cache/QueryCache.d.ts +0 -1
  33. package/dist/lib/queries/client/queries/cache/types.d.ts +0 -1
  34. package/dist/lib/queries/client/queries/observer/QueryObserver.d.ts +1 -2
  35. package/dist/lib/queries/client/queries/observer/queryStateHelpers.d.ts +0 -1
  36. package/dist/lib/queries/client/queries/observer/types.d.ts +0 -1
  37. package/dist/lib/queries/client/queries/query/Query.d.ts +2 -3
  38. package/dist/lib/queries/client/queries/query/delayOnNetworkMode.d.ts +1 -2
  39. package/dist/lib/queries/client/queries/query/delayUntilFocus.d.ts +0 -1
  40. package/dist/lib/queries/client/queries/query/execution/completeFnIfNotMoreObservers.d.ts +0 -1
  41. package/dist/lib/queries/client/queries/query/execution/executeQuery.d.ts +1 -2
  42. package/dist/lib/queries/client/queries/query/getDefaultState.d.ts +0 -1
  43. package/dist/lib/queries/client/queries/query/operators.d.ts +1 -2
  44. package/dist/lib/queries/client/queries/query/state/whenNewData.d.ts +0 -1
  45. package/dist/lib/queries/client/queries/query/types.d.ts +0 -1
  46. package/dist/lib/queries/client/queries/retryer/CancelledError.d.ts +0 -1
  47. package/dist/lib/queries/client/queries/retryer/utils.d.ts +0 -1
  48. package/dist/lib/queries/client/queries/types.d.ts +0 -1
  49. package/dist/lib/queries/client/queries/utils.d.ts +6 -1
  50. package/dist/lib/queries/client/store.d.ts +0 -1
  51. package/dist/lib/queries/client/tests/utils.d.ts +0 -1
  52. package/dist/lib/queries/client/types.d.ts +0 -1
  53. package/dist/lib/queries/client/utils/makeObservable.d.ts +0 -1
  54. package/dist/lib/queries/react/QueryClientProvider.d.ts +0 -1
  55. package/dist/lib/queries/react/mutations/types.d.ts +0 -1
  56. package/dist/lib/queries/react/mutations/useIsMutating.d.ts +1 -2
  57. package/dist/lib/queries/react/mutations/useMutation.d.ts +0 -1
  58. package/dist/lib/queries/react/mutations/useMutationState.d.ts +0 -1
  59. package/dist/lib/queries/react/queries/errorBoundaryUtils.d.ts +0 -1
  60. package/dist/lib/queries/react/queries/queryOptions.d.ts +0 -1
  61. package/dist/lib/queries/react/queries/types.d.ts +0 -1
  62. package/dist/lib/queries/react/queries/useBaseQuery.d.ts +0 -1
  63. package/dist/lib/queries/react/queries/useForeverQuery.d.ts +0 -1
  64. package/dist/lib/queries/react/queries/useIsFetching.d.ts +0 -1
  65. package/dist/lib/queries/react/queries/useQuery.d.ts +0 -1
  66. package/dist/lib/queries/react/useQueryClient.d.ts +0 -1
  67. package/dist/lib/state/persistance/adapters/createLocalStorageAdapter.d.ts +1 -2
  68. package/dist/lib/state/persistance/adapters/createLocalforageAdapter.d.ts +0 -1
  69. package/dist/lib/state/persistance/getNormalizedPersistanceValue.d.ts +0 -1
  70. package/dist/lib/state/persistance/types.d.ts +0 -1
  71. package/dist/lib/state/persistance/usePersistSignals.d.ts +0 -1
  72. package/dist/lib/state/signal.d.ts +0 -1
  73. package/dist/lib/state/useSignal.d.ts +1 -4
  74. package/dist/lib/state/useSignalValue.d.ts +0 -1
  75. package/dist/lib/utils/index.d.ts +9 -1
  76. package/dist/lib/utils/isPromiseLike.d.ts +1 -1
  77. package/dist/lib/utils/operators/emitToSubject.d.ts +0 -1
  78. package/dist/lib/utils/operators/retryBackoff.d.ts +0 -1
  79. package/dist/lib/utils/operators/trackSubscriptions.d.ts +0 -1
  80. package/dist/lib/utils/{useEffectOnce.d.ts → react/useEffectOnce.d.ts} +0 -1
  81. package/dist/lib/utils/{useLiveRef.d.ts → react/useLiveRef.d.ts} +0 -1
  82. package/dist/tests/utils.d.ts +0 -1
  83. package/package.json +12 -11
  84. package/dist/lib/utils/hasObjectPrototype.d.ts +0 -1
  85. package/dist/lib/utils/primitiveEqual.d.ts +0 -1
  86. package/dist/lib/utils/replaceEqualDeep.d.ts +0 -6
  87. /package/dist/lib/utils/{useConstant.d.ts → react/useConstant.d.ts} +0 -0
  88. /package/dist/lib/utils/{useLiveRef.test.d.ts → react/useLiveRef.test.d.ts} +0 -0
  89. /package/dist/lib/utils/{useMount.d.ts → react/useMount.d.ts} +0 -0
  90. /package/dist/lib/utils/{useUnmountObservable.d.ts → react/useUnmountObservable.d.ts} +0 -0
  91. /package/dist/lib/utils/{useUnmountObservable.test.d.ts → react/useUnmountObservable.test.d.ts} +0 -0
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var yt=Object.defineProperty;var De=s=>{throw TypeError(s)};var St=(s,e,t)=>e in s?yt(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var g=(s,e,t)=>St(s,typeof e!="symbol"?e+"":e,t),Ke=(s,e,t)=>e.has(s)||De("Cannot "+t);var c=(s,e,t)=>(Ke(s,e,"read from private field"),t?t.call(s):e.get(s)),w=(s,e,t)=>e.has(s)?De("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(s):e.set(s,t),j=(s,e,t,n)=>(Ke(s,e,"write to private field"),n?n.call(s,t):e.set(s,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("react"),r=require("rxjs"),K=require("rxjs/operators"),Ne=require("react/jsx-runtime");function vt(s){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const t in s)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(s,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>s[t]})}}return e.default=s,Object.freeze(e)}const we=vt(S),Q=s=>{const e=S.useRef(s);return S.useMemo(()=>{e.current=s},[s]),e};function Ot(s,e){return typeof s=="string"&&s===e||typeof s=="number"&&s===e||typeof s=="boolean"&&s===e||typeof s=="symbol"&&s===e||typeof s=="bigint"&&s===e||typeof s>"u"&&s===e||s===null&&s===e}function qe(s){return s instanceof Promise||s&&typeof s.then=="function"&&typeof s.catch=="function"}function R(s){if(r.isObservable(s))return s;if(qe(s))return r.from(s);if(typeof s!="function")return r.of(s);const e=s;return r.defer(()=>{const t=e();return qe(t)?r.from(t):r.isObservable(t)?t:r.of(t)})}function fe(s,e,t){const n=e!=null&&!Array.isArray(e)?e:{defaultValue:void 0,unsubscribeOnUnmount:!0},i=!t&&Array.isArray(e)?e:typeof s=="function"?t??[]:[s],u=S.useRef("getValue"in s&&typeof s.getValue=="function"?s.getValue():n.defaultValue),a=Q(s),l=Q(n),h=S.useCallback(b=>{const E=a.current,d=R(E).pipe(r.distinctUntilChanged(Ot),r.tap(p=>{u.current=p}),r.catchError(p=>(console.error(p),r.EMPTY))).subscribe(b);return()=>{l.current.unsubscribeOnUnmount!==!1&&d.unsubscribe()}},[...i]),f=S.useCallback(()=>u.current,[]);return S.useSyncExternalStore(h,f,f)}function Fe(s,e=[]){const t=Q(s);S.useEffect(()=>{const n=R(t.current).pipe(r.catchError(i=>(console.error(i),r.EMPTY))).subscribe();return()=>{n.unsubscribe()}},[...e,t])}const $e=s=>{const e=S.useRef();return e.current||(e.current=s()),S.useEffect(()=>{process.env.NODE_ENV},[]),e},Re=({onBeforeComplete:s,completeOnUnmount:e=!0}={})=>{const t=$e(()=>new r.Subject),n=S.useRef(!1),i=Q(s),u=Q(e);return S.useEffect(()=>(n.current&&(t.current=new r.Subject,n.current=!1),()=>{if(!u.current){n.current=!0;return}n.current||(i.current!=null&&i.current(),t.current.complete(),n.current=!0)}),[u,i,t]),t},wt=()=>{const s=Re(),e=Q(s.current.asObservable()),t=S.useCallback(n=>{s.current.next(n)},[]);return[e.current,t]},xe=s=>{const e=$e(()=>new r.BehaviorSubject(s)),t=S.useRef(!1),n=S.useRef(s);return S.useEffect(()=>(t.current&&(e.current=new r.BehaviorSubject(n.current),t.current=!1),()=>{t.current||(e.current.complete(),t.current=!0)}),[e]),e},$t=s=>{const e=xe(s),t=Q(e.current.asObservable()),n=S.useCallback(i=>{e.current.next(i)},[e.current]);return[t.current,n,e.current.getValue()]},Je=Symbol("SIGNAL_RESET");function Xe(s={}){const e={default:s.default,key:s.key},{default:t}=e??{},n=new r.BehaviorSubject(t),i=a=>{if(typeof a=="function"){const l=a(n.getValue());if(l===n.getValue())return;n.next(l);return}if(a===Je){n.next(t??void 0);return}n.next(a)},u=()=>n.getValue();if("get"in s){const a=h=>(h.subject.pipe(r.skip(1),r.first()).subscribe(()=>{var o;const f=(o=s.get)==null?void 0:o.call(s,a);i(f)}),h.getValue()),l=s.get(a);return i(l),{getValue:u,config:s,subject:n}}return{setValue:i,getValue:u,config:e,subject:n}}function Ze(s,e){const n=e??(()=>s.getValue());return fe(()=>s.subject.pipe(r.map(u=>n(u)),r.distinctUntilChanged()),{defaultValue:n(s.getValue())},[])}const Et=s=>{const[e]=S.useState(()=>Xe(s));return[Ze(e),e]},Ct=s=>({getItem:async e=>{const t=await s.getItem(e);if(t)return JSON.parse(t)},setItem:async(e,t)=>{await s.setItem(e,JSON.stringify(t))},removeItem:async e=>{},clear:async()=>{}}),Ce=s=>{if(!(!s||typeof s!="object"))return s},Mt=({adapter:s,key:e})=>({clear:async()=>await s.removeItem(e),removeItem:async t=>{const n=await s.getItem(e),{[t]:i,...u}=Ce(n)??{};await s.setItem(e,u)},getItem:async t=>{const n=await s.getItem(e),i=Ce(n)??{};if(t in i)return i[t]},setItem:async(t,n)=>{const i=await s.getItem(e),u=Ce(i)??{};await s.setItem(e,{...u,[t]:n})}}),et=({key:s}={})=>s?Mt({adapter:et(),key:s}):{clear:async()=>{localStorage.clear()},removeItem:async e=>{localStorage.removeItem(e)},getItem:async e=>{const t=localStorage.getItem(e);if(t)return JSON.parse(t)},setItem:async(e,t)=>{localStorage.setItem(e,JSON.stringify(t))}},se="__reactjrx",jt=s=>{if(typeof s=="object"&&s!==null&&se in s&&s[se]===se)return s};function me(s){return s!=null}const He=s=>{const e=xe(s);return S.useEffect(()=>{e.current.next(s)},[s,e]),e},Ft=({adapter:s,config:e})=>{const{signal:t,version:n}=e,u={value:t.getValue(),[se]:se,migrationVersion:n};return r.from(s.setItem(t.config.key,u)).pipe(r.catchError(a=>(console.error(a),r.of(null))))};function Rt({adapter:s,config:e}){const{hydrate:t=({value:u})=>u,signal:n,version:i}=e;return r.from(s.getItem(n.config.key)).pipe(r.switchMap(u=>{const a=jt(u);if(!a||a.migrationVersion!==void 0&&i>a.migrationVersion||a.value===void 0)return r.of(u);const l=a.value;return n.setValue(t({value:l,version:i})),r.of(u)}))}function xt({entries:s=[],onReady:e,adapter:t}){const n=Q(s),i=Q(e),u=He(t),a=fe(()=>{const h=n.current;return u.current.pipe(r.switchMap(f=>(h.length===0||!f?r.of(!0):r.zip(...h.map(b=>Rt({adapter:f,config:b}))).pipe(r.map(()=>!0))).pipe(r.tap(()=>{i.current!=null&&i.current()}),r.catchError(b=>(console.error("Unable to hydrate",b),r.EMPTY)))))},{defaultValue:!1},[u,n]),l=He(a);return Fe(()=>l.current.pipe(r.filter(h=>h),r.switchMap(()=>u.current),r.filter(me),r.switchMap(h=>r.merge(...n.current.map(f=>f.signal.subject.pipe(r.throttleTime(500,r.asyncScheduler,{trailing:!0}),r.switchMap(()=>r.from(Ft({adapter:h,config:f})))))))),[l,u]),{isHydrated:a}}const Ut=()=>{const s=Re({onBeforeComplete:()=>{s.current.next()}});return s};function tt(s,e){return Math.min(s,e)}function rt(s,e){return Math.pow(2,s)*e}function Ue(s){const{retry:e,retryDelay:t,retryAfterDelay:n,retryAfter:i=()=>r.of(!0)}=s,u=typeof e!="function"?e===!1?0:e===!0?1/0:e??1/0:1/0,a=typeof e=="function"?e:()=>!0,l=typeof t=="number"?t:100,h={shouldRetry:a,...s},{maxInterval:f=1/0,resetOnSuccess:o=!1,backoffDelay:b=rt}=h;return E=>r.defer(()=>{let d=0;const p=(m,C)=>m<u?a(m,C):!1;return E.pipe(K.catchError(m=>{var $;if(d++,!p(d-1,m))throw m;const C=($=s.caughtError)==null?void 0:$.call(s,d,m);if(!C)throw m;return C.pipe(K.mergeMap(O=>r.merge(r.of(O),r.throwError(()=>m))))}),K.retryWhen(m=>m.pipe(K.concatMap(C=>{const $=d-1;return i().pipe(K.first(),K.mergeMap(()=>p($,C)?r.timer(tt(b($,l),f)).pipe(K.mergeMap(O=>n&&!n($,C)?r.throwError(()=>C):r.of(O))):r.throwError(()=>C)))}))),K.catchError(m=>{if(s.catchError)return s.catchError(d,m);throw m}),K.tap(()=>{o&&(d=0)}))})}const At=(s,e)=>s.length===e.length&&s.every((t,n)=>t===e[n]),st=s=>{S.useEffect(s,[])},Qt=s=>{st(()=>{s()})};function We(s){return Object.prototype.toString.call(s)==="[object Object]"}function Me(s){if(!We(s))return!1;const e=s.constructor;if(typeof e>"u")return!0;const t=e.prototype;return!(!We(t)||!t.hasOwnProperty("isPrototypeOf"))}const re=s=>JSON.stringify(s,(e,t)=>Me(t)?Object.keys(t).sort().reduce((n,i)=>(n[i]=t[i],n),{}):t),Ae=(s=21)=>crypto.getRandomValues(new Uint8Array(s)).reduce((e,t)=>(t&=63,t<36?e+=t.toString(36):t<62?e+=(t-26).toString(36).toUpperCase():t>62?e+="-":e+="_",e),""),J=()=>({context:void 0,data:void 0,error:null,status:"idle",submittedAt:0,variables:void 0,failureCount:0,failureReason:null,isPaused:!1});function Qe(s){let e=0;return function(n){return new r.Observable(i=>{e++;const u=n.subscribe(i);return s(e),()=>{e--,s(e),u.unsubscribe()}})}}const ne=s=>s.pipe(r.takeWhile(e=>e.status!=="error"&&e.status!=="success",!0));var H;class Pt{constructor({__queryFinalizeHook:e}={}){w(this,H,new r.Subject);g(this,"state$");const t=new r.BehaviorSubject(0),n=t.pipe(r.filter(i=>i===0));this.state$=c(this,H).pipe(r.concatMap(({args:i,mutation:u,options:a})=>{const l=a.mapOperator??"merge",h=c(this,H).pipe(r.filter(()=>l==="merge")),f=c(this,H).pipe(r.filter(()=>l==="switch"),r.tap(()=>{u.cancel()})),o=r.defer(()=>(u.execute(i),r.EMPTY)),b=u.state$.pipe(ne,r.last(),r.mergeMap(()=>u.state$),r.takeUntil(c(this,H))),E=u.state$.pipe(ne,r.skip(1)),d=r.merge(n,h,f,u.cancelled$);return r.merge(E,b,o).pipe(r.map(p=>({state:p,mutation:u})),e??r.identity,r.takeUntil(d))}),r.shareReplay({refCount:!0,bufferSize:1}),Qe(i=>{t.next(i)}))}trigger({args:e,options:t,mutation:n}){c(this,H).next({args:e,options:t,mutation:n})}}H=new WeakMap;function Ee(s,e){return s===e?!0:typeof s!=typeof e?!1:s&&e&&typeof s=="object"&&typeof e=="object"?!Object.keys(e).some(t=>!Ee(s[t],e[t])):!1}const ye=(s,e,{exact:t=!1}={})=>t?re(s)===re(e):Ee(s,e);function x(s,e){if(s==null||e===void 0||typeof s!="object"||typeof e!="object")return s===e;if(s.constructor!==(e==null?void 0:e.constructor))return!1;const t=Object.keys(s),n=Object.keys(e);if(t.length!==n.length)return!1;for(const i of t)if(!e.hasOwnProperty(i)||s[i]!==e[i])return!1;return!0}const nt=s=>s.pipe(r.distinctUntilChanged(({data:e,...t},{data:n,...i})=>x(t,i)&&x(e,n)));var z,I;class kt{constructor(e,t={},n){w(this,z);w(this,I,new r.BehaviorSubject(void 0));g(this,"observed$");g(this,"getObserverResultFromState",e=>({...J(),...e,isSuccess:e.status==="success",isPending:e.status==="pending",isIdle:e.status==="idle",isError:e.status==="error",mutate:this.mutate,reset:this.reset}));var i;this.client=e,this.options=t,this.options.mutationKey=((i=this.options)==null?void 0:i.mutationKey)??[Ae()],j(this,z,n??new Pt(this.options)),this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this),c(this,I).pipe(r.filter(me),r.mergeMap(u=>c(this,z).state$.pipe(r.takeUntil(u.mutation.state$.pipe(ne,r.last()))))).subscribe(),this.observed$=c(this,I).pipe(r.switchMap(u=>(u==null?void 0:u.mutation.state$.pipe(r.map(a=>({state:a,options:u.options}))))??r.EMPTY),r.tap(({state:u,options:a})=>{u.status==="error"&&(a!=null&&a.onError&&(a==null||a.onError(u.error,u.variables,u.context)),a!=null&&a.onSettled&&(a==null||a.onSettled(u.data,u.error,u.variables,u.context))),u.status==="success"&&(a!=null&&a.onSuccess&&(a==null||a.onSuccess(u.data,u.variables,u.context)),a!=null&&a.onSettled&&(a==null||a.onSettled(u.data,u.error,u.variables,u.context)))}),r.ignoreElements())}setOptions(e){var i;const t=this.options;this.options=this.client.defaultMutationOptions({mutationKey:this.options.mutationKey,...e});const n=(i=c(this,I).getValue())==null?void 0:i.mutation;this.options.mutationKey&&t.mutationKey&&!ye(this.options.mutationKey,t.mutationKey,{exact:!0})?this.reset():n==null||n.setOptions(this.options)}observe(){var u;const e=this.getObserverResultFromState(((u=c(this,I).getValue())==null?void 0:u.mutation.state)??J()),t=c(this,z).state$.pipe(r.distinctUntilChanged(({mutation:a,state:{data:l,...h}},{mutation:f,state:{data:o,...b}})=>a===f&&x(h,b)&&x(l,o)),r.map(({state:a})=>a),r.scan((a,l)=>({...a,...l,...l.status==="pending"&&{data:l.data??a.data},...l.status==="pending"&&{error:l.error??a.error}})),r.map(a=>this.getObserverResultFromState(a))),n=c(this,I).pipe(r.filter(me),r.switchMap(a=>a.mutation.cancelled$),r.map(()=>this.getObserverResultFromState(J())));return{result$:r.merge(this.observed$,t,n).pipe(nt),lastValue:e}}subscribe(e){const t=this.observe().result$.subscribe(n=>{e(n)});return()=>{t.unsubscribe()}}async mutate(e,t={}){const n=this.client.getMutationCache().build(this.client,this.options);return c(this,I).next({mutation:n,options:t}),c(this,z).trigger({args:e,options:this.options,mutation:n}),await new Promise((i,u)=>{n.state$.pipe(ne,r.last()).subscribe({error:a=>{u(a)},next:a=>{a.error?u(a.error):i(a.data)}})})}getCurrentResult(){var t;const e=this.client.getMutationCache().find({exact:!0,mutationKey:(t=this.options)==null?void 0:t.mutationKey});return this.getObserverResultFromState((e==null?void 0:e.state)??J())}reset(){const{mutation:e}=c(this,I).getValue()??{};c(this,I).next(void 0),e==null||e.cancel()}}z=new WeakMap,I=new WeakMap;const it=S.createContext(void 0),Vt=({client:s})=>(S.useEffect(()=>(s.mount(),()=>{s.unmount()}),[s]),null),It=S.memo(({children:s,client:e})=>{const t=S.useMemo(()=>e,[e]);return Ne.jsxs(it.Provider,{value:t,children:[Ne.jsx(Vt,{client:e}),s]})}),Pe=s=>{const e=S.useContext(it);if(s)return s;if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e};function Tt(){}function Dt(s,e){const t=Pe(e),n=Q(s),i=$e(()=>[Ae()]),u=re(s.mutationKey??i.current),[a]=S.useState(()=>new kt(t,s));S.useEffect(()=>{a.setOptions(s)},[a,s]);const l=S.useMemo(()=>a.observe(),[u,a]),h=fe(l.result$)??l.lastValue,f=S.useCallback((o,b)=>{a.mutate(o,b).catch(Tt)},[a]);return S.useEffect(()=>()=>{n.current.cancelOnUnMount&&a.reset()},[a,n]),{...h,mutate:f,mutateAsync:h.mutate}}function Kt(s){return e=>e.pipe(K.tap(t=>{s.next(t)}))}const X=typeof window>"u"||"Deno"in window;class Nt{constructor(){g(this,"isOnlineSubject",new r.BehaviorSubject(!0));g(this,"online$",this.isOnlineSubject.pipe(r.distinctUntilChanged()));g(this,"backToOnline$",this.online$.pipe(r.filter(e=>e),r.first()));r.merge(X?r.EMPTY:r.fromEvent(window,"offline").pipe(r.map(()=>!1)),X?r.EMPTY:r.fromEvent(window,"online").pipe(r.map(()=>!0))).pipe(Kt(this.isOnlineSubject)).subscribe()}isOnline(){return this.isOnlineSubject.getValue()}setOnline(e){this.isOnlineSubject.getValue()!==e&&this.isOnlineSubject.next(e)}}const _=new Nt;function ke(s,e){return s.isStaleByTime(e.staleTime)}function qt(s,e){return e.enabled!==!1&&!s.state.dataUpdatedAt&&!(s.state.status==="error"&&e.retryOnMount===!1)&&s.state.fetchStatus!=="fetching"}function Le(s,e){return qt(s,e)||s.state.dataUpdatedAt>0&&at(s,e,e.refetchOnMount)}function _e(s,e,t,n){return s.state.fetchStatus!=="fetching"&&t.enabled!==!1&&(s!==e||n.enabled===!1)&&(!t.suspense||s.state.status!=="error")&&ke(s,t)}function Ht(s,e){return at(s,e,e.refetchOnWindowFocus)}function at(s,e,t){if(e.enabled!==!1){const n=typeof t=="function"?t(s):t;return n==="idle"?s.state.fetchStatus==="idle":n==="always"||n!==!1&&ke(s,e)}return!1}function Wt(s){return(s??"online")==="online"?_.isOnline():!0}function ze(s,e){return e.reduce((t,n)=>n in s?{...t,[n]:s[n]}:t,{})}function Be(s){return Array.isArray(s)&&s.length===Object.keys(s).length}function ut(s,e){if(s===e)return s;const t=Be(s)&&Be(e);if(t||Me(s)&&Me(e)){const n=t?s:Object.keys(s),i=n.length,u=t?e:Object.keys(e),a=u.length,l=t?[]:{};let h=0;for(let f=0;f<a;f++){const o=t?f:u[f];!t&&s[o]===void 0&&e[o]===void 0&&n.includes(o)?(l[o]=void 0,h++):(l[o]=ut(s[o],e[o]),l[o]===s[o]&&s[o]!==void 0&&h++)}return i===a&&h===i?s:l}return e}function Ve(s,e){return((e==null?void 0:e.queryKeyHashFn)??re)(s)}function Ye(s,e){const{type:t="all",exact:n,fetchStatus:i,predicate:u,queryKey:a,stale:l}=s;if(a){if(n){if(e.queryHash!==Ve(a,e.options))return!1}else if(!Ee(e.queryKey,a))return!1}if(t!=="all"){const h=e.isActive();if(t==="active"&&!h||t==="inactive"&&h)return!1}return!(typeof l=="boolean"&&e.isStale()!==l||typeof i<"u"&&i!==e.state.fetchStatus||u&&!u(e))}function Lt(s,e){return Math.max(s+(e??0)-Date.now(),0)}function _t(s,e){return typeof s=="function"?s(e):s}function Se(s,e,t){return typeof t.structuralSharing=="function"?t.structuralSharing(s,e):t.structuralSharing!==!1?ut(s,e):e}const je=Symbol(),zt=({getOptions:s,getState:e,initialState:t})=>n=>n.pipe(r.scan((i,{command:u,state:a})=>{if(u==="reset")return{...i,...a};if(u==="cancel"){const v=i.status==="pending"?"pending":a.status??i.status;return{...i,...a,status:v}}const l=a.data,h=l!==void 0&&l!==i.data,f="data"in a,o=a.status==="success",b=i.data!==void 0,E=i.error!==void 0||i.error!==null,d=a.status??i.status,p=h?Se(e().data,l,s()):f?a.data:i.data,m=i.status==="error"||i.status==="success",C=a.status==="error"&&(i.status==="error"&&i.fetchStatus==="fetching"||i.status!=="error")?i.errorUpdateCount+1:i.errorUpdateCount,$=h?i.dataUpdateCount+1:a.dataUpdateCount??i.dataUpdateCount,O=a.status==="pending"&&m&&(b||E),U=d==="pending"?null:a.error??i.error;return{...i,...a,status:d,error:U,errorUpdateCount:C,...o&&{isInvalidated:!1},data:p,dataUpdateCount:$,...O&&{status:i.status}}},t)),Bt=s=>s.pipe(r.map(({status:e,fetchStatus:t})=>t==="idle"&&(e==="success"||e==="error"))),ct=s=>s.pipe(r.takeWhile(e=>e.fetchStatus!=="idle",!0));var Oe,W;class Yt{constructor(){w(this,Oe,r.merge(X?r.EMPTY:r.fromEvent(document,"visibilitychange"),X?r.EMPTY:r.fromEvent(window,"visibilitychange")).pipe(r.map(()=>document.visibilityState)));w(this,W,new r.BehaviorSubject(X?!0:document.visibilityState==="visible"));g(this,"focused$",c(this,W));g(this,"focusRegained$",this.focused$.pipe(r.skip(1),r.filter(e=>e)));c(this,Oe).pipe(r.tap(e=>{c(this,W).next(e==="visible")})).subscribe()}isFocused(){return c(this,W).getValue()}setFocused(e){c(this,W).getValue()!==(e??!0)&&c(this,W).next(e??!0)}subscribe(e){const t=this.focused$.subscribe(e);return()=>{t.unsubscribe()}}refresh(){document.dispatchEvent(new Event("visibilitychange"))}}Oe=new WeakMap,W=new WeakMap;const ve=new Yt,Gt=s=>s.pipe(r.filter(e=>e.status==="success"),r.map(e=>({data:e.data,status:e.status,dataUpdatedAt:e.dataUpdatedAt})),r.distinctUntilChanged(x));var q,M,ie,B,A,Z,ae;class ot{constructor(e,t){w(this,q);w(this,M);w(this,ie,new r.Subject);g(this,"queryUpdateSubject",new r.Subject);w(this,B);w(this,A);w(this,Z);w(this,ae,0);g(this,"getObserverResultFromQuery",({options:e,query:t,optimisticResult:n,prevResult:{result:i,options:u,state:a,select:l,selectError:h,selectResult:f}})=>{var ge;const o=t.state,b=t.state.status==="pending",E=c(this,M),d=this.options,m=t!==E?t.state:c(this,B);let{errorUpdatedAt:C,fetchStatus:$,error:O}=o;if(n){const P=!!c(this,ae),Te=!P&&Le(t,e),mt=P&&_e(t,E,e,d);(Te||mt)&&($=Wt(t.options.networkMode)?"fetching":"paused")}const U=b&&$==="fetching";let v,y=h,T=l??null,D=f;if(e.select&&typeof o.data<"u")if(i&&o.data===(a==null?void 0:a.data)&&e.select===l)v=f;else try{T=e.select,v=e.select(o.data),v=Se(i==null?void 0:i.data,v,e),D=v,y=null}catch(P){v=f,y=P}else v=o.data,y=null;let V=$!=="idle"&&!o.dataUpdatedAt?"pending":o.status;y&&(O=y,v=f,C=(i==null?void 0:i.errorUpdatedAt)??C,V="error");const de=V==="error";let pe=!1;if(typeof e.placeholderData<"u"&&typeof v>"u"&&V==="pending"){let P;if(i!=null&&i.isPlaceholderData&&e.placeholderData===(u==null?void 0:u.placeholderData))P=i.data;else if(P=typeof e.placeholderData=="function"?e.placeholderData((ge=c(this,Z))==null?void 0:ge.state.data,c(this,Z)):e.placeholderData,e.select&&typeof P<"u")try{P=e.select(P)}catch{}typeof P<"u"&&(V="success",v=Se(i==null?void 0:i.data,P,e),pe=!0)}const be=$==="fetching";return{result:{status:V,fetchStatus:$,isPending:b,isSuccess:V==="success",isError:de,isInitialLoading:U,isLoading:U,data:v,dataUpdatedAt:o.dataUpdatedAt,error:O,errorUpdatedAt:C,failureCount:o.fetchFailureCount,failureReason:o.fetchFailureReason,errorUpdateCount:o.errorUpdateCount,isFetched:o.dataUpdateCount>0||o.errorUpdateCount>0,isFetchedAfterMount:o.dataUpdateCount>m.dataUpdateCount||o.errorUpdateCount>m.errorUpdateCount,isFetching:be,isRefetching:be&&!b,isLoadingError:de&&o.dataUpdatedAt===0,isPaused:$==="paused",isPlaceholderData:pe,isRefetchError:de&&o.dataUpdatedAt!==0,isStale:ke(t,e),refetch:this.refetch},selectError:y,select:T,selectResult:D}});this.options=t,j(this,q,e),this.bindMethods(),j(this,M,this.setOptions(t));const n=c(this,M);j(this,B,n.state);const{result:i,select:u}=this.getObserverResultFromQuery({query:n,options:this.options,prevResult:{options:this.options,state:n.state}});j(this,A,{state:n.state,options:t,result:i,select:u})}bindMethods(){this.refetch=this.refetch.bind(this)}setOptions(e){const t=this.options;if(this.options=c(this,q).defaultQueryOptions(e),x(this.options,t)||c(this,q).getQueryCache().notify({type:"observerOptionsUpdated",query:c(this,M),observer:this}),typeof this.options.enabled<"u"&&typeof this.options.enabled!="boolean")throw new Error("Expected enabled to be a boolean");const n=this.buildQuery(this.options);return n!==c(this,M)&&(j(this,B,n.state),j(this,M,n)),this.queryUpdateSubject.next({options:this.options,query:n}),n}buildQuery(e){const t=c(this,q).getQueryCache().build(c(this,q),e);return!t.options.queryFn&&this.options.queryFn&&t.setOptions(e),t}getCurrentResult(){return this.getObserverResultFromQuery({options:this.options,prevResult:c(this,A),query:c(this,M)}).result}getCurrentQuery(){return c(this,M)}getOptimisticResult(e){const t=this.buildQuery(e),n=this.getObserverResultFromQuery({query:t,options:e,optimisticResult:!0,prevResult:c(this,A)});return Jt(this,n.result)&&this.updateResult({query:t,...n}),n.result}updateResult({query:e,result:t,selectError:n,select:i,selectResult:u}){c(this,A).state=e.state,c(this,A).result=t,c(this,A).selectResult=u,n!==void 0&&(c(this,A).selectError=n),i!==void 0&&(c(this,A).select=i),c(this,A).options=this.options,e.state.data!==void 0&&j(this,Z,e),c(this,q).getQueryCache().notify({query:c(this,M),type:"observerResultsUpdated"})}async refetch({...e}={}){return await this.fetch({...e})}async fetch(e){const t=this.buildQuery(this.options);t!==c(this,M)&&(j(this,M,t),j(this,B,t.state),this.queryUpdateSubject.next({options:this.options,query:t}));const n={...e,cancelRefetch:(e==null?void 0:e.cancelRefetch)??!0};c(this,M).fetch(this.options,n).catch(r.noop),c(this,ie).next({query:t,fetchOptions:n}),await t.getFetchResultAsPromise();const{result:i}=this.getObserverResultFromQuery({query:t,options:this.options,prevResult:c(this,A)});return i}subscribe(e){const t=this.observe().subscribe(e);return()=>{t.unsubscribe()}}observe(){const e=c(this,M),t=this.queryUpdateSubject.pipe(r.map(({query:a})=>a),r.startWith(c(this,M)),r.distinctUntilChanged()),n=this.queryUpdateSubject.pipe(r.startWith({query:c(this,M),options:this.options}),r.pairwise(),r.tap(([{options:a,query:l},{options:h,query:f}])=>{_e(f,l,h,a)&&this.fetch().catch(r.noop)}),r.ignoreElements()),i=t.pipe(r.switchMap(a=>a.observe(this)),r.ignoreElements());return r.merge(i,n,t.pipe(r.switchMap(a=>{const l=this.options,h=this.queryUpdateSubject.pipe(r.startWith({query:a,options:l}),r.filter(y=>y.query===a),r.map(y=>y.options),r.distinctUntilChanged(),r.shareReplay(1)),f=c(this,ie).pipe(r.filter(y=>y.query===a)),o=a.state$.pipe(Gt,r.switchMap(y=>this.options.staleTime===1/0?r.NEVER:(this.options.staleTime??0)<=0?r.of(y).pipe(r.delay(1)):r.timer(this.options.staleTime??1)),r.takeWhile(()=>this.options.enabled??!0)),b=(y,T)=>{const D=l.notifyOnChangeProps,V=typeof D=="function"?D():D;return(Array.isArray(V)?V.length===0?()=>!0:(pe,be)=>{const Ie=ze(pe,V),ge=ze(be,V);return x(Ie,ge)}:x)(y,T)},E=f.pipe(r.switchMap(()=>a.state$),ct),d=h.pipe(r.map(({refetchInterval:y,refetchIntervalInBackground:T})=>({refetchInterval:(typeof y=="function"?y(c(this,M)):y)??!1,refetchIntervalInBackground:T})),r.distinctUntilChanged(x),r.switchMap(({refetchInterval:y,refetchIntervalInBackground:T})=>y?r.interval(y).pipe(r.tap(()=>{(T||ve.isFocused())&&this.fetch({cancelRefetch:!1}).catch(r.noop)})):r.NEVER),r.ignoreElements()),p=h.pipe(r.map(({enabled:y})=>y??!0),r.distinctUntilChanged()),m=p.pipe(r.filter(y=>!y),r.map(()=>a.state)),C=p.pipe(r.filter(y=>y),r.switchMap(()=>ve.focusRegained$),r.withLatestFrom(h),r.tap(([,y])=>{Ht(a,y)&&this.fetch({cancelRefetch:!1}).catch(r.noop)}),r.ignoreElements()),$=m.pipe(r.map(()=>a.state)),O=y=>y.pipe(r.withLatestFrom(h),r.map(([,T])=>{const D=this.getObserverResultFromQuery({query:a,options:T,prevResult:c(this,A)});return this.updateResult({query:a,...D}),D.result})),v=r.merge($,E,a.state$,o).pipe(O,r.distinctUntilChanged(x),r.distinctUntilChanged(b));return r.merge(d,C,v)})).pipe(Qe(a=>j(this,ae,a)),r.tap({subscribe:()=>{Le(e,this.options)&&this.fetch().catch(r.noop)}})))}destroy(){}}q=new WeakMap,M=new WeakMap,ie=new WeakMap,B=new WeakMap,A=new WeakMap,Z=new WeakMap,ae=new WeakMap;function Jt(s,e){return!x(s.getCurrentResult(),e)}const lt=we.createContext(!1),Xt=()=>we.useContext(lt);lt.Provider;function Zt(){let s=!1;return{clearReset:()=>{s=!1},reset:()=>{s=!0},isReset:()=>s}}const er=we.createContext(Zt()),tr=()=>we.useContext(er);function rr(s,e){return typeof s=="function"?s(...e):!!s}const sr=({result:s,errorResetBoundary:e,throwOnError:t,query:n})=>s.isError&&!e.isReset()&&!s.isFetching&&n&&rr(t,[s.error,n]);function ht(s,e,t){if(process.env.NODE_ENV!=="production"&&(typeof s!="object"||Array.isArray(s)))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');const n=Pe(t),i=Xt(),u=tr(),a=n.defaultQueryOptions(s);a._optimisticResults=i?"isRestoring":"optimistic";const[l]=S.useState(()=>new e(n,a)),h=$e(()=>l.observe()),f=Q(l.getOptimisticResult(a)),o=f.current;fe(()=>h.current.pipe(r.filter(E=>!x(E,f.current))),[]),S.useEffect(()=>{l.setOptions(a)},[a,l]);const b=o.error;if(b&&sr({result:o,errorResetBoundary:u,throwOnError:a.throwOnError,query:n.getQueryCache().get(a.queryHash)}))throw b;return f.current}function nr(s,e){return ht(s,ot,e)}function ir(s,e){return ht({refetchOnMount:"idle",refetchOnReconnect:!1,refetchInterval:!1,refetchOnWindowFocus:!1,...s},ot,e)}function ar(s,e,t=[]){const n=e!=null&&!Array.isArray(e)?e:{},i=n.retry??!0,u=Q(n.onError??(h=>{console.error(h)})),a=S.useCallback(()=>R(s),t),l=S.useCallback(()=>a().pipe(r.catchError(h=>{throw u.current(h),h}),i?r.retry():r.identity),[a,i,u]);Fe(l,t)}const ft=()=>s=>r.merge(r.of({isPaused:!0}),_.backToOnline$.pipe(r.mergeMap(()=>r.merge(r.of({isPaused:!1}),s)))),ur=s=>{let e=0;return s.pipe(r.catchError(t=>(e++,e<=1&&!_.isOnline()?r.merge(r.of({failureCount:e,failureReason:t}),r.timer(1).pipe(r.mergeMap(()=>r.throwError(()=>t).pipe(ft())))):r.throwError(()=>t))))},cr=({variables:s,state:e,options:t})=>{const n=e.isPaused,i=async()=>await Promise.reject(new Error("No mutationFn found")),u=t.mutationFn??i,a=R(()=>{var d;return((d=t.onMutate)==null?void 0:d.call(t,s))??void 0}),l=r.of(e.context),h=r.iif(()=>n,l,a).pipe(r.shareReplay(1)),f=(d,p,m)=>R(()=>{var $;return($=t.onError)==null?void 0:$.call(t,d,s,p)}).pipe(r.catchError(()=>r.of(d)),r.map(()=>({failureCount:m,error:d,failureReason:d,context:p,status:"error"}))),o=h.pipe(r.switchMap(d=>{const m=(typeof u=="function"?R(()=>u(s)):u).pipe(r.share()),C=m.pipe(r.isEmpty(),r.tap(O=>{if(O)throw new Error("Mutation completed without any emission (EMPTY)")}),r.ignoreElements()),$=r.merge(m,C).pipe(r.map(O=>({result:{data:O},error:null,context:d})),ur,Ue({...t,retry:(O,U)=>{const v=t.retry??0;return typeof v=="function"?v(O,U):typeof v=="boolean"?v:O<v},caughtError:(O,U)=>r.of({failureCount:O,failureReason:U}),catchError:(O,U)=>f(U,d,O).pipe(r.map(v=>({...v,result:void 0})))}),r.takeWhile(({result:O,error:U})=>(O==null?void 0:O.data)===void 0&&U===void 0,!0));return _.isOnline()||t.networkMode==="offlineFirst"||t.networkMode==="always"?$:$.pipe(ft())})),b=r.of({...e,variables:s,status:"pending",isPaused:!1,failureCount:0,failureReason:null,submittedAt:e.submittedAt??new Date().getTime()});return r.merge(b,h.pipe(r.map(d=>({context:d}))),o.pipe(r.switchMap(({result:d,error:p,...m})=>{if(!d&&!p)return r.of({...m});const C=p?r.of(null):R(()=>{var v;return(v=t.onSuccess)==null?void 0:v.call(t,d==null?void 0:d.data,s,m.context)}),O=R(()=>{var v;return(v=t.onSettled)==null?void 0:v.call(t,d==null?void 0:d.data,p,s,m.context)}).pipe(r.catchError(v=>d?r.of(d):r.of(v)));return r.concat(C,O).pipe(r.toArray(),r.map(()=>p?{error:p,data:void 0,variables:s,...m}:{status:"success",error:p,data:d==null?void 0:d.data,variables:s,failureCount:0,failureReason:null,...m}),r.catchError(v=>f(v,m.context,0).pipe(r.map(y=>({...y,data:void 0})))))}))).pipe(r.scan((d,p)=>({...d,...p,data:p.data??d.data,error:p.error??d.error}),J()))};var ue,L,ee;class or{constructor({options:e,mutationCache:t,state:n}){w(this,ue,new r.BehaviorSubject(0));w(this,L,new r.Subject);w(this,ee,new r.Subject);g(this,"state",J());g(this,"state$");g(this,"options");g(this,"observerCount$",c(this,ue).asObservable());g(this,"cancelled$",c(this,L).asObservable());this.options=e,this.state=n??this.state;const i=c(this,L).pipe(r.filter(()=>this.state.status==="pending"),r.map(()=>({status:"idle"}))),u=c(this,ee).pipe(r.switchMap(l=>cr({options:{...this.options,onMutate:h=>{const f=R(()=>{var d,p;return(p=(d=t.config).onMutate)==null?void 0:p.call(d,h,this)}),b=R(()=>{var d,p;return(p=(d=this.options).onMutate)==null?void 0:p.call(d,h)});return f.pipe(r.mergeMap(()=>b))},onError:(h,f,o)=>{const b=R(()=>{var d,p;return(p=(d=t.config).onError)==null?void 0:p.call(d,h,f,o,this)}),E=R(()=>{var d,p;return(p=(d=this.options).onError)==null?void 0:p.call(d,h,f,o)});return r.concat(b,E).pipe(r.toArray())},onSettled:(h,f,o,b)=>{const E=R(()=>{var p,m;return(m=(p=t.config).onSettled)==null?void 0:m.call(p,h,f,o,b,this)}),d=R(()=>{var p,m;return(m=(p=this.options).onSettled)==null?void 0:m.call(p,h,f,o,b)});return r.concat(E,d).pipe(r.toArray())},onSuccess:(h,f,o)=>{const b=R(()=>{var d,p;return(p=(d=t.config).onSuccess)==null?void 0:p.call(d,h,f,o,this)}),E=R(()=>{var d,p;return(p=(d=this.options).onSuccess)==null?void 0:p.call(d,h,f,o)});return r.concat(b,E).pipe(r.toArray())}},state:this.state,variables:l}).pipe(r.takeUntil(c(this,L))))),a=r.merge(i,u);this.state$=a.pipe(r.startWith(this.state),r.scan((l,h)=>({...l,...h}),this.state),nt,r.tap(l=>{this.state=l}),r.shareReplay(1),Qe(l=>{c(this,ue).next(l)}))}get meta(){return this.options.meta}setOptions(e){this.options={...this.options,...e}}execute(e){return c(this,ee).next(e),c(this,ee).complete(),this.state$.pipe(ne)}continue(){return this.execute(this.state.variables)}cancel(){c(this,L).next(),c(this,L).complete()}}ue=new WeakMap,L=new WeakMap,ee=new WeakMap;const Ge=({mutationKey:s,status:e,predicate:t,exact:n=!0}={})=>u=>n&&s!==void 0&&u.options.mutationKey!==void 0&&!ye(u.options.mutationKey,s,{exact:n})||!n&&s!==void 0&&u.options.mutationKey!==void 0&&!ye(u.options.mutationKey,s,{exact:n})||e&&u.state.status!==e?!1:t?t(u):!0;class dt{constructor(){g(this,"entriesSubject",new r.BehaviorSubject([]));g(this,"changeSubject",new r.Subject);g(this,"entries$",this.entriesSubject.pipe(r.share()));g(this,"added$",this.changeSubject.pipe(r.filter(({type:e})=>e==="added"),r.map(({entity:e})=>e),r.share()));g(this,"removed$",this.changeSubject.pipe(r.filter(({type:e})=>e==="removed"),r.map(({entity:e})=>e),r.share()));g(this,"stateChange$",r.merge(this.entriesSubject.pipe(r.first(),r.mergeMap(e=>r.from(e))),this.added$).pipe(r.mergeMap(e=>e.state$.pipe(r.map(()=>e),r.takeUntil(this.removed$.pipe(r.filter(t=>t===e))))),r.share()))}getValues(){return this.entriesSubject.getValue()}remove(e){this.entriesSubject.next(this.entriesSubject.getValue().filter(t=>e!==t)),this.changeSubject.next({type:"removed",entity:e})}add(e){this.entriesSubject.next([...this.entriesSubject.getValue(),e]),this.changeSubject.next({type:"added",entity:e})}find(e){return this.entriesSubject.getValue().find(e)}}var k;class pt{constructor(e={}){w(this,k,new dt);this.config=e}build(e,t,n){const i=new or({mutationCache:this,options:e.defaultMutationOptions(t),state:n});return i.state$.pipe(r.filter(({status:u})=>u==="success"||u==="error"),r.switchMap(()=>i.observerCount$.pipe(r.filter(u=>u<=1),r.take(1))),r.switchMap(()=>r.timer(i.options.gcTime??5*60*1e3)),r.take(1)).subscribe({complete:()=>{this.remove(i)}}),c(this,k).add(i),i}getAll(){return this.findAll()}remove(e){const t=c(this,k).getValues().find(n=>n===e);t==null||t.cancel(),c(this,k).remove(e)}find(e){const t={exact:!0,...e},n=Ge(t);return c(this,k).getValues().find(i=>n(i))}findAll(e={}){const t={exact:!0,...e},n=Ge(t);return c(this,k).getValues().filter(i=>n(i)).map(i=>i)}observe(){return c(this,k).stateChange$.pipe(r.startWith())}subscribe(e){const t=r.merge(c(this,k).added$.pipe(r.tap(n=>{e({type:"added",mutation:n})})),c(this,k).removed$.pipe(r.tap(n=>{e({type:"removed",mutation:n})})),c(this,k).stateChange$.pipe(r.tap(n=>{e({type:"updated",action:{...n.state,type:"success"},mutation:n})}))).subscribe();return()=>{t.unsubscribe()}}resumePausedMutations(){const e=this.findAll({predicate:n=>n.state.isPaused});if(!e.length)return r.EMPTY;const t=e.map(n=>n.continue());return r.combineLatest(t)}clear(){this.getAll().forEach(e=>{this.remove(e)})}}k=new WeakMap;function lr(s){const e=typeof s.initialData=="function"?s.initialData():s.initialData,t=typeof e<"u",n=t?typeof s.initialDataUpdatedAt=="function"?s.initialDataUpdatedAt():s.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:t?n??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:t?"success":"pending",fetchStatus:"idle"}}const hr=s=>r.defer(()=>ve.isFocused()?s:ve.focusRegained$.pipe(r.mergeMap(()=>s))),fr=s=>{let e=0;return t=>{const n=_.backToOnline$.pipe(r.mergeMap(()=>r.merge(r.of({fetchStatus:"fetching"}),t)));return r.defer(()=>(e++,!_.isOnline()&&s.networkMode==="offlineFirst"&&e>1?r.merge(r.of({fetchStatus:"paused"}),n):!_.isOnline()&&s.networkMode!=="always"&&s.networkMode!=="offlineFirst"?r.merge(r.of({fetchStatus:"paused"}),n):t))}},dr=s=>e=>{const t=new r.Subject,n=t.pipe(r.first(),r.delay(1),r.mergeMap(()=>s.pipe(r.filter(i=>i===0))));return e.pipe(r.tap(()=>{t.next()}),r.takeUntil(n))},pr=s=>{const e=async()=>await Promise.reject(new Error("No query found"));process.env.NODE_ENV!=="production"&&s.queryFn===je&&console.error(`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${s.queryHash}'`);let t=!1;const n=s.queryFn&&s.queryFn!==je?s.queryFn:e,i=new AbortController,u={meta:s.meta,queryKey:s.queryKey};(o=>{Object.defineProperty(o,"signal",{enumerable:!0,get:()=>(s.onSignalConsumed(),i.signal)})})(u);const h=(typeof n=="function"?R(()=>n(u)):n).pipe(dr(s.observers$),r.tap({complete:()=>{t=!0}}),r.map(o=>({data:o})),fr(s),Ue({...s,retryAfter:()=>r.of(!0).pipe(hr),catchError:(o,b)=>r.of({status:"error",fetchStatus:"idle",fetchFailureCount:o,fetchFailureReason:b,error:b}),caughtError:(o,b)=>r.of({fetchFailureCount:o,fetchFailureReason:b})}),r.mergeMap(o=>"data"in o?r.of({...o,status:"success",fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null,dataUpdatedAt:new Date().getTime()}).pipe(r.delay(1),r.map(b=>t?b:{...b,fetchStatus:"fetching"})):r.of(o)),r.endWith({fetchStatus:"idle"}),r.share()),f=r.of({status:"pending",fetchStatus:_.isOnline()?"fetching":"paused"});return{state$:r.merge(f,h).pipe(r.share()),abortController:i}};class br{constructor(e){g(this,"revert");g(this,"silent");this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}}const gr={backgroundColor:"transparent",color:"inherit"};function bt(s){const e={namespaces:[{name:"@reactjrx",style:{backgroundColor:"#d02f4e",color:"white"}}],namespace(t,n){const i=bt();return i.namespaces.push({name:t,style:n??gr}),i},printNamespaces(){return{namespaces:e.namespaces.map(({name:t})=>`%c ${t} %c`).join(" "),styles:e.namespaces.reduce((t,{style:n})=>(t.push(`background-color: ${n.backgroundColor}; color: ${n.color};`),t.push("background-color: transparent; color: inherit;"),t),[])}},print(t,...n){return e},printWithoutNamespace(t,...n){return e},log(...t){return e.print("log",...t)},warn(...t){return e.print("warn",...t)},error(...t){return e.print("error",...t)},group(...t){return e.print("group",...t)},groupEnd(){return e}};return e}const mr=bt();var ce,Y;class yr{constructor(e){g(this,"queryKey");g(this,"queryHash");g(this,"gcTime");g(this,"options");w(this,ce);w(this,Y);g(this,"state");g(this,"executeSubject",new r.Subject);g(this,"cancelSubject",new r.Subject);g(this,"setDataSubject",new r.Subject);g(this,"invalidatedSubject",new r.Subject);g(this,"resetSubject",new r.Subject);g(this,"destroySubject",new r.Subject);g(this,"observersSubject",new r.BehaviorSubject([]));g(this,"abortSignalConsumed",!1);g(this,"observerCount$",this.observersSubject.asObservable().pipe(r.map(e=>e.length)));g(this,"observers$",this.observersSubject.asObservable());g(this,"state$");j(this,ce,e.defaultOptions),this.options=this.setOptions(e.options),this.queryKey=e.queryKey,this.queryHash=e.queryHash,j(this,Y,e.state??lr(this.options)),this.state=c(this,Y),this.gcTime=this.updateGcTime(this.options.gcTime),this.state$=r.merge(this.resetSubject.pipe(r.map(()=>({command:"reset",state:c(this,Y)}))),this.invalidatedSubject.pipe(r.filter(()=>!this.state.isInvalidated),r.map(()=>({command:"invalidate",state:{isInvalidated:!0}}))),this.cancelSubject.pipe(r.filter(()=>!(this.state.error&&this.state.status==="error")),r.map(t=>({command:"cancel",state:{status:t!=null&&t.revert?this.state.status:"error",fetchStatus:"idle",error:new br(t)}}))),this.executeSubject.pipe(r.mergeMap(()=>{let t=!1;const n=this.executeSubject.pipe(r.filter(f=>(f==null?void 0:f.cancelRefetch)!==!1)),i=this.observers$.pipe(r.pairwise(),r.tap(([f,o])=>{o.length===0&&f.length>0?t=!0:t=!1}),r.ignoreElements()),{state$:u,abortController:a}=pr({...this.options,observers$:this.observerCount$,queryKey:this.queryKey,retry:(f,o)=>{const b=this.options.retry??!0;return typeof b=="function"?b(f,o):typeof b=="boolean"?b:f<b},retryAfterDelay:()=>!t,onSignalConsumed:()=>{this.abortSignalConsumed=!0}}),l=this.observerCount$.pipe(r.filter(f=>f===0&&this.abortSignalConsumed),r.tap(()=>{this.cancelSubject.next({revert:!0})})),h=r.merge(this.cancelSubject,n,this.resetSubject,l).pipe(r.tap(()=>{this.abortSignalConsumed&&a.abort()}));return r.merge(u,i).pipe(r.map(f=>({command:"execute",state:f})),r.takeUntil(h))})),this.setDataSubject.pipe(r.map(({data:t,options:n})=>({command:"setData",state:{status:"success",data:t,dataUpdatedAt:(n==null?void 0:n.updatedAt)!==void 0?n.updatedAt:new Date().getTime()}})))).pipe(zt({initialState:this.state,getOptions:()=>this.options,getState:()=>this.state}),r.startWith(c(this,Y)),r.distinctUntilChanged(x),r.tap(t=>{this.state=t}),r.catchError(t=>{throw mr.error(t),t}),r.takeUntil(this.destroySubject),r.shareReplay({bufferSize:1,refCount:!1}))}setOptions(e){return this.options={...c(this,ce),...e},this.updateGcTime(this.options.gcTime),this.options}get meta(){return this.options.meta}get success$(){return this.state$.pipe(r.map(({data:e,status:t})=>({data:e,status:t})),r.distinctUntilChanged(x),r.filter(({status:e})=>e==="success"))}get error$(){return this.state$.pipe(r.map(({error:e,status:t})=>({error:e,status:t})),r.distinctUntilChanged(x),r.filter(({status:e})=>e==="error"))}get settled$(){return this.state$.pipe(r.map(({status:e})=>({status:e})),r.distinctUntilChanged(x),r.filter(({status:e})=>e==="success"||e==="error"))}observe(e){return this.state$.pipe(r.tap({subscribe:()=>{this.observersSubject.next([e,...this.observersSubject.getValue()])},unsubscribe:()=>{this.observersSubject.next(this.observersSubject.getValue().filter(n=>n!==e))}}))}getObserversCount(){return this.observersSubject.getValue().length}updateGcTime(e){return this.gcTime=Math.max(this.gcTime||0,e??(X?1/0:5*60*1e3)),this.gcTime}isActive(){return this.observersSubject.getValue().some(e=>e.options.enabled!==!1)}isDisabled(){return this.getObserversCount()>0&&!this.isActive()}isStale(){return this.state.isInvalidated||!this.state.dataUpdatedAt||this.observersSubject.getValue().some(e=>e.getCurrentResult().isStale)}isStaleByTime(e=0){return this.state.isInvalidated||!this.state.dataUpdatedAt||!Lt(this.state.dataUpdatedAt,e)}async getFetchResultAsPromise(){return await new Promise((e,t)=>{this.state$.pipe(ct,r.last()).subscribe({error:t,next:n=>{n.error?t(n.error):e(n.data)}})})}async fetch(e,t){const{cancelRefetch:n}=t??{};return this.state.fetchStatus!=="idle"&&!(!!this.state.dataUpdatedAt&&n)?await this.getFetchResultAsPromise():(e&&this.setOptions(e),this.executeSubject.next(t),await this.getFetchResultAsPromise())}setData(e,t){const n=Se(this.state.data,e,this.options);return this.setDataSubject.next({data:n,options:t}),n}invalidate(){this.invalidatedSubject.next()}async cancel(e){this.cancelSubject.next(e)}destroy(){this.destroySubject.next(),this.destroySubject.complete(),this.executeSubject.complete()}reset(){this.resetSubject.next()}}ce=new WeakMap,Y=new WeakMap;var oe,N;class gt{constructor(e={}){w(this,oe,new r.Subject);w(this,N,new dt);this.config=e}mount(){}unmount(){}notify(e){c(this,oe).next(e)}observeIsFetching(e){return c(this,N).stateChange$.pipe(r.startWith(),r.map(()=>this.findAll({...e,fetchStatus:"fetching"}).length),r.distinctUntilChanged())}getAll(){return[...c(this,N).getValues()]}findAll(e={}){const t=this.getAll();return Object.keys(e).length>0?t.filter(n=>Ye(e,n)):t}build(e,t,n){const i=t.queryKey??[Ae()],u=t.queryHash??Ve(i,t);let a=this.get(u);return a||(a=new yr({cache:this,queryKey:i,queryHash:u,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(i)}),this.add(a)),a}add(e){if(!c(this,N).find(t=>t.queryHash===e.queryHash)){c(this,N).add(e);const t=e.observerCount$.pipe(r.filter(n=>n<1),r.take(1));e.success$.subscribe(()=>{var n,i;(i=(n=this.config).onSuccess)==null||i.call(n,e.state.data,e)}),e.error$.subscribe(()=>{var n,i;(i=(n=this.config).onError)==null||i.call(n,e.state.error,e)}),e.settled$.subscribe(()=>{var n,i;(i=(n=this.config).onSettled)==null||i.call(n,e.state.data,e.state.error,e)}),e.state$.pipe(Bt,r.switchMap(n=>n?t.pipe(r.switchMap(()=>e.gcTime===1/0?r.NEVER:(setTimeout(r.noop,e.gcTime),r.timer(e.gcTime)))):r.NEVER),r.take(1)).subscribe({complete:()=>{this.remove(e)}})}}get(e){return c(this,N).find(t=>t.queryHash===e)}find(e){const t={exact:!0,...e};return this.getAll().find(n=>Ye(t,n))}subscribe(e){const t=r.merge(c(this,oe).pipe(r.tap(e))).subscribe();return()=>{t.unsubscribe()}}remove(e){const t=c(this,N).find(n=>n===e);t&&(e.destroy(),t===e&&c(this,N).remove(e))}clear(){}}oe=new WeakMap,N=new WeakMap;var G,F,le,he,te;class Sr{constructor({mutationCache:e,queryCache:t,defaultOptions:n}={}){w(this,G);w(this,F);w(this,le,new Map);w(this,he,new Map);w(this,te);j(this,G,e??new pt),j(this,F,t??new gt),j(this,te,n??{})}mount(){}unmount(){}getMutationCache(){return c(this,G)}getQueryCache(){return c(this,F)}defaultMutationOptions(e){return{...c(this,te).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e}}defaultQueryOptions(e){if(e._defaulted)return e;const t={...c(this,te).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=Ve(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===je&&(t.enabled=!1),t}async fetchQuery(e){const t=this.defaultQueryOptions(e);typeof t.retry>"u"&&(t.retry=!1);const n=c(this,F).build(this,t);return n.isStaleByTime(t.staleTime)?await n.fetch(t):await Promise.resolve(n.state.data)}async prefetchQuery(e){await this.fetchQuery(e).then(r.noop).catch(r.noop)}async resetQueries(e,t){const n=c(this,F),i={type:"active",...e};n.findAll(e).forEach(u=>{u.reset()}),await this.refetchQueries(i,t)}async refetchQueries(e={},t){const n={...t,cancelRefetch:(t==null?void 0:t.cancelRefetch)??!0},i=c(this,F).findAll(e).filter(u=>!u.isDisabled()).map(async u=>{let a=u.fetch(void 0,n);return n.throwOnError||(a=a.catch(r.noop)),u.state.fetchStatus==="paused"?void 0:await a});await Promise.all(i).then(r.noop)}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=c(this,F).get(t.queryHash))==null?void 0:n.state.data}setQueryData(e,t,n){const i=this.defaultQueryOptions({queryKey:e}),u=c(this,F).get(i.queryHash),a=u==null?void 0:u.state.data,l=_t(t,a);if(l!==void 0)return c(this,F).build(this,i).setData(l,{...n,manual:!0})}getMutationDefaults(e){const t=[...c(this,le).values()];let n={};return t.forEach(i=>{ye(e,i.mutationKey)&&(n={...n,...i.defaultOptions})}),n}getQueryState(e){var t;return(t=c(this,F).find({queryKey:e}))==null?void 0:t.state}setMutationDefaults(e,t){c(this,le).set(re(e),{mutationKey:e,defaultOptions:t})}setQueryDefaults(e,t){c(this,he).set(re(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...c(this,he).values()];let n={};return t.forEach(i=>{Ee(e,i.queryKey)&&(n={...n,...i.defaultOptions})}),n}removeQueries(e){const t=c(this,F);t.findAll(e).forEach(n=>{t.remove(n)})}async cancelQueries(e={},t={}){const n={revert:!0,...t},i=c(this,F).findAll(e).map(async u=>{await u.cancel(n)});await Promise.all(i).then(r.noop).catch(r.noop)}async invalidateQueries(e={},t={}){if(c(this,F).findAll(e).forEach(i=>{i.invalidate()}),e.refetchType==="none"){await Promise.resolve();return}const n={...e,type:e.refetchType??e.type??"active"};await this.refetchQueries(n,t)}async resumePausedMutations(){return await r.lastValueFrom(c(this,G).resumePausedMutations())}isFetching(e){return c(this,F).findAll({...e,fetchStatus:"fetching"}).length}clear(){c(this,F).clear(),c(this,G).clear()}}G=new WeakMap,F=new WeakMap,le=new WeakMap,he=new WeakMap,te=new WeakMap;exports.MutationCache=pt;exports.QueryCache=gt;exports.QueryClient=Sr;exports.QueryClientProvider=It;exports.SIGNAL_RESET=Je;exports.arrayEqual=At;exports.createLocalStorageAdapter=et;exports.createLocalforageAdapter=Ct;exports.exponentialBackoffDelay=rt;exports.getDelay=tt;exports.isDefined=me;exports.retryBackoff=Ue;exports.signal=Xe;exports.useBehaviorSubject=xe;exports.useEffectOnce=st;exports.useForeverQuery=ir;exports.useLiveRef=Q;exports.useMount=Qt;exports.useMutation=Dt;exports.useObservableState=$t;exports.useObserve=fe;exports.useObserveCallback=wt;exports.usePersistSignals=xt;exports.useQuery=nr;exports.useQueryClient=Pe;exports.useSignal=Et;exports.useSignalValue=Ze;exports.useSubject=Re;exports.useSubscribe=Fe;exports.useSubscribeEffect=ar;exports.useUnmountObservable=Ut;
1
+ "use strict";var yt=Object.defineProperty;var Ke=s=>{throw TypeError(s)};var St=(s,e,t)=>e in s?yt(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var m=(s,e,t)=>St(s,typeof e!="symbol"?e+"":e,t),Ne=(s,e,t)=>e.has(s)||Ke("Cannot "+t);var o=(s,e,t)=>(Ne(s,e,"read from private field"),t?t.call(s):e.get(s)),w=(s,e,t)=>e.has(s)?Ke("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(s):e.set(s,t),M=(s,e,t,n)=>(Ne(s,e,"write to private field"),n?n.call(s,t):e.set(s,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("react"),r=require("rxjs"),K=require("rxjs/operators"),qe=require("react/jsx-runtime");function vt(s){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const t in s)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(s,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>s[t]})}}return e.default=s,Object.freeze(e)}const we=vt(S),Q=s=>{const e=S.useRef(s);return S.useMemo(()=>{e.current=s},[s]),e};function je(s){return s instanceof Promise||s&&typeof s=="object"&&"then"in s&&typeof s.then=="function"&&"catch"in s&&s.catch==="function"}function R(s){if(r.isObservable(s))return s;if(je(s))return r.from(s);if(typeof s!="function")return r.of(s);const e=s;return r.defer(()=>{const t=e();return je(t)?r.from(t):r.isObservable(t)?t:r.of(t)})}function fe(s,e,t){const n=e!=null&&!Array.isArray(e)?e:{defaultValue:void 0,unsubscribeOnUnmount:!0},i=!t&&Array.isArray(e)?e:typeof s=="function"?t??[]:[s],u=S.useRef("getValue"in s&&typeof s.getValue=="function"?s.getValue():n.defaultValue),a=Q(s),l=Q(n),h=S.useCallback(b=>{const E=a.current,d=R(E).pipe(r.distinctUntilChanged((p,g)=>p===g),r.tap(p=>{u.current=p}),r.catchError(p=>(console.error(p),r.EMPTY))).subscribe(b);return()=>{l.current.unsubscribeOnUnmount!==!1&&d.unsubscribe()}},[...i]),f=S.useCallback(()=>u.current,[]);return S.useSyncExternalStore(h,f,f)}function Re(s,e=[]){const t=Q(s);S.useEffect(()=>{const n=R(t.current).pipe(r.catchError(i=>(console.error(i),r.EMPTY))).subscribe();return()=>{n.unsubscribe()}},[...e,t])}const $e=s=>{const e=S.useRef();return e.current||(e.current=s()),S.useEffect(()=>{process.env.NODE_ENV},[]),e},xe=({onBeforeComplete:s,completeOnUnmount:e=!0}={})=>{const t=$e(()=>new r.Subject),n=S.useRef(!1),i=Q(s),u=Q(e);return S.useEffect(()=>(n.current&&(t.current=new r.Subject,n.current=!1),()=>{if(!u.current){n.current=!0;return}n.current||(i.current!=null&&i.current(),t.current.complete(),n.current=!0)}),[u,i,t]),t},Ot=()=>{const s=xe(),e=Q(s.current.asObservable()),t=S.useCallback(n=>{s.current.next(n)},[]);return[e.current,t]},Ue=s=>{const e=$e(()=>new r.BehaviorSubject(s)),t=S.useRef(!1),n=S.useRef(s);return S.useEffect(()=>(t.current&&(e.current=new r.BehaviorSubject(n.current),t.current=!1),()=>{t.current||(e.current.complete(),t.current=!0)}),[e]),e},wt=s=>{const e=Ue(s),t=Q(e.current.asObservable()),n=S.useCallback(i=>{e.current.next(i)},[e.current]);return[t.current,n,e.current.getValue()]},Je=Symbol("SIGNAL_RESET");function Xe(s={}){const e={default:s.default,key:s.key},{default:t}=e??{},n=new r.BehaviorSubject(t),i=a=>{if(typeof a=="function"){const l=a(n.getValue());if(l===n.getValue())return;n.next(l);return}if(a===Je){n.next(t??void 0);return}n.next(a)},u=()=>n.getValue();if("get"in s){const a=h=>(h.subject.pipe(r.skip(1),r.first()).subscribe(()=>{var c;const f=(c=s.get)==null?void 0:c.call(s,a);i(f)}),h.getValue()),l=s.get(a);return i(l),{getValue:u,config:s,subject:n}}return{setValue:i,getValue:u,config:e,subject:n}}function Ze(s,e){const n=e??(()=>s.getValue());return fe(()=>s.subject.pipe(r.map(u=>n(u)),r.distinctUntilChanged()),{defaultValue:n(s.getValue())},[])}const $t=s=>{const[e]=S.useState(()=>Xe(s));return[Ze(e),e]},Et=s=>({getItem:async e=>{const t=await s.getItem(e);if(t)return JSON.parse(t)},setItem:async(e,t)=>{await s.setItem(e,JSON.stringify(t))},removeItem:async e=>{},clear:async()=>{}}),Ce=s=>{if(!(!s||typeof s!="object"))return s},Ct=({adapter:s,key:e})=>({clear:async()=>await s.removeItem(e),removeItem:async t=>{const n=await s.getItem(e),{[t]:i,...u}=Ce(n)??{};await s.setItem(e,u)},getItem:async t=>{const n=await s.getItem(e),i=Ce(n)??{};if(t in i)return i[t]},setItem:async(t,n)=>{const i=await s.getItem(e),u=Ce(i)??{};await s.setItem(e,{...u,[t]:n})}}),et=({key:s}={})=>s?Ct({adapter:et(),key:s}):{clear:async()=>{localStorage.clear()},removeItem:async e=>{localStorage.removeItem(e)},getItem:async e=>{const t=localStorage.getItem(e);if(t)return JSON.parse(t)},setItem:async(e,t)=>{localStorage.setItem(e,JSON.stringify(t))}},se="__reactjrx",jt=s=>{if(typeof s=="object"&&s!==null&&se in s&&s[se]===se)return s};function me(s){return s!=null}const He=s=>{const e=Ue(s);return S.useEffect(()=>{e.current.next(s)},[s,e]),e},Mt=({adapter:s,config:e})=>{const{signal:t,version:n}=e,u={value:t.getValue(),[se]:se,migrationVersion:n};return r.from(s.setItem(t.config.key,u)).pipe(r.catchError(a=>(console.error(a),r.of(null))))};function Ft({adapter:s,config:e}){const{hydrate:t=({value:u})=>u,signal:n,version:i}=e;return r.from(s.getItem(n.config.key)).pipe(r.switchMap(u=>{const a=jt(u);if(!a||a.migrationVersion!==void 0&&i>a.migrationVersion||a.value===void 0)return r.of(u);const l=a.value;return n.setValue(t({value:l,version:i})),r.of(u)}))}function Rt({entries:s=[],onReady:e,adapter:t}){const n=Q(s),i=Q(e),u=He(t),a=fe(()=>{const h=n.current;return u.current.pipe(r.switchMap(f=>(h.length===0||!f?r.of(!0):r.zip(...h.map(b=>Ft({adapter:f,config:b}))).pipe(r.map(()=>!0))).pipe(r.tap(()=>{i.current!=null&&i.current()}),r.catchError(b=>(console.error("Unable to hydrate",b),r.EMPTY)))))},{defaultValue:!1},[u,n]),l=He(a);return Re(()=>l.current.pipe(r.filter(h=>h),r.switchMap(()=>u.current),r.filter(me),r.switchMap(h=>r.merge(...n.current.map(f=>f.signal.subject.pipe(r.throttleTime(500,r.asyncScheduler,{trailing:!0}),r.switchMap(()=>r.from(Mt({adapter:h,config:f})))))))),[l,u]),{isHydrated:a}}const xt=()=>{const s=xe({onBeforeComplete:()=>{s.current.next()}});return s},tt=s=>{S.useEffect(s,[])},Ut=s=>{tt(()=>{s()})};function rt(s,e){return Math.min(s,e)}function st(s,e){return Math.pow(2,s)*e}function Ae(s){const{retry:e,retryDelay:t,retryAfterDelay:n,retryAfter:i=()=>r.of(!0)}=s,u=typeof e!="function"?e===!1?0:e===!0?1/0:e??1/0:1/0,a=typeof e=="function"?e:()=>!0,l=typeof t=="number"?t:100,h={shouldRetry:a,...s},{maxInterval:f=1/0,resetOnSuccess:c=!1,backoffDelay:b=st}=h;return E=>r.defer(()=>{let d=0;const p=(g,C)=>g<u?a(g,C):!1;return E.pipe(K.catchError(g=>{var $;if(d++,!p(d-1,g))throw g;const C=($=s.caughtError)==null?void 0:$.call(s,d,g);if(!C)throw g;return C.pipe(K.mergeMap(O=>r.merge(r.of(O),r.throwError(()=>g))))}),K.retryWhen(g=>g.pipe(K.concatMap(C=>{const $=d-1;return i().pipe(K.first(),K.mergeMap(()=>p($,C)?r.timer(rt(b($,l),f)).pipe(K.mergeMap(O=>n&&!n($,C)?r.throwError(()=>C):r.of(O))):r.throwError(()=>C)))}))),K.catchError(g=>{if(s.catchError)return s.catchError(d,g);throw g}),K.tap(()=>{c&&(d=0)}))})}const At=(s,e)=>s.length===e.length&&s.every((t,n)=>t===e[n]),J=typeof window>"u"||"Deno"in window;function Le(s){return Object.prototype.toString.call(s)==="[object Object]"}function Me(s){if(!Le(s))return!1;const e=s.constructor;if(typeof e>"u")return!0;const t=e.prototype;return!(!Le(t)||!t.hasOwnProperty("isPrototypeOf"))}const re=s=>JSON.stringify(s,(e,t)=>Me(t)?Object.keys(t).sort().reduce((n,i)=>(n[i]=t[i],n),{}):t),Qe=(s=21)=>crypto.getRandomValues(new Uint8Array(s)).reduce((e,t)=>(t&=63,t<36?e+=t.toString(36):t<62?e+=(t-26).toString(36).toUpperCase():t>62?e+="-":e+="_",e),""),X=()=>({context:void 0,data:void 0,error:null,status:"idle",submittedAt:0,variables:void 0,failureCount:0,failureReason:null,isPaused:!1});function Pe(s){let e=0;return function(n){return new r.Observable(i=>{e++;const u=n.subscribe(i);return s(e),()=>{e--,s(e),u.unsubscribe()}})}}const ne=s=>s.pipe(r.takeWhile(e=>e.status!=="error"&&e.status!=="success",!0));var H;class Qt{constructor({__queryFinalizeHook:e}={}){w(this,H,new r.Subject);m(this,"state$");const t=new r.BehaviorSubject(0),n=t.pipe(r.filter(i=>i===0));this.state$=o(this,H).pipe(r.concatMap(({args:i,mutation:u,options:a})=>{const l=a.mapOperator??"merge",h=o(this,H).pipe(r.filter(()=>l==="merge")),f=o(this,H).pipe(r.filter(()=>l==="switch"),r.tap(()=>{u.cancel()})),c=r.defer(()=>(u.execute(i),r.EMPTY)),b=u.state$.pipe(ne,r.last(),r.mergeMap(()=>u.state$),r.takeUntil(o(this,H))),E=u.state$.pipe(ne,r.skip(1)),d=r.merge(n,h,f,u.cancelled$);return r.merge(E,b,c).pipe(r.map(p=>({state:p,mutation:u})),e??r.identity,r.takeUntil(d))}),r.shareReplay({refCount:!0,bufferSize:1}),Pe(i=>{t.next(i)}))}trigger({args:e,options:t,mutation:n}){o(this,H).next({args:e,options:t,mutation:n})}}H=new WeakMap;function Ee(s,e){return s===e?!0:typeof s!=typeof e?!1:s&&e&&typeof s=="object"&&typeof e=="object"?!Object.keys(e).some(t=>!Ee(s[t],e[t])):!1}const ye=(s,e,{exact:t=!1}={})=>t?re(s)===re(e):Ee(s,e);function x(s,e){if(s==null||e===void 0||typeof s!="object"||typeof e!="object")return s===e;if(s.constructor!==(e==null?void 0:e.constructor))return!1;const t=Object.keys(s),n=Object.keys(e);if(t.length!==n.length)return!1;for(const i of t)if(!e.hasOwnProperty(i)||s[i]!==e[i])return!1;return!0}const nt=s=>s.pipe(r.distinctUntilChanged(({data:e,...t},{data:n,...i})=>x(t,i)&&x(e,n)));var B,I;class Pt{constructor(e,t={},n){w(this,B);w(this,I,new r.BehaviorSubject(void 0));m(this,"observed$");m(this,"getObserverResultFromState",e=>({...X(),...e,isSuccess:e.status==="success",isPending:e.status==="pending",isIdle:e.status==="idle",isError:e.status==="error",mutate:this.mutate,reset:this.reset}));var i;this.client=e,this.options=t,this.options.mutationKey=((i=this.options)==null?void 0:i.mutationKey)??[Qe()],M(this,B,n??new Qt(this.options)),this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this),o(this,I).pipe(r.filter(me),r.mergeMap(u=>o(this,B).state$.pipe(r.takeUntil(u.mutation.state$.pipe(ne,r.last()))))).subscribe(),this.observed$=o(this,I).pipe(r.switchMap(u=>(u==null?void 0:u.mutation.state$.pipe(r.map(a=>({state:a,options:u.options}))))??r.EMPTY),r.tap(({state:u,options:a})=>{u.status==="error"&&(a!=null&&a.onError&&(a==null||a.onError(u.error,u.variables,u.context)),a!=null&&a.onSettled&&(a==null||a.onSettled(u.data,u.error,u.variables,u.context))),u.status==="success"&&(a!=null&&a.onSuccess&&(a==null||a.onSuccess(u.data,u.variables,u.context)),a!=null&&a.onSettled&&(a==null||a.onSettled(u.data,u.error,u.variables,u.context)))}),r.ignoreElements())}setOptions(e){var i;const t=this.options;this.options=this.client.defaultMutationOptions({mutationKey:this.options.mutationKey,...e});const n=(i=o(this,I).getValue())==null?void 0:i.mutation;this.options.mutationKey&&t.mutationKey&&!ye(this.options.mutationKey,t.mutationKey,{exact:!0})?this.reset():n==null||n.setOptions(this.options)}observe(){var u;const e=this.getObserverResultFromState(((u=o(this,I).getValue())==null?void 0:u.mutation.state)??X()),t=o(this,B).state$.pipe(r.distinctUntilChanged(({mutation:a,state:{data:l,...h}},{mutation:f,state:{data:c,...b}})=>a===f&&x(h,b)&&x(l,c)),r.map(({state:a})=>a),r.scan((a,l)=>({...a,...l,...l.status==="pending"&&{data:l.data??a.data},...l.status==="pending"&&{error:l.error??a.error}})),r.map(a=>this.getObserverResultFromState(a))),n=o(this,I).pipe(r.filter(me),r.switchMap(a=>a.mutation.cancelled$),r.map(()=>this.getObserverResultFromState(X())));return{result$:r.merge(this.observed$,t,n).pipe(nt),lastValue:e}}subscribe(e){const t=this.observe().result$.subscribe(n=>{e(n)});return()=>{t.unsubscribe()}}async mutate(e,t={}){const n=this.client.getMutationCache().build(this.client,this.options);return o(this,I).next({mutation:n,options:t}),o(this,B).trigger({args:e,options:this.options,mutation:n}),await new Promise((i,u)=>{n.state$.pipe(ne,r.last()).subscribe({error:a=>{u(a)},next:a=>{a.error?u(a.error):i(a.data)}})})}getCurrentResult(){var t;const e=this.client.getMutationCache().find({exact:!0,mutationKey:(t=this.options)==null?void 0:t.mutationKey});return this.getObserverResultFromState((e==null?void 0:e.state)??X())}reset(){const{mutation:e}=o(this,I).getValue()??{};o(this,I).next(void 0),e==null||e.cancel()}}B=new WeakMap,I=new WeakMap;const it=S.createContext(void 0),kt=({client:s})=>(S.useEffect(()=>(s.mount(),()=>{s.unmount()}),[s]),null),Vt=S.memo(({children:s,client:e})=>{const t=S.useMemo(()=>e,[e]);return qe.jsxs(it.Provider,{value:t,children:[qe.jsx(kt,{client:e}),s]})}),ke=s=>{const e=S.useContext(it);if(s)return s;if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e};function It(){}function Tt(s,e){const t=ke(e),n=Q(s),i=$e(()=>[Qe()]),u=re(s.mutationKey??i.current),[a]=S.useState(()=>new Pt(t,s));S.useEffect(()=>{a.setOptions(s)},[a,s]);const l=S.useMemo(()=>a.observe(),[u,a]),h=fe(l.result$)??l.lastValue,f=S.useCallback((c,b)=>{a.mutate(c,b).catch(It)},[a]);return S.useEffect(()=>()=>{n.current.cancelOnUnMount&&a.reset()},[a,n]),{...h,mutate:f,mutateAsync:h.mutate}}function Dt(s){return e=>e.pipe(K.tap(t=>{s.next(t)}))}class Kt{constructor(){m(this,"isOnlineSubject",new r.BehaviorSubject(!0));m(this,"online$",this.isOnlineSubject.pipe(r.distinctUntilChanged()));m(this,"backToOnline$",this.online$.pipe(r.filter(e=>e),r.first()));r.merge(J?r.EMPTY:r.fromEvent(window,"offline").pipe(r.map(()=>!1)),J?r.EMPTY:r.fromEvent(window,"online").pipe(r.map(()=>!0))).pipe(Dt(this.isOnlineSubject)).subscribe()}isOnline(){return this.isOnlineSubject.getValue()}setOnline(e){this.isOnlineSubject.getValue()!==e&&this.isOnlineSubject.next(e)}}const _=new Kt;function Ve(s,e){return s.isStaleByTime(e.staleTime)}function Nt(s,e){return e.enabled!==!1&&!s.state.dataUpdatedAt&&!(s.state.status==="error"&&e.retryOnMount===!1)&&s.state.fetchStatus!=="fetching"}function We(s,e){return Nt(s,e)||s.state.dataUpdatedAt>0&&at(s,e,e.refetchOnMount)}function _e(s,e,t,n){return s.state.fetchStatus!=="fetching"&&t.enabled!==!1&&(s!==e||n.enabled===!1)&&(!t.suspense||s.state.status!=="error")&&Ve(s,t)}function qt(s,e){return at(s,e,e.refetchOnWindowFocus)}function at(s,e,t){if(e.enabled!==!1){const n=typeof t=="function"?t(s):t;return n==="idle"?s.state.fetchStatus==="idle":n==="always"||n!==!1&&Ve(s,e)}return!1}function Ht(s){return(s??"online")==="online"?_.isOnline():!0}function Be(s,e){return e.reduce((t,n)=>n in s?{...t,[n]:s[n]}:t,{})}function ze(s){return Array.isArray(s)&&s.length===Object.keys(s).length}function ut(s,e){if(s===e)return s;const t=ze(s)&&ze(e);if(t||Me(s)&&Me(e)){const n=t?s:Object.keys(s),i=n.length,u=t?e:Object.keys(e),a=u.length,l=t?[]:{};let h=0;for(let f=0;f<a;f++){const c=t?f:u[f];!t&&s[c]===void 0&&e[c]===void 0&&n.includes(c)?(l[c]=void 0,h++):(l[c]=ut(s[c],e[c]),l[c]===s[c]&&s[c]!==void 0&&h++)}return i===a&&h===i?s:l}return e}function Ie(s,e){return((e==null?void 0:e.queryKeyHashFn)??re)(s)}function Ye(s,e){const{type:t="all",exact:n,fetchStatus:i,predicate:u,queryKey:a,stale:l}=s;if(a){if(n){if(e.queryHash!==Ie(a,e.options))return!1}else if(!Ee(e.queryKey,a))return!1}if(t!=="all"){const h=e.isActive();if(t==="active"&&!h||t==="inactive"&&h)return!1}return!(typeof l=="boolean"&&e.isStale()!==l||typeof i<"u"&&i!==e.state.fetchStatus||u&&!u(e))}function Lt(s,e){return Math.max(s+(e??0)-Date.now(),0)}function Wt(s,e){return typeof s=="function"?s(e):s}function Se(s,e,t){return typeof t.structuralSharing=="function"?t.structuralSharing(s,e):t.structuralSharing!==!1?ut(s,e):e}const Fe=Symbol(),_t=({getOptions:s,getState:e,initialState:t})=>n=>n.pipe(r.scan((i,{command:u,state:a})=>{if(u==="reset")return{...i,...a};if(u==="cancel"){const v=i.status==="pending"?"pending":a.status??i.status;return{...i,...a,status:v}}const l=a.data,h=l!==void 0&&l!==i.data,f="data"in a,c=a.status==="success",b=i.data!==void 0,E=i.error!==void 0||i.error!==null,d=a.status??i.status,p=h?Se(e().data,l,s()):f?a.data:i.data,g=i.status==="error"||i.status==="success",C=a.status==="error"&&(i.status==="error"&&i.fetchStatus==="fetching"||i.status!=="error")?i.errorUpdateCount+1:i.errorUpdateCount,$=h?i.dataUpdateCount+1:a.dataUpdateCount??i.dataUpdateCount,O=a.status==="pending"&&g&&(b||E),U=d==="pending"?null:a.error??i.error;return{...i,...a,status:d,error:U,errorUpdateCount:C,...c&&{isInvalidated:!1},data:p,dataUpdateCount:$,...O&&{status:i.status}}},t)),Bt=s=>s.pipe(r.map(({status:e,fetchStatus:t})=>t==="idle"&&(e==="success"||e==="error"))),ot=s=>s.pipe(r.takeWhile(e=>e.fetchStatus!=="idle",!0));var Oe,L;class zt{constructor(){w(this,Oe,r.merge(J?r.EMPTY:r.fromEvent(document,"visibilitychange"),J?r.EMPTY:r.fromEvent(window,"visibilitychange")).pipe(r.map(()=>document.visibilityState)));w(this,L,new r.BehaviorSubject(J?!0:document.visibilityState==="visible"));m(this,"focused$",o(this,L));m(this,"focusRegained$",this.focused$.pipe(r.skip(1),r.filter(e=>e)));o(this,Oe).pipe(r.tap(e=>{o(this,L).next(e==="visible")})).subscribe()}isFocused(){return o(this,L).getValue()}setFocused(e){o(this,L).getValue()!==(e??!0)&&o(this,L).next(e??!0)}subscribe(e){const t=this.focused$.subscribe(e);return()=>{t.unsubscribe()}}refresh(){document.dispatchEvent(new Event("visibilitychange"))}}Oe=new WeakMap,L=new WeakMap;const ve=new zt,Yt=s=>s.pipe(r.filter(e=>e.status==="success"),r.map(e=>({data:e.data,status:e.status,dataUpdatedAt:e.dataUpdatedAt})),r.distinctUntilChanged(x));var q,j,ie,z,A,Z,ae;class ct{constructor(e,t){w(this,q);w(this,j);w(this,ie,new r.Subject);m(this,"queryUpdateSubject",new r.Subject);w(this,z);w(this,A);w(this,Z);w(this,ae,0);m(this,"getObserverResultFromQuery",({options:e,query:t,optimisticResult:n,prevResult:{result:i,options:u,state:a,select:l,selectError:h,selectResult:f}})=>{var ge;const c=t.state,b=t.state.status==="pending",E=o(this,j),d=this.options,g=t!==E?t.state:o(this,z);let{errorUpdatedAt:C,fetchStatus:$,error:O}=c;if(n){const P=!!o(this,ae),De=!P&&We(t,e),mt=P&&_e(t,E,e,d);(De||mt)&&($=Ht(t.options.networkMode)?"fetching":"paused")}const U=b&&$==="fetching";let v,y=h,T=l??null,D=f;if(e.select&&typeof c.data<"u")if(i&&c.data===(a==null?void 0:a.data)&&e.select===l)v=f;else try{T=e.select,v=e.select(c.data),v=Se(i==null?void 0:i.data,v,e),D=v,y=null}catch(P){v=f,y=P}else v=c.data,y=null;let V=$!=="idle"&&!c.dataUpdatedAt?"pending":c.status;y&&(O=y,v=f,C=(i==null?void 0:i.errorUpdatedAt)??C,V="error");const de=V==="error";let pe=!1;if(typeof e.placeholderData<"u"&&typeof v>"u"&&V==="pending"){let P;if(i!=null&&i.isPlaceholderData&&e.placeholderData===(u==null?void 0:u.placeholderData))P=i.data;else if(P=typeof e.placeholderData=="function"?e.placeholderData((ge=o(this,Z))==null?void 0:ge.state.data,o(this,Z)):e.placeholderData,e.select&&typeof P<"u")try{P=e.select(P)}catch{}typeof P<"u"&&(V="success",v=Se(i==null?void 0:i.data,P,e),pe=!0)}const be=$==="fetching";return{result:{status:V,fetchStatus:$,isPending:b,isSuccess:V==="success",isError:de,isInitialLoading:U,isLoading:U,data:v,dataUpdatedAt:c.dataUpdatedAt,error:O,errorUpdatedAt:C,failureCount:c.fetchFailureCount,failureReason:c.fetchFailureReason,errorUpdateCount:c.errorUpdateCount,isFetched:c.dataUpdateCount>0||c.errorUpdateCount>0,isFetchedAfterMount:c.dataUpdateCount>g.dataUpdateCount||c.errorUpdateCount>g.errorUpdateCount,isFetching:be,isRefetching:be&&!b,isLoadingError:de&&c.dataUpdatedAt===0,isPaused:$==="paused",isPlaceholderData:pe,isRefetchError:de&&c.dataUpdatedAt!==0,isStale:Ve(t,e),refetch:this.refetch},selectError:y,select:T,selectResult:D}});this.options=t,M(this,q,e),this.bindMethods(),M(this,j,this.setOptions(t));const n=o(this,j);M(this,z,n.state);const{result:i,select:u}=this.getObserverResultFromQuery({query:n,options:this.options,prevResult:{options:this.options,state:n.state}});M(this,A,{state:n.state,options:t,result:i,select:u})}bindMethods(){this.refetch=this.refetch.bind(this)}setOptions(e){const t=this.options;if(this.options=o(this,q).defaultQueryOptions(e),x(this.options,t)||o(this,q).getQueryCache().notify({type:"observerOptionsUpdated",query:o(this,j),observer:this}),typeof this.options.enabled<"u"&&typeof this.options.enabled!="boolean")throw new Error("Expected enabled to be a boolean");const n=this.buildQuery(this.options);return n!==o(this,j)&&(M(this,z,n.state),M(this,j,n)),this.queryUpdateSubject.next({options:this.options,query:n}),n}buildQuery(e){const t=o(this,q).getQueryCache().build(o(this,q),e);return!t.options.queryFn&&this.options.queryFn&&t.setOptions(e),t}getCurrentResult(){return this.getObserverResultFromQuery({options:this.options,prevResult:o(this,A),query:o(this,j)}).result}getCurrentQuery(){return o(this,j)}getOptimisticResult(e){const t=this.buildQuery(e),n=this.getObserverResultFromQuery({query:t,options:e,optimisticResult:!0,prevResult:o(this,A)});return Gt(this,n.result)&&this.updateResult({query:t,...n}),n.result}updateResult({query:e,result:t,selectError:n,select:i,selectResult:u}){o(this,A).state=e.state,o(this,A).result=t,o(this,A).selectResult=u,n!==void 0&&(o(this,A).selectError=n),i!==void 0&&(o(this,A).select=i),o(this,A).options=this.options,e.state.data!==void 0&&M(this,Z,e),o(this,q).getQueryCache().notify({query:o(this,j),type:"observerResultsUpdated"})}async refetch({...e}={}){return await this.fetch({...e})}async fetch(e){const t=this.buildQuery(this.options);t!==o(this,j)&&(M(this,j,t),M(this,z,t.state),this.queryUpdateSubject.next({options:this.options,query:t}));const n={...e,cancelRefetch:(e==null?void 0:e.cancelRefetch)??!0};o(this,j).fetch(this.options,n).catch(r.noop),o(this,ie).next({query:t,fetchOptions:n}),await t.getFetchResultAsPromise();const{result:i}=this.getObserverResultFromQuery({query:t,options:this.options,prevResult:o(this,A)});return i}subscribe(e){const t=this.observe().subscribe(e);return()=>{t.unsubscribe()}}observe(){const e=o(this,j),t=this.queryUpdateSubject.pipe(r.map(({query:a})=>a),r.startWith(o(this,j)),r.distinctUntilChanged()),n=this.queryUpdateSubject.pipe(r.startWith({query:o(this,j),options:this.options}),r.pairwise(),r.tap(([{options:a,query:l},{options:h,query:f}])=>{_e(f,l,h,a)&&this.fetch().catch(r.noop)}),r.ignoreElements()),i=t.pipe(r.switchMap(a=>a.observe(this)),r.ignoreElements());return r.merge(i,n,t.pipe(r.switchMap(a=>{const l=this.options,h=this.queryUpdateSubject.pipe(r.startWith({query:a,options:l}),r.filter(y=>y.query===a),r.map(y=>y.options),r.distinctUntilChanged(),r.shareReplay(1)),f=o(this,ie).pipe(r.filter(y=>y.query===a)),c=a.state$.pipe(Yt,r.switchMap(y=>this.options.staleTime===1/0?r.NEVER:(this.options.staleTime??0)<=0?r.of(y).pipe(r.delay(1)):r.timer(this.options.staleTime??1)),r.takeWhile(()=>this.options.enabled??!0)),b=(y,T)=>{const D=l.notifyOnChangeProps,V=typeof D=="function"?D():D;return(Array.isArray(V)?V.length===0?()=>!0:(pe,be)=>{const Te=Be(pe,V),ge=Be(be,V);return x(Te,ge)}:x)(y,T)},E=f.pipe(r.switchMap(()=>a.state$),ot),d=h.pipe(r.map(({refetchInterval:y,refetchIntervalInBackground:T})=>({refetchInterval:(typeof y=="function"?y(o(this,j)):y)??!1,refetchIntervalInBackground:T})),r.distinctUntilChanged(x),r.switchMap(({refetchInterval:y,refetchIntervalInBackground:T})=>y?r.interval(y).pipe(r.tap(()=>{(T||ve.isFocused())&&this.fetch({cancelRefetch:!1}).catch(r.noop)})):r.NEVER),r.ignoreElements()),p=h.pipe(r.map(({enabled:y})=>y??!0),r.distinctUntilChanged()),g=p.pipe(r.filter(y=>!y),r.map(()=>a.state)),C=p.pipe(r.filter(y=>y),r.switchMap(()=>ve.focusRegained$),r.withLatestFrom(h),r.tap(([,y])=>{qt(a,y)&&this.fetch({cancelRefetch:!1}).catch(r.noop)}),r.ignoreElements()),$=g.pipe(r.map(()=>a.state)),O=y=>y.pipe(r.withLatestFrom(h),r.map(([,T])=>{const D=this.getObserverResultFromQuery({query:a,options:T,prevResult:o(this,A)});return this.updateResult({query:a,...D}),D.result})),v=r.merge($,E,a.state$,c).pipe(O,r.distinctUntilChanged(x),r.distinctUntilChanged(b));return r.merge(d,C,v)})).pipe(Pe(a=>M(this,ae,a)),r.tap({subscribe:()=>{We(e,this.options)&&this.fetch().catch(r.noop)}})))}destroy(){}}q=new WeakMap,j=new WeakMap,ie=new WeakMap,z=new WeakMap,A=new WeakMap,Z=new WeakMap,ae=new WeakMap;function Gt(s,e){return!x(s.getCurrentResult(),e)}const lt=we.createContext(!1),Jt=()=>we.useContext(lt);lt.Provider;function Xt(){let s=!1;return{clearReset:()=>{s=!1},reset:()=>{s=!0},isReset:()=>s}}const Zt=we.createContext(Xt()),er=()=>we.useContext(Zt);function tr(s,e){return typeof s=="function"?s(...e):!!s}const rr=({result:s,errorResetBoundary:e,throwOnError:t,query:n})=>s.isError&&!e.isReset()&&!s.isFetching&&n&&tr(t,[s.error,n]);function ht(s,e,t){if(process.env.NODE_ENV!=="production"&&(typeof s!="object"||Array.isArray(s)))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');const n=ke(t),i=Jt(),u=er(),a=n.defaultQueryOptions(s);a._optimisticResults=i?"isRestoring":"optimistic";const[l]=S.useState(()=>new e(n,a)),h=$e(()=>l.observe()),f=Q(l.getOptimisticResult(a)),c=f.current;fe(()=>h.current.pipe(r.filter(E=>!x(E,f.current))),[]),S.useEffect(()=>{l.setOptions(a)},[a,l]);const b=c.error;if(b&&rr({result:c,errorResetBoundary:u,throwOnError:a.throwOnError,query:n.getQueryCache().get(a.queryHash)}))throw b;return f.current}function sr(s,e){return ht(s,ct,e)}function nr(s,e){return ht({refetchOnMount:"idle",refetchOnReconnect:!1,refetchInterval:!1,refetchOnWindowFocus:!1,...s},ct,e)}function ir(s,e,t=[]){const n=e!=null&&!Array.isArray(e)?e:{},i=n.retry??!0,u=Q(n.onError??(h=>{console.error(h)})),a=S.useCallback(()=>R(s),t),l=S.useCallback(()=>a().pipe(r.catchError(h=>{throw u.current(h),h}),i?r.retry():r.identity),[a,i,u]);Re(l,t)}const ft=()=>s=>r.merge(r.of({isPaused:!0}),_.backToOnline$.pipe(r.mergeMap(()=>r.merge(r.of({isPaused:!1}),s)))),ar=s=>{let e=0;return s.pipe(r.catchError(t=>(e++,e<=1&&!_.isOnline()?r.merge(r.of({failureCount:e,failureReason:t}),r.timer(1).pipe(r.mergeMap(()=>r.throwError(()=>t).pipe(ft())))):r.throwError(()=>t))))},ur=({variables:s,state:e,options:t})=>{const n=e.isPaused,i=async()=>await Promise.reject(new Error("No mutationFn found")),u=t.mutationFn??i,a=R(()=>{var d;return((d=t.onMutate)==null?void 0:d.call(t,s))??void 0}),l=r.of(e.context),h=r.iif(()=>n,l,a).pipe(r.shareReplay(1)),f=(d,p,g)=>R(()=>{var $;return($=t.onError)==null?void 0:$.call(t,d,s,p)}).pipe(r.catchError(()=>r.of(d)),r.map(()=>({failureCount:g,error:d,failureReason:d,context:p,status:"error"}))),c=h.pipe(r.switchMap(d=>{const g=(typeof u=="function"?R(()=>u(s)):u).pipe(r.share()),C=g.pipe(r.isEmpty(),r.tap(O=>{if(O)throw new Error("Mutation completed without any emission (EMPTY)")}),r.ignoreElements()),$=r.merge(g,C).pipe(r.map(O=>({result:{data:O},error:null,context:d})),ar,Ae({...t,retry:(O,U)=>{const v=t.retry??0;return typeof v=="function"?v(O,U):typeof v=="boolean"?v:O<v},caughtError:(O,U)=>r.of({failureCount:O,failureReason:U}),catchError:(O,U)=>f(U,d,O).pipe(r.map(v=>({...v,result:void 0})))}),r.takeWhile(({result:O,error:U})=>(O==null?void 0:O.data)===void 0&&U===void 0,!0));return _.isOnline()||t.networkMode==="offlineFirst"||t.networkMode==="always"?$:$.pipe(ft())})),b=r.of({...e,variables:s,status:"pending",isPaused:!1,failureCount:0,failureReason:null,submittedAt:e.submittedAt??new Date().getTime()});return r.merge(b,h.pipe(r.map(d=>({context:d}))),c.pipe(r.switchMap(({result:d,error:p,...g})=>{if(!d&&!p)return r.of({...g});const C=p?r.of(null):R(()=>{var v;return(v=t.onSuccess)==null?void 0:v.call(t,d==null?void 0:d.data,s,g.context)}),O=R(()=>{var v;return(v=t.onSettled)==null?void 0:v.call(t,d==null?void 0:d.data,p,s,g.context)}).pipe(r.catchError(v=>d?r.of(d):r.of(v)));return r.concat(C,O).pipe(r.toArray(),r.map(()=>p?{error:p,data:void 0,variables:s,...g}:{status:"success",error:p,data:d==null?void 0:d.data,variables:s,failureCount:0,failureReason:null,...g}),r.catchError(v=>f(v,g.context,0).pipe(r.map(y=>({...y,data:void 0})))))}))).pipe(r.scan((d,p)=>({...d,...p,data:p.data??d.data,error:p.error??d.error}),X()))};var ue,W,ee;class or{constructor({options:e,mutationCache:t,state:n}){w(this,ue,new r.BehaviorSubject(0));w(this,W,new r.Subject);w(this,ee,new r.Subject);m(this,"state",X());m(this,"state$");m(this,"options");m(this,"observerCount$",o(this,ue).asObservable());m(this,"cancelled$",o(this,W).asObservable());this.options=e,this.state=n??this.state;const i=o(this,W).pipe(r.filter(()=>this.state.status==="pending"),r.map(()=>({status:"idle"}))),u=o(this,ee).pipe(r.switchMap(l=>ur({options:{...this.options,onMutate:h=>{const f=R(()=>{var d,p;return(p=(d=t.config).onMutate)==null?void 0:p.call(d,h,this)}),b=R(()=>{var d,p;return(p=(d=this.options).onMutate)==null?void 0:p.call(d,h)});return f.pipe(r.mergeMap(()=>b))},onError:(h,f,c)=>{const b=R(()=>{var d,p;return(p=(d=t.config).onError)==null?void 0:p.call(d,h,f,c,this)}),E=R(()=>{var d,p;return(p=(d=this.options).onError)==null?void 0:p.call(d,h,f,c)});return r.concat(b,E).pipe(r.toArray())},onSettled:(h,f,c,b)=>{const E=R(()=>{var p,g;return(g=(p=t.config).onSettled)==null?void 0:g.call(p,h,f,c,b,this)}),d=R(()=>{var p,g;return(g=(p=this.options).onSettled)==null?void 0:g.call(p,h,f,c,b)});return r.concat(E,d).pipe(r.toArray())},onSuccess:(h,f,c)=>{const b=R(()=>{var d,p;return(p=(d=t.config).onSuccess)==null?void 0:p.call(d,h,f,c,this)}),E=R(()=>{var d,p;return(p=(d=this.options).onSuccess)==null?void 0:p.call(d,h,f,c)});return r.concat(b,E).pipe(r.toArray())}},state:this.state,variables:l}).pipe(r.takeUntil(o(this,W))))),a=r.merge(i,u);this.state$=a.pipe(r.startWith(this.state),r.scan((l,h)=>({...l,...h}),this.state),nt,r.tap(l=>{this.state=l}),r.shareReplay(1),Pe(l=>{o(this,ue).next(l)}))}get meta(){return this.options.meta}setOptions(e){this.options={...this.options,...e}}execute(e){return o(this,ee).next(e),o(this,ee).complete(),this.state$.pipe(ne)}continue(){return this.execute(this.state.variables)}cancel(){o(this,W).next(),o(this,W).complete()}}ue=new WeakMap,W=new WeakMap,ee=new WeakMap;const Ge=({mutationKey:s,status:e,predicate:t,exact:n=!0}={})=>u=>n&&s!==void 0&&u.options.mutationKey!==void 0&&!ye(u.options.mutationKey,s,{exact:n})||!n&&s!==void 0&&u.options.mutationKey!==void 0&&!ye(u.options.mutationKey,s,{exact:n})||e&&u.state.status!==e?!1:t?t(u):!0;class dt{constructor(){m(this,"entriesSubject",new r.BehaviorSubject([]));m(this,"changeSubject",new r.Subject);m(this,"entries$",this.entriesSubject.pipe(r.share()));m(this,"added$",this.changeSubject.pipe(r.filter(({type:e})=>e==="added"),r.map(({entity:e})=>e),r.share()));m(this,"removed$",this.changeSubject.pipe(r.filter(({type:e})=>e==="removed"),r.map(({entity:e})=>e),r.share()));m(this,"stateChange$",r.merge(this.entriesSubject.pipe(r.first(),r.mergeMap(e=>r.from(e))),this.added$).pipe(r.mergeMap(e=>e.state$.pipe(r.map(()=>e),r.takeUntil(this.removed$.pipe(r.filter(t=>t===e))))),r.share()))}getValues(){return this.entriesSubject.getValue()}remove(e){this.entriesSubject.next(this.entriesSubject.getValue().filter(t=>e!==t)),this.changeSubject.next({type:"removed",entity:e})}add(e){this.entriesSubject.next([...this.entriesSubject.getValue(),e]),this.changeSubject.next({type:"added",entity:e})}find(e){return this.entriesSubject.getValue().find(e)}}var k;class pt{constructor(e={}){w(this,k,new dt);this.config=e}build(e,t,n){const i=new or({mutationCache:this,options:e.defaultMutationOptions(t),state:n});return i.state$.pipe(r.filter(({status:u})=>u==="success"||u==="error"),r.switchMap(()=>i.observerCount$.pipe(r.filter(u=>u<=1),r.take(1))),r.switchMap(()=>r.timer(i.options.gcTime??5*60*1e3)),r.take(1)).subscribe({complete:()=>{this.remove(i)}}),o(this,k).add(i),i}getAll(){return this.findAll()}remove(e){const t=o(this,k).getValues().find(n=>n===e);t==null||t.cancel(),o(this,k).remove(e)}find(e){const t={exact:!0,...e},n=Ge(t);return o(this,k).getValues().find(i=>n(i))}findAll(e={}){const t={exact:!0,...e},n=Ge(t);return o(this,k).getValues().filter(i=>n(i)).map(i=>i)}observe(){return o(this,k).stateChange$.pipe(r.startWith())}subscribe(e){const t=r.merge(o(this,k).added$.pipe(r.tap(n=>{e({type:"added",mutation:n})})),o(this,k).removed$.pipe(r.tap(n=>{e({type:"removed",mutation:n})})),o(this,k).stateChange$.pipe(r.tap(n=>{e({type:"updated",action:{...n.state,type:"success"},mutation:n})}))).subscribe();return()=>{t.unsubscribe()}}resumePausedMutations(){const e=this.findAll({predicate:n=>n.state.isPaused});if(!e.length)return r.EMPTY;const t=e.map(n=>n.continue());return r.combineLatest(t)}clear(){this.getAll().forEach(e=>{this.remove(e)})}}k=new WeakMap;function cr(s){const e=typeof s.initialData=="function"?s.initialData():s.initialData,t=typeof e<"u",n=t?typeof s.initialDataUpdatedAt=="function"?s.initialDataUpdatedAt():s.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:t?n??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:t?"success":"pending",fetchStatus:"idle"}}const lr=s=>r.defer(()=>ve.isFocused()?s:ve.focusRegained$.pipe(r.mergeMap(()=>s))),hr=s=>{let e=0;return t=>{const n=_.backToOnline$.pipe(r.mergeMap(()=>r.merge(r.of({fetchStatus:"fetching"}),t)));return r.defer(()=>(e++,!_.isOnline()&&s.networkMode==="offlineFirst"&&e>1?r.merge(r.of({fetchStatus:"paused"}),n):!_.isOnline()&&s.networkMode!=="always"&&s.networkMode!=="offlineFirst"?r.merge(r.of({fetchStatus:"paused"}),n):t))}},fr=s=>e=>{const t=new r.Subject,n=t.pipe(r.first(),r.delay(1),r.mergeMap(()=>s.pipe(r.filter(i=>i===0))));return e.pipe(r.tap(()=>{t.next()}),r.takeUntil(n))},dr=s=>{const e=async()=>await Promise.reject(new Error("No query found"));process.env.NODE_ENV!=="production"&&s.queryFn===Fe&&console.error(`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${s.queryHash}'`);let t=!1;const n=s.queryFn&&s.queryFn!==Fe?s.queryFn:e,i=new AbortController,u={meta:s.meta,queryKey:s.queryKey};(c=>{Object.defineProperty(c,"signal",{enumerable:!0,get:()=>(s.onSignalConsumed(),i.signal)})})(u);const h=(typeof n=="function"?R(()=>n(u)):n).pipe(fr(s.observers$),r.tap({complete:()=>{t=!0}}),r.map(c=>({data:c})),hr(s),Ae({...s,retryAfter:()=>r.of(!0).pipe(lr),catchError:(c,b)=>r.of({status:"error",fetchStatus:"idle",fetchFailureCount:c,fetchFailureReason:b,error:b}),caughtError:(c,b)=>r.of({fetchFailureCount:c,fetchFailureReason:b})}),r.mergeMap(c=>"data"in c?r.of({...c,status:"success",fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null,dataUpdatedAt:new Date().getTime()}).pipe(r.delay(1),r.map(b=>t?b:{...b,fetchStatus:"fetching"})):r.of(c)),r.endWith({fetchStatus:"idle"}),r.share()),f=r.of({status:"pending",fetchStatus:_.isOnline()?"fetching":"paused"});return{state$:r.merge(f,h).pipe(r.share()),abortController:i}};class pr{constructor(e){m(this,"revert");m(this,"silent");this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}}const br={backgroundColor:"transparent",color:"inherit"};function bt(s){const e={namespaces:[{name:"@reactjrx",style:{backgroundColor:"#d02f4e",color:"white"}}],namespace(t,n){const i=bt();return i.namespaces.push({name:t,style:n??br}),i},printNamespaces(){return{namespaces:e.namespaces.map(({name:t})=>`%c ${t} %c`).join(" "),styles:e.namespaces.reduce((t,{style:n})=>(t.push(`background-color: ${n.backgroundColor}; color: ${n.color};`),t.push("background-color: transparent; color: inherit;"),t),[])}},print(t,...n){return e},printWithoutNamespace(t,...n){return e},log(...t){return e.print("log",...t)},warn(...t){return e.print("warn",...t)},error(...t){return e.print("error",...t)},group(...t){return e.print("group",...t)},groupEnd(){return e}};return e}const gr=bt();var oe,Y;class mr{constructor(e){m(this,"queryKey");m(this,"queryHash");m(this,"gcTime");m(this,"options");w(this,oe);w(this,Y);m(this,"state");m(this,"executeSubject",new r.Subject);m(this,"cancelSubject",new r.Subject);m(this,"setDataSubject",new r.Subject);m(this,"invalidatedSubject",new r.Subject);m(this,"resetSubject",new r.Subject);m(this,"destroySubject",new r.Subject);m(this,"observersSubject",new r.BehaviorSubject([]));m(this,"abortSignalConsumed",!1);m(this,"observerCount$",this.observersSubject.asObservable().pipe(r.map(e=>e.length)));m(this,"observers$",this.observersSubject.asObservable());m(this,"state$");M(this,oe,e.defaultOptions),this.options=this.setOptions(e.options),this.queryKey=e.queryKey,this.queryHash=e.queryHash,M(this,Y,e.state??cr(this.options)),this.state=o(this,Y),this.gcTime=this.updateGcTime(this.options.gcTime),this.state$=r.merge(this.resetSubject.pipe(r.map(()=>({command:"reset",state:o(this,Y)}))),this.invalidatedSubject.pipe(r.filter(()=>!this.state.isInvalidated),r.map(()=>({command:"invalidate",state:{isInvalidated:!0}}))),this.cancelSubject.pipe(r.filter(()=>!(this.state.error&&this.state.status==="error")),r.map(t=>({command:"cancel",state:{status:t!=null&&t.revert?this.state.status:"error",fetchStatus:"idle",error:new pr(t)}}))),this.executeSubject.pipe(r.mergeMap(()=>{let t=!1;const n=this.executeSubject.pipe(r.filter(f=>(f==null?void 0:f.cancelRefetch)!==!1)),i=this.observers$.pipe(r.pairwise(),r.tap(([f,c])=>{c.length===0&&f.length>0?t=!0:t=!1}),r.ignoreElements()),{state$:u,abortController:a}=dr({...this.options,observers$:this.observerCount$,queryKey:this.queryKey,retry:(f,c)=>{const b=this.options.retry??!0;return typeof b=="function"?b(f,c):typeof b=="boolean"?b:f<b},retryAfterDelay:()=>!t,onSignalConsumed:()=>{this.abortSignalConsumed=!0}}),l=this.observerCount$.pipe(r.filter(f=>f===0&&this.abortSignalConsumed),r.tap(()=>{this.cancelSubject.next({revert:!0})})),h=r.merge(this.cancelSubject,n,this.resetSubject,l).pipe(r.tap(()=>{this.abortSignalConsumed&&a.abort()}));return r.merge(u,i).pipe(r.map(f=>({command:"execute",state:f})),r.takeUntil(h))})),this.setDataSubject.pipe(r.map(({data:t,options:n})=>({command:"setData",state:{status:"success",data:t,dataUpdatedAt:(n==null?void 0:n.updatedAt)!==void 0?n.updatedAt:new Date().getTime()}})))).pipe(_t({initialState:this.state,getOptions:()=>this.options,getState:()=>this.state}),r.startWith(o(this,Y)),r.distinctUntilChanged(x),r.tap(t=>{this.state=t}),r.catchError(t=>{throw gr.error(t),t}),r.takeUntil(this.destroySubject),r.shareReplay({bufferSize:1,refCount:!1}))}setOptions(e){return this.options={...o(this,oe),...e},this.updateGcTime(this.options.gcTime),this.options}get meta(){return this.options.meta}get success$(){return this.state$.pipe(r.map(({data:e,status:t})=>({data:e,status:t})),r.distinctUntilChanged(x),r.filter(({status:e})=>e==="success"))}get error$(){return this.state$.pipe(r.map(({error:e,status:t})=>({error:e,status:t})),r.distinctUntilChanged(x),r.filter(({status:e})=>e==="error"))}get settled$(){return this.state$.pipe(r.map(({status:e})=>({status:e})),r.distinctUntilChanged(x),r.filter(({status:e})=>e==="success"||e==="error"))}observe(e){return this.state$.pipe(r.tap({subscribe:()=>{this.observersSubject.next([e,...this.observersSubject.getValue()])},unsubscribe:()=>{this.observersSubject.next(this.observersSubject.getValue().filter(n=>n!==e))}}))}getObserversCount(){return this.observersSubject.getValue().length}updateGcTime(e){return this.gcTime=Math.max(this.gcTime||0,e??(J?1/0:5*60*1e3)),this.gcTime}isActive(){return this.observersSubject.getValue().some(e=>e.options.enabled!==!1)}isDisabled(){return this.getObserversCount()>0&&!this.isActive()}isStale(){return this.state.isInvalidated||!this.state.dataUpdatedAt||this.observersSubject.getValue().some(e=>e.getCurrentResult().isStale)}isStaleByTime(e=0){return this.state.isInvalidated||!this.state.dataUpdatedAt||!Lt(this.state.dataUpdatedAt,e)}async getFetchResultAsPromise(){return await new Promise((e,t)=>{this.state$.pipe(ot,r.last()).subscribe({error:t,next:n=>{n.error?t(n.error):e(n.data)}})})}async fetch(e,t){const{cancelRefetch:n}=t??{};return this.state.fetchStatus!=="idle"&&!(!!this.state.dataUpdatedAt&&n)?await this.getFetchResultAsPromise():(e&&this.setOptions(e),this.executeSubject.next(t),await this.getFetchResultAsPromise())}setData(e,t){const n=Se(this.state.data,e,this.options);return this.setDataSubject.next({data:n,options:t}),n}invalidate(){this.invalidatedSubject.next()}async cancel(e){this.cancelSubject.next(e)}destroy(){this.destroySubject.next(),this.destroySubject.complete(),this.executeSubject.complete()}reset(){this.resetSubject.next()}}oe=new WeakMap,Y=new WeakMap;var ce,N;class gt{constructor(e={}){w(this,ce,new r.Subject);w(this,N,new dt);this.config=e}mount(){}unmount(){}notify(e){o(this,ce).next(e)}observeIsFetching(e){return o(this,N).stateChange$.pipe(r.startWith(),r.map(()=>this.findAll({...e,fetchStatus:"fetching"}).length),r.distinctUntilChanged())}getAll(){return[...o(this,N).getValues()]}findAll(e={}){const t=this.getAll();return Object.keys(e).length>0?t.filter(n=>Ye(e,n)):t}build(e,t,n){const i=t.queryKey??[Qe()],u=t.queryHash??Ie(i,t);let a=this.get(u);return a||(a=new mr({cache:this,queryKey:i,queryHash:u,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(i)}),this.add(a)),a}add(e){if(!o(this,N).find(t=>t.queryHash===e.queryHash)){o(this,N).add(e);const t=e.observerCount$.pipe(r.filter(n=>n<1),r.take(1));e.success$.subscribe(()=>{var n,i;(i=(n=this.config).onSuccess)==null||i.call(n,e.state.data,e)}),e.error$.subscribe(()=>{var n,i;(i=(n=this.config).onError)==null||i.call(n,e.state.error,e)}),e.settled$.subscribe(()=>{var n,i;(i=(n=this.config).onSettled)==null||i.call(n,e.state.data,e.state.error,e)}),e.state$.pipe(Bt,r.switchMap(n=>n?t.pipe(r.switchMap(()=>e.gcTime===1/0?r.NEVER:(setTimeout(r.noop,e.gcTime),r.timer(e.gcTime)))):r.NEVER),r.take(1)).subscribe({complete:()=>{this.remove(e)}})}}get(e){return o(this,N).find(t=>t.queryHash===e)}find(e){const t={exact:!0,...e};return this.getAll().find(n=>Ye(t,n))}subscribe(e){const t=r.merge(o(this,ce).pipe(r.tap(e))).subscribe();return()=>{t.unsubscribe()}}remove(e){const t=o(this,N).find(n=>n===e);t&&(e.destroy(),t===e&&o(this,N).remove(e))}clear(){}}ce=new WeakMap,N=new WeakMap;var G,F,le,he,te;class yr{constructor({mutationCache:e,queryCache:t,defaultOptions:n}={}){w(this,G);w(this,F);w(this,le,new Map);w(this,he,new Map);w(this,te);M(this,G,e??new pt),M(this,F,t??new gt),M(this,te,n??{})}mount(){}unmount(){}getMutationCache(){return o(this,G)}getQueryCache(){return o(this,F)}defaultMutationOptions(e){return{...o(this,te).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e}}defaultQueryOptions(e){if(e._defaulted)return e;const t={...o(this,te).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===Fe&&(t.enabled=!1),t}async fetchQuery(e){const t=this.defaultQueryOptions(e);typeof t.retry>"u"&&(t.retry=!1);const n=o(this,F).build(this,t);return n.isStaleByTime(t.staleTime)?await n.fetch(t):await Promise.resolve(n.state.data)}async prefetchQuery(e){await this.fetchQuery(e).then(r.noop).catch(r.noop)}async resetQueries(e,t){const n=o(this,F),i={type:"active",...e};n.findAll(e).forEach(u=>{u.reset()}),await this.refetchQueries(i,t)}async refetchQueries(e={},t){const n={...t,cancelRefetch:(t==null?void 0:t.cancelRefetch)??!0},i=o(this,F).findAll(e).filter(u=>!u.isDisabled()).map(async u=>{let a=u.fetch(void 0,n);return n.throwOnError||(a=a.catch(r.noop)),u.state.fetchStatus==="paused"?void 0:await a});await Promise.all(i).then(r.noop)}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=o(this,F).get(t.queryHash))==null?void 0:n.state.data}setQueryData(e,t,n){const i=this.defaultQueryOptions({queryKey:e}),u=o(this,F).get(i.queryHash),a=u==null?void 0:u.state.data,l=Wt(t,a);if(l!==void 0)return o(this,F).build(this,i).setData(l,{...n,manual:!0})}getMutationDefaults(e){const t=[...o(this,le).values()];let n={};return t.forEach(i=>{ye(e,i.mutationKey)&&(n={...n,...i.defaultOptions})}),n}getQueryState(e){var t;return(t=o(this,F).find({queryKey:e}))==null?void 0:t.state}setMutationDefaults(e,t){o(this,le).set(re(e),{mutationKey:e,defaultOptions:t})}setQueryDefaults(e,t){o(this,he).set(re(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...o(this,he).values()];let n={};return t.forEach(i=>{Ee(e,i.queryKey)&&(n={...n,...i.defaultOptions})}),n}removeQueries(e){const t=o(this,F);t.findAll(e).forEach(n=>{t.remove(n)})}async cancelQueries(e={},t={}){const n={revert:!0,...t},i=o(this,F).findAll(e).map(async u=>{await u.cancel(n)});await Promise.all(i).then(r.noop).catch(r.noop)}async invalidateQueries(e={},t={}){if(o(this,F).findAll(e).forEach(i=>{i.invalidate()}),e.refetchType==="none"){await Promise.resolve();return}const n={...e,type:e.refetchType??e.type??"active"};await this.refetchQueries(n,t)}async resumePausedMutations(){return await r.lastValueFrom(o(this,G).resumePausedMutations())}isFetching(e){return o(this,F).findAll({...e,fetchStatus:"fetching"}).length}clear(){o(this,F).clear(),o(this,G).clear()}}G=new WeakMap,F=new WeakMap,le=new WeakMap,he=new WeakMap,te=new WeakMap;exports.MutationCache=pt;exports.QueryCache=gt;exports.QueryClient=yr;exports.QueryClientProvider=Vt;exports.SIGNAL_RESET=Je;exports.arrayEqual=At;exports.createLocalStorageAdapter=et;exports.createLocalforageAdapter=Et;exports.exponentialBackoffDelay=st;exports.getDelay=rt;exports.isDefined=me;exports.isPromiseLike=je;exports.isServer=J;exports.retryBackoff=Ae;exports.signal=Xe;exports.useBehaviorSubject=Ue;exports.useEffectOnce=tt;exports.useForeverQuery=nr;exports.useLiveRef=Q;exports.useMount=Ut;exports.useMutation=Tt;exports.useObservableState=wt;exports.useObserve=fe;exports.useObserveCallback=Ot;exports.usePersistSignals=Rt;exports.useQuery=sr;exports.useQueryClient=ke;exports.useSignal=$t;exports.useSignalValue=Ze;exports.useSubject=xe;exports.useSubscribe=Re;exports.useSubscribeEffect=ir;exports.useUnmountObservable=xt;
package/dist/index.d.ts CHANGED
@@ -12,13 +12,7 @@ export * from './lib/state/persistance/adapters/createLocalforageAdapter';
12
12
  export * from './lib/state/persistance/adapters/createLocalStorageAdapter';
13
13
  export * from './lib/state/persistance/usePersistSignals';
14
14
  export { type SignalPersistenceConfig } from './lib/state/persistance/types';
15
- export * from './lib/utils/useUnmountObservable';
16
- export * from './lib/utils/operators/retryBackoff';
17
- export * from './lib/utils/useLiveRef';
18
- export * from './lib/utils/isDefined';
19
- export * from './lib/utils/arrayEqual';
20
- export * from './lib/utils/useMount';
21
- export * from './lib/utils/useEffectOnce';
15
+ export * from './lib/utils';
22
16
  export * from './lib/queries/react/mutations/useMutation';
23
17
  export * from './lib/queries/react/queries/useQuery';
24
18
  export * from './lib/queries/react/useQueryClient';