/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/effector-persist@1.0.4/lib/index.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.withPersist=void 0;const effector_1=require("effector"),defaultConfig={key:"persist"},withPersist=(e,t=defaultConfig)=>{const r=e.shortName,{key:s,expire:o}=t,i=`${s}:${r}`,a=(0,effector_1.createEvent)("@PERSIST/REHYDRATE");o&&isExpired(o)&&localStorage.removeItem(i);const c=localStorage.getItem(i);return c&&(e.on(a,(()=>JSON.parse(c))),a()),e.watch((e=>{localStorage.setItem(i,JSON.stringify(e))})),e};exports.withPersist=withPersist;const isExpired=e=>e<Date.now();
//# sourceMappingURL=/sm/fcddaf31419add9901ffd299a57ab8f160788908a43a6e5b743e090b0ed45c3f.map