import{p as t,H as e,c as s,h as i,a}from"./index.js";import{g as c}from"./p-DKo9A5gq.js";import{p as o}from"./p-CQvUntGY.js";import{S as h}from"./p-BcQO4NH2.js";import{i as n}from"./p-DrPpH_9c.js";import{v as r}from"./p-BKP-F1qP.js";import{d as l,s as m,g as f}from"./p-BJnSrRNH.js";const d=o(h,["_XS","_S","_M","_L","_XL"]);const b={root:"gov-theme-switch",indicator:"gov-theme-switch__indicator",label:"gov-theme-switch__label",iconLight:"gov-theme-switch__icon-light",iconDark:"gov-theme-switch__icon-dark"};const p="data-theme";var g;(function(t){t["auto"]="auto";t["light"]="light";t["dark"]="dark"})(g||(g={}));const u=t(class t extends e{constructor(){super();this.__registerHost();this.govChange=s(this,"gov-change");this.size="m";this.displayLabel=false;this.ariaLabelLight="Přepnout na tmavý mód";this.ariaLabelDark="Přepnout na světlý mód";this.labelLight="Světlý mód";this.labelDark="Tmavý mód";this.theme=g.auto;this.setThemeState=t=>{this.theme=t;this.govChange.emit({component:b.root,state:this.theme,ref:this.host})};this.h=c(this.host)}validateSize(t){r(d,t,b.root)}watchTheme(t){this.htmlElement.setAttribute(p,t);this.htmlElement.classList.remove(...Object.keys(g));this.htmlElement.classList.add(t);m(p,t)}get storageValue(){return f(p)}get htmlElement(){return document.documentElement}get isSystemPrefersColorDark(){return n&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches}componentWillLoad(){this.initDefaultState();this.validateSize(this.size)}initDefaultState(){const t=Object.keys(g);let e=this.storageValue;const s=this.htmlElement.getAttribute(p);if(e&&t.includes(e)){this.theme=e}else if(s&&t.includes(s)){this.theme=s}else{this.theme=g.auto}}render(){let t=this.theme===g.dark;if(this.theme===g.auto){t=this.isSystemPrefersColorDark}return i(a,{key:"77b26165b2a824ff9649ac9c28d7b300cdb76280",class:this.h.classes(b.root),theme:t?g.dark:g.light,size:this.size},i("button",{key:"c46058c2a0e797fef9c7e1ab4975ff379bbc3fb4",onClick:()=>this.setThemeState(t?g.light:g.dark),"aria-current":this.theme,"aria-label":t?this.ariaLabelDark:this.ariaLabelLight},i("span",{key:"c1d8824467dc7bfa5d23f1f99db686e91e93087b"},i("span",{key:"62da0a9fecc5fc713b98ac9e4e728e3e19b9aa67",class:b.indicator},g.light&&i("gov-icon",{key:"7c9dd1cf819afbd7f63609916d6c845c2236fbca",name:"sun",class:b.iconLight,type:"components"}),g.dark&&i("gov-icon",{key:"3f1acf71f8afb5ca893c460b7d0b6e49fe6f5c2d",name:"moon",class:b.iconDark,type:"components"})),this.displayLabel?i("span",{class:b.label},t?this.labelDark:this.labelLight):null)))}get host(){return this}static get watchers(){return{size:["validateSize"],theme:["watchTheme"]}}},[0,"gov-theme-switch",{size:[1],displayLabel:[4,"display-label"],ariaLabelLight:[1,"aria-label-light"],ariaLabelDark:[1,"aria-label-dark"],labelLight:[1,"label-light"],labelDark:[1,"label-dark"],theme:[32]},undefined,{size:["validateSize"],theme:["watchTheme"]}]);function v(){if(typeof customElements==="undefined"){return}const t=["gov-theme-switch","gov-icon"];t.forEach((t=>{switch(t){case"gov-theme-switch":if(!customElements.get(t)){customElements.define(t,u)}break;case"gov-icon":if(!customElements.get(t)){l()}break}}))}v();const k=u;const w=v;export{k as GovThemeSwitch,w as defineCustomElement};
//# sourceMappingURL=gov-theme-switch.js.map