{"version":3,"file":"dist/js/tabler-theme.min.js.map","names":["themeDefaults","theme","layout","navbar","sidebar","params","URLSearchParams","window","location","search","prefersDark","matchMedia","key","param","get","selectedValue","localStorage","setItem","storedTheme","getItem","serverValue","document","documentElement","getAttribute","_ref","matches","setAttribute","removeAttribute","addEventListener","event","_localStorage$getItem"],"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\nfor (const key in themeDefaults) {\n  const param = params.get(key)\n  let selectedValue: string\n\n  if (!!param) {\n    localStorage.setItem('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 = localStorage.getItem('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 ((localStorage.getItem('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,gCAEtC,IAAK,MAAMC,KAAOZ,EAAe,CAC/B,MAAMa,EAAQR,EAAOS,IAAIF,GACzB,IAAIG,EAEJ,GAAMF,EACJG,aAAaC,QAAQ,UAAYL,EAAKC,GACtCE,EAAgBF,MACX,C,MAEL,MAAMK,EAAcF,aAAaG,QAAQ,UAAYP,GAC/CQ,EAAcC,SAASC,gBAAgBC,aAAa,WAAaX,GACvEG,EAA+B,QAA/BS,EAAgBN,UAAeE,SAAA,IAAAI,IAAexB,EAAcY,EAC9D,CAEY,UAARA,GAAqC,SAAlBG,IACrBA,EAAgBL,EAAYe,QAAU,OAAS,SAG7CV,IAAkBf,EAAcY,GAClCS,SAASC,gBAAgBI,aAAa,WAAad,EAAKG,GAExDM,SAASC,gBAAgBK,gBAAgB,WAAaf,EAE1D,CAEAF,EAAYkB,iBAAiB,SAAWC,I,MAEmB,UAAjB,QAAxCC,EAAKd,aAAaG,QAAQ,uBAAc,IAAAW,IAAK,UACvCD,EAAMJ,QACRJ,SAASC,gBAAgBI,aAAa,gBAAiB,QAEvDL,SAASC,gBAAgBK,gBAAgB,mB","ignoreList":[]}