var e={615:(e,t,n)=>{n.d(t,{A:()=>s});class s{constructor(e,t,n){this.el=e,this.options=t,this.events=n,this.el=e,this.options=t,this.events={}}createCollection(e,t){var n;e.push({id:(null===(n=null==t?void 0:t.el)||void 0===n?void 0:n.id)||e.length+1,element:t})}fireEvent(e,t=null){if(this.events.hasOwnProperty(e))return this.events[e](t)}on(e,t){this.events[e]=t}}}},t={};function n(s){var o=t[s];if(void 0!==o)return o.exports;var a=t[s]={exports:{}};return e[s](a,a.exports,n),a.exports}n.d=(e,t)=>{for(var s in t)n.o(t,s)&&!n.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var s={};n.d(s,{A:()=>i});var o=n(615);class a extends o.A{constructor(e,t){super(e,t);const n=e.getAttribute("data-hs-theme-switch"),s=n?JSON.parse(n):{},o=Object.assign(Object.assign({},s),t);this.theme=(null==o?void 0:o.theme)||localStorage.getItem("hs_theme")||"default",this.themeSet=["light","dark","default"],this.init()}init(){this.createCollection(window.$hsThemeSwitchCollection,this),"default"!==this.theme&&this.setAppearance()}setResetStyles(){const e=document.createElement("style");return e.innerText="*{transition: unset !important;}",e.setAttribute("data-hs-appearance-onload-styles",""),document.head.appendChild(e),e}addSystemThemeObserver(){window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",(({matches:e})=>{e?this.setAppearance("dark",!1):this.setAppearance("default",!1)}))}removeSystemThemeObserver(){window.matchMedia("(prefers-color-scheme: dark)").removeEventListener}setAppearance(e=this.theme,t=!0,n=!0){const s=document.querySelector("html"),o=this.setResetStyles();t&&localStorage.setItem("hs_theme",e),"auto"===e&&(e=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"default"),s.classList.remove("light","dark","default","auto"),s.classList.add(e),setTimeout((()=>o.remove())),n&&window.dispatchEvent(new CustomEvent("on-hs-appearance-change",{detail:e}))}static getInstance(e){const t=window.$hsThemeSwitchCollection.find((t=>t.element.el===("string"==typeof e?document.querySelector(e):e)));return t?t.element:null}static autoInit(){window.$hsThemeSwitchCollection||(window.$hsThemeSwitchCollection=[]);const e=e=>{"auto"===localStorage.getItem("hs_theme")?e.addSystemThemeObserver():e.removeSystemThemeObserver()};document.querySelectorAll("[data-hs-theme-switch]:not(.--prevent-on-load-init)").forEach((t=>{if(!window.$hsThemeSwitchCollection.find((e=>{var n;return(null===(n=null==e?void 0:e.element)||void 0===n?void 0:n.el)===t}))){const n=new a(t);n.el.checked="dark"===n.theme,e(n),n.el.addEventListener("change",(t=>{const s=t.target.checked?"dark":"default";n.setAppearance(s),e(n)}))}})),document.querySelectorAll("[data-hs-theme-click-value]:not(.--prevent-on-load-init)").forEach((t=>{const n=t.getAttribute("data-hs-theme-click-value"),s=new a(t);e(s),s.el.addEventListener("click",(()=>{s.setAppearance(n),e(s)}))}))}}window.addEventListener("load",(()=>{a.autoInit()})),window.$hsThemeSwitchCollection&&window.addEventListener("on-hs-appearance-change",(e=>{window.$hsThemeSwitchCollection.forEach((t=>{t.element.el.checked="dark"===e.detail}))})),"undefined"!=typeof window&&(window.HSThemeSwitch=a);const i=a;var r=s.A;export{r as default};