{"version":3,"file":"cookies.mjs","sources":["../../../../packages/theme/utils/cookies.ts"],"sourcesContent":["// TODO: use /packages/utils/cookies-client-side.ts\n\nimport { ThemeName } from '../../theme/index.js'\nimport { themeCookieKey } from '../constants.js'\n\n// we're using all-same regex in element-theme-script.tsx.\n// Sadly, we cannot re-use it as this script is supposed to be inlined in document head\nconst cookieThemeMatcher = new RegExp(`(^| )${themeCookieKey}=([^;]+)`)\n\nexport const getThemeNameFromCookies = (): ThemeName | null => {\n  if (typeof window === 'undefined') {\n    return null\n  }\n\n  return (document.cookie.match(cookieThemeMatcher)?.[2] as ThemeName) ?? null\n}\n"],"names":["cookieThemeMatcher","RegExp","themeCookieKey","getThemeNameFromCookies","window","document","cookie","match"],"mappings":";;AAAA;;;AAKA;AACA;AACA,MAAMA,kBAAkB,GAAG,IAAIC,MAAM,CAAC,CAAQC,KAAAA,EAAAA,cAAc,UAAU,CAAC,CAAA;AAE1DC,MAAAA,uBAAuB,GAAGA,MAAwB;AAC7D,EAAA,IAAI,OAAOC,MAAM,KAAK,WAAW,EAAE;AACjC,IAAA,OAAO,IAAI,CAAA;AACb,GAAA;AAEA,EAAA,OAAQC,QAAQ,CAACC,MAAM,CAACC,KAAK,CAACP,kBAAkB,CAAC,GAAG,CAAC,CAAC,IAAkB,IAAI,CAAA;AAC9E;;;;"}