iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
88 lines • 37.9 kB
JavaScript
/*! For license information please see chunk.f99f79334d5eff72e29f.js.LICENSE.txt */
(self.webpackChunkhome_assistant_frontend=self.webpackChunkhome_assistant_frontend||[]).push([[8133],{28417:(e,t,r)=>{"use strict";r(50808);var i=r(33367),n=r(93592),o=r(87156);const s={getTabbableNodes:function(e){const t=[];return this._collectTabbableNodes(e,t)?n.H._sortByTabIndex(t):t},_collectTabbableNodes:function(e,t){if(e.nodeType!==Node.ELEMENT_NODE||!n.H._isVisible(e))return!1;const r=e,i=n.H._normalizedTabIndex(r);let s,a=i>0;i>=0&&t.push(r),s="content"===r.localName||"slot"===r.localName?(0,o.vz)(r).getDistributedNodes():(0,o.vz)(r.shadowRoot||r.root||r).children;for(let n=0;n<s.length;n++)a=this._collectTabbableNodes(s[n],t)||a;return a}},a=customElements.get("paper-dialog"),l={get _focusableNodes(){return s.getTabbableNodes(this)}};class c extends((0,i.P)([l],a)){}customElements.define("ha-paper-dialog",c)},18900:(e,t,r)=>{"use strict";var i=r(50947),n=r(15652),o=r(47181),s=r(96151);r(53822);function a(){a=function(){return e};var e={elementsDefinitionOrder:[["method"],["field"]],initializeInstanceElements:function(e,t){["method","field"].forEach((function(r){t.forEach((function(t){t.kind===r&&"own"===t.placement&&this.defineClassElement(e,t)}),this)}),this)},initializeClassElements:function(e,t){var r=e.prototype;["method","field"].forEach((function(i){t.forEach((function(t){var n=t.placement;if(t.kind===i&&("static"===n||"prototype"===n)){var o="static"===n?e:r;this.defineClassElement(o,t)}}),this)}),this)},defineClassElement:function(e,t){var r=t.descriptor;if("field"===t.kind){var i=t.initializer;r={enumerable:r.enumerable,writable:r.writable,configurable:r.configurable,value:void 0===i?void 0:i.call(e)}}Object.defineProperty(e,t.key,r)},decorateClass:function(e,t){var r=[],i=[],n={static:[],prototype:[],own:[]};if(e.forEach((function(e){this.addElementPlacement(e,n)}),this),e.forEach((function(e){if(!d(e))return r.push(e);var t=this.decorateElement(e,n);r.push(t.element),r.push.apply(r,t.extras),i.push.apply(i,t.finishers)}),this),!t)return{elements:r,finishers:i};var o=this.decorateConstructor(r,t);return i.push.apply(i,o.finishers),o.finishers=i,o},addElementPlacement:function(e,t,r){var i=t[e.placement];if(!r&&-1!==i.indexOf(e.key))throw new TypeError("Duplicated element ("+e.key+")");i.push(e.key)},decorateElement:function(e,t){for(var r=[],i=[],n=e.decorators,o=n.length-1;o>=0;o--){var s=t[e.placement];s.splice(s.indexOf(e.key),1);var a=this.fromElementDescriptor(e),l=this.toElementFinisherExtras((0,n[o])(a)||a);e=l.element,this.addElementPlacement(e,t),l.finisher&&i.push(l.finisher);var c=l.extras;if(c){for(var d=0;d<c.length;d++)this.addElementPlacement(c[d],t);r.push.apply(r,c)}}return{element:e,finishers:i,extras:r}},decorateConstructor:function(e,t){for(var r=[],i=t.length-1;i>=0;i--){var n=this.fromClassDescriptor(e),o=this.toClassDescriptor((0,t[i])(n)||n);if(void 0!==o.finisher&&r.push(o.finisher),void 0!==o.elements){e=o.elements;for(var s=0;s<e.length-1;s++)for(var a=s+1;a<e.length;a++)if(e[s].key===e[a].key&&e[s].placement===e[a].placement)throw new TypeError("Duplicated element ("+e[s].key+")")}}return{elements:e,finishers:r}},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)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(t)||function(e,t){if(e){if("string"==typeof e)return h(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?h(e,t):void 0}}(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 r=u(e.key),i=String(e.placement);if("static"!==i&&"prototype"!==i&&"own"!==i)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 "'+i+'"');var n=e.descriptor;this.disallowProperty(e,"elements","An element descriptor");var o={kind:t,key:r,placement:i,descriptor:Object.assign({},n)};return"field"!==t?this.disallowProperty(e,"initializer","A method descriptor"):(this.disallowProperty(n,"get","The property descriptor of a field descriptor"),this.disallowProperty(n,"set","The property descriptor of a field descriptor"),this.disallowProperty(n,"value","The property descriptor of a field descriptor"),o.initializer=e.initializer),o},toElementFinisherExtras:function(e){return{element:this.toElementDescriptor(e),finisher:f(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 r=f(e,"finisher");return{elements:this.toElementDescriptors(e.elements),finisher:r}},runClassFinishers:function(e,t){for(var r=0;r<t.length;r++){var i=(0,t[r])(e);if(void 0!==i){if("function"!=typeof i)throw new TypeError("Finishers must return a constructor.");e=i}}return e},disallowProperty:function(e,t,r){if(void 0!==e[t])throw new TypeError(r+" can't have a ."+t+" property.")}};return e}function l(e){var t,r=u(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 i={kind:"field"===e.kind?"field":"method",key:r,placement:e.static?"static":"field"===e.kind?"own":"prototype",descriptor:t};return e.decorators&&(i.decorators=e.decorators),"field"===e.kind&&(i.initializer=e.value),i}function c(e,t){void 0!==e.descriptor.get?t.descriptor.get=e.descriptor.get:t.descriptor.set=e.descriptor.set}function d(e){return e.decorators&&e.decorators.length}function p(e){return void 0!==e&&!(void 0===e.value&&void 0===e.writable)}function f(e,t){var r=e[t];if(void 0!==r&&"function"!=typeof r)throw new TypeError("Expected '"+t+"' to be a function");return r}function u(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}function h(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=new Array(t);r<t;r++)i[r]=e[r];return i}!function(e,t,r,i){var n=a();if(i)for(var o=0;o<i.length;o++)n=i[o](n);var s=t((function(e){n.initializeInstanceElements(e,f.elements)}),r),f=n.decorateClass(function(e){for(var t=[],r=function(e){return"method"===e.kind&&e.key===o.key&&e.placement===o.placement},i=0;i<e.length;i++){var n,o=e[i];if("method"===o.kind&&(n=t.find(r)))if(p(o.descriptor)||p(n.descriptor)){if(d(o)||d(n))throw new ReferenceError("Duplicated methods ("+o.key+") can't be decorated.");n.descriptor=o.descriptor}else{if(d(o)){if(d(n))throw new ReferenceError("Decorators can't be placed on different accessors with for the same property ("+o.key+").");n.decorators=o.decorators}c(o,n)}else t.push(o)}return t}(s.d.map(l)),e);n.initializeClassElements(s.F,f.elements),n.runClassFinishers(s.F,f.finishers)}([(0,n.Mo)("ha-yaml-editor")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[(0,n.Cb)()],key:"value",value:void 0},{kind:"field",decorators:[(0,n.Cb)()],key:"defaultValue",value:void 0},{kind:"field",decorators:[(0,n.Cb)()],key:"isValid",value:()=>!0},{kind:"field",decorators:[(0,n.Cb)()],key:"label",value:void 0},{kind:"field",decorators:[(0,n.sz)()],key:"_yaml",value:()=>""},{kind:"field",decorators:[(0,n.IO)("ha-code-editor",!0)],key:"_editor",value:void 0},{kind:"method",key:"setValue",value:function(e){try{this._yaml=e&&!(e=>{if("object"!=typeof e)return!1;for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0})(e)?(0,i.safeDump)(e):""}catch(t){console.error(t),alert("There was an error converting to YAML: "+t)}(0,s.T)((()=>{var e;(null===(e=this._editor)||void 0===e?void 0:e.codemirror)&&this._editor.codemirror.refresh(),(0,s.T)((()=>(0,o.B)(this,"editor-refreshed")))}))}},{kind:"method",key:"firstUpdated",value:function(){this.defaultValue&&this.setValue(this.defaultValue)}},{kind:"method",key:"render",value:function(){return void 0===this._yaml?n.dy``:n.dy`
${this.label?n.dy` <p>${this.label}</p> `:""}
<ha-code-editor
.value=${this._yaml}
mode="yaml"
.error=${!1===this.isValid}
-changed=${this._onChange}
></ha-code-editor>
`}},{kind:"method",key:"_onChange",value:function(e){e.stopPropagation();const t=e.detail.value;let r,n=!0;if(t)try{r=(0,i.safeLoad)(t)}catch(s){n=!1}else r={};this.value=r,this.isValid=n,(0,o.B)(this,"value-changed",{value:r,isValid:n})}},{kind:"get",key:"yaml",value:function(){var e;return null===(e=this._editor)||void 0===e?void 0:e.value}}]}}),n.oi)},77760:(e,t,r)=>{"use strict";r.d(t,{VG:()=>w,UO:()=>P});var i=r(4915),n=r(58831),o=r(27269),s=r(22311),a=r(91741),l=r(49706);var c=r(85415);const d=async(e,t)=>new Promise((r=>{const i=t(e,(e=>{i(),r(e)}))}));var p=r(57066),f=r(57292),u=r(74186),h=r(5986),m=r(41499),y=r(14748);const v=["binary_sensor","mailbox","person","sensor","sun","timer"],g=new Set(["automation","configurator","device_tracker","geo_location","persistent_notification","zone"]),b=new Set(["mobile_app"]);let k=!1;const w=(e,t,r=!1)=>{const i=[],o=[],s=t.title?t.title+" ":void 0;for(const[l,c]of e){const e=(0,n.M)(l);if("alarm_control_panel"===e){const e={type:"alarm-panel",entity:l};i.push(e)}else if("camera"===e){const e={type:"picture-entity",entity:l};i.push(e)}else if("climate"===e){const e={type:"thermostat",entity:l};i.push(e)}else if("humidifier"===e){const e={type:"humidifier",entity:l};i.push(e)}else if("light"===e&&r){const e={type:"light",entity:l};i.push(e)}else if("media_player"===e){const e={type:"media-control",entity:l};i.push(e)}else if("plant"===e){const e={type:"plant-status",entity:l};i.push(e)}else if("weather"===e){const e={type:"weather-forecast",entity:l,show_forecast:!1};i.push(e)}else if("sensor"===e&&(null==c?void 0:c.attributes.device_class)===m.A);else{let e;const t=s&&c&&(e=(0,a.C)(c)).startsWith(s)?{entity:l,name:e.substr(s.length)}:l;o.push(t)}}return o.length>0&&i.unshift({type:"entities",entities:o,...t}),i},E=(e,t,r,i,o,l)=>{const d=(e=>{const t=[],r={};return Object.keys(e).forEach((i=>{const o=e[i];"group"===(0,n.M)(i)?t.push(o):r[i]=o})),t.forEach((e=>e.attributes.entity_id.forEach((e=>{delete r[e]})))),{groups:t,ungrouped:r}})(o);d.groups.sort(((e,t)=>l[e.entity_id]-l[t.entity_id]));const p={},f={};Object.keys(d.ungrouped).forEach((e=>{const t=d.ungrouped[e],r=(0,s.N)(t),i=v.includes(r)?p:f;r in i||(i[r]=[]),i[r].push(t.entity_id)}));let u=[];v.forEach((e=>{e in p&&(u=u.concat(p[e]))}));let m=[];d.groups.forEach((e=>{m=m.concat(w(e.attributes.entity_id.map((e=>[e,o[e]])),{title:(0,a.C)(e),show_header_toggle:"hidden"!==e.attributes.control}))})),Object.keys(f).sort().forEach((t=>{m=m.concat(w(f[t].sort(((e,t)=>(0,c.q)((0,a.C)(o[e]),(0,a.C)(o[t])))).map((e=>[e,o[e]])),{title:(0,h.Lh)(e,t)}))}));const g={path:t,title:r,badges:(0,y.Q)(u),cards:m};return i&&(g.icon=i),g},_=(e,t,r,i,n)=>{const o=((e,t)=>{const r={},i=new Set(t.filter((e=>b.has(e.platform))).map((e=>e.entity_id)));return Object.keys(e).forEach((t=>{const n=e[t];g.has((0,s.N)(n))||i.has(n.entity_id)||(r[t]=e[t])})),r})(i,r),a={};Object.keys(o).forEach((e=>{const t=o[e];t.attributes.order&&(a[e]=t.attributes.order)}));const l=((e,t,r,i)=>{const n={...i},o=[];for(const s of e){const e=[],i=new Set(t.filter((e=>e.area_id===s.area_id)).map((e=>e.id)));for(const t of r)i.has(t.device_id)&&t.entity_id in n&&(e.push(n[t.entity_id]),delete n[t.entity_id]);e.length>0&&o.push([s,e])}return{areasWithEntities:o,otherEntities:n}})(e,t,r,o),c=E(n,"default_view","Home",undefined,l.otherEntities,a),d=[];return l.areasWithEntities.forEach((([e,t])=>{d.push(...w(t.map((e=>[e.entity_id,e])),{title:e.name}))})),c.cards.unshift(...d),c},C=async(e,t,r,i,s,c)=>{if(e.safe_mode)return{title:e.location_name,views:[{cards:[{type:"safe-mode"}]}]};const d=(e=>{const t=[];return Object.keys(e).forEach((r=>{const i=e[r];i.attributes.view&&t.push(i)})),t.sort(((e,t)=>e.entity_id===l.a1?-1:t.entity_id===l.a1?1:e.attributes.order-t.attributes.order)),t})(s),p=d.map((e=>{const t=((e,t)=>{const r={};return t.attributes.entity_id.forEach((t=>{const i=e[t];if(i&&(r[i.entity_id]=i,"group"===(0,n.M)(i.entity_id))){const t=((e,t)=>{const r={};return t.attributes.entity_id.forEach((t=>{const i=e[t];i&&(r[i.entity_id]=i)})),r})(e,i);Object.keys(t).forEach((e=>{const i=t[e];r[e]=i}))}})),r})(s,e),r={};return Object.keys(t).forEach(((e,t)=>{r[e]=t})),E(c,(0,o.p)(e.entity_id),(0,a.C)(e),e.attributes.icon,t,r)}));let f=e.location_name;return 0!==d.length&&"group.default_view"===d[0].entity_id||(p.unshift(_(t,r,i,s,c)),e.components.includes("geo_location")&&p[0]&&p[0].cards&&p[0].cards.push({type:"map",geo_location_sources:["all"]}),p.length>1&&"Home"===f&&(f="ioBroker")),1===p.length&&0===p[0].cards.length&&p[0].cards.push({type:"empty-state"}),{title:f,views:p}},P=async(e,t)=>{if(e.config.state===i.UE)return{title:e.config.location_name,views:[{cards:[{type:"starting"}]}]};if(e.config.safe_mode)return{title:e.config.location_name,views:[{cards:[{type:"safe-mode"}]}]};k||(k=!0,(0,p.sG)(e.connection,(()=>{})),(0,f.q4)(e.connection,(()=>{})),(0,u.LM)(e.connection,(()=>{})));const[r,n,o]=await Promise.all([d(e.connection,p.sG),d(e.connection,f.q4),d(e.connection,u.LM)]);return C(e.config,r,n,o,e.states,t||e.localize)}},65430:(e,t,r)=>{"use strict";r(25856);var i=r(87744),n=r(46628),o=r(7778),s=r(15652);function a(){a=function(){return e};var e={elementsDefinitionOrder:[["method"],["field"]],initializeInstanceElements:function(e,t){["method","field"].forEach((function(r){t.forEach((function(t){t.kind===r&&"own"===t.placement&&this.defineClassElement(e,t)}),this)}),this)},initializeClassElements:function(e,t){var r=e.prototype;["method","field"].forEach((function(i){t.forEach((function(t){var n=t.placement;if(t.kind===i&&("static"===n||"prototype"===n)){var o="static"===n?e:r;this.defineClassElement(o,t)}}),this)}),this)},defineClassElement:function(e,t){var r=t.descriptor;if("field"===t.kind){var i=t.initializer;r={enumerable:r.enumerable,writable:r.writable,configurable:r.configurable,value:void 0===i?void 0:i.call(e)}}Object.defineProperty(e,t.key,r)},decorateClass:function(e,t){var r=[],i=[],n={static:[],prototype:[],own:[]};if(e.forEach((function(e){this.addElementPlacement(e,n)}),this),e.forEach((function(e){if(!d(e))return r.push(e);var t=this.decorateElement(e,n);r.push(t.element),r.push.apply(r,t.extras),i.push.apply(i,t.finishers)}),this),!t)return{elements:r,finishers:i};var o=this.decorateConstructor(r,t);return i.push.apply(i,o.finishers),o.finishers=i,o},addElementPlacement:function(e,t,r){var i=t[e.placement];if(!r&&-1!==i.indexOf(e.key))throw new TypeError("Duplicated element ("+e.key+")");i.push(e.key)},decorateElement:function(e,t){for(var r=[],i=[],n=e.decorators,o=n.length-1;o>=0;o--){var s=t[e.placement];s.splice(s.indexOf(e.key),1);var a=this.fromElementDescriptor(e),l=this.toElementFinisherExtras((0,n[o])(a)||a);e=l.element,this.addElementPlacement(e,t),l.finisher&&i.push(l.finisher);var c=l.extras;if(c){for(var d=0;d<c.length;d++)this.addElementPlacement(c[d],t);r.push.apply(r,c)}}return{element:e,finishers:i,extras:r}},decorateConstructor:function(e,t){for(var r=[],i=t.length-1;i>=0;i--){var n=this.fromClassDescriptor(e),o=this.toClassDescriptor((0,t[i])(n)||n);if(void 0!==o.finisher&&r.push(o.finisher),void 0!==o.elements){e=o.elements;for(var s=0;s<e.length-1;s++)for(var a=s+1;a<e.length;a++)if(e[s].key===e[a].key&&e[s].placement===e[a].placement)throw new TypeError("Duplicated element ("+e[s].key+")")}}return{elements:e,finishers:r}},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)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(t)||function(e,t){if(e){if("string"==typeof e)return h(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?h(e,t):void 0}}(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 r=u(e.key),i=String(e.placement);if("static"!==i&&"prototype"!==i&&"own"!==i)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 "'+i+'"');var n=e.descriptor;this.disallowProperty(e,"elements","An element descriptor");var o={kind:t,key:r,placement:i,descriptor:Object.assign({},n)};return"field"!==t?this.disallowProperty(e,"initializer","A method descriptor"):(this.disallowProperty(n,"get","The property descriptor of a field descriptor"),this.disallowProperty(n,"set","The property descriptor of a field descriptor"),this.disallowProperty(n,"value","The property descriptor of a field descriptor"),o.initializer=e.initializer),o},toElementFinisherExtras:function(e){return{element:this.toElementDescriptor(e),finisher:f(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 r=f(e,"finisher");return{elements:this.toElementDescriptors(e.elements),finisher:r}},runClassFinishers:function(e,t){for(var r=0;r<t.length;r++){var i=(0,t[r])(e);if(void 0!==i){if("function"!=typeof i)throw new TypeError("Finishers must return a constructor.");e=i}}return e},disallowProperty:function(e,t,r){if(void 0!==e[t])throw new TypeError(r+" can't have a ."+t+" property.")}};return e}function l(e){var t,r=u(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 i={kind:"field"===e.kind?"field":"method",key:r,placement:e.static?"static":"field"===e.kind?"own":"prototype",descriptor:t};return e.decorators&&(i.decorators=e.decorators),"field"===e.kind&&(i.initializer=e.value),i}function c(e,t){void 0!==e.descriptor.get?t.descriptor.get=e.descriptor.get:t.descriptor.set=e.descriptor.set}function d(e){return e.decorators&&e.decorators.length}function p(e){return void 0!==e&&!(void 0===e.value&&void 0===e.writable)}function f(e,t){var r=e[t];if(void 0!==r&&"function"!=typeof r)throw new TypeError("Expected '"+t+"' to be a function");return r}function u(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}function h(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=new Array(t);r<t;r++)i[r]=e[r];return i}function m(e,t,r){return(m="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,r){var i=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=y(e)););return e}(e,t);if(i){var n=Object.getOwnPropertyDescriptor(i,t);return n.get?n.get.call(r):n.value}})(e,t,r||e)}function y(e){return(y=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}let v=function(e,t,r,i){var n=a();if(i)for(var o=0;o<i.length;o++)n=i[o](n);var s=t((function(e){n.initializeInstanceElements(e,f.elements)}),r),f=n.decorateClass(function(e){for(var t=[],r=function(e){return"method"===e.kind&&e.key===o.key&&e.placement===o.placement},i=0;i<e.length;i++){var n,o=e[i];if("method"===o.kind&&(n=t.find(r)))if(p(o.descriptor)||p(n.descriptor)){if(d(o)||d(n))throw new ReferenceError("Duplicated methods ("+o.key+") can't be decorated.");n.descriptor=o.descriptor}else{if(d(o)){if(d(n))throw new ReferenceError("Decorators can't be placed on different accessors with for the same property ("+o.key+").");n.decorators=o.decorators}c(o,n)}else t.push(o)}return t}(s.d.map(l)),e);return n.initializeClassElements(s.F,f.elements),n.runClassFinishers(s.F,f.finishers)}(null,(function(e,t){class r extends t{constructor(){super(),e(this),this.addEventListener("ll-rebuild",(()=>{this._cleanup(),this.config&&this._createCard(this.config)}))}}return{F:r,d:[{kind:"field",decorators:[(0,s.Cb)({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[(0,s.Cb)()],key:"config",value:void 0},{kind:"field",key:"_element",value:void 0},{kind:"get",key:"_error",value:function(){var e;return"HUI-ERROR-CARD"===(null===(e=this._element)||void 0===e?void 0:e.tagName)}},{kind:"method",key:"update",value:function(e){if(m(y(r.prototype),"update",this).call(this,e),e.has("config")){const r=e.get("config");if(!this.config)return void this._cleanup();if(!this.config.type)return void this._createCard((0,o.N2)("No card type found",this.config));if(!this._element)return void this._createCard(this.config);if(!this._error&&r&&this.config.type===r.type)try{this._element.setConfig(this.config)}catch(t){this._createCard((0,o.N2)(t.message,this.config))}else this._createCard(this.config)}if(e.has("hass")){const t=e.get("hass");t&&t.language===this.hass.language||(this.style.direction=(0,i.HE)(this.hass)?"rtl":"ltr"),this._element&&(this._element.hass=this.hass)}}},{kind:"method",key:"_createCard",value:function(e){this._cleanup(),this._element=(0,n.Z6)(e),this.hass&&(this._element.hass=this.hass),this.appendChild(this._element)}},{kind:"method",key:"_cleanup",value:function(){this._element&&(this.removeChild(this._element),this._element=void 0)}}]}}),s.f4);customElements.define("hui-card-preview",v)},9444:(e,t,r)=>{"use strict";r.r(t),r.d(t,{HuiDialogSuggestCard:()=>b});r(22626);var i=r(60461),n=r.n(i),o=r(15652),s=(r(28417),r(18900),r(11654)),a=r(98573),l=r(77760),c=r(54324),d=(r(65430),r(97504));function p(){p=function(){return e};var e={elementsDefinitionOrder:[["method"],["field"]],initializeInstanceElements:function(e,t){["method","field"].forEach((function(r){t.forEach((function(t){t.kind===r&&"own"===t.placement&&this.defineClassElement(e,t)}),this)}),this)},initializeClassElements:function(e,t){var r=e.prototype;["method","field"].forEach((function(i){t.forEach((function(t){var n=t.placement;if(t.kind===i&&("static"===n||"prototype"===n)){var o="static"===n?e:r;this.defineClassElement(o,t)}}),this)}),this)},defineClassElement:function(e,t){var r=t.descriptor;if("field"===t.kind){var i=t.initializer;r={enumerable:r.enumerable,writable:r.writable,configurable:r.configurable,value:void 0===i?void 0:i.call(e)}}Object.defineProperty(e,t.key,r)},decorateClass:function(e,t){var r=[],i=[],n={static:[],prototype:[],own:[]};if(e.forEach((function(e){this.addElementPlacement(e,n)}),this),e.forEach((function(e){if(!h(e))return r.push(e);var t=this.decorateElement(e,n);r.push(t.element),r.push.apply(r,t.extras),i.push.apply(i,t.finishers)}),this),!t)return{elements:r,finishers:i};var o=this.decorateConstructor(r,t);return i.push.apply(i,o.finishers),o.finishers=i,o},addElementPlacement:function(e,t,r){var i=t[e.placement];if(!r&&-1!==i.indexOf(e.key))throw new TypeError("Duplicated element ("+e.key+")");i.push(e.key)},decorateElement:function(e,t){for(var r=[],i=[],n=e.decorators,o=n.length-1;o>=0;o--){var s=t[e.placement];s.splice(s.indexOf(e.key),1);var a=this.fromElementDescriptor(e),l=this.toElementFinisherExtras((0,n[o])(a)||a);e=l.element,this.addElementPlacement(e,t),l.finisher&&i.push(l.finisher);var c=l.extras;if(c){for(var d=0;d<c.length;d++)this.addElementPlacement(c[d],t);r.push.apply(r,c)}}return{element:e,finishers:i,extras:r}},decorateConstructor:function(e,t){for(var r=[],i=t.length-1;i>=0;i--){var n=this.fromClassDescriptor(e),o=this.toClassDescriptor((0,t[i])(n)||n);if(void 0!==o.finisher&&r.push(o.finisher),void 0!==o.elements){e=o.elements;for(var s=0;s<e.length-1;s++)for(var a=s+1;a<e.length;a++)if(e[s].key===e[a].key&&e[s].placement===e[a].placement)throw new TypeError("Duplicated element ("+e[s].key+")")}}return{elements:e,finishers:r}},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)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(t)||function(e,t){if(e){if("string"==typeof e)return g(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?g(e,t):void 0}}(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 r=v(e.key),i=String(e.placement);if("static"!==i&&"prototype"!==i&&"own"!==i)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 "'+i+'"');var n=e.descriptor;this.disallowProperty(e,"elements","An element descriptor");var o={kind:t,key:r,placement:i,descriptor:Object.assign({},n)};return"field"!==t?this.disallowProperty(e,"initializer","A method descriptor"):(this.disallowProperty(n,"get","The property descriptor of a field descriptor"),this.disallowProperty(n,"set","The property descriptor of a field descriptor"),this.disallowProperty(n,"value","The property descriptor of a field descriptor"),o.initializer=e.initializer),o},toElementFinisherExtras:function(e){return{element:this.toElementDescriptor(e),finisher:y(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 r=y(e,"finisher");return{elements:this.toElementDescriptors(e.elements),finisher:r}},runClassFinishers:function(e,t){for(var r=0;r<t.length;r++){var i=(0,t[r])(e);if(void 0!==i){if("function"!=typeof i)throw new TypeError("Finishers must return a constructor.");e=i}}return e},disallowProperty:function(e,t,r){if(void 0!==e[t])throw new TypeError(r+" can't have a ."+t+" property.")}};return e}function f(e){var t,r=v(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 i={kind:"field"===e.kind?"field":"method",key:r,placement:e.static?"static":"field"===e.kind?"own":"prototype",descriptor:t};return e.decorators&&(i.decorators=e.decorators),"field"===e.kind&&(i.initializer=e.value),i}function u(e,t){void 0!==e.descriptor.get?t.descriptor.get=e.descriptor.get:t.descriptor.set=e.descriptor.set}function h(e){return e.decorators&&e.decorators.length}function m(e){return void 0!==e&&!(void 0===e.value&&void 0===e.writable)}function y(e,t){var r=e[t];if(void 0!==r&&"function"!=typeof r)throw new TypeError("Expected '"+t+"' to be a function");return r}function v(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}function g(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=new Array(t);r<t;r++)i[r]=e[r];return i}let b=function(e,t,r,i){var n=p();if(i)for(var o=0;o<i.length;o++)n=i[o](n);var s=t((function(e){n.initializeInstanceElements(e,a.elements)}),r),a=n.decorateClass(function(e){for(var t=[],r=function(e){return"method"===e.kind&&e.key===o.key&&e.placement===o.placement},i=0;i<e.length;i++){var n,o=e[i];if("method"===o.kind&&(n=t.find(r)))if(m(o.descriptor)||m(n.descriptor)){if(h(o)||h(n))throw new ReferenceError("Duplicated methods ("+o.key+") can't be decorated.");n.descriptor=o.descriptor}else{if(h(o)){if(h(n))throw new ReferenceError("Decorators can't be placed on different accessors with for the same property ("+o.key+").");n.decorators=o.decorators}u(o,n)}else t.push(o)}return t}(s.d.map(f)),e);return n.initializeClassElements(s.F,a.elements),n.runClassFinishers(s.F,a.finishers)}([(0,o.Mo)("hui-dialog-suggest-card")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[(0,o.Cb)({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[(0,o.sz)()],key:"_params",value:void 0},{kind:"field",decorators:[(0,o.sz)()],key:"_cardConfig",value:void 0},{kind:"field",decorators:[(0,o.sz)()],key:"_saving",value:()=>!1},{kind:"field",decorators:[(0,o.IO)("ha-yaml-editor")],key:"_yamlEditor",value:void 0},{kind:"method",key:"showDialog",value:function(e){this._params=e,this._cardConfig=e.cardConfig||(0,l.VG)(e.entities.map((e=>[e,this.hass.states[e]])),{},!0),Object.isFrozen(this._cardConfig)||(this._cardConfig=n()(this._cardConfig)),this._yamlEditor&&this._yamlEditor.setValue(this._cardConfig)}},{kind:"method",key:"render",value:function(){return this._params?o.dy`
<ha-paper-dialog with-backdrop opened>
<h2>
${this.hass.localize("ui.panel.lovelace.editor.suggest_card.header")}
</h2>
<paper-dialog-scrollable>
${this._cardConfig?o.dy`
<div class="element-preview">
${this._cardConfig.map((e=>o.dy`
<hui-card-preview
.hass=${this.hass}
.config="${e}"
></hui-card-preview>
`))}
</div>
`:""}
${this._params.yaml&&this._cardConfig?o.dy`
<div class="editor">
<ha-yaml-editor
.defaultValue=${this._cardConfig}
></ha-yaml-editor>
</div>
`:""}
</paper-dialog-scrollable>
<div class="paper-dialog-buttons">
<mwc-button ="${this._close}">
${this._params.yaml?this.hass.localize("ui.common.close"):this.hass.localize("ui.common.cancel")}
</mwc-button>
${this._params.yaml?"":o.dy`
<mwc-button ="${this._pickCard}"
>${this.hass.localize("ui.panel.lovelace.editor.suggest_card.create_own")}</mwc-button
>
<mwc-button ?disabled="${this._saving}" ="${this._save}">
${this._saving?o.dy`
<ha-circular-progress
active
title="Saving"
size="small"
></ha-circular-progress>
`:this.hass.localize("ui.panel.lovelace.editor.suggest_card.add")}
</mwc-button>
`}
</div>
</ha-paper-dialog>
`:o.dy``}},{kind:"get",static:!0,key:"styles",value:function(){return[s.yu,o.iv`
all and (max-width: 450px), all and (max-height: 500px) {
/* overrule the ha-style-dialog max-height on small screens */
ha-paper-dialog {
max-height: 100%;
height: 100%;
}
}
all and (min-width: 850px) {
ha-paper-dialog {
width: 845px;
}
}
ha-paper-dialog {
max-width: 845px;
--dialog-z-index: 5;
}
.hidden {
display: none;
}
.element-preview {
position: relative;
}
hui-card-preview {
padding-top: 8px;
margin: 4px auto;
max-width: 390px;
display: block;
width: 100%;
}
.editor {
padding-top: 16px;
}
`]}},{kind:"method",key:"_close",value:function(){this._params=void 0,this._cardConfig=void 0}},{kind:"method",key:"_pickCard",value:function(){var e,t,r;(null===(e=this._params)||void 0===e?void 0:e.lovelaceConfig)&&(null===(t=this._params)||void 0===t?void 0:t.path)&&(null===(r=this._params)||void 0===r?void 0:r.saveConfig)&&((0,d.F)(this,{lovelaceConfig:this._params.lovelaceConfig,saveConfig:this._params.saveConfig,path:this._params.path,entities:this._params.entities}),this._close())}},{kind:"method",key:"_save",value:async function(){var e,t,r;(null===(e=this._params)||void 0===e?void 0:e.lovelaceConfig)&&(null===(t=this._params)||void 0===t?void 0:t.path)&&(null===(r=this._params)||void 0===r?void 0:r.saveConfig)&&this._cardConfig&&(this._saving=!0,await this._params.saveConfig((0,c.BN)(this._params.lovelaceConfig,this._params.path,this._cardConfig)),this._saving=!1,(0,a.f)(this,this.hass),this._close())}}]}}),o.oi)},97504:(e,t,r)=>{"use strict";r.d(t,{F:()=>o});var i=r(47181);const n=()=>Promise.all([r.e(6372),r.e(5755),r.e(9494),r.e(5324),r.e(1480),r.e(2899),r.e(2979),r.e(4077),r.e(8170)]).then(r.bind(r,52408)),o=(e,t)=>{(0,i.B)(e,"show-dialog",{dialogTag:"hui-dialog-create-card",dialogImport:n,dialogParams:t})}},14748:(e,t,r)=>{"use strict";function i(e){return e.map((e=>"string"==typeof e?{entity:e}:e))}r.d(t,{Q:()=>i})},98573:(e,t,r)=>{"use strict";r.d(t,{f:()=>n});var i=r(81796);const n=(e,t)=>(0,i.C)(e,{message:t.localize("ui.common.successfully_saved")})}}]);
//# sourceMappingURL=chunk.f99f79334d5eff72e29f.js.map