Files
haos_config/www/community/custom-sidebar/custom-sidebar-json.js
2026-01-30 23:31:00 -06:00

2 lines
87 KiB
JavaScript

!function(){"use strict";var e=function(){return e=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},e.apply(this,arguments)};function t(e,t,n,o){return new(n||(n=Promise))((function(r,i){function a(e){try{s(o.next(e))}catch(e){i(e)}}function c(e){try{s(o.throw(e))}catch(e){i(e)}}function s(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,c)}s((o=o.apply(e,t||[])).next())}))}function n(e,t){var n,o,r,i={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=c(0),a.throw=c(1),a.return=c(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(c){return function(s){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(i=0)),i;)try{if(n=1,o&&(r=2&c[0]?o.return:c[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,c[1])).done)return r;switch(o=0,r&&(c=[2&c[0],r.value]),c[0]){case 0:case 1:r=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,o=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(r=i.trys,(r=r.length>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]<r[3])){i.label=c[1];break}if(6===c[0]&&i.label<r[1]){i.label=r[1],r=c;break}if(r&&i.label<r[2]){i.label=r[2],i.ops.push(c);break}r[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}catch(e){c=[6,e],o=0}finally{n=r=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}}function o(e,t,n){if(n||2===arguments.length)for(var o,r=0,i=t.length;r<i;r++)!o&&r in t||(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return e.concat(o||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError;var r=function(e,t,n){var o;void 0===n&&(n={});var r=n.retries,i=void 0===r?10:r,a=n.delay,c=void 0===a?10:a,s=n.shouldReject,u=void 0===s||s,_=null!==(o=n.rejectMessage)&&void 0!==o?o:"Could not get the result after {{ retries }} retries";return new Promise((function(n,o){var r=0,a=function(){var s=e();t(s)?n(s):++r<i?setTimeout(a,c):u?o(new Error(_.replace(/\{\{\s*retries\s*\}\}/g,"".concat(i)))):n(s)};a()}))},i=function(){return i=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},i.apply(this,arguments)};function a(e,t,n,o){return new(n||(n=Promise))((function(t,r){function i(e){try{c(o.next(e))}catch(e){r(e)}}function a(e){try{c(o.throw(e))}catch(e){r(e)}}function c(e){var o;e.done?t(e.value):(o=e.value,o instanceof n?o:new n((function(e){e(o)}))).then(i,a)}c((o=o.apply(e,[])).next())}))}function c(e,t){var n,o,r,i={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=c(0),a.throw=c(1),a.return=c(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(c){return function(s){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(i=0)),i;)try{if(n=1,o&&(r=2&c[0]?o.return:c[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,c[1])).done)return r;switch(o=0,r&&(c=[2&c[0],r.value]),c[0]){case 0:case 1:r=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,o=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!((r=(r=i.trys).length>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]<r[3])){i.label=c[1];break}if(6===c[0]&&i.label<r[1]){i.label=r[1],r=c;break}if(r&&i.label<r[2]){i.label=r[2],i.ops.push(c);break}r[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}catch(e){c=[6,e],o=0}finally{n=r=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}}"function"==typeof SuppressedError&&SuppressedError;var s="$",u=":host",_="invalid selector",l=10,d=10,f=function(e){var t,n=e[0],o=e[1];return(t=n)&&(t instanceof Document||t instanceof Element||t instanceof ShadowRoot)&&"string"==typeof o};function h(e,t){return function(e){return e.split(",").map((function(e){return e.trim()}))}(e).map((function(e){var n=function(e){return e.split(s).map((function(e){return e.trim()}))}(e);return t(n)}))}function E(e,t){var n=t?" If you want to select a shadowRoot, use ".concat(t," instead."):"";return"".concat(e," cannot be used with a selector ending in a shadowRoot (").concat(s,").").concat(n)}function O(e){return e instanceof Promise?e:Promise.resolve(e)}function p(){return"You can not select a shadowRoot (".concat(s,") of the document.")}function T(){return"You can not select a shadowRoot (".concat(s,") of a shadowRoot.")}function v(e,t){for(var n,o,r=null,i=e.length,a=0;a<i;a++){if(0===a)if(e[a].length)r=t.querySelector(e[a]);else{if(t instanceof Document)throw new SyntaxError(p());if(t instanceof ShadowRoot)throw new SyntaxError(T());r=(null===(n=t.shadowRoot)||void 0===n?void 0:n.querySelector(e[++a]))||null}else r=(null===(o=r.shadowRoot)||void 0===o?void 0:o.querySelector("".concat(u," ").concat(e[a])))||null;if(null===r)return null}return r}function I(e,t){var n,o=function(e,t,n){for(var o,r=0,i=t.length;r<i;r++)!o&&r in t||(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return[].concat(o||Array.prototype.slice.call(t))}(0,e),r=o.pop();if(!o.length)return t.querySelectorAll(r);var i=v(o,t);return(null===(n=null==i?void 0:i.shadowRoot)||void 0===n?void 0:n.querySelectorAll("".concat(u," ").concat(r)))||null}function m(e,t){if(1===e.length&&!e[0].length){if(t instanceof Document)throw new SyntaxError(p());if(t instanceof ShadowRoot)throw new SyntaxError(T());return t.shadowRoot}var n=v(e,t);return(null==n?void 0:n.shadowRoot)||null}function A(e,t,n,o){return a(this,0,void 0,(function(){return c(this,(function(i){return[2,r((function(){return function(e,t,n,o){for(var r=h(e,(function(e){if(!e[e.length-1].length)throw new SyntaxError(E(n,o));return e})),i=r.length,a=0;a<i;a++){var c=v(r[a],t);if(c)return c}return null}(e,t,"asyncQuerySelector","asyncShadowRootQuerySelector")}),(function(e){return!!e}),{retries:n,delay:o,shouldReject:!1})]}))}))}function b(e,t,n,o){return a(this,0,void 0,(function(){return c(this,(function(i){return[2,r((function(){return function(e,t,n){for(var o=h(e,(function(e){if(!e[e.length-1].length)throw new SyntaxError(E(n));return e})),r=o.length,i=0;i<r;i++){var a=I(o[i],t);if(null==a?void 0:a.length)return a}return document.querySelectorAll(_)}(e,t,"asyncQuerySelectorAll")}),(function(e){return!!e.length}),{retries:n,delay:o,shouldReject:!1})]}))}))}function R(e,t,n,o){return a(this,0,void 0,(function(){return c(this,(function(i){return[2,r((function(){return function(e,t,n,o){for(var r=h(e,(function(e){if(e.pop().length)throw new SyntaxError(function(e,t){return"".concat(e," must be used with a selector ending in a shadowRoot (").concat(s,"). If you don't want to select a shadowRoot, use ").concat(t," instead.")}(n,o));return e})),i=r.length,a=0;a<i;a++){var c=m(r[a],t);if(c)return c}return null}(e,t,"asyncShadowRootQuerySelector","asyncQuerySelector")}),(function(e){return!!e}),{retries:n,delay:o,shouldReject:!1})]}))}))}var S=function(e,t){var n=e.querySelectorAll(t);if(n.length)return n;if(e instanceof Element&&e.shadowRoot){var o=S(e.shadowRoot,t);if(o.length)return o}for(var r=0,i=Array.from(e.querySelectorAll("*"));r<i.length;r++){var a=i[r],c=S(a,t);if(c.length)return c}return document.querySelectorAll(_)},y=function(e,t,n,o){return r((function(){return S(e,t)}),(function(e){return!!e.length}),{retries:n,delay:o,shouldReject:!1})};function g(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return a(this,0,void 0,(function(){var t,n,o,r,i;return c(this,(function(a){switch(a.label){case 0:return f(e)?(t=e[0],n=e[1],o=e[2],[4,A(n,t,(null==o?void 0:o.retries)||l,(null==o?void 0:o.delay)||d)]):[3,2];case 1:case 3:return[2,a.sent()];case 2:return r=e[0],i=e[1],[4,A(r,document,(null==i?void 0:i.retries)||l,(null==i?void 0:i.delay)||d)]}}))}))}function N(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return a(this,0,void 0,(function(){var t,n,o,r,i;return c(this,(function(a){switch(a.label){case 0:return f(e)?(t=e[0],n=e[1],o=e[2],[4,b(n,t,(null==o?void 0:o.retries)||l,(null==o?void 0:o.delay)||d)]):[3,2];case 1:return[2,a.sent()];case 2:return r=e[0],i=e[1],[2,b(r,document,(null==i?void 0:i.retries)||l,(null==i?void 0:i.delay)||d)]}}))}))}function L(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return a(this,0,void 0,(function(){var t,n,o,r,i;return c(this,(function(a){switch(a.label){case 0:return f(e)?(t=e[0],n=e[1],o=e[2],[4,R(n,t,(null==o?void 0:o.retries)||l,(null==o?void 0:o.delay)||d)]):[3,2];case 1:return[2,a.sent()];case 2:return r=e[0],i=e[1],[2,R(r,document,(null==i?void 0:i.retries)||l,(null==i?void 0:i.delay)||d)]}}))}))}var C=function(){function e(e,t){e instanceof Node||e instanceof Promise?(this._element=e,this._asyncParams=i({retries:l,delay:d},t||{})):(this._element=document,this._asyncParams=i({retries:l,delay:d},e||{}))}return Object.defineProperty(e.prototype,"element",{get:function(){return O(this._element).then((function(e){return e instanceof NodeList?e[0]||null:e}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"$",{get:function(){var t=this;return new e(O(this._element).then((function(e){return e instanceof Document||e instanceof ShadowRoot||null===e||e instanceof NodeList&&0===e.length?null:e instanceof NodeList?L(e[0],s,t._asyncParams):L(e,s,t._asyncParams)})),this._asyncParams)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"all",{get:function(){return O(this._element).then((function(e){return e instanceof NodeList?e:document.querySelectorAll(_)}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"asyncParams",{get:function(){return this._asyncParams},enumerable:!1,configurable:!0}),e.prototype.eq=function(e){return a(this,0,void 0,(function(){return c(this,(function(t){return[2,O(this._element).then((function(t){return t instanceof NodeList&&t[e]||null}))]}))}))},e.prototype.query=function(t){var n=this;return new e(O(this._element).then((function(e){return null===e||e instanceof NodeList&&0===e.length?null:e instanceof NodeList?N(e[0],t,n._asyncParams):N(e,t,n._asyncParams)})),this._asyncParams)},e.prototype.deepQuery=function(t){var n=this;return new e(O(this._element).then((function(e){return null===e||e instanceof NodeList&&0===e.length?null:e instanceof NodeList?Promise.race(Array.from(e).map((function(e){return y(e,t,n._asyncParams.retries,n._asyncParams.delay)}))):y(e,t,n._asyncParams.retries,n._asyncParams.delay)})),this._asyncParams)},e}(),D=function(e,t){return D=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},D(e,t)},w=function(){return w=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},w.apply(this,arguments)};"function"==typeof SuppressedError&&SuppressedError;var H,M,x,P,B,F,G,U,k,V,j,W,X,K,q,Y,$="$",J={retries:100,delay:50,eventThreshold:450};!function(e){e.HOME_ASSISTANT="HOME_ASSISTANT",e.HOME_ASSISTANT_MAIN="HOME_ASSISTANT_MAIN",e.HA_DRAWER="HA_DRAWER",e.HA_SIDEBAR="HA_SIDEBAR",e.PARTIAL_PANEL_RESOLVER="PARTIAL_PANEL_RESOLVER"}(H||(H={})),function(e){e.HA_PANEL_LOVELACE="HA_PANEL_LOVELACE",e.HUI_ROOT="HUI_ROOT",e.HEADER="HEADER",e.HUI_VIEW="HUI_VIEW"}(M||(M={})),function(e){e.HA_MORE_INFO_DIALOG="HA_MORE_INFO_DIALOG",e.HA_DIALOG="HA_DIALOG",e.HA_DIALOG_CONTENT="HA_DIALOG_CONTENT",e.HA_MORE_INFO_DIALOG_INFO="HA_MORE_INFO_DIALOG_INFO",e.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK="HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK",e.HA_DIALOG_MORE_INFO_SETTINGS="HA_DIALOG_MORE_INFO_SETTINGS"}(x||(x={})),function(e){e.ON_LISTEN="onListen",e.ON_PANEL_LOAD="onPanelLoad",e.ON_LOVELACE_PANEL_LOAD="onLovelacePanelLoad",e.ON_MORE_INFO_DIALOG_OPEN="onMoreInfoDialogOpen",e.ON_HISTORY_AND_LOGBOOK_DIALOG_OPEN="onHistoryAndLogBookDialogOpen",e.ON_SETTINGS_DIALOG_OPEN="onSettingsDialogOpen"}(P||(P={})),function(e){e.HOME_ASSISTANT="home-assistant",e.HOME_ASSISTANT_MAIN="home-assistant-main",e.HA_DRAWER="ha-drawer",e.HA_SIDEBAR="ha-sidebar",e.PARTIAL_PANEL_RESOLVER="partial-panel-resolver",e.HA_PANEL_LOVELACE="ha-panel-lovelace",e.HUI_ROOT="hui-root",e.HEADER=".header",e.HUI_VIEW="hui-view",e.HA_MORE_INFO_DIALOG="ha-more-info-dialog",e.HA_DIALOG="ha-dialog",e.HA_DIALOG_CONTENT=".content",e.HA_MORE_INFO_DIALOG_INFO="ha-more-info-info",e.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK="ha-more-info-history-and-logbook",e.HA_DIALOG_MORE_INFO_SETTINGS="ha-more-info-settings"}(Y||(Y={}));var z=((B={})[H.HOME_ASSISTANT]={selector:Y.HOME_ASSISTANT,children:{shadowRoot:{selector:$,children:(F={},F[H.HOME_ASSISTANT_MAIN]={selector:Y.HOME_ASSISTANT_MAIN,children:{shadowRoot:{selector:$,children:(G={},G[H.HA_DRAWER]={selector:Y.HA_DRAWER,children:(U={},U[H.HA_SIDEBAR]={selector:Y.HA_SIDEBAR,children:{shadowRoot:{selector:$}}},U[H.PARTIAL_PANEL_RESOLVER]={selector:Y.PARTIAL_PANEL_RESOLVER},U)},G)}}},F)}}},B),Q=((k={})[M.HA_PANEL_LOVELACE]={selector:Y.HA_PANEL_LOVELACE,children:{shadowRoot:{selector:$,children:(V={},V[M.HUI_ROOT]={selector:Y.HUI_ROOT,children:{shadowRoot:{selector:$,children:(j={},j[M.HEADER]={selector:Y.HEADER},j[M.HUI_VIEW]={selector:Y.HUI_VIEW},j)}}},V)}}},k),Z={shadowRoot:{selector:$,children:(W={},W[x.HA_MORE_INFO_DIALOG]={selector:Y.HA_MORE_INFO_DIALOG,children:{shadowRoot:{selector:$,children:(X={},X[x.HA_DIALOG]={selector:Y.HA_DIALOG,children:(K={},K[x.HA_DIALOG_CONTENT]={selector:Y.HA_DIALOG_CONTENT,children:(q={},q[x.HA_MORE_INFO_DIALOG_INFO]={selector:Y.HA_MORE_INFO_DIALOG_INFO},q[x.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK]={selector:Y.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK},q[x.HA_DIALOG_MORE_INFO_SETTINGS]={selector:Y.HA_DIALOG_MORE_INFO_SETTINGS},q)},K)},X)}}},W)}},ee=function(e,t,n,o){return void 0===n&&(n=null),void 0===o&&(o=!1),Object.entries(t||{}).reduce((function(t,r){var i=r[0],a=r[1];if(a.selector===$&&n)return a.children?w(w({},t),ee(e,a.children,n,!0)):t;var c=n?n.then((function(t){return t?g(t,(n=a.selector,o?"$ "+n:n),e):null;var n})):g(a.selector,e);return t[i]={element:c,children:ee(e,a.children,c),selector:new C(c,e)},t}),{})},te=function(e,t){for(var n=0,o=Object.entries(t);n<o.length;n++){var r=o[n];if(r[0]===e)return r[1];var i=te(e,r[1].children);if(i)return i}},ne=function(e,t){return Object.keys(e).reduce((function(e,n){var o=te(n,t);o.children;var r=function(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);r<o.length;r++)t.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(n[o[r]]=e[o[r]])}return n}(o,["children"]);return e[n]=w({},r),e}),{})},oe=function(){function e(){this.delegate=document.createDocumentFragment()}return e.prototype.addEventListener=function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];(e=this.delegate).addEventListener.apply(e,t)},e.prototype.dispatchEvent=function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return(e=this.delegate).dispatchEvent.apply(e,t)},e.prototype.removeEventListener=function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return(e=this.delegate).removeEventListener.apply(e,t)},e}(),re=function(e){function t(t){void 0===t&&(t={});var n=e.call(this)||this;return n._config=w(w({},J),t),n._timestaps={},n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}D(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}(t,e),t.prototype._dispatchEvent=function(e,t){var n=Date.now();n-this._timestaps[e]<this._config.eventThreshold||(this._timestaps[e]=n,this.dispatchEvent(new CustomEvent(e,{detail:t})))},t.prototype._updateDialogElements=function(e){var t,n=this;void 0===e&&(e=x.HA_MORE_INFO_DIALOG_INFO),this._dialogTree=ee(this._config,Z,this._haRootElements.HOME_ASSISTANT.element);var o=ne(x,this._dialogTree);o.HA_DIALOG_CONTENT.element.then((function(e){n._dialogsContentObserver.disconnect(),n._dialogsContentObserver.observe(e,{childList:!0})})),this._haDialogElements=function(e,t){return[x.HA_MORE_INFO_DIALOG,x.HA_DIALOG,x.HA_DIALOG_CONTENT,t].reduce((function(t,n){return t[n]=e[n],t}),{})}(o,e);var r=((t={})[x.HA_MORE_INFO_DIALOG_INFO]=P.ON_MORE_INFO_DIALOG_OPEN,t[x.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK]=P.ON_HISTORY_AND_LOGBOOK_DIALOG_OPEN,t[x.HA_DIALOG_MORE_INFO_SETTINGS]=P.ON_SETTINGS_DIALOG_OPEN,t);this._dispatchEvent(r[e],this._haDialogElements)},t.prototype._updateRootElements=function(){var e=this;this._homeAssistantRootTree=ee(this._config,z),this._haRootElements=ne(H,this._homeAssistantRootTree),this._haRootElements[H.HOME_ASSISTANT].selector.$.element.then((function(t){e._dialogsObserver.disconnect(),e._dialogsObserver.observe(t,{childList:!0})})),this._haRootElements[H.PARTIAL_PANEL_RESOLVER].element.then((function(t){e._panelResolverObserver.disconnect(),t&&e._panelResolverObserver.observe(t,{subtree:!0,childList:!0})})),this._dispatchEvent(P.ON_LISTEN,this._haRootElements),this._dispatchEvent(P.ON_PANEL_LOAD,this._haRootElements)},t.prototype._updateLovelaceElements=function(){var e=this;this._homeAssistantResolverTree=ee(this._config,Q,this._haRootElements[H.HA_DRAWER].element),this._haResolverElements=ne(M,this._homeAssistantResolverTree),this._haResolverElements[M.HA_PANEL_LOVELACE].element.then((function(t){e._lovelaceObserver.disconnect(),t&&(e._lovelaceObserver.observe(t.shadowRoot,{childList:!0}),e._dispatchEvent(P.ON_LOVELACE_PANEL_LOAD,w(w({},e._haRootElements),e._haResolverElements)))}))},t.prototype._watchDialogs=function(e){var t=this;e.forEach((function(e){e.addedNodes.forEach((function(e){e.localName===Y.HA_MORE_INFO_DIALOG&&t._updateDialogElements()}))}))},t.prototype._watchDialogsContent=function(e){var t=this;e.forEach((function(e){e.addedNodes.forEach((function(e){var n,o=((n={})[Y.HA_MORE_INFO_DIALOG_INFO]=x.HA_MORE_INFO_DIALOG_INFO,n[Y.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK]=x.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK,n[Y.HA_DIALOG_MORE_INFO_SETTINGS]=x.HA_DIALOG_MORE_INFO_SETTINGS,n);if(e.localName&&e.localName in o){var r=e.localName;t._updateDialogElements(o[r])}}))}))},t.prototype._watchDashboards=function(e){var t=this;e.forEach((function(e){e.addedNodes.forEach((function(e){t._dispatchEvent(P.ON_PANEL_LOAD,t._haRootElements),e.localName===Y.HA_PANEL_LOVELACE&&t._updateLovelaceElements()}))}))},t.prototype._watchLovelace=function(e){var t=this;e.forEach((function(e){e.addedNodes.forEach((function(e){e.localName===Y.HUI_ROOT&&t._updateLovelaceElements()}))}))},t.prototype.listen=function(){this._watchDialogsBinded=this._watchDialogs.bind(this),this._watchDialogsContentBinded=this._watchDialogsContent.bind(this),this._watchDashboardsBinded=this._watchDashboards.bind(this),this._watchLovelaceBinded=this._watchLovelace.bind(this),this._dialogsObserver=new MutationObserver(this._watchDialogsBinded),this._dialogsContentObserver=new MutationObserver(this._watchDialogsContentBinded),this._panelResolverObserver=new MutationObserver(this._watchDashboardsBinded),this._lovelaceObserver=new MutationObserver(this._watchLovelaceBinded),this._updateRootElements(),this._updateLovelaceElements()},t.prototype.addEventListener=function(t,n,o){e.prototype.addEventListener.call(this,t,n,o)},t}(oe),ie=function(){return ie=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},ie.apply(this,arguments)};function ae(e,t,n){if(2===arguments.length)for(var o,r=0,i=t.length;r<i;r++)!o&&r in t||(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return e.concat(o||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError;var ce,se,ue,_e,le="[home-assistant-javascript-templates]",de=/^([a-z_]+)\.(\w+)$/;!function(e){e.UNKNOWN="unknown",e.UNAVAILABLE="unavailable"}(ce||(ce={})),function(e){e.AREA_ID="area_id",e.NAME="name"}(se||(se={})),function(e){e.PANEL_URL="panel_url",e.LANG="lang"}(ue||(ue={})),function(e){e.LOCATION_CHANGED="location-changed",e.TRANSLATIONS_UPDATED="translations-updated",e.POPSTATE="popstate",e.SUBSCRIBE_EVENTS="subscribe_events",e.STATE_CHANGE_EVENT="state_changed"}(_e||(_e={}));var fe=function(e){return e.reduce((function(e,t){var n=t[0],o=t[1];return e[n.replace(de,"$2")]=o,e}),{})},he=function(e){return e.includes(".")},Ee="ref",Oe="value",pe="toJSON",Te=function(e){return"".concat(Ee,".").concat(e)};function ve(e,t,n){var o=function(){return Object.entries(e.hass.areas)},r=function(){return Object.entries(e.hass.devices)},i=function(){return Object.entries(e.hass.entities)},a=new Set,c=new Map,s=function(e,t){n&&console.warn("".concat(e," ").concat(t," used in a JavaScript template doesn't exist"))},u=function(e){return s("Entity",e)},_=function(e){return s("Domain",e)},l=function(e){var o=new SyntaxError(e);if(t)throw o;n&&console.warn(o)},d=function(t){e.hass.states[t]?a.add(t):u(t)},f=function(e){a.add(e)},h=function(t,n){var o=n.with_unit,r=void 0!==o&&o,i=n.rounded,a=void 0!==i&&i;if(t){var c=t.state,s=t.attributes.unit_of_measurement,u=Number(a),_=!1===a||isNaN(Number(c))?c:new Intl.NumberFormat(e.hass.language,{minimumFractionDigits:u,maximumFractionDigits:u}).format(Number(c));return r&&s?"".concat(_," ").concat(s):_}},E=function(e){return new Proxy(e,{get:function(e,t){return"state_with_unit"===t?h(e,{rounded:!0,with_unit:!0}):e[t]}})};return{get hass(){return e.hass},states:new Proxy((function(t,n){if(void 0===n&&(n={}),he(t))return d(t),h(e.hass.states[t],n);throw SyntaxError("".concat(le,": states method cannot be used with a domain, use it as an object instead."))}),{get:function(t,n){if(he(n))return d(n),E(e.hass.states[n]);var o=Object.entries(e.hass.states).filter((function(e){return e[0].startsWith(n)}));return o.length||_(n),new Proxy(fe(o),{get:function(e,t){return d("".concat(n,".").concat(t)),E(e[t])}})}}),state_translated:function(t){if(d(t),e.hass.states[t])return e.hass.formatEntityState(e.hass.states[t])},is_state:function(t,n){var o;return d(t),Array.isArray(n)?n.some((function(n){var o;return(null===(o=e.hass.states[t])||void 0===o?void 0:o.state)===n})):(null===(o=e.hass.states[t])||void 0===o?void 0:o.state)===n},state_attr:function(t,n){var o,r;return d(t),null===(r=null===(o=e.hass.states[t])||void 0===o?void 0:o.attributes)||void 0===r?void 0:r[n]},is_state_attr:function(e,t,n){return this.state_attr(e,t)===n},has_value:function(e){return this.states(e)?!(this.is_state(e,ce.UNKNOWN)||this.is_state(e,ce.UNAVAILABLE)):(u(e),!1)},entities:new Proxy((function(t){if(void 0===t)return e.hass.entities;if(he(t))return d(t),e.hass.entities[t];var n=i().filter((function(e){return e[0].startsWith(t)}));return n.length||_(t),new Proxy(fe(n),{get:function(e,n){return d("".concat(t,".").concat(n)),e[n]}})}),{get:function(e,t){return e(t)}}),entity_prop:function(t,n){var o;return d(t),null===(o=e.hass.entities[t])||void 0===o?void 0:o[n]},is_entity_prop:function(e,t,n){return this.entity_prop(e,t)===n},devices:new Proxy((function(t){if(void 0===t)return e.hass.devices;if(he(t))throw SyntaxError("".concat(le,": devices method cannot be used with an entity id, you should use a device id instead."));return e.hass.devices[t]}),{get:function(t,n){if(he(n))throw SyntaxError("".concat(le,": devices cannot be accesed using an entity id, you should use a device id instead."));return e.hass.devices[n]}}),device_attr:function(t,n){var o,r,i;if(he(t)){d(t);var a=null===(o=e.hass.entities[t])||void 0===o?void 0:o.device_id;return null===(r=e.hass.devices[a])||void 0===r?void 0:r[n]}return null===(i=e.hass.devices[t])||void 0===i?void 0:i[n]},is_device_attr:function(e,t,n){return this.device_attr(e,t)===n},device_id:function(t){var n;if(he(t))return d(t),null===(n=e.hass.entities[t])||void 0===n?void 0:n.device_id;var o=r().find((function(e){return e[1].name===t}));return null==o?void 0:o[0]},device_name:function(t){var n,o,r;if(he(t)){d(t);var i=null===(n=e.hass.entities[t])||void 0===n?void 0:n.device_id;return null===(o=e.hass.devices[i])||void 0===o?void 0:o.name}return null===(r=e.hass.devices[t])||void 0===r?void 0:r.name},areas:function(){return o().map((function(e){return e[1].area_id}))},area_id:function(t){var n,r;if(t in e.hass.devices)return this.device_attr(t,se.AREA_ID);var i=null===(n=e.hass.entities[t])||void 0===n?void 0:n.device_id;if(i)return this.device_attr(i,se.AREA_ID);var a=o().find((function(e){return e[1].name===t}));return null===(r=null==a?void 0:a[1])||void 0===r?void 0:r.area_id},area_name:function(t){var n,r,i;t in e.hass.devices&&(i=this.device_attr(t,se.AREA_ID));var a=null===(n=e.hass.entities[t])||void 0===n?void 0:n.device_id;a&&(i=this.device_attr(a,se.AREA_ID));var c=o().find((function(e){var n=e[1];return n.area_id===t||n.area_id===i}));return null===(r=null==c?void 0:c[1])||void 0===r?void 0:r.name},area_entities:function(e){var t=o().find((function(t){var n=t[1];return n.area_id===e||n.name===e}));return t?i().filter((function(e){return e[1].area_id===t[1].area_id})).map((function(e){return e[0]})):[]},area_devices:function(e){var t=o().find((function(t){var n=t[1];return n.area_id===e||n.name===e}));return t?r().filter((function(e){return e[1].area_id===t[1].area_id})).map((function(e){return e[1].id})):[]},get user_name(){return e.hass.user.name},get user_is_admin(){return e.hass.user.is_admin},get user_is_owner(){return e.hass.user.is_owner},get user_agent(){return window.navigator.userAgent},get tracked(){return a},cleanTracked:function(){a.clear()},ref:function(e,t,n){var o;void 0===n&&(n=void 0);var r=Te(t);if(c.has(t))return c.get(t);var i=new Proxy(((o={})[Oe]=n,o[pe]=function(){return this[Oe]},o),{get:function(e,t,n){if(t===Oe||t===pe)return f(r),Reflect.get(e,t,n);l("".concat(t," is not a valid ").concat(Ee," property. A ").concat(Ee,' only exposes a "').concat(Oe,'" property'))},set:function(t,n,o){if(n===Oe){var i=t[Oe];return t[Oe]=o,e({event_type:_e.STATE_CHANGE_EVENT,data:{entity_id:r,old_state:{state:JSON.stringify(i)},new_state:{state:JSON.stringify(o)}}}),!0}return l('property "'.concat(n,'" cannot be set in a ').concat(Ee)),!1}});return c.set(t,i),i},unref:function(e,t){var n=Te(t);c.has(t)?(c.delete(t),e(n)):l("".concat(t," is not a ref or it has been unrefed already"))},refs:function(e,t,n){void 0===n&&(n={});var o=this.ref,r=this.unref,i=new Proxy(n,{get:function(t,n){return o(e,n).value},set:function(t,n,r){return o(e,n).value=r,!0}});return Object.entries(n).forEach((function(n){var i=n[0],a=n[1];c.has(i)&&r(t,i),o(e,i,a)})),i},cleanRefs:function(e){var t=this;Array.from(c.keys()).forEach((function(n){t.unref(e,n)}))},clientSideProxy:new Proxy({},{get:function(t,o){switch(Object.values(ue).includes(o)&&f(o),o){case ue.PANEL_URL:return location.pathname;case ue.LANG:return e.hass.language}n&&console.warn("clientSideProxy should only be used to access these variables: ".concat(Object.values(ue).join(", ")))}})}}var Ie,me,Ae,be,Re,Se,ye,ge,Ne=function(){function e(e,t){var n=t.throwErrors,o=void 0!==n&&n,r=t.throwWarnings,i=void 0===r||r,a=t.variables,c=void 0===a?{}:a,s=t.refs,u=void 0===s?{}:s,_=t.refsVariableName,l=void 0===_?"refs":_,d=t.autoReturn,f=void 0===d||d;this._throwErrors=o,this._throwWarnings=i,this._variables=c,this._refsVariableName=l,this._autoReturn=f,this._subscriptions=new Map,this._clientSideEntitiesRegExp=new RegExp("(^|[ \\?(+:\\{\\[><,])(".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<arguments.length;n++)t[n]=arguments[n];return t.reduce((function(t,n){var r,i;return e(e(e({},t),n),{order:o(o([],null!==(r=t.order)&&void 0!==r?r:[],!0),null!==(i=n.order)&&void 0!==i?i:[],!0)})}),{})},t.prototype._pickExtendableOptions=function(t){var n=Object.entries(t),o=Object.fromEntries(n.filter((function(e){var t=e[0];return!Yt.includes(t)})));return t.extend_from?this._mergeConfigs(this._importConfig(t.extend_from),o):e({},o)},t.prototype._importConfig=function(e){var t,n=this;return(Xt(t=e)?t:[t]).reduce((function(e,t){return t===Ve?n._mergeConfigs(n._pickExtendableOptions(n._config),e):n._mergeConfigs(n._pickExtendableOptions(n._extendable.get(t)),e)}),{})},t.prototype._buildFlattenConfigFromExceptions=function(){var t=this,n=$t.reduce((function(n,o){var r;return t._config[o]?e(e({},n),((r={})[o]=t._config[o],r)):n}),{});this._flattenConfig=this._exceptions.reduce((function(e,n){return n.extend_from?t._mergeConfigs(t._importConfig(n.extend_from),e,n):t._mergeConfigs(e,n)}),n)},t.prototype._buildFlattenConfigFromMainConfig=function(){this._flattenConfig=this._config.extend_from?this._mergeConfigs(this._importConfig(this._config.extend_from),this._config):this._config},t.prototype._buildFlattenConfig=function(){this._exceptions.length?this._buildFlattenConfigFromExceptions():this._buildFlattenConfigFromMainConfig()},t.prototype._flattenOrder=function(t){var n,o=null!==(n=t.order)&&void 0!==n?n:[],r=new Map;return o.forEach((function(t){r.has(t.item)?r.set(t.item,e(e({},r.get(t.item)),t)):r.set(t.item,t)})),r.forEach((function(e){qt.forEach((function(n){void 0===e[n]&&void 0!==t[n]&&(e[n]=t[n])})),e.new_item||void 0!==e.hide||void 0===t.hide_all||(e.hide=t.hide_all)})),Array.from(r.values()).sort((function(e,t){return!!e.bottom!=!!t.bottom?e.bottom?1:-1:Ut(e.order)||Ut(t.order)?e.order===t.order?0:Ut(e.order)?1:-1:e.order-t.order}))},Object.defineProperty(t.prototype,"config",{get:function(){return e(e({},this._flattenConfig),{order:this._flattenOrder(this._flattenConfig)})},enumerable:!1,configurable:!0}),t}(),zt=function(e,t,n){return void 0===n&&(n=[]),e.replace(Ft,(function(e,r){if(null==t?void 0:t[r]){if(n.includes(r))throw new SyntaxError("".concat(Ge,": circular partials dependency ").concat(n.join(" > ")," > ").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<arguments.length;t++)e[t]=arguments[t];var n=e[0],o=e.slice(1);return 0===o.length?n.startsWith("--")?"var(".concat(n,")"):n:"var(".concat(n,", ").concat(Qt.apply(void 0,o),")")},Zt=function(){return t(void 0,void 0,void 0,(function(){var e;return n(this,(function(t){switch(t.label){case 0:return customElements.get(ze.HA_PANEL_CONFIG)?[3,3]:((e=document.createElement(ze.PARTIAL_PANEL_RESOLVER)).hass={panels:[{url_path:"config",component_name:"config"}]},e._updateRoutes(),[4,e.routerOptions.routes.config.load()]);case 1:return t.sent(),[4,customElements.whenDefined(ze.HA_PANEL_CONFIG)];case 2:t.sent(),t.label=3;case 3:return[2,document.createElement(ze.HA_PANEL_CONFIG)]}}))}))},en=function(e){return t(void 0,void 0,void 0,(function(){return n(this,(function(t){switch(t.label){case 0:return customElements.get(ze.HA_CONFIG_BACKUP)?[3,3]:[4,e.routerOptions.routes.backup.load()];case 1:return t.sent(),[4,customElements.whenDefined(ze.HA_CONFIG_BACKUP)];case 2:t.sent(),t.label=3;case 3:return[2,document.createElement(ze.HA_CONFIG_BACKUP_BACKUPS)]}}))}))},tn=function(e){return t(void 0,void 0,void 0,(function(){return n(this,(function(t){switch(t.label){case 0:return customElements.get(ze.HA_CONFIG_SYSTEM_NAVIGATION)?[3,3]:[4,e.routerOptions.routes.system.load()];case 1:return t.sent(),[4,customElements.whenDefined(ze.HA_CONFIG_SYSTEM_NAVIGATION)];case 2:t.sent(),t.label=3;case 3:return[2,document.createElement(ze.HA_CONFIG_SYSTEM_NAVIGATION)]}}))}))},nn=function(e){return t(void 0,void 0,void 0,(function(){var t,o,r;return n(this,(function(n){switch(n.label){case 0:return(t=customElements.get(ze.DIALOG_BOX))?[2,t]:[4,Zt()];case 1:return o=n.sent(),[4,en(o)];case 2:return(r=n.sent()).hass=e.hass,[2,new Promise((function(e){r.addEventListener(Qe.SHOW_DIALOG,(function(t){var n=t.detail.dialogImport();e(n)}),{once:!0}),r._deleteBackup({parentElement:{anchorElement:{backup:!0}}})}))]}}))}))},on=function(e,t,n,o){e.dispatchEvent(new CustomEvent(Qe.SHOW_DIALOG,{bubbles:!0,cancelable:!1,composed:!0,detail:{dialogTag:t,dialogImport:n,dialogParams:o}}))},rn=function(e){return t(void 0,void 0,void 0,(function(){var o;return n(this,(function(r){switch(r.label){case 0:return[4,t(void 0,void 0,void 0,(function(){var e,t,o;return n(this,(function(n){switch(n.label){case 0:return(e=customElements.get(ze.DIALOG_RESTART))?[2,e]:[4,Zt()];case 1:return t=n.sent(),[4,tn(t)];case 2:return o=n.sent(),[2,new Promise((function(e){o.addEventListener(Qe.SHOW_DIALOG,(function(t){var n=t.detail.dialogImport();e(n)}),{once:!0}),o._showRestartDialog()}))]}}))}))];case 1:return o=r.sent(),function(e,t){on(e,ze.DIALOG_RESTART,t,{})}(e,(function(){return Promise.resolve(o)})),[2]}}))}))},an=function(e,t){e.dispatchEvent(new CustomEvent(Qe.HASS_MORE_INFO,{detail:{entityId:t}}))},cn=function(o){return{openAlertDialog:function(e){var r=e.title,i=e.text,a=e.confirmText,c=e.confirm;!function(e,o){t(void 0,void 0,void 0,(function(){var t;return n(this,(function(n){switch(n.label){case 0:return[4,nn(e)];case 1:return t=n.sent(),on(e,ze.DIALOG_BOX,(function(){return Promise.resolve(t)}),o),[2]}}))}))}(o,{title:r,text:i,confirmText:a,confirm:c})},openConfirmDialog:function(r){var i=r.title,a=r.text,c=r.destructive,s=r.confirmText,u=r.dismissText,_=r.confirm,l=r.cancel;!function(o,r){t(void 0,void 0,void 0,(function(){var t;return n(this,(function(n){switch(n.label){case 0:return[4,nn(o)];case 1:return t=n.sent(),on(o,ze.DIALOG_BOX,(function(){return Promise.resolve(t)}),e(e({},r),{confirmation:!0})),[2]}}))}))}(o,{title:i,text:a,destructive:c,confirmText:s,dismissText:u,confirm:_,cancel:l})},openRestartDialog:function(){rn(o)},openMoreInfoDialog:function(e){an(o,e)}}},sn={backgroundColor:Qt(qe.NOTIFICATION_COLOR,Ke.ACCENT_COLOR),color:Qt(qe.NOTIFICATION_TEXT_COLOR,Ke.TEXT_ACCENT_COLOR,Ke.TEXT_PRIMARY_COLOR),display:"block",maxWidth:"80px",overflow:"hidden",textOverflow:"ellipsis",textWrap:"nowrap",zIndex:1},un=((it={})["".concat(We.HOST_EXPANDED," ").concat(je.ITEM," > ").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 <span class="item-text" slot="headline">'.concat(e.item,'</span>\n <span class="badge" slot="end"></span>\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;a<i;a++){var c=a>n-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&&a<c||!n&&a>0?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)}}();