import{f as F,r as Y,g as H,j as p,k as V,t as Z,n as G,l as $,m as q,e as A,w as T,q as tt,v as et,i as st,x as nt}from"./vue-CrDyBScg.js";let B;const E=t=>B=t,D=Symbol();function R(t){return t&&typeof t=="object"&&Object.prototype.toString.call(t)==="[object Object]"&&typeof t.toJSON!="function"}var k;(function(t){t.direct="direct",t.patchObject="patch object",t.patchFunction="patch function"})(k||(k={}));function it(){const t=H(!0),o=t.run(()=>F({}));let s=[],e=[];const r=q({install(u){E(r),r._a=u,u.provide(D,r),u.config.globalProperties.$pinia=r,e.forEach(a=>s.push(a)),e=[]},use(u){return this._a?s.push(u):e.push(u),this},_p:s,_a:null,_e:t,_s:new Map,state:o});return r}const J=()=>{};function O(t,o,s,e=J){t.push(o);const r=()=>{const u=t.indexOf(o);u>-1&&(t.splice(u,1),e())};return!s&&tt()&&et(r),r}function P(t,...o){t.slice().forEach(s=>{s(...o)})}const ot=t=>t();function I(t,o){t instanceof Map&&o instanceof Map&&o.forEach((s,e)=>t.set(e,s)),t instanceof Set&&o instanceof Set&&o.forEach(t.add,t);for(const s in o){if(!o.hasOwnProperty(s))continue;const e=o[s],r=t[s];R(r)&&R(e)&&t.hasOwnProperty(s)&&!p(e)&&!V(e)?t[s]=I(r,e):t[s]=e}return t}const ct=Symbol();function rt(t){return!R(t)||!t.hasOwnProperty(ct)}const{assign:v}=Object;function ut(t){return!!(p(t)&&t.effect)}function ft(t,o,s,e){const{state:r,actions:u,getters:a}=o,f=s.state.value[t];let g;function b(){f||(s.state.value[t]=r?r():{});const y=$(s.state.value[t]);return v(y,u,Object.keys(a||{}).reduce((m,_)=>(m[_]=q(A(()=>{E(s);const d=s._s.get(t);return a[_].call(d,d)})),m),{}))}return g=N(t,b,o,s,e,!0),g}function N(t,o,s={},e,r,u){let a;const f=v({actions:{}},s),g={deep:!0};let b,y,m=[],_=[],d;const j=e.state.value[t];!u&&!j&&(e.state.value[t]={}),F({});let L;function W(c){let n;b=y=!1,typeof c=="function"?(c(e.state.value[t]),n={type:k.patchFunction,storeId:t,events:d}):(I(e.state.value[t],c),n={type:k.patchObject,payload:c,storeId:t,events:d});const h=L=Symbol();G().then(()=>{L===h&&(b=!0)}),y=!0,P(m,n,e.state.value[t])}const z=u?function(){const{state:n}=s,h=n?n():{};this.$patch(S=>{v(S,h)})}:J;function K(){a.stop(),m=[],_=[],e._s.delete(t)}function M(c,n){return function(){E(e);const h=Array.from(arguments),S=[],x=[];function U(l){S.push(l)}function X(l){x.push(l)}P(_,{args:h,name:c,store:i,after:U,onError:X});let C;try{C=n.apply(this&&this.$id===t?this:i,h)}catch(l){throw P(x,l),l}return C instanceof Promise?C.then(l=>(P(S,l),l)).catch(l=>(P(x,l),Promise.reject(l))):(P(S,C),C)}}const Q={_p:e,$id:t,$onAction:O.bind(null,_),$patch:W,$reset:z,$subscribe(c,n={}){const h=O(m,c,n.detached,()=>S()),S=a.run(()=>T(()=>e.state.value[t],x=>{(n.flush==="sync"?y:b)&&c({storeId:t,type:k.direct,events:d},x)},v({},g,n)));return h},$dispose:K},i=Y(Q);e._s.set(t,i);const w=(e._a&&e._a.runWithContext||ot)(()=>e._e.run(()=>(a=H()).run(o)));for(const c in w){const n=w[c];if(p(n)&&!ut(n)||V(n))u||(j&&rt(n)&&(p(n)?n.value=j[c]:I(n,j[c])),e.state.value[t][c]=n);else if(typeof n=="function"){const h=M(c,n);w[c]=h,f.actions[c]=n}}return v(i,w),v(Z(i),w),Object.defineProperty(i,"$state",{get:()=>e.state.value[t],set:c=>{W(n=>{v(n,c)})}}),e._p.forEach(c=>{v(i,a.run(()=>c({store:i,app:e._a,pinia:e,options:f})))}),j&&u&&s.hydrate&&s.hydrate(i.$state,j),b=!0,y=!0,i}function ht(t,o,s){let e,r;const u=typeof o=="function";typeof t=="string"?(e=t,r=u?s:o):(r=t,e=t.id);function a(f,g){const b=nt();return f=f||(b?st(D,null):null),f&&E(f),f=B,f._s.has(e)||(u?N(e,o,r,f):ft(e,r,f)),f._s.get(e)}return a.$id=e,a}export{it as c,ht as d};
