import{e as o}from"./chunk-Q6OK2OOV.js";import"./chunk-KAT7YFEL.js";var a=class extends o{constructor(){super(...arguments),this.group="CapacitorStorage"}async configure({group:e}){typeof e=="string"&&(this.group=e)}async get(e){return{value:this.impl.getItem(this.applyPrefix(e.key))}}async set(e){this.impl.setItem(this.applyPrefix(e.key),e.value)}async remove(e){this.impl.removeItem(this.applyPrefix(e.key))}async keys(){return{keys:this.rawKeys().map(t=>t.substring(this.prefix.length))}}async clear(){for(let e of this.rawKeys())this.impl.removeItem(e)}async migrate(){var e;let t=[],s=[],n="_cap_",l=Object.keys(this.impl).filter(i=>i.indexOf(n)===0);for(let i of l){let r=i.substring(n.length),p=(e=this.impl.getItem(i))!==null&&e!==void 0?e:"",{value:c}=await this.get({key:r});typeof c=="string"?s.push(r):(await this.set({key:r,value:p}),t.push(r))}return{migrated:t,existing:s}}async removeOld(){let e="_cap_",t=Object.keys(this.impl).filter(s=>s.indexOf(e)===0);for(let s of t)this.impl.removeItem(s)}get impl(){return window.localStorage}get prefix(){return this.group==="NativeStorage"?"":`${this.group}.`}rawKeys(){return Object.keys(this.impl).filter(e=>e.indexOf(this.prefix)===0)}applyPrefix(e){return this.prefix+e}};export{a as PreferencesWeb};
