{"version":3,"file":"state.d26qcWB5.js","sources":["../../../../node_modules/nuxt/dist/app/composables/state.js"],"sourcesContent":["import { isRef, toRef } from \"vue\";\nimport { useNuxtApp } from \"../nuxt.js\";\nimport { toArray } from \"../utils.js\";\nconst useStateKeyPrefix = \"$s\";\nexport function useState(...args) {\n const autoKey = typeof args[args.length - 1] === \"string\" ? args.pop() : void 0;\n if (typeof args[0] !== \"string\") {\n args.unshift(autoKey);\n }\n const [_key, init] = args;\n if (!_key || typeof _key !== \"string\") {\n throw new TypeError(\"[nuxt] [useState] key must be a string: \" + _key);\n }\n if (init !== void 0 && typeof init !== \"function\") {\n throw new Error(\"[nuxt] [useState] init must be a function: \" + init);\n }\n const key = useStateKeyPrefix + _key;\n const nuxtApp = useNuxtApp();\n const state = toRef(nuxtApp.payload.state, key);\n if (state.value === void 0 && init) {\n const initialValue = init();\n if (isRef(initialValue)) {\n nuxtApp.payload.state[key] = initialValue;\n return initialValue;\n }\n state.value = initialValue;\n }\n return state;\n}\nexport function clearNuxtState(keys) {\n const nuxtApp = useNuxtApp();\n const _allKeys = Object.keys(nuxtApp.payload.state).map((key) => key.substring(useStateKeyPrefix.length));\n const _keys = !keys ? _allKeys : typeof keys === \"function\" ? _allKeys.filter(keys) : toArray(keys);\n for (const _key of _keys) {\n const key = useStateKeyPrefix + _key;\n if (key in nuxtApp.payload.state) {\n nuxtApp.payload.state[key] = void 0;\n }\n }\n}\n"],"names":["useStateKeyPrefix","useState","args","autoKey","_key","init","key","nuxtApp","useNuxtApp","state","toRef","initialValue","isRef"],"mappings":"+WAGA,MAAMA,EAAoB,KACnB,SAASC,KAAYC,EAAM,CAChC,MAAMC,EAAU,OAAOD,EAAKA,EAAK,OAAS,CAAC,GAAM,SAAWA,EAAK,IAAK,EAAG,OACrE,OAAOA,EAAK,CAAC,GAAM,UACrBA,EAAK,QAAQC,CAAO,EAEtB,KAAM,CAACC,EAAMC,CAAI,EAAIH,EACrB,GAAI,CAACE,GAAQ,OAAOA,GAAS,SAC3B,MAAM,IAAI,UAAU,2CAA6CA,CAAI,EAEvE,GAAIC,IAAS,QAAU,OAAOA,GAAS,WACrC,MAAM,IAAI,MAAM,8CAAgDA,CAAI,EAEtE,MAAMC,EAAMN,EAAoBI,EAC1BG,EAAUC,IACVC,EAAQC,EAAMH,EAAQ,QAAQ,MAAOD,CAAG,EAC9C,GAAIG,EAAM,QAAU,QAAUJ,EAAM,CAClC,MAAMM,EAAeN,IACrB,GAAIO,EAAMD,CAAY,EACpB,OAAAJ,EAAQ,QAAQ,MAAMD,CAAG,EAAIK,EACtBA,EAETF,EAAM,MAAQE,CACf,CACD,OAAOF,CACT","x_google_ignoreList":[0]}