class t{storagePrefix="";constructor(t=""){this.storagePrefix=t}async fetchJson(t,e={},n=false,s=null){const i=typeof t==="string"?t:t.url;const r=i;let o=null;let f=null;if(n){f=this.store.get(r);if(f&&!f.permanent){if(f.data){return f.data}}}try{const i=await fetch(t,e);o=await i.json();if(n){if(typeof s==="function"&&f!=null){s(o)}this.store.set(r,this.wrapJson(o,true),true);this.store.set(r,this.wrapJson(o,false),false)}return o}catch(t){console.error(t);return null}}wrapJson(t,e=false){const n=new Date;return{timestamp:n.getTime(),time:n.toISOString(),data:t,permanent:e}}store={get:(t,e=false)=>{const n=e?window.localStorage:window.sessionStorage;const s=e?window.sessionStorage:window.localStorage;let i=n.getItem(`${this.storagePrefix}-${t}`);if(!i){i=s.getItem(`${this.storagePrefix}-${t}`)}if(!i){return i}if(i.indexOf("{")===0){try{return JSON.parse(i)}catch(t){}}if(i.indexOf(",")!==-1){return i.split(",")}return i},set:(t,e,n=false)=>{const s=n?window.localStorage:window.sessionStorage;if(typeof e==="object"&&typeof e.length==="undefined"){s.setItem(`${this.storagePrefix}-${t}`,JSON.stringify(e));return}s.setItem(`${this.storagePrefix}-${t}`,e)},remove:t=>{window.sessionStorage.removeItem(`${this.storagePrefix}-${t}`)}}}export{t as F};
//# sourceMappingURL=p-3478f368.js.map