-
-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathcustom-sidebar-plugin.js
More file actions
1 lines (1 loc) · 130 KB
/
Copy pathcustom-sidebar-plugin.js
File metadata and controls
1 lines (1 loc) · 130 KB
1
!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,signal:l}=o,d=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 l=e();i(l)?t(l):(o++,o<s?setTimeout(r,a):c?n(new Error(d.replace(/\{\{\s*retries\s*\}\}/g,`${s}`))):t(l))};null==l||l.throwIfAborted(),null==l||l.addEventListener("abort",(()=>{n(l.reason)}),{once:!0}),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,h=()=>`You can not select a shadowRoot (${r}) of the document.`,u=()=>`You can not select a shadowRoot (${r}) of a shadowRoot.`,_=e=>"string"==typeof e,p=e=>{return t=e,"[object Object]"===Object.prototype.toString.call(t)&&(0===Object.keys(e).length||["retries","delay","shouldReject"].some((t=>t in e)));var t},E=(e,t,n)=>{var i,o,r,s,a,h;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!==(h=n.shouldReject)&&void 0!==h?h:d]:[e,t,c,l,d];throw new TypeError("Wrong parameters have been provided.")};function f(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(h());if(t instanceof ShadowRoot)throw new SyntaxError(u());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 g(e,t){if(1===e.length&&!e[0].length){if(t instanceof Document)throw new SyntaxError(h());if(t instanceof ShadowRoot)throw new SyntaxError(u());return t.shadowRoot}const n=T(e,t);return(null==n?void 0:n.shadowRoot)||null}const I=(e,t)=>{const n=e.querySelectorAll(t);if(n.length)return n;if(e instanceof Element&&e.shadowRoot){const n=I(e.shadowRoot,t);if(n.length)return n}const i=Array.from(e.querySelectorAll("*"));for(const e of i){const n=I(e,t);if(n.length)return n}return document.querySelectorAll(a)},b=(e,t,n,o,r)=>i((()=>I(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=f(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})}))}(...E(e,t,n))}))}function N(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=f(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})}))}(...E(e,t,n))}))}function v(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=f(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=g(o[t],e);if(n)return n}return null}(e,t,"asyncShadowRootQuerySelector","asyncQuerySelector")),(e=>!!e),{retries:n,delay:s,shouldReject:a})}))}(...E(e,t,n))}))}let R=class e{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 t=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?v(e[0],r,this._asyncParams):v(e,r,this._asyncParams)}));return new e(t,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(t){const n=m(this._element).then((e=>{if(null===e||e instanceof NodeList&&0===e.length){if(!this._asyncParams.shouldReject)return null;throw new SyntaxError('The "query" method can only be called from a defined element.')}return e instanceof NodeList?N(e[0],t,this._asyncParams):N(e,t,this._asyncParams)}));return new e(n,this._asyncParams)}deepQuery(t){const n=m(this._element).then((e=>{if(null===e||e instanceof NodeList&&0===e.length){if(!this._asyncParams.shouldReject)return null;throw new SyntaxError('The "deepQuery" method can only be called from a defined element.')}return e instanceof NodeList?Promise.race(Array.from(e).map((e=>b(e,t,this._asyncParams.retries,this._asyncParams.delay,this._asyncParams.shouldReject)))):b(e,t,this._asyncParams.retries,this._asyncParams.delay,this._asyncParams.shouldReject)}));return new e(n,this._asyncParams)}};const y="$",C={retries:100,delay:50,shouldReject:!1,eventThreshold:450};var L,D,w,$,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"}(D||(D={})),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"}(w||(w={})),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",e.DIV="div",e.FIRST_CHILD=":scope > *"}(x||(x={}));const H={[L.HOME_ASSISTANT]:{selector:x.HOME_ASSISTANT,children:{shadowRoot:{selector:y,children:{[L.HOME_ASSISTANT_MAIN]:{selector:x.HOME_ASSISTANT_MAIN,children:{shadowRoot:{selector:y,children:{[L.HA_DRAWER]:{selector:x.HA_DRAWER,children:{[L.HA_SIDEBAR]:{selector:x.HA_SIDEBAR,children:{shadowRoot:{selector:y}}},[L.PARTIAL_PANEL_RESOLVER]:{selector:x.PARTIAL_PANEL_RESOLVER}}}}}}}}}}}},M={[D.HA_PANEL_LOVELACE]:{selector:x.HA_PANEL_LOVELACE,children:{shadowRoot:{selector:y,children:{[D.HUI_ROOT]:{selector:x.HUI_ROOT,children:{shadowRoot:{selector:y,children:{[D.HEADER]:{selector:x.HEADER},[D.HUI_VIEW]:{selector:x.HUI_VIEW}}}}}}}}}},B={shadowRoot:{selector:y,children:{[w.HA_MORE_INFO_DIALOG]:{selector:x.HA_MORE_INFO_DIALOG,children:{shadowRoot:{selector:y,children:{[w.HA_DIALOG]:{selector:`${x.HA_ADAPTATIVE_DIALOG}, ${x.HA_DIALOG}`,children:{[w.HA_DIALOG_CONTENT]:{selector:x.HA_DIALOG_CONTENT,children:{[w.HA_MORE_INFO_DIALOG_INFO]:{selector:x.HA_MORE_INFO_DIALOG_INFO},[w.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK]:{selector:x.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK},[w.HA_DIALOG_MORE_INFO_SETTINGS]:{selector:x.HA_DIALOG_MORE_INFO_SETTINGS}}}}}}}}}}}};"function"==typeof SuppressedError&&SuppressedError;const P=(e,t,n,i=!1)=>Object.entries(t||{}).reduce(((t,o)=>{const[r,s]=o;if(s.selector===y&&n)return s.children?Object.assign(Object.assign({},t),P(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:P(e,s.children,a),selector:new R(a,e)},t}),{}),F=(e,t)=>{const n=Object.entries(t);for(const t of n){if(t[0]===e)return t[1];{const n=F(e,t[1].children);if(n)return n}}},k=(e,t)=>Object.keys(e).reduce(((e,n)=>{const i=F(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 U{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 j=class extends U{constructor(e={}){super(),this._config=Object.assign(Object.assign({},C),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=w.HA_MORE_INFO_DIALOG_INFO){this._dialogTree=P(this._config,B,this._haRootElements.HOME_ASSISTANT.element);const t=k(w,this._dialogTree);t.HA_DIALOG_CONTENT.element.then((e=>{this._dialogsContentObserver.disconnect(),this._dialogsContentObserver.observe(e,{childList:!0})})),this._haDialogElements=((e,t)=>[w.HA_MORE_INFO_DIALOG,w.HA_DIALOG,w.HA_DIALOG_CONTENT,t].reduce(((t,n)=>(t[n]=e[n],t)),{}))(t,e);const n={[w.HA_MORE_INFO_DIALOG_INFO]:$.ON_MORE_INFO_DIALOG_OPEN,[w.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK]:$.ON_HISTORY_AND_LOGBOOK_DIALOG_OPEN,[w.HA_DIALOG_MORE_INFO_SETTINGS]:$.ON_SETTINGS_DIALOG_OPEN};this._dispatchEvent(n[e],this._haDialogElements)}_updateRootElements(){this._homeAssistantRootTree=P(this._config,H),this._haRootElements=k(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=P(this._config,M,this._haRootElements[L.HA_DRAWER].element),this._haResolverElements=k(D,this._homeAssistantResolverTree),this._haResolverElements[D.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]:w.HA_MORE_INFO_DIALOG_INFO,[x.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK]:w.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK,[x.HA_DIALOG_MORE_INFO_SETTINGS]:w.HA_DIALOG_MORE_INFO_SETTINGS};if(e instanceof Element&&e.localName)if(e.localName===x.DIV){const n=e.querySelector(x.FIRST_CHILD);if(n&&n.localName in t){const e=n.localName;this._updateDialogElements(t[e])}}else if(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)}};function G(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 V="[home-assistant-javascript-templates]",W=/^([a-z_]+)\.(\w+)$/;var K,X,Y,q;!function(e){e.UNKNOWN="unknown",e.UNAVAILABLE="unavailable"}(K||(K={})),function(e){e.AREA_ID="area_id",e.NAME="name"}(X||(X={})),function(e){e.PANEL_URL="panel_url",e.LANG="lang"}(Y||(Y={})),function(e){e.LOCATION_CHANGED="location-changed",e.TRANSLATIONS_UPDATED="translations-updated",e.POPSTATE="popstate",e.SUBSCRIBE_ENTITIES="subscribe_entities"}(q||(q={}));const z="refs",Q=e=>e.reduce(((e,t)=>{const[n,i]=t;return e[n.replace(W,"$2")]=i,e}),{}),J=e=>e.includes("."),Z="ref",ee="value",te="toJSON",ne=e=>`${Z}.${e}`;function ie(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),h=e=>{const i=new SyntaxError(e);if(t)throw i;n&&console.warn(i)},u=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}},E=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(J(t))return u(t),p(e.hass.states[t],n);throw SyntaxError(`${V}: states method cannot be used with a domain, use it as an object instead.`)}),{get(t,n){if(J(n))return u(n),E(e.hass.states[n]);const i=Object.entries(e.hass.states).filter((([e])=>e.startsWith(n)));return i.length||d(n),new Proxy(Q(i),{get:(e,t)=>(u(`${n}.${t}`),E(e[t]))})}}),state_translated(t){if(u(t),e.hass.states[t])return e.hass.formatEntityState(e.hass.states[t])},is_state(t,n){var i;return u(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 u(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(u(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,K.UNKNOWN)||this.is_state(e,K.UNAVAILABLE)):(l(e),!1)},entities:new Proxy((t=>{if(void 0===t)return e.hass.entities;if(J(t))return u(t),e.hass.entities[t];const n=r().filter((([e])=>e.startsWith(t)));return n.length||d(t),new Proxy(Q(n),{get:(e,n)=>(u(`${t}.${n}`),e[n])})}),{get:(e,t)=>e(t)}),entity_prop(t,n){var i;return u(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(J(t))throw SyntaxError(`${V}: 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(J(n))throw SyntaxError(`${V}: 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(J(t)){u(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(J(t))return u(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(J(t)){u(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=ne(t);if(a.has(t))return a.get(t);const o=new Proxy({[ee]:n,[te](){return this[ee]}},{get(e,t,n){if(t===ee||t===te)return _(i),Reflect.get(e,t,n);h(`${t} is not a valid ${Z} property. A ${Z} only exposes a "${ee}" property`)},set:(t,n,o)=>n===ee?(t[ee]=o,e({c:{[i]:{}}}),!0):(h(`property "${n}" cannot be set in a ${Z}`),!1)});return a.set(t,o),o},unref(e,t){const n=ne(t);a.has(t)?(a.delete(t),e(n)):h(`${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(Y).includes(i)&&_(i),i){case Y.PANEL_URL:return window.location.pathname;case Y.LANG:return e.hass.language}n&&console.warn(`clientSideProxy should only be used to access these variables: ${Object.values(Y).join(", ")}`)}})}}class oe{constructor(e,t){const{throwErrors:n=!1,throwWarnings:i=!0,variables:o={},refs:r={},refsVariableName:s=z,autoReturn:a=!0}=t;this._subscribed=!1,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(Y).join("|")})($|[ \\?)+:\\}\\]><.,])`,"gm"),this._scopped=ie(e,n,i),this.refs=r,this._panelUrlWatchCallbackBinded=this._panelUrlWatchCallback.bind(this),this._watchForLanguageChangeCallbackBinded=this._watchForLanguageChangeCallback.bind(this)}_executeRenderingFunctions(e){e.forEach(((e,t)=>{e.forEach(((e,n)=>{this.trackTemplate(t,n,e)}))}))}_executeRenderingFunctionsByEntityId(e){this._executeRenderingFunctions(this._subscriptions.get(e))}_watchForPanelUrlChange(){window.addEventListener(q.LOCATION_CHANGED,this._panelUrlWatchCallbackBinded),window.addEventListener(q.POPSTATE,this._panelUrlWatchCallbackBinded)}_stopWatchForPanelUrlChange(){window.removeEventListener(q.LOCATION_CHANGED,this._panelUrlWatchCallbackBinded),window.removeEventListener(q.POPSTATE,this._panelUrlWatchCallbackBinded)}_panelUrlWatchCallback(){this._subscriptions.has(Y.PANEL_URL)&&this._executeRenderingFunctionsByEntityId(Y.PANEL_URL)}_watchForLanguageChange(){window.addEventListener(q.TRANSLATIONS_UPDATED,this._watchForLanguageChangeCallbackBinded)}_stopWatchForLanguageChange(){window.removeEventListener(q.TRANSLATIONS_UPDATED,this._watchForLanguageChangeCallbackBinded)}_watchForLanguageChangeCallback(){this._subscriptions.has(Y.LANG)&&this._executeRenderingFunctionsByEntityId(Y.LANG)}_watchForEntitiesChange(){return G(this,0,void 0,(function*(){if(this._subscribed)throw new Error("You cannot call init method consecutively, call stop first");this._subscribed=!0;try{const e=yield window.hassConnection,t=yield e.conn.subscribeMessage((e=>this._entityWatchCallback(e)),{type:q.SUBSCRIBE_ENTITIES});return this._cancelSubscription=t,this}catch(e){throw this._subscribed=!1,e}}))}_stopWatchForEntitiesChange(){if(!this._subscribed)throw new Error("You cannot call stop method without init being called");this._subscribed=!1,this._cancelSubscription()}_entityWatchCallback(e){if(this._subscriptions.size&&e.c)for(const t in e.c)this._subscriptions.has(t)&&this._executeRenderingFunctionsByEntityId(t)}_storeTracked(e,t,n,i){n.forEach((n=>{const o=[t,i];if(this._subscriptions.has(n)){const i=this._subscriptions.get(n);if(i.has(e)){const n=i.get(e);n.has(t)||n.set(...o)}else i.set(e,new Map([o]))}else this._subscriptions.set(n,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))}}))}init(){return G(this,0,void 0,(function*(){return this._watchForPanelUrlChange(),this._watchForLanguageChange(),this._watchForEntitiesChange()}))}stop(){this._stopWatchForPanelUrlChange(),this._stopWatchForLanguageChange(),this._stopWatchForEntitiesChange()}parseTemplate(e,t={}){try{this._scopped.cleanTracked();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{result: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())),entities:[...this._scopped.tracked]}}catch(e){if(this._throwErrors)throw e;return this._throwWarnings&&console.warn(e),{result:void 0,entities:[]}}}renderTemplate(e,t={}){const{result:n}=this.parseTemplate(e,t);return n}trackTemplate(e,t,n={}){const{result:i,entities:o}=this.parseTemplate(e,n);return this._storeTracked(e,t,o,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)}get subscribed(){return this._subscribed}}class re{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 oe(e,t)))}getRenderer(){return this._renderer}}const se=/([A-Z])([a-z0-9_-]+)/g,ae=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}{${ae(o)}}`):!1===o?n.push(`${t}{display: none !important}`):i.push(`${(e=>e.replace(se,((e,t,n,i)=>{const o=t.toLocaleLowerCase();return i?`-${o}${n}`:`--${o}${n}`})))(t)}:${o}`)})),`${n.join("")}${i.join(";")}`})).join(""),ce=(e,t)=>`${t}_${e}`,le=e=>e instanceof ShadowRoot?e.host.localName:e.localName,de=(e,t)=>{const n=ce(le(e),t);return e.querySelector(`#${n}`)};class he{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 de(e,this._prefix)}addStyle(e,t){((e,t,n,i,o)=>{if(t){let i=de(t,n);if(!i){const e=ce(le(t),n);i=document.createElement("style"),i.setAttribute("id",e),t.appendChild(i)}i.innerHTML="string"==typeof e?e:ae(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=de(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,_e,pe,Ee,fe,Oe,me,Te;!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"}(_e||(_e={})),function(e){e.AND="AND",e.OR="OR"}(pe||(pe={})),function(e){e.TEXT="text",e.HREF="href"}(Ee||(Ee={})),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"}(Oe||(Oe={})),function(e){e.GET="GET",e.POST="POST"}(me||(me={})),function(e){e.DATE="date",e.DATETIME="datetime",e.TIME="time",e.RELATIVE="relative"}(Te||(Te={}));const Ae="custom-sidebar",ge="custom-sidebar-config",Ie=`/local/${ge}`,be="base";var Se;!function(e){e.BOOLEAN="boolean",e.STRING="string",e.UNDEFINED="undefined",e.NUMBER="number"}(Se||(Se={}));var Ne,ve,Re,ye,Ce,Le,De,we,$e,xe,He;!function(e){e.ANCHOR="a",e.BUTTON="button",e.SPAN="span"}(Ne||(Ne={})),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.PARTIAL_PANEL_RESOLVER="partial-panel-resolver",e.TOOLTIP="ha-tooltip",e.USER_BADGE="ha-user-badge"}(ve||(ve={})),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_MODAL=":is(:host([expanded][modal]), :host(:not([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_HA_LIST_NAV=".panels-list > .wrapper > ha-list-nav",e.SIDEBAR_TOP_ITEMS_CONTAINER='.panels-list > .wrapper > ha-list-nav > slot[name="main-navigation"]',e.SIDEBAR_BOTTOM_ITEMS_CONTAINER='.panels-list > ha-list-nav > slot[name="fixed-navigation"]',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]"}(Re||(Re={})),function(e){e.MEDIA_HOVER="@media (hover:hover)"}(ye||(ye={})),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"}(Le||(Le={})),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"}(De||(De={})),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"}($e||($e={})),function(e){e.ARROW_DOWN="ArrowDown",e.ARROW_UP="ArrowUp",e.ENTER="Enter",e.TAB="Tab"}(xe||(xe={})),function(e){e.ITEM="HA-LIST-ITEM-BUTTON",e.ITEM_BASE="HA-LIST-ITEM-BASE",e.A="A"}(He||(He={}));const Me=["HOME-ASSISTANT","HOME-ASSISTANT-MAIN","HA-SIDEBAR"];var Be,Pe;!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"}(Be||(Be={})),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"}(Pe||(Pe={}));const Fe=["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"],ke=["selection_opacity","item_background_hover_opacity"],Ue=[["item_background",Pe.ITEM_BACKGROUND],["item_background_hover",Pe.ITEM_BACKGROUND_HOVER],["item_background_hover_opacity",Pe.ITEM_BACKGROUND_HOVER_OPACITY],["icon_color",Pe.ICON_COLOR],["icon_color_selected",Pe.ICON_COLOR_SELECTED],["icon_color_hover",Pe.ICON_COLOR_HOVER],["text_color",Pe.TEXT_COLOR],["text_color_selected",Pe.TEXT_COLOR_SELECTED],["text_color_hover",Pe.TEXT_COLOR_HOVER],["selection_background",Pe.SELECTION_BACKGROUND],["selection_opacity",Pe.SELECTION_OPACITY],["info_color",Pe.INFO_COLOR],["info_color_selected",Pe.INFO_COLOR_SELECTED],["info_color_hover",Pe.INFO_COLOR_HOVER],["notification_color",Pe.NOTIFICATION_COLOR],["notification_color_selected",Pe.NOTIFICATION_COLOR_SELECTED],["notification_color_hover",Pe.NOTIFICATION_COLOR_HOVER],["notification_text_color",Pe.NOTIFICATION_TEXT_COLOR],["notification_text_color_selected",Pe.NOTIFICATION_TEXT_COLOR_SELECTED],["notification_text_color_hover",Pe.NOTIFICATION_TEXT_COLOR_HOVER],["divider_color",Pe.DIVIDER_COLOR]],je=[["title_color",Pe.TITLE_COLOR],["subtitle_color",Pe.SUBTITLE_COLOR],["sidebar_button_color",Pe.BUTTON_COLOR],["sidebar_button_color_hover",Pe.BUTTON_COLOR_HOVER],["sidebar_button_background_hover",Pe.BUTTON_BACKGROUND_HOVER],["sidebar_button_background_hover_opacity",Pe.BUTTON_BACKGROUND_HOVER_OPACITY],["sidebar_background",Pe.BACKGROUND],["menu_background",Pe.MENU_BACKGROUND],["scrollbar_thumb_color",Pe.SCROLLBAR_THUMB_COLOR],...Ue],Ge=[["sidebar_border_color",Pe.BORDER_COLOR]],Ve=Object.freeze({CHECK_CONFIG:"config/core/check_config",TEMPLATE:"template",SERVICES:"services"}),We=Object.freeze({[ue.HIDDEN]:_e.ALWAYS_HIDDEN,[ue.NARROW]:_e.AUTO,[ue.EXTENDED]:_e.DOCKED}),Ke=Object.freeze({PANEL_VISITED:"panel_visited",SIDEBAR_ITEM_CLICKED:"sidebar_item_clicked"}),Xe=["%","em","ex","px","rem","vh","vmax","vmin","vw"],Ye=/\/profile(\/general)?$/,qe=/^\s*\[\[\[([\s\S]+)\]\]\]\s*$/,ze=/\{\{[\s\S]*\}\}|\{%[\s\S]*%\}/,Qe=/@partial\s+([\w-]+)/g,Je=/^\s*([a-z_]+)\.([\w-]+)\s*$/;var Ze=Symbol("NOT_RESOLVED");function et(e,t){return{tagName:e,nodeKind:"scalar",implicit:t.implicit??!1,matchByTagPrefix:t.matchByTagPrefix??!1,implicitFirstChars:t.implicitFirstChars??null,resolve:t.resolve,identify:t.identify,represent:t.represent??(e=>String(e)),representTagName:t.representTagName??(()=>e)}}function tt(e,t){const n=void 0===t.finalize;return{tagName:e,nodeKind:"sequence",implicit:!1,matchByTagPrefix:t.matchByTagPrefix??!1,create:t.create,addItem:t.addItem,finalize:t.finalize??(e=>e),carrierIsResult:n,identify:t.identify,represent:t.represent??(e=>e),representTagName:t.representTagName??(()=>e)}}function nt(e,t){const n=void 0===t.finalize;return{tagName:e,nodeKind:"mapping",implicit:!1,matchByTagPrefix:t.matchByTagPrefix??!1,create:t.create,addPair:t.addPair,has:t.has,keys:t.keys,get:t.get,finalize:t.finalize??(e=>e),carrierIsResult:n,identify:t.identify,represent:t.represent??(e=>e),representTagName:t.representTagName??(()=>e)}}var it=et("tag:yaml.org,2002:str",{resolve:e=>e,identify:e=>"string"==typeof e}),ot=["","~","null","Null","NULL"],rt=et("tag:yaml.org,2002:null",{implicit:!0,implicitFirstChars:["","~","n","N"],resolve:e=>-1!==ot.indexOf(e)?null:Ze,identify:e=>null===e,represent:()=>"null"}),st=et("tag:yaml.org,2002:null",{implicit:!0,implicitFirstChars:["n"],resolve:(e,t)=>"null"===e||t&&""===e?null:Ze,identify:e=>null===e,represent:()=>"null"}),at=["","~","null","Null","NULL"],ct=et("tag:yaml.org,2002:null",{implicit:!0,implicitFirstChars:["","~","n","N"],resolve:e=>-1!==at.indexOf(e)?null:Ze,identify:e=>null===e,represent:()=>"null"}),lt=["true","True","TRUE"],dt=["false","False","FALSE"],ht=et("tag:yaml.org,2002:bool",{implicit:!0,implicitFirstChars:["t","T","f","F"],resolve:e=>-1!==lt.indexOf(e)||-1===dt.indexOf(e)&&Ze,identify:e=>"[object Boolean]"===Object.prototype.toString.call(e),represent:e=>e?"true":"false"}),ut=["true"],_t=["false"],pt=et("tag:yaml.org,2002:bool",{implicit:!0,implicitFirstChars:["t","f"],resolve:e=>-1!==ut.indexOf(e)||-1===_t.indexOf(e)&&Ze,identify:e=>"[object Boolean]"===Object.prototype.toString.call(e),represent:e=>e?"true":"false"}),Et=["true","True","TRUE","y","Y","yes","Yes","YES","on","On","ON"],ft=["false","False","FALSE","n","N","no","No","NO","off","Off","OFF"],Ot=et("tag:yaml.org,2002:bool",{implicit:!0,implicitFirstChars:["y","Y","n","N","t","T","f","F","o","O"],resolve:e=>-1!==Et.indexOf(e)||-1===ft.indexOf(e)&&Ze,identify:e=>"[object Boolean]"===Object.prototype.toString.call(e),represent:e=>e?"true":"false"}),mt=new RegExp("^(?:0o[0-7]+|0x[0-9a-fA-F]+|[-+]?[0-9]+)$"),Tt=new RegExp("^(?:[-+]?0b[0-1]+|[-+]?0o[0-7]+|[-+]?0x[0-9a-fA-F]+|[-+]?[0-9]+)$");var At=et("tag:yaml.org,2002:int",{implicit:!0,implicitFirstChars:["-","+",..."0123456789"],resolve:function(e,t){if(t){if(!Tt.test(e))return Ze}else if(!mt.test(e))return Ze;const n=function(e){let t=e,n=1;return"-"!==t[0]&&"+"!==t[0]||("-"===t[0]&&(n=-1),t=t.slice(1)),t.startsWith("0b")?n*parseInt(t.slice(2),2):t.startsWith("0o")?n*parseInt(t.slice(2),8):t.startsWith("0x")?n*parseInt(t.slice(2),16):n*parseInt(t,10)}(e);return Number.isFinite(n)?n:Ze},identify:e=>Number.isInteger(e)&&!Object.is(e,-0)&&e.toString(10).indexOf("e")<0,represent:e=>e.toString(10)}),gt=new RegExp("^-?(?:0|[1-9][0-9]*)$"),It=new RegExp("^(?:[-+]?0b[0-1]+|[-+]?0o[0-7]+|[-+]?0x[0-9a-fA-F]+|[-+]?[0-9]+)$");var bt=et("tag:yaml.org,2002:int",{implicit:!0,implicitFirstChars:["-",..."0123456789"],resolve:function(e,t){if(t){if(!It.test(e))return Ze}else if(!gt.test(e))return Ze;const n=function(e){let t=e,n=1;return"-"!==t[0]&&"+"!==t[0]||("-"===t[0]&&(n=-1),t=t.slice(1)),t.startsWith("0b")?n*parseInt(t.slice(2),2):t.startsWith("0o")?n*parseInt(t.slice(2),8):t.startsWith("0x")?n*parseInt(t.slice(2),16):n*parseInt(t,10)}(e);return Number.isFinite(n)?n:Ze},identify:e=>Number.isInteger(e)&&!Object.is(e,-0)&&e.toString(10).indexOf("e")<0,represent:e=>e.toString(10)}),St=new RegExp("^(?:[-+]?0b[0-1_]+|[-+]?0[0-7_]+|[-+]?0x[0-9a-fA-F_]+|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+|[-+]?(?:0|[1-9][0-9_]*))$");var Nt=et("tag:yaml.org,2002:int",{implicit:!0,implicitFirstChars:["-","+",..."0123456789"],resolve:function(e){if(!St.test(e))return Ze;const t=function(e){let t=e.replace(/_/g,""),n=1;if("-"!==t[0]&&"+"!==t[0]||("-"===t[0]&&(n=-1),t=t.slice(1)),t.startsWith("0b"))return n*parseInt(t.slice(2),2);if(t.startsWith("0x"))return n*parseInt(t.slice(2),16);if(t.includes(":")){let e=0;for(const n of t.split(":"))e=60*e+Number(n);return n*e}return"0"!==t&&"0"===t[0]?n*parseInt(t,8):n*parseInt(t,10)}(e);return Number.isFinite(t)?t:Ze},identify:e=>Number.isInteger(e)&&!Object.is(e,-0)&&e.toString(10).indexOf("e")<0,represent:e=>e.toString(10)}),vt=new RegExp("^(?:[-+]?[0-9]+(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|[-+]?\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),Rt=new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");var yt=et("tag:yaml.org,2002:float",{implicit:!0,implicitFirstChars:["-","+",".",..."0123456789"],resolve:function(e){if(!vt.test(e))return Ze;let t=e.toLowerCase();const n="-"===t[0]?-1:1;if("+-".includes(t[0])&&(t=t.slice(1)),".inf"===t)return 1===n?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY;if(".nan"===t)return NaN;const i=n*parseFloat(t);return Number.isFinite(i)||Rt.test(e)?i:Ze},identify:e=>"number"==typeof e&&(!Number.isInteger(e)||Object.is(e,-0)||e.toString(10).indexOf("e")>=0),represent:function(e){if(isNaN(e))return".nan";if(e===Number.POSITIVE_INFINITY)return".inf";if(e===Number.NEGATIVE_INFINITY)return"-.inf";if(Object.is(e,-0))return"-0.0";const t=e.toString(10);return/^[-+]?[0-9]+e/.test(t)?t.replace("e",".e"):t}}),Ct=new RegExp("^-?(?:0|[1-9][0-9]*)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$"),Lt=new RegExp("^(?:[-+]?[0-9]+(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|[-+]?\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");var Dt=et("tag:yaml.org,2002:float",{implicit:!0,implicitFirstChars:["-",..."0123456789"],resolve:function(e,t){if(t){if(!Lt.test(e))return Ze;let t=e.toLowerCase();const n="-"===t[0]?-1:1;if("+-".includes(t[0])&&(t=t.slice(1)),".inf"===t)return 1===n?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY;if(".nan"===t)return NaN;const i=n*parseFloat(t);return Number.isFinite(i)?i:Ze}if(!Ct.test(e))return Ze;const n=Number(e);return Number.isFinite(n)?n:Ze},identify:e=>"number"==typeof e&&(!Number.isInteger(e)||Object.is(e,-0)||e.toString(10).indexOf("e")>=0),represent:function(e){if(isNaN(e))return".nan";if(e===Number.POSITIVE_INFINITY)return".inf";if(e===Number.NEGATIVE_INFINITY)return"-.inf";if(Object.is(e,-0))return"-0.0";const t=e.toString(10);return/^[-+]?[0-9]+e/.test(t)?t.replace("e",".e"):t}}),wt=new RegExp("^(?:[-+]?(?:(?:[0-9][0-9_]*)?\\.[0-9_]*)(?:[eE][-+][0-9]+)?|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),$t=new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");var xt=et("tag:yaml.org,2002:float",{implicit:!0,implicitFirstChars:["-","+",".",..."0123456789"],resolve:function(e){if(!wt.test(e))return Ze;let t=e.toLowerCase().replace(/_/g,"");const n="-"===t[0]?-1:1;if("+-".includes(t[0])&&(t=t.slice(1)),".inf"===t)return 1===n?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY;if(".nan"===t)return NaN;let i=0;if(t.includes(":")){for(const e of t.split(":"))i=60*i+Number(e);i*=n}else i=n*parseFloat(t);return Number.isFinite(i)||$t.test(e)?i:Ze},identify:e=>"number"==typeof e&&(!Number.isInteger(e)||Object.is(e,-0)||e.toString(10).indexOf("e")>=0),represent:function(e){if(isNaN(e))return".nan";if(e===Number.POSITIVE_INFINITY)return".inf";if(e===Number.NEGATIVE_INFINITY)return"-.inf";if(Object.is(e,-0))return"-0.0";const t=e.toString(10);return/^[-+]?[0-9]+e/.test(t)?t.replace("e",".e"):t}}),Ht=et("tag:yaml.org,2002:merge",{implicit:!0,implicitFirstChars:["<"],resolve:(e,t)=>"<<"===e||t&&""===e?"<<":Ze,identify:()=>!1}),Mt=/^[A-Za-z0-9+/]*={0,2}$/;var Bt=et("tag:yaml.org,2002:binary",{resolve:function(e){const t=e.replace(/\s/g,"");if(t.length%4!=0||!Mt.test(t))return Ze;const n=atob(t),i=new Uint8Array(n.length);for(let e=0;e<n.length;e++)i[e]=n.charCodeAt(e);return i},identify:e=>"[object Uint8Array]"===Object.prototype.toString.call(e),represent:function(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}}),Pt=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),Ft=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]))?))?$");function kt(e,t,n,i=0,o=0,r=0,s=0){const a=new Date(Date.UTC(e,t,n,i,o,r,s));return a.setUTCFullYear(e,t,n),a}var Ut=et("tag:yaml.org,2002:timestamp",{implicit:!0,implicitFirstChars:[..."0123456789"],resolve:function(e){let t=Pt.exec(e);if(null===t&&(t=Ft.exec(e)),null===t)return Ze;const n=+t[1],i=+t[2]-1,o=+t[3];if(!t[4]){const e=kt(n,i,o);return e.getUTCFullYear()!==n||e.getUTCMonth()!==i||e.getUTCDate()!==o?Ze:e}const r=+t[4],s=+t[5],a=+t[6];let c=0;if(r>23||s>59||a>59)return Ze;if(t[7]){let e=t[7].slice(0,3);for(;e.length<3;)e+="0";c=+e}const l=kt(n,i,o,r,s,a,c);if(l.getUTCFullYear()!==n||l.getUTCMonth()!==i||l.getUTCDate()!==o)return Ze;if(t[9]){const e=+t[10],n=+(t[11]||0);if(e>23||n>59)return Ze;const i=6e4*(60*e+n);l.setTime(l.getTime()-("-"===t[9]?-i:i))}return l},identify:e=>e instanceof Date,represent:e=>e.toISOString()}),jt=tt("tag:yaml.org,2002:seq",{create:()=>[],addItem:(e,t)=>{e.push(t)},identify:Array.isArray});function Gt(e){if(null===e||"object"!=typeof e||Array.isArray(e))return!1;const t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function Vt(e,t){const n={};for(const i of t)void 0!==e[i]&&(n[i]=e[i]);return n}var Wt=tt("tag:yaml.org,2002:omap",{create:()=>({list:[],seen:new Set}),addItem:(e,t)=>{let n;if(t instanceof Map){if(1!==t.size)return"cannot resolve an ordered map item";n=t.keys().next().value}else{if(!Gt(t))return"cannot resolve an ordered map item";{const e=Object.keys(t);if(1!==e.length)return"cannot resolve an ordered map item";n=e[0]}}return e.seen.has(n)?"duplicate key in ordered map":(e.seen.add(n),e.list.push(t),"")},finalize:e=>e.list,identify:()=>!1}),Kt=tt("tag:yaml.org,2002:pairs",{create:()=>[],addItem:(e,t)=>{if(t instanceof Map)return 1!==t.size?"cannot resolve a pairs item":(e.push(t.entries().next().value),"");if("[object Object]"!==Object.prototype.toString.call(t))return"cannot resolve a pairs item";const n=t,i=Object.keys(n);return 1!==i.length?"cannot resolve a pairs item":(e.push([i[0],n[i[0]]]),"")},identify:()=>!1}),Xt=nt("tag:yaml.org,2002:map",{create:()=>({}),identify:Gt,represent:e=>{const t=new Map;for(const n of Object.keys(e))t.set(n,e[n]);return t},addPair:(e,t,n)=>{if(null!==t&&"object"==typeof t)return"object-based map does not support complex keys";const i=String(t);return"__proto__"===i?Object.defineProperty(e,i,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[i]=n,""},has:(e,t)=>(null===t||"object"!=typeof t)&&Object.prototype.hasOwnProperty.call(e,String(t)),keys:e=>Object.keys(e),get:(e,t)=>{const n=String(t);return Object.prototype.hasOwnProperty.call(e,n)?e[n]:null}}),Yt=nt("tag:yaml.org,2002:set",{create:()=>new Set,identify:e=>e instanceof Set,represent:e=>{const t=new Map;for(const n of e)t.set(n,null);return t},addPair:(e,t,n)=>null!==n?"cannot resolve a set item":(e.add(t),""),has:(e,t)=>e.has(t),keys:e=>e.keys(),get:()=>null});var qt=class e{tags;implicitScalarTags;implicitScalarByFirstChar;implicitScalarAnyFirstChar;defaultScalarTag;defaultSequenceTag;defaultMappingTag;exact;prefix;constructor(e){const t=function(e){const t=[];for(const n of e){let e=t.length;for(let i=0;i<t.length;i++){const o=t[i];if(o.nodeKind===n.nodeKind&&o.tagName===n.tagName&&o.matchByTagPrefix===n.matchByTagPrefix){e=i;break}}t[e]=n}return t}(e),n=[],i={scalar:Object.create(null),sequence:Object.create(null),mapping:Object.create(null)},o={scalar:[],sequence:[],mapping:[]};for(const e of t){if("scalar"===e.nodeKind&&e.implicit){if(e.matchByTagPrefix)throw new Error("Implicit scalar tags cannot match by tag prefix");n.push(e)}switch(e.nodeKind){case"scalar":e.matchByTagPrefix?o.scalar.push(e):i.scalar[e.tagName]=e;break;case"sequence":e.matchByTagPrefix?o.sequence.push(e):i.sequence[e.tagName]=e;break;case"mapping":e.matchByTagPrefix?o.mapping.push(e):i.mapping[e.tagName]=e}}const r=n.filter((e=>null===e.implicitFirstChars)),s=new Set;for(const e of n)if(null!==e.implicitFirstChars)for(const t of e.implicitFirstChars)s.add(t);const a=new Map;for(const e of s)a.set(e,n.filter((t=>null===t.implicitFirstChars||-1!==t.implicitFirstChars.indexOf(e))));const c=i.scalar["tag:yaml.org,2002:str"];if(!c)throw new Error("schema does not define the default scalar tag (tag:yaml.org,2002:str)");this.tags=t,this.implicitScalarTags=n,this.implicitScalarByFirstChar=a,this.implicitScalarAnyFirstChar=r,this.defaultScalarTag=c,this.defaultSequenceTag=i.sequence["tag:yaml.org,2002:seq"],this.defaultMappingTag=i.mapping["tag:yaml.org,2002:map"],this.exact=i,this.prefix=o}lookupScalarTag(e){const t=this.exact.scalar[e];if(t)return t;for(const t of this.prefix.scalar)if(e.startsWith(t.tagName))return t}lookupSequenceTag(e){const t=this.exact.sequence[e];if(t)return t;for(const t of this.prefix.sequence)if(e.startsWith(t.tagName))return t}lookupMappingTag(e){const t=this.exact.mapping[e];if(t)return t;for(const t of this.prefix.mapping)if(e.startsWith(t.tagName))return t}resolveImplicitScalarTag(e){const t=this.implicitScalarByFirstChar.get(e.charAt(0))??this.implicitScalarAnyFirstChar;for(const n of t){const t=n.resolve(e,!1,n.tagName);if(t!==Ze)return{value:t,tag:n}}const n=this.defaultScalarTag;return{value:n.resolve(e,!1,n.tagName),tag:n}}withTags(...t){let n=[];for(const e of t)n=n.concat(e);return new e([...this.tags,...n])}},zt=new qt([it,jt,Xt]);new qt([...zt.tags,st,pt,bt,Dt]);var Qt=new qt([...zt.tags,rt,ht,At,yt]);function Jt(e){if(Array.isArray(e)){const t=Array.prototype.slice.call(e);for(let e=0;e<t.length;e++){if(Array.isArray(t[e]))return null;"object"==typeof t[e]&&"[object Object]"===Object.prototype.toString.call(t[e])&&(t[e]="[object Object]")}return String(t)}return"object"==typeof e&&"[object Object]"===Object.prototype.toString.call(e)?"[object Object]":String(e)}new qt([...zt.tags,ct,Ot,Nt,xt,Ut,Ht,Bt,Wt,Kt,Yt]).withTags({...Nt,resolve:(e,t,n)=>{const i=Nt.resolve(e,t,n);return i===Ze?At.resolve(e,t,n):i}},{...xt,resolve:(e,t,n)=>{const i=xt.resolve(e,t,n);return i===Ze?yt.resolve(e,t,n):i}}),nt("tag:yaml.org,2002:map",{create:()=>new Map,addPair:(e,t,n)=>(e.set(t,n),""),has:(e,t)=>e.has(t),keys:e=>e.keys(),get:(e,t)=>e.get(t),identify:e=>e instanceof Map||Gt(e),represent:e=>{if(e instanceof Map)return e;const t=new Map,n=e;for(const e of Object.keys(n))t.set(e,n[e]);return t}}),nt("tag:yaml.org,2002:map",{create:()=>({}),identify:Gt,represent:e=>{const t=new Map;for(const n of Object.keys(e))t.set(n,e[n]);return t},addPair:(e,t,n)=>{const i=Jt(t);return null===i?"nested arrays are not supported inside keys":("__proto__"===i?Object.defineProperty(e,i,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[i]=n,"")},has:(e,t)=>{const n=Jt(t);return null!==n&&Object.prototype.hasOwnProperty.call(e,n)},keys:e=>Object.keys(e),get:(e,t)=>{const n=String(t);return Object.prototype.hasOwnProperty.call(e,n)?e[n]:null}});var Zt={maxLength:79,indent:1,linesBefore:3,linesAfter:2};function en(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 tn(e,t){return" ".repeat(Math.max(t-e.length,0))+e}function nn(e,t){let n="";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}`),`${e.reason} ${n}`):e.reason}var on=class e extends Error{reason;mark;constructor(e,t){super(),this.name="YAMLException",this.reason=e,this.mark=t,this.message=nn(this,!1),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}toString(e){return`${this.name}: ${nn(this,e)}`}static throwAt(t,n,i,o=""){let r=0,s=0;for(let e=0;e<n;e++){const n=t.charCodeAt(e);10===n?(r++,s=e+1):13===n&&(r++,10===t.charCodeAt(e+1)&&e++,s=e+1)}const a={name:o,buffer:t,position:n,line:r,column:n-s};throw a.snippet=function(e,t){if(!e.buffer)return null;const n={...Zt,...t},i=/\r?\n|\r|\0/g,o=[0],r=[];let s,a=-1;for(;s=i.exec(e.buffer);)r.push(s.index),o.push(s.index+s[0].length),e.position<=s.index&&a<0&&(a=o.length-2);a<0&&(a=o.length-1);let c="";const l=Math.min(e.line+n.linesAfter,r.length).toString().length,d=n.maxLength-(n.indent+l+3);for(let t=1;t<=n.linesBefore&&!(a-t<0);t++){const i=en(e.buffer,o[a-t],r[a-t],e.position-(o[a]-o[a-t]),d);c=`${" ".repeat(n.indent)}${tn((e.line-t+1).toString(),l)} | ${i.str}\n${c}`}const h=en(e.buffer,o[a],r[a],e.position,d);c+=`${" ".repeat(n.indent)}${tn((e.line+1).toString(),l)} | ${h.str}\n`,c+=`${"-".repeat(n.indent+l+3+h.pos)}^\n`;for(let t=1;t<=n.linesAfter&&!(a+t>=r.length);t++){const i=en(e.buffer,o[a+t],r[a+t],e.position-(o[a]-o[a+t]),d);c+=`${" ".repeat(n.indent)}${tn((e.line+t+1).toString(),l)} | ${i.str}\n`}return c.replace(/\n$/,"")}(a),new e(i,a)}},rn={DOCUMENT:1,SEQUENCE:2,MAPPING:3,SCALAR:4,ALIAS:5,POP:6},sn={PLAIN:1,SINGLE_QUOTED:2,DOUBLE_QUOTED:3,LITERAL_BLOCK:4,FOLDED_BLOCK:5},an={BLOCK:1,FLOW:2},cn={CLIP:1,STRIP:2,KEEP:3},ln=-1;function dn(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""}}var hn=new Array(256),un=new Array(256);for(let e=0;e<256;e++)hn[e]=dn(e)?1:0,un[e]=dn(e);function _n(e){return e<=65535?String.fromCharCode(e):String.fromCharCode(55296+(e-65536>>10),56320+(e-65536&1023))}function pn(e){return e>=48&&e<=57?e-48:(32|e)-97+10}function En(e){return 120===e?2:117===e?4:8}function fn(e,t,n){let i=0;for(;t<n;){const n=e.charCodeAt(t);if(10===n)i++,t++;else if(13===n)i++,t++,10===e.charCodeAt(t)&&t++;else{if(32!==n&&9!==n)break;t++}}return{position:t,breaks:i}}function On(e){return 1===e?" ":"\n".repeat(e-1)}function mn(e,t,n,i,o,r){const s=i<0?0:i,a=e.slice(t,n).replace(/\r\n?/g,"\n"),c=""===a?[]:(a.endsWith("\n")?a.slice(0,-1):a).split("\n");let l="",d=!1,h=0,u=!1;for(const e of c){let t=0;for(;t<s&&32===e.charCodeAt(t);)t++;if(i<0||t>=e.length){h++;continue}const n=e.slice(s),o=n.charCodeAt(0);r?32===o||9===o?(u=!0,l+="\n".repeat(d?1+h:h)):u?(u=!1,l+="\n".repeat(h+1)):0===h?d&&(l+=" "):l+="\n".repeat(h):l+="\n".repeat(d?1+h:h),l+=n,d=!0,h=0}return o===cn.KEEP?l+="\n".repeat(d?1+h:h):o!==cn.STRIP&&d&&(l+="\n"),l}function Tn(e,t){if(t.valueStart===ln)return"";const{valueStart:n,valueEnd:i}=t;if(t.fast)return e.slice(n,i);switch(t.style){case sn.SINGLE_QUOTED:return function(e,t,n){let i="",o=t,r=t,s=t;for(;o<n;){const t=e.charCodeAt(o);if(39===t)i+=e.slice(r,o)+"'",o+=2,r=s=o;else if(10===t||13===t){i+=e.slice(r,s);const t=fn(e,o,n);i+=On(t.breaks),o=r=s=t.position}else o++,32!==t&&9!==t&&(s=o)}return i+e.slice(r,n)}(e,n,i);case sn.DOUBLE_QUOTED:return function(e,t,n){let i="",o=t,r=t,s=t;for(;o<n;){const t=e.charCodeAt(o);if(92===t){i+=e.slice(r,o),o++;const t=e.charCodeAt(o);if(10===t||13===t)o=fn(e,o,n).position;else if(t<256&&hn[t])i+=un[t],o++;else{let n=En(t),r=0;for(;n>0;n--)o++,r=(r<<4)+pn(e.charCodeAt(o));i+=_n(r),o++}r=s=o}else if(10===t||13===t){i+=e.slice(r,s);const t=fn(e,o,n);i+=On(t.breaks),o=r=s=t.position}else o++,32!==t&&9!==t&&(s=o)}return i+e.slice(r,n)}(e,n,i);case sn.LITERAL_BLOCK:return mn(e,n,i,t.indent,t.chomping,!1);case sn.FOLDED_BLOCK:return mn(e,n,i,t.indent,t.chomping,!0);default:return function(e,t,n){let i="",o=t,r=t,s=t;for(;o<n;){const t=e.charCodeAt(o);if(10===t||13===t){i+=e.slice(r,s);const t=fn(e,o,n);i+=On(t.breaks),o=r=s=t.position}else o++,32!==t&&9!==t&&(s=o)}return i+e.slice(r,s)}(e,n,i)}}var An=Object.assign(Object.create(null),{"!":"!","!!":"tag:yaml.org,2002:"});function gn(e,t){if(e.startsWith("!<")&&e.endsWith(">"))return decodeURIComponent(e.slice(2,-1));const n=e.indexOf("!",1),i=-1===n?"!":e.slice(0,n+1),o=t?.[i]??An[i]??i;return decodeURIComponent(o)+decodeURIComponent(e.slice(i.length))}var In=-1,bn="tag:yaml.org,2002:merge",Sn={filename:"",schema:Qt,json:!1,maxTotalMergeKeys:1e4,maxAliases:-1};function Nn(e){return"tagStart"in e&&e.tagStart!==In?e.tagStart:"anchorStart"in e&&e.anchorStart!==In?e.anchorStart:"valueStart"in e&&e.valueStart!==In?e.valueStart:"start"in e?e.start:0}function vn(e,t){on.throwAt(e.source,e.position,t,e.filename)}function Rn(e,t,n,i){try{return n.finalize(i)}catch(n){if(n instanceof on)throw n;on.throwAt(e.source,t,n instanceof Error?n.message:String(n),e.filename)}}function yn(e,t){const n=Tn(e.source,t),i=t.tagStart===In?"":e.source.slice(t.tagStart,t.tagEnd),o=e.schema.defaultScalarTag;if(""!==i){if("!"===i)return{value:n,tag:o};const t=gn(i,e.tagHandlers),r=e.schema.lookupScalarTag(t);if(r){const i=r.resolve(n,!0,t);return i===Ze&&vn(e,`cannot resolve a node with !<${t}> explicit tag`),{value:i,tag:r}}const s=e.schema.lookupMappingTag(t)??e.schema.lookupSequenceTag(t);if(s){""!==n&&vn(e,`cannot resolve a node with !<${t}> explicit tag`);const i=s.create(t);return{value:s.carrierIsResult?i:Rn(e,e.position,s,i),tag:s}}vn(e,`unknown scalar tag !<${t}>`)}return t.style===sn.PLAIN?e.schema.resolveImplicitScalarTag(n):{value:o.resolve(n,!1,o.tagName),tag:o}}function Cn(e,t,n){const i=t.tagStart===In?"":e.source.slice(t.tagStart,t.tagEnd);return""===i||"!"===i?n:gn(i,e.tagHandlers)}function Ln(e){return"mapping"===e.nodeKind}function Dn(e){e.totalMergeKeys++,-1!==e.maxTotalMergeKeys&&e.totalMergeKeys>e.maxTotalMergeKeys&&vn(e,`merge keys exceeded maxTotalMergeKeys (${e.maxTotalMergeKeys})`)}function wn(e,t,n,i){Dn(e);for(const o of i.keys(n)){if(Dn(e),t.tag.has(t.value,o))continue;const r=t.tag.addPair(t.value,o,i.get(n,o));r&&vn(e,r),t.overridable??=new Set,t.overridable.add(o)}}function $n(e,t,n,i,o){if(e.position=t.keyPosition,t.keyIsMerge)return void function(e,t,n,i){if(e.position=t.keyPosition,Ln(i))wn(e,t,n,i);else if("sequence"===i.nodeKind&&Array.isArray(n)){n.length>100&&vn(e,"abnormal merge sequence size");for(const i of n){const n=e.nodeTags.get(i);n||vn(e,"cannot merge mappings; the provided source object is unacceptable"),wn(e,t,i,n)}}else vn(e,"cannot merge mappings; the provided source object is unacceptable")}(e,t,i,o);e.json||!t.tag.has(t.value,n)||t.overridable?.has(n)||vn(e,"duplicated mapping key");const r=t.tag.addPair(t.value,n,i);r&&vn(e,r),t.overridable?.delete(n)}function xn(e,t,n){const i=e.frames[e.frames.length-1];if("document"===i.kind)i.value=t,i.hasValue=!0;else if("sequence"===i.kind){Ln(n)&&e.nodeTags.set(t,n);const o=i.tag.addItem(i.value,t,i.index++);o&&vn(e,o)}else if(i.hasKey){const o=i.key;i.key=void 0,i.hasKey=!1,$n(e,i,o,t,n)}else i.key=t,i.keyPosition=e.position,i.hasKey=!0,i.keyIsMerge=n.tagName===bn}function Hn(e,t,n,i,o){if(t.anchorStart!==In){const r={value:n,tag:i,isValueFinal:o};return e.anchors.set(e.source.slice(t.anchorStart,t.anchorEnd),r),r}return null}var Mn=-1,Bn=Object.prototype.hasOwnProperty,Pn=1,Fn=2,kn=3,Un=4,jn=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,Gn=/[,\[\]{}]/,Vn=/^(?:!|!!|![0-9A-Za-z-]+!)$/,Wn=String.raw`(?:%[0-9A-Fa-f]{2}|[0-9A-Za-z\-#;/?:@&=+$,_.!~*'()\[\]])`,Kn=String.raw`(?:%[0-9A-Fa-f]{2}|[0-9A-Za-z\-#;/?:@&=+$.~*'()_])`,Xn=new RegExp(`^(?:${Wn})*$`),Yn=new RegExp(`^(?:${Kn})+$`),qn=new RegExp(`^(?:!(?:${Wn})*|${Kn}(?:${Wn})*)$`),zn={filename:"",maxDepth:100};function Qn(e,t,n,i,o,r,s){e.events.push({type:rn.SEQUENCE,start:t,anchorStart:n,anchorEnd:i,tagStart:o,tagEnd:r,style:s})}function Jn(e,t,n,i,o,r,s){e.events.push({type:rn.MAPPING,start:t,anchorStart:n,anchorEnd:i,tagStart:o,tagEnd:r,style:s})}function Zn(e,t){e.events.splice(t.eventsLength,0,{type:rn.MAPPING,start:t.position,anchorStart:Mn,anchorEnd:Mn,tagStart:Mn,tagEnd:Mn,style:an.FLOW})}function ei(e,t,n,i,o,r,s,a,c=cn.CLIP,l=-1,d=!1){e.events.push({type:rn.SCALAR,valueStart:t,valueEnd:n,anchorStart:i,anchorEnd:o,tagStart:r,tagEnd:s,style:a,chomping:c,indent:l,fast:d})}function ti(e){e.events.push({type:rn.POP})}function ni(e){ei(e,Mn,Mn,Mn,Mn,Mn,Mn,sn.PLAIN)}function ii(){return{anchorStart:Mn,anchorEnd:Mn,tagStart:Mn,tagEnd:Mn}}function oi(e){return{position:e.position,line:e.line,lineStart:e.lineStart,lineIndent:e.lineIndent,firstTabInLine:e.firstTabInLine,eventsLength:e.events.length}}function ri(e,t){e.position=t.position,e.line=t.line,e.lineStart=t.lineStart,e.lineIndent=t.lineIndent,e.firstTabInLine=t.firstTabInLine,e.events.length=t.eventsLength}function si(e,t){on.throwAt(e.input.slice(0,e.length),e.position,t,e.filename)}function ai(e){return 10===e||13===e}function ci(e){return 9===e||32===e}function li(e){return ci(e)||ai(e)}function di(e){return 0===e||li(e)}function hi(e){return 44===e||91===e||93===e||123===e||125===e}function ui(e){return e>=48&&e<=57?e-48:-1}function _i(e){if(e>=48&&e<=57)return e-48;const t=32|e;return t>=97&&t<=102?t-97+10:-1}function pi(e){return 120===e?2:117===e?4:85===e?8:0}function Ei(e){return 48===e||97===e||98===e||116===e||9===e||110===e||118===e||102===e||114===e||101===e||32===e||34===e||47===e||92===e||78===e||95===e||76===e||80===e}function fi(e){10===e.input.charCodeAt(e.position)?e.position++:(e.position++,10===e.input.charCodeAt(e.position)&&e.position++),e.line++,e.lineStart=e.position,e.lineIndent=0,e.firstTabInLine=-1}function Oi(e,t){let n=0,i=e.input.charCodeAt(e.position),o=e.position===e.lineStart||li(e.input.charCodeAt(e.position-1));for(;0!==i;){for(;ci(i);)o=!0,9===i&&-1===e.firstTabInLine&&(e.firstTabInLine=e.position),i=e.input.charCodeAt(++e.position);if(t&&o&&35===i)do{i=e.input.charCodeAt(++e.position)}while(!ai(i)&&0!==i);if(!ai(i))break;for(fi(e),n++,o=!0,i=e.input.charCodeAt(e.position);32===i;)e.lineIndent++,i=e.input.charCodeAt(++e.position)}return n}function mi(e,t=e.position){const n=e.input.charCodeAt(t);if((45===n||46===n)&&n===e.input.charCodeAt(t+1)&&n===e.input.charCodeAt(t+2)){const n=e.input.charCodeAt(t+3);return 0===n||li(n)}return!1}function Ti(e){e.position===e.lineStart&&65279===e.input.charCodeAt(e.position)&&(e.position++,e.lineStart=e.position)}function Ai(e){if(e.position!==e.lineStart)return!1;if(mi(e))return!0;if(65279!==e.input.charCodeAt(e.position))return!1;const t=oi(e);Ti(e),Oi(e,!0);const n=e.input.charCodeAt(e.position),i=e.position===e.lineStart&&(37===n||45===n&&mi(e));return ri(e,t),i}function gi(e){let t=e.input.charCodeAt(e.position);for(;0!==t&&!ai(t);)t=e.input.charCodeAt(++e.position)}function Ii(e,t,n){jn.test(e.input.slice(t,n))&&si(e,"the stream contains non-printable characters")}function bi(e,t,n){if(33!==e.input.charCodeAt(e.position))return!1;t.tagStart!==Mn&&si(e,"duplication of a tag property");const i=e.position;let o=!1,r=!1,s="!",a=e.input.charCodeAt(++e.position);60===a?(o=!0,a=e.input.charCodeAt(++e.position)):33===a&&(r=!0,s="!!",a=e.input.charCodeAt(++e.position));let c,l=e.position;if(o){for(;0!==a&&62!==a;)a=e.input.charCodeAt(++e.position);62!==a&&si(e,"unexpected end of the stream within a verbatim tag"),c=e.input.slice(l,e.position),e.position++}else{for(;!(0===a||li(a)||n&&hi(a));)33===a&&(r?si(e,"tag suffix cannot contain exclamation marks"):(s=e.input.slice(l-1,e.position+1),Vn.test(s)||si(e,"named tag handle cannot contain such characters"),r=!0,l=e.position+1)),a=e.input.charCodeAt(++e.position);c=e.input.slice(l,e.position),Gn.test(c)&&si(e,"tag suffix cannot contain flow indicator characters")}return c&&!(o?Xn.test(c):Yn.test(c))&&si(e,`tag name cannot contain such characters: ${c}`),o||"!"===s||"!!"===s||Bn.call(e.tagHandlers,s)||si(e,`undeclared tag handle "${s}"`),t.tagStart=i,t.tagEnd=e.position,!0}function Si(e,t){if(38!==e.input.charCodeAt(e.position))return!1;t.anchorStart!==Mn&&si(e,"duplication of an anchor property"),e.position++;const n=e.position;for(;0!==e.input.charCodeAt(e.position)&&!li(e.input.charCodeAt(e.position))&&!hi(e.input.charCodeAt(e.position));)e.position++;return e.position===n&&si(e,"name of an anchor node must contain at least one character"),t.anchorStart=n,t.anchorEnd=e.position,!0}function Ni(e,t){if(42!==e.input.charCodeAt(e.position))return!1;t.anchorStart===Mn&&t.tagStart===Mn||si(e,"alias node should not have any properties"),e.position++;const n=e.position;for(;0!==e.input.charCodeAt(e.position)&&!li(e.input.charCodeAt(e.position))&&!hi(e.input.charCodeAt(e.position));)e.position++;return e.position===n&&si(e,"name of an alias node must contain at least one character"),function(e,t,n){e.events.push({type:rn.ALIAS,anchorStart:t,anchorEnd:n})}(e,n,e.position),!0}function vi(e,t){Oi(e,!1),e.lineIndent<t&&si(e,"deficient indentation")}function Ri(e,t,n,i){if(!function(e,t){const n=e.input.charCodeAt(e.position),i=t===Pn;if(0===n||li(n)||35===n||38===n||42===n||33===n||124===n||62===n||39===n||34===n||37===n||64===n||96===n||i&&hi(n))return!1;if(63===n||45===n){const t=e.input.charCodeAt(e.position+1);if(di(t)||i&&hi(t))return!1}return!0}(e,n))return!1;const o=e.position;let r=e.position,s=e.input.charCodeAt(e.position);const a=n===Pn;let c=!1;for(;0!==s&&!Ai(e);){if(58===s){const t=e.input.charCodeAt(e.position+1);if(di(t)||a&&hi(t))break}else if(35===s){if(li(e.input.charCodeAt(e.position-1)))break}else{if(a&&hi(s))break;if(ai(s)){const n=e.position,i=e.line,o=e.lineStart,r=e.lineIndent;if(Oi(e,!1),e.lineIndent>=t){c=!0,s=e.input.charCodeAt(e.position);continue}e.position=n,e.line=i,e.lineStart=o,e.lineIndent=r;break}}ci(s)||(r=e.position+1),s=e.input.charCodeAt(++e.position)}return r!==o&&(Ii(e,o,r),ei(e,o,r,i.anchorStart,i.anchorEnd,i.tagStart,i.tagEnd,sn.PLAIN,cn.CLIP,-1,!c),!0)}function yi(e,t){const n=e.line;Oi(e,!0),(e.line>n&&e.lineIndent<t||-1!==e.firstTabInLine&&e.lineIndent<t)&&si(e,"deficient indentation")}function Ci(e,t,n){if(-1!==e.firstTabInLine||45!==e.input.charCodeAt(e.position)||!di(e.input.charCodeAt(e.position+1)))return!1;for(Qn(e,e.position,n.anchorStart,n.anchorEnd,n.tagStart,n.tagEnd,an.BLOCK);45===e.input.charCodeAt(e.position)&&di(e.input.charCodeAt(e.position+1));){-1!==e.firstTabInLine&&(e.position=e.firstTabInLine,si(e,"tab characters must not be used in indentation"));const n=e.line;e.position++;const i=Oi(e,!0)>0;if(-1!==e.firstTabInLine&&45===e.input.charCodeAt(e.position)&&di(e.input.charCodeAt(e.position+1))&&si(e,"bad indentation of a sequence entry"),i&&e.lineIndent<=t?ni(e):Di(e,t,kn,!1,!0),Oi(e,!0),e.lineIndent<t||e.position>=e.length)break;e.lineIndent>t&&si(e,"bad indentation of a sequence entry"),e.line===n&&45===e.input.charCodeAt(e.position)&&di(e.input.charCodeAt(e.position+1))&&si(e,"bad indentation of a sequence entry")}return ti(e),!0}function Li(e,t,n,i){let o=!1,r=!1,s=!1,a=!1;if(-1!==e.firstTabInLine)return!1;let c=e.input.charCodeAt(e.position);for(;0!==c;){o||-1===e.firstTabInLine||(e.position=e.firstTabInLine,si(e,"tab characters must not be used in indentation"));const l=e.input.charCodeAt(e.position+1),d=e.line;if(63!==c&&58!==c||!di(l)){o&&(ni(e),o=!1);const t=oi(e);if(!Di(e,n,Fn,!1,!0))break;if(e.line===d){for(c=e.input.charCodeAt(e.position);ci(c);)c=e.input.charCodeAt(++e.position);if(58===c){if(c=e.input.charCodeAt(++e.position),di(c)||si(e,"a whitespace character is expected after the key-value separator within a block mapping"),!s){for(ri(e,t),Jn(e,t.position,i.anchorStart,i.anchorEnd,i.tagStart,i.tagEnd,an.BLOCK),s=!0,Di(e,n,Fn,!1,!0),c=e.input.charCodeAt(e.position);ci(c);)c=e.input.charCodeAt(++e.position);e.position++}r=!0,o=!1,a=!1}else{if(!r)return i.anchorStart===Mn&&i.tagStart===Mn||(ri(e,t),!1);si(e,"expected ':' after a mapping key")}}else{if(!r)return i.anchorStart===Mn&&i.tagStart===Mn||(ri(e,t),!1);si(e,"can not read a block mapping entry; a multiline key may not be an implicit key")}}else s||(Jn(e,e.position,i.anchorStart,i.anchorEnd,i.tagStart,i.tagEnd,an.BLOCK),s=!0),63===c?(o&&ni(e),r=!0,o=!0):(o||(ni(e),r=!0),o=!1),e.position+=1,a=!0;if(Di(e,t,Un,!0,a)&&(a=!1),o||a&&(ni(e),a=!1),Oi(e,!0),c=e.input.charCodeAt(e.position),(e.line===d||e.lineIndent>t)&&0!==c)si(e,"bad indentation of a mapping entry");else if(e.lineIndent<t)break}return!!r&&(o&&ni(e),s&&ti(e),!0)}function Di(e,t,n,i,o,r=!0){e.depth>=e.maxDepth&&si(e,`nesting exceeded maxDepth (${e.maxDepth})`),e.depth++;let s=1,a=!1,c=!1,l=null;const d=ii();let h=n===Un||n===kn,u=h;const _=h;if(i&&Oi(e,!0)&&(a=!0,s=e.lineIndent>t?1:e.lineIndent===t?0:-1),1===s)for(;;){const i=e.input.charCodeAt(e.position),o=oi(e);if(a&&1!==s&&(33===i||38===i))break;if(a&&_&&(d.tagStart!==Mn||d.anchorStart!==Mn)&&(33===i||38===i)){const n=oi(e),i=t+1;if(Li(e,e.position-e.lineStart,i,d)&&e.events[n.eventsLength]?.type===rn.MAPPING)return e.depth--,!0;ri(e,n)}if(a&&(33===i&&d.tagStart!==Mn||38===i&&d.anchorStart!==Mn))break;if(!bi(e,d,n===Pn)&&!Si(e,d))break;null===l&&(l=o),Oi(e,!0)?(a=!0,u=_,s=e.lineIndent>t?1:e.lineIndent===t?0:-1):u=!1}if(u&&(u=a||o),1===s||n===Un){const i=n===Pn||n===Fn?t:t+1,o=e.position-e.lineStart;if(1===s)if(u&&(Ci(e,o,d)||Li(e,o,i,d))||function(e,t,n){const i=e.input.charCodeAt(e.position),o=123===i,r=e.position;let s=!0;if(91!==i&&123!==i)return!1;const a=o?125:93;for(o?Jn(e,r,n.anchorStart,n.anchorEnd,n.tagStart,n.tagEnd,an.FLOW):Qn(e,r,n.anchorStart,n.anchorEnd,n.tagStart,n.tagEnd,an.FLOW),e.position++;0!==e.input.charCodeAt(e.position);){yi(e,t);let n=e.input.charCodeAt(e.position);if(n===a)return e.position++,ti(e),!0;s?44===n&&si(e,"expected the node content, but found ','"):si(e,"missed comma between flow collection entries");let i=!1,r=!1;63===n&&li(e.input.charCodeAt(e.position+1))&&(i=r=!0,e.position+=1,yi(e,t));const c=e.line,l=oi(e),d=Di(e,t,Pn,!1,!0);yi(e,t),n=e.input.charCodeAt(e.position),(o||r||e.line===c)&&58===n?(i=!0,e.position++,yi(e,t),o||Zn(e,l),d||ni(e),Di(e,t,Pn,!1,!0)||ni(e),yi(e,t),o||ti(e)):o&&i?(d||ni(e),ni(e)):o?ni(e):i&&(Zn(e,l),d||ni(e),ni(e),ti(e)),n=e.input.charCodeAt(e.position),44===n?(s=!0,e.position++):s=!1}si(e,"unexpected end of the stream within a flow collection")}(e,i,d))c=!0;else{const t=e.input.charCodeAt(e.position);if(null!==l&&r&&_&&!u&&124!==t&&62!==t){const t=oi(e),n=l.position-l.lineStart;ri(e,l),Li(e,n,i,ii())&&e.events[t.eventsLength]?.type===rn.MAPPING?c=!0:ri(e,t)}!c&&(h&&function(e,t,n){const i=e.input.charCodeAt(e.position);let o=cn.CLIP,r=-1,s=!1;if(124!==i&&62!==i)return!1;const a=124===i?sn.LITERAL_BLOCK:sn.FOLDED_BLOCK;for(e.position++;0!==e.input.charCodeAt(e.position);){const n=e.input.charCodeAt(e.position),i=ui(n);if(43===n||45===n)o!==cn.CLIP&&si(e,"repeat of a chomping mode identifier"),o=43===n?cn.KEEP:cn.STRIP,e.position++;else{if(!(i>=0))break;0===i&&si(e,"bad explicit indentation width of a block scalar; it cannot be less than one"),s&&si(e,"repeat of an indentation width identifier"),r=t+i-1,s=!0,e.position++}}let c=!1;for(;ci(e.input.charCodeAt(e.position));)c=!0,e.position++;c&&35===e.input.charCodeAt(e.position)&&gi(e),ai(e.input.charCodeAt(e.position))?fi(e):0!==e.input.charCodeAt(e.position)&&si(e,"a line break is expected");let l=s?r:-1,d=0;const h=e.position;let u=e.position;for(;0!==e.input.charCodeAt(e.position);){const n=e.position;let i=0;for(;32===e.input.charCodeAt(n+i);)i++;const o=e.input.charCodeAt(n+i);if(0===o){l>=0?i>l&&(u=n+i):i>0&&(u=n+i);break}if(Ai(e))break;if(!s&&-1===l&&ai(o)&&(d=Math.max(d,i)),s||-1!==l||ai(o)||(9===o&&i<t&&(e.position=n+i,si(e,"tab characters must not be used in indentation")),i<d&&(e.position=n+i,si(e,"bad indentation of a mapping entry"))),-1===l&&0!==o&&!ai(o)&&i<t){e.lineIndent=i,e.position=n+i;break}s||0===o||ai(o)||-1!==l||(l=i);const r=-1===l?t+1:l;if(0!==o&&!ai(o)&&i<r){e.lineIndent=i,e.position=n+i;break}gi(e),u=e.position,ai(e.input.charCodeAt(e.position))&&(fi(e),u=e.position)}return Ii(e,h,u),ei(e,h,u,n.anchorStart,n.anchorEnd,n.tagStart,n.tagEnd,a,o,l),!0}(e,i,d)||function(e,t,n){if(39!==e.input.charCodeAt(e.position))return!1;e.position++;const i=e.position;let o=!0;for(;0!==e.input.charCodeAt(e.position);){const r=e.input.charCodeAt(e.position);if(39===r){if(39===e.input.charCodeAt(e.position+1)){o=!1,e.position+=2;continue}const t=e.position;return e.position++,ei(e,i,t,n.anchorStart,n.anchorEnd,n.tagStart,n.tagEnd,sn.SINGLE_QUOTED,cn.CLIP,-1,o),!0}ai(r)?(o=!1,vi(e,t)):e.position===e.lineStart&&mi(e)?si(e,"unexpected end of the document within a single quoted scalar"):9!==r&&r<32?si(e,"expected valid JSON character"):e.position++}si(e,"unexpected end of the stream within a single quoted scalar")}(e,i,d)||function(e,t,n){if(34!==e.input.charCodeAt(e.position))return!1;e.position++;const i=e.position;let o=!0;for(;0!==e.input.charCodeAt(e.position);){const r=e.input.charCodeAt(e.position);if(34===r){const t=e.position;return e.position++,ei(e,i,t,n.anchorStart,n.anchorEnd,n.tagStart,n.tagEnd,sn.DOUBLE_QUOTED,cn.CLIP,-1,o),!0}if(92===r){o=!1;const n=e.input.charCodeAt(++e.position);if(ai(n))vi(e,t);else if(Ei(n))e.position++;else{let t=pi(n);for(0===t&&si(e,"unknown escape sequence");t-- >0;)e.position++,_i(e.input.charCodeAt(e.position))<0&&si(e,"expected hexadecimal character");e.position++}}else ai(r)?(o=!1,vi(e,t)):e.position===e.lineStart&&mi(e)?si(e,"unexpected end of the document within a double quoted scalar"):9!==r&&r<32?si(e,"expected valid JSON character"):e.position++}si(e,"unexpected end of the stream within a double quoted scalar")}(e,i,d)||Ni(e,d)||Ri(e,i,n,d))&&(c=!0)}else 0===s&&(c=u&&Ci(e,o,d))}return h=h&&!c,c||d.anchorStart===Mn&&d.tagStart===Mn&&!h||(ei(e,Mn,Mn,d.anchorStart,d.anchorEnd,d.tagStart,d.tagEnd,sn.PLAIN),c=!0),e.depth--,c||d.anchorStart!==Mn||d.tagStart!==Mn}function wi(e){if(e.lineIndent>0||37!==e.input.charCodeAt(e.position))return!1;e.position++;const t=e.position;for(;0!==e.input.charCodeAt(e.position)&&!li(e.input.charCodeAt(e.position));)e.position++;const n=e.input.slice(t,e.position),i=[];for(0===n.length&&si(e,"directive name must not be less than one character in length");0!==e.input.charCodeAt(e.position)&&!ai(e.input.charCodeAt(e.position));){for(;ci(e.input.charCodeAt(e.position));)e.position++;if(35===e.input.charCodeAt(e.position)||ai(e.input.charCodeAt(e.position))||0===e.input.charCodeAt(e.position))break;const t=e.position;for(;0!==e.input.charCodeAt(e.position)&&!li(e.input.charCodeAt(e.position));)e.position++;i.push(e.input.slice(t,e.position))}if(ai(e.input.charCodeAt(e.position))&&fi(e),"YAML"===n){e.directives.some((e=>"yaml"===e.kind))&&si(e,"duplication of %YAML directive"),1!==i.length&&si(e,"YAML directive accepts exactly one argument");const t=/^([0-9]+)\.([0-9]+)$/.exec(i[0]);null===t&&si(e,"ill-formed argument of the YAML directive"),1!==parseInt(t[1],10)&&si(e,"unacceptable YAML version of the document"),e.directives.push({kind:"yaml",version:i[0]})}else if("TAG"===n){2!==i.length&&si(e,"TAG directive accepts exactly two arguments");const[t,n]=i;Vn.test(t)||si(e,"ill-formed tag handle (first argument) of the TAG directive"),Bn.call(e.tagHandlers,t)&&si(e,`there is a previously declared suffix for "${t}" tag handle`),qn.test(n)||si(e,"ill-formed tag prefix (second argument) of the TAG directive"),e.tagHandlers[t]=n,e.directives.push({kind:"tag",handle:t,prefix:n})}return!0}function $i(e){e.directives=[],e.tagHandlers=Object.create(null);let t=!1;for(Oi(e,!0);wi(e);)t=!0,Oi(e,!0);let n=!1,i=!1,o=!0;if(0===e.lineIndent&&45===e.input.charCodeAt(e.position)&&45===e.input.charCodeAt(e.position+1)&&45===e.input.charCodeAt(e.position+2)&&di(e.input.charCodeAt(e.position+3))){n=!0;const t=e.line;e.position+=3,Oi(e,!0),o=e.line>t}else t&&si(e,"directives end mark is expected");const r=e.events.length;if(!n&&e.position===e.lineStart&&46===e.input.charCodeAt(e.position)&&mi(e))return e.position+=3,void Oi(e,!0);if(function(e,t,n){e.events.push({type:rn.DOCUMENT,explicitStart:t,explicitEnd:n,directives:e.directives})}(e,n,!1),Di(e,e.lineIndent-1,Un,!1,o,o)||ni(e),Oi(e,!0),e.position===e.lineStart&&mi(e)&&(i=46===e.input.charCodeAt(e.position),i)){const t=e.line;e.position+=3,Oi(e,!0),e.line===t&&e.position<e.length&&si(e,"end of the stream or a document separator is expected")}const s=e.events[r];s?.type===rn.DOCUMENT&&(s.explicitEnd=i),ti(e),!i&&e.position<e.length&&!Ai(e)&&si(e,"end of the stream or a document separator is expected")}var xi={...zn,...Sn};function Hi(e,t={}){const n={...xi,...t},i=String(e),o=Object.keys(zn),r=Object.keys(Sn);return function(e,t){const n={...Sn,...t,events:e,documents:[],eventIndex:0,position:0,frames:[],anchors:new Map,nodeTags:new Map,tagHandlers:Object.create(null),totalMergeKeys:0,aliasCount:0};for(;n.eventIndex<n.events.length;){const e=n.events[n.eventIndex++];switch(n.position=Nn(e),e.type){case rn.DOCUMENT:n.anchors=new Map,n.nodeTags=new Map,n.aliasCount=0,n.tagHandlers=Object.create(null);for(const t of e.directives)"tag"===t.kind&&(n.tagHandlers[t.handle]=t.prefix);n.frames.push({kind:"document",position:n.position,value:void 0,hasValue:!1});break;case rn.SCALAR:{const{value:t,tag:i}=yn(n,e);Hn(n,e,t,i,!0),xn(n,t,i);break}case rn.SEQUENCE:{const t=Cn(n,e,"tag:yaml.org,2002:seq"),i=n.schema.lookupSequenceTag(t);i||vn(n,`unknown sequence tag !<${t}>`);const o=i.create(t),r=Hn(n,e,o,i,i.carrierIsResult);n.frames.push({kind:"sequence",position:n.position,value:o,tag:i,anchor:r,index:0});break}case rn.MAPPING:{const t=Cn(n,e,"tag:yaml.org,2002:map"),i=n.schema.lookupMappingTag(t);i||vn(n,`unknown mapping tag !<${t}>`);const o=i.create(t),r=Hn(n,e,o,i,i.carrierIsResult);n.frames.push({kind:"mapping",position:n.position,value:o,tag:i,anchor:r,key:void 0,keyPosition:n.position,hasKey:!1,keyIsMerge:!1,overridable:null});break}case rn.ALIAS:{-1!==n.maxAliases&&++n.aliasCount>n.maxAliases&&vn(n,`aliases exceeded maxAliases (${n.maxAliases})`);const t=n.source.slice(e.anchorStart,e.anchorEnd),i=n.anchors.get(t);i||vn(n,`unidentified alias "${t}"`),i.isValueFinal||vn(n,`recursive alias "${t}" is not supported for tag ${i.tag.tagName} because it uses finalize()`),xn(n,i.value,i.tag);break}case rn.POP:{const e=n.frames.pop();if("mapping"===e.kind&&e.hasKey&&(n.position=e.keyPosition,vn(n,"incomplete mapping pair in event stream")),"document"===e.kind)n.documents.push(e.value);else{const t=e.tag.carrierIsResult?e.value:Rn(n,e.position,e.tag,e.value);e.anchor&&(e.anchor.value=t,e.anchor.isValueFinal=!0),xn(n,t,e.tag)}break}}}return n.documents}(function(e,t){const n=e.length,i={...zn,...t,input:`${e}\0`,length:n,position:0,line:0,lineStart:0,lineIndent:0,firstTabInLine:-1,depth:0,directives:[],tagHandlers:Object.create(null),events:[]},o=e.indexOf("\0");for(-1!==o&&on.throwAt(e,o,"null byte is not allowed in input",i.filename);i.position<i.length&&(Ti(i),Oi(i,!0),!(i.position>=i.length));){const e=i.position;$i(i),i.position===e&&si(i,"can not read a document")}return i.events}(i,Vt(n,o)),{...Vt(n,r),source:i})}function Mi(e,t){return!!(e&1<<t)}var Bi={applyQuoteFlowKeysOption:function(e){if(!e.presenterOptions.quoteFlowKeys)return;if(!e.isKey||!e.flowOnly||e.style!==sn.PLAIN)return;e.style=sn.DOUBLE_QUOTED},doubleQuoteForInvisibles:function(e){e.style===sn.PLAIN&&/[\t\x7F-\xA0\u2028\u2029\uFEFF\uFFFE\uFFFF]/.test(e.node.value)&&(e.style=sn.DOUBLE_QUOTED)},doubleQuoteWhitespaceOnly:function(e){e.style===sn.PLAIN&&/^\s+$/.test(e.node.value)&&(e.style=sn.DOUBLE_QUOTED)},applyForceQuotesOption:function(e){if(!e.presenterOptions.forceQuotes)return;if(e.isKey||e.style!==sn.PLAIN)return;e.style=e.node.value.includes("\n")?sn.DOUBLE_QUOTED:Pi(e)},tryLongOrMultilineAsBlock:function(e){if(e.style!==sn.PLAIN||e.isKey)return;const t=e.node.value,n=-1!==t.indexOf("\n");if(!Mi(e.allowedStylesMask,sn.LITERAL_BLOCK))return void(n&&(e.style=sn.DOUBLE_QUOTED));const i=e.presenterOptions.lineWidth;if(-1===i)return void(n&&(e.style=sn.LITERAL_BLOCK));const o=Math.max(Math.min(i,40),i-e.shiftOfContent);let r=0,s=!1;for(;r<=t.length;){let e=t.length;const n=t.indexOf("\n",r);-1!==n&&(e=n);const i=t.slice(r,e);if(i.length>o&&" "!==i[0]&&/ [^ \t]/.test(i)&&(s=!0),-1===n)break;r=n+1}s?e.style=sn.FOLDED_BLOCK:n&&(e.style=sn.LITERAL_BLOCK)},quoteInvalidPlain:function(e){e.style!==sn.PLAIN||Mi(e.allowedStylesMask,sn.PLAIN)||(e.style=Pi(e))},fallbackToDoubleQuoted:function(e){Mi(e.allowedStylesMask,e.style)||(e.style=sn.DOUBLE_QUOTED)}};function Pi(e){return"single"===e.presenterOptions.quoteStyle&&Mi(e.allowedStylesMask,sn.SINGLE_QUOTED)?sn.SINGLE_QUOTED:sn.DOUBLE_QUOTED}Object.keys(Bi).map((e=>Reflect.get(Bi,e)));const Fi=e=>typeof e===Se.UNDEFINED,ki=e=>typeof e===Se.STRING,Ui=e=>typeof e===Se.NUMBER&&!Number.isNaN(e),ji=e=>typeof e===Se.BOOLEAN,Gi=e=>"[object Object]"===Object.prototype.toString.call(e),Vi=e=>Array.isArray(e),Wi=e=>Vi(e)?e.map((e=>e.toLowerCase())):e.toLowerCase().split(/\s*,\s*/),Ki=e=>Ui(e)?`${e}px`:e,Xi=/(?:iphone|android|ipad)/i.test(navigator.userAgent),Yi=()=>e(void 0,void 0,void 0,(function*(){return yield i((()=>window.hassConnection),(e=>!!e))})),qi=e=>{const t=document.createElement(Ne.SPAN);return t.classList.add(Le.BADGE),t.setAttribute(De.SLOT,e),t},zi=e=>{var t,n;const i=document.createElement(e.section_header?ve.ITEM_BASE:ve.ITEM),o=document.createElement(Ne.SPAN);if(o.classList.add(Le.ITEM_TEXT),o.setAttribute(De.SLOT,we.HEADLINE),o.innerText=e.item,e.section_header)i.appendChild(o);else{i.setAttribute(De.ID,(e=>{var t;const n=(null!==(t=e.href)&&void 0!==t?t:e.item).replace(/\W/g,"-");return`${we.SIDEBAR_PANEL}-${n}`})(e)),i.setAttribute(De.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=qi(we.START),s=qi(we.END);i.appendChild(r),i.appendChild(o),i.appendChild(s)}return i.tabIndex=-1,i},Qi=e=>e.querySelector(Re.ITEM_TEXT),Ji=e=>Qi(e).textContent.trim(),Zi=e=>e.parentElement.querySelector(`${ve.TOOLTIP}[${De.FOR}="${e.id}"]`),eo=(e,t)=>{t?e.style.display=we.NONE:e.style.removeProperty("display")};function to(e,t,n={}){const o=ki(e)?document:e,r=ki(e)?e:String(t),s=ki(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 no=(t,n)=>e(void 0,void 0,void 0,(function*(){const e=yield t.selector.$.element;yield to(e,Re.SIDEBAR_LOADER,{shouldReject:n}).toBeRemoved()})),io=(t,n,...o)=>e(void 0,[t,n,...o],void 0,(function*(e,t,n=!1){const o=yield i((()=>e.querySelectorAll(`:scope > ${Re.ITEM}`)),(e=>Array.from(e).every((e=>Ji(e).length>0))),{retries:100,delay:50,shouldReject:t});return o.forEach((e=>{e.setAttribute(De.FIXED,n?we.TRUE:we.FALSE)})),o})),oo=e=>Array.from(e).map((e=>{const t=e.href;return{text:Ji(e),href:t}})),ro=(e,t,n)=>{const i=e.length;let o=0;if(n){const n=t+1,r=n+i;for(let t=n;t<r;t++){const n=t>i-1?t-i:t;if(e[n].nodeName!==He.ITEM_BASE&&e[n].style.display!==we.NONE){o=n;break}}}else{const n=t-1,r=n-i;for(let t=n;t>r;t--){const n=t<0?i+t:t;if(e[n].nodeName!==He.ITEM_BASE&&e[n].style.display!==we.NONE){o=n;break}}}e[o].focus(),e[o].tabIndex=0},so=(e,t,n)=>{const i=[`${Re.SCOPE} > ${ve.ITEM}:not(.${Le.ITEM_SELECTED}):focus`,`${Re.SCOPE} > ${ve.ITEM}:focus`],o=t.querySelector(i.join(","));let r=0;e.forEach(((e,t)=>{e===o&&(r=t),e.tabIndex=-1})),ro(e,r,n)},ao=(e=document)=>{const t=e.activeElement;return t?t instanceof HTMLElement&&t.nodeName===He.ITEM?t:t.shadowRoot&&Me.includes(t.nodeName)?ao(t.shadowRoot):null:null},co=t=>e(void 0,void 0,void 0,(function*(){const e=yield t.element,n=e.alwaysExpand||Xi;e.shadowRoot.querySelectorAll(`${ve.ITEM}[${De.NEW_ITEM}]`).forEach((e=>{let t=Zi(e);if(n)null==t||t.parentElement.removeChild(t);else if(!t){const n=Ji(e);t=((e,t)=>{const n=document.createElement(ve.TOOLTIP);return n.setAttribute(De.FOR,e),n.setAttribute(De.SHOW_DELAY,we.ZERO),n.setAttribute(De.HIDE_DELAY,we.ZERO),n.setAttribute(De.PLACEMENT,we.RIGHT),n.textContent=t,n})(e.id,n),e.after(t)}}))})),lo=(e,t)=>{t.forEach((([t,n])=>{n&&e.style.setProperty(t,n)}))},ho=(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}))},uo=(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,t)=>{const n=()=>{ho(window,$e.LOCATION_CHANGED,{replace:e,source:Ae})};n();const i=Date.now(),o=e=>{var o;Date.now()-i<100&&(null===(o=e.detail)||void 0===o?void 0:o.source)!==Ae&&(window.history.replaceState(...t),n())};window.addEventListener($e.LOCATION_CHANGED,o),setTimeout((()=>{window.removeEventListener($e.LOCATION_CHANGED,o)}),100)})(t,n)}else console.warn(`${Ae}: ${n} "${e}" as it doesn't start with "/".`)},_o=t=>e(void 0,void 0,void 0,(function*(){if(!customElements.get(ve.HA_PANEL_CONFIG)){const e=yield t.element;yield e.routerOptions.routes.config.load(),yield customElements.whenDefined(ve.HA_PANEL_CONFIG)}return document.createElement(ve.HA_PANEL_CONFIG)})),po=(t,n)=>e(void 0,void 0,void 0,(function*(){const i=customElements.get(ve.DIALOG_BOX);if(i)return i;const o=yield _o(n),r=yield(t=>e(void 0,void 0,void 0,(function*(){return customElements.get(ve.HA_CONFIG_BACKUP)||(yield t.routerOptions.routes.backup.load(),yield customElements.whenDefined(ve.HA_CONFIG_BACKUP)),document.createElement(ve.HA_CONFIG_BACKUP_BACKUPS)})))(o);return r.hass=t.hass,new Promise((e=>{r.addEventListener($e.SHOW_DIALOG,(t=>{const n=t.detail.dialogImport();e(n)}),{once:!0}),r._overflowBackup=!0,r._deleteBackup()}))})),Eo=t=>e(void 0,void 0,void 0,(function*(){const n=customElements.get(ve.DIALOG_RESTART);if(n)return n;const i=yield _o(t),o=yield(t=>e(void 0,void 0,void 0,(function*(){return customElements.get(ve.HA_CONFIG_SYSTEM_NAVIGATION)||(yield t.routerOptions.routes.system.load(),yield customElements.whenDefined(ve.HA_CONFIG_SYSTEM_NAVIGATION)),document.createElement(ve.HA_CONFIG_SYSTEM_NAVIGATION)})))(i);return new Promise((e=>{o.addEventListener($e.SHOW_DIALOG,(t=>{const n=t.detail.dialogImport();e(n)}),{once:!0}),o._showRestartDialog()}))})),fo=(e,t,n,i)=>{ho(e,$e.SHOW_DIALOG,{dialogTag:t,dialogImport:n,dialogParams:i})},Oo=(t,n)=>e(void 0,void 0,void 0,(function*(){const e=yield Eo(n);((e,t)=>{fo(e,ve.DIALOG_RESTART,t,{})})(t,(()=>Promise.resolve(e)))})),mo=(e,t)=>{ho(e,$e.HASS_MORE_INFO,{entityId:t})},To=(t,n)=>({openAlertDialog:i=>{const{title:o,text:r,confirmText:s,confirm:a}=i;((t,n,i)=>{e(void 0,void 0,void 0,(function*(){const e=yield po(t,n);fo(t,ve.DIALOG_BOX,(()=>Promise.resolve(e)),i)}))})(t,n,{title:o,text:r,confirmText:s,confirm:a})},openConfirmDialog:i=>{const{title:o,text:r,destructive:s,confirmText:a,dismissText:c,confirm:l,cancel:d}=i;((t,n,i)=>{e(void 0,void 0,void 0,(function*(){const e=yield po(t,n);fo(t,ve.DIALOG_BOX,(()=>Promise.resolve(e)),Object.assign(Object.assign({},i),{confirmation:!0}))}))})(t,n,{title:o,text:r,destructive:s,confirmText:a,dismissText:c,confirm:l,cancel:d})},openRestartDialog:()=>{Oo(t,n)},openMoreInfoDialog:e=>{mo(t,e)}}),Ao=[...Fe,...ke],go=["id","exceptions","extendable_configs","extend_from","user","not_user","device","not_device","is_admin"],Io=["js_variables","jinja_variables","partials"];class bo{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:pe.OR,o=void 0!==t.user&&Wi(t.user).includes(e),r=void 0!==t.not_user&&!Wi(t.not_user).includes(e),s=void 0!==t.device&&Wi(t.device).some((e=>this._userAgent.includes(e))),a=void 0!==t.not_device&&!Wi(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===pe.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!go.includes(t)})));return e.extend_from?this._mergeConfigs(this._importConfig(e.extend_from),n):Object.assign({},n)}_importConfig(e){var t;return(Vi(t=e)?t:[t]).reduce(((e,t)=>t===be?this._mergeConfigs(this._pickExtendableOptions(this._config),e):this._mergeConfigs(this._pickExtendableOptions(this._extendable.get(t)),e)),{})}_buildFlattenConfigFromExceptions(){const e=Io.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=>{Ao.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:Fi(e.order)||Fi(t.order)?e.order===t.order?0:Fi(e.order)?1:-1:e.order-t.order))}get config(){return Object.assign(Object.assign({},this._flattenConfig),{order:this._flattenOrder(this._flattenConfig)})}}const So=(e,t,n=[])=>e.replace(Qe,((e,i)=>{if(null==t?void 0:t[i]){if(n.includes(i))throw new SyntaxError(`${Ae}: circular partials dependency ${n.join(" > ")} > ${i}`);return So(t[i].trim(),t,[...n,i])}return console.warn(`${Ae}: partial ${i} doesn't exist`),""})),No=(...e)=>{const[t,...n]=e;return 0===n.length?ki(t)&&t.startsWith("--")?`var(${t})`:`${t}`:`var(${t}, ${No(...n)})`};const vo=new class{constructor(){this._langKey="language",this._locale=new Promise((t=>{Yi().then((n=>e(this,void 0,void 0,(function*(){const e=n.conn.subscribeMessage((e=>{t(e.value)}),{type:$e.SUBSCRIBE_USER_DATA,key:this._langKey});(yield e)()}))))}))}get locale(){return this._locale}};class Ro{constructor(e){this._enabled=e}static logVersionToConsole(){console.info(`%c≡ ${Ae.toUpperCase()} %cv17.1.0`,"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=`${Ae} 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 yo="Invalid configuration",Co=["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",...Fe,"default_path"],Lo=["js_variables","jinja_variables","partials","extendable_configs"],Do=(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(!(Fi(o)||ki(o)||Ui(o)||Gi(o)))throw new SyntaxError(`${t} "width" property should be a number, a string or an object`);if(ki(o)&&!i.test(o))throw new SyntaxError(`${t} "width" property has an invalid format. ${n}`);if(Gi(o)){const{extended:e,hidden:r}=o;if(Fi(e)&&Fi(r))throw new SyntaxError(`${t} if "width" property is an object it should have an "extended" or a "hidden" property`);if(!Fi(e)&&!Ui(e)&&!ki(e))throw new SyntaxError(`${t} "width.extended" property should be a number or a string`);if(!Fi(r)&&!Ui(r)&&!ki(r))throw new SyntaxError(`${t} "width.hidden" property should be a number or a string`);if(i.lastIndex=0,ki(e)&&!i.test(e))throw new SyntaxError(`${t} "width.extended" property has an invalid format. ${n}`);if(i.lastIndex=0,ki(r)&&!i.test(r))throw new SyntaxError(`${t} "width.hidden" property has an invalid format. ${n}`)}},wo=(e,t,n)=>{t.forEach((t=>{if(!Fi(e[t])&&!ki(e[t]))throw new SyntaxError(`${n} "${String(t)}" property should be a string`)}))},$o=(e,t,n)=>{t.forEach((t=>{if(!Fi(e[t])&&!ki(e[t])&&!Ui(e[t]))throw new SyntaxError(`${n} "${String(t)}" property should be a number or a string`)}))},xo=(e,t,n)=>{t.forEach((t=>{if(!Fi(e[t])&&!ji(e[t]))throw new SyntaxError(`${n} "${String(t)}" property should be a boolean`)}))},Ho=(e,t,n)=>{t.forEach((t=>{if(!Fi(e[t])&&!ji(e[t])&&!ki(e[t]))throw new SyntaxError(`${n} "${String(t)}" property should be a boolean or a string`)}))},Mo=(e,t)=>{e.forEach((e=>{const[n,i]=e;if(!Bo(i))throw new SyntaxError(`${t} "${n}" property should be a string or an array of strings`)}))},Bo=e=>!!Fi(e)||(ki(e)||Vi(e)&&e.some(ki)),Po=(e,t,n,i=!1)=>{if(e){(Vi(e)?e:[e]).forEach((e=>{var o;if(e===be&&!i)throw new SyntaxError(`${n} "entend_from" can only be "base" in exceptions`);if(e!==be&&!(e in(null!==(o=t.extendable_configs)&&void 0!==o?o:{})))throw new SyntaxError(`${n} "${e}" doesn't exist in "extendable_configs"`)}))}},Fo=(e,t,n)=>{if(e){(Vi(e)?e:[e]).forEach((e=>{if(n.includes(e))throw new SyntaxError(`${yo}, circular extend dependency detected in "${n.join(" > ")} > ${e}"`);if(e===be)throw new SyntaxError(`${yo}, 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(`${yo}, error in "${n[n.length-1]}": "${e}" doesn't exist in "extendable_configs"`);Fo(t.extendable_configs[e].extend_from,t,[...n,e])}))}},ko=(e,t)=>{Lo.forEach((n=>{if(n in e)throw new SyntaxError(`${t} "${n}" option can only be placed in the main config`)}))},Uo=(e,t,n)=>{if(ki(t)&&(qe.test(t)||ze.test(t)))console.warn(`"${e}" property should not have templates. "${n.join(" > ")}" seems to be a template`);else if(!ki(t)&&!Ui(t)&&!ji(t))if(Vi(t))t.forEach(((t,i)=>{Uo(e,t,[...n,`[${i}]`])}));else{if(!Gi(t))throw new SyntaxError(`${yo}, "${e}: ${n.join(" > ")}" has a wrong type ${Object.prototype.toString.call(t)}`);{const i=t;Object.entries(i).forEach((t=>{const[i,o]=t;Uo(e,o,[...n,i])}))}}},jo=(e,t)=>{if(!Fi(t)){if(!Gi(t))throw new SyntaxError(`${yo}, "${e}" property should be an object`);Object.entries(t).forEach((t=>{const[n,i]=t;Uo(e,i,[n])}))}},Go=(e,t)=>{if(e.analytics){if(!ji(e.analytics)&&!Gi(e.analytics))throw new SyntaxError(`${t} "analytics" should be a boolean or an object`);Gi(e.analytics)&&xo(e.analytics,["sidebar_item_clicked","panel_visited"],`${t} "analytics"`)}},Vo=(e,t)=>{if(!Fi(e)){if(!Vi(e))throw new SyntaxError(`${yo}, exceptions should be an array`);e.forEach((e=>{((e,t)=>{var n;if(ko(e,`${yo}, exceptions`),wo(e,[...Co],`${yo}, exceptions`),Do(e,`${yo}, exceptions`),$o(e,[...ke,"sidebar_button_background_hover_opacity"],`${yo}, exceptions`),Mo([["user",e.user],["not_user",e.not_user],["device",e.device],["not_device",e.not_device],["extend_from",e.extend_from]],`${yo}, exceptions`),Po(e.extend_from,t,`${yo}, error in exception:`,!0),!Fi(e.matchers_conditions)&&e.matchers_conditions!==pe.AND&&e.matchers_conditions!==pe.OR)throw new SyntaxError(`${yo}, exceptions "matchers_conditions" property should be "${pe.AND}" or "${pe.OR}"`);if(!Fi(e.order)&&!Vi(e.order))throw new SyntaxError(`${yo}, exceptions "order" property should be an array`);if(Ho(e,["sidebar_editable"],`${yo}, exceptions`),xo(e,["hide_all","is_admin","is_owner"],`${yo}, exceptions`),Go(e,`${yo}, error in exception:`),!Fi(e.sidebar_mode)&&!(e.sidebar_mode in We))throw new SyntaxError(`${yo}, exceptions "sidebar_mode" property should be ${ue.HIDDEN}, ${ue.NARROW} or ${ue.EXTENDED}`);if(e.user&&e.not_user)throw new SyntaxError(`${yo}, exceptions "user" and "not_user" properties cannot be used together`);if(e.device&&e.not_device)throw new SyntaxError(`${yo}, exceptions "device" and "not_device" properties cannot be used together`);null===(n=e.order)||void 0===n||n.forEach(Wo)})(e,t)}))}},Wo=e=>{if(!e.item)throw new SyntaxError(`${yo}, every item in an "order" array should have an "item" property`);if("section_header"in e&&(e=>{if(!ji(e.section_header))throw new SyntaxError(`${yo}, "section_header" property should be a boolean`);if(!ji(e.new_item))throw new SyntaxError(`${yo}, 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(`${yo}, property "${e}" is not allowed in a section header item`)}))})(e),ko(e,`${yo} in ${e.item},`),wo(e,["item","info",...Fe],`${yo} in ${e.item},`),$o(e,[...ke],`${yo} in ${e.item},`),Ho(e,["hide"],`${yo} in ${e.item},`),xo(e,["divider"],`${yo} in ${e.item},`),((e,t)=>{if(!Fi(e.on_click)){if(!Gi(e.on_click))throw new SyntaxError(`${t} "on_click" property should be an object`);if(!ki(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(!ki(e.on_click.path))throw new SyntaxError(`${t} the "path" parameter should be a string`);if(!Fi(e.on_click.replace)&&!ji(e.on_click.replace))throw new SyntaxError(`${t} the "replace" parameter should be a boolean`)}if(e.on_click.action===fe.CALL_SERVICE){if(!ki(e.on_click.service))throw new SyntaxError(`${t} the "service" parameter should be a string`);if(!Fi(e.on_click.data)&&!Gi(e.on_click.data))throw new SyntaxError(`${t} the "data" parameter needs to be an object`)}if(e.on_click.action===fe.JAVASCRIPT&&!ki(e.on_click.code))throw new SyntaxError(`${t} the "code" parameter should be a string`)}})(e,`${yo} in ${e.item},`),((e,t)=>{if(!Fi(e)){if(!Gi(e)&&!ki(e))throw new SyntaxError(`${t} the "attributes" parameter should be an object or a template string`);if(Gi(e))Object.entries(e).forEach((e=>{const[n,i]=e;if(!ki(i)&&!ji(i)&&!Ui(i))throw new SyntaxError(`${t} the prop "${n}" in the attributes should be a string, a number or a boolean`)}));else if(ki(e)&&!qe.test(e))throw new SyntaxError(`${t} the "attributes" parameter as a string should be a JavaScript template`)}})(e.attributes,`${yo} in ${e.item},`),e.new_item&&!e.section_header){if(wo(e,["href","icon"],`${yo} in ${e.item},`),!e.href&&!e.on_click)throw new SyntaxError(`${yo} 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(`${yo} in ${e.item}, if you set "new_item" as "true", "icon" property is necessary`)}},Ko=e=>{var t;if(wo(e,[...Co],`${yo},`),Do(e,`${yo},`),Mo([["extend_from",e.extend_from]],`${yo},`),Po(e.extend_from,e,`${yo}, error in main config:`),(e=>{e.extendable_configs&&Object.entries(e.extendable_configs).forEach((t=>{const[n,i]=t;Fo(i.extend_from,e,[n])}))})(e),$o(e,[...ke,"sidebar_button_background_hover_opacity"],`${yo},`),Ho(e,["sidebar_editable"],`${yo},`),xo(e,["hide_all"],`${yo},`),!Fi(e.sidebar_mode)&&!(e.sidebar_mode in We))throw new SyntaxError(`${yo}, "sidebar_mode" property should be ${ue.HIDDEN}, ${ue.NARROW} or ${ue.EXTENDED}`);if(!Fi(e.order)&&!Vi(e.order))throw new SyntaxError(`${yo}, "order" property should be an array`);if(!Fi(e.partials)){if(!Gi(e.partials))throw new SyntaxError(`${yo}, "partials" property should be an object`);Object.entries(e.partials).forEach((e=>{const[t,n]=e;if(!ki(n))throw new SyntaxError(`${yo}, "partials" should be an object with strings. The partial ${t} is not a string`)}))}jo("js_variables",e.js_variables),jo("js_refs",e.js_refs),jo("jinja_variables",e.jinja_variables),Go(e,`${yo},`),null===(t=e.order)||void 0===t||t.forEach(Wo),Vo(e.exceptions,e)},Xo=()=>e(void 0,void 0,void 0,(function*(){const e=`${Ae}: Config file not found.`,t=`Make sure you have a valid config in /config/www/${ge}.yaml file.`;return new Promise((n=>{fetch(`${Ie}.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=>function(e,t){const n=Hi(e,t);if(0===n.length)throw new on("expected a document, but the input is empty");if(1===n.length)return n[0];throw new on("expected a single document in the stream, but found more")}(e))).then((e=>{var t;const i=e;(null===(t=i.id)||void 0===t?void 0:t.startsWith("example"))&&console.warn(`${Ae}: You seem to be using the example configuration.`),Ko(i),n(i)})).catch((e=>{throw Error(`${Ae}: ${e}`)}))})).catch((()=>{throw Error(`${e}\n${t}`)}))}))}));class Yo{constructor(e,t,n){this._ha=e,this._config=t,this._renderer=n}_getTemplateString(t){return e(this,void 0,void 0,(function*(){let e="";if(t instanceof Promise||ki(t)||Ui(t)||ji(t)||Gi(t)||Vi(t)||(n=t,"[object RegExp]"===Object.prototype.toString.call(n)))if(ki(t))e=t.trim();else if(Ui(t)||ji(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}))}_checkForJsTemplateSubscriptionStart(e){if(!this._renderer.subscribed){const{entities:t}=this._renderer.parseTemplate(e);if(t.length>0){t.some((e=>Je.test(e)))&&this._renderer.init()}}}createJsTemplateSubscription(e,t){this._checkForJsTemplateSubscriptionStart(e),this._renderer.trackTemplate(e,(e=>{this._getTemplateString(e).then((e=>{t(e)}))}))}createJinjaTemplateSubscription(e,t){return new Promise((n=>{Yi().then((i=>{const o=i.conn.subscribeMessage((e=>{t(`${e.result}`)}),{type:$e.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)}))}))}_subscribeTemplate(e,t){const n=So(`${e}`,this._config.partials);qe.test(n)?this.createJsTemplateSubscription(n.replace(qe,"$1"),t):ze.test(n)?this.createJinjaTemplateSubscription(n,t):this._getTemplateString(n).then((e=>{t(e)}))}subscribeTitle(e){e.selector.$.query(Re.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(e,t){const n=e=>{e.preventDefault(),e.stopImmediatePropagation()},i=(e,t)=>{e.removeEventListener($e.SHOW_DIALOG,n,!0),t.removeAttribute(De.BLOCKED)},o=(e,t)=>{e.removeEventListener($e.SHOW_DIALOG,n,!0),e.addEventListener($e.SHOW_DIALOG,n,!0),t.setAttribute(De.BLOCKED,we.EMPTY)};Promise.all([e.element,e.selector.$.query(Re.MENU).element]).then((([e,n])=>{ji(this._config.sidebar_editable)&&(this._config.sidebar_editable||o(e,n)),ki(this._config.sidebar_editable)&&this._subscribeTemplate(this._config.sidebar_editable,(r=>{let s;r===we.TRUE||r===we.FALSE?(s=!(r===we.FALSE),s?i(e,n):o(e,n)):(s=void 0,i(e,n)),t(s)}))}))}subscribeAttributes(e,t){const n=t=>{var n,i;const o=null!==(i=null===(n=e.element.getAttribute(De.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;ki(i)||Ui(i)||ji(i)?(e.element.setAttribute(n,`${i}`),o.push(n)):console.warn(`${Ae}: 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(De.CUSTOM_SIDEBAR_ATTRIBUTES,o.join("|"))};ki(t)?this._subscribeTemplate(t,(e=>{try{const t=JSON.parse(e);n(Object.entries(t))}catch(e){throw new SyntaxError(`${Ae}: "attributes" template must always return an object`)}})):n(Object.entries(t))}subscribeName(e,t){const n=Qi(e);n.innerHTML="",this._subscribeTemplate(t,(t=>{n.innerHTML=t;const i=Zi(e);i&&(i.textContent=t)}))}subscribeIcon(e,t){this._subscribeTemplate(t,(t=>{let n=e.querySelector(ve.HA_ICON);if(!n){n=document.createElement(ve.HA_ICON),n.setAttribute(De.SLOT,we.START);const t=e.querySelector(ve.HA_SVG_ICON);t?t.replaceWith(n):e.prepend(n)}n.setAttribute(De.ICON,t)}))}subscribeInfo(e,t){const n=Qi(e);this._subscribeTemplate(t,(e=>{n.dataset.info=e}))}subscribeNotification(e,t){const n=Qi(e);let i=e.querySelector(`${Re.BADGE}[slot="${we.START}"]`),o=e.querySelector(`${Re.BADGE}[slot="${we.END}"]`);i||(i=qi(we.START),e.insertBefore(i,n)),o||(o=qi(we.END),e.append(o));this._subscribeTemplate(t,(t=>{t.length?(i.innerHTML=t,o.innerHTML=t,e.setAttribute(De.WITH_NOTIFICATION,we.TRUE)):(i.innerHTML="",o.innerHTML="",e.removeAttribute(De.WITH_NOTIFICATION))}))}subscribeHide(e,t,n){ji(t)?eo(e,t):this._subscribeTemplate(t,(t=>{eo(e,t===we.TRUE),n()}))}subscribeTemplateVariableChanges(e,t,n){n.forEach((([n,i])=>{e[n]&&this._subscribeTemplate(e[n],(e=>{t.style.setProperty(i,e)}))}))}}const qo={backgroundColor:No(Pe.NOTIFICATION_COLOR,Be.ACCENT_COLOR),color:No(Pe.NOTIFICATION_TEXT_COLOR,Be.TEXT_ACCENT_COLOR,Be.TEXT_PRIMARY_COLOR),display:"inline-flex",maxWidth:"80px",overflow:"hidden",textAlign:"center",textOverflow:"ellipsis",textWrap:"nowrap",zIndex:1},zo={[`${Re.HOST} ${ve.ITEM_BASE}`]:{fontWeight:"var(--ha-font-weight-medium)"}},Qo={[`${Re.HOST_EXPANDED_NOT_NAROW} ${Re.MENU}`]:{width:"100%"},[`${Re.HOST_EXPANDED} ${Re.ITEM}`]:{width:"calc(100% - var(--ha-space-2)) !important"},[`${Re.HOST_EXPANDED} ${ve.ITEM} > ${ve.USER_BADGE}`]:{zIndex:1},[`${Re.HOST_EXPANDED} ${Re.ITEM} > ${Re.ITEM_TEXT}`]:{position:"relative",zIndex:1},[`${Re.HOST_EXPANDED} ${Re.ITEM} > ${Re.ITEM_TEXT}${Re.DATA_INFO}`]:{display:"flex",flexDirection:"column",gap:"5px",lineHeight:"1"},[`${Re.HOST_EXPANDED} ${Re.ITEM} > ${Re.ITEM_TEXT}${Re.DATA_INFO}${Ce.AFTER}`]:{content:"attr(data-info)",display:"block",fontSize:"11px",lineHeight:"1",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},[`${Re.HOST} ${ve.ITEM}:not([${De.WITH_NOTIFICATION}], ${Re.CONFIGURATION}, ${Re.SIDEBAR_NOTIFICATIONS}) > ${Re.BADGE}`]:{display:"none"},[`${Re.HOST_NOT_EXPANDED} ${ve.ITEM}:not([${De.WITH_NOTIFICATION}], ${Re.CONFIGURATION}, ${Re.SIDEBAR_NOTIFICATIONS}) > ${Re.BADGE}`]:{display:"none"},[`${Re.HOST} ${ve.ITEM} > ${Re.BADGE}`]:qo,[`${Re.HOST_NOT_EXPANDED} ${ve.ITEM} > ${Re.BADGE}`]:Object.assign(Object.assign({},qo),{maxWidth:"10px",textOverflow:"unset"}),[`${Re.HOST} ${ve.ITEM} > ${ve.HA_ICON} + ${Re.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)"}},Jo={[`${Re.HOST} ${Re.MENU} > ${Re.TITLE}`]:{color:No(Pe.TITLE_COLOR,Be.SIDEBAR_TITLE_COLOR,Be.PRIMARY_TEXT_COLOR)}},Zo={[`${Re.HOST} ${Re.MENU} > ${Re.TITLE}${Ce.AFTER}`]:{content:"attr(data-subtitle)",color:No(Pe.SUBTITLE_COLOR,Pe.TITLE_COLOR,Be.SIDEBAR_TITLE_COLOR,Be.PRIMARY_TEXT_COLOR),display:"block",fontSize:"12px",lineHeight:"1.5"}},er={[`${Re.HOST} ${Re.MENU} > ${ve.HA_ICON_BUTTON}`]:{color:No(Pe.BUTTON_COLOR,Be.SIDEBAR_ICON_COLOR)}},tr={[`${Re.HOST} ${Re.MENU} > ${ve.HA_ICON_BUTTON_HOVER}`]:{color:No(Pe.BUTTON_COLOR_HOVER,Pe.BUTTON_COLOR,Be.SIDEBAR_ICON_COLOR)}},nr={[`${Re.HOST} ${ve.HA_BUTTON}${Ce.AFTER}`]:{background:No(Pe.BUTTON_BACKGROUND_HOVER,Pe.BUTTON_COLOR_HOVER,Pe.BUTTON_COLOR,Be.CURRENT_COLOR)},[ye.MEDIA_HOVER]:{[`${Re.HOST_HOVER_NOT_DISABLED} ${ve.HA_BUTTON}[appearance="plain"]${Ce.AFTER}`]:{opacity:No(Pe.BUTTON_BACKGROUND_HOVER_OPACITY,.1)}}},ir={[Re.HOST]:{background:No(Pe.BACKGROUND,Be.SIDEBAR_BACKGROUND_COLOR)+" !important"}},or={[`${Re.HOST} ${Re.MENU}`]:{background:No(Pe.MENU_BACKGROUND,Pe.BACKGROUND,Be.SIDEBAR_MENU_BUTTON_BACKGROUND_COLOR,"inherit"),borderBottomColor:No(Pe.DIVIDER_COLOR,Be.DIVIDER_COLOR),borderBottomStyle:"solid",borderBottomWidth:"1px"}},rr={[`${Re.HOST} ${Re.SIDEBAR_SHELL}`]:{borderInlineEndColor:No(Pe.BORDER_COLOR,Be.DIVIDER_COLOR,"rgba(0,0,0,.12)")}},sr={[`${Re.HOST} ${Re.SIDEBAR_TOP_HA_LIST_NAV}`]:{scrollbarColor:No(Pe.SCROLLBAR_THUMB_COLOR,Be.SCROLLBAR_THUMB_COLOR)+" transparent"},[`${Re.HOST} ${Re.SIDEBAR_TOP_HA_LIST_NAV}${Ce.WEBKIT_SCROLLBAR_THUMB}`]:{background:No(Pe.SCROLLBAR_THUMB_COLOR,Be.SCROLLBAR_THUMB_COLOR)}},ar={[`${Re.MENU}[${De.BLOCKED}]`]:{pointerEvents:"none"},[`${Re.MENU}[${De.BLOCKED}] > ${ve.HA_ICON_BUTTON}`]:{pointerEvents:"all"}},cr={[`${Re.HOST} ${ve.ITEM}:not(${Re.ITEM_SELECTED})${Ce.BEFORE}`]:{background:No(Pe.ITEM_BACKGROUND,"none"),bottom:"0px",content:'""',borderRadius:"4px",display:"block",left:"0px",position:"absolute",pointerEvents:"none",right:"0px",top:"0px"}},lr={[`${Re.HOST} ${Re.SURFACE}${Ce.BEFORE}`]:{background:No(Pe.ITEM_BACKGROUND_HOVER,Be.MD_RIPPLE_HOVER_COLOR,Be.MD_SYS_COLOR_ON_SURFACE,"#1d1b20")},[`${Re.HOST} ${Re.SURFACE_HOVERED}${Ce.BEFORE}`]:{opacity:No(Pe.ITEM_BACKGROUND_HOVER_OPACITY,Be.MD_RIPPLE_HOVER_OPACITY,".08")}},dr={[`${Re.HOST} ${Re.ITEM}[${De.WITH_DIVIDER}]`]:{marginBottom:"var(--ha-space-2)",position:"relative"},[`${Re.HOST} ${ve.ITEM}[${De.WITH_DIVIDER}]`]:{paddingBottom:"10px"},[`${Re.HOST} ${Re.ITEM}[${De.WITH_DIVIDER}]${Ce.AFTER}`]:{content:'""',backgroundColor:No(Pe.DIVIDER_COLOR,Be.DIVIDER_COLOR),bottom:0,height:"1px",left:"calc(-1 * var(--ha-space-2))",position:"absolute",right:"calc(-1 * var(--ha-space-2))"},[`${Re.HOST} ${ve.ITEM}${Re.ITEM_SELECTED}[${De.WITH_DIVIDER}]`]:{borderBottomLeftRadius:0,borderBottomRightRadius:0},[`${Re.HOST} ${ve.ITEM}${Re.ITEM_SELECTED}[${De.WITH_DIVIDER}]${Ce.BEFORE}`]:{bottom:"10px"}},hr={[`${Re.HOST} ${ve.ITEM} > :is(${ve.HA_SVG_ICON}, ${ve.HA_ICON})`]:{color:No(Pe.ICON_COLOR,Be.SIDEBAR_ICON_COLOR)}},ur={[`${Re.HOST} ${ve.ITEM}${Re.ITEM_SELECTED} > :is(${ve.HA_SVG_ICON}, ${ve.HA_ICON})[slot="start"]`]:{color:No(Pe.ICON_COLOR_SELECTED,Be.SIDEBAR_SELECTED_ICON_COLOR)}},_r={[`${Re.HOST} ${Re.ITEM_HOVER}:not(${Re.ITEM_SELECTED}) > :is(${ve.HA_SVG_ICON}, ${ve.HA_ICON})`]:{color:No(Pe.ICON_COLOR_HOVER,Pe.ICON_COLOR,Be.SIDEBAR_ICON_COLOR)}},pr={[`${Re.HOST} ${Re.ITEM} > ${Re.ITEM_TEXT}`]:{color:No(Pe.TEXT_COLOR,Be.SIDEBAR_TEXT_COLOR)}},Er={[`${Re.HOST} ${ve.ITEM}${Re.ITEM_SELECTED} > ${Re.ITEM_TEXT}`]:{color:No(Pe.TEXT_COLOR_SELECTED,Be.SIDEBAR_SELECTED_TEXT_COLOR)}},fr={[`${Re.HOST} ${Re.ITEM_HOVER}:not(${Re.ITEM_SELECTED}) > ${Re.ITEM_TEXT}`]:{color:No(Pe.TEXT_COLOR_HOVER,Pe.TEXT_COLOR,Be.SIDEBAR_TEXT_COLOR)}},Or={[`${Re.HOST} ${ve.ITEM}${Re.ITEM_SELECTED}${Ce.BEFORE}`]:{backgroundColor:No(Pe.SELECTION_BACKGROUND,Pe.ICON_COLOR_SELECTED,Be.SIDEBAR_SELECTED_ICON_COLOR),opacity:No(Pe.SELECTION_OPACITY,Be.DIVIDER_OPACITY)}},mr={[`${Re.HOST_EXPANDED} :is(${Re.SIDEBAR_TOP_ITEMS_CONTAINER}, ${Re.SIDEBAR_BOTTOM_ITEMS_CONTAINER}) > ${Re.ITEM} > ${Re.ITEM_TEXT}${Re.DATA_INFO}${Ce.AFTER}`]:{color:No(Pe.INFO_COLOR,Be.SIDEBAR_TEXT_COLOR)}},Tr={[`${Re.HOST_EXPANDED} :is(${Re.SIDEBAR_TOP_ITEMS_CONTAINER}, ${Re.SIDEBAR_BOTTOM_ITEMS_CONTAINER}) > ${ve.ITEM}${Re.ITEM_SELECTED} > ${Re.ITEM_TEXT}${Re.DATA_INFO}${Ce.AFTER}`]:{color:No(Pe.INFO_COLOR_SELECTED,Be.SIDEBAR_SELECTED_TEXT_COLOR)}},Ar={[`${Re.HOST_EXPANDED} :is(${Re.SIDEBAR_TOP_ITEMS_CONTAINER}, ${Re.SIDEBAR_BOTTOM_ITEMS_CONTAINER}) > ${Re.ITEM_HOVER}:not(${Re.ITEM_SELECTED}) > ${Re.ITEM_TEXT}${Re.DATA_INFO}${Ce.AFTER}`]:{color:No(Pe.INFO_COLOR_HOVER,Pe.INFO_COLOR,Be.SIDEBAR_TEXT_COLOR)}},gr={[`${Re.HOST} ${Re.ITEM_SELECTED} > ${Re.BADGE}`]:{backgroundColor:No(Pe.NOTIFICATION_COLOR_SELECTED,Pe.NOTIFICATION_COLOR,Be.ACCENT_COLOR),color:No(Pe.NOTIFICATION_TEXT_COLOR_SELECTED,Pe.NOTIFICATION_TEXT_COLOR,Be.TEXT_ACCENT_COLOR,Be.TEXT_PRIMARY_COLOR)}},Ir={[`${Re.HOST} ${Re.ITEM_HOVER}:not(${Re.ITEM_SELECTED}) > ${Re.BADGE}`]:{backgroundColor:No(Pe.NOTIFICATION_COLOR_HOVER,Pe.NOTIFICATION_COLOR,Be.ACCENT_COLOR),color:No(Pe.NOTIFICATION_TEXT_COLOR_HOVER,Pe.NOTIFICATION_TEXT_COLOR,Be.TEXT_ACCENT_COLOR,Be.TEXT_PRIMARY_COLOR)}},br={[`${Re.HA_MENU_BUTTON}`]:!1},Sr={[Re.HOST_EXPANDED_NOT_MODAL]:{HaSidebarWidth:No(Pe.WIDTH,Pe.WIDTH_EXTENDED,"calc(256px + var(--safe-area-inset-left, 0px))")},[Re.HOST_MODAL]:{HaSidebarWidth:No(Pe.WIDTH,Pe.WIDTH_HIDDEN,"calc(256px + var(--safe-area-inset-left, 0px))")}},Nr={[`${Re.HOST} > ${Re.SIDEBAR_BOTTOM_ITEMS_CONTAINER}[${De.EMPTY}]`]:{display:"none"}};class vr{constructor(t,n){this._logger=n;const i=new j({shouldReject:this._logger.enabled});var o;i.addEventListener($.ON_LISTEN,(e=>{this._homeAssistant=e.detail.HOME_ASSISTANT,this._main=e.detail.HOME_ASSISTANT_MAIN,this._haDrawer=e.detail.HA_DRAWER,this._sidebar=e.detail.HA_SIDEBAR,this._partialPanelResolver=e.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(t)}),{once:!0}),i.addEventListener($.ON_PANEL_LOAD,this._panelLoaded.bind(this)),this._huiViewContainerObserver=new MutationObserver(this._watchHuiViewContainer.bind(this)),this._styleManager=new he({prefix:Ae,namespace:Ae,throwWarnings:!1}),this._items=[],this._logBookMessagesMap=new Map,this._logger.log("Wait for Home Assistant to be ready..."),(o=this._logger.enabled,e(void 0,void 0,void 0,(function*(){const e={shouldReject:o},t=yield to(ve.HOME_ASISTANT,e).toBeAdded(),n=yield to(t.shadowRoot,ve.HOME_ASSISTANT_MAIN,e).toBeAdded();yield to(n.shadowRoot,ve.HA_SIDEBAR,e).toBeAdded()}))).then((()=>{this._logger.log("Starting the plugin..."),i.listen()}))}_compileConfig(e){this._config=((e,t,n)=>new bo(n,e,t).config)(this._ha.hass.user,navigator.userAgent.toLowerCase(),e),this._logger.log("Compiled config",this._config)}_checkEmptyBottomList(){return e(this,void 0,void 0,(function*(){const e=yield this._sidebar.selector.$.query(Re.SIDEBAR_BOTTOM_ITEMS_CONTAINER).element,t=e.querySelectorAll(`:scope > ${Re.ITEM}`);Array.from(t).some((e=>""===e.style.display))?e.removeAttribute(De.EMPTY):e.setAttribute(De.EMPTY,we.EMPTY)}))}_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:Ae,message:e,domain:"person",entity_id:this._getUserEntity()}),this._logBookMessagesMap.delete(e)}),500))}_processDefaultPath(){const e=this._config.default_path;if(e){const t=So(e,this._config.partials);if(qe.test(t)){const e=this._renderer.renderTemplate(t.replace(qe,"$1"));this._executeDefaultPath(e)}else if(ze.test(t)){const e=this._subscribers.createJinjaTemplateSubscription(t,(t=>{this._executeDefaultPath(t),e.then((e=>{e()}))}))}else this._executeDefaultPath(t)}}_executeDefaultPath(e){uo(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=We[r];c!==l&&ho(this._ha,$e.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(ve.HA_PANEL_LOVELACE))||void 0===e?void 0:e.shadowRoot;return null===(t=null==i?void 0:i.querySelector(ve.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(br,e))}));s.addEventListener($e.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;Gi(r)?lo(t,[[Pe.WIDTH_EXTENDED,Ki(r.extended)],[Pe.WIDTH_HIDDEN,Ki(r.hidden)]]):lo(t,[[Pe.WIDTH,Ki(r)]]),this._subscribers.subscribeTemplateVariableChanges(this._config,n,Ge),this._subscribers.subscribeTemplateVariableChanges(this._config,i,je);this._sidebar.selector.$.query(Re.MENU_BUTTON).$.element.then((e=>{this._styleManager.addStyle([nr],e)})),this._styleManager.addStyle([rr],n.shadowRoot),this._styleManager.addStyle(Sr,t.shadowRoot),this._styleManager.addStyle([zo,Qo,Jo,Zo,er,tr,ir,or,sr,ar,dr,cr,hr,ur,_r,pr,Er,fr,Or,mr,Tr,Ar,gr,Ir,Nr,this._config.styles||""],o)})),yield no(this._sidebar,this._logger.enabled).then((()=>{Promise.all([this._sidebar.selector.$.query(Re.SIDEBAR_TOP_ITEMS_CONTAINER).element,this._sidebar.selector.$.query(Re.SIDEBAR_BOTTOM_ITEMS_CONTAINER).element,this._sidebar.selector.$.element]).then((e=>{const[t,n,i]=e;window.addEventListener($e.KEYDOWN,(e=>{if(e.key===xe.TAB){const t=ao();if(t){const n=t;n.nodeName===He.ITEM&&(n.classList.contains(Le.USER)&&!e.shiftKey||(e.preventDefault(),e.stopImmediatePropagation(),((e,t,n,i)=>{const o=t.querySelector(ve.HA_ICON_BUTTON),r=e.indexOf(n),s=e.length-1;r>=0&&(i&&r<s||!i&&r>0?ro(e,r,i):i||o.focus())})(this._items,i,n,!e.shiftKey)))}}}),!0),this._isAnalyticsOptionEnabled(Ke.SIDEBAR_ITEM_CLICKED)&&i.addEventListener($e.CLICK,(e=>{const t=e.target.closest(ve.ITEM);if(t){const e=Ji(t);this._logBookLog(`${Ke.SIDEBAR_ITEM_CLICKED}: ${e}`)}})),t.addEventListener($e.KEYDOWN,(e=>{e.key!==xe.ARROW_DOWN&&e.key!==xe.ARROW_UP||(e.preventDefault(),e.stopImmediatePropagation(),so(this._items,t,e.key===xe.ARROW_DOWN))}),!0),n.addEventListener($e.KEYDOWN,(e=>{e.key!==xe.ARROW_DOWN&&e.key!==xe.ARROW_UP||(e.preventDefault(),e.stopImmediatePropagation(),so(this._items,n,e.key===xe.ARROW_DOWN))}),!0)}))}))}))}_aplyItemRippleStyles(){return e(this,void 0,void 0,(function*(){const e=yield this._sidebar.selector.$.query(ve.ITEM).all;Array.from(e).forEach((e=>{const t=e.shadowRoot.querySelector(`${Ne.ANCHOR}, ${Ne.BUTTON}`).querySelector(ve.HA_RIPPLE).shadowRoot.querySelector(Re.SURFACE);this._styleManager.addStyle([lr],t)}))}))}_patchSidebarMethods(){const e=this._logger,t=this;e.log("Patching the sidebar shouldUpdate method..."),customElements.whenDefined(ve.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"))&&co(t._sidebar),i.call(this,n))}}))}_rearrange(){var t,n;(t=this._sidebar,n=this._logger,e(void 0,void 0,void 0,(function*(){yield no(t,n.enabled);const e=yield t.selector.$.query(Re.SIDEBAR_TOP_ITEMS_CONTAINER).element,i=yield t.selector.$.query(Re.SIDEBAR_BOTTOM_ITEMS_CONTAINER).element,o=yield io(e,n.enabled),r=yield io(i,n.enabled,!0);if(n.enabled){const e=oo(o),t=oo(r);n.log("Top Native sidebar items",e,{table:!0}),n.log("Bottom Native sidebar items",t,{table:!0})}return{topItemsContainer:e,bottomItemsContainer:i,topItems:o,bottomItems:r}}))).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 Map,h=this._items.length;n&&this._items.forEach((e=>{eo(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===Ee.HREF?e.href:Ji(e);if(!!o&&n===t||!o&&!!t&&!!t.toLowerCase().includes(s)){if(d.has(e)){const t=d.get(e);return this._logger.log(`item "${n}" matches with the element with text "${Ji(e)}" and href "${e.href}" but as this element was already matched by "${t}", this matching will be ignored`),!1}return this._logger.log(`item "${n}" matched the element with text "${Ji(e)}" and href "${e.href}"`),d.set(e,n),!0}return!1}));return a&&a.setAttribute(De.PROCESSED,we.TRUE),(r||a)&&e.push(Object.assign(Object.assign({},t),{element:a})),r||a||console.warn(`${Ae}: 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=zi(e);e.element=t,e.element.setAttribute(De.PROCESSED,we.TRUE),e.element.setAttribute(De.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(De.FIXED)===we.FALSE||!e.bottom&&e.element.getAttribute(De.FIXED)===we.TRUE)&&(e.bottom?l.appendChild(e.element):c.appendChild(e.element)),Fi(e.order)?(e.element.style.order=`${a}`,a++):(e.element.style.order=`${e.order}`,a=e.order+1),Fi(e.attributes)||this._subscribers.subscribeAttributes(e,e.attributes),e.divider&&e.element.setAttribute(De.WITH_DIVIDER,we.TRUE),e.name&&this._subscribers.subscribeName(e.element,e.name),e.icon&&this._subscribers.subscribeIcon(e.element,e.icon),e.info&&this._subscribers.subscribeInfo(e.element,e.info),e.notification&&this._subscribers.subscribeNotification(e.element,e.notification),Fi(e.hide)||this._subscribers.subscribeHide(e.element,e.hide,(()=>{this._checkEmptyBottomList()})),this._subscribers.subscribeTemplateVariableChanges(e,e.element,Ue),e.on_click&&e.element.addEventListener($e.CLICK,this._mouseClick.bind(this,e),!0)})),this._items.forEach((e=>{e.hasAttribute(De.PROCESSED)||(e.style.order=a>0?`${a}`:`${h}`)})),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._processSidebarMode(),co(this._sidebar)}))}_mouseClick(t,n){return e(this,void 0,void 0,(function*(){const{on_click:e,element:i}=t,o=e,r=i,s=Ji(r);"#"===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;qe.test(e)&&(n=a(So(e.replace(qe,"$1"),this._config.partials))),uo(n,t,"ignoring on_click.path property");break}case fe.CALL_SERVICE:{const{service:e,data:t={}}=o,n=e.match(Je),i=Object.entries(t).map((([e,t])=>{const n=So(`${t}`,this._config.partials);return qe.test(n)?[e,a(n.replace(qe,"$1"))]:[e,t]}));3===(null==n?void 0:n.length)?this._ha.hass.callService(n[1],n[2],Object.fromEntries(i)):console.warn(`${Ae} ignoring "${fe.CALL_SERVICE}" action in "${s}" item. The service parameter is malfomed.`);break}case fe.JAVASCRIPT:{const{code:e}=o;a(So(e,this._config.partials));break}case fe.OPEN_DIALOG:{const{type:e}=o;switch(e){case Oe.MORE_INFO:mo(this._ha,o.entity_id);break;case Oe.RESTART:Oo(this._ha,this._partialPanelResolver)}}}}))}_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(Ye.test(n)){const t=yield this._partialPanelResolver.selector.query(Re.EDIT_SIDEBAR_BUTTON).element;if(t){const n=ji(e)?e:this._config.sidebar_editable;if(!ji(n))return;!1===n?t.setAttribute(De.DISABLED,we.EMPTY):t.removeAttribute(De.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(ve.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(Le.ITEM_SELECTED,t),e.tabIndex=t?0:-1})),this._huiViewContainerObserver.disconnect();if(e.querySelector(ve.HA_PANEL_LOVELACE)){this._partialPanelResolver.selector.query(ve.HA_PANEL_LOVELACE).$.query(ve.HUI_ROOT).$.query(ve.HUI_VIEW_CONTAINER).element.then((e=>{e&&this._huiViewContainerObserver.observe(e,{subtree:!0,childList:!0})}))}this._isAnalyticsOptionEnabled(Ke.PANEL_VISITED)&&this._logBookLog(`${Ke.PANEL_VISITED}: ${t}`)}))}_watchHuiViewContainer(e){e.forEach((({addedNodes:e})=>{e.forEach((e=>{e instanceof Element&&e.localName===ve.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 re(this._ha).getRenderer().then((n=>{var i,o,r;this._logger.log("HomeAssistantJavaScriptTemplates instantiated"),this._compileConfig(t),this._renderer=n,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:uo,activateItem:t=>e(void 0,void 0,void 0,(function*(){yield new Promise((e=>setTimeout(e,5)));const e=yield r.selector.$.query(`${ve.ITEM}.${Le.ITEM_SELECTED}`).element;e.classList.remove(Le.ITEM_SELECTED),e.tabIndex=-1,t.classList.add(Le.ITEM_SELECTED),t.tabIndex=0}))})),(e=>({fireEvent:function(t,n,i){const o=ki(t)?e:t,r=ki(t)?t:ki(n)?n:null,s=Gi(n)?n:Gi(i)?i:void 0;if(null===r)throw new SyntaxError('fireEvent method needs a string as event "type"');ho(o,r,s)}}))(this._ha)),(e=>({checkConfig:()=>e.hass.callApi(me.POST,Ve.CHECK_CONFIG),renderTemplate:t=>e.hass.callApi(me.POST,Ve.TEMPLATE,{template:t}),callService:(t,n,i)=>e.hass.callService(t,n,i)}))(this._ha)),To(this._ha,this._partialPanelResolver)),(t=>{const n=e=>{const n=document.createElement(ve.HUI_TIMESTAMP_DISPLAY);return n._config=t.hass.config,n.__transform__config=t.hass.config,n._localize=t.hass.localize,n.__transform__localize=t.hass.localize,n._locale=t.hass.locale,n.__transform__locale=t.hass.locale,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 vo.locale,t(...n)})),r={formatDate:e=>{const t=n(e);return t.format=Te.DATE,i(t)},formatDateTime:e=>{const t=n(e);return t.format=Te.DATETIME,i(t)},formatTime:e=>{const t=/^\d+:\d+(:\d+)?$/.test(e.toString())?`1900-01-01T${e}`:e,o=n(t);return o.format=Te.TIME,i(o)},getRelativeTime:(e,t=!1)=>{const o=n(e);return o.format=Te.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=>{ho(e,$e.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 vo.locale,n(t)}))}})(this._ha)),this._renderer.refs=null!==(o=this._config.js_refs)&&void 0!==o?o:{},this._subscribers=new Yo(this._ha,this._config,this._renderer),this._logger.log("Executing plugin logic..."),this._subscribers.subscribeTitle(this._sidebar),this._subscribers.subscribeSideBarEdition(this._sidebar,(e=>{this._checkProfileEditableButton(e)})),this._processDefaultPath(),this._processSidebar(),this._rearrange()}))}))}}if(!window.CustomSidebar){const e=new Ro(new URLSearchParams(window.location.search).has("cs_debug"));Ro.logVersionToConsole(),e.log("Getting the config..."),Xo().then((t=>{e.log("Raw config",t),window.CustomSidebar=new vr(t,e)}))}}();