import { CustomJSONStringify as e } from "../../functions/utils/serialize.utils.mjs";
import { BaseCacheDevice as t } from "./BaseCacheDevice.mjs";
//#region libs/shared/common/src/data-structures/cacheDevices/LocalStorageCacheDevice.ts
var n = class extends t {
	localDataStorage;
	constructor(e, t) {
		super(), !e && typeof localStorage < "u" && (this.localDataStorage = localStorage), t && this.mergeWithSerialized(t);
	}
	get(e) {
		return this.localDataStorage ? this.localDataStorage.getItem(e) ?? void 0 : this.getInMemory(e);
	}
	set(e, t) {
		this.localDataStorage ? this.localDataStorage.setItem(e, t) : this.setInMemory(e, t);
	}
	serialize() {
		let t = this.localDataStorage ? Object.entries(localStorage) : [...this.inMemoryCache];
		return Object.fromEntries(t.map(([t, n]) => [t, e(n)]));
	}
};
//#endregion
export { n as LocalStorageCacheDevice };
