import{d as S}from"./destr.CVtkxrq9.js";import{d as h,a as $}from"./deep-pick-omit.CegYQlcN.js";function p(e,{storage:c,serializer:t,key:s,debug:i,pick:o,omit:d,beforeHydrate:a,afterHydrate:r},n,f=!0){try{f&&(a==null||a(n));const l=c.getItem(s);if(l){const u=t.deserialize(l),g=o?h(u,o):u,z=d?$(g,d):g;e.$patch(z)}f&&(r==null||r(n))}catch(l){i&&console.error("[pinia-plugin-persistedstate]",l)}}function m(e,{storage:c,serializer:t,key:s,debug:i,pick:o,omit:d}){try{const a=o?h(e,o):e,r=d?$(a,d):a,n=t.serialize(r);c.setItem(s,n)}catch(a){i&&console.error("[pinia-plugin-persistedstate]",a)}}function y(e,c,t){const{pinia:s,store:i,options:{persist:o=t}}=e;if(!o)return;if(!(i.$id in s.state.value)){const r=s._s.get(i.$id.replace("__hot:",""));r&&Promise.resolve().then(()=>r.$persist());return}const a=(Array.isArray(o)?o:o===!0?[{}]:[o]).map(c);i.$hydrate=({runHooks:r=!0}={})=>{a.forEach(n=>{p(i,n,e,r)})},i.$persist=()=>{a.forEach(r=>{m(i.$state,r)})},a.forEach(r=>{p(i,r,e),i.$subscribe((n,f)=>m(f,r),{detached:!0})})}function k(e={}){return function(c){y(c,t=>({key:(e.key?e.key:s=>s)(t.key??c.store.$id),debug:t.debug??e.debug??!1,serializer:t.serializer??e.serializer??{serialize:s=>JSON.stringify(s),deserialize:s=>S(s)},storage:t.storage??e.storage??window.localStorage,beforeHydrate:t.beforeHydrate,afterHydrate:t.afterHydrate,pick:t.pick,omit:t.omit}),e.auto??!1)}}var P=k();export{P as s};
