(()=>{"use strict";var t=/d{1,4}|M{1,4}|YY(?:YY)?|S{1,3}|Do|ZZ|Z|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g,n="[1-9]\\d?",e="\\d\\d",r="[^\\s]+",i=/\[([^]*?)\]/gm;function o(t,n){for(var e=[],r=0,i=t.length;r-1?r:null}};function u(t){for(var n=[],e=1;e3?0:(t-t%10!=10?1:0)*t%10]}},d=u({},l),y=function(t,n){for(void 0===n&&(n=2),t=String(t);t.length0?"-":"+")+y(100*Math.floor(Math.abs(n)/60)+Math.abs(n)%60,4)},Z:function(t){var n=t.getTimezoneOffset();return(n>0?"-":"+")+y(Math.floor(Math.abs(n)/60),2)+":"+y(Math.abs(n)%60,2)}},m=function(t){return+t-1},g=[null,n],p=[null,r],b=["isPm",r,function(t,n){var e=t.toLowerCase();return e===n.amPm[0]?0:e===n.amPm[1]?1:null}],v=["timezoneOffset","[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z?",function(t){var n=(t+"").match(/([+-]|\d\d)/gi);if(n){var e=60*+n[1]+parseInt(n[2],10);return"+"===n[0]?e:-e}return 0}],w=(a("monthNamesShort"),a("monthNames"),{default:"ddd MMM DD YYYY HH:mm:ss",shortDate:"M/D/YY",mediumDate:"MMM D, YYYY",longDate:"MMMM D, YYYY",fullDate:"dddd, MMMM D, YYYY",isoDate:"YYYY-MM-DD",isoDateTime:"YYYY-MM-DDTHH:mm:ssZ",shortTime:"HH:mm",mediumTime:"HH:mm:ss",longTime:"HH:mm:ss.SSS"});const _=function(n,e,r){if(void 0===e&&(e=w.default),void 0===r&&(r={}),"number"==typeof n&&(n=new Date(n)),"[object Date]"!==Object.prototype.toString.call(n)||isNaN(n.getTime()))throw new Error("Invalid Date pass to format");var o=[];e=(e=w[e]||e).replace(i,(function(t,n){return o.push(n),"@@@"}));var a=u(u({},d),r);return(e=e.replace(t,(function(t){return h[t](n,a)}))).replace(/@@@/g,(function(){return o.shift()}))};var O=function(){try{(new Date).toLocaleDateString("i")}catch(t){return"RangeError"===t.name}return!1}()?function(t,n){return t.toLocaleDateString(n,{year:"numeric",month:"long",day:"numeric"})}:function(t){return _(t,"mediumDate")},M=function(){try{(new Date).toLocaleString("i")}catch(t){return"RangeError"===t.name}return!1}()?function(t,n){return t.toLocaleString(n,{year:"numeric",month:"long",day:"numeric",hour:"numeric",minute:"2-digit"})}:function(t){return _(t,"haDateTime")},S=function(){try{(new Date).toLocaleTimeString("i")}catch(t){return"RangeError"===t.name}return!1}()?function(t,n){return t.toLocaleTimeString(n,{hour:"numeric",minute:"2-digit"})}:function(t){return _(t,"shortTime")},D=function(t){return t<10?"0"+t:t};function j(t){return t.substr(0,t.indexOf("."))}var k=["closed","locked","off"],Y=(new Set(["fan","input_boolean","light","switch","group","automation"]),function(t,n,e,r){r=r||{},e=null==e?{}:e;var i=new Event(n,{bubbles:void 0===r.bubbles||r.bubbles,cancelable:Boolean(r.cancelable),composed:void 0===r.composed||r.composed});return i.detail=e,t.dispatchEvent(i),i});new Set(["call-service","divider","section","weblink","cast","select"]);var E=function(t){Y(window,"haptic",t)};function P(t){return(P="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var H,T,x,N,I,z,F,L,R,C,Z,A,W=["entity-id","last-changed","last-updated","last-triggered","position","tilt-position","brightness"],U=function(t){return"object"===P(t)&&!Array.isArray(t)&&!!t},V=function(t){return!t||["unknown","unavailable"].includes(t.state)},B=function(t,n){return n.hide_unavailable&&(V(t)||n.attribute&&void 0===t.attributes[n.attribute])},J=function(t){if(U(t)&&!(t.entity||t.attribute||t.icon))throw new Error("Entity object requires at least one 'entity', 'attribute' or 'icon'.");if("string"==typeof t&&""===t)throw new Error("Entity ID string must not be blank.");if("string"!=typeof t&&!U(t))throw new Error("Entity config must be a valid entity ID string or entity object.")},q=function(t,n){return!1===n.name?null:n.name||(n.entity?t.attributes.friendly_name||(e=t.entity_id).substr(e.indexOf(".")+1):null)||null;var e},G=function(t){return U(null==t?void 0:t.styles)?Object.keys(t.styles).map((function(n){return"".concat(n,": ").concat(t.styles[n],";")})).join(""):""};function K(t){return(K="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Q(t,n){return n||(n=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(n)}}))}function X(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable}))),e.push.apply(e,r)}return e}function $(t){for(var n=1;n\n
\n ',"","\n
\n "])),this._hass,this.config,this.renderSecondaryInfo(),this.config.column?"entities-column":"entities-row",this.entities.map((function(n){return t.renderEntity(n.stateObj,n)})),this.renderMainEntity()):this.renderWarning():ct(T||(T=Q([""])))}},{key:"renderSecondaryInfo",value:function(){if(!this.config.secondary_info||"string"==typeof(t=this.config.secondary_info)&&W.includes(t)||B(this.info,this.config.secondary_info))return null;var t;if("string"==typeof this.config.secondary_info)return ct(N||(N=Q(["",""])),this.config.secondary_info);var n=q(this.info,this.config.secondary_info);return ct(I||(I=Q([""," ",""])),n,this.renderValue(this.info,this.config.secondary_info))}},{key:"renderMainEntity",value:function(){return!1===this.config.show_state?null:ct(z||(z=Q(['
\n ',"\n
","
\n
"])),G(this.config),this.onRowClick,this.config.state_header&&ct(F||(F=Q(["",""])),this.config.state_header),this.renderValue(this.stateObj,this.config))}},{key:"renderEntity",value:function(t,n){if(!t||B(t,n))return null;var e=this.clickHandler(t.entity_id,n.tap_action);return ct(L||(L=Q(['
\n ',"\n
","
\n
"])),G(n),e,q(t,n),n.icon?this.renderIcon(t,n):this.renderValue(t,n))}},{key:"renderValue",value:function(t,n){return!0===n.toggle?ct(R||(R=Q([''])),t,this._hass):n.format?this.renderFormat(t,n):function(t,n,e){if(V(n))return t.localize("state.default.".concat(n.state));var r=j(n.entity_id),i=function(e){return n.attributes.device_class&&t.localize("component.".concat(r,".state.").concat(n.attributes.device_class,".").concat(e))||t.localize("component.".concat(r,".state._.").concat(e))||e};if(e.attribute)return e.attribute in n.attributes?"".concat(i(n.attributes[e.attribute])).concat(e.unit?" ".concat(e.unit):""):t.localize("state.default.unavailable");if(!1!==e.unit&&(e.unit||n.attributes.unit_of_measurement))return"".concat(n.state," ").concat(e.unit||n.attributes.unit_of_measurement);if("input_datetime"===r){var o;if(!n.attributes.has_time)return o=new Date(n.attributes.year,n.attributes.month-1,n.attributes.day),O(o,t.language);if(!n.attributes.has_date){var a=new Date;return o=new Date(a.getFullYear(),a.getMonth(),a.getDay(),n.attributes.hour,n.attributes.minute),S(o,t.language)}return o=new Date(n.attributes.year,n.attributes.month-1,n.attributes.day,n.attributes.hour,n.attributes.minute),M(o,t.language)}return i(n.state)}(this._hass,t,n)}},{key:"renderFormat",value:function(t,n){var e=function(t,n){return void 0!==n.attribute?t.attributes[n.attribute]:t.state}(t,n);if(["relative","total","date","time","datetime"].includes(n.format)){var r=new Date(e);return r instanceof Date&&!isNaN(r.getTime())?ct(C||(C=Q([""])),r,n.format,this._hass):e}if(isNaN(parseFloat(e))||!isFinite(e))return e;if("brightness"===n.format)return"".concat(Math.round(e/255*100)," %");if("duration"===n.format)return function(t){var n=Math.floor(t/3600),e=Math.floor(t%3600/60),r=Math.floor(t%3600%60);return n>0?n+":"+D(e)+":"+D(r):e>0?e+":"+D(r):r>0?""+r:null}(e);if(n.format.startsWith("precision")){var i=function(t,n){return!1===n.unit?null:void 0!==n.attribute?n.unit:n.unit||t.attributes.unit_of_measurement}(t,n),o=parseInt(n.format.slice(-1),10);return"".concat(parseFloat(e).toFixed(o)).concat(i?" ".concat(i):"")}return e}},{key:"renderIcon",value:function(t,n){return ct(Z||(Z=Q([''])),t,!0===n.icon?t.attributes.icon||null:n.icon,n.state_color)}},{key:"renderWarning",value:function(){return ct(A||(A=Q(["\n ","\n "])),this._hass.localize("ui.panel.lovelace.warning.entity_not_found","entity",this.config.entity))}},{key:"clickHandler",value:function(t,n){var e=this;return function(){return function(t,n,e,r,i){var o;if(e.tap_action&&(o=e.tap_action),o||(o={action:"more-info"}),!o.confirmation||o.confirmation.exemptions&&o.confirmation.exemptions.some((function(t){return t.user===n.user.id}))||confirm(o.confirmation.text||"Are you sure you want to "+o.action+"?"))switch(o.action){case"more-info":(o.entity||e.entity||e.camera_image)&&(Y(t,"hass-more-info",{entityId:o.entity?o.entity:e.entity?e.entity:e.camera_image}),o.haptic&&E(o.haptic));break;case"navigate":o.navigation_path&&(function(t,n,e){void 0===e&&(e=!1),e?history.replaceState(null,"",n):history.pushState(null,"",n),Y(window,"location-changed",{replace:e})}(0,o.navigation_path),o.haptic&&E(o.haptic));break;case"url":o.url_path&&window.open(o.url_path),o.haptic&&E(o.haptic);break;case"toggle":e.entity&&(function(t,n){(function(t,n,e){void 0===e&&(e=!0);var r,i=j(n),o="group"===i?"homeassistant":i;switch(i){case"lock":r=e?"unlock":"lock";break;case"cover":r=e?"open_cover":"close_cover";break;default:r=e?"turn_on":"turn_off"}t.callService(o,r,{entity_id:n})})(t,n,k.includes(t.states[n].state))}(n,e.entity),o.haptic&&E(o.haptic));break;case"call-service":if(!o.service)return;var a=o.service.split(".",2),u=a[0],c=a[1],s=Object.assign({},o.service_data);"entity"===s.entity_id&&(s.entity_id=e.entity),n.callService(u,c,s),o.haptic&&E(o.haptic);break;case"fire-dom-event":Y(t,"ll-custom",o),o.haptic&&E(o.haptic)}}(e,e._hass,{entity:t,tap_action:n})}}}])&&et(n.prototype,e),r&&et(n,r),u}(at);customElements.define("multiple-entity-row",ft)})();