`}_cardEntities(t){const e=this._planHass,i=[],s=new Set,o=t=>{if(!t||s.has(t)||!e.states[t])return;const o=e.entities[t];if("config"===o?.entity_category||"diagnostic"===o?.entity_category)return;s.add(t);const n=t.split(".")[0];["light","switch","fan","humidifier","siren","input_boolean"].includes(n)?i.push({eid:t,kind:"toggle"}):["cover","valve","lock","climate","media_player","vacuum","water_heater"].includes(n)?i.push({eid:t,kind:"open"}):["sensor","binary_sensor","number","select"].includes(n)&&i.push({eid:t,kind:"value"})};for(const i of xo(e,[t]))o(i.eid);t.primary&&o(t.primary);for(const e of t.entities)o(e);return i.slice(0,12)}_cardToggle(t){const e=t.split(".")[0];"lock"!==e&&"alarm_control_panel"!==e&&this._planEntityAvailable(t)&&this.hass.callService("homeassistant","toggle",{entity_id:t}).catch(t=>this._showToast(this._t("toast.error",{err:this._errText(t)})))}_renderInfoCard(){const t=this._infoCard,e=t.primary?this.hass.states[t.primary]:void 0,i=e?Oi(this.hass,t.primary)?.text??e.state:null,s=(t.controls??t.marker?.controls??[]).filter(ps).filter(t=>this._planEntityAvailable(t));return B``}_cardEntities(t){const e=this._planHass,i=[],s=new Set,n=t=>{if(!t||s.has(t)||!e.states[t])return;const n=e.entities[t];if("config"===n?.entity_category||"diagnostic"===n?.entity_category)return;s.add(t);const o=t.split(".")[0];["light","switch","fan","humidifier","siren","input_boolean"].includes(o)?i.push({eid:t,kind:"toggle"}):["cover","valve","lock","climate","media_player","vacuum","water_heater"].includes(o)?i.push({eid:t,kind:"open"}):["sensor","binary_sensor","number","select"].includes(o)&&i.push({eid:t,kind:"value"})};for(const i of xn(e,[t]))n(i.eid);t.primary&&n(t.primary);for(const e of t.entities)n(e);return i.slice(0,12)}_cardToggle(t){const e=t.split(".")[0];"lock"!==e&&"alarm_control_panel"!==e&&this._planEntityAvailable(t)&&this.hass.callService("homeassistant","toggle",{entity_id:t}).catch(t=>this._showToast(this._t("toast.error",{err:this._errText(t)})))}_renderInfoCard(){const t=this._infoCard,e=t.primary?this.hass.states[t.primary]:void 0,i=e?Oi(this.hass,t.primary)?.text??e.state:null,s=(t.controls??t.marker?.controls??[]).filter(ps).filter(t=>this._planEntityAvailable(t));return B`
`}get _glowRadiusCm(){const t=Number(this._settings.glow_radius_cm);return Number.isFinite(t)&&t>0?t:300}get _imperial(){return"mi"===this.hass?.config?.unit_system?.length}get _glowRadiusPlaceholder(){const t=this._glowRadiusCm;return this._imperial?String(Math.round(t/30.48*10)/10):String(t/100)}_glowTransition(t,e){let i=this._glowRenderedSources.get(t);if(e){const e=this._glowFadeTimers.get(t);if(null!=e&&(clearTimeout(e),this._glowFadeTimers.delete(t)),null==i){i=++this._glowSourceSeq,this._glowRenderedSources.set(t,i),this._glowEnteringSources.add(t);const e=requestAnimationFrame(()=>{this._glowEnterRafs.get(t)===e&&(this._glowEnterRafs.delete(t),this._glowEnteringSources.delete(t),this.isConnected&&this.requestUpdate())});this._glowEnterRafs.set(t,e)}return{domId:i,entering:this._glowEnteringSources.has(t),leaving:!1}}if(null==i)return null;const s=this._glowEnterRafs.get(t);if(null!=s&&cancelAnimationFrame(s),this._glowEnterRafs.delete(t),this._glowEnteringSources.delete(t),!this._glowFadeTimers.has(t)){const e=window.setTimeout(()=>{this._glowFadeTimers.get(t)===e&&(this._glowFadeTimers.delete(t),this._glowRenderedSources.delete(t),this._glowLastAppearance.delete(t),this.isConnected&&this.requestUpdate())},534);this._glowFadeTimers.set(t,e)}return{domId:i,entering:!1,leaving:!0}}_forgetGlowSource(t){const e=this._glowFadeTimers.get(t);null!=e&&clearTimeout(e);const i=this._glowEnterRafs.get(t);null!=i&&cancelAnimationFrame(i),this._glowFadeTimers.delete(t),this._glowEnterRafs.delete(t),this._glowEnteringSources.delete(t),this._glowRenderedSources.delete(t),this._glowLastAppearance.delete(t)}_forgetGlowSpace(t){const e=`${t}|`;for(const t of this._glowRenderedSources.keys())t.startsWith(e)&&this._forgetGlowSource(t)}_lightBarriers(t,e,i){const s=this._openPairs().flatMap(t=>t.segs),o=[...s],n=Math.max(this._cmToUnits(10),.5*this._gridPitch),r=t=>e.some(e=>this._pointInRoom(t,e.r)),a=this._openingsR.filter(t=>{if("window"===t.type)return!1;const e=t.angle*Math.PI/180,i=-Math.sin(e),s=Math.cos(e);return r([t.rx+i*n,t.ry+s*n])&&r([t.rx-i*n,t.ry-s*n])});for(const t of a){const e=t.angle*Math.PI/180,i=Math.cos(e)*t.rlen/2,s=Math.sin(e)*t.rlen/2;o.push([t.rx-i,t.ry-s,t.rx+i,t.ry+s])}let l=2166136261;const c=t=>{l^=Math.round(64*(Number.isFinite(t)?t:0)),l=Math.imul(l,16777619)>>>0},h=this._spaceWalls;for(const{poly:t}of e){c(t.length);for(const e of t)c(e[0]),c(e[1])}for(const t of o)for(const e of t)c(e);for(const t of i)c(t.length),c(t[0]?.[0]??0),c(t[0]?.[1]??0);for(const t of h)c(t.cm),c(t.a?.[0]??0),c(t.a?.[1]??0);const d=l.toString(36);if(this._lightBarrierCache?.key===d)return this._lightBarrierCache.value;const p=.02*this._gridPitch,u=[],_=h.length?Wr(t.rooms,h,s,a.map(t=>({x:t.rx,y:t.ry,angle:t.angle,length:t.rlen})),this._wallKeyPitch,this._cellCm,this._gridPitch,eh):null;for(const t of function(t){const e=[];for(const i of t||[])for(const t of i||[])t?.length>=4&&e.push(t.slice(0,-1).map(t=>[t[0],t[1]]));return e}(_?.geom))u.push(...Ql(t));for(const{poly:t}of e)for(const e of o.length?ms(t,o,p):Ql(t))u.push(e);for(const t of i)u.push(...Ql(t));const m={occluders:Xl(u),floor:e.map(t=>t.poly),fingerprint:d};return this._lightBarrierCache={key:d,value:m},m}_renderGlowLayer(t,e){const i=this._fillColors,s=this._glowRadiusCm/this._cellCm*this._gridPitch;this._gridPitch;const o=t.rooms.map(t=>({r:t,poly:Je(t)})).filter(t=>!!t.poly),n=o.filter(({r:t})=>ws(e.glow,t));if(!n.length)return this._forgetGlowSpace(t.id),j``;const r=this._physicalBodiesR(t),{occluders:a,floor:l,fingerprint:c}=this._lightBarriers(t,o,r),h=xo(this._planHass,this._devices.filter(e=>e.space===t.id)),d=new Map;for(const t of h){if(!t.device.id)continue;const e=d.get(t.device.id)||[];e.push(t),d.set(t.device.id,e)}const p=[],u=new Set;for(const e of this._devices){if(e.space!==t.id)continue;const o=So(d.get(e.id)||[]);if(!o)continue;const n=`${t.id}|${e.id}`;u.add(n);const h=hs(this._planHass.states[o.eid],e.marker?.glow_color,i.glow_light.c),_=Number(e.marker?.glow_radius_cm),m=Number.isFinite(_)&&_>0?_/this._cellCm*this._gridPitch:s,g=this._pos(e);if(r.some(t=>ya([g.x,g.y],t))){this._glowTransition(n,!1);continue}const f=this._glowTransition(n,!!h);if(!f)continue;h&&this._glowLastAppearance.set(n,{c:h.c,alpha:ds(h.bri,i.glow_light.a)});const v=this._glowLastAppearance.get(n);if(!v)continue;let y=null;const b=`${t.id}|${c}|${g.x.toFixed(4)},${g.y.toFixed(4)}|${m.toFixed(4)}`,w=qc(this._glowClipCache,b);if(w.hit)y=w.value;else{const t=ic([g.x,g.y],m,a,96);y={lit:t.length>=3?ma([t],l):[]},Uc(this._glowClipCache,b,y,256)}p.push({key:n,sourceEid:o.eid,domId:f.domId,entering:f.entering,leaving:f.leaving,pos:g,c:v.c,alpha:v.alpha,geometry:y,r:m})}const _=`${t.id}|`;for(const t of this._glowRenderedSources.keys())t.startsWith(_)&&!u.has(t)&&this._forgetGlowSource(t);if(!p.length)return j``;const m=this._spaceWalls,g=n.length===o.length?null:n.map(({r:e,poly:i})=>{const s=m.length&&e.id&&jr(t.rooms,e.id,m,this._openPairs().flatMap(t=>t.segs),this._wallKeyPitch,this._cellCm,this._gridPitch,eh)||i,n=this._cleanFloor(e,s,t).path,r=_i(s,o.filter(t=>t.r!==e).map(t=>t.poly)),a=t=>"M "+t.map(t=>t[0]+" "+t[1]).join(" L ")+" Z";return[n||a(s),...r.map(a)].join(" ")}),f=this._viewOr(this._baseVb()),v=this._stageEl?.clientWidth&&f.w?this._stageEl.clientWidth/f.w:1,y=1/(v>0?v:1),b=4*y,w=p.reduce((t,e)=>({x:Math.min(t.x,e.pos.x-e.r-b),y:Math.min(t.y,e.pos.y-e.r-b),maxX:Math.max(t.maxX,e.pos.x+e.r+b),maxY:Math.max(t.maxY,e.pos.y+e.r+b),w:0,h:0}),{x:1/0,y:1/0,maxX:-1/0,maxY:-1/0,w:0,h:0});return w.w=w.maxX-w.x,w.h=w.maxY-w.y,j`
- ${kt(p,t=>t.key,t=>{const e=t.domId,i=t.geometry;return j`
+
`}get _glowRadiusCm(){const t=Number(this._settings.glow_radius_cm);return Number.isFinite(t)&&t>0?t:300}get _imperial(){return"mi"===this.hass?.config?.unit_system?.length}get _glowRadiusPlaceholder(){const t=this._glowRadiusCm;return this._imperial?String(Math.round(t/30.48*10)/10):String(t/100)}_glowTransition(t,e){let i=this._glowRenderedSources.get(t);if(e){const e=this._glowFadeTimers.get(t);if(null!=e&&(clearTimeout(e),this._glowFadeTimers.delete(t)),null==i){this._suspendGlowFeatherForTransition(),i=++this._glowSourceSeq,this._glowRenderedSources.set(t,i),this._glowEnteringSources.add(t);const e=requestAnimationFrame(()=>{this._glowEnterRafs.get(t)===e&&(this._glowEnterRafs.delete(t),this._glowEnteringSources.delete(t),this.isConnected&&this.requestUpdate())});this._glowEnterRafs.set(t,e)}return{domId:i,entering:this._glowEnteringSources.has(t),leaving:!1}}if(null==i)return null;const s=this._glowEnterRafs.get(t);if(null!=s&&cancelAnimationFrame(s),this._glowEnterRafs.delete(t),this._glowEnteringSources.delete(t),!this._glowFadeTimers.has(t)){this._suspendGlowFeatherForTransition();const e=window.setTimeout(()=>{this._glowFadeTimers.get(t)===e&&(this._glowFadeTimers.delete(t),this._glowRenderedSources.delete(t),this._glowLastAppearance.delete(t),this.isConnected&&this.requestUpdate())},534);this._glowFadeTimers.set(t,e)}return{domId:i,entering:!1,leaving:!0}}_suspendGlowFeatherForTransition(){if(window.matchMedia?.("(prefers-reduced-motion: reduce)").matches)return;this._glowFeatherSuspendUntil=Math.max(this._glowFeatherSuspendUntil,Date.now()+500),clearTimeout(this._glowFeatherResumeTimer);const t=Math.max(0,this._glowFeatherSuspendUntil-Date.now())+17,e=()=>{this._glowFeatherResumeTimer=0,Date.now()t.segs),n=[...s],o=Math.max(this._cmToUnits(10),.5*this._gridPitch),r=t=>e.some(e=>this._pointInRoom(t,e.r)),a=this._openingsR.filter(t=>{if("window"===t.type)return!1;const e=t.angle*Math.PI/180,i=-Math.sin(e),s=Math.cos(e);return r([t.rx+i*o,t.ry+s*o])&&r([t.rx-i*o,t.ry-s*o])});for(const t of a){const e=t.angle*Math.PI/180,i=Math.cos(e)*t.rlen/2,s=Math.sin(e)*t.rlen/2;n.push([t.rx-i,t.ry-s,t.rx+i,t.ry+s])}let l=2166136261;const c=t=>{l^=Math.round(64*(Number.isFinite(t)?t:0)),l=Math.imul(l,16777619)>>>0},h=this._spaceWalls;c(this._cellCm),c(this._gridPitch),c(this._wallKeyPitch);for(const{poly:t}of e){c(t.length);for(const e of t)c(e[0]),c(e[1])}for(const t of n)for(const e of t)c(e);for(const t of i){c(t.length);for(const e of t)c(e[0]),c(e[1])}for(const t of h)c(t.cm),c(t.a?.[0]??0),c(t.a?.[1]??0),c(t.b?.[0]??0),c(t.b?.[1]??0);const d=l.toString(36),p=`${t.id}|${d}`;if(this._lightBarrierCache?.key===p)return this._lightBarrierCache.value;const u=.02*this._gridPitch,_=[],m=h.length?Gr(t.rooms,h,s,a.map(t=>({x:t.rx,y:t.ry,angle:t.angle,length:t.rlen})),this._wallKeyPitch,this._cellCm,this._gridPitch,oh):null;for(const t of function(t){const e=[];for(const i of t||[])for(const t of i||[])t?.length>=4&&e.push(t.slice(0,-1).map(t=>[t[0],t[1]]));return e}(m?.geom))_.push(...tc(t));for(const{poly:t}of e)for(const e of n.length?ms(t,n,u):tc(t))_.push(e);for(const t of i)_.push(...tc(t));const g={occluders:Ql(_),floor:e.map(t=>t.poly),fingerprint:d};return this._lightBarrierCache={key:p,value:g},g}_renderGlowLayer(t,e){const i=this._fillColors,s=this._glowRadiusCm/this._cellCm*this._gridPitch,n=t.rooms.map(t=>({r:t,poly:Je(t)})).filter(t=>!!t.poly),o=n.filter(({r:t})=>ws(e.glow,t));if(!o.length)return this._forgetGlowSpace(t.id),W``;const r=this._physicalBodiesR(t),{occluders:a,floor:l,fingerprint:c}=this._lightBarriers(t,n,r),h=xn(this._planHass,this._devices.filter(e=>e.space===t.id)),d=new Map;for(const t of h){if(!t.device.id)continue;const e=d.get(t.device.id)||[];e.push(t),d.set(t.device.id,e)}const p=[],u=new Set;for(const e of this._devices){if(e.space!==t.id)continue;const n=Sn(d.get(e.id)||[]);if(!n)continue;const o=`${t.id}|${e.id}`;u.add(o);const h=hs(this._planHass.states[n.eid],e.marker?.glow_color,i.glow_light.c),_=Number(e.marker?.glow_radius_cm),m=Number.isFinite(_)&&_>0?_/this._cellCm*this._gridPitch:s,g=this._pos(e);if(r.some(t=>va([g.x,g.y],t))){this._forgetGlowSource(o);continue}const f=this._glowTransition(o,!!h);if(!f)continue;h&&this._glowLastAppearance.set(o,{c:h.c,alpha:ds(h.bri,i.glow_light.a)});const v=this._glowLastAppearance.get(o);if(!v)continue;let y=null;const b=`${t.id}|${c}|${g.x.toFixed(4)},${g.y.toFixed(4)}|${m.toFixed(4)}`,w=Kc(this._glowClipCache,b);if(w.hit)y=w.value;else{const t=sc([g.x,g.y],m,a,96);y={lit:t.length>=3?_a([t],l):[]},Yc(this._glowClipCache,b,y,256)}p.push({key:o,sourceEid:n.eid,domId:f.domId,entering:f.entering,leaving:f.leaving,pos:g,c:v.c,alpha:v.alpha,geometry:y,r:m})}const _=`${t.id}|`;for(const t of this._glowRenderedSources.keys())t.startsWith(_)&&!u.has(t)&&this._forgetGlowSource(t);if(!p.length)return W``;const m=this._spaceWalls,g=o.length===n.length?[]:this._openPairs().flatMap(t=>t.segs),f=o.length===n.length?null:o.map(({r:e,poly:i})=>{const s=m.length&&e.id&&Wr(t.rooms,e.id,m,g,this._wallKeyPitch,this._cellCm,this._gridPitch,oh)||i,o=this._cleanFloor(e,s,t).path,r=_i(s,n.filter(t=>t.r!==e).map(t=>t.poly)),a=t=>"M "+t.map(t=>t[0]+" "+t[1]).join(" L ")+" Z";return[o||a(s),...r.map(a)].join(" ")}),v=this._viewOr(this._baseVb()),y=this._stageEl?.clientWidth&&v.w?this._stageEl.clientWidth/v.w:1,b=1/(y>0?y:1),w=!this._pinchStart&&!this._panStart&&Date.now()>=this._glowFeatherSuspendUntil;(null==this._glowFeatherUnits||w)&&(this._glowFeatherUnits=b);const k=this._glowFeatherUnits??b,$=4*k,x=p.reduce((t,e)=>({x:Math.min(t.x,e.pos.x-e.r-$),y:Math.min(t.y,e.pos.y-e.r-$),maxX:Math.max(t.maxX,e.pos.x+e.r+$),maxY:Math.max(t.maxY,e.pos.y+e.r+$),w:0,h:0}),{x:1/0,y:1/0,maxX:-1/0,maxY:-1/0,w:0,h:0});return x.w=x.maxX-x.x,x.h=x.maxY-x.y,W`
+ ${kt(p,t=>t.key,t=>{const e=t.domId,i=t.geometry;return W`
${""}
- ${ih.map(([e,i])=>j`
+ ${rh.map(([e,i])=>W`
`)}
${""}
- ${i?j`
+ ${i?W`
- `:W}`})}
- ${g?j`${g.map(t=>j``)}`:W}
+ `:G}`})}
+ ${f?W`${f.map(t=>W``)}`:G}
${""}
-
+
${""}
+ filter=${w?"url(#hp-glowfeather)":G}>
- ${kt(p,t=>t.key,t=>{const e=t.domId;return j`
+ clip-path=${f?"url(#hp-glow-enabled)":G}>
+ ${kt(p,t=>t.key,t=>{const e=t.domId;return W`
+ clip-path=${t.geometry?`url(#hp-glowclip-${e})`:G}>
`})}
`}_renderAlignDialog(){const t=this._alignDialog,e=t.report;return B`this._alignDialog=null}>
`}_cardEntities(t){const e=this._planHass,i=[],s=new Set,o=t=>{if(!t||s.has(t)||!e.states[t])return;const o=e.entities[t];if("config"===o?.entity_category||"diagnostic"===o?.entity_category)return;s.add(t);const n=t.split(".")[0];["light","switch","fan","humidifier","siren","input_boolean"].includes(n)?i.push({eid:t,kind:"toggle"}):["cover","valve","lock","climate","media_player","vacuum","water_heater"].includes(n)?i.push({eid:t,kind:"open"}):["sensor","binary_sensor","number","select"].includes(n)&&i.push({eid:t,kind:"value"})};for(const i of xo(e,[t]))o(i.eid);t.primary&&o(t.primary);for(const e of t.entities)o(e);return i.slice(0,12)}_cardToggle(t){const e=t.split(".")[0];"lock"!==e&&"alarm_control_panel"!==e&&this._planEntityAvailable(t)&&this.hass.callService("homeassistant","toggle",{entity_id:t}).catch(t=>this._showToast(this._t("toast.error",{err:this._errText(t)})))}_renderInfoCard(){const t=this._infoCard,e=t.primary?this.hass.states[t.primary]:void 0,i=e?Oi(this.hass,t.primary)?.text??e.state:null,s=(t.controls??t.marker?.controls??[]).filter(ps).filter(t=>this._planEntityAvailable(t));return B``}_cardEntities(t){const e=this._planHass,i=[],s=new Set,n=t=>{if(!t||s.has(t)||!e.states[t])return;const n=e.entities[t];if("config"===n?.entity_category||"diagnostic"===n?.entity_category)return;s.add(t);const o=t.split(".")[0];["light","switch","fan","humidifier","siren","input_boolean"].includes(o)?i.push({eid:t,kind:"toggle"}):["cover","valve","lock","climate","media_player","vacuum","water_heater"].includes(o)?i.push({eid:t,kind:"open"}):["sensor","binary_sensor","number","select"].includes(o)&&i.push({eid:t,kind:"value"})};for(const i of xn(e,[t]))n(i.eid);t.primary&&n(t.primary);for(const e of t.entities)n(e);return i.slice(0,12)}_cardToggle(t){const e=t.split(".")[0];"lock"!==e&&"alarm_control_panel"!==e&&this._planEntityAvailable(t)&&this.hass.callService("homeassistant","toggle",{entity_id:t}).catch(t=>this._showToast(this._t("toast.error",{err:this._errText(t)})))}_renderInfoCard(){const t=this._infoCard,e=t.primary?this.hass.states[t.primary]:void 0,i=e?Oi(this.hass,t.primary)?.text??e.state:null,s=(t.controls??t.marker?.controls??[]).filter(ps).filter(t=>this._planEntityAvailable(t));return B`