"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("crypto-js");function f({encryptionKey:c}){const s=!!c,g=(t,e,r=null)=>{try{const o=r!==null?Date.now()+r*36e5:null,n=s?p({value:e,expiry:o}):JSON.stringify({value:e,expiry:o});localStorage.setItem(t,n)}catch(o){throw console.error("Failed to set item",o),new Error("Failed to set item")}},a=t=>{const e=localStorage.getItem(t);if(!e)return null;try{const r=s?m(e):JSON.parse(e);return r.expiry&&Date.now()>r.expiry?(localStorage.removeItem(t),null):r.value}catch(r){return console.error("Failed to get item",r),null}},i=t=>{localStorage.removeItem(t)},u=()=>{const t=Object.keys(localStorage).reduce((e,r)=>{const o=localStorage.getItem(r);return o?e+r.length+o.length:e},0);return{usedBytes:t,remainingBytes:5*1024*1024-t}},y=()=>{localStorage.clear()},S=()=>{Object.keys(localStorage).forEach(t=>{const e=a(t);e!=null&&e.expiry&&Date.now()>e.expiry&&i(t)})},d=t=>{const e=[];for(let r=0;r{try{return l.AES.encrypt(JSON.stringify(t),c).toString()}catch(e){throw console.error("Encryption failed",e),new Error("Encryption failed")}},m=t=>{try{const e=l.AES.decrypt(t,c);return JSON.parse(e.toString(l.enc.Utf8))}catch(e){throw console.error("Decryption failed",e),new Error("Decryption failed")}};return{setItem:g,getItem:a,removeItem:i,getRemainingStorage:u,clearStorage:y,cleanUp:S,query:d}}exports.createSecureTimedStorage=f;