Last active
February 12, 2024 12:04
-
-
Save elchininet/9a2648ea0016d3194072712c745c5ad2 to your computer and use it in GitHub Desktop.
Compiled Kiosk-mode library with the latest code in master.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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; | |
return g = { next: verb(0), "throw": verb(1), "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 n$1=function(){return n$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},n$1.apply(this,arguments)};function t(n,t,e,r){return new(e||(e=Promise))((function(o,u){function i(n){try{c(r.next(n));}catch(n){u(n);}}function a(n){try{c(r.throw(n));}catch(n){u(n);}}function c(n){var t;n.done?o(n.value):(t=n.value,t instanceof e?t:new e((function(n){n(t);}))).then(i,a);}c((r=r.apply(n,t||[])).next());}))}function e(n,t){var e,r,o,u,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return u={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(u[Symbol.iterator]=function(){return this}),u;function a(a){return function(c){return function(a){if(e)throw new TypeError("Generator is already executing.");for(;u&&(u=0,a[0]&&(i=0)),i;)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 i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(n,i);}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,c])}}}"function"==typeof SuppressedError&&SuppressedError;var r$1="$",o$1=":host",u$1="invalid selector",i$1=10,a$1=10,c$1=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 l$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(r$1).map((function(n){return n.trim()}))}(n);return t(e)}))}var s$1=function(n,t,e,r){return new Promise((function(o){var u=0,i=function(){var a=n();t(a)?o(a):++u<e?setTimeout(i,r):o(a);};i();}))};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(r$1,").").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(r$1,") of the document.")}function v$1(){return "You can not select a shadowRoot (".concat(r$1,") of a shadowRoot.")}function y(n,t){for(var e,r,u=null,i=n.length,a=0;a<i;a++){if(0===a)if(n[a].length)u=t.querySelector(n[a]);else {if(t instanceof Document)throw new SyntaxError(h$1());if(t instanceof ShadowRoot)throw new SyntaxError(v$1());u=(null===(e=t.shadowRoot)||void 0===e?void 0:e.querySelector(n[++a]))||null;}else u=(null===(r=u.shadowRoot)||void 0===r?void 0:r.querySelector("".concat(o$1," ").concat(n[a])))||null;if(null===u)return null}return u}function m$1(n,t){var e,r=function(n,t,e){if(e||2===arguments.length)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,!0),u=r.pop();if(!r.length)return t.querySelectorAll(u);var i=y(r,t);return (null===(e=null==i?void 0:i.shadowRoot)||void 0===e?void 0:e.querySelectorAll("".concat(o$1," ").concat(u)))||null}function p$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(v$1());return t.shadowRoot}var e=y(n,t);return (null==e?void 0:e.shadowRoot)||null}function w(n,t,e,r){void 0===e&&(e="querySelector"),void 0===r&&(r="shadowRootQuerySelector");for(var o=l$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=y(o[i],t);if(a)return a}return null}function g(n,t,e){void 0===e&&(e="querySelectorAll");for(var r=l$1(n,(function(n){if(!n[n.length-1].length)throw new SyntaxError(f$1(e));return n})),o=r.length,i=0;i<o;i++){var a=m$1(r[i],t);if(null==a?void 0:a.length)return a}return document.querySelectorAll(u$1)}function S$1(n,t,e,o){void 0===e&&(e="shadowRootQuerySelector"),void 0===o&&(o="querySelector");for(var u=l$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(r$1,"). If you don't want to select a shadowRoot, use ").concat(t," instead.")}(e,o));return n})),i=u.length,a=0;a<i;a++){var c=p$1(u[a],t);if(c)return c}return null}function b(n,r,o,u){return t(this,void 0,void 0,(function(){return e(this,(function(t){return [2,s$1((function(){return w(n,r,"asyncQuerySelector","asyncShadowRootQuerySelector")}),(function(n){return !!n}),o,u)]}))}))}function P(n,r,o,u){return t(this,void 0,void 0,(function(){return e(this,(function(t){return [2,s$1((function(){return g(n,r,"asyncQuerySelectorAll")}),(function(n){return !!n.length}),o,u)]}))}))}function R$1(n,r,o,u){return t(this,void 0,void 0,(function(){return e(this,(function(t){return [2,s$1((function(){return S$1(n,r,"asyncShadowRootQuerySelector","asyncQuerySelector")}),(function(n){return !!n}),o,u)]}))}))}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,i=Array.from(n.querySelectorAll("*"));o<i.length;o++){var a=i[o],c=_$1(a,t);if(c.length)return c}return document.querySelectorAll(u$1)},q=function(n,t,e,r){return s$1((function(){return _$1(n,t)}),(function(n){return !!n.length}),e,r)};function Q(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return t(this,void 0,void 0,(function(){var t,r,o,u,l;return e(this,(function(e){switch(e.label){case 0:return c$1(n)?(t=n[0],r=n[1],o=n[2],[4,b(r,t,(null==o?void 0:o.retries)||i$1,(null==o?void 0:o.delay)||a$1)]):[3,2];case 1:case 3:return [2,e.sent()];case 2:return u=n[0],l=n[1],[4,b(u,document,(null==l?void 0:l.retries)||i$1,(null==l?void 0:l.delay)||a$1)]}}))}))}function j(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return t(this,void 0,void 0,(function(){var t,r,o,u,l;return e(this,(function(e){switch(e.label){case 0:return c$1(n)?(t=n[0],r=n[1],o=n[2],[4,P(r,t,(null==o?void 0:o.retries)||i$1,(null==o?void 0:o.delay)||a$1)]):[3,2];case 1:return [2,e.sent()];case 2:return u=n[0],l=n[1],[2,P(u,document,(null==l?void 0:l.retries)||i$1,(null==l?void 0:l.delay)||a$1)]}}))}))}function D$1(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return t(this,void 0,void 0,(function(){var t,r,o,u,l;return e(this,(function(e){switch(e.label){case 0:return c$1(n)?(t=n[0],r=n[1],o=n[2],[4,R$1(r,t,(null==o?void 0:o.retries)||i$1,(null==o?void 0:o.delay)||a$1)]):[3,2];case 1:return [2,e.sent()];case 2:return u=n[0],l=n[1],[2,R$1(u,document,(null==l?void 0:l.retries)||i$1,(null==l?void 0:l.delay)||a$1)]}}))}))}var I$1=function(){function o(t,e){t instanceof Node||t instanceof Promise?(this._element=t,this._asyncParams=n$1({retries:i$1,delay:a$1},e||{})):(this._element=document,this._asyncParams=n$1({retries:i$1,delay:a$1},t||{}));}return Object.defineProperty(o.prototype,"element",{get:function(){return d$1(this._element).then((function(n){return n instanceof NodeList?n[0]||null:n}))},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,r$1,{get:function(){var n=this;return new o(d$1(this._element).then((function(t){return t instanceof Document||t instanceof ShadowRoot||null===t||t instanceof NodeList&&0===t.length?null:t instanceof NodeList?D$1(t[0],r$1,n._asyncParams):D$1(t,r$1,n._asyncParams)})),this._asyncParams)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"all",{get:function(){return d$1(this._element).then((function(n){return n instanceof NodeList?n:document.querySelectorAll(u$1)}))},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"asyncParams",{get:function(){return this._asyncParams},enumerable:!1,configurable:!0}),o.prototype.eq=function(n){return t(this,void 0,void 0,(function(){return e(this,(function(t){return [2,d$1(this._element).then((function(t){return t instanceof NodeList&&t[n]||null}))]}))}))},o.prototype.query=function(n){var t=this;return new o(d$1(this._element).then((function(e){return null===e||e instanceof NodeList&&0===e.length?null:e instanceof NodeList?j(e[0],n,t._asyncParams):j(e,n,t._asyncParams)})),this._asyncParams)},o.prototype.deepQuery=function(n){var t=this;return new o(d$1(this._element).then((function(e){return null===e||e instanceof NodeList&&0===e.length?null:e instanceof NodeList?Promise.race(Array.from(e).map((function(e){return q(e,n,t._asyncParams.retries,t._asyncParams.delay)}))):q(e,n,t._asyncParams.retries,t._asyncParams.delay)})),this._asyncParams)},o}(); | |
var o=function(e,t){return o=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(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,r,O,i,s,a,A,l,c,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||(n={})),function(e){e.HA_PANEL_LOVELACE="HA_PANEL_LOVELACE",e.HUI_ROOT="HUI_ROOT",e.HEADER="HEADER",e.HUI_VIEW="HUI_VIEW";}(r||(r={})),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.HOME_ASSISTANT]={selector:R.HOME_ASSISTANT,children:{shadowRoot:{selector:u,children:(a={},a[n.HOME_ASSISTANT_MAIN]={selector:R.HOME_ASSISTANT_MAIN,children:{shadowRoot:{selector:u,children:(A={},A[n.HA_DRAWER]={selector:R.HA_DRAWER,children:(l={},l[n.HA_SIDEBAR]={selector:R.HA_SIDEBAR,children:{shadowRoot:{selector:u}}},l[n.PARTIAL_PANEL_RESOLVER]={selector:R.PARTIAL_PANEL_RESOLVER},l)},A)}}},a)}}},s),H=((c={})[r.HA_PANEL_LOVELACE]={selector:R.HA_PANEL_LOVELACE,children:{shadowRoot:{selector:u,children:(E={},E[r.HUI_ROOT]={selector:R.HUI_ROOT,children:{shadowRoot:{selector:u,children:(h={},h[r.HEADER]={selector:R.HEADER},h[r.HUI_VIEW]={selector:R.HUI_VIEW},h)}}},E)}}},c),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=!1),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,!0)):n;var A=r?r.then((function(t){return t?Q(t,(_=a.selector,O?"$ "+_:_),o):null;var _;})):Q(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(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:!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.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,this._homeAssistantRootTree),this._haRootElements[n.HOME_ASSISTANT].selector.$.element.then((function(t){e._dialogsObserver.disconnect(),e._dialogsObserver.observe(t,{childList:!0});})),this._haRootElements[n.PARTIAL_PANEL_RESOLVER].element.then((function(t){e._panelResolverObserver.disconnect(),t&&e._panelResolverObserver.observe(t,{subtree:!0,childList:!0});})),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.HA_DRAWER].element),this._haResolverElements=S(r,this._homeAssistantResolverTree),this._haResolverElements[r.HA_PANEL_LOVELACE].element.then((function(t){e._lovelaceObserver.disconnect(),t&&(e._lovelaceObserver.observe(t.shadowRoot,{childList:!0}),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 _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_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_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 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_SIREN"] = "more-info-siren"; | |
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_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_ATTRIBUTES"] = "ha-attributes"; | |
})(ELEMENT || (ELEMENT = {})); | |
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 MAX_ATTEMPTS = 500; | |
var RETRY_DELAY = 50; | |
var WINDOW_RESIZE_DELAY = 250; | |
var toArray = function (x) { | |
return Array.isArray(x) ? x : [x]; | |
}; | |
var getElementName = function (elem) { | |
if (elem instanceof ShadowRoot) { | |
return elem.host.localName; | |
} | |
return elem.localName; | |
}; | |
var styleExists = function (elem) { | |
var name = getElementName(elem); | |
return elem.querySelector("#".concat(STYLES_PREFIX, "_").concat(name)); | |
}; | |
var addStyle = function (css, elem) { | |
if (!elem) | |
return; | |
var name = getElementName(elem); | |
var style = styleExists(elem); | |
if (!style) { | |
style = document.createElement('style'); | |
style.setAttribute('id', "".concat(STYLES_PREFIX, "_").concat(name)); | |
elem.appendChild(style); | |
} | |
style.innerHTML = css; | |
}; | |
var removeStyle = function (elements) { | |
if (!elements) | |
return; | |
toArray(elements).forEach(function (elem) { | |
var name = getElementName(elem); | |
if (styleExists(elem)) { | |
elem.querySelector("#".concat(STYLES_PREFIX, "_").concat(name)).remove(); | |
} | |
}); | |
}; | |
var getCacheKey = function (option) { | |
var optionCamelCase = option.replace(/(?:^|_)([a-z])/g, function (__match, letter) { | |
return letter.toUpperCase(); | |
}); | |
return "km".concat(optionCamelCase); | |
}; | |
var queryString = function (keywords) { | |
var params = new URLSearchParams(window.location.search); | |
return toArray(keywords).some(function (x) { return params.has(x); }); | |
}; | |
var setCache = function (options, value) { | |
toArray(options) | |
.forEach(function (option) { return window.localStorage.setItem(getCacheKey(option), value); }); | |
}; | |
var cached = function (options) { | |
return toArray(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 getCSSString = function (cssInJs) { | |
return Object.entries(cssInJs) | |
.map(function (entry) { | |
var decl = entry[0], value = entry[1]; | |
return "".concat(decl, ":").concat(value); | |
}) | |
.join(';') + ';'; | |
}; | |
var getCSSRulesString = function (cssRulesInJs) { | |
return Object.entries(cssRulesInJs) | |
.map(function (entry) { | |
var rule = entry[0], cssInJs = entry[1]; | |
return "".concat(rule, "{").concat(getCSSString(cssInJs), "}"); | |
}).join(''); | |
}; | |
var getDisplayNoneRulesString = function () { | |
var rules = []; | |
for (var _i = 0; _i < arguments.length; _i++) { | |
rules[_i] = arguments[_i]; | |
} | |
return rules.map(function (rule) { | |
return "".concat(rule, "{display: none !important;}"); | |
}).join(''); | |
}; | |
var getHAResources = function (ha) { | |
var attempts = 0; | |
var referencePaths = Object.values(MENU_REFERENCES); | |
return new Promise(function (resolve, reject) { | |
var getResources = function () { | |
var _a; | |
var resources = (_a = ha === null || ha === void 0 ? void 0 : ha.hass) === null || _a === void 0 ? void 0 : _a.resources; | |
var success = false; | |
if (resources) { | |
var language_1 = ha.hass.language; | |
var anyEmptyResource = referencePaths.find(function (path) { | |
if (resources[language_1][path]) { | |
return false; | |
} | |
return true; | |
}); | |
if (!anyEmptyResource) { | |
success = true; | |
} | |
} | |
if (success) { | |
resolve(resources); | |
} | |
else { | |
attempts++; | |
if (attempts < MAX_ATTEMPTS) { | |
setTimeout(getResources, RETRY_DELAY); | |
} | |
else { | |
reject(); | |
} | |
} | |
}; | |
getResources(); | |
}); | |
}; | |
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 getPromisableElement = function (getElement, check, elementName) { | |
return new Promise(function (resolve, reject) { | |
var attempts = 0; | |
var select = function () { | |
var element = getElement(); | |
if (element && check(element)) { | |
resolve(element); | |
} | |
else { | |
attempts++; | |
if (attempts < MAX_ATTEMPTS) { | |
setTimeout(select, RETRY_DELAY); | |
} | |
else { | |
reject(new Error("".concat(NAMESPACE, ": Cannot select ").concat(elementName, " after ").concat(MAX_ATTEMPTS, " attempts. Giving up!"))); | |
} | |
} | |
}; | |
select(); | |
}); | |
}; | |
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: getCSSRulesString({ | |
'#view': { | |
'min-height': '100vh !important', | |
'--header-height': '0px' | |
}, | |
'.header': { | |
'display': 'none' | |
} | |
}), | |
ACCOUNT: getDisplayNoneRulesString('.profile'), | |
NOTIFICATIONS: getDisplayNoneRulesString('.notifications-container'), | |
DIVIDER: getDisplayNoneRulesString('.divider'), | |
PEPER_LISTBOX: function (hideAccount, hideNotifications) { | |
var size = 132; | |
if (hideAccount && hideNotifications) { | |
size = 0; | |
} | |
else if (hideAccount) { | |
size -= 50; | |
} | |
else if (hideNotifications) { | |
size -= 48; | |
} | |
return getCSSRulesString({ | |
'paper-listbox': { | |
height: "calc(100% - var(--header-height) - ".concat(size, "px - env(safe-area-inset-bottom)) !important") | |
} | |
}); | |
}, | |
MENU_BUTTON: getDisplayNoneRulesString('.menu ha-icon-button'), | |
MENU_BUTTON_BURGER: getDisplayNoneRulesString('ha-menu-button'), | |
MOUSE: getCSSRulesString({ | |
'body::after': { | |
'bottom': '0', | |
'content': '""', | |
'cursor': 'none', | |
'display': 'block', | |
'left': '0', | |
'position': 'fixed', | |
'right': '0', | |
'top': '0', | |
'z-index': '999999' | |
} | |
}), | |
SIDEBAR: getCSSRulesString({ | |
':host': { | |
'--mdc-drawer-width': '0 !important' | |
}, | |
'partial-panel-resolver': { | |
'--mdc-top-app-bar-width': '100% !important' | |
}, | |
'ha-drawer > ha-sidebar': { | |
'display': 'none' | |
}, | |
'.header': { | |
'width': '100% !important' | |
} | |
}), | |
ASIDE: getDisplayNoneRulesString('.mdc-drawer'), | |
OVERFLOW_MENU: getDisplayNoneRulesString("".concat(ELEMENT.TOOLBAR, " > ").concat(ELEMENT.ACTION_ITEMS, " > ").concat(ELEMENT.BUTTON_MENU)), | |
BLOCK_OVERFLOW: getCSSRulesString((_a = {}, | |
_a["".concat(ELEMENT.TOOLBAR, " > ").concat(ELEMENT.ACTION_ITEMS, " > ").concat(ELEMENT.BUTTON_MENU)] = { | |
'pointer-events': 'none !important' | |
}, | |
_a)), | |
SEARCH: getDisplayNoneRulesString("".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: getDisplayNoneRulesString("".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: getDisplayNoneRulesString("".concat(ELEMENT.TOOLBAR, " > ").concat(ELEMENT.ACTION_ITEMS, " > ").concat(ELEMENT.BUTTON_MENU, " > ").concat(ELEMENT.OVERLAY_MENU_ITEM, "[data-selector=\"").concat(MENU.REFRESH, "\"]")), | |
UNUSED_ENTITIES: getDisplayNoneRulesString("".concat(ELEMENT.TOOLBAR, " > ").concat(ELEMENT.ACTION_ITEMS, " > ").concat(ELEMENT.BUTTON_MENU, " > ").concat(ELEMENT.OVERLAY_MENU_ITEM, "[data-selector=\"").concat(MENU.UNUSED_ENTITIES, "\"]")), | |
RELOAD_RESOURCES: getDisplayNoneRulesString("".concat(ELEMENT.TOOLBAR, " > ").concat(ELEMENT.ACTION_ITEMS, " > ").concat(ELEMENT.BUTTON_MENU, " > ").concat(ELEMENT.OVERLAY_MENU_ITEM, "[data-selector=\"").concat(MENU.RELOAD_RESOURCES, "\"]")), | |
EDIT_DASHBOARD: getDisplayNoneRulesString("".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: getDisplayNoneRulesString("".concat(ELEMENT.HA_DIALOG_HEADER, " > ").concat(ELEMENT.MENU_ITEM, "[data-selector=\"").concat(MENU.DIALOG_HISTORY, "\"]")), | |
DIALOG_HEADER_SETTINGS: getDisplayNoneRulesString("".concat(ELEMENT.HA_DIALOG_HEADER, " > ").concat(ELEMENT.MENU_ITEM, "[data-selector=\"").concat(MENU.DIALOG_SETTINGS, "\"]")), | |
DIALOG_HEADER_OVERFLOW: getDisplayNoneRulesString("".concat(ELEMENT.HA_DIALOG_HEADER, " > ").concat(ELEMENT.BUTTON_MENU)), | |
DIALOG_HISTORY: getDisplayNoneRulesString(ELEMENT.HA_DIALOG_HISTORY), | |
DIALOG_LOGBOOK: getDisplayNoneRulesString(ELEMENT.HA_DIALOG_LOGBOOK), | |
DIALOG_ATTRIBUTES: getDisplayNoneRulesString(ELEMENT.HA_DIALOG_ATTRIBUTES), | |
DIALOG_MEDIA_ACTIONS: getDisplayNoneRulesString('.controls'), | |
DIALOG_TIMER_ACTIONS: getDisplayNoneRulesString('.actions'), | |
DIALOG_UPDATE_ACTIONS: getDisplayNoneRulesString('.actions', "hr:has(+ .actions)"), | |
DIALOG_CLIMATE_CONTROL_SELECT: getDisplayNoneRulesString(ELEMENT.HA_DIALOG_CLIMATE_CONTROL_SELECT), | |
DIALOG_CLIMATE_TEMPERATURE_BUTTONS: getDisplayNoneRulesString(ELEMENT.HA_DIALOG_CLIMATE_TEMPERATURE_BUTTONS), | |
DIALOG_CLIMATE_CIRCULAR_SLIDER_INTERACTION: getDisplayNoneRulesString(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_SHOW_MORE: getDisplayNoneRulesString(".header a") | |
}; | |
var version = "5.2.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 (lastIndex === 0) { | |
borderWidthStart = '1px 0 1px 1px'; | |
borderWidthEnd = '1px 1px 1px 0'; | |
} | |
else 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(getCSSString(__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(getCSSString(__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 = {}; | |
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(); | |
if (!this.huiRoot) return [3, 8]; | |
_h = this; | |
return [4, getPromisableElement(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; }, "".concat(ELEMENT.HOME_ASSISTANT, " > hass > user"))]; | |
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(); | |
this.entityWatch(); | |
_l.label = 8; | |
case 8: 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.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, getPromisableElement(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; }, 'Lovelace config') | |
.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) | |
.then(function (menuTranslations) { | |
_this.menuTranslations = menuTranslations; | |
_this.updateMenuItemsLabels(); | |
}) | |
.catch(function () { | |
console.warn("".concat(NAMESPACE, ": ").concat(NON_CRITICAL_WARNING, " Cannot get resources translations")); | |
}); | |
if (cached(Object.values(OPTION)) || | |
queryString(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) { | |
toArray(config.user_settings).forEach(function (conf) { | |
if (toArray(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 _a, _b, _c, _d; | |
if (this.options[OPTION.KIOSK] || | |
this.options[OPTION.HIDE_HEADER]) { | |
addStyle(STYLES.HEADER, this.huiRoot); | |
if (queryString(SPECIAL_QUERY_PARAMS.CACHE)) | |
setCache(OPTION.HIDE_HEADER, TRUE); | |
} | |
else { | |
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]) { | |
(_d = (_c = this.main) === null || _c === void 0 ? void 0 : _c.host) === null || _d === void 0 ? void 0 : _d.addEventListener(TOGGLE_MENU_EVENT, this.blockEventHandler, true); | |
addStyle(STYLES.SIDEBAR, this.drawerLayout); | |
addStyle(STYLES.ASIDE, this.drawerLayout.shadowRoot); | |
if (queryString(SPECIAL_QUERY_PARAMS.CACHE)) | |
setCache(OPTION.HIDE_SIDEBAR, TRUE); | |
} | |
else { | |
removeStyle(this.drawerLayout); | |
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_ACCOUNT] || this.options[OPTION.HIDE_NOTIFICATIONS] | |
? STYLES.PEPER_LISTBOX(this.options[OPTION.HIDE_ACCOUNT], this.options[OPTION.HIDE_NOTIFICATIONS]) | |
: '', | |
this.options[OPTION.HIDE_MENU_BUTTON] | |
? STYLES.MENU_BUTTON : '', | |
]; | |
addStyle(styles.join(''), this.sideBarRoot); | |
if (queryString(SPECIAL_QUERY_PARAMS.CACHE)) { | |
if (this.options[OPTION.HIDE_ACCOUNT]) | |
setCache(OPTION.HIDE_ACCOUNT, TRUE); | |
if (this.options[OPTION.HIDE_NOTIFICATIONS]) | |
setCache(OPTION.HIDE_NOTIFICATIONS, TRUE); | |
} | |
} | |
else { | |
removeStyle(this.sideBarRoot); | |
} | |
if (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.HIDE_OVERFLOW] || | |
this.options[OPTION.BLOCK_OVERFLOW] || | |
this.options[OPTION.HIDE_SIDEBAR] || | |
this.options[OPTION.HIDE_MENU_BUTTON]) { | |
var styles = [ | |
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.HIDE_OVERFLOW] | |
? STYLES.OVERFLOW_MENU : '', | |
this.options[OPTION.BLOCK_OVERFLOW] | |
? STYLES.BLOCK_OVERFLOW : '', | |
this.options[OPTION.HIDE_MENU_BUTTON] || this.options[OPTION.HIDE_SIDEBAR] | |
? STYLES.MENU_BUTTON_BURGER : '', | |
]; | |
addStyle(styles.join(''), this.appToolbar); | |
if (queryString(SPECIAL_QUERY_PARAMS.CACHE)) { | |
if (this.options[OPTION.HIDE_SEARCH]) | |
setCache(OPTION.HIDE_SEARCH, TRUE); | |
if (this.options[OPTION.HIDE_ASSISTANT]) | |
setCache(OPTION.HIDE_ASSISTANT, TRUE); | |
if (this.options[OPTION.HIDE_REFRESH]) | |
setCache(OPTION.HIDE_REFRESH, TRUE); | |
if (this.options[OPTION.HIDE_UNUSED_ENTITIES]) | |
setCache(OPTION.HIDE_UNUSED_ENTITIES, TRUE); | |
if (this.options[OPTION.HIDE_RELOAD_RESOURCES]) | |
setCache(OPTION.HIDE_RELOAD_RESOURCES, TRUE); | |
if (this.options[OPTION.HIDE_EDIT_DASHBOARD]) | |
setCache(OPTION.HIDE_EDIT_DASHBOARD, TRUE); | |
if (this.options[OPTION.HIDE_OVERFLOW]) | |
setCache(OPTION.HIDE_OVERFLOW, TRUE); | |
if (this.options[OPTION.BLOCK_OVERFLOW]) | |
setCache(OPTION.BLOCK_OVERFLOW, TRUE); | |
if (this.options[OPTION.HIDE_MENU_BUTTON]) | |
setCache(OPTION.HIDE_MENU_BUTTON, TRUE); | |
} | |
} | |
else { | |
removeStyle(this.appToolbar); | |
} | |
if (this.options[OPTION.BLOCK_MOUSE]) { | |
addStyle(STYLES.MOUSE, document.body); | |
if (queryString(SPECIAL_QUERY_PARAMS.CACHE)) | |
setCache(OPTION.BLOCK_MOUSE, TRUE); | |
} | |
else { | |
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(OPTION.BLOCK_CONTEXT_MENU, TRUE); | |
} | |
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 legacyMoreInfoDialog, dialog, moreInfoDialogContent, MORE_INFO_CHILD_ROOT, moreInfo, styles, styles, haDialogClimate, haDialogClimateTemperature, haDialogClimateCircularSlider, attributesShadowRoot, haDialogUpdateShadowRoot; | |
var _this = this; | |
return __generator(this, function (_a) { | |
switch (_a.label) { | |
case 0: | |
legacyMoreInfoDialog = Boolean(this.version && | |
(this.version[0] < 2023 || | |
(this.version[0] === 2023 && | |
this.version[1] < 12))); | |
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 (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_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 : '' | |
]; | |
addStyle(styles.join(''), dialog); | |
if (queryString(SPECIAL_QUERY_PARAMS.CACHE)) { | |
if (this.options[OPTION.HIDE_DIALOG_HEADER_ACTION_ITEMS]) | |
setCache(OPTION.HIDE_DIALOG_HEADER_ACTION_ITEMS, TRUE); | |
if (this.options[OPTION.HIDE_DIALOG_HEADER_HISTORY]) | |
setCache(OPTION.HIDE_DIALOG_HEADER_HISTORY, TRUE); | |
if (this.options[OPTION.HIDE_DIALOG_HEADER_SETTINGS]) | |
setCache(OPTION.HIDE_DIALOG_HEADER_SETTINGS, TRUE); | |
if (this.options[OPTION.HIDE_DIALOG_HEADER_OVERFLOW]) | |
setCache(OPTION.HIDE_DIALOG_HEADER_OVERFLOW, TRUE); | |
} | |
} | |
else { | |
removeStyle(dialog); | |
} | |
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 : '' | |
]; | |
addStyle(styles.join(''), moreInfo); | |
if (queryString(SPECIAL_QUERY_PARAMS.CACHE)) { | |
if (this.options[OPTION.HIDE_DIALOG_HISTORY]) | |
setCache(OPTION.HIDE_DIALOG_HISTORY, TRUE); | |
if (this.options[OPTION.HIDE_DIALOG_LOGBOOK]) | |
setCache(OPTION.HIDE_DIALOG_LOGBOOK, TRUE); | |
} | |
} | |
else { | |
removeStyle(moreInfo); | |
} | |
haDialogClimate = legacyMoreInfoDialog | |
? MORE_INFO_CHILD_ROOT | |
.query(ELEMENT.HA_DIALOG_CLIMATE) | |
.$ | |
: MORE_INFO_CHILD_ROOT | |
.query(ELEMENT.HA_DIALOG_MORE_INFO_CONTENT) | |
.$ | |
.query(ELEMENT.HA_DIALOG_CLIMATE) | |
.$; | |
haDialogClimateTemperature = haDialogClimate | |
.query(legacyMoreInfoDialog | |
? ELEMENT.HA_DIALOG_CLIMATE_TEMPERATURE | |
: 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]) { | |
addStyle(STYLES.DIALOG_CLIMATE_CONTROL_SELECT, haDialogClimate); | |
if (queryString(SPECIAL_QUERY_PARAMS.CACHE)) { | |
if (_this.options[OPTION.HIDE_DIALOG_CLIMATE_ACTIONS]) | |
setCache(OPTION.HIDE_DIALOG_CLIMATE_ACTIONS, TRUE); | |
if (_this.options[OPTION.HIDE_DIALOG_CLIMATE_SETTINGS_ACTIONS]) | |
setCache(OPTION.HIDE_DIALOG_CLIMATE_SETTINGS_ACTIONS, TRUE); | |
} | |
} | |
else { | |
removeStyle(haDialogClimate); | |
} | |
}); | |
haDialogClimateTemperature.element.then(function (haDialogClimateTemperature) { | |
if (_this.options[OPTION.HIDE_DIALOG_CLIMATE_ACTIONS] || | |
_this.options[OPTION.HIDE_DIALOG_CLIMATE_TEMPERATURE_ACTIONS]) { | |
addStyle(STYLES.DIALOG_CLIMATE_TEMPERATURE_BUTTONS, haDialogClimateTemperature); | |
if (queryString(SPECIAL_QUERY_PARAMS.CACHE)) { | |
if (_this.options[OPTION.HIDE_DIALOG_CLIMATE_TEMPERATURE_ACTIONS]) | |
setCache(OPTION.HIDE_DIALOG_CLIMATE_TEMPERATURE_ACTIONS, TRUE); | |
} | |
} | |
else { | |
removeStyle(haDialogClimateTemperature); | |
} | |
}); | |
haDialogClimateCircularSlider.element.then(function (haDialogClimateCircularSlider) { | |
if (_this.options[OPTION.HIDE_DIALOG_CLIMATE_ACTIONS] || | |
_this.options[OPTION.HIDE_DIALOG_CLIMATE_TEMPERATURE_ACTIONS]) { | |
addStyle(STYLES.DIALOG_CLIMATE_CIRCULAR_SLIDER_INTERACTION, haDialogClimateCircularSlider); | |
} | |
else { | |
removeStyle(haDialogClimateCircularSlider); | |
} | |
}); | |
MORE_INFO_CHILD_ROOT | |
.query(ELEMENT.HA_DIALOG_HISTORY) | |
.$ | |
.element | |
.then(function (dialogHistory) { | |
if (_this.options[OPTION.HIDE_DIALOG_HISTORY_SHOW_MORE]) { | |
addStyle(STYLES.DIALOG_SHOW_MORE, dialogHistory); | |
if (queryString(SPECIAL_QUERY_PARAMS.CACHE)) | |
setCache(OPTION.HIDE_DIALOG_HISTORY_SHOW_MORE, TRUE); | |
} | |
else { | |
removeStyle(dialogHistory); | |
} | |
}); | |
MORE_INFO_CHILD_ROOT | |
.query(ELEMENT.HA_DIALOG_LOGBOOK) | |
.$ | |
.element | |
.then(function (dialogLogbook) { | |
if (_this.options[OPTION.HIDE_DIALOG_LOGBOOK_SHOW_MORE]) { | |
addStyle(STYLES.DIALOG_SHOW_MORE, dialogLogbook); | |
if (queryString(SPECIAL_QUERY_PARAMS.CACHE)) | |
setCache(OPTION.HIDE_DIALOG_LOGBOOK_SHOW_MORE, TRUE); | |
} | |
else { | |
removeStyle(dialogLogbook); | |
} | |
}); | |
attributesShadowRoot = legacyMoreInfoDialog | |
? MORE_INFO_CHILD_ROOT | |
.query([ | |
"".concat(ELEMENT.HA_DIALOG_MORE_INFO_CONTENT, " > ").concat(ELEMENT.HA_DIALOG_DEFAULT), | |
"".concat(ELEMENT.HA_DIALOG_MORE_INFO_CONTENT, " > ").concat(ELEMENT.HA_DIALOG_VACUUM), | |
"".concat(ELEMENT.HA_DIALOG_MORE_INFO_CONTENT, " > ").concat(ELEMENT.HA_DIALOG_TIMER), | |
"".concat(ELEMENT.HA_DIALOG_MORE_INFO_CONTENT, " > ").concat(ELEMENT.HA_DIALOG_LIGHT), | |
"".concat(ELEMENT.HA_DIALOG_MORE_INFO_CONTENT, " > ").concat(ELEMENT.HA_DIALOG_SIREN), | |
"".concat(ELEMENT.HA_DIALOG_MORE_INFO_CONTENT, " > ").concat(ELEMENT.HA_DIALOG_MEDIA_PLAYER) | |
].join(',')) | |
.$ | |
.element | |
: MORE_INFO_CHILD_ROOT | |
.query(ELEMENT.HA_DIALOG_MORE_INFO_CONTENT) | |
.$ | |
.query([ | |
ELEMENT.HA_DIALOG_DEFAULT, | |
ELEMENT.HA_DIALOG_VACUUM, | |
ELEMENT.HA_DIALOG_TIMER, | |
ELEMENT.HA_DIALOG_LIGHT, | |
ELEMENT.HA_DIALOG_SIREN, | |
ELEMENT.HA_DIALOG_MEDIA_PLAYER | |
].join(',')) | |
.$ | |
.element; | |
attributesShadowRoot | |
.then(function (dialogChild) { | |
if (_this.options[OPTION.HIDE_DIALOG_ATTRIBUTES] || | |
_this.options[OPTION.HIDE_DIALOG_TIMER_ACTIONS] || | |
_this.options[OPTION.HIDE_DIALOG_MEDIA_ACTIONS]) { | |
var styles = [ | |
_this.options[OPTION.HIDE_DIALOG_ATTRIBUTES] ? STYLES.DIALOG_ATTRIBUTES : '', | |
_this.options[OPTION.HIDE_DIALOG_TIMER_ACTIONS] ? STYLES.DIALOG_TIMER_ACTIONS : '', | |
(_this.options[OPTION.HIDE_DIALOG_MEDIA_ACTIONS] && | |
dialogChild.host.localName === ELEMENT.HA_DIALOG_MEDIA_PLAYER) | |
? STYLES.DIALOG_MEDIA_ACTIONS | |
: '', | |
]; | |
addStyle(styles.join(''), dialogChild); | |
if (queryString(SPECIAL_QUERY_PARAMS.CACHE)) { | |
if (_this.options[OPTION.HIDE_DIALOG_ATTRIBUTES]) | |
setCache(OPTION.HIDE_DIALOG_ATTRIBUTES, TRUE); | |
if (_this.options[OPTION.HIDE_DIALOG_TIMER_ACTIONS]) | |
setCache(OPTION.HIDE_DIALOG_TIMER_ACTIONS, TRUE); | |
if (_this.options[OPTION.HIDE_DIALOG_MEDIA_ACTIONS]) | |
setCache(OPTION.HIDE_DIALOG_MEDIA_ACTIONS, TRUE); | |
} | |
} | |
else { | |
removeStyle(dialogChild); | |
} | |
}); | |
haDialogUpdateShadowRoot = legacyMoreInfoDialog | |
? MORE_INFO_CHILD_ROOT | |
.query("".concat(ELEMENT.HA_DIALOG_MORE_INFO_CONTENT, " > ").concat(ELEMENT.HA_DIALOG_UPDATE)) | |
.$ | |
.element | |
: MORE_INFO_CHILD_ROOT | |
.query(ELEMENT.HA_DIALOG_MORE_INFO_CONTENT) | |
.$ | |
.query(ELEMENT.HA_DIALOG_UPDATE) | |
.$ | |
.element; | |
haDialogUpdateShadowRoot | |
.then(function (dialogChild) { | |
if (_this.options[OPTION.HIDE_DIALOG_UPDATE_ACTIONS]) { | |
addStyle(STYLES.DIALOG_UPDATE_ACTIONS, dialogChild); | |
if (queryString(SPECIAL_QUERY_PARAMS.CACHE)) | |
setCache(OPTION.HIDE_DIALOG_UPDATE_ACTIONS, TRUE); | |
} | |
else { | |
removeStyle(dialogChild); | |
} | |
}); | |
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) { | |
if (overflowMenuItem && | |
overflowMenuItem.dataset && | |
!overflowMenuItem.dataset.selector) { | |
var textContent = overflowMenuItem.textContent.trim(); | |
overflowMenuItem.dataset.selector = _this.menuTranslations[textContent]; | |
} | |
}); | |
}); | |
} | |
}; | |
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) { | |
var _a, _b; | |
return __awaiter(this, void 0, void 0, function () { | |
var entities; | |
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