reactjrx 1.79.0 → 1.79.1
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.js +107 -106
- package/dist/lib/queries/client/mutations/mutation/types.d.ts +2 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var lt=Object.defineProperty;var ht=(s,e,t)=>e in s?lt(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var g=(s,e,t)=>(ht(s,typeof e!="symbol"?e+"":e,t),t),Pe=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)};var c=(s,e,t)=>(Pe(s,e,"read from private field"),t?t.call(s):e.get(s)),w=(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)=>(Pe(s,e,"write to private field"),n?n.call(s,t):e.set(s,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("react"),r=require("rxjs"),K=require("rxjs/operators"),ke=require("react/jsx-runtime");function ft(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 ve=ft(S),A=s=>{const e=S.useRef(s);return S.useMemo(()=>{e.current=s},[s]),e};function dt(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 he(s,e,t){const n=e!=null&&!Array.isArray(e)?e:{defaultValue:void 0,key:"",unsubscribeOnUnmount:!0},i=t==null&&Array.isArray(e)?e:typeof s=="function"?t??[]:[s],u=S.useRef("getValue"in s&&typeof s.getValue=="function"?s.getValue():n.defaultValue),a=A(s),h=A(n),d=S.useCallback(p=>{const o=a.current,$=(typeof o=="function"?o:()=>o)().pipe(r.distinctUntilChanged(dt),r.tap(b=>{u.current=b}),r.finalize(p),r.catchError(b=>(console.error(b),u.current=void 0,r.EMPTY))).subscribe(p);return()=>{h.current.unsubscribeOnUnmount!==!1&&$.unsubscribe()}},[...i]),f=S.useCallback(()=>u.current,[]);return S.useSyncExternalStore(d,f,f)}function Ve(s){return s instanceof Promise||s&&typeof s.then=="function"&&typeof s.catch=="function"}function R(s){if(r.isObservable(s))return s;if(Ve(s))return r.from(s);if(typeof s!="function")return r.of(s);const e=s;return r.defer(()=>{const t=e();return Ve(t)?r.from(t):r.isObservable(t)?t:r.of(t)})}function Ee(s,e=[]){const t=A(s);S.useEffect(()=>{const n=R(t.current).subscribe();return()=>{n.unsubscribe()}},[...e,t])}const Oe=s=>{const e=S.useRef();return e.current||(e.current=s()),S.useEffect(()=>{process.env.NODE_ENV},[]),e},Me=({onBeforeComplete:s,completeOnUnmount:e=!0}={})=>{const t=Oe(()=>new r.Subject),n=S.useRef(!1),i=A(s),u=A(e);return S.useEffect(()=>(n.current&&(t.current=new r.Subject,n.current=!1),()=>{if(!u.current){n.current=!0;return}n.current||(i.current!=null&&i.current(),t.current.complete(),n.current=!0)}),[u,i,t]),t},pt=()=>{const s=Me(),e=A(s.current.asObservable()),t=S.useCallback(n=>{s.current.next(n)},[]);return[e.current,t]},Le=s=>{const e=Oe(()=>new r.BehaviorSubject(s)),t=S.useRef(!1),n=S.useRef(s);return S.useEffect(()=>(t.current&&(e.current=new r.BehaviorSubject(n.current),t.current=!1),()=>{t.current||(e.current.complete(),t.current=!0)}),[e]),e},bt=s=>{const e=Le(s),t=A(e.current.asObservable()),n=S.useCallback(i=>{e.current.next(i)},[e.current]);return[t.current,n,e.current.getValue()]},_e=Symbol("SIGNAL_RESET");function gt(s){const{default:e}=s??{},t=new r.BehaviorSubject(e);return{setValue:u=>{if(typeof u=="function"){const a=u(t.getValue());if(a===t.getValue())return;t.next(a);return}if(u===_e){t.next(e??void 0);return}t.next(u)},getValue:()=>t.getValue(),config:s,subject:t}}function yt(s,e){const t=e??(n=>n);return he(()=>s.subject.pipe(r.map(n=>t(n)),r.distinctUntilChanged()),{defaultValue:t(s.getValue())},[])}const Ie=s=>{if(!(!s||typeof s!="object"))return s},mt=({adapter:s,key:e})=>({getItem:async t=>{const n=await s.getItem(e),i=Ie(n)??{};if(t in i)return i[t]},setItem:async(t,n)=>{const i=await s.getItem(e),u=Ie(i)??{};await s.setItem(e,{...u,[t]:n})}}),St=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))}}),ze=()=>({getItem:async s=>{const e=localStorage.getItem(s);if(e)return JSON.parse(e)},setItem:async(s,e)=>{localStorage.setItem(s,JSON.stringify(e))}}),te="__reactjrx",vt=s=>{if(typeof s=="object"&&s!==null&&te in s&&s[te]===te)return s},Ot=async({adapter:s,signal:e,version:t})=>{const i={value:e.getValue(),[te]:te,migrationVersion:t};await s.setItem(e.config.key,i)},wt=({adapter:s,version:e,signal:t})=>r.from(s.getItem(t.config.key)).pipe(r.switchMap(n=>{const i=vt(n);return!i||i.migrationVersion!==void 0&&e>i.migrationVersion||t.setValue(i.value),r.of(n)})),$t=({entries:s=[],onReady:e,adapter:t=ze()})=>{const n=A(s),i=A(e),u=A(t),a=he(()=>{const h=n.current;return(h.length===0?r.of(!0):r.zip(...h.map(({signal:f,version:l})=>wt({adapter:u.current,signal:f,version:l}))).pipe(r.map(()=>!0))).pipe(r.tap(()=>{i.current!=null&&i.current()}),r.catchError(f=>(console.error("Unable to hydrate",f),r.EMPTY)))},{defaultValue:!1},[]);return Ee(()=>a?r.merge(...n.current.map(({signal:h,version:d})=>h.subject.pipe(r.throttleTime(500,r.asyncScheduler,{trailing:!0}),r.switchMap(()=>r.from(Ot({adapter:u.current,signal:h,version:d})))))):r.EMPTY,[a,u]),{isHydrated:a}},Ct=()=>{const s=Me({onBeforeComplete:()=>{s.current.next()}});return s};function Be(s,e){return Math.min(s,e)}function Ye(s,e){return Math.pow(2,s)*e}function je(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,h=typeof t=="number"?t:100,d={shouldRetry:a,...s},{maxInterval:f=1/0,resetOnSuccess:l=!1,backoffDelay:p=Ye}=d;return o=>r.defer(()=>{let y=0;const $=(b,v)=>b<u?a(b,v):!1;return o.pipe(K.catchError(b=>{var O;if(y++,!$(y-1,b))throw b;const v=(O=s.caughtError)==null?void 0:O.call(s,y,b);if(!v)throw b;return v.pipe(K.mergeMap(k=>r.merge(r.of(k),r.throwError(()=>b))))}),K.retryWhen(b=>b.pipe(K.concatMap(v=>{const O=y-1;return i().pipe(K.first(),K.mergeMap(()=>$(O,v)?r.timer(Be(p(O,h),f)).pipe(K.mergeMap(k=>n&&!n(O,v)?r.throwError(()=>v):r.of(k))):r.throwError(()=>v)))}))),K.catchError(b=>{if(s.catchError)return s.catchError(y,b);throw b}),K.tap(()=>{l&&(y=0)}))})}function $e(s){return s!=null}function De(s){return Object.prototype.toString.call(s)==="[object Object]"}function Ce(s){if(!De(s))return!1;const e=s.constructor;if(typeof e>"u")return!0;const t=e.prototype;return!(!De(t)||!t.hasOwnProperty("isPrototypeOf"))}const ee=s=>JSON.stringify(s,(e,t)=>Ce(t)?Object.keys(t).sort().reduce((n,i)=>(n[i]=t[i],n),{}):t),Re=(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),""),z=()=>({context:void 0,data:void 0,error:null,status:"idle",submittedAt:0,variables:void 0,failureCount:0,failureReason:null,isPaused:!1});function F(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}function Fe(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 re=s=>s.pipe(r.takeWhile(e=>e.status!=="error"&&e.status!=="success",!0));var q;class Et{constructor({__queryFinalizeHook:e}={}){w(this,q,new r.Subject);g(this,"state$");const t=new r.BehaviorSubject(0),n=t.pipe(r.filter(i=>i===0));this.state$=c(this,q).pipe(r.concatMap(({args:i,mutation:u,options:a})=>{const h=a.mapOperator??"merge",d=c(this,q).pipe(r.filter(()=>h==="merge")),f=c(this,q).pipe(r.filter(()=>h==="switch"),r.tap(()=>{u.cancel()})),l=r.defer(()=>(u.execute(i),r.EMPTY)),p=u.state$.pipe(re,r.last(),r.mergeMap(()=>u.state$),r.takeUntil(c(this,q))),o=u.state$.pipe(re,r.skip(1)),y=r.merge(n,d,f,u.cancelled$);return r.merge(o,p,l).pipe(e??r.identity,r.takeUntil(y))}),r.scan((i,u)=>({...i,...u,...u.status==="pending"&&{data:u.data??i.data},...u.status==="pending"&&{error:u.error??i.error}}),z()),r.distinctUntilChanged(({data:i,...u},{data:a,...h})=>F(u,h)&&F(i,a)),r.shareReplay({refCount:!0,bufferSize:1}),Fe(i=>{t.next(i)}))}trigger({args:e,options:t,mutation:n}){c(this,q).next({args:e,options:t,mutation:n})}}q=new WeakMap;function we(s,e){return s===e?!0:typeof s!=typeof e?!1:s&&e&&typeof s=="object"&&typeof e=="object"?!Object.keys(e).some(t=>!we(s[t],e[t])):!1}const ge=(s,e,{exact:t=!1}={})=>t?ee(s)===ee(e):we(s,e);var B,I;class Mt{constructor(e,t={},n){w(this,B,void 0);w(this,I,new r.BehaviorSubject(void 0));g(this,"observed$");g(this,"getObserverResultFromState",e=>({...z(),...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)??[Re()],M(this,B,n??new Et(this.options)),this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this),c(this,I).pipe(r.filter($e),r.mergeMap(u=>c(this,B).state$.pipe(r.takeUntil(u.mutation.state$.pipe(re,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&&!ge(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)??z()),t=c(this,B).state$.pipe(r.map(a=>this.getObserverResultFromState(a))),n=c(this,I).pipe(r.filter($e),r.switchMap(a=>a.mutation.cancelled$),r.map(()=>this.getObserverResultFromState(z())));return{result$:r.merge(this.observed$,t,n),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,B).trigger({args:e,options:this.options,mutation:n}),await new Promise((i,u)=>{n.state$.pipe(re,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)??z())}reset(){const{mutation:e}=c(this,I).getValue()??{};c(this,I).next(void 0),e==null||e.cancel()}}B=new WeakMap,I=new WeakMap;const Ge=S.createContext(void 0),jt=({client:s})=>(S.useEffect(()=>(s.mount(),()=>{s.unmount()}),[s]),null),Rt=S.memo(({children:s,client:e})=>{const t=S.useMemo(()=>e,[e]);return ke.jsxs(Ge.Provider,{value:t,children:[ke.jsx(jt,{client:e}),s]})}),Je=s=>{const e=S.useContext(Ge);if(s)return s;if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e};function Ft(){}function Ut(s,e){const t=Je(e),n=A(s),i=Oe(()=>[Re()]),u=ee(s.mutationKey??i.current),[a]=S.useState(()=>new Mt(t,s));S.useEffect(()=>{a.setOptions(s)},[a,s]);const h=S.useMemo(()=>a.observe(),[u,a]),d=he(h.result$)??h.lastValue,f=S.useCallback((l,p)=>{a.mutate(l,p).catch(Ft)},[a]);return S.useEffect(()=>()=>{n.current.cancelOnUnMount&&a.reset()},[a,n]),{...d,mutate:f,mutateAsync:d.mutate}}function xt(s){return e=>e.pipe(K.tap(t=>{s.next(t)}))}class At{constructor(){g(this,"isOnlineSubject",new r.BehaviorSubject(!0));g(this,"online$",this.isOnlineSubject.pipe(r.distinctUntilChanged()));g(this,"backToOnline$",this.online$.pipe(r.filter(e=>e),r.first()));r.merge(r.fromEvent(window,"offline").pipe(r.map(()=>!1)),r.fromEvent(window,"online").pipe(r.map(()=>!0))).pipe(xt(this.isOnlineSubject)).subscribe()}isOnline(){return this.isOnlineSubject.getValue()}setOnline(e){this.isOnlineSubject.getValue()!==e&&this.isOnlineSubject.next(e)}}const _=new At;function Ue(s,e){return s.isStaleByTime(e.staleTime)}function Qt(s,e){return e.enabled!==!1&&!s.state.dataUpdatedAt&&!(s.state.status==="error"&&e.retryOnMount===!1)&&s.state.fetchStatus!=="fetching"}function Te(s,e){return Qt(s,e)||s.state.dataUpdatedAt>0&&Xe(s,e,e.refetchOnMount)}function Ke(s,e,t,n){return s.state.fetchStatus!=="fetching"&&t.enabled!==!1&&(s!==e||n.enabled===!1)&&(!t.suspense||s.state.status!=="error")&&Ue(s,t)}function Pt(s,e){return Xe(s,e,e.refetchOnWindowFocus)}function Xe(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&&Ue(s,e)}return!1}function kt(s){return(s??"online")==="online"?_.isOnline():!0}function Ne(s,e){return e.reduce((t,n)=>n in s?{...t,[n]:s[n]}:t,{})}function We(s){return Array.isArray(s)&&s.length===Object.keys(s).length}function Ze(s,e){if(s===e)return s;const t=We(s)&&We(e);if(t||Ce(s)&&Ce(e)){const n=t?s:Object.keys(s),i=n.length,u=t?e:Object.keys(e),a=u.length,h=t?[]:{};let d=0;for(let f=0;f<a;f++){const l=t?f:u[f];!t&&s[l]===void 0&&e[l]===void 0&&n.includes(l)?(h[l]=void 0,d++):(h[l]=Ze(s[l],e[l]),h[l]===s[l]&&s[l]!==void 0&&d++)}return i===a&&d===i?s:h}return e}function xe(s,e){return((e==null?void 0:e.queryKeyHashFn)??ee)(s)}function qe(s,e){const{type:t="all",exact:n,fetchStatus:i,predicate:u,queryKey:a,stale:h}=s;if(a){if(n){if(e.queryHash!==xe(a,e.options))return!1}else if(!we(e.queryKey,a))return!1}if(t!=="all"){const d=e.isActive();if(t==="active"&&!d||t==="inactive"&&d)return!1}return!(typeof h=="boolean"&&e.isStale()!==h||typeof i<"u"&&i!==e.state.fetchStatus||u&&!u(e))}function Vt(s,e){return Math.max(s+(e??0)-Date.now(),0)}function It(s,e){return typeof s=="function"?s(e):s}function ye(s,e,t){return typeof t.structuralSharing=="function"?t.structuralSharing(s,e):t.structuralSharing!==!1?Ze(s,e):e}const Dt=({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 h=a.data,d=h!==void 0&&h!==i.data,f="data"in a,l=a.status==="success",p=i.data!==void 0,o=i.error!==void 0||i.error!==null,y=a.status??i.status,$=d?ye(e().data,h,s()):f?a.data:i.data,b=i.status==="error"||i.status==="success",v=a.status==="error"&&(i.status==="error"&&i.fetchStatus==="fetching"||i.status!=="error")?i.errorUpdateCount+1:i.errorUpdateCount,O=d?i.dataUpdateCount+1:a.dataUpdateCount??i.dataUpdateCount,k=a.status==="pending"&&b&&(p||o),U=y==="pending"?null:a.error??i.error;return{...i,...a,status:y,error:U,errorUpdateCount:v,...l&&{isInvalidated:!1},data:$,dataUpdateCount:O,...k&&{status:i.status}}},t)),Tt=s=>s.pipe(r.map(({status:e,fetchStatus:t})=>t==="idle"&&(e==="success"||e==="error"))),et=s=>s.pipe(r.takeWhile(e=>e.fetchStatus!=="idle",!0));var Se,H;class Kt{constructor(){w(this,Se,r.merge(r.fromEvent(document,"visibilitychange"),r.fromEvent(window,"visibilitychange")).pipe(r.map(()=>document.visibilityState)));w(this,H,new r.BehaviorSubject(document.visibilityState==="visible"));g(this,"focused$",c(this,H));g(this,"focusRegained$",this.focused$.pipe(r.skip(1),r.filter(e=>e)));c(this,Se).pipe(r.tap(e=>{c(this,H).next(e==="visible")})).subscribe()}isFocused(){return c(this,H).getValue()}setFocused(e){c(this,H).getValue()!==(e??!0)&&c(this,H).next(e??!0)}subscribe(e){const t=this.focused$.subscribe(e);return()=>{t.unsubscribe()}}refresh(){document.dispatchEvent(new Event("visibilitychange"))}}Se=new WeakMap,H=new WeakMap;const me=new Kt,Nt=s=>s.pipe(r.filter(e=>e.status==="success"),r.map(e=>({data:e.data,status:e.status,dataUpdatedAt:e.dataUpdatedAt})),r.distinctUntilChanged(F));var W,C,se,Y,x,X,ne;class tt{constructor(e,t){w(this,W,void 0);w(this,C,void 0);w(this,se,new r.Subject);g(this,"queryUpdateSubject",new r.Subject);w(this,Y,void 0);w(this,x,void 0);w(this,X,void 0);w(this,ne,0);g(this,"getObserverResultFromQuery",({options:e,query:t,optimisticResult:n,prevResult:{result:i,options:u,state:a,select:h,selectError:d,selectResult:f}})=>{var be;const l=t.state,p=t.state.status==="pending",o=c(this,C),y=this.options,b=t!==o?t.state:c(this,Y);let{errorUpdatedAt:v,fetchStatus:O,error:k}=l;if(n){const Q=!!c(this,ne),Qe=!Q&&Te(t,e),ot=Q&&Ke(t,o,e,y);(Qe||ot)&&(O=kt(t.options.networkMode)?"fetching":"paused")}const U=p&&O==="fetching";let E,m=d,D=h??null,T=f;if(e.select&&typeof l.data<"u")if(i&&l.data===(a==null?void 0:a.data)&&e.select===h)E=f;else try{D=e.select,E=e.select(l.data),E=ye(i==null?void 0:i.data,E,e),T=E,m=null}catch(Q){E=f,m=Q}else E=l.data,m=null;let V=O!=="idle"&&!l.dataUpdatedAt?"pending":l.status;m&&(k=m,E=f,v=(i==null?void 0:i.errorUpdatedAt)??v,V="error");const fe=V==="error";let de=!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((be=c(this,X))==null?void 0:be.state.data,c(this,X)):e.placeholderData,e.select&&typeof Q<"u")try{Q=e.select(Q)}catch{}typeof Q<"u"&&(V="success",E=ye(i==null?void 0:i.data,Q,e),de=!0)}const pe=O==="fetching";return{result:{status:V,fetchStatus:O,isPending:p,isSuccess:V==="success",isError:fe,isInitialLoading:U,isLoading:U,data:E,dataUpdatedAt:l.dataUpdatedAt,error:k,errorUpdatedAt:v,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:l.dataUpdateCount>0||l.errorUpdateCount>0,isFetchedAfterMount:l.dataUpdateCount>b.dataUpdateCount||l.errorUpdateCount>b.errorUpdateCount,isFetching:pe,isRefetching:pe&&!p,isLoadingError:fe&&l.dataUpdatedAt===0,isPaused:O==="paused",isPlaceholderData:de,isRefetchError:fe&&l.dataUpdatedAt!==0,isStale:Ue(t,e),refetch:this.refetch},selectError:m,select:D,selectResult:T}});this.options=t,M(this,W,e),this.bindMethods(),M(this,C,this.setOptions(t));const n=c(this,C);M(this,Y,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,W).defaultQueryOptions(e),F(this.options,t)||c(this,W).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,Y,n.state),M(this,C,n)),this.queryUpdateSubject.next({options:this.options,query:n}),n}buildQuery(e){const t=c(this,W).getQueryCache().build(c(this,W),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 Wt(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,X,e),c(this,W).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,Y,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,se).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:h},{options:d,query:f}])=>{Ke(f,h,d,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 h=this.options,d=this.queryUpdateSubject.pipe(r.startWith({query:a,options:h}),r.filter(m=>m.query===a),r.map(m=>m.options),r.distinctUntilChanged(),r.shareReplay(1)),f=c(this,se).pipe(r.filter(m=>m.query===a)),l=a.state$.pipe(Nt,r.switchMap(m=>this.options.staleTime===1/0?r.NEVER:(this.options.staleTime??0)<=0?r.of(m).pipe(r.delay(1)):r.timer(this.options.staleTime??1)),r.takeWhile(()=>this.options.enabled??!0)),p=(m,D)=>{const T=h.notifyOnChangeProps,V=typeof T=="function"?T():T;return(Array.isArray(V)?V.length===0?()=>!0:(de,pe)=>{const Ae=Ne(de,V),be=Ne(pe,V);return F(Ae,be)}:F)(m,D)},o=f.pipe(r.switchMap(()=>a.state$),et),y=d.pipe(r.map(({refetchInterval:m,refetchIntervalInBackground:D})=>({refetchInterval:(typeof m=="function"?m(c(this,C)):m)??!1,refetchIntervalInBackground:D})),r.distinctUntilChanged(F),r.switchMap(({refetchInterval:m,refetchIntervalInBackground:D})=>m?r.interval(m).pipe(r.tap(()=>{(D||me.isFocused())&&this.fetch({cancelRefetch:!1}).catch(r.noop)})):r.NEVER),r.ignoreElements()),$=d.pipe(r.map(({enabled:m})=>m??!0),r.distinctUntilChanged()),b=$.pipe(r.filter(m=>!m),r.map(()=>a.state)),v=$.pipe(r.filter(m=>m),r.switchMap(()=>me.focusRegained$),r.withLatestFrom(d),r.tap(([,m])=>{Pt(a,m)&&this.fetch({cancelRefetch:!1}).catch(r.noop)}),r.ignoreElements()),O=b.pipe(r.map(()=>a.state)),k=m=>m.pipe(r.withLatestFrom(d),r.map(([,D])=>{const T=this.getObserverResultFromQuery({query:a,options:D,prevResult:c(this,x)});return this.updateResult({query:a,...T}),T.result})),E=r.merge(O,o,a.state$,l).pipe(k,r.distinctUntilChanged(F),r.distinctUntilChanged(p));return r.merge(y,v,E)})).pipe(Fe(a=>M(this,ne,a)),r.tap({subscribe:()=>{Te(e,this.options)&&this.fetch().catch(r.noop)}})))}destroy(){}}W=new WeakMap,C=new WeakMap,se=new WeakMap,Y=new WeakMap,x=new WeakMap,X=new WeakMap,ne=new WeakMap;function Wt(s,e){return!F(s.getCurrentResult(),e)}const rt=ve.createContext(!1),qt=()=>ve.useContext(rt);rt.Provider;function Ht(){let s=!1;return{clearReset:()=>{s=!1},reset:()=>{s=!0},isReset:()=>s}}const Lt=ve.createContext(Ht()),_t=()=>ve.useContext(Lt);function zt(s,e){return typeof s=="function"?s(...e):!!s}const Bt=({result:s,errorResetBoundary:e,throwOnError:t,query:n})=>s.isError&&!e.isReset()&&!s.isFetching&&n&&zt(t,[s.error,n]);function st(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=Je(t),i=qt(),u=_t(),a=n.defaultQueryOptions(s);a._optimisticResults=i?"isRestoring":"optimistic";const[h]=S.useState(()=>new e(n,a)),d=Oe(()=>h.observe()),f=A(h.getOptimisticResult(a)),l=f.current;he(()=>d.current.pipe(r.filter(o=>!F(o,f.current))),[]),S.useEffect(()=>{h.setOptions(a)},[a,h]);const p=l.error;if(p&&Bt({result:l,errorResetBoundary:u,throwOnError:a.throwOnError,query:n.getQueryCache().get(a.queryHash)}))throw p;return f.current}function Yt(s,e){return st(s,tt,e)}function Gt(s,e){return st({refetchOnMount:"idle",refetchOnReconnect:!1,refetchInterval:!1,refetchOnWindowFocus:!1,...s},tt,e)}function Jt(s,e,t=[]){const n=e!=null&&!Array.isArray(e)?e:{},i=n.retry??!0,u=A(n.onError??(d=>{console.error(d)})),a=S.useCallback(()=>R(s),t),h=S.useCallback(()=>a().pipe(r.catchError(d=>{throw u.current(d),d}),i?r.retry():r.identity),[a,i,u]);Ee(h,t)}const nt=()=>s=>r.merge(r.of({isPaused:!0}),_.backToOnline$.pipe(r.mergeMap(()=>r.merge(r.of({isPaused:!1}),s)))),Xt=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(nt())))):r.throwError(()=>t))))},Zt=({variables:s,state:e,options:t})=>{const n=e.isPaused,i=async()=>await Promise.reject(new Error("No mutationFn found")),u=t.mutationFn??i,h=r.iif(()=>n,r.of(e.context),R(()=>{var o;return((o=t.onMutate)==null?void 0:o.call(t,s))??void 0})).pipe(r.shareReplay(1)),d=(o,y,$)=>R(()=>{var v;return(v=t.onError)==null?void 0:v.call(t,o,s,y)}).pipe(r.catchError(()=>r.of(o)),r.map(()=>({failureCount:$,error:o,failureReason:o,context:y,status:"error"}))),f=h.pipe(r.switchMap(o=>{const $=(typeof u=="function"?R(()=>u(s)):u).pipe(r.map(b=>({result:{data:b},error:null,context:o})),Xt,je({...t,retry:(b,v)=>{const O=t.retry??0;return typeof O=="function"?O(b,v):typeof O=="boolean"?O:b<O},caughtError:(b,v)=>r.of({failureCount:b,failureReason:v}),catchError:(b,v)=>d(v,o,b).pipe(r.map(O=>({...O,result:void 0})))}),r.takeWhile(({result:b,error:v})=>(b==null?void 0:b.data)===void 0&&v===void 0,!0));return _.isOnline()||t.networkMode==="offlineFirst"?$:$.pipe(nt())})),l=r.of({...e,variables:s,status:"pending",isPaused:!1,failureCount:0,failureReason:null,submittedAt:e.submittedAt??new Date().getTime()});return r.merge(l,h.pipe(r.map(o=>({context:o}))),f.pipe(r.switchMap(({result:o,error:y,...$})=>{if(!o&&!y)return r.of({...$});const b=y?r.of(null):R(()=>{var U;return(U=t.onSuccess)==null?void 0:U.call(t,o==null?void 0:o.data,s,$.context)}),O=R(()=>{var U;return(U=t.onSettled)==null?void 0:U.call(t,o==null?void 0:o.data,y,s,$.context)}).pipe(r.catchError(U=>o?r.of(o):r.of(U)));return r.concat(b,O).pipe(r.toArray(),r.map(()=>y?{error:y,data:void 0,variables:s,...$}:{status:"success",error:y,data:o==null?void 0:o.data,variables:s,failureCount:0,failureReason:null,...$}),r.catchError(U=>d(U,$.context,0).pipe(r.map(E=>({...E,data:void 0})))))}))).pipe(r.scan((o,y)=>({...o,...y,data:y.data??o.data,error:y.error??o.error}),z()),r.distinctUntilChanged(({data:o,...y},{data:$,...b})=>F(y,b)&&F(o,$)))};var ie,L,Z;class er{constructor({options:e,mutationCache:t,state:n}){w(this,ie,new r.BehaviorSubject(0));w(this,L,new r.Subject);w(this,Z,new r.Subject);g(this,"state",z());g(this,"state$");g(this,"options");g(this,"observerCount$",c(this,ie).asObservable());g(this,"cancelled$",c(this,L).asObservable());this.options=e,this.state=n??this.state;const i=c(this,Z).pipe(r.switchMap(u=>Zt({options:{...this.options,onMutate:a=>{const h=R(()=>{var p,o;return(o=(p=t.config).onMutate)==null?void 0:o.call(p,a,this)}),f=R(()=>{var p,o;return(o=(p=this.options).onMutate)==null?void 0:o.call(p,a)});return h.pipe(r.mergeMap(()=>f))},onError:(a,h,d)=>{const f=R(()=>{var p,o;return(o=(p=t.config).onError)==null?void 0:o.call(p,a,h,d,this)}),l=R(()=>{var p,o;return(o=(p=this.options).onError)==null?void 0:o.call(p,a,h,d)});return r.concat(f,l).pipe(r.toArray())},onSettled:(a,h,d,f)=>{const l=R(()=>{var o,y;return(y=(o=t.config).onSettled)==null?void 0:y.call(o,a,h,d,f,this)}),p=R(()=>{var o,y;return(y=(o=this.options).onSettled)==null?void 0:y.call(o,a,h,d,f)});return r.concat(l,p).pipe(r.toArray())},onSuccess:(a,h,d)=>{const f=R(()=>{var p,o;return(o=(p=t.config).onSuccess)==null?void 0:o.call(p,a,h,d,this)}),l=R(()=>{var p,o;return(o=(p=this.options).onSuccess)==null?void 0:o.call(p,a,h,d)});return r.concat(f,l).pipe(r.toArray())}},state:this.state,variables:u}).pipe(r.takeUntil(c(this,L)))));this.state$=r.merge(i,r.NEVER).pipe(r.startWith(this.state),r.tap(u=>{this.state={...this.state,...u}}),r.takeUntil(c(this,L)),r.shareReplay({bufferSize:1,refCount:!1}),Fe(u=>{c(this,ie).next(u)}))}get meta(){return this.options.meta}setOptions(e){this.options={...this.options,...e}}execute(e){return c(this,Z).next(e),c(this,Z).complete(),this.state$.pipe(re)}continue(){return this.execute(this.state.variables)}cancel(){c(this,L).next(),c(this,L).complete()}}ie=new WeakMap,L=new WeakMap,Z=new WeakMap;const He=({mutationKey:s,status:e,predicate:t,exact:n=!0}={})=>u=>n&&s!==void 0&&u.options.mutationKey!==void 0&&!ge(u.options.mutationKey,s,{exact:n})||!n&&s!==void 0&&u.options.mutationKey!==void 0&&!ge(u.options.mutationKey,s,{exact:n})||e&&u.state.status!==e?!1:t?t(u):!0;class it{constructor(){g(this,"entriesSubject",new r.BehaviorSubject([]));g(this,"changeSubject",new r.Subject);g(this,"entries$",this.entriesSubject.pipe(r.share()));g(this,"added$",this.changeSubject.pipe(r.filter(({type:e})=>e==="added"),r.map(({entity:e})=>e),r.share()));g(this,"removed$",this.changeSubject.pipe(r.filter(({type:e})=>e==="removed"),r.map(({entity:e})=>e),r.share()));g(this,"stateChange$",r.merge(this.entriesSubject.pipe(r.first(),r.mergeMap(e=>r.from(e))),this.added$).pipe(r.mergeMap(e=>e.state$.pipe(r.map(()=>e),r.takeUntil(this.removed$.pipe(r.filter(t=>t===e))))),r.share()))}getValues(){return this.entriesSubject.getValue()}remove(e){this.entriesSubject.next(this.entriesSubject.getValue().filter(t=>e!==t)),this.changeSubject.next({type:"removed",entity:e})}add(e){this.entriesSubject.next([...this.entriesSubject.getValue(),e]),this.changeSubject.next({type:"added",entity:e})}find(e){return this.entriesSubject.getValue().find(e)}}var P;class at{constructor(e={}){w(this,P,new it);this.config=e}build(e,t,n){const i=new er({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=He(t);return c(this,P).getValues().find(i=>n(i))}findAll(e={}){const t={exact:!0,...e},n=He(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;const tr=typeof window>"u"||"Deno"in window;function rr(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 sr=s=>r.defer(()=>me.isFocused()?s:me.focusRegained$.pipe(r.mergeMap(()=>s))),nr=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))}},ir=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))},ar=s=>{const e=async()=>await Promise.reject(new Error("No query found"));let t=!1;const n=s.queryFn??e,i=new AbortController,u={meta:s.meta,queryKey:s.queryKey};(l=>{Object.defineProperty(l,"signal",{enumerable:!0,get:()=>(s.onSignalConsumed(),i.signal)})})(u);const d=(typeof n=="function"?R(()=>n(u)):n).pipe(ir(s.observers$),r.tap({complete:()=>{t=!0}}),r.map(l=>({data:l})),nr(s),je({...s,retryAfter:()=>r.of(!0).pipe(sr),catchError:(l,p)=>r.of({status:"error",fetchStatus:"idle",fetchFailureCount:l,fetchFailureReason:p,error:p}),caughtError:(l,p)=>r.of({fetchFailureCount:l,fetchFailureReason:p})}),r.mergeMap(l=>"data"in l?r.of({...l,status:"success",fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null,dataUpdatedAt:new Date().getTime()}).pipe(r.delay(1),r.map(p=>t?p:{...p,fetchStatus:"fetching"})):r.of(l)),r.endWith({fetchStatus:"idle"}),r.share()),f=r.of({status:"pending",fetchStatus:_.isOnline()?"fetching":"paused"});return{state$:r.merge(f,d).pipe(r.share()),abortController:i}};class ur{constructor(e){g(this,"revert");g(this,"silent");this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}}const cr={backgroundColor:"transparent",color:"inherit"};function ut(s){const e={namespaces:[{name:"@reactjrx",style:{backgroundColor:"#d02f4e",color:"white"}}],namespace(t,n){const i=ut(s);return i.namespaces.push({name:t,style:n??cr}),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){if(s==="development"){const{namespaces:i,styles:u}=e.printNamespaces();console[t](i,...u,...n)}return e},printWithoutNamespace(t,...n){return s==="development"&&console[t](...n),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 s==="development"&&console.groupEnd(),e}};return e}const or=ut("production");var ae,G;class lr{constructor(e){g(this,"queryKey");g(this,"queryHash");g(this,"gcTime");g(this,"options");w(this,ae,void 0);w(this,G,void 0);g(this,"state");g(this,"executeSubject",new r.Subject);g(this,"cancelSubject",new r.Subject);g(this,"setDataSubject",new r.Subject);g(this,"invalidatedSubject",new r.Subject);g(this,"resetSubject",new r.Subject);g(this,"destroySubject",new r.Subject);g(this,"observersSubject",new r.BehaviorSubject([]));g(this,"abortSignalConsumed",!1);g(this,"observerCount$",this.observersSubject.asObservable().pipe(r.map(e=>e.length)));g(this,"observers$",this.observersSubject.asObservable());g(this,"state$");M(this,ae,e.defaultOptions),this.options=this.setOptions(e.options),this.queryKey=e.queryKey,this.queryHash=e.queryHash,M(this,G,e.state??rr(this.options)),this.state=c(this,G),this.gcTime=this.updateGcTime(this.options.gcTime),this.state$=r.merge(this.resetSubject.pipe(r.map(()=>({command:"reset",state:c(this,G)}))),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 ur(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,l])=>{l.length===0&&f.length>0?t=!0:t=!1}),r.ignoreElements()),{state$:u,abortController:a}=ar({...this.options,observers$:this.observerCount$,queryKey:this.queryKey,retry:(f,l)=>{const p=this.options.retry??!0;return typeof p=="function"?p(f,l):typeof p=="boolean"?p:f<p},retryAfterDelay:()=>!t,onSignalConsumed:()=>{this.abortSignalConsumed=!0}}),h=this.observerCount$.pipe(r.filter(f=>f===0&&this.abortSignalConsumed),r.tap(()=>{this.cancelSubject.next({revert:!0})})),d=r.merge(this.cancelSubject,n,this.resetSubject,h).pipe(r.tap(()=>{this.abortSignalConsumed&&a.abort()}));return r.merge(u,i).pipe(r.map(f=>({command:"execute",state:f})),r.takeUntil(d))})),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(Dt({initialState:this.state,getOptions:()=>this.options,getState:()=>this.state}),r.startWith(c(this,G)),r.distinctUntilChanged(F),r.tap(t=>{this.state=t}),r.catchError(t=>{throw or.error(t),t}),r.takeUntil(this.destroySubject),r.shareReplay({bufferSize:1,refCount:!1}))}setOptions(e){return this.options={...c(this,ae),...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(F),r.filter(({status:e})=>e==="success"))}get error$(){return this.state$.pipe(r.map(({error:e,status:t})=>({error:e,status:t})),r.distinctUntilChanged(F),r.filter(({status:e})=>e==="error"))}get settled$(){return this.state$.pipe(r.map(({status:e})=>({status:e})),r.distinctUntilChanged(F),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??(tr?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||!Vt(this.state.dataUpdatedAt,e)}async getFetchResultAsPromise(){return await new Promise((e,t)=>{this.state$.pipe(et,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=ye(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()}}ae=new WeakMap,G=new WeakMap;var ue,N;class ct{constructor(e={}){w(this,ue,new r.Subject);w(this,N,new it);this.config=e}mount(){}unmount(){}notify(e){c(this,ue).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=>qe(e,n)):t}build(e,t,n){const i=t.queryKey??[Re()],u=t.queryHash??xe(i,t);let a=this.get(u);return a||(a=new lr({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(Tt,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=>qe(t,n))}subscribe(e){const t=r.merge(c(this,ue).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(){}}ue=new WeakMap,N=new WeakMap;var J,j,ce,oe,le;class hr{constructor({mutationCache:e,queryCache:t,defaultOptions:n}={}){w(this,J,void 0);w(this,j,void 0);w(this,ce,new Map);w(this,oe,new Map);w(this,le,void 0);M(this,J,e??new at),M(this,j,t??new ct),M(this,le,n??{})}mount(){}unmount(){}getMutationCache(){return c(this,J)}getQueryCache(){return c(this,j)}defaultMutationOptions(e){return{...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e}}defaultQueryOptions(e){if(e!=null&&e._defaulted)return e;const t={...c(this,le).queries,...(e==null?void 0:e.queryKey)&&this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=xe(t.queryKey,t)),typeof t.refetchOnReconnect>"u"&&(t.refetchOnReconnect=t.networkMode!=="always"),typeof t.throwOnError>"u"&&(t.throwOnError=!!t.suspense),typeof t.networkMode>"u"&&t.persister&&(t.networkMode="offlineFirst"),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=c(this,j).find({queryKey:e}),u=i==null?void 0:i.state.data,a=It(t,u);if(typeof a>"u")return;const h=this.defaultQueryOptions({queryKey:e});return c(this,j).build(this,h).setData(a,{...n,manual:!0})}getMutationDefaults(e){const t=[...c(this,ce).values()];let n={};return t.forEach(i=>{ge(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,ce).set(ee(e),{mutationKey:e,defaultOptions:t})}setQueryDefaults(e,t){c(this,oe).set(ee(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...c(this,oe).values()];let n={};return t.forEach(i=>{we(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,J).resumePausedMutations())}isFetching(e){return c(this,j).findAll({...e,fetchStatus:"fetching"}).length}clear(){c(this,j).clear(),c(this,J).clear()}}J=new WeakMap,j=new WeakMap,ce=new WeakMap,oe=new WeakMap,le=new WeakMap;exports.MutationCache=at;exports.QueryCache=ct;exports.QueryClient=hr;exports.QueryClientProvider=Rt;exports.SIGNAL_RESET=_e;exports.createLocalStorageAdapter=ze;exports.createLocalforageAdapter=St;exports.createSharedStoreAdapter=mt;exports.exponentialBackoffDelay=Ye;exports.getDelay=Be;exports.isDefined=$e;exports.retryBackoff=je;exports.signal=gt;exports.useBehaviorSubject=Le;exports.useForeverQuery=Gt;exports.useLiveRef=A;exports.useMutation=Ut;exports.useObservableState=bt;exports.useObserve=he;exports.useObserveCallback=pt;exports.usePersistSignals=$t;exports.useQuery=Yt;exports.useSignalValue=yt;exports.useSubject=Me;exports.useSubscribe=Ee;exports.useSubscribeEffect=Jt;exports.useUnmountObservable=Ct;
|
|
1
|
+
"use strict";var lt=Object.defineProperty;var ht=(s,e,t)=>e in s?lt(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var g=(s,e,t)=>(ht(s,typeof e!="symbol"?e+"":e,t),t),Pe=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)};var c=(s,e,t)=>(Pe(s,e,"read from private field"),t?t.call(s):e.get(s)),w=(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)=>(Pe(s,e,"write to private field"),n?n.call(s,t):e.set(s,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("react"),r=require("rxjs"),K=require("rxjs/operators"),ke=require("react/jsx-runtime");function ft(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 ve=ft(S),A=s=>{const e=S.useRef(s);return S.useMemo(()=>{e.current=s},[s]),e};function dt(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 he(s,e,t){const n=e!=null&&!Array.isArray(e)?e:{defaultValue:void 0,key:"",unsubscribeOnUnmount:!0},i=t==null&&Array.isArray(e)?e:typeof s=="function"?t??[]:[s],u=S.useRef("getValue"in s&&typeof s.getValue=="function"?s.getValue():n.defaultValue),a=A(s),h=A(n),d=S.useCallback(p=>{const o=a.current,$=(typeof o=="function"?o:()=>o)().pipe(r.distinctUntilChanged(dt),r.tap(b=>{u.current=b}),r.finalize(p),r.catchError(b=>(console.error(b),u.current=void 0,r.EMPTY))).subscribe(p);return()=>{h.current.unsubscribeOnUnmount!==!1&&$.unsubscribe()}},[...i]),f=S.useCallback(()=>u.current,[]);return S.useSyncExternalStore(d,f,f)}function Ve(s){return s instanceof Promise||s&&typeof s.then=="function"&&typeof s.catch=="function"}function R(s){if(r.isObservable(s))return s;if(Ve(s))return r.from(s);if(typeof s!="function")return r.of(s);const e=s;return r.defer(()=>{const t=e();return Ve(t)?r.from(t):r.isObservable(t)?t:r.of(t)})}function Ee(s,e=[]){const t=A(s);S.useEffect(()=>{const n=R(t.current).subscribe();return()=>{n.unsubscribe()}},[...e,t])}const Oe=s=>{const e=S.useRef();return e.current||(e.current=s()),S.useEffect(()=>{process.env.NODE_ENV},[]),e},Me=({onBeforeComplete:s,completeOnUnmount:e=!0}={})=>{const t=Oe(()=>new r.Subject),n=S.useRef(!1),i=A(s),u=A(e);return S.useEffect(()=>(n.current&&(t.current=new r.Subject,n.current=!1),()=>{if(!u.current){n.current=!0;return}n.current||(i.current!=null&&i.current(),t.current.complete(),n.current=!0)}),[u,i,t]),t},pt=()=>{const s=Me(),e=A(s.current.asObservable()),t=S.useCallback(n=>{s.current.next(n)},[]);return[e.current,t]},Le=s=>{const e=Oe(()=>new r.BehaviorSubject(s)),t=S.useRef(!1),n=S.useRef(s);return S.useEffect(()=>(t.current&&(e.current=new r.BehaviorSubject(n.current),t.current=!1),()=>{t.current||(e.current.complete(),t.current=!0)}),[e]),e},bt=s=>{const e=Le(s),t=A(e.current.asObservable()),n=S.useCallback(i=>{e.current.next(i)},[e.current]);return[t.current,n,e.current.getValue()]},_e=Symbol("SIGNAL_RESET");function gt(s){const{default:e}=s??{},t=new r.BehaviorSubject(e);return{setValue:u=>{if(typeof u=="function"){const a=u(t.getValue());if(a===t.getValue())return;t.next(a);return}if(u===_e){t.next(e??void 0);return}t.next(u)},getValue:()=>t.getValue(),config:s,subject:t}}function yt(s,e){const t=e??(n=>n);return he(()=>s.subject.pipe(r.map(n=>t(n)),r.distinctUntilChanged()),{defaultValue:t(s.getValue())},[])}const Ie=s=>{if(!(!s||typeof s!="object"))return s},mt=({adapter:s,key:e})=>({getItem:async t=>{const n=await s.getItem(e),i=Ie(n)??{};if(t in i)return i[t]},setItem:async(t,n)=>{const i=await s.getItem(e),u=Ie(i)??{};await s.setItem(e,{...u,[t]:n})}}),St=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))}}),ze=()=>({getItem:async s=>{const e=localStorage.getItem(s);if(e)return JSON.parse(e)},setItem:async(s,e)=>{localStorage.setItem(s,JSON.stringify(e))}}),re="__reactjrx",vt=s=>{if(typeof s=="object"&&s!==null&&re in s&&s[re]===re)return s},Ot=async({adapter:s,signal:e,version:t})=>{const i={value:e.getValue(),[re]:re,migrationVersion:t};await s.setItem(e.config.key,i)},wt=({adapter:s,version:e,signal:t})=>r.from(s.getItem(t.config.key)).pipe(r.switchMap(n=>{const i=vt(n);return!i||i.migrationVersion!==void 0&&e>i.migrationVersion||t.setValue(i.value),r.of(n)})),$t=({entries:s=[],onReady:e,adapter:t=ze()})=>{const n=A(s),i=A(e),u=A(t),a=he(()=>{const h=n.current;return(h.length===0?r.of(!0):r.zip(...h.map(({signal:f,version:l})=>wt({adapter:u.current,signal:f,version:l}))).pipe(r.map(()=>!0))).pipe(r.tap(()=>{i.current!=null&&i.current()}),r.catchError(f=>(console.error("Unable to hydrate",f),r.EMPTY)))},{defaultValue:!1},[]);return Ee(()=>a?r.merge(...n.current.map(({signal:h,version:d})=>h.subject.pipe(r.throttleTime(500,r.asyncScheduler,{trailing:!0}),r.switchMap(()=>r.from(Ot({adapter:u.current,signal:h,version:d})))))):r.EMPTY,[a,u]),{isHydrated:a}},Ct=()=>{const s=Me({onBeforeComplete:()=>{s.current.next()}});return s};function Be(s,e){return Math.min(s,e)}function Ye(s,e){return Math.pow(2,s)*e}function je(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,h=typeof t=="number"?t:100,d={shouldRetry:a,...s},{maxInterval:f=1/0,resetOnSuccess:l=!1,backoffDelay:p=Ye}=d;return o=>r.defer(()=>{let y=0;const $=(b,v)=>b<u?a(b,v):!1;return o.pipe(K.catchError(b=>{var O;if(y++,!$(y-1,b))throw b;const v=(O=s.caughtError)==null?void 0:O.call(s,y,b);if(!v)throw b;return v.pipe(K.mergeMap(k=>r.merge(r.of(k),r.throwError(()=>b))))}),K.retryWhen(b=>b.pipe(K.concatMap(v=>{const O=y-1;return i().pipe(K.first(),K.mergeMap(()=>$(O,v)?r.timer(Be(p(O,h),f)).pipe(K.mergeMap(k=>n&&!n(O,v)?r.throwError(()=>v):r.of(k))):r.throwError(()=>v)))}))),K.catchError(b=>{if(s.catchError)return s.catchError(y,b);throw b}),K.tap(()=>{l&&(y=0)}))})}function $e(s){return s!=null}function De(s){return Object.prototype.toString.call(s)==="[object Object]"}function Ce(s){if(!De(s))return!1;const e=s.constructor;if(typeof e>"u")return!0;const t=e.prototype;return!(!De(t)||!t.hasOwnProperty("isPrototypeOf"))}const te=s=>JSON.stringify(s,(e,t)=>Ce(t)?Object.keys(t).sort().reduce((n,i)=>(n[i]=t[i],n),{}):t),Re=(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),""),z=()=>({context:void 0,data:void 0,error:null,status:"idle",submittedAt:0,variables:void 0,failureCount:0,failureReason:null,isPaused:!1});function F(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}function Fe(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 se=s=>s.pipe(r.takeWhile(e=>e.status!=="error"&&e.status!=="success",!0));var q;class Et{constructor({__queryFinalizeHook:e}={}){w(this,q,new r.Subject);g(this,"state$");const t=new r.BehaviorSubject(0),n=t.pipe(r.filter(i=>i===0));this.state$=c(this,q).pipe(r.concatMap(({args:i,mutation:u,options:a})=>{const h=a.mapOperator??"merge",d=c(this,q).pipe(r.filter(()=>h==="merge")),f=c(this,q).pipe(r.filter(()=>h==="switch"),r.tap(()=>{u.cancel()})),l=r.defer(()=>(u.execute(i),r.EMPTY)),p=u.state$.pipe(se,r.last(),r.mergeMap(()=>u.state$),r.takeUntil(c(this,q))),o=u.state$.pipe(se,r.skip(1)),y=r.merge(n,d,f,u.cancelled$);return r.merge(o,p,l).pipe(e??r.identity,r.takeUntil(y))}),r.scan((i,u)=>({...i,...u,...u.status==="pending"&&{data:u.data??i.data},...u.status==="pending"&&{error:u.error??i.error}}),z()),r.distinctUntilChanged(({data:i,...u},{data:a,...h})=>F(u,h)&&F(i,a)),r.shareReplay({refCount:!0,bufferSize:1}),Fe(i=>{t.next(i)}))}trigger({args:e,options:t,mutation:n}){c(this,q).next({args:e,options:t,mutation:n})}}q=new WeakMap;function we(s,e){return s===e?!0:typeof s!=typeof e?!1:s&&e&&typeof s=="object"&&typeof e=="object"?!Object.keys(e).some(t=>!we(s[t],e[t])):!1}const ge=(s,e,{exact:t=!1}={})=>t?te(s)===te(e):we(s,e);var B,I;class Mt{constructor(e,t={},n){w(this,B,void 0);w(this,I,new r.BehaviorSubject(void 0));g(this,"observed$");g(this,"getObserverResultFromState",e=>({...z(),...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)??[Re()],M(this,B,n??new Et(this.options)),this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this),c(this,I).pipe(r.filter($e),r.mergeMap(u=>c(this,B).state$.pipe(r.takeUntil(u.mutation.state$.pipe(se,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&&!ge(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)??z()),t=c(this,B).state$.pipe(r.map(a=>this.getObserverResultFromState(a))),n=c(this,I).pipe(r.filter($e),r.switchMap(a=>a.mutation.cancelled$),r.map(()=>this.getObserverResultFromState(z())));return{result$:r.merge(this.observed$,t,n),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,B).trigger({args:e,options:this.options,mutation:n}),await new Promise((i,u)=>{n.state$.pipe(se,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)??z())}reset(){const{mutation:e}=c(this,I).getValue()??{};c(this,I).next(void 0),e==null||e.cancel()}}B=new WeakMap,I=new WeakMap;const Ge=S.createContext(void 0),jt=({client:s})=>(S.useEffect(()=>(s.mount(),()=>{s.unmount()}),[s]),null),Rt=S.memo(({children:s,client:e})=>{const t=S.useMemo(()=>e,[e]);return ke.jsxs(Ge.Provider,{value:t,children:[ke.jsx(jt,{client:e}),s]})}),Je=s=>{const e=S.useContext(Ge);if(s)return s;if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e};function Ft(){}function Ut(s,e){const t=Je(e),n=A(s),i=Oe(()=>[Re()]),u=te(s.mutationKey??i.current),[a]=S.useState(()=>new Mt(t,s));S.useEffect(()=>{a.setOptions(s)},[a,s]);const h=S.useMemo(()=>a.observe(),[u,a]),d=he(h.result$)??h.lastValue,f=S.useCallback((l,p)=>{a.mutate(l,p).catch(Ft)},[a]);return S.useEffect(()=>()=>{n.current.cancelOnUnMount&&a.reset()},[a,n]),{...d,mutate:f,mutateAsync:d.mutate}}function xt(s){return e=>e.pipe(K.tap(t=>{s.next(t)}))}class At{constructor(){g(this,"isOnlineSubject",new r.BehaviorSubject(!0));g(this,"online$",this.isOnlineSubject.pipe(r.distinctUntilChanged()));g(this,"backToOnline$",this.online$.pipe(r.filter(e=>e),r.first()));r.merge(r.fromEvent(window,"offline").pipe(r.map(()=>!1)),r.fromEvent(window,"online").pipe(r.map(()=>!0))).pipe(xt(this.isOnlineSubject)).subscribe()}isOnline(){return this.isOnlineSubject.getValue()}setOnline(e){this.isOnlineSubject.getValue()!==e&&this.isOnlineSubject.next(e)}}const _=new At;function Ue(s,e){return s.isStaleByTime(e.staleTime)}function Qt(s,e){return e.enabled!==!1&&!s.state.dataUpdatedAt&&!(s.state.status==="error"&&e.retryOnMount===!1)&&s.state.fetchStatus!=="fetching"}function Te(s,e){return Qt(s,e)||s.state.dataUpdatedAt>0&&Xe(s,e,e.refetchOnMount)}function Ke(s,e,t,n){return s.state.fetchStatus!=="fetching"&&t.enabled!==!1&&(s!==e||n.enabled===!1)&&(!t.suspense||s.state.status!=="error")&&Ue(s,t)}function Pt(s,e){return Xe(s,e,e.refetchOnWindowFocus)}function Xe(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&&Ue(s,e)}return!1}function kt(s){return(s??"online")==="online"?_.isOnline():!0}function Ne(s,e){return e.reduce((t,n)=>n in s?{...t,[n]:s[n]}:t,{})}function We(s){return Array.isArray(s)&&s.length===Object.keys(s).length}function Ze(s,e){if(s===e)return s;const t=We(s)&&We(e);if(t||Ce(s)&&Ce(e)){const n=t?s:Object.keys(s),i=n.length,u=t?e:Object.keys(e),a=u.length,h=t?[]:{};let d=0;for(let f=0;f<a;f++){const l=t?f:u[f];!t&&s[l]===void 0&&e[l]===void 0&&n.includes(l)?(h[l]=void 0,d++):(h[l]=Ze(s[l],e[l]),h[l]===s[l]&&s[l]!==void 0&&d++)}return i===a&&d===i?s:h}return e}function xe(s,e){return((e==null?void 0:e.queryKeyHashFn)??te)(s)}function qe(s,e){const{type:t="all",exact:n,fetchStatus:i,predicate:u,queryKey:a,stale:h}=s;if(a){if(n){if(e.queryHash!==xe(a,e.options))return!1}else if(!we(e.queryKey,a))return!1}if(t!=="all"){const d=e.isActive();if(t==="active"&&!d||t==="inactive"&&d)return!1}return!(typeof h=="boolean"&&e.isStale()!==h||typeof i<"u"&&i!==e.state.fetchStatus||u&&!u(e))}function Vt(s,e){return Math.max(s+(e??0)-Date.now(),0)}function It(s,e){return typeof s=="function"?s(e):s}function ye(s,e,t){return typeof t.structuralSharing=="function"?t.structuralSharing(s,e):t.structuralSharing!==!1?Ze(s,e):e}const Dt=({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 h=a.data,d=h!==void 0&&h!==i.data,f="data"in a,l=a.status==="success",p=i.data!==void 0,o=i.error!==void 0||i.error!==null,y=a.status??i.status,$=d?ye(e().data,h,s()):f?a.data:i.data,b=i.status==="error"||i.status==="success",v=a.status==="error"&&(i.status==="error"&&i.fetchStatus==="fetching"||i.status!=="error")?i.errorUpdateCount+1:i.errorUpdateCount,O=d?i.dataUpdateCount+1:a.dataUpdateCount??i.dataUpdateCount,k=a.status==="pending"&&b&&(p||o),U=y==="pending"?null:a.error??i.error;return{...i,...a,status:y,error:U,errorUpdateCount:v,...l&&{isInvalidated:!1},data:$,dataUpdateCount:O,...k&&{status:i.status}}},t)),Tt=s=>s.pipe(r.map(({status:e,fetchStatus:t})=>t==="idle"&&(e==="success"||e==="error"))),et=s=>s.pipe(r.takeWhile(e=>e.fetchStatus!=="idle",!0));var Se,H;class Kt{constructor(){w(this,Se,r.merge(r.fromEvent(document,"visibilitychange"),r.fromEvent(window,"visibilitychange")).pipe(r.map(()=>document.visibilityState)));w(this,H,new r.BehaviorSubject(document.visibilityState==="visible"));g(this,"focused$",c(this,H));g(this,"focusRegained$",this.focused$.pipe(r.skip(1),r.filter(e=>e)));c(this,Se).pipe(r.tap(e=>{c(this,H).next(e==="visible")})).subscribe()}isFocused(){return c(this,H).getValue()}setFocused(e){c(this,H).getValue()!==(e??!0)&&c(this,H).next(e??!0)}subscribe(e){const t=this.focused$.subscribe(e);return()=>{t.unsubscribe()}}refresh(){document.dispatchEvent(new Event("visibilitychange"))}}Se=new WeakMap,H=new WeakMap;const me=new Kt,Nt=s=>s.pipe(r.filter(e=>e.status==="success"),r.map(e=>({data:e.data,status:e.status,dataUpdatedAt:e.dataUpdatedAt})),r.distinctUntilChanged(F));var W,C,ne,Y,x,X,ie;class tt{constructor(e,t){w(this,W,void 0);w(this,C,void 0);w(this,ne,new r.Subject);g(this,"queryUpdateSubject",new r.Subject);w(this,Y,void 0);w(this,x,void 0);w(this,X,void 0);w(this,ie,0);g(this,"getObserverResultFromQuery",({options:e,query:t,optimisticResult:n,prevResult:{result:i,options:u,state:a,select:h,selectError:d,selectResult:f}})=>{var be;const l=t.state,p=t.state.status==="pending",o=c(this,C),y=this.options,b=t!==o?t.state:c(this,Y);let{errorUpdatedAt:v,fetchStatus:O,error:k}=l;if(n){const Q=!!c(this,ie),Qe=!Q&&Te(t,e),ot=Q&&Ke(t,o,e,y);(Qe||ot)&&(O=kt(t.options.networkMode)?"fetching":"paused")}const U=p&&O==="fetching";let E,m=d,D=h??null,T=f;if(e.select&&typeof l.data<"u")if(i&&l.data===(a==null?void 0:a.data)&&e.select===h)E=f;else try{D=e.select,E=e.select(l.data),E=ye(i==null?void 0:i.data,E,e),T=E,m=null}catch(Q){E=f,m=Q}else E=l.data,m=null;let V=O!=="idle"&&!l.dataUpdatedAt?"pending":l.status;m&&(k=m,E=f,v=(i==null?void 0:i.errorUpdatedAt)??v,V="error");const fe=V==="error";let de=!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((be=c(this,X))==null?void 0:be.state.data,c(this,X)):e.placeholderData,e.select&&typeof Q<"u")try{Q=e.select(Q)}catch{}typeof Q<"u"&&(V="success",E=ye(i==null?void 0:i.data,Q,e),de=!0)}const pe=O==="fetching";return{result:{status:V,fetchStatus:O,isPending:p,isSuccess:V==="success",isError:fe,isInitialLoading:U,isLoading:U,data:E,dataUpdatedAt:l.dataUpdatedAt,error:k,errorUpdatedAt:v,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:l.dataUpdateCount>0||l.errorUpdateCount>0,isFetchedAfterMount:l.dataUpdateCount>b.dataUpdateCount||l.errorUpdateCount>b.errorUpdateCount,isFetching:pe,isRefetching:pe&&!p,isLoadingError:fe&&l.dataUpdatedAt===0,isPaused:O==="paused",isPlaceholderData:de,isRefetchError:fe&&l.dataUpdatedAt!==0,isStale:Ue(t,e),refetch:this.refetch},selectError:m,select:D,selectResult:T}});this.options=t,M(this,W,e),this.bindMethods(),M(this,C,this.setOptions(t));const n=c(this,C);M(this,Y,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,W).defaultQueryOptions(e),F(this.options,t)||c(this,W).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,Y,n.state),M(this,C,n)),this.queryUpdateSubject.next({options:this.options,query:n}),n}buildQuery(e){const t=c(this,W).getQueryCache().build(c(this,W),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 Wt(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,X,e),c(this,W).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,Y,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,ne).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:h},{options:d,query:f}])=>{Ke(f,h,d,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 h=this.options,d=this.queryUpdateSubject.pipe(r.startWith({query:a,options:h}),r.filter(m=>m.query===a),r.map(m=>m.options),r.distinctUntilChanged(),r.shareReplay(1)),f=c(this,ne).pipe(r.filter(m=>m.query===a)),l=a.state$.pipe(Nt,r.switchMap(m=>this.options.staleTime===1/0?r.NEVER:(this.options.staleTime??0)<=0?r.of(m).pipe(r.delay(1)):r.timer(this.options.staleTime??1)),r.takeWhile(()=>this.options.enabled??!0)),p=(m,D)=>{const T=h.notifyOnChangeProps,V=typeof T=="function"?T():T;return(Array.isArray(V)?V.length===0?()=>!0:(de,pe)=>{const Ae=Ne(de,V),be=Ne(pe,V);return F(Ae,be)}:F)(m,D)},o=f.pipe(r.switchMap(()=>a.state$),et),y=d.pipe(r.map(({refetchInterval:m,refetchIntervalInBackground:D})=>({refetchInterval:(typeof m=="function"?m(c(this,C)):m)??!1,refetchIntervalInBackground:D})),r.distinctUntilChanged(F),r.switchMap(({refetchInterval:m,refetchIntervalInBackground:D})=>m?r.interval(m).pipe(r.tap(()=>{(D||me.isFocused())&&this.fetch({cancelRefetch:!1}).catch(r.noop)})):r.NEVER),r.ignoreElements()),$=d.pipe(r.map(({enabled:m})=>m??!0),r.distinctUntilChanged()),b=$.pipe(r.filter(m=>!m),r.map(()=>a.state)),v=$.pipe(r.filter(m=>m),r.switchMap(()=>me.focusRegained$),r.withLatestFrom(d),r.tap(([,m])=>{Pt(a,m)&&this.fetch({cancelRefetch:!1}).catch(r.noop)}),r.ignoreElements()),O=b.pipe(r.map(()=>a.state)),k=m=>m.pipe(r.withLatestFrom(d),r.map(([,D])=>{const T=this.getObserverResultFromQuery({query:a,options:D,prevResult:c(this,x)});return this.updateResult({query:a,...T}),T.result})),E=r.merge(O,o,a.state$,l).pipe(k,r.distinctUntilChanged(F),r.distinctUntilChanged(p));return r.merge(y,v,E)})).pipe(Fe(a=>M(this,ie,a)),r.tap({subscribe:()=>{Te(e,this.options)&&this.fetch().catch(r.noop)}})))}destroy(){}}W=new WeakMap,C=new WeakMap,ne=new WeakMap,Y=new WeakMap,x=new WeakMap,X=new WeakMap,ie=new WeakMap;function Wt(s,e){return!F(s.getCurrentResult(),e)}const rt=ve.createContext(!1),qt=()=>ve.useContext(rt);rt.Provider;function Ht(){let s=!1;return{clearReset:()=>{s=!1},reset:()=>{s=!0},isReset:()=>s}}const Lt=ve.createContext(Ht()),_t=()=>ve.useContext(Lt);function zt(s,e){return typeof s=="function"?s(...e):!!s}const Bt=({result:s,errorResetBoundary:e,throwOnError:t,query:n})=>s.isError&&!e.isReset()&&!s.isFetching&&n&&zt(t,[s.error,n]);function st(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=Je(t),i=qt(),u=_t(),a=n.defaultQueryOptions(s);a._optimisticResults=i?"isRestoring":"optimistic";const[h]=S.useState(()=>new e(n,a)),d=Oe(()=>h.observe()),f=A(h.getOptimisticResult(a)),l=f.current;he(()=>d.current.pipe(r.filter(o=>!F(o,f.current))),[]),S.useEffect(()=>{h.setOptions(a)},[a,h]);const p=l.error;if(p&&Bt({result:l,errorResetBoundary:u,throwOnError:a.throwOnError,query:n.getQueryCache().get(a.queryHash)}))throw p;return f.current}function Yt(s,e){return st(s,tt,e)}function Gt(s,e){return st({refetchOnMount:"idle",refetchOnReconnect:!1,refetchInterval:!1,refetchOnWindowFocus:!1,...s},tt,e)}function Jt(s,e,t=[]){const n=e!=null&&!Array.isArray(e)?e:{},i=n.retry??!0,u=A(n.onError??(d=>{console.error(d)})),a=S.useCallback(()=>R(s),t),h=S.useCallback(()=>a().pipe(r.catchError(d=>{throw u.current(d),d}),i?r.retry():r.identity),[a,i,u]);Ee(h,t)}const nt=()=>s=>r.merge(r.of({isPaused:!0}),_.backToOnline$.pipe(r.mergeMap(()=>r.merge(r.of({isPaused:!1}),s)))),Xt=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(nt())))):r.throwError(()=>t))))},Zt=({variables:s,state:e,options:t})=>{const n=e.isPaused,i=async()=>await Promise.reject(new Error("No mutationFn found")),u=t.mutationFn??i,h=r.iif(()=>n,r.of(e.context),R(()=>{var o;return((o=t.onMutate)==null?void 0:o.call(t,s))??void 0})).pipe(r.shareReplay(1)),d=(o,y,$)=>R(()=>{var v;return(v=t.onError)==null?void 0:v.call(t,o,s,y)}).pipe(r.catchError(()=>r.of(o)),r.map(()=>({failureCount:$,error:o,failureReason:o,context:y,status:"error"}))),f=h.pipe(r.switchMap(o=>{const $=(typeof u=="function"?R(()=>u(s)):u).pipe(r.map(b=>({result:{data:b},error:null,context:o})),Xt,je({...t,retry:(b,v)=>{const O=t.retry??0;return typeof O=="function"?O(b,v):typeof O=="boolean"?O:b<O},caughtError:(b,v)=>r.of({failureCount:b,failureReason:v}),catchError:(b,v)=>d(v,o,b).pipe(r.map(O=>({...O,result:void 0})))}),r.takeWhile(({result:b,error:v})=>(b==null?void 0:b.data)===void 0&&v===void 0,!0));return _.isOnline()||t.networkMode==="offlineFirst"||t.networkMode==="always"?$:$.pipe(nt())})),l=r.of({...e,variables:s,status:"pending",isPaused:!1,failureCount:0,failureReason:null,submittedAt:e.submittedAt??new Date().getTime()});return r.merge(l,h.pipe(r.map(o=>({context:o}))),f.pipe(r.switchMap(({result:o,error:y,...$})=>{if(!o&&!y)return r.of({...$});const b=y?r.of(null):R(()=>{var U;return(U=t.onSuccess)==null?void 0:U.call(t,o==null?void 0:o.data,s,$.context)}),O=R(()=>{var U;return(U=t.onSettled)==null?void 0:U.call(t,o==null?void 0:o.data,y,s,$.context)}).pipe(r.catchError(U=>o?r.of(o):r.of(U)));return r.concat(b,O).pipe(r.toArray(),r.map(()=>y?{error:y,data:void 0,variables:s,...$}:{status:"success",error:y,data:o==null?void 0:o.data,variables:s,failureCount:0,failureReason:null,...$}),r.catchError(U=>d(U,$.context,0).pipe(r.map(E=>({...E,data:void 0})))))}))).pipe(r.scan((o,y)=>({...o,...y,data:y.data??o.data,error:y.error??o.error}),z()),r.distinctUntilChanged(({data:o,...y},{data:$,...b})=>F(y,b)&&F(o,$)))};var ae,L,Z;class er{constructor({options:e,mutationCache:t,state:n}){w(this,ae,new r.BehaviorSubject(0));w(this,L,new r.Subject);w(this,Z,new r.Subject);g(this,"state",z());g(this,"state$");g(this,"options");g(this,"observerCount$",c(this,ae).asObservable());g(this,"cancelled$",c(this,L).asObservable());this.options=e,this.state=n??this.state;const i=c(this,Z).pipe(r.switchMap(u=>Zt({options:{...this.options,onMutate:a=>{const h=R(()=>{var p,o;return(o=(p=t.config).onMutate)==null?void 0:o.call(p,a,this)}),f=R(()=>{var p,o;return(o=(p=this.options).onMutate)==null?void 0:o.call(p,a)});return h.pipe(r.mergeMap(()=>f))},onError:(a,h,d)=>{const f=R(()=>{var p,o;return(o=(p=t.config).onError)==null?void 0:o.call(p,a,h,d,this)}),l=R(()=>{var p,o;return(o=(p=this.options).onError)==null?void 0:o.call(p,a,h,d)});return r.concat(f,l).pipe(r.toArray())},onSettled:(a,h,d,f)=>{const l=R(()=>{var o,y;return(y=(o=t.config).onSettled)==null?void 0:y.call(o,a,h,d,f,this)}),p=R(()=>{var o,y;return(y=(o=this.options).onSettled)==null?void 0:y.call(o,a,h,d,f)});return r.concat(l,p).pipe(r.toArray())},onSuccess:(a,h,d)=>{const f=R(()=>{var p,o;return(o=(p=t.config).onSuccess)==null?void 0:o.call(p,a,h,d,this)}),l=R(()=>{var p,o;return(o=(p=this.options).onSuccess)==null?void 0:o.call(p,a,h,d)});return r.concat(f,l).pipe(r.toArray())}},state:this.state,variables:u}).pipe(r.takeUntil(c(this,L)))));this.state$=r.merge(i,r.NEVER).pipe(r.startWith(this.state),r.tap(u=>{this.state={...this.state,...u}}),r.takeUntil(c(this,L)),r.shareReplay({bufferSize:1,refCount:!1}),Fe(u=>{c(this,ae).next(u)}))}get meta(){return this.options.meta}setOptions(e){this.options={...this.options,...e}}execute(e){return c(this,Z).next(e),c(this,Z).complete(),this.state$.pipe(se)}continue(){return this.execute(this.state.variables)}cancel(){c(this,L).next(),c(this,L).complete()}}ae=new WeakMap,L=new WeakMap,Z=new WeakMap;const He=({mutationKey:s,status:e,predicate:t,exact:n=!0}={})=>u=>n&&s!==void 0&&u.options.mutationKey!==void 0&&!ge(u.options.mutationKey,s,{exact:n})||!n&&s!==void 0&&u.options.mutationKey!==void 0&&!ge(u.options.mutationKey,s,{exact:n})||e&&u.state.status!==e?!1:t?t(u):!0;class it{constructor(){g(this,"entriesSubject",new r.BehaviorSubject([]));g(this,"changeSubject",new r.Subject);g(this,"entries$",this.entriesSubject.pipe(r.share()));g(this,"added$",this.changeSubject.pipe(r.filter(({type:e})=>e==="added"),r.map(({entity:e})=>e),r.share()));g(this,"removed$",this.changeSubject.pipe(r.filter(({type:e})=>e==="removed"),r.map(({entity:e})=>e),r.share()));g(this,"stateChange$",r.merge(this.entriesSubject.pipe(r.first(),r.mergeMap(e=>r.from(e))),this.added$).pipe(r.mergeMap(e=>e.state$.pipe(r.map(()=>e),r.takeUntil(this.removed$.pipe(r.filter(t=>t===e))))),r.share()))}getValues(){return this.entriesSubject.getValue()}remove(e){this.entriesSubject.next(this.entriesSubject.getValue().filter(t=>e!==t)),this.changeSubject.next({type:"removed",entity:e})}add(e){this.entriesSubject.next([...this.entriesSubject.getValue(),e]),this.changeSubject.next({type:"added",entity:e})}find(e){return this.entriesSubject.getValue().find(e)}}var P;class at{constructor(e={}){w(this,P,new it);this.config=e}build(e,t,n){const i=new er({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=He(t);return c(this,P).getValues().find(i=>n(i))}findAll(e={}){const t={exact:!0,...e},n=He(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;const tr=typeof window>"u"||"Deno"in window;function rr(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 sr=s=>r.defer(()=>me.isFocused()?s:me.focusRegained$.pipe(r.mergeMap(()=>s))),nr=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))}},ir=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))},ar=s=>{const e=async()=>await Promise.reject(new Error("No query found"));let t=!1;const n=s.queryFn??e,i=new AbortController,u={meta:s.meta,queryKey:s.queryKey};(l=>{Object.defineProperty(l,"signal",{enumerable:!0,get:()=>(s.onSignalConsumed(),i.signal)})})(u);const d=(typeof n=="function"?R(()=>n(u)):n).pipe(ir(s.observers$),r.tap({complete:()=>{t=!0}}),r.map(l=>({data:l})),nr(s),je({...s,retryAfter:()=>r.of(!0).pipe(sr),catchError:(l,p)=>r.of({status:"error",fetchStatus:"idle",fetchFailureCount:l,fetchFailureReason:p,error:p}),caughtError:(l,p)=>r.of({fetchFailureCount:l,fetchFailureReason:p})}),r.mergeMap(l=>"data"in l?r.of({...l,status:"success",fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null,dataUpdatedAt:new Date().getTime()}).pipe(r.delay(1),r.map(p=>t?p:{...p,fetchStatus:"fetching"})):r.of(l)),r.endWith({fetchStatus:"idle"}),r.share()),f=r.of({status:"pending",fetchStatus:_.isOnline()?"fetching":"paused"});return{state$:r.merge(f,d).pipe(r.share()),abortController:i}};class ur{constructor(e){g(this,"revert");g(this,"silent");this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}}const cr={backgroundColor:"transparent",color:"inherit"};function ut(s){const e={namespaces:[{name:"@reactjrx",style:{backgroundColor:"#d02f4e",color:"white"}}],namespace(t,n){const i=ut(s);return i.namespaces.push({name:t,style:n??cr}),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){if(s==="development"){const{namespaces:i,styles:u}=e.printNamespaces();console[t](i,...u,...n)}return e},printWithoutNamespace(t,...n){return s==="development"&&console[t](...n),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 s==="development"&&console.groupEnd(),e}};return e}const or=ut("production");var ue,G;class lr{constructor(e){g(this,"queryKey");g(this,"queryHash");g(this,"gcTime");g(this,"options");w(this,ue,void 0);w(this,G,void 0);g(this,"state");g(this,"executeSubject",new r.Subject);g(this,"cancelSubject",new r.Subject);g(this,"setDataSubject",new r.Subject);g(this,"invalidatedSubject",new r.Subject);g(this,"resetSubject",new r.Subject);g(this,"destroySubject",new r.Subject);g(this,"observersSubject",new r.BehaviorSubject([]));g(this,"abortSignalConsumed",!1);g(this,"observerCount$",this.observersSubject.asObservable().pipe(r.map(e=>e.length)));g(this,"observers$",this.observersSubject.asObservable());g(this,"state$");M(this,ue,e.defaultOptions),this.options=this.setOptions(e.options),this.queryKey=e.queryKey,this.queryHash=e.queryHash,M(this,G,e.state??rr(this.options)),this.state=c(this,G),this.gcTime=this.updateGcTime(this.options.gcTime),this.state$=r.merge(this.resetSubject.pipe(r.map(()=>({command:"reset",state:c(this,G)}))),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 ur(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,l])=>{l.length===0&&f.length>0?t=!0:t=!1}),r.ignoreElements()),{state$:u,abortController:a}=ar({...this.options,observers$:this.observerCount$,queryKey:this.queryKey,retry:(f,l)=>{const p=this.options.retry??!0;return typeof p=="function"?p(f,l):typeof p=="boolean"?p:f<p},retryAfterDelay:()=>!t,onSignalConsumed:()=>{this.abortSignalConsumed=!0}}),h=this.observerCount$.pipe(r.filter(f=>f===0&&this.abortSignalConsumed),r.tap(()=>{this.cancelSubject.next({revert:!0})})),d=r.merge(this.cancelSubject,n,this.resetSubject,h).pipe(r.tap(()=>{this.abortSignalConsumed&&a.abort()}));return r.merge(u,i).pipe(r.map(f=>({command:"execute",state:f})),r.takeUntil(d))})),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(Dt({initialState:this.state,getOptions:()=>this.options,getState:()=>this.state}),r.startWith(c(this,G)),r.distinctUntilChanged(F),r.tap(t=>{this.state=t}),r.catchError(t=>{throw or.error(t),t}),r.takeUntil(this.destroySubject),r.shareReplay({bufferSize:1,refCount:!1}))}setOptions(e){return this.options={...c(this,ue),...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(F),r.filter(({status:e})=>e==="success"))}get error$(){return this.state$.pipe(r.map(({error:e,status:t})=>({error:e,status:t})),r.distinctUntilChanged(F),r.filter(({status:e})=>e==="error"))}get settled$(){return this.state$.pipe(r.map(({status:e})=>({status:e})),r.distinctUntilChanged(F),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??(tr?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||!Vt(this.state.dataUpdatedAt,e)}async getFetchResultAsPromise(){return await new Promise((e,t)=>{this.state$.pipe(et,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=ye(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()}}ue=new WeakMap,G=new WeakMap;var ce,N;class ct{constructor(e={}){w(this,ce,new r.Subject);w(this,N,new it);this.config=e}mount(){}unmount(){}notify(e){c(this,ce).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=>qe(e,n)):t}build(e,t,n){const i=t.queryKey??[Re()],u=t.queryHash??xe(i,t);let a=this.get(u);return a||(a=new lr({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(Tt,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=>qe(t,n))}subscribe(e){const t=r.merge(c(this,ce).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(){}}ce=new WeakMap,N=new WeakMap;var J,j,oe,le,ee;class hr{constructor({mutationCache:e,queryCache:t,defaultOptions:n}={}){w(this,J,void 0);w(this,j,void 0);w(this,oe,new Map);w(this,le,new Map);w(this,ee,void 0);M(this,J,e??new at),M(this,j,t??new ct),M(this,ee,n??{})}mount(){}unmount(){}getMutationCache(){return c(this,J)}getQueryCache(){return c(this,j)}defaultMutationOptions(e){return{...c(this,ee).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e}}defaultQueryOptions(e){if(e!=null&&e._defaulted)return e;const t={...c(this,ee).queries,...(e==null?void 0:e.queryKey)&&this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=xe(t.queryKey,t)),typeof t.refetchOnReconnect>"u"&&(t.refetchOnReconnect=t.networkMode!=="always"),typeof t.throwOnError>"u"&&(t.throwOnError=!!t.suspense),typeof t.networkMode>"u"&&t.persister&&(t.networkMode="offlineFirst"),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=c(this,j).find({queryKey:e}),u=i==null?void 0:i.state.data,a=It(t,u);if(typeof a>"u")return;const h=this.defaultQueryOptions({queryKey:e});return c(this,j).build(this,h).setData(a,{...n,manual:!0})}getMutationDefaults(e){const t=[...c(this,oe).values()];let n={};return t.forEach(i=>{ge(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,oe).set(te(e),{mutationKey:e,defaultOptions:t})}setQueryDefaults(e,t){c(this,le).set(te(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...c(this,le).values()];let n={};return t.forEach(i=>{we(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,J).resumePausedMutations())}isFetching(e){return c(this,j).findAll({...e,fetchStatus:"fetching"}).length}clear(){c(this,j).clear(),c(this,J).clear()}}J=new WeakMap,j=new WeakMap,oe=new WeakMap,le=new WeakMap,ee=new WeakMap;exports.MutationCache=at;exports.QueryCache=ct;exports.QueryClient=hr;exports.QueryClientProvider=Rt;exports.SIGNAL_RESET=_e;exports.createLocalStorageAdapter=ze;exports.createLocalforageAdapter=St;exports.createSharedStoreAdapter=mt;exports.exponentialBackoffDelay=Ye;exports.getDelay=Be;exports.isDefined=$e;exports.retryBackoff=je;exports.signal=gt;exports.useBehaviorSubject=Le;exports.useForeverQuery=Gt;exports.useLiveRef=A;exports.useMutation=Ut;exports.useObservableState=bt;exports.useObserve=he;exports.useObserveCallback=pt;exports.usePersistSignals=$t;exports.useQuery=Yt;exports.useSignalValue=yt;exports.useSubject=Me;exports.useSubscribe=Ee;exports.useSubscribeEffect=Jt;exports.useUnmountObservable=Ct;
|
package/dist/index.js
CHANGED
|
@@ -10,12 +10,12 @@ var a = (s, e, t) => (lt(s, e, "read from private field"), t ? t.call(s) : e.get
|
|
|
10
10
|
e instanceof WeakSet ? e.add(s) : e.set(s, t);
|
|
11
11
|
}, M = (s, e, t, r) => (lt(s, e, "write to private field"), r ? r.call(s, t) : e.set(s, t), t);
|
|
12
12
|
import * as We from "react";
|
|
13
|
-
import { useRef as
|
|
14
|
-
import { distinctUntilChanged as A, tap as E, finalize as Yt, catchError as te, EMPTY as
|
|
13
|
+
import { useRef as be, useMemo as et, useCallback as le, useSyncExternalStore as _t, useEffect as re, createContext as Wt, memo as Gt, useContext as Jt, useState as Ct } from "react";
|
|
14
|
+
import { distinctUntilChanged as A, tap as E, finalize as Yt, catchError as te, EMPTY as ge, isObservable as ht, from as Oe, of as S, defer as Ae, Subject as P, BehaviorSubject as J, map as g, zip as Bt, merge as C, throttleTime as Xt, asyncScheduler as Zt, switchMap as Q, throwError as Se, timer as Qe, Observable as es, takeWhile as Ge, filter as $, concatMap as ts, last as Ke, mergeMap as H, takeUntil as B, skip as Ft, identity as Et, scan as tt, shareReplay as Ue, ignoreElements as he, first as st, fromEvent as Ne, noop as N, startWith as oe, pairwise as xt, NEVER as $e, delay as rt, interval as ss, withLatestFrom as ft, retry as rs, iif as ns, concat as ke, toArray as Te, share as fe, take as He, combineLatest as is, endWith as us, lastValueFrom as as } from "rxjs";
|
|
15
15
|
import { catchError as dt, mergeMap as Xe, retryWhen as cs, concatMap as os, first as ls, tap as Rt } from "rxjs/operators";
|
|
16
16
|
import { jsxs as hs, jsx as fs } from "react/jsx-runtime";
|
|
17
|
-
const
|
|
18
|
-
const e =
|
|
17
|
+
const k = (s) => {
|
|
18
|
+
const e = be(s);
|
|
19
19
|
return et(() => {
|
|
20
20
|
e.current = s;
|
|
21
21
|
}, [s]), e;
|
|
@@ -28,9 +28,9 @@ function Je(s, e, t) {
|
|
|
28
28
|
defaultValue: void 0,
|
|
29
29
|
key: "",
|
|
30
30
|
unsubscribeOnUnmount: !0
|
|
31
|
-
}, n = t == null && Array.isArray(e) ? e : typeof s == "function" ? t ?? [] : [s], u =
|
|
31
|
+
}, n = t == null && Array.isArray(e) ? e : typeof s == "function" ? t ?? [] : [s], u = be(
|
|
32
32
|
"getValue" in s && typeof s.getValue == "function" ? s.getValue() : r.defaultValue
|
|
33
|
-
), i =
|
|
33
|
+
), i = k(s), l = k(r), f = le(
|
|
34
34
|
(d) => {
|
|
35
35
|
const c = i.current, F = (typeof c == "function" ? c : () => c)().pipe(
|
|
36
36
|
/**
|
|
@@ -44,7 +44,7 @@ function Je(s, e, t) {
|
|
|
44
44
|
u.current = p;
|
|
45
45
|
}),
|
|
46
46
|
Yt(d),
|
|
47
|
-
te((p) => (console.error(p), u.current = void 0,
|
|
47
|
+
te((p) => (console.error(p), u.current = void 0, ge))
|
|
48
48
|
).subscribe(d);
|
|
49
49
|
return () => {
|
|
50
50
|
l.current.unsubscribeOnUnmount !== !1 && F.unsubscribe();
|
|
@@ -62,17 +62,17 @@ function U(s) {
|
|
|
62
62
|
if (ht(s))
|
|
63
63
|
return s;
|
|
64
64
|
if (pt(s))
|
|
65
|
-
return
|
|
65
|
+
return Oe(s);
|
|
66
66
|
if (typeof s != "function")
|
|
67
67
|
return S(s);
|
|
68
68
|
const e = s;
|
|
69
69
|
return Ae(() => {
|
|
70
70
|
const t = e();
|
|
71
|
-
return pt(t) ?
|
|
71
|
+
return pt(t) ? Oe(t) : ht(t) ? t : S(t);
|
|
72
72
|
});
|
|
73
73
|
}
|
|
74
74
|
function Mt(s, e = []) {
|
|
75
|
-
const t =
|
|
75
|
+
const t = k(s);
|
|
76
76
|
re(() => {
|
|
77
77
|
const r = U(t.current).subscribe();
|
|
78
78
|
return () => {
|
|
@@ -85,7 +85,7 @@ function Mt(s, e = []) {
|
|
|
85
85
|
]);
|
|
86
86
|
}
|
|
87
87
|
const Ye = (s) => {
|
|
88
|
-
const e =
|
|
88
|
+
const e = be();
|
|
89
89
|
return e.current || (e.current = s()), re(() => {
|
|
90
90
|
process.env.NODE_ENV;
|
|
91
91
|
}, []), e;
|
|
@@ -93,7 +93,7 @@ const Ye = (s) => {
|
|
|
93
93
|
onBeforeComplete: s,
|
|
94
94
|
completeOnUnmount: e = !0
|
|
95
95
|
} = {}) => {
|
|
96
|
-
const t = Ye(() => new P()), r =
|
|
96
|
+
const t = Ye(() => new P()), r = be(!1), n = k(s), u = k(e);
|
|
97
97
|
return re(() => (r.current && (t.current = new P(), r.current = !1), () => {
|
|
98
98
|
if (!u.current) {
|
|
99
99
|
r.current = !0;
|
|
@@ -102,7 +102,7 @@ const Ye = (s) => {
|
|
|
102
102
|
r.current || (n.current != null && n.current(), t.current.complete(), r.current = !0);
|
|
103
103
|
}), [u, n, t]), t;
|
|
104
104
|
}, lr = () => {
|
|
105
|
-
const s = jt(), e =
|
|
105
|
+
const s = jt(), e = k(s.current.asObservable()), t = le(
|
|
106
106
|
(r) => {
|
|
107
107
|
s.current.next(r);
|
|
108
108
|
},
|
|
@@ -111,12 +111,12 @@ const Ye = (s) => {
|
|
|
111
111
|
);
|
|
112
112
|
return [e.current, t];
|
|
113
113
|
}, ps = (s) => {
|
|
114
|
-
const e = Ye(() => new J(s)), t =
|
|
114
|
+
const e = Ye(() => new J(s)), t = be(!1), r = be(s);
|
|
115
115
|
return re(() => (t.current && (e.current = new J(r.current), t.current = !1), () => {
|
|
116
116
|
t.current || (e.current.complete(), t.current = !0);
|
|
117
117
|
}), [e]), e;
|
|
118
118
|
}, hr = (s) => {
|
|
119
|
-
const e = ps(s), t =
|
|
119
|
+
const e = ps(s), t = k(e.current.asObservable()), r = le(
|
|
120
120
|
(n) => {
|
|
121
121
|
e.current.next(n);
|
|
122
122
|
},
|
|
@@ -194,8 +194,8 @@ const yt = (s) => {
|
|
|
194
194
|
setItem: async (s, e) => {
|
|
195
195
|
localStorage.setItem(s, JSON.stringify(e));
|
|
196
196
|
}
|
|
197
|
-
}),
|
|
198
|
-
if (typeof s == "object" && s !== null &&
|
|
197
|
+
}), ve = "__reactjrx", gs = (s) => {
|
|
198
|
+
if (typeof s == "object" && s !== null && ve in s && s[ve] === ve)
|
|
199
199
|
return s;
|
|
200
200
|
}, ms = async ({
|
|
201
201
|
adapter: s,
|
|
@@ -204,7 +204,7 @@ const yt = (s) => {
|
|
|
204
204
|
}) => {
|
|
205
205
|
const n = {
|
|
206
206
|
value: e.getValue(),
|
|
207
|
-
[
|
|
207
|
+
[ve]: ve,
|
|
208
208
|
migrationVersion: t
|
|
209
209
|
};
|
|
210
210
|
await s.setItem(e.config.key, n);
|
|
@@ -212,7 +212,7 @@ const yt = (s) => {
|
|
|
212
212
|
adapter: s,
|
|
213
213
|
version: e,
|
|
214
214
|
signal: t
|
|
215
|
-
}) =>
|
|
215
|
+
}) => Oe(s.getItem(t.config.key)).pipe(
|
|
216
216
|
Q((r) => {
|
|
217
217
|
const n = gs(r);
|
|
218
218
|
return n ? n.migrationVersion !== void 0 && e > n.migrationVersion ? S(r) : (t.setValue(n.value), S(r)) : S(r);
|
|
@@ -222,7 +222,7 @@ const yt = (s) => {
|
|
|
222
222
|
onReady: e,
|
|
223
223
|
adapter: t = bs()
|
|
224
224
|
}) => {
|
|
225
|
-
const r =
|
|
225
|
+
const r = k(s), n = k(e), u = k(t), i = Je(
|
|
226
226
|
() => {
|
|
227
227
|
const l = r.current;
|
|
228
228
|
return (l.length === 0 ? S(!0) : Bt(
|
|
@@ -237,7 +237,7 @@ const yt = (s) => {
|
|
|
237
237
|
E(() => {
|
|
238
238
|
n.current != null && n.current();
|
|
239
239
|
}),
|
|
240
|
-
te((h) => (console.error("Unable to hydrate", h),
|
|
240
|
+
te((h) => (console.error("Unable to hydrate", h), ge))
|
|
241
241
|
);
|
|
242
242
|
},
|
|
243
243
|
{ defaultValue: !1 },
|
|
@@ -250,13 +250,13 @@ const yt = (s) => {
|
|
|
250
250
|
trailing: !0
|
|
251
251
|
}),
|
|
252
252
|
Q(
|
|
253
|
-
() =>
|
|
253
|
+
() => Oe(
|
|
254
254
|
ms({ adapter: u.current, signal: l, version: f })
|
|
255
255
|
)
|
|
256
256
|
)
|
|
257
257
|
)
|
|
258
258
|
)
|
|
259
|
-
) :
|
|
259
|
+
) : ge, [i, u]), { isHydrated: i };
|
|
260
260
|
}, gr = () => {
|
|
261
261
|
const s = jt({
|
|
262
262
|
onBeforeComplete: () => {
|
|
@@ -303,7 +303,7 @@ function At(s) {
|
|
|
303
303
|
Xe(
|
|
304
304
|
(q) => C(
|
|
305
305
|
S(q),
|
|
306
|
-
|
|
306
|
+
Se(() => p)
|
|
307
307
|
)
|
|
308
308
|
)
|
|
309
309
|
);
|
|
@@ -320,8 +320,8 @@ function At(s) {
|
|
|
320
320
|
h
|
|
321
321
|
)
|
|
322
322
|
).pipe(
|
|
323
|
-
Xe((q) => r && !r(O, v) ?
|
|
324
|
-
) :
|
|
323
|
+
Xe((q) => r && !r(O, v) ? Se(() => v) : S(q))
|
|
324
|
+
) : Se(() => v)
|
|
325
325
|
)
|
|
326
326
|
);
|
|
327
327
|
})
|
|
@@ -352,7 +352,7 @@ function Ze(s) {
|
|
|
352
352
|
const t = e.prototype;
|
|
353
353
|
return !(!gt(t) || !t.hasOwnProperty("isPrototypeOf"));
|
|
354
354
|
}
|
|
355
|
-
const
|
|
355
|
+
const me = (s) => JSON.stringify(
|
|
356
356
|
s,
|
|
357
357
|
(e, t) => Ze(t) ? Object.keys(t).sort().reduce((r, n) => (r[n] = t[n], r), {}) : t
|
|
358
358
|
), nt = (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), ""), ne = () => ({
|
|
@@ -391,7 +391,7 @@ function it(s) {
|
|
|
391
391
|
});
|
|
392
392
|
};
|
|
393
393
|
}
|
|
394
|
-
const
|
|
394
|
+
const we = (s) => s.pipe(
|
|
395
395
|
Ge(
|
|
396
396
|
(e) => e.status !== "error" && e.status !== "success",
|
|
397
397
|
!0
|
|
@@ -416,13 +416,13 @@ class $s {
|
|
|
416
416
|
E(() => {
|
|
417
417
|
u.cancel();
|
|
418
418
|
})
|
|
419
|
-
), o = Ae(() => (u.execute(n),
|
|
420
|
-
|
|
419
|
+
), o = Ae(() => (u.execute(n), ge)), d = u.state$.pipe(
|
|
420
|
+
we,
|
|
421
421
|
Ke(),
|
|
422
422
|
H(() => u.state$),
|
|
423
423
|
B(a(this, X))
|
|
424
424
|
), c = u.state$.pipe(
|
|
425
|
-
|
|
425
|
+
we,
|
|
426
426
|
Ft(1)
|
|
427
427
|
), b = C(
|
|
428
428
|
r,
|
|
@@ -477,7 +477,7 @@ X = new WeakMap();
|
|
|
477
477
|
function Be(s, e) {
|
|
478
478
|
return s === e ? !0 : typeof s != typeof e ? !1 : s && e && typeof s == "object" && typeof e == "object" ? !Object.keys(e).some((t) => !Be(s[t], e[t])) : !1;
|
|
479
479
|
}
|
|
480
|
-
const qe = (s, e, { exact: t = !1 } = {}) => t ?
|
|
480
|
+
const qe = (s, e, { exact: t = !1 } = {}) => t ? me(s) === me(e) : Be(s, e);
|
|
481
481
|
var ie, L;
|
|
482
482
|
class ws {
|
|
483
483
|
constructor(e, t = {}, r) {
|
|
@@ -508,7 +508,7 @@ class ws {
|
|
|
508
508
|
H(
|
|
509
509
|
(u) => a(this, ie).state$.pipe(
|
|
510
510
|
B(
|
|
511
|
-
u.mutation.state$.pipe(
|
|
511
|
+
u.mutation.state$.pipe(we, Ke())
|
|
512
512
|
)
|
|
513
513
|
)
|
|
514
514
|
)
|
|
@@ -519,7 +519,7 @@ class ws {
|
|
|
519
519
|
state: i,
|
|
520
520
|
options: u.options
|
|
521
521
|
}))
|
|
522
|
-
)) ??
|
|
522
|
+
)) ?? ge),
|
|
523
523
|
E(({ state: u, options: i }) => {
|
|
524
524
|
u.status === "error" && (i != null && i.onError && (i == null || i.onError(
|
|
525
525
|
u.error,
|
|
@@ -592,7 +592,7 @@ class ws {
|
|
|
592
592
|
options: this.options,
|
|
593
593
|
mutation: r
|
|
594
594
|
}), await new Promise((n, u) => {
|
|
595
|
-
r.state$.pipe(
|
|
595
|
+
r.state$.pipe(we, Ke()).subscribe({
|
|
596
596
|
error: (i) => {
|
|
597
597
|
u(i);
|
|
598
598
|
},
|
|
@@ -636,7 +636,7 @@ const Qt = Wt(void 0), Cs = ({ client: s }) => (re(() => (s.mount(), () => {
|
|
|
636
636
|
function Fs() {
|
|
637
637
|
}
|
|
638
638
|
function Sr(s, e) {
|
|
639
|
-
const t = Ut(e), r =
|
|
639
|
+
const t = Ut(e), r = k(s), n = Ye(() => [nt()]), u = me(s.mutationKey ?? n.current), [i] = Ct(
|
|
640
640
|
() => new ws(
|
|
641
641
|
t,
|
|
642
642
|
s
|
|
@@ -733,7 +733,7 @@ function It(s, e) {
|
|
|
733
733
|
return e;
|
|
734
734
|
}
|
|
735
735
|
function at(s, e) {
|
|
736
|
-
return ((e == null ? void 0 : e.queryKeyHashFn) ??
|
|
736
|
+
return ((e == null ? void 0 : e.queryKeyHashFn) ?? me)(s);
|
|
737
737
|
}
|
|
738
738
|
function $t(s, e) {
|
|
739
739
|
const {
|
|
@@ -859,12 +859,12 @@ const Le = new Is(), Vs = (s) => s.pipe(
|
|
|
859
859
|
})),
|
|
860
860
|
A(I)
|
|
861
861
|
);
|
|
862
|
-
var Y, x,
|
|
862
|
+
var Y, x, Ce, ue, D, de, Fe;
|
|
863
863
|
class Dt {
|
|
864
864
|
constructor(e, t) {
|
|
865
865
|
w(this, Y, void 0);
|
|
866
866
|
w(this, x, void 0);
|
|
867
|
-
w(this,
|
|
867
|
+
w(this, Ce, new P());
|
|
868
868
|
/**
|
|
869
869
|
* Used to subscribe to changes in either query or options (or both).
|
|
870
870
|
* We need to be able to track change to both of them at the same time
|
|
@@ -883,7 +883,7 @@ class Dt {
|
|
|
883
883
|
// This property keeps track of the last query with defined data.
|
|
884
884
|
// It will be used to pass the previous data and query to the placeholder function between renders.
|
|
885
885
|
w(this, de, void 0);
|
|
886
|
-
w(this,
|
|
886
|
+
w(this, Fe, 0);
|
|
887
887
|
y(this, "getObserverResultFromQuery", ({
|
|
888
888
|
options: e,
|
|
889
889
|
query: t,
|
|
@@ -901,7 +901,7 @@ class Dt {
|
|
|
901
901
|
const o = t.state, d = t.state.status === "pending", c = a(this, x), b = this.options, p = t !== c ? t.state : a(this, ue);
|
|
902
902
|
let { errorUpdatedAt: v, fetchStatus: O, error: q } = o;
|
|
903
903
|
if (r) {
|
|
904
|
-
const
|
|
904
|
+
const T = !!a(this, Fe), ot = !T && mt(t, e), qt = T && St(t, c, e, b);
|
|
905
905
|
(ot || qt) && (O = js(t.options.networkMode) ? "fetching" : "paused");
|
|
906
906
|
}
|
|
907
907
|
const V = d && O === "fetching";
|
|
@@ -912,8 +912,8 @@ class Dt {
|
|
|
912
912
|
else
|
|
913
913
|
try {
|
|
914
914
|
_ = e.select, R = e.select(o.data), R = ze(n == null ? void 0 : n.data, R, e), W = R, m = null;
|
|
915
|
-
} catch (
|
|
916
|
-
R = h, m =
|
|
915
|
+
} catch (T) {
|
|
916
|
+
R = h, m = T;
|
|
917
917
|
}
|
|
918
918
|
else
|
|
919
919
|
R = o.data, m = null;
|
|
@@ -922,20 +922,20 @@ class Dt {
|
|
|
922
922
|
const Pe = z === "error";
|
|
923
923
|
let Ie = !1;
|
|
924
924
|
if (typeof e.placeholderData < "u" && typeof R > "u" && z === "pending") {
|
|
925
|
-
let
|
|
925
|
+
let T;
|
|
926
926
|
if (n != null && n.isPlaceholderData && e.placeholderData === (u == null ? void 0 : u.placeholderData))
|
|
927
|
-
|
|
928
|
-
else if (
|
|
927
|
+
T = n.data;
|
|
928
|
+
else if (T = typeof e.placeholderData == "function" ? e.placeholderData(
|
|
929
929
|
(De = a(this, de)) == null ? void 0 : De.state.data,
|
|
930
930
|
a(this, de)
|
|
931
|
-
) : e.placeholderData, e.select && typeof
|
|
931
|
+
) : e.placeholderData, e.select && typeof T < "u")
|
|
932
932
|
try {
|
|
933
|
-
|
|
933
|
+
T = e.select(T);
|
|
934
934
|
} catch {
|
|
935
935
|
}
|
|
936
|
-
typeof
|
|
936
|
+
typeof T < "u" && (z = "success", R = ze(
|
|
937
937
|
n == null ? void 0 : n.data,
|
|
938
|
-
|
|
938
|
+
T,
|
|
939
939
|
e
|
|
940
940
|
), Ie = !0);
|
|
941
941
|
}
|
|
@@ -1058,7 +1058,7 @@ class Dt {
|
|
|
1058
1058
|
...e,
|
|
1059
1059
|
cancelRefetch: (e == null ? void 0 : e.cancelRefetch) ?? !0
|
|
1060
1060
|
};
|
|
1061
|
-
a(this, x).fetch(this.options, r).catch(N), a(this,
|
|
1061
|
+
a(this, x).fetch(this.options, r).catch(N), a(this, Ce).next({
|
|
1062
1062
|
query: t,
|
|
1063
1063
|
fetchOptions: r
|
|
1064
1064
|
}), await t.getFetchResultAsPromise();
|
|
@@ -1114,12 +1114,12 @@ class Dt {
|
|
|
1114
1114
|
g((m) => m.options),
|
|
1115
1115
|
A(),
|
|
1116
1116
|
Ue(1)
|
|
1117
|
-
), h = a(this,
|
|
1117
|
+
), h = a(this, Ce).pipe(
|
|
1118
1118
|
$((m) => m.query === i)
|
|
1119
1119
|
), o = i.state$.pipe(
|
|
1120
1120
|
Vs,
|
|
1121
1121
|
Q(
|
|
1122
|
-
(m) => this.options.staleTime === 1 / 0 ?
|
|
1122
|
+
(m) => this.options.staleTime === 1 / 0 ? $e : (this.options.staleTime ?? 0) <= 0 ? S(m).pipe(rt(1)) : Qe(this.options.staleTime ?? 1)
|
|
1123
1123
|
),
|
|
1124
1124
|
Ge(() => this.options.enabled ?? !0)
|
|
1125
1125
|
), d = (m, _) => {
|
|
@@ -1148,7 +1148,7 @@ class Dt {
|
|
|
1148
1148
|
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
1149
1149
|
(_ || Le.isFocused()) && this.fetch({ cancelRefetch: !1 }).catch(N);
|
|
1150
1150
|
})
|
|
1151
|
-
) :
|
|
1151
|
+
) : $e),
|
|
1152
1152
|
he()
|
|
1153
1153
|
), F = f.pipe(
|
|
1154
1154
|
g(({ enabled: m }) => m ?? !0),
|
|
@@ -1192,7 +1192,7 @@ class Dt {
|
|
|
1192
1192
|
return C(b, v, R);
|
|
1193
1193
|
})
|
|
1194
1194
|
).pipe(
|
|
1195
|
-
it((i) => M(this,
|
|
1195
|
+
it((i) => M(this, Fe, i)),
|
|
1196
1196
|
E({
|
|
1197
1197
|
subscribe: () => {
|
|
1198
1198
|
mt(e, this.options) && this.fetch().catch(N);
|
|
@@ -1204,13 +1204,13 @@ class Dt {
|
|
|
1204
1204
|
destroy() {
|
|
1205
1205
|
}
|
|
1206
1206
|
}
|
|
1207
|
-
Y = new WeakMap(), x = new WeakMap(),
|
|
1207
|
+
Y = new WeakMap(), x = new WeakMap(), Ce = new WeakMap(), ue = new WeakMap(), D = new WeakMap(), de = new WeakMap(), Fe = new WeakMap();
|
|
1208
1208
|
function Ds(s, e) {
|
|
1209
1209
|
return !I(s.getCurrentResult(), e);
|
|
1210
1210
|
}
|
|
1211
|
-
const
|
|
1212
|
-
|
|
1213
|
-
function
|
|
1211
|
+
const kt = We.createContext(!1), ks = () => We.useContext(kt);
|
|
1212
|
+
kt.Provider;
|
|
1213
|
+
function Ts() {
|
|
1214
1214
|
let s = !1;
|
|
1215
1215
|
return {
|
|
1216
1216
|
clearReset: () => {
|
|
@@ -1222,7 +1222,7 @@ function ks() {
|
|
|
1222
1222
|
isReset: () => s
|
|
1223
1223
|
};
|
|
1224
1224
|
}
|
|
1225
|
-
const Ks = We.createContext(
|
|
1225
|
+
const Ks = We.createContext(Ts()), Ns = () => We.useContext(Ks);
|
|
1226
1226
|
function Hs(s, e) {
|
|
1227
1227
|
return typeof s == "function" ? s(...e) : !!s;
|
|
1228
1228
|
}
|
|
@@ -1232,19 +1232,19 @@ const qs = ({
|
|
|
1232
1232
|
throwOnError: t,
|
|
1233
1233
|
query: r
|
|
1234
1234
|
}) => s.isError && !e.isReset() && !s.isFetching && r && Hs(t, [s.error, r]);
|
|
1235
|
-
function
|
|
1235
|
+
function Tt(s, e, t) {
|
|
1236
1236
|
if (process.env.NODE_ENV !== "production" && (typeof s != "object" || Array.isArray(s)))
|
|
1237
1237
|
throw new Error(
|
|
1238
1238
|
'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'
|
|
1239
1239
|
);
|
|
1240
|
-
const r = Ut(t), n =
|
|
1240
|
+
const r = Ut(t), n = ks(), u = Ns(), i = r.defaultQueryOptions(s);
|
|
1241
1241
|
i._optimisticResults = n ? "isRestoring" : "optimistic";
|
|
1242
1242
|
const [l] = Ct(
|
|
1243
1243
|
() => new e(
|
|
1244
1244
|
r,
|
|
1245
1245
|
i
|
|
1246
1246
|
)
|
|
1247
|
-
), f = Ye(() => l.observe()), h =
|
|
1247
|
+
), f = Ye(() => l.observe()), h = k(
|
|
1248
1248
|
l.getOptimisticResult(i)
|
|
1249
1249
|
), o = h.current;
|
|
1250
1250
|
Je(
|
|
@@ -1273,10 +1273,10 @@ function kt(s, e, t) {
|
|
|
1273
1273
|
return h.current;
|
|
1274
1274
|
}
|
|
1275
1275
|
function vr(s, e) {
|
|
1276
|
-
return
|
|
1276
|
+
return Tt(s, Dt, e);
|
|
1277
1277
|
}
|
|
1278
1278
|
function Or(s, e) {
|
|
1279
|
-
return
|
|
1279
|
+
return Tt(
|
|
1280
1280
|
{
|
|
1281
1281
|
refetchOnMount: "idle",
|
|
1282
1282
|
refetchOnReconnect: !1,
|
|
@@ -1289,7 +1289,7 @@ function Or(s, e) {
|
|
|
1289
1289
|
);
|
|
1290
1290
|
}
|
|
1291
1291
|
function $r(s, e, t = []) {
|
|
1292
|
-
const r = e != null && !Array.isArray(e) ? e : {}, n = r.retry ?? !0, u =
|
|
1292
|
+
const r = e != null && !Array.isArray(e) ? e : {}, n = r.retry ?? !0, u = k(
|
|
1293
1293
|
r.onError ?? ((f) => {
|
|
1294
1294
|
console.error(f);
|
|
1295
1295
|
})
|
|
@@ -1328,9 +1328,9 @@ const Kt = () => (s) => C(
|
|
|
1328
1328
|
* timer needed to be iso RQ, so the state returned by mutation include both previous and next one
|
|
1329
1329
|
*/
|
|
1330
1330
|
Qe(1).pipe(
|
|
1331
|
-
H(() =>
|
|
1331
|
+
H(() => Se(() => t).pipe(Kt()))
|
|
1332
1332
|
)
|
|
1333
|
-
) :
|
|
1333
|
+
) : Se(() => t)))
|
|
1334
1334
|
);
|
|
1335
1335
|
}, Ls = ({
|
|
1336
1336
|
variables: s,
|
|
@@ -1404,7 +1404,7 @@ const Kt = () => (s) => C(
|
|
|
1404
1404
|
!0
|
|
1405
1405
|
)
|
|
1406
1406
|
);
|
|
1407
|
-
return se.isOnline() || t.networkMode === "offlineFirst" ? F : F.pipe(Kt());
|
|
1407
|
+
return se.isOnline() || t.networkMode === "offlineFirst" || t.networkMode === "always" ? F : F.pipe(Kt());
|
|
1408
1408
|
})
|
|
1409
1409
|
), o = S({
|
|
1410
1410
|
...e,
|
|
@@ -1449,8 +1449,8 @@ const Kt = () => (s) => C(
|
|
|
1449
1449
|
).pipe(
|
|
1450
1450
|
te((V) => c ? S(c) : S(V))
|
|
1451
1451
|
);
|
|
1452
|
-
return
|
|
1453
|
-
|
|
1452
|
+
return ke(p, O).pipe(
|
|
1453
|
+
Te(),
|
|
1454
1454
|
g(
|
|
1455
1455
|
() => b ? {
|
|
1456
1456
|
error: b,
|
|
@@ -1490,20 +1490,20 @@ const Kt = () => (s) => C(
|
|
|
1490
1490
|
)
|
|
1491
1491
|
);
|
|
1492
1492
|
};
|
|
1493
|
-
var
|
|
1493
|
+
var Ee, ee, pe;
|
|
1494
1494
|
class _s {
|
|
1495
1495
|
constructor({
|
|
1496
1496
|
options: e,
|
|
1497
1497
|
mutationCache: t,
|
|
1498
1498
|
state: r
|
|
1499
1499
|
}) {
|
|
1500
|
-
w(this,
|
|
1500
|
+
w(this, Ee, new J(0));
|
|
1501
1501
|
w(this, ee, new P());
|
|
1502
1502
|
w(this, pe, new P());
|
|
1503
1503
|
y(this, "state", ne());
|
|
1504
1504
|
y(this, "state$");
|
|
1505
1505
|
y(this, "options");
|
|
1506
|
-
y(this, "observerCount$", a(this,
|
|
1506
|
+
y(this, "observerCount$", a(this, Ee).asObservable());
|
|
1507
1507
|
y(this, "cancelled$", a(this, ee).asObservable());
|
|
1508
1508
|
this.options = e, this.state = r ?? this.state;
|
|
1509
1509
|
const n = a(this, pe).pipe(
|
|
@@ -1547,7 +1547,7 @@ class _s {
|
|
|
1547
1547
|
return (c = (d = this.options).onError) == null ? void 0 : c.call(d, i, l, f);
|
|
1548
1548
|
}
|
|
1549
1549
|
);
|
|
1550
|
-
return
|
|
1550
|
+
return ke(h, o).pipe(Te());
|
|
1551
1551
|
},
|
|
1552
1552
|
onSettled: (i, l, f, h) => {
|
|
1553
1553
|
const o = U(
|
|
@@ -1568,7 +1568,7 @@ class _s {
|
|
|
1568
1568
|
return (b = (c = this.options).onSettled) == null ? void 0 : b.call(c, i, l, f, h);
|
|
1569
1569
|
}
|
|
1570
1570
|
);
|
|
1571
|
-
return
|
|
1571
|
+
return ke(o, d).pipe(Te());
|
|
1572
1572
|
},
|
|
1573
1573
|
onSuccess: (i, l, f) => {
|
|
1574
1574
|
const h = U(
|
|
@@ -1588,7 +1588,7 @@ class _s {
|
|
|
1588
1588
|
return (c = (d = this.options).onSuccess) == null ? void 0 : c.call(d, i, l, f);
|
|
1589
1589
|
}
|
|
1590
1590
|
);
|
|
1591
|
-
return
|
|
1591
|
+
return ke(h, o).pipe(Te());
|
|
1592
1592
|
}
|
|
1593
1593
|
},
|
|
1594
1594
|
state: this.state,
|
|
@@ -1602,7 +1602,7 @@ class _s {
|
|
|
1602
1602
|
* We keep state forever since only a explicit destroy
|
|
1603
1603
|
* may terminate the mutation
|
|
1604
1604
|
*/
|
|
1605
|
-
|
|
1605
|
+
$e
|
|
1606
1606
|
).pipe(
|
|
1607
1607
|
oe(this.state),
|
|
1608
1608
|
E((u) => {
|
|
@@ -1616,7 +1616,7 @@ class _s {
|
|
|
1616
1616
|
*/
|
|
1617
1617
|
Ue({ bufferSize: 1, refCount: !1 }),
|
|
1618
1618
|
it((u) => {
|
|
1619
|
-
a(this,
|
|
1619
|
+
a(this, Ee).next(u);
|
|
1620
1620
|
})
|
|
1621
1621
|
);
|
|
1622
1622
|
}
|
|
@@ -1632,7 +1632,7 @@ class _s {
|
|
|
1632
1632
|
* is over, unlike the state which can be re-subscribed later.
|
|
1633
1633
|
*/
|
|
1634
1634
|
execute(e) {
|
|
1635
|
-
return a(this, pe).next(e), a(this, pe).complete(), this.state$.pipe(
|
|
1635
|
+
return a(this, pe).next(e), a(this, pe).complete(), this.state$.pipe(we);
|
|
1636
1636
|
}
|
|
1637
1637
|
continue() {
|
|
1638
1638
|
return this.execute(this.state.variables);
|
|
@@ -1642,7 +1642,7 @@ class _s {
|
|
|
1642
1642
|
a(this, ee).next(), a(this, ee).complete();
|
|
1643
1643
|
}
|
|
1644
1644
|
}
|
|
1645
|
-
|
|
1645
|
+
Ee = new WeakMap(), ee = new WeakMap(), pe = new WeakMap();
|
|
1646
1646
|
const wt = ({
|
|
1647
1647
|
mutationKey: s,
|
|
1648
1648
|
status: e,
|
|
@@ -1671,7 +1671,7 @@ class Nt {
|
|
|
1671
1671
|
y(this, "stateChange$", C(
|
|
1672
1672
|
this.entriesSubject.pipe(
|
|
1673
1673
|
st(),
|
|
1674
|
-
H((e) =>
|
|
1674
|
+
H((e) => Oe(e))
|
|
1675
1675
|
),
|
|
1676
1676
|
this.added$
|
|
1677
1677
|
).pipe(
|
|
@@ -1798,7 +1798,7 @@ class Ws {
|
|
|
1798
1798
|
predicate: (r) => r.state.isPaused
|
|
1799
1799
|
});
|
|
1800
1800
|
if (!e.length)
|
|
1801
|
-
return
|
|
1801
|
+
return ge;
|
|
1802
1802
|
const t = e.map((r) => r.continue());
|
|
1803
1803
|
return is(t);
|
|
1804
1804
|
}
|
|
@@ -2020,14 +2020,14 @@ function Ht(s) {
|
|
|
2020
2020
|
return e;
|
|
2021
2021
|
}
|
|
2022
2022
|
const sr = Ht("production");
|
|
2023
|
-
var
|
|
2023
|
+
var xe, ae;
|
|
2024
2024
|
class rr {
|
|
2025
2025
|
constructor(e) {
|
|
2026
2026
|
y(this, "queryKey");
|
|
2027
2027
|
y(this, "queryHash");
|
|
2028
2028
|
y(this, "gcTime");
|
|
2029
2029
|
y(this, "options");
|
|
2030
|
-
w(this,
|
|
2030
|
+
w(this, xe, void 0);
|
|
2031
2031
|
w(this, ae, void 0);
|
|
2032
2032
|
y(this, "state");
|
|
2033
2033
|
// @todo to share with mutation
|
|
@@ -2042,7 +2042,7 @@ class rr {
|
|
|
2042
2042
|
y(this, "observerCount$", this.observersSubject.asObservable().pipe(g((e) => e.length)));
|
|
2043
2043
|
y(this, "observers$", this.observersSubject.asObservable());
|
|
2044
2044
|
y(this, "state$");
|
|
2045
|
-
M(this,
|
|
2045
|
+
M(this, xe, e.defaultOptions), this.options = this.setOptions(e.options), this.queryKey = e.queryKey, this.queryHash = e.queryHash, M(this, ae, e.state ?? Js(this.options)), this.state = a(this, ae), this.gcTime = this.updateGcTime(this.options.gcTime), this.state$ = C(
|
|
2046
2046
|
this.resetSubject.pipe(
|
|
2047
2047
|
g(() => ({ command: "reset", state: a(this, ae) }))
|
|
2048
2048
|
),
|
|
@@ -2144,7 +2144,7 @@ class rr {
|
|
|
2144
2144
|
);
|
|
2145
2145
|
}
|
|
2146
2146
|
setOptions(e) {
|
|
2147
|
-
return this.options = { ...a(this,
|
|
2147
|
+
return this.options = { ...a(this, xe), ...e }, this.updateGcTime(this.options.gcTime), this.options;
|
|
2148
2148
|
}
|
|
2149
2149
|
get meta() {
|
|
2150
2150
|
return this.options.meta;
|
|
@@ -2242,13 +2242,13 @@ class rr {
|
|
|
2242
2242
|
this.resetSubject.next();
|
|
2243
2243
|
}
|
|
2244
2244
|
}
|
|
2245
|
-
|
|
2246
|
-
var
|
|
2245
|
+
xe = new WeakMap(), ae = new WeakMap();
|
|
2246
|
+
var Re, G;
|
|
2247
2247
|
class nr {
|
|
2248
2248
|
// protected mountSubscriptions: Subscription[]
|
|
2249
2249
|
constructor(e = {}) {
|
|
2250
2250
|
// readonly #queries: QueryStore = new Map<string, Query>()
|
|
2251
|
-
w(this,
|
|
2251
|
+
w(this, Re, new P());
|
|
2252
2252
|
w(this, G, new Nt());
|
|
2253
2253
|
this.config = e;
|
|
2254
2254
|
}
|
|
@@ -2257,7 +2257,7 @@ class nr {
|
|
|
2257
2257
|
unmount() {
|
|
2258
2258
|
}
|
|
2259
2259
|
notify(e) {
|
|
2260
|
-
a(this,
|
|
2260
|
+
a(this, Re).next(e);
|
|
2261
2261
|
}
|
|
2262
2262
|
observeIsFetching(e) {
|
|
2263
2263
|
return a(this, G).stateChange$.pipe(
|
|
@@ -2318,8 +2318,8 @@ class nr {
|
|
|
2318
2318
|
Ps,
|
|
2319
2319
|
Q((r) => r ? t.pipe(
|
|
2320
2320
|
// defaults to 5mn
|
|
2321
|
-
Q(() => e.gcTime === 1 / 0 ?
|
|
2322
|
-
) :
|
|
2321
|
+
Q(() => e.gcTime === 1 / 0 ? $e : (setTimeout(N, e.gcTime), Qe(e.gcTime)))
|
|
2322
|
+
) : $e),
|
|
2323
2323
|
He(1)
|
|
2324
2324
|
).subscribe({
|
|
2325
2325
|
complete: () => {
|
|
@@ -2339,7 +2339,7 @@ class nr {
|
|
|
2339
2339
|
}
|
|
2340
2340
|
subscribe(e) {
|
|
2341
2341
|
const t = C(
|
|
2342
|
-
a(this,
|
|
2342
|
+
a(this, Re).pipe(E(e))
|
|
2343
2343
|
// this.#store.added$.pipe(
|
|
2344
2344
|
// mergeMap((query) => {
|
|
2345
2345
|
// fn({
|
|
@@ -2375,8 +2375,8 @@ class nr {
|
|
|
2375
2375
|
clear() {
|
|
2376
2376
|
}
|
|
2377
2377
|
}
|
|
2378
|
-
|
|
2379
|
-
var ce, j,
|
|
2378
|
+
Re = new WeakMap(), G = new WeakMap();
|
|
2379
|
+
var ce, j, Me, je, ye;
|
|
2380
2380
|
class wr {
|
|
2381
2381
|
// #destroy = () => {}
|
|
2382
2382
|
constructor({
|
|
@@ -2386,10 +2386,10 @@ class wr {
|
|
|
2386
2386
|
} = {}) {
|
|
2387
2387
|
w(this, ce, void 0);
|
|
2388
2388
|
w(this, j, void 0);
|
|
2389
|
-
w(this, Re, /* @__PURE__ */ new Map());
|
|
2390
2389
|
w(this, Me, /* @__PURE__ */ new Map());
|
|
2391
|
-
w(this, je,
|
|
2392
|
-
|
|
2390
|
+
w(this, je, /* @__PURE__ */ new Map());
|
|
2391
|
+
w(this, ye, void 0);
|
|
2392
|
+
M(this, ce, e ?? new Ws()), M(this, j, t ?? new nr()), M(this, ye, r ?? {});
|
|
2393
2393
|
}
|
|
2394
2394
|
mount() {
|
|
2395
2395
|
}
|
|
@@ -2403,6 +2403,7 @@ class wr {
|
|
|
2403
2403
|
}
|
|
2404
2404
|
defaultMutationOptions(e) {
|
|
2405
2405
|
return {
|
|
2406
|
+
...a(this, ye).mutations,
|
|
2406
2407
|
...(e == null ? void 0 : e.mutationKey) && this.getMutationDefaults(e.mutationKey),
|
|
2407
2408
|
...e
|
|
2408
2409
|
};
|
|
@@ -2411,7 +2412,7 @@ class wr {
|
|
|
2411
2412
|
if (e != null && e._defaulted)
|
|
2412
2413
|
return e;
|
|
2413
2414
|
const t = {
|
|
2414
|
-
...a(this,
|
|
2415
|
+
...a(this, ye).queries,
|
|
2415
2416
|
...(e == null ? void 0 : e.queryKey) && this.getQueryDefaults(e.queryKey),
|
|
2416
2417
|
...e,
|
|
2417
2418
|
_defaulted: !0
|
|
@@ -2462,7 +2463,7 @@ class wr {
|
|
|
2462
2463
|
return a(this, j).build(this, l).setData(i, { ...r, manual: !0 });
|
|
2463
2464
|
}
|
|
2464
2465
|
getMutationDefaults(e) {
|
|
2465
|
-
const t = [...a(this,
|
|
2466
|
+
const t = [...a(this, Me).values()];
|
|
2466
2467
|
let r = {};
|
|
2467
2468
|
return t.forEach((n) => {
|
|
2468
2469
|
qe(e, n.mutationKey) && (r = { ...r, ...n.defaultOptions });
|
|
@@ -2473,19 +2474,19 @@ class wr {
|
|
|
2473
2474
|
return (t = a(this, j).find({ queryKey: e })) == null ? void 0 : t.state;
|
|
2474
2475
|
}
|
|
2475
2476
|
setMutationDefaults(e, t) {
|
|
2476
|
-
a(this,
|
|
2477
|
+
a(this, Me).set(me(e), {
|
|
2477
2478
|
mutationKey: e,
|
|
2478
2479
|
defaultOptions: t
|
|
2479
2480
|
});
|
|
2480
2481
|
}
|
|
2481
2482
|
setQueryDefaults(e, t) {
|
|
2482
|
-
a(this,
|
|
2483
|
+
a(this, je).set(me(e), {
|
|
2483
2484
|
queryKey: e,
|
|
2484
2485
|
defaultOptions: t
|
|
2485
2486
|
});
|
|
2486
2487
|
}
|
|
2487
2488
|
getQueryDefaults(e) {
|
|
2488
|
-
const t = [...a(this,
|
|
2489
|
+
const t = [...a(this, je).values()];
|
|
2489
2490
|
let r = {};
|
|
2490
2491
|
return t.forEach((n) => {
|
|
2491
2492
|
Be(e, n.queryKey) && (r = { ...r, ...n.defaultOptions });
|
|
@@ -2526,7 +2527,7 @@ class wr {
|
|
|
2526
2527
|
a(this, j).clear(), a(this, ce).clear();
|
|
2527
2528
|
}
|
|
2528
2529
|
}
|
|
2529
|
-
ce = new WeakMap(), j = new WeakMap(),
|
|
2530
|
+
ce = new WeakMap(), j = new WeakMap(), Me = new WeakMap(), je = new WeakMap(), ye = new WeakMap();
|
|
2530
2531
|
export {
|
|
2531
2532
|
Ws as MutationCache,
|
|
2532
2533
|
nr as QueryCache,
|
|
@@ -2543,7 +2544,7 @@ export {
|
|
|
2543
2544
|
fr as signal,
|
|
2544
2545
|
ps as useBehaviorSubject,
|
|
2545
2546
|
Or as useForeverQuery,
|
|
2546
|
-
|
|
2547
|
+
k as useLiveRef,
|
|
2547
2548
|
Sr as useMutation,
|
|
2548
2549
|
hr as useObservableState,
|
|
2549
2550
|
Je as useObserve,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type Observable, type MonoTypeOperatorFunction } from "rxjs";
|
|
2
2
|
import { type DefaultError, type DeprecatedQuery, type QueryResult, type Register } from "../../types";
|
|
3
3
|
import { type MapOperator, type MutationFn, type MutationKey } from "../types";
|
|
4
|
+
import { type NetworkMode } from "../../queries/types";
|
|
4
5
|
export type MutationStatus = "idle" | "pending" | "success" | "error";
|
|
5
6
|
export interface MutationState<TData = unknown, TError = unknown, TVariables = void, TContext = unknown> {
|
|
6
7
|
context: TContext | undefined;
|
|
@@ -17,7 +18,7 @@ export type MutationMeta = Register extends {
|
|
|
17
18
|
mutationMeta: infer TMutationMeta;
|
|
18
19
|
} ? TMutationMeta extends Record<string, unknown> ? TMutationMeta : Record<string, unknown> : Record<string, unknown>;
|
|
19
20
|
export interface MutationOptions<TData, TError = DefaultError, TVariables = void, TContext = unknown> {
|
|
20
|
-
networkMode?:
|
|
21
|
+
networkMode?: NetworkMode;
|
|
21
22
|
enabled?: boolean;
|
|
22
23
|
retry?: false | number | ((attempt: number, error: unknown) => boolean);
|
|
23
24
|
retryDelay?: number | ((failureCount: number, error: TError) => number);
|