(function(r,w){typeof exports=="object"&&typeof module<"u"?w(exports,require("swrev"),require("svelte")):typeof define=="function"&&define.amd?define(["exports","swrev","svelte"],w):(r=typeof globalThis<"u"?globalThis:r||self,w(r.sswr={},r.swrev,r.svelte))})(this,function(r,w,D){"use strict";const d=()=>{};function E(e){for(var t=0;t<e.length;t++)e[t]()}function O(e,t){return e!=e?t==t:e!==t||e!==null&&typeof e=="object"||typeof e=="function"}let S=!1;function j(e){var t=S;try{return S=!0,e()}finally{S=t}}function K(e,t,s){if(e==null)return t(void 0),s&&s(void 0),d;const n=j(()=>e.subscribe(t,s));return n.unsubscribe?()=>n.unsubscribe():n}const b=[];function T(e,t){return{subscribe:W(e,t).subscribe}}function W(e,t=d){let s=null;const n=new Set;function o(a){if(O(e,a)&&(e=a,s)){const f=!b.length;for(const u of n)u[1](),b.push(u,e);if(f){for(let u=0;u<b.length;u+=2)b[u][0](b[u+1]);b.length=0}}}function l(a){o(a(e))}function v(a,f=d){const u=[a,f];return n.add(u),n.size===1&&(s=t(o,l)||d),a(e),()=>{n.delete(u),n.size===0&&s&&(s(),s=null)}}return{set:o,update:l,subscribe:v}}function _(e,t,s){const n=!Array.isArray(e),o=n?[e]:e;if(!o.every(Boolean))throw new Error("derived() expects stores as input, got a falsy value");const l=t.length<2;return T(s,(v,a)=>{let f=!1;const u=[];let h=0,g=d;const y=()=>{if(h)return;g();const c=t(n?u[0]:u,v,a);l?v(c):g=typeof c=="function"?c:d},i=o.map((c,m)=>K(c,F=>{u[m]=F,h&=~(1<<m),f&&y()},()=>{h|=1<<m}));return f=!0,y(),function(){E(i),g(),f=!1}})}class q extends w.SWR{useSWR(t,s){let n;const o=W(void 0,()=>()=>n==null?void 0:n()),l=W(void 0,()=>()=>n==null?void 0:n()),v=i=>{l.set(void 0),o.set(i)},a=i=>l.set(i);n=this.subscribe(t,v,a,{loadInitialCache:!0,...s}).unsubscribe,D.onDestroy(()=>n==null?void 0:n());const f=(i,c)=>this.mutate(this.resolveKey(t),i,{revalidateOptions:s,...c}),u=i=>this.revalidate(this.resolveKey(t),{...s,...i}),h=i=>this.clear(this.resolveKey(t),i),g=_([o,l],([i,c])=>i===void 0&&c===void 0),y=_([o,l],([i,c])=>i!==void 0&&c===void 0);return{data:o,error:l,mutate:f,revalidate:u,clear:h,isLoading:g,isValid:y}}}const R=e=>new q(e);r.swr=R();const z=e=>(r.swr=R(e),r.swr),A=(e,t)=>r.swr.subscribeData(e,t),B=(e,t)=>r.swr.subscribeErrors(e,t),C=e=>r.swr.get(e),I=e=>r.swr.getWait(e),L=(e,t,s,n)=>r.swr.subscribe(e,t,s,n),M=(e,t)=>r.swr.useSWR(e,t),P=(e,t,s)=>r.swr.mutate(e,t,s),V=(e,t)=>r.swr.revalidate(e,t),k=(e,t)=>r.swr.clear(e,t);r.SSWR=q,r.clear=k,r.createDefaultSWR=z,r.createSWR=R,r.get=C,r.getOrWait=I,r.mutate=P,r.revalidate=V,r.subscribe=A,r.subscribeErrors=B,r.use=L,r.useSWR=M,Object.defineProperty(r,Symbol.toStringTag,{value:"Module"})});
