const s=(s,e)=>{const t=s.storage||sessionStorage,i=s.key||e.$id;if(s.paths){const o=s.paths.reduce(((s,t)=>(s[t]=e.$state[t],s)),{});t.setItem(i,JSON.stringify(o))}else t.setItem(i,JSON.stringify(e.$state))};var e=({options:e,store:t})=>{var i,o,r,a;if(null==(i=e.persist)?void 0:i.enabled){const i=[{key:t.$id,storage:sessionStorage}],n=(null==(r=null==(o=e.persist)?void 0:o.strategies)?void 0:r.length)?null==(a=e.persist)?void 0:a.strategies:i;n.forEach((e=>{const i=e.storage||sessionStorage,o=e.key||t.$id,r=i.getItem(o);r&&(t.$patch(JSON.parse(r)),s(e,t))})),t.$subscribe((()=>{n.forEach((e=>{s(e,t)}))}))}};export{e as i};
