var e=1,t=new Set([`endpointList`,`selectedEndpoint`,`geoIPCache`]),n=[`bing`,`vue-query`];function r(e){return t.has(e)?!0:n.some(t=>e.startsWith(t))}function i(){function t(){let e={};for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);if(!n||r(n))continue;let i=localStorage.getItem(n);i!==null&&(e[n]=i)}return e}function n(){return{app:`metacubexd`,version:e,exportedAt:new Date().toISOString(),settings:t()}}function i(){let e=new Blob([JSON.stringify(n(),null,2)],{type:`application/json`}),t=URL.createObjectURL(e),r=document.createElement(`a`);r.href=t,r.download=`metacubexd-settings-${new Date().toISOString().slice(0,19).replaceAll(`:`,`-`).replace(`T`,`-`)}.json`,r.click(),URL.revokeObjectURL(t)}function a(){return n()}function o(e){if(!e||e.app!==`metacubexd`||typeof e.settings!=`object`||e.settings===null)throw Error(`Not a valid metacubexd settings backup`);let t=0;for(let[n,i]of Object.entries(e.settings))r(n)||typeof i!=`string`||(localStorage.setItem(n,i),t++);return t}async function s(e){let t=await e.text(),n;try{n=JSON.parse(t)}catch{throw Error(`Invalid JSON file`)}return o(n)}return{downloadSettings:i,importSettings:s,exportSettings:a,applySettings:o}}export{i as t};