{"version":3,"file":"dist/js/tabler-theme.min.js.map","names":["themeDefaults","theme","layout","navbar","sidebar","params","URLSearchParams","window","location","search","prefersDark","matchMedia","VALUE_PATTERN","storage","get","key","localStorage","getItem","_unused","set","value","setItem","_unused2","param","selectedValue","test","storedTheme","serverValue","document","documentElement","getAttribute","_ref","matches","setAttribute","removeAttribute","addEventListener","event","_storage$get"],"sources":["../../js/src/theme-config.ts","../../js/tabler-theme.ts"],"sourcesContent":["/**\n * Every setting the theme switcher understands, with its default value. Each\n * key becomes a `data-bs-<key>` attribute on `<html>`, a `tabler-<key>`\n * localStorage entry and a `?<key>=` URL parameter, written only when the value\n * differs from the default. Adding a key here is all the JavaScript a new\n * setting needs; the switcher loops over this object.\n */\nexport const themeDefaults = {\n  'theme': 'auto',\n  'theme-base': 'neutral',\n  'theme-font': 'sans-serif',\n  'theme-primary': 'blue',\n  'theme-radius': '1',\n  'layout': 'default',\n  'navbar': 'default',\n  'navbar-position': 'horizontal',\n  'navbar-style': 'default',\n  'navbar-theme': 'default',\n  'offcanvas-style': 'default',\n  'sidebar': 'default',\n} as const\n\nexport type ThemeKey = keyof typeof themeDefaults\n","/**\n * demo-theme is specifically loaded right after the body and not deferred\n * to ensure we switch to the chosen dark/light theme as fast as possible.\n * This will prevent any flashes of the light theme (default) before switching.\n */\nimport { themeDefaults, type ThemeKey } from './src/theme-config'\n\nconst params = new URLSearchParams(window.location.search)\n\nconst prefersDark = window.matchMedia('(prefers-color-scheme: dark)')\n\n// A setting value is a short token: it ends up as a `data-bs-*` attribute on\n// <html> and in localStorage, so anything else from the URL is ignored.\nconst VALUE_PATTERN = /^[a-z0-9-]{1,32}$/\n\n// Accessing localStorage throws when site data is blocked (Chrome \"block all\n// cookies\", Safari with storage disabled, partitioned third-party frames), so\n// every access is guarded and the switcher falls back to the page defaults.\nconst storage = {\n  get(key: string): string | null {\n    try {\n      return localStorage.getItem(key)\n    } catch {\n      return null\n    }\n  },\n  set(key: string, value: string): void {\n    try {\n      localStorage.setItem(key, value)\n    } catch {\n      // ignore: the choice applies to this page only\n    }\n  },\n}\n\nfor (const key in themeDefaults) {\n  const param = params.get(key)\n  let selectedValue: string\n\n  if (param && VALUE_PATTERN.test(param)) {\n    storage.set('tabler-' + key, param)\n    selectedValue = param\n  } else {\n    // A stored choice wins; otherwise a server-rendered attribute is the starting value.\n    const storedTheme = storage.get('tabler-' + key)\n    const serverValue = document.documentElement.getAttribute('data-bs-' + key)\n    selectedValue = storedTheme ?? serverValue ?? themeDefaults[key as ThemeKey]\n  }\n\n  if (key === 'theme' && selectedValue === 'auto') {\n    selectedValue = prefersDark.matches ? 'dark' : 'light'\n  }\n\n  if (selectedValue !== themeDefaults[key as ThemeKey]) {\n    document.documentElement.setAttribute('data-bs-' + key, selectedValue)\n  } else {\n    document.documentElement.removeAttribute('data-bs-' + key)\n  }\n}\n\nprefersDark.addEventListener('change', (event) => {\n  // No stored choice means the default, which is auto.\n  if ((storage.get('tabler-theme') ?? 'auto') === 'auto') {\n    if (event.matches) {\n      document.documentElement.setAttribute('data-bs-theme', 'dark')\n    } else {\n      document.documentElement.removeAttribute('data-bs-theme')\n    }\n  }\n})\n"],"mappings":";;;;;;gFAOA,IAAaA,EAAgB,CAC3BC,MAAS,OACT,aAAc,UACd,aAAc,aACd,gBAAiB,OACjB,eAAgB,IAChBC,OAAU,UACVC,OAAU,UACV,kBAAmB,aACnB,eAAgB,UAChB,eAAgB,UAChB,kBAAmB,UACnBC,QAAW,WCZPC,EAAS,IAAIC,gBAAgBC,OAAOC,SAASC,QAE7CC,EAAcH,OAAOI,WAAW,gCAIhCC,EAAgB,oBAKhBC,EAAU,CACd,GAAAC,CAAIC,GACF,IACE,OAAOC,aAAaC,QAAQF,EAC9B,OAAAG,GACE,OAAO,IACT,CACF,EACA,GAAAC,CAAIJ,EAAaK,GACf,IACEJ,aAAaK,QAAQN,EAAKK,EAC5B,OAAAE,GAEA,CACF,GAGF,IAAK,MAAMP,KAAOf,EAAe,CAC/B,MAAMuB,EAAQlB,EAAOS,IAAIC,GACzB,IAAIS,EAEJ,GAAID,GAASX,EAAca,KAAKF,GAC9BV,EAAQM,IAAI,UAAYJ,EAAKQ,GAC7BC,EAAgBD,MACX,C,MAEL,MAAMG,EAAcb,EAAQC,IAAI,UAAYC,GACtCY,EAAcC,SAASC,gBAAgBC,aAAa,WAAaf,GACvES,EAA+B,QAA/BO,EAAgBL,UAAeC,SAAA,IAAAI,IAAe/B,EAAce,EAC9D,CAEY,UAARA,GAAqC,SAAlBS,IACrBA,EAAgBd,EAAYsB,QAAU,OAAS,SAG7CR,IAAkBxB,EAAce,GAClCa,SAASC,gBAAgBI,aAAa,WAAalB,EAAKS,GAExDI,SAASC,gBAAgBK,gBAAgB,WAAanB,EAE1D,CAEAL,EAAYyB,iBAAiB,SAAWC,I,MAEU,UAAjB,QAA/BC,EAAKxB,EAAQC,IAAI,uBAAc,IAAAuB,IAAK,UAC9BD,EAAMJ,QACRJ,SAASC,gBAAgBI,aAAa,gBAAiB,QAEvDL,SAASC,gBAAgBK,gBAAgB,mB","ignoreList":[]}