var at=i=>{throw TypeError(i)};var K=(i,t,e)=>t.has(i)||at("Cannot "+e);var s=(i,t,e)=>(K(i,t,"read from private field"),e?e.call(i):t.get(i)),b=(i,t,e)=>t.has(i)?at("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(i):t.set(i,e),l=(i,t,e,r)=>(K(i,t,"write to private field"),r?r.call(i,e):t.set(i,e),e),f=(i,t,e)=>(K(i,t,"access private method"),e);import{am as yt,a4 as Rt,an as mt,ao as gt,ap as O,aq as N,ar as k,as as Ot,at as rt,au as ot,av as Ct,aw as W,ax as St,ay as wt,az as ht,aA as Qt,aB as It,a3 as Et,J as _,M as Ft,aC as Dt,j as Ut,S as Mt,aD as ut,aE as lt,aF as Pt,L as Tt}from"./index-5N4i3DXm.js";function xt(i=""){if(!yt())throw new Error("vue-query hooks can only be used inside setup() function or functions that support injection context.");const t=mt(i),e=Rt(t);if(!e)throw new Error("No 'queryClient' found in Vue context, use 'VueQueryPlugin' to properly initialize the library.");return e}var y,a,B,R,E,P,w,z,T,x,F,D,I,L,h,A,J,G,X,Y,Z,$,q,pt,ft,Lt=(ft=class extends gt{constructor(t,e){super();b(this,h);b(this,y);b(this,a);b(this,B);b(this,R);b(this,E);b(this,P);b(this,w);b(this,z);b(this,T);b(this,x);b(this,F);b(this,D);b(this,I);b(this,L,new Set);this.options=e,l(this,y,t),l(this,w,null),this.bindMethods(),this.setOptions(e)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(s(this,a).addObserver(this),ct(s(this,a),this.options)?f(this,h,A).call(this):this.updateResult(),f(this,h,Y).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return tt(s(this,a),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return tt(s(this,a),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,f(this,h,Z).call(this),f(this,h,$).call(this),s(this,a).removeObserver(this)}setOptions(t){const e=this.options,r=s(this,a);if(this.options=s(this,y).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof O(this.options.enabled,s(this,a))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");f(this,h,q).call(this),s(this,a).setOptions(this.options),e._defaulted&&!N(this.options,e)&&s(this,y).getQueryCache().notify({type:"observerOptionsUpdated",query:s(this,a),observer:this});const o=this.hasListeners();o&&dt(s(this,a),r,this.options,e)&&f(this,h,A).call(this),this.updateResult(),o&&(s(this,a)!==r||O(this.options.enabled,s(this,a))!==O(e.enabled,s(this,a))||k(this.options.staleTime,s(this,a))!==k(e.staleTime,s(this,a)))&&f(this,h,J).call(this);const n=f(this,h,G).call(this);o&&(s(this,a)!==r||O(this.options.enabled,s(this,a))!==O(e.enabled,s(this,a))||n!==s(this,I))&&f(this,h,X).call(this,n)}getOptimisticResult(t){const e=s(this,y).getQueryCache().build(s(this,y),t),r=this.createResult(e,t);return At(this,r)&&(l(this,R,r),l(this,P,this.options),l(this,E,s(this,a).state)),r}getCurrentResult(){return s(this,R)}trackResult(t,e){return new Proxy(t,{get:(r,o)=>(this.trackProp(o),e==null||e(o),Reflect.get(r,o))})}trackProp(t){s(this,L).add(t)}getCurrentQuery(){return s(this,a)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const e=s(this,y).defaultQueryOptions(t),r=s(this,y).getQueryCache().build(s(this,y),e);let o=()=>{},n;const c=new Promise(v=>{n=v,o=s(this,y).getQueryCache().subscribe(g=>{g.type==="updated"&&g.query.queryHash===r.queryHash&&r.state.data!==void 0&&(o(),v(this.createResult(r,e)))})});return Promise.race([r.fetch().then(()=>{const v=this.createResult(r,e);return n==null||n(v),v}).finally(()=>{o()}),c])}fetch(t){return f(this,h,A).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),s(this,R)))}createResult(t,e){var nt;const r=s(this,a),o=this.options,n=s(this,R),c=s(this,E),v=s(this,P),g=t!==r?t.state:s(this,B),{state:V}=t;let p={...V},j=!1,d;if(e._optimisticResults){const S=this.hasListeners(),bt=!S&&ct(t,e),vt=S&&dt(t,r,e,o);(bt||vt)&&(p={...p,...wt(V.data,t.options)}),e._optimisticResults==="isRestoring"&&(p.fetchStatus="idle")}let{error:u,errorUpdatedAt:C,status:m}=p;d=p.data;let Q=!1;if(e.placeholderData!==void 0&&d===void 0&&m==="pending"){let S;n!=null&&n.isPlaceholderData&&e.placeholderData===(v==null?void 0:v.placeholderData)?(S=n.data,Q=!0):S=typeof e.placeholderData=="function"?e.placeholderData((nt=s(this,x))==null?void 0:nt.state.data,s(this,x)):e.placeholderData,S!==void 0&&(m="success",d=ht(n==null?void 0:n.data,S,e),j=!0)}if(e.select&&d!==void 0&&!Q)if(n&&d===(c==null?void 0:c.data)&&e.select===s(this,z))d=s(this,T);else try{l(this,z,e.select),d=e.select(d),d=ht(n==null?void 0:n.data,d,e),l(this,T,d),l(this,w,null)}catch(S){l(this,w,S)}else d===void 0&&l(this,w,null);s(this,w)&&(u=s(this,w),d=s(this,T),C=Date.now(),m="error",j=!1);const U=p.fetchStatus==="fetching",M=m==="pending",H=m==="error",st=M&&U,it=d!==void 0;return{status:m,fetchStatus:p.fetchStatus,isPending:M,isSuccess:m==="success",isError:H,isInitialLoading:st,isLoading:st,data:d,dataUpdatedAt:p.dataUpdatedAt,error:u,errorUpdatedAt:C,failureCount:p.fetchFailureCount,failureReason:p.fetchFailureReason,errorUpdateCount:p.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:p.dataUpdateCount>g.dataUpdateCount||p.errorUpdateCount>g.errorUpdateCount,isFetching:U,isRefetching:U&&!M,isLoadingError:H&&!it,isPaused:p.fetchStatus==="paused",isPlaceholderData:j,isRefetchError:H&&it,isStale:et(t,e),refetch:this.refetch,isEnabled:O(e.enabled,t)!==!1}}updateResult(){const t=s(this,R),e=this.createResult(s(this,a),this.options);if(l(this,E,s(this,a).state),l(this,P,this.options),s(this,E).data!==void 0&&l(this,x,s(this,a)),N(e,t))return;l(this,R,e);const r=()=>{if(!t)return!0;const{notifyOnChangeProps:o}=this.options,n=typeof o=="function"?o():o;if(n==="all"||!n&&!s(this,L).size)return!0;const c=new Set(n??s(this,L));return this.options.throwOnError&&c.add("error"),Object.keys(s(this,R)).some(v=>{const g=v;return s(this,R)[g]!==t[g]&&c.has(g)})};f(this,h,pt).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&f(this,h,Y).call(this)}},y=new WeakMap,a=new WeakMap,B=new WeakMap,R=new WeakMap,E=new WeakMap,P=new WeakMap,w=new WeakMap,z=new WeakMap,T=new WeakMap,x=new WeakMap,F=new WeakMap,D=new WeakMap,I=new WeakMap,L=new WeakMap,h=new WeakSet,A=function(t){f(this,h,q).call(this);let e=s(this,a).fetch(this.options,t);return t!=null&&t.throwOnError||(e=e.catch(Ot)),e},J=function(){f(this,h,Z).call(this);const t=k(this.options.staleTime,s(this,a));if(rt.isServer()||s(this,R).isStale||!ot(t))return;const e=Ct(s(this,R).dataUpdatedAt,t)+1;l(this,F,W.setTimeout(()=>{s(this,R).isStale||this.updateResult()},e))},G=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(s(this,a)):this.options.refetchInterval)??!1},X=function(t){f(this,h,$).call(this),l(this,I,t),!(rt.isServer()||O(this.options.enabled,s(this,a))===!1||!ot(s(this,I))||s(this,I)===0)&&l(this,D,W.setInterval(()=>{(this.options.refetchIntervalInBackground||St.isFocused())&&f(this,h,A).call(this)},s(this,I)))},Y=function(){f(this,h,J).call(this),f(this,h,X).call(this,f(this,h,G).call(this))},Z=function(){s(this,F)!==void 0&&(W.clearTimeout(s(this,F)),l(this,F,void 0))},$=function(){s(this,D)!==void 0&&(W.clearInterval(s(this,D)),l(this,D,void 0))},q=function(){const t=s(this,y).getQueryCache().build(s(this,y),this.options);if(t===s(this,a))return;const e=s(this,a);l(this,a,t),l(this,B,t.state),this.hasListeners()&&(e==null||e.removeObserver(this),t.addObserver(this))},pt=function(t){Qt.batch(()=>{t.listeners&&this.listeners.forEach(e=>{e(s(this,R))}),s(this,y).getQueryCache().notify({query:s(this,a),type:"observerResultsUpdated"})})},ft);function jt(i,t){return O(t.enabled,i)!==!1&&i.state.data===void 0&&!(i.state.status==="error"&&O(t.retryOnMount,i)===!1)}function ct(i,t){return jt(i,t)||i.state.data!==void 0&&tt(i,t,t.refetchOnMount)}function tt(i,t,e){if(O(t.enabled,i)!==!1&&k(t.staleTime,i)!=="static"){const r=typeof e=="function"?e(i):e;return r==="always"||r!==!1&&et(i,t)}return!1}function dt(i,t,e,r){return(i!==t||O(r.enabled,i)===!1)&&(!e.suspense||i.state.status!=="error")&&et(i,e)}function et(i,t){return O(t.enabled,i)!==!1&&i.isStaleByTime(k(t.staleTime,i))}function At(i,t){return!N(i.getCurrentResult(),t)}function kt(i,t,e){const r=xt(),o=Ut(()=>{var Q;let u=t;typeof u=="function"&&(u=u());const C=Pt(u);typeof C.enabled=="function"&&(C.enabled=C.enabled());const m=r.defaultQueryOptions(C);return m._optimisticResults=(Q=r.isRestoring)!=null&&Q.value?"isRestoring":"optimistic",m}),n=new i(r,o.value),c=o.value.shallow?It(n.getCurrentResult()):Et(n.getCurrentResult());let v=()=>{};r.isRestoring&&_(r.isRestoring,u=>{u||(v(),v=n.subscribe(C=>{lt(c,C)}))},{immediate:!0});const g=()=>{n.setOptions(o.value),lt(c,n.getCurrentResult())};_(o,g),Tt(()=>{v()});const V=(...u)=>(g(),c.refetch(...u)),p=()=>new Promise((u,C)=>{let m=()=>{};const Q=()=>{if(o.value.enabled!==!1){n.setOptions(o.value);const U=n.getOptimisticResult(o.value);U.isStale?(m(),n.fetchOptimistic(o.value).then(u,M=>{ut(o.value.throwOnError,[M,n.getCurrentQuery()])?C(M):u(n.getCurrentResult())})):(m(),u(U))}};Q(),m=_(o,Q)});_(()=>c.error,u=>{if(c.isError&&!c.isFetching&&ut(o.value.throwOnError,[u,n.getCurrentQuery()]))throw u});const j=o.value.shallow?Ft(c):Dt(c),d=Mt(j);for(const u in c)typeof c[u]=="function"&&(d[u]=c[u]);return d.suspense=p,d.refetch=V,d}function Vt(i,t){return kt(Lt,i)}export{Vt as u};