"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("vue"),x={create:()=>Promise.resolve({data:null}),deleteOne:()=>Promise.resolve({data:null}),getList:()=>Promise.resolve({data:Array.from({length:30}).map((e,n)=>({name:n,id:n})),total:20}),getMany:()=>Promise.resolve({data:[]}),getManyReference:()=>Promise.resolve({data:[],total:0}),getOne:()=>Promise.resolve({data:null}),update:()=>Promise.resolve({data:null})},C=new WeakMap,M=(...e)=>{var n;const r=e[0],o=(n=l.getCurrentInstance())==null?void 0:n.proxy;if(o==null)throw new Error("injectLocal must be called in setup");return C.has(o)&&r in C.get(o)?C.get(o)[r]:l.inject(...e)};function b(e){return typeof e=="function"?e():l.unref(e)}typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const B=()=>{};function S(e,n=!1,r="Timeout"){return new Promise((o,h)=>{setTimeout(n?()=>h(r):o,e)})}function D(e,n=!1){function r(t,{flush:u="sync",deep:a=!1,timeout:c,throwOnTimeout:w}={}){let f=null;const v=[new Promise(y=>{f=l.watch(e,d=>{t(d)!==n&&(f==null||f(),y(d))},{flush:u,deep:a,immediate:!0})})];return c!=null&&v.push(S(c,w).then(()=>b(e)).finally(()=>f==null?void 0:f())),Promise.race(v)}function o(t,u){if(!l.isRef(t))return r(d=>d===t,u);const{flush:a="sync",deep:c=!1,timeout:w,throwOnTimeout:f}=u??{};let i=null;const y=[new Promise(d=>{i=l.watch([e,t],([s,T])=>{n!==(s===T)&&(i==null||i(),d(s))},{flush:a,deep:c,immediate:!0})})];return w!=null&&y.push(S(w,f).then(()=>b(e)).finally(()=>(i==null||i(),b(e)))),Promise.race(y)}function h(t){return r(u=>!!u,t)}function g(t){return o(null,t)}function O(t){return o(void 0,t)}function A(t){return r(Number.isNaN,t)}function E(t,u){return r(a=>{const c=Array.from(a);return c.includes(t)||c.includes(b(t))},u)}function P(t){return m(1,t)}function m(t=1,u){let a=-1;return r(()=>(a+=1,a>=t),u)}return Array.isArray(b(e))?{toMatch:r,toContains:E,changed:P,changedTimes:m,get not(){return D(e,!n)}}:{toMatch:r,toBe:o,toBeTruthy:h,toBeNull:g,toBeNaN:A,toBeUndefined:O,changed:P,changedTimes:m,get not(){return D(e,!n)}}}function U(e){return D(e)}const _=Symbol("DATA_PROVIDER_CONTEXT"),F=()=>M(_,x);function N(e){const{initialData:n,shallow:r,onSuccess:o=B,onError:h=B,immediate:g,resetOnExecute:O=!1,queryFn:A,queryKey:E}=e,P=(r?l.shallowRef:l.ref)(n),m=l.ref(!1),t=l.ref(!1),u=l.ref(!1),a=l.shallowRef(),c=s=>{t.value=s,m.value=!s},w=()=>{O&&(P.value=n)},f=()=>new Promise((s,T)=>{U(m).toBe(!0).then(()=>a.value?T(a.value):s(d))}),i={then:(...s)=>f().then(...s),catch:(...s)=>f().catch(...s)};let v=0;const y=s=>{if(a.value=void 0,t.value)return i;if(A===void 0)return m.value=!0,i;w(),c(!0),v+=1;const T=v;return A(s).then(p=>{const R=p;P.value=R,o(R)}).catch(p=>{a.value=p,h(p)}).finally(()=>{var p;(p=e.onFinish)==null||p.call(e),T===v&&c(!1)}),i};g&&y();const d={data:P,error:a,isFinished:m,isLoading:t,isAborted:u,isCanceled:u,execute:y};return{...d,...i}}const j=(e,n=!1)=>{const{update:r}=F(),o=N({immediate:n,queryFn:g=>r(e,g)}),h=o.execute;return{...o,sendUpdate:h}};exports.useUpdate=j;
//# sourceMappingURL=useUpdate.js.map
