UNPKG

iobroker.lovelace

Version:

With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI

3 lines 78.8 kB
/*! For license information please see chunk.2e8d27378043fa4c0a8a.js.LICENSE.txt */
(self.webpackChunkhome_assistant_frontend=self.webpackChunkhome_assistant_frontend||[]).push([[2896],{51654:function(e,t,n){"use strict";n.d(t,{Z:function(){return o},n:function(){return a}});n(43437);var r=n(75009),i=n(87156),o={hostAttributes:{role:"dialog",tabindex:"-1"},properties:{modal:{type:Boolean,value:!1},__readied:{type:Boolean,value:!1}},observers:["_modalChanged(modal, __readied)"],listeners:{tap:"_onDialogClick"},ready:function(){this.__prevNoCancelOnOutsideClick=this.noCancelOnOutsideClick,this.__prevNoCancelOnEscKey=this.noCancelOnEscKey,this.__prevWithBackdrop=this.withBackdrop,this.__readied=!0},_modalChanged:function(e,t){t&&(e?(this.__prevNoCancelOnOutsideClick=this.noCancelOnOutsideClick,this.__prevNoCancelOnEscKey=this.noCancelOnEscKey,this.__prevWithBackdrop=this.withBackdrop,this.noCancelOnOutsideClick=!0,this.noCancelOnEscKey=!0,this.withBackdrop=!0):(this.noCancelOnOutsideClick=this.noCancelOnOutsideClick&&this.__prevNoCancelOnOutsideClick,this.noCancelOnEscKey=this.noCancelOnEscKey&&this.__prevNoCancelOnEscKey,this.withBackdrop=this.withBackdrop&&this.__prevWithBackdrop))},_updateClosingReasonConfirmed:function(e){this.closingReason=this.closingReason||{},this.closingReason.confirmed=e},_onDialogClick:function(e){for(var t=(0,i.vz)(e).path,n=0,r=t.indexOf(this);n<r;n++){var o=t[n];if(o.hasAttribute&&(o.hasAttribute("dialog-dismiss")||o.hasAttribute("dialog-confirm"))){this._updateClosingReasonConfirmed(o.hasAttribute("dialog-confirm")),this.close(),e.stopPropagation();break}}}},a=[r.$,o]},22626:function(e,t,n){"use strict";n(43437),n(65660),n(1656);var r=n(51654),i=n(9672),o=n(50856);function a(){var e=function(e,t){t||(t=e.slice(0));return Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}(['\n    <style>\n\n      :host {\n        display: block;\n        @apply --layout-relative;\n      }\n\n      :host(.is-scrolled:not(:first-child))::before {\n        content: \'\';\n        position: absolute;\n        top: 0;\n        left: 0;\n        right: 0;\n        height: 1px;\n        background: var(--divider-color);\n      }\n\n      :host(.can-scroll:not(.scrolled-to-bottom):not(:last-child))::after {\n        content: \'\';\n        position: absolute;\n        bottom: 0;\n        left: 0;\n        right: 0;\n        height: 1px;\n        background: var(--divider-color);\n      }\n\n      .scrollable {\n        padding: 0 24px;\n\n        @apply --layout-scroll;\n        @apply --paper-dialog-scrollable;\n      }\n\n      .fit {\n        @apply --layout-fit;\n      }\n    </style>\n\n    <div id="scrollable" class="scrollable" on-scroll="updateScrollState">\n      <slot></slot>\n    </div>\n']);return a=function(){return e},e}(0,i.k)({_template:(0,o.d)(a()),is:"paper-dialog-scrollable",properties:{dialogElement:{type:Object}},get scrollTarget(){return this.$.scrollable},ready:function(){this._ensureTarget(),this.classList.add("no-padding")},attached:function(){this._ensureTarget(),requestAnimationFrame(this.updateScrollState.bind(this))},updateScrollState:function(){this.toggleClass("is-scrolled",this.scrollTarget.scrollTop>0),this.toggleClass("can-scroll",this.scrollTarget.offsetHeight<this.scrollTarget.scrollHeight),this.toggleClass("scrolled-to-bottom",this.scrollTarget.scrollTop+this.scrollTarget.offsetHeight>=this.scrollTarget.scrollHeight)},_ensureTarget:function(){this.dialogElement=this.dialogElement||this.parentElement,this.dialogElement&&this.dialogElement.behaviors&&this.dialogElement.behaviors.indexOf(r.Z)>=0?(this.dialogElement.sizingTarget=this.scrollTarget,this.scrollTarget.classList.remove("fit")):this.dialogElement&&this.scrollTarget.classList.add("fit")}})},50808:function(e,t,n){"use strict";n(43437),n(65660),n(1656),n(47686),n(54242);var r=document.createElement("template");r.setAttribute("style","display: none;"),r.innerHTML='<dom-module id="paper-dialog-shared-styles">\n  <template>\n    <style>\n      :host {\n        display: block;\n        margin: 24px 40px;\n\n        background: var(--paper-dialog-background-color, var(--primary-background-color));\n        color: var(--paper-dialog-color, var(--primary-text-color));\n\n        @apply --paper-font-body1;\n        @apply --shadow-elevation-16dp;\n        @apply --paper-dialog;\n      }\n\n      :host > ::slotted(*) {\n        margin-top: 20px;\n        padding: 0 24px;\n      }\n\n      :host > ::slotted(.no-padding) {\n        padding: 0;\n      }\n\n      \n      :host > ::slotted(*:first-child) {\n        margin-top: 24px;\n      }\n\n      :host > ::slotted(*:last-child) {\n        margin-bottom: 24px;\n      }\n\n      /* In 1.x, this selector was `:host > ::content h2`. In 2.x <slot> allows\n      to select direct children only, which increases the weight of this\n      selector, so we have to re-define first-child/last-child margins below. */\n      :host > ::slotted(h2) {\n        position: relative;\n        margin: 0;\n\n        @apply --paper-font-title;\n        @apply --paper-dialog-title;\n      }\n\n      /* Apply mixin again, in case it sets margin-top. */\n      :host > ::slotted(h2:first-child) {\n        margin-top: 24px;\n        @apply --paper-dialog-title;\n      }\n\n      /* Apply mixin again, in case it sets margin-bottom. */\n      :host > ::slotted(h2:last-child) {\n        margin-bottom: 24px;\n        @apply --paper-dialog-title;\n      }\n\n      :host > ::slotted(.paper-dialog-buttons),\n      :host > ::slotted(.buttons) {\n        position: relative;\n        padding: 8px 8px 8px 24px;\n        margin: 0;\n\n        color: var(--paper-dialog-button-color, var(--primary-color));\n\n        @apply --layout-horizontal;\n        @apply --layout-end-justified;\n      }\n    </style>\n  </template>\n</dom-module>',document.head.appendChild(r.content);var i=n(96540),o=n(51654),a=n(9672),s=n(50856);function c(){var e=function(e,t){t||(t=e.slice(0));return Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}(['\n    <style include="paper-dialog-shared-styles"></style>\n    <slot></slot>\n']);return c=function(){return e},e}(0,a.k)({_template:(0,s.d)(c()),is:"paper-dialog",behaviors:[o.n,i.t],listeners:{"neon-animation-finish":"_onNeonAnimationFinish"},_renderOpened:function(){this.cancelAnimation(),this.playAnimation("entry")},_renderClosed:function(){this.cancelAnimation(),this.playAnimation("exit")},_onNeonAnimationFinish:function(){this.opened?this._finishRenderOpened():this._finishRenderClosed()}})},28417:function(e,t,n){"use strict";n(50808);var r=n(33367),i=n(93592),o=n(87156),a={getTabbableNodes:function(e){var t=[];return this._collectTabbableNodes(e,t)?i.H._sortByTabIndex(t):t},_collectTabbableNodes:function(e,t){if(e.nodeType!==Node.ELEMENT_NODE||!i.H._isVisible(e))return!1;var n,r=e,a=i.H._normalizedTabIndex(r),s=a>0;a>=0&&t.push(r),n="content"===r.localName||"slot"===r.localName?(0,o.vz)(r).getDistributedNodes():(0,o.vz)(r.shadowRoot||r.root||r).children;for(var c=0;c<n.length;c++)s=this._collectTabbableNodes(n[c],t)||s;return s}};function s(e){return(s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function c(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function l(e,t){return(l=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function u(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=f(e);if(t){var i=f(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return d(this,n)}}function d(e,t){return!t||"object"!==s(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function f(e){return(f=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var p=customElements.get("paper-dialog"),h={get _focusableNodes(){return a.getTabbableNodes(this)}},v=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&l(e,t)}(n,e);var t=u(n);function n(){return c(this,n),t.apply(this,arguments)}return n}((0,r.P)([h],p));customElements.define("ha-paper-dialog",v)},5986:function(e,t,n){"use strict";n.d(t,{H0:function(){return r},Lh:function(){return i},F3:function(){return o},t4:function(){return a}});var r=function(e,t){return t.issue_tracker||"https://github.com/home-assistant/home-assistant/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+".concat(e,"%22")},i=function(e,t){return e("component.".concat(t,".title"))||t},o=function(e){return e.callWS({type:"manifest/list"})},a=function(e,t){return e.callWS({type:"manifest/get",integration:t})}},72868:function(e,t,n){"use strict";n.r(t);n(53918),n(22626),n(30879),n(31206);var r=n(15652),i=(n(28417),n(83270)),o=n(11654),a=n(47181),s=n(58831),c=function e(t,n,r){if(1!==n.length)return t[n[0]]||(t[n[0]]={}),e(t[n[0]],n.slice(1),r);t[n[0]]=r},l=function e(t,n){return 1===n.length?t[n[0]]:void 0!==t[n[0]]?e(t[n[0]],n.slice(1)):void 0},u=(n(10983),n(53973),n(89194),n(51095),n(68374),n(14516)),d=n(85415),f=n(57066),p=n(57292),h=n(74186),v=n(73826);n(60033);function m(e){return(m="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function y(e){return function(e){if(Array.isArray(e))return L(e)}(e)||V(e)||N(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function b(e,t,n,r,i,o,a){try{var s=e[o](a),c=s.value}catch(l){return void n(l)}s.done?t(c):Promise.resolve(c).then(r,i)}function k(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var o=e.apply(t,n);function a(e){b(o,r,i,a,s,"next",e)}function s(e){b(o,r,i,a,s,"throw",e)}a(void 0)}))}}function g(){var e=E(["\n          <div>\n            <ha-device-picker\n              allow-custom-entity\n              .curValue=","\n              .hass=","\n              .includeDomains=","\n              .excludeDomains=","\n              .includeDeviceClasses=","\n              .value=","\n              .label=","\n              @value-changed=","\n            ></ha-device-picker>\n          </div>\n        "]);return g=function(){return e},e}function _(){var e=E(["\n      ","\n      <div>\n        <ha-device-picker\n          .hass=","\n          .includeDomains=","\n          .excludeDomains=","\n          .includeDeviceClasses=","\n          .label=","\n          @value-changed=","\n        ></ha-device-picker>\n      </div>\n    "]);return _=function(){return e},e}function w(){var e=E([""]);return w=function(){return e},e}function E(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function C(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function x(e,t){return(x=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function D(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=S(e);if(t){var i=S(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return O(this,n)}}function O(e,t){return!t||"object"!==m(t)&&"function"!=typeof t?P(e):t}function P(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function S(e){return(S=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function j(){j=function(){return e};var e={elementsDefinitionOrder:[["method"],["field"]],initializeInstanceElements:function(e,t){["method","field"].forEach((function(n){t.forEach((function(t){t.kind===n&&"own"===t.placement&&this.defineClassElement(e,t)}),this)}),this)},initializeClassElements:function(e,t){var n=e.prototype;["method","field"].forEach((function(r){t.forEach((function(t){var i=t.placement;if(t.kind===r&&("static"===i||"prototype"===i)){var o="static"===i?e:n;this.defineClassElement(o,t)}}),this)}),this)},defineClassElement:function(e,t){var n=t.descriptor;if("field"===t.kind){var r=t.initializer;n={enumerable:n.enumerable,writable:n.writable,configurable:n.configurable,value:void 0===r?void 0:r.call(e)}}Object.defineProperty(e,t.key,n)},decorateClass:function(e,t){var n=[],r=[],i={static:[],prototype:[],own:[]};if(e.forEach((function(e){this.addElementPlacement(e,i)}),this),e.forEach((function(e){if(!z(e))return n.push(e);var t=this.decorateElement(e,i);n.push(t.element),n.push.apply(n,t.extras),r.push.apply(r,t.finishers)}),this),!t)return{elements:n,finishers:r};var o=this.decorateConstructor(n,t);return r.push.apply(r,o.finishers),o.finishers=r,o},addElementPlacement:function(e,t,n){var r=t[e.placement];if(!n&&-1!==r.indexOf(e.key))throw new TypeError("Duplicated element ("+e.key+")");r.push(e.key)},decorateElement:function(e,t){for(var n=[],r=[],i=e.decorators,o=i.length-1;o>=0;o--){var a=t[e.placement];a.splice(a.indexOf(e.key),1);var s=this.fromElementDescriptor(e),c=this.toElementFinisherExtras((0,i[o])(s)||s);e=c.element,this.addElementPlacement(e,t),c.finisher&&r.push(c.finisher);var l=c.extras;if(l){for(var u=0;u<l.length;u++)this.addElementPlacement(l[u],t);n.push.apply(n,l)}}return{element:e,finishers:r,extras:n}},decorateConstructor:function(e,t){for(var n=[],r=t.length-1;r>=0;r--){var i=this.fromClassDescriptor(e),o=this.toClassDescriptor((0,t[r])(i)||i);if(void 0!==o.finisher&&n.push(o.finisher),void 0!==o.elements){e=o.elements;for(var a=0;a<e.length-1;a++)for(var s=a+1;s<e.length;s++)if(e[a].key===e[s].key&&e[a].placement===e[s].placement)throw new TypeError("Duplicated element ("+e[a].key+")")}}return{elements:e,finishers:n}},fromElementDescriptor:function(e){var t={kind:e.kind,key:e.key,placement:e.placement,descriptor:e.descriptor};return Object.defineProperty(t,Symbol.toStringTag,{value:"Descriptor",configurable:!0}),"field"===e.kind&&(t.initializer=e.initializer),t},toElementDescriptors:function(e){var t;if(void 0!==e)return(t=e,function(e){if(Array.isArray(e))return e}(t)||V(t)||N(t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).map((function(e){var t=this.toElementDescriptor(e);return this.disallowProperty(e,"finisher","An element descriptor"),this.disallowProperty(e,"extras","An element descriptor"),t}),this)},toElementDescriptor:function(e){var t=String(e.kind);if("method"!==t&&"field"!==t)throw new TypeError('An element descriptor\'s .kind property must be either "method" or "field", but a decorator created an element descriptor with .kind "'+t+'"');var n=F(e.key),r=String(e.placement);if("static"!==r&&"prototype"!==r&&"own"!==r)throw new TypeError('An element descriptor\'s .placement property must be one of "static", "prototype" or "own", but a decorator created an element descriptor with .placement "'+r+'"');var i=e.descriptor;this.disallowProperty(e,"elements","An element descriptor");var o={kind:t,key:n,placement:r,descriptor:Object.assign({},i)};return"field"!==t?this.disallowProperty(e,"initializer","A method descriptor"):(this.disallowProperty(i,"get","The property descriptor of a field descriptor"),this.disallowProperty(i,"set","The property descriptor of a field descriptor"),this.disallowProperty(i,"value","The property descriptor of a field descriptor"),o.initializer=e.initializer),o},toElementFinisherExtras:function(e){return{element:this.toElementDescriptor(e),finisher:I(e,"finisher"),extras:this.toElementDescriptors(e.extras)}},fromClassDescriptor:function(e){var t={kind:"class",elements:e.map(this.fromElementDescriptor,this)};return Object.defineProperty(t,Symbol.toStringTag,{value:"Descriptor",configurable:!0}),t},toClassDescriptor:function(e){var t=String(e.kind);if("class"!==t)throw new TypeError('A class descriptor\'s .kind property must be "class", but a decorator created a class descriptor with .kind "'+t+'"');this.disallowProperty(e,"key","A class descriptor"),this.disallowProperty(e,"placement","A class descriptor"),this.disallowProperty(e,"descriptor","A class descriptor"),this.disallowProperty(e,"initializer","A class descriptor"),this.disallowProperty(e,"extras","A class descriptor");var n=I(e,"finisher");return{elements:this.toElementDescriptors(e.elements),finisher:n}},runClassFinishers:function(e,t){for(var n=0;n<t.length;n++){var r=(0,t[n])(e);if(void 0!==r){if("function"!=typeof r)throw new TypeError("Finishers must return a constructor.");e=r}}return e},disallowProperty:function(e,t,n){if(void 0!==e[t])throw new TypeError(n+" can't have a ."+t+" property.")}};return e}function A(e){var t,n=F(e.key);"method"===e.kind?t={value:e.value,writable:!0,configurable:!0,enumerable:!1}:"get"===e.kind?t={get:e.value,configurable:!0,enumerable:!1}:"set"===e.kind?t={set:e.value,configurable:!0,enumerable:!1}:"field"===e.kind&&(t={configurable:!0,writable:!0,enumerable:!0});var r={kind:"field"===e.kind?"field":"method",key:n,placement:e.static?"static":"field"===e.kind?"own":"prototype",descriptor:t};return e.decorators&&(r.decorators=e.decorators),"field"===e.kind&&(r.initializer=e.value),r}function T(e,t){void 0!==e.descriptor.get?t.descriptor.get=e.descriptor.get:t.descriptor.set=e.descriptor.set}function z(e){return e.decorators&&e.decorators.length}function R(e){return void 0!==e&&!(void 0===e.value&&void 0===e.writable)}function I(e,t){var n=e[t];if(void 0!==n&&"function"!=typeof n)throw new TypeError("Expected '"+t+"' to be a function");return n}function F(e){var t=function(e,t){if("object"!==m(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!==m(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===m(t)?t:String(t)}function N(e,t){if(e){if("string"==typeof e)return L(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?L(e,t):void 0}}function L(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function V(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}!function(e,t,n,r){var i=j();if(r)for(var o=0;o<r.length;o++)i=r[o](i);var a=t((function(e){i.initializeInstanceElements(e,s.elements)}),n),s=i.decorateClass(function(e){for(var t=[],n=function(e){return"method"===e.kind&&e.key===o.key&&e.placement===o.placement},r=0;r<e.length;r++){var i,o=e[r];if("method"===o.kind&&(i=t.find(n)))if(R(o.descriptor)||R(i.descriptor)){if(z(o)||z(i))throw new ReferenceError("Duplicated methods ("+o.key+") can't be decorated.");i.descriptor=o.descriptor}else{if(z(o)){if(z(i))throw new ReferenceError("Decorators can't be placed on different accessors with for the same property ("+o.key+").");i.decorators=o.decorators}T(o,i)}else t.push(o)}return t}(a.d.map(A)),e);i.initializeClassElements(a.F,s.elements),i.runClassFinishers(a.F,s.finishers)}([(0,r.Mo)("ha-devices-picker")],(function(e,t){var n,i;return{F:function(t){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&x(e,t)}(r,t);var n=D(r);function r(){var t;C(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return t=n.call.apply(n,[this].concat(o)),e(P(t)),t}return r}(t),d:[{kind:"field",decorators:[(0,r.Cb)({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[(0,r.Cb)()],key:"value",value:void 0},{kind:"field",decorators:[(0,r.Cb)({type:Array,attribute:"include-domains"})],key:"includeDomains",value:void 0},{kind:"field",decorators:[(0,r.Cb)({type:Array,attribute:"exclude-domains"})],key:"excludeDomains",value:void 0},{kind:"field",decorators:[(0,r.Cb)({attribute:"picked-device-label"}),(0,r.Cb)({type:Array,attribute:"include-device-classes"})],key:"includeDeviceClasses",value:void 0},{kind:"field",key:"pickedDeviceLabel",value:void 0},{kind:"field",decorators:[(0,r.Cb)({attribute:"pick-device-label"})],key:"pickDeviceLabel",value:void 0},{kind:"method",key:"render",value:function(){var e=this;if(!this.hass)return(0,r.dy)(w());var t=this._currentDevices;return(0,r.dy)(_(),t.map((function(t){return(0,r.dy)(g(),t,e.hass,e.includeDomains,e.excludeDomains,e.includeDeviceClasses,t,e.pickedDeviceLabel,e._deviceChanged)})),this.hass,this.includeDomains,this.excludeDomains,this.includeDeviceClasses,this.pickDeviceLabel,this._addDevice)}},{kind:"get",key:"_currentDevices",value:function(){return this.value||[]}},{kind:"method",key:"_updateDevices",value:(i=k(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:(0,a.B)(this,"value-changed",{value:t}),this.value=t;case 2:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{kind:"method",key:"_deviceChanged",value:function(e){e.stopPropagation();var t=e.currentTarget.curValue,n=e.detail.value;n!==t&&""===n&&(""===n?this._updateDevices(this._currentDevices.filter((function(e){return e!==t}))):this._updateDevices(this._currentDevices.map((function(e){return e===t?n:e}))))}},{kind:"method",key:"_addDevice",value:(n=k(regeneratorRuntime.mark((function e(t){var n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.stopPropagation(),n=t.detail.value,t.currentTarget.value="",n){e.next=5;break}return e.abrupt("return");case 5:if(!(r=this._currentDevices).includes(n)){e.next=8;break}return e.abrupt("return");case 8:this._updateDevices([].concat(y(r),[n]));case 9:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})}]}}),r.oi);function B(e){return(B="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function M(){var e=Q(["\n      paper-input > ha-icon-button {\n        width: 24px;\n        height: 24px;\n        padding: 2px;\n        color: var(--secondary-text-color);\n      }\n      [hidden] {\n        display: none;\n      }\n    "]);return M=function(){return e},e}function q(e,t,n,r,i,o,a){try{var s=e[o](a),c=s.value}catch(l){return void n(l)}s.done?t(c):Promise.resolve(c).then(r,i)}function U(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var o=e.apply(t,n);function a(e){q(o,r,i,a,s,"next",e)}function s(e){q(o,r,i,a,s,"throw",e)}a(void 0)}))}}function H(){var e=Q(["\n                <ha-icon-button\n                  aria-label=",'\n                  slot="suffix"\n                  class="toggle-button"\n                  .icon=',"\n                >\n                  Toggle\n                </ha-icon-button>\n              "]);return H=function(){return e},e}function K(){var e=Q(["\n                <ha-icon-button\n                  aria-label=",'\n                  slot="suffix"\n                  class="clear-button"\n                  icon="hass:close"\n                  @click=',"\n                  no-ripple\n                >\n                  Clear\n                </ha-icon-button>\n              "]);return K=function(){return e},e}function W(){var e=Q(['\n      <vaadin-combo-box-light\n        item-value-path="id"\n        item-id-path="id"\n        item-label-path="name"\n        .items=',"\n        .value=","\n        .renderer=","\n        @opened-changed=","\n        @value-changed=","\n      >\n        <paper-input\n          .label=",'\n          class="input"\n          autocapitalize="none"\n          autocomplete="off"\n          autocorrect="off"\n          spellcheck="false"\n        >\n          ',"\n          ","\n        </paper-input>\n      </vaadin-combo-box-light>\n      <mwc-button @click=","\n        >Choose individual devices</mwc-button\n      >\n    "]);return W=function(){return e},e}function $(){var e=Q(["\n              <mwc-button @click=","\n                >Choose an area</mwc-button\n              >\n            "]);return $=function(){return e},e}function G(){var e=Q(["\n        <ha-devices-picker\n          @value-changed=","\n          .hass=","\n          .includeDomains=","\n          .includeDeviceClasses=","\n          .value=","\n          .pickDeviceLabel=","\n          .pickedDeviceLabel=","\n        ></ha-devices-picker>\n        ","\n      "]);return G=function(){return e},e}function Z(){var e=Q([""]);return Z=function(){return e},e}function Q(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function J(e){return function(e){if(Array.isArray(e))return fe(e)}(e)||pe(e)||de(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function X(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=de(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}function Y(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ee(e,t){return(ee=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function te(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ve(e);if(t){var i=ve(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return ne(this,n)}}function ne(e,t){return!t||"object"!==B(t)&&"function"!=typeof t?re(e):t}function re(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function ie(){ie=function(){return e};var e={elementsDefinitionOrder:[["method"],["field"]],initializeInstanceElements:function(e,t){["method","field"].forEach((function(n){t.forEach((function(t){t.kind===n&&"own"===t.placement&&this.defineClassElement(e,t)}),this)}),this)},initializeClassElements:function(e,t){var n=e.prototype;["method","field"].forEach((function(r){t.forEach((function(t){var i=t.placement;if(t.kind===r&&("static"===i||"prototype"===i)){var o="static"===i?e:n;this.defineClassElement(o,t)}}),this)}),this)},defineClassElement:function(e,t){var n=t.descriptor;if("field"===t.kind){var r=t.initializer;n={enumerable:n.enumerable,writable:n.writable,configurable:n.configurable,value:void 0===r?void 0:r.call(e)}}Object.defineProperty(e,t.key,n)},decorateClass:function(e,t){var n=[],r=[],i={static:[],prototype:[],own:[]};if(e.forEach((function(e){this.addElementPlacement(e,i)}),this),e.forEach((function(e){if(!se(e))return n.push(e);var t=this.decorateElement(e,i);n.push(t.element),n.push.apply(n,t.extras),r.push.apply(r,t.finishers)}),this),!t)return{elements:n,finishers:r};var o=this.decorateConstructor(n,t);return r.push.apply(r,o.finishers),o.finishers=r,o},addElementPlacement:function(e,t,n){var r=t[e.placement];if(!n&&-1!==r.indexOf(e.key))throw new TypeError("Duplicated element ("+e.key+")");r.push(e.key)},decorateElement:function(e,t){for(var n=[],r=[],i=e.decorators,o=i.length-1;o>=0;o--){var a=t[e.placement];a.splice(a.indexOf(e.key),1);var s=this.fromElementDescriptor(e),c=this.toElementFinisherExtras((0,i[o])(s)||s);e=c.element,this.addElementPlacement(e,t),c.finisher&&r.push(c.finisher);var l=c.extras;if(l){for(var u=0;u<l.length;u++)this.addElementPlacement(l[u],t);n.push.apply(n,l)}}return{element:e,finishers:r,extras:n}},decorateConstructor:function(e,t){for(var n=[],r=t.length-1;r>=0;r--){var i=this.fromClassDescriptor(e),o=this.toClassDescriptor((0,t[r])(i)||i);if(void 0!==o.finisher&&n.push(o.finisher),void 0!==o.elements){e=o.elements;for(var a=0;a<e.length-1;a++)for(var s=a+1;s<e.length;s++)if(e[a].key===e[s].key&&e[a].placement===e[s].placement)throw new TypeError("Duplicated element ("+e[a].key+")")}}return{elements:e,finishers:n}},fromElementDescriptor:function(e){var t={kind:e.kind,key:e.key,placement:e.placement,descriptor:e.descriptor};return Object.defineProperty(t,Symbol.toStringTag,{value:"Descriptor",configurable:!0}),"field"===e.kind&&(t.initializer=e.initializer),t},toElementDescriptors:function(e){var t;if(void 0!==e)return(t=e,function(e){if(Array.isArray(e))return e}(t)||pe(t)||de(t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).map((function(e){var t=this.toElementDescriptor(e);return this.disallowProperty(e,"finisher","An element descriptor"),this.disallowProperty(e,"extras","An element descriptor"),t}),this)},toElementDescriptor:function(e){var t=String(e.kind);if("method"!==t&&"field"!==t)throw new TypeError('An element descriptor\'s .kind property must be either "method" or "field", but a decorator created an element descriptor with .kind "'+t+'"');var n=ue(e.key),r=String(e.placement);if("static"!==r&&"prototype"!==r&&"own"!==r)throw new TypeError('An element descriptor\'s .placement property must be one of "static", "prototype" or "own", but a decorator created an element descriptor with .placement "'+r+'"');var i=e.descriptor;this.disallowProperty(e,"elements","An element descriptor");var o={kind:t,key:n,placement:r,descriptor:Object.assign({},i)};return"field"!==t?this.disallowProperty(e,"initializer","A method descriptor"):(this.disallowProperty(i,"get","The property descriptor of a field descriptor"),this.disallowProperty(i,"set","The property descriptor of a field descriptor"),this.disallowProperty(i,"value","The property descriptor of a field descriptor"),o.initializer=e.initializer),o},toElementFinisherExtras:function(e){return{element:this.toElementDescriptor(e),finisher:le(e,"finisher"),extras:this.toElementDescriptors(e.extras)}},fromClassDescriptor:function(e){var t={kind:"class",elements:e.map(this.fromElementDescriptor,this)};return Object.defineProperty(t,Symbol.toStringTag,{value:"Descriptor",configurable:!0}),t},toClassDescriptor:function(e){var t=String(e.kind);if("class"!==t)throw new TypeError('A class descriptor\'s .kind property must be "class", but a decorator created a class descriptor with .kind "'+t+'"');this.disallowProperty(e,"key","A class descriptor"),this.disallowProperty(e,"placement","A class descriptor"),this.disallowProperty(e,"descriptor","A class descriptor"),this.disallowProperty(e,"initializer","A class descriptor"),this.disallowProperty(e,"extras","A class descriptor");var n=le(e,"finisher");return{elements:this.toElementDescriptors(e.elements),finisher:n}},runClassFinishers:function(e,t){for(var n=0;n<t.length;n++){var r=(0,t[n])(e);if(void 0!==r){if("function"!=typeof r)throw new TypeError("Finishers must return a constructor.");e=r}}return e},disallowProperty:function(e,t,n){if(void 0!==e[t])throw new TypeError(n+" can't have a ."+t+" property.")}};return e}function oe(e){var t,n=ue(e.key);"method"===e.kind?t={value:e.value,writable:!0,configurable:!0,enumerable:!1}:"get"===e.kind?t={get:e.value,configurable:!0,enumerable:!1}:"set"===e.kind?t={set:e.value,configurable:!0,enumerable:!1}:"field"===e.kind&&(t={configurable:!0,writable:!0,enumerable:!0});var r={kind:"field"===e.kind?"field":"method",key:n,placement:e.static?"static":"field"===e.kind?"own":"prototype",descriptor:t};return e.decorators&&(r.decorators=e.decorators),"field"===e.kind&&(r.initializer=e.value),r}function ae(e,t){void 0!==e.descriptor.get?t.descriptor.get=e.descriptor.get:t.descriptor.set=e.descriptor.set}function se(e){return e.decorators&&e.decorators.length}function ce(e){return void 0!==e&&!(void 0===e.value&&void 0===e.writable)}function le(e,t){var n=e[t];if(void 0!==n&&"function"!=typeof n)throw new TypeError("Expected '"+t+"' to be a function");return n}function ue(e){var t=function(e,t){if("object"!==B(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!==B(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===B(t)?t:String(t)}function de(e,t){if(e){if("string"==typeof e)return fe(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?fe(e,t):void 0}}function fe(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function pe(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}function he(e,t,n){return(he="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var r=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=ve(e)););return e}(e,t);if(r){var i=Object.getOwnPropertyDescriptor(r,t);return i.get?i.get.call(n):i.value}})(e,t,n||e)}function ve(e){return(ve=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var me=function(e,t,n){e.firstElementChild||(e.innerHTML="\n    <style>\n      paper-item {\n        width: 100%;\n        margin: -10px 0;\n        padding: 0;\n      }\n      ha-icon-button {\n        float: right;\n      }\n      .devices {\n        display: none;\n      }\n      .devices.visible {\n        display: block;\n      }\n    </style>\n    <paper-item>\n      <paper-item-body two-line=\"\">\n        <div class='name'>[[item.name]]</div>\n        <div secondary>[[item.devices.length]] devices</div>\n      </paper-item-body>\n    </paper-item>\n    "),e.querySelector(".name").textContent=n.item.name,e.querySelector("[secondary]").textContent="".concat(n.item.devices.length.toString()," devices")},ye=(function(e,t,n,r){var i=ie();if(r)for(var o=0;o<r.length;o++)i=r[o](i);var a=t((function(e){i.initializeInstanceElements(e,s.elements)}),n),s=i.decorateClass(function(e){for(var t=[],n=function(e){return"method"===e.kind&&e.key===o.key&&e.placement===o.placement},r=0;r<e.length;r++){var i,o=e[r];if("method"===o.kind&&(i=t.find(n)))if(ce(o.descriptor)||ce(i.descriptor)){if(se(o)||se(i))throw new ReferenceError("Duplicated methods ("+o.key+") can't be decorated.");i.descriptor=o.descriptor}else{if(se(o)){if(se(i))throw new ReferenceError("Decorators can't be placed on different accessors with for the same property ("+o.key+").");i.decorators=o.decorators}ae(o,i)}else t.push(o)}return t}(a.d.map(oe)),e);i.initializeClassElements(a.F,s.elements),i.runClassFinishers(a.F,s.finishers)}([(0,r.Mo)("ha-area-devices-picker")],(function(e,t){var n,i,o=function(t){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&ee(e,t)}(r,t);var n=te(r);function r(){var t;Y(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return t=n.call.apply(n,[this].concat(o)),e(re(t)),t}return r}(t);return{F:o,d:[{kind:"field",decorators:[(0,r.Cb)({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[(0,r.Cb)()],key:"label",value:void 0},{kind:"field",decorators:[(0,r.Cb)()],key:"value",value:void 0},{kind:"field",decorators:[(0,r.Cb)()],key:"area",value:void 0},{kind:"field",decorators:[(0,r.Cb)()],key:"devices",value:void 0},{kind:"field",decorators:[(0,r.Cb)({type:Array,attribute:"include-domains"})],key:"includeDomains",value:void 0},{kind:"field",decorators:[(0,r.Cb)({type:Array,attribute:"exclude-domains"})],key:"excludeDomains",value:void 0},{kind:"field",decorators:[(0,r.Cb)({type:Array,attribute:"include-device-classes"})],key:"includeDeviceClasses",value:void 0},{kind:"field",decorators:[(0,r.Cb)({type:Boolean})],key:"_opened",value:void 0},{kind:"field",decorators:[(0,r.sz)()],key:"_areaPicker",value:function(){return!0}},{kind:"field",decorators:[(0,r.sz)()],key:"_devices",value:void 0},{kind:"field",decorators:[(0,r.sz)()],key:"_areas",value:void 0},{kind:"field",decorators:[(0,r.sz)()],key:"_entities",value:void 0},{kind:"field",key:"_selectedDevices",value:function(){return[]}},{kind:"field",key:"_filteredDevices",value:function(){return[]}},{kind:"field",key:"_getDevices",value:function(){var e=this;return(0,u.Z)((function(t,n,r,i,o,a){if(!t.length)return[];var c,l={},u=X(r);try{for(u.s();!(c=u.n()).done;){var f=c.value;f.device_id&&(f.device_id in l||(l[f.device_id]=[]),l[f.device_id].push(f))}}catch(E){u.e(E)}finally{u.f()}var p=J(t);i&&(p=p.filter((function(e){var t=l[e.id];return!(!t||!t.length)&&l[e.id].some((function(e){return i.includes((0,s.M)(e.entity_id))}))}))),o&&(p=p.filter((function(e){var t=l[e.id];return!t||!t.length||r.every((function(e){return!o.includes((0,s.M)(e.entity_id))}))}))),a&&(p=p.filter((function(t){var n=l[t.id];return!(!n||!n.length)&&l[t.id].some((function(t){var n=e.hass.states[t.entity_id];return!!n&&(n.attributes.device_class&&a.includes(n.attributes.device_class))}))}))),e._filteredDevices=p;var h,v={},m=X(n);try{for(m.s();!(h=m.n()).done;){var y=h.value;v[y.area_id]=y}}catch(E){m.e(E)}finally{m.f()}var b,k={},g=X(p);try{for(g.s();!(b=g.n()).done;){var _=b.value,w=_.area_id;w&&(w in k||(k[w]={id:w,name:v[w].name,devices:[]}),k[w].devices.push(_.id))}}catch(E){g.e(E)}finally{g.f()}return Object.keys(k).sort((function(e,t){return(0,d.q)(k[e].name||"",k[t].name||"")})).map((function(e){return k[e]}))}))}},{kind:"method",key:"hassSubscribe",value:function(){var e=this;return[(0,p.q4)(this.hass.connection,(function(t){e._devices=t})),(0,f.sG)(this.hass.connection,(function(t){e._areas=t})),(0,h.LM)(this.hass.connection,(function(t){e._entities=t}))]}},{kind:"method",key:"updated",value:function(e){if(he(ve(o.prototype),"updated",this).call(this,e),e.has("area")&&this.area)this._areaPicker=!0,this.value=this.area;else if(e.has("devices")&&this.devices){this._areaPicker=!1;var t=this._filteredDevices.map((function(e){return e.id})),n=this.devices.filter((function(e){return t.includes(e)}));this._setValue(n)}}},{kind:"method",key:"render",value:function(){if(!this._devices||!this._areas||!this._entities)return(0,r.dy)(Z());var e=this._getDevices(this._devices,this._areas,this._entities,this.includeDomains,this.excludeDomains,this.includeDeviceClasses);return this._areaPicker&&0!==e.length?(0,r.dy)(W(),e,this._value,me,this._openedChanged,this._areaPicked,void 0===this.label&&this.hass?this.hass.localize("ui.components.device-picker.device"):"".concat(this.label," in area"),this.value?(0,r.dy)(K(),this.hass.localize("ui.components.device-picker.clear"),this._clearValue):"",e.length>0?(0,r.dy)(H(),this.hass.localize("ui.components.device-picker.show_devices"),this._opened?"hass:menu-up":"hass:menu-down"):"",this._switchPicker):(0,r.dy)(G(),this._devicesPicked,this.hass,this.includeDomains,this.includeDeviceClasses,this._selectedDevices,"Add ".concat(this.label," device"),"".concat(this.label," device"),e.length>0?(0,r.dy)($(),this._switchPicker):"")}},{kind:"method",key:"_clearValue",value:function(e){e.stopPropagation(),this._setValue([])}},{kind:"get",key:"_value",value:function(){return this.value||[]}},{kind:"method",key:"_openedChanged",value:function(e){this._opened=e.detail.value}},{kind:"method",key:"_switchPicker",value:(i=U(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._areaPicker=!this._areaPicker;case 1:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{kind:"method",key:"_areaPicked",value:(n=U(regeneratorRuntime.mark((function e(t){var n,r,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=t.detail.value,r=[],(i=t.target).selectedItem&&(r=i.selectedItem.devices),n===this._value&&this._selectedDevices===r||this._setValue(r,n);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{kind:"method",key:"_devicesPicked",value:function(e){e.stopPropagation();var t=e.detail.value;this._setValue(t)}},{kind:"method",key:"_setValue",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";this.value=n,this._selectedDevices=e,setTimeout((function(){(0,a.B)(t,"value-changed",{value:e}),(0,a.B)(t,"change")}),0)}},{kind:"get",static:!0,key:"styles",value:function(){return(0,r.iv)(M())}}]}}),(0,v.f)(r.oi)),n(5986));n(74535);function be(e){return(be="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ke(){var e=je(["\n        ha-paper-dialog {\n          max-width: 500px;\n        }\n        mwc-button.left {\n          margin-right: auto;\n        }\n        paper-dialog-scrollable {\n          margin-top: 10px;\n        }\n        h3 {\n          margin: 10px 0 0 0;\n          font-weight: 500;\n        }\n        .error {\n          color: var(--error-color);\n        }\n      "]);return ke=function(){return e},e}function ge(){var e=je([" ","<br /> "]);return ge=function(){return e},e}function _e(){var e=je(['\n                    <div class="error">\n                      Unknown placeholder<br />\n                      ',"<br />\n                      ","\n                    </div>\n                  "]);return _e=function(){return e},e}function we(){var e=je(["\n                      <ha-entity-picker\n                        .type=","\n                        .placeholder=","\n                        @change=","\n                        .includeDomains=","\n                        .includeDeviceClasses=","\n                        .hass=","\n                        .label=","\n                      ></ha-entity-picker>\n                    "]);return we=function(){return e},e}function Ee(){var e=je(['\n                                <ha-entity-picker\n                                  id="device-entity-picker"\n                                  .type=',"\n                                  .placeholder=","\n                                  .index=","\n                                  @change=","\n                                  .includeDomains=","\n                                  .includeDeviceClasses=","\n                                  .hass=","\n                                  .label=","\n                                  .entityFilter=","\n                                ></ha-entity-picker>\n                              "]);return Ee=function(){return e},e}function Ce(){var e=je(["\n                            <h3>\n                              One or more devices have more than one matching\n                              entity, please pick the one you want to use.\n                            </h3>\n                            ","\n                          "]);return Ce=function(){return e},e}function xe(){var e=je(["\n                      <ha-area-devices-picker\n                        .type=","\n                        .placeholder=","\n                        @value-changed=","\n                        .hass=","\n                        .area=","\n                        .devices=","\n                        .includeDomains=","\n                        .includeDeviceClasses=","\n                        .label=","\n                      ></ha-area-devices-picker>\n                      ","\n                    "]);return xe=function(){return e},e}function De(){var e=je(["\n                <h3>\n                  ",":\n                </h3>\n                ","\n              "]);return De=function(){return e},e}function Oe(e,t){return $e(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var n=[],r=!0,i=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(c){i=!0,o=c}finally{try{r||null==s.return||s.return()}finally{if(i)throw o}}return n}(e,t)||Ke(e,t)||He()}function Pe(){var e=je([' <div class="error">',"</div> "]);return Pe=function(){return e},e}function Se(){var e=je(["\n      <ha-paper-dialog\n        modal\n        with-backdrop\n        .opened=",'\n        @opened-changed="','"\n      >\n        <h2>Great! Now we need to link some devices.</h2>\n        <paper-dialog-scrollable>\n          ',"\n          ",'\n        </paper-dialog-scrollable>\n        <div class="paper-dialog-buttons">\n          <mwc-button class="left" @click="','">\n            Skip\n          </mwc-button>\n          <mwc-button @click="','" .disabled=',">\n            Create automation\n          </mwc-button>\n        </div>\n      </ha-paper-dialog>\n    "]);return Se=function(){return e},e}function je(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function Ae(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Te(e,t){return(Te=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function ze(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=Fe(e);if(t){var i=Fe(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return Re(this,n)}}function Re(e,t){return!t||"object"!==be(t)&&"function"!=typeof t?Ie(e):t}function Ie(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Fe(e){return(Fe=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function Ne(){Ne=function(){return e};var e={elementsDefinitionOrder:[["method"],["field"]],initializeInstanceElements:function(e,t){["method","field"].forEach((function(n){t.forEach((function(t){t.kind===n&&"own"===t.placement&&this.defineClassElement(e,t)}),this)}),this)},initializeClassElements:function(e,t){var n=e.prototype;["method","field"].forEach((function(r){t.forEach((function(t){var i=t.placement;if(t.kind===r&&("static"===i||"prototype"===i)){var o="static"===i?e:n;this.defineClassElement(o,t)}}),this)}),this)},defineClassElement:function(e,t){var n=t.descriptor;if("field"===t.kind){var r=t.initializer;n={enumerable:n.enumerable,writable:n.writable,configurable:n.configurable,value:void 0===r?void 0:r.call(e)}}Object.defineProperty(e,t.key,n)},decorateClass:function(e,t){var n=[],r=[],i={static:[],prototype:[],own:[]};if(e.forEach((function(e){this.addElementPlacement(e,i)}),this),e.forEach((function(e){if(!Be(e))return n.push(e);var t=this.decorateElement(e,i);n.push(t.element),n.push.apply(n,t.extras),r.push.apply(r,t.finishers)}),this),!t)return{elements:n,finishers:r};var o=this.decorateConstructor(n,t);return r.push.apply(r,o.finishers),o.finishers=r,o},addElementPlacement:function(e,t,n){var r=t[e.placement];if(!n&&-1!==r.indexOf(e.key))throw new TypeError("Duplicated element ("+e.key+")");r.push(e.key)},decorateElement:function(e,t){for(var n=[],r=[],i=e.decorators,o=i.length-1;o>=0;o--){var a=t[e.placement];a.splice(a.indexOf(e.key),1);var s=this.fromElementDescriptor(e),c=this.toElementFinisherExtras((0,i[o])(s)||s);e=c.element,this.addElementPlacement(e,t),c.finisher&&r.push(c.finisher);var l=c.extras;if(l){for(var u=0;u<l.length;u++)this.addElementPlacement(l[u],t);n.push.apply(n,l)}}return{element:e,finishers:r,extras:n}},decorateConstructor:function(e,t){for(var n=[],r=t.length-1;r>=0;r--){var i=this.fromClassDescriptor(e),o=this.toClassDescriptor((0,t[r])(i)||i);if(void 0!==o.finisher&&n.push(o.finisher),void 0!==o.elements){e=o.elements;for(var a=0;a<e.length-1;a++)for(var s=a+1;s<e.length;s++)if(e[a].key===e[s].key&&e[a].placement===e[s].placement)throw new TypeError("Duplicated element ("+e[a].key+")")}}return{elements:e,finishers:n}},fromElementDescriptor:function(e){var t={kind:e.kind,key:e.key,placement:e.placement,descriptor:e.descriptor};return Object.defineProperty(t,Symbol.toStringTag,{value:"Descriptor",configurable:!0}),"field"===e.kind&&(t.initializer=e.initializer),t},toElementDescriptors:function(e){var t;if(void 0!==e)return(t=e,$e(t)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(t)||Ke(t)||He()).map((function(e){var t=this.toElementDescriptor(e);return this.disallowProperty(e,"finisher","An element descriptor"),this.disallowProperty(e,"extras","An element descriptor"),t}),this)},toElementDescriptor:function(e){var t=String(e.kind);if("method"!==t&&"field"!==t)throw new TypeError('An element descriptor\'s .kind property must be either "method" or "field", but a decorator created an element descriptor with .kind "'+t+'"');var n=Ue(e.key),r=String(e.placement);if("static"!==r&&"prototype"!==r&&"own"!==r)throw new TypeError('An element descriptor\'s .placement property must be one of "static", "prototype" or "own", but a decorator created an element descriptor with .placement "'+r+'"');var i=e.descriptor;this.disallowProperty(e,"elements","An element descriptor");var o={kind:t,key:n,placement:r,descriptor:Object.assign({},i)};return"field"!==t?this.disallowProperty(e,"initializer","A method descriptor"):(this.disallowProperty(i,"get","The property descriptor of a field descriptor"),this.disallowProperty(i,"set","The property descriptor of a field descriptor"),this.disallowProperty(i,"value","The property descriptor of a field descriptor"),o.initializer=e.initializer),o},toElementFinisherExtras:function(e){return{element:this.toElementDescriptor(e),finisher:qe(e,"finisher"),extras:this.toElementDescriptors(e.extras)}},fromClassDescriptor:function(e){var t={kind:"class",elements:e.map(this.fromElementDescriptor,this)};return Object.defineProperty(t,Symbol.toStringTag,{value:"Descriptor",configurable:!0}),t},toClassDescriptor:function(e){var t=String(e.kind);if("class"!==t)throw new TypeError('A class descriptor\'s .kind property must be "class", but a decorator created a class descriptor with .kind "'+t+'"');this.disallowProperty(e,"key","A class descriptor"),this.disallowProperty(e,"placement","A class descriptor"),this.disallowProperty(e,"descriptor","A class descriptor"),this.disallowProperty(e,"initializer","A class descriptor"),this.disallowProperty(e,"extras","A class descriptor");var n=qe(e,"finisher");return{elements:this.toElementDescriptors(e.elements),finisher:n}},runClassFinishers:function(e,t){for(var n=0;n<t.length;n++){var r=(0,t[n])(e);if(void 0!==r){if("function"!=typeof r)throw new TypeError("Finishers must return a constructor.");e=r}}return e},disallowProperty:function(e,t,n){if(void 0!==e[t])throw new TypeError(n+" can't have a ."+t+" property.")}};return e}function Le(e){var t,n=Ue(e.key);"method"===e.kind?t={value:e.value,writable:!0,configurable:!0,enumerable:!1}:"get"===e.kind?t={get:e.value,configurable:!0,enumerable:!1}:"set"===e.kind?t={set:e.value,configurable:!0,enumerable:!1}:"field"===e.kind&&(t={configurable:!0,writable:!0,enumerable:!0});var r={kind:"field"===e.kind?"field":"method",key:n,placement:e.static?"static":"field"===e.kind?"own":"prototype",descriptor:t};return e.decorators&&(r.decorators=e.decorators),"field"===e.kind&&(r.initializer=e.value),r}function Ve(e,t){void 0!==e.descriptor.get?t.descriptor.get=e.descriptor.get:t.descriptor.set=e.descriptor.set}function Be(e){return e.decorators&&e.decorators.length}function Me(e){return void 0!==e&&!(void 0===e.value&&void 0===e.writable)}function qe(e,t){var n=e[t];if(void 0!==n&&"function"!=typeof n)throw new TypeError("Expected '"+t+"' to be a function");return n}function Ue(e){var t=function(e,t){if("object"!==be(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!==be(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===be(t)?t:String(t)}function He(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Ke(e,t){if(e){if("string"==typeof e)return We(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?We(e,t):void 0}}function We(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function $e(e){if(Array.isArray(e))return e}!function(e,t,n,r){var i=Ne();if(r)for(var o=0;o<r.length;o++)i=r[o](i);var a=t((function(e){i.initializeInstanceElements(e,s.elements)}),n),s=i.decorateClass(function(e){for(var t=[],n=function(e){return"method"===e.kind&&e.key===o.key&&e.placement===o.placement},r=0;r<e.length;r++){var i,o=e[r];if("method"===o.kind&&(i=t.find(n)))if(Me(o.descriptor)||Me(i.descriptor)){if(Be(o)||Be(i))throw new ReferenceError("Duplicated methods ("+o.key+") can't be decorated.");i.descriptor=o.descriptor}else{if(Be(o)){if(Be(i))throw new ReferenceError("Decorators can't be placed on different accessors with for the same property ("+o.key+").");i.decorators=o.decorators}Ve(o,i)}else t.push(o)}return t}(a.d.map(Le)),e);i.initializeClassElements(a.F,s.elements),i.runClassFinishers(a.F,s.finishers)}([(0,r.Mo)("ha-thingtalk-placeholders")],(function(e,t){return{F:function(t){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Te(e,t)}(r,t);var n=ze(r);function r(){var t;Ae(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return t=n.call.apply(n,[this].concat(o)),e(Ie(t)),t}return r}(t),d:[{kind:"field",decorators:[(0,r.Cb)({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[(0,r.Cb)()],key:"opened",value:void 0},{kind:"field",key:"skip",value:void 0},{kind:"field",decorators:[(0,r.Cb)()],key:"placeholders",value:void 0},{kind:"field",decorators:[(0,r.sz)()],key:"_error",value:void 0},{kind:"field",key:"_deviceEntityLookup",value:function(){return{}}},{kind:"field",decorators:[(0,r.sz)()],key:"_extraInfo",value:function(){return{}}},{kind:"field",decorators:[(0,r.sz)()],key:"_placeholderValues",value:function(){return{}}},{kind:"field",key:"_devices",value:void 0},{kind:"field",key:"_areas",value:void 0},{kind:"field",key:"_search",value:function(){return!1}},{kind:"method",key:"hassSubscribe",value:function(){var e=this;return[(0,h.LM)(this.hass.connection,(function(t){var n,r=function(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=Ke(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}(t);try{for(r.s();!(n=r.n()).done;){var i=n.value;i.device_id&&(i.device_id in e._deviceEntityLookup||(e._deviceEntityLookup[i.device_id]=[]),e._deviceEntityLookup[i.device_id].includes(i.entity_id)||e._deviceEntityLookup[i.device_id].push(i.entity_id))}}catch(o){r.e(o)}finally{r.f()}})),(0,p.q4)(this.hass.connection,(function(t){e._devices=t,e._searchNames()})),(0,f.sG)(this.hass.connection,(function(t){e._areas=t,e._searchNames()}))]}},{kind:"method",key:"updated",value:function(e){e.has("placeholders")&&(this._search=!0,this._searchNames())}},{kind:"method",key:"render",value:function(){var e=this;return(0,r.dy)(Se(),this.opened,this._openedChanged,this._error?(0,r.dy)(Pe(),this._error):"",Object.entries(this.placeholders).map((function(t){var n=Oe(t,2),i=n[0],o=n[1];return(0,r.dy)(De(),e.hass.localize("ui.panel.config.automation.editor.".concat(i,"s.name")),o.map((function(t){if(t.fields.includes("device_id")){var n=l(e._extraInfo,[i,t.index]);return(0,r.dy)(xe(),i,t,e._devicePicked,e.hass,n?n.area_id:void 0,n&&n.device_ids?n.device_ids:void 0,t.domains,t.device_classes,e._getLabel(t.domains,t.device_classes),n&&n.manualEntity?(0,r.dy)(Ce(),Object.keys(n.manualEntity).map((function(n){return(0,r.dy)(Ee(),i,t,n,e._entityPicked,t.domains,t.device_classes,e.hass,"".concat(e._getLabel(t.domains,t.device_classes)," of device ").concat(e._getDeviceName(l(e._placeholderValues,[i,t.index,n,"device_id"]))),(function(r){var o=e._placeholderValues[i][t.index][n].device_id;return e._deviceEntityLookup[o].includes(r.entity_id)}))}))):"")}return t.fields.includes("entity_id")?(0,r.dy)(we(),i,t,e._entityPicked,t.domains,t.device_classes,e.hass,e._getLabel(t.domains,t.device_classes)):(0,r.dy)(_e(),t.domains,t.fields.map((function(e){return(0,r.dy)(ge(),e)})))})))})),this.skip,this._done,!this._isDone)}},{kind:"method",key:"_getDeviceName",value:function(e){if(!this._devices)return"";var t=this._devices.find((function(t){return t.id===e}));return t&&(t.name_by_user||t.name)||""}},{kind:"method",key:"_searchNames",value:function(){var e=this;this._search&&this._areas&&this._devices&&(this._search=!1,Object.entries(this.placeholders).forEach((function(t){var n=Oe(t,2),r=n[0];return n[1].forEach((function(t){if(t.name){var n=t.name,i=e._areas.find((function(e){return e.name.toLowerCase().includes(n)}));if(i)return c(e._extraInfo,[r,t.index,"area_id"],i.area_id),void e.requestUpdate("_extraInfo");var o=e._devices.filter((function(e){var t=e.name_by_user||e.name;return!!t&&t.toLowerCase().includes(n)}));o.length&&(c(e._extraInfo,[r,t.index,"device_ids"],o.map((function(e){return e.id}))),e.requestUpdate("_extraInfo"))}}))})))}},{kind:"get",key:"_isDone",value:function(){var e=this;return Object.entries(this.placeholders).every((function(t){var n=Oe(t,2),r=n[0];return n[1].every((function(t){return t.fields.every((function(n){var i=l(e._placeholderValues,[r,t.index]);return!!i&&Object.values(i).every((function(e){return void 0!==e[n]&&""!==e[n]}))}))}))}))}},{kind:"method",key:"_getLabel",value:function(e,t){var n=this;return"".concat(e.map((function(e){return(0,ye.Lh)(n.hass.localize,e)})).join(", ")).concat(t?" of type ".concat(t.join(", ")):"")}},{kind:"method",key:"_devicePicked",value:function(e){var t=this,n=e.detail.value;if(n){var r=e.target,i=r.placeholder,o=r.type,u=l(this._placeholderValues,[o,i.index]);u&&(u=Object.values(u));var d=l(this._extraInfo,[o,i.index]);this._placeholderValues[o]&&delete this._placeholderValues[o][i.index],this._extraInfo[o]&&delete this._extraInfo[o][i.index],n.length?(n.forEach((function(e,n){var r;if(u){var a=u.find((function(t,n){return r=n,t.device_id===e}));if(a)return c(t._placeholderValues,[o,i.index,n],a),void(d&&c(t._extraInfo,[o,i.index,n],d[r]))}if(c(t._placeholderValues,[o,i.index,n,"device_id"],e),i.fields.includes("entity_id")){var l=t._deviceEntityLookup[e].filter((function(e){if(i.device_classes){var n=t.hass.states[e];return!!n&&(i.domains.includes((0,s.M)(e))&&n.attributes.device_class&&i.device_classes.includes(n.attributes.device_class))}return i.domains.includes((0,s.M)(e))}));0===l.length?t._error="No ".concat(i.domains.map((function(e){return(0,ye.Lh)(t.hass.localize,e)})).join(", ")," entities found in this device."):1===l.length?(c(t._placeholderValues,[o,i.index,n,"entity_id"],l[0]),t.requestUpdate("_placeholderValues")):(delete t._placeholderValues[o][i.index][n].entity_id,c(t._extraInfo,[o,i.index,"manualEntity",n],!0),t.requestUpdate("_placeholderValues"))}})),(0,a.B)(this.shadowRoot.querySelector("ha-paper-dialog"),"iron-resize")):this.requestUpdate("_placeholderValues")}}},{kind:"method",key:"_entityPicked",value:function(e){var t=e.target,n=t.placeholder,r=t.value,i=t.type,o=t.index||0;c(this._placeholderValues,[i,n.index,o,"entity_id"],r),this.requestUpdate("_placeholderValues")}},{kind:"method",key:"_done",value:function(){(0,a.B)(this,"placeholders-filled",{value:this._placeholderValues})}},{kind:"method",key:"_openedChanged",value:function(e){this.dispatchEvent(new CustomEvent(e.type,e))}},{kind:"get",static:!0,key:"styles",value:function(){return[o.yu,(0,r.iv)(ke())]}}]}}),(0,v.f)(r.oi));function Ge(e){return(Ge="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Ze(){var e=rt(["\n        ha-paper-dialog {\n          max-width: 500px;\n        }\n        mwc-button.left {\n          margin-right: auto;\n        }\n        .error {\n          color: var(--error-color);\n        }\n        .attribution {\n          color: var(--secondary-text-color);\n        }\n      "]);return Ze=function(){return e},e}function Qe(e,t){return gt(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var n=[],r=!0,i=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(c){i=!0,o=c}finally{try{r||null==s.return||s.return()}finally{if(i)throw o}}return n}(e,t)||bt(e,t)||yt()}function Je(e,t,n,r,i,o,a){try{var s=e[o](a),c=s.value}catch(l){return void n(l)}s.done?t(c):Promise.resolve(c).then(r,i)}function Xe(){var e=rt(['<ha-circular-progress\n                  active\n                  size="small"\n                  title="Creating your automation..."\n                ></ha-circular-progress>']);return Xe=function(){return e},e}function Ye(){var e=rt([' <div class="error">',"</div> "]);return Ye=function(){return e},e}function et(){var e=rt(["\n      <ha-paper-dialog\n        with-backdrop\n        .opened=","\n        @opened-changed=","\n      >\n        <h2>Create a new automation</h2>\n        <paper-dialog-scrollable>\n          ","\n          Type below what this automation should do, and we will try to convert\n          it into a ioBroker automation. (only English is supported for\n          now)<br /><br />\n          For example:\n          <ul @click=",'>\n            <li>\n              <button class="link">\n                Turn off the lights when I leave home\n              </button>\n            </li>\n            <li>\n              <button class="link">\n                Turn on the lights when the sun is set\n              </button>\n            </li>\n            <li>\n              <button class="link">\n                Notify me if the door opens and I am not at home\n              </button>\n            </li>\n            <li>\n              <button class="link">\n                Turn the light on when motion is detected\n              </button>\n            </li>\n          </ul>\n          <paper-input\n            id="input"\n            label="What should this automation do?"\n            autofocus\n            @keyup=','\n          ></paper-input>\n          <a\n            href="https://almond.stanford.edu/"\n            target="_blank"\n            rel="noreferrer"\n            class="attribution"\n            >Powered by Almond</a\n          >\n        </paper-dialog-scrollable>\n        <div class="paper-dialog-buttons">\n          <mwc-button class="left" @click="','">\n            Skip\n          </mwc-button>\n          <mwc-button @click="','" .disabled=',">\n            ","\n            Create automation\n          </mwc-button>\n        </div>\n      </ha-paper-dialog>\n    "]);return et=function(){return e},e}function tt(){var e=rt(["\n        <ha-thingtalk-placeholders\n          .hass=","\n          .placeholders=","\n          .opened=","\n          .skip=","\n          @opened-changed=","\n          @placeholders-filled=","\n        >\n        </ha-thingtalk-placeholders>\n      "]);return tt=function(){return e},e}function nt(){var e=rt([""]);return nt=function(){return e},e}function rt(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function it(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ot(e,t){return(ot=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function at(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=lt(e);if(t){var i=lt(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return st(this,n)}}function st(e,t){return!t||"object"!==Ge(t)&&"function"!=typeof t?ct(e):t}function ct(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function lt(e){return(lt=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function ut(){ut=function(){return e};var e={elementsDefinitionOrder:[["method"],["field"]],initializeInstanceElements:function(e,t){["method","field"].forEach((function(n){t.forEach((function(t){t.kind===n&&"own"===t.placement&&this.defineClassElement(e,t)}),this)}),this)},initializeClassElements:function(e,t){var n=e.prototype;["method","field"].forEach((function(r){t.forEach((function(t){var i=t.placement;if(t.kind===r&&("static"===i||"prototype"===i)){var o="static"===i?e:n;this.defineClassElement(o,t)}}),this)}),this)},defineClassElement:function(e,t){var n=t.descriptor;if("field"===t.kind){var r=t.initializer;n={enumerable:n.enumerable,writable:n.writable,configurable:n.configurable,value:void 0===r?void 0:r.call(e)}}Object.defineProperty(e,t.key,n)},decorateClass:function(e,t){var n=[],r=[],i={static:[],prototype:[],own:[]};if(e.forEach((function(e){this.addElementPlacement(e,i)}),this),e.forEach((function(e){if(!pt(e))return n.push(e);var t=this.decorateElement(e,i);n.push(t.element),n.push.apply(n,t.extras),r.push.apply(r,t.finishers)}),this),!t)return{elements:n,finishers:r};var o=this.decorateConstructor(n,t);return r.push.apply(r,o.finishers),o.finishers=r,o},addElementPlacement:function(e,t,n){var r=t[e.placement];if(!n&&-1!==r.indexOf(e.key))throw new TypeError("Duplicated element ("+e.key+")");r.push(e.key)},decorateElement:function(e,t){for(var n=[],r=[],i=e.decorators,o=i.length-1;o>=0;o--){var a=t[e.placement];a.splice(a.indexOf(e.key),1);var s=this.fromElementDescriptor(e),c=this.toElementFinisherExtras((0,i[o])(s)||s);e=c.element,this.addElementPlacement(e,t),c.finisher&&r.push(c.finisher);var l=c.extras;if(l){for(var u=0;u<l.length;u++)this.addElementPlacement(l[u],t);n.push.apply(n,l)}}return{element:e,finishers:r,extras:n}},decorateConstructor:function(e,t){for(var n=[],r=t.length-1;r>=0;r--){var i=this.fromClassDescriptor(e),o=this.toClassDescriptor((0,t[r])(i)||i);if(void 0!==o.finisher&&n.push(o.finisher),void 0!==o.elements){e=o.elements;for(var a=0;a<e.length-1;a++)for(var s=a+1;s<e.length;s++)if(e[a].key===e[s].key&&e[a].placement===e[s].placement)throw new TypeError("Duplicated element ("+e[a].key+")")}}return{elements:e,finishers:n}},fromElementDescriptor:function(e){var t={kind:e.kind,key:e.key,placement:e.placement,descriptor:e.descriptor};return Object.defineProperty(t,Symbol.toStringTag,{value:"Descriptor",configurable:!0}),"field"===e.kind&&(t.initializer=e.initializer),t},toElementDescriptors:function(e){var t;if(void 0!==e)return(t=e,gt(t)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(t)||bt(t)||yt()).map((function(e){var t=this.toElementDescriptor(e);return this.disallowProperty(e,"finisher","An element descriptor"),this.disallowProperty(e,"extras","An element descriptor"),t}),this)},toElementDescriptor:function(e){var t=String(e.kind);if("method"!==t&&"field"!==t)throw new TypeError('An element descriptor\'s .kind property must be either "method" or "field", but a decorator created an element descriptor with .kind "'+t+'"');var n=mt(e.key),r=String(e.placement);if("static"!==r&&"prototype"!==r&&"own"!==r)throw new TypeError('An element descriptor\'s .placement property must be one of "static", "prototype" or "own", but a decorator created an element descriptor with .placement "'+r+'"');var i=e.descriptor;this.disallowProperty(e,"elements","An element descriptor");var o={kind:t,key:n,placement:r,descriptor:Object.assign({},i)};return"field"!==t?this.disallowProperty(e,"initializer","A method descriptor"):(this.disallowProperty(i,"get","The property descriptor of a field descriptor"),this.disallowProperty(i,"set","The property descriptor of a field descriptor"),this.disallowProperty(i,"value","The property descriptor of a field descriptor"),o.initializer=e.initializer),o},toElementFinisherExtras:function(e){return{element:this.toElementDescriptor(e),finisher:vt(e,"finisher"),extras:this.toElementDescriptors(e.extras)}},fromClassDescriptor:function(e){var t={kind:"class",elements:e.map(this.fromElementDescriptor,this)};return Object.defineProperty(t,Symbol.toStringTag,{value:"Descriptor",configurable:!0}),t},toClassDescriptor:function(e){var t=String(e.kind);if("class"!==t)throw new TypeError('A class descriptor\'s .kind property must be "class", but a decorator created a class descriptor with .kind "'+t+'"');this.disallowProperty(e,"key","A class descriptor"),this.disallowProperty(e,"placement","A class descriptor"),this.disallowProperty(e,"descriptor","A class descriptor"),this.disallowProperty(e,"initializer","A class descriptor"),this.disallowProperty(e,"extras","A class descriptor");var n=vt(e,"finisher");return{elements:this.toElementDescriptors(e.elements),finisher:n}},runClassFinishers:function(e,t){for(var n=0;n<t.length;n++){var r=(0,t[n])(e);if(void 0!==r){if("function"!=typeof r)throw new TypeError("Finishers must return a constructor.");e=r}}return e},disallowProperty:function(e,t,n){if(void 0!==e[t])throw new TypeError(n+" can't have a ."+t+" property.")}};return e}function dt(e){var t,n=mt(e.key);"method"===e.kind?t={value:e.value,writable:!0,configurable:!0,enumerable:!1}:"get"===e.kind?t={get:e.value,configurable:!0,enumerable:!1}:"set"===e.kind?t={set:e.value,configurable:!0,enumerable:!1}:"field"===e.kind&&(t={configurable:!0,writable:!0,enumerable:!0});var r={kind:"field"===e.kind?"field":"method",key:n,placement:e.static?"static":"field"===e.kind?"own":"prototype",descriptor:t};return e.decorators&&(r.decorators=e.decorators),"field"===e.kind&&(r.initializer=e.value),r}function ft(e,t){void 0!==e.descriptor.get?t.descriptor.get=e.descriptor.get:t.descriptor.set=e.descriptor.set}function pt(e){return e.decorators&&e.decorators.length}function ht(e){return void 0!==e&&!(void 0===e.value&&void 0===e.writable)}function vt(e,t){var n=e[t];if(void 0!==n&&"function"!=typeof n)throw new TypeError("Expected '"+t+"' to be a function");return n}function mt(e){var t=function(e,t){if("object"!==Ge(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!==Ge(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===Ge(t)?t:String(t)}function yt(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function bt(e,t){if(e){if("string"==typeof e)return kt(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?kt(e,t):void 0}}function kt(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function gt(e){if(Array.isArray(e))return e}!function(e,t,n,r){var i=ut();if(r)for(var o=0;o<r.length;o++)i=r[o](i);var a=t((function(e){i.initializeInstanceElements(e,s.elements)}),n),s=i.decorateClass(function(e){for(var t=[],n=function(e){return"method"===e.kind&&e.key===o.key&&e.placement===o.placement},r=0;r<e.length;r++){var i,o=e[r];if("method"===o.kind&&(i=t.find(n)))if(ht(o.descriptor)||ht(i.descriptor)){if(pt(o)||pt(i))throw new ReferenceError("Duplicated methods ("+o.key+") can't be decorated.");i.descriptor=o.descriptor}else{if(pt(o)){if(pt(i))throw new ReferenceError("Decorators can't be placed on different accessors with for the same property ("+o.key+").");i.decorators=o.decorators}ft(o,i)}else t.push(o)}return t}(a.d.map(dt)),e);i.initializeClassElements(a.F,s.elements),i.runClassFinishers(a.F,s.finishers)}([(0,r.Mo)("ha-dialog-thinktalk")],(function(e,t){var n,a;return{F:function(t){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&ot(e,t)}(r,t);var n=at(r);function r(){var t;it(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return t=n.call.apply(n,[this].concat(o)),e(ct(t)),t}return r}(t),d:[{kind:"field",decorators:[(0,r.Cb)({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[(0,r.sz)()],key:"_error",value:void 0},{kind:"field",decorators:[(0,r.sz)()],key:"_params",value:void 0},{kind:"field",decorators:[(0,r.sz)()],key:"_submitting",value:function(){return!1}},{kind:"field",decorators:[(0,r.sz)()],key:"_opened",value:function(){return!1}},{kind:"field",decorators:[(0,r.sz)()],key:"_placeholders",value:void 0},{kind:"field",decorators:[(0,r.IO)("#input",!0)],key:"_input",value:void 0},{kind:"field",key:"_value",value:void 0},{kind:"field",key:"_config",value:void 0},{kind:"method",key:"showDialog",value:function(e){this._params=e,this._error=void 0,this._opened=!0}},{kind:"method",key:"render",value:function(){var e=this;return this._params?this._placeholders?(0,r.dy)(tt(),this.hass,this._placeholders,this._opened,(function(){return e._skip()}),this._openedChanged,this._handlePlaceholders):(0,r.dy)(et(),this._opened,this._openedChanged,this._error?(0,r.dy)(Ye(),this._error):"",this._handleExampleClick,this._handleKeyUp,this._skip,this._generate,this._submitting,this._submitting?(0,r.dy)(Xe()):""):(0,r.dy)(nt())}},{kind:"method",key:"_generate",value:(n=regeneratorRuntime.mark((function e(){var t,n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._value=this._input.value,this._value){e.next=4;break}return this._error="Enter a command or tap skip.",e.abrupt("return");case 4:return this._submitting=!0,e.prev=5,e.next=8,(0,i.Wz)(this.hass,this._value);case 8:r=e.sent,t=r.config,n=r.placeholders,e.next=18;break;case 13:return e.prev=13,e.t0=e.catch(5),this._error=e.t0.message,this._submitting=!1,e.abrupt("return");case 18:this._submitting=!1,Object.keys(t).length?Object.keys(n).length?(this._config=t,this._placeholders=n):this._sendConfig(this._value,t):this._error="We couldn't create an automation for that (yet?).";case 20:case"end":return e.stop()}}),e,this,[[5,13]])})),a=function(){var e=this,t=arguments;return new Promise((function(r,i){var o=n.apply(e,t);function a(e){Je(o,r,i,a,s,"next",e)}function s(e){Je(o,r,i,a,s,"throw",e)}a(void 0)}))},function(){return a.apply(this,arguments)})},{kind:"method",key:"_handlePlaceholders",value:function(e){var t=this,n=e.detail.value;Object.entries(n).forEach((function(e){var n=Qe(e,2),r=n[0],i=n[1];Object.entries(i).forEach((function(e){var n,i=Qe(e,2),o=i[0],a=i[1],s=Object.values(a);if(1!==s.length){var c=Object.assign({},t._config[r][o]),l=[];s.forEach((function(e){var t=Object.assign({},c);Object.entries(e).forEach((function(e){var n=Qe(e,2),r=n[0],i=n[1];t[r]=i})),l.push(t)})),(n=t._config[r]).splice.apply(n,[o,1].concat(l))}else Object.entries(s[0]).forEach((function(e){var n=Qe(e,2),i=n[0],a=n[1];t._config[r][o][i]=a}))}))})),this._sendConfig(this._value,this._config)}},{kind:"method",key:"_sendConfig",value:function(e,t){this._params.callback(Object.assign({alias:e},t)),this._closeDialog()}},{kind:"method",key:"_skip",value:function(){this._params.callback(void 0),this._closeDialog()}},{kind:"method",key:"_closeDialog",value:function(){this._placeholders=void 0,this._input&&(this._input.value=null),this._opened=!1}},{kind:"method",key:"_openedChanged",value:function(e){e.detail.value||this._closeDialog()}},{kind:"method",key:"_handleKeyUp",value:function(e){13===e.keyCode&&this._generate()}},{kind:"method",key:"_handleExampleClick",value:function(e){this._input.value=e.target.innerText}},{kind:"get",static:!0,key:"styles",value:function(){return[o.Qx,o.yu,(0,r.iv)(Ze())]}}]}}),r.oi)}}]);
//# sourceMappingURL=chunk.2e8d27378043fa4c0a8a.js.map