From 2f7fb1f254809869bd0f22eb76184c94621ce93e Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Tue, 2 Jan 2024 10:19:28 +0000 Subject: [PATCH] Add changes to dist and docs --- docs/_docs/floorplan/floorplan-examples.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/_docs/floorplan/floorplan-examples.js b/docs/_docs/floorplan/floorplan-examples.js index 773da3d6..2ae369ee 100644 --- a/docs/_docs/floorplan/floorplan-examples.js +++ b/docs/_docs/floorplan/floorplan-examples.js @@ -45,7 +45,7 @@ const ie=e=>t=>"function"==typeof t?((e,t)=>(customElements.define(e,t),t))(e,t) * Copyright 2021 Google LLC * SPDX-License-Identifier: BSD-3-Clause */}var se;null===(se=window.HTMLSlotElement)||void 0===se||se.prototype.assignedElements;class ae{constructor(){this.states={}}callWS(e){return console.log(e),Promise.resolve(null)}callService(e,t,i){return Promise.resolve({context:{id:"",parent_id:void 0,user_id:void 0}})}clone(){const e=new ae;return e.callService=this.callService,e.states=JSON.parse(JSON.stringify(this.states)),e}}class oe{}let ce=/(-?(?:\d+\.?\d*|\d*\.?\d+)(?:e[-+]?\d+)?)\s*([\p{L}]*)/giu;function le(e="",t="ms"){var i=null;return(e=(e+"").replace(/(\d)[,_](\d)/g,"$1$2")).replace(ce,(function(e,t,n){(n=he(n))&&(i=(i||0)+parseFloat(t,10)*n)})),i&&i/(he(t)||1)}function he(e){return le[e]||le[e.toLowerCase().replace(/s$/,"")]}le.nanosecond=le.ns=1e-6,le["µs"]=le["μs"]=le.us=le.microsecond=.001,le.millisecond=le.ms=le[""]=1,le.second=le.sec=le.s=1e3*le.ms,le.minute=le.min=le.m=60*le.s,le.hour=le.hr=le.h=60*le.m,le.day=le.d=24*le.h,le.week=le.wk=le.w=7*le.d,le.month=le.b=30.4375*le.d,le.year=le.yr=le.y=365.25*le.d;const ue=le;class pe{static miredToRGB(e){return this.kelvinToRGB(1e6/e)}static kelvinToRGB(e){const t=e/100;let i,n,r;return t<=66?(i=255,n=t,n=99.4708025861*Math.log(n)-161.1195681661,t<=19?r=0:(r=t-10,r=138.5177312231*Math.log(r)-305.0447927307)):(i=t-60,i=329.698727446*Math.pow(i,-.1332047592),n=t-60,n=288.1221695283*Math.pow(n,-.0755148492),r=255),[Math.min(Math.max(Math.round(i),0),255),Math.min(Math.max(Math.round(n),0),255),Math.min(Math.max(Math.round(r),0),255)]}}var de,fe=i(1),me=i.n(fe);class ge{static timeago(e){let t="second",i=0;const n=("string"==typeof e?new Date(e):e).getTime()-(new Date).getTime(),r=n/this.MILLISECONDS_IN_YEAR;if(Math.abs(r)>=1)t="year",i=r;else{const e=n/this.MILLISECONDS_IN_DAY;if(Math.abs(e)>=1)t="day",i=e;else{const e=n/this.MILLISECONDS_IN_HOUR;if(Math.abs(e)>=1)t="hour",i=e;else{const e=n/this.MILLISECONDS_IN_MINUTE;Math.abs(e)>=1?(t="minute",i=e):(t="second",i=n/this.MILLISECONDS_IN_SECOND)}}}return this.relativeTimeFormat.format(Math.round(i),t)}}ge.strftime=me(),ge.MILLISECONDS_IN_SECOND=1e3,ge.MILLISECONDS_IN_MINUTE=6e4,ge.MILLISECONDS_IN_HOUR=36e5,ge.MILLISECONDS_IN_DAY=864e5,ge.MILLISECONDS_IN_YEAR=31536e6,ge.relativeTimeFormat=new Intl.RelativeTimeFormat(null!==(de=navigator.language)&&void 0!==de?de:"en",{numeric:"auto",style:"long"});var ve=i(449),ye=i.n(ve);function be(e){return(e=>{if("object"==typeof(t=e)&&null!==t&&"message"in t&&"string"==typeof t.message)return e;var t;try{return new Error(JSON.stringify(e))}catch(t){return new Error(String(e))}})(e).message}class xe{static isCode(e){return this.isCodeBlock(e)||this.isCodeLine(e)}static isCodeBlock(e){return e.trim().startsWith(">")}static isCodeLine(e){return e.includes("${")&&e.includes("}")}static evaluate(e,t){var i;this.expression=e.trim();const n=`${this.expression}_${null!==(i=t.entity_id)&&void 0!==i?i:""}`;this.parsedFunction=this.cache[n],void 0===this.parsedFunction&&(this.functionBody=this.expression,this.isCodeBlock(this.functionBody)?this.functionBody=this.functionBody.slice(1).trim():this.isCodeLine(this.functionBody)&&(this.functionBody.startsWith('"')&&this.functionBody.endsWith('"')&&(this.functionBody=this.functionBody.slice(1,this.functionBody.length-2)),this.functionBody=this.functionBody.replace(/\\"/g,'"'),this.functionBody=`\`${this.functionBody}\`;`,this.functionBody.includes("return")||(this.functionBody=`return ${this.functionBody}`)),this.parsedFunction=this.interpreter.parse(`exports.result = (() => { ${this.functionBody} })();`),this.cache[n]=this.parsedFunction,this.interpreter.import("util",this.util)),this.entityState=t,this.interpreter.import("entity",this.entityState);try{this.interpreter.run(this.parsedFunction)}catch(e){throw new EvalError(be(e))}return this.interpreter.exports.result}}xe.cache={},xe.interpreter=new(ye())({ecmaVer:2019,sandBox:!0}),xe.util={color:pe,date:ge};class we{constructor(e,t){this.hassChanged=t,this.simulationProcessors=[],this.hass=new ae,this.hass.callService=this.callService.bind(this);for(const t of e.simulations){const e=new Se(t,this.hass,this.onEntityStatesChanged.bind(this));this.simulationProcessors.push(e)}}onEntityStatesChanged(e){for(const t of e)this.hass.states[t.entity_id]=t;this.hassChanged(this.hass.clone())}callService(e,t,i){switch(console.log("HassSimulator.callService()",e,t,i),e){case"homeassistant":case"light":case"fan":"toggle"===t&&this.homeAssistantToggle(i);break;case"media_player":switch(t){case"volume_up":this.homeAssistantVolumeUp(i);break;case"volume_down":this.homeAssistantVolumeDown(i)}}return Promise.resolve({context:{id:"",parent_id:void 0,user_id:void 0}})}homeAssistantToggle(e){if(e.entity_id){const t=e.entity_id.split(".")[0],i=this.hass.states[e.entity_id];switch(t){case"switch":case"light":case"fan":case"binary_sensor":case"sensor":case"media_player":i.state="on"===i.state?"off":"on";for(const t of this.simulationProcessors)t.updateEntityState(e.entity_id,i)}}}homeAssistantVolumeUp(e){if(e.entity_id){const t=e.entity_id.split(".")[0],i=this.hass.states[e.entity_id];let n;if("media_player"===t){n=i.attributes.volume_level,i.attributes.volume_level=Math.min(1,n+.1);for(const t of this.simulationProcessors)t.updateEntityState(e.entity_id,i)}}}homeAssistantVolumeDown(e){if(e.entity_id){const t=e.entity_id.split(".")[0],i=this.hass.states[e.entity_id];let n;if("media_player"===t){n=i.attributes.volume_level,i.attributes.volume_level=Math.max(0,n-.1);for(const t of this.simulationProcessors)t.updateEntityState(e.entity_id,i)}}}}class Se{constructor(e,t,i){var n,r;this.simulation=e,this.hass=t,this.onEntityStatesChanged=i,this.currentIndex=0,this.entities=[],this.simulation.entities&&(this.entities=this.entities.concat(this.simulation.entities)),this.simulation.entity&&(this.entities=this.entities.concat(this.simulation.entity)),this.entities.length||console.error("Simulation must contain at least one entity",e),(null===(n=this.simulation.states)||void 0===n?void 0:n.length)||this.simulation.state||console.error("Simulation must contain at least one state",e),this.triggerState(null!==(r=this.simulation.state)&&void 0!==r?r:this.simulation.states[0])}triggerState(e){var t;if(this.simulation.enabled||void 0===this.simulation.enabled)for(const t of this.entities)this.updateEntityState(t,e);if(this.simulation.states){let i;if("string"==typeof this.simulation.states){const e=null!==(t=this.simulation.state)&&void 0!==t?t:{entity_id:this.simulation.entity};i=xe.evaluate(this.simulation.states,e),this.simulation.state=i}else{const t=(this.simulation.states.indexOf(e)+1)%this.simulation.states.length;i=this.simulation.states[t]}if(null==i?void 0:i.duration){const t=e,n="number"==typeof t.duration?1e3*t.duration:ue(t.duration);setTimeout(this.triggerState.bind(this),n,i)}}}updateEntityState(e,t){var i,n,r;const s="string"==typeof e?e:e.entity_id,a=this.hass.states[s];let o;a?(o=Object.assign({},a),o.attributes=Object.assign({},a.attributes)):(o=new oe,o.entity_id=s),"string"==typeof t?o.state="string"==typeof t?t:t.state:"object"==typeof t&&(o.state=t.state,t.attributes&&(o.attributes=Object.assign({},o.attributes,t.attributes))),o.attributes=null!==(i=o.attributes)&&void 0!==i?i:{},o.attributes.friendly_name=null!==(r=null===(n=o.attributes)||void 0===n?void 0:n.friendly_name)&&void 0!==r?r:s,o.last_changed=(new Date).toString(),o.last_updated=(new Date).toString(),this.onEntityStatesChanged([o])}} -/*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT */function _e(e){return null==e}var ke={isNothing:_e,isObject:function(e){return"object"==typeof e&&null!==e},toArray:function(e){return Array.isArray(e)?e:_e(e)?[]:[e]},repeat:function(e,t){var i,n="";for(i=0;io&&(t=n-o+(s=" ... ").length),i-n>o&&(i=n+o-(a=" ...").length),{str:s+e.slice(t,i).replace(/\t/g,"→")+a,pos:n-t+s.length}}function Te(e,t){return ke.repeat(" ",t-e.length)+e}var Pe=function(e,t){if(t=Object.create(t||null),!e.buffer)return null;t.maxLength||(t.maxLength=79),"number"!=typeof t.indent&&(t.indent=1),"number"!=typeof t.linesBefore&&(t.linesBefore=3),"number"!=typeof t.linesAfter&&(t.linesAfter=2);for(var i,n=/\r?\n|\r|\0/g,r=[0],s=[],a=-1;i=n.exec(e.buffer);)s.push(i.index),r.push(i.index+i[0].length),e.position<=i.index&&a<0&&(a=r.length-2);a<0&&(a=r.length-1);var o,c,l="",h=Math.min(e.line+t.linesAfter,s.length).toString().length,u=t.maxLength-(t.indent+h+3);for(o=1;o<=t.linesBefore&&!(a-o<0);o++)c=Ie(e.buffer,r[a-o],s[a-o],e.position-(r[a]-r[a-o]),u),l=ke.repeat(" ",t.indent)+Te((e.line-o+1).toString(),h)+" | "+c.str+"\n"+l;for(c=Ie(e.buffer,r[a],s[a],e.position,u),l+=ke.repeat(" ",t.indent)+Te((e.line+1).toString(),h)+" | "+c.str+"\n",l+=ke.repeat("-",t.indent+h+3+c.pos)+"^\n",o=1;o<=t.linesAfter&&!(a+o>=s.length);o++)c=Ie(e.buffer,r[a+o],s[a+o],e.position-(r[a]-r[a+o]),u),l+=ke.repeat(" ",t.indent)+Te((e.line+o+1).toString(),h)+" | "+c.str+"\n";return l.replace(/\n$/,"")},Oe=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],Ne=["scalar","sequence","mapping"],Me=function(e,t){if(t=t||{},Object.keys(t).forEach((function(t){if(-1===Oe.indexOf(t))throw new Ce('Unknown option "'+t+'" is met in definition of "'+e+'" YAML type.')})),this.options=t,this.tag=e,this.kind=t.kind||null,this.resolve=t.resolve||function(){return!0},this.construct=t.construct||function(e){return e},this.instanceOf=t.instanceOf||null,this.predicate=t.predicate||null,this.represent=t.represent||null,this.representName=t.representName||null,this.defaultStyle=t.defaultStyle||null,this.multi=t.multi||!1,this.styleAliases=function(e){var t={};return null!==e&&Object.keys(e).forEach((function(i){e[i].forEach((function(e){t[String(e)]=i}))})),t}(t.styleAliases||null),-1===Ne.indexOf(this.kind))throw new Ce('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')};function Le(e,t){var i=[];return e[t].forEach((function(e){var t=i.length;i.forEach((function(i,n){i.tag===e.tag&&i.kind===e.kind&&i.multi===e.multi&&(t=n)})),i[t]=e})),i}function De(e){return this.extend(e)}De.prototype.extend=function(e){var t=[],i=[];if(e instanceof Me)i.push(e);else if(Array.isArray(e))i=i.concat(e);else{if(!e||!Array.isArray(e.implicit)&&!Array.isArray(e.explicit))throw new Ce("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");e.implicit&&(t=t.concat(e.implicit)),e.explicit&&(i=i.concat(e.explicit))}t.forEach((function(e){if(!(e instanceof Me))throw new Ce("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(e.loadKind&&"scalar"!==e.loadKind)throw new Ce("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(e.multi)throw new Ce("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")})),i.forEach((function(e){if(!(e instanceof Me))throw new Ce("Specified list of YAML types (or a single Type object) contains a non-Type object.")}));var n=Object.create(De.prototype);return n.implicit=(this.implicit||[]).concat(t),n.explicit=(this.explicit||[]).concat(i),n.compiledImplicit=Le(n,"implicit"),n.compiledExplicit=Le(n,"explicit"),n.compiledTypeMap=function(){var e,t,i={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function n(e){e.multi?(i.multi[e.kind].push(e),i.multi.fallback.push(e)):i[e.kind][e.tag]=i.fallback[e.tag]=e}for(e=0,t=arguments.length;e=0?"0b"+e.toString(2):"-0b"+e.toString(2).slice(1)},octal:function(e){return e>=0?"0o"+e.toString(8):"-0o"+e.toString(8).slice(1)},decimal:function(e){return e.toString(10)},hexadecimal:function(e){return e>=0?"0x"+e.toString(16).toUpperCase():"-0x"+e.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),Ye=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),Ge=/^[-+]?[0-9]+e/,Je=new Me("tag:yaml.org,2002:float",{kind:"scalar",resolve:function(e){return null!==e&&!(!Ye.test(e)||"_"===e[e.length-1])},construct:function(e){var t,i;return i="-"===(t=e.replace(/_/g,"").toLowerCase())[0]?-1:1,"+-".indexOf(t[0])>=0&&(t=t.slice(1)),".inf"===t?1===i?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:".nan"===t?NaN:i*parseFloat(t,10)},predicate:function(e){return"[object Number]"===Object.prototype.toString.call(e)&&(e%1!=0||ke.isNegativeZero(e))},represent:function(e,t){var i;if(isNaN(e))switch(t){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===e)switch(t){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===e)switch(t){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(ke.isNegativeZero(e))return"-0.0";return i=e.toString(10),Ge.test(i)?i.replace("e",".e"):i},defaultStyle:"lowercase"}),Xe=Ve.extend({implicit:[Fe,Ue,We,Je]}),Ke=Xe,Qe=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),Ze=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$"),et=new Me("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:function(e){return null!==e&&(null!==Qe.exec(e)||null!==Ze.exec(e))},construct:function(e){var t,i,n,r,s,a,o,c,l=0,h=null;if(null===(t=Qe.exec(e))&&(t=Ze.exec(e)),null===t)throw new Error("Date resolve error");if(i=+t[1],n=+t[2]-1,r=+t[3],!t[4])return new Date(Date.UTC(i,n,r));if(s=+t[4],a=+t[5],o=+t[6],t[7]){for(l=t[7].slice(0,3);l.length<3;)l+="0";l=+l}return t[9]&&(h=6e4*(60*+t[10]+ +(t[11]||0)),"-"===t[9]&&(h=-h)),c=new Date(Date.UTC(i,n,r,s,a,o,l)),h&&c.setTime(c.getTime()-h),c},instanceOf:Date,represent:function(e){return e.toISOString()}}),tt=new Me("tag:yaml.org,2002:merge",{kind:"scalar",resolve:function(e){return"<<"===e||null===e}}),it="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r",nt=new Me("tag:yaml.org,2002:binary",{kind:"scalar",resolve:function(e){if(null===e)return!1;var t,i,n=0,r=e.length,s=it;for(i=0;i64)){if(t<0)return!1;n+=6}return n%8==0},construct:function(e){var t,i,n=e.replace(/[\r\n=]/g,""),r=n.length,s=it,a=0,o=[];for(t=0;t>16&255),o.push(a>>8&255),o.push(255&a)),a=a<<6|s.indexOf(n.charAt(t));return 0==(i=r%4*6)?(o.push(a>>16&255),o.push(a>>8&255),o.push(255&a)):18===i?(o.push(a>>10&255),o.push(a>>2&255)):12===i&&o.push(a>>4&255),new Uint8Array(o)},predicate:function(e){return"[object Uint8Array]"===Object.prototype.toString.call(e)},represent:function(e){var t,i,n="",r=0,s=e.length,a=it;for(t=0;t>18&63],n+=a[r>>12&63],n+=a[r>>6&63],n+=a[63&r]),r=(r<<8)+e[t];return 0==(i=s%3)?(n+=a[r>>18&63],n+=a[r>>12&63],n+=a[r>>6&63],n+=a[63&r]):2===i?(n+=a[r>>10&63],n+=a[r>>4&63],n+=a[r<<2&63],n+=a[64]):1===i&&(n+=a[r>>2&63],n+=a[r<<4&63],n+=a[64],n+=a[64]),n}}),rt=Object.prototype.hasOwnProperty,st=Object.prototype.toString,at=new Me("tag:yaml.org,2002:omap",{kind:"sequence",resolve:function(e){if(null===e)return!0;var t,i,n,r,s,a=[],o=e;for(t=0,i=o.length;t>10),56320+(e-65536&1023))}for(var Dt=new Array(256),$t=new Array(256),Rt=0;Rt<256;Rt++)Dt[Rt]=Mt(Rt)?1:0,$t[Rt]=Mt(Rt);function jt(e,t){this.input=e,this.filename=t.filename||null,this.schema=t.schema||ut,this.onWarning=t.onWarning||null,this.legacy=t.legacy||!1,this.json=t.json||!1,this.listener=t.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=e.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.firstTabInLine=-1,this.documents=[]}function Bt(e,t){var i={name:e.filename,buffer:e.input.slice(0,-1),position:e.position,line:e.line,column:e.position-e.lineStart};return i.snippet=Pe(i),new Ce(t,i)}function Vt(e,t){throw Bt(e,t)}function Ft(e,t){e.onWarning&&e.onWarning.call(null,Bt(e,t))}var Ut={YAML:function(e,t,i){var n,r,s;null!==e.version&&Vt(e,"duplication of %YAML directive"),1!==i.length&&Vt(e,"YAML directive accepts exactly one argument"),null===(n=/^([0-9]+)\.([0-9]+)$/.exec(i[0]))&&Vt(e,"ill-formed argument of the YAML directive"),r=parseInt(n[1],10),s=parseInt(n[2],10),1!==r&&Vt(e,"unacceptable YAML version of the document"),e.version=i[0],e.checkLineBreaks=s<2,1!==s&&2!==s&&Ft(e,"unsupported YAML version of the document")},TAG:function(e,t,i){var n,r;2!==i.length&&Vt(e,"TAG directive accepts exactly two arguments"),n=i[0],r=i[1],_t.test(n)||Vt(e,"ill-formed tag handle (first argument) of the TAG directive"),pt.call(e.tagMap,n)&&Vt(e,'there is a previously declared suffix for "'+n+'" tag handle'),kt.test(r)||Vt(e,"ill-formed tag prefix (second argument) of the TAG directive");try{r=decodeURIComponent(r)}catch(t){Vt(e,"tag prefix is malformed: "+r)}e.tagMap[n]=r}};function Ht(e,t,i,n){var r,s,a,o;if(t1&&(e.result+=ke.repeat("\n",t-1))}function Xt(e,t){var i,n,r=e.tag,s=e.anchor,a=[],o=!1;if(-1!==e.firstTabInLine)return!1;for(null!==e.anchor&&(e.anchorMap[e.anchor]=a),n=e.input.charCodeAt(e.position);0!==n&&(-1!==e.firstTabInLine&&(e.position=e.firstTabInLine,Vt(e,"tab characters must not be used in indentation")),45===n)&&It(e.input.charCodeAt(e.position+1));)if(o=!0,e.position++,Yt(e,!0,-1)&&e.lineIndent<=t)a.push(null),n=e.input.charCodeAt(e.position);else if(i=e.line,Zt(e,t,mt,!1,!0),a.push(e.result),Yt(e,!0,-1),n=e.input.charCodeAt(e.position),(e.line===i||e.lineIndent>t)&&0!==n)Vt(e,"bad indentation of a sequence entry");else if(e.lineIndentt?f=1:e.lineIndent===t?f=0:e.lineIndentt?f=1:e.lineIndent===t?f=0:e.lineIndentt)&&(v&&(a=e.line,o=e.lineStart,c=e.position),Zt(e,t,gt,!0,r)&&(v?m=e.result:g=e.result),v||(zt(e,p,d,f,m,g,a,o,c),f=m=g=null),Yt(e,!0,-1),l=e.input.charCodeAt(e.position)),(e.line===s||e.lineIndent>t)&&0!==l)Vt(e,"bad indentation of a mapping entry");else if(e.lineIndent=0))break;0===r?Vt(e,"bad explicit indentation width of a block scalar; it cannot be less than one"):c?Vt(e,"repeat of an indentation width identifier"):(l=t+r-1,c=!0)}if(Ct(s)){do{s=e.input.charCodeAt(++e.position)}while(Ct(s));if(35===s)do{s=e.input.charCodeAt(++e.position)}while(!At(s)&&0!==s)}for(;0!==s;){for(Wt(e),e.lineIndent=0,s=e.input.charCodeAt(e.position);(!c||e.lineIndentl&&(l=e.lineIndent),At(s))h++;else{if(e.lineIndent0){for(r=a,s=0;r>0;r--)(a=Pt(o=e.input.charCodeAt(++e.position)))>=0?s=(s<<4)+a:Vt(e,"expected hexadecimal character");e.result+=Lt(s),e.position++}else Vt(e,"unknown escape sequence");i=n=e.position}else At(o)?(Ht(e,i,n,!0),Jt(e,Yt(e,!1,t)),i=n=e.position):e.position===e.lineStart&&Gt(e)?Vt(e,"unexpected end of the document within a double quoted scalar"):(e.position++,n=e.position)}Vt(e,"unexpected end of the stream within a double quoted scalar")}(e,p)?g=!0:function(e){var t,i,n;if(42!==(n=e.input.charCodeAt(e.position)))return!1;for(n=e.input.charCodeAt(++e.position),t=e.position;0!==n&&!It(n)&&!Tt(n);)n=e.input.charCodeAt(++e.position);return e.position===t&&Vt(e,"name of an alias node must contain at least one character"),i=e.input.slice(t,e.position),pt.call(e.anchorMap,i)||Vt(e,'unidentified alias "'+i+'"'),e.result=e.anchorMap[i],Yt(e,!0,-1),!0}(e)?(g=!0,null===e.tag&&null===e.anchor||Vt(e,"alias node should not have any properties")):function(e,t,i){var n,r,s,a,o,c,l,h,u=e.kind,p=e.result;if(It(h=e.input.charCodeAt(e.position))||Tt(h)||35===h||38===h||42===h||33===h||124===h||62===h||39===h||34===h||37===h||64===h||96===h)return!1;if((63===h||45===h)&&(It(n=e.input.charCodeAt(e.position+1))||i&&Tt(n)))return!1;for(e.kind="scalar",e.result="",r=s=e.position,a=!1;0!==h;){if(58===h){if(It(n=e.input.charCodeAt(e.position+1))||i&&Tt(n))break}else if(35===h){if(It(e.input.charCodeAt(e.position-1)))break}else{if(e.position===e.lineStart&&Gt(e)||i&&Tt(h))break;if(At(h)){if(o=e.line,c=e.lineStart,l=e.lineIndent,Yt(e,!1,-1),e.lineIndent>=t){a=!0,h=e.input.charCodeAt(e.position);continue}e.position=s,e.line=o,e.lineStart=c,e.lineIndent=l;break}}a&&(Ht(e,r,s,!1),Jt(e,e.line-o),r=s=e.position,a=!1),Ct(h)||(s=e.position+1),h=e.input.charCodeAt(++e.position)}return Ht(e,r,s,!1),!!e.result||(e.kind=u,e.result=p,!1)}(e,p,dt===i)&&(g=!0,null===e.tag&&(e.tag="?")),null!==e.anchor&&(e.anchorMap[e.anchor]=e.result)):0===f&&(g=o&&Xt(e,d))),null===e.tag)null!==e.anchor&&(e.anchorMap[e.anchor]=e.result);else if("?"===e.tag){for(null!==e.result&&"scalar"!==e.kind&&Vt(e,'unacceptable node kind for ! tag; it should be "scalar", not "'+e.kind+'"'),c=0,l=e.implicitTypes.length;c"),null!==e.result&&u.kind!==e.kind&&Vt(e,"unacceptable node kind for !<"+e.tag+'> tag; it should be "'+u.kind+'", not "'+e.kind+'"'),u.resolve(e.result,e.tag)?(e.result=u.construct(e.result,e.tag),null!==e.anchor&&(e.anchorMap[e.anchor]=e.result)):Vt(e,"cannot resolve a node with !<"+e.tag+"> explicit tag")}return null!==e.listener&&e.listener("close",e),null!==e.tag||null!==e.anchor||g}function ei(e){var t,i,n,r,s=e.position,a=!1;for(e.version=null,e.checkLineBreaks=e.legacy,e.tagMap=Object.create(null),e.anchorMap=Object.create(null);0!==(r=e.input.charCodeAt(e.position))&&(Yt(e,!0,-1),r=e.input.charCodeAt(e.position),!(e.lineIndent>0||37!==r));){for(a=!0,r=e.input.charCodeAt(++e.position),t=e.position;0!==r&&!It(r);)r=e.input.charCodeAt(++e.position);for(n=[],(i=e.input.slice(t,e.position)).length<1&&Vt(e,"directive name must not be less than one character in length");0!==r;){for(;Ct(r);)r=e.input.charCodeAt(++e.position);if(35===r){do{r=e.input.charCodeAt(++e.position)}while(0!==r&&!At(r));break}if(At(r))break;for(t=e.position;0!==r&&!It(r);)r=e.input.charCodeAt(++e.position);n.push(e.input.slice(t,e.position))}0!==r&&Wt(e),pt.call(Ut,i)?Ut[i](e,i,n):Ft(e,'unknown document directive "'+i+'"')}Yt(e,!0,-1),0===e.lineIndent&&45===e.input.charCodeAt(e.position)&&45===e.input.charCodeAt(e.position+1)&&45===e.input.charCodeAt(e.position+2)?(e.position+=3,Yt(e,!0,-1)):a&&Vt(e,"directives end mark is expected"),Zt(e,e.lineIndent-1,gt,!1,!0),Yt(e,!0,-1),e.checkLineBreaks&&wt.test(e.input.slice(s,e.position))&&Ft(e,"non-ASCII line breaks are interpreted as content"),e.documents.push(e.result),e.position===e.lineStart&&Gt(e)?46===e.input.charCodeAt(e.position)&&(e.position+=3,Yt(e,!0,-1)):e.position=55296&&n<=56319&&t+1=56320&&i<=57343?1024*(n-55296)+i-56320+65536:n}function Hi(e){return/^\n* /.test(e)}var qi=1,zi=2,Wi=3,Yi=4,Gi=5;function Ji(e,t,i,n,r){e.dump=function(){if(0===t.length)return e.quotingType===Li?'""':"''";if(!e.noCompatMode&&(-1!==Oi.indexOf(t)||Ni.test(t)))return e.quotingType===Li?'"'+t+'"':"'"+t+"'";var s=e.indent*Math.max(1,i),a=-1===e.lineWidth?-1:Math.max(Math.min(e.lineWidth,40),e.lineWidth-s),o=n||e.flowLevel>-1&&i>=e.flowLevel;switch(function(e,t,i,n,r,s,a,o){var c,l=0,h=null,u=!1,p=!1,d=-1!==n,f=-1,m=function(e){return Bi(e)&&e!==si&&!ji(e)&&e!==yi&&e!==Si&&e!==bi&&e!==vi&&e!==ki&&e!==Ei&&e!==Ci&&e!==Ti&&e!==pi&&e!==fi&&e!==gi&&e!==hi&&e!==Ii&&e!==xi&&e!==wi&&e!==mi&&e!==ui&&e!==di&&e!==_i&&e!==Ai}(Ui(e,0))&&function(e){return!ji(e)&&e!==bi}(Ui(e,e.length-1));if(t||a)for(c=0;c=65536?c+=2:c++){if(!Bi(l=Ui(e,c)))return Gi;m=m&&Fi(l,h,o),h=l}else{for(c=0;c=65536?c+=2:c++){if((l=Ui(e,c))===oi)u=!0,d&&(p=p||c-f-1>n&&" "!==e[f+1],f=c);else if(!Bi(l))return Gi;m=m&&Fi(l,h,o),h=l}p=p||d&&c-f-1>n&&" "!==e[f+1]}return u||p?i>9&&Hi(e)?Gi:a?s===Li?Gi:zi:p?Yi:Wi:!m||a||r(e)?s===Li?Gi:zi:qi}(t,o,e.indent,a,(function(t){return function(e,t){var i,n;for(i=0,n=e.implicitTypes.length;i"+Xi(t,e.indent)+Ki($i(function(e,t){for(var i,n,r,s=/(\n+)([^\n]*)/g,a=(r=-1!==(r=e.indexOf("\n"))?r:e.length,s.lastIndex=r,Qi(e.slice(0,r),t)),o="\n"===e[0]||" "===e[0];n=s.exec(e);){var c=n[1],l=n[2];i=" "===l[0],a+=c+(o||i||""===l?"":"\n")+Qi(l,t),o=i}return a}(t,a),s));case Gi:return'"'+function(e){for(var t,i="",n=0,r=0;r=65536?r+=2:r++)n=Ui(e,r),!(t=Pi[n])&&Bi(n)?(i+=e[r],n>=65536&&(i+=e[r+1])):i+=t||Mi(n);return i}(t)+'"';default:throw new Ce("impossible error: invalid scalar style")}}()}function Xi(e,t){var i=Hi(e)?String(t):"",n="\n"===e[e.length-1];return i+(!n||"\n"!==e[e.length-2]&&"\n"!==e?n?"":"-":"+")+"\n"}function Ki(e){return"\n"===e[e.length-1]?e.slice(0,-1):e}function Qi(e,t){if(""===e||" "===e[0])return e;for(var i,n,r=/ [^ ]/g,s=0,a=0,o=0,c="";i=r.exec(e);)(o=i.index)-s>t&&(n=a>s?a:o,c+="\n"+e.slice(s,n),s=n+1),a=o;return c+="\n",e.length-s>t&&a>s?c+=e.slice(s,a)+"\n"+e.slice(a+1):c+=e.slice(s),c.slice(1)}function Zi(e,t,i,n){var r,s,a,o="",c=e.tag;for(r=0,s=i.length;r tag resolver accepts not "'+c+'" style');n=o.represent[c](t,c)}e.dump=n}return!0}return!1}function tn(e,t,i,n,r,s,a){e.tag=null,e.dump=i,en(e,i,!1)||en(e,i,!0);var o,c=ni.call(e.dump),l=n;n&&(n=e.flowLevel<0||e.flowLevel>t);var h,u,p="[object Object]"===c||"[object Array]"===c;if(p&&(u=-1!==(h=e.duplicates.indexOf(i))),(null!==e.tag&&"?"!==e.tag||u||2!==e.indent&&t>0)&&(r=!1),u&&e.usedDuplicates[h])e.dump="*ref_"+h;else{if(p&&u&&!e.usedDuplicates[h]&&(e.usedDuplicates[h]=!0),"[object Object]"===c)n&&0!==Object.keys(e.dump).length?(function(e,t,i,n){var r,s,a,o,c,l,h="",u=e.tag,p=Object.keys(i);if(!0===e.sortKeys)p.sort();else if("function"==typeof e.sortKeys)p.sort(e.sortKeys);else if(e.sortKeys)throw new Ce("sortKeys must be a boolean or a function");for(r=0,s=p.length;r1024)&&(e.dump&&oi===e.dump.charCodeAt(0)?l+="?":l+="? "),l+=e.dump,c&&(l+=Ri(e,t)),tn(e,t+1,o,!0,c)&&(e.dump&&oi===e.dump.charCodeAt(0)?l+=":":l+=": ",h+=l+=e.dump));e.tag=u,e.dump=h||"{}"}(e,t,e.dump,r),u&&(e.dump="&ref_"+h+e.dump)):(function(e,t,i){var n,r,s,a,o,c="",l=e.tag,h=Object.keys(i);for(n=0,r=h.length;n1024&&(o+="? "),o+=e.dump+(e.condenseFlow?'"':"")+":"+(e.condenseFlow?"":" "),tn(e,t,a,!1,!1)&&(c+=o+=e.dump));e.tag=l,e.dump="{"+c+"}"}(e,t,e.dump),u&&(e.dump="&ref_"+h+" "+e.dump));else if("[object Array]"===c)n&&0!==e.dump.length?(e.noArrayIndent&&!a&&t>0?Zi(e,t-1,e.dump,r):Zi(e,t,e.dump,r),u&&(e.dump="&ref_"+h+e.dump)):(function(e,t,i){var n,r,s,a="",o=e.tag;for(n=0,r=i.length;n",e.dump=o+" "+e.dump)}return!0}function nn(e,t){var i,n,r=[],s=[];for(rn(e,r,s),i=0,n=s.length;ie.trim())).filter((e=>e.length));for(let t=0;te.trim()));e.style.setProperty(n[0],n[1])}}static setText(e,t,i){e instanceof SVGTextElement||(e=e.querySelector("text")||e);const n=t.replace(/\\n/g,"\n").split("\n"),r=n.length>1,s=e.querySelector("tspan");if(r){const t=null==s?void 0:s.getAttribute("x"),r=null==s?void 0:s.getAttribute("y");t&&!e.getAttribute("x")&&e.setAttribute("x",t),r&&!e.getAttribute("y")&&e.setAttribute("y",r);const a=e.querySelector("tspan")||!1;e.textContent="",e.dataset.ha_floorplan_notice="The text_set function split your text into multiple tspans. Only the style of the first tspan is preserved. The style from the original tspan is reused on every tspan. The x and y are calculated on the basis of the first tspan or text-element.";const o=e.getAttribute("x")||"0",c=i||"1em";n.forEach(((t,i)=>{const n=document.createElementNS("http://www.w3.org/2000/svg","tspan");if(n.textContent=t,n.setAttribute("x",o),n.setAttribute("dy",i>=1?c:"0"),a){const e=a.getAttribute("style");e&&n.setAttribute("style",e)}e.appendChild(n)}))}else(s||e).textContent=t}static waitForChildNodes(e,t,i){return new Promise(((n,r)=>{const s=setTimeout((()=>r("Timeout waiting for child element(s) to load")),i);new MutationObserver((e=>{for(const t of e)if("childList"===t.type&&t.addedNodes.length)return clearTimeout(s),n()})).observe(e,{childList:!0,subtree:!0}),t()}))}static formatDate(e){return e?"string"==typeof e?new Date(e).toLocaleString():e.toLocaleString():""}static parseYaml(e){return an.load(e)}static fetchText(e,t,i,n){return on(this,void 0,void 0,(function*(){i&&(e=e.replace(/^\/local\/floorplan\/examples\//g,`${i}/`)),e=n?e:cn.cacheBuster(e);const r=new Request(e,{cache:n?"default":"no-store",mode:t?"no-cors":void 0});try{const e=yield fetch(r);if(e.ok||t&&"opaque"===e.type)return yield e.text();throw new Error("Error fetching resource")}catch(t){throw new URIError(`${e}: ${t.message}`)}}))}static fetchImage(e,t,i,n){return on(this,void 0,void 0,(function*(){t&&(e=e.replace(/^\/local\/floorplan\/examples\//g,`${i}/`)),e=n?e:cn.cacheBuster(e);const r=new Request(e,{cache:n?"default":"no-store",headers:new Headers({"Content-Type":"text/plain; charset=x-user-defined"}),mode:t?"no-cors":void 0});try{const e=yield fetch(r);if(e.ok||t&&"opaque"===e.type){const t=yield e.arrayBuffer();return`data:image/jpeg;base64,${cn.arrayBufferToBase64(t)}`}throw new Error("Error fetching resource")}catch(t){throw new URIError(`${e}: ${t.message}`)}}))}static singleToArray(e){return null==e?[]:Array.isArray(e)?e:[e]}static getArray(e){if(null==e)return[];if(Array.isArray(e))return e;{const t=e;return Object.values(t)}}static getSet(e){if(Array.isArray(e))return new Set(e);{const t=e;return new Set(Object.values(t))}}static arrayBufferToBase64(e){let t="";[].slice.call(new Uint8Array(e)).forEach((e=>t+=String.fromCharCode(e)));let i=window.btoa(t);for(;i.length%4>0;)i+="=";return i}static cacheBuster(e){return`${e}${e.includes("?")?"&":"?"}_=${(new Date).getTime()}`}static equal(e,t){if(e===t)return!0;const i=Array.isArray(e),n=Array.isArray(t);let r=0;if(i&&n){if(e.length!=t.length)return!1;for(r=0;rMath.floor(1e5*(1+Math.random())).toString(16).substring(1);localStorage[e]=`${t()}${t()}_${t()}${t()}`}return localStorage[e]}}class ln{static closestElement(e,t){return function t(i){if(!i||i===document||i===window)return null;i.assignedSlot&&(i=i.assignedSlot);return i.closest(e)||t(i.getRootNode().host)}(t)}}const hn=(e,t,i,n)=>{n=n||{},i=null==i?{}:i;const r=new Event(t,{bubbles:void 0===n.bubbles||n.bubbles,cancelable:Boolean(n.cancelable),composed:void 0===n.composed||n.composed});return r.detail=i,e.dispatchEvent(r),r},un=(e,t,i=!1)=>{i?history.replaceState(null,"",t):history.pushState(null,"",t),hn(window,"location-changed",{replace:i})};class pn{constructor(e,t,i,n){this.entityId=e,this.svgElement=t,this.originalSvgElement=i,this.originalBBox=n}}class dn{constructor(e){this.rule=e,this.svgElementInfos={}}}class fn{constructor(e,t,i,n,r,s){this.instance=e,this.entityId=t,this.elementId=i,this.svgElementInfo=n,this.ruleInfo=r,this.actions=s}}const mn={},gn={};gn.click=gn.mousedown=gn.mouseup=gn.mousemove="MouseEvents";let vn=1;function yn(e){return e._dtId||(e._dtId=vn++)}function bn(e){const t=e.indexOf(".");return t>0?{e:e.substring(0,e.indexOf(".")),ns:e.substring(t+1,e.length)}:{e}}function xn(e,t,i,n){const r=bn(i).e;if(!e._dtId)return!1;const s=mn[yn(e)],a=function(e,t,i,n){return i=bn(i),(mn[yn(e)]||[]).filter((e=>e&&(!i.e||e.e===i.e)&&(!i.ns||e.ns===i.ns)&&(!n||e.callback===n)&&(!t||e.selector===t)))}(e,t,i,n);a.forEach((t=>{e.removeEventListener?e.removeEventListener(r,t.delegator||t.callback):e.detachEvent&&e.detachEvent("on"+r,t.delegator||t.callback),s.splice(s.indexOf(t),1)}))}function wn(e,t,i,n,r,s){const a=bn(i).e,o=bn(i).ns;e.addEventListener?e.addEventListener(a,r||n,s):e.attachEvent&&e.attachEvent("on"+a,r||n);const c=yn(e);(mn[c]||(mn[c]=[])).push({delegator:r,callback:n,e:a,ns:o,selector:t})}const Sn={on(e,t,i,n=null){wn(e,null,t,i,null,n)},off(e,t,i=null){xn(e,null,t,i)},once(e,t,i){const n=e=>(Sn.off(e.currentTarget,e.type,n),i(e));this.on(e,t,n)},delegate(e,t,i,n,r=null){wn(e,t,i,n,(function(i){const r=e.querySelectorAll(t);let s=!1;for(let e=0;e{i=!1,t=setTimeout((()=>{i=!0,e.dispatchEvent(new Event("longClick"))}),400)},r=n=>{clearTimeout(t),i||e.dispatchEvent(new Event("short"+n.type[0].toUpperCase()+n.type.slice(1)))},s=e=>{i&&(e.preventDefault(),e.stopImmediatePropagation&&e.stopImmediatePropagation())};kn.on(e,"mousedown",n.bind(this)),kn.on(e,"tapstart",n.bind(this)),kn.on(e,"touchstart",n.bind(this),{passive:!0}),kn.on(e,"click",r.bind(this)),kn.on(e,"mouseup",r.bind(this)),kn.on(e,"tapend",r.bind(this)),kn.on(e,"touchend",r.bind(this)),kn.on(e,"tap",s.bind(this)),kn.on(e,"touch",s.bind(this)),kn.on(e,"mouseup",s.bind(this)),kn.on(e,"tapend",s.bind(this)),kn.on(e,"touchend",s.bind(this)),kn.on(e,"click",(e=>{e.preventDefault(),e.stopImmediatePropagation&&e.stopImmediatePropagation()}).bind(this))}}const An=_n,Cn=new Set;class In{static observe(e){if(Cn.has(e))return;Cn.add(e);let t,i=0;An.on(e,"click",(()=>{i++,t=setTimeout((()=>{1===i&&(i=0,e.dispatchEvent(new Event("singleClick")))}),400),2===i&&(clearTimeout(t),i=0,e.dispatchEvent(new Event("doubleClick")))}).bind(this))}}class Tn{static isCode(e){return this.isCodeBlock(e)||this.isCodeLine(e)}static isCodeBlock(e){return e.trim().startsWith(">")}static isCodeLine(e){return e.includes("${")&&e.includes("}")}static evaluate(e,t,i,n,r,s,a){this.expression=e.trim();const o=`${this.expression}_${null!=r?r:""}`;this.parsedFunction=this.cache[o],void 0===this.parsedFunction&&(this.functionBody=this.expression,this.isCodeBlock(this.functionBody)?this.functionBody=this.functionBody.slice(1).trim():this.isCodeLine(this.functionBody)&&(this.functionBody.startsWith('"')&&this.functionBody.endsWith('"')&&(this.functionBody=this.functionBody.slice(1,this.functionBody.length-2)),this.functionBody=this.functionBody.replace(/\\"/g,'"'),this.functionBody=`\`${this.functionBody}\`;`,this.functionBody.includes("return")||(this.functionBody=`return ${this.functionBody}`)),this.parsedFunction=this.interpreter.parse(`exports.result = (() => { ${this.functionBody} })();`),this.cache[o]=this.parsedFunction,this.interpreter.import("config",i),this.interpreter.import("util",this.util)),this.entityState=n?t.states[n]:void 0,this.interpreter.import("functions",a),this.interpreter.import("entity",this.entityState),this.interpreter.import("entities",t.states),this.interpreter.import("states",t.states),this.interpreter.import("hass",t),this.interpreter.import("element",r),this.interpreter.import("elements",s);try{this.interpreter.run(this.parsedFunction)}catch(e){throw new EvalError(be(e))}return this.interpreter.exports.result}}Tn.cache={},Tn.interpreter=new(ye())({ecmaVer:2019,sandBox:!0}),Tn.util={color:pe,date:ge};class Pn{constructor(e,t,i){this.element=e,this.logLevel=t,this.consoleLogLevel=i,this.logLevelGroups={error:["error"],warn:["error","warning","warn"],warning:["error","warning","warn"],info:["error","warning","warn","info"],debug:["error","warning","warn","info","debug"]}}log(e,t,i=!1){var n;const r=`${cn.formatDate(new Date)} ${e.toUpperCase()} ${t}`,s=this.logLevel&&this.logLevelGroups[this.logLevel.toLowerCase()],a=(null==s?void 0:s.length)&&s.includes(e.toLowerCase());if((i||a)&&this.element){const t=document.createElement("li");cn.addClass(t,e),t.textContent=r,null===(n=this.element.querySelector("ul"))||void 0===n||n.prepend(t),this.element.style.display="block"}this.consoleLog(e,t,i)}consoleLog(e,t,i=!1){const n=`${cn.formatDate(new Date)} ${e.toUpperCase()} ${t}`,r=this.consoleLogLevel&&this.logLevelGroups[this.consoleLogLevel.toLowerCase()],s=(null==r?void 0:r.length)&&r.includes(e.toLowerCase());if(i||s)switch(e){case"error":console.error(n);break;case"warn":case"warning":console.warn(n);break;case"info":console.info(n);break;default:console.log(n)}}}var On=function(e,t,i,n){var r,s=arguments.length,a=s<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,i,n);else for(var o=e.length-1;o>=0;o--)(r=e[o])&&(a=(s<3?r(a):s>3?r(t,i,a):r(t,i))||a);return s>3&&a&&Object.defineProperty(t,i,a),a},Nn=function(e,t,i,n){return new(i||(i=Promise))((function(r,s){function a(e){try{c(n.next(e))}catch(e){s(e)}}function o(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(a,o)}c((n=n.apply(e,t||[])).next())}))};const Mn=_n;console.info("%cFloorplan for Home Assistant (ha-floorplan)%c\nVersion 1.0.40","color: orange; font-weight: bold; background: black","color: white; font-weight: bold; background: rgb(71, 170, 238)");let Ln=class extends ee{constructor(){super(),this.pageInfos={},this.entityInfos={},this.elementInfos={},this.cssRules=[],this.functions={},this.variables={},this.svgElements={},this.isRulesLoaded=!1,window.onerror=this.handleWindowError.bind(this)}render(){return $` +/*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT */function _e(e){return null==e}var ke={isNothing:_e,isObject:function(e){return"object"==typeof e&&null!==e},toArray:function(e){return Array.isArray(e)?e:_e(e)?[]:[e]},repeat:function(e,t){var i,n="";for(i=0;io&&(t=n-o+(s=" ... ").length),i-n>o&&(i=n+o-(a=" ...").length),{str:s+e.slice(t,i).replace(/\t/g,"→")+a,pos:n-t+s.length}}function Te(e,t){return ke.repeat(" ",t-e.length)+e}var Pe=function(e,t){if(t=Object.create(t||null),!e.buffer)return null;t.maxLength||(t.maxLength=79),"number"!=typeof t.indent&&(t.indent=1),"number"!=typeof t.linesBefore&&(t.linesBefore=3),"number"!=typeof t.linesAfter&&(t.linesAfter=2);for(var i,n=/\r?\n|\r|\0/g,r=[0],s=[],a=-1;i=n.exec(e.buffer);)s.push(i.index),r.push(i.index+i[0].length),e.position<=i.index&&a<0&&(a=r.length-2);a<0&&(a=r.length-1);var o,c,l="",h=Math.min(e.line+t.linesAfter,s.length).toString().length,u=t.maxLength-(t.indent+h+3);for(o=1;o<=t.linesBefore&&!(a-o<0);o++)c=Ie(e.buffer,r[a-o],s[a-o],e.position-(r[a]-r[a-o]),u),l=ke.repeat(" ",t.indent)+Te((e.line-o+1).toString(),h)+" | "+c.str+"\n"+l;for(c=Ie(e.buffer,r[a],s[a],e.position,u),l+=ke.repeat(" ",t.indent)+Te((e.line+1).toString(),h)+" | "+c.str+"\n",l+=ke.repeat("-",t.indent+h+3+c.pos)+"^\n",o=1;o<=t.linesAfter&&!(a+o>=s.length);o++)c=Ie(e.buffer,r[a+o],s[a+o],e.position-(r[a]-r[a+o]),u),l+=ke.repeat(" ",t.indent)+Te((e.line+o+1).toString(),h)+" | "+c.str+"\n";return l.replace(/\n$/,"")},Oe=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],Ne=["scalar","sequence","mapping"],Me=function(e,t){if(t=t||{},Object.keys(t).forEach((function(t){if(-1===Oe.indexOf(t))throw new Ce('Unknown option "'+t+'" is met in definition of "'+e+'" YAML type.')})),this.options=t,this.tag=e,this.kind=t.kind||null,this.resolve=t.resolve||function(){return!0},this.construct=t.construct||function(e){return e},this.instanceOf=t.instanceOf||null,this.predicate=t.predicate||null,this.represent=t.represent||null,this.representName=t.representName||null,this.defaultStyle=t.defaultStyle||null,this.multi=t.multi||!1,this.styleAliases=function(e){var t={};return null!==e&&Object.keys(e).forEach((function(i){e[i].forEach((function(e){t[String(e)]=i}))})),t}(t.styleAliases||null),-1===Ne.indexOf(this.kind))throw new Ce('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')};function Le(e,t){var i=[];return e[t].forEach((function(e){var t=i.length;i.forEach((function(i,n){i.tag===e.tag&&i.kind===e.kind&&i.multi===e.multi&&(t=n)})),i[t]=e})),i}function De(e){return this.extend(e)}De.prototype.extend=function(e){var t=[],i=[];if(e instanceof Me)i.push(e);else if(Array.isArray(e))i=i.concat(e);else{if(!e||!Array.isArray(e.implicit)&&!Array.isArray(e.explicit))throw new Ce("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");e.implicit&&(t=t.concat(e.implicit)),e.explicit&&(i=i.concat(e.explicit))}t.forEach((function(e){if(!(e instanceof Me))throw new Ce("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(e.loadKind&&"scalar"!==e.loadKind)throw new Ce("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(e.multi)throw new Ce("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")})),i.forEach((function(e){if(!(e instanceof Me))throw new Ce("Specified list of YAML types (or a single Type object) contains a non-Type object.")}));var n=Object.create(De.prototype);return n.implicit=(this.implicit||[]).concat(t),n.explicit=(this.explicit||[]).concat(i),n.compiledImplicit=Le(n,"implicit"),n.compiledExplicit=Le(n,"explicit"),n.compiledTypeMap=function(){var e,t,i={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function n(e){e.multi?(i.multi[e.kind].push(e),i.multi.fallback.push(e)):i[e.kind][e.tag]=i.fallback[e.tag]=e}for(e=0,t=arguments.length;e=0?"0b"+e.toString(2):"-0b"+e.toString(2).slice(1)},octal:function(e){return e>=0?"0o"+e.toString(8):"-0o"+e.toString(8).slice(1)},decimal:function(e){return e.toString(10)},hexadecimal:function(e){return e>=0?"0x"+e.toString(16).toUpperCase():"-0x"+e.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),Ye=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),Ge=/^[-+]?[0-9]+e/,Je=new Me("tag:yaml.org,2002:float",{kind:"scalar",resolve:function(e){return null!==e&&!(!Ye.test(e)||"_"===e[e.length-1])},construct:function(e){var t,i;return i="-"===(t=e.replace(/_/g,"").toLowerCase())[0]?-1:1,"+-".indexOf(t[0])>=0&&(t=t.slice(1)),".inf"===t?1===i?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:".nan"===t?NaN:i*parseFloat(t,10)},predicate:function(e){return"[object Number]"===Object.prototype.toString.call(e)&&(e%1!=0||ke.isNegativeZero(e))},represent:function(e,t){var i;if(isNaN(e))switch(t){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===e)switch(t){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===e)switch(t){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(ke.isNegativeZero(e))return"-0.0";return i=e.toString(10),Ge.test(i)?i.replace("e",".e"):i},defaultStyle:"lowercase"}),Xe=Ve.extend({implicit:[Fe,Ue,We,Je]}),Ke=Xe,Qe=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),Ze=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$"),et=new Me("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:function(e){return null!==e&&(null!==Qe.exec(e)||null!==Ze.exec(e))},construct:function(e){var t,i,n,r,s,a,o,c,l=0,h=null;if(null===(t=Qe.exec(e))&&(t=Ze.exec(e)),null===t)throw new Error("Date resolve error");if(i=+t[1],n=+t[2]-1,r=+t[3],!t[4])return new Date(Date.UTC(i,n,r));if(s=+t[4],a=+t[5],o=+t[6],t[7]){for(l=t[7].slice(0,3);l.length<3;)l+="0";l=+l}return t[9]&&(h=6e4*(60*+t[10]+ +(t[11]||0)),"-"===t[9]&&(h=-h)),c=new Date(Date.UTC(i,n,r,s,a,o,l)),h&&c.setTime(c.getTime()-h),c},instanceOf:Date,represent:function(e){return e.toISOString()}}),tt=new Me("tag:yaml.org,2002:merge",{kind:"scalar",resolve:function(e){return"<<"===e||null===e}}),it="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r",nt=new Me("tag:yaml.org,2002:binary",{kind:"scalar",resolve:function(e){if(null===e)return!1;var t,i,n=0,r=e.length,s=it;for(i=0;i64)){if(t<0)return!1;n+=6}return n%8==0},construct:function(e){var t,i,n=e.replace(/[\r\n=]/g,""),r=n.length,s=it,a=0,o=[];for(t=0;t>16&255),o.push(a>>8&255),o.push(255&a)),a=a<<6|s.indexOf(n.charAt(t));return 0==(i=r%4*6)?(o.push(a>>16&255),o.push(a>>8&255),o.push(255&a)):18===i?(o.push(a>>10&255),o.push(a>>2&255)):12===i&&o.push(a>>4&255),new Uint8Array(o)},predicate:function(e){return"[object Uint8Array]"===Object.prototype.toString.call(e)},represent:function(e){var t,i,n="",r=0,s=e.length,a=it;for(t=0;t>18&63],n+=a[r>>12&63],n+=a[r>>6&63],n+=a[63&r]),r=(r<<8)+e[t];return 0==(i=s%3)?(n+=a[r>>18&63],n+=a[r>>12&63],n+=a[r>>6&63],n+=a[63&r]):2===i?(n+=a[r>>10&63],n+=a[r>>4&63],n+=a[r<<2&63],n+=a[64]):1===i&&(n+=a[r>>2&63],n+=a[r<<4&63],n+=a[64],n+=a[64]),n}}),rt=Object.prototype.hasOwnProperty,st=Object.prototype.toString,at=new Me("tag:yaml.org,2002:omap",{kind:"sequence",resolve:function(e){if(null===e)return!0;var t,i,n,r,s,a=[],o=e;for(t=0,i=o.length;t>10),56320+(e-65536&1023))}for(var Dt=new Array(256),$t=new Array(256),Rt=0;Rt<256;Rt++)Dt[Rt]=Mt(Rt)?1:0,$t[Rt]=Mt(Rt);function jt(e,t){this.input=e,this.filename=t.filename||null,this.schema=t.schema||ut,this.onWarning=t.onWarning||null,this.legacy=t.legacy||!1,this.json=t.json||!1,this.listener=t.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=e.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.firstTabInLine=-1,this.documents=[]}function Bt(e,t){var i={name:e.filename,buffer:e.input.slice(0,-1),position:e.position,line:e.line,column:e.position-e.lineStart};return i.snippet=Pe(i),new Ce(t,i)}function Vt(e,t){throw Bt(e,t)}function Ft(e,t){e.onWarning&&e.onWarning.call(null,Bt(e,t))}var Ut={YAML:function(e,t,i){var n,r,s;null!==e.version&&Vt(e,"duplication of %YAML directive"),1!==i.length&&Vt(e,"YAML directive accepts exactly one argument"),null===(n=/^([0-9]+)\.([0-9]+)$/.exec(i[0]))&&Vt(e,"ill-formed argument of the YAML directive"),r=parseInt(n[1],10),s=parseInt(n[2],10),1!==r&&Vt(e,"unacceptable YAML version of the document"),e.version=i[0],e.checkLineBreaks=s<2,1!==s&&2!==s&&Ft(e,"unsupported YAML version of the document")},TAG:function(e,t,i){var n,r;2!==i.length&&Vt(e,"TAG directive accepts exactly two arguments"),n=i[0],r=i[1],_t.test(n)||Vt(e,"ill-formed tag handle (first argument) of the TAG directive"),pt.call(e.tagMap,n)&&Vt(e,'there is a previously declared suffix for "'+n+'" tag handle'),kt.test(r)||Vt(e,"ill-formed tag prefix (second argument) of the TAG directive");try{r=decodeURIComponent(r)}catch(t){Vt(e,"tag prefix is malformed: "+r)}e.tagMap[n]=r}};function Ht(e,t,i,n){var r,s,a,o;if(t1&&(e.result+=ke.repeat("\n",t-1))}function Xt(e,t){var i,n,r=e.tag,s=e.anchor,a=[],o=!1;if(-1!==e.firstTabInLine)return!1;for(null!==e.anchor&&(e.anchorMap[e.anchor]=a),n=e.input.charCodeAt(e.position);0!==n&&(-1!==e.firstTabInLine&&(e.position=e.firstTabInLine,Vt(e,"tab characters must not be used in indentation")),45===n)&&It(e.input.charCodeAt(e.position+1));)if(o=!0,e.position++,Yt(e,!0,-1)&&e.lineIndent<=t)a.push(null),n=e.input.charCodeAt(e.position);else if(i=e.line,Zt(e,t,mt,!1,!0),a.push(e.result),Yt(e,!0,-1),n=e.input.charCodeAt(e.position),(e.line===i||e.lineIndent>t)&&0!==n)Vt(e,"bad indentation of a sequence entry");else if(e.lineIndentt?f=1:e.lineIndent===t?f=0:e.lineIndentt?f=1:e.lineIndent===t?f=0:e.lineIndentt)&&(v&&(a=e.line,o=e.lineStart,c=e.position),Zt(e,t,gt,!0,r)&&(v?m=e.result:g=e.result),v||(zt(e,p,d,f,m,g,a,o,c),f=m=g=null),Yt(e,!0,-1),l=e.input.charCodeAt(e.position)),(e.line===s||e.lineIndent>t)&&0!==l)Vt(e,"bad indentation of a mapping entry");else if(e.lineIndent=0))break;0===r?Vt(e,"bad explicit indentation width of a block scalar; it cannot be less than one"):c?Vt(e,"repeat of an indentation width identifier"):(l=t+r-1,c=!0)}if(Ct(s)){do{s=e.input.charCodeAt(++e.position)}while(Ct(s));if(35===s)do{s=e.input.charCodeAt(++e.position)}while(!At(s)&&0!==s)}for(;0!==s;){for(Wt(e),e.lineIndent=0,s=e.input.charCodeAt(e.position);(!c||e.lineIndentl&&(l=e.lineIndent),At(s))h++;else{if(e.lineIndent0){for(r=a,s=0;r>0;r--)(a=Pt(o=e.input.charCodeAt(++e.position)))>=0?s=(s<<4)+a:Vt(e,"expected hexadecimal character");e.result+=Lt(s),e.position++}else Vt(e,"unknown escape sequence");i=n=e.position}else At(o)?(Ht(e,i,n,!0),Jt(e,Yt(e,!1,t)),i=n=e.position):e.position===e.lineStart&&Gt(e)?Vt(e,"unexpected end of the document within a double quoted scalar"):(e.position++,n=e.position)}Vt(e,"unexpected end of the stream within a double quoted scalar")}(e,p)?g=!0:function(e){var t,i,n;if(42!==(n=e.input.charCodeAt(e.position)))return!1;for(n=e.input.charCodeAt(++e.position),t=e.position;0!==n&&!It(n)&&!Tt(n);)n=e.input.charCodeAt(++e.position);return e.position===t&&Vt(e,"name of an alias node must contain at least one character"),i=e.input.slice(t,e.position),pt.call(e.anchorMap,i)||Vt(e,'unidentified alias "'+i+'"'),e.result=e.anchorMap[i],Yt(e,!0,-1),!0}(e)?(g=!0,null===e.tag&&null===e.anchor||Vt(e,"alias node should not have any properties")):function(e,t,i){var n,r,s,a,o,c,l,h,u=e.kind,p=e.result;if(It(h=e.input.charCodeAt(e.position))||Tt(h)||35===h||38===h||42===h||33===h||124===h||62===h||39===h||34===h||37===h||64===h||96===h)return!1;if((63===h||45===h)&&(It(n=e.input.charCodeAt(e.position+1))||i&&Tt(n)))return!1;for(e.kind="scalar",e.result="",r=s=e.position,a=!1;0!==h;){if(58===h){if(It(n=e.input.charCodeAt(e.position+1))||i&&Tt(n))break}else if(35===h){if(It(e.input.charCodeAt(e.position-1)))break}else{if(e.position===e.lineStart&&Gt(e)||i&&Tt(h))break;if(At(h)){if(o=e.line,c=e.lineStart,l=e.lineIndent,Yt(e,!1,-1),e.lineIndent>=t){a=!0,h=e.input.charCodeAt(e.position);continue}e.position=s,e.line=o,e.lineStart=c,e.lineIndent=l;break}}a&&(Ht(e,r,s,!1),Jt(e,e.line-o),r=s=e.position,a=!1),Ct(h)||(s=e.position+1),h=e.input.charCodeAt(++e.position)}return Ht(e,r,s,!1),!!e.result||(e.kind=u,e.result=p,!1)}(e,p,dt===i)&&(g=!0,null===e.tag&&(e.tag="?")),null!==e.anchor&&(e.anchorMap[e.anchor]=e.result)):0===f&&(g=o&&Xt(e,d))),null===e.tag)null!==e.anchor&&(e.anchorMap[e.anchor]=e.result);else if("?"===e.tag){for(null!==e.result&&"scalar"!==e.kind&&Vt(e,'unacceptable node kind for ! tag; it should be "scalar", not "'+e.kind+'"'),c=0,l=e.implicitTypes.length;c"),null!==e.result&&u.kind!==e.kind&&Vt(e,"unacceptable node kind for !<"+e.tag+'> tag; it should be "'+u.kind+'", not "'+e.kind+'"'),u.resolve(e.result,e.tag)?(e.result=u.construct(e.result,e.tag),null!==e.anchor&&(e.anchorMap[e.anchor]=e.result)):Vt(e,"cannot resolve a node with !<"+e.tag+"> explicit tag")}return null!==e.listener&&e.listener("close",e),null!==e.tag||null!==e.anchor||g}function ei(e){var t,i,n,r,s=e.position,a=!1;for(e.version=null,e.checkLineBreaks=e.legacy,e.tagMap=Object.create(null),e.anchorMap=Object.create(null);0!==(r=e.input.charCodeAt(e.position))&&(Yt(e,!0,-1),r=e.input.charCodeAt(e.position),!(e.lineIndent>0||37!==r));){for(a=!0,r=e.input.charCodeAt(++e.position),t=e.position;0!==r&&!It(r);)r=e.input.charCodeAt(++e.position);for(n=[],(i=e.input.slice(t,e.position)).length<1&&Vt(e,"directive name must not be less than one character in length");0!==r;){for(;Ct(r);)r=e.input.charCodeAt(++e.position);if(35===r){do{r=e.input.charCodeAt(++e.position)}while(0!==r&&!At(r));break}if(At(r))break;for(t=e.position;0!==r&&!It(r);)r=e.input.charCodeAt(++e.position);n.push(e.input.slice(t,e.position))}0!==r&&Wt(e),pt.call(Ut,i)?Ut[i](e,i,n):Ft(e,'unknown document directive "'+i+'"')}Yt(e,!0,-1),0===e.lineIndent&&45===e.input.charCodeAt(e.position)&&45===e.input.charCodeAt(e.position+1)&&45===e.input.charCodeAt(e.position+2)?(e.position+=3,Yt(e,!0,-1)):a&&Vt(e,"directives end mark is expected"),Zt(e,e.lineIndent-1,gt,!1,!0),Yt(e,!0,-1),e.checkLineBreaks&&wt.test(e.input.slice(s,e.position))&&Ft(e,"non-ASCII line breaks are interpreted as content"),e.documents.push(e.result),e.position===e.lineStart&&Gt(e)?46===e.input.charCodeAt(e.position)&&(e.position+=3,Yt(e,!0,-1)):e.position=55296&&n<=56319&&t+1=56320&&i<=57343?1024*(n-55296)+i-56320+65536:n}function Hi(e){return/^\n* /.test(e)}var qi=1,zi=2,Wi=3,Yi=4,Gi=5;function Ji(e,t,i,n,r){e.dump=function(){if(0===t.length)return e.quotingType===Li?'""':"''";if(!e.noCompatMode&&(-1!==Oi.indexOf(t)||Ni.test(t)))return e.quotingType===Li?'"'+t+'"':"'"+t+"'";var s=e.indent*Math.max(1,i),a=-1===e.lineWidth?-1:Math.max(Math.min(e.lineWidth,40),e.lineWidth-s),o=n||e.flowLevel>-1&&i>=e.flowLevel;switch(function(e,t,i,n,r,s,a,o){var c,l=0,h=null,u=!1,p=!1,d=-1!==n,f=-1,m=function(e){return Bi(e)&&e!==si&&!ji(e)&&e!==yi&&e!==Si&&e!==bi&&e!==vi&&e!==ki&&e!==Ei&&e!==Ci&&e!==Ti&&e!==pi&&e!==fi&&e!==gi&&e!==hi&&e!==Ii&&e!==xi&&e!==wi&&e!==mi&&e!==ui&&e!==di&&e!==_i&&e!==Ai}(Ui(e,0))&&function(e){return!ji(e)&&e!==bi}(Ui(e,e.length-1));if(t||a)for(c=0;c=65536?c+=2:c++){if(!Bi(l=Ui(e,c)))return Gi;m=m&&Fi(l,h,o),h=l}else{for(c=0;c=65536?c+=2:c++){if((l=Ui(e,c))===oi)u=!0,d&&(p=p||c-f-1>n&&" "!==e[f+1],f=c);else if(!Bi(l))return Gi;m=m&&Fi(l,h,o),h=l}p=p||d&&c-f-1>n&&" "!==e[f+1]}return u||p?i>9&&Hi(e)?Gi:a?s===Li?Gi:zi:p?Yi:Wi:!m||a||r(e)?s===Li?Gi:zi:qi}(t,o,e.indent,a,(function(t){return function(e,t){var i,n;for(i=0,n=e.implicitTypes.length;i"+Xi(t,e.indent)+Ki($i(function(e,t){for(var i,n,r,s=/(\n+)([^\n]*)/g,a=(r=-1!==(r=e.indexOf("\n"))?r:e.length,s.lastIndex=r,Qi(e.slice(0,r),t)),o="\n"===e[0]||" "===e[0];n=s.exec(e);){var c=n[1],l=n[2];i=" "===l[0],a+=c+(o||i||""===l?"":"\n")+Qi(l,t),o=i}return a}(t,a),s));case Gi:return'"'+function(e){for(var t,i="",n=0,r=0;r=65536?r+=2:r++)n=Ui(e,r),!(t=Pi[n])&&Bi(n)?(i+=e[r],n>=65536&&(i+=e[r+1])):i+=t||Mi(n);return i}(t)+'"';default:throw new Ce("impossible error: invalid scalar style")}}()}function Xi(e,t){var i=Hi(e)?String(t):"",n="\n"===e[e.length-1];return i+(!n||"\n"!==e[e.length-2]&&"\n"!==e?n?"":"-":"+")+"\n"}function Ki(e){return"\n"===e[e.length-1]?e.slice(0,-1):e}function Qi(e,t){if(""===e||" "===e[0])return e;for(var i,n,r=/ [^ ]/g,s=0,a=0,o=0,c="";i=r.exec(e);)(o=i.index)-s>t&&(n=a>s?a:o,c+="\n"+e.slice(s,n),s=n+1),a=o;return c+="\n",e.length-s>t&&a>s?c+=e.slice(s,a)+"\n"+e.slice(a+1):c+=e.slice(s),c.slice(1)}function Zi(e,t,i,n){var r,s,a,o="",c=e.tag;for(r=0,s=i.length;r tag resolver accepts not "'+c+'" style');n=o.represent[c](t,c)}e.dump=n}return!0}return!1}function tn(e,t,i,n,r,s,a){e.tag=null,e.dump=i,en(e,i,!1)||en(e,i,!0);var o,c=ni.call(e.dump),l=n;n&&(n=e.flowLevel<0||e.flowLevel>t);var h,u,p="[object Object]"===c||"[object Array]"===c;if(p&&(u=-1!==(h=e.duplicates.indexOf(i))),(null!==e.tag&&"?"!==e.tag||u||2!==e.indent&&t>0)&&(r=!1),u&&e.usedDuplicates[h])e.dump="*ref_"+h;else{if(p&&u&&!e.usedDuplicates[h]&&(e.usedDuplicates[h]=!0),"[object Object]"===c)n&&0!==Object.keys(e.dump).length?(function(e,t,i,n){var r,s,a,o,c,l,h="",u=e.tag,p=Object.keys(i);if(!0===e.sortKeys)p.sort();else if("function"==typeof e.sortKeys)p.sort(e.sortKeys);else if(e.sortKeys)throw new Ce("sortKeys must be a boolean or a function");for(r=0,s=p.length;r1024)&&(e.dump&&oi===e.dump.charCodeAt(0)?l+="?":l+="? "),l+=e.dump,c&&(l+=Ri(e,t)),tn(e,t+1,o,!0,c)&&(e.dump&&oi===e.dump.charCodeAt(0)?l+=":":l+=": ",h+=l+=e.dump));e.tag=u,e.dump=h||"{}"}(e,t,e.dump,r),u&&(e.dump="&ref_"+h+e.dump)):(function(e,t,i){var n,r,s,a,o,c="",l=e.tag,h=Object.keys(i);for(n=0,r=h.length;n1024&&(o+="? "),o+=e.dump+(e.condenseFlow?'"':"")+":"+(e.condenseFlow?"":" "),tn(e,t,a,!1,!1)&&(c+=o+=e.dump));e.tag=l,e.dump="{"+c+"}"}(e,t,e.dump),u&&(e.dump="&ref_"+h+" "+e.dump));else if("[object Array]"===c)n&&0!==e.dump.length?(e.noArrayIndent&&!a&&t>0?Zi(e,t-1,e.dump,r):Zi(e,t,e.dump,r),u&&(e.dump="&ref_"+h+e.dump)):(function(e,t,i){var n,r,s,a="",o=e.tag;for(n=0,r=i.length;n",e.dump=o+" "+e.dump)}return!0}function nn(e,t){var i,n,r=[],s=[];for(rn(e,r,s),i=0,n=s.length;ie.trim())).filter((e=>e.length));for(let t=0;te.trim()));e.style.setProperty(n[0],n[1])}}static setText(e,t,i){e instanceof SVGTextElement||(e=e.querySelector("text")||e);const n=t.replace(/\\n/g,"\n").split("\n"),r=n.length>1,s=e.querySelector("tspan");if(r){const t=null==s?void 0:s.getAttribute("x"),r=null==s?void 0:s.getAttribute("y");t&&!e.getAttribute("x")&&e.setAttribute("x",t),r&&!e.getAttribute("y")&&e.setAttribute("y",r);const a=e.querySelector("tspan")||!1;e.textContent="",e.dataset.ha_floorplan_notice="The text_set function split your text into multiple tspans. Only the style of the first tspan is preserved. The style from the original tspan is reused on every tspan. The x and y are calculated on the basis of the first tspan or text-element.";const o=e.getAttribute("x")||"0",c=i||"1em";n.forEach(((t,i)=>{const n=document.createElementNS("http://www.w3.org/2000/svg","tspan");if(n.textContent=t,n.setAttribute("x",o),n.setAttribute("dy",i>=1?c:"0"),a){const e=a.getAttribute("style");e&&n.setAttribute("style",e)}e.appendChild(n)}))}else(s||e).textContent=t}static waitForChildNodes(e,t,i){return new Promise(((n,r)=>{const s=setTimeout((()=>r("Timeout waiting for child element(s) to load")),i);new MutationObserver((e=>{for(const t of e)if("childList"===t.type&&t.addedNodes.length)return clearTimeout(s),n()})).observe(e,{childList:!0,subtree:!0}),t()}))}static formatDate(e){return e?"string"==typeof e?new Date(e).toLocaleString():e.toLocaleString():""}static parseYaml(e){return an.load(e)}static fetchText(e,t,i,n){return on(this,void 0,void 0,(function*(){i&&(e=e.replace(/^\/local\/floorplan\/examples\//g,`${i}/`)),e=n?e:cn.cacheBuster(e);const r=new Request(e,{cache:n?"default":"no-store",mode:t?"no-cors":void 0});try{const e=yield fetch(r);if(e.ok||t&&"opaque"===e.type)return yield e.text();throw new Error("Error fetching resource")}catch(t){throw new URIError(`${e}: ${t.message}`)}}))}static fetchImage(e,t,i,n){return on(this,void 0,void 0,(function*(){t&&(e=e.replace(/^\/local\/floorplan\/examples\//g,`${i}/`)),e=n?e:cn.cacheBuster(e);const r=new Request(e,{cache:n?"default":"no-store",headers:new Headers({"Content-Type":"text/plain; charset=x-user-defined"}),mode:t?"no-cors":void 0});try{const e=yield fetch(r);if(e.ok||t&&"opaque"===e.type){const t=yield e.arrayBuffer();return`data:image/jpeg;base64,${cn.arrayBufferToBase64(t)}`}throw new Error("Error fetching resource")}catch(t){throw new URIError(`${e}: ${t.message}`)}}))}static singleToArray(e){return null==e?[]:Array.isArray(e)?e:[e]}static getArray(e){if(null==e)return[];if(Array.isArray(e))return e;{const t=e;return Object.values(t)}}static getSet(e){if(Array.isArray(e))return new Set(e);{const t=e;return new Set(Object.values(t))}}static arrayBufferToBase64(e){let t="";[].slice.call(new Uint8Array(e)).forEach((e=>t+=String.fromCharCode(e)));let i=window.btoa(t);for(;i.length%4>0;)i+="=";return i}static cacheBuster(e){return`${e}${e.includes("?")?"&":"?"}_=${(new Date).getTime()}`}static equal(e,t){if(e===t)return!0;const i=Array.isArray(e),n=Array.isArray(t);let r=0;if(i&&n){if(e.length!=t.length)return!1;for(r=0;rMath.floor(1e5*(1+Math.random())).toString(16).substring(1);localStorage[e]=`${t()}${t()}_${t()}${t()}`}return localStorage[e]}}class ln{static closestElement(e,t){return function t(i){if(!i||i===document||i===window)return null;i.assignedSlot&&(i=i.assignedSlot);return i.closest(e)||t(i.getRootNode().host)}(t)}}const hn=(e,t,i,n)=>{n=n||{},i=null==i?{}:i;const r=new Event(t,{bubbles:void 0===n.bubbles||n.bubbles,cancelable:Boolean(n.cancelable),composed:void 0===n.composed||n.composed});return r.detail=i,e.dispatchEvent(r),r},un=(e,t,i=!1)=>{i?history.replaceState(null,"",t):history.pushState(null,"",t),hn(window,"location-changed",{replace:i})};class pn{constructor(e,t,i,n){this.entityId=e,this.svgElement=t,this.originalSvgElement=i,this.originalBBox=n}}class dn{constructor(e){this.rule=e,this.svgElementInfos={}}}class fn{constructor(e,t,i,n,r,s){this.instance=e,this.entityId=t,this.elementId=i,this.svgElementInfo=n,this.ruleInfo=r,this.actions=s}}const mn={},gn={};gn.click=gn.mousedown=gn.mouseup=gn.mousemove="MouseEvents";let vn=1;function yn(e){return e._dtId||(e._dtId=vn++)}function bn(e){const t=e.indexOf(".");return t>0?{e:e.substring(0,e.indexOf(".")),ns:e.substring(t+1,e.length)}:{e}}function xn(e,t,i,n){const r=bn(i).e;if(!e._dtId)return!1;const s=mn[yn(e)],a=function(e,t,i,n){return i=bn(i),(mn[yn(e)]||[]).filter((e=>e&&(!i.e||e.e===i.e)&&(!i.ns||e.ns===i.ns)&&(!n||e.callback===n)&&(!t||e.selector===t)))}(e,t,i,n);a.forEach((t=>{e.removeEventListener?e.removeEventListener(r,t.delegator||t.callback):e.detachEvent&&e.detachEvent("on"+r,t.delegator||t.callback),s.splice(s.indexOf(t),1)}))}function wn(e,t,i,n,r,s){const a=bn(i).e,o=bn(i).ns;e.addEventListener?e.addEventListener(a,r||n,s):e.attachEvent&&e.attachEvent("on"+a,r||n);const c=yn(e);(mn[c]||(mn[c]=[])).push({delegator:r,callback:n,e:a,ns:o,selector:t})}const Sn={on(e,t,i,n=null){wn(e,null,t,i,null,n)},off(e,t,i=null){xn(e,null,t,i)},once(e,t,i){const n=e=>(Sn.off(e.currentTarget,e.type,n),i(e));this.on(e,t,n)},delegate(e,t,i,n,r=null){wn(e,t,i,n,(function(i){const r=e.querySelectorAll(t);let s=!1;for(let e=0;e{i=!1,t=setTimeout((()=>{i=!0,e.dispatchEvent(new Event("longClick"))}),400)},r=n=>{clearTimeout(t),i||e.dispatchEvent(new Event("short"+n.type[0].toUpperCase()+n.type.slice(1)))},s=e=>{i&&(e.preventDefault(),e.stopImmediatePropagation&&e.stopImmediatePropagation())};kn.on(e,"mousedown",n.bind(this)),kn.on(e,"tapstart",n.bind(this)),kn.on(e,"touchstart",n.bind(this),{passive:!0}),kn.on(e,"click",r.bind(this)),kn.on(e,"mouseup",r.bind(this)),kn.on(e,"tapend",r.bind(this)),kn.on(e,"touchend",r.bind(this)),kn.on(e,"tap",s.bind(this)),kn.on(e,"touch",s.bind(this)),kn.on(e,"mouseup",s.bind(this)),kn.on(e,"tapend",s.bind(this)),kn.on(e,"touchend",s.bind(this)),kn.on(e,"click",(e=>{e.preventDefault(),e.stopImmediatePropagation&&e.stopImmediatePropagation()}).bind(this))}}const An=_n,Cn=new Set;class In{static observe(e){if(Cn.has(e))return;Cn.add(e);let t,i=0;An.on(e,"click",(()=>{i++,t=setTimeout((()=>{1===i&&(i=0,e.dispatchEvent(new Event("singleClick")))}),400),2===i&&(clearTimeout(t),i=0,e.dispatchEvent(new Event("doubleClick")))}).bind(this))}}class Tn{static isCode(e){return this.isCodeBlock(e)||this.isCodeLine(e)}static isCodeBlock(e){return e.trim().startsWith(">")}static isCodeLine(e){return e.includes("${")&&e.includes("}")}static evaluate(e,t,i,n,r,s,a){this.expression=e.trim();const o=`${this.expression}_${null!=r?r:""}`;this.parsedFunction=this.cache[o],void 0===this.parsedFunction&&(this.functionBody=this.expression,this.isCodeBlock(this.functionBody)?this.functionBody=this.functionBody.slice(1).trim():this.isCodeLine(this.functionBody)&&(this.functionBody.startsWith('"')&&this.functionBody.endsWith('"')&&(this.functionBody=this.functionBody.slice(1,this.functionBody.length-2)),this.functionBody=this.functionBody.replace(/\\"/g,'"'),this.functionBody=`\`${this.functionBody}\`;`,this.functionBody.includes("return")||(this.functionBody=`return ${this.functionBody}`)),this.parsedFunction=this.interpreter.parse(`exports.result = (() => { ${this.functionBody} })();`),this.cache[o]=this.parsedFunction,this.interpreter.import("config",i),this.interpreter.import("util",this.util)),this.entityState=n?t.states[n]:void 0,this.interpreter.import("functions",a),this.interpreter.import("entity",this.entityState),this.interpreter.import("entities",t.states),this.interpreter.import("states",t.states),this.interpreter.import("hass",t),this.interpreter.import("element",r),this.interpreter.import("elements",s);try{this.interpreter.run(this.parsedFunction)}catch(e){throw new EvalError(be(e))}return this.interpreter.exports.result}}Tn.cache={},Tn.interpreter=new(ye())({ecmaVer:2019,sandBox:!0}),Tn.util={color:pe,date:ge};class Pn{constructor(e,t,i){this.element=e,this.logLevel=t,this.consoleLogLevel=i,this.logLevelGroups={error:["error"],warn:["error","warning","warn"],warning:["error","warning","warn"],info:["error","warning","warn","info"],debug:["error","warning","warn","info","debug"]}}log(e,t,i=!1){var n;const r=`${cn.formatDate(new Date)} ${e.toUpperCase()} ${t}`,s=this.logLevel&&this.logLevelGroups[this.logLevel.toLowerCase()],a=(null==s?void 0:s.length)&&s.includes(e.toLowerCase());if((i||a)&&this.element){const t=document.createElement("li");cn.addClass(t,e),t.textContent=r,null===(n=this.element.querySelector("ul"))||void 0===n||n.prepend(t),this.element.style.display="block"}this.consoleLog(e,t,i)}consoleLog(e,t,i=!1){const n=`${cn.formatDate(new Date)} ${e.toUpperCase()} ${t}`,r=this.consoleLogLevel&&this.logLevelGroups[this.consoleLogLevel.toLowerCase()],s=(null==r?void 0:r.length)&&r.includes(e.toLowerCase());if(i||s)switch(e){case"error":console.error(n);break;case"warn":case"warning":console.warn(n);break;case"info":console.info(n);break;default:console.log(n)}}}var On=function(e,t,i,n){var r,s=arguments.length,a=s<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,i,n);else for(var o=e.length-1;o>=0;o--)(r=e[o])&&(a=(s<3?r(a):s>3?r(t,i,a):r(t,i))||a);return s>3&&a&&Object.defineProperty(t,i,a),a},Nn=function(e,t,i,n){return new(i||(i=Promise))((function(r,s){function a(e){try{c(n.next(e))}catch(e){s(e)}}function o(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(a,o)}c((n=n.apply(e,t||[])).next())}))};const Mn=_n;console.info("%cFloorplan for Home Assistant (ha-floorplan)%c\nVersion 1.0.41","color: orange; font-weight: bold; background: black","color: white; font-weight: bold; background: rgb(71, 170, 238)");let Ln=class extends ee{constructor(){super(),this.pageInfos={},this.entityInfos={},this.elementInfos={},this.cssRules=[],this.functions={},this.variables={},this.svgElements={},this.isRulesLoaded=!1,window.onerror=this.handleWindowError.bind(this)}render(){return $`
@@ -122,7 +122,7 @@ const ie=e=>t=>"function"==typeof t?((e,t)=>(customElements.define(e,t),t))(e,t) .debug { color: #000000; } - `}clearLog(){this.logElement.querySelector("#log ul").innerHTML=""}updated(e){const t=Object.create(null,{updated:{get:()=>super.updated}});return Nn(this,void 0,void 0,(function*(){t.updated.call(this,e),e.has("_config")&&(yield this._configChanged(),yield this.hassChanged()),e.has("hass")&&(yield this.hassChanged())}))}_configChanged(){return Nn(this,void 0,void 0,(function*(){this._config&&(yield this.init())}))}hassChanged(){return Nn(this,void 0,void 0,(function*(){if(!this.hass||!this.config||!this.svg)return;const e=cn.deviceId();this.hass.states[`sensor.ha_floorplan_${e}`]={entity_id:`sensor.ha_floorplan_${e}`,state:"on",last_changed:(new Date).toString(),last_updated:(new Date).toString(),attributes:{device_class:"ha-floorplan",friendly_name:"ha-floorplan - Floorplan for Home Assistant",icon:"mdi:floor-plan",assumed_state:!1,hidden:!0},context:{}},this.isRulesLoaded?this.handleEntities():(this.initFloorplanRules(this.svg,this.config),this.isRulesLoaded=!0,yield this.handleEntities(!0))}))}get floorplanElement(){var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.getElementById("floorplan")}get logElement(){var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.getElementById("log")}init(){return Nn(this,void 0,void 0,(function*(){try{const e=yield this.loadConfig(this._config,!1);if(this.isShowLog=void 0!==e.log_level,this.logger=new Pn(this.logElement,e.log_level,e.console_log_level),this.logInfo("INIT","Floorplan for Home Assistant (ha-floorplan) v1.0.40"),!this.validateConfig(e))return;this.config=e,this.config.pages?yield this.initMultiPage():yield this.initSinglePage()}catch(e){this.handleError(e)}}))}initMultiPage(){return Nn(this,void 0,void 0,(function*(){try{yield this.loadPages(),this.initPageDisplay(),this.initVariables(),this.initStartupActions()}catch(e){this.handleError(e)}}))}initSinglePage(){return Nn(this,void 0,void 0,(function*(){try{yield this.loadStyleSheet(this.config.stylesheet);const e=this.getBestImage(this.config);this.svg=yield this.loadFloorplanSvg(e),this.initPageDisplay(),this.initVariables(),this.initStartupActions()}catch(e){this.handleError(e)}}))}loadConfig(e,t){return Nn(this,void 0,void 0,(function*(){if("string"==typeof e){let i;try{i=yield cn.fetchText(e,this.isDemo,this.examplespath,t)}catch(t){throw this.logError("CONFIG",`Error loading config: ${e}`),t}return an.load(i)}return JSON.parse(JSON.stringify(e))}))}loadScript(e,t){return e?new Promise(((i,n)=>{var r;const s=document.createElement("script");s.src=t?e:cn.cacheBuster(e),s.onload=()=>i(),s.onerror=e=>{n(new URIError(`${e.target.src}`))},null===(r=this.shadowRoot)||void 0===r||r.appendChild(s)})):Promise.resolve()}loadPages(){return Nn(this,void 0,void 0,(function*(){for(const e of this.config.pages)yield this.loadPageConfig(e,this.config.pages.indexOf(e));const e=Object.keys(this.pageInfos).map((e=>this.pageInfos[e]));e.sort(((e,t)=>e.index-t.index));const t=e.find((e=>void 0!==e.config.master_page));if(!t)throw new Error("A master page is required");t.isMaster=!0;const i=e.find((e=>void 0===e.config.master_page));i&&(i.isDefault=!0),yield this.loadPageFloorplanSvg(t,t);const n=e.filter((e=>e!==t));for(const e of n)yield this.loadPageFloorplanSvg(e,t);this.svg=t.svg}))}loadPageConfig(e,t){return Nn(this,void 0,void 0,(function*(){const i=yield this.loadConfig(e,!1),n=this.createPageInfo(i);return n.index=t,n}))}loadPageFloorplanSvg(e,t){return Nn(this,void 0,void 0,(function*(){const i=this.getBestImage(e.config),n=yield this.loadFloorplanSvg(i,e,t);n.id=e.config.page_id,e.svg=n,yield this.loadStyleSheet(e.config.stylesheet),this.initFloorplanRules(e.svg,e.config)}))}getBestImage(e){var t;let i="",n=!0;if("string"==typeof e.image)i=cn.isMobile&&"string"==typeof e.image_mobile?e.image_mobile:e.image;else if(null===(t=e.image)||void 0===t?void 0:t.sizes){e.image.sizes.sort(((e,t)=>t.min_width-e.min_width));for(const t of e.image.sizes)if(screen.width>=t.min_width){i=t.location,n=!0===t.cache;break}}else cn.isMobile&&e.image_mobile?(i=e.image_mobile.location,n=!0===e.image_mobile.cache):(i=e.image.location,n=!0===e.image.cache);return{location:i,cache:n}}createPageInfo(e){const t={config:e};return t.config.rules&&this.config.rules&&(t.config.rules=t.config.rules.concat(this.config.rules)),this.pageInfos[t.config.page_id]=t,t}loadStyleSheet(e){return Nn(this,void 0,void 0,(function*(){const t="string"==typeof e?e:e.location,i="string"!=typeof e&&!0===e.cache;if(!t)return;let n;try{n=yield cn.fetchText(t,this.isDemo,this.examplespath,i)}catch(e){throw this.logError("STYLESHEET",`Error loading stylesheet: ${t}`),e}const r=document.createElement("style"),s=()=>{var e;r.innerHTML=n,null===(e=this.shadowRoot)||void 0===e||e.appendChild(r)};try{yield cn.waitForChildNodes(r,s,1e4)}catch(e){this.logError("STYLESHEET","Error loading stylesheet")}const a=this.getCssRules(r);this.cssRules=this.cssRules.concat(a)}))}getCssRules(e){var t,i,n,r,s,a;let o;if(e.sheet)o=null!==(i=null===(t=e.sheet)||void 0===t?void 0:t.cssRules)&&void 0!==i?i:null===(n=e.sheet)||void 0===n?void 0:n.rules;else{const t=e;t.styleSheet&&(o=null!==(s=null===(r=t.styleSheet)||void 0===r?void 0:r.cssRules)&&void 0!==s?s:null===(a=t.styleSheet)||void 0===a?void 0:a.rules)}return o?cn.getArray(o):[]}loadFloorplanSvg(e,t,i){var n;return Nn(this,void 0,void 0,(function*(){let r;try{r=yield cn.fetchText(e.location,this.isDemo,this.examplespath,e.cache)}catch(t){throw this.logError("IMAGE",`Error loading image: ${e.location}`),t}const s=document.createElement("div");s.innerHTML=r;const a=s.querySelector("svg");if(t&&a.setAttribute("id",t.config.page_id),a.setAttribute("height","100%"),a.setAttribute("width","100%"),a.style.height="100%",a.style.width="100%",a.style.margin="auto",a.style.cursor="default",a.style.opacity="0",a.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink"),t&&i){const e=i.config.page_id,r=i.config.master_page.content_element;if(t.config.page_id===e)this.floorplanElement.replaceChildren(a);else{const e=this.floorplanElement.querySelector("#"+r),t=Number.parseFloat(a.getAttribute("height")),i=Number.parseFloat(a.getAttribute("width"));a.getAttribute("viewBox")||a.setAttribute("viewBox",`0 0 ${i} ${t}`),a.setAttribute("preserveAspectRatio","xMinYMin meet"),a.setAttribute("height",e.getAttribute("height")),a.setAttribute("width",e.getAttribute("width")),a.setAttribute("x",e.getAttribute("x")),a.setAttribute("y",e.getAttribute("y")),null===(n=e.parentElement)||void 0===n||n.replaceChildren(a)}}else this.floorplanElement.replaceChildren(a);return a}))}loadImage(e,t,i,n,r){return Nn(this,void 0,void 0,(function*(){return e.toLowerCase().includes(".svg")||"svg"===t.svgElement.nodeName||t.svgElement.querySelector("svg")?yield this.loadSvgImage(e,t,i,n,r):yield this.loadBitmapImage(e,t,i,n,r)}))}loadBitmapImage(e,t,i,n,r){return Nn(this,void 0,void 0,(function*(){e=r?e:cn.cacheBuster(e),this.logDebug("IMAGE",`${i} (setting image: ${e})`);let s=t.svgElement;return"image"!==s.nodeName&&(s=this.createImageElement(t.originalSvgElement),t.svgElement=this.replaceElement(t.svgElement,s),this.attachClickHandlers(s,t,i,void 0,n),s.onmouseover=()=>{this.handleEntityIdSetHoverOver(i,t)}),s.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",e),s}))}loadSvgImage(e,t,i,n,r){return Nn(this,void 0,void 0,(function*(){let s;if(null==e?void 0:e.trim().length)try{s=yield cn.fetchText(e,this.isDemo,this.examplespath,r)}catch(t){throw this.logError("IMAGE",`Error loading image: ${e}`),t}else{const e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("viewBox","0 0 0 0"),s=e.outerHTML}this.logDebug("IMAGE",`${i} (setting image: ${e})`);const a="g"===t.svgElement.nodeName?t.svgElement:document.createElement("div");a.innerHTML=s;const o=a.querySelector("svg"),c=Number.parseFloat(o.getAttribute("height")),l=Number.parseFloat(o.getAttribute("width"));if(o.getAttribute("viewBox")||o.setAttribute("viewBox",`0 0 ${l} ${c}`),o.id=t.svgElement.id,o.setAttribute("preserveAspectRatio","xMinYMin meet"),null!==t.originalBBox&&(o.setAttribute("height",t.originalBBox.height.toString()),o.setAttribute("width",t.originalBBox.width.toString()),o.setAttribute("x",t.originalBBox.x.toString()),o.setAttribute("y",t.originalBBox.y.toString())),"g"!==t.svgElement.nodeName){const e=t.svgElement.getAttribute("transform");e&&o.setAttribute("transform",e),t.svgElement=this.replaceElement(t.svgElement,o)}return this.attachClickHandlers(o,t,i,void 0,n),t.svgElement.onmouseover=()=>{this.handleEntityIdSetHoverOver(i,t)},o}))}_querySelectorAll(e,t=void 0,i){let n=t?Array.from(e.querySelectorAll(t).values()):[];return n=i?[e].concat(n):n,n}replaceElement(e,t){const i=e.parentElement;for(const i of Array.from(e.classList))t.classList.add(i);return this._querySelectorAll(e,"*",!0).forEach((e=>{Mn.off(e,"click"),Mn.off(e,"longClick"),e.remove()})),e.remove(),null==i||i.appendChild(t),t}initPageDisplay(){if(this.config.pages)for(const e of Object.values(this.pageInfos))e.svg.style.opacity="1",e.svg.style.display=e.isMaster||e.isDefault?"initial":"none";else this.svg.style.opacity="1",this.svg.style.display="block"}initVariables(){if(this.config.variables)for(const e of this.config.variables)this.initVariable(e);if(this.config.pages)for(const e of Object.values(this.pageInfos))if(e.config.variables)for(const t of e.config.variables)this.initVariable(t)}initVariable(e){let t,i;if("string"==typeof e?t=e:(t=e.name,i=e.value,e.value&&(i=this.evaluate(e.value,t,void 0))),!this.entityInfos[t]){const e={entityId:t,ruleInfos:[],lastState:void 0};this.entityInfos[t]=e}this.hass.states[t]||(this.hass.states[t]={entity_id:t,state:i,last_changed:(new Date).toString(),last_updated:(new Date).toString(),attributes:{},context:{}}),this.setVariable(t,i,{},!0)}getActionConfigs(e){var t,i;if(null==e)return[];if(Array.isArray(e)){for(const i of e)i.action=null!==(t=i.action)&&void 0!==t?t:"call-service";return e}return"object"==typeof e?(e.action=null!==(i=e.action)&&void 0!==i?i:"call-service",[e]):"string"==typeof e?e.includes(".")?[{action:"call-service",service:e}]:[{action:e}]:[]}initStartupActions(){if(this.handleActions(this.config.startup_action,void 0,void 0,void 0),this.config.pages)for(const e of Object.values(this.pageInfos))this.handleActions(e.config.startup_action,void 0,void 0,void 0)}initFloorplanRules(e,t){if(!t.rules)return;const i=this._querySelectorAll(e,"*",!0);for(const e of i)e.id&&(this.svgElements[e.id]=e);this.initRules(t,e,i)}initRules(e,t,i){if(e.functions&&(this.functions=this.evaluate(e.functions)),e.defaults){const t=e.defaults;for(const i of e.rules)i.hover_action=void 0===i.hover_action?t.hover_action:i.hover_action,i.tap_action=void 0===i.tap_action?t.tap_action:i.tap_action,i.hold_action=void 0===i.hold_action?t.hold_action:i.hold_action,i.hover_info_filter=void 0===i.hover_info_filter?t.hover_info_filter:i.hover_info_filter}for(const n of e.rules)n.entity||n.entities?this.initEntityRule(n,t,i):(n.element||n.elements)&&this.initElementRule(n,t,i)}initEntityRule(e,t,i){const n=this.initGetEntityRuleEntities(e);for(const r of n){const n=r.entityId;let s=this.entityInfos[n];s||(s={entityId:n,ruleInfos:[],lastState:void 0},this.entityInfos[n]=s);const a=new dn(e);s.ruleInfos.push(a);for(const e of r.elementIds){const r=i.find((t=>t.id===e));if(!r){this.logWarning("CONFIG",`Cannot find element '${e}' in SVG file`);continue}const o=this.addSvgElementToRule(t,r,a);o.svgElement=r,r.querySelector("title")||r.appendChild(document.createElementNS("http://www.w3.org/2000/svg","title")),r.onmouseenter=()=>{this.handleEntitySetHoverOver(s,o)},r.onmouseleave=()=>{this.handleEntitySetHoverOver(s,o)},this.attachClickHandlers(r,o,n,void 0,a)}}}initGetEntityRuleEntities(e){const t=[];e.groups=e.groups?e.groups:[];for(const i of e.groups){const e=this.hass.states[i];if(e)for(const i of e.attributes.entity_id)this.addTargetEntity(i,[i],t);else this.logWarning("CONFIG",`Cannot find '${i}' in Home Assistant groups`)}e.entities=e.entities?e.entities:[],e.entities=e.entity?e.entities.concat(e.entity):e.entities;const i=e.entities.filter((e=>"string"==typeof e));for(const n of i){let i=[];e.elements?i=i.concat(e.elements):e.element?i=i.concat(this.evaluate(e.element,n,void 0)):null!==e.element&&(i=i.concat(n)),this.addTargetEntity(n,i,t)}const n=e.entities.filter((e=>"string"!=typeof e));for(const e of n){const i=e;this.addTargetEntity(i.entity,[i.element],t)}return t}addTargetEntity(e,t,i){const n=this.hass.states[e],r="floorplan"===e.split(".")[0];n||r?i.push({entityId:e,elementIds:t}):this.logWarning("CONFIG",`Cannot find '${e}' in Home Assistant entities`)}initElementRule(e,t,i){if(e.element||e.elements){e.elements=e.elements?e.elements:[],e.elements=e.element?e.elements.concat(e.element):e.elements;for(const n of e.elements){const r=i.find((e=>e.id===n));if(r){let i=this.elementInfos[n];i||(i={ruleInfos:[],lastState:void 0},this.elementInfos[n]=i);const s=new dn(e);i.ruleInfos.push(s);const a=this.addSvgElementToRule(t,r,s);this.attachClickHandlers(r,a,void 0,n,s)}else this.logWarning("CONFIG",`Cannot find '${n}' in SVG file`)}}}attachClickHandlers(e,t,i,n,r){this._querySelectorAll(e,void 0,!0).forEach((s=>{const a=s,o=s===e;if(a.querySelector("title")||a.appendChild(document.createElementNS("http://www.w3.org/2000/svg","title")),r.rule.tap_action||r.rule.double_tap_action){const e=!!r.rule.tap_action&&this.getActionConfigs(r.rule.tap_action),s=!!r.rule.double_tap_action&&this.getActionConfigs(r.rule.double_tap_action),c=!!e&&new fn(this,i,n,t,r,e);if(e&&!s&&Mn.on(a,"click",this.onClick.bind(c)),s){const o=!!s&&new fn(this,i,n,t,r,s);In.observe(a),e&&Mn.on(a,"singleClick",this.onClick.bind(c)),Mn.on(a,"doubleClick",this.onLongClick.bind(o))}a.style&&(a.style.cursor="pointer"),cn.addClass(a,"floorplan-click"+(o?"":"-child"))}if(r.rule.hold_action){const e=this.getActionConfigs(r.rule.hold_action),s=new fn(this,i,n,t,r,e);En.observe(a),Mn.on(a,"longClick",this.onLongClick.bind(s)),a.style&&(a.style.cursor="pointer"),cn.addClass(a,"floorplan-long-click"+(o?"":"-child"))}}))}addSvgElementToRule(e,t,i){const n=t.getBBox?t.getBBox():null,r=new pn(t.id,t,t,n);return i.svgElementInfos[t.id]=r,r}createImageElement(e){const t=document.createElementNS("http://www.w3.org/2000/svg","image");return t.setAttribute("id",e.getAttribute("id")),t.setAttribute("x",e.getAttribute("x")),t.setAttribute("y",e.getAttribute("y")),t.setAttribute("height",e.getAttribute("height")),t.setAttribute("width",e.getAttribute("width")),t}handleEntities(e=!1){return Nn(this,void 0,void 0,(function*(){this.handleElements();const t=this.getChangedEntities(e);for(const e of Object.keys(this.variables))t.add(e);if(t.size)for(const e of t)yield this.handleEntity(e)}))}getChangedEntities(e){const t=new Set,i=Object.keys(this.hass.states),n=cn.deviceId();for(const r of i)if(r!==`sensor.ha_floorplan_${n}`||t.has(r)){const i=this.entityInfos[r];if(i){const n=this.hass.states[r];if(e)this.logDebug("STATE",`${r}: ${n.state} (initial load)`),t.has(r)||t.add(r);else if(i.lastState){const e=n.state;n.last_changed!==i.lastState.last_changed?(this.logDebug("STATE",`${r}: ${e} (last changed ${cn.formatDate(i.lastState.last_changed)})`),t.has(r)||t.add(r)):cn.equal(i.lastState.attributes,n.attributes)||(this.logDebug("STATE",`${r}: attributes (last updated ${cn.formatDate(i.lastState.last_changed)})`),t.has(r)||t.add(r))}}}else t.add(r);return t}handleEntity(e){return Nn(this,void 0,void 0,(function*(){const t=this.hass.states[e],i=this.entityInfos[e];if(i){i.lastState=Object.assign({},t);for(const e of i.ruleInfos){const t=Object.values(e.svgElementInfos);if(t.length)for(const n of t)n.svgElement&&this.handleActions(e.rule.state_action,i.entityId,n,e);else this.handleActions(e.rule.state_action,i.entityId,void 0,e)}}}))}handleElements(){return Nn(this,void 0,void 0,(function*(){for(const e of Object.values(this.elementInfos))for(const t of e.ruleInfos)for(const e of Object.values(t.svgElementInfos))this.handleActions(t.rule.state_action,void 0,e,t)}))}handleEntityIdSetHoverOver(e,t){const i=this.entityInfos[e];i&&this.handleEntitySetHoverOver(i,t)}handleEntitySetHoverOver(e,t){const i=e.entityId,n=this.hass.states[i];for(const i of e.ruleInfos)if(i.rule.hover_action){let r="string"==typeof i.rule.hover_action&&"hover-info"===i.rule.hover_action;if(r=r||"object"==typeof i.rule.hover_action&&"hover-info"===i.rule.hover_action.action,r=r||Array.isArray(i.rule.hover_action)&&i.rule.hover_action.some((e=>"hover-info"===e.action)),r){const e=new Set(i.rule.hover_info_filter);for(const t of Object.values(i.svgElementInfos))cn.addClass(t.svgElement,"floorplan-hover"),t.svgElement.style.cursor="pointer",t.svgElement.querySelectorAll("title").forEach((t=>{let i=`${n.attributes.friendly_name}\n`;i+=`State: ${n.state}\n\n`,Object.keys(n.attributes).map((t=>{e.has(t)||(i+=`${t}: ${n.attributes[t]}\n`)})),i+="\n",i+=`Last changed: ${ge.timeago(n.last_changed)}\n`,i+=`Last updated: ${ge.timeago(n.last_updated)}`,t.textContent=i}))}else i.rule.hover_action&&this.handleActions(i.rule.hover_action,e.entityId,t,i)}}isOptionEnabled(e){return null===e||void 0!==e}validateConfig(e){let t=!0;if(e.pages||e.rules)if(e.pages)e.pages.length||this.logWarning("CONFIG","The 'pages' section must contain one or more pages in floorplan configuration");else{e.rules||this.logWarning("CONFIG","Cannot find 'rules' in floorplan configuration");let i=e.rules.filter((e=>e.entities&&e.elements));i.length&&(this.logError("CONFIG","A rule cannot contain both 'entities' and 'elements' in floorplan configuration"),t=!1),i=e.rules.filter((e=>!(e.entity||e.entities||e.element||e.elements))),i.length&&(this.logError("CONFIG","A rule must contain either 'entities' or 'elements' in floorplan configuration"),t=!1)}else this.logWarning("CONFIG","Cannot find 'pages' nor 'rules' in floorplan configuration");return t}evaluate(e,t,i){if("string"!=typeof e||!Tn.isCode(e))return e;try{return Tn.evaluate(e,this.hass,this.config,t,i,this.svgElements,this.functions)}catch(n){return this.handleError(n,{expression:e,entityId:t,hass:this.hass,svgElement:i})}}onClick(e){e.stopPropagation(),e.preventDefault();const t=this;t.instance.handleActions(t.actions,t.entityId,t.svgElementInfo,t.ruleInfo)}onLongClick(e){e.stopPropagation(),e.preventDefault();const t=this,i=t.instance;setTimeout((()=>{i.handleActions(t.actions,t.entityId,t.svgElementInfo,t.ruleInfo)}),300)}handleActions(e,t,i,n){const r=this.getActionConfigs(e);for(const e of r){if(e.confirmation&&(!e.confirmation.exemptions||!e.confirmation.exemptions.some((e=>e.user===this.hass.user.id)))&&!confirm(e.confirmation.text||`Are you sure you want to ${e.action}?`))return;switch(e.action){case"more-info":this.isDemo?this.notify(`Performing action: ${e.action} ${t}`):hn(this,"hass-more-info",{entityId:t});break;case"navigate":this.isDemo?this.notify(`Performing action: ${e.action} ${e.navigation_path}`):un(0,e.navigation_path);break;case"url":if(this.isDemo)this.notify(`Performing action: ${e.action} ${e.url_path}`);else{const t=e.same_tab?"_self":"_blank";window.open(e.url_path,t)}break;case"toggle":if(t){const e={action:"call-service",service:"homeassistant.toggle",service_data:{entity_id:t}};this.callService(e,t,i,n)}break;case"call-service":if(!e.service)return;this.callService(e,t,i,n);break;case"fire-dom-event":hn(this,"ll-custom",e)}}}getSvgElementsFromServiceData(e,t){let i=[],n=[];if(Array.isArray(null==e?void 0:e.elements)&&(n=n.concat(null==e?void 0:e.elements)),"string"==typeof(null==e?void 0:e.element)&&(n=n.concat([null==e?void 0:e.element])),n.length)for(const e of n)i=i.concat(this._querySelectorAll(this.svg,`#${e.replace(/\./g,"\\.")}`,!1));else t&&(i=[t]);return i}getServiceData(e,t,i){let n={};if("object"==typeof e.service_data)for(const r of Object.keys(e.service_data))n[r]=this.evaluate(e.service_data[r],t,i);else if("string"==typeof e.service_data){const r=this.evaluate(e.service_data,t,i);n="string"==typeof r&&r.trim().startsWith("{")?JSON.parse(r):r}else void 0!==e.service_data&&(n=e.service_data);return n}executeServiceData(e,t,i){try{if("object"==typeof e.service_data)for(const n of Object.keys(e.service_data))this.evaluate(e.service_data[n],t,i);else"string"==typeof e.service_data?this.evaluate(e.service_data,t,i):void 0!==e.service_data&&this.logWarning("CONFIG","Invalid execution data");return!0}catch(e){return this.logWarning("CONFIG","Error thrown while executing service"),!1}}callService(e,t,i,n){const r=this.evaluate(e.service,t,null==i?void 0:i.svgElement),[s,a]=r.split(".",2);"floorplan"===s?this.callFloorplanService(s,a,e,t,i,n):this.callHomeAssistantService(s,a,e,t,i)}callFloorplanService(e,t,i,n,r,s){var a,o,c;const l=null!==(a=null==r?void 0:r.svgElement)&&void 0!==a?a:void 0;let h,u,p,d,f,m,g,v,y,b=[],x=null;switch(x=["execute"].includes(t)?{}:this.getServiceData(i,n,l),t){case"class_toggle":b=this.getSvgElementsFromServiceData(x,null==r?void 0:r.svgElement);for(const e of b)y=1===b.length&&b[0]===(null==r?void 0:r.svgElement),y||(x=this.getServiceData(i,n,e)),p="string"==typeof x?x:x.class,cn.toggleClass(e,p);break;case"class_set":b=this.getSvgElementsFromServiceData(x,null==r?void 0:r.svgElement);for(const e of b)y=1===b.length&&b[0]===(null==r?void 0:r.svgElement),y||(x=this.getServiceData(i,n,e)),p="string"==typeof x?x:x.class,cn.setClass(e,p);break;case"dataset_set":{let e,t;if("string"==typeof x){const i=x.split(":");if(i.length<2){this.logError("FLOORPLAN_ACTION",`Service data "${x}" is not a valid dataset key value pair.`);break}e=i[1],t=i[0]}else e=x.value,t=x.key;b=this.getSvgElementsFromServiceData(x,null==r?void 0:r.svgElement);for(const s of b)y=1===b.length&&b[0]===(null==r?void 0:r.svgElement),y||(x=this.getServiceData(i,n,s)),cn.datasetSet(s,t,e);break}case"style_set":b=this.getSvgElementsFromServiceData(x,null==r?void 0:r.svgElement);for(const e of b)y=1===b.length&&b[0]===(null==r?void 0:r.svgElement),y||(x=this.getServiceData(i,n,e)),d="string"==typeof x?x:x.style,cn.setStyle(e,d);break;case"text_set":b=this.getSvgElementsFromServiceData(x,null==r?void 0:r.svgElement);for(const e of b){y=1===b.length&&b[0]===(null==r?void 0:r.svgElement),y||(x=this.getServiceData(i,n,e)),v="string"==typeof x?x:x.text;const t=(null===(o=i.service_data)||void 0===o?void 0:o.shift_y_axis)?null===(c=i.service_data)||void 0===c?void 0:c.shift_y_axis:"1em";cn.setText(e,v,t)}break;case"image_set":r&&s&&(x=this.getServiceData(i,n,null==r?void 0:r.svgElement),f="string"==typeof x?x:x.image,m="object"==typeof x?x.image_refresh_interval:0,g=!(m>0||"object"==typeof x&&!0!==x.cache),s.imageLoader&&clearInterval(s.imageLoader),m&&(s.imageLoader=setInterval(this.loadImage.bind(this),1e3*m,f,r,n,s,g)),this.loadImage(f,r,n,s,g));break;case"page_navigate":x=this.getServiceData(i,n,null==r?void 0:r.svgElement),h=x.page_id,u=h?this.pageInfos[h]:void 0,u&&(Object.keys(this.pageInfos).map((e=>{const t=this.pageInfos[e];t.isMaster||"none"===t.svg.style.display||(t.svg.style.display="none")})),u.svg.style.display="block");break;case"variable_set":if(x=this.getServiceData(i,n,null==r?void 0:r.svgElement),x.variable){const e={};if(x.attributes){const t=x.attributes;for(const i of Object.keys(t))e[i]=this.getActionValue(t[i],n,l)}const t=x,i=this.getActionValue(t,n,l);this.setVariable(x.variable,i,e,!1)}break;case"execute":this.executeServiceData(i,n,null==r?void 0:r.svgElement);for(const e of b)y=1===b.length&&b[0]===(null==r?void 0:r.svgElement),y||this.executeServiceData(i,n,e)}}getActionValue(e,t,i){let n=e.value;return e.value&&(n=this.evaluate(e.value,t,i)),n}setVariable(e,t,i,n){if(this.variables[e]=t,this.hass.states[e]){this.hass.states[e].state=t.toString();for(const t of Object.keys(i))this.hass.states[e].attributes[t]=i[t]}for(const e of Object.keys(this.variables)){const t=this.hass.states[e];t&&(t.last_changed=(new Date).toString())}n||this.handleEntities()}callHomeAssistantService(e,t,i,n,r){const s=this.getServiceData(i,n,null==r?void 0:r.svgElement);"object"==typeof s&&(null===s.entity_id||Array.isArray(s.entity_id)&&!s.entity_id.length||!s.entity_id&&n&&(s.entity_id=n)),this.hass.callService(e,t,s),this.isDemo&&this.notify(`Calling service: ${e}.${t} (${s.entity_id})`)}handleWindowError(e,t,i,n,r){if(e.toLowerCase().includes("script error"))this.logError("SCRIPT","Script error: See browser console for detail");else{const s=[e,"URL: "+t,"Line: "+i+", column: "+n,"Error: "+JSON.stringify(r)].join("
");this.logError("ERROR",s)}return!1}handleError(e,t){console.error(e,t);let i="Error";"string"==typeof e&&(i=e),e.message?i=`${e.message} (See console for more info)`:e.stack&&(i=`${e.stack}`),this.logger.log("error",i)}logError(e,t){this.logger.log("error",`${e} ${t}`)}logWarning(e,t){this.logger.log("warning",`${e} ${t}`)}logInfo(e,t){this.logger.log("info",`${e} ${t}`)}logDebug(e,t){this.logger.log("debug",`${e} ${t}`)}};On([re({type:String})],Ln.prototype,"examplespath",void 0),On([re({type:Object})],Ln.prototype,"hass",void 0),On([re({type:String||Object})],Ln.prototype,"_config",void 0),On([re({type:Boolean})],Ln.prototype,"isDemo",void 0),On([re({type:Boolean})],Ln.prototype,"isShowLog",void 0),On([re({type:Function})],Ln.prototype,"notify",void 0),Ln=On([ie("floorplan-element")],Ln); + `}clearLog(){this.logElement.querySelector("#log ul").innerHTML=""}updated(e){const t=Object.create(null,{updated:{get:()=>super.updated}});return Nn(this,void 0,void 0,(function*(){t.updated.call(this,e),e.has("_config")&&(yield this._configChanged(),yield this.hassChanged()),e.has("hass")&&(yield this.hassChanged())}))}_configChanged(){return Nn(this,void 0,void 0,(function*(){this._config&&(yield this.init())}))}hassChanged(){return Nn(this,void 0,void 0,(function*(){if(!this.hass||!this.config||!this.svg)return;const e=cn.deviceId();this.hass.states[`sensor.ha_floorplan_${e}`]={entity_id:`sensor.ha_floorplan_${e}`,state:"on",last_changed:(new Date).toString(),last_updated:(new Date).toString(),attributes:{device_class:"ha-floorplan",friendly_name:"ha-floorplan - Floorplan for Home Assistant",icon:"mdi:floor-plan",assumed_state:!1,hidden:!0},context:{}},this.isRulesLoaded?this.handleEntities():(this.initFloorplanRules(this.svg,this.config),this.isRulesLoaded=!0,yield this.handleEntities(!0))}))}get floorplanElement(){var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.getElementById("floorplan")}get logElement(){var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.getElementById("log")}init(){return Nn(this,void 0,void 0,(function*(){try{const e=yield this.loadConfig(this._config,!1);if(this.isShowLog=void 0!==e.log_level,this.logger=new Pn(this.logElement,e.log_level,e.console_log_level),this.logInfo("INIT","Floorplan for Home Assistant (ha-floorplan) v1.0.41"),!this.validateConfig(e))return;this.config=e,this.config.pages?yield this.initMultiPage():yield this.initSinglePage()}catch(e){this.handleError(e)}}))}initMultiPage(){return Nn(this,void 0,void 0,(function*(){try{yield this.loadPages(),this.initPageDisplay(),this.initVariables(),this.initStartupActions()}catch(e){this.handleError(e)}}))}initSinglePage(){return Nn(this,void 0,void 0,(function*(){try{yield this.loadStyleSheet(this.config.stylesheet);const e=this.getBestImage(this.config);this.svg=yield this.loadFloorplanSvg(e),this.initPageDisplay(),this.initVariables(),this.initStartupActions()}catch(e){this.handleError(e)}}))}loadConfig(e,t){return Nn(this,void 0,void 0,(function*(){if("string"==typeof e){let i;try{i=yield cn.fetchText(e,this.isDemo,this.examplespath,t)}catch(t){throw this.logError("CONFIG",`Error loading config: ${e}`),t}return an.load(i)}return JSON.parse(JSON.stringify(e))}))}loadScript(e,t){return e?new Promise(((i,n)=>{var r;const s=document.createElement("script");s.src=t?e:cn.cacheBuster(e),s.onload=()=>i(),s.onerror=e=>{n(new URIError(`${e.target.src}`))},null===(r=this.shadowRoot)||void 0===r||r.appendChild(s)})):Promise.resolve()}loadPages(){return Nn(this,void 0,void 0,(function*(){for(const e of this.config.pages)yield this.loadPageConfig(e,this.config.pages.indexOf(e));const e=Object.keys(this.pageInfos).map((e=>this.pageInfos[e]));e.sort(((e,t)=>e.index-t.index));const t=e.find((e=>void 0!==e.config.master_page));if(!t)throw new Error("A master page is required");t.isMaster=!0;const i=e.find((e=>void 0===e.config.master_page));i&&(i.isDefault=!0),yield this.loadPageFloorplanSvg(t,t);const n=e.filter((e=>e!==t));for(const e of n)yield this.loadPageFloorplanSvg(e,t);this.svg=t.svg}))}loadPageConfig(e,t){return Nn(this,void 0,void 0,(function*(){const i=yield this.loadConfig(e,!1),n=this.createPageInfo(i);return n.index=t,n}))}loadPageFloorplanSvg(e,t){return Nn(this,void 0,void 0,(function*(){const i=this.getBestImage(e.config),n=yield this.loadFloorplanSvg(i,e,t);n.id=e.config.page_id,e.svg=n,yield this.loadStyleSheet(e.config.stylesheet),this.initFloorplanRules(e.svg,e.config)}))}getBestImage(e){var t;let i="",n=!0;if("string"==typeof e.image)i=cn.isMobile&&"string"==typeof e.image_mobile?e.image_mobile:e.image;else if(null===(t=e.image)||void 0===t?void 0:t.sizes){e.image.sizes.sort(((e,t)=>t.min_width-e.min_width));for(const t of e.image.sizes)if(screen.width>=t.min_width){i=t.location,n=!0===t.cache;break}}else cn.isMobile&&e.image_mobile?(i=e.image_mobile.location,n=!0===e.image_mobile.cache):(i=e.image.location,n=!0===e.image.cache);return{location:i,cache:n}}createPageInfo(e){const t={config:e};return t.config.rules&&this.config.rules&&(t.config.rules=t.config.rules.concat(this.config.rules)),this.pageInfos[t.config.page_id]=t,t}loadStyleSheet(e){return Nn(this,void 0,void 0,(function*(){const t="string"==typeof e?e:e.location,i="string"!=typeof e&&!0===e.cache;if(!t)return;let n;try{n=yield cn.fetchText(t,this.isDemo,this.examplespath,i)}catch(e){throw this.logError("STYLESHEET",`Error loading stylesheet: ${t}`),e}const r=document.createElement("style"),s=()=>{var e;r.innerHTML=n,null===(e=this.shadowRoot)||void 0===e||e.appendChild(r)};try{yield cn.waitForChildNodes(r,s,1e4)}catch(e){this.logError("STYLESHEET","Error loading stylesheet")}const a=this.getCssRules(r);this.cssRules=this.cssRules.concat(a)}))}getCssRules(e){var t,i,n,r,s,a;let o;if(e.sheet)o=null!==(i=null===(t=e.sheet)||void 0===t?void 0:t.cssRules)&&void 0!==i?i:null===(n=e.sheet)||void 0===n?void 0:n.rules;else{const t=e;t.styleSheet&&(o=null!==(s=null===(r=t.styleSheet)||void 0===r?void 0:r.cssRules)&&void 0!==s?s:null===(a=t.styleSheet)||void 0===a?void 0:a.rules)}return o?cn.getArray(o):[]}loadFloorplanSvg(e,t,i){var n;return Nn(this,void 0,void 0,(function*(){let r;try{r=yield cn.fetchText(e.location,this.isDemo,this.examplespath,e.cache)}catch(t){throw this.logError("IMAGE",`Error loading image: ${e.location}`),t}const s=document.createElement("div");s.innerHTML=r;const a=s.querySelector("svg");if(t&&a.setAttribute("id",t.config.page_id),a.setAttribute("height","100%"),a.setAttribute("width","100%"),a.style.height="100%",a.style.width="100%",a.style.margin="auto",a.style.cursor="default",a.style.opacity="0",a.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink"),t&&i){const e=i.config.page_id,r=i.config.master_page.content_element;if(t.config.page_id===e)this.floorplanElement.replaceChildren(a);else{const e=this.floorplanElement.querySelector("#"+r),t=Number.parseFloat(a.getAttribute("height")),i=Number.parseFloat(a.getAttribute("width"));a.getAttribute("viewBox")||a.setAttribute("viewBox",`0 0 ${i} ${t}`),a.setAttribute("preserveAspectRatio","xMinYMin meet"),a.setAttribute("height",e.getAttribute("height")),a.setAttribute("width",e.getAttribute("width")),a.setAttribute("x",e.getAttribute("x")),a.setAttribute("y",e.getAttribute("y")),null===(n=e.parentElement)||void 0===n||n.replaceChildren(a)}}else this.floorplanElement.replaceChildren(a);return a}))}loadImage(e,t,i,n,r){return Nn(this,void 0,void 0,(function*(){return e.toLowerCase().includes(".svg")||"svg"===t.svgElement.nodeName||t.svgElement.querySelector("svg")?yield this.loadSvgImage(e,t,i,n,r):yield this.loadBitmapImage(e,t,i,n,r)}))}loadBitmapImage(e,t,i,n,r){return Nn(this,void 0,void 0,(function*(){e=r?e:cn.cacheBuster(e),this.logDebug("IMAGE",`${i} (setting image: ${e})`);let s=t.svgElement;return"image"!==s.nodeName&&(s=this.createImageElement(t.originalSvgElement),t.svgElement=this.replaceElement(t.svgElement,s),this.attachClickHandlers(s,t,i,void 0,n),s.onmouseover=()=>{this.handleEntityIdSetHoverOver(i,t)}),s.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",e),s}))}loadSvgImage(e,t,i,n,r){return Nn(this,void 0,void 0,(function*(){let s;if(null==e?void 0:e.trim().length)try{s=yield cn.fetchText(e,this.isDemo,this.examplespath,r)}catch(t){throw this.logError("IMAGE",`Error loading image: ${e}`),t}else{const e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("viewBox","0 0 0 0"),s=e.outerHTML}this.logDebug("IMAGE",`${i} (setting image: ${e})`);const a="g"===t.svgElement.nodeName?t.svgElement:document.createElement("div");a.innerHTML=s;const o=a.querySelector("svg"),c=Number.parseFloat(o.getAttribute("height")),l=Number.parseFloat(o.getAttribute("width"));if(o.getAttribute("viewBox")||o.setAttribute("viewBox",`0 0 ${l} ${c}`),o.id=t.svgElement.id,o.setAttribute("preserveAspectRatio","xMinYMin meet"),null!==t.originalBBox&&(o.setAttribute("height",t.originalBBox.height.toString()),o.setAttribute("width",t.originalBBox.width.toString()),o.setAttribute("x",t.originalBBox.x.toString()),o.setAttribute("y",t.originalBBox.y.toString())),"g"!==t.svgElement.nodeName){const e=t.svgElement.getAttribute("transform");e&&o.setAttribute("transform",e),t.svgElement=this.replaceElement(t.svgElement,o)}return this.attachClickHandlers(o,t,i,void 0,n),t.svgElement.onmouseover=()=>{this.handleEntityIdSetHoverOver(i,t)},o}))}_querySelectorAll(e,t=void 0,i){let n=t?Array.from(e.querySelectorAll(t).values()):[];return n=i?[e].concat(n):n,n}replaceElement(e,t){const i=e.parentElement;for(const i of Array.from(e.classList))t.classList.add(i);return this._querySelectorAll(e,"*",!0).forEach((e=>{Mn.off(e,"click"),Mn.off(e,"longClick"),e.remove()})),e.remove(),null==i||i.appendChild(t),t}initPageDisplay(){if(this.config.pages)for(const e of Object.values(this.pageInfos))e.svg.style.opacity="1",e.svg.style.display=e.isMaster||e.isDefault?"initial":"none";else this.svg.style.opacity="1",this.svg.style.display="block"}initVariables(){if(this.config.variables)for(const e of this.config.variables)this.initVariable(e);if(this.config.pages)for(const e of Object.values(this.pageInfos))if(e.config.variables)for(const t of e.config.variables)this.initVariable(t)}initVariable(e){let t,i;if("string"==typeof e?t=e:(t=e.name,i=e.value,e.value&&(i=this.evaluate(e.value,t,void 0))),!this.entityInfos[t]){const e={entityId:t,ruleInfos:[],lastState:void 0};this.entityInfos[t]=e}this.hass.states[t]||(this.hass.states[t]={entity_id:t,state:i,last_changed:(new Date).toString(),last_updated:(new Date).toString(),attributes:{},context:{}}),this.setVariable(t,i,{},!0)}getActionConfigs(e){var t,i;if(null==e)return[];if(Array.isArray(e)){for(const i of e)i.action=null!==(t=i.action)&&void 0!==t?t:"call-service";return e}return"object"==typeof e?(e.action=null!==(i=e.action)&&void 0!==i?i:"call-service",[e]):"string"==typeof e?e.includes(".")?[{action:"call-service",service:e}]:[{action:e}]:[]}initStartupActions(){if(this.handleActions(this.config.startup_action,void 0,void 0,void 0),this.config.pages)for(const e of Object.values(this.pageInfos))this.handleActions(e.config.startup_action,void 0,void 0,void 0)}initFloorplanRules(e,t){if(!t.rules)return;const i=this._querySelectorAll(e,"*",!0);for(const e of i)e.id&&(this.svgElements[e.id]=e);this.initRules(t,e,i)}initRules(e,t,i){if(e.functions&&(this.functions=this.evaluate(e.functions)),e.defaults){const t=e.defaults;for(const i of e.rules)i.hover_action=void 0===i.hover_action?t.hover_action:i.hover_action,i.tap_action=void 0===i.tap_action?t.tap_action:i.tap_action,i.hold_action=void 0===i.hold_action?t.hold_action:i.hold_action,i.hover_info_filter=void 0===i.hover_info_filter?t.hover_info_filter:i.hover_info_filter}for(const n of e.rules)n.entity||n.entities?this.initEntityRule(n,t,i):(n.element||n.elements)&&this.initElementRule(n,t,i)}initEntityRule(e,t,i){const n=this.initGetEntityRuleEntities(e);for(const r of n){const n=r.entityId;let s=this.entityInfos[n];s||(s={entityId:n,ruleInfos:[],lastState:void 0},this.entityInfos[n]=s);const a=new dn(e);s.ruleInfos.push(a);for(const e of r.elementIds){const r=i.find((t=>t.id===e));if(!r){this.logWarning("CONFIG",`Cannot find element '${e}' in SVG file`);continue}const o=this.addSvgElementToRule(t,r,a);o.svgElement=r,r.querySelector("title")||r.appendChild(document.createElementNS("http://www.w3.org/2000/svg","title")),r.onmouseenter=()=>{this.handleEntitySetHoverOver(s,o)},r.onmouseleave=()=>{this.handleEntitySetHoverOver(s,o)},this.attachClickHandlers(r,o,n,void 0,a)}}}initGetEntityRuleEntities(e){const t=[];e.groups=e.groups?e.groups:[];for(const i of e.groups){const e=this.hass.states[i];if(e)for(const i of e.attributes.entity_id)this.addTargetEntity(i,[i],t);else this.logWarning("CONFIG",`Cannot find '${i}' in Home Assistant groups`)}e.entities=e.entities?e.entities:[],e.entities=e.entity?e.entities.concat(e.entity):e.entities;const i=e.entities.filter((e=>"string"==typeof e));for(const n of i){let i=[];e.elements?i=i.concat(e.elements):e.element?i=i.concat(this.evaluate(e.element,n,void 0)):null!==e.element&&(i=i.concat(n)),this.addTargetEntity(n,i,t)}const n=e.entities.filter((e=>"string"!=typeof e));for(const e of n){const i=e;this.addTargetEntity(i.entity,[i.element],t)}return t}addTargetEntity(e,t,i){const n=this.hass.states[e],r="floorplan"===e.split(".")[0];n||r?i.push({entityId:e,elementIds:t}):this.logWarning("CONFIG",`Cannot find '${e}' in Home Assistant entities`)}initElementRule(e,t,i){if(e.element||e.elements){e.elements=e.elements?e.elements:[],e.elements=e.element?e.elements.concat(e.element):e.elements;for(const n of e.elements){const r=i.find((e=>e.id===n));if(r){let i=this.elementInfos[n];i||(i={ruleInfos:[],lastState:void 0},this.elementInfos[n]=i);const s=new dn(e);i.ruleInfos.push(s);const a=this.addSvgElementToRule(t,r,s);this.attachClickHandlers(r,a,void 0,n,s)}else this.logWarning("CONFIG",`Cannot find '${n}' in SVG file`)}}}attachClickHandlers(e,t,i,n,r){this._querySelectorAll(e,void 0,!0).forEach((s=>{const a=s,o=s===e;if(a.querySelector("title")||a.appendChild(document.createElementNS("http://www.w3.org/2000/svg","title")),r.rule.tap_action||r.rule.double_tap_action){const e=!!r.rule.tap_action&&this.getActionConfigs(r.rule.tap_action),s=!!r.rule.double_tap_action&&this.getActionConfigs(r.rule.double_tap_action),c=!!e&&new fn(this,i,n,t,r,e);if(e&&!s&&Mn.on(a,"click",this.onClick.bind(c)),s){const o=!!s&&new fn(this,i,n,t,r,s);In.observe(a),e&&Mn.on(a,"singleClick",this.onClick.bind(c)),Mn.on(a,"doubleClick",this.onLongClick.bind(o))}a.style&&(a.style.cursor="pointer"),cn.addClass(a,"floorplan-click"+(o?"":"-child"))}if(r.rule.hold_action){const e=this.getActionConfigs(r.rule.hold_action),s=new fn(this,i,n,t,r,e);En.observe(a),Mn.on(a,"longClick",this.onLongClick.bind(s)),a.style&&(a.style.cursor="pointer"),cn.addClass(a,"floorplan-long-click"+(o?"":"-child"))}}))}addSvgElementToRule(e,t,i){const n=t.getBBox?t.getBBox():null,r=new pn(t.id,t,t,n);return i.svgElementInfos[t.id]=r,r}createImageElement(e){const t=document.createElementNS("http://www.w3.org/2000/svg","image");return t.setAttribute("id",e.getAttribute("id")),t.setAttribute("x",e.getAttribute("x")),t.setAttribute("y",e.getAttribute("y")),t.setAttribute("height",e.getAttribute("height")),t.setAttribute("width",e.getAttribute("width")),t}handleEntities(e=!1){return Nn(this,void 0,void 0,(function*(){this.handleElements();const t=this.getChangedEntities(e);for(const e of Object.keys(this.variables))t.add(e);if(t.size)for(const e of t)yield this.handleEntity(e)}))}getChangedEntities(e){const t=new Set,i=Object.keys(this.hass.states),n=cn.deviceId();for(const r of i)if(r!==`sensor.ha_floorplan_${n}`||t.has(r)){const i=this.entityInfos[r];if(i){const n=this.hass.states[r];if(e)this.logDebug("STATE",`${r}: ${n.state} (initial load)`),t.has(r)||t.add(r);else if(i.lastState){const e=n.state;n.last_changed!==i.lastState.last_changed?(this.logDebug("STATE",`${r}: ${e} (last changed ${cn.formatDate(i.lastState.last_changed)})`),t.has(r)||t.add(r)):cn.equal(i.lastState.attributes,n.attributes)||(this.logDebug("STATE",`${r}: attributes (last updated ${cn.formatDate(i.lastState.last_changed)})`),t.has(r)||t.add(r))}}}else t.add(r);return t}handleEntity(e){return Nn(this,void 0,void 0,(function*(){const t=this.hass.states[e],i=this.entityInfos[e];if(i){i.lastState=Object.assign({},t);for(const e of i.ruleInfos){const t=Object.values(e.svgElementInfos);if(t.length)for(const n of t)n.svgElement&&this.handleActions(e.rule.state_action,i.entityId,n,e);else this.handleActions(e.rule.state_action,i.entityId,void 0,e)}}}))}handleElements(){return Nn(this,void 0,void 0,(function*(){for(const e of Object.values(this.elementInfos))for(const t of e.ruleInfos)for(const e of Object.values(t.svgElementInfos))this.handleActions(t.rule.state_action,void 0,e,t)}))}handleEntityIdSetHoverOver(e,t){const i=this.entityInfos[e];i&&this.handleEntitySetHoverOver(i,t)}handleEntitySetHoverOver(e,t){const i=e.entityId,n=this.hass.states[i];for(const i of e.ruleInfos)if(i.rule.hover_action){let r="string"==typeof i.rule.hover_action&&"hover-info"===i.rule.hover_action;if(r=r||"object"==typeof i.rule.hover_action&&"hover-info"===i.rule.hover_action.action,r=r||Array.isArray(i.rule.hover_action)&&i.rule.hover_action.some((e=>"hover-info"===e.action)),r){const e=new Set(i.rule.hover_info_filter);for(const t of Object.values(i.svgElementInfos))cn.addClass(t.svgElement,"floorplan-hover"),t.svgElement.style.cursor="pointer",t.svgElement.querySelectorAll("title").forEach((t=>{let i=`${n.attributes.friendly_name}\n`;i+=`State: ${n.state}\n\n`,Object.keys(n.attributes).map((t=>{e.has(t)||(i+=`${t}: ${n.attributes[t]}\n`)})),i+="\n",i+=`Last changed: ${ge.timeago(n.last_changed)}\n`,i+=`Last updated: ${ge.timeago(n.last_updated)}`,t.textContent=i}))}else i.rule.hover_action&&this.handleActions(i.rule.hover_action,e.entityId,t,i)}}isOptionEnabled(e){return null===e||void 0!==e}validateConfig(e){let t=!0;if(e.pages||e.rules)if(e.pages)e.pages.length||this.logWarning("CONFIG","The 'pages' section must contain one or more pages in floorplan configuration");else{e.rules||this.logWarning("CONFIG","Cannot find 'rules' in floorplan configuration");let i=e.rules.filter((e=>e.entities&&e.elements));i.length&&(this.logError("CONFIG","A rule cannot contain both 'entities' and 'elements' in floorplan configuration"),t=!1),i=e.rules.filter((e=>!(e.entity||e.entities||e.element||e.elements))),i.length&&(this.logError("CONFIG","A rule must contain either 'entities' or 'elements' in floorplan configuration"),t=!1)}else this.logWarning("CONFIG","Cannot find 'pages' nor 'rules' in floorplan configuration");return t}evaluate(e,t,i){if("string"!=typeof e||!Tn.isCode(e))return e;try{return Tn.evaluate(e,this.hass,this.config,t,i,this.svgElements,this.functions)}catch(n){return this.handleError(n,{expression:e,entityId:t,hass:this.hass,svgElement:i})}}onClick(e){e.stopPropagation(),e.preventDefault();const t=this;t.instance.handleActions(t.actions,t.entityId,t.svgElementInfo,t.ruleInfo)}onLongClick(e){e.stopPropagation(),e.preventDefault();const t=this,i=t.instance;setTimeout((()=>{i.handleActions(t.actions,t.entityId,t.svgElementInfo,t.ruleInfo)}),300)}handleActions(e,t,i,n){var r;const s=this.getActionConfigs(e);for(const e of s){if(e.confirmation&&(!e.confirmation.exemptions||!e.confirmation.exemptions.some((e=>e.user===this.hass.user.id)))&&!confirm(e.confirmation.text||`Are you sure you want to ${e.action}?`))return;switch(e.action){case"more-info":this.isDemo?this.notify(`Performing action: ${e.action} ${t}`):hn(this,"hass-more-info",{entityId:t});break;case"navigate":if(this.isDemo)this.notify(`Performing action: ${e.action} ${e.navigation_path}`);else{const n=this.evaluate(e.navigation_path,t,null==i?void 0:i.svgElement);un(0,n,null!==(r=e.navigation_replace)&&void 0!==r&&r)}break;case"url":if(this.isDemo)this.notify(`Performing action: ${e.action} ${e.url_path}`);else{const t=e.same_tab?"_self":"_blank";window.open(e.url_path,t)}break;case"toggle":if(t){const e={action:"call-service",service:"homeassistant.toggle",service_data:{entity_id:t}};this.callService(e,t,i,n)}break;case"call-service":if(!e.service)return;this.callService(e,t,i,n);break;case"fire-dom-event":hn(this,"ll-custom",e)}}}getSvgElementsFromServiceData(e,t){let i=[],n=[];if(Array.isArray(null==e?void 0:e.elements)&&(n=n.concat(null==e?void 0:e.elements)),"string"==typeof(null==e?void 0:e.element)&&(n=n.concat([null==e?void 0:e.element])),n.length)for(const e of n)i=i.concat(this._querySelectorAll(this.svg,`#${e.replace(/\./g,"\\.")}`,!1));else t&&(i=[t]);return i}getServiceData(e,t,i){let n={};if("object"==typeof e.service_data)for(const r of Object.keys(e.service_data))n[r]=this.evaluate(e.service_data[r],t,i);else if("string"==typeof e.service_data){const r=this.evaluate(e.service_data,t,i);n="string"==typeof r&&r.trim().startsWith("{")?JSON.parse(r):r}else void 0!==e.service_data&&(n=e.service_data);return n}executeServiceData(e,t,i){try{if("object"==typeof e.service_data)for(const n of Object.keys(e.service_data))this.evaluate(e.service_data[n],t,i);else"string"==typeof e.service_data?this.evaluate(e.service_data,t,i):void 0!==e.service_data&&this.logWarning("CONFIG","Invalid execution data");return!0}catch(e){return this.logWarning("CONFIG","Error thrown while executing service"),!1}}callService(e,t,i,n){const r=this.evaluate(e.service,t,null==i?void 0:i.svgElement),[s,a]=r.split(".",2);"floorplan"===s?this.callFloorplanService(s,a,e,t,i,n):this.callHomeAssistantService(s,a,e,t,i)}callFloorplanService(e,t,i,n,r,s){var a,o,c;const l=null!==(a=null==r?void 0:r.svgElement)&&void 0!==a?a:void 0;let h,u,p,d,f,m,g,v,y,b=[],x=null;switch(x=["execute"].includes(t)?{}:this.getServiceData(i,n,l),t){case"class_toggle":b=this.getSvgElementsFromServiceData(x,null==r?void 0:r.svgElement);for(const e of b)y=1===b.length&&b[0]===(null==r?void 0:r.svgElement),y||(x=this.getServiceData(i,n,e)),p="string"==typeof x?x:x.class,cn.toggleClass(e,p);break;case"class_set":b=this.getSvgElementsFromServiceData(x,null==r?void 0:r.svgElement);for(const e of b)y=1===b.length&&b[0]===(null==r?void 0:r.svgElement),y||(x=this.getServiceData(i,n,e)),p="string"==typeof x?x:x.class,cn.setClass(e,p);break;case"dataset_set":{let e,t;if("string"==typeof x){const i=x.split(":");if(i.length<2){this.logError("FLOORPLAN_ACTION",`Service data "${x}" is not a valid dataset key value pair.`);break}e=i[1],t=i[0]}else e=x.value,t=x.key;b=this.getSvgElementsFromServiceData(x,null==r?void 0:r.svgElement);for(const s of b)y=1===b.length&&b[0]===(null==r?void 0:r.svgElement),y||(x=this.getServiceData(i,n,s)),cn.datasetSet(s,t,e);break}case"style_set":b=this.getSvgElementsFromServiceData(x,null==r?void 0:r.svgElement);for(const e of b)y=1===b.length&&b[0]===(null==r?void 0:r.svgElement),y||(x=this.getServiceData(i,n,e)),d="string"==typeof x?x:x.style,cn.setStyle(e,d);break;case"text_set":b=this.getSvgElementsFromServiceData(x,null==r?void 0:r.svgElement);for(const e of b){y=1===b.length&&b[0]===(null==r?void 0:r.svgElement),y||(x=this.getServiceData(i,n,e)),v="string"==typeof x?x:x.text;const t=(null===(o=i.service_data)||void 0===o?void 0:o.shift_y_axis)?null===(c=i.service_data)||void 0===c?void 0:c.shift_y_axis:"1em";cn.setText(e,v,t)}break;case"image_set":r&&s&&(x=this.getServiceData(i,n,null==r?void 0:r.svgElement),f="string"==typeof x?x:x.image,m="object"==typeof x?x.image_refresh_interval:0,g=!(m>0||"object"==typeof x&&!0!==x.cache),s.imageLoader&&clearInterval(s.imageLoader),m&&(s.imageLoader=setInterval(this.loadImage.bind(this),1e3*m,f,r,n,s,g)),this.loadImage(f,r,n,s,g));break;case"page_navigate":x=this.getServiceData(i,n,null==r?void 0:r.svgElement),h=x.page_id,u=h?this.pageInfos[h]:void 0,u&&(Object.keys(this.pageInfos).map((e=>{const t=this.pageInfos[e];t.isMaster||"none"===t.svg.style.display||(t.svg.style.display="none")})),u.svg.style.display="block");break;case"variable_set":if(x=this.getServiceData(i,n,null==r?void 0:r.svgElement),x.variable){const e={};if(x.attributes){const t=x.attributes;for(const i of Object.keys(t))e[i]=this.getActionValue(t[i],n,l)}const t=x,i=this.getActionValue(t,n,l);this.setVariable(x.variable,i,e,!1)}break;case"execute":this.executeServiceData(i,n,null==r?void 0:r.svgElement);for(const e of b)y=1===b.length&&b[0]===(null==r?void 0:r.svgElement),y||this.executeServiceData(i,n,e)}}getActionValue(e,t,i){let n=e.value;return e.value&&(n=this.evaluate(e.value,t,i)),n}setVariable(e,t,i,n){if(this.variables[e]=t,this.hass.states[e]){this.hass.states[e].state=t.toString();for(const t of Object.keys(i))this.hass.states[e].attributes[t]=i[t]}for(const e of Object.keys(this.variables)){const t=this.hass.states[e];t&&(t.last_changed=(new Date).toString())}n||this.handleEntities()}callHomeAssistantService(e,t,i,n,r){const s=this.getServiceData(i,n,null==r?void 0:r.svgElement);"object"==typeof s&&(null===s.entity_id||Array.isArray(s.entity_id)&&!s.entity_id.length||!s.entity_id&&n&&(s.entity_id=n)),this.hass.callService(e,t,s),this.isDemo&&this.notify(`Calling service: ${e}.${t} (${s.entity_id})`)}handleWindowError(e,t,i,n,r){if(e.toLowerCase().includes("script error"))this.logError("SCRIPT","Script error: See browser console for detail");else{const s=[e,"URL: "+t,"Line: "+i+", column: "+n,"Error: "+JSON.stringify(r)].join("
");this.logError("ERROR",s)}return!1}handleError(e,t){console.error(e,t);let i="Error";"string"==typeof e&&(i=e),e.message?i=`${e.message} (See console for more info)`:e.stack&&(i=`${e.stack}`),this.logger.log("error",i)}logError(e,t){this.logger.log("error",`${e} ${t}`)}logWarning(e,t){this.logger.log("warning",`${e} ${t}`)}logInfo(e,t){this.logger.log("info",`${e} ${t}`)}logDebug(e,t){this.logger.log("debug",`${e} ${t}`)}};On([re({type:String})],Ln.prototype,"examplespath",void 0),On([re({type:Object})],Ln.prototype,"hass",void 0),On([re({type:String||Object})],Ln.prototype,"_config",void 0),On([re({type:Boolean})],Ln.prototype,"isDemo",void 0),On([re({type:Boolean})],Ln.prototype,"isShowLog",void 0),On([re({type:Function})],Ln.prototype,"notify",void 0),Ln=On([ie("floorplan-element")],Ln); /** * @license * Copyright 2017 Google LLC