reactjrx 1.142.1 → 1.142.2

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 CHANGED
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let e=require("react/compiler-runtime"),t=require("react"),r=require("rxjs"),n=require("rxjs/operators"),s=require("@tanstack/react-query"),o=require("react/jsx-runtime");var a=Symbol("UNSET"),u=e=>{const r=(0,t.useRef)(a);return r.current===a&&(r.current=e()),r},i=e=>u(e).current,c=n=>{const s=(0,e.c)(6);let o;s[0]!==n?(o=()=>new r.BehaviorSubject(n),s[0]=n,s[1]=o):o=s[1];const a=i(o);let u,c;return s[2]!==n||s[3]!==a?(u=()=>{a.next(n)},c=[n,a],s[2]=n,s[3]=a,s[4]=u,s[5]=c):(u=s[4],c=s[5]),(0,t.useEffect)(u,c),a},l=(e,t)=>e.length===t.length&&e.every((e,r)=>e===t[r]);function p(e){return e instanceof Promise||e&&"object"==typeof e&&"then"in e&&"function"==typeof e.then&&"catch"in e&&"function"==typeof e.catch}var f="undefined"==typeof window||"Deno"in window;function y(e,t){return Math.min(e,t)}function d(e,t){return 2**e*t}var m=r=>{const n=(0,e.c)(1);let s;n[0]===Symbol.for("react.memo_cache_sentinel")?(s=[],n[0]=s):s=n[0],(0,t.useEffect)(r,s)},v=e=>{const r=(0,t.useRef)(e);r.current=e,m(()=>()=>r.current())},b=e=>{const r=(0,t.useRef)(e);return(0,t.useMemo)(()=>{r.current=e},[e]),r},h=class{state;source$;sub;constructor({source$:e,defaultValue:t,compareFn:n}){const s="function"==typeof e?e():e,o=void 0===s;if(this.state={data:s instanceof r.BehaviorSubject?s.value:t,status:o?"success":"pending",observableState:o?"complete":"live",error:void 0},o)return this.source$=r.NEVER,void(this.sub=r.Subscription.EMPTY);this.source$=s.pipe((0,r.distinctUntilChanged)(n),(0,r.tap)({complete:()=>{this.state={...this.state,status:"success",observableState:"complete"}},error:e=>{this.state={...this.state,observableState:"error",status:"error",error:e}},next:e=>{this.state={...this.state,data:e}}}),(0,r.share)()),this.sub=this.source$.subscribe()}subscribe=e=>{if("complete"===this.state.observableState)return()=>{};const t=this.source$.subscribe({complete:e,error:e,next:e});return()=>{t.unsubscribe()}};getSnapshot=()=>this.state};function g(r,n,s){const o=(0,e.c)(6);let a;o[0]!==n?(a=null==n||Array.isArray(n)?{defaultValue:void 0,compareFn:void 0}:n,o[0]=n,o[1]=a):a=o[1];const u=a;let i;o[2]!==s||o[3]!==n||o[4]!==r?(i=!s&&Array.isArray(n)?n:"function"==typeof r?s??[]:[r],o[2]=s,o[3]=n,o[4]=r,o[5]=i):i=o[5];const c=((e,r,n)=>{const s=b(r),o=(0,t.useRef)(void 0);o.current&&l(n,o.current.deps)||(o.current={deps:n,store:new h({source$:e,defaultValue:s.current.defaultValue,compareFn:(e,t)=>s.current?.compareFn?.(e,t)??e===t})});const a=o.current.store;return(0,t.useEffect)(()=>()=>{a.sub.unsubscribe()},[a]),a})(r,u,i);return(0,t.useSyncExternalStore)(c.subscribe,c.getSnapshot,c.getSnapshot)}function x(e){if((0,r.isObservable)(e))return()=>e;if(p(e))return()=>(0,r.from)(e);if("function"!=typeof e)return()=>(0,r.of)(e);const t=e;return e=>(0,r.defer)(()=>{const n=t(e);return p(n)?(0,r.from)(n):(0,r.isObservable)(n)?n:(0,r.of)(n)})}function S(r){const n=(0,e.c)(3);let s,o;n[0]!==r?(s=()=>{const e=x(r)().subscribe();return()=>{e.unsubscribe()}},o=[r],n[0]=r,n[1]=s,n[2]=o):(s=n[1],o=n[2]),(0,t.useEffect)(s,o)}var w=class{queryClient;queryMap=/* @__PURE__ */new Map;constructor(e){this.queryClient=e}getQuery(e){return this.queryMap.get(e)}setQuery(e,t,n){const o=(0,s.hashKey)(e),a=t.pipe((0,r.takeUntil)((0,r.fromEvent)(n,"abort")),(0,r.share)()),u={queryKey:e,query$:a,signal:n,sub:void 0,isCompleted:!1,lastData:void 0};return this.queryMap.set(o,u),u.sub=a.subscribe({next:e=>{const t=this.queryMap.get(o);t&&(t.lastData={value:e})},complete:()=>{this.queryMap.get(o)===u&&this.deleteQuery(o)}}),u}deleteQuery(e,{cancelQuery:t=!1}={}){const r=this.queryMap.get(e);r&&(r.isCompleted=!0,this.queryMap.delete(e),r.sub&&(r.sub.unsubscribe(),r.sub=void 0),t&&!r.signal.aborted&&void 0!==r.lastData&&this.queryClient?.cancelQueries({queryKey:r.queryKey,exact:!0}))}destroy(){this.queryMap.forEach((e,t)=>{this.deleteQuery(t,{cancelQuery:!0})})}},E=(0,t.createContext)(void 0),I=(0,t.memo)(function(r){const n=(0,e.c)(13),{children:a,client:u}=r,i=(0,s.useQueryClient)();let c;n[0]!==u||n[1]!==i?(c=()=>u??new w(i),n[0]=u,n[1]=i,n[2]=c):c=n[2];const[l]=(0,t.useState)(c);let p,f,y,d,m;return n[3]!==l||n[4]!==i?(p=function(){return i.getQueryCache().subscribe(e=>{const t=e.query.getObserversCount();"observerRemoved"===e.type&&0===t&&l.deleteQuery(e.query.queryHash,{cancelQuery:!0})})},f=[i,l],n[3]=l,n[4]=i,n[5]=p,n[6]=f):(p=n[5],f=n[6]),(0,t.useEffect)(p,f),n[7]!==l?(y=()=>()=>{l.destroy()},d=[l],n[7]=l,n[8]=y,n[9]=d):(y=n[8],d=n[9]),(0,t.useEffect)(y,d),n[10]!==a||n[11]!==l?(m=/* @__PURE__ */ /* @__PURE__ */(0,o.jsx)(E.Provider,{value:l,children:a}),n[10]=a,n[11]=l,n[12]=m):m=n[12],m}),C=()=>{const e=(0,t.useContext)(E);if(!e)throw new Error("useReactJrxQueryClient must be used within a ReactJrxQueryProvider");return e};function M(e,t){return"function"==typeof e?e(t):e}function q({onMutate:e,onSuccess:t,onError:r,onSettled:n}){return{onMutate:e?({variables:t},...r)=>e(t,...r):void 0,onSuccess:(e,{variables:r},...n)=>t?.(e,r,...n),onError:(e,{variables:t},...n)=>r?.(e,t,...n),onSettled:(e,t,{variables:r},...s)=>n?.(e,t,r,...s)}}function V(n,o){const a=(0,e.c)(16),u=i(j);let c,l;a[0]!==n?(c=e=>{let t;return new Promise((s,o)=>{M(n.mutationFn,e).pipe((0,r.take)(1)).subscribe({next:e=>{t={value:e}},error:e=>{o(e)},complete:()=>{if(void 0===t)return o(/* @__PURE__ */new Error("Stream completed without any data"));s(t.value)}})})},a[0]=n,a[1]=c):c=a[1],a[2]!==n||a[3]!==c?(l={...n,mutationFn:c},a[2]=n,a[3]=c,a[4]=l):l=a[4];const p=(0,s.useMutation)(l,o),{status:f,isPending:y,isError:d,isSuccess:m,isIdle:v}=p;let b,h,g;return a[5]!==d||a[6]!==v||a[7]!==y||a[8]!==m||a[9]!==u||a[10]!==f?(b=()=>{u.next({status:f,isPending:y,isError:d,isSuccess:m,isIdle:v})},h=[f,y,d,m,v,u],a[5]=d,a[6]=v,a[7]=y,a[8]=m,a[9]=u,a[10]=f,a[11]=b,a[12]=h):(b=a[11],h=a[12]),(0,t.useEffect)(b,h),a[13]!==p||a[14]!==u?(g={...p,state$:u},a[13]=p,a[14]=u,a[15]=g):g=a[15],g}function j(){return new r.BehaviorSubject({status:"idle",isPending:!1,isError:!1,isSuccess:!1,isIdle:!0})}function O(e){return e.continue().catch(r.noop)}function Q(e){return e}function k(e,t,n){return n===s.skipToken||void 0===n?n:o=>new Promise((a,u)=>{const i=(0,s.hashKey)(o.queryKey),c=e.getQuery(i),l=c??e.setQuery(o.queryKey,(0,r.defer)(()=>"function"==typeof n?n(o):n),o.signal),p=()=>{!1===l?.isCompleted&&setTimeout(()=>{l?.isCompleted||t?.refetchQueries({queryKey:o.queryKey,exact:!0})})};if(!c&&void 0!==l.lastData)return a(l.lastData.value),void p();l.query$.pipe((0,r.take)(1),(0,r.delay)(1)).subscribe({error:e=>u(e),complete:()=>{if(void 0===l?.lastData)return l.signal.aborted||console.warn(`cancelled due to stream completing without data for query ${i}`),u(new s.CancelledError);a(l.lastData.value),p()}})})}var N=class extends Error{constructor(e="Mutation canceled"){super(e),this.name="SwitchMutationCancelError"}};function P(){throw new N}function $(){return new AbortController}var _=Symbol("SIGNAL_RESET"),F=e=>{if(e&&"object"==typeof e)return e},T=({key:e}={})=>e?(({adapter:e,key:t})=>({clear:async()=>await e.removeItem(t),removeItem:async r=>{const n=await e.getItem(t),{[r]:s,...o}=F(n)??{};await e.setItem(t,o)},getItem:async r=>{const n=await e.getItem(t),s=F(n)??{};if(r in s)return s[r]},setItem:async(r,n)=>{const s=await e.getItem(t),o=F(s)??{};await e.setItem(t,{...o,[r]:n})}}))({adapter:T(),key:e}):{clear:async()=>{localStorage.clear()},removeItem:async e=>{localStorage.removeItem(e)},getItem:async e=>{const t=localStorage.getItem(e);if(t)return JSON.parse(t)},setItem:async(e,t)=>{localStorage.setItem(e,JSON.stringify(t))}},A=class extends r.BehaviorSubject{config;constructor(e){super(e.default),this.config=e}update=e=>{if(e===_)super.next(this.config.default);else if("function"==typeof e){const t=e;super.next(t(this.value))}else super.next(e)};setValue=this.update.bind(this);get subject(){return this}get key(){return this.config.key}},D=class{config;constructor(e){this.config=e}};var R=class{signals=new r.BehaviorSubject(/* @__PURE__ */new Map);isDestroyed=!1;getOrCreateSignal(e){const t=this.signals.value.get(e);if(t)return t;const r=new A({...e.config,key:void 0});return this.signals.value.set(e,r),this.signals.next(this.signals.value),r}destroy(){this.signals.value.forEach(e=>{e.complete()}),this.signals.value.clear(),this.signals.complete(),this.isDestroyed=!0}},K=(0,t.createContext)(new R),B=(0,t.memo)(({children:e})=>{const r=u(()=>new R),n=r.current,[s,a]=(0,t.useState)(!1);s&&(r.current=new R,a(!1));const i=n;return(0,t.useEffect)(()=>()=>{r.current?.destroy(),a(!0)},[r]),/* @__PURE__ */ /* @__PURE__ */(0,o.jsx)(K.Provider,{value:i,children:e})}),H=()=>(0,t.useContext)(K);function L(e,t){if(null==e||void 0===t)return e===t;if("object"!=typeof e||"object"!=typeof t)return e===t;if(e.constructor!==t?.constructor)return!1;const r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(const s of r)if(!t.hasOwnProperty(s)||e[s]!==t[s])return!1;return!0}var J="__reactjrx";function U({entries:e=[],onHydrated:t,adapter:n}){const s=(0===e.length?(0,r.of)([]):(0,r.zip)(...e.map(e=>function({adapter:e,config:t}){const{hydrate:n=({value:e})=>e,signal:s,version:o}=t;return(0,r.from)(e.getItem(s.config.key)).pipe((0,r.switchMap)(e=>{const t=(e=>{if("object"==typeof e&&null!==e&&"__reactjrx"in e&&"__reactjrx"===e.__reactjrx)return e})(e);if(!t)return(0,r.of)(e);const a="number"!=typeof t.migrationVersion,u=void 0!==t.migrationVersion&&o>t.migrationVersion;if(a||u||void 0===t.value)return(0,r.of)(e);const i=t.value;return"development"===process.env.NODE_ENV&&console.log("[reactjrx][state][persistance]:","Hydrate value",t,`for signal ${s.config.key}`),s.setValue(n({value:i,version:o})),(0,r.of)(e)}))}({adapter:n,config:e})))).pipe((0,r.tap)(t),(0,r.catchError)(e=>(console.error("Unable to hydrate",e),r.EMPTY)),(0,r.share)()),o=s.pipe((0,r.switchMap)(()=>(0,r.merge)(...e.map(e=>e.signal.pipe((0,r.throttleTime)(500,r.asyncScheduler,{trailing:!0}),(0,r.switchMap)(()=>(0,r.from)((({adapter:e,config:t})=>{const{signal:n,version:s}=t,o={value:n.getValue(),[J]:J,migrationVersion:s};return"development"===process.env.NODE_ENV&&console.log("[reactjrx][state][persistance]:","Persist value",o,`for signal ${n.config.key}`),(0,r.from)(e.setItem(n.config.key,o)).pipe((0,r.catchError)(e=>(console.error(e),(0,r.of)(null))))})({adapter:n,config:e}))))))));return(0,r.merge)(s.pipe((0,r.map)(()=>({type:"hydrated"}))),o.pipe((0,r.map)(()=>({type:"persisted"}))))}function Y(e,t){return"reset"===t.type?{isHydrated:!1}:"hydrated"===t.type?{isHydrated:!0}:e}function G(t){const r=(0,e.c)(3),n=H();if(t instanceof D&&!n)throw new Error("useSignalValue must be used within a SignalContextProvider");let s;return r[0]!==t||r[1]!==n?(s=t instanceof D?n.getOrCreateSignal(t):t,r[0]=t,r[1]=n,r[2]=s):s=r[2],s}function z(e){return G(e).update}var W=Object.is;function X(n,s,o){const a=(0,e.c)(7),u=void 0===o?W:o,i=G(n);let c;a[0]===Symbol.for("react.memo_cache_sentinel")?(c={hasValue:!1,signal:void 0,selector:void 0,sourceValue:void 0,value:void 0},a[0]=c):c=a[0];const l=(0,t.useRef)(c);let p;a[1]!==i?(p=e=>{const t=i.pipe((0,r.skip)(1)).subscribe(()=>{e()});return()=>{t.unsubscribe()}},a[1]=i,a[2]=p):p=a[2];const f=p;let y;a[3]!==u||a[4]!==i||a[5]!==s?(y=()=>{const e=l.current,t=i.value;if(e.hasValue&&e.signal===i&&e.selector===s&&e.sourceValue===t)return e.value;const r=s?s(t):t;return e.hasValue&&e.signal===i&&u(e.value,r)?(l.current={hasValue:!0,signal:i,selector:s,sourceValue:t,value:e.value},e.value):(l.current={hasValue:!0,signal:i,selector:s,sourceValue:t,value:r},r)},a[3]=u,a[4]=i,a[5]=s,a[6]=y):y=a[6];const d=y;return(0,t.useSyncExternalStore)(f,d,d)}exports.Context=E,exports.QueryClient$=w,exports.QueryClientProvider$=I,exports.SIGNAL_RESET=_,exports.Signal=A,exports.SignalContextProvider=B,exports.SignalReactContext=K,exports.SwitchMutationCancelError=N,exports.VirtualSignal=D,exports.arrayEqual=l,exports.createLocalStorageAdapter=T,exports.createLocalforageAdapter=e=>({getItem:async t=>{const r=await e.getItem(t);if(r)return JSON.parse(r)},setItem:async(t,r)=>{await e.setItem(t,JSON.stringify(r))},removeItem:async e=>{},clear:async()=>{}}),exports.exponentialBackoffDelay=d,exports.getDelay=y,exports.isDefined=function(e){return null!=e},exports.isPromiseLike=p,exports.isServer=f,exports.retryBackoff=function(e){const{retry:t,retryAfterDelay:s,retryAfter:o=()=>(0,r.of)(!0)}=e,a="function"!=typeof t?!1===t?0:!0===t?Number.POSITIVE_INFINITY:t??Number.POSITIVE_INFINITY:Number.POSITIVE_INFINITY,u="function"==typeof t?t:()=>!0,{initialInterval:i=100,maxInterval:c=Number.POSITIVE_INFINITY,resetOnSuccess:l=!1,backoffDelay:p=d}={shouldRetry:u,...e};return t=>(0,r.defer)(()=>{let f=0;const d=(e,t)=>e<a&&u(e,t);return t.pipe((0,n.catchError)(t=>{if(f++,!d(f-1,t))throw t;const s=e.caughtError?.(f,t);if(!s)throw t;return s.pipe((0,n.mergeMap)(e=>(0,r.merge)((0,r.of)(e),(0,r.throwError)(()=>t))))}),(0,n.retryWhen)(e=>e.pipe((0,n.concatMap)(e=>{const t=f-1;return o().pipe((0,n.first)(),(0,n.mergeMap)(()=>d(t,e)?(0,r.timer)(y(p(t,i),c)).pipe((0,n.mergeMap)(n=>s&&!s(t,e)?(0,r.throwError)(()=>e):(0,r.of)(n))):(0,r.throwError)(()=>e)))}))),(0,n.catchError)(t=>{if(e.catchError)return e.catchError(f,t);throw t}),(0,n.tap)(()=>{l&&(f=0)}))})},exports.signal=function(e={}){return new A({key:void 0,...e,default:e.default??void 0})},exports.useConcatMutation$=function(t,n){const o=(0,e.c)(21),a=(0,s.useQueryClient)(n),u=t.mutationKey;let i,c,l;o[0]!==t?(i=q(t),o[0]=t,o[1]=i):i=o[1],o[2]!==t.mutationFn?(c=e=>{const{ready$:n,variables:s}=e,o=M(t.mutationFn,s);return n.pipe((0,r.filter)(Q),(0,r.first)(),(0,r.switchMap)(()=>o))},o[2]=t.mutationFn,o[3]=c):c=o[3],o[4]!==t||o[5]!==i||o[6]!==c?(l={...t,...i,mutationFn:c},o[4]=t,o[5]=i,o[6]=c,o[7]=l):l=o[7];const p=V(l,n);let f,y,d;o[8]!==p?(({mutateAsync:f,...y}=p),o[8]=p,o[9]=f,o[10]=y):(f=o[9],y=o[10]),o[11]!==a||o[12]!==f||o[13]!==u?(d=async e=>{const t=a.getMutationCache().findAll({mutationKey:u,exact:!0}),n=new r.BehaviorSubject(!1),s=f({variables:e,ready$:n});return await Promise.all(t.map(O)),n.next(!0),await s.finally(()=>{n.complete()})},o[11]=a,o[12]=f,o[13]=u,o[14]=d):d=o[14];const m=d;let v;o[15]!==m?(v=e=>{m(e).catch(r.noop)},o[15]=m,o[16]=v):v=o[16];const b=v;let h;return o[17]!==m||o[18]!==b||o[19]!==y?(h={...y,mutate:b,mutateAsync:m},o[17]=m,o[18]=b,o[19]=y,o[20]=h):h=o[20],h},exports.useConstant=i,exports.useDebounced=(r,n,s)=>{const o=(0,e.c)(7);let a;o[0]!==s?(a=void 0===s?{}:s,o[0]=s,o[1]=a):a=o[1];const{cancelOnUnmount:u}=a,i=void 0!==u&&u,c=(0,t.useRef)(null);let l;o[2]!==r||o[3]!==n?(l=e=>{null!==c.current&&clearTimeout(c.current),c.current=setTimeout(()=>r(e),n)},o[2]=r,o[3]=n,o[4]=l):l=o[4];const p=l;let f;return o[5]!==i?(f=()=>{i&&c.current&&clearTimeout(c.current)},o[5]=i,o[6]=f):f=o[6],v(f),p},exports.useEffectOnce=m,exports.useLiveBehaviorSubject=c,exports.useLiveRef=b,exports.useMakeOrRetrieveSignal=t=>{const r=(0,e.c)(3),n=H();let s;return r[0]!==n||r[1]!==t?(s=t?n.getOrCreateSignal(t):void 0,r[0]=n,r[1]=t,r[2]=s):s=r[2],s},exports.useMemoCompare=(e,r)=>{const n=(0,t.useRef)({value:e});return(0,t.useMemo)(()=>r(e,n.current.value)?n.current.value:(n.current={value:e},e),[e,r])},exports.useMount=t=>{const r=(0,e.c)(2);let n;r[0]!==t?(n=()=>{t()},r[0]=t,r[1]=n):n=r[1],m(n)},exports.useMutation$=V,exports.useObservableState=n=>{const s=(0,e.c)(12);let o;s[0]!==n?(o=()=>new r.BehaviorSubject(n),s[0]=n,s[1]=o):o=s[1];const a=i(o);let u;s[2]!==a?(u=e=>{const t="function"==typeof(r=e)?r(a.getValue()):r;var r;t!==a.getValue()&&a.next(t)},s[2]=a,s[3]=u):u=s[3];const c=u;let l;s[4]!==a?(l=e=>{const t=a.pipe((0,r.skip)(1)).subscribe(e);return()=>{t.unsubscribe()}},s[4]=a,s[5]=l):l=s[5];const p=l;let f;s[6]!==a?(f=()=>a.getValue(),s[6]=a,s[7]=f):f=s[7];const y=f,d=(0,t.useSyncExternalStore)(p,y,y);let m;return s[8]!==c||s[9]!==a||s[10]!==d?(m=[d,c,a],s[8]=c,s[9]=a,s[10]=d,s[11]=m):m=s[11],m},exports.useObserve=g,exports.usePersistSignals=function(t){const n=(0,e.c)(10),{entries:s,onHydrated:o,adapter:a}=t;let u;n[0]!==s?(u=void 0===s?[]:s,n[0]=s,n[1]=u):u=n[1];const i=u,l=b(o),p=c(a),f=c(i);let y,d,m;return n[2]!==p||n[3]!==f||n[4]!==l?(y=()=>p.pipe((0,r.switchMap)(e=>e?(0,r.merge)((0,r.of)({type:"reset"}),f.pipe((0,r.concatMap)(t=>U({adapter:e,entries:t,onHydrated:()=>{l.current?.()}})))):(0,r.of)({type:"reset"}))).pipe((0,r.scan)(Y,{isHydrated:!1})),n[2]=p,n[3]=f,n[4]=l,n[5]=y):y=n[5],n[6]===Symbol.for("react.memo_cache_sentinel")?(d={defaultValue:{isHydrated:!1},compareFn:L},n[6]=d):d=n[6],n[7]!==p||n[8]!==f?(m=[p,f],n[7]=p,n[8]=f,n[9]=m):m=n[9],g(y,d,m).data},exports.useQueries$=function(t,r){const n=(0,e.c)(14);let o,a;n[0]!==t?(({queries:a,...o}=t),n[0]=t,n[1]=o,n[2]=a):(o=n[1],a=n[2]);const u=(0,s.useQueryClient)(r),i=C();let c;if(n[3]!==u||n[4]!==a||n[5]!==i){let e;n[7]!==u||n[8]!==i?(e=e=>({...e,queryFn:k(i,u,e.queryFn)}),n[7]=u,n[8]=i,n[9]=e):e=n[9],c=a.map(e),n[3]=u,n[4]=a,n[5]=i,n[6]=c}else c=n[6];const l=c,p=o.combine;let f;return n[10]!==o.subscribed||n[11]!==l||n[12]!==p?(f={queries:l,combine:p,subscribed:o.subscribed},n[10]=o.subscribed,n[11]=l,n[12]=p,n[13]=f):f=n[13],(0,s.useQueries)(f,r)},exports.useQuery$=function(t,r){const n=(0,e.c)(10);let o,a;n[0]!==t?(({queryFn:a,...o}=t),n[0]=t,n[1]=o,n[2]=a):(o=n[1],a=n[2]);const u=(0,s.useQueryClient)(r),i=C();let c,l;return n[3]!==u||n[4]!==i||n[5]!==a?(c=k(i,u,a),n[3]=u,n[4]=i,n[5]=a,n[6]=c):c=n[6],n[7]!==o||n[8]!==c?(l={...o,queryFn:c},n[7]=o,n[8]=c,n[9]=l):l=n[9],(0,s.useQuery)(l,r)},exports.useQueryClient$=C,exports.useRefOnce=u,exports.useSetSignal=z,exports.useSignal=function(t){const r=(0,e.c)(4),n=G(t),s=X(n),o=z(n);let a;return r[0]!==n||r[1]!==o||r[2]!==s?(a=[s,o,n],r[0]=n,r[1]=o,r[2]=s,r[3]=a):a=r[3],a},exports.useSignalContext=H,exports.useSignalState=t=>{const r=(0,e.c)(3),n=i(t),s=X(n);let o;return r[0]!==n||r[1]!==s?(o=[s,n],r[0]=n,r[1]=s,r[2]=o):o=r[2],o},exports.useSignalValue=X,exports.useSubscribe=S,exports.useSubscribeEffect=function(t,n){const s=(0,e.c)(3),o=b(n);let a;s[0]!==o||s[1]!==t?(a=()=>x(t)().pipe((0,r.tap)({error:e=>{o.current?.onError?.(e)}}),(0,r.retry)({delay:e=>o.current?.retryOnError?(0,r.of)(0):(0,r.throwError)(()=>e)})),s[0]=o,s[1]=t,s[2]=a):a=s[2],S(a)},exports.useSwitchMutation$=function(t,n){const s=(0,e.c)(20),{mutationFn:o,...a}=t,i=u($);let c;s[0]!==o?(c=e=>{const{variables:t,abort:n}=e;if(n.aborted)throw new N;return(0,r.merge)(M(o,t).pipe((0,r.defaultIfEmpty)(null)),(0,r.fromEvent)(n,"abort").pipe((0,r.tap)(P),(0,r.ignoreElements)())).pipe((0,r.first)())},s[0]=o,s[1]=c):c=s[1];const l=c,p=q(a);let f;s[2]!==a||s[3]!==l||s[4]!==p?(f={...a,mutationFn:l,...p},s[2]=a,s[3]=l,s[4]=p,s[5]=f):f=s[5];const y=V(f,n);let d,m,v,b;s[6]!==y?(({mutate:d,mutateAsync:m,...v}=y),s[6]=y,s[7]=d,s[8]=m,s[9]=v):(d=s[7],m=s[8],v=s[9]),s[10]!==d||s[11]!==i?(b=e=>(i.current.abort(),i.current=new AbortController,d({variables:e,abort:i.current.signal})),s[10]=d,s[11]=i,s[12]=b):b=s[12];const h=b;let g;s[13]!==m||s[14]!==i?(g=e=>(i.current.abort(),i.current=new AbortController,m({variables:e,abort:i.current.signal})),s[13]=m,s[14]=i,s[15]=g):g=s[15];const x=g;let S;return s[16]!==x||s[17]!==h||s[18]!==v?(S={...v,mutate:h,mutateAsync:x},s[16]=x,s[17]=h,s[18]=v,s[19]=S):S=s[19],S},exports.useUnmount=v,exports.virtualSignal=function(e){return new D(e)};
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let e=require("react/compiler-runtime"),t=require("react"),r=require("rxjs"),n=require("rxjs/operators"),s=require("@tanstack/react-query"),o=require("react/jsx-runtime");var a=Symbol("UNSET"),u=e=>{const r=(0,t.useRef)(a);return r.current===a&&(r.current=e()),r},c=e=>u(e).current,i=n=>{const s=(0,e.c)(6);let o;s[0]!==n?(o=()=>new r.BehaviorSubject(n),s[0]=n,s[1]=o):o=s[1];const a=c(o);let u,i;return s[2]!==n||s[3]!==a?(u=()=>{Object.is(a.getValue(),n)||a.next(n)},i=[n,a],s[2]=n,s[3]=a,s[4]=u,s[5]=i):(u=s[4],i=s[5]),(0,t.useEffect)(u,i),a},l=(e,t)=>e.length===t.length&&e.every((e,r)=>e===t[r]);function f(e){return e instanceof Promise||e&&"object"==typeof e&&"then"in e&&"function"==typeof e.then&&"catch"in e&&"function"==typeof e.catch}var p="undefined"==typeof window||"Deno"in window;function y(e,t){return Math.min(e,t)}function d(e,t){return 2**e*t}var b=r=>{const n=(0,e.c)(1);let s;n[0]===Symbol.for("react.memo_cache_sentinel")?(s=[],n[0]=s):s=n[0],(0,t.useEffect)(r,s)},g=e=>{const r=(0,t.useRef)(e);r.current=e,b(()=>()=>r.current())},m=e=>{const r=(0,t.useRef)(e);return(0,t.useMemo)(()=>{r.current=e},[e]),r},v=class{state;source$;sub;constructor({source$:e,defaultValue:t,compareFn:n}){const s="function"==typeof e?e():e,o=void 0===s;if(this.state={data:s instanceof r.BehaviorSubject?s.value:t,status:o?"success":"pending",observableState:o?"complete":"live",error:void 0},o)return this.source$=r.NEVER,void(this.sub=r.Subscription.EMPTY);this.source$=s.pipe((0,r.distinctUntilChanged)(n),(0,r.tap)({complete:()=>{this.state={...this.state,status:"success",observableState:"complete"}},error:e=>{this.state={...this.state,observableState:"error",status:"error",error:e}},next:e=>{this.state={...this.state,data:e}}}),(0,r.share)()),this.sub=this.source$.subscribe()}subscribe=e=>{if("complete"===this.state.observableState)return()=>{};const t=this.source$.subscribe({complete:e,error:e,next:e});return()=>{t.unsubscribe()}};getSnapshot=()=>this.state};function h(r,n,s){const o=(0,e.c)(6);let a;o[0]!==n?(a=null==n||Array.isArray(n)?{defaultValue:void 0,compareFn:void 0}:n,o[0]=n,o[1]=a):a=o[1];const u=a;let c;o[2]!==s||o[3]!==n||o[4]!==r?(c=!s&&Array.isArray(n)?n:"function"==typeof r?s??[]:[r],o[2]=s,o[3]=n,o[4]=r,o[5]=c):c=o[5];const i=((e,r,n)=>{const s=m(r),o=(0,t.useRef)(void 0);o.current&&l(n,o.current.deps)||(o.current={deps:n,store:new v({source$:e,defaultValue:s.current.defaultValue,compareFn:(e,t)=>s.current?.compareFn?.(e,t)??e===t})});const a=o.current.store;return(0,t.useEffect)(()=>()=>{a.sub.unsubscribe()},[a]),a})(r,u,c);return(0,t.useSyncExternalStore)(i.subscribe,i.getSnapshot,i.getSnapshot)}function x(e){if((0,r.isObservable)(e))return()=>e;if(f(e))return()=>(0,r.from)(e);if("function"!=typeof e)return()=>(0,r.of)(e);const t=e;return e=>(0,r.defer)(()=>{const n=t(e);return f(n)?(0,r.from)(n):(0,r.isObservable)(n)?n:(0,r.of)(n)})}function S(r){const n=(0,e.c)(3);let s,o;n[0]!==r?(s=()=>{const e=x(r)().subscribe();return()=>{e.unsubscribe()}},o=[r],n[0]=r,n[1]=s,n[2]=o):(s=n[1],o=n[2]),(0,t.useEffect)(s,o)}var w=class{queryClient;queryMap=/* @__PURE__ */new Map;constructor(e){this.queryClient=e}getQuery(e){return this.queryMap.get(e)}setQuery(e,t,n){const o=(0,s.hashKey)(e),a=t.pipe((0,r.takeUntil)((0,r.fromEvent)(n,"abort")),(0,r.share)()),u={queryKey:e,query$:a,signal:n,sub:void 0,isCompleted:!1,lastData:void 0};return this.queryMap.set(o,u),u.sub=a.subscribe({next:e=>{const t=this.queryMap.get(o);t&&(t.lastData={value:e})},complete:()=>{this.queryMap.get(o)===u&&this.deleteQuery(o)}}),u}deleteQuery(e,{cancelQuery:t=!1}={}){const r=this.queryMap.get(e);r&&(r.isCompleted=!0,this.queryMap.delete(e),r.sub&&(r.sub.unsubscribe(),r.sub=void 0),t&&!r.signal.aborted&&void 0!==r.lastData&&this.queryClient?.cancelQueries({queryKey:r.queryKey,exact:!0}))}destroy(){this.queryMap.forEach((e,t)=>{this.deleteQuery(t,{cancelQuery:!0})})}},E=(0,t.createContext)(void 0),C=(0,t.memo)(function(r){const n=(0,e.c)(13),{children:a,client:u}=r,c=(0,s.useQueryClient)();let i;n[0]!==u||n[1]!==c?(i=()=>u??new w(c),n[0]=u,n[1]=c,n[2]=i):i=n[2];const[l]=(0,t.useState)(i);let f,p,y,d,b;return n[3]!==l||n[4]!==c?(f=function(){return c.getQueryCache().subscribe(e=>{const t=e.query.getObserversCount();"observerRemoved"===e.type&&0===t&&l.deleteQuery(e.query.queryHash,{cancelQuery:!0})})},p=[c,l],n[3]=l,n[4]=c,n[5]=f,n[6]=p):(f=n[5],p=n[6]),(0,t.useEffect)(f,p),n[7]!==l?(y=()=>()=>{l.destroy()},d=[l],n[7]=l,n[8]=y,n[9]=d):(y=n[8],d=n[9]),(0,t.useEffect)(y,d),n[10]!==a||n[11]!==l?(b=/* @__PURE__ */ /* @__PURE__ */(0,o.jsx)(E.Provider,{value:l,children:a}),n[10]=a,n[11]=l,n[12]=b):b=n[12],b}),q=()=>{const e=(0,t.useContext)(E);if(!e)throw new Error("useReactJrxQueryClient must be used within a ReactJrxQueryProvider");return e};function M(e,t){return"function"==typeof e?e(t):e}function I({onMutate:e,onSuccess:t,onError:r,onSettled:n}){return{onMutate:e?({variables:t},...r)=>e(t,...r):void 0,onSuccess:(e,{variables:r},...n)=>t?.(e,r,...n),onError:(e,{variables:t},...n)=>r?.(e,t,...n),onSettled:(e,t,{variables:r},...s)=>n?.(e,t,r,...s)}}function V(n,o){const a=(0,e.c)(16),u=c(j);let i,l;a[0]!==n?(i=e=>{let t;return new Promise((s,o)=>{M(n.mutationFn,e).pipe((0,r.take)(1)).subscribe({next:e=>{t={value:e}},error:e=>{o(e)},complete:()=>{if(void 0===t)return o(/* @__PURE__ */new Error("Stream completed without any data"));s(t.value)}})})},a[0]=n,a[1]=i):i=a[1],a[2]!==n||a[3]!==i?(l={...n,mutationFn:i},a[2]=n,a[3]=i,a[4]=l):l=a[4];const f=(0,s.useMutation)(l,o),{status:p,isPending:y,isError:d,isSuccess:b,isIdle:g}=f;let m,v,h;return a[5]!==d||a[6]!==g||a[7]!==y||a[8]!==b||a[9]!==u||a[10]!==p?(m=()=>{u.next({status:p,isPending:y,isError:d,isSuccess:b,isIdle:g})},v=[p,y,d,b,g,u],a[5]=d,a[6]=g,a[7]=y,a[8]=b,a[9]=u,a[10]=p,a[11]=m,a[12]=v):(m=a[11],v=a[12]),(0,t.useEffect)(m,v),a[13]!==f||a[14]!==u?(h={...f,state$:u},a[13]=f,a[14]=u,a[15]=h):h=a[15],h}function j(){return new r.BehaviorSubject({status:"idle",isPending:!1,isError:!1,isSuccess:!1,isIdle:!0})}function k(e){return e.continue().catch(r.noop)}function O(e){return e}function Q(e,t,n){return n===s.skipToken||void 0===n?n:o=>new Promise((a,u)=>{const c=(0,s.hashKey)(o.queryKey),i=e.getQuery(c),l=i??e.setQuery(o.queryKey,(0,r.defer)(()=>"function"==typeof n?n(o):n),o.signal),f=()=>{!1===l?.isCompleted&&setTimeout(()=>{l?.isCompleted||t?.refetchQueries({queryKey:o.queryKey,exact:!0})})};if(!i&&void 0!==l.lastData)return a(l.lastData.value),void f();l.query$.pipe((0,r.take)(1),(0,r.delay)(1)).subscribe({error:e=>u(e),complete:()=>{if(void 0===l?.lastData)return l.signal.aborted||console.warn(`cancelled due to stream completing without data for query ${c}`),u(new s.CancelledError);a(l.lastData.value),f()}})})}var $=class extends Error{constructor(e="Mutation canceled"){super(e),this.name="SwitchMutationCancelError"}};function P(){throw new $}function _(){return new AbortController}var A=Symbol("SIGNAL_RESET"),D=e=>{if(e&&"object"==typeof e)return e},F=({key:e}={})=>e?(({adapter:e,key:t})=>({clear:async()=>await e.removeItem(t),removeItem:async r=>{const n=await e.getItem(t),{[r]:s,...o}=D(n)??{};await e.setItem(t,o)},getItem:async r=>{const n=await e.getItem(t),s=D(n)??{};if(r in s)return s[r]},setItem:async(r,n)=>{const s=await e.getItem(t),o=D(s)??{};await e.setItem(t,{...o,[r]:n})}}))({adapter:F(),key:e}):{clear:async()=>{localStorage.clear()},removeItem:async e=>{localStorage.removeItem(e)},getItem:async e=>{const t=localStorage.getItem(e);if(t)return JSON.parse(t)},setItem:async(e,t)=>{localStorage.setItem(e,JSON.stringify(t))}},R=class extends r.BehaviorSubject{config;constructor(e){super(e.default),this.config=e}update=e=>{if(e===A)super.next(this.config.default);else if("function"==typeof e){const t=e;super.next(t(this.value))}else super.next(e)};setValue=this.update.bind(this);get subject(){return this}get key(){return this.config.key}},N=class{config;constructor(e){this.config=e}};var T=class{signals=new r.BehaviorSubject(/* @__PURE__ */new Map);isDestroyed=!1;getOrCreateSignal(e){const t=this.signals.value.get(e);if(t)return t;const r=new R({...e.config,key:void 0});return this.signals.value.set(e,r),this.signals.next(this.signals.value),r}destroy(){this.signals.value.forEach(e=>{e.complete()}),this.signals.value.clear(),this.signals.complete(),this.isDestroyed=!0}},K=(0,t.createContext)(new T),B=(0,t.memo)(({children:e})=>{const r=u(()=>new T),n=r.current,[s,a]=(0,t.useState)(!1);s&&(r.current=new T,a(!1));const c=n;return(0,t.useEffect)(()=>()=>{r.current?.destroy(),a(!0)},[r]),/* @__PURE__ */ /* @__PURE__ */(0,o.jsx)(K.Provider,{value:c,children:e})}),H=()=>(0,t.useContext)(K);function L(e,t){if(null==e||void 0===t)return e===t;if("object"!=typeof e||"object"!=typeof t)return e===t;if(e.constructor!==t?.constructor)return!1;const r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(const s of r)if(!t.hasOwnProperty(s)||e[s]!==t[s])return!1;return!0}var J="__reactjrx";var U=({adapter:e,entry:t,onHydrated:n})=>{const{signal:s}=t.config;let o;const a=()=>(o=s.getValue(),(({adapter:e,config:t})=>{const{signal:n,version:s}=t,o={value:n.getValue(),[J]:J,migrationVersion:s};return"development"===process.env.NODE_ENV&&console.log("[reactjrx][state][persistance]:","Persist value",o,`for signal ${n.config.key}`),(0,r.from)(e.setItem(n.config.key,o)).pipe((0,r.catchError)(e=>(console.error(e),(0,r.of)(null))))})({adapter:e,config:t.config}));return function({adapter:e,config:t}){const{hydrate:n=({value:e})=>e,signal:s,version:o}=t;return(0,r.from)(e.getItem(s.config.key)).pipe((0,r.switchMap)(e=>{const t=(e=>{if("object"==typeof e&&null!==e&&"__reactjrx"in e&&"__reactjrx"===e.__reactjrx)return e})(e);if(!t)return(0,r.of)(e);const a="number"!=typeof t.migrationVersion,u=void 0!==t.migrationVersion&&o>t.migrationVersion;if(a||u||void 0===t.value)return(0,r.of)(e);const c=t.value;return"development"===process.env.NODE_ENV&&console.log("[reactjrx][state][persistance]:","Hydrate value",t,`for signal ${s.config.key}`),s.setValue(n({value:c,version:o})),(0,r.of)(e)}))}({adapter:e,config:t.config}).pipe((0,r.catchError)(e=>(console.error(`Unable to hydrate signal ${s.config.key}`,e),r.EMPTY)),(0,r.tap)(n),(0,r.switchMap)(()=>s.pipe((0,r.throttleTime)(500,r.asyncScheduler,{trailing:!0}),(0,r.switchMap)(()=>a()),(0,r.finalize)(()=>{s.getValue()!==o&&a().subscribe()}))))};function Y(e){return{isHydrated:"hydrated"===e.type}}function z(t){const r=(0,e.c)(3),n=H();if(t instanceof N&&!n)throw new Error("useSignalValue must be used within a SignalContextProvider");let s;return r[0]!==t||r[1]!==n?(s=t instanceof N?n.getOrCreateSignal(t):t,r[0]=t,r[1]=n,r[2]=s):s=r[2],s}function G(e){return z(e).update}var W=Object.is;function X(n,s,o){const a=(0,e.c)(7),u=void 0===o?W:o,c=z(n);let i;a[0]===Symbol.for("react.memo_cache_sentinel")?(i={hasValue:!1,signal:void 0,selector:void 0,sourceValue:void 0,value:void 0},a[0]=i):i=a[0];const l=(0,t.useRef)(i);let f;a[1]!==c?(f=e=>{const t=c.pipe((0,r.skip)(1)).subscribe(()=>{e()});return()=>{t.unsubscribe()}},a[1]=c,a[2]=f):f=a[2];const p=f;let y;a[3]!==u||a[4]!==c||a[5]!==s?(y=()=>{const e=l.current,t=c.value;if(e.hasValue&&e.signal===c&&e.selector===s&&e.sourceValue===t)return e.value;const r=s?s(t):t;return e.hasValue&&e.signal===c&&u(e.value,r)?(l.current={hasValue:!0,signal:c,selector:s,sourceValue:t,value:e.value},e.value):(l.current={hasValue:!0,signal:c,selector:s,sourceValue:t,value:r},r)},a[3]=u,a[4]=c,a[5]=s,a[6]=y):y=a[6];const d=y;return(0,t.useSyncExternalStore)(p,d,d)}exports.Context=E,exports.QueryClient$=w,exports.QueryClientProvider$=C,exports.SIGNAL_RESET=A,exports.Signal=R,exports.SignalContextProvider=B,exports.SignalReactContext=K,exports.SwitchMutationCancelError=$,exports.VirtualSignal=N,exports.arrayEqual=l,exports.createLocalStorageAdapter=F,exports.createLocalforageAdapter=e=>({getItem:async t=>{const r=await e.getItem(t);if(r)return JSON.parse(r)},setItem:async(t,r)=>{await e.setItem(t,JSON.stringify(r))},removeItem:async e=>{},clear:async()=>{}}),exports.exponentialBackoffDelay=d,exports.getDelay=y,exports.isDefined=function(e){return null!=e},exports.isPromiseLike=f,exports.isServer=p,exports.retryBackoff=function(e){const{retry:t=()=>!0,retryAfterDelay:s,retryAfter:o=()=>(0,r.of)(!0),initialInterval:a=100,maxInterval:u=Number.POSITIVE_INFINITY,resetOnSuccess:c=!1,backoffDelay:i=d}=e;return l=>(0,r.defer)(()=>{let f=0;return l.pipe((0,n.catchError)(s=>{if(f++,!t(f-1,s))throw s;const o=e.caughtError?.(f,s);if(!o)throw s;return o.pipe((0,n.mergeMap)(e=>(0,r.merge)((0,r.of)(e),(0,r.throwError)(()=>s))))}),(0,n.retry)({delay:e=>{const c=f-1;return o().pipe((0,n.first)(),(0,n.mergeMap)(()=>t(c,e)?(0,r.timer)(y(i(c,a),u)).pipe((0,n.mergeMap)(t=>s&&!s(c,e)?(0,r.throwError)(()=>e):(0,r.of)(t))):(0,r.throwError)(()=>e)))}}),(0,n.catchError)(t=>{if(e.catchError)return e.catchError(f,t);throw t}),(0,n.tap)(()=>{c&&(f=0)}))})},exports.signal=function(e={}){return new R({key:void 0,...e,default:e.default??void 0})},exports.useConcatMutation$=function(t,n){const o=(0,e.c)(21),a=(0,s.useQueryClient)(n),u=t.mutationKey;let c,i,l;o[0]!==t?(c=I(t),o[0]=t,o[1]=c):c=o[1],o[2]!==t.mutationFn?(i=e=>{const{ready$:n,variables:s}=e,o=M(t.mutationFn,s);return n.pipe((0,r.filter)(O),(0,r.first)(),(0,r.switchMap)(()=>o))},o[2]=t.mutationFn,o[3]=i):i=o[3],o[4]!==t||o[5]!==c||o[6]!==i?(l={...t,...c,mutationFn:i},o[4]=t,o[5]=c,o[6]=i,o[7]=l):l=o[7];const f=V(l,n);let p,y,d;o[8]!==f?(({mutateAsync:p,...y}=f),o[8]=f,o[9]=p,o[10]=y):(p=o[9],y=o[10]),o[11]!==a||o[12]!==p||o[13]!==u?(d=async e=>{const t=a.getMutationCache().findAll({mutationKey:u,exact:!0}),n=new r.BehaviorSubject(!1),s=p({variables:e,ready$:n});return await Promise.all(t.map(k)),n.next(!0),await s.finally(()=>{n.complete()})},o[11]=a,o[12]=p,o[13]=u,o[14]=d):d=o[14];const b=d;let g;o[15]!==b?(g=e=>{b(e).catch(r.noop)},o[15]=b,o[16]=g):g=o[16];const m=g;let v;return o[17]!==b||o[18]!==m||o[19]!==y?(v={...y,mutate:m,mutateAsync:b},o[17]=b,o[18]=m,o[19]=y,o[20]=v):v=o[20],v},exports.useConstant=c,exports.useDebounced=(r,n,s)=>{const o=(0,e.c)(7);let a;o[0]!==s?(a=void 0===s?{}:s,o[0]=s,o[1]=a):a=o[1];const{cancelOnUnmount:u}=a,c=void 0!==u&&u,i=(0,t.useRef)(null);let l;o[2]!==r||o[3]!==n?(l=e=>{null!==i.current&&clearTimeout(i.current),i.current=setTimeout(()=>r(e),n)},o[2]=r,o[3]=n,o[4]=l):l=o[4];const f=l;let p;return o[5]!==c?(p=()=>{c&&i.current&&clearTimeout(i.current)},o[5]=c,o[6]=p):p=o[6],g(p),f},exports.useEffectOnce=b,exports.useLiveBehaviorSubject=i,exports.useLiveRef=m,exports.useMakeOrRetrieveSignal=t=>{const r=(0,e.c)(3),n=H();let s;return r[0]!==n||r[1]!==t?(s=t?n.getOrCreateSignal(t):void 0,r[0]=n,r[1]=t,r[2]=s):s=r[2],s},exports.useMemoCompare=(e,r)=>{const n=(0,t.useRef)({value:e});return(0,t.useMemo)(()=>r(e,n.current.value)?n.current.value:(n.current={value:e},e),[e,r])},exports.useMount=t=>{const r=(0,e.c)(2);let n;r[0]!==t?(n=()=>{t()},r[0]=t,r[1]=n):n=r[1],b(n)},exports.useMutation$=V,exports.useObservableState=n=>{const s=(0,e.c)(12);let o;s[0]!==n?(o=()=>new r.BehaviorSubject(n),s[0]=n,s[1]=o):o=s[1];const a=c(o);let u;s[2]!==a?(u=e=>{const t="function"==typeof(r=e)?r(a.getValue()):r;var r;t!==a.getValue()&&a.next(t)},s[2]=a,s[3]=u):u=s[3];const i=u;let l;s[4]!==a?(l=e=>{const t=a.pipe((0,r.skip)(1)).subscribe(e);return()=>{t.unsubscribe()}},s[4]=a,s[5]=l):l=s[5];const f=l;let p;s[6]!==a?(p=()=>a.getValue(),s[6]=a,s[7]=p):p=s[7];const y=p,d=(0,t.useSyncExternalStore)(f,y,y);let b;return s[8]!==i||s[9]!==a||s[10]!==d?(b=[d,i,a],s[8]=i,s[9]=a,s[10]=d,s[11]=b):b=s[11],b},exports.useObserve=h,exports.usePersistSignals=function(t){const n=(0,e.c)(10),{entries:s,onHydrated:o,adapter:a}=t;let u;n[0]!==s?(u=void 0===s?[]:s,n[0]=s,n[1]=u):u=n[1];const c=u,l=m(o),f=i(a),p=i(c);let y,d,b;return n[2]!==f||n[3]!==p||n[4]!==l?(y=()=>f.pipe((0,r.switchMap)(e=>e?(0,r.merge)((0,r.of)({type:"reset"}),function({entries$:e,onHydrated:t,adapter:n}){return new r.Observable(s=>{const o=/* @__PURE__ */new Map,a=/* @__PURE__ */new Set;let u=!1,c=!1;const i=()=>{c||u||a.size>0||(c=!0,t?.(),s.next({type:"hydrated"}))},l=e=>{const t={config:e,subscription:new r.Subscription};o.set(e.signal,t),a.add(e.signal),t.subscription.add(U({adapter:n,entry:t,onHydrated:()=>{a.delete(e.signal),i()}}).subscribe())},f=e=>{const t=o.get(e);t&&(o.delete(e),a.delete(e),t.subscription.unsubscribe())},p=e.subscribe({next:e=>{u=!0;const t=new Set(e.map(({signal:e})=>e));for(const r of[...o.keys()])t.has(r)||f(r);for(const r of e){const e=o.get(r.signal);e?e.config=r:l(r)}u=!1,i()},error:e=>s.error(e)});return()=>{p.unsubscribe();for(const e of[...o.keys()])f(e)}})}({adapter:e,entries$:p,onHydrated:()=>{l.current?.()}})):(0,r.of)({type:"reset"})),(0,r.map)(Y)),n[2]=f,n[3]=p,n[4]=l,n[5]=y):y=n[5],n[6]===Symbol.for("react.memo_cache_sentinel")?(d={defaultValue:{isHydrated:!1},compareFn:L},n[6]=d):d=n[6],n[7]!==f||n[8]!==p?(b=[f,p],n[7]=f,n[8]=p,n[9]=b):b=n[9],h(y,d,b).data},exports.useQueries$=function(t,r){const n=(0,e.c)(14);let o,a;n[0]!==t?(({queries:a,...o}=t),n[0]=t,n[1]=o,n[2]=a):(o=n[1],a=n[2]);const u=(0,s.useQueryClient)(r),c=q();let i;if(n[3]!==u||n[4]!==a||n[5]!==c){let e;n[7]!==u||n[8]!==c?(e=e=>({...e,queryFn:Q(c,u,e.queryFn)}),n[7]=u,n[8]=c,n[9]=e):e=n[9],i=a.map(e),n[3]=u,n[4]=a,n[5]=c,n[6]=i}else i=n[6];const l=i,f=o.combine;let p;return n[10]!==o.subscribed||n[11]!==l||n[12]!==f?(p={queries:l,combine:f,subscribed:o.subscribed},n[10]=o.subscribed,n[11]=l,n[12]=f,n[13]=p):p=n[13],(0,s.useQueries)(p,r)},exports.useQuery$=function(t,r){const n=(0,e.c)(10);let o,a;n[0]!==t?(({queryFn:a,...o}=t),n[0]=t,n[1]=o,n[2]=a):(o=n[1],a=n[2]);const u=(0,s.useQueryClient)(r),c=q();let i,l;return n[3]!==u||n[4]!==c||n[5]!==a?(i=Q(c,u,a),n[3]=u,n[4]=c,n[5]=a,n[6]=i):i=n[6],n[7]!==o||n[8]!==i?(l={...o,queryFn:i},n[7]=o,n[8]=i,n[9]=l):l=n[9],(0,s.useQuery)(l,r)},exports.useQueryClient$=q,exports.useRefOnce=u,exports.useSetSignal=G,exports.useSignal=function(t){const r=(0,e.c)(4),n=z(t),s=X(n),o=G(n);let a;return r[0]!==n||r[1]!==o||r[2]!==s?(a=[s,o,n],r[0]=n,r[1]=o,r[2]=s,r[3]=a):a=r[3],a},exports.useSignalContext=H,exports.useSignalState=t=>{const r=(0,e.c)(3),n=c(t),s=X(n);let o;return r[0]!==n||r[1]!==s?(o=[s,n],r[0]=n,r[1]=s,r[2]=o):o=r[2],o},exports.useSignalValue=X,exports.useSubscribe=S,exports.useSubscribeEffect=function(t,n){const s=(0,e.c)(3),o=m(n);let a;s[0]!==o||s[1]!==t?(a=()=>x(t)().pipe((0,r.tap)({error:e=>{o.current?.onError?.(e)}}),(0,r.retry)({delay:e=>o.current?.retryOnError?(0,r.of)(0):(0,r.throwError)(()=>e)})),s[0]=o,s[1]=t,s[2]=a):a=s[2],S(a)},exports.useSwitchMutation$=function(t,n){const s=(0,e.c)(20),{mutationFn:o,...a}=t,c=u(_);let i;s[0]!==o?(i=e=>{const{variables:t,abort:n}=e;if(n.aborted)throw new $;return(0,r.merge)(M(o,t).pipe((0,r.defaultIfEmpty)(null)),(0,r.fromEvent)(n,"abort").pipe((0,r.tap)(P),(0,r.ignoreElements)())).pipe((0,r.first)())},s[0]=o,s[1]=i):i=s[1];const l=i,f=I(a);let p;s[2]!==a||s[3]!==l||s[4]!==f?(p={...a,mutationFn:l,...f},s[2]=a,s[3]=l,s[4]=f,s[5]=p):p=s[5];const y=V(p,n);let d,b,g,m;s[6]!==y?(({mutate:d,mutateAsync:b,...g}=y),s[6]=y,s[7]=d,s[8]=b,s[9]=g):(d=s[7],b=s[8],g=s[9]),s[10]!==d||s[11]!==c?(m=e=>(c.current.abort(),c.current=new AbortController,d({variables:e,abort:c.current.signal})),s[10]=d,s[11]=c,s[12]=m):m=s[12];const v=m;let h;s[13]!==b||s[14]!==c?(h=e=>(c.current.abort(),c.current=new AbortController,b({variables:e,abort:c.current.signal})),s[13]=b,s[14]=c,s[15]=h):h=s[15];const x=h;let S;return s[16]!==x||s[17]!==v||s[18]!==g?(S={...g,mutate:v,mutateAsync:x},s[16]=x,s[17]=v,s[18]=g,s[19]=S):S=s[19],S},exports.useUnmount=g,exports.virtualSignal=function(e){return new N(e)};
2
2
  //# sourceMappingURL=index.cjs.map