Skip to content

Instantly share code, notes, and snippets.

@elchininet
Last active September 10, 2025 21:31
Show Gist options
  • Select an option

  • Save elchininet/9a2648ea0016d3194072712c745c5ad2 to your computer and use it in GitHub Desktop.

Select an option

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$2=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$1(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$2(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:true}}([a,l])}}}"function"==typeof SuppressedError&&SuppressedError;var o$2="$",u$1=":host",i$1="invalid selector",a$2=10,l$1=10,c$2=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$1(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$2).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$2,").").concat(e)}function d$1(n){return n instanceof Promise?n:Promise.resolve(n)}function h$1(){return "You can not select a shadowRoot (".concat(o$2,") of the document.")}function y(){return "You can not select a shadowRoot (".concat(o$2,") 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$1," ").concat(n[a])))||null;if(null===o)return null}return o}function p$1(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$1," ").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$1(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$1(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$1(r[u],t);if(null==a?void 0:a.length)return a}return document.querySelectorAll(i$1)}function b(n,t,e,r){for(var u=s$1(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$2,"). 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$1(this,void 0,void 0,(function(){return r$2(this,(function(e){return [2,e$2((function(){return w(t,o,"asyncQuerySelector","asyncShadowRootQuerySelector")}),(function(n){return !!n}),{retries:u,delay:i,shouldReject:false})]}))}))}function R$1(t,o,u,i){return e$1(this,void 0,void 0,(function(){return r$2(this,(function(e){return [2,e$2((function(){return g(t,o,"asyncQuerySelectorAll")}),(function(n){return !!n.length}),{retries:u,delay:i,shouldReject:false})]}))}))}function P(t,o,u,i){return e$1(this,void 0,void 0,(function(){return r$2(this,(function(e){return [2,e$2((function(){return b(t,o,"asyncShadowRootQuerySelector","asyncQuerySelector")}),(function(n){return !!n}),{retries:u,delay:i,shouldReject:false})]}))}))}var _$1=function(n,t){var e=n.querySelectorAll(t);if(e.length)return e;if(n instanceof Element&&n.shadowRoot){var r=_$1(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=_$1(a,t);if(l.length)return l}return document.querySelectorAll(i$1)},q=function(t,e,r,o){return e$2((function(){return _$1(t,e)}),(function(n){return !!n.length}),{retries:r,delay:o,shouldReject:false})};function L$1(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];return e$1(this,void 0,void 0,(function(){var t,e,o,u,i;return r$2(this,(function(r){switch(r.label){case 0:return c$2(n)?(t=n[0],e=n[1],o=n[2],[4,S$1(e,t,(null==o?void 0:o.retries)||a$2,(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$2,(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$1(this,void 0,void 0,(function(){var t,e,o,u,i;return r$2(this,(function(r){switch(r.label){case 0:return c$2(n)?(t=n[0],e=n[1],o=n[2],[4,R$1(e,t,(null==o?void 0:o.retries)||a$2,(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$2,(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$1(this,void 0,void 0,(function(){var t,e,o,u,i;return r$2(this,(function(r){switch(r.label){case 0:return c$2(n)?(t=n[0],e=n[1],o=n[2],[4,P(e,t,(null==o?void 0:o.retries)||a$2,(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$2,(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$2,delay:l$1},e||{})):(this._element=document,this._asyncParams=t$1({retries:a$2,delay:l$1},n||{}));}return Object.defineProperty(n.prototype,"element",{get:function(){return d$1(this._element).then((function(n){return n instanceof NodeList?n[0]||null:n}))},enumerable:false,configurable:true}),Object.defineProperty(n.prototype,"$",{get:function(){var t=this;return new n(d$1(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$2,t._asyncParams):D$1(n,o$2,t._asyncParams)})),this._asyncParams)},enumerable:false,configurable:true}),Object.defineProperty(n.prototype,"all",{get:function(){return d$1(this._element).then((function(n){return n instanceof NodeList?n:document.querySelectorAll(i$1)}))},enumerable:false,configurable:true}),Object.defineProperty(n.prototype,"asyncParams",{get:function(){return this._asyncParams},enumerable:false,configurable:true}),n.prototype.eq=function(n){return e$1(this,void 0,void 0,(function(){return r$2(this,(function(t){return [2,d$1(this._element).then((function(t){return t instanceof NodeList&&t[n]||null}))]}))}))},n.prototype.query=function(t){var e=this;return new n(d$1(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$1(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$1=function(e,t){return o$1=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$1(e,t)};var _=function(){return _=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},_.apply(this,arguments)};"function"==typeof SuppressedError&&SuppressedError;var n$1,r$1,O,i,s,a$1,A,l,c$1,E,h,I,d,N,L,R,u="$",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$1||(n$1={})),function(e){e.HA_PANEL_LOVELACE="HA_PANEL_LOVELACE",e.HUI_ROOT="HUI_ROOT",e.HEADER="HEADER",e.HUI_VIEW="HUI_VIEW";}(r$1||(r$1={})),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||(i={})),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={})[n$1.HOME_ASSISTANT]={selector:R.HOME_ASSISTANT,children:{shadowRoot:{selector:u,children:(a$1={},a$1[n$1.HOME_ASSISTANT_MAIN]={selector:R.HOME_ASSISTANT_MAIN,children:{shadowRoot:{selector:u,children:(A={},A[n$1.HA_DRAWER]={selector:R.HA_DRAWER,children:(l={},l[n$1.HA_SIDEBAR]={selector:R.HA_SIDEBAR,children:{shadowRoot:{selector:u}}},l[n$1.PARTIAL_PANEL_RESOLVER]={selector:R.PARTIAL_PANEL_RESOLVER},l)},A)}}},a$1)}}},s),H=((c$1={})[r$1.HA_PANEL_LOVELACE]={selector:R.HA_PANEL_LOVELACE,children:{shadowRoot:{selector:u,children:(E={},E[r$1.HUI_ROOT]={selector:R.HUI_ROOT,children:{shadowRoot:{selector:u,children:(h={},h[r$1.HEADER]={selector:R.HEADER},h[r$1.HUI_VIEW]={selector:R.HUI_VIEW},h)}}},E)}}},c$1),p={shadowRoot:{selector:u,children:(I={},I[O.HA_MORE_INFO_DIALOG]={selector:R.HA_MORE_INFO_DIALOG,children:{shadowRoot:{selector:u,children:(d={},d[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)}}},I)}},f=function(o,n,r,O){return void 0===r&&(r=null),void 0===O&&(O=false),Object.entries(n||{}).reduce((function(n,i){var s=i[0],a=i[1];if(a.selector===u&&r)return a.children?_(_({},n),f(o,a.children,r,true)):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]=_({},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=_(_({},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$1(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,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:true});})),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.ON_MORE_INFO_DIALOG_OPEN,t[O.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK]=i.ON_HISTORY_AND_LOGBOOK_DIALOG_OPEN,t[O.HA_DIALOG_MORE_INFO_SETTINGS]=i.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$1,this._homeAssistantRootTree),this._haRootElements[n$1.HOME_ASSISTANT].selector.$.element.then((function(t){e._dialogsObserver.disconnect(),e._dialogsObserver.observe(t,{childList:true});})),this._haRootElements[n$1.PARTIAL_PANEL_RESOLVER].element.then((function(t){e._panelResolverObserver.disconnect(),t&&e._panelResolverObserver.observe(t,{subtree:true,childList:true});})),this._dispatchEvent(i.ON_LISTEN,this._haRootElements),this._dispatchEvent(i.ON_PANEL_LOAD,this._haRootElements);},t.prototype._updateLovelaceElements=function(){var e=this;this._homeAssistantResolverTree=f(this._config,H,this._haRootElements[n$1.HA_DRAWER].element),this._haResolverElements=S(r$1,this._homeAssistantResolverTree),this._haResolverElements[r$1.HA_PANEL_LOVELACE].element.then((function(t){e._lovelaceObserver.disconnect(),t&&(e._lovelaceObserver.observe(t.shadowRoot,{childList:true}),e._dispatchEvent(i.ON_LOVELACE_PANEL_LOAD,_(_({},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.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=/([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,(function(n,t,e,o){var r=t.toLocaleLowerCase();return o?"-".concat(r).concat(e):"--".concat(r).concat(e)}))}(e),":").concat(o)})).join(";")+";"},e=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 false===o?"".concat(e,"{display: none !important}"):"".concat(e,"{").concat(t(o),"}")})).join("")})).join("")},o=function(n,t){return "".concat(t,"_").concat(n)},r=function(n){return n instanceof ShadowRoot?n.host.localName:n.localName},a=function(n,t){var e=o(r(n),t);return n.querySelector("#".concat(e))},c=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(n,this._prefix)},n.prototype.addStyle=function(n,t){!function(n,t,c,i,s){if(t){var l=a(t,c);if(!l){var u=o(r(t),c);(l=document.createElement("style")).setAttribute("id",u),t.appendChild(l);}l.innerHTML="string"==typeof n?n:e(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(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}();
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_ADD_TO_HOME_ASSISTANT"] = "hide_add_to_home_assistant";
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_BREADCRUMB_NAVIGATION"] = "hide_dialog_header_breadcrumb_navigation";
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_ENTITY_SETTINGS"] = "ignore_entity_settings";
CONDITIONAL_OPTION["IGNORE_MOBILE_SETTINGS"] = "ignore_mobile_settings";
CONDITIONAL_OPTION["IGNORE_DISABLE_KM"] = "ignore_disable_km";
})(CONDITIONAL_OPTION || (CONDITIONAL_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 EDITOR_PREFIX = "".concat(LOVELACE_PREFIX, ".editor");
var MENU_EDITOR_PREFIX = "".concat(EDITOR_PREFIX, ".menu");
var DIALOGS_PREFIX = "".concat(UI_PREFIX, ".dialogs.more_info_control");
var MENU;
(function (MENU) {
MENU["ADD"] = "ADD";
MENU["OVERFLOW"] = "OVERFLOW";
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.ADD] = "".concat(MENU_PREFIX, ".add"),
_a$1[MENU.OVERFLOW] = "".concat(MENU_EDITOR_PREFIX, ".open"),
_a$1[MENU.SEARCH] = "".concat(MENU_PREFIX, ".search_entities"),
_a$1[MENU.ASSIST] = "".concat(MENU_PREFIX, ".assist_tooltip"),
_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(COMMON_PREFIX, ".close"),
_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["TOOLTIP"] = "ha-tooltip";
ELEMENT["MENU_ITEM_ICON"] = "mwc-icon-button";
ELEMENT["BUTTON_MENU"] = "ha-button-menu";
ELEMENT["OVERLAY_MENU_ITEM"] = "ha-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_DIALOG_CLIMATE_TEMPERATURE"] = "ha-more-info-climate-temperature";
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 RESOURCE_WITH_SUFFIX_REGEXP = /^(.*?)( \([A-Z]\))?$/;
var TRUE = 'true';
var CUSTOM_MOBILE_WIDTH_DEFAULT = 812;
var SUSCRIBE_EVENTS_TYPE = 'subscribe_events';
var STATE_CHANGED_EVENT = 'state_changed';
var TOGGLE_MENU_EVENT = 'hass-toggle-menu';
var MC_DRAWER_CLOSED_EVENT = 'MDCDrawer:closed';
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 getMenuTranslations = function (ha, version) { return __awaiter(void 0, void 0, void 0, function () {
var referencePaths, isLegacy, finalReferencePaths, translations;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
referencePaths = Object.entries(MENU_REFERENCES);
isLegacy = (version[0] < 2025
|| (version[0] === 2025
&& version[1] < 9));
finalReferencePaths = isLegacy
? referencePaths.filter(function (_a) {
var key = _a[1];
return MENU_REFERENCES[MENU.ADD] !== key;
})
: referencePaths;
return [4, e$2(function () { return finalReferencePaths.map(function (entry) {
var key = entry[0], translationPath = entry[1];
return [ha.hass.localize(translationPath), key];
}); }, function (translationEntries) {
return !translationEntries.find(function (entry) { return !entry[0]; });
}, {
retries: MAX_ATTEMPTS,
delay: RETRY_DELAY
})];
case 1:
translations = _a.sent();
return [2, Object.fromEntries(translations)];
}
});
}); };
var getTranslationWithoutShorcutSuffix = function (text) {
return text
.trim()
.replace(RESOURCE_WITH_SUFFIX_REGEXP, '$1')
.trim();
};
var addMenuItemsDataSelectors = function (buttonItemsTooltips, translations) {
buttonItemsTooltips.forEach(function (buttonItemTooltip) {
if (buttonItemTooltip &&
buttonItemTooltip.dataset &&
!buttonItemTooltip.dataset.selector) {
var translation = getTranslationWithoutShorcutSuffix(buttonItemTooltip.content);
buttonItemTooltip.dataset.selector = translations[translation];
}
});
};
var addHeaderButtonsDataSelectors = function (headerButtons, translations) {
headerButtons.forEach(function (headerButton) {
var menuItem = headerButton
.querySelector(ELEMENT.MENU_ITEM);
if (menuItem &&
menuItem.dataset &&
!menuItem.dataset.selector) {
var icon = menuItem.shadowRoot.querySelector(ELEMENT.MENU_ITEM_ICON);
menuItem.dataset.selector = translations[icon.title.trim()];
}
});
};
var addDialogsMenuItemsDataSelectors = 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.trim()];
}
});
};
var addOverlayMenuItemsDataSelectors = function (overflowMenuItems, translations) {
overflowMenuItems.forEach(function (overflowMenuItem) {
if (overflowMenuItem &&
overflowMenuItem.dataset &&
!overflowMenuItem.dataset.selector) {
var textContent = getTranslationWithoutShorcutSuffix(overflowMenuItem.textContent);
overflowMenuItem.dataset.selector = translations[textContent];
}
});
};
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('ha-md-list-item.user'),
NOTIFICATIONS: getDisplayNoneRules('ha-md-list-item.notifications'),
DIVIDER: getDisplayNoneRules('.divider'),
SIDEBAR_ITEMS_CONTAINER: 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([expanded]) .title': {
marginLeft: hideMenuButton
? '19px'
: '3px'
},
':host(:not([expanded])) ha-md-list.ha-scrollbar': {
height: "calc(100% - var(--header-height) - ".concat(sizeMinimized, "px - env(safe-area-inset-bottom)) !important")
},
':host([expanded]) ha-md-list.ha-scrollbar': {
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',
KioskSidebarWidth: '0px'
},
'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, " > ").concat(ELEMENT.MENU_ITEM, "[data-selector=\"").concat(MENU.OVERFLOW, "\"]")),
BLOCK_OVERFLOW: (_a = {},
_a["".concat(ELEMENT.TOOLBAR, " > ").concat(ELEMENT.ACTION_ITEMS, " > ").concat(ELEMENT.BUTTON_MENU)] = {
'pointer-events': 'none !important'
},
_a),
ADD_TO_HOME_ASSISTANT: getDisplayNoneRules("".concat(ELEMENT.TOOLBAR, " > ").concat(ELEMENT.ACTION_ITEMS, " > ").concat(ELEMENT.BUTTON_MENU, " > ").concat(ELEMENT.MENU_ITEM, "[data-selector=\"").concat(MENU.ADD, "\"]"), "".concat(ELEMENT.TOOLBAR, " > ").concat(ELEMENT.ACTION_ITEMS, " > ").concat(ELEMENT.BUTTON_MENU, " > ").concat(ELEMENT.OVERLAY_MENU_ITEM, "[data-selector=\"").concat(MENU.ADD, "\"]")),
SEARCH: getDisplayNoneRules("".concat(ELEMENT.TOOLBAR, " > ").concat(ELEMENT.ACTION_ITEMS, " > ha-tooltip[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-tooltip[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-tooltip[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_BREADCRUMB_NAVIGATION: getDisplayNoneRules("".concat(ELEMENT.HA_DIALOG_HEADER, " > .title > .breadcrumb")),
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', 'ha-md-list:has(+ .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 = "7.3.0";
var MAX_LENGTH = 27;
var ConInfo = (function () {
function ConInfo() {
this.lines = [
{
content: '%c≡ kiosk-mode',
color: 'white',
background: '#03a9f4'
},
{
content: "%cversion ".concat(version)
}
];
}
ConInfo.prototype.log = function () {
var contents = [];
var styles = [];
var lastIndex = this.lines.length - 1;
var commonStyles = {
'border-color': '#424242',
'border-style': 'solid',
'display': 'inline-block',
'font-family': 'monospace',
'font-size': '12px'
};
this.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));
};
return ConInfo;
}());
var KioskMode = (function () {
function KioskMode() {
var _this = this;
if (queryString(SPECIAL_QUERY_PARAMS.CLEAR_CACHE)) {
resetCache();
}
window.kioskModeEntities = {};
this.options = {};
this.styleManager = new c({
prefix: STYLES_PREFIX,
throwWarnings: false
});
var selector = new m();
selector.addEventListener(i.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;
var _this = this;
var _j, _k;
return __generator(this, function (_l) {
switch (_l.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 = (_l.sent());
_c = this;
return [4, HOME_ASSISTANT_MAIN.selector.$.element];
case 2:
_c.main = _l.sent();
_d = this;
return [4, HUI_ROOT.selector.$.element];
case 3:
_d.huiRoot = _l.sent();
_e = this;
return [4, HA_DRAWER.element];
case 4:
_e.drawerLayout = (_l.sent());
_f = this;
return [4, HEADER.selector.query(ELEMENT.TOOLBAR).element];
case 5:
_f.appToolbar = _l.sent();
_g = this;
return [4, HA_SIDEBAR.selector.$.element];
case 6:
_g.sideBarRoot = _l.sent();
_h = this;
return [4, e$2(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 = _l.sent();
this.version = parseVersion((_k = (_j = this.ha.hass) === null || _j === void 0 ? void 0 : _j.config) === null || _k === void 0 ? void 0 : _k.version);
this.run();
return [2];
}
});
}); });
selector.addEventListener(i.ON_MORE_INFO_DIALOG_OPEN, function (event) {
_this.HAMoreInfoDialogElements = event.detail;
_this.insertMoreInfoDialogStyles();
});
selector.addEventListener(i.ON_HISTORY_AND_LOGBOOK_DIALOG_OPEN, function (event) {
_this.HAMoreInfoDialogElements = event.detail;
_this.insertMoreInfoDialogStyles();
});
selector.listen();
this.entityWatch();
this.resizeWindowBinded = this.resizeWindow.bind(this);
}
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];
}
return [2, e$2(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 || {});
})];
});
});
};
KioskMode.prototype.runDialogs = function (dialog) {
var _a, _b;
if (dialog === void 0) { 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); }
if (!dialog)
return;
this.insertMoreInfoDialogStyles();
};
KioskMode.prototype.processConfig = function (config) {
return __awaiter(this, void 0, void 0, function () {
var dash, adminConfig, mobileConfig, mobileWidth, entityConfig;
var _this = this;
return __generator(this, function (_a) {
dash = this.ha.hass.panelUrl;
if (!window.kioskModeEntities[dash]) {
window.kioskModeEntities[dash] = [];
}
Object.values(OPTION).forEach(function (option) {
_this.options[option] = false;
});
Object.values(CONDITIONAL_OPTION).forEach(function (option) {
_this.options[option] = false;
});
getMenuTranslations(this.ha, this.version)
.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) {
_this.options[option] = cached(option) || queryString(option);
});
}
else {
this.setOptions(config, false);
}
adminConfig = this.user.is_admin
? config.admin_settings
: config.non_admin_settings;
if (adminConfig) {
this.setOptions(adminConfig, true);
}
if (config.user_settings) {
config.user_settings.forEach(function (conf) {
if (conf.users.some(function (x) { return x.toLowerCase() === _this.user.name.toLowerCase(); })) {
_this.setOptions(conf, true);
}
});
}
mobileConfig = this.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) {
this.setOptions(mobileConfig, true);
}
}
entityConfig = this.options[CONDITIONAL_OPTION.IGNORE_ENTITY_SETTINGS]
? null
: config.entity_settings;
if (entityConfig) {
entityConfig.forEach(function (conf) {
var entity = Object.keys(conf.entity)[0];
if (!window.kioskModeEntities[dash].includes(entity)) {
window.kioskModeEntities[dash].push(entity);
}
if (_this.ha.hass.states[entity].state == conf.entity[entity]) {
_this.setOptions(conf, false);
}
});
}
if (queryString(SPECIAL_QUERY_PARAMS.DISABLE_KIOSK_MODE) &&
!this.options[CONDITIONAL_OPTION.IGNORE_DISABLE_KM]) {
return [2];
}
this.insertStyles();
return [2];
});
});
};
KioskMode.prototype.insertStyles = function () {
var _this = this;
var _a, _b, _c;
if (this.options[OPTION.KIOSK] ||
this.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 (this.options[OPTION.KIOSK] ||
this.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 (this.options[OPTION.HIDE_ACCOUNT] ||
this.options[OPTION.HIDE_NOTIFICATIONS] ||
this.options[OPTION.HIDE_MENU_BUTTON]) {
var styles = [
this.options[OPTION.HIDE_ACCOUNT]
&& STYLES.ACCOUNT,
this.options[OPTION.HIDE_NOTIFICATIONS]
&& STYLES.NOTIFICATIONS,
this.options[OPTION.HIDE_ACCOUNT] && this.options[OPTION.HIDE_NOTIFICATIONS]
&& STYLES.DIVIDER,
(this.options[OPTION.HIDE_MENU_BUTTON] ||
this.options[OPTION.HIDE_NOTIFICATIONS] ||
this.options[OPTION.HIDE_ACCOUNT])
&& STYLES.SIDEBAR_ITEMS_CONTAINER(this.options[OPTION.HIDE_MENU_BUTTON], this.options[OPTION.HIDE_NOTIFICATIONS], this.options[OPTION.HIDE_ACCOUNT]),
this.options[OPTION.HIDE_MENU_BUTTON]
&& STYLES.MENU_BUTTON,
];
this.styleManager.addStyle(styles, this.sideBarRoot);
if (queryString(SPECIAL_QUERY_PARAMS.CACHE)) {
if (this.options[OPTION.HIDE_ACCOUNT])
setCache(TRUE, OPTION.HIDE_ACCOUNT);
if (this.options[OPTION.HIDE_NOTIFICATIONS])
setCache(TRUE, OPTION.HIDE_NOTIFICATIONS);
}
}
else {
this.styleManager.removeStyle(this.sideBarRoot);
}
if (this.options[OPTION.HIDE_ADD_TO_HOME_ASSISTANT] ||
this.options[OPTION.HIDE_OVERFLOW] ||
this.options[OPTION.HIDE_SEARCH] ||
this.options[OPTION.HIDE_ASSISTANT] ||
this.options[OPTION.HIDE_REFRESH] ||
this.options[OPTION.HIDE_UNUSED_ENTITIES] ||
this.options[OPTION.HIDE_RELOAD_RESOURCES] ||
this.options[OPTION.HIDE_EDIT_DASHBOARD] ||
this.options[OPTION.BLOCK_OVERFLOW] ||
this.options[OPTION.HIDE_SIDEBAR] ||
this.options[OPTION.HIDE_MENU_BUTTON]) {
var styles = [
this.options[OPTION.HIDE_ADD_TO_HOME_ASSISTANT]
&& STYLES.ADD_TO_HOME_ASSISTANT,
this.options[OPTION.HIDE_OVERFLOW]
&& STYLES.OVERFLOW_MENU,
this.options[OPTION.HIDE_SEARCH]
&& STYLES.SEARCH,
this.options[OPTION.HIDE_ASSISTANT]
&& STYLES.ASSISTANT,
this.options[OPTION.HIDE_REFRESH]
&& STYLES.REFRESH,
this.options[OPTION.HIDE_UNUSED_ENTITIES]
&& STYLES.UNUSED_ENTITIES,
this.options[OPTION.HIDE_RELOAD_RESOURCES]
&& STYLES.RELOAD_RESOURCES,
this.options[OPTION.HIDE_EDIT_DASHBOARD]
&& STYLES.EDIT_DASHBOARD,
this.options[OPTION.BLOCK_OVERFLOW]
&& STYLES.BLOCK_OVERFLOW,
(this.options[OPTION.HIDE_MENU_BUTTON] || this.options[OPTION.HIDE_SIDEBAR])
&& STYLES.MENU_BUTTON_BURGER
];
this.styleManager.addStyle(styles, this.appToolbar);
if (queryString(SPECIAL_QUERY_PARAMS.CACHE)) {
if (this.options[OPTION.HIDE_ADD_TO_HOME_ASSISTANT])
setCache(TRUE, OPTION.HIDE_ADD_TO_HOME_ASSISTANT);
if (this.options[OPTION.HIDE_OVERFLOW])
setCache(TRUE, OPTION.HIDE_OVERFLOW);
if (this.options[OPTION.HIDE_SEARCH])
setCache(TRUE, OPTION.HIDE_SEARCH);
if (this.options[OPTION.HIDE_ASSISTANT])
setCache(TRUE, OPTION.HIDE_ASSISTANT);
if (this.options[OPTION.HIDE_REFRESH])
setCache(TRUE, OPTION.HIDE_REFRESH);
if (this.options[OPTION.HIDE_UNUSED_ENTITIES])
setCache(TRUE, OPTION.HIDE_UNUSED_ENTITIES);
if (this.options[OPTION.HIDE_RELOAD_RESOURCES])
setCache(TRUE, OPTION.HIDE_RELOAD_RESOURCES);
if (this.options[OPTION.HIDE_EDIT_DASHBOARD])
setCache(TRUE, OPTION.HIDE_EDIT_DASHBOARD);
if (this.options[OPTION.BLOCK_OVERFLOW])
setCache(TRUE, OPTION.BLOCK_OVERFLOW);
if (this.options[OPTION.HIDE_MENU_BUTTON])
setCache(TRUE, OPTION.HIDE_MENU_BUTTON);
}
}
else {
this.styleManager.removeStyle(this.appToolbar);
}
if (this.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('contextmenu', this.blockEventHandler, true);
if (this.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', this.resizeWindowBinded);
window.addEventListener('resize', this.resizeWindowBinded);
window.dispatchEvent(new Event('resize'));
};
KioskMode.prototype.insertMoreInfoDialogStyles = function () {
return __awaiter(this, void 0, void 0, function () {
var 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:
this.HAMoreInfoDialogElements.HA_DIALOG
.selector.query("".concat(ELEMENT.HA_DIALOG_HEADER, " > ").concat(ELEMENT.MENU_ITEM))
.all
.then(function (menuItems) {
addDialogsMenuItemsDataSelectors(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 (this.options[OPTION.HIDE_DIALOG_HEADER_BREADCRUMB_NAVIGATION] ||
this.options[OPTION.HIDE_DIALOG_HEADER_ACTION_ITEMS] ||
this.options[OPTION.HIDE_DIALOG_HEADER_HISTORY] ||
this.options[OPTION.HIDE_DIALOG_HEADER_SETTINGS] ||
this.options[OPTION.HIDE_DIALOG_HEADER_OVERFLOW]) {
styles = [
this.options[OPTION.HIDE_DIALOG_HEADER_BREADCRUMB_NAVIGATION]
&& STYLES.DIALOG_HEADER_BREADCRUMB_NAVIGATION,
(this.options[OPTION.HIDE_DIALOG_HEADER_ACTION_ITEMS] || this.options[OPTION.HIDE_DIALOG_HEADER_HISTORY])
&& STYLES.DIALOG_HEADER_HISTORY,
(this.options[OPTION.HIDE_DIALOG_HEADER_ACTION_ITEMS] || this.options[OPTION.HIDE_DIALOG_HEADER_SETTINGS])
&& STYLES.DIALOG_HEADER_SETTINGS,
(this.options[OPTION.HIDE_DIALOG_HEADER_ACTION_ITEMS] || this.options[OPTION.HIDE_DIALOG_HEADER_OVERFLOW])
&& STYLES.DIALOG_HEADER_OVERFLOW
];
this.styleManager.addStyle(styles, dialog);
if (queryString(SPECIAL_QUERY_PARAMS.CACHE)) {
if (this.options[OPTION.HIDE_DIALOG_HEADER_BREADCRUMB_NAVIGATION])
setCache(TRUE, OPTION.HIDE_DIALOG_HEADER_BREADCRUMB_NAVIGATION);
if (this.options[OPTION.HIDE_DIALOG_HEADER_ACTION_ITEMS])
setCache(TRUE, OPTION.HIDE_DIALOG_HEADER_ACTION_ITEMS);
if (this.options[OPTION.HIDE_DIALOG_HEADER_HISTORY])
setCache(TRUE, OPTION.HIDE_DIALOG_HEADER_HISTORY);
if (this.options[OPTION.HIDE_DIALOG_HEADER_SETTINGS])
setCache(TRUE, OPTION.HIDE_DIALOG_HEADER_SETTINGS);
if (this.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 (_this.options[OPTION.HIDE_DIALOG_CLIMATE_ACTIONS] ||
_this.options[OPTION.HIDE_DIALOG_CLIMATE_SETTINGS_ACTIONS]) {
_this.styleManager.addStyle(STYLES.DIALOG_CLIMATE_CONTROL_SELECT, haDialogClimate);
if (queryString(SPECIAL_QUERY_PARAMS.CACHE)) {
if (_this.options[OPTION.HIDE_DIALOG_CLIMATE_ACTIONS])
setCache(TRUE, OPTION.HIDE_DIALOG_CLIMATE_ACTIONS);
if (_this.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 (_this.options[OPTION.HIDE_DIALOG_CLIMATE_ACTIONS] ||
_this.options[OPTION.HIDE_DIALOG_CLIMATE_TEMPERATURE_ACTIONS]) {
_this.styleManager.addStyle(STYLES.DIALOG_CLIMATE_TEMPERATURE_BUTTONS, haDialogClimateTemperature);
if (queryString(SPECIAL_QUERY_PARAMS.CACHE)) {
if (_this.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 (_this.options[OPTION.HIDE_DIALOG_CLIMATE_ACTIONS] ||
_this.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 (_this.options[OPTION.HIDE_DIALOG_ATTRIBUTES] ||
_this.options[OPTION.HIDE_DIALOG_TIMER_ACTIONS] ||
_this.options[OPTION.HIDE_DIALOG_MEDIA_ACTIONS] ||
_this.options[OPTION.HIDE_DIALOG_UPDATE_ACTIONS] ||
_this.options[OPTION.HIDE_DIALOG_CAMERA_ACTIONS] ||
_this.options[OPTION.HIDE_DIALOG_LIGHT_ACTIONS] ||
_this.options[OPTION.HIDE_DIALOG_LIGHT_CONTROL_ACTIONS] ||
_this.options[OPTION.HIDE_DIALOG_LIGHT_COLOR_ACTIONS] ||
_this.options[OPTION.HIDE_DIALOG_LIGHT_SETTINGS_ACTIONS]) {
var styles = [
_this.options[OPTION.HIDE_DIALOG_ATTRIBUTES]
&& STYLES.DIALOG_ATTRIBUTES,
_this.options[OPTION.HIDE_DIALOG_TIMER_ACTIONS] &&
dialogChild.host.localName === ELEMENT.HA_DIALOG_TIMER
&& STYLES.DIALOG_TIMER_ACTIONS,
_this.options[OPTION.HIDE_DIALOG_MEDIA_ACTIONS] &&
dialogChild.host.localName === ELEMENT.HA_DIALOG_MEDIA_PLAYER
&& STYLES.DIALOG_MEDIA_ACTIONS,
_this.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,
(_this.options[OPTION.HIDE_DIALOG_LIGHT_ACTIONS] ||
_this.options[OPTION.HIDE_DIALOG_LIGHT_CONTROL_ACTIONS])
&& STYLES.DIALOG_LIGHT_CONTROL_ACTIONS,
(_this.options[OPTION.HIDE_DIALOG_LIGHT_ACTIONS] ||
_this.options[OPTION.HIDE_DIALOG_LIGHT_COLOR_ACTIONS])
&& STYLES.DIALOG_LIGHT_COLOR_ACTIONS,
(_this.options[OPTION.HIDE_DIALOG_LIGHT_ACTIONS] ||
_this.options[OPTION.HIDE_DIALOG_LIGHT_SETTINGS_ACTIONS])
&& STYLES.DIALOG_LIGHT_SETTINGS_ACTIONS
];
_this.styleManager.addStyle(styles, dialogChild);
if (queryString(SPECIAL_QUERY_PARAMS.CACHE)) {
if (_this.options[OPTION.HIDE_DIALOG_ATTRIBUTES])
setCache(TRUE, OPTION.HIDE_DIALOG_ATTRIBUTES);
if (_this.options[OPTION.HIDE_DIALOG_TIMER_ACTIONS])
setCache(TRUE, OPTION.HIDE_DIALOG_TIMER_ACTIONS);
if (_this.options[OPTION.HIDE_DIALOG_MEDIA_ACTIONS])
setCache(TRUE, OPTION.HIDE_DIALOG_MEDIA_ACTIONS);
if (_this.options[OPTION.HIDE_DIALOG_UPDATE_ACTIONS])
setCache(TRUE, OPTION.HIDE_DIALOG_UPDATE_ACTIONS);
if (_this.options[OPTION.HIDE_DIALOG_CAMERA_ACTIONS])
setCache(TRUE, OPTION.HIDE_DIALOG_CAMERA_ACTIONS);
if (_this.options[OPTION.HIDE_DIALOG_LIGHT_ACTIONS])
setCache(TRUE, OPTION.HIDE_DIALOG_LIGHT_ACTIONS);
if (_this.options[OPTION.HIDE_DIALOG_LIGHT_CONTROL_ACTIONS])
setCache(TRUE, OPTION.HIDE_DIALOG_LIGHT_CONTROL_ACTIONS);
if (_this.options[OPTION.HIDE_DIALOG_LIGHT_COLOR_ACTIONS])
setCache(TRUE, OPTION.HIDE_DIALOG_LIGHT_COLOR_ACTIONS);
if (_this.options[OPTION.HIDE_DIALOG_LIGHT_SETTINGS_ACTIONS])
setCache(TRUE, OPTION.HIDE_DIALOG_LIGHT_SETTINGS_ACTIONS);
}
}
else {
_this.styleManager.removeStyle(dialogChild);
}
});
if (this.options[OPTION.HIDE_DIALOG_HISTORY] ||
this.options[OPTION.HIDE_DIALOG_LOGBOOK]) {
styles = [
this.options[OPTION.HIDE_DIALOG_HISTORY]
&& STYLES.DIALOG_HISTORY,
this.options[OPTION.HIDE_DIALOG_LOGBOOK]
&& STYLES.DIALOG_LOGBOOK
];
this.styleManager.addStyle(styles, moreInfo);
if (queryString(SPECIAL_QUERY_PARAMS.CACHE)) {
if (this.options[OPTION.HIDE_DIALOG_HISTORY])
setCache(TRUE, OPTION.HIDE_DIALOG_HISTORY);
if (this.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 (_this.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 (_this.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.TOOLTIP)).all
.then(function (buttonItemsTooltips) {
addMenuItemsDataSelectors(buttonItemsTooltips, _this.menuTranslations);
});
this.HAElements.HEADER
.selector
.query("".concat(ELEMENT.TOOLBAR, " > ").concat(ELEMENT.ACTION_ITEMS, " > ").concat(ELEMENT.BUTTON_MENU))
.all
.then(function (headerButtons) {
addHeaderButtonsDataSelectors(headerButtons, _this.menuTranslations);
});
this.HAElements.HEADER.selector.query("".concat(ELEMENT.TOOLBAR, " ").concat(ELEMENT.OVERLAY_MENU_ITEM)).all
.then(function (overflowMenuItems) {
addOverlayMenuItemsDataSelectors(overflowMenuItems, _this.menuTranslations);
});
};
KioskMode.prototype.entityWatch = function () {
return __awaiter(this, void 0, void 0, function () {
var _this = this;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4, window.hassConnection];
case 1:
(_a.sent()).conn.subscribeMessage(function (e) { return _this.entityWatchCallback(e); }, {
type: SUSCRIBE_EVENTS_TYPE,
event_type: STATE_CHANGED_EVENT,
});
return [2];
}
});
});
};
KioskMode.prototype.entityWatchCallback = function (event) {
return __awaiter(this, void 0, void 0, function () {
var entities;
var _a, _b;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
entities = window.kioskModeEntities[(_b = (_a = this.ha) === null || _a === void 0 ? void 0 : _a.hass) === null || _b === void 0 ? void 0 : _b.panelUrl] || [];
if (!(entities.length &&
event.event_type === STATE_CHANGED_EVENT &&
entities.includes(event.data.entity_id) &&
(!event.data.old_state ||
event.data.new_state.state !== event.data.old_state.state))) return [3, 2];
return [4, this.run()];
case 1:
_c.sent();
this.runDialogs();
_c.label = 2;
case 2: return [2];
}
});
});
};
KioskMode.prototype.blockEventHandler = function (event) {
event.preventDefault();
event.stopImmediatePropagation();
};
KioskMode.prototype.setOptions = function (config, conditional) {
var _this = this;
Object.values(OPTION).forEach(function (option) {
if (option in config) {
_this.options[option] = config[option];
}
});
if (conditional) {
Object.values(CONDITIONAL_OPTION).forEach(function (option) {
if (option in config) {
_this.options[option] = config[option];
}
});
}
};
return KioskMode;
}());
var info = new ConInfo();
info.log();
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