import e from"lodash/set";import r from"lodash/get";import t from"lodash/unset";import a from"moment";var o=function(e){return e.expiry?e.value:e};function i(e){if("string"==typeof e)localStorage.removeItem(e);else if(Array.isArray(e)&&e.length){var r=JSON.parse(localStorage.getItem(e[0]));t(r,e.slice(1)),localStorage.setItem(e[0],JSON.stringify(r))}}function l(r,t){var i,l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=arguments.length>3?arguments[3]:void 0,g=l&&l.length?{value:t,expiry:a().add(l[0],l[1])}:t;if("string"==typeof r?(i=g,localStorage.setItem(r,JSON.stringify(i))):Array.isArray(r)&&r.length&&(i=JSON.parse(localStorage.getItem(r[0]))||{},e(i,r.slice(1),g),localStorage.setItem(r[0],JSON.stringify(i))),i&&"function"==typeof n){var s=o(i);n(s)}}var n=function(e,r){var t=e;return Array.isArray(e)?(l(r,t=e.filter((function(e){return!e.expiry||a().diff(e.expiry)<0}))),t.map((function(e){return e.value}))):(e&&e.expiry&&a().diff(e.expiry)>0&&(i(r),t=void 0),t)};function g(e){var t,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if("string"==typeof e)t=JSON.parse(localStorage.getItem(e));else if(Array.isArray(e)&&e.length){var o=JSON.parse(localStorage.getItem(e[0]));t=r(o,e.slice(1))}var i=n(t,e);return void 0!==i?i:a}function s(t,i){var l,n,g=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,s=arguments.length>3?arguments[3]:void 0,f=g&&g.length?{value:i,expiry:a().add(g[0],g[1])}:i;if("string"==typeof t?((n=JSON.parse(localStorage.getItem(t))||[]).push(f),localStorage.setItem(t,n)):Array.isArray(t)&&t.length&&(l=JSON.parse(localStorage.getItem(t[0]))||{},(n=r(l,t.slice(1),[])).push(f),e(l,t.slice(1),n),localStorage.setItem(t[0],JSON.stringify(l))),n&&"function"==typeof s){var c=n.map((function(e){return o(e)}));s(c)}}export{i as deleteValue,g as getValue,s as pushValue,l as setValue};
//# sourceMappingURL=core.js.map
