import{i as e,w as t,t as n,a as r,b as a,c as o,d as l}from"./index-BMspkLA9.js";import{bv as i,r as u,w as s,bV as f,E as c,aw as d,bW as v}from"./main-D8Z-8iPZ.js";const g=e?window:void 0;function p(...e){const t=[],n=()=>{t.forEach((e=>e())),t.length=0},i=s((()=>{const t=r(f(e[0])).filter((e=>null!=e));return t.every((e=>"string"!=typeof e))?t:void 0})),u=a((()=>{var t,n;return[null!=(n=null==(t=i.value)?void 0:t.map((e=>function(e){var t;const n=f(e);return null!=(t=null==n?void 0:n.$el)?t:n}(e))))?n:[g].filter((e=>null!=e)),r(f(i.value?e[1]:e[0])),r(v(i.value?e[2]:e[1])),f(i.value?e[3]:e[2])]}),(([e,r,a,o])=>{if(n(),!(null==e?void 0:e.length)||!(null==r?void 0:r.length)||!(null==a?void 0:a.length))return;const i=l(o)?{...o}:o;t.push(...e.flatMap((e=>r.flatMap((t=>a.map((n=>((e,t,n,r)=>(e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)))(e,t,n,i))))))))}),{flush:"post"});return o(n),()=>{u(),n()}}const w="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},y="__vueuse_ssr_handlers__",m=S();function S(){return y in w||(w[y]=w[y]||{}),w[y]}const b={boolean:{read:e=>"true"===e,write:e=>String(e)},object:{read:e=>JSON.parse(e),write:e=>JSON.stringify(e)},number:{read:e=>Number.parseFloat(e),write:e=>String(e)},any:{read:e=>e,write:e=>String(e)},string:{read:e=>e,write:e=>String(e)},map:{read:e=>new Map(JSON.parse(e)),write:e=>JSON.stringify(Array.from(e.entries()))},set:{read:e=>new Set(JSON.parse(e)),write:e=>JSON.stringify(Array.from(e))},date:{read:e=>new Date(e),write:e=>e.toISOString()}},h="vueuse-storage";function N(e,r,a,o={}){var l;const{flush:v="pre",deep:w=!0,listenToStorageChanges:y=!0,writeDefaults:S=!0,mergeDefaults:N=!1,shallow:E,window:O=g,eventFilter:j,onError:A=e=>{},initOnMounted:I}=o,J=(E?i:u)("function"==typeof r?r():r),_=s((()=>f(e)));if(!a)try{a=function(e,t){return m[e]||t}("getDefaultStorage",(()=>{var e;return null==(e=g)?void 0:e.localStorage}))()}catch(L){A(L)}if(!a)return J;const D=f(r),M=function(e){return null==e?"any":e instanceof Set?"set":e instanceof Map?"map":e instanceof Date?"date":"boolean"==typeof e?"boolean":"string"==typeof e?"string":"object"==typeof e?"object":Number.isNaN(e)?"any":"number"}(D),V=null!=(l=o.serializer)?l:b[M],{pause:F,resume:k}=t(J,(()=>function(e){try{const t=a.getItem(_.value);if(null==e)T(t,null),a.removeItem(_.value);else{const n=V.write(e);t!==n&&(a.setItem(_.value,n),T(t,n))}}catch(L){A(L)}}(J.value)),{flush:v,deep:w,eventFilter:j});function T(e,t){if(O){const n={key:_.value,oldValue:e,newValue:t,storageArea:a};O.dispatchEvent(a instanceof Storage?new StorageEvent("storage",n):new CustomEvent(h,{detail:n}))}}function x(e){if(!e||e.storageArea===a)if(e&&null==e.key)J.value=D;else if(!e||e.key===_.value){F();try{(null==e?void 0:e.newValue)!==V.write(J.value)&&(J.value=function(e){const t=e?e.newValue:a.getItem(_.value);if(null==t)return S&&null!=D&&a.setItem(_.value,V.write(D)),D;if(!e&&N){const e=V.read(t);return"function"==typeof N?N(e,D):"object"!==M||Array.isArray(e)?e:{...D,...e}}return"string"!=typeof t?t:V.read(t)}(e))}catch(L){A(L)}finally{e?d(k):k()}}}function C(e){x(e.detail)}return c(_,(()=>x()),{flush:v}),O&&y&&n((()=>{a instanceof Storage?p(O,"storage",x,{passive:!0}):p(O,h,C),I&&x()})),I||x(),J}function E(e,t,n={}){const{window:r=g}=n;return N(e,t,null==r?void 0:r.localStorage,n)}export{E as u};
