// Simple Pinia persistence plugin supporting `persist: true` and Map serialization. export function persistPlugin({ store }) { if (!store.$options || !store.$options.persist) return const key = `pinia-${store.$id}` try { const raw = localStorage.getItem(key) if (raw) { const state = JSON.parse(raw, (k, v) => { if (v && v.__map === true && Array.isArray(v.data)) return new Map(v.data) return v }) store.$patch(state) } } catch {} store.$subscribe((_mutation, state) => { try { const json = JSON.stringify(state, (_k, v) => { if (v instanceof Map) return { __map: true, data: Array.from(v.entries()) } return v }) localStorage.setItem(key, json) } catch {} }) }