!function(){"use strict";var e=function(){return e=Object.assign||function(e){for(var t,n=1,o=arguments.length;n0&&r[r.length-1])||6!==c[0]&&2!==c[0])){i=0;continue}if(3===c[0]&&(!r||c[1]>r[0]&&c[1]0&&r[r.length-1])||6!==c[0]&&2!==c[0])){i=0;continue}if(3===c[0]&&(!r||c[1]>r[0]&&c[1]<,])(".concat(Object.values(ue).join("|"),")($|[ \\?)+:\\}\\]><.,])"),"gm"),this._scopped=ve(e,o,i),this.refs=u,this._watchForPanelUrlChange(),this._watchForEntitiesChange(),this._watchForLanguageChange()}return e.prototype._executeRenderingFunctions=function(e){var t=this;this._subscriptions.get(e).forEach((function(e,n){e.forEach((function(e,o){t.trackTemplate(n,o,e)}))}))},e.prototype._watchForPanelUrlChange=function(){var e=this;window.addEventListener(_e.LOCATION_CHANGED,(function(){e._panelUrlWatchCallback()})),window.addEventListener(_e.POPSTATE,(function(){e._panelUrlWatchCallback()}))},e.prototype._panelUrlWatchCallback=function(){this._subscriptions.has(ue.PANEL_URL)&&this._executeRenderingFunctions(ue.PANEL_URL)},e.prototype._watchForEntitiesChange=function(){var e=this;window.hassConnection.then((function(t){t.conn.subscribeMessage((function(t){return e._entityWatchCallback(t)}),{type:_e.SUBSCRIBE_EVENTS,event_type:_e.STATE_CHANGE_EVENT})}))},e.prototype._watchForLanguageChange=function(){var e=this;window.addEventListener(_e.TRANSLATIONS_UPDATED,(function(){e._subscriptions.has(ue.LANG)&&e._executeRenderingFunctions(ue.LANG)}))},e.prototype._entityWatchCallback=function(e){if(this._subscriptions.size){var t=e.data.entity_id;this._subscriptions.has(t)&&this._executeRenderingFunctions(t)}},e.prototype._storeTracked=function(e,t,n){var o=this;this._scopped.tracked.forEach((function(r){var i=[t,n];if(o._subscriptions.has(r)){var a=o._subscriptions.get(r);if(a.has(e)){var c=a.get(e);c.has(t)||c.set.apply(c,i)}else a.set(e,new Map([i]))}else o._subscriptions.set(r,new Map([[e,new Map([i])]]))}))},e.prototype._untrackTemplate=function(e,t){var n=this;this._subscriptions.forEach((function(o,r){if(o.has(e)){var i=o.get(e);i.delete(t),0===i.size&&(o.delete(e),0===o.size&&n._subscriptions.delete(r))}}))},e.prototype.renderTemplate=function(e,t){void 0===t&&(t={});try{var n=t.variables,o=void 0===n?{}:n,r=t.refs,i=void 0===r?{}:r,a=new Map(Object.entries(ie(ie({},this._variables),o))),c=e.trim().replace(this._clientSideEntitiesRegExp,"$1clientSide.$2$3"),s=c.includes("return")||!this._autoReturn?c:"return ".concat(c);return(new(Function.bind.apply(Function,ae(ae([void 0,"hass","states","state_translated","is_state","state_attr","is_state_attr","has_value","entities","entity_prop","is_entity_prop","devices","device_attr","is_device_attr","device_id","device_name","areas","area_id","area_name","area_entities","area_devices","user_name","user_is_admin","user_is_owner","user_agent","clientSide","ref","unref",this._refsVariableName],Array.from(a.keys()),!1),["".concat('"use strict";'," ").concat(s)],!1)))).apply(void 0,ae([this._scopped.hass,this._scopped.states,this._scopped.state_translated.bind(this._scopped),this._scopped.is_state.bind(this._scopped),this._scopped.state_attr.bind(this._scopped),this._scopped.is_state_attr.bind(this._scopped),this._scopped.has_value.bind(this._scopped),this._scopped.entities,this._scopped.entity_prop,this._scopped.is_entity_prop.bind(this._scopped),this._scopped.devices,this._scopped.device_attr.bind(this._scopped),this._scopped.is_device_attr.bind(this._scopped),this._scopped.device_id.bind(this._scopped),this._scopped.device_name.bind(this._scopped),this._scopped.areas.bind(this._scopped),this._scopped.area_id.bind(this._scopped),this._scopped.area_name.bind(this._scopped),this._scopped.area_entities.bind(this._scopped),this._scopped.area_devices.bind(this._scopped),this._scopped.user_name,this._scopped.user_is_admin,this._scopped.user_is_owner,this._scopped.user_agent,this._scopped.clientSideProxy,this._scopped.ref.bind(this._scopped,this._entityWatchCallback.bind(this)),this._scopped.unref.bind(this._scopped,this.cleanTracked.bind(this)),this._scopped.refs(this._entityWatchCallback.bind(this),this.cleanTracked.bind(this),i)],Array.from(a.values()),!1))}catch(e){if(this._throwErrors)throw e;return void(this._throwWarnings&&console.warn(e))}},e.prototype.trackTemplate=function(e,t,n){var o=this;void 0===n&&(n={}),this._scopped.cleanTracked();var r=this.renderTemplate(e,n);return this._storeTracked(e,t,n),t(r),function(){return o._untrackTemplate(e,t)}},e.prototype.cleanTracked=function(e){e?this._subscriptions.has(e)&&this._subscriptions.delete(e):this._subscriptions.clear()},Object.defineProperty(e.prototype,"variables",{get:function(){return this._variables},set:function(e){this._variables=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"refs",{get:function(){return this._scopped.refs(this._entityWatchCallback.bind(this),this.cleanTracked.bind(this))},set:function(e){this._scopped.cleanRefs(this.cleanTracked.bind(this)),this._scopped.refs(this._entityWatchCallback.bind(this),this.cleanTracked.bind(this),e)},enumerable:!1,configurable:!0}),e}(),Le=function(){function e(e,t){void 0===t&&(t={}),this._renderer=r((function(){return e.hass}),(function(e){return!!(e&&e.areas&&e.devices&&e.entities&&e.states&&e.user)}),{retries:100,delay:50,rejectMessage:"The provided element doesn't contain a proper or initialised hass object"}).then((function(){return new Ne(e,t)}))}return e.prototype.getRenderer=function(){return this._renderer},e}(),Ce=/([A-Z])([a-z0-9_-]+)/g,De=function(e){return Object.entries(e).map((function(e){var t=e[0],n=e[1];return"".concat(function(e){return e.replace(Ce,(function(e,t,n,o){var r=t.toLocaleLowerCase();return o?"-".concat(r).concat(n):"--".concat(r).concat(n)}))}(t),":").concat(n)})).join(";")+";"},we=function(e){return(Array.isArray(e)?e:[e]).map((function(e){return"string"==typeof e?e:Object.entries(e).map((function(e){var t=e[0],n=e[1];return!1===n?"".concat(t,"{display: none !important}"):"".concat(t,"{").concat(De(n),"}")})).join("")})).join("")},He=function(e,t){return"".concat(t,"_").concat(e)},Me=function(e){return e instanceof ShadowRoot?e.host.localName:e.localName},xe=function(e,t){var n=He(Me(e),t);return e.querySelector("#".concat(n))},Pe=function(){function e(e){var t,n,o;void 0===e&&(e={}),this._prefix=null!==(t=e.prefix)&&void 0!==t?t:"ha-styles-manager",this._namespace=null!==(n=e.namespace)&&void 0!==n?n:"home-assistant-styles-manager",this._throwWarnings=null===(o=e.throwWarnings)||void 0===o||o}return e.prototype.getStyleElement=function(e){return xe(e,this._prefix)},e.prototype.addStyle=function(e,t){!function(e,t,n,o,r){if(t){var i=xe(t,n);if(!i){var a=He(Me(t),n);(i=document.createElement("style")).setAttribute("id",a),t.appendChild(i)}i.innerHTML="string"==typeof e?e:we(e)}else r&&console.warn("".concat(o,': no element has been provided calling "addStyle"'))}(e,t,this._prefix,this._namespace,this._throwWarnings)},e.prototype.removeStyle=function(e){!function(e,t,n,o){if(e){var r=xe(e,t);r?r.remove():o&&console.warn("".concat(n,': no style to remove calling "removeStyle"'))}else o&&console.warn("".concat(n,': no element has been provided calling "removeStyle"'))}(e,this._prefix,this._namespace,this._throwWarnings)},e}();!function(e){e.HIDDEN="hidden",e.NARROW="narrow",e.EXTENDED="extended"}(Ie||(Ie={})),function(e){e.DOCKED="docked",e.AUTO="auto",e.ALWAYS_HIDDEN="always_hidden"}(me||(me={})),function(e){e.AND="AND",e.OR="OR"}(Ae||(Ae={})),function(e){e.TEXT="text",e.HREF="href"}(be||(be={})),function(e){e.CALL_SERVICE="call-service",e.JAVASCRIPT="javascript",e.OPEN_DIALOG="open-dialog"}(Re||(Re={})),function(e){e.MORE_INFO="more-info",e.ALERT="alert",e.RESTART="restart"}(Se||(Se={})),function(e){e.GET="GET",e.POST="POST"}(ye||(ye={})),function(e){e.DATE="date",e.DATETIME="datetime",e.TIME="time",e.RELATIVE="relative"}(ge||(ge={}));var Be,Fe,Ge="custom-sidebar",Ue="sidebar-config",ke="".concat("/local/").concat(Ue),Ve="base";!function(e){e.BOOLEAN="boolean",e.STRING="string",e.UNDEFINED="undefined",e.NUMBER="number"}(Fe||(Fe={}));var je,We,Xe,Ke,qe,Ye="data-blocked";!function(e){e.ITEM="ha-md-list-item",e.HA_SVG_ICON="ha-svg-icon",e.HA_ICON="ha-icon",e.HA_ICON_BUTTON="ha-icon-button",e.ANCHOR="a",e.BUTTON="button",e.HA_RIPPLE="ha-ripple",e.USER_BADGE="ha-user-badge",e.HA_PANEL_LOVELACE="ha-panel-lovelace",e.HUI_ROOT="hui-root",e.HUI_VIEW_CONTAINER="hui-view-container",e.HUI_VIEW="hui-view"}(je||(je={})),function(e){e.HOST=":host",e.HOST_EXPANDED=":host([expanded])",e.HOST_NOT_EXPANDED=":host(:not([expanded]))",e.SIDEBAR_LOADER="ha-fade-in",e.SIDEBAR_ITEMS_CONTAINER="ha-md-list.ha-scrollbar",e.SCOPE=":scope",e.TITLE=".title",e.ITEM_SELECTED=".selected",e.ITEM_HOVER="ha-md-list-item:hover",e.SURFACE=".surface",e.SURFACE_HOVERED=".surface.hovered",e.SPACER=".spacer",e.ITEM_TEXT=".item-text",e.BADGE=".badge",e.CONFIGURATION=".configuration",e.HUI_ROOT="ha-panel-lovelace$ hui-root",e.HA_MENU_BUTTON=".header .toolbar > ha-menu-button",e.EDIT_SIDEBAR_BUTTON="ha-panel-profile ha-profile-section-general$ ha-settings-row mwc-button, ha-panel-profile ha-profile-section-general$ ha-settings-row ha-button",e.SIDEBAR_NOTIFICATIONS_CONTAINER=".notifications-container",e.SIDEBAR_NOTIFICATIONS_CONTAINER_HOVER=".notifications-container:hover",e.SIDEBAR_NOTIFICATIONS=".notifications",e.USER=".user",e.MENU=".menu",e.DIVIDER=".divider",e.MC_DRAWER=".mdc-drawer",e.DATA_INFO="[data-info]"}(We||(We={})),function(e){e.AFTER="::after",e.BEFORE="::before",e.WEBKIT_SCROLLBAR_THUMB="::-webkit-scrollbar-thumb"}(Xe||(Xe={})),function(e){e.SIDEBAR_BACKGROUND_COLOR="--sidebar-background-color",e.SIDEBAR_TITLE_COLOR="--sidebar-menu-button-text-color",e.SIDEBAR_BUTTON_COLOR="--sidebar-icon-color",e.SIDEBAR_MENU_BUTTON_BACKGROUND_COLOR="--sidebar-menu-button-background-color",e.SIDEBAR_ICON_COLOR="--sidebar-icon-color",e.SIDEBAR_SELECTED_ICON_COLOR="--sidebar-selected-icon-color",e.SIDEBAR_TEXT_COLOR="--sidebar-text-color",e.SIDEBAR_SELECTED_TEXT_COLOR="--sidebar-selected-text-color",e.MD_RIPPLE_HOVER_COLOR="--md-ripple-hover-color",e.MD_RIPPLE_HOVER_OPACITY="--md-ripple-hover-opacity",e.MD_SYS_COLOR_ON_SURFACE="--md-sys-color-on-surface",e.ACCENT_COLOR="--accent-color",e.TEXT_ACCENT_COLOR="--text-accent-color",e.TEXT_PRIMARY_COLOR="--text-primary-color",e.PRIMARY_TEXT_COLOR="--primary-text-color",e.DIVIDER_COLOR="--divider-color",e.DIVIDER_OPACITY="--dark-divider-opacity",e.SCROLLBAR_THUMB_COLOR="--scrollbar-thumb-color"}(Ke||(Ke={})),function(e){e.BACKGROUND="--custom-sidebar-background",e.BORDER_COLOR="--custom-sidebar-border-color",e.MENU_BACKGROUND="--custom-sidebar-menu-background",e.TITLE_COLOR="--custom-sidebar-title-color",e.SUBTITLE_COLOR="--custom-sidebar-subtitle-color",e.BUTTON_COLOR="--custom-sidebar-button-color",e.DIVIDER_COLOR="--custom-sidebar-divider-color",e.DIVIDER_TOP_COLOR="--custom-sidebar-divider-top-color",e.DIVIDER_BOTTOM_COLOR="--custom-sidebar-divider-bottom-color",e.SCROLLBAR_THUMB_COLOR="--custom-sidebar-scrollbar-thumb-color",e.ITEM_BACKGROUND="--custom-sidebar-item-background",e.ITEM_BACKGROUND_HOVER="--custom-sidebar-item-background-hover",e.ITEM_BACKGROUND_HOVER_OPACITY="--custom-sidebar-item-background-hover-opacity",e.ICON_COLOR="--custom-sidebar-icon-color",e.ICON_COLOR_SELECTED="--custom-sidebar-icon-color-selected",e.ICON_COLOR_HOVER="--custom-sidebar-icon-color-hover",e.TEXT_COLOR="--custom-sidebar-text-color",e.TEXT_COLOR_SELECTED="--custom-sidebar-text-color-selected",e.TEXT_COLOR_HOVER="--custom-sidebar-text-color-hover",e.SELECTION_BACKGROUND="--custom-sidebar-selection-background",e.SELECTION_OPACITY="--custom-sidebar-selection-opacity",e.INFO_COLOR="--custom-sidebar-info-color",e.INFO_COLOR_SELECTED="--custom-sidebar-info-color-selected",e.INFO_COLOR_HOVER="--custom-sidebar-info-color-hover",e.NOTIFICATION_COLOR="--custom-sidebar-notification-color",e.NOTIFICATION_COLOR_SELECTED="--custom-sidebar-notification-color-selected",e.NOTIFICATION_COLOR_HOVER="--custom-sidebar-notification-color-hover",e.NOTIFICATION_TEXT_COLOR="--custom-sidebar-notification-text-color",e.NOTIFICATION_TEXT_COLOR_SELECTED="--custom-sidebar-notification-text-color-selected",e.NOTIFICATION_TEXT_COLOR_HOVER="--custom-sidebar-notification-text-color-hover"}(qe||(qe={}));var $e,Je,ze,Qe,Ze,et,tt=["item_background","item_background_hover","icon_color","icon_color_selected","icon_color_hover","text_color","text_color_selected","text_color_hover","selection_background","info_color","info_color_selected","info_color_hover","notification_color","notification_color_selected","notification_color_hover","notification_text_color","notification_text_color_selected","notification_text_color_hover","divider_color"],nt=["selection_opacity","item_background_hover_opacity"],ot=[["item_background",qe.ITEM_BACKGROUND],["item_background_hover",qe.ITEM_BACKGROUND_HOVER],["item_background_hover_opacity",qe.ITEM_BACKGROUND_HOVER_OPACITY],["icon_color",qe.ICON_COLOR],["icon_color_selected",qe.ICON_COLOR_SELECTED],["icon_color_hover",qe.ICON_COLOR_HOVER],["text_color",qe.TEXT_COLOR],["text_color_selected",qe.TEXT_COLOR_SELECTED],["text_color_hover",qe.TEXT_COLOR_HOVER],["selection_background",qe.SELECTION_BACKGROUND],["selection_opacity",qe.SELECTION_OPACITY],["info_color",qe.INFO_COLOR],["info_color_selected",qe.INFO_COLOR_SELECTED],["info_color_hover",qe.INFO_COLOR_HOVER],["notification_color",qe.NOTIFICATION_COLOR],["notification_color_selected",qe.NOTIFICATION_COLOR_SELECTED],["notification_color_hover",qe.NOTIFICATION_COLOR_HOVER],["notification_text_color",qe.NOTIFICATION_TEXT_COLOR],["notification_text_color_selected",qe.NOTIFICATION_TEXT_COLOR_SELECTED],["notification_text_color_hover",qe.NOTIFICATION_TEXT_COLOR_HOVER],["divider_color",qe.DIVIDER_COLOR]],rt=o([["title_color",qe.TITLE_COLOR],["subtitle_color",qe.SUBTITLE_COLOR],["sidebar_button_color",qe.BUTTON_COLOR],["sidebar_background",qe.BACKGROUND],["menu_background",qe.MENU_BACKGROUND],["scrollbar_thumb_color",qe.SCROLLBAR_THUMB_COLOR],["divider_top_color",qe.DIVIDER_TOP_COLOR],["divider_bottom_color",qe.DIVIDER_BOTTOM_COLOR]],ot,!0);!function(e){e.BADGE="badge",e.ITEM_SELECTED="selected",e.USER="user"}($e||($e={})),function(e){e.ROLE="role",e.PROCESSED="data-processed",e.WITH_NOTIFICATION="data-notification",e.WITH_DIVIDER="data-divider",e.TAB_INDEX="tabindex",e.DISABLED="disabled",e.HREF="href",e.SLOT="slot",e.TYPE="type",e.CUSTOM_SIDEBAR_ATTRIBUTES="data-custom-sidebar-attrs"}(Je||(Je={})),function(e){e.PARTIAL_PANEL_RESOLVER="partial-panel-resolver",e.HA_PANEL_CONFIG="ha-panel-config",e.HA_CONFIG_BACKUP="ha-config-backup",e.HA_CONFIG_BACKUP_BACKUPS="ha-config-backup-backups",e.HA_CONFIG_SYSTEM_NAVIGATION="ha-config-system-navigation",e.DIALOG_BOX="dialog-box",e.DIALOG_RESTART="dialog-restart",e.HUI_TIMESTAMP_DISPLAY="hui-timestamp-display"}(ze||(ze={})),function(e){e.CLICK="click",e.MOUSEDOWN="mousedown",e.MOUSEENTER="mouseenter",e.MOUSELEAVE="mouseleave",e.KEYDOWN="keydown",e.RENDER_TEMPLATE="render_template",e.LOCATION_CHANGED="location-changed",e.HASS_MORE_INFO="hass-more-info",e.SHOW_DIALOG="show-dialog"}(Qe||(Qe={})),function(e){e.ARROW_DOWN="ArrowDown",e.ARROW_UP="ArrowUp",e.ENTER="Enter",e.TAB="Tab"}(Ze||(Ze={})),function(e){e.ITEM="HA-MD-LIST-ITEM",e.A="A"}(et||(et={}));var it,at,ct,st,ut,_t,lt,dt,ft,ht,Et,Ot,pt,Tt,vt,It,mt,At,bt,Rt,St,yt,gt,Nt,Lt,Ct,Dt=["HOME-ASSISTANT","HOME-ASSISTANT-MAIN","HA-SIDEBAR"],wt="config/core/check_config",Ht="template",Mt=((Be={})[Ie.HIDDEN]=me.ALWAYS_HIDDEN,Be[Ie.NARROW]=me.AUTO,Be[Ie.EXTENDED]=me.DOCKED,Be),xt=/\/profile(\/general)?$/,Pt=/^\s*\[\[\[([\s\S]+)\]\]\]\s*$/,Bt=/\{\{[\s\S]*\}\}|\{%[\s\S]*%\}/,Ft=/@partial\s+([\w-]+)/g,Gt=/^\s*([a-z_]+)\.([\w-]+)\s*$/,Ut=function(e){return typeof e===Fe.UNDEFINED},kt=function(e){return typeof e===Fe.STRING},Vt=function(e){return typeof e===Fe.NUMBER&&!Number.isNaN(e)},jt=function(e){return typeof e===Fe.BOOLEAN},Wt=function(e){return"[object Object]"===Object.prototype.toString.call(e)},Xt=function(e){return Array.isArray(e)},Kt=function(e){return Xt(e)?e.map((function(e){return e.toLowerCase()})):e.toLowerCase().split(/\s*,\s*/)},qt=o(o([],tt,!0),nt,!0),Yt=["id","exceptions","extendable_configs","extend_from","user","not_user","device","not_device","is_admin"],$t=["js_variables","jinja_variables","partials"],Jt=function(){function t(e,t,n){var o;this._config=e,this._extendable=new Map(Object.entries(null!==(o=this._config.extendable_configs)&&void 0!==o?o:[])),this._user=t,this._userAgent=n,this._exceptions=this._getExceptions(),this._buildFlattenConfig()}return t.prototype._getExceptions=function(){var e=this;if(this._config.exceptions){var t=this._user.name.toLocaleLowerCase();return this._config.exceptions.filter((function(n){var o,r=null!==(o=n.matchers_conditions)&&void 0!==o?o:Ae.OR,i=void 0!==n.user&&Kt(n.user).includes(t),a=void 0!==n.not_user&&!Kt(n.not_user).includes(t),c=void 0!==n.device&&Kt(n.device).some((function(t){return e._userAgent.includes(t)})),s=void 0!==n.not_device&&!Kt(n.not_device).some((function(t){return e._userAgent.includes(t)})),u=void 0!==n.is_admin&&n.is_admin===e._user.is_admin,_=void 0!==n.is_owner&&n.is_owner===e._user.is_owner;return r===Ae.OR?i||a||c||s||u||_:(void 0===n.user||i)&&(void 0===n.not_user||a)&&(void 0===n.device||c)&&(void 0===n.not_device||s)&&(void 0===n.is_admin||u)&&(void 0===n.is_owner||_)}))}return[]},t.prototype._mergeConfigs=function(){for(var t=[],n=0;n ")," > ").concat(r));return zt(t[r].trim(),t,o(o([],n,!0),[r],!1))}return console.warn("".concat(Ge,": partial ").concat(r," doesn't exist")),""}))},Qt=function(){for(var e=[],t=0;t ").concat(je.USER_BADGE)]={zIndex:1},it["".concat(We.HOST_EXPANDED," ").concat(je.ITEM," > ").concat(We.ITEM_TEXT)]={position:"relative",zIndex:1},it["".concat(We.HOST_EXPANDED," ").concat(je.ITEM," > ").concat(We.ITEM_TEXT).concat(We.DATA_INFO)]={display:"flex",flexDirection:"column",gap:"5px",lineHeight:"1"},it["".concat(We.HOST_EXPANDED," ").concat(je.ITEM," > ").concat(We.ITEM_TEXT).concat(We.DATA_INFO).concat(Xe.AFTER)]={content:"attr(data-info)",display:"block",fontSize:"11px",lineHeight:"1",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},it["".concat(We.HOST," ").concat(je.ITEM,":not([").concat(Je.WITH_NOTIFICATION,"], ").concat(We.CONFIGURATION,", ").concat(We.SIDEBAR_NOTIFICATIONS,") > ").concat(We.BADGE)]={display:"none"},it["".concat(We.HOST_NOT_EXPANDED," ").concat(je.ITEM,":not([").concat(Je.WITH_NOTIFICATION,"], ").concat(We.CONFIGURATION,", ").concat(We.SIDEBAR_NOTIFICATIONS,") > ").concat(We.BADGE)]={display:"none"},it["".concat(We.HOST," ").concat(je.ITEM," > ").concat(We.BADGE)]=sn,it["".concat(We.HOST_NOT_EXPANDED," ").concat(je.ITEM," > ").concat(We.BADGE)]=e(e({},sn),{display:"flex",fontSize:"0.65em",justifyContent:"center",left:"26px",lineHeight:"2",maxWidth:"5px",textOverflow:"unset",top:"4px",padding:"0 5px",position:"absolute"}),it),_n=((at={})["".concat(We.HOST," ").concat(We.MENU," > ").concat(We.TITLE)]={color:Qt(qe.TITLE_COLOR,Ke.SIDEBAR_TITLE_COLOR,Ke.PRIMARY_TEXT_COLOR)},at),ln=((ct={})["".concat(We.HOST," ").concat(We.MENU," > ").concat(We.TITLE).concat(Xe.AFTER)]={content:"attr(data-subtitle)",color:Qt(qe.SUBTITLE_COLOR,qe.TITLE_COLOR,Ke.SIDEBAR_TITLE_COLOR,Ke.PRIMARY_TEXT_COLOR),display:"block",fontSize:"12px",lineHeight:"1.5"},ct),dn=((st={})["".concat(We.HOST," ").concat(We.MENU," > ").concat(je.HA_ICON_BUTTON)]={color:Qt(qe.BUTTON_COLOR,Ke.SIDEBAR_ICON_COLOR)},st),fn=((ut={})[We.HOST]={background:Qt(qe.BACKGROUND,Ke.SIDEBAR_BACKGROUND_COLOR)+" !important"},ut),hn=((_t={})["".concat(We.HOST," ").concat(We.MENU)]={background:Qt(qe.MENU_BACKGROUND,qe.BACKGROUND,Ke.SIDEBAR_MENU_BUTTON_BACKGROUND_COLOR,"inherit"),borderBottomColor:Qt(qe.DIVIDER_TOP_COLOR,qe.DIVIDER_COLOR,Ke.DIVIDER_COLOR),borderBottomStyle:"solid",borderBottomWidth:"1px"},_t),En=((lt={})["".concat(We.HOST," ").concat(We.DIVIDER).concat(Xe.BEFORE)]={backgroundColor:Qt(qe.DIVIDER_BOTTOM_COLOR,qe.DIVIDER_COLOR,Ke.DIVIDER_COLOR)},lt),On=((dt={})["".concat(We.HOST," > ").concat(We.MC_DRAWER)]={borderColor:Qt(qe.BORDER_COLOR,Ke.DIVIDER_COLOR,"rgba(0,0,0,.12)")},dt),pn=((ft={})["".concat(We.HOST," ").concat(We.SIDEBAR_ITEMS_CONTAINER)]={scrollbarColor:Qt(qe.SCROLLBAR_THUMB_COLOR,Ke.SCROLLBAR_THUMB_COLOR)+" transparent"},ft["".concat(We.HOST," ").concat(We.SIDEBAR_ITEMS_CONTAINER).concat(Xe.WEBKIT_SCROLLBAR_THUMB)]={background:Qt(qe.SCROLLBAR_THUMB_COLOR,Ke.SCROLLBAR_THUMB_COLOR)},ft),Tn=((ht={})["".concat(We.MENU,"[").concat(Ye,"]")]={pointerEvents:"none"},ht["".concat(We.MENU,"[").concat(Ye,"] > ").concat(je.HA_ICON_BUTTON)]={pointerEvents:"all"},ht),vn=((Et={})["".concat(We.HOST," ").concat(je.ITEM,":not(").concat(We.ITEM_SELECTED,")").concat(Xe.BEFORE)]={background:Qt(qe.ITEM_BACKGROUND,"none"),bottom:"0px",content:'""',borderRadius:"4px",display:"block",left:"0px",position:"absolute",pointerEvents:"none",right:"0px",top:"0px"},Et),In=((Ot={})["".concat(We.HOST," ").concat(We.SURFACE).concat(Xe.BEFORE)]={background:Qt(qe.ITEM_BACKGROUND_HOVER,Ke.MD_RIPPLE_HOVER_COLOR,Ke.MD_SYS_COLOR_ON_SURFACE,"#1d1b20")},Ot["".concat(We.HOST," ").concat(We.SURFACE_HOVERED).concat(Xe.BEFORE)]={opacity:Qt(qe.ITEM_BACKGROUND_HOVER_OPACITY,Ke.MD_RIPPLE_HOVER_OPACITY,".08")},Ot),mn=((pt={})["".concat(We.HOST," ").concat(je.ITEM,"[").concat(Je.WITH_DIVIDER,"]")]={marginBottom:"10px",paddingBottom:"15px",position:"relative"},pt["".concat(We.HOST," ").concat(je.ITEM,"[").concat(Je.WITH_DIVIDER,"]").concat(Xe.AFTER)]={content:'""',backgroundColor:Qt(qe.DIVIDER_COLOR,Ke.DIVIDER_COLOR),bottom:0,height:"1px",left:"-4px",position:"absolute",right:"-4px"},pt["".concat(We.HOST," ").concat(je.ITEM).concat(We.ITEM_SELECTED,"[").concat(Je.WITH_DIVIDER,"]")]={borderBottomLeftRadius:0,borderBottomRightRadius:0},pt["".concat(We.HOST," ").concat(je.ITEM).concat(We.ITEM_SELECTED,"[").concat(Je.WITH_DIVIDER,"]").concat(Xe.BEFORE)]={bottom:"10px"},pt),An=((Tt={})["".concat(We.HOST," ").concat(je.ITEM," > :is(").concat(je.HA_SVG_ICON,", ").concat(je.HA_ICON,")")]={color:Qt(qe.ICON_COLOR,Ke.SIDEBAR_ICON_COLOR)},Tt),bn=((vt={})["".concat(We.HOST," ").concat(je.ITEM).concat(We.ITEM_SELECTED," > :is(").concat(je.HA_SVG_ICON,", ").concat(je.HA_ICON,')[slot="start"]')]={color:Qt(qe.ICON_COLOR_SELECTED,Ke.SIDEBAR_SELECTED_ICON_COLOR)},vt),Rn=((It={})["".concat(We.HOST," ").concat(We.ITEM_HOVER,":not(").concat(We.ITEM_SELECTED,") > :is(").concat(je.HA_SVG_ICON,", ").concat(je.HA_ICON,")")]={color:Qt(qe.ICON_COLOR_HOVER,qe.ICON_COLOR,Ke.SIDEBAR_ICON_COLOR)},It),Sn=((mt={})["".concat(We.HOST," ").concat(je.ITEM," > ").concat(We.ITEM_TEXT)]={color:Qt(qe.TEXT_COLOR,Ke.SIDEBAR_TEXT_COLOR)},mt),yn=((At={})["".concat(We.HOST," ").concat(je.ITEM).concat(We.ITEM_SELECTED," > ").concat(We.ITEM_TEXT)]={color:Qt(qe.TEXT_COLOR_SELECTED,Ke.SIDEBAR_SELECTED_TEXT_COLOR)},At),gn=((bt={})["".concat(We.HOST," ").concat(We.ITEM_HOVER,":not(").concat(We.ITEM_SELECTED,") > ").concat(We.ITEM_TEXT)]={color:Qt(qe.TEXT_COLOR_HOVER,qe.TEXT_COLOR,Ke.SIDEBAR_TEXT_COLOR)},bt),Nn=((Rt={})["".concat(We.HOST," ").concat(je.ITEM).concat(We.ITEM_SELECTED).concat(Xe.BEFORE)]={backgroundColor:Qt(qe.SELECTION_BACKGROUND,qe.ICON_COLOR_SELECTED,Ke.SIDEBAR_SELECTED_ICON_COLOR),opacity:Qt(qe.SELECTION_OPACITY,Ke.DIVIDER_OPACITY)},Rt),Ln=((St={})["".concat(We.HOST_EXPANDED," ").concat(We.SIDEBAR_ITEMS_CONTAINER," > ").concat(je.ITEM," > ").concat(We.ITEM_TEXT).concat(We.DATA_INFO).concat(Xe.AFTER)]={color:Qt(qe.INFO_COLOR,Ke.SIDEBAR_TEXT_COLOR)},St),Cn=((yt={})["".concat(We.HOST_EXPANDED," ").concat(We.SIDEBAR_ITEMS_CONTAINER," > ").concat(je.ITEM).concat(We.ITEM_SELECTED," > ").concat(We.ITEM_TEXT).concat(We.DATA_INFO).concat(Xe.AFTER)]={color:Qt(qe.INFO_COLOR_SELECTED,Ke.SIDEBAR_SELECTED_TEXT_COLOR)},yt),Dn=((gt={})["".concat(We.HOST_EXPANDED," ").concat(We.ITEM_HOVER,":not(").concat(We.ITEM_SELECTED,") > ").concat(We.ITEM_TEXT).concat(We.DATA_INFO).concat(Xe.AFTER)]={color:Qt(qe.INFO_COLOR_HOVER,qe.INFO_COLOR,Ke.SIDEBAR_TEXT_COLOR)},gt),wn=((Nt={})["".concat(We.HOST," ").concat(We.ITEM_SELECTED," > ").concat(We.BADGE)]={backgroundColor:Qt(qe.NOTIFICATION_COLOR_SELECTED,qe.NOTIFICATION_COLOR,Ke.ACCENT_COLOR),color:Qt(qe.NOTIFICATION_TEXT_COLOR_SELECTED,qe.NOTIFICATION_TEXT_COLOR,Ke.TEXT_ACCENT_COLOR,Ke.TEXT_PRIMARY_COLOR)},Nt),Hn=((Lt={})["".concat(We.HOST," ").concat(We.ITEM_HOVER,":not(").concat(We.ITEM_SELECTED,") > ").concat(We.BADGE)]={backgroundColor:Qt(qe.NOTIFICATION_COLOR_HOVER,qe.NOTIFICATION_COLOR,Ke.ACCENT_COLOR),color:Qt(qe.NOTIFICATION_TEXT_COLOR_HOVER,qe.NOTIFICATION_TEXT_COLOR,Ke.TEXT_ACCENT_COLOR,Ke.TEXT_PRIMARY_COLOR)},Lt),Mn=((Ct={})["".concat(We.HA_MENU_BUTTON)]=!1,Ct),xn="Invalid configuration",Pn=o(o(["title","subtitle","sidebar_background","title_color","subtitle_color","sidebar_button_color","sidebar_border_color","menu_background","divider_color","divider_top_color","divider_bottom_color","scrollbar_thumb_color","styles"],tt,!0),["default_path"],!0),Bn=["js_variables","jinja_variables","partials","extendable_configs"],Fn=function(e,t,n){t.forEach((function(t){if(!Ut(e[t])&&!kt(e[t]))throw new SyntaxError("".concat(n,' "').concat(String(t),'" property should be a string'))}))},Gn=function(e,t,n){t.forEach((function(t){if(!Ut(e[t])&&!kt(e[t])&&!Vt(e[t]))throw new SyntaxError("".concat(n,' "').concat(String(t),'" property should be a number or a string'))}))},Un=function(e,t,n){t.forEach((function(t){if(!Ut(e[t])&&!jt(e[t]))throw new SyntaxError("".concat(n,' "').concat(String(t),'" property should be a boolean'))}))},kn=function(e,t,n){t.forEach((function(t){if(!Ut(e[t])&&!jt(e[t])&&!kt(e[t]))throw new SyntaxError("".concat(n,' "').concat(String(t),'" property should be a boolean or a string'))}))},Vn=function(e,t){e.forEach((function(e){var n=e[0],o=e[1];if(!jn(o))throw new SyntaxError("".concat(t,' "').concat(n,'" property should be a string or an array of strings'))}))},jn=function(e){return!!Ut(e)||(kt(e)||Xt(e)&&e.some(kt))},Wn=function(e,t,n,o){(void 0===o&&(o=!1),e)&&(Xt(e)?e:[e]).forEach((function(e){var r;if(e===Ve&&!o)throw new SyntaxError("".concat(n,' "entend_from" can only be "base" in exceptions'));if(e!==Ve&&!(e in(null!==(r=t.extendable_configs)&&void 0!==r?r:{})))throw new SyntaxError("".concat(n,' "').concat(e,'" doesn\'t exist in "extendable_configs"'))}))},Xn=function(e,t,n){e&&(Xt(e)?e:[e]).forEach((function(e){if(n.includes(e))throw new SyntaxError("".concat(xn,', circular extend dependency detected in "').concat(n.join(" > ")," > ").concat(e,'"'));if(e===Ve)throw new SyntaxError("".concat(xn,', error in extendable config "').concat(n[0],'": "entend_from" can only be "base" in exceptions'));if(!(e in t.extendable_configs))throw new SyntaxError("".concat(xn,', error in "').concat(n[n.length-1],'": "').concat(e,'" doesn\'t exist in "extendable_configs"'));Xn(t.extendable_configs[e].extend_from,t,o(o([],n,!0),[e],!1))}))},Kn=function(e,t){Bn.forEach((function(n){if(n in e)throw new SyntaxError("".concat(t,' "').concat(n,'" option can only be placed in the main config'))}))},qn=function(e,t,n){if(kt(t)&&(Pt.test(t)||Bt.test(t)))console.warn('"'.concat(e,'" property should not have templates. "').concat(n.join(" > "),'" seems to be a template'));else if(!kt(t)&&!Vt(t)&&!jt(t))if(Xt(t))t.forEach((function(t,r){qn(e,t,o(o([],n,!0),["[".concat(r,"]")],!1))}));else{if(!Wt(t))throw new SyntaxError("".concat(xn,', "').concat(e,": ").concat(n.join(" > "),'" has a wrong type ').concat(Object.prototype.toString.call(t)));var r=t;Object.entries(r).forEach((function(t){var r=t[0],i=t[1];qn(e,i,o(o([],n,!0),[r],!1))}))}},Yn=function(e,t){if(!Ut(t)){if(!Wt(t))throw new SyntaxError("".concat(xn,', "').concat(e,'" property should be an object'));Object.entries(t).forEach((function(t){var n=t[0],o=t[1];qn(e,o,[n])}))}},$n=function(e,t){if(e.analytics){if(!jt(e.analytics)&&!Wt(e.analytics))throw new SyntaxError("".concat(t,' "analytics" should be a boolean or an object'));Wt(e.analytics)&&Un(e.analytics,["sidebar_item_clicked","panel_visited"],"".concat(t,' "analytics"'))}},Jn=function(e,t){if(!Ut(e)){if(!Xt(e))throw new SyntaxError("".concat(xn,", exceptions should be an array"));e.forEach((function(e){!function(e,t){var n;if(Kn(e,"".concat(xn,", exceptions")),Fn(e,o([],Pn,!0),"".concat(xn,", exceptions")),Gn(e,o([],nt,!0),"".concat(xn,", exceptions")),Vn([["user",e.user],["not_user",e.not_user],["device",e.device],["not_device",e.not_device],["extend_from",e.extend_from]],"".concat(xn,", exceptions")),Wn(e.extend_from,t,"".concat(xn,", error in exception:"),!0),!Ut(e.matchers_conditions)&&e.matchers_conditions!==Ae.AND&&e.matchers_conditions!==Ae.OR)throw new SyntaxError("".concat(xn,', exceptions "matchers_conditions" property should be "').concat(Ae.AND,'" or "').concat(Ae.OR,'"'));if(!Ut(e.order)&&!Xt(e.order))throw new SyntaxError("".concat(xn,', exceptions "order" property should be an array'));if(kn(e,["sidebar_editable"],"".concat(xn,", exceptions")),Un(e,["hide_all","is_admin","is_owner"],"".concat(xn,", exceptions")),$n(e,"".concat(xn,", error in exception:")),!Ut(e.sidebar_mode)&&!(e.sidebar_mode in Mt))throw new SyntaxError("".concat(xn,', exceptions "sidebar_mode" property should be ').concat(Ie.HIDDEN,", ").concat(Ie.NARROW," or ").concat(Ie.EXTENDED));if(e.user&&e.not_user)throw new SyntaxError("".concat(xn,', exceptions "user" and "not_user" properties cannot be used together'));if(e.device&&e.not_device)throw new SyntaxError("".concat(xn,', exceptions "device" and "not_device" properties cannot be used together'));null===(n=e.order)||void 0===n||n.forEach(zn)}(e,t)}))}},zn=function(e){if(Kn(e,"".concat(xn," in ").concat(e.item,",")),!e.item)throw new SyntaxError("".concat(xn,', every item in an "order" array should have an "item" property'));if(Fn(e,o(["item","info"],tt,!0),"".concat(xn," in ").concat(e.item,",")),Gn(e,o([],nt,!0),"".concat(xn," in ").concat(e.item,",")),kn(e,["hide"],"".concat(xn," in ").concat(e.item,",")),Un(e,["divider"],"".concat(xn," in ").concat(e.item,",")),function(e,t){if(!Ut(e.on_click)){if(!Wt(e.on_click))throw new SyntaxError("".concat(t,' "on_click" property should be an object'));if(!kt(e.on_click.action))throw new SyntaxError("".concat(t,' the "action" parameter should be a string'));if(!Object.values(Re).includes(e.on_click.action))throw new SyntaxError("".concat(t,' the "action" parameter should be one of these values: ').concat(Object.values(Re).join(", ")));if(e.on_click.action===Re.CALL_SERVICE){if(!kt(e.on_click.service))throw new SyntaxError("".concat(t,' the "service" parameter should be a string'));if(!Ut(e.on_click.data)&&!Wt(e.on_click.data))throw new SyntaxError("".concat(t,' the "data" parameter needs to be an object'))}if(e.on_click.action===Re.JAVASCRIPT&&!kt(e.on_click.code))throw new SyntaxError("".concat(t,' the "code" parameter should be a string'))}}(e,"".concat(xn," in ").concat(e.item,",")),function(e,t){if(!Ut(e)){if(!Wt(e)&&!kt(e))throw new SyntaxError("".concat(t,' the "attributes" parameter should be an object or a template string'));if(Wt(e))Object.entries(e).forEach((function(e){var n=e[0],o=e[1];if(!kt(o)&&!jt(o)&&!Vt(o))throw new SyntaxError("".concat(t,' the prop "').concat(n,'" in the attributes should be a string, a number or a boolean'))}));else if(kt(e)&&!Pt.test(e))throw new SyntaxError("".concat(t,' the "attributes" parameter as a string should be a JavaScript template'))}}(e.attributes,"".concat(xn," in ").concat(e.item,",")),e.new_item){if(Fn(e,["href","icon"],"".concat(xn," in ").concat(e.item,",")),!e.href&&!e.on_click)throw new SyntaxError("".concat(xn," in ").concat(e.item,', if you set "new_item" as "true", it is necessary an "href" or an "on_click "property'));if(!e.icon)throw new SyntaxError("".concat(xn," in ").concat(e.item,', if you set "new_item" as "true", "icon" property is necessary'))}},Qn=function(e){var t;if(Fn(e,o([],Pn,!0),"".concat(xn,",")),Vn([["extend_from",e.extend_from]],"".concat(xn,",")),Wn(e.extend_from,e,"".concat(xn,", error in main config:")),function(e){e.extendable_configs&&Object.entries(e.extendable_configs).forEach((function(t){var n=t[0],o=t[1];Xn(o.extend_from,e,[n])}))}(e),Gn(e,o([],nt,!0),"".concat(xn,",")),kn(e,["sidebar_editable"],"".concat(xn,",")),Un(e,["hide_all"],"".concat(xn,",")),!Ut(e.sidebar_mode)&&!(e.sidebar_mode in Mt))throw new SyntaxError("".concat(xn,', "sidebar_mode" property should be ').concat(Ie.HIDDEN,", ").concat(Ie.NARROW," or ").concat(Ie.EXTENDED));if(!Ut(e.order)&&!Xt(e.order))throw new SyntaxError("".concat(xn,', "order" property should be an array'));if(!Ut(e.partials)){if(!Wt(e.partials))throw new SyntaxError("".concat(xn,', "partials" property should be an object'));Object.entries(e.partials).forEach((function(e){var t=e[0],n=e[1];if(!kt(n))throw new SyntaxError("".concat(xn,', "partials" should be an object with strings. The partial ').concat(t," is not a string"))}))}Yn("js_variables",e.js_variables),Yn("js_refs",e.js_refs),Yn("jinja_variables",e.jinja_variables),$n(e,"".concat(xn,",")),null===(t=e.order)||void 0===t||t.forEach(zn),Jn(e.exceptions,e)},Zn=function(){return t(void 0,void 0,void 0,(function(){var e,t;return n(this,(function(n){return e="".concat(Ge,": JSON config file not found."),t="Make sure you have valid config in /config/www/".concat(Ue,".json file."),[2,new Promise((function(n){fetch("".concat(ke,".json?hash=").concat(Math.random().toString(16).slice(2)),{cache:"no-store"}).then((function(o){if(!o.ok)throw Error("".concat(e,"\n").concat(t));o.json().then((function(e){var o;(null===(o=e.id)||void 0===o?void 0:o.startsWith("example_json"))&&console.warn("".concat(Ge,": You seem to be using the example configuration.\n").concat(t)),Qn(e),n(e)})).catch((function(e){throw Error("".concat(Ge,": ").concat(e.message))}))})).catch((function(){throw Error("".concat(e,"\n").concat(t))}))}))]}))}))},eo=function(){function o(e){var t=this;this._debug=e;var n=new re;n.addEventListener(P.ON_LISTEN,(function(e){t._homeAssistant=e.detail.HOME_ASSISTANT,t._main=e.detail.HOME_ASSISTANT_MAIN,t._haDrawer=e.detail.HA_DRAWER,t._sidebar=e.detail.HA_SIDEBAR,t._partialPanelResolver=e.detail.PARTIAL_PANEL_RESOLVER,t._debugLog("HAQuerySelector init executed",{HOME_ASSISTANT:t._homeAssistant,HOME_ASSISTANT_MAIN:t._main,HA_DRAWER:t._haDrawer,HA_SIDEBAR:t._sidebar,PARTIAL_PANEL_RESOLVER:t._partialPanelResolver},{stringify:!1}),t._process()}),{once:!0}),n.addEventListener(P.ON_PANEL_LOAD,this._panelLoaded.bind(this)),this._huiViewContainerObserver=new MutationObserver(this._watchHuiViewContainer.bind(this)),this._styleManager=new Pe({prefix:Ge,namespace:Ge,throwWarnings:!1}),this._debugLog("Starting the plugin..."),this._items=[],this._logBookMessagesMap=new Map,this._sidebarScroll=0,this._itemTouchedBinded=this._itemTouched.bind(this),this._mouseEnterBinded=this._mouseEnter.bind(this),this._mouseLeaveBinded=this._mouseLeave.bind(this),this._configPromise=Zn(),n.listen()}return o.prototype._debugLog=function(e,t,n){var o=null!=n?n:{},r=o.stringify,i=void 0===r||r,a=o.table,c=void 0!==a&&a;if(this._debug){var s="".concat(Ge," debug: ").concat(e);t?(console.groupCollapsed(s),c?console.table(t):console.log(i?JSON.stringify(t,null,4):t),console.groupEnd()):console.log(s)}},o.prototype._getConfig=function(){return t(this,void 0,void 0,(function(){var e,t=this;return n(this,(function(n){switch(n.label){case 0:return this._debugLog("Getting the config..."),e=this,[4,this._configPromise.then((function(e){return t._debugLog("Raw config",e),function(e,t,n){return new Jt(n,e,t).config}(t._ha.hass.user,navigator.userAgent.toLowerCase(),e)}))];case 1:return e._config=n.sent(),[2]}}))}))},o.prototype._getElements=function(){return t(this,void 0,void 0,(function(){var e,t,o,i,a,c;return n(this,(function(n){switch(n.label){case 0:return e={retries:100,delay:50,shouldReject:!1},[4,this._sidebar.selector.$.element];case 1:return t=n.sent(),[4,r((function(){return t.querySelector(We.SIDEBAR_LOADER)}),(function(e){return null===e}),e)];case 2:return n.sent(),[4,this._sidebar.selector.$.query(We.SIDEBAR_ITEMS_CONTAINER).element];case 3:return o=n.sent(),[4,r((function(){return o.querySelector(":scope > ".concat(We.SPACER))}),(function(e){return!!e}),e)];case 4:return i=n.sent(),[4,r((function(){return o.querySelectorAll(":scope > ".concat(je.ITEM))}),(function(e){return Array.from(e).every((function(e){return e.querySelector(We.ITEM_TEXT).innerText.trim().length>0}))}),e)];case 5:return a=n.sent(),this._debug&&(c=Array.from(a).map((function(e){var t=e.href;return{text:e.querySelector(We.ITEM_TEXT).textContent.trim(),href:t}})),this._debugLog("Native sidebar items",c,{table:!0})),[2,[o,a,i]]}}))}))},o.prototype._getAnchorElement=function(e){return e.shadowRoot.querySelector(je.ANCHOR)},o.prototype._getButtonElement=function(e){return e.shadowRoot.querySelector(je.BUTTON)},o.prototype._hideItem=function(e,t){t?e.style.display="none":e.style.removeProperty("display")},o.prototype._buildNewItem=function(e){var t,n,o=document.createElement("ha-md-list-item");return o.setAttribute(Je.TYPE,"link"),o.href=null!==(t=e.href)&&void 0!==t?t:"#",o.target=null!==(n=e.target)&&void 0!==n?n:"",o.tabIndex=-1,o.innerHTML='\n '.concat(e.item,'\n \n '),o},o.prototype._getTemplateString=function(e){return t(this,void 0,void 0,(function(){var t,o;return n(this,(function(n){switch(n.label){case 0:return t="",e instanceof Promise||kt(e)||Vt(e)||jt(e)||Wt(e)||Xt(e)||(r=e,"[object RegExp]"===Object.prototype.toString.call(r))?kt(e)?(t=e.trim(),[3,6]):[3,1]:[3,6];case 1:return Vt(e)||jt(e)?(t=e.toString(),[3,6]):[3,2];case 2:return e instanceof Promise?[4,e]:[3,5];case 3:return o=n.sent(),[4,this._getTemplateString(o)];case 4:return t=n.sent(),[3,6];case 5:t=JSON.stringify(e),n.label=6;case 6:return[2,t]}var r}))}))},o.prototype._subscribeTitle=function(){var e=this;this._sidebar.selector.$.query(We.TITLE).element.then((function(t){e._config.title&&e._subscribeTemplate(e._config.title,(function(e){t.innerHTML=e})),e._config.subtitle&&e._subscribeTemplate(e._config.subtitle,(function(e){t.dataset.subtitle=e}))}))},o.prototype._subscribeSideBarEdition=function(){var e=this,t=function(e){e.preventDefault(),e.stopImmediatePropagation()},n=function(e,n){e.removeEventListener(Qe.SHOW_DIALOG,t,!0),n.removeAttribute(Ye)},o=function(e,n){e.removeEventListener(Qe.SHOW_DIALOG,t,!0),e.addEventListener(Qe.SHOW_DIALOG,t,!0),n.setAttribute(Ye,"")};Promise.all([this._sidebar.element,this._sidebar.selector.$.query(We.MENU).element]).then((function(t){var r=t[0],i=t[1];jt(e._config.sidebar_editable)&&(e._config.sidebar_editable||o(r,i)),kt(e._config.sidebar_editable)&&e._subscribeTemplate(e._config.sidebar_editable,(function(t){var a=void 0;"true"===t||"false"===t?(a=!("false"===t))?n(r,i):o(r,i):(a=void 0,n(r,i)),e._checkProfileEditableButton(a)}))}))},o.prototype._subscribeAttributes=function(e,t){var n=function(t){var n,o,r=null!==(o=null===(n=e.element.getAttribute(Je.CUSTOM_SIDEBAR_ATTRIBUTES))||void 0===n?void 0:n.split("|"))&&void 0!==o?o:[];r.forEach((function(t){e.element.removeAttribute(t)})),r.splice(0),t.forEach((function(t){var n=t[0],o=t[1];kt(o)||Vt(o)||jt(o)?(e.element.setAttribute(n,"".concat(o)),r.push(n)):console.warn("".concat(Ge,': the property "').concat(n,'" in the attributes property of the item "').concat(e.item,'" should be a string, a number or a boolean. This property will be omitted'))})),e.element.setAttribute(Je.CUSTOM_SIDEBAR_ATTRIBUTES,r.join("|"))};kt(t)?this._subscribeTemplate(t,(function(e){try{var t=JSON.parse(e);n(Object.entries(t))}catch(e){throw new SyntaxError("".concat(Ge,': "attributes" template must always return an object'))}})):n(Object.entries(t))},o.prototype._subscribeName=function(e,t){var n=e.querySelector(We.ITEM_TEXT);this._subscribeTemplate(t,(function(e){n.innerHTML=e}))},o.prototype._subscribeIcon=function(e,t){this._subscribeTemplate(t,(function(t){var n=e.querySelector(je.HA_ICON);if(!n){(n=document.createElement(je.HA_ICON)).setAttribute(Je.SLOT,"start");var o=e.querySelector(je.HA_SVG_ICON);o?o.replaceWith(n):e.prepend(n)}n.setAttribute("icon",t)}))},o.prototype._subscribeInfo=function(e,t){var n=e.querySelector(We.ITEM_TEXT);this._subscribeTemplate(t,(function(e){n.dataset.info=e}))},o.prototype._subscribeNotification=function(e,t){var n=e.querySelector(We.BADGE);n||((n=document.createElement("span")).classList.add($e.BADGE),n.setAttribute(Je.SLOT,"end"),e.append(n));this._subscribeTemplate(t,(function(t){t.length?(n.innerHTML=t,e.setAttribute(Je.WITH_NOTIFICATION,"true")):(n.innerHTML="",e.removeAttribute(Je.WITH_NOTIFICATION))}))},o.prototype._subscribeHide=function(e,t){var n=this;jt(t)?this._hideItem(e,t):this._subscribeTemplate(t,(function(t){n._hideItem(e,"true"===t)}))},o.prototype._subscribeTemplateColorChanges=function(e,t,n){var o=this;n.forEach((function(n){var r=n[0],i=n[1];e[r]&&o._subscribeTemplate(e[r],(function(e){t.style.setProperty(i,e)}))}))},o.prototype._subscribeTemplate=function(e,t){var n=zt("".concat(e),this._config.partials);Pt.test(n)?this._createJsTemplateSubscription(n.replace(Pt,"$1"),t):Bt.test(n)?this._createJinjaTemplateSubscription(n,t):this._getTemplateString(n).then((function(e){t(e)}))},o.prototype._createJsTemplateSubscription=function(e,t){var n=this;this._renderer.trackTemplate(e,(function(e){n._getTemplateString(e).then((function(e){t(e)}))}))},o.prototype._createJinjaTemplateSubscription=function(t,n){var o=this;return new Promise((function(r){window.hassConnection.then((function(i){var a=i.conn.subscribeMessage((function(e){n("".concat(e.result))}),{type:Qe.RENDER_TEMPLATE,template:t,variables:e({user_name:o._ha.hass.user.name,user_is_admin:o._ha.hass.user.is_admin,user_is_owner:o._ha.hass.user.is_owner,user_agent:window.navigator.userAgent},o._config.jinja_variables)});r(a)}))}))},o.prototype._focusItem=function(e,t){var n=this._items.length,o="none",r=0;if(t)for(var i=(s=e+1)+n,a=s;an-1?a-n:a;if(this._items[c].style.display!==o){r=c;break}}else{var s;for(i=(s=e-1)-n,a=s;a>i;a--){c=a<0?n+a:a;if(this._items[c].style.display!==o){r=c;break}}}this._items[r].focus(),this._items[r].tabIndex=0},o.prototype._focusItemByKeyboard=function(e,t){var n=e.querySelector("\n ".concat(We.SCOPE," > ").concat(je.ITEM,":not(.").concat($e.ITEM_SELECTED,"):focus,\n ").concat(We.SCOPE," > ").concat(je.ITEM,":focus\n ")),o=0;this._items.forEach((function(e,t){e===n&&(o=t),e.tabIndex=-1})),this._focusItem(o,t)},o.prototype._focusItemByTab=function(e,t,n){var o=e.querySelector(We.SIDEBAR_NOTIFICATIONS),r=e.querySelector(We.USER),i=e.querySelector(je.HA_ICON_BUTTON),a=this._items.indexOf(t);if(t===o||t===r||a>=0)if(t===o)n?r.focus():this._focusItem(0,n);else if(t===r)o.focus();else{var c=this._items.length-1;n&&a0?this._focusItem(a,n):n?o.focus():i.focus()}},o.prototype._getActiveElement=function(e){void 0===e&&(e=document);var t=e.activeElement;return t?t instanceof HTMLElement&&t.nodeName===et.ITEM?t:t.shadowRoot&&Dt.includes(t.nodeName)?this._getActiveElement(t.shadowRoot):null:null},o.prototype._isAnalyticsOptionEnabled=function(e){return this._config.analytics&&(!0===this._config.analytics||this._config.analytics[e])},o.prototype._getUserEntity=function(){var e,t=this,n=Object.entries(this._ha.hass.entities).filter((function(e){var n=e[1];return"".concat(n.name).toLowerCase()===t._ha.hass.user.name.toLocaleLowerCase()}));return null===(e=n[0])||void 0===e?void 0:e[0]},o.prototype._logBookLog=function(e){var t=this;window.clearTimeout(this._logBookMessagesMap.get(e)),this._logBookMessagesMap.set(e,window.setTimeout((function(){t._ha.hass.callService("logbook","log",{name:Ge,message:e,domain:"person",entity_id:t._getUserEntity()}),t._logBookMessagesMap.delete(e)}),500))},o.prototype._processDefaultPath=function(){var e=this,t=this._config.default_path;if(t){var n=zt(t,this._config.partials);if(Pt.test(n)){var o=this._renderer.renderTemplate(n.replace(Pt,"$1"));this._executeDefaultPath(o)}else if(Bt.test(n))var r=this._createJinjaTemplateSubscription(n,(function(t){e._executeDefaultPath(t),r.then((function(e){e()}))}));else this._executeDefaultPath(n)}},o.prototype._executeDefaultPath=function(e){var t;if(e.startsWith("/")){var n=[null,"",e];(t=window.history).replaceState.apply(t,n),window.dispatchEvent(new CustomEvent(Qe.LOCATION_CHANGED,{detail:{replace:e}}))}else console.warn("".concat(Ge,': ignoring default_path property "').concat(e,'" as it doesn\'t start with "/".'))},o.prototype._processSidebar=function(){var e=this;Promise.all([this._main.element,this._partialPanelResolver.element]).then((function(o){var r=o[0],i=o[1],a=e._config.sidebar_mode,c=matchMedia("(max-width: 870px)");if(a){r.hass.dockedSidebar=Mt[a];var s=function(o){return t(e,void 0,void 0,(function(){var e;return n(this,(function(t){switch(t.label){case 0:return[4,this._partialPanelResolver.selector.query(We.HUI_ROOT).$.element];case 1:return e=t.sent(),this._styleManager.removeStyle(e),a!==Ie.HIDDEN&&(r.narrow=!1,i.narrow=o,o&&this._styleManager.addStyle(Mn,e)),[2]}}))}))};c.addEventListener("change",(function(e){s(e.matches)})),s(c.matches)}})),Promise.all([this._haDrawer.selector.$.query(We.MC_DRAWER).element,this._sidebar.element,this._sidebar.selector.$.element,this._sidebar.selector.$.query(We.SIDEBAR_ITEMS_CONTAINER).element]).then((function(t){var n=t[0],o=t[1],r=t[2],i=t[3];e._subscribeTemplateColorChanges(e._config,o,rt),e._subscribeTemplateColorChanges(e._config,n,[["sidebar_border_color",qe.BORDER_COLOR]]),i.addEventListener(Qe.KEYDOWN,(function(t){t.key!==Ze.ARROW_DOWN&&t.key!==Ze.ARROW_UP||(t.preventDefault(),t.stopImmediatePropagation(),e._focusItemByKeyboard(i,t.key===Ze.ARROW_DOWN))}),!0),window.addEventListener(Qe.KEYDOWN,(function(t){if(t.key===Ze.TAB){var n=e._getActiveElement();if(n){var o=n;o.nodeName===et.ITEM&&(o.classList.contains($e.USER)&&!t.shiftKey||(t.preventDefault(),t.stopImmediatePropagation(),e._focusItemByTab(r,o,!t.shiftKey)))}}}),!0),e._isAnalyticsOptionEnabled("sidebar_item_clicked")&&r.addEventListener(Qe.CLICK,(function(t){var n=t.target.closest(je.ITEM);if(n){var o=n.querySelector(We.ITEM_TEXT).innerText;e._logBookLog("sidebar_item_clicked: ".concat(o))}})),e._styleManager.addStyle(On,n),e._styleManager.addStyle([un,_n,ln,dn,fn,hn,En,pn,Tn,mn,vn,An,bn,Rn,Sn,yn,gn,Nn,Ln,Cn,Dn,wn,Hn,e._config.styles||""],r)}))},o.prototype._aplyItemRippleStyles=function(){return t(this,void 0,void 0,(function(){var e,t=this;return n(this,(function(n){switch(n.label){case 0:return[4,this._sidebar.selector.$.query(je.ITEM).all];case 1:return e=n.sent(),Array.from(e).forEach((function(e){var n=("link"===e.getAttribute(Je.TYPE)?t._getAnchorElement(e):t._getButtonElement(e)).querySelector(je.HA_RIPPLE).shadowRoot.querySelector(We.SURFACE);t._styleManager.addStyle([In],n)})),[2]}}))}))},o.prototype._rearrange=function(){var t=this;this._getElements().then((function(n){var o=t._config,r=o.order,i=o.hide_all,a=n[0],c=n[1],s=n[2],u=0,_=!1;t._items=Array.from(c);var l=new Set;i&&t._items.forEach((function(e){t._hideItem(e,!0)}));var d=r.reduce((function(n,o){var r=o.item,i=o.match,a=o.exact,c=o.new_item,s=r.toLocaleLowerCase(),u=c?void 0:t._items.find((function(e){var t=i===be.HREF?e.href:e.querySelector(We.ITEM_TEXT).innerText.trim();return!((!a||r!==t)&&(a||!t.toLowerCase().includes(s)))&&(!l.has(e)&&(l.add(e),!0))}));return u&&u.setAttribute(Je.PROCESSED,"true"),(c||u)&&n.push(e(e({},o),{element:u})),c||u||console.warn("".concat(Ge,": you have an order item in your configuration that didn't match any sidebar item: \"").concat(r,'"')),n}),[]),f=function(){_||(t._items.forEach((function(e){e.hasAttribute(Je.PROCESSED)||(e.style.order="".concat(u))})),u++,s.style.order="".concat(u),u++,_=!0)};d.forEach((function(e){if(e.bottom&&f(),e.new_item){var n=t._buildNewItem(e);a.append(n),e.element=n,e.element.setAttribute(Je.PROCESSED,"true"),t._items.push(e.element)}else if(e.element){var o=e.element;e.href&&(o.href=e.href),e.target&&(o.target=e.target)}e.element.style.order="".concat(u),Ut(e.attributes)||t._subscribeAttributes(e,e.attributes),e.divider&&e.element.setAttribute(Je.WITH_DIVIDER,"true"),e.name&&t._subscribeName(e.element,e.name),e.icon&&t._subscribeIcon(e.element,e.icon),e.info&&t._subscribeInfo(e.element,e.info),e.notification&&t._subscribeNotification(e.element,e.notification),Ut(e.hide)||t._subscribeHide(e.element,e.hide),t._subscribeTemplateColorChanges(e,e.element,ot),e.new_item&&(e.element.addEventListener(Qe.MOUSEENTER,t._mouseEnterBinded),e.element.addEventListener(Qe.MOUSELEAVE,t._mouseLeaveBinded)),e.on_click&&e.element.addEventListener(Qe.CLICK,t._mouseClick.bind(t,e),!0),u++})),d.length&&f(),t._items.sort((function(e,t){return+e.style.order-+t.style.order})),a.addEventListener(Qe.MOUSEDOWN,t._itemTouchedBinded),a.addEventListener(Qe.KEYDOWN,(function(e){e.key===Ze.ENTER&&t._itemTouchedBinded()})),t._aplyItemRippleStyles(),t._panelLoaded()}))},o.prototype._itemTouched=function(){return t(this,void 0,void 0,(function(){var e=this;return n(this,(function(t){return this._sidebar.selector.$.query(We.SIDEBAR_ITEMS_CONTAINER).element.then((function(t){e._sidebarScroll=t.scrollTop})),[2]}))}))},o.prototype._mouseEnter=function(e){this._sidebar.element.then((function(t){t.alwaysExpand||(t._mouseLeaveTimeout&&(clearTimeout(t._mouseLeaveTimeout),t._mouseLeaveTimeout=void 0),t._showTooltip(e.currentTarget))}))},o.prototype._mouseLeave=function(){return t(this,void 0,void 0,(function(){return n(this,(function(e){return this._sidebar.element.then((function(e){e._mouseLeaveTimeout&&clearTimeout(e._mouseLeaveTimeout),e._mouseLeaveTimeout=window.setTimeout((function(){e._hideTooltip()}),500)})),[2]}))}))},o.prototype._mouseClick=function(e,o){return t(this,void 0,void 0,(function(){var t,r,i,a,c,s,u,_,l,d,f,h,E=this;return n(this,(function(n){switch(t=e.on_click,r=e.element,i=r,a=r.querySelector(We.ITEM_TEXT),c=a.textContent.trim(),"#"===i.href&&o.preventDefault(),s=function(t){var n=t.includes("return")?t:"".concat(t,"\n;return;");return E._renderer.renderTemplate(n,{variables:{item:e,itemText:c}})},t.action){case Re.CALL_SERVICE:u=t.service,_=t.data,l=void 0===_?{}:_,d=u.match(Gt),f=Object.entries(l).map((function(e){var t=e[0],n=e[1],o=zt("".concat(n),E._config.partials);return Pt.test(o)?[t,s(o.replace(Pt,"$1"))]:[t,n]})),3===(null==d?void 0:d.length)?this._ha.hass.callService(d[1],d[2],Object.fromEntries(f)):console.warn("".concat(Ge,' ignoring "').concat(Re.CALL_SERVICE,'" action in "').concat(c,'" item. The service parameter is malfomed.'));break;case Re.JAVASCRIPT:h=t.code,s(zt(h,this._config.partials));break;case Re.OPEN_DIALOG:switch(t.type){case Se.MORE_INFO:an(this._ha,t.entity_id);break;case Se.RESTART:rn(this._ha)}}return[2]}))}))},o.prototype._checkProfileEditableButton=function(){return t(this,arguments,void 0,(function(e){var t,o,r,i;return void 0===e&&(e=void 0),n(this,(function(n){switch(n.label){case 0:return[4,this._partialPanelResolver.element];case 1:return t=n.sent(),o=t.route.path,xt.test(o)?[4,this._partialPanelResolver.selector.query(We.EDIT_SIDEBAR_BUTTON).element]:[3,3];case 2:if(r=n.sent()){if(i=jt(e)?e:this._config.sidebar_editable,!jt(i))return[2];!1===i?r.setAttribute(Je.DISABLED,""):r.removeAttribute(Je.DISABLED)}n.label=3;case 3:return[2]}}))}))},o.prototype._panelLoaded=function(){return t(this,void 0,void 0,(function(){var e,t,o,i,a,c=this;return n(this,(function(n){switch(n.label){case 0:return this._checkProfileEditableButton(),[4,this._partialPanelResolver.element];case 1:return e=n.sent(),t="".concat(location.pathname).concat(location.search),[4,this._sidebar.selector.$.query(We.SIDEBAR_ITEMS_CONTAINER).element];case 2:return o=n.sent(),i=Array.from(o.querySelectorAll(je.ITEM)),a=i.reduce((function(e,n){return t.startsWith(n.href)&&(null===e||n.href.length>e.href.length)?n:e}),null),i.forEach((function(e){var t=a===e;e.classList.toggle($e.ITEM_SELECTED,t),e.tabIndex=t?0:-1})),o.scrollTop!==this._sidebarScroll&&(o.scrollTop=this._sidebarScroll),this._huiViewContainerObserver.disconnect(),e.querySelector(je.HA_PANEL_LOVELACE)&&this._partialPanelResolver.selector.query(je.HA_PANEL_LOVELACE).$.query(je.HUI_ROOT).$.query(je.HUI_VIEW_CONTAINER).element.then((function(e){c._huiViewContainerObserver.observe(e,{subtree:!0,childList:!0})})),this._config?[3,4]:[4,r((function(){return c._config}),(function(e){return!!e}),{retries:100,delay:50,shouldReject:!1})];case 3:n.sent(),n.label=4;case 4:return this._isAnalyticsOptionEnabled("panel_visited")&&this._logBookLog("panel_visited: ".concat(t)),[2]}}))}))},o.prototype._watchHuiViewContainer=function(e){var t=this;e.forEach((function(e){e.addedNodes.forEach((function(e){e.localName===je.HUI_VIEW&&t._panelLoaded()}))}))},o.prototype._process=function(){var t=this;this._homeAssistant.element.then((function(n){t._ha=n,t._debugLog("Instantiating HomeAssistantJavaScriptTemplates..."),new Le(t._ha).getRenderer().then((function(n){t._debugLog("HomeAssistantJavaScriptTemplates instantiated"),t._renderer=n,t._getConfig().then((function(){var n,o;t._debugLog("Compiled config",t._config),t._debugLog("Executing plugin logic..."),t._renderer.variables=e(e(e(e({},null!==(n=t._config.js_variables)&&void 0!==n?n:{}),function(e){return{checkConfig:function(){return e.hass.callApi(ye.POST,wt)},renderTemplate:function(t){return e.hass.callApi(ye.POST,Ht,{template:t})},callService:function(t,n,o){return e.hass.callService(t,n,o)}}}(t._ha)),cn(t._ha)),function(e){var t=function(t){var n=document.createElement(ze.HUI_TIMESTAMP_DISPLAY);return n.hass=e.hass,n.ts=t instanceof Date?t:new Date(t),n},n=function(e){return e.render().values.join("")};return{formatDate:function(e){var o=t(e);return o.format=ge.DATE,n(o)},formatDateTime:function(e){var o=t(e);return o.format=ge.DATETIME,n(o)},formatTime:function(e){var o=/^\d+:\d+(:\d+)?$/.test(e.toString())?"1900-01-01T".concat(e):e,r=t(o);return r.format=ge.TIME,n(r)},getRelativeTime:function(e,o){void 0===o&&(o=!1);var r=t(e);return r.format=ge.RELATIVE,r.capitalize=o,r._updateRelative(),n(r)}}}(t._ha)),t._renderer.refs=null!==(o=t._config.js_refs)&&void 0!==o?o:{},t._processDefaultPath(),t._processSidebar(),t._subscribeTitle(),t._subscribeSideBarEdition(),t._rearrange()}))}))}))},o}();if(!window.CustomSidebar){console.info("%c≡ ".concat(Ge.toUpperCase()," (JSON)%cv").concat("11.1.0"),"font-weight: bold; background: #EEEEEE; color: #666666; padding: 2px 5px;","font-weight: normal; background: #E87A24; color: #FFFFFF; padding: 2px 5px");var to=new URLSearchParams(window.location.search).has("cs_debug");window.CustomSidebar=new eo(to)}}();