Skip to content

Instantly share code, notes, and snippets.

@elchininet
Last active January 9, 2025 23:34
Show Gist options
  • Save elchininet/9a2648ea0016d3194072712c745c5ad2 to your computer and use it in GitHub Desktop.
Save elchininet/9a2648ea0016d3194072712c745c5ad2 to your computer and use it in GitHub Desktop.
Compiled Kiosk-mode library with the latest code in master.
(function () {
'use strict';
var __assign = function() {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
function __awaiter(thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
}
function __generator(thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
}
function __spreadArray(to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
}
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
var e = new Error(message);
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
};
var e$3=function(e,r,t){var o;void 0===t&&(t={});var i=t.retries,n=void 0===i?10:i,s=t.delay,a=void 0===s?10:s,v=t.shouldReject,u=void 0===v||v,c=null!==(o=t.rejectMessage)&&void 0!==o?o:"Could not get the result after {{ retries }} retries";return new Promise((function(t,o){var i=0,s=function(){var v=e();r(v)?t(v):++i<n?setTimeout(s,a):u?o(new Error(c.replace(/\{\{\s*retries\s*\}\}/g,"".concat(n)))):t(v);};s();}))};
var t$1=function(){return t$1=Object.assign||function(n){for(var t,e=1,r=arguments.length;e<r;e++)for(var o in t=arguments[e])Object.prototype.hasOwnProperty.call(t,o)&&(n[o]=t[o]);return n},t$1.apply(this,arguments)};function e$2(n,t,e,r){return new(e||(e=Promise))((function(o,u){function i(n){try{l(r.next(n));}catch(n){u(n);}}function a(n){try{l(r.throw(n));}catch(n){u(n);}}function l(n){var t;n.done?o(n.value):(t=n.value,t instanceof e?t:new e((function(n){n(t);}))).then(i,a);}l((r=r.apply(n,[])).next());}))}function r$3(n,t){var e,r,o,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=a(0),i.throw=a(1),i.return=a(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(l){return function(a){if(e)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(u=0)),u;)try{if(e=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return u.label++,{value:a[1],done:!1};case 5:u.label++,r=a[1],a=[0];continue;case 7:a=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){u=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){u.label=a[1];break}if(6===a[0]&&u.label<o[1]){u.label=o[1],o=a;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(a);break}o[2]&&u.ops.pop(),u.trys.pop();continue}a=t.call(n,u);}catch(n){a=[6,n],r=0;}finally{e=o=0;}if(5&a[0])throw a[1];return {value:a[0]?a[1]:void 0,done:!0}}([a,l])}}}"function"==typeof SuppressedError&&SuppressedError;var o$3="$",u$2=":host",i$2="invalid selector",a$3=10,l$1=10,c$3=function(n){var t,e=n[0],r=n[1];return (t=e)&&(t instanceof Document||t instanceof Element||t instanceof ShadowRoot)&&"string"==typeof r};function s$2(n,t){return function(n){return n.split(",").map((function(n){return n.trim()}))}(n).map((function(n){var e=function(n){return n.split(o$3).map((function(n){return n.trim()}))}(n);return t(e)}))}function f$1(n,t){var e=t?" If you want to select a shadowRoot, use ".concat(t," instead."):"";return "".concat(n," cannot be used with a selector ending in a shadowRoot (").concat(o$3,").").concat(e)}function d$2(n){return n instanceof Promise?n:Promise.resolve(n)}function h$1(){return "You can not select a shadowRoot (".concat(o$3,") of the document.")}function y(){return "You can not select a shadowRoot (".concat(o$3,") of a shadowRoot.")}function v$1(n,t){for(var e,r,o=null,i=n.length,a=0;a<i;a++){if(0===a)if(n[a].length)o=t.querySelector(n[a]);else {if(t instanceof Document)throw new SyntaxError(h$1());if(t instanceof ShadowRoot)throw new SyntaxError(y());o=(null===(e=t.shadowRoot)||void 0===e?void 0:e.querySelector(n[++a]))||null;}else o=(null===(r=o.shadowRoot)||void 0===r?void 0:r.querySelector("".concat(u$2," ").concat(n[a])))||null;if(null===o)return null}return o}function p$2(n,t){var e,r=function(n,t,e){for(var r,o=0,u=t.length;o<u;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return n.concat(r||Array.prototype.slice.call(t))}([],n),o=r.pop();if(!r.length)return t.querySelectorAll(o);var i=v$1(r,t);return (null===(e=null==i?void 0:i.shadowRoot)||void 0===e?void 0:e.querySelectorAll("".concat(u$2," ").concat(o)))||null}function m$1(n,t){if(1===n.length&&!n[0].length){if(t instanceof Document)throw new SyntaxError(h$1());if(t instanceof ShadowRoot)throw new SyntaxError(y());return t.shadowRoot}var e=v$1(n,t);return (null==e?void 0:e.shadowRoot)||null}function w(n,t,e,r){for(var o=s$2(n,(function(n){if(!n[n.length-1].length)throw new SyntaxError(f$1(e,r));return n})),u=o.length,i=0;i<u;i++){var a=v$1(o[i],t);if(a)return a}return null}function g(n,t,e){for(var r=s$2(n,(function(n){if(!n[n.length-1].length)throw new SyntaxError(f$1(e));return n})),o=r.length,u=0;u<o;u++){var a=p$2(r[u],t);if(null==a?void 0:a.length)return a}return document.querySelectorAll(i$2)}function b(n,t,e,r){for(var u=s$2(n,(function(n){if(n.pop().length)throw new SyntaxError(function(n,t){return "".concat(n," must be used with a selector ending in a shadowRoot (").concat(o$3,"). If you don't want to select a shadowRoot, use ").concat(t," instead.")}(e,r));return n})),i=u.length,a=0;a<i;a++){var l=m$1(u[a],t);if(l)return l}return null}function S$1(t,o,u,i){return e$2(this,void 0,void 0,(function(){return r$3(this,(function(e){return [2,e$3((function(){return w(t,o,"asyncQuerySelector","asyncShadowRootQuerySelector")}),(function(n){return !!n}),{retries:u,delay:i,shouldReject:!1})]}))}))}function R$1(t,o,u,i){return e$2(this,void 0,void 0,(function(){return r$3(this,(function(e){return [2,e$3((function(){return g(t,o,"asyncQuerySelectorAll")}),(function(n){return !!n.length}),{retries:u,delay:i,shouldReject:!1})]}))}))}function P(t,o,u,i){return e$2(this,void 0,void 0,(function(){return r$3(this,(function(e){return [2,e$3((function(){return b(t,o,"asyncShadowRootQuerySelector","asyncQuerySelector")}),(function(n){return !!n}),{retries:u,delay:i,shouldReject:!1})]}))}))}var _$2=function(n,t){var e=n.querySelectorAll(t);if(e.length)return e;if(n instanceof Element&&n.shadowRoot){var r=_$2(n.shadowRoot,t);if(r.length)return r}for(var o=0,u=Array.from(n.querySelectorAll("*"));o<u.length;o++){var a=u[o],l=_$2(a,t);if(l.length)return l}return document.querySelectorAll(i$2)},q=function(t,e,r,o){return e$3((function(){return _$2(t,e)}),(function(n){return !!n.length}),{retries:r,delay:o,shouldReject:!1})};function L$1(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];return e$2(this,void 0,void 0,(function(){var t,e,o,u,i;return r$3(this,(function(r){switch(r.label){case 0:return c$3(n)?(t=n[0],e=n[1],o=n[2],[4,S$1(e,t,(null==o?void 0:o.retries)||a$3,(null==o?void 0:o.delay)||l$1)]):[3,2];case 1:case 3:return [2,r.sent()];case 2:return u=n[0],i=n[1],[4,S$1(u,document,(null==i?void 0:i.retries)||a$3,(null==i?void 0:i.delay)||l$1)]}}))}))}function Q(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];return e$2(this,void 0,void 0,(function(){var t,e,o,u,i;return r$3(this,(function(r){switch(r.label){case 0:return c$3(n)?(t=n[0],e=n[1],o=n[2],[4,R$1(e,t,(null==o?void 0:o.retries)||a$3,(null==o?void 0:o.delay)||l$1)]):[3,2];case 1:return [2,r.sent()];case 2:return u=n[0],i=n[1],[2,R$1(u,document,(null==i?void 0:i.retries)||a$3,(null==i?void 0:i.delay)||l$1)]}}))}))}function D$1(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];return e$2(this,void 0,void 0,(function(){var t,e,o,u,i;return r$3(this,(function(r){switch(r.label){case 0:return c$3(n)?(t=n[0],e=n[1],o=n[2],[4,P(e,t,(null==o?void 0:o.retries)||a$3,(null==o?void 0:o.delay)||l$1)]):[3,2];case 1:return [2,r.sent()];case 2:return u=n[0],i=n[1],[2,P(u,document,(null==i?void 0:i.retries)||a$3,(null==i?void 0:i.delay)||l$1)]}}))}))}var I$1=function(){function n(n,e){n instanceof Node||n instanceof Promise?(this._element=n,this._asyncParams=t$1({retries:a$3,delay:l$1},e||{})):(this._element=document,this._asyncParams=t$1({retries:a$3,delay:l$1},n||{}));}return Object.defineProperty(n.prototype,"element",{get:function(){return d$2(this._element).then((function(n){return n instanceof NodeList?n[0]||null:n}))},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"$",{get:function(){var t=this;return new n(d$2(this._element).then((function(n){return n instanceof Document||n instanceof ShadowRoot||null===n||n instanceof NodeList&&0===n.length?null:n instanceof NodeList?D$1(n[0],o$3,t._asyncParams):D$1(n,o$3,t._asyncParams)})),this._asyncParams)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"all",{get:function(){return d$2(this._element).then((function(n){return n instanceof NodeList?n:document.querySelectorAll(i$2)}))},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"asyncParams",{get:function(){return this._asyncParams},enumerable:!1,configurable:!0}),n.prototype.eq=function(n){return e$2(this,void 0,void 0,(function(){return r$3(this,(function(t){return [2,d$2(this._element).then((function(t){return t instanceof NodeList&&t[n]||null}))]}))}))},n.prototype.query=function(t){var e=this;return new n(d$2(this._element).then((function(n){return null===n||n instanceof NodeList&&0===n.length?null:n instanceof NodeList?Q(n[0],t,e._asyncParams):Q(n,t,e._asyncParams)})),this._asyncParams)},n.prototype.deepQuery=function(t){var e=this;return new n(d$2(this._element).then((function(n){return null===n||n instanceof NodeList&&0===n.length?null:n instanceof NodeList?Promise.race(Array.from(n).map((function(n){return q(n,t,e._asyncParams.retries,e._asyncParams.delay)}))):q(n,t,e._asyncParams.retries,e._asyncParams.delay)})),this._asyncParams)},n}();
var o$2=function(e,t){return o$2=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t;}||function(e,t){for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);},o$2(e,t)};var _$1=function(){return _$1=Object.assign||function(e){for(var t,o=1,_=arguments.length;o<_;o++)for(var n in t=arguments[o])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},_$1.apply(this,arguments)};"function"==typeof SuppressedError&&SuppressedError;var n$2,r$2,O,i$1,s$1,a$2,A,l,c$2,E,h,I,d$1,N,L,R,u$1="$",D={retries:100,delay:50,eventThreshold:450};!function(e){e.HOME_ASSISTANT="HOME_ASSISTANT",e.HOME_ASSISTANT_MAIN="HOME_ASSISTANT_MAIN",e.HA_DRAWER="HA_DRAWER",e.HA_SIDEBAR="HA_SIDEBAR",e.PARTIAL_PANEL_RESOLVER="PARTIAL_PANEL_RESOLVER";}(n$2||(n$2={})),function(e){e.HA_PANEL_LOVELACE="HA_PANEL_LOVELACE",e.HUI_ROOT="HUI_ROOT",e.HEADER="HEADER",e.HUI_VIEW="HUI_VIEW";}(r$2||(r$2={})),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";}(O||(O={})),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";}(i$1||(i$1={})),function(e){e.HOME_ASSISTANT="home-assistant",e.HOME_ASSISTANT_MAIN="home-assistant-main",e.HA_DRAWER="ha-drawer",e.HA_SIDEBAR="ha-sidebar",e.PARTIAL_PANEL_RESOLVER="partial-panel-resolver",e.HA_PANEL_LOVELACE="ha-panel-lovelace",e.HUI_ROOT="hui-root",e.HEADER=".header",e.HUI_VIEW="hui-view",e.HA_MORE_INFO_DIALOG="ha-more-info-dialog",e.HA_DIALOG="ha-dialog",e.HA_DIALOG_CONTENT=".content",e.HA_MORE_INFO_DIALOG_INFO="ha-more-info-info",e.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK="ha-more-info-history-and-logbook",e.HA_DIALOG_MORE_INFO_SETTINGS="ha-more-info-settings";}(R||(R={}));var v=((s$1={})[n$2.HOME_ASSISTANT]={selector:R.HOME_ASSISTANT,children:{shadowRoot:{selector:u$1,children:(a$2={},a$2[n$2.HOME_ASSISTANT_MAIN]={selector:R.HOME_ASSISTANT_MAIN,children:{shadowRoot:{selector:u$1,children:(A={},A[n$2.HA_DRAWER]={selector:R.HA_DRAWER,children:(l={},l[n$2.HA_SIDEBAR]={selector:R.HA_SIDEBAR,children:{shadowRoot:{selector:u$1}}},l[n$2.PARTIAL_PANEL_RESOLVER]={selector:R.PARTIAL_PANEL_RESOLVER},l)},A)}}},a$2)}}},s$1),H=((c$2={})[r$2.HA_PANEL_LOVELACE]={selector:R.HA_PANEL_LOVELACE,children:{shadowRoot:{selector:u$1,children:(E={},E[r$2.HUI_ROOT]={selector:R.HUI_ROOT,children:{shadowRoot:{selector:u$1,children:(h={},h[r$2.HEADER]={selector:R.HEADER},h[r$2.HUI_VIEW]={selector:R.HUI_VIEW},h)}}},E)}}},c$2),p$1={shadowRoot:{selector:u$1,children:(I={},I[O.HA_MORE_INFO_DIALOG]={selector:R.HA_MORE_INFO_DIALOG,children:{shadowRoot:{selector:u$1,children:(d$1={},d$1[O.HA_DIALOG]={selector:R.HA_DIALOG,children:(N={},N[O.HA_DIALOG_CONTENT]={selector:R.HA_DIALOG_CONTENT,children:(L={},L[O.HA_MORE_INFO_DIALOG_INFO]={selector:R.HA_MORE_INFO_DIALOG_INFO},L[O.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK]={selector:R.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK},L[O.HA_DIALOG_MORE_INFO_SETTINGS]={selector:R.HA_DIALOG_MORE_INFO_SETTINGS},L)},N)},d$1)}}},I)}},f=function(o,n,r,O){return void 0===r&&(r=null),void 0===O&&(O=!1),Object.entries(n||{}).reduce((function(n,i){var s=i[0],a=i[1];if(a.selector===u$1&&r)return a.children?_$1(_$1({},n),f(o,a.children,r,!0)):n;var A=r?r.then((function(t){return t?L$1(t,(_=a.selector,O?"$ "+_:_),o):null;var _;})):L$1(a.selector,o);return n[s]={element:A,children:f(o,a.children,A),selector:new I$1(A,o)},n}),{})},T=function(e,t){for(var o=0,_=Object.entries(t);o<_.length;o++){var n=_[o];if(n[0]===e)return n[1];var r=T(e,n[1].children);if(r)return r}},S=function(e,t){return Object.keys(e).reduce((function(e,o){var n=T(o,t);n.children;var r=function(e,t){var o={};for(var _ in e)Object.prototype.hasOwnProperty.call(e,_)&&t.indexOf(_)<0&&(o[_]=e[_]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(_=Object.getOwnPropertySymbols(e);n<_.length;n++)t.indexOf(_[n])<0&&Object.prototype.propertyIsEnumerable.call(e,_[n])&&(o[_[n]]=e[_[n]]);}return o}(n,["children"]);return e[o]=_$1({},r),e}),{})},G=function(){function e(){this.delegate=document.createDocumentFragment();}return e.prototype.addEventListener=function(){for(var e,t=[],o=0;o<arguments.length;o++)t[o]=arguments[o];(e=this.delegate).addEventListener.apply(e,t);},e.prototype.dispatchEvent=function(){for(var e,t=[],o=0;o<arguments.length;o++)t[o]=arguments[o];return (e=this.delegate).dispatchEvent.apply(e,t)},e.prototype.removeEventListener=function(){for(var e,t=[],o=0;o<arguments.length;o++)t[o]=arguments[o];return (e=this.delegate).removeEventListener.apply(e,t)},e}(),m=function(e){function t(t){void 0===t&&(t={});var o=e.call(this)||this;return o._config=_$1(_$1({},D),t),o._timestaps={},o}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function _(){this.constructor=e;}o$2(e,t),e.prototype=null===t?Object.create(t):(_.prototype=t.prototype,new _);}(t,e),t.prototype._dispatchEvent=function(e,t){var o=Date.now();o-this._timestaps[e]<this._config.eventThreshold||(this._timestaps[e]=o,this.dispatchEvent(new CustomEvent(e,{detail:t})));},t.prototype._updateDialogElements=function(e){var t,o=this;void 0===e&&(e=O.HA_MORE_INFO_DIALOG_INFO),this._dialogTree=f(this._config,p$1,this._haRootElements.HOME_ASSISTANT.element);var _=S(O,this._dialogTree);_.HA_DIALOG_CONTENT.element.then((function(e){o._dialogsContentObserver.disconnect(),o._dialogsContentObserver.observe(e,{childList:!0});})),this._haDialogElements=function(e,t){return [O.HA_MORE_INFO_DIALOG,O.HA_DIALOG,O.HA_DIALOG_CONTENT,t].reduce((function(t,o){return t[o]=e[o],t}),{})}(_,e);var n=((t={})[O.HA_MORE_INFO_DIALOG_INFO]=i$1.ON_MORE_INFO_DIALOG_OPEN,t[O.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK]=i$1.ON_HISTORY_AND_LOGBOOK_DIALOG_OPEN,t[O.HA_DIALOG_MORE_INFO_SETTINGS]=i$1.ON_SETTINGS_DIALOG_OPEN,t);this._dispatchEvent(n[e],this._haDialogElements);},t.prototype._updateRootElements=function(){var e=this;this._homeAssistantRootTree=f(this._config,v),this._haRootElements=S(n$2,this._homeAssistantRootTree),this._haRootElements[n$2.HOME_ASSISTANT].selector.$.element.then((function(t){e._dialogsObserver.disconnect(),e._dialogsObserver.observe(t,{childList:!0});})),this._haRootElements[n$2.PARTIAL_PANEL_RESOLVER].element.then((function(t){e._panelResolverObserver.disconnect(),t&&e._panelResolverObserver.observe(t,{subtree:!0,childList:!0});})),this._dispatchEvent(i$1.ON_LISTEN,this._haRootElements),this._dispatchEvent(i$1.ON_PANEL_LOAD,this._haRootElements);},t.prototype._updateLovelaceElements=function(){var e=this;this._homeAssistantResolverTree=f(this._config,H,this._haRootElements[n$2.HA_DRAWER].element),this._haResolverElements=S(r$2,this._homeAssistantResolverTree),this._haResolverElements[r$2.HA_PANEL_LOVELACE].element.then((function(t){e._lovelaceObserver.disconnect(),t&&(e._lovelaceObserver.observe(t.shadowRoot,{childList:!0}),e._dispatchEvent(i$1.ON_LOVELACE_PANEL_LOAD,_$1(_$1({},e._haRootElements),e._haResolverElements)));}));},t.prototype._watchDialogs=function(e){var t=this;e.forEach((function(e){e.addedNodes.forEach((function(e){e.localName===R.HA_MORE_INFO_DIALOG&&t._updateDialogElements();}));}));},t.prototype._watchDialogsContent=function(e){var t=this;e.forEach((function(e){e.addedNodes.forEach((function(e){var o,_=((o={})[R.HA_MORE_INFO_DIALOG_INFO]=O.HA_MORE_INFO_DIALOG_INFO,o[R.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK]=O.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK,o[R.HA_DIALOG_MORE_INFO_SETTINGS]=O.HA_DIALOG_MORE_INFO_SETTINGS,o);if(e.localName&&e.localName in _){var n=e.localName;t._updateDialogElements(_[n]);}}));}));},t.prototype._watchDashboards=function(e){var t=this;e.forEach((function(e){e.addedNodes.forEach((function(e){t._dispatchEvent(i$1.ON_PANEL_LOAD,t._haRootElements),e.localName===R.HA_PANEL_LOVELACE&&t._updateLovelaceElements();}));}));},t.prototype._watchLovelace=function(e){var t=this;e.forEach((function(e){e.addedNodes.forEach((function(e){e.localName===R.HUI_ROOT&&t._updateLovelaceElements();}));}));},t.prototype.listen=function(){this._watchDialogsBinded=this._watchDialogs.bind(this),this._watchDialogsContentBinded=this._watchDialogsContent.bind(this),this._watchDashboardsBinded=this._watchDashboards.bind(this),this._watchLovelaceBinded=this._watchLovelace.bind(this),this._dialogsObserver=new MutationObserver(this._watchDialogsBinded),this._dialogsContentObserver=new MutationObserver(this._watchDialogsContentBinded),this._panelResolverObserver=new MutationObserver(this._watchDashboardsBinded),this._lovelaceObserver=new MutationObserver(this._watchLovelaceBinded),this._updateRootElements(),this._updateLovelaceElements();},t.prototype.addEventListener=function(t,o,_){e.prototype.addEventListener.call(this,t,o,_);},t}(G);
var n$1=/([A-Z])([a-z0-9_-]+)/g,t=function(t){return Object.entries(t).map((function(t){var e=t[0],o=t[1];return "".concat(function(t){return t.replace(n$1,(function(n,t,e,o){var r=t.toLocaleLowerCase();return o?"-".concat(r).concat(e):"--".concat(r).concat(e)}))}(e),":").concat(o)})).join(";")+";"},e$1=function(n){return (Array.isArray(n)?n:[n]).map((function(n){return "string"==typeof n?n:Object.entries(n).map((function(n){var e=n[0],o=n[1];return !1===o?"".concat(e,"{display: none !important}"):"".concat(e,"{").concat(t(o),"}")})).join("")})).join("")},o$1=function(n,t){return "".concat(t,"_").concat(n)},r$1=function(n){return n instanceof ShadowRoot?n.host.localName:n.localName},a$1=function(n,t){var e=o$1(r$1(n),t);return n.querySelector("#".concat(e))},c$1=function(){function n(n){var t,e,o;void 0===n&&(n={}),this._prefix=null!==(t=n.prefix)&&void 0!==t?t:"ha-styles-manager",this._namespace=null!==(e=n.namespace)&&void 0!==e?e:"home-assistant-styles-manager",this._throwWarnings=null===(o=n.throwWarnings)||void 0===o||o;}return n.prototype.getStyleElement=function(n){return a$1(n,this._prefix)},n.prototype.addStyle=function(n,t){!function(n,t,c,i,s){if(t){var l=a$1(t,c);if(!l){var u=o$1(r$1(t),c);(l=document.createElement("style")).setAttribute("id",u),t.appendChild(l);}l.innerHTML="string"==typeof n?n:e$1(n);}else s&&console.warn("".concat(i,': no element has been provided calling "addStyle"'));}(n,t,this._prefix,this._namespace,this._throwWarnings);},n.prototype.removeStyle=function(n){!function(n,t,e,o){if(n){var r=a$1(n,t);r?r.remove():o&&console.warn("".concat(e,': no style to remove calling "removeStyle"'));}else o&&console.warn("".concat(e,': no element has been provided calling "removeStyle"'));}(n,this._prefix,this._namespace,this._throwWarnings);},n}();
function e(t,e,i){if(2===arguments.length)for(var n,s=0,r=e.length;s<r;s++)!n&&s in e||(n||(n=Array.prototype.slice.call(e,0,s)),n[s]=e[s]);return t.concat(n||Array.prototype.slice.call(e))}"function"==typeof SuppressedError&&SuppressedError;var i,n,s,r,a="[home-assistant-javascript-templates]",o=/^([a-z_]+)\.(\w+)$/;!function(t){t.UNKNOWN="unknown",t.UNAVAILABLE="unavailable";}(i||(i={})),function(t){t.AREA_ID="area_id",t.NAME="name";}(n||(n={})),function(t){t.PANEL_URL="panel_url";}(s||(s={})),function(t){t.LOCATION_CHANGED="location-changed",t.POPSTATE="popstate",t.SUBSCRIBE_EVENTS="subscribe_events",t.STATE_CHANGE_EVENT="state_changed";}(r||(r={}));var c=function(t){return t.reduce((function(t,e){var i=e[0],n=e[1];return t[i.replace(o,"$2")]=n,t}),{})},u=function(t){return t.includes(".")};function d(t,e){var r=function(){return Object.entries(t.hass.areas)},o=function(){return Object.entries(t.hass.entities)},d=new Set,_=function(t,i){e&&console.warn("".concat(t," ").concat(i," used in a JavaScript template doesn't exist"));},p=function(t){return _("Entity",t)},h=function(t){return _("Domain",t)},v=function(e){t.hass.states[e]?d.add(e):p(e);};return {get hass(){return t.hass},states:new Proxy((function(e){var i;if(u(e))return v(e),null===(i=t.hass.states[e])||void 0===i?void 0:i.state;throw SyntaxError("".concat(a,": states method cannot be used with a domain, use it as an object instead."))}),{get:function(e,i){if(u(i))return v(i),t.hass.states[i];var n=Object.entries(t.hass.states).filter((function(t){return t[0].startsWith(i)}));return n.length||h(i),new Proxy(c(n),{get:function(t,e){return v("".concat(i,".").concat(e)),t[e]}})}}),is_state:function(e,i){var n;return v(e),(null===(n=t.hass.states[e])||void 0===n?void 0:n.state)===i},state_attr:function(e,i){var n,s;return v(e),null===(s=null===(n=t.hass.states[e])||void 0===n?void 0:n.attributes)||void 0===s?void 0:s[i]},is_state_attr:function(t,e,i){return this.state_attr(t,e)===i},has_value:function(t){return this.states(t)?!(this.is_state(t,i.UNKNOWN)||this.is_state(t,i.UNAVAILABLE)):(p(t),!1)},entities:new Proxy((function(e){if(void 0===e)return t.hass.entities;if(u(e))return v(e),t.hass.entities[e];var i=o().filter((function(t){return t[0].startsWith(e)}));return i.length||h(e),new Proxy(c(i),{get:function(t,i){return v("".concat(e,".").concat(i)),t[i]}})}),{get:function(t,e){return t(e)}}),entity_prop:function(e,i){var n;return v(e),null===(n=t.hass.entities[e])||void 0===n?void 0:n[i]},is_entity_prop:function(t,e,i){return this.entity_prop(t,e)===i},devices:new Proxy((function(e){if(void 0===e)return t.hass.devices;if(u(e))throw SyntaxError("".concat(a,": devices method cannot be used with an entity id, you should use a device id instead."));return t.hass.devices[e]}),{get:function(e,i){if(u(i))throw SyntaxError("".concat(a,": devices cannot be accesed using an entity id, you should use a device id instead."));return t.hass.devices[i]}}),device_attr:function(e,i){var n;return null===(n=t.hass.devices[e])||void 0===n?void 0:n[i]},is_device_attr:function(t,e,i){return this.device_attr(t,e)===i},device_id:function(e){var i;return v(e),null===(i=t.hass.entities[e])||void 0===i?void 0:i.device_id},areas:function(){return r().map((function(t){return t[1].area_id}))},area_id:function(e){var i,s;if(e in t.hass.devices)return this.device_attr(e,n.AREA_ID);var a=null===(i=t.hass.entities[e])||void 0===i?void 0:i.device_id;if(a)return this.device_attr(a,n.AREA_ID);var o=r().find((function(t){return t[1].name===e}));return null===(s=null==o?void 0:o[1])||void 0===s?void 0:s.area_id},area_name:function(e){var i,s,a;e in t.hass.devices&&(a=this.device_attr(e,n.AREA_ID));var o=null===(i=t.hass.entities[e])||void 0===i?void 0:i.device_id;o&&(a=this.device_attr(o,n.AREA_ID));var c=r().find((function(t){var i=t[1];return i.area_id===e||i.area_id===a}));return null===(s=null==c?void 0:c[1])||void 0===s?void 0:s.name},area_entities:function(t){var e=r().find((function(e){var i=e[1];return i.area_id===t||i.name===t}));return e?o().filter((function(t){return t[1].area_id===e[1].area_id})).map((function(t){return t[0]})):[]},area_devices:function(e){var i=r().find((function(t){var i=t[1];return i.area_id===e||i.name===e}));return i?Object.entries(t.hass.devices).filter((function(t){return t[1].area_id===i[1].area_id})).map((function(t){return t[1].id})):[]},get user_name(){return t.hass.user.name},get user_is_admin(){return t.hass.user.is_admin},get user_is_owner(){return t.hass.user.is_owner},get user_agent(){return window.navigator.userAgent},get tracked(){return d},cleanTracked:function(){d.clear();},clientSideProxy:new Proxy({},{get:function(t,i){if(i===s.PANEL_URL)return n=s.PANEL_URL,d.add(n),location.pathname;var n;e&&console.warn("clientSideProxy should only be used to access these variables: ".concat(Object.values(s).join(", ")));}})}}var _=function(){function t(t,e){var i=e.throwErrors,n=void 0!==i&&i,r=e.throwWarnings,a=void 0===r||r,o=e.variables,c=void 0===o?{}:o,u=e.autoReturn,_=void 0===u||u;this._throwErrors=n,this._throwWarnings=a,this._variables=c,this._autoReturn=_,this._subscriptions=new Map,this._clientSideEntitiesRegExp=new RegExp("(^|[ \\?(+:\\{\\[><])(".concat(Object.values(s).join("|"),")($|[ \\?)+:\\}\\]><.])"),"gm"),this._scopped=d(t,a),this._watchForPanelUrlChange(),this._watchForEntitiesChange();}return t.prototype._executeRenderingFunctions=function(t){var e=this;this._subscriptions.get(t).forEach((function(t,i){t.forEach((function(t){e.trackTemplate(i,t);}));}));},t.prototype._watchForPanelUrlChange=function(){var t=this;window.addEventListener(r.LOCATION_CHANGED,(function(e){t._panelUrlWatchCallback();})),window.addEventListener(r.POPSTATE,(function(){t._panelUrlWatchCallback();}));},t.prototype._panelUrlWatchCallback=function(){this._subscriptions.has(s.PANEL_URL)&&this._executeRenderingFunctions(s.PANEL_URL);},t.prototype._watchForEntitiesChange=function(){var t=this;window.hassConnection.then((function(e){e.conn.subscribeMessage((function(e){return t._entityWatchCallback(e)}),{type:r.SUBSCRIBE_EVENTS,event_type:r.STATE_CHANGE_EVENT});}));},t.prototype._entityWatchCallback=function(t){if(this._subscriptions.size){var e=t.data.entity_id;this._subscriptions.has(e)&&this._executeRenderingFunctions(e);}},t.prototype._storeTracked=function(t,e){var i=this;this._scopped.tracked.forEach((function(n){if(i._subscriptions.has(n)){var s=i._subscriptions.get(n);if(s.has(t)){var r=s.get(t);r.has(e)||r.add(e);}else s.set(t,new Set([e]));}else i._subscriptions.set(n,new Map([[t,new Set([e])]]));}));},t.prototype._untrackTemplate=function(t,e){var i=this;this._subscriptions.forEach((function(n,s){if(n.has(t)){var r=n.get(t);r.has(e)&&r.delete(e),0===r.size&&(n.delete(t),0===n.size&&i._subscriptions.delete(s));}}));},t.prototype.renderTemplate=function(t){try{var i=new Map(Object.entries(this._variables)),n=t.trim().replace(this._clientSideEntitiesRegExp,"$1clientSide.$2$3"),s=n.includes("return")||!this._autoReturn?n:"return ".concat(n);return (new(Function.bind.apply(Function,e(e([void 0,"hass","states","is_state","state_attr","is_state_attr","has_value","entities","entity_prop","is_entity_prop","devices","device_attr","is_device_attr","device_id","areas","area_id","area_name","area_entities","area_devices","user_name","user_is_admin","user_is_owner","user_agent","clientSide"],Array.from(i.keys()),!1),["".concat('"use strict";'," ").concat(s)],!1)))).apply(void 0,e([this._scopped.hass,this._scopped.states,this._scopped.is_state.bind(this._scopped),this._scopped.state_attr.bind(this._scopped),this._scopped.is_state_attr.bind(this._scopped),this._scopped.has_value.bind(this._scopped),this._scopped.entities,this._scopped.entity_prop,this._scopped.is_entity_prop.bind(this._scopped),this._scopped.devices,this._scopped.device_attr.bind(this._scopped),this._scopped.is_device_attr.bind(this._scopped),this._scopped.device_id.bind(this._scopped),this._scopped.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],Array.from(i.values()),!1))}catch(t){if(this._throwErrors)throw t;return void(this._throwWarnings&&console.warn(t))}},t.prototype.trackTemplate=function(t,e){var i=this;this._scopped.cleanTracked();var n=this.renderTemplate(t);return this._storeTracked(t,e),e(n),function(){return i._untrackTemplate(t,e)}},t.prototype.cleanTracked=function(t){t?this._subscriptions.has(t)&&this._subscriptions.delete(t):this._subscriptions.clear();},Object.defineProperty(t.prototype,"variables",{get:function(){return this._variables},set:function(t){this._variables=t;},enumerable:!1,configurable:!0}),t}(),p=function(){function e(e,i){void 0===i&&(i={}),this._renderer=e$3((function(){return e.hass}),(function(t){return !!(t&&t.areas&&t.devices&&t.entities&&t.states&&t.user)}),{retries:100,delay:50,rejectMessage:"The provided element doesn't contain a proper or initialised hass object"}).then((function(){return new _(e,i)}));}return e.prototype.getRenderer=function(){return this._renderer},e}();
var _a$1;
var NAMESPACE = 'kiosk-mode';
var STYLES_PREFIX = 'kiosk_mode';
var NON_CRITICAL_WARNING = '[ Non critial warning ]';
var OPTION;
(function (OPTION) {
OPTION["KIOSK"] = "kiosk";
OPTION["HIDE_SIDEBAR"] = "hide_sidebar";
OPTION["HIDE_HEADER"] = "hide_header";
OPTION["HIDE_OVERFLOW"] = "hide_overflow";
OPTION["HIDE_MENU_BUTTON"] = "hide_menubutton";
OPTION["HIDE_ACCOUNT"] = "hide_account";
OPTION["HIDE_NOTIFICATIONS"] = "hide_notifications";
OPTION["HIDE_SEARCH"] = "hide_search";
OPTION["HIDE_ASSISTANT"] = "hide_assistant";
OPTION["HIDE_REFRESH"] = "hide_refresh";
OPTION["HIDE_UNUSED_ENTITIES"] = "hide_unused_entities";
OPTION["HIDE_RELOAD_RESOURCES"] = "hide_reload_resources";
OPTION["HIDE_EDIT_DASHBOARD"] = "hide_edit_dashboard";
OPTION["HIDE_DIALOG_HEADER_ACTION_ITEMS"] = "hide_dialog_header_action_items";
OPTION["HIDE_DIALOG_HEADER_HISTORY"] = "hide_dialog_header_history";
OPTION["HIDE_DIALOG_HEADER_SETTINGS"] = "hide_dialog_header_settings";
OPTION["HIDE_DIALOG_HEADER_OVERFLOW"] = "hide_dialog_header_overflow";
OPTION["HIDE_DIALOG_HISTORY"] = "hide_dialog_history";
OPTION["HIDE_DIALOG_LOGBOOK"] = "hide_dialog_logbook";
OPTION["HIDE_DIALOG_ATTRIBUTES"] = "hide_dialog_attributes";
OPTION["HIDE_DIALOG_MEDIA_ACTIONS"] = "hide_dialog_media_actions";
OPTION["HIDE_DIALOG_UPDATE_ACTIONS"] = "hide_dialog_update_actions";
OPTION["HIDE_DIALOG_CAMERA_ACTIONS"] = "hide_dialog_camera_actions";
OPTION["HIDE_DIALOG_CLIMATE_ACTIONS"] = "hide_dialog_climate_actions";
OPTION["HIDE_DIALOG_CLIMATE_TEMPERATURE_ACTIONS"] = "hide_dialog_climate_temperature_actions";
OPTION["HIDE_DIALOG_CLIMATE_SETTINGS_ACTIONS"] = "hide_dialog_climate_settings_actions";
OPTION["HIDE_DIALOG_TIMER_ACTIONS"] = "hide_dialog_timer_actions";
OPTION["HIDE_DIALOG_LIGHT_ACTIONS"] = "hide_dialog_light_actions";
OPTION["HIDE_DIALOG_LIGHT_CONTROL_ACTIONS"] = "hide_dialog_light_control_actions";
OPTION["HIDE_DIALOG_LIGHT_COLOR_ACTIONS"] = "hide_dialog_light_color_actions";
OPTION["HIDE_DIALOG_LIGHT_SETTINGS_ACTIONS"] = "hide_dialog_light_settings_actions";
OPTION["HIDE_DIALOG_HISTORY_SHOW_MORE"] = "hide_dialog_history_show_more";
OPTION["HIDE_DIALOG_LOGBOOK_SHOW_MORE"] = "hide_dialog_logbook_show_more";
OPTION["BLOCK_OVERFLOW"] = "block_overflow";
OPTION["BLOCK_MOUSE"] = "block_mouse";
OPTION["BLOCK_CONTEXT_MENU"] = "block_context_menu";
})(OPTION || (OPTION = {}));
var CONDITIONAL_OPTION;
(function (CONDITIONAL_OPTION) {
CONDITIONAL_OPTION["IGNORE_MOBILE_SETTINGS"] = "ignore_mobile_settings";
CONDITIONAL_OPTION["IGNORE_DISABLE_KM"] = "ignore_disable_km";
})(CONDITIONAL_OPTION || (CONDITIONAL_OPTION = {}));
var DEBUG_CONFIG_OPTION;
(function (DEBUG_CONFIG_OPTION) {
DEBUG_CONFIG_OPTION["DEBUG"] = "debug";
DEBUG_CONFIG_OPTION["DEBUG_TEMPLATE"] = "debug_template";
})(DEBUG_CONFIG_OPTION || (DEBUG_CONFIG_OPTION = {}));
var SPECIAL_QUERY_PARAMS;
(function (SPECIAL_QUERY_PARAMS) {
SPECIAL_QUERY_PARAMS["CACHE"] = "cache";
SPECIAL_QUERY_PARAMS["CLEAR_CACHE"] = "clear_km_cache";
SPECIAL_QUERY_PARAMS["DISABLE_KIOSK_MODE"] = "disable_km";
})(SPECIAL_QUERY_PARAMS || (SPECIAL_QUERY_PARAMS = {}));
var UI_PREFIX = 'ui';
var COMMON_PREFIX = "".concat(UI_PREFIX, ".common");
var PANEL_PREFIX = "".concat(UI_PREFIX, ".panel");
var LOVELACE_PREFIX = "".concat(PANEL_PREFIX, ".lovelace");
var MENU_PREFIX = "".concat(LOVELACE_PREFIX, ".menu");
var DIALOGS_PREFIX = "".concat(UI_PREFIX, ".dialogs.more_info_control");
var MENU;
(function (MENU) {
MENU["SEARCH"] = "SEARCH";
MENU["ASSIST"] = "ASSIST";
MENU["REFRESH"] = "REFRESH";
MENU["UNUSED_ENTITIES"] = "UNUSED_ENTITIES";
MENU["RELOAD_RESOURCES"] = "RELOAD_RESOURCES";
MENU["EDIT_DASHBOARD"] = "EDIT_DASHBOARD";
MENU["DIALOG_DISMISS"] = "DIALOG_DISMISS";
MENU["DIALOG_HISTORY"] = "DIALOG_HISTORY";
MENU["DIALOG_SETTINGS"] = "DIALOG_SETTINGS";
})(MENU || (MENU = {}));
var MENU_REFERENCES = Object.freeze((_a$1 = {},
_a$1[MENU.SEARCH] = "".concat(MENU_PREFIX, ".search"),
_a$1[MENU.ASSIST] = "".concat(MENU_PREFIX, ".assist"),
_a$1[MENU.REFRESH] = "".concat(COMMON_PREFIX, ".refresh"),
_a$1[MENU.UNUSED_ENTITIES] = "".concat(LOVELACE_PREFIX, ".unused_entities.title"),
_a$1[MENU.RELOAD_RESOURCES] = "".concat(MENU_PREFIX, ".reload_resources"),
_a$1[MENU.EDIT_DASHBOARD] = "".concat(MENU_PREFIX, ".configure_ui"),
_a$1[MENU.DIALOG_HISTORY] = "".concat(DIALOGS_PREFIX, ".history"),
_a$1[MENU.DIALOG_SETTINGS] = "".concat(DIALOGS_PREFIX, ".settings"),
_a$1[MENU.DIALOG_DISMISS] = "".concat(DIALOGS_PREFIX, ".dismiss"),
_a$1));
var ELEMENT;
(function (ELEMENT) {
ELEMENT["HOME_ASSISTANT"] = "home-assistant";
ELEMENT["HA_PANEL_LOVELACE"] = "ha-panel-lovelace";
ELEMENT["HUI_VIEW"] = "hui-view";
ELEMENT["MENU_ITEM"] = "ha-icon-button";
ELEMENT["MENU_ITEM_ICON"] = "mwc-icon-button";
ELEMENT["BUTTON_MENU"] = "ha-button-menu";
ELEMENT["OVERLAY_MENU_ITEM"] = "mwc-list-item";
ELEMENT["TOOLBAR"] = ".toolbar";
ELEMENT["ACTION_ITEMS"] = ".action-items";
ELEMENT["HA_MORE_INFO_DIALOG"] = "ha-more-info-dialog";
ELEMENT["HA_DIALOG"] = "ha-dialog";
ELEMENT["HA_DIALOG_HEADER"] = "ha-dialog-header";
ELEMENT["HA_DIALOG_MORE_INFO"] = "ha-more-info-info";
ELEMENT["HA_DIALOG_HISTORY"] = "ha-more-info-history";
ELEMENT["HA_DIALOG_LOGBOOK"] = "ha-more-info-logbook";
ELEMENT["HA_DIALOG_MORE_INFO_CONTENT"] = "more-info-content";
ELEMENT["HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK"] = "ha-more-info-history-and-logbook";
ELEMENT["HA_DIALOG_DEFAULT"] = "more-info-default";
ELEMENT["HA_DIALOG_TIMER"] = "more-info-timer";
ELEMENT["HA_DIALOG_VACUUM"] = "more-info-vacuum";
ELEMENT["HA_DIALOG_CAMERA"] = "more-info-camera";
ELEMENT["HA_DIALOG_SIREN"] = "more-info-siren";
ELEMENT["HA_DIALOG_PERSON"] = "more-info-person";
ELEMENT["HA_DIALOG_MEDIA_PLAYER"] = "more-info-media_player";
ELEMENT["HA_DIALOG_LIGHT"] = "more-info-light";
ELEMENT["HA_DIALOG_UPDATE"] = "more-info-update";
ELEMENT["HA_DIALOG_LOCK"] = "more-info-lock";
ELEMENT["HA_DIALOG_CLIMATE"] = "more-info-climate";
ELEMENT["HA_DIALOG_CLIMATE_CONTROL_SELECT"] = "ha-more-info-control-select-container";
ELEMENT["HA_STATE_CONTROL_CLIMATE_TEMPERATURE"] = "ha-state-control-climate-temperature";
ELEMENT["HA_DIALOG_CLIMATE_TEMPERATURE_BUTTONS"] = ".buttons";
ELEMENT["HA_DIALOG_CLIMATE_CIRCULAR_SLIDER"] = "ha-control-circular-slider";
ELEMENT["HA_DIALOG_CLIMATE_CIRCULAR_SLIDER_INTERACTION"] = "#interaction";
ELEMENT["HA_DIALOG_CLIMATE_CIRCULAR_SLIDER_INTERACTION_SLIDER"] = "path[role=\"slider\"]";
ELEMENT["HA_DIALOG_CLIMATE_CIRCULAR_SLIDER_INTERACTION_TARGET"] = ".target";
ELEMENT["HA_DIALOG_CLIMATE_CIRCULAR_SLIDER_INTERACTION_TARGET_BORDER"] = ".target-border";
ELEMENT["HA_DIALOG_LIGHT_BRIGHTNESS"] = "ha-state-control-light-brightness";
ELEMENT["HA_DIALOG_LIGHT_CONTROLS"] = "ha-icon-button-group";
ELEMENT["HA_DIALOG_LIGHT_COLORS"] = "ha-more-info-light-favorite-colors";
ELEMENT["HA_DIALOG_LIGHT_SETTINGS"] = "ha-more-info-control-select-container";
ELEMENT["HA_DIALOG_ATTRIBUTES"] = "ha-attributes";
})(ELEMENT || (ELEMENT = {}));
var TRUE = 'true';
var JS_TEMPLATE_REG = /^\s*\[\[\[([\s\S]+)\]\]\]\s*$/;
var JINJA_TEMPLATE_REG = /\{\{[\s\S]*\}\}|\{%[\s\S]*%\}/;
var CUSTOM_MOBILE_WIDTH_DEFAULT = 812;
var TOGGLE_MENU_EVENT = 'hass-toggle-menu';
var MC_DRAWER_CLOSED_EVENT = 'MDCDrawer:closed';
var CONTEXT_MENU_EVENT = 'contextmenu';
var RENDER_TEMPLATE_EVENT = 'render_template';
var RESIZE_EVENT = 'resize';
var MAX_ATTEMPTS = 500;
var RETRY_DELAY = 50;
var WINDOW_RESIZE_DELAY = 250;
var getCacheKey = function (option) {
var optionCamelCase = option.replace(/(?:^|_)([a-z])/g, function (__match, letter) {
return letter.toUpperCase();
});
return "km".concat(optionCamelCase);
};
var queryString = function () {
var keywords = [];
for (var _i = 0; _i < arguments.length; _i++) {
keywords[_i] = arguments[_i];
}
var params = new URLSearchParams(window.location.search);
return keywords.some(function (x) { return params.has(x); });
};
var setCache = function (value) {
var options = [];
for (var _i = 1; _i < arguments.length; _i++) {
options[_i - 1] = arguments[_i];
}
options.forEach(function (option) { return window.localStorage.setItem(getCacheKey(option), value); });
};
var cached = function () {
var options = [];
for (var _i = 0; _i < arguments.length; _i++) {
options[_i] = arguments[_i];
}
return options.some(function (option) {
return window.localStorage.getItem(getCacheKey(option)) === TRUE;
});
};
var resetCache = function () {
Object.values(OPTION).forEach(function (option) {
window.localStorage.removeItem(getCacheKey(option));
});
};
var getDisplayNoneRules = function () {
var rules = [];
for (var _i = 0; _i < arguments.length; _i++) {
rules[_i] = arguments[_i];
}
return Object.fromEntries(rules.map(function (rule) { return [rule, false]; }));
};
var getHAResources = function (ha) {
var referencePaths = Object.values(MENU_REFERENCES);
return e$3(function () { var _a; return (_a = ha === null || ha === void 0 ? void 0 : ha.hass) === null || _a === void 0 ? void 0 : _a.resources; }, function (resources) {
var language = ha.hass.language;
var anyEmptyResource = referencePaths.find(function (path) {
return !(resources === null || resources === void 0 ? void 0 : resources[language][path]);
});
if (!anyEmptyResource) {
return true;
}
return false;
}, {
retries: MAX_ATTEMPTS,
delay: RETRY_DELAY
});
};
var getMenuTranslations = function (ha) { return __awaiter(void 0, void 0, void 0, function () {
var resources, language, resourcesTranslated, entries, menuTranslationsEntries;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4, getHAResources(ha)];
case 1:
resources = _a.sent();
language = ha.hass.language;
resourcesTranslated = resources[language];
entries = Object.entries(MENU_REFERENCES);
menuTranslationsEntries = entries.map(function (entry) {
var reference = entry[0], prop = entry[1];
return [resourcesTranslated[prop], reference];
});
return [2, Object.fromEntries(menuTranslationsEntries)];
}
});
}); };
var addMenuItemsDataSelectors = function (menuItems, translations) {
menuItems.forEach(function (menuItem) {
if (menuItem &&
menuItem.dataset &&
!menuItem.dataset.selector) {
var icon = menuItem.shadowRoot.querySelector(ELEMENT.MENU_ITEM_ICON);
menuItem.dataset.selector = translations[icon.title];
}
});
};
var parseVersion = function (version) {
var versionRegExp = /^(\d+)\.(\d+)\.(\w+)(?:\.(\w+))?$/;
var match = version
? version.match(versionRegExp)
: null;
if (match) {
return [
+match[1],
+match[2],
match[3]
];
}
return null;
};
var _a;
var STYLES = {
HEADER: {
'#view': {
minHeight: '100vh !important',
KioskHeaderHeight: '0px',
paddingTop: 'calc(var(--kiosk-header-height) + env(safe-area-inset-top)) !important'
},
'.header': false
},
ACCOUNT: getDisplayNoneRules('.profile'),
NOTIFICATIONS: getDisplayNoneRules('.notifications-container'),
DIVIDER: getDisplayNoneRules('.divider'),
PAPER_LISTBOX: function (hideMenuButton, hideNotifications, hideAccount) {
var menuButtonHeight = 56;
var notificationsHeight = 48;
var accountHeight = 50;
var sizeMinimized = 132;
var sizeExpanded = 132;
if (hideAccount && hideNotifications) {
sizeMinimized = 0;
sizeExpanded = 0;
}
else if (hideAccount) {
sizeMinimized -= accountHeight;
sizeExpanded -= accountHeight;
}
else if (hideNotifications) {
sizeMinimized -= notificationsHeight;
sizeExpanded -= notificationsHeight;
}
if (hideMenuButton) {
sizeMinimized -= menuButtonHeight;
}
return {
':host(:not([expanded])) paper-listbox': {
height: "calc(100% - var(--header-height) - ".concat(sizeMinimized, "px - env(safe-area-inset-bottom)) !important")
},
':host([expanded]) paper-listbox': {
height: "calc(100% - var(--header-height) - ".concat(sizeExpanded, "px - env(safe-area-inset-bottom)) !important")
}
};
},
MENU_BUTTON: getDisplayNoneRules(':host(:not([expanded])) .menu', ':host([expanded]) .menu ha-icon-button'),
MENU_BUTTON_BURGER: getDisplayNoneRules('ha-menu-button'),
MOUSE: {
'body::after': {
bottom: 0,
content: '""',
cursor: 'none',
display: 'block',
left: 0,
position: 'fixed',
right: 0,
top: 0,
zIndex: 999999
}
},
SIDEBAR: {
':host': {
MdcDrawerWidth: '0px !important'
},
'partial-panel-resolver': {
MdcTopAppBarWidth: '100% !important'
},
'ha-drawer > ha-sidebar': false,
'.header': {
width: '100% !important'
}
},
ASIDE: getDisplayNoneRules('.mdc-drawer'),
OVERFLOW_MENU: getDisplayNoneRules("".concat(ELEMENT.TOOLBAR, " > ").concat(ELEMENT.ACTION_ITEMS, " > ").concat(ELEMENT.BUTTON_MENU)),
BLOCK_OVERFLOW: (_a = {},
_a["".concat(ELEMENT.TOOLBAR, " > ").concat(ELEMENT.ACTION_ITEMS, " > ").concat(ELEMENT.BUTTON_MENU)] = {
'pointer-events': 'none !important'
},
_a),
SEARCH: getDisplayNoneRules("".concat(ELEMENT.TOOLBAR, " > ").concat(ELEMENT.ACTION_ITEMS, " > ha-icon-button[data-selector=\"").concat(MENU.SEARCH, "\"]"), "".concat(ELEMENT.TOOLBAR, " > ").concat(ELEMENT.ACTION_ITEMS, " > ").concat(ELEMENT.BUTTON_MENU, " > ").concat(ELEMENT.OVERLAY_MENU_ITEM, "[data-selector=\"").concat(MENU.SEARCH, "\"]")),
ASSISTANT: getDisplayNoneRules("".concat(ELEMENT.TOOLBAR, " > ").concat(ELEMENT.ACTION_ITEMS, " > ha-icon-button[data-selector=\"").concat(MENU.ASSIST, "\"]"), "".concat(ELEMENT.TOOLBAR, " > ").concat(ELEMENT.ACTION_ITEMS, " > ").concat(ELEMENT.BUTTON_MENU, " > ").concat(ELEMENT.OVERLAY_MENU_ITEM, "[data-selector=\"").concat(MENU.ASSIST, "\"]")),
REFRESH: getDisplayNoneRules("".concat(ELEMENT.TOOLBAR, " > ").concat(ELEMENT.ACTION_ITEMS, " > ").concat(ELEMENT.BUTTON_MENU, " > ").concat(ELEMENT.OVERLAY_MENU_ITEM, "[data-selector=\"").concat(MENU.REFRESH, "\"]")),
UNUSED_ENTITIES: getDisplayNoneRules("".concat(ELEMENT.TOOLBAR, " > ").concat(ELEMENT.ACTION_ITEMS, " > ").concat(ELEMENT.BUTTON_MENU, " > ").concat(ELEMENT.OVERLAY_MENU_ITEM, "[data-selector=\"").concat(MENU.UNUSED_ENTITIES, "\"]")),
RELOAD_RESOURCES: getDisplayNoneRules("".concat(ELEMENT.TOOLBAR, " > ").concat(ELEMENT.ACTION_ITEMS, " > ").concat(ELEMENT.BUTTON_MENU, " > ").concat(ELEMENT.OVERLAY_MENU_ITEM, "[data-selector=\"").concat(MENU.RELOAD_RESOURCES, "\"]")),
EDIT_DASHBOARD: getDisplayNoneRules("".concat(ELEMENT.TOOLBAR, " > ").concat(ELEMENT.ACTION_ITEMS, " > ha-icon-button[data-selector=\"").concat(MENU.EDIT_DASHBOARD, "\"]"), "".concat(ELEMENT.TOOLBAR, " > ").concat(ELEMENT.ACTION_ITEMS, " > ").concat(ELEMENT.BUTTON_MENU, " > ").concat(ELEMENT.OVERLAY_MENU_ITEM, "[data-selector=\"").concat(MENU.EDIT_DASHBOARD, "\"]")),
DIALOG_HEADER_HISTORY: getDisplayNoneRules("".concat(ELEMENT.HA_DIALOG_HEADER, " > ").concat(ELEMENT.MENU_ITEM, "[data-selector=\"").concat(MENU.DIALOG_HISTORY, "\"]")),
DIALOG_HEADER_SETTINGS: getDisplayNoneRules("".concat(ELEMENT.HA_DIALOG_HEADER, " > ").concat(ELEMENT.MENU_ITEM, "[data-selector=\"").concat(MENU.DIALOG_SETTINGS, "\"]")),
DIALOG_HEADER_OVERFLOW: getDisplayNoneRules("".concat(ELEMENT.HA_DIALOG_HEADER, " > ").concat(ELEMENT.BUTTON_MENU)),
DIALOG_HISTORY: getDisplayNoneRules(ELEMENT.HA_DIALOG_HISTORY),
DIALOG_LOGBOOK: getDisplayNoneRules(ELEMENT.HA_DIALOG_LOGBOOK),
DIALOG_ATTRIBUTES: getDisplayNoneRules(ELEMENT.HA_DIALOG_ATTRIBUTES),
DIALOG_MEDIA_ACTIONS: getDisplayNoneRules('.controls'),
DIALOG_TIMER_ACTIONS: getDisplayNoneRules('.actions'),
DIALOG_UPDATE_ACTIONS: getDisplayNoneRules('.actions', "hr:has(+ .actions)"),
DIALOG_CAMERA_ACTIONS: getDisplayNoneRules('.actions'),
DIALOG_CLIMATE_CONTROL_SELECT: getDisplayNoneRules(ELEMENT.HA_DIALOG_CLIMATE_CONTROL_SELECT),
DIALOG_CLIMATE_TEMPERATURE_BUTTONS: getDisplayNoneRules(ELEMENT.HA_DIALOG_CLIMATE_TEMPERATURE_BUTTONS),
DIALOG_CLIMATE_CIRCULAR_SLIDER_INTERACTION: getDisplayNoneRules(ELEMENT.HA_DIALOG_CLIMATE_CIRCULAR_SLIDER_INTERACTION, ELEMENT.HA_DIALOG_CLIMATE_CIRCULAR_SLIDER_INTERACTION_SLIDER, ELEMENT.HA_DIALOG_CLIMATE_CIRCULAR_SLIDER_INTERACTION_TARGET_BORDER, ELEMENT.HA_DIALOG_CLIMATE_CIRCULAR_SLIDER_INTERACTION_TARGET),
DIALOG_LIGHT_CONTROL_ACTIONS: getDisplayNoneRules(".controls > ".concat(ELEMENT.HA_DIALOG_LIGHT_BRIGHTNESS, " + ").concat(ELEMENT.HA_DIALOG_LIGHT_CONTROLS)),
DIALOG_LIGHT_COLOR_ACTIONS: getDisplayNoneRules(".controls > ".concat(ELEMENT.HA_DIALOG_LIGHT_COLORS)),
DIALOG_LIGHT_SETTINGS_ACTIONS: getDisplayNoneRules(".controls:has(> ".concat(ELEMENT.HA_DIALOG_LIGHT_BRIGHTNESS, ") + div > ").concat(ELEMENT.HA_DIALOG_LIGHT_SETTINGS)),
DIALOG_SHOW_MORE: getDisplayNoneRules('.header a')
};
var version = "6.6.0";
var MAX_LENGTH = 27;
var LINES = [
{
content: '%c≡ kiosk-mode',
color: 'white',
background: '#03a9f4'
},
{
content: "%cversion ".concat(version)
}
];
var CONSOLE_STYLES = {
NORMAL: 'font-weight: normal; color: inherit;',
BLUE: 'font-weight: bold; color: blue;',
RED: 'font-weight: bold; color: red;',
GREEN: 'font-weight: bold; color: green;',
CODE: 'color: #666',
UNDERLINE: 'text-decoration: underline'
};
var CONDITIONAL_OPTION_VALUES = Object.values(CONDITIONAL_OPTION);
var ConsoleMessenger = (function () {
function ConsoleMessenger() {
}
ConsoleMessenger.logInfo = function () {
var contents = [];
var styles = [];
var lastIndex = LINES.length - 1;
var commonStyles = {
'border-color': '#424242',
'border-style': 'solid',
'display': 'inline-block',
'font-family': 'monospace',
'font-size': '12px'
};
LINES.forEach(function (line, index) {
contents.push(line.content.padEnd(MAX_LENGTH));
contents.push('%c⋮');
if (index !== lastIndex)
contents.push('%c\n');
var borderWidthStart = '0 0 0 1px';
var borderWidthEnd = '0 1px 0 1px';
if (index === 0) {
borderWidthStart = '1px 0 0 1px';
borderWidthEnd = '1px 1px 0 0';
}
else if (index === lastIndex) {
borderWidthStart = '0 0 1px 1px';
borderWidthEnd = '0 1px 1px 0';
}
styles.push(t(__assign(__assign({}, commonStyles), { 'background': line.background || 'white', 'color': line.color || '#424242', 'padding': index === 0
? '1px 0px 1px 5px'
: '1px 0px 1px 10px', 'border-width': borderWidthStart })));
styles.push(t(__assign(__assign({}, commonStyles), { 'background': line.background || 'white', 'color': line.color || 'white', 'padding': index === 0
? '1px 5px'
: '1px 5px 1px 0px', 'border-width': borderWidthEnd })));
if (index !== lastIndex)
styles.push('');
});
console.info.apply(console, __spreadArray([contents.join('')], styles, false));
};
ConsoleMessenger.debugRawConfig = function (config, panel) {
console.groupCollapsed("".concat(NAMESPACE, " raw config for ").concat(panel, " panel"));
console.table(config);
console.groupEnd();
};
ConsoleMessenger.debugFinalConfig = function (config, panel) {
var entries = Object.entries(config);
var filteredConfig = entries.filter(function (_a) {
var prop = _a[0];
return !(prop in CONDITIONAL_OPTION_VALUES);
});
console.groupCollapsed("".concat(NAMESPACE, " final config for ").concat(panel, " panel"));
console.table(Object.fromEntries(filteredConfig));
console.groupEnd();
};
ConsoleMessenger.debug = function (option, code, result) {
console.groupCollapsed("".concat(NAMESPACE, " debug"));
console.info("Template rendering triggered for option %c".concat(option, "%c with the next template:"), CONSOLE_STYLES.BLUE, CONSOLE_STYLES.NORMAL);
console.info("%c".concat(code), CONSOLE_STYLES.CODE);
console.info("The evaluation of this template is: %c".concat(result), typeof result === 'boolean'
? CONSOLE_STYLES.GREEN
: CONSOLE_STYLES.RED);
if (typeof result !== 'boolean') {
console.warn('%c⚠️ As this template didn\'t return a boolean, this option has been set to false', CONSOLE_STYLES.UNDERLINE);
}
console.groupEnd();
};
ConsoleMessenger.debugTemplate = function (code, result) {
console.group("".concat(NAMESPACE, " template debug"));
console.info("The template debug has been triggered with the next template:");
console.info("%c".concat(code), CONSOLE_STYLES.CODE);
console.info("The evaluation of this template is: %c".concat(result), typeof result === 'boolean'
? CONSOLE_STYLES.GREEN
: CONSOLE_STYLES.RED);
if (typeof result !== 'boolean') {
console.warn('%c⚠️ This template doesn\'t return a boolean. It cannot be used as a kiosk-mode option.', CONSOLE_STYLES.UNDERLINE);
}
console.groupEnd();
};
return ConsoleMessenger;
}());
var KioskMode = (function () {
function KioskMode() {
var _this = this;
if (queryString(SPECIAL_QUERY_PARAMS.CLEAR_CACHE)) {
resetCache();
}
this.panelOptions = new Map();
this.styleManager = new c$1({
prefix: STYLES_PREFIX,
throwWarnings: false
});
var selector = new m();
selector.addEventListener(i$1.ON_LOVELACE_PANEL_LOAD, function (event) { return __awaiter(_this, void 0, void 0, function () {
var _a, HOME_ASSISTANT, HOME_ASSISTANT_MAIN, HUI_ROOT, HA_DRAWER, HEADER, HA_SIDEBAR, _b, _c, _d, _e, _f, _g, _h, _j;
var _this = this;
var _k, _l;
return __generator(this, function (_m) {
switch (_m.label) {
case 0:
this.HAElements = event.detail;
_a = this.HAElements, HOME_ASSISTANT = _a.HOME_ASSISTANT, HOME_ASSISTANT_MAIN = _a.HOME_ASSISTANT_MAIN, HUI_ROOT = _a.HUI_ROOT, HA_DRAWER = _a.HA_DRAWER, HEADER = _a.HEADER, HA_SIDEBAR = _a.HA_SIDEBAR;
_b = this;
return [4, HOME_ASSISTANT.element];
case 1:
_b.ha = (_m.sent());
_c = this;
return [4, HOME_ASSISTANT_MAIN.selector.$.element];
case 2:
_c.main = _m.sent();
_d = this;
return [4, HUI_ROOT.selector.$.element];
case 3:
_d.huiRoot = _m.sent();
_e = this;
return [4, HA_DRAWER.element];
case 4:
_e.drawerLayout = (_m.sent());
_f = this;
return [4, HEADER.selector.query(ELEMENT.TOOLBAR).element];
case 5:
_f.appToolbar = _m.sent();
_g = this;
return [4, HA_SIDEBAR.selector.$.element];
case 6:
_g.sideBarRoot = _m.sent();
_h = this;
return [4, e$3(function () { var _a, _b; return (_b = (_a = _this.ha) === null || _a === void 0 ? void 0 : _a.hass) === null || _b === void 0 ? void 0 : _b.user; }, function (user) { return !!user; }, {
retries: MAX_ATTEMPTS,
delay: RETRY_DELAY,
rejectMessage: "".concat(NAMESPACE, ": Cannot select ").concat(ELEMENT.HOME_ASSISTANT, " > hass > user after {{ retries }} attempts. Giving up!")
})];
case 7:
_h.user = _m.sent();
_j = this;
return [4, new p(this.ha).getRenderer()];
case 8:
_j._renderer = _m.sent();
this.version = parseVersion((_l = (_k = this.ha.hass) === null || _k === void 0 ? void 0 : _k.config) === null || _l === void 0 ? void 0 : _l.version);
this.run();
return [2];
}
});
}); });
selector.addEventListener(i$1.ON_MORE_INFO_DIALOG_OPEN, function (event) {
_this.HAMoreInfoDialogElements = event.detail;
_this.insertMoreInfoDialogStyles();
});
selector.addEventListener(i$1.ON_HISTORY_AND_LOGBOOK_DIALOG_OPEN, function (event) {
_this.HAMoreInfoDialogElements = event.detail;
_this.insertMoreInfoDialogStyles();
});
selector.listen();
this.resizeWindowBinded = this.resizeWindow.bind(this);
}
KioskMode.prototype._getPanelUrl = function () {
return this.ha.hass.panelUrl;
};
KioskMode.prototype._hasStoredOptions = function () {
var panelUrl = this._getPanelUrl();
return this.panelOptions.has(panelUrl);
};
KioskMode.prototype._getOptions = function () {
var panelUrl = this._getPanelUrl();
return this.panelOptions.get(panelUrl);
};
KioskMode.prototype._storeOptions = function (options) {
var panelUrl = this._getPanelUrl();
this.panelOptions.set(panelUrl, options);
};
KioskMode.prototype._isDebug = function (debug) {
return typeof debug === 'boolean' && debug;
};
KioskMode.prototype._isKioskModeDisabled = function (options) {
if (!options ||
(queryString(SPECIAL_QUERY_PARAMS.DISABLE_KIOSK_MODE) &&
!options[CONDITIONAL_OPTION.IGNORE_DISABLE_KM])) {
return true;
}
return false;
};
KioskMode.prototype.runThrottle = function () {
var _this = this;
window.clearTimeout(this._runTimeout);
this._runTimeout = window.setTimeout(function () {
_this.run();
_this.runDialogs();
}, RETRY_DELAY);
};
KioskMode.prototype.run = function () {
return __awaiter(this, void 0, void 0, function () {
var lovelace;
var _this = this;
return __generator(this, function (_a) {
lovelace = this.main.querySelector(ELEMENT.HA_PANEL_LOVELACE);
if (!lovelace) {
return [2];
}
if (this._hasStoredOptions()) {
this.insertStyles();
}
else {
return [2, e$3(function () { var _a; return (_a = lovelace === null || lovelace === void 0 ? void 0 : lovelace.lovelace) === null || _a === void 0 ? void 0 : _a.config; }, function (config) { return !!config; }, {
retries: MAX_ATTEMPTS,
delay: RETRY_DELAY,
rejectMessage: "".concat(NAMESPACE, ": Cannot select Lovelace config after {{ retries }} attempts. Giving up!")
})
.then(function (config) {
return _this.processConfig(config.kiosk_mode || {});
})];
}
return [2];
});
});
};
KioskMode.prototype.runDialogs = function () {
var _a, _b;
var dialog = (_b = (_a = this.ha) === null || _a === void 0 ? void 0 : _a.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector(ELEMENT.HA_MORE_INFO_DIALOG);
var haDialog = dialog === null || dialog === void 0 ? void 0 : dialog.shadowRoot.querySelector(ELEMENT.HA_DIALOG);
if (!haDialog ||
!haDialog.__open) {
return;
}
this.insertMoreInfoDialogStyles();
};
KioskMode.prototype.processConfig = function (config) {
return __awaiter(this, void 0, void 0, function () {
var mergedConfig, options, adminConfig, mobileConfig, mobileWidth;
var _this = this;
return __generator(this, function (_a) {
if (this._isDebug(config.debug)) {
ConsoleMessenger.debugRawConfig(config, this._getPanelUrl());
}
mergedConfig = {};
options = {};
Object.values(OPTION).forEach(function (option) {
mergedConfig[option] = false;
options[option] = false;
});
Object.values(CONDITIONAL_OPTION).forEach(function (option) {
mergedConfig[option] = false;
options[option] = false;
});
Object.values(DEBUG_CONFIG_OPTION).forEach(function (option) {
mergedConfig[option] = false;
options[option] = false;
});
getMenuTranslations(this.ha)
.then(function (menuTranslations) {
_this.menuTranslations = menuTranslations;
_this.updateMenuItemsLabels();
})
.catch(function () {
console.warn("".concat(NAMESPACE, ": ").concat(NON_CRITICAL_WARNING, " Cannot get resources translations"));
});
if (cached.apply(void 0, Object.values(OPTION)) || queryString.apply(void 0, Object.values(OPTION))) {
Object.values(OPTION).forEach(function (option) {
mergedConfig[option] = cached(option) || queryString(option);
});
}
else {
mergedConfig = __assign(__assign({}, mergedConfig), config);
}
adminConfig = this.user.is_admin
? config.admin_settings
: config.non_admin_settings;
if (adminConfig) {
mergedConfig = __assign(__assign({}, mergedConfig), adminConfig);
}
if (config.user_settings) {
config.user_settings.forEach(function (userConfig) {
if (userConfig.users.some(function (user) { return user.toLowerCase() === _this.user.name.toLowerCase(); })) {
mergedConfig = __assign(__assign({}, mergedConfig), userConfig);
}
});
}
mobileConfig = options[CONDITIONAL_OPTION.IGNORE_MOBILE_SETTINGS]
? null
: config.mobile_settings;
if (mobileConfig) {
mobileWidth = mobileConfig.custom_width
? mobileConfig.custom_width
: CUSTOM_MOBILE_WIDTH_DEFAULT;
if (window.innerWidth <= mobileWidth) {
mergedConfig = __assign(__assign({}, mergedConfig), mobileConfig);
}
}
if (this._isDebug(mergedConfig.debug)) {
ConsoleMessenger.debugFinalConfig(mergedConfig, this._getPanelUrl());
}
this.setOptions(options, mergedConfig);
this._storeOptions(options);
this.insertStyles();
return [2];
});
});
};
KioskMode.prototype.insertStyles = function () {
var _this = this;
var _a, _b, _c;
var options = this._getOptions();
if (this._isKioskModeDisabled(options)) {
return;
}
if (options[OPTION.KIOSK] ||
options[OPTION.HIDE_HEADER]) {
this.styleManager.addStyle(STYLES.HEADER, this.huiRoot);
if (queryString(SPECIAL_QUERY_PARAMS.CACHE))
setCache(TRUE, OPTION.HIDE_HEADER);
}
else {
this.styleManager.removeStyle(this.huiRoot);
}
(_b = (_a = this.main) === null || _a === void 0 ? void 0 : _a.host) === null || _b === void 0 ? void 0 : _b.removeEventListener(TOGGLE_MENU_EVENT, this.blockEventHandler, true);
if (options[OPTION.KIOSK] ||
options[OPTION.HIDE_SIDEBAR]) {
var hideSidebarCommands_1 = function () {
var _a, _b;
(_b = (_a = _this.main) === null || _a === void 0 ? void 0 : _a.host) === null || _b === void 0 ? void 0 : _b.addEventListener(TOGGLE_MENU_EVENT, _this.blockEventHandler, true);
_this.styleManager.addStyle(STYLES.SIDEBAR, _this.drawerLayout);
_this.styleManager.addStyle(STYLES.ASIDE, _this.drawerLayout.shadowRoot);
if (queryString(SPECIAL_QUERY_PARAMS.CACHE))
setCache(TRUE, OPTION.HIDE_SIDEBAR);
_this.drawerLayout.removeEventListener(MC_DRAWER_CLOSED_EVENT, hideSidebarCommands_1);
};
if (this.drawerLayout.type === 'modal' &&
((_c = this.drawerLayout.appContent) === null || _c === void 0 ? void 0 : _c.inert)) {
this.drawerLayout.addEventListener(MC_DRAWER_CLOSED_EVENT, hideSidebarCommands_1);
}
else {
hideSidebarCommands_1();
}
}
else {
this.styleManager.removeStyle(this.drawerLayout);
this.styleManager.removeStyle(this.drawerLayout.shadowRoot);
}
if (options[OPTION.HIDE_ACCOUNT] ||
options[OPTION.HIDE_NOTIFICATIONS] ||
options[OPTION.HIDE_MENU_BUTTON]) {
var styles = [
options[OPTION.HIDE_ACCOUNT]
&& STYLES.ACCOUNT,
options[OPTION.HIDE_NOTIFICATIONS]
&& STYLES.NOTIFICATIONS,
options[OPTION.HIDE_ACCOUNT] && options[OPTION.HIDE_NOTIFICATIONS]
&& STYLES.DIVIDER,
(options[OPTION.HIDE_MENU_BUTTON] ||
options[OPTION.HIDE_NOTIFICATIONS] ||
options[OPTION.HIDE_ACCOUNT])
&& STYLES.PAPER_LISTBOX(options[OPTION.HIDE_MENU_BUTTON], options[OPTION.HIDE_NOTIFICATIONS], options[OPTION.HIDE_ACCOUNT]),
options[OPTION.HIDE_MENU_BUTTON]
&& STYLES.MENU_BUTTON
];
this.styleManager.addStyle(styles, this.sideBarRoot);
if (queryString(SPECIAL_QUERY_PARAMS.CACHE)) {
if (options[OPTION.HIDE_ACCOUNT])
setCache(TRUE, OPTION.HIDE_ACCOUNT);
if (options[OPTION.HIDE_NOTIFICATIONS])
setCache(TRUE, OPTION.HIDE_NOTIFICATIONS);
}
}
else {
this.styleManager.removeStyle(this.sideBarRoot);
}
if (options[OPTION.HIDE_SEARCH] ||
options[OPTION.HIDE_ASSISTANT] ||
options[OPTION.HIDE_REFRESH] ||
options[OPTION.HIDE_UNUSED_ENTITIES] ||
options[OPTION.HIDE_RELOAD_RESOURCES] ||
options[OPTION.HIDE_EDIT_DASHBOARD] ||
options[OPTION.HIDE_OVERFLOW] ||
options[OPTION.BLOCK_OVERFLOW] ||
options[OPTION.HIDE_SIDEBAR] ||
options[OPTION.HIDE_MENU_BUTTON]) {
var styles = [
options[OPTION.HIDE_SEARCH]
&& STYLES.SEARCH,
options[OPTION.HIDE_ASSISTANT]
&& STYLES.ASSISTANT,
options[OPTION.HIDE_REFRESH]
&& STYLES.REFRESH,
options[OPTION.HIDE_UNUSED_ENTITIES]
&& STYLES.UNUSED_ENTITIES,
options[OPTION.HIDE_RELOAD_RESOURCES]
&& STYLES.RELOAD_RESOURCES,
options[OPTION.HIDE_EDIT_DASHBOARD]
&& STYLES.EDIT_DASHBOARD,
options[OPTION.HIDE_OVERFLOW]
&& STYLES.OVERFLOW_MENU,
options[OPTION.BLOCK_OVERFLOW]
&& STYLES.BLOCK_OVERFLOW,
(options[OPTION.HIDE_MENU_BUTTON] || options[OPTION.HIDE_SIDEBAR])
&& STYLES.MENU_BUTTON_BURGER
];
this.styleManager.addStyle(styles, this.appToolbar);
if (queryString(SPECIAL_QUERY_PARAMS.CACHE)) {
if (options[OPTION.HIDE_SEARCH])
setCache(TRUE, OPTION.HIDE_SEARCH);
if (options[OPTION.HIDE_ASSISTANT])
setCache(TRUE, OPTION.HIDE_ASSISTANT);
if (options[OPTION.HIDE_REFRESH])
setCache(TRUE, OPTION.HIDE_REFRESH);
if (options[OPTION.HIDE_UNUSED_ENTITIES])
setCache(TRUE, OPTION.HIDE_UNUSED_ENTITIES);
if (options[OPTION.HIDE_RELOAD_RESOURCES])
setCache(TRUE, OPTION.HIDE_RELOAD_RESOURCES);
if (options[OPTION.HIDE_EDIT_DASHBOARD])
setCache(TRUE, OPTION.HIDE_EDIT_DASHBOARD);
if (options[OPTION.HIDE_OVERFLOW])
setCache(TRUE, OPTION.HIDE_OVERFLOW);
if (options[OPTION.BLOCK_OVERFLOW])
setCache(TRUE, OPTION.BLOCK_OVERFLOW);
if (options[OPTION.HIDE_MENU_BUTTON])
setCache(TRUE, OPTION.HIDE_MENU_BUTTON);
}
}
else {
this.styleManager.removeStyle(this.appToolbar);
}
if (options[OPTION.BLOCK_MOUSE]) {
this.styleManager.addStyle(STYLES.MOUSE, document.body);
if (queryString(SPECIAL_QUERY_PARAMS.CACHE))
setCache(TRUE, OPTION.BLOCK_MOUSE);
}
else {
this.styleManager.removeStyle(document.body);
}
window.removeEventListener(CONTEXT_MENU_EVENT, this.blockEventHandler, true);
if (options[OPTION.BLOCK_CONTEXT_MENU]) {
window.addEventListener('contextmenu', this.blockEventHandler, true);
if (queryString(SPECIAL_QUERY_PARAMS.CACHE))
setCache(TRUE, OPTION.BLOCK_CONTEXT_MENU);
}
window.removeEventListener(RESIZE_EVENT, this.resizeWindowBinded);
window.addEventListener(RESIZE_EVENT, this.resizeWindowBinded);
window.dispatchEvent(new Event(RESIZE_EVENT));
};
KioskMode.prototype.insertMoreInfoDialogStyles = function () {
return __awaiter(this, void 0, void 0, function () {
var options, dialog, moreInfoDialogContent, MORE_INFO_CHILD_ROOT, moreInfo, styles, haDialogClimate, haDialogClimateTemperature, haDialogClimateCircularSlider, styles;
var _this = this;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
options = this._getOptions();
if (this._isKioskModeDisabled(options)) {
return [2];
}
this.HAMoreInfoDialogElements.HA_DIALOG
.selector.query("".concat(ELEMENT.HA_DIALOG_HEADER, " > ").concat(ELEMENT.MENU_ITEM))
.all
.then(function (menuItems) {
addMenuItemsDataSelectors(menuItems, _this.menuTranslations);
});
return [4, this.HAMoreInfoDialogElements.HA_DIALOG.element];
case 1:
dialog = _a.sent();
moreInfoDialogContent = this.HAMoreInfoDialogElements.HA_DIALOG_CONTENT;
MORE_INFO_CHILD_ROOT = moreInfoDialogContent
.selector
.query("".concat(ELEMENT.HA_DIALOG_MORE_INFO, ", ").concat(ELEMENT.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK))
.$;
return [4, MORE_INFO_CHILD_ROOT.element];
case 2:
moreInfo = _a.sent();
if (options[OPTION.HIDE_DIALOG_HEADER_ACTION_ITEMS] ||
options[OPTION.HIDE_DIALOG_HEADER_HISTORY] ||
options[OPTION.HIDE_DIALOG_HEADER_SETTINGS] ||
options[OPTION.HIDE_DIALOG_HEADER_OVERFLOW]) {
styles = [
(options[OPTION.HIDE_DIALOG_HEADER_ACTION_ITEMS] || options[OPTION.HIDE_DIALOG_HEADER_HISTORY])
&& STYLES.DIALOG_HEADER_HISTORY,
(options[OPTION.HIDE_DIALOG_HEADER_ACTION_ITEMS] || options[OPTION.HIDE_DIALOG_HEADER_SETTINGS])
&& STYLES.DIALOG_HEADER_SETTINGS,
(options[OPTION.HIDE_DIALOG_HEADER_ACTION_ITEMS] || options[OPTION.HIDE_DIALOG_HEADER_OVERFLOW])
&& STYLES.DIALOG_HEADER_OVERFLOW
];
this.styleManager.addStyle(styles, dialog);
if (queryString(SPECIAL_QUERY_PARAMS.CACHE)) {
if (options[OPTION.HIDE_DIALOG_HEADER_ACTION_ITEMS])
setCache(TRUE, OPTION.HIDE_DIALOG_HEADER_ACTION_ITEMS);
if (options[OPTION.HIDE_DIALOG_HEADER_HISTORY])
setCache(TRUE, OPTION.HIDE_DIALOG_HEADER_HISTORY);
if (options[OPTION.HIDE_DIALOG_HEADER_SETTINGS])
setCache(TRUE, OPTION.HIDE_DIALOG_HEADER_SETTINGS);
if (options[OPTION.HIDE_DIALOG_HEADER_OVERFLOW])
setCache(TRUE, OPTION.HIDE_DIALOG_HEADER_OVERFLOW);
}
}
else {
this.styleManager.removeStyle(dialog);
}
haDialogClimate = MORE_INFO_CHILD_ROOT
.query(ELEMENT.HA_DIALOG_MORE_INFO_CONTENT)
.$
.query(ELEMENT.HA_DIALOG_CLIMATE)
.$;
haDialogClimateTemperature = haDialogClimate
.query(ELEMENT.HA_STATE_CONTROL_CLIMATE_TEMPERATURE)
.$;
haDialogClimateCircularSlider = haDialogClimateTemperature
.query(ELEMENT.HA_DIALOG_CLIMATE_CIRCULAR_SLIDER)
.$;
haDialogClimate.element.then(function (haDialogClimate) {
if (options[OPTION.HIDE_DIALOG_CLIMATE_ACTIONS] ||
options[OPTION.HIDE_DIALOG_CLIMATE_SETTINGS_ACTIONS]) {
_this.styleManager.addStyle(STYLES.DIALOG_CLIMATE_CONTROL_SELECT, haDialogClimate);
if (queryString(SPECIAL_QUERY_PARAMS.CACHE)) {
if (options[OPTION.HIDE_DIALOG_CLIMATE_ACTIONS])
setCache(TRUE, OPTION.HIDE_DIALOG_CLIMATE_ACTIONS);
if (options[OPTION.HIDE_DIALOG_CLIMATE_SETTINGS_ACTIONS])
setCache(TRUE, OPTION.HIDE_DIALOG_CLIMATE_SETTINGS_ACTIONS);
}
}
else {
_this.styleManager.removeStyle(haDialogClimate);
}
});
haDialogClimateTemperature.element.then(function (haDialogClimateTemperature) {
if (options[OPTION.HIDE_DIALOG_CLIMATE_ACTIONS] ||
options[OPTION.HIDE_DIALOG_CLIMATE_TEMPERATURE_ACTIONS]) {
_this.styleManager.addStyle(STYLES.DIALOG_CLIMATE_TEMPERATURE_BUTTONS, haDialogClimateTemperature);
if (queryString(SPECIAL_QUERY_PARAMS.CACHE)) {
if (options[OPTION.HIDE_DIALOG_CLIMATE_TEMPERATURE_ACTIONS])
setCache(TRUE, OPTION.HIDE_DIALOG_CLIMATE_TEMPERATURE_ACTIONS);
}
}
else {
_this.styleManager.removeStyle(haDialogClimateTemperature);
}
});
haDialogClimateCircularSlider.element.then(function (haDialogClimateCircularSlider) {
if (options[OPTION.HIDE_DIALOG_CLIMATE_ACTIONS] ||
options[OPTION.HIDE_DIALOG_CLIMATE_TEMPERATURE_ACTIONS]) {
_this.styleManager.addStyle(STYLES.DIALOG_CLIMATE_CIRCULAR_SLIDER_INTERACTION, haDialogClimateCircularSlider);
}
else {
_this.styleManager.removeStyle(haDialogClimateCircularSlider);
}
});
MORE_INFO_CHILD_ROOT
.query(ELEMENT.HA_DIALOG_MORE_INFO_CONTENT)
.$
.query([
ELEMENT.HA_DIALOG_DEFAULT,
ELEMENT.HA_DIALOG_LIGHT,
ELEMENT.HA_DIALOG_LOCK,
ELEMENT.HA_DIALOG_MEDIA_PLAYER,
ELEMENT.HA_DIALOG_PERSON,
ELEMENT.HA_DIALOG_SIREN,
ELEMENT.HA_DIALOG_TIMER,
ELEMENT.HA_DIALOG_UPDATE,
ELEMENT.HA_DIALOG_VACUUM,
ELEMENT.HA_DIALOG_CAMERA
].join(','))
.$
.element
.then(function (dialogChild) {
if (options[OPTION.HIDE_DIALOG_ATTRIBUTES] ||
options[OPTION.HIDE_DIALOG_TIMER_ACTIONS] ||
options[OPTION.HIDE_DIALOG_MEDIA_ACTIONS] ||
options[OPTION.HIDE_DIALOG_UPDATE_ACTIONS] ||
options[OPTION.HIDE_DIALOG_CAMERA_ACTIONS] ||
options[OPTION.HIDE_DIALOG_LIGHT_ACTIONS] ||
options[OPTION.HIDE_DIALOG_LIGHT_CONTROL_ACTIONS] ||
options[OPTION.HIDE_DIALOG_LIGHT_COLOR_ACTIONS] ||
options[OPTION.HIDE_DIALOG_LIGHT_SETTINGS_ACTIONS]) {
var styles = [
options[OPTION.HIDE_DIALOG_ATTRIBUTES]
&& STYLES.DIALOG_ATTRIBUTES,
options[OPTION.HIDE_DIALOG_TIMER_ACTIONS] &&
dialogChild.host.localName === ELEMENT.HA_DIALOG_TIMER
&& STYLES.DIALOG_TIMER_ACTIONS,
options[OPTION.HIDE_DIALOG_MEDIA_ACTIONS] &&
dialogChild.host.localName === ELEMENT.HA_DIALOG_MEDIA_PLAYER
&& STYLES.DIALOG_MEDIA_ACTIONS,
options[OPTION.HIDE_DIALOG_UPDATE_ACTIONS] &&
dialogChild.host.localName === ELEMENT.HA_DIALOG_UPDATE
&& STYLES.DIALOG_UPDATE_ACTIONS,
dialogChild.host.localName === ELEMENT.HA_DIALOG_CAMERA
&& STYLES.DIALOG_CAMERA_ACTIONS,
(options[OPTION.HIDE_DIALOG_LIGHT_ACTIONS] ||
options[OPTION.HIDE_DIALOG_LIGHT_CONTROL_ACTIONS])
&& STYLES.DIALOG_LIGHT_CONTROL_ACTIONS,
(options[OPTION.HIDE_DIALOG_LIGHT_ACTIONS] ||
options[OPTION.HIDE_DIALOG_LIGHT_COLOR_ACTIONS])
&& STYLES.DIALOG_LIGHT_COLOR_ACTIONS,
(options[OPTION.HIDE_DIALOG_LIGHT_ACTIONS] ||
options[OPTION.HIDE_DIALOG_LIGHT_SETTINGS_ACTIONS])
&& STYLES.DIALOG_LIGHT_SETTINGS_ACTIONS
];
_this.styleManager.addStyle(styles, dialogChild);
if (queryString(SPECIAL_QUERY_PARAMS.CACHE)) {
if (options[OPTION.HIDE_DIALOG_ATTRIBUTES])
setCache(TRUE, OPTION.HIDE_DIALOG_ATTRIBUTES);
if (options[OPTION.HIDE_DIALOG_TIMER_ACTIONS])
setCache(TRUE, OPTION.HIDE_DIALOG_TIMER_ACTIONS);
if (options[OPTION.HIDE_DIALOG_MEDIA_ACTIONS])
setCache(TRUE, OPTION.HIDE_DIALOG_MEDIA_ACTIONS);
if (options[OPTION.HIDE_DIALOG_UPDATE_ACTIONS])
setCache(TRUE, OPTION.HIDE_DIALOG_UPDATE_ACTIONS);
if (options[OPTION.HIDE_DIALOG_CAMERA_ACTIONS])
setCache(TRUE, OPTION.HIDE_DIALOG_CAMERA_ACTIONS);
if (options[OPTION.HIDE_DIALOG_LIGHT_ACTIONS])
setCache(TRUE, OPTION.HIDE_DIALOG_LIGHT_ACTIONS);
if (options[OPTION.HIDE_DIALOG_LIGHT_CONTROL_ACTIONS])
setCache(TRUE, OPTION.HIDE_DIALOG_LIGHT_CONTROL_ACTIONS);
if (options[OPTION.HIDE_DIALOG_LIGHT_COLOR_ACTIONS])
setCache(TRUE, OPTION.HIDE_DIALOG_LIGHT_COLOR_ACTIONS);
if (options[OPTION.HIDE_DIALOG_LIGHT_SETTINGS_ACTIONS])
setCache(TRUE, OPTION.HIDE_DIALOG_LIGHT_SETTINGS_ACTIONS);
}
}
else {
_this.styleManager.removeStyle(dialogChild);
}
});
if (options[OPTION.HIDE_DIALOG_HISTORY] ||
options[OPTION.HIDE_DIALOG_LOGBOOK]) {
styles = [
options[OPTION.HIDE_DIALOG_HISTORY]
&& STYLES.DIALOG_HISTORY,
options[OPTION.HIDE_DIALOG_LOGBOOK]
&& STYLES.DIALOG_LOGBOOK
];
this.styleManager.addStyle(styles, moreInfo);
if (queryString(SPECIAL_QUERY_PARAMS.CACHE)) {
if (options[OPTION.HIDE_DIALOG_HISTORY])
setCache(TRUE, OPTION.HIDE_DIALOG_HISTORY);
if (options[OPTION.HIDE_DIALOG_LOGBOOK])
setCache(TRUE, OPTION.HIDE_DIALOG_LOGBOOK);
}
}
else {
this.styleManager.removeStyle(moreInfo);
}
MORE_INFO_CHILD_ROOT
.query(ELEMENT.HA_DIALOG_HISTORY)
.$
.element
.then(function (dialogHistory) {
if (options[OPTION.HIDE_DIALOG_HISTORY_SHOW_MORE]) {
_this.styleManager.addStyle(STYLES.DIALOG_SHOW_MORE, dialogHistory);
if (queryString(SPECIAL_QUERY_PARAMS.CACHE))
setCache(TRUE, OPTION.HIDE_DIALOG_HISTORY_SHOW_MORE);
}
else {
_this.styleManager.removeStyle(dialogHistory);
}
});
MORE_INFO_CHILD_ROOT
.query(ELEMENT.HA_DIALOG_LOGBOOK)
.$
.element
.then(function (dialogLogbook) {
if (options[OPTION.HIDE_DIALOG_LOGBOOK_SHOW_MORE]) {
_this.styleManager.addStyle(STYLES.DIALOG_SHOW_MORE, dialogLogbook);
if (queryString(SPECIAL_QUERY_PARAMS.CACHE))
setCache(TRUE, OPTION.HIDE_DIALOG_LOGBOOK_SHOW_MORE);
}
else {
_this.styleManager.removeStyle(dialogLogbook);
}
});
return [2];
}
});
});
};
KioskMode.prototype.resizeWindow = function () {
var _this = this;
window.clearTimeout(this.resizeDelay);
this.resizeDelay = window.setTimeout(function () {
_this.updateMenuItemsLabels();
}, WINDOW_RESIZE_DELAY);
};
KioskMode.prototype.updateMenuItemsLabels = function () {
var _this = this;
if (!this.menuTranslations)
return;
this.HAElements.HEADER.selector.query("".concat(ELEMENT.TOOLBAR, " > ").concat(ELEMENT.ACTION_ITEMS, " > ").concat(ELEMENT.MENU_ITEM)).all
.then(function (menuItems) {
addMenuItemsDataSelectors(menuItems, _this.menuTranslations);
});
if (this.user.is_admin) {
this.HAElements.HEADER.selector.query("".concat(ELEMENT.TOOLBAR, " ").concat(ELEMENT.OVERLAY_MENU_ITEM)).all
.then(function (overflowMenuItems) {
overflowMenuItems.forEach(function (overflowMenuItem) {
var _a;
if (!((_a = overflowMenuItem === null || overflowMenuItem === void 0 ? void 0 : overflowMenuItem.dataset) === null || _a === void 0 ? void 0 : _a.selector)) {
var textContent = overflowMenuItem.textContent.trim();
overflowMenuItem.dataset.selector = _this.menuTranslations[textContent];
}
});
});
}
};
KioskMode.prototype.blockEventHandler = function (event) {
event.preventDefault();
event.stopImmediatePropagation();
};
KioskMode.prototype.setOptions = function (options, mergedConfig) {
var _this = this;
Object.values(__assign(__assign({}, DEBUG_CONFIG_OPTION), OPTION)).forEach(function (option) {
if (option in mergedConfig) {
_this.setOptionsOrSubscribeToSetOptions(options, mergedConfig, option);
}
});
};
KioskMode.prototype.setOptionsOrSubscribeToSetOptions = function (options, mergedConfig, option) {
var _this = this;
var panelUrl = this._getPanelUrl();
var value = mergedConfig[option];
var executeRendering = function (value, result) {
if (_this._getPanelUrl() === panelUrl) {
if (option === DEBUG_CONFIG_OPTION.DEBUG_TEMPLATE) {
ConsoleMessenger.debugTemplate(value, result);
}
else {
if (_this._isDebug(options.debug)) {
ConsoleMessenger.debug(option, value, result);
}
_this.runThrottle();
}
}
};
if (typeof value === 'boolean') {
options[option] = value;
}
else if (JS_TEMPLATE_REG.test(value)) {
var renderingFunction = function (result) {
options[option] = typeof result === 'boolean'
? result
: false;
executeRendering(value, result);
};
this._renderer.trackTemplate(value.replace(JS_TEMPLATE_REG, '$1'), renderingFunction);
}
else if (JINJA_TEMPLATE_REG.test(value)) {
window.hassConnection.then(function (hassConnection) {
hassConnection.conn.subscribeMessage(function (message) {
var result = message.result;
options[option] = typeof result === 'boolean'
? result
: false;
executeRendering(value, result);
}, {
type: RENDER_TEMPLATE_EVENT,
template: value,
variables: {
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
}
});
});
}
else {
throw SyntaxError("".concat(NAMESPACE, ": the value \"").concat(value, "\" of the option \"").concat(option, "\" is not a well formed JavaScript or Jinja template"));
}
};
return KioskMode;
}());
ConsoleMessenger.logInfo();
Promise.resolve(customElements.whenDefined(ELEMENT.HUI_VIEW))
.then(function () {
window.KioskMode = new KioskMode();
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment