var at=e=>{throw TypeError(e)};var z=(e,t,i)=>t.has(e)||at("Cannot "+i);var s=(e,t,i)=>(z(e,t,"read from private field"),i?i.call(e):t.get(e)),p=(e,t,i)=>t.has(e)?at("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,i),u=(e,t,i,r)=>(z(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i),l=(e,t,i)=>(z(e,t,"access private method"),i);import{aL as vt,aM as C,aN as H,aO as j,aP as Rt,aQ as nt,aR as ht,aS as yt,aT as gt,aU as mt,aV as ot,aW as dt,r as E,aX as Ct}from"./entry.client-CV0PzNS2.js";var v,a,_,b,w,x,m,B,F,D,T,U,Q,M,n,L,K,X,G,J,Y,Z,$,ft,lt,Ot=(lt=class extends vt{constructor(t,i){super();p(this,n);p(this,v);p(this,a);p(this,_);p(this,b);p(this,w);p(this,x);p(this,m);p(this,B);p(this,F);p(this,D);p(this,T);p(this,U);p(this,Q);p(this,M,new Set);this.options=i,u(this,v,t),u(this,m,null),this.bindMethods(),this.setOptions(i)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(s(this,a).addObserver(this),ut(s(this,a),this.options)?l(this,n,L).call(this):this.updateResult(),l(this,n,J).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return q(s(this,a),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return q(s(this,a),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,l(this,n,Y).call(this),l(this,n,Z).call(this),s(this,a).removeObserver(this)}setOptions(t,i){const r=this.options,f=s(this,a);if(this.options=s(this,v).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof C(this.options.enabled,s(this,a))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");l(this,n,$).call(this),s(this,a).setOptions(this.options),r._defaulted&&!H(this.options,r)&&s(this,v).getQueryCache().notify({type:"observerOptionsUpdated",query:s(this,a),observer:this});const c=this.hasListeners();c&&ct(s(this,a),f,this.options,r)&&l(this,n,L).call(this),this.updateResult(i),c&&(s(this,a)!==f||C(this.options.enabled,s(this,a))!==C(r.enabled,s(this,a))||j(this.options.staleTime,s(this,a))!==j(r.staleTime,s(this,a)))&&l(this,n,K).call(this);const h=l(this,n,X).call(this);c&&(s(this,a)!==f||C(this.options.enabled,s(this,a))!==C(r.enabled,s(this,a))||h!==s(this,Q))&&l(this,n,G).call(this,h)}getOptimisticResult(t){const i=s(this,v).getQueryCache().build(s(this,v),t),r=this.createResult(i,t);return Et(this,r)&&(u(this,b,r),u(this,x,this.options),u(this,w,s(this,a).state)),r}getCurrentResult(){return s(this,b)}trackResult(t,i){const r={};return Object.keys(t).forEach(f=>{Object.defineProperty(r,f,{configurable:!1,enumerable:!0,get:()=>(this.trackProp(f),i==null||i(f),t[f])})}),r}trackProp(t){s(this,M).add(t)}getCurrentQuery(){return s(this,a)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const i=s(this,v).defaultQueryOptions(t),r=s(this,v).getQueryCache().build(s(this,v),i);return r.isFetchingOptimistic=!0,r.fetch().then(()=>this.createResult(r,i))}fetch(t){return l(this,n,L).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),s(this,b)))}createResult(t,i){var rt;const r=s(this,a),f=this.options,c=s(this,b),h=s(this,w),d=s(this,x),O=t!==r?t.state:s(this,_),{state:S}=t;let o={...S},P=!1,R;if(i._optimisticResults){const y=this.hasListeners(),N=!y&&ut(t,i),bt=y&&ct(t,r,i,f);(N||bt)&&(o={...o,...mt(S.data,t.options)}),i._optimisticResults==="isRestoring"&&(o.fetchStatus="idle")}let{error:A,errorUpdatedAt:et,status:I}=o;if(i.select&&o.data!==void 0)if(c&&o.data===(h==null?void 0:h.data)&&i.select===s(this,B))R=s(this,F);else try{u(this,B,i.select),R=i.select(o.data),R=ot(c==null?void 0:c.data,R,i),u(this,F,R),u(this,m,null)}catch(y){u(this,m,y)}else R=o.data;if(i.placeholderData!==void 0&&R===void 0&&I==="pending"){let y;if(c!=null&&c.isPlaceholderData&&i.placeholderData===(d==null?void 0:d.placeholderData))y=c.data;else if(y=typeof i.placeholderData=="function"?i.placeholderData((rt=s(this,D))==null?void 0:rt.state.data,s(this,D)):i.placeholderData,i.select&&y!==void 0)try{y=i.select(y),u(this,m,null)}catch(N){u(this,m,N)}y!==void 0&&(I="success",R=ot(c==null?void 0:c.data,y,i),P=!0)}s(this,m)&&(A=s(this,m),R=s(this,F),et=Date.now(),I="error");const k=o.fetchStatus==="fetching",V=I==="pending",W=I==="error",st=V&&k,it=R!==void 0;return{status:I,fetchStatus:o.fetchStatus,isPending:V,isSuccess:I==="success",isError:W,isInitialLoading:st,isLoading:st,data:R,dataUpdatedAt:o.dataUpdatedAt,error:A,errorUpdatedAt:et,failureCount:o.fetchFailureCount,failureReason:o.fetchFailureReason,errorUpdateCount:o.errorUpdateCount,isFetched:o.dataUpdateCount>0||o.errorUpdateCount>0,isFetchedAfterMount:o.dataUpdateCount>O.dataUpdateCount||o.errorUpdateCount>O.errorUpdateCount,isFetching:k,isRefetching:k&&!V,isLoadingError:W&&!it,isPaused:o.fetchStatus==="paused",isPlaceholderData:P,isRefetchError:W&&it,isStale:tt(t,i),refetch:this.refetch}}updateResult(t){const i=s(this,b),r=this.createResult(s(this,a),this.options);if(u(this,w,s(this,a).state),u(this,x,this.options),s(this,w).data!==void 0&&u(this,D,s(this,a)),H(r,i))return;u(this,b,r);const f={},c=()=>{if(!i)return!0;const{notifyOnChangeProps:h}=this.options,d=typeof h=="function"?h():h;if(d==="all"||!d&&!s(this,M).size)return!0;const g=new Set(d??s(this,M));return this.options.throwOnError&&g.add("error"),Object.keys(s(this,b)).some(O=>{const S=O;return s(this,b)[S]!==i[S]&&g.has(S)})};(t==null?void 0:t.listeners)!==!1&&c()&&(f.listeners=!0),l(this,n,ft).call(this,{...f,...t})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&l(this,n,J).call(this)}},v=new WeakMap,a=new WeakMap,_=new WeakMap,b=new WeakMap,w=new WeakMap,x=new WeakMap,m=new WeakMap,B=new WeakMap,F=new WeakMap,D=new WeakMap,T=new WeakMap,U=new WeakMap,Q=new WeakMap,M=new WeakMap,n=new WeakSet,L=function(t){l(this,n,$).call(this);let i=s(this,a).fetch(this.options,t);return t!=null&&t.throwOnError||(i=i.catch(Rt)),i},K=function(){l(this,n,Y).call(this);const t=j(this.options.staleTime,s(this,a));if(nt||s(this,b).isStale||!ht(t))return;const r=yt(s(this,b).dataUpdatedAt,t)+1;u(this,T,setTimeout(()=>{s(this,b).isStale||this.updateResult()},r))},X=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(s(this,a)):this.options.refetchInterval)??!1},G=function(t){l(this,n,Z).call(this),u(this,Q,t),!(nt||C(this.options.enabled,s(this,a))===!1||!ht(s(this,Q))||s(this,Q)===0)&&u(this,U,setInterval(()=>{(this.options.refetchIntervalInBackground||gt.isFocused())&&l(this,n,L).call(this)},s(this,Q)))},J=function(){l(this,n,K).call(this),l(this,n,G).call(this,l(this,n,X).call(this))},Y=function(){s(this,T)&&(clearTimeout(s(this,T)),u(this,T,void 0))},Z=function(){s(this,U)&&(clearInterval(s(this,U)),u(this,U,void 0))},$=function(){const t=s(this,v).getQueryCache().build(s(this,v),this.options);if(t===s(this,a))return;const i=s(this,a);u(this,a,t),u(this,_,t.state),this.hasListeners()&&(i==null||i.removeObserver(this),t.addObserver(this))},ft=function(t){dt.batch(()=>{t.listeners&&this.listeners.forEach(i=>{i(s(this,b))}),s(this,v).getQueryCache().notify({query:s(this,a),type:"observerResultsUpdated"})})},lt);function St(e,t){return C(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function ut(e,t){return St(e,t)||e.state.data!==void 0&&q(e,t,t.refetchOnMount)}function q(e,t,i){if(C(t.enabled,e)!==!1){const r=typeof i=="function"?i(e):i;return r==="always"||r!==!1&&tt(e,t)}return!1}function ct(e,t,i,r){return(e!==t||C(r.enabled,e)===!1)&&(!i.suspense||e.state.status!=="error")&&tt(e,i)}function tt(e,t){return C(t.enabled,e)!==!1&&e.isStaleByTime(j(t.staleTime,e))}function Et(e,t){return!H(e.getCurrentResult(),t)}var pt=E.createContext(!1),Qt=()=>E.useContext(pt);pt.Provider;function It(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var wt=E.createContext(It()),Tt=()=>E.useContext(wt);function Ut(e,t){return typeof e=="function"?e(...t):!!e}var xt=(e,t)=>{(e.suspense||e.throwOnError)&&(t.isReset()||(e.retryOnMount=!1))},Ft=e=>{E.useEffect(()=>{e.clearReset()},[e])},Dt=({result:e,errorResetBoundary:t,throwOnError:i,query:r})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&Ut(i,[e.error,r]),Mt=e=>{e.suspense&&(typeof e.staleTime!="number"&&(e.staleTime=1e3),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3)))},Pt=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,Lt=(e,t,i)=>t.fetchOptimistic(e).catch(()=>{i.clearReset()});function _t(e,t,i){var O,S,o,P;const r=Ct(),f=Qt(),c=Tt(),h=r.defaultQueryOptions(e);(S=(O=r.getDefaultOptions().queries)==null?void 0:O._experimental_beforeQuery)==null||S.call(O,h),h._optimisticResults=f?"isRestoring":"optimistic",Mt(h),xt(h,c),Ft(c);const[d]=E.useState(()=>new t(r,h)),g=d.getOptimisticResult(h);if(E.useSyncExternalStore(E.useCallback(R=>{const A=f?()=>{}:d.subscribe(dt.batchCalls(R));return d.updateResult(),A},[d,f]),()=>d.getCurrentResult(),()=>d.getCurrentResult()),E.useEffect(()=>{d.setOptions(h,{listeners:!1})},[h,d]),Pt(h,g))throw Lt(h,d,c);if(Dt({result:g,errorResetBoundary:c,throwOnError:h.throwOnError,query:r.getQueryCache().get(h.queryHash)}))throw g.error;return(P=(o=r.getDefaultOptions().queries)==null?void 0:o._experimental_afterQuery)==null||P.call(o,h,g),h.notifyOnChangeProps?g:d.trackResult(g)}function kt(e,t){return _t(e,Ot)}export{kt as u};