Skip to content

Instantly share code, notes, and snippets.

@elchininet
Last active June 7, 2026 15:35
Show Gist options
  • Select an option

  • Save elchininet/8e835f2946bfcd87595eaea54be1a2d9 to your computer and use it in GitHub Desktop.

Select an option

Save elchininet/8e835f2946bfcd87595eaea54be1a2d9 to your computer and use it in GitHub Desktop.
Custom Sidebar bundle with debug logs to debug what happens during restarts
!function(){"use strict";function e(e,t,n,i){return new(n||(n=Promise))((function(o,r){function s(e){try{c(i.next(e))}catch(e){r(e)}}function a(e){try{c(i.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((i=i.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const t=10,n=10,i=(e,i,o={})=>{var r;const{retries:s=t,delay:a=n,shouldReject:c=!0}=o,l=null!==(r=o.rejectMessage)&&void 0!==r?r:"Could not get the result after {{ retries }} retries";return new Promise(((t,n)=>{let o=0;const r=()=>{const d=e();i(d)?t(d):(o++,o<s?setTimeout(r,a):c?n(new Error(l.replace(/\{\{\s*retries\s*\}\}/g,`${s}`))):t(d))};r()}))};function o(e,t,n,i){return new(n||(n=Promise))((function(t,o){function r(e){try{a(i.next(e))}catch(e){o(e)}}function s(e){try{a(i.throw(e))}catch(e){o(e)}}function a(e){var i;e.done?t(e.value):(i=e.value,i instanceof n?i:new n((function(e){e(i)}))).then(r,s)}a((i=i.apply(e,[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const r="$",s=":host",a="invalid selector",c=10,l=10,d=!1,u=()=>`You can not select a shadowRoot (${r}) of the document.`,h=()=>`You can not select a shadowRoot (${r}) of a shadowRoot.`,_=e=>"string"==typeof e,p=e=>{const t=["retries","delay","shouldReject"];return n=e,"[object Object]"===Object.prototype.toString.call(n)&&(0===Object.keys(e).length||Object.keys(e).every((e=>t.includes(e))));var n},f=(e,t,n)=>{var i,o,r,s,a,u;if(_(e))return p(t)?[document,e,null!==(i=t.retries)&&void 0!==i?i:c,null!==(o=t.delay)&&void 0!==o?o:l,null!==(r=t.shouldReject)&&void 0!==r?r:d]:[document,e,c,l,d];if((e=>!!e&&(e instanceof Document||e instanceof Element||e instanceof ShadowRoot))(e)&&_(t))return p(n)?[e,t,null!==(s=n.retries)&&void 0!==s?s:c,null!==(a=n.delay)&&void 0!==a?a:l,null!==(u=n.shouldReject)&&void 0!==u?u:d]:[e,t,c,l,d];throw new TypeError("Wrong parameters have been provided.")};function E(e,t){return function(e){return e.split(",").map((e=>e.trim()))}(e).map((e=>{const n=function(e){return e.split(r).map((e=>e.trim()))}(e);return t(n)}))}function O(e,t){return`${e} cannot be used with a selector ending in a shadowRoot (${r}).${t?` If you want to select a shadowRoot, use ${t} instead.`:""}`}function m(e){return e instanceof Promise?e:Promise.resolve(e)}function T(e,t){var n,i;let o=null;const r=e.length;for(let a=0;a<r;a++){if(0===a)if(e[a].length)o=t.querySelector(e[a]);else{if(t instanceof Document)throw new SyntaxError(u());if(t instanceof ShadowRoot)throw new SyntaxError(h());o=(null===(n=t.shadowRoot)||void 0===n?void 0:n.querySelector(e[++a]))||null}else o=(null===(i=o.shadowRoot)||void 0===i?void 0:i.querySelector(`${s} ${e[a]}`))||null;if(null===o)return null}return o}function A(e,t){var n;const i=[...e],o=i.pop();if(!i.length)return t.querySelectorAll(o);const r=T(i,t);return(null===(n=null==r?void 0:r.shadowRoot)||void 0===n?void 0:n.querySelectorAll(`${s} ${o}`))||null}function b(e,t){if(1===e.length&&!e[0].length){if(t instanceof Document)throw new SyntaxError(u());if(t instanceof ShadowRoot)throw new SyntaxError(h());return t.shadowRoot}const n=T(e,t);return(null==n?void 0:n.shadowRoot)||null}const g=(e,t)=>{const n=e.querySelectorAll(t);if(n.length)return n;if(e instanceof Element&&e.shadowRoot){const n=g(e.shadowRoot,t);if(n.length)return n}const i=Array.from(e.querySelectorAll("*"));for(const e of i){const n=g(e,t);if(n.length)return n}return document.querySelectorAll(a)},I=(e,t,n,o,r)=>i((()=>g(e,t)),(e=>!!e.length),{retries:n,delay:o,shouldReject:r});function S(e,t,n){return o(this,0,void 0,(function*(){return yield function(e,t,n,r,s){return o(this,0,void 0,(function*(){return i((()=>function(e,t,n="querySelector",i="shadowRootQuerySelector"){const o=E(t,(e=>{if(!e[e.length-1].length)throw new SyntaxError(O(n,i));return e})),r=o.length;for(let t=0;t<r;t++){const n=T(o[t],e);if(n)return n}return null}(e,t,"asyncQuerySelector","asyncShadowRootQuerySelector")),(e=>!!e),{retries:n,delay:r,shouldReject:s})}))}(...f(e,t,n))}))}function R(e,t,n){return o(this,0,void 0,(function*(){return function(e,t,n,r,s){return o(this,0,void 0,(function*(){return i((()=>function(e,t,n="querySelectorAll"){const i=E(t,(e=>{if(!e[e.length-1].length)throw new SyntaxError(O(n));return e})),o=i.length;for(let t=0;t<o;t++){const n=A(i[t],e);if(null==n?void 0:n.length)return n}return document.querySelectorAll(a)}(e,t,"asyncQuerySelectorAll")),(e=>!!e.length),{retries:n,delay:r,shouldReject:s})}))}(...f(e,t,n))}))}function y(e,t,n){return o(this,0,void 0,(function*(){return function(e,t,n,s,a){return o(this,0,void 0,(function*(){return i((()=>function(e,t,n="shadowRootQuerySelector",i="querySelector"){const o=E(t,(e=>{if(e.pop().length)throw new SyntaxError(function(e,t){return`${e} must be used with a selector ending in a shadowRoot (${r}). If you don't want to select a shadowRoot, use ${t} instead.`}(n,i));return e})),s=o.length;for(let t=0;t<s;t++){const n=b(o[t],e);if(n)return n}return null}(e,t,"asyncShadowRootQuerySelector","asyncQuerySelector")),(e=>!!e),{retries:n,delay:s,shouldReject:a})}))}(...f(e,t,n))}))}class N{constructor(e,t){e instanceof Node||e instanceof Promise?(this._element=e,this._asyncParams=Object.assign({retries:c,delay:l,shouldReject:d},t||{})):(this._element=document,this._asyncParams=Object.assign({retries:c,delay:l,shouldReject:d},e||{}))}get element(){return m(this._element).then((e=>{if(e instanceof NodeList){if(e[0])return e[0];if(!this._asyncParams.shouldReject)return null;throw new SyntaxError('The "element" method can only be called from a NodeList with elements.')}if(e)return e;if(!this._asyncParams.shouldReject)return null;throw new SyntaxError('The "element" method can only be called from a non-null element.')}))}get $(){const e=m(this._element).then((e=>{if(e instanceof Document||e instanceof ShadowRoot||null===e||e instanceof NodeList&&0===e.length){if(!this._asyncParams.shouldReject)return null;throw new SyntaxError('The "$" method can only be called in an element with a ShadowRoot.')}return e instanceof NodeList?y(e[0],r,this._asyncParams):y(e,r,this._asyncParams)}));return new N(e,this._asyncParams)}get all(){return m(this._element).then((e=>{if(e instanceof NodeList){if(0===e.length&&this._asyncParams.shouldReject)throw new SyntaxError('The "all" method can only be called in a valid element.');return e}if(!this._asyncParams.shouldReject)return document.querySelectorAll(a);throw new SyntaxError('The "all" method can only be called in a NodeList element.')}))}get asyncParams(){return this._asyncParams}eq(e){return o(this,0,void 0,(function*(){return m(this._element).then((t=>{if(t instanceof NodeList){if(t[e])return t[e];if(!this._asyncParams.shouldReject)return null;throw new SyntaxError(`Could not get any element at index ${e}.`)}if(!this._asyncParams.shouldReject)return null;throw new SyntaxError('The "eq" method can only be called in a NodeList element.')}))}))}query(e){const t=m(this._element).then((t=>{if(null===t||t instanceof NodeList&&0===t.length){if(!this._asyncParams.shouldReject)return null;throw new SyntaxError('The "query" method can only be called from a defined element.')}return t instanceof NodeList?R(t[0],e,this._asyncParams):R(t,e,this._asyncParams)}));return new N(t,this._asyncParams)}deepQuery(e){const t=m(this._element).then((t=>{if(null===t||t instanceof NodeList&&0===t.length){if(!this._asyncParams.shouldReject)return null;throw new SyntaxError('The "deepQuery" method can only be called from a defined element.')}return t instanceof NodeList?Promise.race(Array.from(t).map((t=>I(t,e,this._asyncParams.retries,this._asyncParams.delay,this._asyncParams.shouldReject)))):I(t,e,this._asyncParams.retries,this._asyncParams.delay,this._asyncParams.shouldReject)}));return new N(t,this._asyncParams)}}const C="$",v={retries:100,delay:50,shouldReject:!1,eventThreshold:450};var L,w,D,$,x;!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"}(L||(L={})),function(e){e.HA_PANEL_LOVELACE="HA_PANEL_LOVELACE",e.HUI_ROOT="HUI_ROOT",e.HEADER="HEADER",e.HUI_VIEW="HUI_VIEW"}(w||(w={})),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"}(D||(D={})),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"}($||($={})),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_ADAPTATIVE_DIALOG="ha-adaptive-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"}(x||(x={}));const M={[L.HOME_ASSISTANT]:{selector:x.HOME_ASSISTANT,children:{shadowRoot:{selector:C,children:{[L.HOME_ASSISTANT_MAIN]:{selector:x.HOME_ASSISTANT_MAIN,children:{shadowRoot:{selector:C,children:{[L.HA_DRAWER]:{selector:x.HA_DRAWER,children:{[L.HA_SIDEBAR]:{selector:x.HA_SIDEBAR,children:{shadowRoot:{selector:C}}},[L.PARTIAL_PANEL_RESOLVER]:{selector:x.PARTIAL_PANEL_RESOLVER}}}}}}}}}}}},H={[w.HA_PANEL_LOVELACE]:{selector:x.HA_PANEL_LOVELACE,children:{shadowRoot:{selector:C,children:{[w.HUI_ROOT]:{selector:x.HUI_ROOT,children:{shadowRoot:{selector:C,children:{[w.HEADER]:{selector:x.HEADER},[w.HUI_VIEW]:{selector:x.HUI_VIEW}}}}}}}}}},B={shadowRoot:{selector:C,children:{[D.HA_MORE_INFO_DIALOG]:{selector:x.HA_MORE_INFO_DIALOG,children:{shadowRoot:{selector:C,children:{[D.HA_DIALOG]:{selector:`${x.HA_ADAPTATIVE_DIALOG}, ${x.HA_DIALOG}`,children:{[D.HA_DIALOG_CONTENT]:{selector:x.HA_DIALOG_CONTENT,children:{[D.HA_MORE_INFO_DIALOG_INFO]:{selector:x.HA_MORE_INFO_DIALOG_INFO},[D.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK]:{selector:x.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK},[D.HA_DIALOG_MORE_INFO_SETTINGS]:{selector:x.HA_DIALOG_MORE_INFO_SETTINGS}}}}}}}}}}}};"function"==typeof SuppressedError&&SuppressedError;const k=(e,t,n,i=!1)=>Object.entries(t||{}).reduce(((t,o)=>{const[r,s]=o;if(s.selector===C&&n)return s.children?Object.assign(Object.assign({},t),k(e,s.children,n,!0)):t;const a=n?n.then((t=>{return t?S(t,(n=s.selector,i?"$ "+n:n),e):null;var n})):S(s.selector,e);return t[r]={element:a,children:k(e,s.children,a),selector:new N(a,e)},t}),{}),P=(e,t)=>{const n=Object.entries(t);for(const t of n){if(t[0]===e)return t[1];{const n=P(e,t[1].children);if(n)return n}}},F=(e,t)=>Object.keys(e).reduce(((e,n)=>{const i=P(n,t);if(i){const{children:t}=i,o=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(i=Object.getOwnPropertySymbols(e);o<i.length;o++)t.indexOf(i[o])<0&&Object.prototype.propertyIsEnumerable.call(e,i[o])&&(n[i[o]]=e[i[o]])}return n}(i,["children"]);e[n]=Object.assign({},o)}return e}),{});class j{constructor(){this.delegate=document.createDocumentFragment()}addEventListener(...e){this.delegate.addEventListener(...e)}dispatchEvent(...e){return this.delegate.dispatchEvent(...e)}removeEventListener(...e){return this.delegate.removeEventListener(...e)}}let U=class extends j{constructor(e={}){super(),this._config=Object.assign(Object.assign({},v),e),this._timestaps={}}_dispatchEvent(e,t){const n=Date.now();this._timestaps[e]&&n-this._timestaps[e]<this._config.eventThreshold||(this._timestaps[e]=n,this.dispatchEvent(new CustomEvent(e,{detail:t})))}_updateDialogElements(e=D.HA_MORE_INFO_DIALOG_INFO){this._dialogTree=k(this._config,B,this._haRootElements.HOME_ASSISTANT.element);const t=F(D,this._dialogTree);t.HA_DIALOG_CONTENT.element.then((e=>{this._dialogsContentObserver.disconnect(),this._dialogsContentObserver.observe(e,{childList:!0})})),this._haDialogElements=((e,t)=>[D.HA_MORE_INFO_DIALOG,D.HA_DIALOG,D.HA_DIALOG_CONTENT,t].reduce(((t,n)=>(t[n]=e[n],t)),{}))(t,e);const n={[D.HA_MORE_INFO_DIALOG_INFO]:$.ON_MORE_INFO_DIALOG_OPEN,[D.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK]:$.ON_HISTORY_AND_LOGBOOK_DIALOG_OPEN,[D.HA_DIALOG_MORE_INFO_SETTINGS]:$.ON_SETTINGS_DIALOG_OPEN};this._dispatchEvent(n[e],this._haDialogElements)}_updateRootElements(){this._homeAssistantRootTree=k(this._config,M),this._haRootElements=F(L,this._homeAssistantRootTree),this._haRootElements[L.HOME_ASSISTANT].selector.$.element.then((e=>{this._dialogsObserver.disconnect(),this._dialogsObserver.observe(e,{childList:!0})})),this._haRootElements[L.PARTIAL_PANEL_RESOLVER].element.then((e=>{this._panelResolverObserver.disconnect(),e&&this._panelResolverObserver.observe(e,{subtree:!0,childList:!0})})),this._dispatchEvent($.ON_LISTEN,this._haRootElements),this._dispatchEvent($.ON_PANEL_LOAD,this._haRootElements)}_updateLovelaceElements(){this._homeAssistantResolverTree=k(this._config,H,this._haRootElements[L.HA_DRAWER].element),this._haResolverElements=F(w,this._homeAssistantResolverTree),this._haResolverElements[w.HA_PANEL_LOVELACE].element.then((e=>{this._lovelaceObserver.disconnect(),e&&(this._lovelaceObserver.observe(e.shadowRoot,{childList:!0}),this._dispatchEvent($.ON_LOVELACE_PANEL_LOAD,Object.assign(Object.assign({},this._haRootElements),this._haResolverElements)))}))}_watchDialogs(e){e.forEach((({addedNodes:e})=>{e.forEach((e=>{e instanceof Element&&e.localName===x.HA_MORE_INFO_DIALOG&&(this._dialogsChildrenObserver.disconnect(),this._dialogsChildrenObserver.observe(e.shadowRoot,{childList:!0}),this._updateDialogElements())}))}))}_watchDialogsChildren(e){e.forEach((({addedNodes:e})=>{e.forEach((e=>{const t=[`${x.HA_DIALOG}`,`${x.HA_ADAPTATIVE_DIALOG}`];e instanceof Element&&t.includes(e.localName)&&this._updateDialogElements()}))}))}_watchDialogsContent(e){e.forEach((({addedNodes:e})=>{e.forEach((e=>{const t={[x.HA_MORE_INFO_DIALOG_INFO]:D.HA_MORE_INFO_DIALOG_INFO,[x.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK]:D.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK,[x.HA_DIALOG_MORE_INFO_SETTINGS]:D.HA_DIALOG_MORE_INFO_SETTINGS};if(e instanceof Element&&e.localName&&e.localName in t){const n=e.localName;this._updateDialogElements(t[n])}}))}))}_watchDashboards(e){e.forEach((({addedNodes:e})=>{e.forEach((e=>{this._dispatchEvent($.ON_PANEL_LOAD,this._haRootElements),e instanceof Element&&e.localName===x.HA_PANEL_LOVELACE&&this._updateLovelaceElements()}))}))}_watchLovelace(e){e.forEach((({addedNodes:e})=>{e.forEach((e=>{e instanceof Element&&e.localName===x.HUI_ROOT&&this._updateLovelaceElements()}))}))}listen(){this._watchDialogsBinded=this._watchDialogs.bind(this),this._watchDialogsChildrenBinded=this._watchDialogsChildren.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._dialogsChildrenObserver=new MutationObserver(this._watchDialogsChildrenBinded),this._dialogsContentObserver=new MutationObserver(this._watchDialogsContentBinded),this._panelResolverObserver=new MutationObserver(this._watchDashboardsBinded),this._lovelaceObserver=new MutationObserver(this._watchLovelaceBinded),this._updateRootElements(),this._updateLovelaceElements()}addEventListener(e,t,n){super.addEventListener(e,t,n)}};const G="[home-assistant-javascript-templates]",V=/^([a-z_]+)\.(\w+)$/;var W,X,q,K;!function(e){e.UNKNOWN="unknown",e.UNAVAILABLE="unavailable"}(W||(W={})),function(e){e.AREA_ID="area_id",e.NAME="name"}(X||(X={})),function(e){e.PANEL_URL="panel_url",e.LANG="lang"}(q||(q={})),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"}(K||(K={}));const Y="refs",J=e=>e.reduce(((e,t)=>{const[n,i]=t;return e[n.replace(V,"$2")]=i,e}),{}),z=e=>e.includes("."),Q="ref",Z="value",ee="toJSON",te=e=>`${Q}.${e}`;function ne(e,t,n){const i=()=>Object.entries(e.hass.areas),o=()=>Object.entries(e.hass.devices),r=()=>Object.entries(e.hass.entities),s=new Set,a=new Map,c=(e,t)=>{n&&console.warn(`${e} ${t} used in a JavaScript template doesn't exist`)},l=e=>c("Entity",e),d=e=>c("Domain",e),u=e=>{const i=new SyntaxError(e);if(t)throw i;n&&console.warn(i)},h=t=>{e.hass.states[t]?s.add(t):l(t)},_=e=>{s.add(e)},p=(t,n)=>{const{with_unit:i=!1,rounded:o=!1}=n;if(t){const n=t.state,r=t.attributes.unit_of_measurement,s=Number(o),a=!1===o||isNaN(Number(n))?n:new Intl.NumberFormat(e.hass.language,{minimumFractionDigits:s,maximumFractionDigits:s}).format(Number(n));return i&&r?`${a} ${r}`:a}},f=e=>new Proxy(e,{get:(e,t)=>"state_with_unit"===t?p(e,{rounded:!0,with_unit:!0}):e[t]});return{get hass(){return e.hass},states:new Proxy(((t,n={})=>{if(z(t))return h(t),p(e.hass.states[t],n);throw SyntaxError(`${G}: states method cannot be used with a domain, use it as an object instead.`)}),{get(t,n){if(z(n))return h(n),f(e.hass.states[n]);const i=Object.entries(e.hass.states).filter((([e])=>e.startsWith(n)));return i.length||d(n),new Proxy(J(i),{get:(e,t)=>(h(`${n}.${t}`),f(e[t]))})}}),state_translated(t){if(h(t),e.hass.states[t])return e.hass.formatEntityState(e.hass.states[t])},is_state(t,n){var i;return h(t),Array.isArray(n)?n.some((n=>{var i;return(null===(i=e.hass.states[t])||void 0===i?void 0:i.state)===n})):(null===(i=e.hass.states[t])||void 0===i?void 0:i.state)===n},state_attr(t,n){var i,o;return h(t),null===(o=null===(i=e.hass.states[t])||void 0===i?void 0:i.attributes)||void 0===o?void 0:o[n]},state_attr_translated(t,n){if(h(t),e.hass.states[t])return e.hass.formatEntityAttributeValue(e.hass.states[t],n)},is_state_attr(e,t,n){return this.state_attr(e,t)===n},has_value(e){return this.states(e)?!(this.is_state(e,W.UNKNOWN)||this.is_state(e,W.UNAVAILABLE)):(l(e),!1)},entities:new Proxy((t=>{if(void 0===t)return e.hass.entities;if(z(t))return h(t),e.hass.entities[t];const n=r().filter((([e])=>e.startsWith(t)));return n.length||d(t),new Proxy(J(n),{get:(e,n)=>(h(`${t}.${n}`),e[n])})}),{get:(e,t)=>e(t)}),entity_prop(t,n){var i;return h(t),null===(i=e.hass.entities[t])||void 0===i?void 0:i[n]},is_entity_prop(e,t,n){return this.entity_prop(e,t)===n},devices:new Proxy((t=>{if(void 0===t)return e.hass.devices;if(z(t))throw SyntaxError(`${G}: devices method cannot be used with an entity id, you should use a device id instead.`);return e.hass.devices[t]}),{get(t,n){if(z(n))throw SyntaxError(`${G}: devices cannot be accesed using an entity id, you should use a device id instead.`);return e.hass.devices[n]}}),device_attr(t,n){var i,o,r;if(z(t)){h(t);const r=null===(i=e.hass.entities[t])||void 0===i?void 0:i.device_id;return null===(o=e.hass.devices[r])||void 0===o?void 0:o[n]}return null===(r=e.hass.devices[t])||void 0===r?void 0:r[n]},is_device_attr(e,t,n){return this.device_attr(e,t)===n},device_id(t){var n;if(z(t))return h(t),null===(n=e.hass.entities[t])||void 0===n?void 0:n.device_id;const i=o().find((e=>e[1].name===t));return null==i?void 0:i[0]},device_name(t){var n,i,o,r,s;if(z(t)){h(t);const r=null===(n=e.hass.entities[t])||void 0===n?void 0:n.device_id;return null!==(o=null===(i=e.hass.devices[r])||void 0===i?void 0:i.name)&&void 0!==o?o:void 0}return null!==(s=null===(r=e.hass.devices[t])||void 0===r?void 0:r.name)&&void 0!==s?s:void 0},areas:()=>i().map((([,e])=>e.area_id)),area_id(t){var n,o;if(t in e.hass.devices)return this.device_attr(t,X.AREA_ID);const r=null===(n=e.hass.entities[t])||void 0===n?void 0:n.device_id;if(r)return this.device_attr(r,X.AREA_ID);const s=i().find((([,e])=>e.name===t));return null===(o=null==s?void 0:s[1])||void 0===o?void 0:o.area_id},area_name(t){var n,o;let r;t in e.hass.devices&&(r=this.device_attr(t,X.AREA_ID));const s=null===(n=e.hass.entities[t])||void 0===n?void 0:n.device_id;s&&(r=this.device_attr(s,X.AREA_ID));const a=i().find((([,e])=>e.area_id===t||e.area_id===r));return null===(o=null==a?void 0:a[1])||void 0===o?void 0:o.name},area_entities(e){const t=i().find((([,t])=>t.area_id===e||t.name===e));return t?r().filter((([,e])=>e.area_id===t[1].area_id)).map((([e])=>e)):[]},area_devices(e){const t=i().find((([,t])=>t.area_id===e||t.name===e));return t?o().filter((([,e])=>e.area_id===t[1].area_id)).map((([,e])=>e.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 s},cleanTracked(){s.clear()},ref(e,t,n=void 0){const i=te(t);if(a.has(t))return a.get(t);const o=new Proxy({[Z]:n,[ee](){return this[Z]}},{get(e,t,n){if(t===Z||t===ee)return _(i),Reflect.get(e,t,n);u(`${t} is not a valid ${Q} property. A ${Q} only exposes a "${Z}" property`)},set(t,n,o){if(n===Z){const n=t[Z];return t[Z]=o,e({event_type:K.STATE_CHANGE_EVENT,data:{entity_id:i,old_state:{state:JSON.stringify(n)},new_state:{state:JSON.stringify(o)}}}),!0}return u(`property "${n}" cannot be set in a ${Q}`),!1}});return a.set(t,o),o},unref(e,t){const n=te(t);a.has(t)?(a.delete(t),e(n)):u(`${t} is not a ref or it has been unrefed already`)},refs(e,t,n={}){const i=this.ref,o=this.unref,r=new Proxy(n,{get:(t,n)=>i(e,n).value,set:(t,n,o)=>(i(e,n).value=o,!0)});return Object.entries(n).forEach((n=>{const[r,s]=n;a.has(r)&&o(t,r),i(e,r,s)})),r},cleanRefs(e){Array.from(a.keys()).forEach((t=>{this.unref(e,t)}))},clientSideProxy:new Proxy({},{get(t,i){switch(Object.values(q).includes(i)&&_(i),i){case q.PANEL_URL:return window.location.pathname;case q.LANG:return e.hass.language}n&&console.warn(`clientSideProxy should only be used to access these variables: ${Object.values(q).join(", ")}`)}})}}class ie{constructor(e,t){const{throwErrors:n=!1,throwWarnings:i=!0,variables:o={},refs:r={},refsVariableName:s=Y,autoReturn:a=!0}=t;this._throwErrors=n,this._throwWarnings=i,this._variables=o,this._refsVariableName=s,this._autoReturn=a,this._subscriptions=new Map,this._clientSideEntitiesRegExp=new RegExp(`(^|[ \\?(+:\\{\\[><,])(${Object.values(q).join("|")})($|[ \\?)+:\\}\\]><.,])`,"gm"),this._scopped=ne(e,n,i),this.refs=r,this._watchForPanelUrlChange(),this._watchForEntitiesChange(),this._watchForLanguageChange()}_executeRenderingFunctions(e){this._subscriptions.get(e).forEach(((e,t)=>{e.forEach(((e,n)=>{this.trackTemplate(t,n,e)}))}))}_watchForPanelUrlChange(){window.addEventListener(K.LOCATION_CHANGED,(()=>{this._panelUrlWatchCallback()})),window.addEventListener(K.POPSTATE,(()=>{this._panelUrlWatchCallback()}))}_panelUrlWatchCallback(){this._subscriptions.has(q.PANEL_URL)&&this._executeRenderingFunctions(q.PANEL_URL)}_watchForEntitiesChange(){window.hassConnection.then((e=>{e.conn.subscribeMessage((e=>this._entityWatchCallback(e)),{type:K.SUBSCRIBE_EVENTS,event_type:K.STATE_CHANGE_EVENT})}))}_watchForLanguageChange(){window.addEventListener(K.TRANSLATIONS_UPDATED,(()=>{this._subscriptions.has(q.LANG)&&this._executeRenderingFunctions(q.LANG)}))}_entityWatchCallback(e){if(this._subscriptions.size){const t=e.data.entity_id;this._subscriptions.has(t)&&this._executeRenderingFunctions(t)}}_storeTracked(e,t,n){this._scopped.tracked.forEach((i=>{const o=[t,n];if(this._subscriptions.has(i)){const n=this._subscriptions.get(i);if(n.has(e)){const i=n.get(e);i.has(t)||i.set(...o)}else n.set(e,new Map([o]))}else this._subscriptions.set(i,new Map([[e,new Map([o])]]))}))}_untrackTemplate(e,t){this._subscriptions.forEach(((n,i)=>{if(n.has(e)){const o=n.get(e);o.delete(t),0===o.size&&(n.delete(e),0===n.size&&this._subscriptions.delete(i))}}))}renderTemplate(e,t={}){try{const{variables:n={},refs:i={}}=t,o=new Map(Object.entries(Object.assign(Object.assign({},this._variables),n))),r=e.trim().replace(this._clientSideEntitiesRegExp,"$1clientSide.$2$3"),s=r.includes("return")||!this._autoReturn?r:`return ${r}`;return new Function("hass","states","state_translated","is_state","state_attr","state_attr_translated","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(o.keys()),`"use strict"; ${s}`)(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.state_attr_translated.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(o.values()))}catch(e){if(this._throwErrors)throw e;return void(this._throwWarnings&&console.warn(e))}}trackTemplate(e,t,n={}){this._scopped.cleanTracked();const i=this.renderTemplate(e,n);return this._storeTracked(e,t,n),t(i),()=>this._untrackTemplate(e,t)}cleanTracked(e){e?this._subscriptions.has(e)&&this._subscriptions.delete(e):this._subscriptions.clear()}get variables(){return this._variables}set variables(e){this._variables=e}get refs(){return this._scopped.refs(this._entityWatchCallback.bind(this),this.cleanTracked.bind(this))}set refs(e){this._scopped.cleanRefs(this.cleanTracked.bind(this)),this._scopped.refs(this._entityWatchCallback.bind(this),this.cleanTracked.bind(this),e)}}class oe{constructor(e,t={}){this._renderer=i((()=>e.hass),(e=>!!(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((()=>new ie(e,t)))}getRenderer(){return this._renderer}}const re=/([A-Z])([a-z0-9_-]+)/g,se=e=>(Array.isArray(e)?e:[e]).map((e=>{if("string"==typeof e)return e;const t=Object.entries(e),n=[],i=[];return t.forEach((e=>{const[t,o]=e;"object"==typeof o?n.push(`${t}{${se(o)}}`):!1===o?n.push(`${t}{display: none !important}`):i.push(`${(e=>e.replace(re,((e,t,n,i)=>{const o=t.toLocaleLowerCase();return i?`-${o}${n}`:`--${o}${n}`})))(t)}:${o}`)})),`${n.join("")}${i.join(";")}`})).join(""),ae=(e,t)=>`${t}_${e}`,ce=e=>e instanceof ShadowRoot?e.host.localName:e.localName,le=(e,t)=>{const n=ae(ce(e),t);return e.querySelector(`#${n}`)};class de{constructor(e={}){var t,n,i;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===(i=e.throwWarnings)||void 0===i||i}getStyleElement(e){return le(e,this._prefix)}addStyle(e,t){((e,t,n,i,o)=>{if(t){let i=le(t,n);if(!i){const e=ae(ce(t),n);i=document.createElement("style"),i.setAttribute("id",e),t.appendChild(i)}i.innerHTML="string"==typeof e?e:se(e)}else o&&console.warn(`${i}: no element has been provided calling "addStyle"`)})(e,t,this._prefix,this._namespace,this._throwWarnings)}removeStyle(e){((e,t,n,i)=>{if(e){const o=le(e,t);o?o.remove():i&&console.warn(`${n}: no style to remove calling "removeStyle"`)}else i&&console.warn(`${n}: no element has been provided calling "removeStyle"`)})(e,this._prefix,this._namespace,this._throwWarnings)}}var ue,he,_e,pe,fe,Ee,Oe,me;!function(e){e.HIDDEN="hidden",e.NARROW="narrow",e.EXTENDED="extended"}(ue||(ue={})),function(e){e.DOCKED="docked",e.AUTO="auto",e.ALWAYS_HIDDEN="always_hidden"}(he||(he={})),function(e){e.AND="AND",e.OR="OR"}(_e||(_e={})),function(e){e.TEXT="text",e.HREF="href"}(pe||(pe={})),function(e){e.NAVIGATE="navigate",e.CALL_SERVICE="call-service",e.JAVASCRIPT="javascript",e.OPEN_DIALOG="open-dialog"}(fe||(fe={})),function(e){e.MORE_INFO="more-info",e.ALERT="alert",e.RESTART="restart"}(Ee||(Ee={})),function(e){e.GET="GET",e.POST="POST"}(Oe||(Oe={})),function(e){e.DATE="date",e.DATETIME="datetime",e.TIME="time",e.RELATIVE="relative"}(me||(me={}));const Te="custom-sidebar",Ae="custom-sidebar-config",be=`/local/${Ae}`,ge="base";var Ie;!function(e){e.BOOLEAN="boolean",e.STRING="string",e.UNDEFINED="undefined",e.NUMBER="number"}(Ie||(Ie={}));var Se,Re,ye,Ne,Ce,ve,Le,we,De,$e,xe;!function(e){e.ANCHOR="a",e.BUTTON="button",e.SPAN="span"}(Se||(Se={})),function(e){e.HOME_ASISTANT="home-assistant",e.HOME_ASSISTANT_MAIN="home-assistant-main",e.DIALOG_BOX="dialog-box",e.DIALOG_RESTART="dialog-restart",e.HA_BUTTON="ha-button",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.HA_ICON="ha-icon",e.HA_ICON_BUTTON="ha-icon-button",e.HA_ICON_BUTTON_HOVER="ha-icon-button:hover",e.HA_PANEL_LOVELACE="ha-panel-lovelace",e.HA_RIPPLE="ha-ripple",e.HA_SIDEBAR="ha-sidebar",e.HA_SVG_ICON="ha-svg-icon",e.HUI_ROOT="hui-root",e.HUI_TIMESTAMP_DISPLAY="hui-timestamp-display",e.HUI_VIEW="hui-view",e.HUI_VIEW_CONTAINER="hui-view-container",e.ITEM="ha-list-item-button",e.ITEM_BASE="ha-list-item-base",e.TOOLTIP="ha-tooltip",e.USER_BADGE="ha-user-badge"}(Re||(Re={})),function(e){e.HA_LAUNCH_SCREEN="#ha-launch-screen",e.HOST=":host",e.HOST_EXPANDED=":host([expanded])",e.HOST_NOT_EXPANDED=":host(:not([expanded]))",e.HOST_EXPANDED_MODAL=":host([expanded][modal])",e.HOST_EXPANDED_NOT_MODAL=":host([expanded]:not([modal]))",e.HOST_EXPANDED_NOT_NAROW=":host([expanded]:not([narrow]))",e.HOST_HOVER_NOT_DISABLED=":host(:hover:not([disabled]))",e.SIDEBAR_LOADER="ha-fade-in",e.SIDEBAR_TOP_ITEMS_CONTAINER=".panels-list > .wrapper > ha-list-nav",e.SIDEBAR_BOTTOM_ITEMS_CONTAINER=".panels-list > ha-list-nav",e.SIDEBAR_SHELL=".sidebar-shell",e.SCOPE=":scope",e.TITLE=".title",e.ITEM=":is(ha-list-item-base, ha-list-item-button)",e.ITEM_SELECTED=".selected",e.ITEM_HOVER="ha-list-item-button:hover",e.SURFACE=".surface",e.SURFACE_HOVERED=".surface.hovered",e.ITEM_TEXT=".item-text",e.BADGE=".badge",e.CONFIGURATION=".configuration",e.HA_MENU_BUTTON=".header .toolbar > ha-menu-button",e.EDIT_SIDEBAR_BUTTON="ha-panel-profile ha-profile-section-general$ ha-pick-dashboard-row + ha-row-item > ha-button",e.SIDEBAR_NOTIFICATIONS_CONTAINER=".notifications-container",e.SIDEBAR_NOTIFICATIONS_CONTAINER_HOVER=".notifications-container:hover",e.SIDEBAR_NOTIFICATIONS=".notifications",e.MENU=".menu",e.MENU_BUTTON=".menu ha-icon-button",e.DATA_INFO="[data-info]"}(ye||(ye={})),function(e){e.MEDIA_HOVER="@media (hover:hover)"}(Ne||(Ne={})),function(e){e.AFTER="::after",e.BEFORE="::before",e.WEBKIT_SCROLLBAR_THUMB="::-webkit-scrollbar-thumb"}(Ce||(Ce={})),function(e){e.BADGE="badge",e.ITEM_SELECTED="selected",e.ITEM_TEXT="item-text",e.USER="user"}(ve||(ve={})),function(e){e.BLOCKED="data-blocked",e.CUSTOM_SIDEBAR_ATTRIBUTES="data-custom-sidebar-attrs",e.DISABLED="disabled",e.EMPTY="data-empty",e.FIXED="data-fixed",e.FOR="for",e.HIDE_DELAY="hide-delay",e.HREF="href",e.ICON="icon",e.ID="id",e.NEW_ITEM="new-item",e.PLACEMENT="placement",e.PROCESSED="data-processed",e.ROLE="role",e.SHOW_DELAY="show-delay",e.SLOT="slot",e.TAB_INDEX="tabindex",e.WITH_DIVIDER="data-divider",e.WITH_NOTIFICATION="data-notification"}(Le||(Le={})),function(e){e.EMPTY="",e.END="end",e.FALSE="false",e.HEADLINE="headline",e.NONE="none",e.RIGHT="right",e.SIDEBAR_PANEL="sidebar-panel",e.START="start",e.TRUE="true",e.ZERO="0"}(we||(we={})),function(e){e.CHANGE="change",e.CLICK="click",e.DOCK_SIDEBAR="hass-dock-sidebar",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",e.SHOW_TOAST="hass-notification",e.SUBSCRIBE_USER_DATA="frontend/subscribe_user_data"}(De||(De={})),function(e){e.ARROW_DOWN="ArrowDown",e.ARROW_UP="ArrowUp",e.ENTER="Enter",e.TAB="Tab"}($e||($e={})),function(e){e.ITEM="HA-LIST-ITEM-BUTTON",e.ITEM_BASE="HA-LIST-ITEM-BASE",e.A="A"}(xe||(xe={}));const Me=["HOME-ASSISTANT","HOME-ASSISTANT-MAIN","HA-SIDEBAR"];var He,Be;!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.HA_SIDEBAR_WIDTH="--ha-sidebar-width",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",e.CURRENT_COLOR="currentColor"}(He||(He={})),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.BUTTON_COLOR_HOVER="--custom-sidebar-button-color-hover",e.BUTTON_BACKGROUND_HOVER="--custom-sidebar-button-background-hover",e.BUTTON_BACKGROUND_HOVER_OPACITY="--custom-sidebar-button-background-hover-opacity",e.DIVIDER_COLOR="--custom-sidebar-divider-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",e.WIDTH="--custom-sidebar-width",e.WIDTH_EXTENDED="--custom-sidebar-width-extended",e.WIDTH_HIDDEN="--custom-sidebar-width-hidden"}(Be||(Be={}));const ke=["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"],Pe=["selection_opacity","item_background_hover_opacity"],Fe=[["item_background",Be.ITEM_BACKGROUND],["item_background_hover",Be.ITEM_BACKGROUND_HOVER],["item_background_hover_opacity",Be.ITEM_BACKGROUND_HOVER_OPACITY],["icon_color",Be.ICON_COLOR],["icon_color_selected",Be.ICON_COLOR_SELECTED],["icon_color_hover",Be.ICON_COLOR_HOVER],["text_color",Be.TEXT_COLOR],["text_color_selected",Be.TEXT_COLOR_SELECTED],["text_color_hover",Be.TEXT_COLOR_HOVER],["selection_background",Be.SELECTION_BACKGROUND],["selection_opacity",Be.SELECTION_OPACITY],["info_color",Be.INFO_COLOR],["info_color_selected",Be.INFO_COLOR_SELECTED],["info_color_hover",Be.INFO_COLOR_HOVER],["notification_color",Be.NOTIFICATION_COLOR],["notification_color_selected",Be.NOTIFICATION_COLOR_SELECTED],["notification_color_hover",Be.NOTIFICATION_COLOR_HOVER],["notification_text_color",Be.NOTIFICATION_TEXT_COLOR],["notification_text_color_selected",Be.NOTIFICATION_TEXT_COLOR_SELECTED],["notification_text_color_hover",Be.NOTIFICATION_TEXT_COLOR_HOVER],["divider_color",Be.DIVIDER_COLOR]],je=[["title_color",Be.TITLE_COLOR],["subtitle_color",Be.SUBTITLE_COLOR],["sidebar_button_color",Be.BUTTON_COLOR],["sidebar_button_color_hover",Be.BUTTON_COLOR_HOVER],["sidebar_button_background_hover",Be.BUTTON_BACKGROUND_HOVER],["sidebar_button_background_hover_opacity",Be.BUTTON_BACKGROUND_HOVER_OPACITY],["sidebar_background",Be.BACKGROUND],["menu_background",Be.MENU_BACKGROUND],["scrollbar_thumb_color",Be.SCROLLBAR_THUMB_COLOR],...Fe],Ue=[["sidebar_border_color",Be.BORDER_COLOR]],Ge=Object.freeze({CHECK_CONFIG:"config/core/check_config",TEMPLATE:"template",SERVICES:"services"}),Ve=Object.freeze({[ue.HIDDEN]:he.ALWAYS_HIDDEN,[ue.NARROW]:he.AUTO,[ue.EXTENDED]:he.DOCKED}),We=Object.freeze({PANEL_VISITED:"panel_visited",SIDEBAR_ITEM_CLICKED:"sidebar_item_clicked"}),Xe=["%","em","ex","px","rem","vh","vmax","vmin","vw"],qe=/\/profile(\/general)?$/,Ke=/^\s*\[\[\[([\s\S]+)\]\]\]\s*$/,Ye=/\{\{[\s\S]*\}\}|\{%[\s\S]*%\}/,Je=/@partial\s+([\w-]+)/g,ze=/^\s*([a-z_]+)\.([\w-]+)\s*$/;var Qe=Object.create,Ze=Object.defineProperty,et=Object.getOwnPropertyDescriptor,tt=Object.getOwnPropertyNames,nt=Object.getPrototypeOf,it=Object.prototype.hasOwnProperty,ot=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),rt=(e,t,n)=>(n=null!=e?Qe(nt(e)):{},((e,t,n,i)=>{if(t&&"object"==typeof t||"function"==typeof t)for(var o,r=tt(t),s=0,a=r.length;s<a;s++)o=r[s],it.call(e,o)||o===n||Ze(e,o,{get:(e=>t[e]).bind(null,o),enumerable:!(i=et(t,o))||i.enumerable});return e})(Ze(n,"default",{value:e,enumerable:!0}),e)),st=ot(((e,t)=>{function n(e){return null==e}t.exports.isNothing=n,t.exports.isObject=function(e){return"object"==typeof e&&null!==e},t.exports.toArray=function(e){return Array.isArray(e)?e:n(e)?[]:[e]},t.exports.repeat=function(e,t){let n="";for(let i=0;i<t;i+=1)n+=e;return n},t.exports.isNegativeZero=function(e){return 0===e&&Number.NEGATIVE_INFINITY===1/e},t.exports.extend=function(e,t){if(t){const n=Object.keys(t);for(let i=0,o=n.length;i<o;i+=1){const o=n[i];e[o]=t[o]}}return e}})),at=ot(((e,t)=>{function n(e,t){let n="";const i=e.reason||"(unknown reason)";return e.mark?(e.mark.name&&(n+='in "'+e.mark.name+'" '),n+="("+(e.mark.line+1)+":"+(e.mark.column+1)+")",!t&&e.mark.snippet&&(n+="\n\n"+e.mark.snippet),i+" "+n):i}function i(e,t){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=t,this.message=n(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack||""}i.prototype=Object.create(Error.prototype),i.prototype.constructor=i,i.prototype.toString=function(e){return this.name+": "+n(this,e)},t.exports=i})),ct=ot(((e,t)=>{var n=st();function i(e,t,n,i,o){let r="",s="";const a=Math.floor(o/2)-1;return i-t>a&&(r=" ... ",t=i-a+r.length),n-i>a&&(s=" ...",n=i+a-s.length),{str:r+e.slice(t,n).replace(/\t/g,"→")+s,pos:i-t+r.length}}function o(e,t){return n.repeat(" ",t-e.length)+e}t.exports=function(e,t){if(t=Object.create(t||null),!e.buffer)return null;t.maxLength||(t.maxLength=79),"number"!=typeof t.indent&&(t.indent=1),"number"!=typeof t.linesBefore&&(t.linesBefore=3),"number"!=typeof t.linesAfter&&(t.linesAfter=2);const r=/\r?\n|\r|\0/g,s=[0],a=[];let c,l=-1;for(;c=r.exec(e.buffer);)a.push(c.index),s.push(c.index+c[0].length),e.position<=c.index&&l<0&&(l=s.length-2);l<0&&(l=s.length-1);let d="";const u=Math.min(e.line+t.linesAfter,a.length).toString().length,h=t.maxLength-(t.indent+u+3);for(let r=1;r<=t.linesBefore&&!(l-r<0);r++){const c=i(e.buffer,s[l-r],a[l-r],e.position-(s[l]-s[l-r]),h);d=n.repeat(" ",t.indent)+o((e.line-r+1).toString(),u)+" | "+c.str+"\n"+d}const _=i(e.buffer,s[l],a[l],e.position,h);d+=n.repeat(" ",t.indent)+o((e.line+1).toString(),u)+" | "+_.str+"\n",d+=n.repeat("-",t.indent+u+3+_.pos)+"^\n";for(let r=1;r<=t.linesAfter&&!(l+r>=a.length);r++){const c=i(e.buffer,s[l+r],a[l+r],e.position-(s[l]-s[l+r]),h);d+=n.repeat(" ",t.indent)+o((e.line+r+1).toString(),u)+" | "+c.str+"\n"}return d.replace(/\n$/,"")}})),lt=ot(((e,t)=>{var n=at(),i=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],o=["scalar","sequence","mapping"];t.exports=function(e,t){if(t=t||{},Object.keys(t).forEach((function(t){if(-1===i.indexOf(t))throw new n('Unknown option "'+t+'" is met in definition of "'+e+'" YAML type.')})),this.options=t,this.tag=e,this.kind=t.kind||null,this.resolve=t.resolve||function(){return!0},this.construct=t.construct||function(e){return e},this.instanceOf=t.instanceOf||null,this.predicate=t.predicate||null,this.represent=t.represent||null,this.representName=t.representName||null,this.defaultStyle=t.defaultStyle||null,this.multi=t.multi||!1,this.styleAliases=function(e){const t={};return null!==e&&Object.keys(e).forEach((function(n){e[n].forEach((function(e){t[String(e)]=n}))})),t}(t.styleAliases||null),-1===o.indexOf(this.kind))throw new n('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')}})),dt=ot(((e,t)=>{var n=at(),i=lt();function o(e,t){const n=[];return e[t].forEach((function(e){let t=n.length;n.forEach((function(n,i){n.tag===e.tag&&n.kind===e.kind&&n.multi===e.multi&&(t=i)})),n[t]=e})),n}function r(e){return this.extend(e)}r.prototype.extend=function(e){let t=[],s=[];if(e instanceof i)s.push(e);else if(Array.isArray(e))s=s.concat(e);else{if(!e||!Array.isArray(e.implicit)&&!Array.isArray(e.explicit))throw new n("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");e.implicit&&(t=t.concat(e.implicit)),e.explicit&&(s=s.concat(e.explicit))}t.forEach((function(e){if(!(e instanceof i))throw new n("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(e.loadKind&&"scalar"!==e.loadKind)throw new n("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(e.multi)throw new n("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")})),s.forEach((function(e){if(!(e instanceof i))throw new n("Specified list of YAML types (or a single Type object) contains a non-Type object.")}));const a=Object.create(r.prototype);return a.implicit=(this.implicit||[]).concat(t),a.explicit=(this.explicit||[]).concat(s),a.compiledImplicit=o(a,"implicit"),a.compiledExplicit=o(a,"explicit"),a.compiledTypeMap=function(){const e={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function t(t){t.multi?(e.multi[t.kind].push(t),e.multi.fallback.push(t)):e[t.kind][t.tag]=e.fallback[t.tag]=t}for(let e=0,n=arguments.length;e<n;e+=1)arguments[e].forEach(t);return e}(a.compiledImplicit,a.compiledExplicit),a},t.exports=r})),ut=ot(((e,t)=>{t.exports=new(lt())("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return null!==e?e:""}})})),ht=ot(((e,t)=>{t.exports=new(lt())("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return null!==e?e:[]}})})),_t=ot(((e,t)=>{t.exports=new(lt())("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return null!==e?e:{}}})})),pt=ot(((e,t)=>{t.exports=new(dt())({explicit:[ut(),ht(),_t()]})})),ft=ot(((e,t)=>{var n=lt();t.exports=new n("tag:yaml.org,2002:null",{kind:"scalar",resolve:function(e){if(null===e)return!0;const t=e.length;return 1===t&&"~"===e||4===t&&("null"===e||"Null"===e||"NULL"===e)},construct:function(){return null},predicate:function(e){return null===e},represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"})})),Et=ot(((e,t)=>{var n=lt();t.exports=new n("tag:yaml.org,2002:bool",{kind:"scalar",resolve:function(e){if(null===e)return!1;const t=e.length;return 4===t&&("true"===e||"True"===e||"TRUE"===e)||5===t&&("false"===e||"False"===e||"FALSE"===e)},construct:function(e){return"true"===e||"True"===e||"TRUE"===e},predicate:function(e){return"[object Boolean]"===Object.prototype.toString.call(e)},represent:{lowercase:function(e){return e?"true":"false"},uppercase:function(e){return e?"TRUE":"FALSE"},camelcase:function(e){return e?"True":"False"}},defaultStyle:"lowercase"})})),Ot=ot(((e,t)=>{var n=st(),i=lt();function o(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function r(e){return e>=48&&e<=55}function s(e){return e>=48&&e<=57}function a(e){let t=e,n=1,i=t[0];if("-"!==i&&"+"!==i||("-"===i&&(n=-1),t=t.slice(1),i=t[0]),"0"===t)return 0;if("0"===i){if("b"===t[1])return n*parseInt(t.slice(2),2);if("x"===t[1])return n*parseInt(t.slice(2),16);if("o"===t[1])return n*parseInt(t.slice(2),8)}return n*parseInt(t,10)}t.exports=new i("tag:yaml.org,2002:int",{kind:"scalar",resolve:function(e){if(null===e)return!1;const t=e.length;let n=0,i=!1;if(!t)return!1;let c=e[n];if("-"!==c&&"+"!==c||(c=e[++n]),"0"===c){if(n+1===t)return!0;if(c=e[++n],"b"===c){for(n++;n<t;n++){if(c=e[n],"0"!==c&&"1"!==c)return!1;i=!0}return i&&Number.isFinite(a(e))}if("x"===c){for(n++;n<t;n++){if(!o(e.charCodeAt(n)))return!1;i=!0}return i&&Number.isFinite(a(e))}if("o"===c){for(n++;n<t;n++){if(!r(e.charCodeAt(n)))return!1;i=!0}return i&&Number.isFinite(a(e))}}for(;n<t;n++){if(!s(e.charCodeAt(n)))return!1;i=!0}return!!i&&Number.isFinite(a(e))},construct:function(e){return a(e)},predicate:function(e){return"[object Number]"===Object.prototype.toString.call(e)&&e%1==0&&!n.isNegativeZero(e)},represent:{binary:function(e){return e>=0?"0b"+e.toString(2):"-0b"+e.toString(2).slice(1)},octal:function(e){return e>=0?"0o"+e.toString(8):"-0o"+e.toString(8).slice(1)},decimal:function(e){return e.toString(10)},hexadecimal:function(e){return e>=0?"0x"+e.toString(16).toUpperCase():"-0x"+e.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}})})),mt=ot(((e,t)=>{var n=st(),i=lt(),o=new RegExp("^(?:[-+]?(?:[0-9]+)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),r=new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");var s=/^[-+]?[0-9]+e/;t.exports=new i("tag:yaml.org,2002:float",{kind:"scalar",resolve:function(e){return null!==e&&(!!o.test(e)&&(!!Number.isFinite(parseFloat(e,10))||r.test(e)))},construct:function(e){let t=e.toLowerCase();const n="-"===t[0]?-1:1;return"+-".indexOf(t[0])>=0&&(t=t.slice(1)),".inf"===t?1===n?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:".nan"===t?NaN:n*parseFloat(t,10)},predicate:function(e){return"[object Number]"===Object.prototype.toString.call(e)&&(e%1!=0||n.isNegativeZero(e))},represent:function(e,t){if(isNaN(e))switch(t){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===e)switch(t){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===e)switch(t){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(n.isNegativeZero(e))return"-0.0";const i=e.toString(10);return s.test(i)?i.replace("e",".e"):i},defaultStyle:"lowercase"})})),Tt=ot(((e,t)=>{t.exports=pt().extend({implicit:[ft(),Et(),Ot(),mt()]})})),At=ot(((e,t)=>{t.exports=Tt()})),bt=ot(((e,t)=>{var n=lt(),i=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),o=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");t.exports=new n("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:function(e){return null!==e&&(null!==i.exec(e)||null!==o.exec(e))},construct:function(e){let t=0,n=null,r=i.exec(e);if(null===r&&(r=o.exec(e)),null===r)throw new Error("Date resolve error");const s=+r[1],a=+r[2]-1,c=+r[3];if(!r[4])return new Date(Date.UTC(s,a,c));const l=+r[4],d=+r[5],u=+r[6];if(r[7]){for(t=r[7].slice(0,3);t.length<3;)t+="0";t=+t}if(r[9]){n=6e4*(60*+r[10]+ +(r[11]||0)),"-"===r[9]&&(n=-n)}const h=new Date(Date.UTC(s,a,c,l,d,u,t));return n&&h.setTime(h.getTime()-n),h},instanceOf:Date,represent:function(e){return e.toISOString()}})})),gt=ot(((e,t)=>{var n=lt();t.exports=new n("tag:yaml.org,2002:merge",{kind:"scalar",resolve:function(e){return"<<"===e||null===e}})})),It=ot(((e,t)=>{var n=lt(),i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r";t.exports=new n("tag:yaml.org,2002:binary",{kind:"scalar",resolve:function(e){if(null===e)return!1;let t=0;const n=e.length,o=i;for(let i=0;i<n;i++){const n=o.indexOf(e.charAt(i));if(!(n>64)){if(n<0)return!1;t+=6}}return t%8==0},construct:function(e){const t=e.replace(/[\r\n=]/g,""),n=t.length,o=i;let r=0;const s=[];for(let e=0;e<n;e++)e%4==0&&e&&(s.push(r>>16&255),s.push(r>>8&255),s.push(255&r)),r=r<<6|o.indexOf(t.charAt(e));const a=n%4*6;return 0===a?(s.push(r>>16&255),s.push(r>>8&255),s.push(255&r)):18===a?(s.push(r>>10&255),s.push(r>>2&255)):12===a&&s.push(r>>4&255),new Uint8Array(s)},predicate:function(e){return"[object Uint8Array]"===Object.prototype.toString.call(e)},represent:function(e){let t="",n=0;const o=e.length,r=i;for(let i=0;i<o;i++)i%3==0&&i&&(t+=r[n>>18&63],t+=r[n>>12&63],t+=r[n>>6&63],t+=r[63&n]),n=(n<<8)+e[i];const s=o%3;return 0===s?(t+=r[n>>18&63],t+=r[n>>12&63],t+=r[n>>6&63],t+=r[63&n]):2===s?(t+=r[n>>10&63],t+=r[n>>4&63],t+=r[n<<2&63],t+=r[64]):1===s&&(t+=r[n>>2&63],t+=r[n<<4&63],t+=r[64],t+=r[64]),t}})})),St=ot(((e,t)=>{var n=lt(),i=Object.prototype.hasOwnProperty,o=Object.prototype.toString;t.exports=new n("tag:yaml.org,2002:omap",{kind:"sequence",resolve:function(e){if(null===e)return!0;const t=[],n=e;for(let e=0,r=n.length;e<r;e+=1){const r=n[e];let s,a=!1;if("[object Object]"!==o.call(r))return!1;for(s in r)if(i.call(r,s)){if(a)return!1;a=!0}if(!a)return!1;if(-1!==t.indexOf(s))return!1;t.push(s)}return!0},construct:function(e){return null!==e?e:[]}})})),Rt=ot(((e,t)=>{var n=lt(),i=Object.prototype.toString;t.exports=new n("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:function(e){if(null===e)return!0;const t=e,n=new Array(t.length);for(let e=0,o=t.length;e<o;e+=1){const o=t[e];if("[object Object]"!==i.call(o))return!1;const r=Object.keys(o);if(1!==r.length)return!1;n[e]=[r[0],o[r[0]]]}return!0},construct:function(e){if(null===e)return[];const t=e,n=new Array(t.length);for(let e=0,i=t.length;e<i;e+=1){const i=t[e],o=Object.keys(i);n[e]=[o[0],i[o[0]]]}return n}})})),yt=ot(((e,t)=>{var n=lt(),i=Object.prototype.hasOwnProperty;t.exports=new n("tag:yaml.org,2002:set",{kind:"mapping",resolve:function(e){if(null===e)return!0;const t=e;for(const e in t)if(i.call(t,e)&&null!==t[e])return!1;return!0},construct:function(e){return null!==e?e:{}}})})),Nt=ot(((e,t)=>{t.exports=At().extend({implicit:[bt(),gt()],explicit:[It(),St(),Rt(),yt()]})})),Ct=ot(((e,t)=>{var n=st(),i=at(),o=ct(),r=Nt(),s=Object.prototype.hasOwnProperty,a=1,c=2,l=3,d=4,u=1,h=2,_=3,p=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,f=/[\x85\u2028\u2029]/,E=/[,\[\]{}]/,O=/^(?:!|!!|![0-9A-Za-z-]+!)$/,m=/^(?:!|[^,\[\]{}])(?:%[0-9a-f]{2}|[0-9a-z\-#;/?:@&=+$,_.!~*'()\[\]])*$/i;function T(e){return Object.prototype.toString.call(e)}function A(e){return 10===e||13===e}function b(e){return 9===e||32===e}function g(e){return 9===e||32===e||10===e||13===e}function I(e){return 44===e||91===e||93===e||123===e||125===e}function S(e){if(e>=48&&e<=57)return e-48;const t=32|e;return t>=97&&t<=102?t-97+10:-1}function R(e){return 120===e?2:117===e?4:85===e?8:0}function y(e){return e>=48&&e<=57?e-48:-1}function N(e){switch(e){case 48:return"\0";case 97:return"";case 98:return"\b";case 116:case 9:return"\t";case 110:return"\n";case 118:return"\v";case 102:return"\f";case 114:return"\r";case 101:return"";case 32:return" ";case 34:return'"';case 47:return"/";case 92:return"\\";case 78:return"…";case 95:return" ";case 76:return"\u2028";case 80:return"\u2029";default:return""}}function C(e){return e<=65535?String.fromCharCode(e):String.fromCharCode(55296+(e-65536>>10),56320+(e-65536&1023))}function v(e,t,n){"__proto__"===t?Object.defineProperty(e,t,{configurable:!0,enumerable:!0,writable:!0,value:n}):e[t]=n}var L=new Array(256),w=new Array(256);for(let e=0;e<256;e++)L[e]=N(e)?1:0,w[e]=N(e);function D(e,t){this.input=e,this.filename=t.filename||null,this.schema=t.schema||r,this.onWarning=t.onWarning||null,this.legacy=t.legacy||!1,this.json=t.json||!1,this.listener=t.listener||null,this.maxDepth="number"==typeof t.maxDepth?t.maxDepth:100,this.maxMergeSeqLength="number"==typeof t.maxMergeSeqLength?t.maxMergeSeqLength:20,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=e.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.depth=0,this.firstTabInLine=-1,this.documents=[],this.anchorMapTransactions=[]}function $(e,t){const n={name:e.filename,buffer:e.input.slice(0,-1),position:e.position,line:e.line,column:e.position-e.lineStart};return n.snippet=o(n),new i(t,n)}function x(e,t){throw $(e,t)}function M(e,t){e.onWarning&&e.onWarning.call(null,$(e,t))}function H(e,t,n){const i=e.anchorMapTransactions;if(0!==i.length){const n=i[i.length-1];s.call(n,t)||(n[t]={existed:s.call(e.anchorMap,t),value:e.anchorMap[t]})}e.anchorMap[t]=n}function B(e){return{position:e.position,line:e.line,lineStart:e.lineStart,lineIndent:e.lineIndent,firstTabInLine:e.firstTabInLine,tag:e.tag,anchor:e.anchor,kind:e.kind,result:e.result}}function k(e,t){e.position=t.position,e.line=t.line,e.lineStart=t.lineStart,e.lineIndent=t.lineIndent,e.firstTabInLine=t.firstTabInLine,e.tag=t.tag,e.anchor=t.anchor,e.kind=t.kind,e.result=t.result}var P={YAML:function(e,t,n){null!==e.version&&x(e,"duplication of %YAML directive"),1!==n.length&&x(e,"YAML directive accepts exactly one argument");const i=/^([0-9]+)\.([0-9]+)$/.exec(n[0]);null===i&&x(e,"ill-formed argument of the YAML directive");const o=parseInt(i[1],10),r=parseInt(i[2],10);1!==o&&x(e,"unacceptable YAML version of the document"),e.version=n[0],e.checkLineBreaks=r<2,1!==r&&2!==r&&M(e,"unsupported YAML version of the document")},TAG:function(e,t,n){let i;2!==n.length&&x(e,"TAG directive accepts exactly two arguments");const o=n[0];i=n[1],O.test(o)||x(e,"ill-formed tag handle (first argument) of the TAG directive"),s.call(e.tagMap,o)&&x(e,'there is a previously declared suffix for "'+o+'" tag handle'),m.test(i)||x(e,"ill-formed tag prefix (second argument) of the TAG directive");try{i=decodeURIComponent(i)}catch(t){x(e,"tag prefix is malformed: "+i)}e.tagMap[o]=i}};function F(e,t,n,i){if(t<n){const o=e.input.slice(t,n);if(i)for(let t=0,n=o.length;t<n;t+=1){const n=o.charCodeAt(t);9===n||n>=32&&n<=1114111||x(e,"expected valid JSON character")}else p.test(o)&&x(e,"the stream contains non-printable characters");e.result+=o}}function j(e,t,i,o){n.isObject(i)||x(e,"cannot merge mappings; the provided source object is unacceptable");const r=Object.keys(i);for(let e=0,n=r.length;e<n;e+=1){const n=r[e];s.call(t,n)||(v(t,n,i[n]),o[n]=!0)}}function U(e,t,n,i,o,r,a,c,l){if(Array.isArray(o))for(let t=0,n=(o=Array.prototype.slice.call(o)).length;t<n;t+=1)Array.isArray(o[t])&&x(e,"nested arrays are not supported inside keys"),"object"==typeof o&&"[object Object]"===T(o[t])&&(o[t]="[object Object]");if("object"==typeof o&&"[object Object]"===T(o)&&(o="[object Object]"),o=String(o),null===t&&(t={}),"tag:yaml.org,2002:merge"===i)if(Array.isArray(r)){r.length>e.maxMergeSeqLength&&x(e,"merge sequence length exceeded maxMergeSeqLength ("+e.maxMergeSeqLength+")");const i=new Set;for(let o=0,s=r.length;o<s;o+=1){const s=r[o];i.has(s)||(i.add(s),j(e,t,s,n))}}else j(e,t,r,n);else e.json||s.call(n,o)||!s.call(t,o)||(e.line=a||e.line,e.lineStart=c||e.lineStart,e.position=l||e.position,x(e,"duplicated mapping key")),v(t,o,r),delete n[o];return t}function G(e){const t=e.input.charCodeAt(e.position);10===t?e.position++:13===t?(e.position++,10===e.input.charCodeAt(e.position)&&e.position++):x(e,"a line break is expected"),e.line+=1,e.lineStart=e.position,e.firstTabInLine=-1}function V(e,t,n){let i=0,o=e.input.charCodeAt(e.position);for(;0!==o;){for(;b(o);)9===o&&-1===e.firstTabInLine&&(e.firstTabInLine=e.position),o=e.input.charCodeAt(++e.position);if(t&&35===o)do{o=e.input.charCodeAt(++e.position)}while(10!==o&&13!==o&&0!==o);if(!A(o))break;for(G(e),o=e.input.charCodeAt(e.position),i++,e.lineIndent=0;32===o;)e.lineIndent++,o=e.input.charCodeAt(++e.position)}return-1!==n&&0!==i&&e.lineIndent<n&&M(e,"deficient indentation"),i}function W(e){let t=e.position,n=e.input.charCodeAt(t);return!(45!==n&&46!==n||n!==e.input.charCodeAt(t+1)||n!==e.input.charCodeAt(t+2)||(t+=3,n=e.input.charCodeAt(t),0!==n&&!g(n)))}function X(e,t){1===t?e.result+=" ":t>1&&(e.result+=n.repeat("\n",t-1))}function q(e,t){const n=e.tag,i=e.anchor,o=[];let r=!1;if(-1!==e.firstTabInLine)return!1;null!==e.anchor&&H(e,e.anchor,o);let s=e.input.charCodeAt(e.position);for(;0!==s&&(-1!==e.firstTabInLine&&(e.position=e.firstTabInLine,x(e,"tab characters must not be used in indentation")),45===s)&&g(e.input.charCodeAt(e.position+1));){if(r=!0,e.position++,V(e,!0,-1)&&e.lineIndent<=t){o.push(null),s=e.input.charCodeAt(e.position);continue}const n=e.line;if(Q(e,t,l,!1,!0),o.push(e.result),V(e,!0,-1),s=e.input.charCodeAt(e.position),(e.line===n||e.lineIndent>t)&&0!==s)x(e,"bad indentation of a sequence entry");else if(e.lineIndent<t)break}return!!r&&(e.tag=n,e.anchor=i,e.kind="sequence",e.result=o,!0)}function K(e,t,n){let i,o,r,s;const a=e.tag,l=e.anchor,u={},h=Object.create(null);let _=null,p=null,f=null,E=!1,O=!1;if(-1!==e.firstTabInLine)return!1;null!==e.anchor&&H(e,e.anchor,u);let m=e.input.charCodeAt(e.position);for(;0!==m;){E||-1===e.firstTabInLine||(e.position=e.firstTabInLine,x(e,"tab characters must not be used in indentation"));const T=e.input.charCodeAt(e.position+1),A=e.line;if(63!==m&&58!==m||!g(T)){if(o=e.line,r=e.lineStart,s=e.position,!Q(e,n,c,!1,!0))break;if(e.line===A){for(m=e.input.charCodeAt(e.position);b(m);)m=e.input.charCodeAt(++e.position);if(58===m)m=e.input.charCodeAt(++e.position),g(m)||x(e,"a whitespace character is expected after the key-value separator within a block mapping"),E&&(U(e,u,h,_,p,null,o,r,s),_=p=f=null),O=!0,E=!1,i=!1,_=e.tag,p=e.result;else{if(!O)return e.tag=a,e.anchor=l,!0;x(e,"can not read an implicit mapping pair; a colon is missed")}}else{if(!O)return e.tag=a,e.anchor=l,!0;x(e,"can not read a block mapping entry; a multiline key may not be an implicit key")}}else 63===m?(E&&(U(e,u,h,_,p,null,o,r,s),_=p=f=null),O=!0,E=!0,i=!0):E?(E=!1,i=!0):x(e,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"),e.position+=1,m=T;if((e.line===A||e.lineIndent>t)&&(E&&(o=e.line,r=e.lineStart,s=e.position),Q(e,t,d,!0,i)&&(E?p=e.result:f=e.result),E||(U(e,u,h,_,p,f,o,r,s),_=p=f=null),V(e,!0,-1),m=e.input.charCodeAt(e.position)),(e.line===A||e.lineIndent>t)&&0!==m)x(e,"bad indentation of a mapping entry");else if(e.lineIndent<t)break}return E&&U(e,u,h,_,p,null,o,r,s),O&&(e.tag=a,e.anchor=l,e.kind="mapping",e.result=u),O}function Y(e){let t,n,i=!1,o=!1,r=e.input.charCodeAt(e.position);if(33!==r)return!1;null!==e.tag&&x(e,"duplication of a tag property"),r=e.input.charCodeAt(++e.position),60===r?(i=!0,r=e.input.charCodeAt(++e.position)):33===r?(o=!0,t="!!",r=e.input.charCodeAt(++e.position)):t="!";let a=e.position;if(i){do{r=e.input.charCodeAt(++e.position)}while(0!==r&&62!==r);e.position<e.length?(n=e.input.slice(a,e.position),r=e.input.charCodeAt(++e.position)):x(e,"unexpected end of the stream within a verbatim tag")}else{for(;0!==r&&!g(r);)33===r&&(o?x(e,"tag suffix cannot contain exclamation marks"):(t=e.input.slice(a-1,e.position+1),O.test(t)||x(e,"named tag handle cannot contain such characters"),o=!0,a=e.position+1)),r=e.input.charCodeAt(++e.position);n=e.input.slice(a,e.position),E.test(n)&&x(e,"tag suffix cannot contain flow indicator characters")}n&&!m.test(n)&&x(e,"tag name cannot contain such characters: "+n);try{n=decodeURIComponent(n)}catch(t){x(e,"tag name is malformed: "+n)}return i?e.tag=n:s.call(e.tagMap,t)?e.tag=e.tagMap[t]+n:"!"===t?e.tag="!"+n:"!!"===t?e.tag="tag:yaml.org,2002:"+n:x(e,'undeclared tag handle "'+t+'"'),!0}function J(e){let t=e.input.charCodeAt(e.position);if(38!==t)return!1;null!==e.anchor&&x(e,"duplication of an anchor property"),t=e.input.charCodeAt(++e.position);const n=e.position;for(;0!==t&&!g(t)&&!I(t);)t=e.input.charCodeAt(++e.position);return e.position===n&&x(e,"name of an anchor node must contain at least one character"),e.anchor=e.input.slice(n,e.position),!0}function z(e,t,n,i){const o=B(e);return function(e){e.anchorMapTransactions.push(Object.create(null))}(e),k(e,t),e.tag=null,e.anchor=null,e.kind=null,e.result=null,K(e,n,i)&&"mapping"===e.kind?(function(e){const t=e.anchorMapTransactions.pop(),n=e.anchorMapTransactions;if(0===n.length)return;const i=n[n.length-1],o=Object.keys(t);for(let e=0,n=o.length;e<n;e+=1){const n=o[e];s.call(i,n)||(i[n]=t[n])}}(e),!0):(function(e){const t=e.anchorMapTransactions.pop(),n=Object.keys(t);for(let i=n.length-1;i>=0;i-=1){const o=t[n[i]];o.existed?e.anchorMap[n[i]]=o.value:delete e.anchorMap[n[i]]}}(e),k(e,o),!1)}function Q(e,t,i,o,r){let p,f,E,O,m,T=1,N=!1,v=!1,D=null;e.depth>=e.maxDepth&&x(e,"nesting exceeded maxDepth ("+e.maxDepth+")"),e.depth+=1,null!==e.listener&&e.listener("open",e),e.tag=null,e.anchor=null,e.kind=null,e.result=null;const $=p=f=d===i||l===i;if(o&&V(e,!0,-1)&&(N=!0,e.lineIndent>t?T=1:e.lineIndent===t?T=0:e.lineIndent<t&&(T=-1)),1===T)for(;;){const n=e.input.charCodeAt(e.position),i=B(e);if(N&&(33===n&&null!==e.tag||38===n&&null!==e.anchor))break;if(!Y(e)&&!J(e))break;null===D&&(D=i),V(e,!0,-1)?(N=!0,f=$,e.lineIndent>t?T=1:e.lineIndent===t?T=0:e.lineIndent<t&&(T=-1)):f=!1}if(f&&(f=N||r),1===T||d===i)if(O=a===i||c===i?t:t+1,m=e.position-e.lineStart,1===T)if(f&&(q(e,m)||K(e,m,O))||function(e,t){let n,i,o,r=!0;const s=e.tag;let c;const l=e.anchor;let d,u,h,_;const p=Object.create(null);let f,E,O,m=e.input.charCodeAt(e.position);if(91===m)d=93,_=!1,c=[];else{if(123!==m)return!1;d=125,_=!0,c={}}for(null!==e.anchor&&H(e,e.anchor,c),m=e.input.charCodeAt(++e.position);0!==m;){if(V(e,!0,t),m=e.input.charCodeAt(e.position),m===d)return e.position++,e.tag=s,e.anchor=l,e.kind=_?"mapping":"sequence",e.result=c,!0;r?44===m&&x(e,"expected the node content, but found ','"):x(e,"missed comma between flow collection entries"),E=f=O=null,u=h=!1,63===m&&g(e.input.charCodeAt(e.position+1))&&(u=h=!0,e.position++,V(e,!0,t)),n=e.line,i=e.lineStart,o=e.position,Q(e,t,a,!1,!0),E=e.tag,f=e.result,V(e,!0,t),m=e.input.charCodeAt(e.position),!h&&e.line!==n||58!==m||(u=!0,m=e.input.charCodeAt(++e.position),V(e,!0,t),Q(e,t,a,!1,!0),O=e.result),_?U(e,c,p,E,f,O,n,i,o):u?c.push(U(e,null,p,E,f,O,n,i,o)):c.push(f),V(e,!0,t),m=e.input.charCodeAt(e.position),44===m?(r=!0,m=e.input.charCodeAt(++e.position)):r=!1}x(e,"unexpected end of the stream within a flow collection")}(e,O))v=!0;else{const t=e.input.charCodeAt(e.position);null!==D&&$&&!f&&124!==t&&62!==t&&z(e,D,D.position-D.lineStart,O)||p&&function(e,t){let i,o,r=u,s=!1,a=!1,c=t,l=0,d=!1,p=e.input.charCodeAt(e.position);if(124===p)i=!1;else{if(62!==p)return!1;i=!0}for(e.kind="scalar",e.result="";0!==p;)if(p=e.input.charCodeAt(++e.position),43===p||45===p)u===r?r=43===p?_:h:x(e,"repeat of a chomping mode identifier");else{if(!((o=y(p))>=0))break;0===o?x(e,"bad explicit indentation width of a block scalar; it cannot be less than one"):a?x(e,"repeat of an indentation width identifier"):(c=t+o-1,a=!0)}if(b(p)){do{p=e.input.charCodeAt(++e.position)}while(b(p));if(35===p)do{p=e.input.charCodeAt(++e.position)}while(!A(p)&&0!==p)}for(;0!==p;){for(G(e),e.lineIndent=0,p=e.input.charCodeAt(e.position);(!a||e.lineIndent<c)&&32===p;)e.lineIndent++,p=e.input.charCodeAt(++e.position);if(!a&&e.lineIndent>c&&(c=e.lineIndent),A(p)){l++;continue}if(a||0!==c||x(e,"missing indentation for block scalar"),e.lineIndent<c){r===_?e.result+=n.repeat("\n",s?1+l:l):r===u&&s&&(e.result+="\n");break}i?b(p)?(d=!0,e.result+=n.repeat("\n",s?1+l:l)):d?(d=!1,e.result+=n.repeat("\n",l+1)):0===l?s&&(e.result+=" "):e.result+=n.repeat("\n",l):e.result+=n.repeat("\n",s?1+l:l),s=!0,a=!0,l=0;const t=e.position;for(;!A(p)&&0!==p;)p=e.input.charCodeAt(++e.position);F(e,t,e.position,!1)}return!0}(e,O)||function(e,t){let n,i,o=e.input.charCodeAt(e.position);if(39!==o)return!1;for(e.kind="scalar",e.result="",e.position++,n=i=e.position;0!==(o=e.input.charCodeAt(e.position));)if(39===o){if(F(e,n,e.position,!0),o=e.input.charCodeAt(++e.position),39!==o)return!0;n=e.position,e.position++,i=e.position}else A(o)?(F(e,n,i,!0),X(e,V(e,!1,t)),n=i=e.position):e.position===e.lineStart&&W(e)?x(e,"unexpected end of the document within a single quoted scalar"):(e.position++,b(o)||(i=e.position));x(e,"unexpected end of the stream within a single quoted scalar")}(e,O)||function(e,t){let n,i,o,r=e.input.charCodeAt(e.position);if(34!==r)return!1;for(e.kind="scalar",e.result="",e.position++,n=i=e.position;0!==(r=e.input.charCodeAt(e.position));){if(34===r)return F(e,n,e.position,!0),e.position++,!0;if(92===r){if(F(e,n,e.position,!0),r=e.input.charCodeAt(++e.position),A(r))V(e,!1,t);else if(r<256&&L[r])e.result+=w[r],e.position++;else if((o=R(r))>0){let t=o,n=0;for(;t>0;t--)r=e.input.charCodeAt(++e.position),(o=S(r))>=0?n=(n<<4)+o:x(e,"expected hexadecimal character");e.result+=C(n),e.position++}else x(e,"unknown escape sequence");n=i=e.position}else A(r)?(F(e,n,i,!0),X(e,V(e,!1,t)),n=i=e.position):e.position===e.lineStart&&W(e)?x(e,"unexpected end of the document within a double quoted scalar"):(e.position++,b(r)||(i=e.position))}x(e,"unexpected end of the stream within a double quoted scalar")}(e,O)?v=!0:!function(e){let t=e.input.charCodeAt(e.position);if(42!==t)return!1;t=e.input.charCodeAt(++e.position);const n=e.position;for(;0!==t&&!g(t)&&!I(t);)t=e.input.charCodeAt(++e.position);e.position===n&&x(e,"name of an alias node must contain at least one character");const i=e.input.slice(n,e.position);return s.call(e.anchorMap,i)||x(e,'unidentified alias "'+i+'"'),e.result=e.anchorMap[i],V(e,!0,-1),!0}(e)?function(e,t,n){let i,o,r,s,a,c;const l=e.kind,d=e.result;let u=e.input.charCodeAt(e.position);if(g(u)||I(u)||35===u||38===u||42===u||33===u||124===u||62===u||39===u||34===u||37===u||64===u||96===u)return!1;if(63===u||45===u){const t=e.input.charCodeAt(e.position+1);if(g(t)||n&&I(t))return!1}for(e.kind="scalar",e.result="",i=o=e.position,r=!1;0!==u;){if(58===u){const t=e.input.charCodeAt(e.position+1);if(g(t)||n&&I(t))break}else if(35===u){if(g(e.input.charCodeAt(e.position-1)))break}else{if(e.position===e.lineStart&&W(e)||n&&I(u))break;if(A(u)){if(s=e.line,a=e.lineStart,c=e.lineIndent,V(e,!1,-1),e.lineIndent>=t){r=!0,u=e.input.charCodeAt(e.position);continue}e.position=o,e.line=s,e.lineStart=a,e.lineIndent=c;break}}r&&(F(e,i,o,!1),X(e,e.line-s),i=o=e.position,r=!1),b(u)||(o=e.position+1),u=e.input.charCodeAt(++e.position)}return F(e,i,o,!1),!!e.result||(e.kind=l,e.result=d,!1)}(e,O,a===i)&&(v=!0,null===e.tag&&(e.tag="?")):(v=!0,null===e.tag&&null===e.anchor||x(e,"alias node should not have any properties")),null!==e.anchor&&H(e,e.anchor,e.result)}else 0===T&&(v=f&&q(e,m));if(null===e.tag)null!==e.anchor&&H(e,e.anchor,e.result);else if("?"===e.tag){null!==e.result&&"scalar"!==e.kind&&x(e,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+e.kind+'"');for(let t=0,n=e.implicitTypes.length;t<n;t+=1)if(E=e.implicitTypes[t],E.resolve(e.result)){e.result=E.construct(e.result),e.tag=E.tag,null!==e.anchor&&H(e,e.anchor,e.result);break}}else if("!"!==e.tag){if(s.call(e.typeMap[e.kind||"fallback"],e.tag))E=e.typeMap[e.kind||"fallback"][e.tag];else{E=null;const t=e.typeMap.multi[e.kind||"fallback"];for(let n=0,i=t.length;n<i;n+=1)if(e.tag.slice(0,t[n].tag.length)===t[n].tag){E=t[n];break}}E||x(e,"unknown tag !<"+e.tag+">"),null!==e.result&&E.kind!==e.kind&&x(e,"unacceptable node kind for !<"+e.tag+'> tag; it should be "'+E.kind+'", not "'+e.kind+'"'),E.resolve(e.result,e.tag)?(e.result=E.construct(e.result,e.tag),null!==e.anchor&&H(e,e.anchor,e.result)):x(e,"cannot resolve a node with !<"+e.tag+"> explicit tag")}return null!==e.listener&&e.listener("close",e),e.depth-=1,null!==e.tag||null!==e.anchor||v}function Z(e){const t=e.position;let n,i=!1;for(e.version=null,e.checkLineBreaks=e.legacy,e.tagMap=Object.create(null),e.anchorMap=Object.create(null);0!==(n=e.input.charCodeAt(e.position))&&(V(e,!0,-1),n=e.input.charCodeAt(e.position),!(e.lineIndent>0||37!==n));){i=!0,n=e.input.charCodeAt(++e.position);let t=e.position;for(;0!==n&&!g(n);)n=e.input.charCodeAt(++e.position);const o=e.input.slice(t,e.position),r=[];for(o.length<1&&x(e,"directive name must not be less than one character in length");0!==n;){for(;b(n);)n=e.input.charCodeAt(++e.position);if(35===n){do{n=e.input.charCodeAt(++e.position)}while(0!==n&&!A(n));break}if(A(n))break;for(t=e.position;0!==n&&!g(n);)n=e.input.charCodeAt(++e.position);r.push(e.input.slice(t,e.position))}0!==n&&G(e),s.call(P,o)?P[o](e,o,r):M(e,'unknown document directive "'+o+'"')}V(e,!0,-1),0===e.lineIndent&&45===e.input.charCodeAt(e.position)&&45===e.input.charCodeAt(e.position+1)&&45===e.input.charCodeAt(e.position+2)?(e.position+=3,V(e,!0,-1)):i&&x(e,"directives end mark is expected"),Q(e,e.lineIndent-1,d,!1,!0),V(e,!0,-1),e.checkLineBreaks&&f.test(e.input.slice(t,e.position))&&M(e,"non-ASCII line breaks are interpreted as content"),e.documents.push(e.result),e.position===e.lineStart&&W(e)?46===e.input.charCodeAt(e.position)&&(e.position+=3,V(e,!0,-1)):e.position<e.length-1&&x(e,"end of the stream or a document separator is expected")}function ee(e,t){t=t||{},0!==(e=String(e)).length&&(10!==e.charCodeAt(e.length-1)&&13!==e.charCodeAt(e.length-1)&&(e+="\n"),65279===e.charCodeAt(0)&&(e=e.slice(1)));const n=new D(e,t),i=e.indexOf("\0");for(-1!==i&&(n.position=i,x(n,"null byte is not allowed in input")),n.input+="\0";32===n.input.charCodeAt(n.position);)n.lineIndent+=1,n.position+=1;for(;n.position<n.length-1;)Z(n);return n.documents}t.exports.loadAll=function(e,t,n){null!==t&&"object"==typeof t&&void 0===n&&(n=t,t=null);const i=ee(e,n);if("function"!=typeof t)return i;for(let e=0,n=i.length;e<n;e+=1)t(i[e])},t.exports.load=function(e,t){const n=ee(e,t);if(0!==n.length){if(1===n.length)return n[0];throw new i("expected a single document in the stream, but found more")}}})),vt=ot(((e,t)=>{var n=st(),i=at(),o=Nt(),r=Object.prototype.toString,s=Object.prototype.hasOwnProperty,a=65279,c=9,l=10,d=13,u=32,h=33,_=34,p=35,f=37,E=38,O=39,m=42,T=44,A=45,b=58,g=61,I=62,S=63,R=64,y=91,N=93,C=96,v=123,L=124,w=125,D={0:"\\0",7:"\\a",8:"\\b",9:"\\t",10:"\\n",11:"\\v",12:"\\f",13:"\\r",27:"\\e",34:'\\"',92:"\\\\",133:"\\N",160:"\\_",8232:"\\L",8233:"\\P"},$=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"],x=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function M(e){let t,o;const r=e.toString(16).toUpperCase();if(e<=255)t="x",o=2;else if(e<=65535)t="u",o=4;else{if(!(e<=4294967295))throw new i("code point within a string may not be greater than 0xFFFFFFFF");t="U",o=8}return"\\"+t+n.repeat("0",o-r.length)+r}var H=1,B=2;function k(e){this.schema=e.schema||o,this.indent=Math.max(1,e.indent||2),this.noArrayIndent=e.noArrayIndent||!1,this.skipInvalid=e.skipInvalid||!1,this.flowLevel=n.isNothing(e.flowLevel)?-1:e.flowLevel,this.styleMap=function(e,t){if(null===t)return{};const n={},i=Object.keys(t);for(let o=0,r=i.length;o<r;o+=1){let r=i[o],a=String(t[r]);"!!"===r.slice(0,2)&&(r="tag:yaml.org,2002:"+r.slice(2));const c=e.compiledTypeMap.fallback[r];c&&s.call(c.styleAliases,a)&&(a=c.styleAliases[a]),n[r]=a}return n}(this.schema,e.styles||null),this.sortKeys=e.sortKeys||!1,this.lineWidth=e.lineWidth||80,this.noRefs=e.noRefs||!1,this.noCompatMode=e.noCompatMode||!1,this.condenseFlow=e.condenseFlow||!1,this.quotingType='"'===e.quotingType?B:H,this.forceQuotes=e.forceQuotes||!1,this.replacer="function"==typeof e.replacer?e.replacer:null,this.implicitTypes=this.schema.compiledImplicit,this.explicitTypes=this.schema.compiledExplicit,this.tag=null,this.result="",this.duplicates=[],this.usedDuplicates=null}function P(e,t){const i=n.repeat(" ",t);let o=0,r="";const s=e.length;for(;o<s;){let t;const n=e.indexOf("\n",o);-1===n?(t=e.slice(o),o=s):(t=e.slice(o,n+1),o=n+1),t.length&&"\n"!==t&&(r+=i),r+=t}return r}function F(e,t){return"\n"+n.repeat(" ",e.indent*t)}function j(e){return e===u||e===c}function U(e){return e>=32&&e<=126||e>=161&&e<=55295&&8232!==e&&8233!==e||e>=57344&&e<=65533&&e!==a||e>=65536&&e<=1114111}function G(e){return U(e)&&e!==a&&e!==d&&e!==l}function V(e,t,n){const i=G(e),o=i&&!j(e);return(n?i:i&&e!==T&&e!==y&&e!==N&&e!==v&&e!==w)&&e!==p&&!(t===b&&!o)||G(t)&&!j(t)&&e===p||t===b&&o}function W(e,t){const n=e.charCodeAt(t);let i;return n>=55296&&n<=56319&&t+1<e.length&&(i=e.charCodeAt(t+1),i>=56320&&i<=57343)?1024*(n-55296)+i-56320+65536:n}function X(e){return/^\n* /.test(e)}var q=1,K=2,Y=3,J=4,z=5;function Q(e,t,n,i,o,r,s,c){let d,u=0,D=null,$=!1,x=!1;const M=-1!==i;let H=-1,k=function(e){return U(e)&&e!==a&&!j(e)&&e!==A&&e!==S&&e!==b&&e!==T&&e!==y&&e!==N&&e!==v&&e!==w&&e!==p&&e!==E&&e!==m&&e!==h&&e!==L&&e!==g&&e!==I&&e!==O&&e!==_&&e!==f&&e!==R&&e!==C}(W(e,0))&&function(e){return!j(e)&&e!==b}(W(e,e.length-1));if(t||s)for(d=0;d<e.length;u>=65536?d+=2:d++){if(u=W(e,d),!U(u))return z;k=k&&V(u,D,c),D=u}else{for(d=0;d<e.length;u>=65536?d+=2:d++){if(u=W(e,d),u===l)$=!0,M&&(x=x||d-H-1>i&&" "!==e[H+1],H=d);else if(!U(u))return z;k=k&&V(u,D,c),D=u}x=x||M&&d-H-1>i&&" "!==e[H+1]}return $||x?n>9&&X(e)?z:s?r===B?z:K:x?J:Y:!k||s||o(e)?r===B?z:K:q}function Z(e,t,n,o,r){e.dump=function(){if(0===t.length)return e.quotingType===B?'""':"''";if(!e.noCompatMode&&(-1!==$.indexOf(t)||x.test(t)))return e.quotingType===B?'"'+t+'"':"'"+t+"'";const s=e.indent*Math.max(1,n),a=-1===e.lineWidth?-1:Math.max(Math.min(e.lineWidth,40),e.lineWidth-s),c=o||e.flowLevel>-1&&n>=e.flowLevel;switch(Q(t,c,e.indent,a,(function(t){return function(e,t){for(let n=0,i=e.implicitTypes.length;n<i;n+=1)if(e.implicitTypes[n].resolve(t))return!0;return!1}(e,t)}),e.quotingType,e.forceQuotes&&!o,r)){case q:return t;case K:return"'"+t.replace(/'/g,"''")+"'";case Y:return"|"+ee(t,e.indent)+te(P(t,s));case J:return">"+ee(t,e.indent)+te(P(function(e,t){const n=/(\n+)([^\n]*)/g;let i,o,r=function(){let i=e.indexOf("\n");return i=-1!==i?i:e.length,n.lastIndex=i,ne(e.slice(0,i),t)}(),s="\n"===e[0]||" "===e[0];for(;o=n.exec(e);){const e=o[1],n=o[2];i=" "===n[0],r+=e+(s||i||""===n?"":"\n")+ne(n,t),s=i}return r}(t,a),s));case z:return'"'+function(e){let t="",n=0;for(let i=0;i<e.length;n>=65536?i+=2:i++){n=W(e,i);const o=D[n];!o&&U(n)?(t+=e[i],n>=65536&&(t+=e[i+1])):t+=o||M(n)}return t}(t)+'"';default:throw new i("impossible error: invalid scalar style")}}()}function ee(e,t){const n=X(e)?String(t):"",i="\n"===e[e.length-1];return n+(!i||"\n"!==e[e.length-2]&&"\n"!==e?i?"":"-":"+")+"\n"}function te(e){return"\n"===e[e.length-1]?e.slice(0,-1):e}function ne(e,t){if(""===e||" "===e[0])return e;const n=/ [^ ]/g;let i,o,r=0,s=0,a=0,c="";for(;i=n.exec(e);)a=i.index,a-r>t&&(o=s>r?s:a,c+="\n"+e.slice(r,o),r=o+1),s=a;return c+="\n",e.length-r>t&&s>r?c+=e.slice(r,s)+"\n"+e.slice(s+1):c+=e.slice(r),c.slice(1)}function ie(e,t,n,i){let o="";const r=e.tag;for(let r=0,s=n.length;r<s;r+=1){let s=n[r];e.replacer&&(s=e.replacer.call(n,String(r),s)),(re(e,t+1,s,!0,!0,!1,!0)||void 0===s&&re(e,t+1,null,!0,!0,!1,!0))&&(i&&""===o||(o+=F(e,t)),e.dump&&l===e.dump.charCodeAt(0)?o+="-":o+="- ",o+=e.dump)}e.tag=r,e.dump=o||"[]"}function oe(e,t,n){const o=n?e.explicitTypes:e.implicitTypes;for(let a=0,c=o.length;a<c;a+=1){const c=o[a];if((c.instanceOf||c.predicate)&&(!c.instanceOf||"object"==typeof t&&t instanceof c.instanceOf)&&(!c.predicate||c.predicate(t))){if(n?c.multi&&c.representName?e.tag=c.representName(t):e.tag=c.tag:e.tag="?",c.represent){const n=e.styleMap[c.tag]||c.defaultStyle;let o;if("[object Function]"===r.call(c.represent))o=c.represent(t,n);else{if(!s.call(c.represent,n))throw new i("!<"+c.tag+'> tag resolver accepts not "'+n+'" style');o=c.represent[n](t,n)}e.dump=o}return!0}}return!1}function re(e,t,n,o,s,a,c){e.tag=null,e.dump=n,oe(e,n,!1)||oe(e,n,!0);const d=r.call(e.dump),u=o;o&&(o=e.flowLevel<0||e.flowLevel>t);const h="[object Object]"===d||"[object Array]"===d;let _,p;if(h&&(_=e.duplicates.indexOf(n),p=-1!==_),(null!==e.tag&&"?"!==e.tag||p||2!==e.indent&&t>0)&&(s=!1),p&&e.usedDuplicates[_])e.dump="*ref_"+_;else{if(h&&p&&!e.usedDuplicates[_]&&(e.usedDuplicates[_]=!0),"[object Object]"===d)o&&0!==Object.keys(e.dump).length?(!function(e,t,n,o){let r="";const s=e.tag,a=Object.keys(n);if(!0===e.sortKeys)a.sort();else if("function"==typeof e.sortKeys)a.sort(e.sortKeys);else if(e.sortKeys)throw new i("sortKeys must be a boolean or a function");for(let i=0,s=a.length;i<s;i+=1){let s="";o&&""===r||(s+=F(e,t));const c=a[i];let d=n[c];if(e.replacer&&(d=e.replacer.call(n,c,d)),!re(e,t+1,c,!0,!0,!0))continue;const u=null!==e.tag&&"?"!==e.tag||e.dump&&e.dump.length>1024;u&&(e.dump&&l===e.dump.charCodeAt(0)?s+="?":s+="? "),s+=e.dump,u&&(s+=F(e,t)),re(e,t+1,d,!0,u)&&(e.dump&&l===e.dump.charCodeAt(0)?s+=":":s+=": ",s+=e.dump,r+=s)}e.tag=s,e.dump=r||"{}"}(e,t,e.dump,s),p&&(e.dump="&ref_"+_+e.dump)):(!function(e,t,n){let i="";const o=e.tag,r=Object.keys(n);for(let o=0,s=r.length;o<s;o+=1){let s="";""!==i&&(s+=", "),e.condenseFlow&&(s+='"');const a=r[o];let c=n[a];e.replacer&&(c=e.replacer.call(n,a,c)),re(e,t,a,!1,!1)&&(e.dump.length>1024&&(s+="? "),s+=e.dump+(e.condenseFlow?'"':"")+":"+(e.condenseFlow?"":" "),re(e,t,c,!1,!1)&&(s+=e.dump,i+=s))}e.tag=o,e.dump="{"+i+"}"}(e,t,e.dump),p&&(e.dump="&ref_"+_+" "+e.dump));else if("[object Array]"===d)o&&0!==e.dump.length?(e.noArrayIndent&&!c&&t>0?ie(e,t-1,e.dump,s):ie(e,t,e.dump,s),p&&(e.dump="&ref_"+_+e.dump)):(!function(e,t,n){let i="";const o=e.tag;for(let o=0,r=n.length;o<r;o+=1){let r=n[o];e.replacer&&(r=e.replacer.call(n,String(o),r)),(re(e,t,r,!1,!1)||void 0===r&&re(e,t,null,!1,!1))&&(""!==i&&(i+=","+(e.condenseFlow?"":" ")),i+=e.dump)}e.tag=o,e.dump="["+i+"]"}(e,t,e.dump),p&&(e.dump="&ref_"+_+" "+e.dump));else{if("[object String]"!==d){if("[object Undefined]"===d)return!1;if(e.skipInvalid)return!1;throw new i("unacceptable kind of an object to dump "+d)}"?"!==e.tag&&Z(e,e.dump,t,a,u)}if(null!==e.tag&&"?"!==e.tag){let t=encodeURI("!"===e.tag[0]?e.tag.slice(1):e.tag).replace(/!/g,"%21");t="!"===e.tag[0]?"!"+t:"tag:yaml.org,2002:"===t.slice(0,18)?"!!"+t.slice(18):"!<"+t+">",e.dump=t+" "+e.dump}}return!0}function se(e,t){const n=[],i=[];ae(e,n,i);const o=i.length;for(let e=0;e<o;e+=1)t.duplicates.push(n[i[e]]);t.usedDuplicates=new Array(o)}function ae(e,t,n){if(null!==e&&"object"==typeof e){const i=t.indexOf(e);if(-1!==i)-1===n.indexOf(i)&&n.push(i);else if(t.push(e),Array.isArray(e))for(let i=0,o=e.length;i<o;i+=1)ae(e[i],t,n);else{const i=Object.keys(e);for(let o=0,r=i.length;o<r;o+=1)ae(e[i[o]],t,n)}}}t.exports.dump=function(e,t){const n=new k(t=t||{});n.noRefs||se(e,n);let i=e;return n.replacer&&(i=n.replacer.call({"":i},"",i)),re(n,0,i,!0,!0)?n.dump+"\n":""}})),Lt=rt(ot(((e,t)=>{var n=Ct(),i=vt();function o(e,t){return function(){throw new Error("Function yaml."+e+" is removed in js-yaml 4. Use yaml."+t+" instead, which is now safe by default.")}}t.exports.Type=lt(),t.exports.Schema=dt(),t.exports.FAILSAFE_SCHEMA=pt(),t.exports.JSON_SCHEMA=Tt(),t.exports.CORE_SCHEMA=At(),t.exports.DEFAULT_SCHEMA=Nt(),t.exports.load=n.load,t.exports.loadAll=n.loadAll,t.exports.dump=i.dump,t.exports.YAMLException=at(),t.exports.types={binary:It(),float:mt(),map:_t(),null:ft(),pairs:Rt(),set:yt(),timestamp:bt(),bool:Et(),int:Ot(),merge:gt(),omap:St(),seq:ht(),str:ut()},t.exports.safeLoad=o("safeLoad","load"),t.exports.safeLoadAll=o("safeLoadAll","loadAll"),t.exports.safeDump=o("safeDump","dump")}))()),{Type:wt,Schema:Dt,FAILSAFE_SCHEMA:$t,JSON_SCHEMA:xt,CORE_SCHEMA:Mt,DEFAULT_SCHEMA:Ht,load:Bt,loadAll:kt,dump:Pt,YAMLException:Ft,types:jt,safeLoad:Ut,safeLoadAll:Gt,safeDump:Vt}=Lt.default,Wt=Lt.default;const Xt=e=>typeof e===Ie.UNDEFINED,qt=e=>typeof e===Ie.STRING,Kt=e=>typeof e===Ie.NUMBER&&!Number.isNaN(e),Yt=e=>typeof e===Ie.BOOLEAN,Jt=e=>"[object Object]"===Object.prototype.toString.call(e),zt=e=>Array.isArray(e),Qt=(e,t,n=null,i={})=>{const{bubbles:o=!0,cancelable:r=!1,composed:s=!0}=i;e.dispatchEvent(new CustomEvent(t,{bubbles:o,cancelable:r,composed:s,detail:n}))},Zt=(e,t,n="ignoring navigate method using the path")=>{if(e.startsWith("/")){const n=[null,"",e];t?window.history.replaceState(...n):window.history.pushState(...n),(e=>{Qt(window,De.LOCATION_CHANGED,{replace:e})})(e)}else console.warn(`${Te}: ${n} "${e}" as it doesn't start with "/".`)},en=()=>e(void 0,void 0,void 0,(function*(){return document.createElement(Re.HA_PANEL_CONFIG)})),tn=t=>e(void 0,void 0,void 0,(function*(){const n=customElements.get(Re.DIALOG_BOX);if(n)return n;const i=yield en(),o=yield(t=>e(void 0,void 0,void 0,(function*(){return customElements.get(Re.HA_CONFIG_BACKUP)||(yield t.routerOptions.routes.backup.load(),yield customElements.whenDefined(Re.HA_CONFIG_BACKUP)),document.createElement(Re.HA_CONFIG_BACKUP_BACKUPS)})))(i);return o.hass=t.hass,new Promise((e=>{o.addEventListener(De.SHOW_DIALOG,(t=>{const n=t.detail.dialogImport();e(n)}),{once:!0}),o._overflowBackup=!0,o._deleteBackup()}))})),nn=()=>e(void 0,void 0,void 0,(function*(){const t=customElements.get(Re.DIALOG_RESTART);if(t)return t;const n=yield en(),i=yield(t=>e(void 0,void 0,void 0,(function*(){return customElements.get(Re.HA_CONFIG_SYSTEM_NAVIGATION)||(yield t.routerOptions.routes.system.load(),yield customElements.whenDefined(Re.HA_CONFIG_SYSTEM_NAVIGATION)),document.createElement(Re.HA_CONFIG_SYSTEM_NAVIGATION)})))(n);return new Promise((e=>{i.addEventListener(De.SHOW_DIALOG,(t=>{const n=t.detail.dialogImport();e(n)}),{once:!0}),i._showRestartDialog()}))})),on=(e,t,n,i)=>{Qt(e,De.SHOW_DIALOG,{dialogTag:t,dialogImport:n,dialogParams:i})},rn=t=>e(void 0,void 0,void 0,(function*(){const e=yield nn();((e,t)=>{on(e,Re.DIALOG_RESTART,t,{})})(t,(()=>Promise.resolve(e)))})),sn=(e,t)=>{Qt(e,De.HASS_MORE_INFO,{entityId:t})},an=t=>({openAlertDialog:n=>{const{title:i,text:o,confirmText:r,confirm:s}=n;((t,n)=>{e(void 0,void 0,void 0,(function*(){const e=yield tn(t);on(t,Re.DIALOG_BOX,(()=>Promise.resolve(e)),n)}))})(t,{title:i,text:o,confirmText:r,confirm:s})},openConfirmDialog:n=>{const{title:i,text:o,destructive:r,confirmText:s,dismissText:a,confirm:c,cancel:l}=n;((t,n)=>{e(void 0,void 0,void 0,(function*(){const e=yield tn(t);on(t,Re.DIALOG_BOX,(()=>Promise.resolve(e)),Object.assign(Object.assign({},n),{confirmation:!0}))}))})(t,{title:i,text:o,destructive:r,confirmText:s,dismissText:a,confirm:c,cancel:l})},openRestartDialog:()=>{rn(t)},openMoreInfoDialog:e=>{sn(t,e)}}),cn=e=>zt(e)?e.map((e=>e.toLowerCase())):e.toLowerCase().split(/\s*,\s*/),ln=e=>Kt(e)?`${e}px`:e;function dn(e,t,n={}){const o=qt(e)?document:e,r=qt(e)?e:String(t),s=qt(t)?n:t,a=Object.assign({retries:100,delay:50,shouldReject:!1},s),c=()=>o.querySelector(r);return{toBeAdded:()=>i(c,(e=>null!==e&&null!==e.shadowRoot),a),toBeRemoved:()=>i(c,(e=>null===e),a)}}const un=/(?:iphone|android|ipad)/i.test(navigator.userAgent),hn=()=>e(void 0,void 0,void 0,(function*(){return yield i((()=>window.hassConnection),(e=>!!e))})),_n=[...ke,...Pe],pn=["id","exceptions","extendable_configs","extend_from","user","not_user","device","not_device","is_admin"],fn=["js_variables","jinja_variables","partials"];class En{constructor(e,t,n){var i;this._config=e,this._extendable=new Map(Object.entries(null!==(i=this._config.extendable_configs)&&void 0!==i?i:[])),this._user=t,this._userAgent=n,this._exceptions=this._getExceptions(),this._buildFlattenConfig()}_getExceptions(){if(this._config.exceptions){const e=this._user.name.toLocaleLowerCase();return this._config.exceptions.filter((t=>{var n;const i=null!==(n=t.matchers_conditions)&&void 0!==n?n:_e.OR,o=void 0!==t.user&&cn(t.user).includes(e),r=void 0!==t.not_user&&!cn(t.not_user).includes(e),s=void 0!==t.device&&cn(t.device).some((e=>this._userAgent.includes(e))),a=void 0!==t.not_device&&!cn(t.not_device).some((e=>this._userAgent.includes(e))),c=void 0!==t.is_admin&&t.is_admin===this._user.is_admin,l=void 0!==t.is_owner&&t.is_owner===this._user.is_owner;return i===_e.OR?o||r||s||a||c||l:(void 0===t.user||o)&&(void 0===t.not_user||r)&&(void 0===t.device||s)&&(void 0===t.not_device||a)&&(void 0===t.is_admin||c)&&(void 0===t.is_owner||l)}))}return[]}_mergeConfigs(...e){return e.reduce(((e,t)=>{var n,i;return Object.assign(Object.assign(Object.assign({},e),t),{order:[...null!==(n=e.order)&&void 0!==n?n:[],...null!==(i=t.order)&&void 0!==i?i:[]]})}),{})}_pickExtendableOptions(e){const t=Object.entries(e),n=Object.fromEntries(t.filter((e=>{const[t]=e;return!pn.includes(t)})));return e.extend_from?this._mergeConfigs(this._importConfig(e.extend_from),n):Object.assign({},n)}_importConfig(e){var t;return(zt(t=e)?t:[t]).reduce(((e,t)=>t===ge?this._mergeConfigs(this._pickExtendableOptions(this._config),e):this._mergeConfigs(this._pickExtendableOptions(this._extendable.get(t)),e)),{})}_buildFlattenConfigFromExceptions(){const e=fn.reduce(((e,t)=>this._config[t]?Object.assign(Object.assign({},e),{[t]:this._config[t]}):e),{});this._flattenConfig=this._exceptions.reduce(((e,t)=>t.extend_from?this._mergeConfigs(this._importConfig(t.extend_from),e,t):this._mergeConfigs(e,t)),e)}_buildFlattenConfigFromMainConfig(){this._flattenConfig=this._config.extend_from?this._mergeConfigs(this._importConfig(this._config.extend_from),this._config):this._config}_buildFlattenConfig(){this._exceptions.length?this._buildFlattenConfigFromExceptions():this._buildFlattenConfigFromMainConfig()}_flattenOrder(e){var t;const n=null!==(t=e.order)&&void 0!==t?t:[],i=new Map;n.forEach((e=>{i.has(e.item)?i.set(e.item,Object.assign(Object.assign({},i.get(e.item)),e)):i.set(e.item,e)})),i.forEach((t=>{_n.forEach((n=>{void 0===t[n]&&void 0!==e[n]&&(t[n]=e[n])})),t.new_item||void 0!==t.hide||void 0===e.hide_all||(t.hide=e.hide_all)}));return Array.from(i.values()).sort(((e,t)=>!!e.bottom!=!!t.bottom?e.bottom?1:-1:Xt(e.order)||Xt(t.order)?e.order===t.order?0:Xt(e.order)?1:-1:e.order-t.order))}get config(){return Object.assign(Object.assign({},this._flattenConfig),{order:this._flattenOrder(this._flattenConfig)})}}const On=(e,t,n=[])=>e.replace(Je,((e,i)=>{if(null==t?void 0:t[i]){if(n.includes(i))throw new SyntaxError(`${Te}: circular partials dependency ${n.join(" > ")} > ${i}`);return On(t[i].trim(),t,[...n,i])}return console.warn(`${Te}: partial ${i} doesn't exist`),""})),mn=(...e)=>{const[t,...n]=e;return 0===n.length?qt(t)&&t.startsWith("--")?`var(${t})`:`${t}`:`var(${t}, ${mn(...n)})`};const Tn=new class{constructor(){this._langKey="language",this._locale=new Promise((t=>{hn().then((n=>e(this,void 0,void 0,(function*(){const e=n.conn.subscribeMessage((e=>{t(e.value)}),{type:De.SUBSCRIBE_USER_DATA,key:this._langKey});(yield e)()}))))}))}get locale(){return this._locale}};class An{constructor(e){this._enabled=e}static logVersionToConsole(){console.info(`%c≡ ${Te.toUpperCase()} %cv15.0.1`,"font-weight: bold; background: #EEEEEE; color: #666666; padding: 2px 5px;","font-weight: normal; background: #E87A24; color: #FFFFFF; padding: 2px 5px")}log(e,t,n){const{stringify:i=!0,table:o=!1}=null!=n?n:{};if(this._enabled){const n=`${Te} debug: ${e}`;t?(console.groupCollapsed(n),o?console.table(t):console.log(i?JSON.stringify(t,null,4):t),console.groupEnd()):console.log(n)}}get enabled(){return this._enabled}}const bn="Invalid configuration",gn=["title","subtitle","sidebar_background","title_color","subtitle_color","sidebar_button_color","sidebar_button_color_hover","sidebar_button_background_hover","sidebar_border_color","menu_background","divider_color","scrollbar_thumb_color","styles",...ke,"default_path"],In=["js_variables","jinja_variables","partials","extendable_configs"],Sn=(e,t)=>{const n=`You need to provide a number followed by one of the allowed units (${Xe.join(", ")}) or a CSS calc function`,i=new RegExp(`^(?:\\d+(?:${Xe.join("|")})|calc\\s*\\(.+\\))$`),o=e.width;if(!(Xt(o)||qt(o)||Kt(o)||Jt(o)))throw new SyntaxError(`${t} "width" property should be a number, a string or an object`);if(qt(o)&&!i.test(o))throw new SyntaxError(`${t} "width" property has an invalid format. ${n}`);if(Jt(o)){const{extended:e,hidden:r}=o;if(Xt(e)&&Xt(r))throw new SyntaxError(`${t} if "width" property is an object it should have an "extended" or a "hidden" property`);if(!Xt(e)&&!Kt(e)&&!qt(e))throw new SyntaxError(`${t} "width.extended" property should be a number or a string`);if(!Xt(r)&&!Kt(r)&&!qt(r))throw new SyntaxError(`${t} "width.hidden" property should be a number or a string`);if(i.lastIndex=0,qt(e)&&!i.test(e))throw new SyntaxError(`${t} "width.extended" property has an invalid format. ${n}`);if(i.lastIndex=0,qt(r)&&!i.test(r))throw new SyntaxError(`${t} "width.hidden" property has an invalid format. ${n}`)}},Rn=(e,t,n)=>{t.forEach((t=>{if(!Xt(e[t])&&!qt(e[t]))throw new SyntaxError(`${n} "${String(t)}" property should be a string`)}))},yn=(e,t,n)=>{t.forEach((t=>{if(!Xt(e[t])&&!qt(e[t])&&!Kt(e[t]))throw new SyntaxError(`${n} "${String(t)}" property should be a number or a string`)}))},Nn=(e,t,n)=>{t.forEach((t=>{if(!Xt(e[t])&&!Yt(e[t]))throw new SyntaxError(`${n} "${String(t)}" property should be a boolean`)}))},Cn=(e,t,n)=>{t.forEach((t=>{if(!Xt(e[t])&&!Yt(e[t])&&!qt(e[t]))throw new SyntaxError(`${n} "${String(t)}" property should be a boolean or a string`)}))},vn=(e,t)=>{e.forEach((e=>{const[n,i]=e;if(!Ln(i))throw new SyntaxError(`${t} "${n}" property should be a string or an array of strings`)}))},Ln=e=>!!Xt(e)||(qt(e)||zt(e)&&e.some(qt)),wn=(e,t,n,i=!1)=>{if(e){(zt(e)?e:[e]).forEach((e=>{var o;if(e===ge&&!i)throw new SyntaxError(`${n} "entend_from" can only be "base" in exceptions`);if(e!==ge&&!(e in(null!==(o=t.extendable_configs)&&void 0!==o?o:{})))throw new SyntaxError(`${n} "${e}" doesn't exist in "extendable_configs"`)}))}},Dn=(e,t,n)=>{if(e){(zt(e)?e:[e]).forEach((e=>{if(n.includes(e))throw new SyntaxError(`${bn}, circular extend dependency detected in "${n.join(" > ")} > ${e}"`);if(e===ge)throw new SyntaxError(`${bn}, error in extendable config "${n[0]}": "entend_from" can only be "base" in exceptions`);if(!t.extendable_configs||!(e in t.extendable_configs))throw new SyntaxError(`${bn}, error in "${n[n.length-1]}": "${e}" doesn't exist in "extendable_configs"`);Dn(t.extendable_configs[e].extend_from,t,[...n,e])}))}},$n=(e,t)=>{In.forEach((n=>{if(n in e)throw new SyntaxError(`${t} "${n}" option can only be placed in the main config`)}))},xn=(e,t,n)=>{if(qt(t)&&(Ke.test(t)||Ye.test(t)))console.warn(`"${e}" property should not have templates. "${n.join(" > ")}" seems to be a template`);else if(!qt(t)&&!Kt(t)&&!Yt(t))if(zt(t))t.forEach(((t,i)=>{xn(e,t,[...n,`[${i}]`])}));else{if(!Jt(t))throw new SyntaxError(`${bn}, "${e}: ${n.join(" > ")}" has a wrong type ${Object.prototype.toString.call(t)}`);{const i=t;Object.entries(i).forEach((t=>{const[i,o]=t;xn(e,o,[...n,i])}))}}},Mn=(e,t)=>{if(!Xt(t)){if(!Jt(t))throw new SyntaxError(`${bn}, "${e}" property should be an object`);Object.entries(t).forEach((t=>{const[n,i]=t;xn(e,i,[n])}))}},Hn=(e,t)=>{if(e.analytics){if(!Yt(e.analytics)&&!Jt(e.analytics))throw new SyntaxError(`${t} "analytics" should be a boolean or an object`);Jt(e.analytics)&&Nn(e.analytics,["sidebar_item_clicked","panel_visited"],`${t} "analytics"`)}},Bn=(e,t)=>{if(!Xt(e)){if(!zt(e))throw new SyntaxError(`${bn}, exceptions should be an array`);e.forEach((e=>{((e,t)=>{var n;if($n(e,`${bn}, exceptions`),Rn(e,[...gn],`${bn}, exceptions`),Sn(e,`${bn}, exceptions`),yn(e,[...Pe,"sidebar_button_background_hover_opacity"],`${bn}, exceptions`),vn([["user",e.user],["not_user",e.not_user],["device",e.device],["not_device",e.not_device],["extend_from",e.extend_from]],`${bn}, exceptions`),wn(e.extend_from,t,`${bn}, error in exception:`,!0),!Xt(e.matchers_conditions)&&e.matchers_conditions!==_e.AND&&e.matchers_conditions!==_e.OR)throw new SyntaxError(`${bn}, exceptions "matchers_conditions" property should be "${_e.AND}" or "${_e.OR}"`);if(!Xt(e.order)&&!zt(e.order))throw new SyntaxError(`${bn}, exceptions "order" property should be an array`);if(Cn(e,["sidebar_editable"],`${bn}, exceptions`),Nn(e,["hide_all","is_admin","is_owner"],`${bn}, exceptions`),Hn(e,`${bn}, error in exception:`),!Xt(e.sidebar_mode)&&!(e.sidebar_mode in Ve))throw new SyntaxError(`${bn}, exceptions "sidebar_mode" property should be ${ue.HIDDEN}, ${ue.NARROW} or ${ue.EXTENDED}`);if(e.user&&e.not_user)throw new SyntaxError(`${bn}, exceptions "user" and "not_user" properties cannot be used together`);if(e.device&&e.not_device)throw new SyntaxError(`${bn}, exceptions "device" and "not_device" properties cannot be used together`);null===(n=e.order)||void 0===n||n.forEach(kn)})(e,t)}))}},kn=e=>{if(!e.item)throw new SyntaxError(`${bn}, every item in an "order" array should have an "item" property`);if("section_header"in e&&(e=>{if(!Yt(e.section_header))throw new SyntaxError(`${bn}, "section_header" property should be a boolean`);if(!Yt(e.new_item))throw new SyntaxError(`${bn}, a section header item should be used only in an item with the "new_item" property set in true`);const t=["new_item","section_header","item","name","info","order","bottom","attributes","hide","item_background","text_color","info_color","divider","divider_color"];Object.keys(e).forEach((e=>{if(!t.includes(e))throw new SyntaxError(`${bn}, property "${e}" is not allowed in a section header item`)}))})(e),$n(e,`${bn} in ${e.item},`),Rn(e,["item","info",...ke],`${bn} in ${e.item},`),yn(e,[...Pe],`${bn} in ${e.item},`),Cn(e,["hide"],`${bn} in ${e.item},`),Nn(e,["divider"],`${bn} in ${e.item},`),((e,t)=>{if(!Xt(e.on_click)){if(!Jt(e.on_click))throw new SyntaxError(`${t} "on_click" property should be an object`);if(!qt(e.on_click.action))throw new SyntaxError(`${t} the "action" parameter should be a string`);if(!Object.values(fe).includes(e.on_click.action))throw new SyntaxError(`${t} the "action" parameter should be one of these values: ${Object.values(fe).join(", ")}`);if(e.on_click.action===fe.NAVIGATE){if(!qt(e.on_click.path))throw new SyntaxError(`${t} the "path" parameter should be a string`);if(!Xt(e.on_click.replace)&&!Yt(e.on_click.replace))throw new SyntaxError(`${t} the "replace" parameter should be a boolean`)}if(e.on_click.action===fe.CALL_SERVICE){if(!qt(e.on_click.service))throw new SyntaxError(`${t} the "service" parameter should be a string`);if(!Xt(e.on_click.data)&&!Jt(e.on_click.data))throw new SyntaxError(`${t} the "data" parameter needs to be an object`)}if(e.on_click.action===fe.JAVASCRIPT&&!qt(e.on_click.code))throw new SyntaxError(`${t} the "code" parameter should be a string`)}})(e,`${bn} in ${e.item},`),((e,t)=>{if(!Xt(e)){if(!Jt(e)&&!qt(e))throw new SyntaxError(`${t} the "attributes" parameter should be an object or a template string`);if(Jt(e))Object.entries(e).forEach((e=>{const[n,i]=e;if(!qt(i)&&!Yt(i)&&!Kt(i))throw new SyntaxError(`${t} the prop "${n}" in the attributes should be a string, a number or a boolean`)}));else if(qt(e)&&!Ke.test(e))throw new SyntaxError(`${t} the "attributes" parameter as a string should be a JavaScript template`)}})(e.attributes,`${bn} in ${e.item},`),e.new_item&&!e.section_header){if(Rn(e,["href","icon"],`${bn} in ${e.item},`),!e.href&&!e.on_click)throw new SyntaxError(`${bn} in ${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(`${bn} in ${e.item}, if you set "new_item" as "true", "icon" property is necessary`)}},Pn=e=>{var t;if(Rn(e,[...gn],`${bn},`),Sn(e,`${bn},`),vn([["extend_from",e.extend_from]],`${bn},`),wn(e.extend_from,e,`${bn}, error in main config:`),(e=>{e.extendable_configs&&Object.entries(e.extendable_configs).forEach((t=>{const[n,i]=t;Dn(i.extend_from,e,[n])}))})(e),yn(e,[...Pe,"sidebar_button_background_hover_opacity"],`${bn},`),Cn(e,["sidebar_editable"],`${bn},`),Nn(e,["hide_all"],`${bn},`),!Xt(e.sidebar_mode)&&!(e.sidebar_mode in Ve))throw new SyntaxError(`${bn}, "sidebar_mode" property should be ${ue.HIDDEN}, ${ue.NARROW} or ${ue.EXTENDED}`);if(!Xt(e.order)&&!zt(e.order))throw new SyntaxError(`${bn}, "order" property should be an array`);if(!Xt(e.partials)){if(!Jt(e.partials))throw new SyntaxError(`${bn}, "partials" property should be an object`);Object.entries(e.partials).forEach((e=>{const[t,n]=e;if(!qt(n))throw new SyntaxError(`${bn}, "partials" should be an object with strings. The partial ${t} is not a string`)}))}Mn("js_variables",e.js_variables),Mn("js_refs",e.js_refs),Mn("jinja_variables",e.jinja_variables),Hn(e,`${bn},`),null===(t=e.order)||void 0===t||t.forEach(kn),Bn(e.exceptions,e)},Fn=()=>e(void 0,void 0,void 0,(function*(){const e=`${Te}: Config file not found.`,t=`Make sure you have a valid config in /config/www/${Ae}.yaml file.`;return new Promise((n=>{fetch(`${be}.yaml?hash=${Math.random().toString(16).slice(2)}`,{cache:"no-store"}).then((i=>{if(!i.ok)throw Error(`${e}\n${t}`);i.text().then((e=>Wt.load(e))).then((e=>{var t;const i=e;(null===(t=i.id)||void 0===t?void 0:t.startsWith("example"))&&console.warn(`${Te}: You seem to be using the example configuration.`),Pn(i),n(i)})).catch((e=>{throw Error(`${Te}: ${e}`)}))})).catch((()=>{throw Error(`${e}\n${t}`)}))}))})),jn={backgroundColor:mn(Be.NOTIFICATION_COLOR,He.ACCENT_COLOR),color:mn(Be.NOTIFICATION_TEXT_COLOR,He.TEXT_ACCENT_COLOR,He.TEXT_PRIMARY_COLOR),display:"inline-flex",maxWidth:"80px",overflow:"hidden",textAlign:"center",textOverflow:"ellipsis",textWrap:"nowrap",zIndex:1},Un={[`${ye.HOST} ${Re.ITEM_BASE}`]:{fontWeight:"var(--ha-font-weight-medium)"}},Gn={[`${ye.HOST_EXPANDED_NOT_NAROW} ${ye.MENU}`]:{width:"100%"},[`${ye.HOST_EXPANDED} ${ye.ITEM}`]:{width:"calc(100% - var(--ha-space-2)) !important"},[`${ye.HOST_EXPANDED} ${Re.ITEM} > ${Re.USER_BADGE}`]:{zIndex:1},[`${ye.HOST_EXPANDED} ${ye.ITEM} > ${ye.ITEM_TEXT}`]:{position:"relative",zIndex:1},[`${ye.HOST_EXPANDED} ${ye.ITEM} > ${ye.ITEM_TEXT}${ye.DATA_INFO}`]:{display:"flex",flexDirection:"column",gap:"5px",lineHeight:"1"},[`${ye.HOST_EXPANDED} ${ye.ITEM} > ${ye.ITEM_TEXT}${ye.DATA_INFO}${Ce.AFTER}`]:{content:"attr(data-info)",display:"block",fontSize:"11px",lineHeight:"1",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},[`${ye.HOST} ${Re.ITEM}:not([${Le.WITH_NOTIFICATION}], ${ye.CONFIGURATION}, ${ye.SIDEBAR_NOTIFICATIONS}) > ${ye.BADGE}`]:{display:"none"},[`${ye.HOST_NOT_EXPANDED} ${Re.ITEM}:not([${Le.WITH_NOTIFICATION}], ${ye.CONFIGURATION}, ${ye.SIDEBAR_NOTIFICATIONS}) > ${ye.BADGE}`]:{display:"none"},[`${ye.HOST} ${Re.ITEM} > ${ye.BADGE}`]:jn,[`${ye.HOST_NOT_EXPANDED} ${Re.ITEM} > ${ye.BADGE}`]:Object.assign(Object.assign({},jn),{maxWidth:"10px",textOverflow:"unset"}),[`${ye.HOST} ${Re.ITEM} > ${Re.HA_ICON} + ${ye.BADGE}`]:{position:"absolute",top:"var(--ha-space-1)",left:"26px",borderRadius:"var(--ha-border-radius-md)",fontSize:".65em",lineHeight:"var(--ha-line-height-expanded)",padding:"0 var(--ha-space-1)"}},Vn={[`${ye.HOST} ${ye.MENU} > ${ye.TITLE}`]:{color:mn(Be.TITLE_COLOR,He.SIDEBAR_TITLE_COLOR,He.PRIMARY_TEXT_COLOR)}},Wn={[`${ye.HOST} ${ye.MENU} > ${ye.TITLE}${Ce.AFTER}`]:{content:"attr(data-subtitle)",color:mn(Be.SUBTITLE_COLOR,Be.TITLE_COLOR,He.SIDEBAR_TITLE_COLOR,He.PRIMARY_TEXT_COLOR),display:"block",fontSize:"12px",lineHeight:"1.5"}},Xn={[`${ye.HOST} ${ye.MENU} > ${Re.HA_ICON_BUTTON}`]:{color:mn(Be.BUTTON_COLOR,He.SIDEBAR_ICON_COLOR)}},qn={[`${ye.HOST} ${ye.MENU} > ${Re.HA_ICON_BUTTON_HOVER}`]:{color:mn(Be.BUTTON_COLOR_HOVER,Be.BUTTON_COLOR,He.SIDEBAR_ICON_COLOR)}},Kn={[`${ye.HOST} ${Re.HA_BUTTON}${Ce.AFTER}`]:{background:mn(Be.BUTTON_BACKGROUND_HOVER,Be.BUTTON_COLOR_HOVER,Be.BUTTON_COLOR,He.CURRENT_COLOR)},[Ne.MEDIA_HOVER]:{[`${ye.HOST_HOVER_NOT_DISABLED} ${Re.HA_BUTTON}[appearance="plain"]${Ce.AFTER}`]:{opacity:mn(Be.BUTTON_BACKGROUND_HOVER_OPACITY,.1)}}},Yn={[ye.HOST]:{background:mn(Be.BACKGROUND,He.SIDEBAR_BACKGROUND_COLOR)+" !important"}},Jn={[`${ye.HOST} ${ye.MENU}`]:{background:mn(Be.MENU_BACKGROUND,Be.BACKGROUND,He.SIDEBAR_MENU_BUTTON_BACKGROUND_COLOR,"inherit"),borderBottomColor:mn(Be.DIVIDER_COLOR,He.DIVIDER_COLOR),borderBottomStyle:"solid",borderBottomWidth:"1px"}},zn={[`${ye.HOST} ${ye.SIDEBAR_SHELL}`]:{borderInlineEndColor:mn(Be.BORDER_COLOR,He.DIVIDER_COLOR,"rgba(0,0,0,.12)")}},Qn={[`${ye.HOST} ${ye.SIDEBAR_TOP_ITEMS_CONTAINER}`]:{scrollbarColor:mn(Be.SCROLLBAR_THUMB_COLOR,He.SCROLLBAR_THUMB_COLOR)+" transparent"},[`${ye.HOST} ${ye.SIDEBAR_TOP_ITEMS_CONTAINER}${Ce.WEBKIT_SCROLLBAR_THUMB}`]:{background:mn(Be.SCROLLBAR_THUMB_COLOR,He.SCROLLBAR_THUMB_COLOR)}},Zn={[`${ye.MENU}[${Le.BLOCKED}]`]:{pointerEvents:"none"},[`${ye.MENU}[${Le.BLOCKED}] > ${Re.HA_ICON_BUTTON}`]:{pointerEvents:"all"}},ei={[`${ye.HOST} ${Re.ITEM}:not(${ye.ITEM_SELECTED})${Ce.BEFORE}`]:{background:mn(Be.ITEM_BACKGROUND,"none"),bottom:"0px",content:'""',borderRadius:"4px",display:"block",left:"0px",position:"absolute",pointerEvents:"none",right:"0px",top:"0px"}},ti={[`${ye.HOST} ${ye.SURFACE}${Ce.BEFORE}`]:{background:mn(Be.ITEM_BACKGROUND_HOVER,He.MD_RIPPLE_HOVER_COLOR,He.MD_SYS_COLOR_ON_SURFACE,"#1d1b20")},[`${ye.HOST} ${ye.SURFACE_HOVERED}${Ce.BEFORE}`]:{opacity:mn(Be.ITEM_BACKGROUND_HOVER_OPACITY,He.MD_RIPPLE_HOVER_OPACITY,".08")}},ni={[`${ye.HOST} ${ye.ITEM}[${Le.WITH_DIVIDER}]`]:{marginBottom:"var(--ha-space-2)",position:"relative"},[`${ye.HOST} ${Re.ITEM}[${Le.WITH_DIVIDER}]`]:{paddingBottom:"10px"},[`${ye.HOST} ${ye.ITEM}[${Le.WITH_DIVIDER}]${Ce.AFTER}`]:{content:'""',backgroundColor:mn(Be.DIVIDER_COLOR,He.DIVIDER_COLOR),bottom:0,height:"1px",left:"calc(-1 * var(--ha-space-2))",position:"absolute",right:"calc(-1 * var(--ha-space-2))"},[`${ye.HOST} ${Re.ITEM}${ye.ITEM_SELECTED}[${Le.WITH_DIVIDER}]`]:{borderBottomLeftRadius:0,borderBottomRightRadius:0},[`${ye.HOST} ${Re.ITEM}${ye.ITEM_SELECTED}[${Le.WITH_DIVIDER}]${Ce.BEFORE}`]:{bottom:"10px"}},ii={[`${ye.HOST} ${Re.ITEM} > :is(${Re.HA_SVG_ICON}, ${Re.HA_ICON})`]:{color:mn(Be.ICON_COLOR,He.SIDEBAR_ICON_COLOR)}},oi={[`${ye.HOST} ${Re.ITEM}${ye.ITEM_SELECTED} > :is(${Re.HA_SVG_ICON}, ${Re.HA_ICON})[slot="start"]`]:{color:mn(Be.ICON_COLOR_SELECTED,He.SIDEBAR_SELECTED_ICON_COLOR)}},ri={[`${ye.HOST} ${ye.ITEM_HOVER}:not(${ye.ITEM_SELECTED}) > :is(${Re.HA_SVG_ICON}, ${Re.HA_ICON})`]:{color:mn(Be.ICON_COLOR_HOVER,Be.ICON_COLOR,He.SIDEBAR_ICON_COLOR)}},si={[`${ye.HOST} ${ye.ITEM} > ${ye.ITEM_TEXT}`]:{color:mn(Be.TEXT_COLOR,He.SIDEBAR_TEXT_COLOR)}},ai={[`${ye.HOST} ${Re.ITEM}${ye.ITEM_SELECTED} > ${ye.ITEM_TEXT}`]:{color:mn(Be.TEXT_COLOR_SELECTED,He.SIDEBAR_SELECTED_TEXT_COLOR)}},ci={[`${ye.HOST} ${ye.ITEM_HOVER}:not(${ye.ITEM_SELECTED}) > ${ye.ITEM_TEXT}`]:{color:mn(Be.TEXT_COLOR_HOVER,Be.TEXT_COLOR,He.SIDEBAR_TEXT_COLOR)}},li={[`${ye.HOST} ${Re.ITEM}${ye.ITEM_SELECTED}${Ce.BEFORE}`]:{backgroundColor:mn(Be.SELECTION_BACKGROUND,Be.ICON_COLOR_SELECTED,He.SIDEBAR_SELECTED_ICON_COLOR),opacity:mn(Be.SELECTION_OPACITY,He.DIVIDER_OPACITY)}},di={[`${ye.HOST_EXPANDED} :is(${ye.SIDEBAR_TOP_ITEMS_CONTAINER}, ${ye.SIDEBAR_BOTTOM_ITEMS_CONTAINER}) > ${ye.ITEM} > ${ye.ITEM_TEXT}${ye.DATA_INFO}${Ce.AFTER}`]:{color:mn(Be.INFO_COLOR,He.SIDEBAR_TEXT_COLOR)}},ui={[`${ye.HOST_EXPANDED} :is(${ye.SIDEBAR_TOP_ITEMS_CONTAINER}, ${ye.SIDEBAR_BOTTOM_ITEMS_CONTAINER}) > ${Re.ITEM}${ye.ITEM_SELECTED} > ${ye.ITEM_TEXT}${ye.DATA_INFO}${Ce.AFTER}`]:{color:mn(Be.INFO_COLOR_SELECTED,He.SIDEBAR_SELECTED_TEXT_COLOR)}},hi={[`${ye.HOST_EXPANDED} :is(${ye.SIDEBAR_TOP_ITEMS_CONTAINER}, ${ye.SIDEBAR_BOTTOM_ITEMS_CONTAINER}) > ${ye.ITEM_HOVER}:not(${ye.ITEM_SELECTED}) > ${ye.ITEM_TEXT}${ye.DATA_INFO}${Ce.AFTER}`]:{color:mn(Be.INFO_COLOR_HOVER,Be.INFO_COLOR,He.SIDEBAR_TEXT_COLOR)}},_i={[`${ye.HOST} ${ye.ITEM_SELECTED} > ${ye.BADGE}`]:{backgroundColor:mn(Be.NOTIFICATION_COLOR_SELECTED,Be.NOTIFICATION_COLOR,He.ACCENT_COLOR),color:mn(Be.NOTIFICATION_TEXT_COLOR_SELECTED,Be.NOTIFICATION_TEXT_COLOR,He.TEXT_ACCENT_COLOR,He.TEXT_PRIMARY_COLOR)}},pi={[`${ye.HOST} ${ye.ITEM_HOVER}:not(${ye.ITEM_SELECTED}) > ${ye.BADGE}`]:{backgroundColor:mn(Be.NOTIFICATION_COLOR_HOVER,Be.NOTIFICATION_COLOR,He.ACCENT_COLOR),color:mn(Be.NOTIFICATION_TEXT_COLOR_HOVER,Be.NOTIFICATION_TEXT_COLOR,He.TEXT_ACCENT_COLOR,He.TEXT_PRIMARY_COLOR)}},fi={[`${ye.HA_MENU_BUTTON}`]:!1},Ei={[ye.HOST_EXPANDED_NOT_MODAL]:{HaSidebarWidth:mn(Be.WIDTH,Be.WIDTH_EXTENDED,"calc(256px + var(--safe-area-inset-left, 0px))")},[ye.HOST_EXPANDED_MODAL]:{HaSidebarWidth:mn(Be.WIDTH,Be.WIDTH_HIDDEN,"calc(256px + var(--safe-area-inset-left, 0px))")}},Oi={[`${ye.HOST} > ${ye.SIDEBAR_BOTTOM_ITEMS_CONTAINER}[${Le.EMPTY}]`]:{display:"none"}};class mi{constructor(e,t){this._setElementVariables=(e,t)=>{t.forEach((([t,n])=>{n&&e.style.setProperty(t,n)}))},this._logger=t;const n=new U({shouldReject:this._logger.enabled});n.addEventListener($.ON_LISTEN,(t=>{this._homeAssistant=t.detail.HOME_ASSISTANT,this._main=t.detail.HOME_ASSISTANT_MAIN,this._haDrawer=t.detail.HA_DRAWER,this._sidebar=t.detail.HA_SIDEBAR,this._partialPanelResolver=t.detail.PARTIAL_PANEL_RESOLVER,this._logger.log("HAQuerySelector init executed",{HOME_ASSISTANT:this._homeAssistant,HOME_ASSISTANT_MAIN:this._main,HA_DRAWER:this._haDrawer,HA_SIDEBAR:this._sidebar,PARTIAL_PANEL_RESOLVER:this._partialPanelResolver},{stringify:!1}),this._process(e)}),{once:!0}),n.addEventListener($.ON_PANEL_LOAD,this._panelLoaded.bind(this)),this._huiViewContainerObserver=new MutationObserver(this._watchHuiViewContainer.bind(this)),this._styleManager=new de({prefix:Te,namespace:Te,throwWarnings:!1}),this._items=[],this._logBookMessagesMap=new Map,this._logger.log("Wait for Home Assistant to be ready..."),this._waitForReadiness().then((()=>{this._logger.log("Starting the plugin..."),n.listen()}))}_waitForReadiness(){return e(this,void 0,void 0,(function*(){const e={shouldReject:this._logger.enabled},t=yield dn(Re.HOME_ASISTANT,e).toBeAdded(),n=yield dn(t.shadowRoot,Re.HOME_ASSISTANT_MAIN,e).toBeAdded();yield dn(n.shadowRoot,Re.HA_SIDEBAR,e).toBeAdded()}))}_waitForSidebarReady(){return e(this,void 0,void 0,(function*(){const e=yield this._sidebar.selector.$.element;yield dn(e,ye.SIDEBAR_LOADER,{shouldReject:this._logger.enabled}).toBeRemoved()}))}_compileConfig(e){this._config=((e,t,n)=>new En(n,e,t).config)(this._ha.hass.user,navigator.userAgent.toLowerCase(),e),this._logger.log("Compiled config",this._config)}_getContainerItems(t){return e(this,arguments,void 0,(function*(e,t=!1){const n=yield i((()=>e.querySelectorAll(`:scope > ${ye.ITEM}`)),(e=>Array.from(e).every((e=>e.querySelector(ye.ITEM_TEXT).textContent.trim().length>0))),{retries:100,delay:50,shouldReject:this._logger.enabled});return n.forEach((e=>{e.setAttribute(Le.FIXED,t?we.TRUE:we.FALSE)})),n}))}_mapItemsForDebug(e){return Array.from(e).map((e=>{const t=e.href;return{text:e.querySelector(ye.ITEM_TEXT).textContent.trim(),href:t}}))}_getElements(){return e(this,void 0,void 0,(function*(){yield this._waitForSidebarReady();const e=yield this._sidebar.selector.$.query(ye.SIDEBAR_TOP_ITEMS_CONTAINER).element,t=yield this._sidebar.selector.$.query(ye.SIDEBAR_BOTTOM_ITEMS_CONTAINER).element,n=yield this._getContainerItems(e),i=yield this._getContainerItems(t,!0);if(this._logger.enabled){const e=this._mapItemsForDebug(n),t=this._mapItemsForDebug(i);this._logger.log("Top Native sidebar items",e,{table:!0}),this._logger.log("Bottom Native sidebar items",t,{table:!0})}return{topItemsContainer:e,bottomItemsContainer:t,topItems:n,bottomItems:i}}))}_hideItem(e,t){t?e.style.display=we.NONE:e.style.removeProperty("display")}_buildNotification(e){const t=document.createElement(Se.SPAN);return t.classList.add(ve.BADGE),t.setAttribute(Le.SLOT,e),t}_getId(e){var t;const n=(null!==(t=e.href)&&void 0!==t?t:e.item).replace(/\W/g,"-");return`${we.SIDEBAR_PANEL}-${n}`}_buildNewItem(e){var t,n;const i=document.createElement(e.section_header?Re.ITEM_BASE:Re.ITEM),o=document.createElement(Se.SPAN);if(o.classList.add(ve.ITEM_TEXT),o.setAttribute(Le.SLOT,we.HEADLINE),o.innerText=e.item,e.section_header)i.appendChild(o);else{i.setAttribute(Le.ID,this._getId(e)),i.setAttribute(Le.NEW_ITEM,we.TRUE),i.href=null!==(t=e.href)&&void 0!==t?t:"#",i.target=null!==(n=e.target)&&void 0!==n?n:"";const r=this._buildNotification(we.START),s=this._buildNotification(we.END);i.appendChild(r),i.appendChild(o),i.appendChild(s)}return i.tabIndex=-1,i}_buildTooltip(e,t){const n=document.createElement(Re.TOOLTIP);return n.setAttribute(Le.FOR,e),n.setAttribute(Le.SHOW_DELAY,we.ZERO),n.setAttribute(Le.HIDE_DELAY,we.ZERO),n.setAttribute(Le.PLACEMENT,we.RIGHT),n.textContent=t,n}_getTemplateString(t){return e(this,void 0,void 0,(function*(){let e="";if(t instanceof Promise||qt(t)||Kt(t)||Yt(t)||Jt(t)||zt(t)||(n=t,"[object RegExp]"===Object.prototype.toString.call(n)))if(qt(t))e=t.trim();else if(Kt(t)||Yt(t))e=t.toString();else if(t instanceof Promise){const n=yield t;e=yield this._getTemplateString(n)}else e=JSON.stringify(t);var n;return e}))}_subscribeTitle(){this._sidebar.selector.$.query(ye.TITLE).element.then((e=>{this._config.title&&(e.innerHTML="",this._subscribeTemplate(this._config.title,(t=>{e.innerHTML=t}))),this._config.subtitle&&this._subscribeTemplate(this._config.subtitle,(t=>{e.dataset.subtitle=t}))}))}_subscribeSideBarEdition(){const e=e=>{e.preventDefault(),e.stopImmediatePropagation()},t=(t,n)=>{t.removeEventListener(De.SHOW_DIALOG,e,!0),n.removeAttribute(Le.BLOCKED)},n=(t,n)=>{t.removeEventListener(De.SHOW_DIALOG,e,!0),t.addEventListener(De.SHOW_DIALOG,e,!0),n.setAttribute(Le.BLOCKED,we.EMPTY)};Promise.all([this._sidebar.element,this._sidebar.selector.$.query(ye.MENU).element]).then((([e,i])=>{Yt(this._config.sidebar_editable)&&(this._config.sidebar_editable||n(e,i)),qt(this._config.sidebar_editable)&&this._subscribeTemplate(this._config.sidebar_editable,(o=>{let r;o===we.TRUE||o===we.FALSE?(r=!(o===we.FALSE),r?t(e,i):n(e,i)):(r=void 0,t(e,i)),this._checkProfileEditableButton(r)}))}))}_subscribeAttributes(e,t){const n=t=>{var n,i;const o=null!==(i=null===(n=e.element.getAttribute(Le.CUSTOM_SIDEBAR_ATTRIBUTES))||void 0===n?void 0:n.split("|"))&&void 0!==i?i:[];o.forEach((t=>{e.element.removeAttribute(t)})),o.splice(0),t.forEach((t=>{const[n,i]=t;qt(i)||Kt(i)||Yt(i)?(e.element.setAttribute(n,`${i}`),o.push(n)):console.warn(`${Te}: the property "${n}" in the attributes property of the item "${e.item}" should be a string, a number or a boolean. This property will be omitted`)})),e.element.setAttribute(Le.CUSTOM_SIDEBAR_ATTRIBUTES,o.join("|"))};qt(t)?this._subscribeTemplate(t,(e=>{try{const t=JSON.parse(e);n(Object.entries(t))}catch(e){throw new SyntaxError(`${Te}: "attributes" template must always return an object`)}})):n(Object.entries(t))}_subscribeName(e,t){const n=e.querySelector(ye.ITEM_TEXT);n.innerHTML="",this._subscribeTemplate(t,(t=>{n.innerHTML=t;const i=this._getTooltip(e);i&&(i.textContent=t)}))}_subscribeIcon(e,t){this._subscribeTemplate(t,(t=>{let n=e.querySelector(Re.HA_ICON);if(!n){n=document.createElement(Re.HA_ICON),n.setAttribute(Le.SLOT,we.START);const t=e.querySelector(Re.HA_SVG_ICON);t?t.replaceWith(n):e.prepend(n)}n.setAttribute(Le.ICON,t)}))}_subscribeInfo(e,t){const n=e.querySelector(ye.ITEM_TEXT);this._subscribeTemplate(t,(e=>{n.dataset.info=e}))}_subscribeNotification(e,t){const n=e.querySelector(ye.ITEM_TEXT);let i=e.querySelector(`${ye.BADGE}[slot="${we.START}"]`),o=e.querySelector(`${ye.BADGE}[slot="${we.END}"]`);i||(i=this._buildNotification(we.START),e.insertBefore(i,n)),o||(o=this._buildNotification(we.END),e.append(o));this._subscribeTemplate(t,(t=>{t.length?(i.innerHTML=t,o.innerHTML=t,e.setAttribute(Le.WITH_NOTIFICATION,we.TRUE)):(i.innerHTML="",o.innerHTML="",e.removeAttribute(Le.WITH_NOTIFICATION))}))}_checkEmptyBottomList(){return e(this,void 0,void 0,(function*(){const e=yield this._sidebar.selector.$.query(ye.SIDEBAR_BOTTOM_ITEMS_CONTAINER).element,t=e.querySelectorAll(`:scope > ${ye.ITEM}`);Array.from(t).some((e=>""===e.style.display))?e.removeAttribute(Le.EMPTY):e.setAttribute(Le.EMPTY,we.EMPTY)}))}_subscribeHide(e,t){Yt(t)?this._hideItem(e,t):this._subscribeTemplate(t,(t=>{this._hideItem(e,t===we.TRUE),this._checkEmptyBottomList()}))}_subscribeTemplateVariableChanges(e,t,n){n.forEach((([n,i])=>{e[n]&&this._subscribeTemplate(e[n],(e=>{t.style.setProperty(i,e)}))}))}_subscribeTemplate(e,t){const n=On(`${e}`,this._config.partials);Ke.test(n)?this._createJsTemplateSubscription(n.replace(Ke,"$1"),t):Ye.test(n)?this._createJinjaTemplateSubscription(n,t):this._getTemplateString(n).then((e=>{t(e)}))}_createJsTemplateSubscription(e,t){this._renderer.trackTemplate(e,(e=>{this._getTemplateString(e).then((e=>{t(e)}))}))}_createJinjaTemplateSubscription(e,t){return new Promise((n=>{hn().then((i=>{const o=i.conn.subscribeMessage((e=>{t(`${e.result}`)}),{type:De.RENDER_TEMPLATE,template:e,variables:Object.assign({user_name:this._ha.hass.user.name,user_is_admin:this._ha.hass.user.is_admin,user_is_owner:this._ha.hass.user.is_owner,user_agent:window.navigator.userAgent},this._config.jinja_variables)});n(o)}))}))}_focusItem(e,t){const n=this._items.length;let i=0;if(t){const t=e+1,o=t+n;for(let e=t;e<o;e++){const t=e>n-1?e-n:e;if(this._items[t].nodeName!==xe.ITEM_BASE&&this._items[t].style.display!==we.NONE){i=t;break}}}else{const t=e-1,o=t-n;for(let e=t;e>o;e--){const t=e<0?n+e:e;if(this._items[t].nodeName!==xe.ITEM_BASE&&this._items[t].style.display!==we.NONE){i=t;break}}}this._items[i].focus(),this._items[i].tabIndex=0}_focusItemByKeyboard(e,t){const n=[`${ye.SCOPE} > ${Re.ITEM}:not(.${ve.ITEM_SELECTED}):focus`,`${ye.SCOPE} > ${Re.ITEM}:focus`],i=e.querySelector(n.join(","));let o=0;this._items.forEach(((e,t)=>{e===i&&(o=t),e.tabIndex=-1})),this._focusItem(o,t)}_focusItemByTab(e,t,n){const i=e.querySelector(Re.HA_ICON_BUTTON),o=this._items.indexOf(t),r=this._items.length-1;o>=0&&(n&&o<r||!n&&o>0?this._focusItem(o,n):n||i.focus())}_getActiveElement(e=document){const t=e.activeElement;return t?t instanceof HTMLElement&&t.nodeName===xe.ITEM?t:t.shadowRoot&&Me.includes(t.nodeName)?this._getActiveElement(t.shadowRoot):null:null}_isAnalyticsOptionEnabled(e){return Boolean(this._config.analytics&&(!0===this._config.analytics||this._config.analytics[e]))}_getUserEntity(){var e;return null===(e=Object.entries(this._ha.hass.entities).filter((([,e])=>`${e.name}`.toLowerCase()===this._ha.hass.user.name.toLocaleLowerCase()))[0])||void 0===e?void 0:e[0]}_logBookLog(e){window.clearTimeout(this._logBookMessagesMap.get(e)),this._logBookMessagesMap.set(e,window.setTimeout((()=>{this._ha.hass.callService("logbook","log",{name:Te,message:e,domain:"person",entity_id:this._getUserEntity()}),this._logBookMessagesMap.delete(e)}),500))}_processDefaultPath(){const e=this._config.default_path;if(e){const t=On(e,this._config.partials);if(Ke.test(t)){const e=this._renderer.renderTemplate(t.replace(Ke,"$1"));this._executeDefaultPath(e)}else if(Ye.test(t)){const e=this._createJinjaTemplateSubscription(t,(t=>{this._executeDefaultPath(t),e.then((e=>{e()}))}))}else this._executeDefaultPath(t)}}_executeDefaultPath(e){Zt(e,!0,"ignoring default_path property")}_processSidebarMode(){return e(this,void 0,void 0,(function*(){Promise.all([this._main.element,this._partialPanelResolver.element]).then((([t,n])=>{var o;const r=this._config.sidebar_mode,s=matchMedia("(max-width: 870px)");if(r){const a="dockedSidebar",c=JSON.parse(null!==(o=window.localStorage.getItem(a))&&void 0!==o?o:'""'),l=Ve[r];c!==l&&Qt(this._ha,De.DOCK_SIDEBAR,{dock:l});const d=o=>e(this,void 0,void 0,(function*(){r!==ue.HIDDEN&&(t.narrow=!1,n.narrow=o);const e=yield i((()=>{var e,t;const i=null===(e=n.querySelector(Re.HA_PANEL_LOVELACE))||void 0===e?void 0:e.shadowRoot;return null===(t=null==i?void 0:i.querySelector(Re.HUI_ROOT))||void 0===t?void 0:t.shadowRoot}),(e=>!!e),{shouldReject:!1});e&&(this._styleManager.removeStyle(e),r!==ue.HIDDEN&&o&&this._styleManager.addStyle(fi,e))}));s.addEventListener(De.CHANGE,(e=>{d(e.matches)})),d(s.matches)}}))}))}_processSidebar(){return e(this,void 0,void 0,(function*(){Promise.all([this._main.element,this._haDrawer.element,this._sidebar.element,this._sidebar.selector.$.element]).then((e=>{const[t,n,i,o]=e,{width:r}=this._config;Jt(r)?this._setElementVariables(t,[[Be.WIDTH_EXTENDED,ln(r.extended)],[Be.WIDTH_HIDDEN,ln(r.hidden)]]):this._setElementVariables(t,[[Be.WIDTH,ln(r)]]),this._subscribeTemplateVariableChanges(this._config,n,Ue),this._subscribeTemplateVariableChanges(this._config,i,je);this._sidebar.selector.$.query(ye.MENU_BUTTON).$.element.then((e=>{this._styleManager.addStyle([Kn],e)})),this._styleManager.addStyle([zn],n.shadowRoot),this._styleManager.addStyle(Ei,t.shadowRoot),this._styleManager.addStyle([Un,Gn,Vn,Wn,Xn,qn,Yn,Jn,Qn,Zn,ni,ei,ii,oi,ri,si,ai,ci,li,di,ui,hi,_i,pi,Oi,this._config.styles||""],o)})),yield this._waitForSidebarReady().then((()=>{Promise.all([this._sidebar.selector.$.query(ye.SIDEBAR_TOP_ITEMS_CONTAINER).element,this._sidebar.selector.$.query(ye.SIDEBAR_BOTTOM_ITEMS_CONTAINER).element,this._sidebar.selector.$.element]).then((e=>{const[t,n,i]=e;window.addEventListener(De.KEYDOWN,(e=>{if(e.key===$e.TAB){const t=this._getActiveElement();if(t){const n=t;n.nodeName===xe.ITEM&&(n.classList.contains(ve.USER)&&!e.shiftKey||(e.preventDefault(),e.stopImmediatePropagation(),this._focusItemByTab(i,n,!e.shiftKey)))}}}),!0),this._isAnalyticsOptionEnabled(We.SIDEBAR_ITEM_CLICKED)&&i.addEventListener(De.CLICK,(e=>{const t=e.target.closest(Re.ITEM);if(t){const e=t.querySelector(ye.ITEM_TEXT).textContent;this._logBookLog(`${We.SIDEBAR_ITEM_CLICKED}: ${e}`)}})),t.addEventListener(De.KEYDOWN,(e=>{e.key!==$e.ARROW_DOWN&&e.key!==$e.ARROW_UP||(e.preventDefault(),e.stopImmediatePropagation(),this._focusItemByKeyboard(t,e.key===$e.ARROW_DOWN))}),!0),n.addEventListener(De.KEYDOWN,(e=>{e.key!==$e.ARROW_DOWN&&e.key!==$e.ARROW_UP||(e.preventDefault(),e.stopImmediatePropagation(),this._focusItemByKeyboard(n,e.key===$e.ARROW_DOWN))}),!0)}))}))}))}_aplyItemRippleStyles(){return e(this,void 0,void 0,(function*(){const e=yield this._sidebar.selector.$.query(Re.ITEM).all;Array.from(e).forEach((e=>{const t=e.shadowRoot.querySelector(`${Se.ANCHOR}, ${Se.BUTTON}`).querySelector(Re.HA_RIPPLE).shadowRoot.querySelector(ye.SURFACE);this._styleManager.addStyle([ti],t)}))}))}_getTooltip(e){return e.parentElement.querySelector(`${Re.TOOLTIP}[${Le.FOR}="${e.id}"]`)}_refreshTooltips(){return e(this,void 0,void 0,(function*(){const e=yield this._sidebar.element,t=e.alwaysExpand||un;e.shadowRoot.querySelectorAll(`${Re.ITEM}[${Le.NEW_ITEM}]`).forEach((e=>{let n=this._getTooltip(e);if(t)null==n||n.parentElement.removeChild(n);else if(!n){const t=e.querySelector(ye.ITEM_TEXT).textContent;n=this._buildTooltip(e.id,t),e.after(n)}}))}))}_patchSidebarMethods(){const e=this._logger,t=this;e.log("Patching the sidebar shouldUpdate method..."),customElements.whenDefined(Re.HA_SIDEBAR).then((n=>{const i=n.prototype.shouldUpdate;n.prototype.shouldUpdate=function(n){return"RUNNING"!==this.hass.config.state?(e.log(`Home Assistant config state is ${this.hass.config.state}. Cancelling the update!`),!1):((n.has("expanded")||n.has("narrow")||n.has("alwaysExpand"))&&t._refreshTooltips(),i.call(this,n))}}))}_rearrange(){this._getElements().then((e=>{const{order:t,hide_all:n}=this._config,{topItemsContainer:i,bottomItemsContainer:o,topItems:r,bottomItems:s}=e;let a=0;const c=document.createDocumentFragment(),l=document.createDocumentFragment();this._items=[...Array.from(r),...Array.from(s)];const d=new Set,u=this._items.length;n&&this._items.forEach((e=>{this._hideItem(e,!0)}));t.reduce(((e,t)=>{const{item:n,match:i,exact:o,new_item:r}=t,s=n.toLocaleLowerCase(),a=r?void 0:this._items.find((e=>{const t=i===pe.HREF?e.href:e.querySelector(ye.ITEM_TEXT).textContent.trim();return!((!o||n!==t)&&(o||!t||!t.toLowerCase().includes(s)))&&(!d.has(e)&&(d.add(e),!0))}));return a&&a.setAttribute(Le.PROCESSED,we.TRUE),(r||a)&&e.push(Object.assign(Object.assign({},t),{element:a})),r||a||console.warn(`${Te}: you have an order item in your configuration that didn't match any sidebar item: "${n}"`),e}),[]).forEach((e=>{if(e.new_item){const t=this._buildNewItem(e);e.element=t,e.element.setAttribute(Le.PROCESSED,we.TRUE),e.element.setAttribute(Le.FIXED,e.bottom?we.TRUE:we.FALSE),this._items.push(e.element)}else if(e.element){const t=e.element;e.href&&(t.href=e.href),e.target&&(t.target=e.target)}(e.new_item||e.bottom&&e.element.getAttribute(Le.FIXED)===we.FALSE||!e.bottom&&e.element.getAttribute(Le.FIXED)===we.TRUE)&&(e.bottom?l.appendChild(e.element):c.appendChild(e.element)),Xt(e.order)?(e.element.style.order=`${a}`,a++):(e.element.style.order=`${e.order}`,a=e.order+1),Xt(e.attributes)||this._subscribeAttributes(e,e.attributes),e.divider&&e.element.setAttribute(Le.WITH_DIVIDER,we.TRUE),e.name&&this._subscribeName(e.element,e.name),e.icon&&this._subscribeIcon(e.element,e.icon),e.info&&this._subscribeInfo(e.element,e.info),e.notification&&this._subscribeNotification(e.element,e.notification),Xt(e.hide)||this._subscribeHide(e.element,e.hide),this._subscribeTemplateVariableChanges(e,e.element,Fe),e.on_click&&e.element.addEventListener(De.CLICK,this._mouseClick.bind(this,e),!0)})),this._items.forEach((e=>{e.hasAttribute(Le.PROCESSED)||(e.style.order=a>0?`${a}`:`${u}`)})),this._items.sort(((e,t)=>+e.style.order-+t.style.order)),i.appendChild(c),o.appendChild(l),this._patchSidebarMethods(),this._aplyItemRippleStyles(),this._panelLoaded(),this._checkEmptyBottomList(),this._refreshTooltips(),this._processSidebarMode()}))}_mouseClick(t,n){return e(this,void 0,void 0,(function*(){const{on_click:e,element:i}=t,o=e,r=i,s=r.querySelector(ye.ITEM_TEXT).textContent.trim();"#"===r.href&&n.preventDefault();const a=e=>{const n=e.includes("return")?e:`${e}\n;return;`;return this._renderer.renderTemplate(n,{variables:{item:t,itemText:s}})};switch(o.action){case fe.NAVIGATE:{const{path:e,replace:t=!1}=o;let n=e;Ke.test(e)&&(n=a(On(e.replace(Ke,"$1"),this._config.partials))),Zt(n,t,"ignoring on_click.path property");break}case fe.CALL_SERVICE:{const{service:e,data:t={}}=o,n=e.match(ze),i=Object.entries(t).map((([e,t])=>{const n=On(`${t}`,this._config.partials);return Ke.test(n)?[e,a(n.replace(Ke,"$1"))]:[e,t]}));3===(null==n?void 0:n.length)?this._ha.hass.callService(n[1],n[2],Object.fromEntries(i)):console.warn(`${Te} ignoring "${fe.CALL_SERVICE}" action in "${s}" item. The service parameter is malfomed.`);break}case fe.JAVASCRIPT:{const{code:e}=o;a(On(e,this._config.partials));break}case fe.OPEN_DIALOG:{const{type:e}=o;switch(e){case Ee.MORE_INFO:sn(this._ha,o.entity_id);break;case Ee.RESTART:rn(this._ha)}}}}))}_checkProfileEditableButton(){return e(this,arguments,void 0,(function*(e=void 0){const t=yield this._partialPanelResolver.element,n=(yield i((()=>t.route),(e=>!!(null==e?void 0:e.path)),{shouldReject:this._logger.enabled})).path;if(qe.test(n)){const t=yield this._partialPanelResolver.selector.query(ye.EDIT_SIDEBAR_BUTTON).element;if(t){const n=Yt(e)?e:this._config.sidebar_editable;if(!Yt(n))return;!1===n?t.setAttribute(Le.DISABLED,we.EMPTY):t.removeAttribute(Le.DISABLED)}}}))}_panelLoaded(){return e(this,void 0,void 0,(function*(){this._checkProfileEditableButton();const e=yield this._partialPanelResolver.element,t=`${location.pathname}${location.search}`,n=yield this._sidebar.selector.$.element,i=Array.from(n.querySelectorAll(Re.ITEM)),o=i.filter((e=>e.style.display!==we.NONE)).reduce(((e,n)=>t.startsWith(n.href)&&(null===e||n.href.length>e.href.length)?n:e),null);i.forEach((e=>{const t=o===e;e.classList.toggle(ve.ITEM_SELECTED,t),e.tabIndex=t?0:-1})),this._huiViewContainerObserver.disconnect();if(e.querySelector(Re.HA_PANEL_LOVELACE)){this._partialPanelResolver.selector.query(Re.HA_PANEL_LOVELACE).$.query(Re.HUI_ROOT).$.query(Re.HUI_VIEW_CONTAINER).element.then((e=>{e&&this._huiViewContainerObserver.observe(e,{subtree:!0,childList:!0})}))}this._isAnalyticsOptionEnabled(We.PANEL_VISITED)&&this._logBookLog(`${We.PANEL_VISITED}: ${t}`)}))}_watchHuiViewContainer(e){e.forEach((({addedNodes:e})=>{e.forEach((e=>{e instanceof Element&&e.localName===Re.HUI_VIEW&&this._panelLoaded()}))}))}_process(t){this._homeAssistant.element.then((n=>{this._ha=n,this._logger.log("Hass ready",this._ha.hass),this._logger.log("Instantiating HomeAssistantJavaScriptTemplates..."),new oe(this._ha).getRenderer().then((n=>{var i,o,r;this._logger.log("HomeAssistantJavaScriptTemplates instantiated"),this._renderer=n,this._compileConfig(t),this._logger.log("Executing plugin logic..."),this._renderer.variables=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},null!==(i=this._config.js_variables)&&void 0!==i?i:{}),(r=this._sidebar,{navigate:Zt,activateItem:t=>e(void 0,void 0,void 0,(function*(){yield new Promise((e=>setTimeout(e,5)));const e=yield r.selector.$.query(`${Re.ITEM}.${ve.ITEM_SELECTED}`).element;e.classList.remove(ve.ITEM_SELECTED),e.tabIndex=-1,t.classList.add(ve.ITEM_SELECTED),t.tabIndex=0}))})),(e=>({fireEvent:function(t,n,i){const o=qt(t)?e:t,r=qt(t)?t:qt(n)?n:null,s=Jt(n)?n:Jt(i)?i:void 0;if(null===r)throw new SyntaxError('fireEvent method needs a string as event "type"');Qt(o,r,s)}}))(this._ha)),(e=>({checkConfig:()=>e.hass.callApi(Oe.POST,Ge.CHECK_CONFIG),renderTemplate:t=>e.hass.callApi(Oe.POST,Ge.TEMPLATE,{template:t}),callService:(t,n,i)=>e.hass.callService(t,n,i)}))(this._ha)),an(this._ha)),(t=>{const n=e=>{const n=document.createElement(Re.HUI_TIMESTAMP_DISPLAY);return n.hass=t.hass,n.ts=e instanceof Date?e:new Date(e),n},i=e=>e.render().values.join(""),o=t=>(...n)=>e(void 0,void 0,void 0,(function*(){return yield Tn.locale,t(...n)})),r={formatDate:e=>{const t=n(e);return t.format=me.DATE,i(t)},formatDateTime:e=>{const t=n(e);return t.format=me.DATETIME,i(t)},formatTime:e=>{const t=/^\d+:\d+(:\d+)?$/.test(e.toString())?`1900-01-01T${e}`:e,o=n(t);return o.format=me.TIME,i(o)},getRelativeTime:(e,t=!1)=>{const o=n(e);return o.format=me.RELATIVE,o.capitalize=t,o._updateRelative(),i(o)}},s=Object.fromEntries(Object.entries(r).map((([e,t])=>[`${e}Async`,o(t)])));return Object.assign(Object.assign({},r),s)})(this._ha)),(e=>({showToast:t=>{Qt(e,De.SHOW_TOAST,t)}}))(this._ha)),(t=>{const n=e=>t.hass.localize(e);return{localize:n,localizeAsync:t=>e(void 0,void 0,void 0,(function*(){return yield Tn.locale,n(t)}))}})(this._ha)),this._renderer.refs=null!==(o=this._config.js_refs)&&void 0!==o?o:{},this._processDefaultPath(),this._subscribeTitle(),this._processSidebar(),this._subscribeSideBarEdition(),this._rearrange()}))}))}}if(!window.CustomSidebar){const e=new An(new URLSearchParams(window.location.search).has("cs_debug"));An.logVersionToConsole(),e.log("Getting the config..."),Fn().then((t=>{e.log("Raw config",t),window.CustomSidebar=new mi(t,e)}))}}();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment