| 5 |
*/let D;const C=t=>D=t,H=Symbol();function x(t){return t&&typeof t=="object"&&Object.prototype.toString.call(t)==="[object Object]"&&typeof t.toJSON!="function"}var E;(function(t){t.direct="direct",t.patchObject="patch object",t.patchFunction="patch function"})(E||(E={}));function $t(){const t=K(!0),r=t.run(()=>tt({}));let n=[],e=[];const s=k({install(o){C(s),s._a=o,o.provide(H,s),o.config.globalProperties.$pinia=s,e.forEach(a=>n.push(a)),e=[]},use(o){return!this._a&&!T?e.push(o):n.push(o),this},_p:n,_a:null,_e:t,_s:new Map,state:r});return s}const U=()=>{};function O(t,r,n,e=U){t.push(r);const s=()=>{const o=t.indexOf(r);o>-1&&(t.splice(o,1),e())};return!n&&ot()&&ct(s),s}function R(t,...r){t.slice().forEach(n=>{n(...r)})}const lt=t=>t(),V=Symbol(),I=Symbol();function L(t,r){t instanceof Map&&r instanceof Map?r.forEach((n,e)=>t.set(e,n)):t instanceof Set&&r instanceof Set&&r.forEach(t.add,t);for(const n in r){if(!r.hasOwnProperty(n))continue;const e=r[n],s=t[n];x(s)&&x(e)&&t.hasOwnProperty(n)&&!A(e)&&!q(e)?t[n]=L(s,e):t[n]=e}return t}const ht=Symbol();function dt(t){return!x(t)||!t.hasOwnProperty(ht)}const{assign:S}=Object;function bt(t){return!!(A(t)&&t.effect)}function yt(t,r,n,e){const{state:s,actions:o,getters:a}=r,c=n.state.value[t];let l;function f(){c||(n.state.value[t]=s?s():{});const h=at(n.state.value[t]);return S(h,o,Object.keys(a||{}).reduce((y,m)=>(y[m]=k(ft(()=>{C(n);const _=n._s.get(t);return a[m].call(_,_)})),y),{}))}return l=Q(t,f,r,n,e,!0),l}function Q(t,r,n={},e,s,o){let a;const c=S({actions:{}},n),l={deep:!0};let f,h,y=[],m=[],_;const g=e.state.value[t];!o&&!g&&(e.state.value[t]={});let N;function z(i){let u;f=h=!1,typeof i=="function"?(i(e.state.value[t]),u={type:E.patchFunction,storeId:t,events:_}):(L(e.state.value[t],i),u={type:E.patchObject,payload:i,storeId:t,events:_});const d=N=Symbol();ut().then(()=>{N===d&&(f=!0)}),h=!0,R(y,u,e.state.value[t])}const X=o?function(){const{state:u}=n,d=u?u():{};this.$patch(p=>{S(p,d)})}:U;function Y(){a.stop(),y=[],m=[],e._s.delete(t)}const W=(i,u="")=>{if(V in i)return i[I]=u,i;const d=function(){C(e);const p=Array.from(arguments),P=[],w=[];function G(b){P.push(b)}function M(b){w.push(b)}R(m,{args:p,name:d[I],store:v,after:G,onError:M});let $;try{$=i.apply(this&&this.$id===t?this:v,p)}catch(b){throw R(w,b),b}return $ instanceof Promise?$.then(b=>(R(P,b),b)).catch(b=>(R(w,b),Promise.reject(b))):(R(P,$),$)};return d[V]=!0,d[I]=u,d},Z={_p:e,$id:t,$onAction:O.bind(null,m),$patch:z,$reset:X,$subscribe(i,u={}){const d=O(y,i,u.detached,()=>p()),p=a.run(()=>rt(()=>e.state.value[t],P=>{(u.flush==="sync"?h:f)&&i({storeId:t,type:E.direct,events:_},P)},S({},l,u)));return d},$dispose:Y},v=it(Z);e._s.set(t,v);const j=(e._a&&e._a.runWithContext||lt)(()=>e._e.run(()=>(a=K()).run(()=>r({action:W}))));for(const i in j){const u=j[i];if(A(u)&&!bt(u)||q(u))o||(g&&dt(u)&&(A(u)?u.value=g[i]:L(u,g[i])),e.state.value[t][i]=u);else if(typeof u=="function"){const d=W(u,i);j[i]=d,c.actions[i]=u}}return S(v,j),S(st(v),j),Object.defineProperty(v,"$state",{get:()=>e.state.value[t],set:i=>{z(u=>{S(u,i)})}}),e._p.forEach(i=>{S(v,a.run(()=>i({store:v,app:e._a,pinia:e,options:c})))}),g&&o&&n.hydrate&&n.hydrate(v.$state,g),f=!0,h=!0,v}/*! #__NO_SIDE_EFFECTS__ */function Et(t,r,n){let e,s;const o=typeof r=="function";typeof t=="string"?(e=t,s=o?n:r):(s=t,e=t.id);function a(c,l){const f=et();return c=c||(f?nt(H,null):null),c&&C(c),c=D,c._s.has(e)||(o?Q(e,r,s,c):yt(e,s,c)),c._s.get(e)}return a.$id=e,a}function At(t,r){return Array.isArray(r)?r.reduce((n,e)=>(n[e]=function(){return t(this.$pinia)[e]},n),{}):Object.keys(r).reduce((n,e)=>(n[e]=function(){const s=t(this.$pinia),o=r[e];return typeof o=="function"?o.call(this,s):s[o]},n),{})}function Ct(t,r){return Array.isArray(r)?r.reduce((n,e)=>(n[e]=function(...s){return t(this.$pinia)[e](...s)},n),{}):Object.keys(r).reduce((n,e)=>(n[e]=function(...s){return t(this.$pinia)[r[e]](...s)},n),{})}function vt(t){return typeof t=="object"&&t!==null}function F(t,r){return t=vt(t)?t:Object.create(null),new Proxy(t,{get(n,e,s){return e==="key"?Reflect.get(n,e,s):Reflect.get(n,e,s)||Reflect.get(r,e,s)}})}function St(t,r){return r.reduce((n,e)=>n==null?void 0:n[e],t)}function mt(t,r,n){return r.slice(0,-1).reduce((e,s)=>/^(__proto__)$/.test(s)?{}:e[s]=e[s]||{},t)[r[r.length-1]]=n,t}function _t(t,r){return r.reduce((n,e)=>{const s=e.split(".");return mt(n,s,St(t,s))},{})}function gt(t,r){return n=>{var e;try{const{storage:s=localStorage,beforeRestore:o=void 0,afterRestore:a=void 0,serializer:c={serialize:JSON.stringify,deserialize:JSON.parse},key:l=r.$id,paths:f=null,debug:h=!1}=n;return{storage:s,beforeRestore:o,afterRestore:a,serializer:c,key:((e=t.key)!=null?e:y=>y)(typeof l=="string"?l:l(r.$id)),paths:f,debug:h}}catch(s){return n.debug&&console.error("[pinia-plugin-persistedstate]",s),null}}}function J(t,{storage:r,serializer:n,key:e,debug:s}){try{const o=r==null?void 0:r.getItem(e);o&&t.$patch(n==null?void 0:n.deserialize(o))}catch(o){s&&console.error("[pinia-plugin-persistedstate]",o)}}function B(t,{storage:r,serializer:n,key:e,paths:s,debug:o}){try{const a=Array.isArray(s)?_t(t,s):t;r.setItem(e,n.serialize(a))}catch(a){o&&console.error("[pinia-plugin-persistedstate]",a)}}function pt(t={}){return r=>{const{auto:n=!1}=t,{options:{persist:e=n},store:s,pinia:o}=r;if(!e)return;if(!(s.$id in o.state.value)){const c=o._s.get(s.$id.replace("__hot:",""));c&&Promise.resolve().then(()=>c.$persist());return}const a=(Array.isArray(e)?e.map(c=>F(c,t)):[F(e,t)]).map(gt(t,s)).filter(Boolean);s.$persist=()=>{a.forEach(c=>{B(s.$state,c)})},s.$hydrate=({runHooks:c=!0}={})=>{a.forEach(l=>{const{beforeRestore:f,afterRestore:h}=l;c&&(f==null||f(r)),J(s,l),c&&(h==null||h(r))})},a.forEach(c=>{const{beforeRestore:l,afterRestore:f}=c;l==null||l(r),J(s,c),f==null||f(r),s.$subscribe((h,y)=>{B(y,c)},{detached:!0})})}}var wt=pt();export{Ct as a,$t as c,Et as d,At as m,wt as s}; |