+ `,so=1e3;function oo(t,e){const i=Number(t),s=Number.isFinite(i)&&i>0?i:1,o=s>=1?e:e*s,n=s>=1?e/s:e;return{x:(e-o)/2,y:(e-n)/2,w:o,h:n}}function no(t){if(null==t.x||null==t.y)return{x:t.x,y:t.y,w:t.w,h:t.h};const e=Number(t.w)||0,i=Number(t.h)||0;return{x:e<0?t.x+e:t.x,y:i<0?t.y+i:t.y,w:Math.abs(e),h:Math.abs(i)}}function ro(t){return t&&Array.isArray(t.spaces)?t.spaces.map(t=>{const e=so,i=function(t){return Array.isArray(t)&&4===t.length&&t.every(t=>Number.isFinite(t))&&t[2]>1e-6&&t[3]>1e-6?t:[0,0,1,1]}(t.view_box);return{id:t.id,title:t.title,vb:[i[0]*so,i[1]*e,i[2]*so,i[3]*e],bg:t.plan_url?{href:Pi(t.plan_url),...oo(t.plan_aspect,so)}:null,rooms:(t.rooms||[]).map(t=>{const i={...t,...no(t)};return{id:i.id,name:i.name,area:i.area??null,open_to:i.open_to||void 0,settings:i.settings||void 0,x:null!=i.x?i.x*so:void 0,y:null!=i.y?i.y*e:void 0,w:null!=i.w?i.w*so:void 0,h:null!=i.h?i.h*e:void 0,poly:i.poly?i.poly.map(t=>[t[0]*so,t[1]*e]):void 0}})}}):[]}const ao=5e6,lo=1/3,co=200;function ho(t){let e=1/0,i=1/0,s=-1/0,o=-1/0;for(const n of t){const t=Number(n[0]),r=Number(n[1]);Number.isFinite(t)&&Number.isFinite(r)&&(t
s&&(s=t),r>o&&(o=r))}return e>s?null:{minX:e,minY:i,maxX:s,maxY:o}}function po(t){return t.poly&&t.poly.length?ho(t.poly):null==t.x||null==t.y?null:ho([[t.x,t.y],[t.x+(t.w||0),t.y+(t.h||0)]])}function uo(t,e){const i=[];for(const e of t.rooms||[]){const t=po(e);t&&i.push(t)}t.bg&&i.push({minX:t.bg.x,minY:t.bg.y,maxX:t.bg.x+t.bg.w,maxY:t.bg.y+t.bg.h});for(const t of e||[])if(Array.isArray(t)){const e=ho([t]);e&&i.push(e)}else i.push(t);return i}const _o=t=>{if(!t.length)return 0;const e=[...t].sort((t,e)=>t-e),i=e.length>>1;return e.length%2?e[i]:(e[i-1]+e[i])/2},go=t=>{let e=1/0,i=1/0,s=-1/0,o=-1/0;for(const n of t)n.minXs&&(s=n.maxX),n.maxY>o&&(o=n.maxY);return e>s||i>o?null:{x:e,y:i,w:s-e,h:o-i}};function mo(t,e){let{x:i,y:s,w:o,h:n}=t;o<30&&(i=i+o/2-100,o=co),n<30&&(s=s+n/2-100,n=co);const r=Math.max(o,n)*e;return{x:i-r,y:s-r,w:o+2*r,h:n+2*r}}function fo(t,e={}){const i=e.pad??.05,s=e.k??10,o=e.minSpread??50,n=t.filter(t=>Number.isFinite(t.minX)&&Number.isFinite(t.minY)&&Number.isFinite(t.maxX)&&Number.isFinite(t.maxY)&&Math.abs(t.minX)<=ao&&Math.abs(t.maxX)<=ao&&Math.abs(t.minY)<=ao&&Math.abs(t.maxY)<=ao);if(!n.length)return{core:null,all:null,outliers:0};const r=go(n);if(n.length<4){const t=mo(r,i);return{core:t,all:t,outliers:0}}const a=n.map(t=>(t.minX+t.maxX)/2),l=n.map(t=>(t.minY+t.maxY)/2),c=_o(a),h=_o(l),d=n.map((t,e)=>Math.max(Math.abs(a[e]-c),Math.abs(l[e]-h))),p=Math.max((u=[...d].sort((t,e)=>t-e),_=.75,u.length?u[Math.min(u.length-1,Math.max(0,Math.round(_*(u.length-1))))]:0),o);var u,_;const g=d.map(t=>t>s*p),m=g.filter(Boolean).length,f=m&&m<=n.length*lo?n.filter((t,e)=>!g[e]):n;return{core:mo(go(f)||r,i),all:mo(r,i),outliers:f===n?0:m}}function vo(t,e,i=.05){const s=fo(uo(t,e),{pad:i});if(s.core)return s.core;const o=t.vb&&4===t.vb.length&&t.vb[2]>0&&t.vb[3]>0?t.vb:[0,0,so,so];return{x:o[0],y:o[1],w:o[2],h:o[3]}}function bo(t){const e=vo(t);return{x:e.x+e.w/2,y:e.y+e.h/2}}function yo(t){const e=[];for(const i of t.rooms||[]){const t=po(i);t&&e.push(t)}const i=fo(e,{pad:0}).core;return i?Math.max(so,Math.min(ao,Math.max(i.w,i.h))):so}function wo(t,e,i,s=1){const o=Number(i),n=Number.isFinite(s)&&s>0?s:1;return!Number.isFinite(o)||o<=0?t*n:t*yo(e)*n/o}const $o=[1,2,5,10,20,50,100,200,500,1e3];function ko(t){if(t.poly&&t.poly.length){const e=t.poly.map(t=>t[0]),i=t.poly.map(t=>t[1]),s=Math.min(...e),o=Math.min(...i);return{x:s,y:o,w:Math.max(...e)-s,h:Math.max(...i)-o}}return{x:t.x??0,y:t.y??0,w:t.w??0,h:t.h??0}}function xo(t){if(t.poly){const e=t.poly.length;return[t.poly.reduce((t,e)=>t+e[0],0)/e,t.poly.reduce((t,e)=>t+e[1],0)/e]}return[t.x+t.w/2,t.y+.1*Math.min(t.w,t.h)]}function So(t){const e=ro(t.cfg),i=e.find(e=>e.id===t.spaceId);if(!i)return null;const s=ci(t.cfg.spaces.find(e=>e.id===t.spaceId)),o=t.iconSize??2.5,n=o>8?2.5:o,r={};for(const e of t.cfg.spaces||[])for(const t of e.rooms||[])t.area&&(r[t.area]=e.id);const a=t.cfg.settings?.exclude_integrations?new Set(t.cfg.settings.exclude_integrations):ht,l=pt(t.cfg.settings?.icon_rules?.length?t.cfg.settings.icon_rules:dt),c=Gs({hass:t.hass,areaToSpace:r,markers:t.cfg.markers||[],settings:t.cfg.settings||{},excluded:a,showAll:!!t.cfg.settings?.show_all,firstSpaceId:e[0]?.id||"",loc:e=>to(t.lang,e),iconRules:l}),h=c.filter(e=>e.space===t.spaceId),d=h.filter(t=>!t.hidden),p=function(t,e,i){const s={},o=i/100*yo(e)*1.3;for(const i of e.rooms){if(!i.area)continue;const e=t.filter(t=>t.area===i.area);if(!e.length)continue;const n=ko(i),r=.1*Math.min(n.w,n.h),a=n.w-2*r,l=n.h-2*r,c=Math.max(1,Math.round(Math.sqrt(e.length*a/Math.max(l,1)))),h=a/c,d=l/Math.max(Math.ceil(e.length/c),1),p=e.map((t,e)=>({x:n.x+r+h*(e%c+.5),y:n.y+r+d*(Math.floor(e/c)+.5)}));Ye(p,n,o,.5*r),e.forEach((t,e)=>s[t.id]=p[e])}return s}(h,i,n),u=[];for(const e of d){const i=t.layout[e.id];if(i&&i.s===t.spaceId){const t=i.x*so,e=i.y*so;u.push({minX:t,minY:e,maxX:t,maxY:e})}}const _=vo(i,u),g=[_.x,_.y,_.w,_.h],m=i.rooms.filter(t=>t.area||s.showBorders).map(e=>{let o="room "+(i.bg?"overlay":"yard"),n="";const r=Ri(s.fill,e);if(s.showBorders||"none"!==r){o+=" styled";const i=[`--room-stroke:${s.color}`,`--room-stroke-op:${s.showBorders?s.opacity:0}`],a=e.area?gi(r,"lqi"===r?function(t,e,i){const s=[];for(const o of e){if(o.area!==i||o.virtual)continue;const e=Fs(t,o.entities);null!=e&&s.push(e)}return Ge(s)}(t.hass,h,e.area):null,"light"===r?Ks(t.hass,h,e.area):"none","temp"===r?function(t,e,i){const s=[];for(const o of e){if(o.area!==i)continue;if("mdi:thermometer"!==o.icon&&"mdi:air-filter"!==o.icon)continue;const e=qs(t,o.entities);null!=e&&s.push(e)}return s.length?Math.round(s.reduce((t,e)=>t+e,0)/s.length*10)/10:null}(t.hass,h,e.area):null,s.tempMin,s.tempMax,ui(t.cfg?.settings)):null;a?(o+=" filled",i.push(`--room-fill:${a.c}`,`--room-fill-op:${a.a.toFixed(3)}`)):i.push("--room-fill:transparent","--room-fill-op:0"),n=i.join(";")}const a=!i.bg&&!s.showNames,l=xo(e),c=e.poly?j``:j``;return j`${c}${a?j`${e.name}`:V}`}),f=d.map(e=>{const s=function(t,e,i,s,o){const n=e[t.id];return n&&n.s===t.space?{x:n.x*so,y:n.y*so}:s[t.id]?s[t.id]:bo(o)}(e,t.layout,t.cfg,p,i),o=(s.x-g[0])/g[2]*100,n=(s.y-g[1])/g[3]*100,r=Number(e.marker?.size)>0?Number(e.marker.size):1,a=Number(e.marker?.angle)||0,l=[`left:${o}%`,`top:${n}%`];return 1!==r&&l.push(`--dev-scale:${r}`),B`
-
`}),v=s.showNames?i.rooms.filter(t=>t.name).map(e=>{const o=function(t,e,i){const s=i["rl_"+(t.id||"")];if(s&&s.s===e)return{x:s.x*io,y:s.y*io};const o=ko(t);return{x:o[0],y:o[1]}}(e,i.id,t.layout,t.cfg),n=(o.x-g[0])/g[2]*100,r=(o.y-g[1])/g[3]*100,a=Math.min(1,s.opacity+.25);return j`${e.name}
`}):[],b=i.bg?t.displayUrl?t.displayUrl(i.bg.href):i.bg.href:"",y=t.cfg.spaces.find(e=>e.id===t.spaceId)?.settings||{};let w="";if("daynight"===gs(t.cfg?.settings,y)&&null!==_s(t.cfg?.settings,y)){const e=vs(t.hass);e&&(w=rs(e.elevation).bg)}const $=w||hi(t.cfg?.settings,s),k=i.bg?{x:i.bg.x,y:i.bg.y,w:i.bg.w,h:i.bg.h}:null;return j`
+ `}),v=s.showNames?i.rooms.filter(t=>t.name).map(e=>{const o=function(t,e,i){const s=i["rl_"+(t.id||"")];if(s&&s.s===e)return{x:s.x*so,y:s.y*so};const o=xo(t);return{x:o[0],y:o[1]}}(e,i.id,t.layout,t.cfg),n=(o.x-g[0])/g[2]*100,r=(o.y-g[1])/g[3]*100,a=Math.min(1,s.opacity+.25);return B`