text: var e={version:"Version"},t={docs:"Docs",forums:"Forums"},o={add_exception:"Add Exception",automatic:"automatic",buttons:"Buttons",cancel:"Cancel",chevrons_tip:"Disable scrolling arrows for tabs.",chevrons_title:"Display Tab Chevrons",compact_mode_tip:"Make header compact.",compact_mode_title:"Compact Mode",conditions:"Conditions",config:"Config",current_user_agent:"Current User Agent",current_user:"Current User",default_tab:"Default tab",disable_sidebar_tip:"Disable sidebar and menu button.",disable_sidebar_title:"Disable Sidebar",disabled_mode_tip:"Completely disable Custom-Header.",disabled_mode_title:"Disabled Mode",restrict_users_title:"Restrict Users",restrict_users_tip:"Prevents non-admin users from disabling CH or using it's settings.",disabled_template:"Disabled: The current value is a template.",editor_warnings_second_title:"Display Editor Warnings & Info",editor_warnings_tip:"Toggle editor warnings.",editor_warnings_title:"Display this info and warnings section.",exceptions:"Exceptions",footer_mode_tip:"Turn the header into a footer or reverse split mode.",footer_mode_title:"Footer Mode",header_text:"Header text.",hidden_tab_redirect_tip:"Redirect from hidden tab.",hidden_tab_redirect_title:"Hidden Tab Redirect",hide_configure_ui_tip:"Hide item in options menu.",hide_configure_ui_title:"Hide 'Configure UI'",hide_ch_settings:"Hide 'CH Settings'",hide_header_tip:"Hide header, but allow swipe out of sidebar.",hide_header_title:"Disable Header",hide_help_tip:"Hide item in options menu.",hide_help_title:"Hide 'Help'",hide_raw_editor_tip:"Hide item in options menu.",hide_raw_editor_title:"Hide 'Raw Config Editor'",hide_tab_list:"Comma-separated list of tab numbers to hide",hide_unused_tip:"Hide item in options menu.",hide_unused_title:"Hide 'Unused Entities'",kiosk_mode_tip:"Hide and disable the header and sidebar",kiosk_mode_title:"Kiosk Mode",locale_desc:"Locale for default template variables (date/time).",media_query:"Media Query",menu_dropdown_tip:"Put menu button in options menu.",menu_dropdown_title:"Menu in Dropdown Menu",menu_hide_tip:"Hide the menu button.",menu_hide_title:"Hide Menu Button",menu_items:"Menu Items",options_hide_tip:"Hide the options button.",options_hide_title:"Hide Options Button",query_string:"Query String",removes_edit_ui:"Removes ability to edit UI.",reverse_button_tip:"Reverses all buttons orientation.",reverse_button_title:"Reverse Buttons Orientation",reverse_tab_tip:"Places tabs on right side in reverse order.",reverse_tab_title:"Reverse Tab Direction",save_and_reload:"Save and reload",save_failed:"Save failed",shadow_tip:"Hide header shadows",shadow_title:"Shadows",show_tab_list:"Comma-separated list of tab numbers to show",split_mode_tip:"Split header into one header one footer",split_mode_title:"Split Mode",tabs_hide:"Hide Tabs",tabs_show:"Show Tabs",tabs:"Tabs",tab_icons_and_text_title:"Show Icons with Text",tab_icons_and_text_tip:"Display both icons and text on tabs.",tab_text_only_title:"Show Text Only.",tab_text_only_tip:"Display only text on tabs.",template:"Template",user_agent:"User Agent",user_list:"User (Seperate multiple users with a comma.)",voice_dropdown_tip:"Put voice button in options menu.",voice_dropdown_title:"Voice in Dropdown Menu",voice_hide_tip:"Hide the voice button.",voice_hide_title:"Hide Voice Button",warning_already_a_template:"Designates items that are already a template and won't be modified by the editor.",warning_disable_ch:"You can temporaily disable Custom-Header by adding '?disable_ch' to the end of your URL.",warning_edit_ui:"Marks items that remove your ability to edit the UI.",warning_jinja_info:"Hover over any item for more info. All text options accept Jinja."},n={common:e,links:t,editor:o},i={version:"Versjon"},r={docs:"Documentasjon",forums:"Forum"},a={add_exception:"Legg til unntak",automatic:"automatisk",buttons:"Brytere",cancel:"Avbryt",chevrons_tip:"Deaktiver pilene på tab båndet.",chevrons_title:"Vis tab piler",compact_mode_tip:"Gjør headeren compact.",compact_mode_title:"Kompakt modus",conditions:"Betingelser",config:"Konfigurasjon",current_user_agent:"Nåværende User Agent",current_user:"Pålogget bruker",default_tab:"Standard tab",disable_sidebar_tip:"Deaktiver side panelet og meny knappen.",disable_sidebar_title:"Deaktiver side panelet",disabled_mode_tip:"Deaktiver Custom-Header.",disabled_mode_title:"Deaktivert modus",restrict_users_title:"Begrens til brukere",restrict_users_tip:"Tar vekk muligheten for brukere som ikke er administratorer til å deaktivere CH.",disabled_template:"Deaktivert: Nåværende verdi er en mal.",editor_warnings_second_title:"Vis editor advarser of informasjon",editor_warnings_tip:"Veksle editor advarsler.",editor_warnings_title:"Vis denne informasjonen og advarsel seksjoner.",exceptions:"Unntak",footer_mode_tip:"Gjør header til footer eller reversert split modus.",footer_mode_title:"Footer modus",header_text:"Header tekst.",hidden_tab_redirect_tip:"Omadresser fra gjemt tab.",hidden_tab_redirect_title:"Gjemt tab omadresser",hide_configure_ui_tip:"Gjem 'Konfigurer brukergrensesnitt' in nedtrekksmenyen.",hide_configure_ui_title:"Gjem 'Konfigurer brukergrensesnitt'",hide_ch_settings:"Skjul 'CH instillinger'",hide_header_tip:"Gjem headderen, men tillat å dra inn fra siden for å åpne side panelet",hide_help_tip:"Deaktiver header",hide_help_title:"Gjem 'Hjelp'",hide_raw_editor_tip:"Gjem 'Tekstbasert konfigurasjonsredigering' in nedtrekksmenyen.",hide_raw_editor_title:"Gjem 'Tekstbasert konfigurasjonsredigering'",hide_tab_list:"Komma separert liste over tabber som skal gjemmes",hide_unused_tip:"Gjem 'Unused Entities' in nedtrekksmenyen.",hide_unused_title:"Gjem 'Unused Entities'",kiosk_mode_tip:"Gjem og deaktiver headeren og side panelet.",kiosk_mode_title:"Kiosk modus",locale_desc:"Locale for standard mal variabler (dato/tip).",menu_dropdown_tip:"Plasser meny i nedtrekksmenyen.",menu_dropdown_title:"Meny i nedtrekksmenyen",menu_hide_tip:"Gjem meny knappen.",menu_hide_title:"Gjem meny knappen",menu_items:"Meny elementer",options_hide_tip:"Gjem alternativer knappen.",options_hide_title:"Gjem alternativer knappen",removes_edit_ui:"Fjerner muligheten til å redigere brukergrensesnittet.",reverse_button_tip:"Reverser alle bryter orienteringer.",reverse_button_title:"Reverser bryter orientering",reverse_tab_tip:"Plasser tabber på høyre side i reversert rekkefølge.",reverse_tab_title:"Reverser tab rettning",save_and_reload:"Lagre og last inn på nytt",save_failed:"Lagring feilet",shadow_tip:"Gjemheader skygger",shadow_title:"Skygger",show_tab_list:"Komma separert liste over tabber som skal vises",split_mode_tip:"Split modus, både header og footer",split_mode_title:"Split modus",tabs_hide:"Gjem Tabber",tabs_show:"Vis Tabber",tabs:"Tabber",tab_icons_and_text_title:"Vis ikoner med text.",tab_icons_and_text_tip:"Vis både ikon og text på faner.",tab_text_only_title:"Vis kun tekst.",tab_text_only_tip:"Vis kun tekst på faner.",template:"mal",user_list:"Bruker (Skill flere brukere med komma.)",voice_dropdown_tip:"Plasser stemme i nedtrekksmenyen.",voice_dropdown_title:"Stemme i nedtrekksmenyen",voice_hide_tip:"Gjem stemme knappen.",voice_hide_title:"Gjem stemme knappen",warning_already_a_template:"Etter å ha brukt 'Tekstbasert konfigurasjonsredigering', må du laste inn siden på nytt for å gjenopprette Custom Header.",warning_disable_ch:"Du kan deaktivere Custom-Header midlertidig ved å legge til '?disable_ch' på slutten av nettadressen.",warning_edit_ui:"Markerer elementer som fjerner muligheten til å redigere brukergrensesnittet.",warning_jinja_info:"Alle tekstalternativer godtar Jinja. Hold musepekeren over et hvilket som helst element for mer informasjon."},s={common:i,links:r,editor:a};const c={en:Object.freeze({__proto__:null,common:e,links:t,editor:o,default:n}),nb:Object.freeze({__proto__:null,common:i,links:r,editor:a,default:s})};function localize(e){let t,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;const i=e.split("."),r=(localStorage.getItem("selectedLanguage")||"en").replace(/['"]+/g,"").replace("-","_");try{t=c[r],i.forEach(e=>{t=t[e]})}catch(e){t=c.en,i.forEach(e=>{t=t[e]})}return void 0===t&&(t=c.en,i.forEach(e=>{t=t[e]})),void 0!==o&&void 0!==n&&(t=t.replace(o,n)),t}var l=/d{1,4}|M{1,4}|YY(?:YY)?|S{1,3}|Do|ZZ|Z|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g,d="[^\\s]+",h=/\[([^]*?)\]/gm;function shorten(e,t){for(var o=[],n=0,i=e.length;n<i;n++)o.push(e[n].substr(0,t));return o}var monthUpdate=function(e){return function(t,o){var n=o[e].map((function(e){return e.toLowerCase()})).indexOf(t.toLowerCase());return n>-1?n:null}};function assign(e){for(var t=[],o=1;o<arguments.length;o++)t[o-1]=arguments[o];for(var n=0,i=t;n<i.length;n++){var r=i[n];for(var a in r)e[a]=r[a]}return e}var u=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],p=["January","February","March","April","May","June","July","August","September","October","November","December"],m=shorten(p,3),_={dayNamesShort:shorten(u,3),dayNames:u,monthNamesShort:m,monthNames:p,amPm:["am","pm"],DoFn:function(e){return e+["th","st","nd","rd"][e%10>3?0:(e-e%10!=10?1:0)*e%10]}},b=assign({},_),pad=function(e,t){for(void 0===t&&(t=2),e=String(e);e.length<t;)e="0"+e;return e},g={D:function(e){return String(e.getDate())},DD:function(e){return pad(e.getDate())},Do:function(e,t){return t.DoFn(e.getDate())},d:function(e){return String(e.getDay())},dd:function(e){return pad(e.getDay())},ddd:function(e,t){return t.dayNamesShort[e.getDay()]},dddd:function(e,t){return t.dayNames[e.getDay()]},M:function(e){return String(e.getMonth()+1)},MM:function(e){return pad(e.getMonth()+1)},MMM:function(e,t){return t.monthNamesShort[e.getMonth()]},MMMM:function(e,t){return t.monthNames[e.getMonth()]},YY:function(e){return pad(String(e.getFullYear()),4).substr(2)},YYYY:function(e){return pad(e.getFullYear(),4)},h:function(e){return String(e.getHours()%12||12)},hh:function(e){return pad(e.getHours()%12||12)},H:function(e){return String(e.getHours())},HH:function(e){return pad(e.getHours())},m:function(e){return String(e.getMinutes())},mm:function(e){return pad(e.getMinutes())},s:function(e){return String(e.getSeconds())},ss:function(e){return pad(e.getSeconds())},S:function(e){return String(Math.round(e.getMilliseconds()/100))},SS:function(e){return pad(Math.round(e.getMilliseconds()/10),2)},SSS:function(e){return pad(e.getMilliseconds(),3)},a:function(e,t){return e.getHours()<12?t.amPm[0]:t.amPm[1]},A:function(e,t){return e.getHours()<12?t.amPm[0].toUpperCase():t.amPm[1].toUpperCase()},ZZ:function(e){var t=e.getTimezoneOffset();return(t>0?"-":"+")+pad(100*Math.floor(Math.abs(t)/60)+Math.abs(t)%60,4)},Z:function(e){var t=e.getTimezoneOffset();return(t>0?"-":"+")+pad(Math.floor(Math.abs(t)/60),2)+":"+pad(Math.abs(t)%60,2)}},monthParse=function(e){return+e-1},f=[null,"[1-9]\\d?"],y=[null,d],w=["isPm",d,function(e,t){var o=e.toLowerCase();return o===t.amPm[0]?0:o===t.amPm[1]?1:null}],v=["timezoneOffset","[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z?",function(e){var t=(e+"").match(/([+-]|\d\d)/gi);if(t){var o=60*+t[1]+parseInt(t[2],10);return"+"===t[0]?o:-o}return 0}],S=(monthUpdate("monthNamesShort"),monthUpdate("monthNames"),{default:"ddd MMM DD YYYY HH:mm:ss",shortDate:"M/D/YY",mediumDate:"MMM D, YYYY",longDate:"MMMM D, YYYY",fullDate:"dddd, MMMM D, YYYY",isoDate:"YYYY-MM-DD",isoDateTime:"YYYY-MM-DDTHH:mm:ssZ",shortTime:"HH:mm",mediumTime:"HH:mm:ss",longTime:"HH:mm:ss.SSS"});var fecha_format=function(e,t,o){if(void 0===t&&(t=S.default),void 0===o&&(o={}),"number"==typeof e&&(e=new Date(e)),"[object Date]"!==Object.prototype.toString.call(e)||isNaN(e.getTime()))throw new Error("Invalid Date pass to format");var n=[];t=(t=S[t]||t).replace(h,(function(e,t){return n.push(t),"@@@"}));var i=assign(assign({},b),o);return(t=t.replace(l,(function(t){return g[t](e,i)}))).replace(/@@@/g,(function(){return n.shift()}))},x=(function(){try{(new Date).toLocaleDateString("i")}catch(e){return"RangeError"===e.name}}(),function(){try{(new Date).toLocaleString("i")}catch(e){return"RangeError"===e.name}}(),function(){try{(new Date).toLocaleTimeString("i")}catch(e){return"RangeError"===e.name}}(),function(e,t,o,n){n=n||{},o=null==o?{}:o;var i=new Event(t,{bubbles:void 0===n.bubbles||n.bubbles,cancelable:Boolean(n.cancelable),composed:void 0===n.composed||n.composed});return i.detail=o,e.dispatchEvent(i),i}),J=function(){var e=document.querySelector("home-assistant");if(e=(e=(e=(e=(e=(e=(e=(e=e&&e.shadowRoot)&&e.querySelector("home-assistant-main"))&&e.shadowRoot)&&e.querySelector("app-drawer-layout partial-panel-resolver"))&&e.shadowRoot||e)&&e.querySelector("ha-panel-lovelace"))&&e.shadowRoot)&&e.querySelector("hui-root")){var t=e.lovelace;return t.current_view=e.___curView,t}return null};const getHass=()=>{if(document.querySelector("home-assistant").shadowRoot.querySelector("home-assistant-main").hass)return document.querySelector("home-assistant").shadowRoot.querySelector("home-assistant-main").hass;setTimeout(getHass,300)},C=getHass(),ha_elements=()=>{const e={};if(e.lovelace=J(),e.homeAssistant=document.querySelector("home-assistant"),e.main=e.homeAssistant.shadowRoot.querySelector("home-assistant-main").shadowRoot,e.hass=e.homeAssistant.hass,e.partialPanel=e.main.querySelector("partial-panel-resolver"),e.panel=e.main.querySelector("ha-panel-lovelace"),e.panel&&(e.root=e.panel.shadowRoot.querySelector("hui-root"),e.root))return e.root=e.root.shadowRoot,e.tabs=Array.from((e.root.querySelector("paper-tabs")||e.root).querySelectorAll("paper-tab")),e.tabContainer=e.root.querySelector("paper-tabs"),e.menu=e.root.querySelector("ha-menu-button"),e.options=e.root.querySelector("ha-button-menu, paper-menu-button"),e.voice=e.root.querySelector("app-toolbar").querySelector("mwc-icon-button")||e.root.querySelector("ha-start-voice-button")||e.root.querySelector('paper-icon-button[icon="hass:microphone"]')||e.root.querySelector('ha-icon-button[icon="hass:microphone"]'),e.drawer=e.main.querySelector("#drawer"),e.sidebar={},e.sidebar.main=e.main.querySelector("ha-sidebar").shadowRoot,e.sidebar.menu=e.sidebar.main.querySelector(".menu"),e.sidebar.listbox=e.sidebar.main.querySelector("paper-listbox"),e.sidebar.divider=e.sidebar.main.querySelector("div.divider"),e.appHeader=e.root.querySelector("app-header"),e.appLayout=e.root.querySelector("ha-app-layout"),e};let q=(()=>{if(window.fully&&"function"==typeof fully.getDeviceId)return fully.getDeviceId();if(!localStorage["lovelace-player-device-id"]){const s4=()=>Math.floor(1e5*(1+Math.random())).toString(16).substring(1);localStorage["lovelace-player-device-id"]="".concat(s4()).concat(s4(),"-").concat(s4()).concat(s4())}return localStorage["lovelace-player-device-id"]})();class CustomHeader{constructor(e){if(!e)return;this.ha_elem=e;const t=this.ha_elem.appLayout.querySelector("ch-header"),o=this.ha_elem.appLayout.querySelector("ch-footer");t&&(t.parentNode.removeChild(t),o.parentNode.removeChild(o)),this.header=this.buildHeader(),this.footer=this.buildFooter()}get header(){return this._header}set header(e){this._header=e}get footer(){return this._footer}set footer(e){this._footer=e}buildHeader(){const e={};e.tabContainer=document.createElement("paper-tabs"),e.tabContainer.setAttribute("dir","ltr"),e.tabContainer.setAttribute("scrollable",""),e.tabContainer.style.width="100%",e.tabContainer.style.marginLeft="0",this.ha_elem.tabs.forEach(t=>{const o=this.ha_elem.tabs.indexOf(t),n=t.cloneNode(!0),i=n.querySelector("ha-icon");this.tapOrClick(n,this.ha_elem.tabs[o]),i&&i.setAttribute("icon",this.ha_elem.lovelace.config.views[o].icon),e.tabContainer.appendChild(n)}),e.tabs=e.tabContainer.querySelectorAll("paper-tab"),e.tabs.forEach(t=>{const o=Array.from(e.tabs).indexOf(t),n=document.createElement("p"),i=t.innerText.replace(/\s/g,"");i&&(t.innerText=""),n.innerHTML=i?this.ha_elem.lovelace.config.views[o].title:"",t.appendChild(n)});const t=document.createElement("ch-stack"),o=document.createElement("div");return o.setAttribute("id","ch-content-container"),e.container=document.createElement("ch-header"),this.cloneButton("menu","mdi:menu",e),this.cloneButton("voice","mdi:microphone",e),this.cloneButton("options","mdi:dots-vertical",e),e.container.appendChild(e.menu),e.container.appendChild(t),e.stack=e.container.querySelector("ch-stack"),e.stack.appendChild(o),e.stack.appendChild(e.tabContainer),e.container.appendChild(e.options),e.voice&&"hidden"!=e.voice.style.visibility&&e.container.appendChild(e.voice),e.container.style.visibility="hidden",this.ha_elem.appLayout.appendChild(e.container),e}buildFooter(){const e={};return e.tabContainer=document.createElement("paper-tabs"),e.tabContainer.setAttribute("dir","ltr"),e.tabContainer.setAttribute("scrollable",""),e.tabContainer.style.width="100%",e.tabContainer.style.marginLeft="0",this.ha_elem.tabs.forEach(t=>{const o=this.ha_elem.tabs.indexOf(t),n=t.cloneNode(!0),i=n.querySelector("ha-icon");this.tapOrClick(n,this.ha_elem.tabs[o]),i&&i.setAttribute("icon",this.ha_elem.lovelace.config.views[o].icon),e.tabContainer.appendChild(n)}),e.tabs=e.tabContainer.querySelectorAll("paper-tab"),e.tabs.forEach(t=>{const o=Array.from(e.tabs).indexOf(t),n=document.createElement("p"),i=t.innerText.replace(/\s/g,"");i&&(t.innerText=""),n.innerHTML=i?this.ha_elem.lovelace.config.views[o].title:"",t.appendChild(n)}),e.container=document.createElement("ch-footer"),e.container.appendChild(e.tabContainer),e.container.style.visibility="hidden",this.ha_elem.appLayout.appendChild(e.container),e}cloneButton(e,t,o){if("options"===e){if(o[e]=this.ha_elem[e].cloneNode(!0),o[e].removeAttribute("horizontal-offset"),o[e].querySelector("mwc-icon-button")){const t=document.createElement("ha-icon-button");t.setAttribute("icon","hass:dots-vertical"),t.setAttribute("slot","trigger"),t.setAttribute("title",o[e].querySelector("mwc-icon-button").getAttribute("title")),o[e].appendChild(t),o[e].querySelector("mwc-icon-button").style.display="none"}o[e].querySelector("ha-icon, ha-icon-button, paper-icon-button").style.height="48px";const t=Array.from(o[e].querySelectorAll("mwc-list-item, paper-item"));t.forEach(o=>{const n=t.indexOf(o);this.tapOrClick(o,this.ha_elem[e].querySelectorAll("mwc-list-item, paper-item")[n])})}else{if(!this.ha_elem[e])return;this.ha_elem.menu.shadowRoot.querySelector("paper-icon-button")?o[e]=document.createElement("paper-icon-button"):o[e]=document.createElement("ha-icon-button"),this.tapOrClick(o[e],"voice"==e?this.ha_elem[e]:this.ha_elem[e].shadowRoot.querySelector("mwc-icon-button, paper-icon-button")||this.ha_elem[e])}"options"==e&&o[e].querySelector("mwc-icon-button")?o[e].querySelector("ha-icon-button").setAttribute("buttonElem",e):o[e].setAttribute("buttonElem",e),o[e].style.flexShrink="0",o[e].style.height="48px","options"==e&&o[e].querySelector("mwc-icon-button")?o[e].icon=o[e].querySelector("ha-icon-button"):(o[e].icon=o[e],o[e].setAttribute("icon",t))}tapOrClick(e,t){e.setAttribute("onClick"," "),"MWC-LIST-ITEM"===t.nodeName&&e.addEventListener("tap",()=>{t.dispatchEvent(new MouseEvent("click",{bubbles:!1,cancelable:!1}))}),e.addEventListener("click",()=>{"MWC-LIST-ITEM"===t.nodeName?t.click():t.dispatchEvent(new MouseEvent("click",{bubbles:!1,cancelable:!1}))})}}function asyncGeneratorStep(e,t,o,n,i,r,a){try{var s=e[r](a),c=s.value}catch(e){return void o(e)}s.done?t(c):Promise.resolve(c).then(n,i)}function _defineProperty(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}function ownKeys(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),o.push.apply(o,n)}return o}function _objectSpread2(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(o),!0).forEach((function(t){_defineProperty(e,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):ownKeys(Object(o)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))}))}return e}function _taggedTemplateLiteral(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}Object.defineProperty(Array.prototype,"flat",{value:function value(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return this.reduce((function(t,o){return t.concat(Array.isArray(o)&&e-1?o.flat(e-1):o)}),[])}});const selectTab=(e,t)=>{const o=e.compact_mode||e.button_scroll?t.header:t.footer,n=J();n&&o.tabs[n.current_view]&&o.tabContainer.selected!=n.current_view&&o.tabContainer.selectIndex(n.current_view)},tabIndexByName=e=>{const t=J();if(!t)return;let o;const{views:n}=t.config;return isNaN(e)?n.forEach(t=>{t.title!==e&&t.path!==e||(o=n.indexOf(t))}):o=parseInt(e,10),o},subscribeRenderTemplate=(e,t,o)=>{const n=(e=>{const t=new Date;let o={deviceID:q,userAgent:navigator.userAgent,url:window.location.href,time:t.toLocaleTimeString(e,{hour:"2-digit",minute:"2-digit"}),date:t.toLocaleDateString(e,{}),monthNum:t.getMonth()+1,monthNumLZ:String(t.getMonth()+1).padStart(2,0),monthNameShort:t.toLocaleDateString(e,{month:"short"}),monthNameLong:t.toLocaleDateString(e,{month:"long"}),dayNum:t.getDate(),dayNumLZ:String(t.getDate()).padStart(2,0),dayNameShort:t.toLocaleDateString(e,{weekday:"short"}),dayNameLong:t.toLocaleDateString(e,{weekday:"long"}),hours12:String((t.getHours()+24)%12||12),hours12LZ:String((t.getHours()+24)%12||12).padStart(2,0),hours24:t.getHours(),hours24LZ:String(t.getHours()).padStart(2,0),minutes:t.getMinutes(),minutesLZ:String(t.getMinutes()).padStart(2,0),year2d:String(t.getFullYear()).substr(-2),year4d:t.getFullYear(),AMPM:t.getHours()>=12?"PM":"AM",ampm:t.getHours()>=12?"pm":"am"};const n=ha_elements().hass;o.hassVersion=n?n.config.version:"",o.isAdmin=n?n.user.is_admin:"",o.isOwner=n?n.user.is_owner:"",o.user=n?n.user.name:"",o.userID=n?n.user.id:"";const i=J(),r=i&&null!=i.config.views[i.current_view];return o.viewIndex=i?i.current_view:"",o.viewTitle=r&&i.config.views[i.current_view].title||"",o.viewPath=r&&i.config.views[i.current_view].path||"",o})(o);n||window.setTimeout(()=>{subscribeRenderTemplate(e,t,o)},500);const i=ha_elements().hass,r=i.connection,a=_objectSpread2(_objectSpread2({user:i.user.name,browser:navigator.userAgent},t.variables),n),s=t.template,c=t.entity_ids;return r.subscribeMessage(t=>e(t.result),{type:"render_template",template:s,variables:a,entity_ids:c})},buildRange=e=>{const t=[],range=(e,t)=>new Array(t-e+1).fill(void 0).map((t,o)=>o+e);if(e.includes("to")){const o=e.split("to");parseInt(o[1])>parseInt(o[0])?t.push(range(parseInt(o[0]),parseInt(o[1]))):t.push(range(parseInt(o[1]),parseInt(o[0])))}return t.flat()},processTabArray=e=>{let t=[];e="string"==typeof e?e.replace(/\s+/g,"").split(","):e;for(const o in e)if("string"==typeof e[o]&&e[o].includes("to")){const n=e[o].replace(/ /g,"").split("to");n[0].match(/[a-z]/g)||n[1].match(/[a-z]/g)?t.push(e[o]):t.push(buildRange(e[o]))}else t.push(e[o]);t=t.flat();for(const e in t)isNaN(t[e])?t[e]=tabIndexByName(t[e]):t[e]=parseInt(t[e]);return t.sort((e,t)=>e-t)},T="undefined"!=typeof window&&null!=window.customElements&&void 0!==window.customElements.polyfillWrapFlushCallback,removeNodes=(e,t,o=null)=>{for(;t!==o;){const o=t.nextSibling;e.removeChild(t),t=o}},k=`{{lit-${String(Math.random()).slice(2)}}}`,O=`\x3c!--${k}--\x3e`,E=new RegExp(`${k}|${O}`);class Template{constructor(e,t){this.parts=[],this.element=t;const o=[],n=[],i=document.createTreeWalker(t.content,133,null,!1);let r=0,a=-1,s=0;const{strings:c,values:{length:l}}=e;for(;s<l;){const e=i.nextNode();if(null!==e){if(a++,1===e.nodeType){if(e.hasAttributes()){const t=e.attributes,{length:o}=t;let n=0;for(let e=0;e<o;e++)endsWith(t[e].name,"$lit$")&&n++;for(;n-- >0;){const t=c[s],o=j.exec(t)[2],n=o.toLowerCase()+"$lit$",i=e.getAttribute(n);e.removeAttribute(n);const r=i.split(E);this.parts.push({type:"attribute",index:a,name:o,strings:r}),s+=r.length-1}}"TEMPLATE"===e.tagName&&(n.push(e),i.currentNode=e.content)}else if(3===e.nodeType){const t=e.data;if(t.indexOf(k)>=0){const n=e.parentNode,i=t.split(E),r=i.length-1;for(let t=0;t<r;t++){let o,r=i[t];if(""===r)o=createMarker();else{const e=j.exec(r);null!==e&&endsWith(e[2],"$lit$")&&(r=r.slice(0,e.index)+e[1]+e[2].slice(0,-"$lit$".length)+e[3]),o=document.createTextNode(r)}n.insertBefore(o,e),this.parts.push({type:"node",index:++a})}""===i[r]?(n.insertBefore(createMarker(),e),o.push(e)):e.data=i[r],s+=r}}else if(8===e.nodeType)if(e.data===k){const t=e.parentNode;null!==e.previousSibling&&a!==r||(a++,t.insertBefore(createMarker(),e)),r=a,this.parts.push({type:"node",index:a}),null===e.nextSibling?e.data="":(o.push(e),a--),s++}else{let t=-1;for(;-1!==(t=e.data.indexOf(k,t+1));)this.parts.push({type:"node",index:-1}),s++}}else i.currentNode=n.pop()}for(const e of o)e.parentNode.removeChild(e)}}const endsWith=(e,t)=>{const o=e.length-t.length;return o>=0&&e.slice(o)===t},isTemplatePartActive=e=>-1!==e.index,createMarker=()=>document.createComment(""),j=/([ \x09\x0a\x0c\x0d])([^\0-\x1F\x7F-\x9F "'>=/]+)([ \x09\x0a\x0c\x0d]*=[ \x09\x0a\x0c\x0d]*(?:[^ \x09\x0a\x0c\x0d"'`<>=]*|"[^"]*|'[^']*))$/;function removeNodesFromTemplate(e,t){const{element:{content:o},parts:n}=e,i=document.createTreeWalker(o,133,null,!1);let r=nextActiveIndexInTemplateParts(n),a=n[r],s=-1,c=0;const l=[];let d=null;for(;i.nextNode();){s++;const e=i.currentNode;for(e.previousSibling===d&&(d=null),t.has(e)&&(l.push(e),null===d&&(d=e)),null!==d&&c++;void 0!==a&&a.index===s;)a.index=null!==d?-1:a.index-c,r=nextActiveIndexInTemplateParts(n,r),a=n[r]}l.forEach(e=>e.parentNode.removeChild(e))}const countNodes=e=>{let t=11===e.nodeType?0:1;const o=document.createTreeWalker(e,133,null,!1);for(;o.nextNode();)t++;return t},nextActiveIndexInTemplateParts=(e,t=-1)=>{for(let o=t+1;o<e.length;o++){const t=e[o];if(isTemplatePartActive(t))return o}return-1};
  /**
   * @license
   * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
   * This code may only be used under the BSD style license found at
   * http://polymer.github.io/LICENSE.txt
   * The complete set of authors may be found at
   * http://polymer.github.io/AUTHORS.txt
   * The complete set of contributors may be found at
   * http://polymer.github.io/CONTRIBUTORS.txt
   * Code distributed by Google as part of the polymer project is also
   * subject to an additional IP rights grant found at
   * http://polymer.github.io/PATENTS.txt
   */
  const H=new WeakMap,isDirective=e=>"function"==typeof e&&H.has(e),A={},M={};
  /**
   * @license
   * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
   * This code may only be used under the BSD style license found at
   * http://polymer.github.io/LICENSE.txt
   * The complete set of authors may be found at
   * http://polymer.github.io/AUTHORS.txt
   * The complete set of contributors may be found at
   * http://polymer.github.io/CONTRIBUTORS.txt
   * Code distributed by Google as part of the polymer project is also
   * subject to an additional IP rights grant found at
   * http://polymer.github.io/PATENTS.txt
   */
  class TemplateInstance{constructor(e,t,o){this.__parts=[],this.template=e,this.processor=t,this.options=o}update(e){let t=0;for(const o of this.__parts)void 0!==o&&o.setValue(e[t]),t++;for(const e of this.__parts)void 0!==e&&e.commit()}_clone(){const e=T?this.template.element.content.cloneNode(!0):document.importNode(this.template.element.content,!0),t=[],o=this.template.parts,n=document.createTreeWalker(e,133,null,!1);let i,r=0,a=0,s=n.nextNode();for(;r<o.length;)if(i=o[r],isTemplatePartActive(i)){for(;a<i.index;)a++,"TEMPLATE"===s.nodeName&&(t.push(s),n.currentNode=s.content),null===(s=n.nextNode())&&(n.currentNode=t.pop(),s=n.nextNode());if("node"===i.type){const e=this.processor.handleTextExpression(this.options);e.insertAfterNode(s.previousSibling),this.__parts.push(e)}else this.__parts.push(...this.processor.handleAttributeExpressions(s,i.name,i.strings,this.options));r++}else this.__parts.push(void 0),r++;return T&&(document.adoptNode(e),customElements.upgrade(e)),e}}
  /**
   * @license
   * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
   * This code may only be used under the BSD style license found at
   * http://polymer.github.io/LICENSE.txt
   * The complete set of authors may be found at
   * http://polymer.github.io/AUTHORS.txt
   * The complete set of contributors may be found at
   * http://polymer.github.io/CONTRIBUTORS.txt
   * Code distributed by Google as part of the polymer project is also
   * subject to an additional IP rights grant found at
   * http://polymer.github.io/PATENTS.txt
   */const R=window.trustedTypes&&trustedTypes.createPolicy("lit-html",{createHTML:e=>e}),N=` ${k} `;class TemplateResult{constructor(e,t,o,n){this.strings=e,this.values=t,this.type=o,this.processor=n}getHTML(){const e=this.strings.length-1;let t="",o=!1;for(let n=0;n<e;n++){const e=this.strings[n],i=e.lastIndexOf("\x3c!--");o=(i>-1||o)&&-1===e.indexOf("--\x3e",i+1);const r=j.exec(e);t+=null===r?e+(o?N:O):e.substr(0,r.index)+r[1]+r[2]+"$lit$"+r[3]+k}return t+=this.strings[e],t}getTemplateElement(){const e=document.createElement("template");let t=this.getHTML();return void 0!==R&&(t=R.createHTML(t)),e.innerHTML=t,e}}
  /**
   * @license
   * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
   * This code may only be used under the BSD style license found at
   * http://polymer.github.io/LICENSE.txt
   * The complete set of authors may be found at
   * http://polymer.github.io/AUTHORS.txt
   * The complete set of contributors may be found at
   * http://polymer.github.io/CONTRIBUTORS.txt
   * Code distributed by Google as part of the polymer project is also
   * subject to an additional IP rights grant found at
   * http://polymer.github.io/PATENTS.txt
   */const isPrimitive=e=>null===e||!("object"==typeof e||"function"==typeof e),isIterable=e=>Array.isArray(e)||!(!e||!e[Symbol.iterator]);class AttributeCommitter{constructor(e,t,o){this.dirty=!0,this.element=e,this.name=t,this.strings=o,this.parts=[];for(let e=0;e<o.length-1;e++)this.parts[e]=this._createPart()}_createPart(){return new AttributePart(this)}_getValue(){const e=this.strings,t=e.length-1,o=this.parts;if(1===t&&""===e[0]&&""===e[1]){const e=o[0].value;if("symbol"==typeof e)return String(e);if("string"==typeof e||!isIterable(e))return e}let n="";for(let i=0;i<t;i++){n+=e[i];const t=o[i];if(void 0!==t){const e=t.value;if(isPrimitive(e)||!isIterable(e))n+="string"==typeof e?e:String(e);else for(const t of e)n+="string"==typeof t?t:String(t)}}return n+=e[t],n}commit(){this.dirty&&(this.dirty=!1,this.element.setAttribute(this.name,this._getValue()))}}class AttributePart{constructor(e){this.value=void 0,this.committer=e}setValue(e){e===A||isPrimitive(e)&&e===this.value||(this.value=e,isDirective(e)||(this.committer.dirty=!0))}commit(){for(;isDirective(this.value);){const e=this.value;this.value=A,e(this)}this.value!==A&&this.committer.commit()}}class NodePart{constructor(e){this.value=void 0,this.__pendingValue=void 0,this.options=e}appendInto(e){this.startNode=e.appendChild(createMarker()),this.endNode=e.appendChild(createMarker())}insertAfterNode(e){this.startNode=e,this.endNode=e.nextSibling}appendIntoPart(e){e.__insert(this.startNode=createMarker()),e.__insert(this.endNode=createMarker())}insertAfterPart(e){e.__insert(this.startNode=createMarker()),this.endNode=e.endNode,e.endNode=this.startNode}setValue(e){this.__pendingValue=e}commit(){if(null===this.startNode.parentNode)return;for(;isDirective(this.__pendingValue);){const e=this.__pendingValue;this.__pendingValue=A,e(this)}const e=this.__pendingValue;e!==A&&(isPrimitive(e)?e!==this.value&&this.__commitText(e):e instanceof TemplateResult?this.__commitTemplateResult(e):e instanceof Node?this.__commitNode(e):isIterable(e)?this.__commitIterable(e):e===M?(this.value=M,this.clear()):this.__commitText(e))}__insert(e){this.endNode.parentNode.insertBefore(e,this.endNode)}__commitNode(e){this.value!==e&&(this.clear(),this.__insert(e),this.value=e)}__commitText(e){const t=this.startNode.nextSibling,o="string"==typeof(e=null==e?"":e)?e:String(e);t===this.endNode.previousSibling&&3===t.nodeType?t.data=o:this.__commitNode(document.createTextNode(o)),this.value=e}__commitTemplateResult(e){const t=this.options.templateFactory(e);if(this.value instanceof TemplateInstance&&this.value.template===t)this.value.update(e.values);else{const o=new TemplateInstance(t,e.processor,this.options),n=o._clone();o.update(e.values),this.__commitNode(n),this.value=o}}__commitIterable(e){Array.isArray(this.value)||(this.value=[],this.clear());const t=this.value;let o,n=0;for(const i of e)o=t[n],void 0===o&&(o=new NodePart(this.options),t.push(o),0===n?o.appendIntoPart(this):o.insertAfterPart(t[n-1])),o.setValue(i),o.commit(),n++;n<t.length&&(t.length=n,this.clear(o&&o.endNode))}clear(e=this.startNode){removeNodes(this.startNode.parentNode,e.nextSibling,this.endNode)}}class BooleanAttributePart{constructor(e,t,o){if(this.value=void 0,this.__pendingValue=void 0,2!==o.length||""!==o[0]||""!==o[1])throw new Error("Boolean attributes can only contain a single expression");this.element=e,this.name=t,this.strings=o}setValue(e){this.__pendingValue=e}commit(){for(;isDirective(this.__pendingValue);){const e=this.__pendingValue;this.__pendingValue=A,e(this)}if(this.__pendingValue===A)return;const e=!!this.__pendingValue;this.value!==e&&(e?this.element.setAttribute(this.name,""):this.element.removeAttribute(this.name),this.value=e),this.__pendingValue=A}}class PropertyCommitter extends AttributeCommitter{constructor(e,t,o){super(e,t,o),this.single=2===o.length&&""===o[0]&&""===o[1]}_createPart(){return new PropertyPart(this)}_getValue(){return this.single?this.parts[0].value:super._getValue()}commit(){this.dirty&&(this.dirty=!1,this.element[this.name]=this._getValue())}}class PropertyPart extends AttributePart{}let L=!1;(()=>{try{const e={get capture(){return L=!0,!1}};window.addEventListener("test",e,e),window.removeEventListener("test",e,e)}catch(e){}})();class EventPart{constructor(e,t,o){this.value=void 0,this.__pendingValue=void 0,this.element=e,this.eventName=t,this.eventContext=o,this.__boundHandleEvent=e=>this.handleEvent(e)}setValue(e){this.__pendingValue=e}commit(){for(;isDirective(this.__pendingValue);){const e=this.__pendingValue;this.__pendingValue=A,e(this)}if(this.__pendingValue===A)return;const e=this.__pendingValue,t=this.value,o=null==e||null!=t&&(e.capture!==t.capture||e.once!==t.once||e.passive!==t.passive),n=null!=e&&(null==t||o);o&&this.element.removeEventListener(this.eventName,this.__boundHandleEvent,this.__options),n&&(this.__options=getOptions(e),this.element.addEventListener(this.eventName,this.__boundHandleEvent,this.__options)),this.value=e,this.__pendingValue=A}handleEvent(e){"function"==typeof this.value?this.value.call(this.eventContext||this.element,e):this.value.handleEvent(e)}}const getOptions=e=>e&&(L?{capture:e.capture,passive:e.passive,once:e.once}:e.capture)
  /**
   * @license
   * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
   * This code may only be used under the BSD style license found at
   * http://polymer.github.io/LICENSE.txt
   * The complete set of authors may be found at
   * http://polymer.github.io/AUTHORS.txt
   * The complete set of contributors may be found at
   * http://polymer.github.io/CONTRIBUTORS.txt
   * Code distributed by Google as part of the polymer project is also
   * subject to an additional IP rights grant found at
   * http://polymer.github.io/PATENTS.txt
   */;function templateFactory(e){let t=P.get(e.type);void 0===t&&(t={stringsArray:new WeakMap,keyString:new Map},P.set(e.type,t));let o=t.stringsArray.get(e.strings);if(void 0!==o)return o;const n=e.strings.join(k);return o=t.keyString.get(n),void 0===o&&(o=new Template(e,e.getTemplateElement()),t.keyString.set(n,o)),t.stringsArray.set(e.strings,o),o}const P=new Map,z=new WeakMap;
  /**
   * @license
   * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
   * This code may only be used under the BSD style license found at
   * http://polymer.github.io/LICENSE.txt
   * The complete set of authors may be found at
   * http://polymer.github.io/AUTHORS.txt
   * The complete set of contributors may be found at
   * http://polymer.github.io/CONTRIBUTORS.txt
   * Code distributed by Google as part of the polymer project is also
   * subject to an additional IP rights grant found at
   * http://polymer.github.io/PATENTS.txt
   */const D=new
  /**
   * @license
   * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
   * This code may only be used under the BSD style license found at
   * http://polymer.github.io/LICENSE.txt
   * The complete set of authors may be found at
   * http://polymer.github.io/AUTHORS.txt
   * The complete set of contributors may be found at
   * http://polymer.github.io/CONTRIBUTORS.txt
   * Code distributed by Google as part of the polymer project is also
   * subject to an additional IP rights grant found at
   * http://polymer.github.io/PATENTS.txt
   */
  class DefaultTemplateProcessor{handleAttributeExpressions(e,t,o,n){const i=t[0];if("."===i){return new PropertyCommitter(e,t.slice(1),o).parts}if("@"===i)return[new EventPart(e,t.slice(1),n.eventContext)];if("?"===i)return[new BooleanAttributePart(e,t.slice(1),o)];return new AttributeCommitter(e,t,o).parts}handleTextExpression(e){return new NodePart(e)}};
  /**
   * @license
   * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
   * This code may only be used under the BSD style license found at
   * http://polymer.github.io/LICENSE.txt
   * The complete set of authors may be found at
   * http://polymer.github.io/AUTHORS.txt
   * The complete set of contributors may be found at
   * http://polymer.github.io/CONTRIBUTORS.txt
   * Code distributed by Google as part of the polymer project is also
   * subject to an additional IP rights grant found at
   * http://polymer.github.io/PATENTS.txt
   */"undefined"!=typeof window&&(window.litHtmlVersions||(window.litHtmlVersions=[])).push("1.3.0");const html=(e,...t)=>new TemplateResult(e,t,"html",D)
  /**
   * @license
   * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
   * This code may only be used under the BSD style license found at
   * http://polymer.github.io/LICENSE.txt
   * The complete set of authors may be found at
   * http://polymer.github.io/AUTHORS.txt
   * The complete set of contributors may be found at
   * http://polymer.github.io/CONTRIBUTORS.txt
   * Code distributed by Google as part of the polymer project is also
   * subject to an additional IP rights grant found at
   * http://polymer.github.io/PATENTS.txt
   */,getTemplateCacheKey=(e,t)=>`${e}--${t}`;let V=!0;void 0===window.ShadyCSS?V=!1:void 0===window.ShadyCSS.prepareTemplateDom&&(console.warn("Incompatible ShadyCSS version detected. Please update to at least @webcomponents/webcomponentsjs@2.0.2 and @webcomponents/shadycss@1.3.1."),V=!1);const shadyTemplateFactory=e=>t=>{const o=getTemplateCacheKey(t.type,e);let n=P.get(o);void 0===n&&(n={stringsArray:new WeakMap,keyString:new Map},P.set(o,n));let i=n.stringsArray.get(t.strings);if(void 0!==i)return i;const r=t.strings.join(k);if(i=n.keyString.get(r),void 0===i){const o=t.getTemplateElement();V&&window.ShadyCSS.prepareTemplateDom(o,e),i=new Template(t,o),n.keyString.set(r,i)}return n.stringsArray.set(t.strings,i),i},U=["html","svg"],I=new Set,prepareTemplateStyles=(e,t,o)=>{I.add(e);const n=o?o.element:document.createElement("template"),i=t.querySelectorAll("style"),{length:r}=i;if(0===r)return void window.ShadyCSS.prepareTemplateStyles(n,e);const a=document.createElement("style");for(let e=0;e<r;e++){const t=i[e];t.parentNode.removeChild(t),a.textContent+=t.textContent}(e=>{U.forEach(t=>{const o=P.get(getTemplateCacheKey(t,e));void 0!==o&&o.keyString.forEach(e=>{const{element:{content:t}}=e,o=new Set;Array.from(t.querySelectorAll("style")).forEach(e=>{o.add(e)}),removeNodesFromTemplate(e,o)})})})(e);const s=n.content;o?function insertNodeIntoTemplate(e,t,o=null){const{element:{content:n},parts:i}=e;if(null==o)return void n.appendChild(t);const r=document.createTreeWalker(n,133,null,!1);let a=nextActiveIndexInTemplateParts(i),s=0,c=-1;for(;r.nextNode();){c++;for(r.currentNode===o&&(s=countNodes(t),o.parentNode.insertBefore(t,o));-1!==a&&i[a].index===c;){if(s>0){for(;-1!==a;)i[a].index+=s,a=nextActiveIndexInTemplateParts(i,a);return}a=nextActiveIndexInTemplateParts(i,a)}}}(o,a,s.firstChild):s.insertBefore(a,s.firstChild),window.ShadyCSS.prepareTemplateStyles(n,e);const c=s.querySelector("style");if(window.ShadyCSS.nativeShadow&&null!==c)t.insertBefore(c.cloneNode(!0),t.firstChild);else if(o){s.insertBefore(a,s.firstChild);const e=new Set;e.add(a),removeNodesFromTemplate(o,e)}};window.JSCompiler_renameProperty=(e,t)=>e;const Y={toAttribute(e,t){switch(t){case Boolean:return e?"":null;case Object:case Array:return null==e?e:JSON.stringify(e)}return e},fromAttribute(e,t){switch(t){case Boolean:return null!==e;case Number:return null===e?null:Number(e);case Object:case Array:return JSON.parse(e)}return e}},notEqual=(e,t)=>t!==e&&(t==t||e==e),B={attribute:!0,type:String,converter:Y,reflect:!1,hasChanged:notEqual};class UpdatingElement extends HTMLElement{constructor(){super(),this.initialize()}static get observedAttributes(){this.finalize();const e=[];return this._classProperties.forEach((t,o)=>{const n=this._attributeNameForProperty(o,t);void 0!==n&&(this._attributeToPropertyMap.set(n,o),e.push(n))}),e}static _ensureClassProperties(){if(!this.hasOwnProperty(JSCompiler_renameProperty("_classProperties",this))){this._classProperties=new Map;const e=Object.getPrototypeOf(this)._classProperties;void 0!==e&&e.forEach((e,t)=>this._classProperties.set(t,e))}}static createProperty(e,t=B){if(this._ensureClassProperties(),this._classProperties.set(e,t),t.noAccessor||this.prototype.hasOwnProperty(e))return;const o="symbol"==typeof e?Symbol():"__"+e,n=this.getPropertyDescriptor(e,o,t);void 0!==n&&Object.defineProperty(this.prototype,e,n)}static getPropertyDescriptor(e,t,o){return{get(){return this[t]},set(n){const i=this[e];this[t]=n,this.requestUpdateInternal(e,i,o)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this._classProperties&&this._classProperties.get(e)||B}static finalize(){const e=Object.getPrototypeOf(this);if(e.hasOwnProperty("finalized")||e.finalize(),this.finalized=!0,this._ensureClassProperties(),this._attributeToPropertyMap=new Map,this.hasOwnProperty(JSCompiler_renameProperty("properties",this))){const e=this.properties,t=[...Object.getOwnPropertyNames(e),..."function"==typeof Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e):[]];for(const o of t)this.createProperty(o,e[o])}}static _attributeNameForProperty(e,t){const o=t.attribute;return!1===o?void 0:"string"==typeof o?o:"string"==typeof e?e.toLowerCase():void 0}static _valueHasChanged(e,t,o=notEqual){return o(e,t)}static _propertyValueFromAttribute(e,t){const o=t.type,n=t.converter||Y,i="function"==typeof n?n:n.fromAttribute;return i?i(e,o):e}static _propertyValueToAttribute(e,t){if(void 0===t.reflect)return;const o=t.type,n=t.converter;return(n&&n.toAttribute||Y.toAttribute)(e,o)}initialize(){this._updateState=0,this._updatePromise=new Promise(e=>this._enableUpdatingResolver=e),this._changedProperties=new Map,this._saveInstanceProperties(),this.requestUpdateInternal()}_saveInstanceProperties(){this.constructor._classProperties.forEach((e,t)=>{if(this.hasOwnProperty(t)){const e=this[t];delete this[t],this._instanceProperties||(this._instanceProperties=new Map),this._instanceProperties.set(t,e)}})}_applyInstanceProperties(){this._instanceProperties.forEach((e,t)=>this[t]=e),this._instanceProperties=void 0}connectedCallback(){this.enableUpdating()}enableUpdating(){void 0!==this._enableUpdatingResolver&&(this._enableUpdatingResolver(),this._enableUpdatingResolver=void 0)}disconnectedCallback(){}attributeChangedCallback(e,t,o){t!==o&&this._attributeToProperty(e,o)}_propertyToAttribute(e,t,o=B){const n=this.constructor,i=n._attributeNameForProperty(e,o);if(void 0!==i){const e=n._propertyValueToAttribute(t,o);if(void 0===e)return;this._updateState=8|this._updateState,null==e?this.removeAttribute(i):this.setAttribute(i,e),this._updateState=-9&this._updateState}}_attributeToProperty(e,t){if(8&this._updateState)return;const o=this.constructor,n=o._attributeToPropertyMap.get(e);if(void 0!==n){const e=o.getPropertyOptions(n);this._updateState=16|this._updateState,this[n]=o._propertyValueFromAttribute(t,e),this._updateState=-17&this._updateState}}requestUpdateInternal(e,t,o){let n=!0;if(void 0!==e){const i=this.constructor;o=o||i.getPropertyOptions(e),i._valueHasChanged(this[e],t,o.hasChanged)?(this._changedProperties.has(e)||this._changedProperties.set(e,t),!0!==o.reflect||16&this._updateState||(void 0===this._reflectingProperties&&(this._reflectingProperties=new Map),this._reflectingProperties.set(e,o))):n=!1}!this._hasRequestedUpdate&&n&&(this._updatePromise=this._enqueueUpdate())}requestUpdate(e,t){return this.requestUpdateInternal(e,t),this.updateComplete}async _enqueueUpdate(){this._updateState=4|this._updateState;try{await this._updatePromise}catch(e){}const e=this.performUpdate();return null!=e&&await e,!this._hasRequestedUpdate}get _hasRequestedUpdate(){return 4&this._updateState}get hasUpdated(){return 1&this._updateState}performUpdate(){if(!this._hasRequestedUpdate)return;this._instanceProperties&&this._applyInstanceProperties();let e=!1;const t=this._changedProperties;try{e=this.shouldUpdate(t),e?this.update(t):this._markUpdated()}catch(t){throw e=!1,this._markUpdated(),t}e&&(1&this._updateState||(this._updateState=1|this._updateState,this.firstUpdated(t)),this.updated(t))}_markUpdated(){this._changedProperties=new Map,this._updateState=-5&this._updateState}get updateComplete(){return this._getUpdateComplete()}_getUpdateComplete(){return this._updatePromise}shouldUpdate(e){return!0}update(e){void 0!==this._reflectingProperties&&this._reflectingProperties.size>0&&(this._reflectingProperties.forEach((e,t)=>this._propertyToAttribute(t,this[t],e)),this._reflectingProperties=void 0),this._markUpdated()}updated(e){}firstUpdated(e){}}UpdatingElement.finalized=!0;
  /**
  @license
  Copyright (c) 2019 The Polymer Project Authors. All rights reserved.
  This code may only be used under the BSD style license found at
  http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
  http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
  found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
  part of the polymer project is also subject to an additional IP rights grant
  found at http://polymer.github.io/PATENTS.txt
  */
  const F=window.ShadowRoot&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,G=Symbol();class CSSResult{constructor(e,t){if(t!==G)throw new Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e}get styleSheet(){return void 0===this._styleSheet&&(F?(this._styleSheet=new CSSStyleSheet,this._styleSheet.replaceSync(this.cssText)):this._styleSheet=null),this._styleSheet}toString(){return this.cssText}}
  /**
   * @license
   * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
   * This code may only be used under the BSD style license found at
   * http://polymer.github.io/LICENSE.txt
   * The complete set of authors may be found at
   * http://polymer.github.io/AUTHORS.txt
   * The complete set of contributors may be found at
   * http://polymer.github.io/CONTRIBUTORS.txt
   * Code distributed by Google as part of the polymer project is also
   * subject to an additional IP rights grant found at
   * http://polymer.github.io/PATENTS.txt
   */
  (window.litElementVersions||(window.litElementVersions=[])).push("2.4.0");const $={};class LitElement extends UpdatingElement{static getStyles(){return this.styles}static _getUniqueStyles(){if(this.hasOwnProperty(JSCompiler_renameProperty("_styles",this)))return;const e=this.getStyles();if(Array.isArray(e)){const addStyles=(e,t)=>e.reduceRight((e,t)=>Array.isArray(t)?addStyles(t,e):(e.add(t),e),t),t=addStyles(e,new Set),o=[];t.forEach(e=>o.unshift(e)),this._styles=o}else this._styles=void 0===e?[]:[e];this._styles=this._styles.map(e=>{if(e instanceof CSSStyleSheet&&!F){const t=Array.prototype.slice.call(e.cssRules).reduce((e,t)=>e+t.cssText,"");return new CSSResult(String(t),G)}return e})}initialize(){super.initialize(),this.constructor._getUniqueStyles(),this.renderRoot=this.createRenderRoot(),window.ShadowRoot&&this.renderRoot instanceof window.ShadowRoot&&this.adoptStyles()}createRenderRoot(){return this.attachShadow({mode:"open"})}adoptStyles(){const e=this.constructor._styles;0!==e.length&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow?F?this.renderRoot.adoptedStyleSheets=e.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet):this._needsShimAdoptedStyleSheets=!0:window.ShadyCSS.ScopingShim.prepareAdoptedCssText(e.map(e=>e.cssText),this.localName))}connectedCallback(){super.connectedCallback(),this.hasUpdated&&void 0!==window.ShadyCSS&&window.ShadyCSS.styleElement(this)}update(e){const t=this.render();super.update(e),t!==$&&this.constructor.render(t,this.renderRoot,{scopeName:this.localName,eventContext:this}),this._needsShimAdoptedStyleSheets&&(this._needsShimAdoptedStyleSheets=!1,this.constructor._styles.forEach(e=>{const t=document.createElement("style");t.textContent=e.cssText,this.renderRoot.appendChild(t)}))}render(){return $}}LitElement.finalized=!0,LitElement.render=(e,t,o)=>{if(!o||"object"!=typeof o||!o.scopeName)throw new Error("The `scopeName` option is required.");const n=o.scopeName,i=z.has(t),r=V&&11===t.nodeType&&!!t.host,a=r&&!I.has(n),s=a?document.createDocumentFragment():t;if(((e,t,o)=>{let n=z.get(t);void 0===n&&(removeNodes(t,t.firstChild),z.set(t,n=new NodePart(Object.assign({templateFactory:templateFactory},o))),n.appendInto(t)),n.setValue(e),n.commit()})(e,s,Object.assign({templateFactory:shadyTemplateFactory(n)},o)),a){const e=z.get(s);z.delete(s);const o=e.value instanceof TemplateInstance?e.value.template:void 0;prepareTemplateStyles(n,s,o),removeNodes(t,t.firstChild),t.appendChild(s),z.set(t,e)}!i&&r&&window.ShadyCSS.styleElement(t.host)};const getThemeVar=e=>getComputedStyle(document.body).getPropertyValue(e),defaultConfig=()=>{if(J())return{locale:[],header_text:J().config.title||"Home Assistant",disabled_mode:!1,kiosk_mode:!1,compact_mode:!1,footer_mode:!1,split_mode:!1,disable_sidebar:!1,hide_header:!1,chevrons:!0,indicator_top:!1,hidden_tab_redirect:!0,shadow:!0,default_tab_on_refresh:!0,background:getThemeVar("--ch-background")||getThemeVar("--app-header-background-color")||"var(--primary-color)",elements_color:getThemeVar("--ch-elements-color")||getThemeVar("--app-header-text-color")||"var(--text-primary-color)",menu_color:getThemeVar("--ch-menu-color")||"",voice_color:getThemeVar("--ch-voice-color")||"",options_color:getThemeVar("--ch-options-color")||"",all_tabs_color:getThemeVar("--ch-all-tabs-color")||"",notification_dot_color:getThemeVar("--ch-notification-dot-color")||getThemeVar("var(--accent-color)")||"#ff9800",tab_indicator_color:getThemeVar("--ch-tab-indicator-color")||"",active_tab_color:getThemeVar("--ch-active-tab-color")||"",tabs_color:[],hide_tabs:[],show_tabs:[],default_tab:"",tab_icons:[],tab_text:[],tab_icons_and_text:!1,tab_text_only:!1,reverse_tab_direction:!1,button_icons:[],button_text:[],reverse_button_direction:!1,menu_dropdown:!1,menu_hide:!1,voice_dropdown:!1,voice_hide:!1,options_hide:!1,button_scroll:!1,hide_help:!1,hide_unused:!1,hide_refresh:!1,hide_config:!1,hide_raw:!1,hide_ch_settings:!1,hide_reload_resources:!1,tabs_css:[],header_css:"",stack_css:"",header_text_css:"",active_tab_css:"",options_list_css:"",menu_css:"",options_css:"",voice_css:"",all_tabs_css:"",tab_container_css:"",view_css:"",panel_view_css:"",template_variables:"",exceptions:[],editor_warnings:!0,restrict_users:!1}};function _templateObject22(){const e=_taggedTemplateLiteral(['\n      <paper-input\n        label="','"\n        .value="','"\n        .configValue="','"\n        @value-changed="','"\n      >\n      </paper-input>\n      <paper-input\n        label="','"\n        .value="','"\n        .configValue="','"\n        @value-changed="','"\n      >\n      </paper-input>\n      <paper-input\n        label="','"\n        .value="','"\n        .configValue="','"\n        @value-changed="','"\n      >\n      </paper-input>\n      <paper-input\n        label="','"\n        .value="','"\n        .configValue="','"\n        @value-changed="','"\n      >\n      </paper-input>\n      <paper-input\n        label="','"\n        .value="','"\n        .configValue="','"\n        @value-changed="','"\n      >\n      </paper-input>\n      <paper-input\n        label="','"\n        .value="','"\n        .configValue="','"\n        @value-changed="','"\n      >\n      </paper-input>\n      <paper-input\n        label="Device ID"\n        .value="','"\n        .configValue="','"\n        @value-changed="','"\n      >\n      </paper-input>\n    ']);return _templateObject22=function _templateObject22(){return e},e}function _templateObject21(){const e=_taggedTemplateLiteral([""]);return _templateObject21=function _templateObject21(){return e},e}function _templateObject20(){const e=_taggedTemplateLiteral(["\n      <style>\n        h3,\n        h4 {\n          font-size: 16pt;\n          margin-bottom: 5px;\n          width: 100%;\n        }\n        [closed] {\n          overflow: hidden;\n          height: 52px;\n        }\n        ha-card {\n          margin-top: 10px;\n          width: 100%;\n          transition: all 0.5s ease;\n        }\n        .underline {\n          width: 100%;\n          background: var(--dark-color);\n          color: var(--text-dark-color);\n          padding: 5px;\n          width: calc(100% + 30px);\n          margin-left: calc(0% - 20px);\n        }\n      </style>\n    "]);return _templateObject20=function _templateObject20(){return e},e}function _templateObject19(){const e=_taggedTemplateLiteral(["\n      ",'\n      <custom-style>\n        <style is="custom-style">\n          .card-header {\n            margin-top: -5px;\n            @apply --paper-font-headline;\n          }\n          .card-header ha-icon-button {\n            margin-top: -5px;\n            float: right;\n          }\n        </style>\n      </custom-style>\n      <ha-card ?closed=','>\n        <div class="card-content">\n          <div class="card-header">\n            ','\n            <ha-icon-button icon="','" @click="','">\n            </ha-icon-button>\n            <ha-icon-button ?hidden=',' icon="mdi:delete" @click="','">\n            </ha-icon-button>\n          </div>\n          <h4 class="underline">','</h4>\n          <ch-conditions-editor\n            .conditions="','"\n            @ch-conditions-changed="','"\n          >\n          </ch-conditions-editor>\n          <h4 class="underline">','</h4>\n          <ch-config-editor\n            exception\n            .defaultConfig="','"\n            .config="','"\n            @ch-config-changed="','"\n          >\n          </ch-config-editor>\n        </div>\n      </ha-card>\n    ']);return _templateObject19=function _templateObject19(){return e},e}function _templateObject18(){const e=_taggedTemplateLiteral([""]);return _templateObject18=function _templateObject18(){return e},e}function _templateObject17(){const e=_taggedTemplateLiteral(["\n      <style>\n        h3,\n        h4 {\n          font-size: 16pt;\n          margin-bottom: 5px;\n          width: 100%;\n        }\n        switch-text {\n          padding-left: 10px;\n          vertical-align: bottom;\n        }\n        ha-switch {\n          padding-top: 16px;\n        }\n        ha-icon {\n          padding-right: 5px;\n        }\n        iron-input {\n          max-width: 115px;\n        }\n        .inherited {\n          opacity: 0.4;\n        }\n        .inherited:hover {\n          opacity: 1;\n        }\n        .side-by-side {\n          display: flex;\n          flex-wrap: wrap;\n        }\n        .side-by-side > * {\n          flex: 1;\n          padding-right: 4px;\n          flex-basis: 33%;\n        }\n        .buttons > div {\n          display: flex;\n          align-items: center;\n        }\n        .buttons > div paper-dropdown-menu {\n          flex-grow: 1;\n        }\n        .buttons > div ha-icon {\n          padding-right: 15px;\n          padding-top: 20px;\n          margin-left: -3px;\n        }\n        .buttons > div:nth-of-type(2n) ha-icon {\n          padding-left: 20px;\n        }\n        .warning {\n          background-color: #455a64;\n          padding: 10px;\n          color: #ffcd4c;\n          border-radius: 5px;\n        }\n        .alert {\n          color: #ff9800;\n          padding-right: 0;\n          margin-right: -5px;\n          padding-left: 7px;\n        }\n        [closed] {\n          overflow: hidden;\n          height: 52px;\n        }\n        ha-card {\n          margin-top: 10px;\n          width: 100%;\n          transition: all 0.5s ease;\n        }\n        .underline {\n          width: 100%;\n          background: var(--dark-color);\n          color: var(--text-dark-color);\n          padding: 5px;\n          width: calc(100% + 30px);\n          margin-left: calc(0% - 20px);\n        }\n      </style>\n    "]);return _templateObject17=function _templateObject17(){return e},e}function _templateObject16(){const e=_taggedTemplateLiteral(['\n            <h4 class="underline">Main Config</h4>\n          ']);return _templateObject16=function _templateObject16(){return e},e}function _templateObject15(){const e=_taggedTemplateLiteral(['\n                  <br />\n                  <div class="warning">\n                    <p style="padding: 5px; margin: 0;">\n                      ','\n                    </p>\n                    <p style="padding: 5px; margin: 0;">\n                      ','\n                    </p>\n                    <p style="padding: 5px; margin: 0;">\n                      <ha-icon style="padding-right: 3px;" icon="mdi:alpha-t-box-outline"></ha-icon>\n                      ','\n                      <br /><ha-icon style="padding-right: 3px;" icon="mdi:alert-box-outline"></ha-icon> ',"\n                    </p>\n                  </div>\n                "]);return _templateObject15=function _templateObject15(){return e},e}function _templateObject14(){const e=_taggedTemplateLiteral(['\n            <h1 style="margin-top:-20px;margin-bottom:0;" class="underline">\n              Custom Header\n            </h1>\n            <h4 style="margin-top:-5px;padding-top:10px;font-size:12pt;" class="underline">\n              <a href="https://maykar.github.io/custom-header/" target="_blank">\n                <ha-icon icon="mdi:help-circle" style="margin-top:-5px;"> </ha-icon>\n                ','&nbsp;&nbsp;&nbsp;</a\n              >\n              <a href="https://github.com/maykar/custom-header" target="_blank">\n                <ha-icon icon="mdi:github" style="margin-top:-5px;"> </ha-icon>\n                GitHub&nbsp;&nbsp;&nbsp;</a\n              >\n              <a href="https://community.home-assistant.io/t/custom-header/" target="_blank">\n                <ha-icon icon="hass:home-assistant" style="margin-top:-5px;"> </ha-icon>\n                ',"</a\n              >\n            </h4>\n            ","\n            ","\n          "]);return _templateObject14=function _templateObject14(){return e},e}function _templateObject13(){const e=_taggedTemplateLiteral(['\n      <custom-style>\n        <style is="custom-style">\n          a {\n            color: var(--text-dark-color);\n            text-decoration: none;\n          }\n          .card-header {\n            margin-top: -5px;\n            @apply --paper-font-headline;\n          }\n          .card-header ha-icon-button {\n            margin-top: -5px;\n            float: right;\n          }\n        </style>\n      </custom-style>\n      ',"\n      ","\n      ",'\n      <div style="padding-bottom:20px;" class="side-by-side">\n        ',"\n        ","\n        ","\n        ","\n        ","\n        ","\n        ","\n        ","\n        ","\n        ","\n        ","\n        ",'\n      </div>\n      <hr />\n      <div class="side-by-side">\n        <paper-input\n          style="padding: 10px 10px 0 10px;"\n          class="','"\n          label="','"\n          .value="','"\n          .configValue="','"\n          @value-changed="','"\n        >\n        </paper-input>\n        <paper-input\n          placeholder="','"\n          style="padding: 10px 10px 0 10px;"\n          class="','"\n          label="','"\n          .value="','"\n          .configValue="','"\n          @value-changed="','"\n        >\n        </paper-input>\n      </div>\n      <h4 class="underline">','</h4>\n      <div class="side-by-side">\n        ',"\n        ","\n        ","\n        ","\n        ",'\n      </div>\n      <h4 class="underline">','</h4>\n      <div style="padding-bottom:20px;" class="side-by-side">\n        ',"\n        ","\n        ","\n        ","\n        ","\n        ",'\n      </div>\n      <h4 class="underline">','</h4>\n      <paper-dropdown-menu id="tabs" @value-changed="','">\n        <paper-listbox slot="dropdown-content" .selected="','">\n          <paper-item>',"</paper-item>\n          <paper-item>",'</paper-item>\n        </paper-listbox>\n      </paper-dropdown-menu>\n      <div class="side-by-side">\n        <div id="show" style="display:','">\n          <paper-input\n            class="','"\n            label="',':"\n            .value="','"\n            .configValue="','"\n            @value-changed="','"\n          >\n          </paper-input>\n        </div>\n        <div id="hide" style="display:','">\n          <paper-input\n            class="','"\n            label="',':"\n            .value="','"\n            .configValue="','"\n            @value-changed="','"\n          >\n          </paper-input>\n        </div>\n        <paper-input\n          class="','"\n          label="',"",':"\n          .value="','"\n          .configValue="','"\n          @value-changed="','"\n        >\n        </paper-input>\n        ',"\n        ","\n        ","\n      </div>\n    "]);return _templateObject13=function _templateObject13(){return e},e}function _templateObject12(){const e=_taggedTemplateLiteral(['\n        <ha-switch\n          class="','"\n          ?checked="','"\n          .configValue="','"\n          @change="','"\n          title=',"\n          ?disabled=","\n        >\n          "," ","\n          ","\n        </ha-switch>\n      "]);return _templateObject12=function _templateObject12(){return e},e}function _templateObject11(){const e=_taggedTemplateLiteral(['\n        <div>\n          <ha-switch\n            class="','"\n            ?checked="','"\n            .configValue="','"\n            @change="','"\n            title=',"\n            ?disabled=","\n          >\n          </ha-switch>\n          <switch-text>\n            <sw-text title=","\n              >"," ","</sw-text\n            >\n            ","\n          </switch-text>\n        </div>\n      "]);return _templateObject11=function _templateObject11(){return e},e}function _templateObject10(){const e=_taggedTemplateLiteral(['\n      <ha-icon icon="mdi:alert-box-outline" class="alert" title="','"></ha-icon>\n    ']);return _templateObject10=function _templateObject10(){return e},e}function _templateObject9(){const e=_taggedTemplateLiteral(['\n      <ha-icon icon="mdi:alpha-t-box-outline" class="alert" title="','"></ha-icon>\n    ']);return _templateObject9=function _templateObject9(){return e},e}function _templateObject8(){const e=_taggedTemplateLiteral(["\n      <style>\n        h3,\n        h4 {\n          font-size: 16pt;\n          margin-bottom: 5px;\n          width: 100%;\n        }\n        .toggle-button {\n          margin: 4px;\n          background-color: transparent;\n          color: var(--primary-color);\n        }\n        .title_control {\n          color: var(--text-dark-color);\n          font-weight: bold;\n          font-size: 22px;\n          float: right;\n          cursor: pointer;\n          margin: -10px -5px -5px -5px;\n        }\n        .user_agent {\n          display: block;\n          margin-left: auto;\n          margin-right: auto;\n          padding: 5px;\n          border: 0;\n          resize: none;\n          width: 100%;\n        }\n        .underline {\n          width: 100%;\n          background: var(--dark-color);\n          color: var(--text-dark-color);\n          padding: 5px;\n          width: calc(100% + 30px);\n          margin-left: calc(0% - 20px);\n        }\n      </style>\n    "]);return _templateObject8=function _templateObject8(){return e},e}function _templateObject7(){const e=_taggedTemplateLiteral(['\n      <mwc-button raised @click="','">',"</mwc-button>\n    "]);return _templateObject7=function _templateObject7(){return e},e}function _templateObject6(){const e=_taggedTemplateLiteral(['\n      <mwc-button raised @click="','">',"</mwc-button>\n    "]);return _templateObject6=function _templateObject6(){return e},e}function _templateObject5(){const e=_taggedTemplateLiteral(["\n              ","\n            "]);return _templateObject5=function _templateObject5(){return e},e}function _templateObject4(){const e=_taggedTemplateLiteral(["\n              ","\n            "]);return _templateObject4=function _templateObject4(){return e},e}function _templateObject3(){const e=_taggedTemplateLiteral(['\n              <ch-exception-editor\n                .config="','"\n                .exception="','"\n                .index="','"\n                @ch-exception-changed="','"\n                @ch-exception-delete="','"\n              >\n              </ch-exception-editor>\n            ']);return _templateObject3=function _templateObject3(){return e},e}function _templateObject2(){const e=_taggedTemplateLiteral(['\n      <div @click="','" class="title_control">\n        X\n      </div>\n      ','\n      <ch-config-editor\n        .defaultConfig="','"\n        .config="','"\n        @ch-config-changed="','"\n      >\n      </ch-config-editor>\n      <h4 class="underline">',"</h4>\n      <br />\n      ",'\n      <br />\n      <mwc-button @click="','">','</mwc-button>\n      <h4 class="underline">',"</h4>\n      <br />\n      <b>Name:</b> ","<br />\n      <b>ID:</b> ",'\n      <h4 class="underline">Device ID</h4>\n      <br />\n      ','\n      <br />\n      <h4 class="underline">',"</h4>\n      <br />\n      ",'\n      <br />\n      <h4\n        style="background:var(--ha-card-background-color);\n          margin-bottom:-20px;"\n        class="underline"\n      >\n        ',"\n        ","\n      </h4>\n    "]);return _templateObject2=function _templateObject2(){return e},e}function _templateObject(){const e=_taggedTemplateLiteral([""]);return _templateObject=function _templateObject(){return e},e}customElements.define("custom-header-editor",class CustomHeaderEditor extends LitElement{static get properties(){return{_config:{}}}firstUpdated(){this.defaultConfig=defaultConfig(),this._lovelace=J(),this.hass=ha_elements().hass,this.deepcopy=this.deepcopy.bind(this),this._config=this._lovelace.config.custom_header?this.deepcopy(this._lovelace.config.custom_header):{}}render(){return this._config&&this._lovelace?html(_templateObject2(),this._close,this.renderStyle(),this.defaultConfig,this._config,this._configChanged,localize("editor.exceptions"),this._config.exceptions?this._config.exceptions.map((e,t)=>html(_templateObject3(),this._config,e,t,this._exceptionChanged,this._exceptionDelete)):"",this._addException,localize("editor.add_exception"),localize("editor.current_user"),this.hass.user.name,this.hass.user.id,q,localize("editor.current_user_agent"),navigator.userAgent,this.exception?"":html(_templateObject4(),this._save_button),this.exception?"":html(_templateObject5(),this._cancel_button)):html(_templateObject())}_close(){const e=this.parentNode.parentNode.parentNode.querySelector("editor");this.parentNode.parentNode.parentNode.removeChild(e)}_save(){for(const e in this._config)this._config[e]==this.defaultConfig[e]&&delete this._config[e];const e=_objectSpread2(_objectSpread2({},this._lovelace.config),{custom_header:this._config});try{this._lovelace.saveConfig(e).then(()=>{window.location.href=window.location.href})}catch(e){alert("".concat(localize("editor.save_failed"),": ").concat(e))}}get _save_button(){const e=localize("editor.save_and_reload");return html(_templateObject6(),this._save,e)}get _cancel_button(){return html(_templateObject7(),this._close,localize("editor.cancel"))}_addException(){let e;this._config.exceptions?(e=this._config.exceptions.slice(0),e.push({conditions:{},config:{}})):e=[{conditions:{},config:{}}],this._config=_objectSpread2(_objectSpread2({},this._config),{},{exceptions:e}),x(this,"config-changed",{config:this._config})}_configChanged(e){let{detail:t}=e;this._config&&(this._config=_objectSpread2(_objectSpread2({},this._config),t.config),x(this,"config-changed",{config:this._config}))}_exceptionChanged(e){if(!this._config)return;const t=e.target.index,o=this._config.exceptions.slice(0);o[t]=e.detail.exception;for(const e of o)for(const t in e.config)this._config[t]==e.config[t]?delete e.config[t]:this._config[t]||this.defaultConfig[t]!=e.config[t]||delete e.config[t];this._config=_objectSpread2(_objectSpread2({},this._config),{},{exceptions:o}),x(this,"config-changed",{config:this._config})}_exceptionDelete(e){if(!this._config)return;const t=e.target,o=this._config.exceptions.slice(0);o.splice(t.index,1),this._config=_objectSpread2(_objectSpread2({},this._config),{},{exceptions:o}),x(this,"config-changed",{config:this._config}),this.requestUpdate()}deepcopy(e){if(!e||"object"!=typeof e)return e;if("[object Date]"==Object.prototype.toString.call(e))return new Date(e.getTime());if(Array.isArray(e))return e.map(this.deepcopy);const t={};return Object.keys(e).forEach(o=>{t[o]=this.deepcopy(e[o])}),t}renderStyle(){return html(_templateObject8())}});customElements.define("ch-config-editor",class ChConfigEditor extends LitElement{static get properties(){return{defaultConfig:{},config:{},exception:{},_closed:{}}}constructor(){super(),this.buttonOptions=["show","hide","clock","overflow"],this.overflowOptions=["show","hide","clock"],this.swipeAnimation=["none","swipe","fade","flip"]}get _clock(){return"clock"==this.getConfig("menu")||"clock"==this.getConfig("voice")||"clock"==this.getConfig("options")}getConfig(e){return void 0!==this.config[e]?this.config[e]:this.defaultConfig[e]}templateExists(e){return!("string"!=typeof e||!e.includes("{{")&&!e.includes("{%"))}haSwitch(e,t,o,n,i,r){const a=html(_templateObject9(),localize("editor.disabled_template")),s=html(_templateObject10(),localize("editor.removes_edit_ui"));let c=ha_elements().hass.config.version.split(".");return c=parseInt(c[0]+c[1]),c>111?html(_templateObject11(),this.exception&&void 0===this.config[e]?"inherited slotted":"slotted",!1!==this.getConfig(e)&&!this.templateExists(this.getConfig(e)),e,this._valueChanged,i,this.templateExists(this.getConfig(e)),i,n,this.templateExists(this.getConfig(e))&&t?a:"",o?s:""):html(_templateObject12(),this.exception&&void 0===this.config[e]?"inherited slotted":"slotted",!1!==this.getConfig(e)&&!this.templateExists(this.getConfig(e)),e,this._valueChanged,i,this.templateExists(this.getConfig(e)),n,this.templateExists(this.getConfig(e))&&t?a:"",o?s:"")}render(){return this.exception=void 0!==this.exception&&!1!==this.exception,html(_templateObject13(),this.exception?"":html(_templateObject14(),localize("links.docs"),localize("links.forums"),this.getConfig("editor_warnings")?html(_templateObject15(),localize("editor.warning_disable_ch"),localize("editor.warning_jinja_info"),localize("editor.warning_already_a_template"),localize("editor.warning_edit_ui")):"",!this.exception&&this.getConfig("editor_warnings")?this.haSwitch("editor_warnings",!1,!1,localize("editor.editor_warnings_title"),localize("editor.editor_warnings_tip")):""),this.renderStyle(),this.getConfig("editor_warnings")&&!this.exception?html(_templateObject16()):"",this.haSwitch("disabled_mode",!0,!1,localize("editor.disabled_mode_title"),localize("editor.disabled_mode_tip")),this.haSwitch("footer_mode",!0,!1,localize("editor.footer_mode_title"),localize("editor.footer_mode_tip")),this.haSwitch("compact_mode",!0,!1,localize("editor.compact_mode_title"),localize("editor.compact_mode_tip")),this.haSwitch("split_mode",!0,!1,localize("editor.split_mode_title"),localize("editor.split_mode_tip")),this.haSwitch("kiosk_mode",!0,!0,localize("editor.kiosk_mode_title"),localize("editor.kiosk_mode_tip")),this.haSwitch("disable_sidebar",!0,!1,localize("editor.disable_sidebar_title"),localize("editor.disable_sidebar_tip")),this.haSwitch("hide_header",!0,!1,localize("editor.hide_header_title"),localize("editor.hide_header_tip")),this.haSwitch("chevrons",!0,!1,localize("editor.chevrons_title"),localize("editor.chevrons_tip")),this.haSwitch("hidden_tab_redirect",!0,!1,localize("editor.hidden_tab_redirect_title"),localize("editor.hidden_tab_redirect_tip")),this.haSwitch("shadow",!0,!1,localize("editor.shadow_title"),localize("editor.shadow_tip")),this.exception?"":this.haSwitch("restrict_users",!0,!1,localize("editor.restrict_users_title"),localize("editor.restrict_users_tip")),this.exception||this.getConfig("editor_warnings")?"":this.haSwitch("editor_warnings",!1,!1,localize("editor.editor_warnings_second_title"),localize("editor.editor_warnings_tip")),this.exception&&void 0===this.config.header_text?"inherited slotted":"slotted",localize("editor.header_text"),this.getConfig("header_text"),"header_text",this._valueChanged,localize("editor.automatic"),this.exception&&void 0===this.config.locale?"inherited slotted":"slotted",localize("editor.locale_desc"),this.getConfig("locale"),"locale",this._valueChanged,localize("editor.menu_items"),this.haSwitch("hide_config",!0,!0,localize("editor.hide_configure_ui_title"),localize("editor.hide_configure_ui_tip")),this.haSwitch("hide_raw",!0,!0,localize("editor.hide_raw_editor_title"),localize("editor.hide_raw_editor_tip")),this.haSwitch("hide_help",!0,!1,localize("editor.hide_help_title"),localize("editor.hide_help_tip")),this.haSwitch("hide_unused",!0,!1,localize("editor.hide_unused_title"),localize("editor.hide_unused_tip")),this.haSwitch("hide_ch_settings",!0,!0,localize("editor.hide_ch_settings"),localize("editor.hide_ch_settings")),localize("editor.buttons"),this.haSwitch("menu_hide",!0,!1,localize("editor.menu_hide_title"),localize("editor.menu_hide_tip")),this.haSwitch("menu_dropdown",!0,!1,localize("editor.menu_dropdown_title"),localize("editor.menu_dropdown_tip")),this.haSwitch("voice_hide",!0,!1,localize("editor.voice_hide_title"),localize("editor.voice_hide_tip")),this.haSwitch("voice_dropdown",!0,!1,localize("editor.voice_dropdown_title"),localize("editor.voice_dropdown_tip")),this.haSwitch("options_hide",!0,!0,localize("editor.options_hide_title"),localize("editor.options_hide_tip")),this.haSwitch("reverse_button_direction",!0,!1,localize("editor.reverse_button_title"),localize("editor.reverse_button_tip")),localize("editor.tabs"),this._tabVisibility,this.getConfig("show_tabs").length>0?"1":"0",localize("editor.tabs_hide"),localize("editor.tabs_show"),this.getConfig("show_tabs").length>0?"initial":"none",this.exception&&void 0===this.config.show_tabs?"inherited slotted":"slotted",localize("editor.show_tab_list"),this.getConfig("show_tabs"),"show_tabs",this._valueChanged,this.getConfig("show_tabs").length>0?"none":"initial",this.exception&&void 0===this.config.hide_tabs?"inherited slotted":"slotted",localize("editor.hide_tab_list"),this.getConfig("hide_tabs"),"hide_tabs",this._valueChanged,this.exception&&void 0===this.config.default_tab?"inherited slotted":"slotted",localize("editor.default_tab"),this.exception?' (use "null" to override default)':"",this.getConfig("default_tab"),"default_tab",this._valueChanged,this.haSwitch("tab_icons_and_text",!0,!1,localize("editor.tab_icons_and_text_title"),localize("editor.tab_icons_and_text_tip")),this.haSwitch("reverse_tab_direction",!0,!1,localize("editor.reverse_tab_title"),localize("editor.reverse_tab_tip")),this.haSwitch("tab_text_only",!0,!1,localize("editor.tab_text_only_title"),localize("editor.tab_text_only_tip")))}_toggleCard(){this._closed=!this._closed,x(this,"iron-resize")}_tabVisibility(){const e=this.shadowRoot.querySelector("#show"),t=this.shadowRoot.querySelector("#hide");"Hide Tabs"==this.shadowRoot.querySelector("#tabs").value?(e.style.display="none",t.style.display="initial"):(t.style.display="none",e.style.display="initial")}_valueChanged(e){this.config&&(e.target.configValue&&(""===e.target.value?delete this.config[e.target.configValue]:this.config=_objectSpread2(_objectSpread2({},this.config),{},{[e.target.configValue]:void 0!==e.target.checked?e.target.checked:e.target.value})),x(this,"ch-config-changed",{config:this.config}))}renderStyle(){return html(_templateObject17())}});customElements.define("ch-exception-editor",class ChExceptionEditor extends LitElement{static get properties(){return{config:{},exception:{},_closed:{}}}constructor(){super(),this._closed=!0}render(){return this.exception?html(_templateObject19(),this.renderStyle(),this._closed,Object.values(this.exception.conditions).join(", ").substring(0,40)||"New Exception",this._closed?"mdi:chevron-down":"mdi:chevron-up",this._toggleCard,this._closed,this._deleteException,localize("editor.conditions"),this.exception.conditions,this._conditionsChanged,localize("editor.config"),_objectSpread2(_objectSpread2({},this.defaultConfig),this.config),this.exception.config,this._configChanged):html(_templateObject18())}renderStyle(){return html(_templateObject20())}_toggleCard(){this._closed=!this._closed,x(this,"iron-resize")}_deleteException(){x(this,"ch-exception-delete")}_conditionsChanged(e){let{detail:t}=e;if(!this.exception)return;const o=_objectSpread2(_objectSpread2({},this.exception),{},{conditions:t.conditions});x(this,"ch-exception-changed",{exception:o})}_configChanged(e){if(e.stopPropagation(),!this.exception)return;const t=_objectSpread2(_objectSpread2({},this.exception),{},{config:e.detail.config});x(this,"ch-exception-changed",{exception:t})}});customElements.define("ch-conditions-editor",class ChConditionsEditor extends LitElement{static get properties(){return{conditions:{}}}get _user(){return this.conditions.user||""}get _user_agent(){return this.conditions.user_agent||""}get _media_query(){return this.conditions.media_query||""}get _query_string(){return this.conditions.query_string||""}get _template(){return this.conditions.template||""}get _tab(){return this.conditions.tab||""}get _device_id(){return this.conditions.device_id||""}render(){return this.conditions?html(_templateObject22(),localize("editor.user_list"),this._user,"user",this._valueChanged,localize("editor.user_agent"),this._user_agent,"user_agent",this._valueChanged,localize("editor.media_query"),this._media_query,"media_query",this._valueChanged,localize("editor.query_string"),this._query_string,"query_string",this._valueChanged,localize("editor.template"),this._template,"template",this._valueChanged,localize("editor.tabs"),this._tab,"tab",this._valueChanged,this._device_id,"device_id",this._valueChanged):html(_templateObject21())}_valueChanged(e){if(!this.conditions)return;const t=e.target;this["_".concat(t.configValue)]!==t.value&&(t.configValue&&(""===t.value?delete this.conditions[t.configValue]:this.conditions=_objectSpread2(_objectSpread2({},this.conditions),{},{[t.configValue]:t.value})),x(this,"ch-conditions-changed",{conditions:this.conditions}))}});const hideMenuItems=(e,t,o,n)=>{const localized=(e,t)=>{let o;const n=document.querySelector("home-assistant").hass;return o="raw_editor"===t?n.localize("ui.panel.lovelace.editor.menu.raw_editor"):"unused_entities"==t?n.localize("ui.panel.lovelace.unused_entities.title"):n.localize("ui.panel.lovelace.menu.".concat(t))||t,e.innerHTML.includes(o)||e.getAttribute("aria-label")==o};let i=o?n.options:t.options;i=i.querySelector("paper-listbox")?i.querySelector("paper-listbox"):i,i.querySelectorAll("mwc-list-item, paper-item").forEach(t=>{e.hide_help&&localized(t,"help")||e.hide_unused&&localized(t,"unused_entities")||e.hide_refresh&&localized(t,"refresh")||e.hide_config&&localized(t,"configure_ui")||e.hide_raw&&localized(t,"raw_editor")||e.hide_reload_resources&&localized(t,"reload_resources")?t.style.display="none":t.style.display=""})},buttonToOverflow=(e,t,o,n)=>{o.options.querySelector("#".concat(e.toLowerCase(),"_dropdown"))&&o.options.querySelector("#".concat(e.toLowerCase(),"_dropdown")).remove();let i=document.createElement("paper-item");o.options.querySelector("mwc-list-item")&&(i=document.createElement("mwc-list-item"));const r=document.createElement("ha-icon");i.setAttribute("id","".concat(e.toLowerCase(),"_dropdown")),r.setAttribute("icon",n.button_icons[e.toLowerCase()]||t),r.style.pointerEvents="none",n.reverse_button_direction?r.style.marginLeft="auto":r.style.marginRight="auto",i.innerText=e,i.appendChild(r),i.addEventListener("click",()=>{o[e.toLowerCase()].dispatchEvent(new MouseEvent("click",{bubbles:!1,cancelable:!1}))}),r.addEventListener("click",()=>{o[e.toLowerCase()].dispatchEvent(new MouseEvent("click",{bubbles:!1,cancelable:!1}))}),i.setAttribute("onClick"," "),r.setAttribute("onClick"," "),o.options.querySelector("mwc-list-item")?o.options.appendChild(i):o.options.querySelector("paper-listbox").appendChild(i)},insertSettings=(e,t,o)=>{if("storage"===o.lovelace.mode){let t=document.createElement("paper-item");e.options.querySelector("mwc-list-item")&&(t=document.createElement("mwc-list-item")),t.setAttribute("id","ch_settings"),t.addEventListener("click",()=>(e=>{if(window.scrollTo(0,0),!e.root.querySelector("ha-app-layout editor")){const t=document.createElement("editor"),o=document.createElement("div");o.style.cssText="\n      padding: 20px;\n      max-width: 600px;\n      margin: 15px auto;\n      background: var(--paper-card-background-color);\n      border: 6px solid var(--paper-card-background-color);\n    ",t.style.cssText="\n      width: 100%;\n      min-height: 100%;\n      box-sizing: border-box;\n      position: absolute;\n      background: var(--background-color, grey);\n      z-index: 101;\n      padding: 5px;\n    ",e.root.querySelector("ha-app-layout").insertBefore(t,e.root.querySelector("#view")),t.appendChild(o),o.appendChild(document.createElement("custom-header-editor"))}})(o)),t.setAttribute("onClick"," "),t.innerHTML="Custom Header",e.options.querySelector("mwc-list-item")?(e.options.querySelector("#ch_settings")||e.options.appendChild(t),o.options.querySelector("#ch_settings")||o.options.appendChild(t)):e.options.querySelector("paper-listbox")&&(e.options.querySelector("paper-listbox").querySelector("#ch_settings")||e.options.querySelector("paper-listbox").appendChild(t),o.options.querySelector("paper-listbox").querySelector("#ch_settings")||o.options.querySelector("paper-listbox").appendChild(t))}},conditionalConfig=e=>{const t=ha_elements().hass;let o=document.querySelector("body > home-assistant").shadowRoot.querySelector("home-assistant-main").shadowRoot.querySelector("app-drawer-layout > partial-panel-resolver > ha-panel-lovelace").lovelace;let n={},i=0;return e.exceptions&&e.exceptions.forEach(e=>{const r=(e=>{const n={user:t.user.name,user_agent:navigator.userAgent,device_id:q};let i=0;for(const r in e)if(window.customHeaderTabCond=!!Object.keys(e).includes("tab"),"user"==r&&e[r].includes(","))e[r].split(/,+/).forEach(e=>{n[r].toUpperCase()!=e.toUpperCase().trim()&&e.toUpperCase()!=t.user.id.toUpperCase()||i++});else if("tab"==r&&(e[r].includes(",")||e[r].includes("to"))){const t=processTabArray(e[r]);if(o&&t.includes(o.current_view)){i++;continue}}else{if(!(n[r]==e[r]||"string"==typeof e[r]&&n[r]&&n[r].toUpperCase()==e[r].toUpperCase()||"query_string"==r&&window.location.search.includes(e[r])||"user_agent"==r&&n[r].toUpperCase().includes(e[r].toUpperCase())||"media_query"==r&&window.matchMedia(e[r]).matches||"user"==r&&e[r].toUpperCase()==t.user.id.toUpperCase()||"is_admin"==r&&e[r]==t.user.is_admin||"is_owner"==r&&e[r]==t.user.is_owner||"template"==r&&e[r]||o&&"tab"==r&&tabIndexByName(e[r])==o.current_view))return 0;i++}return i})(e.conditions);r>i&&(i=r,n=e.config)}),n&&n.default_tab&&(null==n.default_tab||"null"==n.default_tab)&&(e.default_tab=[]),n&&(void 0!==n.hide_tabs&&e.show_tabs&&n.hide_tabs.length&&e.show_tabs.length?delete e.show_tabs:n.show_tabs&&e.hide_tabs&&n.show_tabs.length&&e.hide_tabs.length&&delete e.hide_tabs),_objectSpread2(_objectSpread2({},e),n)},kioskMode=(e,t,o,n)=>{if((window.location.href.includes("disable_ch")||window.customHeaderDisabled)&&(e.hass.user.is_admin||e.hass.user.is_owner||!n.restrict_users))return;let i=document.createElement("style");i.setAttribute("id","ch_header_style"),o||(i.innerHTML+="\n        #drawer {\n          display: none;\n        }\n      "),t||(i.innerHTML+="\n        ch-header {\n          display: none;\n        }\n        ch-footer {\n          display: none;\n        }\n        app-header {\n          display: none;\n        }\n        hui-view {\n          padding-top: 100px;\n        }\n        hui-view, hui-panel-view {\n          min-height: calc(100vh + 96px);\n          margin-top: -96px;\n        }\n      ");const r=e.root.querySelector("#ch_header_style");r&&r.innerText==i.innerHTML||(e.root.appendChild(i),r&&r.remove()),n.hide_tabs&&n.hide_tabs.forEach(e=>{i.innerHTML+="\n        paper-tab:nth-child(".concat(tabIndexByName(e)+1,") {\n          display: none;\n        }\n      ")}),o||(e.drawer.style.display="none",e.sidebar.main.querySelector("#ch_sidebar_style")||(i=document.createElement("style"),i.setAttribute("id","ch_sidebar_style"),i.innerHTML=":host(:not([expanded])) {width: 0px !important;}",e.sidebar.main.appendChild(i)),e.main.querySelector("#ch_sidebar_style")||(i=document.createElement("style"),i.setAttribute("id","ch_sidebar_style"),i.innerHTML=":host {--app-drawer-width: 0px !important;}",e.main.appendChild(i))),window.dispatchEvent(new Event("resize"))},removeKioskMode=e=>{e.drawer.style.display="";let t=e.main.querySelector("#ch_sidebar_style");t&&t.remove(),t=e.sidebar.main.querySelector("#ch_sidebar_style"),t&&t.remove(),e.drawer.style.display=""},menuButtonObservers=(e,t,o)=>{if(e.menu_hide)return;const n=o.menu.shadowRoot.querySelector("mwc-icon-button"),buildDot=()=>{const t=document.createElement("div");return t.className="dot",t.style.cssText="\n        pointer-events: none;\n        position: relative;\n        background-color: ".concat(e.notification_dot_color,";\n        width: 12px;\n        height: 12px;\n        top: ").concat(n?"-35px;":"-28px;","\n        right: ").concat(e.reverse_button_direction?"":"-").concat(n?"27px;":"16px;","\n        border-radius: 50%;\n    "),t},menuButtonVisibility=()=>{e.disable_sidebar||window.customHeaderDisabled||e.menu_dropdown||e.menu_hide||("hidden"===o.menu.style.visibility?(t.header.menu.style.display="none",t.footer.tabContainer.style.margin="0 10px"):(t.header.menu.style.display="initial",t.footer.tabContainer.style.margin="0"))};if(window.customHeaderMenuObservers){for(const e of window.customHeaderMenuObservers)e.disconnect();window.customHeaderMenuObservers=[]}const i=new MutationObserver(t=>{const o=document.querySelector("home-assistant").shadowRoot.querySelector("home-assistant-main").shadowRoot.querySelector("ha-panel-lovelace").shadowRoot.querySelector("hui-root");t.forEach(t=>{let{addedNodes:n,removedNodes:i}=t;if(n)for(const t of n)"dot"!==t.className||o.shadowRoot.querySelector('[buttonElem="menu"]').shadowRoot.querySelector(".dot")||(o.shadowRoot.querySelector('[buttonElem="menu"]').shadowRoot.appendChild(buildDot()),o.shadowRoot.querySelector('[buttonElem="menu"]').shadowRoot.querySelector(".buttonText")&&(o.shadowRoot.querySelector('[buttonElem="menu"]').shadowRoot.querySelector(".dot").style.display="none",o.shadowRoot.querySelector('[buttonElem="menu"]').shadowRoot.querySelector(".buttonText").style.borderBottom="3px solid ".concat(e.notification_dot_color)));if(i)for(const e of i)"dot"===e.className&&o.shadowRoot.querySelector('[buttonElem="menu"]').shadowRoot.querySelector(".dot")&&(o.shadowRoot.querySelector('[buttonElem="menu"]').shadowRoot.querySelector(".dot").remove(),o.shadowRoot.querySelector('[buttonElem="menu"]').shadowRoot.querySelector(".buttonText")&&(o.shadowRoot.querySelector('[buttonElem="menu"]').shadowRoot.querySelector(".buttonText").style.borderBottom=""))})});i.observe(o.menu.shadowRoot,{childList:!0});const r=new MutationObserver(menuButtonVisibility);r.observe(o.menu,{attributes:!0,attributeFilter:["style"]}),window.customHeaderMenuObservers=[i,r],menuButtonVisibility();const a=t.header.menu.shadowRoot.querySelector(".dot");a&&a.style.cssText!=buildDot().style.cssText&&(a.remove(),e.button_text.menu&&(t.header.menu.shadowRoot.querySelector(".buttonText").style.textDecoration="")),!t.header.menu.shadowRoot.querySelector(".dot")&&o.menu.shadowRoot.querySelector(".dot")&&(t.header.menu.shadowRoot.appendChild(buildDot()),e.button_text.menu&&(t.header.menu.shadowRoot.querySelector(".dot").style.display="none",t.header.menu.shadowRoot.querySelector(".buttonText").style.borderBottom="3px solid ".concat(e.notification_dot_color)))},insertStyleTags=(e,t,o)=>{let n=48;const i=e.split_mode?t.footer:t.header;e.compact_mode||(e.reverse_button_direction?(t.header.container.querySelector("#ch-content-container").dir="ltr",t.header.container.querySelector("#ch-content-container").style.textAlign="right"):(t.header.container.querySelector("#ch-content-container").style.textAlign="",t.header.container.querySelector("#ch-content-container").dir=""),t.header.container.querySelector("#ch-content-container").innerHTML=e.header_text,n=i.tabs.length?96:48);let r=document.createElement("style");r.setAttribute("id","ch_header_style"),r.innerHTML="\n      ch-header {\n        z-index: 100;\n        padding-left: 10px;\n        padding-right: 10px;\n        box-sizing: border-box;\n        display:flex;\n        justify-content: center;\n        font: 400 20px Roboto, sans-serif;\n        background: ".concat(e.background||"var(--primary-color)",";\n        color: ").concat(e.elements_color||"var(--text-primary-color)",";\n        margin-bottom: 0px;\n        position: sticky;\n        position: -webkit-sticky;\n        ").concat(e.footer_mode?"bottom: 0px;":"top: 0px;","\n        ").concat(e.header_css?e.header_css:"","\n        transition: box-shadow 0.3s ease-in-out;\n        ").concat(e.shadow&&e.split_mode?"box-shadow: 0px 0px 5px 5px rgba(0,0,0,0.2)":"","\n        ").concat(e.footer_mode?"margin-top:48px;margin-bottom:-48px;padding-bottom:4px;":"","\n      }\n      ch-footer {\n        z-index: 99;\n        padding-left: 3px;\n        padding-right: 3px;\n        box-sizing: border-box;\n        display:flex;\n        justify-content: center;\n        font: 400 20px Roboto, sans-serif;\n        background: ").concat(e.background||"var(--primary-color)",";\n        color: ").concat(e.elements_color||"var(--text-primary-color)",";\n        margin-bottom: 0px;\n        margin-top: 0px;\n        position: sticky;\n        position: -webkit-sticky;\n        ").concat(e.footer_mode&&e.split_mode?"top: 0px;":"bottom: 0px;","\n        ").concat(e.footer_mode?"bottom: 48px;":"","\n        ").concat(e.header_css?e.header_css:"","\n        ").concat(e.shadow&&e.split_mode?"box-shadow: 0px 0px 5px 5px rgba(0,0,0,0.2)":"","\n        transition: box-shadow 0.3s ease-in-out;\n        ").concat(e.shadow&&(e.footer_mode||e.split_mode)?"box-shadow: 0px 0px 5px 5px rgba(0,0,0,0.2)":"","\n      }\n      ch-stack {\n        flex-direction: column;\n        width: 100%;\n        margin-left: 9px;\n        margin-right: 9px;\n        ").concat(e.stack_css?e.stack_css:"","\n      }\n\n      #ch-content-container {\n        ").concat(e.compact_mode?"display: none;":"","\n        ").concat(e.header_text.includes("<br>")?"\n          font-size: 17px;\n          line-height: 1.2;\n          margin: -9px 0px 0px;\n        ":"","\n        ").concat(e.header_text_css?e.header_text_css:"","\n        ").concat(e.menu_dropdown||e.disable_sidebar||e.hide_menu?"padding: 12px 0px;":"padding: 12px 6px;","\n      }\n      app-header {\n        display: none;\n      }\n      paper-tab.iron-selected {\n        ").concat(e.active_tab_color?"color: ".concat(e.active_tab_color,";"):"","\n        ").concat(e.active_tab_css?e.active_tab_css:"",'\n      }\n      [buttonElem="menu"] {\n        ').concat(e.menu_color?"color: ".concat(e.menu_color,";"):"","\n        ").concat(e.menu_hide?"display: none;":"","\n        ").concat(e.menu_css?e.menu_css:"","\n        ").concat(e.footer_mode&&e.compact_mode?"margin-top:0 !important;":"",'\n      }\n      [buttonElem="options"] {\n        ').concat(e.options_color?"color: ".concat(e.options_color,";"):"","\n        ").concat(e.options_hide?"display: none;":"","\n        ").concat(e.options_css?e.options_css:"","\n        ").concat(e.footer_mode&&e.compact_mode?"margin-top:0 !important;":"",'\n      }\n      [buttonElem="voice"] {\n        ').concat(e.voice_color?"color: ".concat(e.voice_color,";"):"","\n        ").concat(e.voice_hide?"display: none;":"","\n        ").concat(e.voice_css?e.voice_css:"","\n        ").concat(e.footer_mode&&e.compact_mode?"margin-top:0 !important;":"","\n      }\n      paper-tab {\n        ").concat(e.all_tabs_color?"color: ".concat(e.all_tabs_color,";"):"","\n        ").concat(e.all_tabs_css?e.all_tabs_css:"","\n      }\n      paper-tabs {\n        padding: 0 4px;\n        ").concat(e.tab_indicator_color?"--paper-tabs-selection-bar-color: ".concat(e.tab_indicator_color," !important;"):"","\n        ").concat(e.tab_container_css?e.tab_container_css:"","\n      }\n    "),e.tabs_color&&Object.keys(e.tabs_color).forEach(t=>{r.innerHTML+="\n        paper-tab:nth-child(".concat(tabIndexByName(t)+1,") {\n          color: ").concat(e.tabs_color[t],";\n        }\n      ")}),e.hide_tabs&&e.hide_tabs.forEach(e=>{r.innerHTML+="\n        paper-tab:nth-child(".concat(tabIndexByName(e)+1,") {\n          display: none;\n        }\n      ")}),e.tabs_css&&Object.keys(e.tabs_css).forEach(t=>{r.innerHTML+="\n        paper-tab:nth-child(".concat(tabIndexByName(t)+1,") {\n          ").concat(e.tabs_css[t],";\n        }\n      ")});let a=o.root.querySelector("#ch_header_style");a&&r.innerHTML==a.innerHTML||(o.root.appendChild(r),a&&a.remove()),r=document.createElement("style"),r.setAttribute("id","ch_view_style"),r.innerHTML="\n        hui-view, hui-panel-view {\n          margin-top: -96px;\n          ".concat(e.compact_mode?"min-height: calc(100vh - 96px);":"min-height: calc(100vh - 112px);","\n          ").concat(e.footer_mode&&!e.split_mode?"padding-bottom: ".concat(n,"px;"):"","\n          ").concat(e.footer_mode&&!e.split_mode?"margin-bottom: -".concat(n+4,"px;"):"","\n          ").concat(e.split_mode?"padding-bottom: 48px;":"","\n          ").concat(e.split_mode&&e.footer_mode?"margin-bottom: -4px;":"","\n        }\n        hui-panel-view {\n          padding-top: 96px;\n          ").concat(e.panel_view_css?e.panel_view_css:"","\n          ").concat(e.kiosk_mode||e.hide_header?"min-height: 100vh !important; margin-bottom: 0 !important;":"","\n        }\n        hui-view {\n          padding-top: 100px;\n          ").concat(e.view_css?e.view_css:"","\n        }\n        #view {\n          min-height: calc(100vh - 96px) !important;\n          ").concat(e.footer_mode&&!e.split_mode?"min-height: calc(100vh - ".concat(n,"px) !important;"):"","\n          ").concat(e.compact_mode&&!e.footer_mode?"min-height: calc(100vh - ".concat(n,"px) !important;"):"","\n          ").concat(e.split_mode?"min-height: calc(100vh - 48px) !important; margin-bottom: -48px;":"","\n          ").concat(e.split_mode&&e.footer_mode?"min-height: calc(100vh - 52px) !important; margin-bottom: -48px;":"","\n          ").concat(e.kiosk_mode||e.hide_header?"min-height: 100vh !important;":"","\n          ").concat(e.footer_mode?"min-height: calc(100vh - 100px) !important;":"","\n\n        }\n        #view.tabs-hidden {\n          min-height: calc(100vh - 48px) !important;\n        }\n      "),a=o.root.querySelector("#ch_view_style"),a&&r.innerHTML==a.innerHTML||(o.root.appendChild(r),a&&a.remove()),r=document.createElement("style"),r.setAttribute("id","ch_chevron"),r.innerHTML='\n      .not-visible[icon*="chevron"] {\n        display:none;\n      }\n    ',a=i.tabContainer.shadowRoot.querySelector("#ch_chevron"),i.tabContainer.shadowRoot.appendChild(r),a&&a.remove(),a=t.footer.tabContainer.shadowRoot.querySelector("#ch_chevron"),t.footer.tabContainer.shadowRoot.appendChild(r.cloneNode(!0)),a&&a.remove()},redirects=(e,t)=>{if(window.customHeaderDisabled)return;const o=ha_elements();if(!o)return;const n=e.compact_mode?t.header:t.footer,i=o.sidebar.listbox.querySelector('[data-panel="lovelace"]');if(i)if(e.hide_tabs.includes(0)&&!e.default_tab){for(const e of n.tabs)if("none"!=getComputedStyle(e).display){i.setAttribute("href","/lovelace/".concat(n.tabContainer.indexOf(e)));break}}else e.default_tab&&i.setAttribute("href","/lovelace/".concat(tabIndexByName(e.default_tab)));const r=null!=e.default_tab?tabIndexByName(e.default_tab):null;if(e.hidden_tab_redirect&&o.tabs.length){const t=o.tabContainer.indexOf(o.tabContainer.querySelector("paper-tab.iron-selected"));if(e.hide_tabs.includes(t)&&e.hide_tabs.length!=o.tabs.length)if(r&&!e.hide_tabs.includes(tabIndexByName(r)))"none"!=getComputedStyle(n.tabs[r]).display&&(o.tabs[r].dispatchEvent(new MouseEvent("click",{bubbles:!1,cancelable:!1})),i&&i.setAttribute("href","/lovelace/".concat(r)));else for(const e of n.tabs)if("none"!=getComputedStyle(e).display){e.dispatchEvent(new MouseEvent("click",{bubbles:!1,cancelable:!1})),i&&i.setAttribute("href","/lovelace/".concat(n.tabContainer.indexOf(e)));break}}let a;a=!e.default_tab_on_refresh&&window.performance?0==performance.navigation.type:!(e.default_tab_on_refresh||!performance.getEntriesByType("navigation"))&&"reload"==performance.getEntriesByType("navigation")[0].type,a||null==r||window.customHeaderDefaultClicked||!o.tabs[r]||(o.tabs[r].dispatchEvent(new MouseEvent("click",{bubbles:!1,cancelable:!1})),window.customHeaderDefaultClicked=!0)};class CustomHeaderConfig{static buildConfig(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:J();window.chHeader=e,window.customHeaderUnsub||(window.customHeaderUnsub=[]);const o=ha_elements();if(!t||!o)return;this.default_config=defaultConfig(),this.config=_objectSpread2(_objectSpread2({},this.default_config),t.config.custom_header),this.template_vars=this.config.template_variables,this.test_config=_objectSpread2(_objectSpread2({},this.config),conditionalConfig(this.config,ha_elements())),this.template_failed=!1,this.disabled="boolean"==typeof this.test_config.disabled_mode&&this.test_config.disabled_mode||"string"==typeof this.test_config.disabled_mode&&!this.test_config.disabled_mode.includes("{{")&&!this.test_config.disabled_mode.includes("{%")||window.location.href.includes("disable_ch");const n=o.hass.user;n.is_admin||n.is_owner||!this.test_config.restrict_users||(this.disabled=!1),this.renderTemplate(e,ha_elements()),this.catchTemplate()}static renderTemplate(e,t){if(this.disabled)this.config=conditionalConfig(this.config,ha_elements()),this.processAndContinue(e,ha_elements());else{const o=JSON.stringify(this.template_vars).replace(/\\/g,""),n=JSON.stringify(this.config).replace(/\\/g,"");this.unsub=subscribeRenderTemplate(o=>{try{o=(o=(o=o.replace(/"true"/gi,"true")).replace(/"false"/gi,"false")).replace(/""/,""),this.config=JSON.parse(o),this.config=conditionalConfig(this.config)}catch(e){this.template_failed=!0,this.helpfulTempError(o,e)}if(JSON.stringify(window.last_template_result)==JSON.stringify(this.config))return this.changed=!1,insertSettings(e.header,this.config,t),void redirects(this.config,e);clearTimeout(window.customHeaderTempTimeout),this.changed=!0,window.last_template_result=this.config,this.processAndContinue(e,t)},{template:o+n},this.config.locale)}}static helpfulTempError(e,t){let o,n=t.toString().match(/\d+/g);if(n){n=t.toString().match(/\d+/g)[0];const i=e.substr(0,n).match(/[^,]*$/),r=e.substr(n).match(/^[^,]*/);o="".concat(i?i[0]:"").concat(r?r[0]:"").replace('":"',': "'),o="[CUSTOM-HEADER] There was an issue with the template: ".concat(o)}o&&o.includes("locale")&&(o='[CUSTOM-HEADER] There was an issue one of your "template_variables".'),o&&console.log(o)}static catchTemplate(){var e=this;return function _asyncToGenerator(e){return function(){var t=this,o=arguments;return new Promise((function(n,i){var r=e.apply(t,o);function _next(e){asyncGeneratorStep(r,n,i,_next,_throw,"next",e)}function _throw(e){asyncGeneratorStep(r,n,i,_next,_throw,"throw",e)}_next(void 0)}))}}((function*(){try{const t=yield e.unsub;if(e.changed){for(const e of window.customHeaderUnsub)e();window.customHeaderUnsub=[],window.customHeaderUnsub.push(t)}else t()}catch(t){if(e.template_failed=!0,e.disabled)return;console.log("[CUSTOM-HEADER] There was an error with one or more of your templates:"),console.log("".concat(t.message.substring(0,t.message.indexOf(")")),")"))}}))()}static processAndContinue(e,t){let o=this.config;if(o.disabled_mode?o={disabled_mode:!0}:(o.hide_tabs&&(o.hide_tabs=processTabArray(o.hide_tabs)),o.show_tabs&&(o.show_tabs=processTabArray(o.show_tabs)),o.show_tabs&&o.show_tabs.length&&(o.hide_tabs=(e=>{if(e&&e.length){const t=[],o=ha_elements();if(!o||!o.tabs)return[];for(let e=0;e<o.tabs.length;e+=1)t.push(e);return t.filter(t=>!e.includes(t))}})(o.show_tabs)),(o.disable_sidebar||o.menu_dropdown)&&(o.menu_hide=!0),!o.voice_dropdown&&t.hass.config.components.includes("conversation")||(o.voice_hide=!0),null!=o.header_text&&""==o.header_text&&(o.header_text=this.default_config.header_text),o.header_text&&" "==o.header_text&&(o.header_text="&nbsp;"),o.split_mode&&(o.compact_mode=!1),o.hide_header&&o.disable_sidebar&&(o.kiosk_mode=!0,o.hide_header=!1,o.disable_sidebar=!1),null!=o.test_template&&(this.disabled?console.log("Custom Header cannot render templates while disabled."):"string"==typeof o.test_template&&(o.test_template.toLowerCase().includes("true")||o.test_template.toLowerCase().includes("false"))?(console.log('Custom Header test returned: "'.concat(o.test_template,'"')),console.log("Warning: Boolean is returned as string instead of Boolean.")):"string"==typeof o.test_template?console.log('Custom Header test returned: "'.concat(o.test_template,'"')):console.log("Custom Header test returned: ".concat(o.test_template)))),window.customHeaderTempTimeout)for(const e of window.customHeaderTempTimeout)clearTimeout(e);window.customHeaderTempTimeout=[];const n=window.setTimeout(()=>{if(!(t=ha_elements()))return;const o=t.panel?t.panel.shadowRoot.querySelector("hui-editor"):null;!t.panel||o||this.template_failed||t.root&&t.root.querySelector("custom-header-editor")||this.buildConfig(e)},1e3*(60-(new Date).getSeconds()));window.customHeaderTempTimeout.push(n);let i="visibilitychange";void 0!==document.msHidden?i="msvisibilitychange":void 0!==document.webkitHidden&&(i="webkitvisibilitychange");const simple_update=e=>{window.setTimeout(()=>{if(!(t=ha_elements()))return;const e=t.panel?t.panel.shadowRoot.querySelector("hui-editor"):null;!t.panel||e||this.template_failed||t.root&&t.root.querySelector("custom-header-editor")||CustomHeaderConfig.buildConfig(window.chHeader)},e)};if(window.chVisibilityAndOrientation||(window.addEventListener("orientationchange",(function(){simple_update(500)}),!1),document.addEventListener(i,(function(){simple_update(0)}),!1),window.chVisibilityAndOrientation=!0),"edit-mode"!=t.root.querySelector("app-toolbar").className){if(window.customHeaderObservers){for(const e of window.customHeaderObservers)e.disconnect();window.customHeaderObservers=[]}!function styleHeader(e,t){let o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:ha_elements();if(!o)return;window.location.href.includes("disable_ch")&&(e.disabled_mode=!0);const n=o.hass.user;if(n.is_admin||n.is_owner||!e.restrict_users?e.hide_ch_settings||insertSettings(t.header,0,o):e.disabled_mode=!1,e.disabled_mode)return window.customHeaderDisabled=!0,removeKioskMode(o),o.appHeader.style.display="",t.header.container&&(t.header.container.style.visibility="hidden"),t.footer.container&&(t.footer.container.style.visibility="hidden"),o.root.querySelector("#ch_header_style")&&o.root.querySelector("#ch_header_style").remove(),o.root.querySelector("#ch_view_style")&&o.root.querySelector("#ch_view_style").remove(),t.header.tabContainer.shadowRoot.querySelector("#ch_chevron")&&(t.header.tabContainer.shadowRoot.querySelector("#ch_chevron").remove(),t.footer.tabContainer.shadowRoot.querySelector("#ch_chevron").remove()),t.header.menu.style.display="none",o.root.querySelector("ha-menu-button").style.display="",o.sidebar.main.querySelector(".menu").style="",o.sidebar.main.querySelector("paper-listbox").style="",o.sidebar.main.querySelector("div.divider").style="",void window.dispatchEvent(new Event("resize"));window.customHeaderDisabled=!1,hideMenuItems(e,t.header,!1,o),t.header.menu.style.display="",t.header.container&&(t.header.container.style.visibility="visible"),t.footer.container&&(t.footer.container.style.visibility="visible"),e.compact_mode||e.button_scroll?(t.header.tabContainer.style.display="",t.footer.container.style.display="none"):(t.header.tabContainer.style.display="none",t.footer.container.style.display=""),e.split_mode?(t.header.tabContainer.style.display="none",e.footer_mode?t.footer.container.setAttribute("slot","header"):t.footer.container.setAttribute("slot","")):e.footer_mode?e.footer_mode&&t.footer.container.setAttribute("slot",""):t.footer.container.setAttribute("slot","header");const i=e.compact_mode||e.button_scroll?t.header:t.footer;t.header.tabs.length||(e.compact_mode=!1),e.menu_dropdown&&!e.disable_sidebar?buttonToOverflow("Menu","mdi:menu",t.header,e):t.header.options.querySelector("#menu_dropdown")&&t.header.options.querySelector("#menu_dropdown").remove(),e.voice_dropdown?buttonToOverflow("Voice","mdi:microphone",t.header,e):t.header.options.querySelector("#voice_dropdown")&&t.header.options.querySelector("#voice_dropdown").remove(),e.reverse_button_direction?(t.header.options.setAttribute("horizontal-align","left"),t.header.options.querySelector("paper-listbox")?t.header.options.querySelector("paper-listbox").setAttribute("dir","ltr"):t.header.options.setAttribute("dir","ltr")):(t.header.options.setAttribute("horizontal-align","right"),t.header.options.querySelector("paper-listbox")?t.header.options.querySelector("paper-listbox").setAttribute("dir","rtl"):t.header.options.setAttribute("dir","rtl"));const r=document.createElement("style");r.setAttribute("id","ch_header_style"),r.innerHTML="\n    .menu, paper-listbox {\n      transition: height 0.1s ease-in-out 0s;\n    }\n    .divider {\n      transition: margin-bottom 0.1s ease-in-out 0s;\n    }\n  ",o.sidebar.main.appendChild(r),e.kiosk_mode&&!e.disabled_mode?(insertStyleTags(e,t,o),kioskMode(o,!1,!1,e)):e.disable_sidebar?(kioskMode(o,!0,!1,e),insertStyleTags(e,t,o)):e.hide_header?(insertStyleTags(e,t,o),kioskMode(o,!1,!0,e)):e.disable_sidebar||e.kiosk_mode||e.hide_header||(removeKioskMode(o),e.compact_mode&&!e.footer_mode||!t.header.tabs.length?(o.sidebar.main.querySelector(".menu").style="height:49px;",o.sidebar.main.querySelector("paper-listbox").style="height:calc(100% - 175px);",o.sidebar.main.querySelector("div.divider").style=""):e.footer_mode&&!e.split_mode?(o.sidebar.main.querySelector(".menu").style="",o.sidebar.main.querySelector("paper-listbox").style="height: calc(100% - 170px);",o.sidebar.main.querySelector("div.divider").style="margin-bottom: -10px;"):e.split_mode?(o.sidebar.main.querySelector(".menu").style="height:49px;",o.sidebar.main.querySelector("paper-listbox").style="height: calc(100% - 170px);",o.sidebar.main.querySelector("div.divider").style="margin-bottom: -3px;"):(o.sidebar.main.querySelector(".menu").style="",o.sidebar.main.querySelector("paper-listbox").style="",o.sidebar.main.querySelector("div.divider").style=""),insertStyleTags(e,t,o)),e.chevrons?i.tabContainer.hideScrollButtons=!1:i.tabContainer.hideScrollButtons=!0,e.indicator_top?i.tabContainer.alignBottom=!0:i.tabContainer.alignBottom=!1,e.footer_mode?t.header.options.setAttribute("vertical-align","bottom"):t.header.options.removeAttribute("vertical-align"),e.footer_mode?t.header.container.removeAttribute("slot"):t.header.container.setAttribute("slot","header"),i.tabContainer.dir=e.reverse_tab_direction?"rtl":"ltr",t.header.container.dir=e.reverse_button_direction?"rtl":"ltr";const hideIcons=e=>{const t=document.createElement("style");t.setAttribute("id","ch_icon_style"),t.innerHTML="paper-tab:nth-child(".concat(e+1,") ha-icon{display:none;}"),i.tabs[e].appendChild(t)};if(e.tab_icons&&i.tabs.length)for(const t in e.tab_icons){const n=tabIndexByName(t);if(!i.tabs[n])continue;const r=i.tabs[n].querySelector("ha-icon");e.tab_icons[t]?r.icon=e.tab_icons[t]:r.icon=o.lovelace.config.views[n].icon;i.tabs[n].querySelector("#ch_icon_style")||"none"!=e.tab_icons[t]||hideIcons(n)}if(e.tab_text_only&&i.tabs.length)for(const e of Array.from(i.tabs)){const t=Array.from(i.tabs).indexOf(e);i.tabs[t].querySelector("#ch_icon_style")||hideIcons(t)}if(e.tab_icons_and_text&&i.tabs.length){let t="";for(const n of i.tabs){const r=Array.from(i.tabs).indexOf(n);i.tabs[r]&&(!e.tab_icons_and_text&&n.querySelector("ha-icon")||(t=o.lovelace.config.views[r].title||""),n.querySelector("p")&&(n.querySelector("p").innerHTML=t))}}if(Object.keys(e.tab_text).length&&i.tabs.length)for(const t in e.tab_text){const o=tabIndexByName(t);if(!i.tabs[o])continue;const n=i.tabs[o].querySelector("ha-icon");e.tab_text[t]&&e.tab_icons_and_text?("ltr"==i.tabContainer.dir&&n?n.style.marginRight="5px":n&&(n.style.marginLeft="5px"),i.tabs[o].querySelector("p")&&(i.tabs[o].querySelector("p").innerHTML=e.tab_text[t])):e.tab_text[t]&&i.tabs[o].querySelector("p")&&(i.tabs[o].querySelector("p").innerHTML=e.tab_text[t],n&&(i.tabs[o].querySelector("p").style.display="none"))}if((Object.keys(e.tab_text).length||e.tab_icons_and_text)&&i.tabs.length)for(const e of i.tabs){const t=e.querySelector("ha-icon");t&&e.querySelector("p")&&e.querySelector("p").innerHTML&&("ltr"==i.tabContainer.dir&&t?t.style.marginRight="5px":t&&(t.style.marginLeft="5px"))}if(e.button_icons)for(const o in e.button_icons)t.header[o]&&(e.button_icons[o]?"options"===o?t.header[o].querySelector("ha-icon-button, paper-icon-button").icon=e.button_icons[o]:t.header[o].icon=e.button_icons[o]:"menu"===o?t.header.menu.icon="mdi:menu":"voice"===o&&t.header.voice?t.header.voice.icon="mdi:microphone":"options"===o&&(t.header[o].querySelector("ha-icon-button, paper-icon-button").icon="mdi:dots-vertical"));if(e.button_text)for(const o in e.button_text){const n=document.createElement("p");n.className="buttonText";const i="options"===o?t.header[o].querySelector("ha-icon-button, paper-icon-button"):t.header[o];e.button_text[o]||!i.shadowRoot.querySelector(".buttonText")?e.button_text[o]&&(i.shadowRoot.querySelector(".buttonText")?i.shadowRoot.querySelector(".buttonText").innerHTML=e.button_text[o]:(n.innerHTML=e.button_text[o],i.shadowRoot.appendChild(n)),i.shadowRoot.querySelector(".buttonText").dir="ltr",i.shadowRoot.querySelector(".buttonText").style.textAlign="menu"==o?e.reverse_button_direction?"right":"left":e.reverse_button_direction?"left":"right",i.shadowRoot.querySelector("mwc-icon-button, iron-icon")&&(i.shadowRoot.querySelector("mwc-icon-button, iron-icon").style.display="none",i.style.width="auto",e.button_text[o].includes("<br>")?i.shadowRoot.querySelector("mwc-icon-button")?(i.shadowRoot.querySelector(".buttonText").style.fontSize="17px",i.shadowRoot.querySelector(".buttonText").style.lineHeight="1.2",i.shadowRoot.querySelector(".buttonText").style.margin="4.5px 0px 0px 0px"):(i.shadowRoot.querySelector(".buttonText").style.fontSize="17px",i.shadowRoot.querySelector(".buttonText").style.lineHeight="1.2",i.shadowRoot.querySelector(".buttonText").style.margin="-5px 0px 0px 0px"):i.shadowRoot.querySelector("mwc-icon-button")?i.shadowRoot.querySelector(".buttonText").style.margin="12px 0px 0px 0px":i.shadowRoot.querySelector(".buttonText").style.margin="5.5px 0px 0px 0px")):(i.shadowRoot.querySelector(".buttonText").remove(),i.shadowRoot.querySelector("mwc-icon-button, ha-icon, iron-icon").style.display="",i.style.width="")}i.tabs.length||(i.tabContainer.style.display="none"),menuButtonObservers(e,t,o),window.customHeaderShrink||e.split_mode||e.footer_mode||(window.customHeaderShrink=!0,window.addEventListener("scroll",(function(o){const n="none"===window.getComputedStyle(t.header.container.querySelector("#ch-content-container")).getPropertyValue("display");"0px"===window.getComputedStyle(t.header.container).getPropertyValue("bottom")||n||(e.button_scroll?(window.scrollY>48?(t.header.container.style.top="-48px",t.header.menu.style.marginTop="48px",t.header.voice&&(t.header.voice.style.marginTop="48px"),t.header.options.style.marginTop="48px"):(t.header.container.style.transition="0s",t.header.menu.style.transition="0s",t.header.voice&&(t.header.voice.style.transition="0s"),t.header.options.style.transition="0s",t.header.container.style.top="-".concat(window.scrollY,"px"),t.header.menu.style.marginTop="".concat(window.scrollY,"px"),t.header.voice&&(t.header.voice.style.marginTop="".concat(window.scrollY,"px")),t.header.options.style.marginTop="".concat(window.scrollY,"px")),t.header.container.style.transition=""):(window.scrollY>48?t.header.container.style.top="-48px":(t.header.container.style.transition="0s",t.header.container.style.top="-".concat(window.scrollY,"px")),t.header.container.style.transition=""))})));const shadowScroll=()=>{window.scrollY>15?t.footer.container.style.boxShadow="0px 0px 5px 5px rgba(0,0,0,0.2)":t.footer.container.style.boxShadow="0px 0px 5px 5px rgba(0,0,0,0)"};window.customHeaderShadow||e.footer_mode||e.split_mode||!e.shadow?window.removeEventListener("scroll",shadowScroll):(window.customHeaderShadow=!0,window.addEventListener("scroll",shadowScroll)),x(t.header.container,"iron-resize"),redirects(e,t),selectTab(e,t)}(o,e,t),((e,t,o)=>{const callback=n=>{const i=e.split_mode?t.footer:t.header;n.forEach(r=>{let{addedNodes:a,target:s}=r;if(n.length&&"HTML"==n[0].target.nodeName&&(CustomHeaderConfig.buildConfig(t),n=[]),"view"==s.id&&a.length&&i.tabs.length)"edit-mode"!=o.root.querySelector("app-toolbar").className&&(redirects(e,t),selectTab(e,t),CustomHeaderConfig.buildConfig(t));else if(a.length&&"PARTIAL-PANEL-RESOLVER"==s.nodeName)o.main.querySelector("ha-panel-lovelace")?e.compact_mode&&!e.footer_mode?(o.sidebar.main.querySelector(".menu").style="height:49px;",o.sidebar.main.querySelector("paper-listbox").style="height:calc(100% - 175px);",o.sidebar.main.querySelector("div.divider").style=""):e.footer_mode&&!e.split_mode?(o.sidebar.main.querySelector(".menu").style="",o.sidebar.main.querySelector("paper-listbox").style="height: calc(100% - 170px);",o.sidebar.main.querySelector("div.divider").style="margin-bottom: -10px;"):e.split_mode&&(o.sidebar.main.querySelector(".menu").style="height:49px;",o.sidebar.main.querySelector("paper-listbox").style="height: calc(100% - 170px);",o.sidebar.main.querySelector("div.divider").style="margin-bottom: -3px;"):(o.sidebar.main.querySelector(".menu").style="",o.sidebar.main.querySelector("paper-listbox").style="",o.sidebar.main.querySelector("div.divider").style=""),o.root.querySelector("editor")&&o.root.querySelector("editor").remove();else if("edit-mode"===s.className&&a.length)o.root.querySelector("editor")&&o.root.querySelector("editor").remove(),window.customHeaderDisabled||hideMenuItems(e,t.header,!0,o),o.appHeader.style.display="",o.root.querySelector("ch-header")&&o.root.querySelector("ch-header").remove(),o.root.querySelector("ch-footer")&&o.root.querySelector("ch-footer").remove(),o.root.querySelector("#ch_view_style")&&o.root.querySelector("#ch_view_style").remove(),o.root.querySelector("#ch_header_style")&&o.root.querySelector("#ch_header_style").remove(),o.root.querySelector("#ch_animated")&&o.root.querySelector("#ch_animated").remove(),window.dispatchEvent(new Event("resize"));else if("APP-HEADER"===s.nodeName&&a.length){let e;const wait=()=>{document.querySelector("home-assistant").shadowRoot.querySelector("home-assistant-main").shadowRoot.querySelector("ha-panel-lovelace").shadowRoot.querySelector("hui-root").shadowRoot.querySelector("ha-menu-button, paper-menu-button").shadowRoot.querySelector("mwc-icon-button, paper-icon-button")?(clearTimeout(e),rebuild()):e=window.setTimeout(()=>{wait()},200)};wait()}})},n=new MutationObserver(callback),i=new MutationObserver(callback),r=new MutationObserver(callback),a=new MutationObserver(callback);window.customHeaderObservers&&window.customHeaderObservers.length||(n.observe(o.partialPanel,{childList:!0}),i.observe(o.appHeader,{childList:!0}),r.observe(o.root.querySelector("#view"),{childList:!0}),a.observe(document.querySelector("html"),{attributes:!0})),window.customHeaderObservers=[n,i,r,a]})(o,e,t)}}}console.info(`%c  CUSTOM-HEADER  \n%c  ${localize("common.version")} 1.7.3  `,"color: orange; font-weight: bold; background: black","color: white; font-weight: bold; background: dimgray"),window.setTimeout(()=>{console.log("Current User's Name: ",C.user.name),console.log("Current User's ID: ",C.user.id),customElements.get("card-tools")||console.log("Device ID: ",q)},2e3);const hideHeader=e=>{e&&e.appHeader&&(e.appHeader.style.display="none")};window.location.href.includes("disable_ch")||hideHeader(ha_elements());const rebuild=()=>{const e=ha_elements();if(!document.querySelector("home-assistant").shadowRoot.querySelector("home-assistant-main").shadowRoot.querySelector("ha-panel-lovelace"))return;if(document.querySelector("home-assistant").shadowRoot.querySelector("home-assistant-main").shadowRoot.querySelector("ha-panel-lovelace").shadowRoot.querySelector("hui-editor")){let e;const editModeCallback=t=>{for(const o of t)for(const t of o.removedNodes)if("HUI-EDITOR"==t.nodeName){return(()=>{const e=window.setTimeout(()=>{ha_elements().root.querySelector("app-toolbar")&&clearTimeout(e)},100)})(),rebuild(),void e.disconnect()}};return e=new MutationObserver(editModeCallback),void e.observe(document.querySelector("home-assistant").shadowRoot.querySelector("home-assistant-main").shadowRoot.querySelector("ha-panel-lovelace").shadowRoot,{childList:!0,subtree:!0})}if(e&&e.root.querySelector("app-toolbar")&&"edit-mode"==e.root.querySelector("app-toolbar").className){let t;const editModeCallback=e=>{for(const o of e)for(const e of o.removedNodes)if(e.classList&&e.classList.contains("edit-mode"))return rebuild(),void t.disconnect()};return t=new MutationObserver(editModeCallback),void t.observe(e.appLayout,{childList:!0,subtree:!0})}let t;if(window.last_template_result={},clearTimeout(window.customHeaderTempTimeout),window.location.href.includes("disable_ch")||hideHeader(e),e){if(e&&e.lovelace&&e.menu){if(clearTimeout(t),window.customHeaderUnsub&&window.customHeaderUnsub.length){for(const e of window.customHeaderUnsub)e();window.customHeaderUnsub=[]}const o=new CustomHeader(e);CustomHeaderConfig.buildConfig(o),CustomHeaderConfig.buildConfig(o),rawConfigObserver()}}else t=window.setTimeout(()=>{rebuild()},100)},rawConfigObserver=()=>{const e=ha_elements();window.customHeaderRebuildMO&&window.customHeaderRebuildMO.disconnect(),window.customHeaderRawConfigExit&&window.customHeaderRawConfigExit.disconnect(),e&&e.partialPanel||window.setTimeout(()=>{rawConfigObserver()},100),window.customHeaderRebuildMO=new MutationObserver(rebuild),window.customHeaderRebuildMO.observe(document.querySelector("home-assistant").shadowRoot.querySelector("home-assistant-main").shadowRoot.querySelector("partial-panel-resolver"),{childList:!0});window.customHeaderRawConfigExit=new MutationObserver(e=>{for(const t of e)for(const e of t.removedNodes)if("HUI-EDITOR"==e.nodeName){(()=>{const e=window.setTimeout(()=>{if(document.querySelector("home-assistant").shadowRoot.querySelector("home-assistant-main").shadowRoot.querySelector("ha-panel-lovelace").shadowRoot.querySelector("hui-root").shadowRoot.querySelector("app-toolbar"))return rebuild(),void clearTimeout(e)},100)})()}}),window.customHeaderRawConfigExit.observe(document.querySelector("home-assistant").shadowRoot.querySelector("home-assistant-main").shadowRoot.querySelector("ha-panel-lovelace").shadowRoot,{childList:!0})};rebuild();export{rebuild};
  