+(function(r,t){typeof exports=="object"&&typeof module<"u"?t(exports):typeof define=="function"&&define.amd?define(["exports"],t):(r=typeof globalThis<"u"?globalThis:r||self,t(r.storemanager={}))})(this,function(r){"use strict";var S=Object.defineProperty;var g=(r,t,f)=>t in r?S(r,t,{enumerable:!0,configurable:!0,writable:!0,value:f}):r[t]=f;var c=(r,t,f)=>g(r,typeof t!="symbol"?t+"":t,f);class t{constructor(e="cache"){c(this,"prefix");this.prefix=e}getStorageMedium(e=!0){return typeof window>"u"||typeof window.localStorage>"u"?null:e?window.localStorage:window.sessionStorage}Has(e){return typeof this.Get(`${this.prefix}-${e}`)<"u"}Get(e){const i=this.getStorageMedium(!1),s=this.getStorageMedium(!0);let n=!1,o=null;if(i&&s){try{o=i.getItem(`${this.prefix}-${e}`),o=this.toJSONIfJSON(o),n=o!==null}catch{}if(!n)try{o=s.getItem(`${this.prefix}-${e}`),o=this.toJSONIfJSON(o),n=o!==null}catch{}}return o}toJSONIfJSON(e){return typeof e=="string"&&(e.indexOf("{")===0||e.indexOf("[")===0)&&(e=JSON.parse(e)),e}Save(e,i,s=!0){console.warn("StoreManager.Save is deprecated"),this.Set(e,i,s)}Set(e,i,s=!0){const n=this.getStorageMedium(s);let o=!1;if(n){typeof i=="object"&&(i=JSON.stringify(i));try{n.setItem(`${this.prefix}-${e}`,i),o=!0}catch(u){console.error("Unable to save object",u)}}return o}Remove(e){const i=this.getStorageMedium(!0),s=this.getStorageMedium(!1);i&&i.removeItem(`${this.prefix}-${e}`),s&&s.removeItem(`${this.prefix}-${e}`)}}r.StoreManager=t,Object.defineProperty(r,Symbol.toStringTag,{value:"Module"})});
0 commit comments