forked from andrey-git/home-assistant-custom-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstate-card-custom-ui-es5.html
3 lines (3 loc) · 58 KB
/
state-card-custom-ui-es5.html
1
2
3
<script>/*! For license information please see scripts-es5.js.LICENSE */
!function(t){var e={};function n(i){if(e[i])return e[i].exports;var o=e[i]={i:i,l:!1,exports:{}};return t[i].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:i})},n.r=function(t){Object.defineProperty(t,"__esModule",{value:!0})},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=0)}([function(t,e,n){"use strict";function i(t,e,n){var i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];t._themes||(t._themes={});var o=e.default_theme;("default"===n||n&&e.themes[n])&&(o=n);var a=Object.assign({},t._themes);if("default"!==o){var r=e.themes[o];Object.keys(r).forEach(function(e){var n="--"+e;t._themes[n]="",a[n]=r[e]})}if(t.updateStyles?t.updateStyles(a):window.ShadyCSS&&window.ShadyCSS.styleSubtree(t,a),i){var s=document.querySelector("meta[name=theme-color]");if(s){s.hasAttribute("default-content")||s.setAttribute("default-content",s.getAttribute("content"));var l=a["--primary-color"]||s.getAttribute("default-content");s.setAttribute("content",l)}}}function o(t){return t.substr(0,t.indexOf("."))}function a(t){return o(t.entity_id)}function r(t,e,n){var i=t,o=void 0;i.lastChild&&i.lastChild.tagName===e?o=i.lastChild:(i.lastChild&&i.removeChild(i.lastChild),o=document.createElement(e.toLowerCase())),o.setProperties?o.setProperties(n):Object.keys(n).forEach(function(t){o[t]=n[t]}),null===o.parentNode&&i.appendChild(o)}n.r(e);var s=["climate","cover","configurator","input_select","input_number","input_text","lock","media_player","scene","script","timer","vacuum","weblink"];new Set(["fan","input_boolean","light","switch"]),n(1);var l=function(){function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}(),c=function(){function t(e){!function(e,n){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this),this.value=e.toString()}return l(t,[{key:"toString",value:function(){return this.value}}]),t}();var u,d,p=function(t){for(var e=document.createElement("template"),n=arguments.length,i=Array(n>1?n-1:0),o=1;o<n;o++)i[o-1]=arguments[o];return e.innerHTML=i.reduce(function(e,n,i){return e+function(t){if(t instanceof HTMLTemplateElement)return t.innerHTML;if(t instanceof c)return function(t){if(t instanceof c)return t.value;throw new Error("non-literal value passed to Polymer's htmlLiteral function: "+t)}(t);throw new Error("non-template value passed to Polymer's html function: "+t)}(n)+t[i+1]},t[0]),e},h=function(){function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}(),m=function(){function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}(),f=(u=["\n <style include=\"ha-style\"></style>\n <app-header-layout has-scrolling-region>\n <app-header slot=\"header\" fixed>\n <app-toolbar>\n <paper-icon-button\n icon='mdi:arrow-left'\n on-click='_backHandler'\n ></paper-icon-button>\n <div main-title>Custom UI settings</div>\n </app-toolbar>\n </app-header>\n\n <ha-config-section is-wide='[[isWide]]'>\n <paper-card heading='Device name'>\n <div class='card-content'>\n Set device name so that you can reference it in per-device settings\n <paper-input\n label='Name'\n value='{{name}}'\n ></paper-input>\n </div>\n </paper-card>\n </ha-config-section>\n </app-header-layout>\n "],d=["\n <style include=\"ha-style\"></style>\n <app-header-layout has-scrolling-region>\n <app-header slot=\"header\" fixed>\n <app-toolbar>\n <paper-icon-button\n icon='mdi:arrow-left'\n on-click='_backHandler'\n ></paper-icon-button>\n <div main-title>Custom UI settings</div>\n </app-toolbar>\n </app-header>\n\n <ha-config-section is-wide='[[isWide]]'>\n <paper-card heading='Device name'>\n <div class='card-content'>\n Set device name so that you can reference it in per-device settings\n <paper-input\n label='Name'\n value='{{name}}'\n ></paper-input>\n </div>\n </paper-card>\n </ha-config-section>\n </app-header-layout>\n "],Object.freeze(Object.defineProperties(u,{raw:{value:Object.freeze(d)}}))),b=function(t){function e(){return function(t,n){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this),function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,(n=Polymer.Element,function(t){function e(){return function(t,n){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this),function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,n),h(e,[{key:"fire",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=new Event(t,{bubbles:void 0===n.bubbles||n.bubbles,cancelable:Boolean(n.cancelable),composed:void 0===n.composed||n.composed});return i.detail=e,(n.node||this).dispatchEvent(i),i}}]),e}())),m(e,[{key:"ready",value:function(){(function t(e,n,i){null===e&&(e=Function.prototype);var o=Object.getOwnPropertyDescriptor(e,n);if(void 0===o){var a=Object.getPrototypeOf(e);return null===a?void 0:t(a,n,i)}if("value"in o)return o.value;var r=o.get;return void 0!==r?r.call(i):void 0})(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"ready",this).call(this),this.name=window.customUI.getName()}},{key:"nameChanged",value:function(t){window.customUI.setName(t)}},{key:"_backHandler",value:function(){window.history.back(),this.fire("location-changed")}}],[{key:"template",get:function(){return p(f)}},{key:"properties",get:function(){return{isWide:Boolean,name:{type:String,observer:"nameChanged"}}}}]),e;var n}();customElements.define("ha-config-custom-ui",b);var y={DOMAIN_DEVICE_CLASS:{binary_sensor:["battery","cold","connectivity","door","garage_door","gas","heat","light","lock","moisture","motion","moving","occupancy","opening","plug","power","presence","problem","safety","smoke","sound","vibration","window"],cover:["garage"],sensor:["battery","humidity","illuminance","temperature"]},UNKNOWN_TYPE:"json",ADD_TYPE:"key-value",TYPE_TO_TAG:{string:"ha-customize-string",json:"ha-customize-string",icon:"ha-customize-icon",boolean:"ha-customize-boolean",array:"ha-customize-array","key-value":"ha-customize-key-value"}};y.LOGIC_STATE_ATTRIBUTES=y.LOGIC_STATE_ATTRIBUTES||{entity_picture:void 0,friendly_name:{type:"string",description:"Name"},icon:{type:"icon"},emulated_hue:{type:"boolean",domains:["emulated_hue"]},emulated_hue_name:{type:"string",domains:["emulated_hue"]},haaska_hidden:void 0,haaska_name:void 0,homebridge_hidden:{type:"boolean"},homebridge_name:{type:"string"},supported_features:void 0,attribution:void 0,custom_ui_more_info:{type:"string"},custom_ui_state_card:{type:"string"},device_class:{type:"array",options:y.DOMAIN_DEVICE_CLASS,description:"Device class",domains:["binary_sensor","cover","sensor"]},hidden:{type:"boolean",description:"Hide from UI"},assumed_state:{type:"boolean",domains:["switch","light","cover","climate","fan","group"]},initial_state:{type:"string",domains:["automation"]},unit_of_measurement:{type:"string"}};var g=y;window.hassAttributeUtil=window.hassAttributeUtil||{};var v=["single-line","break-slider","break-slider-toggle","hide-slider","no-slider"],_={group:void 0,device:void 0,templates:void 0,state:void 0,_stateDisplay:void 0,control_element:{type:"string"},state_card_mode:{type:"array",options:{light:v.concat("badges"),cover:v.concat("badges"),climate:v.concat("badges"),"*":["badges"]}},state_card_custom_ui_secondary:{type:"string"},badges_list:{type:"json"},show_last_changed:{type:"boolean"},hide_control:{type:"boolean"},extra_data_template:{type:"string"},extra_badge:{type:"json"},stretch_slider:{type:"boolean"},slider_theme:{type:"json"},theme:{type:"string"},confirm_controls:{type:"boolean"},confirm_controls_show_lock:{type:"boolean"},hide_in_default_view:{type:"boolean"},icon_color:{type:"string"}};window.hassAttributeUtil.LOGIC_STATE_ATTRIBUTES=g.LOGIC_STATE_ATTRIBUTES,window.hassAttributeUtil.UNKNOWN_TYPE=g.UNKNOWN_TYPE,Object.assign(window.hassAttributeUtil.LOGIC_STATE_ATTRIBUTES,_),window.customUI=window.customUI||{SUPPORTED_SLIDER_MODES:["single-line","break-slider","break-slider-toggle","hide-slider","no-slider"],domHost:function(t){if(t===document)return null;var e=t.getRootNode();return e instanceof DocumentFragment?e.host:e},lightOrShadow:function(t,e){return t.shadowRoot?t.shadowRoot.querySelector(e):t.querySelector(e)},getElementHierarchy:function(t,e){if(null===t)return null;var n=e.shift();return n?window.customUI.getElementHierarchy(window.customUI.lightOrShadow(t,n),e):t},getContext:function(t){if(void 0===t._context){t._context=[];for(var e="HA-ENTITIES-CARD"===t.tagName?window.customUI.domHost(t):t;e;e=window.customUI.domHost(e))switch(e.tagName){case"HA-ENTITIES-CARD":e.groupEntity?t._context.push(e.groupEntity.entity_id):!1===e.groupEntity&&e.states&&e.states.length&&t._context.push("group."+a(e.states[0]));break;case"MORE-INFO-GROUP":case"STATE-CARD-CONTENT":e.stateObj&&t._context.push(e.stateObj.entity_id);break;case"HA-CARDS":t._context.push(e.getAttribute("data-view")||"default_view")}t._context.reverse()}return t._context},findMatch:function(t,e){return e?e[t]?t:Object.keys(e).find(function(e){return t.match("^"+e+"$")}):null},maybeChangeObjectByDevice:function(t){var e=window.customUI.getName();if(!e)return t;var n=this.findMatch(e,t.attributes.device);if(!n)return t;var i=Object.assign({},t.attributes.device[n]);return Object.keys(i).length?window.customUI.applyAttributes(t,i):t},maybeChangeObjectByGroup:function(t,e){var n=this,i=window.customUI.getContext(t);if(!i)return e;if(!e.attributes.group)return e;var o={};return i.forEach(function(t){var i=n.findMatch(t,e.attributes.group);e.attributes.group[i]&&Object.assign(o,e.attributes.group[i])}),Object.keys(o).length?window.customUI.applyAttributes(e,o):e},_setKeep:function(t,e){void 0===t._cui_keep?t._cui_keep=e:t._cui_keep=t._cui_keep&&e},maybeApplyTemplateAttributes:function(t,e,n,i){if(!i.templates)return window.customUI._setKeep(n,!0),n;var o={},a=!1,r=!1;if(Object.keys(i.templates).forEach(function(s){var l=i.templates[s];l.match(/\b(entities|hass)\b/)&&(a=!0);var c=window.customUI.computeTemplate(l,t,e,n,i,n.untemplated_attributes&&n.untemplated_attributes[s]||i[s],n.untemplated_state||n.state);null!==c&&(o[s]=c,"state"===s?c!==n.state&&(r=!0):"_stateDisplay"===s?c!==n._stateDisplay&&(r=!0):c!==i[s]&&(r=!0))}),window.customUI._setKeep(n,!a),!r)return n;if(n.attributes===i){var s=window.customUI.applyAttributes(n,o);return Object.prototype.hasOwnProperty.call(o,"state")&&null!==o.state&&(s.state=String(o.state),s.untemplated_state=n.state),Object.prototype.hasOwnProperty.call(o,"_stateDisplay")&&(s._stateDisplay=o._stateDisplay,s.untemplated_stateDisplay=n._stateDisplay),window.customUI._setKeep(s,!a),s}return Object.assign({},n)},maybeApplyTemplates:function(t,e,n){var i=window.customUI.maybeApplyTemplateAttributes(t,e,n,n.attributes),o=i!==n;function a(n){n&&(Object.values(n).forEach(function(n){var a=window.customUI.maybeApplyTemplateAttributes(t,e,i,n);o|=a!==i}),a(n.device),a(n.group))}return a(n.attributes.device),a(n.attributes.group),i!==n?i:o?Object.assign({},n):n},applyAttributes:function(t,e){return{entity_id:t.entity_id,state:t.state,attributes:Object.assign({},t.attributes,e),untemplated_attributes:t.attributes,last_changed:t.last_changed}},maybeChangeObject:function(t,e,n,i){if(n)return e;var o=window.customUI.maybeChangeObjectByDevice(e);return o=window.customUI.maybeChangeObjectByGroup(t,o),(o=window.customUI.maybeApplyTemplateAttributes(t.hass,t.hass.states,o,o.attributes))!==e&&o.attributes.hidden&&i?null:o},fixGroupTitles:function(){var t=window.customUI.getElementHierarchy(document,["home-assistant","home-assistant-main"]);if(null!==t){var e=window.customUI.getElementHierarchy(t,["partial-cards","ha-cards[view-visible]"]);null!==e&&(window.customUI.lightOrShadow(e,".main")||e.$.main).querySelectorAll("ha-entities-card").forEach(function(t){if(t.groupEntity){var e=window.customUI.maybeChangeObject(t,t.groupEntity,!1,!1);e!==t.groupEntity&&e.attributes.friendly_name&&(window.customUI.lightOrShadow(t,".name").textContent=e.attributes.friendly_name)}})}else window.setTimeout(window.customUI.fixGroupTitles,1e3)},controlColumns:function(t){var e=window.customUI.getElementHierarchy(document,["home-assistant","home-assistant-main","partial-cards"]);if(null!==e){var n=e.handleWindowChange||e._updateColumns;e.mqls.forEach(function(t){t.removeListener(n)}),e.mqls=t.map(function(t){var e=window.matchMedia("(min-width: "+t+"px)");return e.addListener(n),e}),n()}else window.setTimeout(window.customUI.controlColumns.bind(null,t),1e3)},useCustomizer:function(){var t=window.customUI.lightOrShadow(document,"home-assistant").hass.states["customizer.customizer"];t&&(t.attributes.columns&&window.customUI.controlColumns(t.attributes.columns),t.attributes.hide_attributes&&window.hassAttributeUtil&&window.hassAttributeUtil.LOGIC_STATE_ATTRIBUTES&&t.attributes.hide_attributes.forEach(function(t){Object.prototype.hasOwnProperty.call(window.hassAttributeUtil.LOGIC_STATE_ATTRIBUTES,t)||(window.hassAttributeUtil.LOGIC_STATE_ATTRIBUTES[t]=void 0)}))},updateConfigPanel:function(){if(window.location.pathname.startsWith("/config")){var t=window.customUI.getElementHierarchy(document,["home-assistant","home-assistant-main","partial-panel-resolver","ha-panel-config"]);if(t){var e=window.customUI.getElementHierarchy(t,["ha-config-dashboard","ha-config-navigation"]);e&&(e.localize&&!e.cuiPatch&&(e.cuiPatch=!0,e._originalComputeLoaded=e._computeLoaded,e._originalComputeCaption=e._computeCaption,e._originalComputeDescription=e._computeDescription,e._computeLoaded=function(t,n){return"customui"===n||e._originalComputeLoaded(t,n)},e._computeCaption=function(t,n){return"customui"===t?"Custom UI":e._originalComputeCaption(t,n)},e._computeDescription=function(t,n){return"customui"===t?"SetUI tweaks":e._originalComputeDescription(t,n)}),e.pages.some(function(t){return"customui"===t||"customui"===t.domain})||e.push("pages",e.localize?"customui":{domain:"customui",caption:"Custom UI",description:"Set UI tweaks.",loaded:!0}));var n=function(){var e=document.createElement("ha-config-custom-ui");return e.isWide=t.isWide,e.setAttribute("page-name","customui"),e},i=window.customUI.lightOrShadow(t,"iron-pages");if(i){if("HA-CONFIG-CUSTOM-UI"!==i.lastElementChild.tagName){var o=n();i.appendChild(o),i.addEventListener("iron-items-changed",function(){window.location.pathname.startsWith("/config/customui")&&i.select("customui")})}}else{var a=t.shadowRoot||t;if("HA-CONFIG-CUSTOM-UI"!==a.lastElementChild.tagName){var r=n();a.appendChild(r)}var s=window.location.pathname.startsWith("/config/customui");a.lastElementChild.style.display=s?"":"none"}}else window.setTimeout(window.customUI.updateConfigPanel,100)}},installStatesHook:function(){customElements.whenDefined("home-assistant").then(function(){var t=customElements.get("home-assistant");if(t&&t.prototype._updateHass){var e=t.prototype._updateHass;t.prototype._updateHass=function(t){var n=this.hass;t.states&&Object.keys(t.states).forEach(function(e){var i=t.states[e];if(!i._cui_keep){var o=window.customUI.maybeApplyTemplates(n,t.states,i);n.states&&i!==n.states[e]?t.states[e]=o:i!==o&&(t.states[e]=o)}}),e.call(this,t),t.themes&&n._themeWaiters&&(n._themeWaiters.forEach(function(t){return t.stateChanged(t.state)}),n._themeWaiters=void 0)};var n=window.customUI.lightOrShadow(document,"home-assistant");n.hass&&n.hass.states&&n._updateHass({states:n.hass.states})}})},installPartialCards:function(){customElements.whenDefined("partial-cards").then(function(){var t=customElements.get("partial-cards");t&&t.prototype._defaultViewFilter&&(t.prototype._defaultViewFilter=function(t,e){if(t.states[e].attributes.hidden)return!1;var n={};return Object.values(t.states).forEach(function(e){if(e.attributes&&e.attributes.hide_in_default_view){var i=e.entity_id;if(n[i])return;if(n[i]=e,e.attributes.view){var a=function(t,n){var i={};return e.attributes.entity_id.forEach(function(e){var n=t[e];if(n&&!n.attributes.hidden&&(i[n.entity_id]=n,"group"===o(n.entity_id))){var a=function(t,e){var i={};return n.attributes.entity_id.forEach(function(e){var n=t[e];n&&(i[n.entity_id]=n)}),i}(t);Object.keys(a).forEach(function(t){var e=a[t];e.attributes.hidden||(i[t]=e)})}}),i}(t.states);Object.keys(a).filter(function(t){return!1!==a[t].attributes.hide_in_default_view}).forEach(function(t){n[t]=a[t]})}}}),!n[e]})})},installActionName:function(t){customElements.whenDefined(t).then(function(){var e=customElements.get(t);e&&e.prototype&&Object.defineProperty(e.prototype,"localize",{get:function(){return function(t){return this.stateObj&&this.stateObj.attributes&&this.stateObj.attributes.action_name?this.stateObj.attributes.action_name:this.__data.localize(t)}},set:function(){}})})},installHaStateLabelBadge:function(){customElements.whenDefined("ha-state-label-badge").then(function(){var t=customElements.get("ha-state-label-badge");t&&t.prototype.stateChanged&&(t.prototype.stateChanged=function(t){t.attributes.theme&&(null===this.hass.themes?(this.hass._themeWaiters=this.hass._themeWaiters||[],this.hass._themeWaiters.push(this)):i(this,this.hass.themes||{default_theme:"default",themes:{}},t.attributes.theme||"default")),this.updateStyles(),this.startInterval&&this.startInterval(t)})})},installStateBadge:function(){customElements.whenDefined("state-badge").then(function(){var t=customElements.get("state-badge");if(t&&t.prototype._updateIconAppearance){var e=t.prototype._updateIconAppearance;t.prototype._updateIconAppearance=function(t){t.attributes.icon_color&&!t.attributes.entity_picture?(this.style.backgroundImage="",Object.assign(this.$.icon.style,{color:t.attributes.icon_color,filter:""})):e.call(this,t)}}})},installHaAttributes:function(){customElements.whenDefined("ha-attributes").then(function(){var t=customElements.get("ha-attributes");t&&t.prototype.computeFiltersArray&&window.hassAttributeUtil&&(t.prototype.computeFiltersArray=function(t){return Object.keys(window.hassAttributeUtil.LOGIC_STATE_ATTRIBUTES).concat(t?t.split(","):[])})})},installHaFormCustomize:function(){window.location.pathname.startsWith("/config")&&customElements.whenDefined("ha-form-customize").then(function(){var t=customElements.get("ha-form-customize");t?window.customUI.haFormCustomizeInitDone||(window.customUI.haFormCustomizeInitDone=!0,window.hassAttributeUtil&&(t.prototype._computeSingleAttribute&&(t.prototype._computeSingleAttribute=function(t,e,n){var i=window.hassAttributeUtil.LOGIC_STATE_ATTRIBUTES[t]||{type:window.hassAttributeUtil.UNKNOWN_TYPE};return this._initOpenObject(t,"json"===i.type?JSON.stringify(e):e,n,i)}),t.prototype.getNewAttributesOptions&&(t.prototype.getNewAttributesOptions=function(t,e,n,i){var o=this;return Object.keys(window.hassAttributeUtil.LOGIC_STATE_ATTRIBUTES).filter(function(t){var e=window.hassAttributeUtil.LOGIC_STATE_ATTRIBUTES[t];return e&&(!e.domains||!o.entity||e.domains.includes(a(o.entity)))}).filter(this.filterFromAttributes(t)).filter(this.filterFromAttributes(e)).filter(this.filterFromAttributes(n)).filter(this.filterFromAttributes(i)).sort().concat("Other")}))):window.setTimeout(window.customUI.installHaFormCustomize,100)})},installClassHooks:function(){window.customUI.classInitDone||(window.customUI.classInitDone=!0,window.customUI.installPartialCards(),window.customUI.installStatesHook(),window.customUI.installHaStateLabelBadge(),window.customUI.installStateBadge(),window.customUI.installHaAttributes(),window.customUI.installActionName("state-card-scene"),window.customUI.installActionName("state-card-script"))},init:function(){if(!window.customUI.initDone){window.customUI.installClassHooks();var t=window.customUI.lightOrShadow(document,"home-assistant");t.hass&&t.hass.states?(window.customUI.initDone=!0,window.customUI.useCustomizer(),window.customUI.runHooks(),window.addEventListener("location-changed",window.setTimeout.bind(null,window.customUI.runHooks,100)),console.log("Loaded CustomUI 20181217"),window.CUSTOM_UI_LIST||(window.CUSTOM_UI_LIST=[]),window.CUSTOM_UI_LIST.push({name:"CustomUI",version:"20181217",url:"https://github.com/andrey-git/home-assistant-custom-ui"})):window.setTimeout(window.customUI.init,1e3)}},runHooks:function(){window.customUI.fixGroupTitles(),window.customUI.updateConfigPanel(),window.customUI.installHaFormCustomize()},getName:function(){return window.localStorage.getItem("ha-device-name")||""},setName:function(t){window.localStorage.setItem("ha-device-name",t||"")},computeTemplate:function(t,e,n,i,o,a,r){var s=t.indexOf("return")>=0?t:"return `"+t+"`;";try{return new Function("hass","entities","entity","attributes","attribute","state",s)(e,n,i,o,a,r)}catch(t){if(t instanceof SyntaxError||t instanceof ReferenceError)return console.warn(t.name+": "+t.message+" in template "+s),null;throw t}}},window.customUI.init();var w=function(){function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}(),O=function(t){function e(){return function(t,n){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this),function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,Polymer.Element),w(e,[{key:"computeExtra",value:function(t,e){var n=e.attributes.extra_data_template;return n?(Array.isArray(n)||(n=[n]),n.map(function(n){return window.customUI.computeTemplate(n,t,t.states,e,e.attributes,void 0,e.state)}).filter(function(t){return null!==t})):[]}},{key:"showLastChanged",value:function(t,e,n){return!!e||!n.length&&!!t.attributes.show_last_changed}},{key:"hasExtra",value:function(t){return t.length>0}}],[{key:"properties",get:function(){return{hass:Object,inDialog:{type:Boolean,value:!1},stateObj:Object,controlElement:String,extra:{type:Array,computed:"computeExtra(hass, stateObj)"}}}}]),e}(),j=function(){function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}(),x=function(t){function e(){return function(t,n){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this),function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,Polymer.Element),j(e,[{key:"observerFunc",value:function(t,e,n,i){r(this,n?n.toUpperCase():"DIV",{hass:t,stateObj:e,inDialog:i})}}],[{key:"properties",get:function(){return{hass:Object,stateObj:Object,elementName:String,inDialog:{type:Boolean,value:!1}}}},{key:"observers",get:function(){return["observerFunc(hass, stateObj, elementName, inDialog)"]}}]),e}();customElements.define("dynamic-element",x);var k=function(){function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}(),E=function t(e,n,i){null===e&&(e=Function.prototype);var o=Object.getOwnPropertyDescriptor(e,n);if(void 0===o){var a=Object.getPrototypeOf(e);return null===a?void 0:t(a,n,i)}if("value"in o)return o.value;var r=o.get;return void 0!==r?r.call(i):void 0},C=Object.freeze(Object.defineProperties(["\n <style is=\"custom-style\" include=\"iron-flex iron-flex-alignment iron-flex-factors\"></style>\n <style>\n :host {\n display: inline-block;\n }\n .control-wrapper {\n margin: -4px -16px -4px 0;\n padding: 4px 16px;\n }\n ha-state-label-badge {\n margin-left: 8px;\n }\n dynamic-element {\n display: block;\n text-align: right;\n }\n #overlay {\n position: absolute;\n left: 0;\n right: 0;\n top: 0;\n bottom: 0;\n text-align: right;\n z-index: 1;\n }\n #lock {\n margin-top: 8px;\n opacity: 0.3;\n margin-right: 7px;\n }\n #lock.ha-cover-controls {\n margin-right: 52px;\n background-color: white;\n }\n .extra {\n margin-bottom: -16px;\n --ha-label-badge-size: 36px;\n --ha-label-badge-font-size: 1.2em;\n }\n .state {\n @apply --paper-font-body1;\n color: var(--primary-text-color);\n margin-left: 16px;\n text-align: right;\n line-height: 40px;\n }\n </style>\n <div class$='[[extraClass(extraObjVisible)]] horizontal layout'>\n <template is='dom-if' if='[[extraObjVisible]]'>\n <template is='dom-repeat'\n items='[[extraObj]]'\n on-dom-change='extraDomChanged'>\n <ha-state-label-badge hass='[[hass]]' state='[[item]]'></ha-state-label-badge>\n </template>\n </template>\n <template is='dom-if' if='[[_showControl(inDialog, stateObj)]]'>\n <template is='dom-if' if='[[controlElement]]'>\n <div class=\"control-wrapper\">\n <dynamic-element\n class='flex'\n state-obj=\"[[stateObj]]\"\n hass='[[hass]]'\n element-name='[[controlElement]]'>\n </dynamic-element>\n <template is='dom-if' if='[[isConfirmControls(stateObj)]]'>\n <div id=\"overlay\" on-click='clickHandler'>\n <template is='dom-if' if='[[stateObj.attributes.confirm_controls_show_lock]]'>\n <iron-icon id=\"lock\" class$=\"[[controlElement]]\" icon=\"mdi:lock-outline\"></iron-icon>\n </template>\n </div>\n </template>\n </div>\n </template>\n <template is='dom-if' if='[[!controlElement]]'>\n <div class='state'>[[computeStateDisplay(stateObj)]]</div>\n </template>\n </template>\n </div>\n "],{raw:{value:Object.freeze(["\n <style is=\"custom-style\" include=\"iron-flex iron-flex-alignment iron-flex-factors\"></style>\n <style>\n :host {\n display: inline-block;\n }\n .control-wrapper {\n margin: -4px -16px -4px 0;\n padding: 4px 16px;\n }\n ha-state-label-badge {\n margin-left: 8px;\n }\n dynamic-element {\n display: block;\n text-align: right;\n }\n #overlay {\n position: absolute;\n left: 0;\n right: 0;\n top: 0;\n bottom: 0;\n text-align: right;\n z-index: 1;\n }\n #lock {\n margin-top: 8px;\n opacity: 0.3;\n margin-right: 7px;\n }\n #lock.ha-cover-controls {\n margin-right: 52px;\n background-color: white;\n }\n .extra {\n margin-bottom: -16px;\n --ha-label-badge-size: 36px;\n --ha-label-badge-font-size: 1.2em;\n }\n .state {\n @apply --paper-font-body1;\n color: var(--primary-text-color);\n margin-left: 16px;\n text-align: right;\n line-height: 40px;\n }\n </style>\n <div class$='[[extraClass(extraObjVisible)]] horizontal layout'>\n <template is='dom-if' if='[[extraObjVisible]]'>\n <template is='dom-repeat'\n items='[[extraObj]]'\n on-dom-change='extraDomChanged'>\n <ha-state-label-badge hass='[[hass]]' state='[[item]]'></ha-state-label-badge>\n </template>\n </template>\n <template is='dom-if' if='[[_showControl(inDialog, stateObj)]]'>\n <template is='dom-if' if='[[controlElement]]'>\n <div class=\"control-wrapper\">\n <dynamic-element\n class='flex'\n state-obj=\"[[stateObj]]\"\n hass='[[hass]]'\n element-name='[[controlElement]]'>\n </dynamic-element>\n <template is='dom-if' if='[[isConfirmControls(stateObj)]]'>\n <div id=\"overlay\" on-click='clickHandler'>\n <template is='dom-if' if='[[stateObj.attributes.confirm_controls_show_lock]]'>\n <iron-icon id=\"lock\" class$=\"[[controlElement]]\" icon=\"mdi:lock-outline\"></iron-icon>\n </template>\n </div>\n </template>\n </div>\n </template>\n <template is='dom-if' if='[[!controlElement]]'>\n <div class='state'>[[computeStateDisplay(stateObj)]]</div>\n </template>\n </template>\n </div>\n "])}}));customElements.whenDefined("state-card-display").then(function(){var t=function(t){function e(){return function(t,n){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this),function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,customElements.get("state-card-display")),k(e,[{key:"connectedCallback",value:function(){E(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"connectedCallback",this).call(this),this._attached=!0}},{key:"disconnectedCallback",value:function(){this._isAttached=!1,E(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"disconnectedCallback",this).call(this)}},{key:"computeExtra",value:function(t,e,n){var i=this;if(!e.attributes.extra_badge||!n)return[];var o=e.attributes.extra_badge;return Array.isArray(o)||(o=[o]),o.map(function(n){var o=null;if(n.entity_id&&t.states[n.entity_id]?o=Object.assign({},window.customUI.maybeChangeObject(i,t.states[n.entity_id],i.inDialog,!1)):n.attribute&&void 0!==e.attributes[n.attribute]&&(o={state:String(e.attributes[n.attribute]),entity_id:"none.none",attributes:{unit_of_measurement:n.unit}}),!o)return null;var a=n.blacklist_states;return void 0!==a&&(Array.isArray(a)||(a=[a]),a.some(function(t){return RegExp(t).test(o.state.toString())}))?null:(o._entityDisplay="",o)}).filter(function(t){return null!=t})}},{key:"computeExtraVisible",value:function(t,e){return!(e||!t)&&0!==t.length}},{key:"extraClass",value:function(t){return t?"extra":""}},{key:"_showControl",value:function(t,e){return!!t||!e.attributes.hide_control}},{key:"computeStateDisplay",value:function(t){return E(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"computeStateDisplay",this).call(this,this.haLocalize||this.localize,t)}},{key:"isConfirmControls",value:function(t){return t.attributes.confirm_controls||t.attributes.confirm_controls_show_lock}},{key:"clickHandler",value:function(t){var e=this;this.root.querySelector("#overlay").style.pointerEvents="none";var n=this.root.querySelector("#lock");n&&(n.icon="mdi:lock-open-outline",n.style.opacity="0.1"),window.setTimeout(function(){e.root.querySelector("#overlay").style.pointerEvents="",n&&(n.icon="mdi:lock-outline",n.style.opacity="")},5e3),t.stopPropagation()}},{key:"applyThemes",value:function(t,e,n){var o=n.attributes.theme||"default";i(e,t.themes||{default_theme:"default",themes:{}},o)}},{key:"extraDomChanged",value:function(){var t=this;this.root.querySelectorAll("ha-state-label-badge").forEach(function(e){t.applyThemes(t.hass,e,e.state)})}}],[{key:"template",get:function(){return p(C)}},{key:"properties",get:function(){return{hass:Object,inDialog:{type:Boolean,value:!1},stateObj:Object,controlElement:String,extraObj:{type:Array,computed:"computeExtra(hass, stateObj, _attached)"},_attached:Boolean,extraObjVisible:{type:Boolean,computed:"computeExtraVisible(extraObj, inDialog)"}}}}]),e}();customElements.define("dynamic-with-extra",t)});var S=function(){function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}(),T=Object.freeze(Object.defineProperties(["\n <style>\n :host {\n margin: var(--ha-themed-slider-margin, initial);\n }\n .disable-off-when-min {\n --paper-slider-pin-start-color: var(--paper-slider-pin-color);\n }\n\n .disable-off-when-min.is-on {\n --paper-slider-knob-start-color: var(--paper-slider-knob-color);\n --paper-slider-knob-start-border-color: var(--paper-slider-knob-color);\n }\n paper-slider {\n margin: 4px 0;\n max-width: 100%;\n min-width: 100px;\n width: var(--ha-paper-slider-width, 200px);\n }\n </style>\n\n <paper-slider\n min='[[_themedMin]]'\n max='[[_computeAttribute(theme, \"max\", max)]]'\n pin='[[_computeAttribute(theme, \"pin\", pin)]]'\n class$='[[computeClass(theme, isOn, _themedMin)]]' value='[[value]]'\n on-change='valueChanged'>\n </paper-slider>\n "],{raw:{value:Object.freeze(["\n <style>\n :host {\n margin: var(--ha-themed-slider-margin, initial);\n }\n .disable-off-when-min {\n --paper-slider-pin-start-color: var(--paper-slider-pin-color);\n }\n\n .disable-off-when-min.is-on {\n --paper-slider-knob-start-color: var(--paper-slider-knob-color);\n --paper-slider-knob-start-border-color: var(--paper-slider-knob-color);\n }\n paper-slider {\n margin: 4px 0;\n max-width: 100%;\n min-width: 100px;\n width: var(--ha-paper-slider-width, 200px);\n }\n </style>\n\n <paper-slider\n min='[[_themedMin]]'\n max='[[_computeAttribute(theme, \"max\", max)]]'\n pin='[[_computeAttribute(theme, \"pin\", pin)]]'\n class$='[[computeClass(theme, isOn, _themedMin)]]' value='[[value]]'\n on-change='valueChanged'>\n </paper-slider>\n "])}})),I=function(t){function e(){return function(t,n){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this),function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,Polymer.Element),S(e,[{key:"ready",value:function(){(function t(e,n,i){null===e&&(e=Function.prototype);var o=Object.getOwnPropertyDescriptor(e,n);if(void 0===o){var a=Object.getPrototypeOf(e);return null===a?void 0:t(a,n,i)}if("value"in o)return o.value;var r=o.get;return void 0!==r?r.call(i):void 0})(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"ready",this).call(this),this.disableOffWhenMin=!this._computeAttribute(this.theme,"off_when_min",!this.disableOffWhenMin),this.computeEnabledThemedReportWhenNotChanged(this.theme,this.disableReportWhenNotChanged)}},{key:"computeEnabledThemedReportWhenNotChanged",value:function(t,e){this._enabledThemedReportWhenNotChanged=this._computeAttribute(t,"report_when_not_changed",!e)}},{key:"_computeAttribute",value:function(t,e,n){return t&&e in t?t[e]:n}},{key:"computeClass",value:function(t,e,n){var i="";return e&&(i+="is-on "),this._computeAttribute(t,"off_when_min",!this.disableOffWhenMin)||0===n?"":i+"disable-off-when-min"}},{key:"valueChanged",value:function(t){this._enabledThemedReportWhenNotChanged||this.value!==t.target.value?this.value=t.target.value:t.stopPropagation()}}],[{key:"template",get:function(){return p(T)}},{key:"properties",get:function(){return{min:{type:Number,value:0},max:{type:Number,value:100},pin:{type:Boolean,value:!1},isOn:{type:Boolean,value:!1},disableOffWhenMin:{type:Boolean,value:!1,notify:!0},disableReportWhenNotChanged:{type:Boolean,value:!1},theme:Object,value:{type:Number,notify:!0},_themedMin:{type:Number,computed:'_computeAttribute(theme, "min", min)'}}}},{key:"observers",get:function(){return["computeEnabledThemedReportWhenNotChanged(theme, disableReportWhenNotChanged)"]}}]),e}();customElements.define("ha-themed-slider",I);var A=function(t,e){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return function(t,e){var n=[],i=!0,o=!1,a=void 0;try{for(var r,s=t[Symbol.iterator]();!(i=(r=s.next()).done)&&(n.push(r.value),!e||n.length!==e);i=!0);}catch(t){o=!0,a=t}finally{try{!i&&s.return&&s.return()}finally{if(o)throw a}}return n}(t,e);throw new TypeError("Invalid attempt to destructure non-iterable instance")},U=function(){function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}(),P=function t(e,n,i){null===e&&(e=Function.prototype);var o=Object.getOwnPropertyDescriptor(e,n);if(void 0===o){var a=Object.getPrototypeOf(e);return null===a?void 0:t(a,n,i)}if("value"in o)return o.value;var r=o.get;return void 0!==r?r.call(i):void 0},D=Object.freeze(Object.defineProperties(["\n <style is=\"custom-style\" include=\"iron-flex iron-flex-alignment iron-flex-factors\"></style>\n <style>\n #container {\n position: relative;\n }\n .second-line, .state-and-toggle, .state-info {\n max-width: 100%;\n }\n .nowrap .state-and-toggle {\n overflow: hidden;\n flex-grow: 0;\n }\n .nowrap .second-line {\n overflow: hidden;\n }\n\n .second-line {\n padding-top: 20px;\n padding-bottom: 16px;\n margin-top: -20px;\n margin-bottom: -16px;\n }\n .stretch .second-line, .stretch ha-themed-slider {\n width: 100%;\n --ha-paper-slider-width: 100%;\n }\n .nowrap .state-info {\n min-width: initial;\n }\n ha-themed-slider, .top-wrapper {\n min-width: 100px;\n max-width: 100%;\n }\n .top-wrapper.stretch {\n display: block;\n }\n\n .hidden {\n display: none;\n }\n </style>\n\n <div id='container' class$='horizontal layout flex top-wrapper [[_computeWrapClass(mode, stretchSlider, lineTooLong, inDialog)]]'>\n <div class='horizontal layout justified flex-auto state-and-toggle'>\n <state-info\n class='state-info flex-auto'\n hass='[[hass]]'\n state-obj='[[stateObj]]'\n in-dialog='[[showLastChanged(stateObj, inDialog, extra)]]'\n secondary-line$='[[hasExtra(extra)]]'\n >\n <template is='dom-repeat' items='[[extra]]'>\n <div>[[item]]</div>\n </template>\n </state-info>\n <template is='dom-if' if='[[breakSlider]]' class='hidden'>\n <dynamic-with-extra hass='[[hass]]' state-obj='[[stateObj]]' control-element='[[controlElement]]' in-dialog='[[inDialog]]'></dynamic-with-extra>\n </template>\n </div>\n <template is='dom-if' if='[[showSlider]]' restamp>\n <div class='horizontal layout flex-auto end-justified second-line'>\n <ha-themed-slider\n id='slider'\n max=[[max]]\n min=[[min]]\n theme='[[stateObj.attributes.slider_theme]]'\n is-on='[[isOn(stateObj, nameOn)]]'\n value='{{sliderValue}}'\n disable-off-when-min='{{disableOffWhenMin}}'\n on-change='sliderChanged'\n on-click='stopPropagation'>\n </ha-themed-slider>\n <template is='dom-if' if='[[!breakSlider]]'>\n <dynamic-with-extra hass='[[hass]]' state-obj='[[stateObj]]' control-element='[[controlElement]]' in-dialog='[[inDialog]]'></dynamic-with-extra>\n </template>\n </div>\n </template>\n </div>\n "],{raw:{value:Object.freeze(["\n <style is=\"custom-style\" include=\"iron-flex iron-flex-alignment iron-flex-factors\"></style>\n <style>\n #container {\n position: relative;\n }\n .second-line, .state-and-toggle, .state-info {\n max-width: 100%;\n }\n .nowrap .state-and-toggle {\n overflow: hidden;\n flex-grow: 0;\n }\n .nowrap .second-line {\n overflow: hidden;\n }\n\n .second-line {\n padding-top: 20px;\n padding-bottom: 16px;\n margin-top: -20px;\n margin-bottom: -16px;\n }\n .stretch .second-line, .stretch ha-themed-slider {\n width: 100%;\n --ha-paper-slider-width: 100%;\n }\n .nowrap .state-info {\n min-width: initial;\n }\n ha-themed-slider, .top-wrapper {\n min-width: 100px;\n max-width: 100%;\n }\n .top-wrapper.stretch {\n display: block;\n }\n\n .hidden {\n display: none;\n }\n </style>\n\n <div id='container' class$='horizontal layout flex top-wrapper [[_computeWrapClass(mode, stretchSlider, lineTooLong, inDialog)]]'>\n <div class='horizontal layout justified flex-auto state-and-toggle'>\n <state-info\n class='state-info flex-auto'\n hass='[[hass]]'\n state-obj='[[stateObj]]'\n in-dialog='[[showLastChanged(stateObj, inDialog, extra)]]'\n secondary-line$='[[hasExtra(extra)]]'\n >\n <template is='dom-repeat' items='[[extra]]'>\n <div>[[item]]</div>\n </template>\n </state-info>\n <template is='dom-if' if='[[breakSlider]]' class='hidden'>\n <dynamic-with-extra hass='[[hass]]' state-obj='[[stateObj]]' control-element='[[controlElement]]' in-dialog='[[inDialog]]'></dynamic-with-extra>\n </template>\n </div>\n <template is='dom-if' if='[[showSlider]]' restamp>\n <div class='horizontal layout flex-auto end-justified second-line'>\n <ha-themed-slider\n id='slider'\n max=[[max]]\n min=[[min]]\n theme='[[stateObj.attributes.slider_theme]]'\n is-on='[[isOn(stateObj, nameOn)]]'\n value='{{sliderValue}}'\n disable-off-when-min='{{disableOffWhenMin}}'\n on-change='sliderChanged'\n on-click='stopPropagation'>\n </ha-themed-slider>\n <template is='dom-if' if='[[!breakSlider]]'>\n <dynamic-with-extra hass='[[hass]]' state-obj='[[stateObj]]' control-element='[[controlElement]]' in-dialog='[[inDialog]]'></dynamic-with-extra>\n </template>\n </div>\n </template>\n </div>\n "])}})),N=function(t){function e(){return function(t,n){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this),function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,O),U(e,[{key:"ready",value:function(){P(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"ready",this).call(this),this._onIronResize=this._onIronResize.bind(this)}},{key:"connectedCallback",value:function(){P(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"connectedCallback",this).call(this),this._isConnected=!0,window.addEventListener("resize",this._onIronResize),this._waitForLayout()}},{key:"disconnectedCallback",value:function(){window.removeEventListener("resize",this._onIronResize),this._isConnected=!1,P(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"disconnectedCallback",this).call(this)}},{key:"_waitForLayout",value:function(){var t=this;this._isConnected&&(this._setMode(),this._frameId||(this.readyToCompute=!1,this._frameId=window.requestAnimationFrame(function(){t._frameId=null,t.readyToCompute=!0,t._onIronResize()})))}},{key:"_setMode",value:function(){var t={hideSlider:"hide-slider"===this.mode&&this.lineTooLong,breakSlider:("break-slider"===this.mode||"hide-slider"===this.mode)&&this.lineTooLong};this.showSlider||(t.breakSlider=!0),this.setProperties(t)}},{key:"_onIronResize",value:function(){if(this.readyToCompute)if("no-slider"!==this.mode){var t=this.breakSlider,e=this.hideSlider;this.setProperties({lineTooLong:!1,hideSlider:!1,breakSlider:!1});var n=this.$.container,i=n.clientWidth;if(0!==i){if(i<=this.minLineBreak)this.lineTooLong=!0;else if(i>=this.maxLineBreak)this.lineTooLong=!1;else{if(e&&"hide-slider"===this.mode)return void this._waitForLayout();var o=n.clientHeight,a=this.root.querySelector(".state-info").clientHeight;this.lineTooLong=o>1.5*a,this.lineTooLong?this.minLineBreak=i:t||(this.maxLineBreak=i)}this._setMode()}}else this.setProperties({hideSlider:!0,breakSlider:!0})}},{key:"_computeWrapClass",value:function(t,e,n,i){return i?"":"single-line"===t?"nowrap":e&&n?"stretch wrap":"wrap"}},{key:"_showSlider",value:function(t,e,n){return!t&&!n}},{key:"sliderChanged",value:function(t){var e=parseInt(t.target.value,10),n={entity_id:this.stateObj.entity_id};if(!Number.isNaN(e)){var i=this.root.querySelector("#slider");if(t.target!==i)i=t.target;else if(t.path)i=A(t.path,1)[0];else if(t.composedPath){var o=t.composedPath();i=A(o,1)[0]}0===e||e<=i.min&&!this.disableOffWhenMin?this.hass.callService(this.domain,this.serviceMin,n):(n[this.setValueName||this.valueName]=e,this.hass.callService(this.domain,this.serviceMax,n))}}},{key:"stateObjChanged",value:function(t,e,n){var i={sliderValue:this.isOn(t,e)?t.attributes[n]:0};t&&Object.assign(i,{minLineBreak:0,maxLineBreak:999,hideSlider:!1,breakSlider:!1,lineTooLong:!1,mode:t.attributes.state_card_mode,stretchSlider:!!t.attributes.stretch_slider}),this.setProperties(i),t&&this._waitForLayout()}},{key:"isOn",value:function(t,e){return t&&(!e||t.state===e)}},{key:"stopPropagation",value:function(t){t.stopPropagation()}}],[{key:"template",get:function(){return p(D)}},{key:"properties",get:function(){return{domain:String,serviceMin:String,serviceMax:String,valueName:String,setValueName:String,nameOn:{type:String,value:"on"},min:{type:Number,value:0},max:{type:Number,value:255},sliderValue:{type:Number,value:0},disableOffWhenMin:Boolean,mode:String,stretchSlider:{type:Boolean,value:!1},breakSlider:{type:Boolean,value:!1},hideSlider:{type:Boolean,value:!1},lineTooLong:{type:Boolean,value:!1},minLineBreak:Number,maxLineBreak:Number,showSlider:{type:Number,computed:"_showSlider(inDialog, stateObj, hideSlider)"}}}},{key:"observers",get:function(){return["stateObjChanged(stateObj, nameOn, valueName)"]}}]),e}();customElements.define("state-card-with-slider",N);var L=function(){function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}(),z=Object.freeze(Object.defineProperties(["\n <style is=\"custom-style\" include=\"iron-flex iron-flex-alignment\"></style>\n <style>\n #container {\n position: relative;\n }\n </style>\n\n <div id='container' class='horizontal layout justified'>\n <state-info\n hass='[[hass]]'\n class='state-info'\n state-obj='[[stateObj]]'\n in-dialog='[[showLastChanged(stateObj, inDialog, extra)]]'\n secondary-line$='[[hasExtra(extra)]]'>\n <template is='dom-repeat' items='[[extra]]'>\n <div>[[item]]</div>\n </template>\n </state-info>\n <dynamic-with-extra\n hass='[[hass]]'\n state-obj='[[stateObj]]'\n control-element='[[controlElement]]'\n in-dialog='[[inDialog]]'>\n </dynamic-with-extra>\n </div>\n "],{raw:{value:Object.freeze(["\n <style is=\"custom-style\" include=\"iron-flex iron-flex-alignment\"></style>\n <style>\n #container {\n position: relative;\n }\n </style>\n\n <div id='container' class='horizontal layout justified'>\n <state-info\n hass='[[hass]]'\n class='state-info'\n state-obj='[[stateObj]]'\n in-dialog='[[showLastChanged(stateObj, inDialog, extra)]]'\n secondary-line$='[[hasExtra(extra)]]'>\n <template is='dom-repeat' items='[[extra]]'>\n <div>[[item]]</div>\n </template>\n </state-info>\n <dynamic-with-extra\n hass='[[hass]]'\n state-obj='[[stateObj]]'\n control-element='[[controlElement]]'\n in-dialog='[[inDialog]]'>\n </dynamic-with-extra>\n </div>\n "])}})),R=function(t){function e(){return function(t,n){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this),function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,O),L(e,null,[{key:"template",get:function(){return p(z)}}]),e}();customElements.define("state-card-without-slider",R);var B=function(){function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}(),H=function t(e,n,i){null===e&&(e=Function.prototype);var o=Object.getOwnPropertyDescriptor(e,n);if(void 0===o){var a=Object.getPrototypeOf(e);return null===a?void 0:t(a,n,i)}if("value"in o)return o.value;var r=o.get;return void 0!==r?r.call(i):void 0},M=["configurator"],W={light:1,cover:4,climate:1},F={toggle:"ha-entity-toggle",display:"",cover:"ha-cover-controls"},G=function(t){function e(){return function(t,n){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this),function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,Polymer.Element),B(e,[{key:"connectedCallback",value:function(){H(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"connectedCallback",this).call(this);var t=this.parentNode.parentNode;"DIV"===t.tagName&&(t.classList.contains("state")||t.classList.contains("child-card"))&&(this._container=t,t.style.setProperty("background-color","var(--paper-card-background-color, inherit)"),t.updateStyles||(t.updateStyles=function(e){Object.keys(e).forEach(function(n){t.style.setProperty(n,e[n])})})),this._isAttached=!0,this.inputChanged(this.hass,this.inDialog,this.stateObj)}},{key:"disconnectedCallback",value:function(){this._isAttached=!1,this._container&&(this._container.updateStyles({display:"",margin:"",padding:""}),i(this._container,this.hass.themes||{default_theme:"default",themes:{}},"default"),this._container=null),H(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"disconnectedCallback",this).call(this)}},{key:"badgeMode",value:function(t,e,n){var i=this,o=[];if("group"===n)e.attributes.entity_id.forEach(function(n){var a=t.states[n];a?e.attributes.badges_list&&!e.attributes.badges_list.includes(a.entity_id)||o.push(window.customUI.maybeChangeObject(i,a,!1,!1)):console.warn("Unknown ID "+n+" in group "+e.entity_id)});else if(o.push(e),this._container){this._container.style.display="inline-block";var a={display:"inline-block"};this._container.classList.contains("state")&&(a.margin="var(--ha-badges-card-margin, 0)"),this.updateStyles(a)}r(this,"HA-BADGES-CARD",{hass:t,states:o}),this._container&&this._container.updateStyles({width:"var(--ha-badges-card-width, initial)","text-align":"var(--ha-badges-card-text-align, initial)"}),this.lastChild.style.fontSize="85%",this.style.setProperty("--ha-state-label-badge-margin-bottom","0")}},{key:"cleanBadgeStyle",value:function(){this._container&&this._container.updateStyles({display:"",width:"","text-align":""}),this.updateStyles({display:"",margin:""})}},{key:"applyThemes",value:function(t,e){var n=this,o="default";this._container&&(n=this._container),e.attributes.theme&&(o=e.attributes.theme),i(n,t.themes||{default_theme:"default",themes:{}},o)}},{key:"maybeHideEntity",value:function(t){return t?(this._container&&this._container.updateStyles({margin:"",padding:""}),!1):(this.lastChild&&this.removeChild(this.lastChild),this._container&&this._container.updateStyles({margin:"0",padding:"0"}),!0)}},{key:"sliderEligible_",value:function(t,e,n){return!n&&W[t]&&W[t]&e.attributes.supported_features&&e.attributes.state_card_mode&&"no-slider"!==e.attributes.state_card_mode}},{key:"inputChanged",value:function(t,e,n){if(n&&t&&this._isAttached){var i=a(n),o=window.customUI.maybeChangeObject(this,n,e,!0);this.maybeHideEntity(o)||(this.applyThemes(t,o),e||"badges"!==o.attributes.state_card_mode?this.regularMode_(t,e,o,i):this.badgeMode(t,o,i))}}},{key:"regularMode_",value:function(t,e,n,i){this.cleanBadgeStyle();var o={hass:t,stateObj:n,inDialog:e},l=function(t,e){if("unavailable"===e.state)return"display";var n=a(e);return s.includes(n)?n:function(t,e){var n=a(e);return"group"===n?"on"===e.state||"off"===e.state:"climate"===n?!!(4096&(e.attributes||{}).supported_features):function(t,e){var n=t.services[e];return!!n&&("lock"===e?"lock"in n:"cover"===e?"open_cover"in n:"turn_on"in n)}(t,n)}(t,e)&&"hidden"!==e.attributes.control?"toggle":"display"}(t,n),c=void 0,u=n.attributes.state_card_custom_ui_secondary;"light"===i&&this.sliderEligible_(i,n,e)?(Object.assign(o,{controlElement:"ha-entity-toggle",serviceMin:"turn_off",serviceMax:"turn_on",valueName:"brightness",domain:i}),c="state-card-with-slider"):"cover"===i&&this.sliderEligible_(i,n,e)?(Object.assign(o,{controlElement:"ha-cover-controls",max:100,serviceMin:"close_cover",serviceMax:"set_cover_position",setValueName:"position",valueName:"current_position",nameOn:"open",domain:i}),c="state-card-with-slider"):"climate"===i&&this.sliderEligible_(i,n,e)?(Object.assign(o,{controlElement:"ha-climate-state",min:n.attributes.min_temp||-100,max:n.attributes.max_temp||200,serviceMin:"set_temperature",serviceMax:"set_temperature",valueName:"temperature",nameOn:"",domain:i}),c="state-card-with-slider"):void 0!==F[l]?(o.controlElement=F[l],c="state-card-without-slider"):n.attributes.show_last_changed&&!M.includes(l)&&(o.inDialog=!0),"unavailable"===n.state&&(o.controlElement=""),void 0!==n.attributes.control_element&&(o.controlElement=n.attributes.control_element),r(this,(u||c||"STATE-CARD-"+l).toUpperCase(),o)}}],[{key:"properties",get:function(){return{hass:Object,inDialog:{type:Boolean,value:!1},stateObj:Object}}},{key:"observers",get:function(){return["inputChanged(hass, inDialog, stateObj)"]}}]),e}();customElements.define("state-card-custom-ui",G)},function(t,e){window.JSCompiler_renameProperty=function(t){return t}}]);
//# sourceMappingURL=scripts-es5.js.map</script>