reactjrx 1.87.1 → 1.88.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.
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +103 -101
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var bt=Object.defineProperty;var gt=(s,e,t)=>e in s?bt(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var y=(s,e,t)=>(gt(s,typeof e!="symbol"?e+"":e,t),t),De=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)};var c=(s,e,t)=>(De(s,e,"read from private field"),t?t.call(s):e.get(s)),$=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t)},M=(s,e,t,n)=>(De(s,e,"write to private field"),n?n.call(s,t):e.set(s,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("react"),r=require("rxjs"),K=require("rxjs/operators"),Ke=require("react/jsx-runtime");function mt(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=mt(v),A=s=>{const e=v.useRef(s);return v.useMemo(()=>{e.current=s},[s]),e};function yt(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 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=v.useRef("getValue"in s&&typeof s.getValue=="function"?s.getValue():n.defaultValue),a=A(s),l=A(n),h=v.useCallback(b=>{const d=a.current,g=(typeof d=="function"?d:()=>d)().pipe(r.distinctUntilChanged(yt),r.tap(m=>{u.current=m}),r.catchError(m=>(console.error(m),r.EMPTY))).subscribe(b);return()=>{l.current.unsubscribeOnUnmount!==!1&&g.unsubscribe()}},[...i]),f=v.useCallback(()=>u.current,[]);return v.useSyncExternalStore(h,f,f)}function Ne(s){return s instanceof Promise||s&&typeof s.then=="function"&&typeof s.catch=="function"}function F(s){if(r.isObservable(s))return s;if(Ne(s))return r.from(s);if(typeof s!="function")return r.of(s);const e=s;return r.defer(()=>{const t=e();return Ne(t)?r.from(t):r.isObservable(t)?t:r.of(t)})}function Fe(s,e=[]){const t=A(s);v.useEffect(()=>{const n=F(t.current).subscribe();return()=>{n.unsubscribe()}},[...e,t])}const $e=s=>{const e=v.useRef();return e.current||(e.current=s()),v.useEffect(()=>{process.env.NODE_ENV},[]),e},Re=({onBeforeComplete:s,completeOnUnmount:e=!0}={})=>{const t=$e(()=>new r.Subject),n=v.useRef(!1),i=A(s),u=A(e);return v.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},St=()=>{const s=Re(),e=A(s.current.asObservable()),t=v.useCallback(n=>{s.current.next(n)},[]);return[e.current,t]},Ue=s=>{const e=$e(()=>new r.BehaviorSubject(s)),t=v.useRef(!1),n=v.useRef(s);return v.useEffect(()=>(t.current&&(e.current=new r.BehaviorSubject(n.current),t.current=!1),()=>{t.current||(e.current.complete(),t.current=!0)}),[e]),e},vt=s=>{const e=Ue(s),t=A(e.current.asObservable()),n=v.useCallback(i=>{e.current.next(i)},[e.current]);return[t.current,n,e.current.getValue()]},Je=Symbol("SIGNAL_RESET");function Ot(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 wt(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=>({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()=>{}}),Ee=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}=Ee(n)??{};await s.setItem(e,u)},getItem:async t=>{const n=await s.getItem(e),i=Ee(n)??{};if(t in i)return i[t]},setItem:async(t,n)=>{const i=await s.getItem(e),u=Ee(i)??{};await s.setItem(e,{...u,[t]:n})}}),Xe=({key:s}={})=>s?Ct({adapter:Xe(),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",Et=s=>{if(typeof s=="object"&&s!==null&&se in s&&s[se]===se)return s};function me(s){return s!=null}const qe=s=>{const e=Ue(s);return v.useEffect(()=>{e.current.next(s)},[s,e]),e},He=({adapter:s,signal:e,version:t})=>{const i={value:e.getValue(),[se]:se,migrationVersion:t};return r.from(s.setItem(e.config.key,i)).pipe(r.catchError(u=>(console.error(u),r.of(null))))},Mt=({adapter:s,version:e,signal:t})=>r.from(s.getItem(t.config.key)).pipe(r.switchMap(n=>{const i=Et(n);return!i||i.migrationVersion!==void 0&&e>i.migrationVersion||t.setValue(i.value),r.of(n)})),jt=({entries:s=[],onReady:e,adapter:t})=>{const n=A(s),i=A(e),u=qe(t),a=fe(()=>{const h=n.current;return u.current.pipe(r.switchMap(f=>{if(!f)return r.of(!1);const o=h.length===0?r.of(!0):r.zip(...h.map(({signal:b,version:d})=>Mt({adapter:f,signal:b,version:d}).pipe(r.mergeMap(()=>He({adapter:f,signal:b,version:d}))))).pipe(r.map(()=>!0));return r.merge(r.of(!1),o).pipe(r.tap(()=>{i.current!=null&&i.current()}),r.catchError(b=>(console.error("Unable to hydrate",b),r.EMPTY)))}))},{defaultValue:!1},[u,n]),l=qe(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(({signal:f,version:o})=>f.subject.pipe(r.throttleTime(500,r.asyncScheduler,{trailing:!0}),r.switchMap(()=>r.from(He({adapter:h,signal:f,version:o})))))))),[l,u]),{isHydrated:a}},Ft=()=>{const s=Re({onBeforeComplete:()=>{s.current.next()}});return s};function Ze(s,e){return Math.min(s,e)}function et(s,e){return Math.pow(2,s)*e}function xe(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=et}=h;return d=>r.defer(()=>{let p=0;const g=(m,O)=>m<u?a(m,O):!1;return d.pipe(K.catchError(m=>{var w;if(p++,!g(p-1,m))throw m;const O=(w=s.caughtError)==null?void 0:w.call(s,p,m);if(!O)throw m;return O.pipe(K.mergeMap(k=>r.merge(r.of(k),r.throwError(()=>m))))}),K.retryWhen(m=>m.pipe(K.concatMap(O=>{const w=p-1;return i().pipe(K.first(),K.mergeMap(()=>g(w,O)?r.timer(Ze(b(w,l),f)).pipe(K.mergeMap(k=>n&&!n(w,O)?r.throwError(()=>O):r.of(k))):r.throwError(()=>O)))}))),K.catchError(m=>{if(s.catchError)return s.catchError(p,m);throw m}),K.tap(()=>{o&&(p=0)}))})}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),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 Rt{constructor({__queryFinalizeHook:e}={}){$(this,H,new r.Subject);y(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))),d=u.state$.pipe(ne,r.skip(1)),p=r.merge(n,h,f,u.cancelled$);return r.merge(d,b,o).pipe(r.map(g=>({state:g,mutation:u})),e??r.identity,r.takeUntil(p))}),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 Ce(s,e){return s===e?!0:typeof s!=typeof e?!1:s&&e&&typeof s=="object"&&typeof e=="object"?!Object.keys(e).some(t=>!Ce(s[t],e[t])):!1}const ye=(s,e,{exact:t=!1}={})=>t?re(s)===re(e):Ce(s,e);function R(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 tt=s=>s.pipe(r.distinctUntilChanged(({data:e,...t},{data:n,...i})=>R(t,i)&&R(e,n)));var z,I;class Ut{constructor(e,t={},n){$(this,z,void 0);$(this,I,new r.BehaviorSubject(void 0));y(this,"observed$");y(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()],M(this,z,n??new Rt(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&&R(h,b)&&R(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(tt),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 rt=v.createContext(void 0),xt=({client:s})=>(v.useEffect(()=>(s.mount(),()=>{s.unmount()}),[s]),null),At=v.memo(({children:s,client:e})=>{const t=v.useMemo(()=>e,[e]);return Ke.jsxs(rt.Provider,{value:t,children:[Ke.jsx(xt,{client:e}),s]})}),Pe=s=>{const e=v.useContext(rt);if(s)return s;if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e};function Qt(){}function Pt(s,e){const t=Pe(e),n=A(s),i=$e(()=>[Ae()]),u=re(s.mutationKey??i.current),[a]=v.useState(()=>new Ut(t,s));v.useEffect(()=>{a.setOptions(s)},[a,s]);const l=v.useMemo(()=>a.observe(),[u,a]),h=fe(l.result$)??l.lastValue,f=v.useCallback((o,b)=>{a.mutate(o,b).catch(Qt)},[a]);return v.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 Vt{constructor(){y(this,"isOnlineSubject",new r.BehaviorSubject(!0));y(this,"online$",this.isOnlineSubject.pipe(r.distinctUntilChanged()));y(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 Vt;function ke(s,e){return s.isStaleByTime(e.staleTime)}function It(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 It(s,e)||s.state.dataUpdatedAt>0&&st(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 Tt(s,e){return st(s,e,e.refetchOnWindowFocus)}function st(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 Dt(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 nt(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]=nt(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(!Ce(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 Kt(s,e){return Math.max(s+(e??0)-Date.now(),0)}function Nt(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?nt(s,e):e}const je=Symbol(),qt=({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 E=i.status==="pending"?"pending":a.status??i.status;return{...i,...a,status:E}}const l=a.data,h=l!==void 0&&l!==i.data,f="data"in a,o=a.status==="success",b=i.data!==void 0,d=i.error!==void 0||i.error!==null,p=a.status??i.status,g=h?Se(e().data,l,s()):f?a.data:i.data,m=i.status==="error"||i.status==="success",O=a.status==="error"&&(i.status==="error"&&i.fetchStatus==="fetching"||i.status!=="error")?i.errorUpdateCount+1:i.errorUpdateCount,w=h?i.dataUpdateCount+1:a.dataUpdateCount??i.dataUpdateCount,k=a.status==="pending"&&m&&(b||d),U=p==="pending"?null:a.error??i.error;return{...i,...a,status:p,error:U,errorUpdateCount:O,...o&&{isInvalidated:!1},data:g,dataUpdateCount:w,...k&&{status:i.status}}},t)),Ht=s=>s.pipe(r.map(({status:e,fetchStatus:t})=>t==="idle"&&(e==="success"||e==="error"))),it=s=>s.pipe(r.takeWhile(e=>e.fetchStatus!=="idle",!0));var Oe,L;class Lt{constructor(){$(this,Oe,r.merge(X?r.EMPTY:r.fromEvent(document,"visibilitychange"),X?r.EMPTY:r.fromEvent(window,"visibilitychange")).pipe(r.map(()=>document.visibilityState)));$(this,L,new r.BehaviorSubject(X?!0:document.visibilityState==="visible"));y(this,"focused$",c(this,L));y(this,"focusRegained$",this.focused$.pipe(r.skip(1),r.filter(e=>e)));c(this,Oe).pipe(r.tap(e=>{c(this,L).next(e==="visible")})).subscribe()}isFocused(){return c(this,L).getValue()}setFocused(e){c(this,L).getValue()!==(e??!0)&&c(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 Lt,Wt=s=>s.pipe(r.filter(e=>e.status==="success"),r.map(e=>({data:e.data,status:e.status,dataUpdatedAt:e.dataUpdatedAt})),r.distinctUntilChanged(R));var q,C,ie,B,x,Z,ae;class at{constructor(e,t){$(this,q,void 0);$(this,C,void 0);$(this,ie,new r.Subject);y(this,"queryUpdateSubject",new r.Subject);$(this,B,void 0);$(this,x,void 0);$(this,Z,void 0);$(this,ae,0);y(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",d=c(this,C),p=this.options,m=t!==d?t.state:c(this,B);let{errorUpdatedAt:O,fetchStatus:w,error:k}=o;if(n){const Q=!!c(this,ae),Te=!Q&&We(t,e),pt=Q&&_e(t,d,e,p);(Te||pt)&&(w=Dt(t.options.networkMode)?"fetching":"paused")}const U=b&&w==="fetching";let E,S=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)E=f;else try{T=e.select,E=e.select(o.data),E=Se(i==null?void 0:i.data,E,e),D=E,S=null}catch(Q){E=f,S=Q}else E=o.data,S=null;let V=w!=="idle"&&!o.dataUpdatedAt?"pending":o.status;S&&(k=S,E=f,O=(i==null?void 0:i.errorUpdatedAt)??O,V="error");const de=V==="error";let pe=!1;if(typeof e.placeholderData<"u"&&typeof E>"u"&&V==="pending"){let Q;if(i!=null&&i.isPlaceholderData&&e.placeholderData===(u==null?void 0:u.placeholderData))Q=i.data;else if(Q=typeof e.placeholderData=="function"?e.placeholderData((ge=c(this,Z))==null?void 0:ge.state.data,c(this,Z)):e.placeholderData,e.select&&typeof Q<"u")try{Q=e.select(Q)}catch{}typeof Q<"u"&&(V="success",E=Se(i==null?void 0:i.data,Q,e),pe=!0)}const be=w==="fetching";return{result:{status:V,fetchStatus:w,isPending:b,isSuccess:V==="success",isError:de,isInitialLoading:U,isLoading:U,data:E,dataUpdatedAt:o.dataUpdatedAt,error:k,errorUpdatedAt:O,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:w==="paused",isPlaceholderData:pe,isRefetchError:de&&o.dataUpdatedAt!==0,isStale:ke(t,e),refetch:this.refetch},selectError:S,select:T,selectResult:D}});this.options=t,M(this,q,e),this.bindMethods(),M(this,C,this.setOptions(t));const n=c(this,C);M(this,B,n.state);const{result:i,select:u}=this.getObserverResultFromQuery({query:n,options:this.options,prevResult:{options:this.options,state:n.state}});M(this,x,{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),R(this.options,t)||c(this,q).getQueryCache().notify({type:"observerOptionsUpdated",query:c(this,C),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,C)&&(M(this,B,n.state),M(this,C,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,x),query:c(this,C)}).result}getCurrentQuery(){return c(this,C)}getOptimisticResult(e){const t=this.buildQuery(e),n=this.getObserverResultFromQuery({query:t,options:e,optimisticResult:!0,prevResult:c(this,x)});return _t(this,n.result)&&this.updateResult({query:t,...n}),n.result}updateResult({query:e,result:t,selectError:n,select:i,selectResult:u}){c(this,x).state=e.state,c(this,x).result=t,c(this,x).selectResult=u,n!==void 0&&(c(this,x).selectError=n),i!==void 0&&(c(this,x).select=i),c(this,x).options=this.options,e.state.data!==void 0&&M(this,Z,e),c(this,q).getQueryCache().notify({query:c(this,C),type:"observerResultsUpdated"})}async refetch({...e}={}){return await this.fetch({...e})}async fetch(e){const t=this.buildQuery(this.options);t!==c(this,C)&&(M(this,C,t),M(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,C).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,x)});return i}subscribe(e){const t=this.observe().subscribe(e);return()=>{t.unsubscribe()}}observe(){const e=c(this,C),t=this.queryUpdateSubject.pipe(r.map(({query:a})=>a),r.startWith(c(this,C)),r.distinctUntilChanged()),n=this.queryUpdateSubject.pipe(r.startWith({query:c(this,C),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(S=>S.query===a),r.map(S=>S.options),r.distinctUntilChanged(),r.shareReplay(1)),f=c(this,ie).pipe(r.filter(S=>S.query===a)),o=a.state$.pipe(Wt,r.switchMap(S=>this.options.staleTime===1/0?r.NEVER:(this.options.staleTime??0)<=0?r.of(S).pipe(r.delay(1)):r.timer(this.options.staleTime??1)),r.takeWhile(()=>this.options.enabled??!0)),b=(S,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 R(Ie,ge)}:R)(S,T)},d=f.pipe(r.switchMap(()=>a.state$),it),p=h.pipe(r.map(({refetchInterval:S,refetchIntervalInBackground:T})=>({refetchInterval:(typeof S=="function"?S(c(this,C)):S)??!1,refetchIntervalInBackground:T})),r.distinctUntilChanged(R),r.switchMap(({refetchInterval:S,refetchIntervalInBackground:T})=>S?r.interval(S).pipe(r.tap(()=>{(T||ve.isFocused())&&this.fetch({cancelRefetch:!1}).catch(r.noop)})):r.NEVER),r.ignoreElements()),g=h.pipe(r.map(({enabled:S})=>S??!0),r.distinctUntilChanged()),m=g.pipe(r.filter(S=>!S),r.map(()=>a.state)),O=g.pipe(r.filter(S=>S),r.switchMap(()=>ve.focusRegained$),r.withLatestFrom(h),r.tap(([,S])=>{Tt(a,S)&&this.fetch({cancelRefetch:!1}).catch(r.noop)}),r.ignoreElements()),w=m.pipe(r.map(()=>a.state)),k=S=>S.pipe(r.withLatestFrom(h),r.map(([,T])=>{const D=this.getObserverResultFromQuery({query:a,options:T,prevResult:c(this,x)});return this.updateResult({query:a,...D}),D.result})),E=r.merge(w,d,a.state$,o).pipe(k,r.distinctUntilChanged(R),r.distinctUntilChanged(b));return r.merge(p,O,E)})).pipe(Qe(a=>M(this,ae,a)),r.tap({subscribe:()=>{We(e,this.options)&&this.fetch().catch(r.noop)}})))}destroy(){}}q=new WeakMap,C=new WeakMap,ie=new WeakMap,B=new WeakMap,x=new WeakMap,Z=new WeakMap,ae=new WeakMap;function _t(s,e){return!R(s.getCurrentResult(),e)}const ut=we.createContext(!1),zt=()=>we.useContext(ut);ut.Provider;function Bt(){let s=!1;return{clearReset:()=>{s=!1},reset:()=>{s=!0},isReset:()=>s}}const Yt=we.createContext(Bt()),Gt=()=>we.useContext(Yt);function Jt(s,e){return typeof s=="function"?s(...e):!!s}const Xt=({result:s,errorResetBoundary:e,throwOnError:t,query:n})=>s.isError&&!e.isReset()&&!s.isFetching&&n&&Jt(t,[s.error,n]);function ct(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=zt(),u=Gt(),a=n.defaultQueryOptions(s);a._optimisticResults=i?"isRestoring":"optimistic";const[l]=v.useState(()=>new e(n,a)),h=$e(()=>l.observe()),f=A(l.getOptimisticResult(a)),o=f.current;fe(()=>h.current.pipe(r.filter(d=>!R(d,f.current))),[]),v.useEffect(()=>{l.setOptions(a)},[a,l]);const b=o.error;if(b&&Xt({result:o,errorResetBoundary:u,throwOnError:a.throwOnError,query:n.getQueryCache().get(a.queryHash)}))throw b;return f.current}function Zt(s,e){return ct(s,at,e)}function er(s,e){return ct({refetchOnMount:"idle",refetchOnReconnect:!1,refetchInterval:!1,refetchOnWindowFocus:!1,...s},at,e)}function tr(s,e,t=[]){const n=e!=null&&!Array.isArray(e)?e:{},i=n.retry??!0,u=A(n.onError??(h=>{console.error(h)})),a=v.useCallback(()=>F(s),t),l=v.useCallback(()=>a().pipe(r.catchError(h=>{throw u.current(h),h}),i?r.retry():r.identity),[a,i,u]);Fe(l,t)}const ot=()=>s=>r.merge(r.of({isPaused:!0}),_.backToOnline$.pipe(r.mergeMap(()=>r.merge(r.of({isPaused:!1}),s)))),rr=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(ot())))):r.throwError(()=>t))))},sr=({variables:s,state:e,options:t})=>{const n=e.isPaused,i=async()=>await Promise.reject(new Error("No mutationFn found")),u=t.mutationFn??i,l=r.iif(()=>n,r.of(e.context),F(()=>{var d;return((d=t.onMutate)==null?void 0:d.call(t,s))??void 0})).pipe(r.shareReplay(1)),h=(d,p,g)=>F(()=>{var O;return(O=t.onError)==null?void 0:O.call(t,d,s,p)}).pipe(r.catchError(()=>r.of(d)),r.map(()=>({failureCount:g,error:d,failureReason:d,context:p,status:"error"}))),f=l.pipe(r.switchMap(d=>{const g=(typeof u=="function"?F(()=>u(s)):u).pipe(r.map(m=>({result:{data:m},error:null,context:d})),rr,xe({...t,retry:(m,O)=>{const w=t.retry??0;return typeof w=="function"?w(m,O):typeof w=="boolean"?w:m<w},caughtError:(m,O)=>r.of({failureCount:m,failureReason:O}),catchError:(m,O)=>h(O,d,m).pipe(r.map(w=>({...w,result:void 0})))}),r.takeWhile(({result:m,error:O})=>(m==null?void 0:m.data)===void 0&&O===void 0,!0));return _.isOnline()||t.networkMode==="offlineFirst"||t.networkMode==="always"?g:g.pipe(ot())})),o=r.of({...e,variables:s,status:"pending",isPaused:!1,failureCount:0,failureReason:null,submittedAt:e.submittedAt??new Date().getTime()});return r.merge(o,l.pipe(r.map(d=>({context:d}))),f.pipe(r.switchMap(({result:d,error:p,...g})=>{if(!d&&!p)return r.of({...g});const m=p?r.of(null):F(()=>{var U;return(U=t.onSuccess)==null?void 0:U.call(t,d==null?void 0:d.data,s,g.context)}),w=F(()=>{var U;return(U=t.onSettled)==null?void 0:U.call(t,d==null?void 0:d.data,p,s,g.context)}).pipe(r.catchError(U=>d?r.of(d):r.of(U)));return r.concat(m,w).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(U=>h(U,g.context,0).pipe(r.map(E=>({...E,data:void 0})))))}))).pipe(r.scan((d,p)=>({...d,...p,data:p.data??d.data,error:p.error??d.error}),J()))};var ue,W,ee;class nr{constructor({options:e,mutationCache:t,state:n}){$(this,ue,new r.BehaviorSubject(0));$(this,W,new r.Subject);$(this,ee,new r.Subject);y(this,"state",J());y(this,"state$");y(this,"options");y(this,"observerCount$",c(this,ue).asObservable());y(this,"cancelled$",c(this,W).asObservable());this.options=e,this.state=n??this.state;const i=c(this,W).pipe(r.filter(()=>this.state.status==="pending"),r.map(()=>({status:"idle"}))),u=c(this,ee).pipe(r.switchMap(l=>sr({options:{...this.options,onMutate:h=>{const f=F(()=>{var p,g;return(g=(p=t.config).onMutate)==null?void 0:g.call(p,h,this)}),b=F(()=>{var p,g;return(g=(p=this.options).onMutate)==null?void 0:g.call(p,h)});return f.pipe(r.mergeMap(()=>b))},onError:(h,f,o)=>{const b=F(()=>{var p,g;return(g=(p=t.config).onError)==null?void 0:g.call(p,h,f,o,this)}),d=F(()=>{var p,g;return(g=(p=this.options).onError)==null?void 0:g.call(p,h,f,o)});return r.concat(b,d).pipe(r.toArray())},onSettled:(h,f,o,b)=>{const d=F(()=>{var g,m;return(m=(g=t.config).onSettled)==null?void 0:m.call(g,h,f,o,b,this)}),p=F(()=>{var g,m;return(m=(g=this.options).onSettled)==null?void 0:m.call(g,h,f,o,b)});return r.concat(d,p).pipe(r.toArray())},onSuccess:(h,f,o)=>{const b=F(()=>{var p,g;return(g=(p=t.config).onSuccess)==null?void 0:g.call(p,h,f,o,this)}),d=F(()=>{var p,g;return(g=(p=this.options).onSuccess)==null?void 0:g.call(p,h,f,o)});return r.concat(b,d).pipe(r.toArray())}},state:this.state,variables:l}).pipe(r.takeUntil(c(this,W))))),a=r.merge(i,u);this.state$=a.pipe(r.startWith(this.state),r.scan((l,h)=>({...l,...h}),this.state),tt,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,W).next(),c(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 lt{constructor(){y(this,"entriesSubject",new r.BehaviorSubject([]));y(this,"changeSubject",new r.Subject);y(this,"entries$",this.entriesSubject.pipe(r.share()));y(this,"added$",this.changeSubject.pipe(r.filter(({type:e})=>e==="added"),r.map(({entity:e})=>e),r.share()));y(this,"removed$",this.changeSubject.pipe(r.filter(({type:e})=>e==="removed"),r.map(({entity:e})=>e),r.share()));y(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 P;class ht{constructor(e={}){$(this,P,new lt);this.config=e}build(e,t,n){const i=new nr({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,P).add(i),i}getAll(){return this.findAll()}remove(e){const t=c(this,P).getValues().find(n=>n===e);t==null||t.cancel(),c(this,P).remove(e)}find(e){const t={exact:!0,...e},n=Ge(t);return c(this,P).getValues().find(i=>n(i))}findAll(e={}){const t={exact:!0,...e},n=Ge(t);return c(this,P).getValues().filter(i=>n(i)).map(i=>i)}observe(){return c(this,P).stateChange$.pipe(r.startWith())}subscribe(e){const t=r.merge(c(this,P).added$.pipe(r.tap(n=>{e({type:"added",mutation:n})})),c(this,P).removed$.pipe(r.tap(n=>{e({type:"removed",mutation:n})})),c(this,P).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)})}}P=new WeakMap;function ir(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 ar=s=>r.defer(()=>ve.isFocused()?s:ve.focusRegained$.pipe(r.mergeMap(()=>s))),ur=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))}},cr=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))},or=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"?F(()=>n(u)):n).pipe(cr(s.observers$),r.tap({complete:()=>{t=!0}}),r.map(o=>({data:o})),ur(s),xe({...s,retryAfter:()=>r.of(!0).pipe(ar),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 lr{constructor(e){y(this,"revert");y(this,"silent");this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}}const hr={backgroundColor:"transparent",color:"inherit"};function ft(s){const e={namespaces:[{name:"@reactjrx",style:{backgroundColor:"#d02f4e",color:"white"}}],namespace(t,n){const i=ft();return i.namespaces.push({name:t,style:n??hr}),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 fr=ft();var ce,Y;class dr{constructor(e){y(this,"queryKey");y(this,"queryHash");y(this,"gcTime");y(this,"options");$(this,ce,void 0);$(this,Y,void 0);y(this,"state");y(this,"executeSubject",new r.Subject);y(this,"cancelSubject",new r.Subject);y(this,"setDataSubject",new r.Subject);y(this,"invalidatedSubject",new r.Subject);y(this,"resetSubject",new r.Subject);y(this,"destroySubject",new r.Subject);y(this,"observersSubject",new r.BehaviorSubject([]));y(this,"abortSignalConsumed",!1);y(this,"observerCount$",this.observersSubject.asObservable().pipe(r.map(e=>e.length)));y(this,"observers$",this.observersSubject.asObservable());y(this,"state$");M(this,ce,e.defaultOptions),this.options=this.setOptions(e.options),this.queryKey=e.queryKey,this.queryHash=e.queryHash,M(this,Y,e.state??ir(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 lr(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}=or({...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(qt({initialState:this.state,getOptions:()=>this.options,getState:()=>this.state}),r.startWith(c(this,Y)),r.distinctUntilChanged(R),r.tap(t=>{this.state=t}),r.catchError(t=>{throw fr.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(R),r.filter(({status:e})=>e==="success"))}get error$(){return this.state$.pipe(r.map(({error:e,status:t})=>({error:e,status:t})),r.distinctUntilChanged(R),r.filter(({status:e})=>e==="error"))}get settled$(){return this.state$.pipe(r.map(({status:e})=>({status:e})),r.distinctUntilChanged(R),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||!Kt(this.state.dataUpdatedAt,e)}async getFetchResultAsPromise(){return await new Promise((e,t)=>{this.state$.pipe(it,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 dt{constructor(e={}){$(this,oe,new r.Subject);$(this,N,new lt);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 dr({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(Ht,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,j,le,he,te;class pr{constructor({mutationCache:e,queryCache:t,defaultOptions:n}={}){$(this,G,void 0);$(this,j,void 0);$(this,le,new Map);$(this,he,new Map);$(this,te,void 0);M(this,G,e??new ht),M(this,j,t??new dt),M(this,te,n??{})}mount(){}unmount(){}getMutationCache(){return c(this,G)}getQueryCache(){return c(this,j)}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,j).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,j),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,j).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,j).get(t.queryHash))==null?void 0:n.state.data}setQueryData(e,t,n){const i=this.defaultQueryOptions({queryKey:e}),u=c(this,j).get(i.queryHash),a=u==null?void 0:u.state.data,l=Nt(t,a);if(l!==void 0)return c(this,j).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,j).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=>{Ce(e,i.queryKey)&&(n={...n,...i.defaultOptions})}),n}removeQueries(e){const t=c(this,j);t.findAll(e).forEach(n=>{t.remove(n)})}async cancelQueries(e={},t={}){const n={revert:!0,...t},i=c(this,j).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,j).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,j).findAll({...e,fetchStatus:"fetching"}).length}clear(){c(this,j).clear(),c(this,G).clear()}}G=new WeakMap,j=new WeakMap,le=new WeakMap,he=new WeakMap,te=new WeakMap;exports.MutationCache=ht;exports.QueryCache=dt;exports.QueryClient=pr;exports.QueryClientProvider=At;exports.SIGNAL_RESET=Je;exports.createLocalStorageAdapter=Xe;exports.createLocalforageAdapter=$t;exports.exponentialBackoffDelay=et;exports.getDelay=Ze;exports.isDefined=me;exports.retryBackoff=xe;exports.signal=Ot;exports.useBehaviorSubject=Ue;exports.useForeverQuery=er;exports.useLiveRef=A;exports.useMutation=Pt;exports.useObservableState=vt;exports.useObserve=fe;exports.useObserveCallback=St;exports.usePersistSignals=jt;exports.useQuery=Zt;exports.useQueryClient=Pe;exports.useSignalValue=wt;exports.useSubject=Re;exports.useSubscribe=Fe;exports.useSubscribeEffect=tr;exports.useUnmountObservable=Ft;
|
|
1
|
+
"use strict";var bt=Object.defineProperty;var gt=(s,e,t)=>e in s?bt(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var y=(s,e,t)=>(gt(s,typeof e!="symbol"?e+"":e,t),t),De=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)};var c=(s,e,t)=>(De(s,e,"read from private field"),t?t.call(s):e.get(s)),$=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t)},M=(s,e,t,n)=>(De(s,e,"write to private field"),n?n.call(s,t):e.set(s,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("react"),r=require("rxjs"),K=require("rxjs/operators"),Ke=require("react/jsx-runtime");function mt(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=mt(v),A=s=>{const e=v.useRef(s);return v.useMemo(()=>{e.current=s},[s]),e};function yt(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 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=v.useRef("getValue"in s&&typeof s.getValue=="function"?s.getValue():n.defaultValue),a=A(s),l=A(n),h=v.useCallback(b=>{const d=a.current,g=(typeof d=="function"?d:()=>d)().pipe(r.distinctUntilChanged(yt),r.tap(m=>{u.current=m}),r.catchError(m=>(console.error(m),r.EMPTY))).subscribe(b);return()=>{l.current.unsubscribeOnUnmount!==!1&&g.unsubscribe()}},[...i]),f=v.useCallback(()=>u.current,[]);return v.useSyncExternalStore(h,f,f)}function Ne(s){return s instanceof Promise||s&&typeof s.then=="function"&&typeof s.catch=="function"}function F(s){if(r.isObservable(s))return s;if(Ne(s))return r.from(s);if(typeof s!="function")return r.of(s);const e=s;return r.defer(()=>{const t=e();return Ne(t)?r.from(t):r.isObservable(t)?t:r.of(t)})}function Fe(s,e=[]){const t=A(s);v.useEffect(()=>{const n=F(t.current).subscribe();return()=>{n.unsubscribe()}},[...e,t])}const $e=s=>{const e=v.useRef();return e.current||(e.current=s()),v.useEffect(()=>{process.env.NODE_ENV},[]),e},Re=({onBeforeComplete:s,completeOnUnmount:e=!0}={})=>{const t=$e(()=>new r.Subject),n=v.useRef(!1),i=A(s),u=A(e);return v.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},St=()=>{const s=Re(),e=A(s.current.asObservable()),t=v.useCallback(n=>{s.current.next(n)},[]);return[e.current,t]},Ue=s=>{const e=$e(()=>new r.BehaviorSubject(s)),t=v.useRef(!1),n=v.useRef(s);return v.useEffect(()=>(t.current&&(e.current=new r.BehaviorSubject(n.current),t.current=!1),()=>{t.current||(e.current.complete(),t.current=!0)}),[e]),e},vt=s=>{const e=Ue(s),t=A(e.current.asObservable()),n=v.useCallback(i=>{e.current.next(i)},[e.current]);return[t.current,n,e.current.getValue()]},Je=Symbol("SIGNAL_RESET");function Ot(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 wt(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=>({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()=>{}}),Ee=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}=Ee(n)??{};await s.setItem(e,u)},getItem:async t=>{const n=await s.getItem(e),i=Ee(n)??{};if(t in i)return i[t]},setItem:async(t,n)=>{const i=await s.getItem(e),u=Ee(i)??{};await s.setItem(e,{...u,[t]:n})}}),Xe=({key:s}={})=>s?Ct({adapter:Xe(),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",Et=s=>{if(typeof s=="object"&&s!==null&&se in s&&s[se]===se)return s};function me(s){return s!=null}const qe=s=>{const e=Ue(s);return v.useEffect(()=>{e.current.next(s)},[s,e]),e},He=({adapter:s,signal:e,version:t})=>{const i={value:e.getValue(),[se]:se,migrationVersion:t};return r.from(s.setItem(e.config.key,i)).pipe(r.catchError(u=>(console.error(u),r.of(null))))},Mt=({adapter:s,version:e,signal:t})=>r.from(s.getItem(t.config.key)).pipe(r.switchMap(n=>{const i=Et(n);return!i||i.migrationVersion!==void 0&&e>i.migrationVersion||t.setValue(i.value),r.of(n)})),jt=({entries:s=[],onReady:e,adapter:t})=>{const n=A(s),i=A(e),u=qe(t),a=fe(()=>{const h=n.current;return u.current.pipe(r.switchMap(f=>{if(!f)return r.of(!1);const o=h.length===0?r.of(!0):r.zip(...h.map(({signal:b,version:d})=>Mt({adapter:f,signal:b,version:d}).pipe(r.mergeMap(()=>He({adapter:f,signal:b,version:d}))))).pipe(r.map(()=>!0));return r.merge(r.of(!1),o).pipe(r.tap(()=>{i.current!=null&&i.current()}),r.catchError(b=>(console.error("Unable to hydrate",b),r.EMPTY)))}))},{defaultValue:!1},[u,n]),l=qe(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(({signal:f,version:o})=>f.subject.pipe(r.throttleTime(500,r.asyncScheduler,{trailing:!0}),r.switchMap(()=>r.from(He({adapter:h,signal:f,version:o})))))))),[l,u]),{isHydrated:a}},Ft=()=>{const s=Re({onBeforeComplete:()=>{s.current.next()}});return s};function Ze(s,e){return Math.min(s,e)}function et(s,e){return Math.pow(2,s)*e}function xe(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=et}=h;return d=>r.defer(()=>{let p=0;const g=(m,O)=>m<u?a(m,O):!1;return d.pipe(K.catchError(m=>{var w;if(p++,!g(p-1,m))throw m;const O=(w=s.caughtError)==null?void 0:w.call(s,p,m);if(!O)throw m;return O.pipe(K.mergeMap(k=>r.merge(r.of(k),r.throwError(()=>m))))}),K.retryWhen(m=>m.pipe(K.concatMap(O=>{const w=p-1;return i().pipe(K.first(),K.mergeMap(()=>g(w,O)?r.timer(Ze(b(w,l),f)).pipe(K.mergeMap(k=>n&&!n(w,O)?r.throwError(()=>O):r.of(k))):r.throwError(()=>O)))}))),K.catchError(m=>{if(s.catchError)return s.catchError(p,m);throw m}),K.tap(()=>{o&&(p=0)}))})}const Rt=(s,e)=>s.length===e.length&&s.every((t,n)=>t===e[n]);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),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 Ut{constructor({__queryFinalizeHook:e}={}){$(this,H,new r.Subject);y(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))),d=u.state$.pipe(ne,r.skip(1)),p=r.merge(n,h,f,u.cancelled$);return r.merge(d,b,o).pipe(r.map(g=>({state:g,mutation:u})),e??r.identity,r.takeUntil(p))}),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 Ce(s,e){return s===e?!0:typeof s!=typeof e?!1:s&&e&&typeof s=="object"&&typeof e=="object"?!Object.keys(e).some(t=>!Ce(s[t],e[t])):!1}const ye=(s,e,{exact:t=!1}={})=>t?re(s)===re(e):Ce(s,e);function R(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 tt=s=>s.pipe(r.distinctUntilChanged(({data:e,...t},{data:n,...i})=>R(t,i)&&R(e,n)));var z,I;class xt{constructor(e,t={},n){$(this,z,void 0);$(this,I,new r.BehaviorSubject(void 0));y(this,"observed$");y(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()],M(this,z,n??new Ut(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&&R(h,b)&&R(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(tt),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 rt=v.createContext(void 0),At=({client:s})=>(v.useEffect(()=>(s.mount(),()=>{s.unmount()}),[s]),null),Qt=v.memo(({children:s,client:e})=>{const t=v.useMemo(()=>e,[e]);return Ke.jsxs(rt.Provider,{value:t,children:[Ke.jsx(At,{client:e}),s]})}),Pe=s=>{const e=v.useContext(rt);if(s)return s;if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e};function Pt(){}function kt(s,e){const t=Pe(e),n=A(s),i=$e(()=>[Ae()]),u=re(s.mutationKey??i.current),[a]=v.useState(()=>new xt(t,s));v.useEffect(()=>{a.setOptions(s)},[a,s]);const l=v.useMemo(()=>a.observe(),[u,a]),h=fe(l.result$)??l.lastValue,f=v.useCallback((o,b)=>{a.mutate(o,b).catch(Pt)},[a]);return v.useEffect(()=>()=>{n.current.cancelOnUnMount&&a.reset()},[a,n]),{...h,mutate:f,mutateAsync:h.mutate}}function Vt(s){return e=>e.pipe(K.tap(t=>{s.next(t)}))}const X=typeof window>"u"||"Deno"in window;class It{constructor(){y(this,"isOnlineSubject",new r.BehaviorSubject(!0));y(this,"online$",this.isOnlineSubject.pipe(r.distinctUntilChanged()));y(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(Vt(this.isOnlineSubject)).subscribe()}isOnline(){return this.isOnlineSubject.getValue()}setOnline(e){this.isOnlineSubject.getValue()!==e&&this.isOnlineSubject.next(e)}}const _=new It;function ke(s,e){return s.isStaleByTime(e.staleTime)}function Tt(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 Tt(s,e)||s.state.dataUpdatedAt>0&&st(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 Dt(s,e){return st(s,e,e.refetchOnWindowFocus)}function st(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 Kt(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 nt(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]=nt(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(!Ce(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 Nt(s,e){return Math.max(s+(e??0)-Date.now(),0)}function qt(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?nt(s,e):e}const je=Symbol(),Ht=({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 E=i.status==="pending"?"pending":a.status??i.status;return{...i,...a,status:E}}const l=a.data,h=l!==void 0&&l!==i.data,f="data"in a,o=a.status==="success",b=i.data!==void 0,d=i.error!==void 0||i.error!==null,p=a.status??i.status,g=h?Se(e().data,l,s()):f?a.data:i.data,m=i.status==="error"||i.status==="success",O=a.status==="error"&&(i.status==="error"&&i.fetchStatus==="fetching"||i.status!=="error")?i.errorUpdateCount+1:i.errorUpdateCount,w=h?i.dataUpdateCount+1:a.dataUpdateCount??i.dataUpdateCount,k=a.status==="pending"&&m&&(b||d),U=p==="pending"?null:a.error??i.error;return{...i,...a,status:p,error:U,errorUpdateCount:O,...o&&{isInvalidated:!1},data:g,dataUpdateCount:w,...k&&{status:i.status}}},t)),Lt=s=>s.pipe(r.map(({status:e,fetchStatus:t})=>t==="idle"&&(e==="success"||e==="error"))),it=s=>s.pipe(r.takeWhile(e=>e.fetchStatus!=="idle",!0));var Oe,L;class Wt{constructor(){$(this,Oe,r.merge(X?r.EMPTY:r.fromEvent(document,"visibilitychange"),X?r.EMPTY:r.fromEvent(window,"visibilitychange")).pipe(r.map(()=>document.visibilityState)));$(this,L,new r.BehaviorSubject(X?!0:document.visibilityState==="visible"));y(this,"focused$",c(this,L));y(this,"focusRegained$",this.focused$.pipe(r.skip(1),r.filter(e=>e)));c(this,Oe).pipe(r.tap(e=>{c(this,L).next(e==="visible")})).subscribe()}isFocused(){return c(this,L).getValue()}setFocused(e){c(this,L).getValue()!==(e??!0)&&c(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 Wt,_t=s=>s.pipe(r.filter(e=>e.status==="success"),r.map(e=>({data:e.data,status:e.status,dataUpdatedAt:e.dataUpdatedAt})),r.distinctUntilChanged(R));var q,C,ie,B,x,Z,ae;class at{constructor(e,t){$(this,q,void 0);$(this,C,void 0);$(this,ie,new r.Subject);y(this,"queryUpdateSubject",new r.Subject);$(this,B,void 0);$(this,x,void 0);$(this,Z,void 0);$(this,ae,0);y(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",d=c(this,C),p=this.options,m=t!==d?t.state:c(this,B);let{errorUpdatedAt:O,fetchStatus:w,error:k}=o;if(n){const Q=!!c(this,ae),Te=!Q&&We(t,e),pt=Q&&_e(t,d,e,p);(Te||pt)&&(w=Kt(t.options.networkMode)?"fetching":"paused")}const U=b&&w==="fetching";let E,S=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)E=f;else try{T=e.select,E=e.select(o.data),E=Se(i==null?void 0:i.data,E,e),D=E,S=null}catch(Q){E=f,S=Q}else E=o.data,S=null;let V=w!=="idle"&&!o.dataUpdatedAt?"pending":o.status;S&&(k=S,E=f,O=(i==null?void 0:i.errorUpdatedAt)??O,V="error");const de=V==="error";let pe=!1;if(typeof e.placeholderData<"u"&&typeof E>"u"&&V==="pending"){let Q;if(i!=null&&i.isPlaceholderData&&e.placeholderData===(u==null?void 0:u.placeholderData))Q=i.data;else if(Q=typeof e.placeholderData=="function"?e.placeholderData((ge=c(this,Z))==null?void 0:ge.state.data,c(this,Z)):e.placeholderData,e.select&&typeof Q<"u")try{Q=e.select(Q)}catch{}typeof Q<"u"&&(V="success",E=Se(i==null?void 0:i.data,Q,e),pe=!0)}const be=w==="fetching";return{result:{status:V,fetchStatus:w,isPending:b,isSuccess:V==="success",isError:de,isInitialLoading:U,isLoading:U,data:E,dataUpdatedAt:o.dataUpdatedAt,error:k,errorUpdatedAt:O,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:w==="paused",isPlaceholderData:pe,isRefetchError:de&&o.dataUpdatedAt!==0,isStale:ke(t,e),refetch:this.refetch},selectError:S,select:T,selectResult:D}});this.options=t,M(this,q,e),this.bindMethods(),M(this,C,this.setOptions(t));const n=c(this,C);M(this,B,n.state);const{result:i,select:u}=this.getObserverResultFromQuery({query:n,options:this.options,prevResult:{options:this.options,state:n.state}});M(this,x,{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),R(this.options,t)||c(this,q).getQueryCache().notify({type:"observerOptionsUpdated",query:c(this,C),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,C)&&(M(this,B,n.state),M(this,C,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,x),query:c(this,C)}).result}getCurrentQuery(){return c(this,C)}getOptimisticResult(e){const t=this.buildQuery(e),n=this.getObserverResultFromQuery({query:t,options:e,optimisticResult:!0,prevResult:c(this,x)});return zt(this,n.result)&&this.updateResult({query:t,...n}),n.result}updateResult({query:e,result:t,selectError:n,select:i,selectResult:u}){c(this,x).state=e.state,c(this,x).result=t,c(this,x).selectResult=u,n!==void 0&&(c(this,x).selectError=n),i!==void 0&&(c(this,x).select=i),c(this,x).options=this.options,e.state.data!==void 0&&M(this,Z,e),c(this,q).getQueryCache().notify({query:c(this,C),type:"observerResultsUpdated"})}async refetch({...e}={}){return await this.fetch({...e})}async fetch(e){const t=this.buildQuery(this.options);t!==c(this,C)&&(M(this,C,t),M(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,C).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,x)});return i}subscribe(e){const t=this.observe().subscribe(e);return()=>{t.unsubscribe()}}observe(){const e=c(this,C),t=this.queryUpdateSubject.pipe(r.map(({query:a})=>a),r.startWith(c(this,C)),r.distinctUntilChanged()),n=this.queryUpdateSubject.pipe(r.startWith({query:c(this,C),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(S=>S.query===a),r.map(S=>S.options),r.distinctUntilChanged(),r.shareReplay(1)),f=c(this,ie).pipe(r.filter(S=>S.query===a)),o=a.state$.pipe(_t,r.switchMap(S=>this.options.staleTime===1/0?r.NEVER:(this.options.staleTime??0)<=0?r.of(S).pipe(r.delay(1)):r.timer(this.options.staleTime??1)),r.takeWhile(()=>this.options.enabled??!0)),b=(S,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 R(Ie,ge)}:R)(S,T)},d=f.pipe(r.switchMap(()=>a.state$),it),p=h.pipe(r.map(({refetchInterval:S,refetchIntervalInBackground:T})=>({refetchInterval:(typeof S=="function"?S(c(this,C)):S)??!1,refetchIntervalInBackground:T})),r.distinctUntilChanged(R),r.switchMap(({refetchInterval:S,refetchIntervalInBackground:T})=>S?r.interval(S).pipe(r.tap(()=>{(T||ve.isFocused())&&this.fetch({cancelRefetch:!1}).catch(r.noop)})):r.NEVER),r.ignoreElements()),g=h.pipe(r.map(({enabled:S})=>S??!0),r.distinctUntilChanged()),m=g.pipe(r.filter(S=>!S),r.map(()=>a.state)),O=g.pipe(r.filter(S=>S),r.switchMap(()=>ve.focusRegained$),r.withLatestFrom(h),r.tap(([,S])=>{Dt(a,S)&&this.fetch({cancelRefetch:!1}).catch(r.noop)}),r.ignoreElements()),w=m.pipe(r.map(()=>a.state)),k=S=>S.pipe(r.withLatestFrom(h),r.map(([,T])=>{const D=this.getObserverResultFromQuery({query:a,options:T,prevResult:c(this,x)});return this.updateResult({query:a,...D}),D.result})),E=r.merge(w,d,a.state$,o).pipe(k,r.distinctUntilChanged(R),r.distinctUntilChanged(b));return r.merge(p,O,E)})).pipe(Qe(a=>M(this,ae,a)),r.tap({subscribe:()=>{We(e,this.options)&&this.fetch().catch(r.noop)}})))}destroy(){}}q=new WeakMap,C=new WeakMap,ie=new WeakMap,B=new WeakMap,x=new WeakMap,Z=new WeakMap,ae=new WeakMap;function zt(s,e){return!R(s.getCurrentResult(),e)}const ut=we.createContext(!1),Bt=()=>we.useContext(ut);ut.Provider;function Yt(){let s=!1;return{clearReset:()=>{s=!1},reset:()=>{s=!0},isReset:()=>s}}const Gt=we.createContext(Yt()),Jt=()=>we.useContext(Gt);function Xt(s,e){return typeof s=="function"?s(...e):!!s}const Zt=({result:s,errorResetBoundary:e,throwOnError:t,query:n})=>s.isError&&!e.isReset()&&!s.isFetching&&n&&Xt(t,[s.error,n]);function ct(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=Bt(),u=Jt(),a=n.defaultQueryOptions(s);a._optimisticResults=i?"isRestoring":"optimistic";const[l]=v.useState(()=>new e(n,a)),h=$e(()=>l.observe()),f=A(l.getOptimisticResult(a)),o=f.current;fe(()=>h.current.pipe(r.filter(d=>!R(d,f.current))),[]),v.useEffect(()=>{l.setOptions(a)},[a,l]);const b=o.error;if(b&&Zt({result:o,errorResetBoundary:u,throwOnError:a.throwOnError,query:n.getQueryCache().get(a.queryHash)}))throw b;return f.current}function er(s,e){return ct(s,at,e)}function tr(s,e){return ct({refetchOnMount:"idle",refetchOnReconnect:!1,refetchInterval:!1,refetchOnWindowFocus:!1,...s},at,e)}function rr(s,e,t=[]){const n=e!=null&&!Array.isArray(e)?e:{},i=n.retry??!0,u=A(n.onError??(h=>{console.error(h)})),a=v.useCallback(()=>F(s),t),l=v.useCallback(()=>a().pipe(r.catchError(h=>{throw u.current(h),h}),i?r.retry():r.identity),[a,i,u]);Fe(l,t)}const ot=()=>s=>r.merge(r.of({isPaused:!0}),_.backToOnline$.pipe(r.mergeMap(()=>r.merge(r.of({isPaused:!1}),s)))),sr=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(ot())))):r.throwError(()=>t))))},nr=({variables:s,state:e,options:t})=>{const n=e.isPaused,i=async()=>await Promise.reject(new Error("No mutationFn found")),u=t.mutationFn??i,l=r.iif(()=>n,r.of(e.context),F(()=>{var d;return((d=t.onMutate)==null?void 0:d.call(t,s))??void 0})).pipe(r.shareReplay(1)),h=(d,p,g)=>F(()=>{var O;return(O=t.onError)==null?void 0:O.call(t,d,s,p)}).pipe(r.catchError(()=>r.of(d)),r.map(()=>({failureCount:g,error:d,failureReason:d,context:p,status:"error"}))),f=l.pipe(r.switchMap(d=>{const g=(typeof u=="function"?F(()=>u(s)):u).pipe(r.map(m=>({result:{data:m},error:null,context:d})),sr,xe({...t,retry:(m,O)=>{const w=t.retry??0;return typeof w=="function"?w(m,O):typeof w=="boolean"?w:m<w},caughtError:(m,O)=>r.of({failureCount:m,failureReason:O}),catchError:(m,O)=>h(O,d,m).pipe(r.map(w=>({...w,result:void 0})))}),r.takeWhile(({result:m,error:O})=>(m==null?void 0:m.data)===void 0&&O===void 0,!0));return _.isOnline()||t.networkMode==="offlineFirst"||t.networkMode==="always"?g:g.pipe(ot())})),o=r.of({...e,variables:s,status:"pending",isPaused:!1,failureCount:0,failureReason:null,submittedAt:e.submittedAt??new Date().getTime()});return r.merge(o,l.pipe(r.map(d=>({context:d}))),f.pipe(r.switchMap(({result:d,error:p,...g})=>{if(!d&&!p)return r.of({...g});const m=p?r.of(null):F(()=>{var U;return(U=t.onSuccess)==null?void 0:U.call(t,d==null?void 0:d.data,s,g.context)}),w=F(()=>{var U;return(U=t.onSettled)==null?void 0:U.call(t,d==null?void 0:d.data,p,s,g.context)}).pipe(r.catchError(U=>d?r.of(d):r.of(U)));return r.concat(m,w).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(U=>h(U,g.context,0).pipe(r.map(E=>({...E,data:void 0})))))}))).pipe(r.scan((d,p)=>({...d,...p,data:p.data??d.data,error:p.error??d.error}),J()))};var ue,W,ee;class ir{constructor({options:e,mutationCache:t,state:n}){$(this,ue,new r.BehaviorSubject(0));$(this,W,new r.Subject);$(this,ee,new r.Subject);y(this,"state",J());y(this,"state$");y(this,"options");y(this,"observerCount$",c(this,ue).asObservable());y(this,"cancelled$",c(this,W).asObservable());this.options=e,this.state=n??this.state;const i=c(this,W).pipe(r.filter(()=>this.state.status==="pending"),r.map(()=>({status:"idle"}))),u=c(this,ee).pipe(r.switchMap(l=>nr({options:{...this.options,onMutate:h=>{const f=F(()=>{var p,g;return(g=(p=t.config).onMutate)==null?void 0:g.call(p,h,this)}),b=F(()=>{var p,g;return(g=(p=this.options).onMutate)==null?void 0:g.call(p,h)});return f.pipe(r.mergeMap(()=>b))},onError:(h,f,o)=>{const b=F(()=>{var p,g;return(g=(p=t.config).onError)==null?void 0:g.call(p,h,f,o,this)}),d=F(()=>{var p,g;return(g=(p=this.options).onError)==null?void 0:g.call(p,h,f,o)});return r.concat(b,d).pipe(r.toArray())},onSettled:(h,f,o,b)=>{const d=F(()=>{var g,m;return(m=(g=t.config).onSettled)==null?void 0:m.call(g,h,f,o,b,this)}),p=F(()=>{var g,m;return(m=(g=this.options).onSettled)==null?void 0:m.call(g,h,f,o,b)});return r.concat(d,p).pipe(r.toArray())},onSuccess:(h,f,o)=>{const b=F(()=>{var p,g;return(g=(p=t.config).onSuccess)==null?void 0:g.call(p,h,f,o,this)}),d=F(()=>{var p,g;return(g=(p=this.options).onSuccess)==null?void 0:g.call(p,h,f,o)});return r.concat(b,d).pipe(r.toArray())}},state:this.state,variables:l}).pipe(r.takeUntil(c(this,W))))),a=r.merge(i,u);this.state$=a.pipe(r.startWith(this.state),r.scan((l,h)=>({...l,...h}),this.state),tt,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,W).next(),c(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 lt{constructor(){y(this,"entriesSubject",new r.BehaviorSubject([]));y(this,"changeSubject",new r.Subject);y(this,"entries$",this.entriesSubject.pipe(r.share()));y(this,"added$",this.changeSubject.pipe(r.filter(({type:e})=>e==="added"),r.map(({entity:e})=>e),r.share()));y(this,"removed$",this.changeSubject.pipe(r.filter(({type:e})=>e==="removed"),r.map(({entity:e})=>e),r.share()));y(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 P;class ht{constructor(e={}){$(this,P,new lt);this.config=e}build(e,t,n){const i=new ir({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,P).add(i),i}getAll(){return this.findAll()}remove(e){const t=c(this,P).getValues().find(n=>n===e);t==null||t.cancel(),c(this,P).remove(e)}find(e){const t={exact:!0,...e},n=Ge(t);return c(this,P).getValues().find(i=>n(i))}findAll(e={}){const t={exact:!0,...e},n=Ge(t);return c(this,P).getValues().filter(i=>n(i)).map(i=>i)}observe(){return c(this,P).stateChange$.pipe(r.startWith())}subscribe(e){const t=r.merge(c(this,P).added$.pipe(r.tap(n=>{e({type:"added",mutation:n})})),c(this,P).removed$.pipe(r.tap(n=>{e({type:"removed",mutation:n})})),c(this,P).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)})}}P=new WeakMap;function ar(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 ur=s=>r.defer(()=>ve.isFocused()?s:ve.focusRegained$.pipe(r.mergeMap(()=>s))),cr=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))}},or=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))},lr=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"?F(()=>n(u)):n).pipe(or(s.observers$),r.tap({complete:()=>{t=!0}}),r.map(o=>({data:o})),cr(s),xe({...s,retryAfter:()=>r.of(!0).pipe(ur),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 hr{constructor(e){y(this,"revert");y(this,"silent");this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}}const fr={backgroundColor:"transparent",color:"inherit"};function ft(s){const e={namespaces:[{name:"@reactjrx",style:{backgroundColor:"#d02f4e",color:"white"}}],namespace(t,n){const i=ft();return i.namespaces.push({name:t,style:n??fr}),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 dr=ft();var ce,Y;class pr{constructor(e){y(this,"queryKey");y(this,"queryHash");y(this,"gcTime");y(this,"options");$(this,ce,void 0);$(this,Y,void 0);y(this,"state");y(this,"executeSubject",new r.Subject);y(this,"cancelSubject",new r.Subject);y(this,"setDataSubject",new r.Subject);y(this,"invalidatedSubject",new r.Subject);y(this,"resetSubject",new r.Subject);y(this,"destroySubject",new r.Subject);y(this,"observersSubject",new r.BehaviorSubject([]));y(this,"abortSignalConsumed",!1);y(this,"observerCount$",this.observersSubject.asObservable().pipe(r.map(e=>e.length)));y(this,"observers$",this.observersSubject.asObservable());y(this,"state$");M(this,ce,e.defaultOptions),this.options=this.setOptions(e.options),this.queryKey=e.queryKey,this.queryHash=e.queryHash,M(this,Y,e.state??ar(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 hr(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}=lr({...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(Ht({initialState:this.state,getOptions:()=>this.options,getState:()=>this.state}),r.startWith(c(this,Y)),r.distinctUntilChanged(R),r.tap(t=>{this.state=t}),r.catchError(t=>{throw dr.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(R),r.filter(({status:e})=>e==="success"))}get error$(){return this.state$.pipe(r.map(({error:e,status:t})=>({error:e,status:t})),r.distinctUntilChanged(R),r.filter(({status:e})=>e==="error"))}get settled$(){return this.state$.pipe(r.map(({status:e})=>({status:e})),r.distinctUntilChanged(R),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||!Nt(this.state.dataUpdatedAt,e)}async getFetchResultAsPromise(){return await new Promise((e,t)=>{this.state$.pipe(it,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 dt{constructor(e={}){$(this,oe,new r.Subject);$(this,N,new lt);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 pr({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(Lt,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,j,le,he,te;class br{constructor({mutationCache:e,queryCache:t,defaultOptions:n}={}){$(this,G,void 0);$(this,j,void 0);$(this,le,new Map);$(this,he,new Map);$(this,te,void 0);M(this,G,e??new ht),M(this,j,t??new dt),M(this,te,n??{})}mount(){}unmount(){}getMutationCache(){return c(this,G)}getQueryCache(){return c(this,j)}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,j).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,j),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,j).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,j).get(t.queryHash))==null?void 0:n.state.data}setQueryData(e,t,n){const i=this.defaultQueryOptions({queryKey:e}),u=c(this,j).get(i.queryHash),a=u==null?void 0:u.state.data,l=qt(t,a);if(l!==void 0)return c(this,j).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,j).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=>{Ce(e,i.queryKey)&&(n={...n,...i.defaultOptions})}),n}removeQueries(e){const t=c(this,j);t.findAll(e).forEach(n=>{t.remove(n)})}async cancelQueries(e={},t={}){const n={revert:!0,...t},i=c(this,j).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,j).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,j).findAll({...e,fetchStatus:"fetching"}).length}clear(){c(this,j).clear(),c(this,G).clear()}}G=new WeakMap,j=new WeakMap,le=new WeakMap,he=new WeakMap,te=new WeakMap;exports.MutationCache=ht;exports.QueryCache=dt;exports.QueryClient=br;exports.QueryClientProvider=Qt;exports.SIGNAL_RESET=Je;exports.arrayEqual=Rt;exports.createLocalStorageAdapter=Xe;exports.createLocalforageAdapter=$t;exports.exponentialBackoffDelay=et;exports.getDelay=Ze;exports.isDefined=me;exports.retryBackoff=xe;exports.signal=Ot;exports.useBehaviorSubject=Ue;exports.useForeverQuery=tr;exports.useLiveRef=A;exports.useMutation=kt;exports.useObservableState=vt;exports.useObserve=fe;exports.useObserveCallback=St;exports.usePersistSignals=jt;exports.useQuery=er;exports.useQueryClient=Pe;exports.useSignalValue=wt;exports.useSubject=Re;exports.useSubscribe=Fe;exports.useSubscribeEffect=rr;exports.useUnmountObservable=Ft;
|
package/dist/index.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export * from './lib/utils/useUnmountObservable';
|
|
|
14
14
|
export * from './lib/utils/operators/retryBackoff';
|
|
15
15
|
export * from './lib/utils/useLiveRef';
|
|
16
16
|
export * from './lib/utils/isDefined';
|
|
17
|
+
export * from './lib/utils/arrayEqual';
|
|
17
18
|
export * from './lib/queries/react/mutations/useMutation';
|
|
18
19
|
export * from './lib/queries/react/queries/useQuery';
|
|
19
20
|
export * from './lib/queries/react/useQueryClient';
|
package/dist/index.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
var Yt = Object.defineProperty;
|
|
2
2
|
var Bt = (s, e, t) => e in s ? Yt(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
|
|
3
|
-
var m = (s, e, t) => (Bt(s, typeof e != "symbol" ? e + "" : e, t), t),
|
|
3
|
+
var m = (s, e, t) => (Bt(s, typeof e != "symbol" ? e + "" : e, t), t), yt = (s, e, t) => {
|
|
4
4
|
if (!e.has(s))
|
|
5
5
|
throw TypeError("Cannot " + t);
|
|
6
6
|
};
|
|
7
|
-
var a = (s, e, t) => (
|
|
7
|
+
var a = (s, e, t) => (yt(s, e, "read from private field"), t ? t.call(s) : e.get(s)), C = (s, e, t) => {
|
|
8
8
|
if (e.has(s))
|
|
9
9
|
throw TypeError("Cannot add the same private member more than once");
|
|
10
10
|
e instanceof WeakSet ? e.add(s) : e.set(s, t);
|
|
11
|
-
}, M = (s, e, t, r) => (
|
|
11
|
+
}, M = (s, e, t, r) => (yt(s, e, "write to private field"), r ? r.call(s, t) : e.set(s, t), t);
|
|
12
12
|
import * as Ge from "react";
|
|
13
13
|
import { useRef as me, useMemo as ut, useCallback as le, useSyncExternalStore as Xt, useEffect as X, createContext as Zt, memo as es, useContext as ts, useState as jt } from "react";
|
|
14
|
-
import { distinctUntilChanged as Q, tap as E, catchError as B, EMPTY as Z, isObservable as
|
|
15
|
-
import { catchError as mt, mergeMap as tt, retryWhen as fs, concatMap as ps, first as
|
|
16
|
-
import { jsxs as
|
|
14
|
+
import { distinctUntilChanged as Q, tap as E, catchError as B, EMPTY as Z, isObservable as bt, from as Se, of as v, defer as Ae, Subject as I, BehaviorSubject as J, skip as at, first as Je, map as g, switchMap as x, zip as ss, mergeMap as k, merge as F, filter as O, throttleTime as rs, asyncScheduler as ns, throwError as Oe, timer as Qe, Observable as is, takeWhile as Ye, concatMap as us, last as Ke, takeUntil as ne, identity as Mt, shareReplay as Ue, ignoreElements as he, scan as Be, fromEvent as Ne, noop as N, startWith as ce, pairwise as At, NEVER as qe, delay as ot, interval as as, withLatestFrom as gt, retry as os, iif as cs, concat as ke, toArray as Te, share as de, take as He, combineLatest as ls, endWith as hs, lastValueFrom as ds } from "rxjs";
|
|
15
|
+
import { catchError as mt, mergeMap as tt, retryWhen as fs, concatMap as ps, first as ys, tap as Qt } from "rxjs/operators";
|
|
16
|
+
import { jsxs as bs, jsx as gs } from "react/jsx-runtime";
|
|
17
17
|
const q = (s) => {
|
|
18
18
|
const e = me(s);
|
|
19
19
|
return ut(() => {
|
|
@@ -31,7 +31,7 @@ function Xe(s, e, t) {
|
|
|
31
31
|
"getValue" in s && typeof s.getValue == "function" ? s.getValue() : r.defaultValue
|
|
32
32
|
), i = q(s), c = q(r), l = le(
|
|
33
33
|
(p) => {
|
|
34
|
-
const d = i.current,
|
|
34
|
+
const d = i.current, y = (typeof d == "function" ? d : () => d)().pipe(
|
|
35
35
|
/**
|
|
36
36
|
* @important
|
|
37
37
|
* We only check primitives because underlying subscription might
|
|
@@ -39,13 +39,13 @@ function Xe(s, e, t) {
|
|
|
39
39
|
* properties values
|
|
40
40
|
*/
|
|
41
41
|
Q(ms),
|
|
42
|
-
E((
|
|
43
|
-
u.current =
|
|
42
|
+
E((b) => {
|
|
43
|
+
u.current = b;
|
|
44
44
|
}),
|
|
45
|
-
B((
|
|
45
|
+
B((b) => (console.error(b), Z))
|
|
46
46
|
).subscribe(p);
|
|
47
47
|
return () => {
|
|
48
|
-
c.current.unsubscribeOnUnmount !== !1 &&
|
|
48
|
+
c.current.unsubscribeOnUnmount !== !1 && y.unsubscribe();
|
|
49
49
|
};
|
|
50
50
|
},
|
|
51
51
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -57,7 +57,7 @@ function St(s) {
|
|
|
57
57
|
return s instanceof Promise || s && typeof s.then == "function" && typeof s.catch == "function";
|
|
58
58
|
}
|
|
59
59
|
function U(s) {
|
|
60
|
-
if (
|
|
60
|
+
if (bt(s))
|
|
61
61
|
return s;
|
|
62
62
|
if (St(s))
|
|
63
63
|
return Se(s);
|
|
@@ -66,7 +66,7 @@ function U(s) {
|
|
|
66
66
|
const e = s;
|
|
67
67
|
return Ae(() => {
|
|
68
68
|
const t = e();
|
|
69
|
-
return St(t) ? Se(t) :
|
|
69
|
+
return St(t) ? Se(t) : bt(t) ? t : v(t);
|
|
70
70
|
});
|
|
71
71
|
}
|
|
72
72
|
function Ut(s, e = []) {
|
|
@@ -123,7 +123,7 @@ const Ze = (s) => {
|
|
|
123
123
|
);
|
|
124
124
|
return [t.current, r, e.current.getValue()];
|
|
125
125
|
}, Ss = Symbol("SIGNAL_RESET");
|
|
126
|
-
function
|
|
126
|
+
function yr(s = {}) {
|
|
127
127
|
const e = {
|
|
128
128
|
default: s.default,
|
|
129
129
|
key: s.key
|
|
@@ -160,7 +160,7 @@ function br(s = {}) {
|
|
|
160
160
|
subject: r
|
|
161
161
|
};
|
|
162
162
|
}
|
|
163
|
-
function
|
|
163
|
+
function br(s, e) {
|
|
164
164
|
const r = e ?? (() => s.getValue());
|
|
165
165
|
return Xe(
|
|
166
166
|
() => s.subject.pipe(
|
|
@@ -361,31 +361,31 @@ function Pt(s) {
|
|
|
361
361
|
} = l;
|
|
362
362
|
return (d) => Ae(() => {
|
|
363
363
|
let f = 0;
|
|
364
|
-
const
|
|
364
|
+
const y = (b, $) => b < u ? i(b, $) : !1;
|
|
365
365
|
return d.pipe(
|
|
366
|
-
mt((
|
|
366
|
+
mt((b) => {
|
|
367
367
|
var w;
|
|
368
|
-
if (f++, !
|
|
369
|
-
throw
|
|
370
|
-
const $ = (w = s.caughtError) == null ? void 0 : w.call(s, f,
|
|
368
|
+
if (f++, !y(f - 1, b))
|
|
369
|
+
throw b;
|
|
370
|
+
const $ = (w = s.caughtError) == null ? void 0 : w.call(s, f, b);
|
|
371
371
|
if (!$)
|
|
372
|
-
throw
|
|
372
|
+
throw b;
|
|
373
373
|
return $.pipe(
|
|
374
374
|
tt(
|
|
375
375
|
(H) => F(
|
|
376
376
|
v(H),
|
|
377
|
-
Oe(() =>
|
|
377
|
+
Oe(() => b)
|
|
378
378
|
)
|
|
379
379
|
)
|
|
380
380
|
);
|
|
381
381
|
}),
|
|
382
|
-
fs((
|
|
382
|
+
fs((b) => b.pipe(
|
|
383
383
|
ps(($) => {
|
|
384
384
|
const w = f - 1;
|
|
385
385
|
return n().pipe(
|
|
386
|
-
|
|
386
|
+
ys(),
|
|
387
387
|
tt(
|
|
388
|
-
() =>
|
|
388
|
+
() => y(w, $) ? Qe(
|
|
389
389
|
Cs(
|
|
390
390
|
p(w, c),
|
|
391
391
|
h
|
|
@@ -397,10 +397,10 @@ function Pt(s) {
|
|
|
397
397
|
);
|
|
398
398
|
})
|
|
399
399
|
)),
|
|
400
|
-
mt((
|
|
400
|
+
mt((b) => {
|
|
401
401
|
if (s.catchError)
|
|
402
|
-
return s.catchError(f,
|
|
403
|
-
throw
|
|
402
|
+
return s.catchError(f, b);
|
|
403
|
+
throw b;
|
|
404
404
|
}),
|
|
405
405
|
Qt(() => {
|
|
406
406
|
o && (f = 0);
|
|
@@ -408,6 +408,7 @@ function Pt(s) {
|
|
|
408
408
|
);
|
|
409
409
|
});
|
|
410
410
|
}
|
|
411
|
+
const vr = (s, e) => s.length === e.length && s.every((t, r) => t === e[r]);
|
|
411
412
|
function $t(s) {
|
|
412
413
|
return Object.prototype.toString.call(s) === "[object Object]";
|
|
413
414
|
}
|
|
@@ -494,7 +495,7 @@ class Es {
|
|
|
494
495
|
*/
|
|
495
496
|
o
|
|
496
497
|
).pipe(
|
|
497
|
-
g((
|
|
498
|
+
g((y) => ({ state: y, mutation: u })),
|
|
498
499
|
e ?? Mt,
|
|
499
500
|
ne(f)
|
|
500
501
|
);
|
|
@@ -692,10 +693,10 @@ class xs {
|
|
|
692
693
|
ie = new WeakMap(), L = new WeakMap();
|
|
693
694
|
const kt = Zt(void 0), Rs = ({ client: s }) => (X(() => (s.mount(), () => {
|
|
694
695
|
s.unmount();
|
|
695
|
-
}), [s]), null),
|
|
696
|
+
}), [s]), null), Or = es(
|
|
696
697
|
({ children: s, client: e }) => {
|
|
697
698
|
const t = ut(() => e, [e]);
|
|
698
|
-
return /* @__PURE__ */
|
|
699
|
+
return /* @__PURE__ */ bs(kt.Provider, { value: t, children: [
|
|
699
700
|
/* @__PURE__ */ gs(Rs, { client: e }),
|
|
700
701
|
s
|
|
701
702
|
] });
|
|
@@ -710,7 +711,7 @@ const kt = Zt(void 0), Rs = ({ client: s }) => (X(() => (s.mount(), () => {
|
|
|
710
711
|
};
|
|
711
712
|
function js() {
|
|
712
713
|
}
|
|
713
|
-
function
|
|
714
|
+
function $r(s, e) {
|
|
714
715
|
const t = Tt(e), r = q(s), n = Ze(() => [ct()]), u = ve(s.mutationKey ?? n.current), [i] = jt(
|
|
715
716
|
() => new xs(
|
|
716
717
|
t,
|
|
@@ -855,7 +856,7 @@ const it = Symbol(), Ds = ({
|
|
|
855
856
|
const j = n.status === "pending" ? "pending" : i.status ?? n.status;
|
|
856
857
|
return { ...n, ...i, status: j };
|
|
857
858
|
}
|
|
858
|
-
const c = i.data, l = c !== void 0 && c !== n.data, h = "data" in i, o = i.status === "success", p = n.data !== void 0, d = n.error !== void 0 || n.error !== null, f = i.status ?? n.status,
|
|
859
|
+
const c = i.data, l = c !== void 0 && c !== n.data, h = "data" in i, o = i.status === "success", p = n.data !== void 0, d = n.error !== void 0 || n.error !== null, f = i.status ?? n.status, y = l ? Le(e().data, c, s()) : h ? i.data : n.data, b = n.status === "error" || n.status === "success", $ = i.status === "error" && (n.status === "error" && n.fetchStatus === "fetching" || n.status !== "error") ? n.errorUpdateCount + 1 : n.errorUpdateCount, w = l ? n.dataUpdateCount + 1 : i.dataUpdateCount ?? n.dataUpdateCount, H = i.status === "pending" && b && // (dataUpdateCount !== 0 || errorUpdateCount !== 0)
|
|
859
860
|
(p || d), P = f === "pending" ? null : i.error ?? n.error;
|
|
860
861
|
return {
|
|
861
862
|
...n,
|
|
@@ -866,7 +867,7 @@ const it = Symbol(), Ds = ({
|
|
|
866
867
|
...o && {
|
|
867
868
|
isInvalidated: !1
|
|
868
869
|
},
|
|
869
|
-
data:
|
|
870
|
+
data: y,
|
|
870
871
|
dataUpdateCount: w,
|
|
871
872
|
...H && {
|
|
872
873
|
status: n.status
|
|
@@ -935,7 +936,7 @@ const ze = new Ts(), Ks = (s) => s.pipe(
|
|
|
935
936
|
})),
|
|
936
937
|
Q(V)
|
|
937
938
|
);
|
|
938
|
-
var Y, R, Ce, ue, D,
|
|
939
|
+
var Y, R, Ce, ue, D, ye, Fe;
|
|
939
940
|
class Ht {
|
|
940
941
|
constructor(e, t) {
|
|
941
942
|
C(this, Y, void 0);
|
|
@@ -958,7 +959,7 @@ class Ht {
|
|
|
958
959
|
C(this, D, void 0);
|
|
959
960
|
// This property keeps track of the last query with defined data.
|
|
960
961
|
// It will be used to pass the previous data and query to the placeholder function between renders.
|
|
961
|
-
C(this,
|
|
962
|
+
C(this, ye, void 0);
|
|
962
963
|
C(this, Fe, 0);
|
|
963
964
|
m(this, "getObserverResultFromQuery", ({
|
|
964
965
|
options: e,
|
|
@@ -974,7 +975,7 @@ class Ht {
|
|
|
974
975
|
}
|
|
975
976
|
}) => {
|
|
976
977
|
var De;
|
|
977
|
-
const o = t.state, p = t.state.status === "pending", d = a(this, R), f = this.options,
|
|
978
|
+
const o = t.state, p = t.state.status === "pending", d = a(this, R), f = this.options, b = t !== d ? t.state : a(this, ue);
|
|
978
979
|
let { errorUpdatedAt: $, fetchStatus: w, error: H } = o;
|
|
979
980
|
if (r) {
|
|
980
981
|
const T = !!a(this, Fe), pt = !T && wt(t, e), Jt = T && Ct(t, d, e, f);
|
|
@@ -1002,8 +1003,8 @@ class Ht {
|
|
|
1002
1003
|
if (n != null && n.isPlaceholderData && e.placeholderData === (u == null ? void 0 : u.placeholderData))
|
|
1003
1004
|
T = n.data;
|
|
1004
1005
|
else if (T = typeof e.placeholderData == "function" ? e.placeholderData(
|
|
1005
|
-
(De = a(this,
|
|
1006
|
-
a(this,
|
|
1006
|
+
(De = a(this, ye)) == null ? void 0 : De.state.data,
|
|
1007
|
+
a(this, ye)
|
|
1007
1008
|
) : e.placeholderData, e.select && typeof T < "u")
|
|
1008
1009
|
try {
|
|
1009
1010
|
T = e.select(T);
|
|
@@ -1033,7 +1034,7 @@ class Ht {
|
|
|
1033
1034
|
failureReason: o.fetchFailureReason,
|
|
1034
1035
|
errorUpdateCount: o.errorUpdateCount,
|
|
1035
1036
|
isFetched: o.dataUpdateCount > 0 || o.errorUpdateCount > 0,
|
|
1036
|
-
isFetchedAfterMount: o.dataUpdateCount >
|
|
1037
|
+
isFetchedAfterMount: o.dataUpdateCount > b.dataUpdateCount || o.errorUpdateCount > b.errorUpdateCount,
|
|
1037
1038
|
isFetching: Pe,
|
|
1038
1039
|
isRefetching: Pe && !p,
|
|
1039
1040
|
isLoadingError: Ie && o.dataUpdatedAt === 0,
|
|
@@ -1114,7 +1115,7 @@ class Ht {
|
|
|
1114
1115
|
select: n,
|
|
1115
1116
|
selectResult: u
|
|
1116
1117
|
}) {
|
|
1117
|
-
a(this, D).state = e.state, a(this, D).result = t, a(this, D).selectResult = u, r !== void 0 && (a(this, D).selectError = r), n !== void 0 && (a(this, D).select = n), a(this, D).options = this.options, e.state.data !== void 0 && M(this,
|
|
1118
|
+
a(this, D).state = e.state, a(this, D).result = t, a(this, D).selectResult = u, r !== void 0 && (a(this, D).selectError = r), n !== void 0 && (a(this, D).select = n), a(this, D).options = this.options, e.state.data !== void 0 && M(this, ye, e), a(this, Y).getQueryCache().notify({
|
|
1118
1119
|
query: a(this, R),
|
|
1119
1120
|
type: "observerResultsUpdated"
|
|
1120
1121
|
});
|
|
@@ -1226,13 +1227,13 @@ class Ht {
|
|
|
1226
1227
|
})
|
|
1227
1228
|
) : qe),
|
|
1228
1229
|
he()
|
|
1229
|
-
),
|
|
1230
|
+
), y = l.pipe(
|
|
1230
1231
|
g(({ enabled: S }) => S ?? !0),
|
|
1231
1232
|
Q()
|
|
1232
|
-
),
|
|
1233
|
+
), b = y.pipe(
|
|
1233
1234
|
O((S) => !S),
|
|
1234
1235
|
g(() => i.state)
|
|
1235
|
-
), $ =
|
|
1236
|
+
), $ = y.pipe(
|
|
1236
1237
|
O((S) => S),
|
|
1237
1238
|
x(() => ze.focusRegained$),
|
|
1238
1239
|
gt(l),
|
|
@@ -1240,7 +1241,7 @@ class Ht {
|
|
|
1240
1241
|
Us(i, S) && this.fetch({ cancelRefetch: !1 }).catch(N);
|
|
1241
1242
|
}),
|
|
1242
1243
|
he()
|
|
1243
|
-
), w =
|
|
1244
|
+
), w = b.pipe(
|
|
1244
1245
|
g(() => i.state)
|
|
1245
1246
|
), H = (S) => S.pipe(
|
|
1246
1247
|
gt(l),
|
|
@@ -1280,7 +1281,7 @@ class Ht {
|
|
|
1280
1281
|
destroy() {
|
|
1281
1282
|
}
|
|
1282
1283
|
}
|
|
1283
|
-
Y = new WeakMap(), R = new WeakMap(), Ce = new WeakMap(), ue = new WeakMap(), D = new WeakMap(),
|
|
1284
|
+
Y = new WeakMap(), R = new WeakMap(), Ce = new WeakMap(), ue = new WeakMap(), D = new WeakMap(), ye = new WeakMap(), Fe = new WeakMap();
|
|
1284
1285
|
function Ns(s, e) {
|
|
1285
1286
|
return !V(s.getCurrentResult(), e);
|
|
1286
1287
|
}
|
|
@@ -1346,10 +1347,10 @@ function Lt(s, e, t) {
|
|
|
1346
1347
|
throw p;
|
|
1347
1348
|
return h.current;
|
|
1348
1349
|
}
|
|
1349
|
-
function
|
|
1350
|
+
function wr(s, e) {
|
|
1350
1351
|
return Lt(s, Ht, e);
|
|
1351
1352
|
}
|
|
1352
|
-
function
|
|
1353
|
+
function Cr(s, e) {
|
|
1353
1354
|
return Lt(
|
|
1354
1355
|
{
|
|
1355
1356
|
refetchOnMount: "idle",
|
|
@@ -1362,7 +1363,7 @@ function wr(s, e) {
|
|
|
1362
1363
|
e
|
|
1363
1364
|
);
|
|
1364
1365
|
}
|
|
1365
|
-
function
|
|
1366
|
+
function Fr(s, e, t = []) {
|
|
1366
1367
|
const r = e != null && !Array.isArray(e) ? e : {}, n = r.retry ?? !0, u = q(
|
|
1367
1368
|
r.onError ?? ((l) => {
|
|
1368
1369
|
console.error(l);
|
|
@@ -1423,7 +1424,7 @@ const zt = () => (s) => F(
|
|
|
1423
1424
|
return ((d = t.onMutate) == null ? void 0 : d.call(t, s)) ?? void 0;
|
|
1424
1425
|
}
|
|
1425
1426
|
)
|
|
1426
|
-
).pipe(Ue(1)), l = (d, f,
|
|
1427
|
+
).pipe(Ue(1)), l = (d, f, y) => U(
|
|
1427
1428
|
() => {
|
|
1428
1429
|
var $;
|
|
1429
1430
|
return ($ = t.onError) == null ? void 0 : $.call(t, d, s, f);
|
|
@@ -1432,7 +1433,7 @@ const zt = () => (s) => F(
|
|
|
1432
1433
|
B(() => v(d)),
|
|
1433
1434
|
g(
|
|
1434
1435
|
() => ({
|
|
1435
|
-
failureCount:
|
|
1436
|
+
failureCount: y,
|
|
1436
1437
|
error: d,
|
|
1437
1438
|
failureReason: d,
|
|
1438
1439
|
context: f,
|
|
@@ -1441,14 +1442,14 @@ const zt = () => (s) => F(
|
|
|
1441
1442
|
)
|
|
1442
1443
|
), h = c.pipe(
|
|
1443
1444
|
x((d) => {
|
|
1444
|
-
const
|
|
1445
|
+
const y = (typeof u == "function" ? (
|
|
1445
1446
|
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
|
1446
1447
|
U(() => u(s))
|
|
1447
1448
|
) : u).pipe(
|
|
1448
1449
|
g(
|
|
1449
|
-
(
|
|
1450
|
+
(b) => ({
|
|
1450
1451
|
result: {
|
|
1451
|
-
data:
|
|
1452
|
+
data: b
|
|
1452
1453
|
},
|
|
1453
1454
|
error: null,
|
|
1454
1455
|
context: d
|
|
@@ -1457,18 +1458,18 @@ const zt = () => (s) => F(
|
|
|
1457
1458
|
Gs,
|
|
1458
1459
|
Pt({
|
|
1459
1460
|
...t,
|
|
1460
|
-
retry: (
|
|
1461
|
+
retry: (b, $) => {
|
|
1461
1462
|
const w = t.retry ?? 0;
|
|
1462
|
-
return typeof w == "function" ? w(
|
|
1463
|
+
return typeof w == "function" ? w(b, $) : typeof w == "boolean" ? w : b < w;
|
|
1463
1464
|
},
|
|
1464
|
-
caughtError: (
|
|
1465
|
+
caughtError: (b, $) => (
|
|
1465
1466
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
1466
1467
|
v({
|
|
1467
|
-
failureCount:
|
|
1468
|
+
failureCount: b,
|
|
1468
1469
|
failureReason: $
|
|
1469
1470
|
})
|
|
1470
1471
|
),
|
|
1471
|
-
catchError: (
|
|
1472
|
+
catchError: (b, $) => l($, d, b).pipe(
|
|
1472
1473
|
g((w) => ({
|
|
1473
1474
|
...w,
|
|
1474
1475
|
result: void 0
|
|
@@ -1476,11 +1477,11 @@ const zt = () => (s) => F(
|
|
|
1476
1477
|
)
|
|
1477
1478
|
}),
|
|
1478
1479
|
Ye(
|
|
1479
|
-
({ result:
|
|
1480
|
+
({ result: b, error: $ }) => (b == null ? void 0 : b.data) === void 0 && $ === void 0,
|
|
1480
1481
|
!0
|
|
1481
1482
|
)
|
|
1482
1483
|
);
|
|
1483
|
-
return re.isOnline() || t.networkMode === "offlineFirst" || t.networkMode === "always" ?
|
|
1484
|
+
return re.isOnline() || t.networkMode === "offlineFirst" || t.networkMode === "always" ? y : y.pipe(zt());
|
|
1484
1485
|
})
|
|
1485
1486
|
), o = v({
|
|
1486
1487
|
...e,
|
|
@@ -1496,19 +1497,19 @@ const zt = () => (s) => F(
|
|
|
1496
1497
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
1497
1498
|
c.pipe(g((d) => ({ context: d }))),
|
|
1498
1499
|
h.pipe(
|
|
1499
|
-
x(({ result: d, error: f, ...
|
|
1500
|
+
x(({ result: d, error: f, ...y }) => {
|
|
1500
1501
|
if (!d && !f)
|
|
1501
1502
|
return v({
|
|
1502
|
-
...
|
|
1503
|
+
...y
|
|
1503
1504
|
});
|
|
1504
|
-
const
|
|
1505
|
+
const b = f ? v(null) : U(
|
|
1505
1506
|
() => {
|
|
1506
1507
|
var P;
|
|
1507
1508
|
return (P = t.onSuccess) == null ? void 0 : P.call(
|
|
1508
1509
|
t,
|
|
1509
1510
|
d == null ? void 0 : d.data,
|
|
1510
1511
|
s,
|
|
1511
|
-
|
|
1512
|
+
y.context
|
|
1512
1513
|
);
|
|
1513
1514
|
}
|
|
1514
1515
|
), w = U(
|
|
@@ -1519,20 +1520,20 @@ const zt = () => (s) => F(
|
|
|
1519
1520
|
d == null ? void 0 : d.data,
|
|
1520
1521
|
f,
|
|
1521
1522
|
s,
|
|
1522
|
-
|
|
1523
|
+
y.context
|
|
1523
1524
|
);
|
|
1524
1525
|
}
|
|
1525
1526
|
).pipe(
|
|
1526
1527
|
B((P) => d ? v(d) : v(P))
|
|
1527
1528
|
);
|
|
1528
|
-
return ke(
|
|
1529
|
+
return ke(b, w).pipe(
|
|
1529
1530
|
Te(),
|
|
1530
1531
|
g(
|
|
1531
1532
|
() => f ? {
|
|
1532
1533
|
error: f,
|
|
1533
1534
|
data: void 0,
|
|
1534
1535
|
variables: s,
|
|
1535
|
-
...
|
|
1536
|
+
...y
|
|
1536
1537
|
} : {
|
|
1537
1538
|
status: "success",
|
|
1538
1539
|
error: f,
|
|
@@ -1540,11 +1541,11 @@ const zt = () => (s) => F(
|
|
|
1540
1541
|
variables: s,
|
|
1541
1542
|
failureCount: 0,
|
|
1542
1543
|
failureReason: null,
|
|
1543
|
-
...
|
|
1544
|
+
...y
|
|
1544
1545
|
}
|
|
1545
1546
|
),
|
|
1546
1547
|
B(
|
|
1547
|
-
(P) => l(P,
|
|
1548
|
+
(P) => l(P, y.context, 0).pipe(
|
|
1548
1549
|
g((j) => ({
|
|
1549
1550
|
...j,
|
|
1550
1551
|
data: void 0
|
|
@@ -1563,7 +1564,7 @@ const zt = () => (s) => F(
|
|
|
1563
1564
|
}), fe())
|
|
1564
1565
|
);
|
|
1565
1566
|
};
|
|
1566
|
-
var Ee, se,
|
|
1567
|
+
var Ee, se, be;
|
|
1567
1568
|
class Ys {
|
|
1568
1569
|
constructor({
|
|
1569
1570
|
options: e,
|
|
@@ -1572,7 +1573,7 @@ class Ys {
|
|
|
1572
1573
|
}) {
|
|
1573
1574
|
C(this, Ee, new J(0));
|
|
1574
1575
|
C(this, se, new I());
|
|
1575
|
-
C(this,
|
|
1576
|
+
C(this, be, new I());
|
|
1576
1577
|
m(this, "state", fe());
|
|
1577
1578
|
m(this, "state$");
|
|
1578
1579
|
m(this, "options");
|
|
@@ -1584,7 +1585,7 @@ class Ys {
|
|
|
1584
1585
|
g(() => ({
|
|
1585
1586
|
status: "idle"
|
|
1586
1587
|
}))
|
|
1587
|
-
), u = a(this,
|
|
1588
|
+
), u = a(this, be).pipe(
|
|
1588
1589
|
x(
|
|
1589
1590
|
(c) => Js({
|
|
1590
1591
|
options: {
|
|
@@ -1592,16 +1593,16 @@ class Ys {
|
|
|
1592
1593
|
onMutate: (l) => {
|
|
1593
1594
|
const h = U(
|
|
1594
1595
|
() => {
|
|
1595
|
-
var f,
|
|
1596
|
-
return (
|
|
1596
|
+
var f, y;
|
|
1597
|
+
return (y = (f = t.config).onMutate) == null ? void 0 : y.call(
|
|
1597
1598
|
f,
|
|
1598
1599
|
l,
|
|
1599
1600
|
this
|
|
1600
1601
|
);
|
|
1601
1602
|
}
|
|
1602
1603
|
), p = U(() => {
|
|
1603
|
-
var f,
|
|
1604
|
-
return (
|
|
1604
|
+
var f, y;
|
|
1605
|
+
return (y = (f = this.options).onMutate) == null ? void 0 : y.call(f, l);
|
|
1605
1606
|
});
|
|
1606
1607
|
return h.pipe(
|
|
1607
1608
|
k(() => p)
|
|
@@ -1610,8 +1611,8 @@ class Ys {
|
|
|
1610
1611
|
onError: (l, h, o) => {
|
|
1611
1612
|
const p = U(
|
|
1612
1613
|
() => {
|
|
1613
|
-
var f,
|
|
1614
|
-
return (
|
|
1614
|
+
var f, y;
|
|
1615
|
+
return (y = (f = t.config).onError) == null ? void 0 : y.call(
|
|
1615
1616
|
f,
|
|
1616
1617
|
l,
|
|
1617
1618
|
h,
|
|
@@ -1621,8 +1622,8 @@ class Ys {
|
|
|
1621
1622
|
}
|
|
1622
1623
|
), d = U(
|
|
1623
1624
|
() => {
|
|
1624
|
-
var f,
|
|
1625
|
-
return (
|
|
1625
|
+
var f, y;
|
|
1626
|
+
return (y = (f = this.options).onError) == null ? void 0 : y.call(f, l, h, o);
|
|
1626
1627
|
}
|
|
1627
1628
|
);
|
|
1628
1629
|
return ke(p, d).pipe(Te());
|
|
@@ -1630,9 +1631,9 @@ class Ys {
|
|
|
1630
1631
|
onSettled: (l, h, o, p) => {
|
|
1631
1632
|
const d = U(
|
|
1632
1633
|
() => {
|
|
1633
|
-
var
|
|
1634
|
-
return (
|
|
1635
|
-
|
|
1634
|
+
var y, b;
|
|
1635
|
+
return (b = (y = t.config).onSettled) == null ? void 0 : b.call(
|
|
1636
|
+
y,
|
|
1636
1637
|
l,
|
|
1637
1638
|
h,
|
|
1638
1639
|
o,
|
|
@@ -1642,8 +1643,8 @@ class Ys {
|
|
|
1642
1643
|
}
|
|
1643
1644
|
), f = U(
|
|
1644
1645
|
() => {
|
|
1645
|
-
var
|
|
1646
|
-
return (
|
|
1646
|
+
var y, b;
|
|
1647
|
+
return (b = (y = this.options).onSettled) == null ? void 0 : b.call(y, l, h, o, p);
|
|
1647
1648
|
}
|
|
1648
1649
|
);
|
|
1649
1650
|
return ke(d, f).pipe(Te());
|
|
@@ -1651,8 +1652,8 @@ class Ys {
|
|
|
1651
1652
|
onSuccess: (l, h, o) => {
|
|
1652
1653
|
const p = U(
|
|
1653
1654
|
() => {
|
|
1654
|
-
var f,
|
|
1655
|
-
return (
|
|
1655
|
+
var f, y;
|
|
1656
|
+
return (y = (f = t.config).onSuccess) == null ? void 0 : y.call(
|
|
1656
1657
|
f,
|
|
1657
1658
|
l,
|
|
1658
1659
|
h,
|
|
@@ -1662,8 +1663,8 @@ class Ys {
|
|
|
1662
1663
|
}
|
|
1663
1664
|
), d = U(
|
|
1664
1665
|
() => {
|
|
1665
|
-
var f,
|
|
1666
|
-
return (
|
|
1666
|
+
var f, y;
|
|
1667
|
+
return (y = (f = this.options).onSuccess) == null ? void 0 : y.call(f, l, h, o);
|
|
1667
1668
|
}
|
|
1668
1669
|
);
|
|
1669
1670
|
return ke(p, d).pipe(Te());
|
|
@@ -1705,7 +1706,7 @@ class Ys {
|
|
|
1705
1706
|
* is over, unlike the state which can be re-subscribed later.
|
|
1706
1707
|
*/
|
|
1707
1708
|
execute(e) {
|
|
1708
|
-
return a(this,
|
|
1709
|
+
return a(this, be).next(e), a(this, be).complete(), this.state$.pipe(we);
|
|
1709
1710
|
}
|
|
1710
1711
|
continue() {
|
|
1711
1712
|
return this.execute(this.state.variables);
|
|
@@ -1719,7 +1720,7 @@ class Ys {
|
|
|
1719
1720
|
a(this, se).next(), a(this, se).complete();
|
|
1720
1721
|
}
|
|
1721
1722
|
}
|
|
1722
|
-
Ee = new WeakMap(), se = new WeakMap(),
|
|
1723
|
+
Ee = new WeakMap(), se = new WeakMap(), be = new WeakMap();
|
|
1723
1724
|
const Rt = ({
|
|
1724
1725
|
mutationKey: s,
|
|
1725
1726
|
status: e,
|
|
@@ -2452,7 +2453,7 @@ class ar {
|
|
|
2452
2453
|
}
|
|
2453
2454
|
Re = new WeakMap(), G = new WeakMap();
|
|
2454
2455
|
var oe, A, je, Me, ge;
|
|
2455
|
-
class
|
|
2456
|
+
class Er {
|
|
2456
2457
|
// #destroy = () => {}
|
|
2457
2458
|
constructor({
|
|
2458
2459
|
mutationCache: e,
|
|
@@ -2606,29 +2607,30 @@ oe = new WeakMap(), A = new WeakMap(), je = new WeakMap(), Me = new WeakMap(), g
|
|
|
2606
2607
|
export {
|
|
2607
2608
|
Bs as MutationCache,
|
|
2608
2609
|
ar as QueryCache,
|
|
2609
|
-
|
|
2610
|
-
|
|
2610
|
+
Er as QueryClient,
|
|
2611
|
+
Or as QueryClientProvider,
|
|
2611
2612
|
Ss as SIGNAL_RESET,
|
|
2613
|
+
vr as arrayEqual,
|
|
2612
2614
|
Os as createLocalStorageAdapter,
|
|
2613
2615
|
gr as createLocalforageAdapter,
|
|
2614
2616
|
Fs as exponentialBackoffDelay,
|
|
2615
2617
|
Cs as getDelay,
|
|
2616
2618
|
rt as isDefined,
|
|
2617
2619
|
Pt as retryBackoff,
|
|
2618
|
-
|
|
2620
|
+
yr as signal,
|
|
2619
2621
|
Vt as useBehaviorSubject,
|
|
2620
|
-
|
|
2622
|
+
Cr as useForeverQuery,
|
|
2621
2623
|
q as useLiveRef,
|
|
2622
|
-
|
|
2624
|
+
$r as useMutation,
|
|
2623
2625
|
pr as useObservableState,
|
|
2624
2626
|
Xe as useObserve,
|
|
2625
2627
|
fr as useObserveCallback,
|
|
2626
2628
|
mr as usePersistSignals,
|
|
2627
|
-
|
|
2629
|
+
wr as useQuery,
|
|
2628
2630
|
Tt as useQueryClient,
|
|
2629
|
-
|
|
2631
|
+
br as useSignalValue,
|
|
2630
2632
|
It as useSubject,
|
|
2631
2633
|
Ut as useSubscribe,
|
|
2632
|
-
|
|
2634
|
+
Fr as useSubscribeEffect,
|
|
2633
2635
|
Sr as useUnmountObservable
|
|
2634
2636
|
};
|