`:f}`}render(){let e=this.hass?.states[this.entity];if(!e)return f;let t=H(this.entity),n=C(e)&&!nn(e)?p`
`:t==="light"?this.renderLight(e):t==="cover"?this.renderCover(e):t==="media"?this.renderMedia(e):this.renderToggle(e);return p`
${L(this.hass,this.entity)}
${n}
this.details()}>${this.t("details")} …
@@ -1584,9 +1584,9 @@ ${t.sources.map(n=>this.hass.states[n]?.attributes.symcon_path||this.hass.states
.qm-note {
color: var(--nf-muted);
}
- `]};function of(r){let e=Math.min(1,Math.max(0,(r-2200)/4300)),t=(n,i)=>Math.round(n+(i-n)*e);return`rgb(${t(255,200)},${t(170,225)},${t(80,255)})`}customElements.get("nf-quick-menu")||customElements.define("nf-quick-menu",$o);var sf=new URL(import.meta.url),af=new URL("./nextfloor-3d.js?v=74227cd20cc3",sf).href,Xc;function eu(){return Xc??=import(af),Xc}function tu(r){if(!r||r.state!=="on")return 0;let e=typeof r.attributes.percentage=="number"?r.attributes.percentage:60;return e<=0?0:.2+.6*Math.min(100,e)/100}var nu="weather.nextfloor_symcon",iu={condition:"Wetterzustand",temperature:"Au\xDFentemperatur",humidity:"Au\xDFenluftfeuchte",pressure:"Luftdruck",wind_speed:"Windgeschwindigkeit",wind_gust_speed:"Windb\xF6en",wind_bearing:"Windrichtung",cloud_coverage:"Bew\xF6lkung",precipitation:"Niederschlagsrate",precipitation_total:"Niederschlagsmenge",illuminance:"Au\xDFenhelligkeit",uv_index:"UV-Index",visibility:"Sichtweite",snow:"Schnee",fog:"Nebel",lightning:"Gewitter"},ru=new WeakMap;function lf(r){let e=r.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").trim();return["sunny","clear-night","partlycloudy","cloudy","fog","rainy","pouring","lightning-rainy","lightning","hail","snowy","snowy-rainy","windy","windy-variant"].includes(e)?e:/kein regen|trocken|wolkenlos|klar|sonnig/.test(e)?"sunny":/gewitter|blitz/.test(e)?"lightning-rainy":/schneeregen/.test(e)?"snowy-rainy":/schnee/.test(e)?"snowy":/hagel/.test(e)?"hail":/starkregen/.test(e)?"pouring":/regen|niesel/.test(e)?"rainy":/nebel/.test(e)?"fog":/teil.*wolk|heiter|leicht.*wolk/.test(e)?"partlycloudy":/wolk|bedeckt/.test(e)?"cloudy":/wind|sturm/.test(e)?"windy":null}function Br(r,e){if(!U(r))return r;let t=e.weather_variables??{};if(!e.rain_sensor&&!Object.values(t).some(h=>h&&h!=="none"))return r;let n=ru.get(r)??new WeakMap;ru.set(r,n);let i=n.get(e);if(i)return i;let o={friendly_name:"Wetter",nf_symcon_weather:!0},s=h=>t[h]&&t[h]!=="none"?r.states[t[h]]:void 0;for(let h of["temperature","humidity","pressure","cloud_coverage","precipitation","precipitation_total","illuminance","uv_index","visibility"]){let g=s(h),_=Pe(g);_!==null&&(o[h]=h==="cloud_coverage"&&g?.attributes.symcon_max===1?_*100:_),g?.attributes.unit_of_measurement&&(o[`${h}_unit`]=g.attributes.unit_of_measurement)}for(let h of["wind_speed","wind_gust_speed"]){let g=s(h),_=Pe(g);_!==null&&(o[h]=Fr(_,g?.attributes.unit_of_measurement))}o.wind_speed_unit="km/h";let a=Ye(s("wind_bearing"));a!==null&&(o.wind_bearing=a);let l=lf(Je(s("condition"))),c=e.rain_sensor?r.states[e.rain_sensor]:void 0,u=oe(c);u!==null&&e.rain_sensor_inverted&&(u=!u),u===null&&typeof o.precipitation=="number"&&(u=o.precipitation>0),oe(s("lightning"))?l=u?"lightning-rainy":"lightning":oe(s("snow"))?l=u?"snowy-rainy":"snowy":oe(s("fog"))?l="fog":u===!0?l=Number(o.precipitation??0)>=8?"pouring":"rainy":u===!1&&l&&/rain|pouring/.test(l)&&(l=null),!l&&typeof o.cloud_coverage=="number"&&(l=o.cloud_coverage>70?"cloudy":o.cloud_coverage>20?"partlycloudy":"sunny"),!l&&u===!1&&(l="sunny");let d={entity_id:nu,state:l??"unknown",attributes:o},m={...r,states:{...r.states,[nu]:d}};return n.set(e,m),m}var cf=new Set(["on","home","open","true","active","playing","heat","heating"]);function Vr(r,e){let t=e.show_when;if(!t?.entity||!r)return!0;let n=r.states[t.entity];if(!n||I(n))return!0;let i=String(n.state).toLowerCase(),o=(t.state??"").split(",").map(a=>a.trim().toLowerCase()).filter(Boolean),s=o.length?o.includes(i):cf.has(i)||Number.isFinite(Number(i))&&Number(i)>0;return t.invert?!s:s}function Eo(r,e){let t=[];for(let n of e.floors)for(let i of n.furniture)Vr(r,i)||t.push(i.id);return t.sort()}function ou(r,e){if(!e.length)return r;let t=new Set(e);return{...r,floors:r.floors.map(n=>n.furniture.some(i=>t.has(i.id))?{...n,furniture:n.furniture.filter(i=>!t.has(i.id))}:n)}}var su="image:";function Ro(r,e,t){let n=(e??"").trim();if(!n)return null;if(n.startsWith(su))return t(n.slice(su.length));if(/^(https?:\/\/|\/)/.test(n))return n;if(/^[a-z_]+\.[a-z0-9_]+$/.test(n)){let i=r?.states[n]?.attributes.entity_picture;return typeof i=="string"&&i?i:null}return null}var En=r=>Number(r);function zn(r){if(Array.isArray(r)){let[o,s]=[En(r[0]),En(r[1])];return Number.isFinite(o)&&Number.isFinite(s)?[o,s]:null}if(!r||typeof r!="object")return null;let{x:e,y:t}=r,[n,i]=[En(e),En(t)];return Number.isFinite(n)&&Number.isFinite(i)?[n,i]:null}function au(r){return r?zn(r.charger)??zn(r.charger_position):null}function lu(r){for(let[e,t]of Object.entries(r.states))if(e.startsWith("camera.")&&(zn(t.attributes?.vacuum_position)??au(t.attributes)))return e;return null}var uf=r=>Array.isArray(r)?typeof r[0]=="number":!!r&&typeof r=="object",Rn=(r,e)=>e?[r[0],-r[1]]:r;function df(r){if(!r)return null;let e=r.mirror===!0,[t,n]=Rn(r.ga,e),[i,o]=Rn(r.gb,e),[s,a]=r.a,[l,c]=r.b,[u,d]=[i-t,o-n],[m,h]=[l-s,c-a],g=Math.hypot(u,d),_=Math.hypot(m,h);if(!(g>1e-6)||!(_>1e-6))return null;let b=_/g,v=Math.atan2(h,m)-Math.atan2(d,u),[k,S]=[Math.cos(v),Math.sin(v)];return M=>{let T=Rn(M,e),[z,$]=[T[0]-t,T[1]-n];return[s+b*(z*k-$*S),a+b*(z*S+$*k)]}}function hf(r){if(!r)return null;let e=r.mirror===!0,[t,n]=Rn(r.ga,e),[i,o]=Rn(r.gb,e),s=Math.atan2(r.b[1]-r.a[1],r.b[0]-r.a[0])-Math.atan2(o-n,i-t);return Number.isFinite(s)?s:null}function cu(r,e,t){if(!e)return null;let n=r.states[e]?.attributes;if(!n)return null;let i=df(t)??(g=>g),o=hf(t)??0,s=t?.mirror===!0?-1:1,a=n.vacuum_position,l=zn(a),c=l?(()=>{let[g,_]=i(l),b=En(a?.a)*s;if(!Number.isFinite(b))return{x:g,z:_,heading:0};let v=b*Math.PI/180+o;return{x:g,z:_,heading:Math.atan2(Math.cos(v),Math.sin(v))}})():null,u=au(n),d=Array.isArray(n.path)?n.path:[],m=d.length>0&&uf(d[0])?[d]:d,h=[];for(let g of m){let _=[];for(let b of Array.isArray(g)?g:[]){let v=zn(b);v&&_.push(i(v))}_.length>1&&h.push(_)}return!c&&!u&&!h.length?null:{pose:c,charger:u?i(u):null,path:h}}var uu="nextfloor.lock3d",du=520,To=class extends X{static properties={hass:{attribute:!1},building:{attribute:!1},floorId:{attribute:!1},roomId:{attribute:!1},wallMode:{attribute:!1},solidWalls:{attribute:!1},glassWalls:{attribute:!1},explode:{type:Boolean},keepRoof:{attribute:!1},markerMode:{attribute:!1},markerNames:{attribute:!1},markersOutside:{attribute:!1},tapInRoom:{type:Boolean},roomDoubleTap:{attribute:!1},heatMode:{attribute:!1},theme:{attribute:!1},accent:{attribute:!1},furnitureColors:{attribute:!1},packs:{attribute:!1},showEnergy:{attribute:!1},flows:{attribute:!1},holograms:{attribute:!1},furnish:{type:Boolean},surfaceGrab:{attribute:!1},furnishTypes:{attribute:!1},weather:{type:Boolean},weatherEntityId:{attribute:!1},weatherDensity:{attribute:!1},timeOfDay:{attribute:!1},selectedFurniture:{attribute:!1},selectedDevice:{attribute:!1},_sky:{state:!0},quality:{attribute:!1},showStats:{type:Boolean},_stats:{state:!0},_error:{state:!0},_energy:{state:!0},_flows:{state:!0},_liveEnergy:{state:!0},_liveCards:{state:!0},_liveCardOn:{state:!0},_houseFolded:{state:!0},_swipe:{state:!0},_menu:{state:!0},_pluginWindow:{state:!0},_plate:{state:!0},_blend:{state:!0},_wallBig:{state:!0},_find:{state:!0},_central:{state:!0},_thumbsCompact:{state:!0},_armed:{state:!0},central:{attribute:!1},centralOpen:{attribute:!1},keepCamera:{attribute:!1},plain:{attribute:!1},rightBack:{attribute:!1},templateName:{attribute:!1},readable:{type:Boolean,reflect:!0},today:{attribute:!1},_todayOpen:{state:!0},_todayItems:{state:!0},_forecast:{state:!0},zoom:{attribute:!1},buttons:{attribute:!1},_thumbs:{state:!0},floorThumbs:{attribute:!1},clean:{attribute:!1},cleanButton:{attribute:!1},clock:{attribute:!1},lockButton:{attribute:!1},walkButton:{attribute:!1},travelButton:{attribute:!1},_travel:{state:!0},_walking:{state:!0},_stick:{state:!0},_locked:{state:!0},_now:{state:!0},roomLabels:{attribute:!1},roomNamesButton:{attribute:!1},floorStack:{attribute:!1},panelOpen:{attribute:!1},alerts:{attribute:!1},alertJump:{attribute:!1},scenes:{attribute:!1},announcements:{attribute:!1},sensorBar:{attribute:!1},screenName:{attribute:!1},_announcement:{state:!0},dimmed:{attribute:!1},autoOrbit:{attribute:!1},startView:{attribute:!1},outsideOpen:{attribute:!1},_low:{state:!0},_narrowStage:{state:!0},_shortStage:{state:!0},_phoneStage:{state:!0},_alerts:{state:!0},_sceneFired:{state:!0}};stopAnnouncements=null;announceTimer;get liveCardsOn(){return this.holograms??this._liveCardOn}cloud=0;confirmSet=new Set;shownStartView;placementInfo=new Map;live=null;travelTimer;dayCurves=null;curvesAt=0;clockTimer;stopPlugins=null;pluginsDirty=!1;resizeObs=null;alertSrc=null;alertTimer;contactTimer;seenAlerts=new Set;roomFlash=null;findIndex=null;tintSig="";thumbTimer;thumbSig="";thumbsAt=0;armTimer;forecastAt=0;forecastKey="";todayAt=0;todayDay="";swipeSent=0;swipeTimer;viewer=null;starting=!1;shownStates=new Map;shownPacks=-1;openingLinks=null;linkedRegistry;furnitureLinks=new Map;tapPins=new Map;heatValues=new Map;watched=[];constructor(){super(),this.building=null,this.floorId=null,this.roomId=null,this.wallMode="auto",this.solidWalls=!1,this.glassWalls=null,this.explode=!0,this.keepRoof=!1,this.markerMode="important",this.markersOutside=null,this.tapInRoom=!1,this.roomDoubleTap="auto",this.heatMode="none",this.theme="neon",this.accent=null,this.furnitureColors=null,this.furnish=!1,this.weather=!0,this.weatherEntityId=null,this.weatherDensity=1,this.showEnergy=!0,this.flows=null,this._liveEnergy=null,this._liveCards=[],this._liveCardOn=localStorage.getItem("nextfloor.cards")!=="0",this._houseFolded=localStorage.getItem("nextfloor.house_card_folded")==="1",this.selectedFurniture=null,this.selectedDevice=null,this._sky=0,this.quality="auto",this.showStats=!1,this._stats=null,this._error=null,this._energy=null,this._swipe=null,this._menu=null,this._pluginWindow=null,this._plate=null,this._wallBig=null,this._blend=.6,this._find=null,this._central=!1;try{this._thumbsCompact=localStorage.getItem("nextfloor.thumbs_compact")==="1"}catch{this._thumbsCompact=!1}this._armed=null,this.central=!0,this.buttons=null,this._thumbs=[],this.floorThumbs=!0,this.clean=!1,this.cleanButton=!1,this.clock=null,this.lockButton=!1,this.walkButton=!1,this.travelButton=!1,this._travel=null,this._walking=!1,this._stick=null,this._now=Date.now(),this._locked=(()=>{try{return localStorage.getItem(uu)==="1"}catch{return!1}})(),this.roomLabels=!0,this.roomNamesButton=!1,this.floorStack="dim",this._low=!1,this.panelOpen=!1,this._narrowStage=!1,this._shortStage=!1,this._phoneStage=!1,this.alerts=!0,this.alertJump=!1,this.announcements=!1,this.sensorBar=!0,this.screenName=null,this._announcement=null,this._alerts=[],this.scenes=!0,this._sceneFired=null,this.dimmed=!1,this.autoOrbit=!1,this.startView=null,this.outsideOpen=!1,this.holograms=null;try{this._flows=localStorage.getItem("nextfloor.flows")==="1"}catch{this._flows=!1}}connectedCallback(){super.connectedCallback(),this.stopPlugins=xt(()=>{this.pluginsDirty=!0,this.requestUpdate()}),this.hasUpdated&&(this.observeStage(),this.viewer||this.start())}disconnectedCallback(){super.disconnectedCallback(),this.stopPlugins?.(),this.stopPlugins=null,this.listenToAnnouncements(!1),this.resizeObs?.disconnect(),this.resizeObs=null,clearInterval(this.alertTimer),this.alertTimer=void 0,clearInterval(this.contactTimer),this.contactTimer=void 0,clearInterval(this.clockTimer),this.clockTimer=void 0,clearInterval(this.travelTimer),this.travelTimer=void 0,this.live=null,this.viewer?.dispose(),this.viewer=null}firstUpdated(){this.observeStage(),this.start()}observeStage(){let e=this.renderRoot.querySelector(".nf-stage");!e||this.resizeObs||typeof ResizeObserver!="function"||(this.resizeObs=new ResizeObserver(t=>{let n=t[0]?.contentRect,i=(n?.width??1e3)<700||(n?.height??1e3)
{this._central&&!this.centralOpen&&!n.target?.closest?.(".nf-central, .nf-central-btn")&&(this._central=!1)}),this.viewer=e.createViewer(t,{quality:this.quality,explode:this.explode,onRoomTap:(n,i)=>this.fire("room-tap",{floorId:n,roomId:i}),onFloorTap:n=>this.fire("floor-tap",{floorId:n}),floorInfo:n=>n.rooms.length===1?A(this.hass,"floor_rooms_one"):A(this.hass,"floor_rooms",{n:n.rooms.length}),onBack:()=>this.fire("back",{}),onDeviceTap:(n,i,o)=>this.onDeviceTap(n,i,o),onDeviceHold:(n,i,o)=>this.onDeviceHold(n,i,o),onRoomDoubleTap:(n,i)=>this.onRoomDoubleTap(n,i),onDeviceSwipe:(n,i,o,s,a)=>this.onDeviceSwipe(n,i,o,s,a),onFurnitureSelect:n=>this.fire("furniture-select",{id:n}),onFurnitureMove:(n,i,o)=>this.fire("furniture-move",{id:n,x:i,z:o}),onDeviceSelect:n=>this.fire("device-select",{id:n}),onDeviceMove:(n,i,o)=>this.fire("device-move",{id:n,x:i,z:o}),onStats:n=>{this.showStats&&(this._stats=n)}}),this.viewer.setWallMode(this.wallMode),this.viewer.setPaintedWalls(this.solidWalls),this.viewer.setGlassWalls((this.glassWalls??20)/100),this.viewer.setTheme(this.theme),this.viewer.setAccent(this.accent??null),this.viewer.setFurnitureColors(this.furnitureColors??null),this.viewer.setNotePhotos(n=>this.hass?Ro(this.hass,n,i=>this.storedPicture(this.hass,i)):null),this.viewer.setNavigationLocked(this._locked),this.viewer.setFurnishMode(this.furnish),this.viewer.setTapInRoom(this.tapInRoom),this.viewer.setSurfaceGrab(this.surfaceGrab??null),this.viewer.setFurnishTypes(this.furnishTypes??null),this.viewer.setFloorStack(this.floorStack),this.viewer.setStats(this.showStats),this.viewer.setAutoOrbit(this.autoOrbit?.06:0),this.viewer.setKeepRoof(this.keepRoof),this.viewer.setKeepCamera(!!this.keepCamera),this.viewer.setPlain(!!this.plain),this.viewer.setRightBack(!!this.rightBack),this.viewer.setZoom(this.zoom??1),this._low=this.viewer.low,this.viewer.setMeshSource(n=>this.hass?.fetchWithAuth?this.hass.fetchWithAuth(`/api/nextfloor/mesh/${encodeURIComponent(n)}`).then(i=>i.ok?i.arrayBuffer():null):Promise.resolve(null)),this.viewer.setPacks([...gi()]),this.shownPacks=Vn(),this.building&&(this.shownStartView=JSON.stringify(this.startViewOf()),this.viewer.setStartView(this.startViewOf()),this.viewer.setBuilding(this.shownBuilding(this.hass)),this.viewer.setMap(this.building.settings.map,this.building.settings.north??0)),this.scheduleThumbs(),this.syncDevices(!0),this.viewer.setFloor(this.floorId,!1),this.roomId&&this.viewer.selectRoom(this.roomId)}catch(e){this._error=String(e)}finally{this.starting=!1}}}updated(e){(e.has("announcements")||e.has("hass")&&this.announcements&&!this.stopAnnouncements)&&this.listenToAnnouncements(this.announcements&&!!this.hass&&this.isConnected),e.has("hass")&&this.live?.el&&(this.live.el.hass=this.hass);let t=this._pluginWindow?.node;e.has("hass")&&t&&"hass"in t&&(t.hass=this.hass),this._central&&!this.centralOpen&&(e.has("roomId")&&e.get("roomId")!==void 0||e.has("floorId")&&e.get("floorId")!==void 0)&&(this._central=!1),e.has("centralOpen")&&this.centralOpen&&(this._central=!0),e.has("clock")&&(clearInterval(this.clockTimer),this.clockTimer=this.clock?setInterval(()=>this._now=Date.now(),1e4):void 0);let n=this.viewer;if(!n)return;if(this.shownPacks!==Vn()&&(this.shownPacks=Vn(),n.setPacks([...gi()]),this.hass&&this.building&&n.setParked(ao(this.hass,this.building)),this.syncDevices(!0)),e.has("building")&&this.building){let s=JSON.stringify(this.startViewOf()),a=this.shownStartView!==void 0&&this.shownStartView!==s;this.shownStartView=s,n.setStartView(this.startViewOf()),n.setBuilding(this.shownBuilding(this.hass)),n.setMap(this.building?.settings.map,this.building?.settings.north??0),a&&this.floorId===null&&n.resetView()}e.has("startView")&&e.get("startView")!==void 0&&(n.setStartView(this.startViewOf()),this.floorId===null&&n.resetView()),(e.has("building")||e.has("theme")||e.has("floorThumbs")||e.has("packs"))&&this.scheduleThumbs();let i=this.markersOutside?["markersOutside","floorId","roomId"]:["markersOutside"],o=this.pluginsDirty||["building","markerMode","heatMode","flows","alerts","dimmed","holograms","roomLabels","floorId","roomId",...i].some(s=>e.has(s));if(this.pluginsDirty=!1,(o||e.has("hass"))&&this.syncDevices(o),e.has("autoOrbit")&&n.setAutoOrbit(this.autoOrbit?.06:0),(e.has("_thumbs")||e.has("_narrowStage")||e.has("_phoneStage"))&&n.setLabelInset(this._thumbs.length&&!this._phoneStage?this.narrowThumbs?136:184:0),e.has("floorId")&&n.setFloor(this.floorId),e.has("roomId")&&(this.roomId||e.get("roomId"))&&n.selectRoom(this.roomId),e.has("outsideOpen")&&e.get("outsideOpen")!==void 0){let s=this.building?.settings.outside_view;this.outsideOpen&&s?n.showView(s):!this.outsideOpen&&s&&this.floorId===null&&!this.roomId&&n.resetView()}e.has("tapInRoom")&&n.setTapInRoom(this.tapInRoom),e.has("wallMode")&&n.setWallMode(this.wallMode),e.has("solidWalls")&&n.setPaintedWalls(this.solidWalls),e.has("glassWalls")&&n.setGlassWalls((this.glassWalls??20)/100),e.has("explode")&&n.setExplode(this.explode),e.has("keepRoof")&&n.setKeepRoof(this.keepRoof),e.has("keepCamera")&&n.setKeepCamera(!!this.keepCamera),e.has("plain")&&n.setPlain(!!this.plain),e.has("rightBack")&&n.setRightBack(!!this.rightBack),e.has("zoom")&&n.setZoom(this.zoom??1),e.has("floorStack")&&n.setFloorStack(this.floorStack),e.has("theme")&&n.setTheme(this.theme),e.has("_locked")&&n.setNavigationLocked(this._locked),e.has("accent")&&n.setAccent(this.accent??null),e.has("furnitureColors")&&n.setFurnitureColors(this.furnitureColors??null),e.has("surfaceGrab")&&n.setSurfaceGrab(this.surfaceGrab??null),e.has("furnishTypes")&&n.setFurnishTypes(this.furnishTypes??null),e.has("furnish")&&(n.setFurnishMode(this.furnish),this.syncDevices(!0)),e.has("selectedFurniture")&&n.selectFurniture(this.selectedFurniture),e.has("selectedDevice")&&n.setSelectedDevice(this.selectedDevice),(e.has("weather")||e.has("weatherEntityId")||e.has("weatherDensity")||e.has("timeOfDay"))&&this.syncDevices(!0),e.has("quality")&&e.get("quality")!==void 0&&(n.setQuality(this.quality),this._low=n.low),e.has("showStats")&&n.setStats(this.showStats),e.has("building")&&(this.findIndex=null)}shownFor=null;framePictureData=new Map;framePictures(e,t){let n=[];for(let i of t.floors)for(let o of i.notes??[])o.photo?.startsWith("image:")&&this.storedPicture(e,o.photo.slice(6));for(let i of t.floors)for(let o of i.furniture){if(!o.picture||!Vr(e,o))continue;let s=Ro(e,o.picture,a=>this.storedPicture(e,a));s&&n.push({furnitureId:o.id,floorId:i.id,url:s,border:o.picture_border??0,fit:o.picture_fit==="contain"?"contain":"cover"})}return n}storedPicture(e,t){let n=this.framePictureData.get(t);return n!==void 0?n||null:(this.framePictureData.set(t,""),ls(e,t).then(i=>{this.framePictureData.set(t,i),this.syncDevices(!0)}).catch(()=>{}),null)}shownBuilding(e){let t=this.building,n=Eo(e,t),i=t.floors.filter(a=>a.layer&&this.hiddenLayers.has(a.id)).map(a=>a.id),o=[...n,...i.map(a=>`layer:${a}`)].join(",");if(this.shownFor?.building===t&&this.shownFor.key===o)return this.shownFor.shown;let s=ou(t,n);return this.shownFor={building:t,key:o,shown:i.length?{...s,floors:s.floors.filter(a=>!i.includes(a.id))}:s},this.shownFor.shown}hiddenLayers=(()=>{try{return new Set(JSON.parse(localStorage.getItem("nextfloor.hidden_layers")??"[]"))}catch{return new Set}})();toggleLayer(e){this.hiddenLayers.has(e)?this.hiddenLayers.delete(e):this.hiddenLayers.add(e);try{localStorage.setItem("nextfloor.hidden_layers",JSON.stringify([...this.hiddenLayers]))}catch{}this.viewer&&this.building&&this.viewer.setBuilding(this.shownBuilding(this.hass)),this.requestUpdate()}renderLayers(){let e=(this.building?.floors??[]).filter(t=>t.layer);return!e.length||this.clean?f:p`
+ `]};function of(r){let e=Math.min(1,Math.max(0,(r-2200)/4300)),t=(n,i)=>Math.round(n+(i-n)*e);return`rgb(${t(255,200)},${t(170,225)},${t(80,255)})`}customElements.get("nf-quick-menu")||customElements.define("nf-quick-menu",Mo);var sf=new URL(import.meta.url),af=new URL("./nextfloor-3d.js?v=74227cd20cc3",sf).href,Xc;function eu(){return Xc??=import(af),Xc}function tu(r){if(!r||r.state!=="on")return 0;let e=typeof r.attributes.percentage=="number"?r.attributes.percentage:60;return e<=0?0:.2+.6*Math.min(100,e)/100}var nu="weather.nextfloor_symcon",iu={condition:"Wetterzustand",temperature:"Au\xDFentemperatur",humidity:"Au\xDFenluftfeuchte",pressure:"Luftdruck",wind_speed:"Windgeschwindigkeit",wind_gust_speed:"Windb\xF6en",wind_bearing:"Windrichtung",cloud_coverage:"Bew\xF6lkung",precipitation:"Niederschlagsrate",precipitation_total:"Niederschlagsmenge",illuminance:"Au\xDFenhelligkeit",uv_index:"UV-Index",visibility:"Sichtweite",snow:"Schnee",fog:"Nebel",lightning:"Gewitter"},ru=new WeakMap;function lf(r){let e=r.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").trim();return["sunny","clear-night","partlycloudy","cloudy","fog","rainy","pouring","lightning-rainy","lightning","hail","snowy","snowy-rainy","windy","windy-variant"].includes(e)?e:/kein regen|trocken|wolkenlos|klar|sonnig/.test(e)?"sunny":/gewitter|blitz/.test(e)?"lightning-rainy":/schneeregen/.test(e)?"snowy-rainy":/schnee/.test(e)?"snowy":/hagel/.test(e)?"hail":/starkregen/.test(e)?"pouring":/regen|niesel/.test(e)?"rainy":/nebel/.test(e)?"fog":/teil.*wolk|heiter|leicht.*wolk/.test(e)?"partlycloudy":/wolk|bedeckt/.test(e)?"cloudy":/wind|sturm/.test(e)?"windy":null}function Vr(r,e){if(!G(r))return r;let t=e.weather_variables??{};if(!e.rain_sensor&&!Object.values(t).some(h=>h&&h!=="none"))return r;let n=ru.get(r)??new WeakMap;ru.set(r,n);let i=n.get(e);if(i)return i;let o={friendly_name:"Wetter",nf_symcon_weather:!0},s=h=>t[h]&&t[h]!=="none"?r.states[t[h]]:void 0;for(let h of["temperature","humidity","pressure","cloud_coverage","precipitation","precipitation_total","illuminance","uv_index","visibility"]){let g=s(h),_=Pe(g);_!==null&&(o[h]=h==="cloud_coverage"&&g?.attributes.symcon_max===1?_*100:_),g?.attributes.unit_of_measurement&&(o[`${h}_unit`]=g.attributes.unit_of_measurement)}for(let h of["wind_speed","wind_gust_speed"]){let g=s(h),_=Pe(g);_!==null&&(o[h]=Hr(_,g?.attributes.unit_of_measurement))}o.wind_speed_unit="km/h";let a=Ye(s("wind_bearing"));a!==null&&(o.wind_bearing=a);let l=lf(Je(s("condition"))),c=e.rain_sensor?r.states[e.rain_sensor]:void 0,u=oe(c);u!==null&&e.rain_sensor_inverted&&(u=!u),u===null&&typeof o.precipitation=="number"&&(u=o.precipitation>0),oe(s("lightning"))?l=u?"lightning-rainy":"lightning":oe(s("snow"))?l=u?"snowy-rainy":"snowy":oe(s("fog"))?l="fog":u===!0?l=Number(o.precipitation??0)>=8?"pouring":"rainy":u===!1&&l&&/rain|pouring/.test(l)&&(l=null),!l&&typeof o.cloud_coverage=="number"&&(l=o.cloud_coverage>70?"cloudy":o.cloud_coverage>20?"partlycloudy":"sunny"),!l&&u===!1&&(l="sunny");let d={entity_id:nu,state:l??"unknown",attributes:o},m={...r,states:{...r.states,[nu]:d}};return n.set(e,m),m}var cf=new Set(["on","home","open","true","active","playing","heat","heating"]);function Kr(r,e){let t=e.show_when;if(!t?.entity||!r)return!0;let n=r.states[t.entity];if(!n||C(n))return!0;let i=String(n.state).toLowerCase(),o=(t.state??"").split(",").map(a=>a.trim().toLowerCase()).filter(Boolean),s=o.length?o.includes(i):cf.has(i)||Number.isFinite(Number(i))&&Number(i)>0;return t.invert?!s:s}function Ro(r,e){let t=[];for(let n of e.floors)for(let i of n.furniture)Kr(r,i)||t.push(i.id);return t.sort()}function ou(r,e){if(!e.length)return r;let t=new Set(e);return{...r,floors:r.floors.map(n=>n.furniture.some(i=>t.has(i.id))?{...n,furniture:n.furniture.filter(i=>!t.has(i.id))}:n)}}var su="image:";function zo(r,e,t){let n=(e??"").trim();if(!n)return null;if(n.startsWith(su))return t(n.slice(su.length));if(/^(https?:\/\/|\/)/.test(n))return n;if(/^[a-z_]+\.[a-z0-9_]+$/.test(n)){let i=r?.states[n]?.attributes.entity_picture;return typeof i=="string"&&i?i:null}return null}var Rn=r=>Number(r);function Tn(r){if(Array.isArray(r)){let[o,s]=[Rn(r[0]),Rn(r[1])];return Number.isFinite(o)&&Number.isFinite(s)?[o,s]:null}if(!r||typeof r!="object")return null;let{x:e,y:t}=r,[n,i]=[Rn(e),Rn(t)];return Number.isFinite(n)&&Number.isFinite(i)?[n,i]:null}function au(r){return r?Tn(r.charger)??Tn(r.charger_position):null}function lu(r){for(let[e,t]of Object.entries(r.states))if(e.startsWith("camera.")&&(Tn(t.attributes?.vacuum_position)??au(t.attributes)))return e;return null}var uf=r=>Array.isArray(r)?typeof r[0]=="number":!!r&&typeof r=="object",zn=(r,e)=>e?[r[0],-r[1]]:r;function df(r){if(!r)return null;let e=r.mirror===!0,[t,n]=zn(r.ga,e),[i,o]=zn(r.gb,e),[s,a]=r.a,[l,c]=r.b,[u,d]=[i-t,o-n],[m,h]=[l-s,c-a],g=Math.hypot(u,d),_=Math.hypot(m,h);if(!(g>1e-6)||!(_>1e-6))return null;let b=_/g,v=Math.atan2(h,m)-Math.atan2(d,u),[k,S]=[Math.cos(v),Math.sin(v)];return $=>{let z=zn($,e),[R,F]=[z[0]-t,z[1]-n];return[s+b*(R*k-F*S),a+b*(R*S+F*k)]}}function hf(r){if(!r)return null;let e=r.mirror===!0,[t,n]=zn(r.ga,e),[i,o]=zn(r.gb,e),s=Math.atan2(r.b[1]-r.a[1],r.b[0]-r.a[0])-Math.atan2(o-n,i-t);return Number.isFinite(s)?s:null}function cu(r,e,t){if(!e)return null;let n=r.states[e]?.attributes;if(!n)return null;let i=df(t)??(g=>g),o=hf(t)??0,s=t?.mirror===!0?-1:1,a=n.vacuum_position,l=Tn(a),c=l?(()=>{let[g,_]=i(l),b=Rn(a?.a)*s;if(!Number.isFinite(b))return{x:g,z:_,heading:0};let v=b*Math.PI/180+o;return{x:g,z:_,heading:Math.atan2(Math.cos(v),Math.sin(v))}})():null,u=au(n),d=Array.isArray(n.path)?n.path:[],m=d.length>0&&uf(d[0])?[d]:d,h=[];for(let g of m){let _=[];for(let b of Array.isArray(g)?g:[]){let v=Tn(b);v&&_.push(i(v))}_.length>1&&h.push(_)}return!c&&!u&&!h.length?null:{pose:c,charger:u?i(u):null,path:h}}var uu="nextfloor.lock3d",du=520,Do=class extends X{static properties={hass:{attribute:!1},building:{attribute:!1},floorId:{attribute:!1},roomId:{attribute:!1},wallMode:{attribute:!1},solidWalls:{attribute:!1},glassWalls:{attribute:!1},explode:{type:Boolean},keepRoof:{attribute:!1},markerMode:{attribute:!1},markerNames:{attribute:!1},markersOutside:{attribute:!1},tapInRoom:{type:Boolean},roomDoubleTap:{attribute:!1},heatMode:{attribute:!1},theme:{attribute:!1},accent:{attribute:!1},furnitureColors:{attribute:!1},packs:{attribute:!1},showEnergy:{attribute:!1},flows:{attribute:!1},holograms:{attribute:!1},furnish:{type:Boolean},surfaceGrab:{attribute:!1},furnishTypes:{attribute:!1},weather:{type:Boolean},weatherEntityId:{attribute:!1},weatherDensity:{attribute:!1},timeOfDay:{attribute:!1},selectedFurniture:{attribute:!1},selectedDevice:{attribute:!1},_sky:{state:!0},quality:{attribute:!1},showStats:{type:Boolean},_stats:{state:!0},_error:{state:!0},_energy:{state:!0},_flows:{state:!0},_liveEnergy:{state:!0},_liveCards:{state:!0},_liveCardOn:{state:!0},_houseFolded:{state:!0},_swipe:{state:!0},_menu:{state:!0},_pluginWindow:{state:!0},_plate:{state:!0},_blend:{state:!0},_wallBig:{state:!0},_find:{state:!0},_central:{state:!0},_thumbsCompact:{state:!0},_armed:{state:!0},central:{attribute:!1},centralOpen:{attribute:!1},keepCamera:{attribute:!1},plain:{attribute:!1},rightBack:{attribute:!1},templateName:{attribute:!1},readable:{type:Boolean,reflect:!0},today:{attribute:!1},_todayOpen:{state:!0},_todayItems:{state:!0},_forecast:{state:!0},zoom:{attribute:!1},buttons:{attribute:!1},_thumbs:{state:!0},floorThumbs:{attribute:!1},clean:{attribute:!1},cleanButton:{attribute:!1},clock:{attribute:!1},lockButton:{attribute:!1},walkButton:{attribute:!1},travelButton:{attribute:!1},_travel:{state:!0},_walking:{state:!0},_stick:{state:!0},_locked:{state:!0},_now:{state:!0},roomLabels:{attribute:!1},roomNamesButton:{attribute:!1},floorStack:{attribute:!1},panelOpen:{attribute:!1},alerts:{attribute:!1},alertJump:{attribute:!1},scenes:{attribute:!1},announcements:{attribute:!1},sensorBar:{attribute:!1},screenName:{attribute:!1},_announcement:{state:!0},dimmed:{attribute:!1},autoOrbit:{attribute:!1},startView:{attribute:!1},outsideOpen:{attribute:!1},_low:{state:!0},_narrowStage:{state:!0},_shortStage:{state:!0},_phoneStage:{state:!0},_alerts:{state:!0},_sceneFired:{state:!0}};stopAnnouncements=null;announceTimer;get liveCardsOn(){return this.holograms??this._liveCardOn}cloud=0;confirmSet=new Set;shownStartView;placementInfo=new Map;live=null;travelTimer;dayCurves=null;curvesAt=0;clockTimer;stopPlugins=null;pluginsDirty=!1;resizeObs=null;alertSrc=null;alertTimer;contactTimer;seenAlerts=new Set;roomFlash=null;findIndex=null;tintSig="";thumbTimer;thumbSig="";thumbsAt=0;armTimer;forecastAt=0;forecastKey="";todayAt=0;todayDay="";swipeSent=0;swipeTimer;viewer=null;starting=!1;shownStates=new Map;shownPacks=-1;openingLinks=null;linkedRegistry;furnitureLinks=new Map;tapPins=new Map;heatValues=new Map;watched=[];constructor(){super(),this.building=null,this.floorId=null,this.roomId=null,this.wallMode="auto",this.solidWalls=!1,this.glassWalls=null,this.explode=!0,this.keepRoof=!1,this.markerMode="important",this.markersOutside=null,this.tapInRoom=!1,this.roomDoubleTap="auto",this.heatMode="none",this.theme="neon",this.accent=null,this.furnitureColors=null,this.furnish=!1,this.weather=!0,this.weatherEntityId=null,this.weatherDensity=1,this.showEnergy=!0,this.flows=null,this._liveEnergy=null,this._liveCards=[],this._liveCardOn=localStorage.getItem("nextfloor.cards")!=="0",this._houseFolded=localStorage.getItem("nextfloor.house_card_folded")==="1",this.selectedFurniture=null,this.selectedDevice=null,this._sky=0,this.quality="auto",this.showStats=!1,this._stats=null,this._error=null,this._energy=null,this._swipe=null,this._menu=null,this._pluginWindow=null,this._plate=null,this._wallBig=null,this._blend=.6,this._find=null,this._central=!1;try{this._thumbsCompact=localStorage.getItem("nextfloor.thumbs_compact")==="1"}catch{this._thumbsCompact=!1}this._armed=null,this.central=!0,this.buttons=null,this._thumbs=[],this.floorThumbs=!0,this.clean=!1,this.cleanButton=!1,this.clock=null,this.lockButton=!1,this.walkButton=!1,this.travelButton=!1,this._travel=null,this._walking=!1,this._stick=null,this._now=Date.now(),this._locked=(()=>{try{return localStorage.getItem(uu)==="1"}catch{return!1}})(),this.roomLabels=!0,this.roomNamesButton=!1,this.floorStack="dim",this._low=!1,this.panelOpen=!1,this._narrowStage=!1,this._shortStage=!1,this._phoneStage=!1,this.alerts=!0,this.alertJump=!1,this.announcements=!1,this.sensorBar=!0,this.screenName=null,this._announcement=null,this._alerts=[],this.scenes=!0,this._sceneFired=null,this.dimmed=!1,this.autoOrbit=!1,this.startView=null,this.outsideOpen=!1,this.holograms=null;try{this._flows=localStorage.getItem("nextfloor.flows")==="1"}catch{this._flows=!1}}connectedCallback(){super.connectedCallback(),this.stopPlugins=kt(()=>{this.pluginsDirty=!0,this.requestUpdate()}),this.hasUpdated&&(this.observeStage(),this.viewer||this.start())}disconnectedCallback(){super.disconnectedCallback(),this.stopPlugins?.(),this.stopPlugins=null,this.listenToAnnouncements(!1),this.resizeObs?.disconnect(),this.resizeObs=null,clearInterval(this.alertTimer),this.alertTimer=void 0,clearInterval(this.contactTimer),this.contactTimer=void 0,clearInterval(this.clockTimer),this.clockTimer=void 0,clearInterval(this.travelTimer),this.travelTimer=void 0,this.live=null,this.viewer?.dispose(),this.viewer=null}firstUpdated(){this.observeStage(),this.start()}observeStage(){let e=this.renderRoot.querySelector(".nf-stage");!e||this.resizeObs||typeof ResizeObserver!="function"||(this.resizeObs=new ResizeObserver(t=>{let n=t[0]?.contentRect,i=(n?.width??1e3)<700||(n?.height??1e3)
{this._central&&!this.centralOpen&&!n.target?.closest?.(".nf-central, .nf-central-btn")&&(this._central=!1)}),this.viewer=e.createViewer(t,{quality:this.quality,explode:this.explode,onRoomTap:(n,i)=>this.fire("room-tap",{floorId:n,roomId:i}),onFloorTap:n=>this.fire("floor-tap",{floorId:n}),floorInfo:n=>n.rooms.length===1?A(this.hass,"floor_rooms_one"):A(this.hass,"floor_rooms",{n:n.rooms.length}),onBack:()=>this.fire("back",{}),onDeviceTap:(n,i,o)=>this.onDeviceTap(n,i,o),onDeviceHold:(n,i,o)=>this.onDeviceHold(n,i,o),onRoomDoubleTap:(n,i)=>this.onRoomDoubleTap(n,i),onDeviceSwipe:(n,i,o,s,a)=>this.onDeviceSwipe(n,i,o,s,a),onFurnitureSelect:n=>this.fire("furniture-select",{id:n}),onFurnitureMove:(n,i,o)=>this.fire("furniture-move",{id:n,x:i,z:o}),onDeviceSelect:n=>this.fire("device-select",{id:n}),onDeviceMove:(n,i,o)=>this.fire("device-move",{id:n,x:i,z:o}),onStats:n=>{this.showStats&&(this._stats=n)}}),this.viewer.setWallMode(this.wallMode),this.viewer.setPaintedWalls(this.solidWalls),this.viewer.setGlassWalls((this.glassWalls??20)/100),this.viewer.setTheme(this.theme),this.viewer.setAccent(this.accent??null),this.viewer.setFurnitureColors(this.furnitureColors??null),this.viewer.setNotePhotos(n=>this.hass?zo(this.hass,n,i=>this.storedPicture(this.hass,i)):null),this.viewer.setNavigationLocked(this._locked),this.viewer.setFurnishMode(this.furnish),this.viewer.setTapInRoom(this.tapInRoom),this.viewer.setSurfaceGrab(this.surfaceGrab??null),this.viewer.setFurnishTypes(this.furnishTypes??null),this.viewer.setFloorStack(this.floorStack),this.viewer.setStats(this.showStats),this.viewer.setAutoOrbit(this.autoOrbit?.06:0),this.viewer.setKeepRoof(this.keepRoof),this.viewer.setKeepCamera(!!this.keepCamera),this.viewer.setPlain(!!this.plain),this.viewer.setRightBack(!!this.rightBack),this.viewer.setZoom(this.zoom??1),this._low=this.viewer.low,this.viewer.setMeshSource(n=>this.hass?.fetchWithAuth?this.hass.fetchWithAuth(`/api/nextfloor/mesh/${encodeURIComponent(n)}`).then(i=>i.ok?i.arrayBuffer():null):Promise.resolve(null)),this.viewer.setPacks([..._i()]),this.shownPacks=Kn(),this.building&&(this.shownStartView=JSON.stringify(this.startViewOf()),this.viewer.setStartView(this.startViewOf()),this.viewer.setBuilding(this.shownBuilding(this.hass)),this.viewer.setMap(this.building.settings.map,this.building.settings.north??0)),this.scheduleThumbs(),this.syncDevices(!0),this.viewer.setFloor(this.floorId,!1),this.roomId&&this.viewer.selectRoom(this.roomId)}catch(e){this._error=String(e)}finally{this.starting=!1}}}updated(e){(e.has("announcements")||e.has("hass")&&this.announcements&&!this.stopAnnouncements)&&this.listenToAnnouncements(this.announcements&&!!this.hass&&this.isConnected),e.has("hass")&&this.live?.el&&(this.live.el.hass=this.hass);let t=this._pluginWindow?.node;e.has("hass")&&t&&"hass"in t&&(t.hass=this.hass),this._central&&!this.centralOpen&&(e.has("roomId")&&e.get("roomId")!==void 0||e.has("floorId")&&e.get("floorId")!==void 0)&&(this._central=!1),e.has("centralOpen")&&this.centralOpen&&(this._central=!0),e.has("clock")&&(clearInterval(this.clockTimer),this.clockTimer=this.clock?setInterval(()=>this._now=Date.now(),1e4):void 0);let n=this.viewer;if(!n)return;if(this.shownPacks!==Kn()&&(this.shownPacks=Kn(),n.setPacks([..._i()]),this.hass&&this.building&&n.setParked(lo(this.hass,this.building)),this.syncDevices(!0)),e.has("building")&&this.building){let s=JSON.stringify(this.startViewOf()),a=this.shownStartView!==void 0&&this.shownStartView!==s;this.shownStartView=s,n.setStartView(this.startViewOf()),n.setBuilding(this.shownBuilding(this.hass)),n.setMap(this.building?.settings.map,this.building?.settings.north??0),a&&this.floorId===null&&n.resetView()}e.has("startView")&&e.get("startView")!==void 0&&(n.setStartView(this.startViewOf()),this.floorId===null&&n.resetView()),(e.has("building")||e.has("theme")||e.has("floorThumbs")||e.has("packs"))&&this.scheduleThumbs();let i=this.markersOutside?["markersOutside","floorId","roomId"]:["markersOutside"],o=this.pluginsDirty||["building","markerMode","heatMode","flows","alerts","dimmed","holograms","roomLabels","floorId","roomId",...i].some(s=>e.has(s));if(this.pluginsDirty=!1,(o||e.has("hass"))&&this.syncDevices(o),e.has("autoOrbit")&&n.setAutoOrbit(this.autoOrbit?.06:0),(e.has("_thumbs")||e.has("_narrowStage")||e.has("_phoneStage"))&&n.setLabelInset(this._thumbs.length&&!this._phoneStage?this.narrowThumbs?136:184:0),e.has("floorId")&&n.setFloor(this.floorId),e.has("roomId")&&(this.roomId||e.get("roomId"))&&n.selectRoom(this.roomId),e.has("outsideOpen")&&e.get("outsideOpen")!==void 0){let s=this.building?.settings.outside_view;this.outsideOpen&&s?n.showView(s):!this.outsideOpen&&s&&this.floorId===null&&!this.roomId&&n.resetView()}e.has("tapInRoom")&&n.setTapInRoom(this.tapInRoom),e.has("wallMode")&&n.setWallMode(this.wallMode),e.has("solidWalls")&&n.setPaintedWalls(this.solidWalls),e.has("glassWalls")&&n.setGlassWalls((this.glassWalls??20)/100),e.has("explode")&&n.setExplode(this.explode),e.has("keepRoof")&&n.setKeepRoof(this.keepRoof),e.has("keepCamera")&&n.setKeepCamera(!!this.keepCamera),e.has("plain")&&n.setPlain(!!this.plain),e.has("rightBack")&&n.setRightBack(!!this.rightBack),e.has("zoom")&&n.setZoom(this.zoom??1),e.has("floorStack")&&n.setFloorStack(this.floorStack),e.has("theme")&&n.setTheme(this.theme),e.has("_locked")&&n.setNavigationLocked(this._locked),e.has("accent")&&n.setAccent(this.accent??null),e.has("furnitureColors")&&n.setFurnitureColors(this.furnitureColors??null),e.has("surfaceGrab")&&n.setSurfaceGrab(this.surfaceGrab??null),e.has("furnishTypes")&&n.setFurnishTypes(this.furnishTypes??null),e.has("furnish")&&(n.setFurnishMode(this.furnish),this.syncDevices(!0)),e.has("selectedFurniture")&&n.selectFurniture(this.selectedFurniture),e.has("selectedDevice")&&n.setSelectedDevice(this.selectedDevice),(e.has("weather")||e.has("weatherEntityId")||e.has("weatherDensity")||e.has("timeOfDay"))&&this.syncDevices(!0),e.has("quality")&&e.get("quality")!==void 0&&(n.setQuality(this.quality),this._low=n.low),e.has("showStats")&&n.setStats(this.showStats),e.has("building")&&(this.findIndex=null)}shownFor=null;framePictureData=new Map;framePictures(e,t){let n=[];for(let i of t.floors)for(let o of i.notes??[])o.photo?.startsWith("image:")&&this.storedPicture(e,o.photo.slice(6));for(let i of t.floors)for(let o of i.furniture){if(!o.picture||!Kr(e,o))continue;let s=zo(e,o.picture,a=>this.storedPicture(e,a));s&&n.push({furnitureId:o.id,floorId:i.id,url:s,border:o.picture_border??0,fit:o.picture_fit==="contain"?"contain":"cover"})}return n}storedPicture(e,t){let n=this.framePictureData.get(t);return n!==void 0?n||null:(this.framePictureData.set(t,""),cs(e,t).then(i=>{this.framePictureData.set(t,i),this.syncDevices(!0)}).catch(()=>{}),null)}shownBuilding(e){let t=this.building,n=Ro(e,t),i=t.floors.filter(a=>a.layer&&this.hiddenLayers.has(a.id)).map(a=>a.id),o=[...n,...i.map(a=>`layer:${a}`)].join(",");if(this.shownFor?.building===t&&this.shownFor.key===o)return this.shownFor.shown;let s=ou(t,n);return this.shownFor={building:t,key:o,shown:i.length?{...s,floors:s.floors.filter(a=>!i.includes(a.id))}:s},this.shownFor.shown}hiddenLayers=(()=>{try{return new Set(JSON.parse(localStorage.getItem("nextfloor.hidden_layers")??"[]"))}catch{return new Set}})();toggleLayer(e){this.hiddenLayers.has(e)?this.hiddenLayers.delete(e):this.hiddenLayers.add(e);try{localStorage.setItem("nextfloor.hidden_layers",JSON.stringify([...this.hiddenLayers]))}catch{}this.viewer&&this.building&&this.viewer.setBuilding(this.shownBuilding(this.hass)),this.requestUpdate()}renderLayers(){let e=(this.building?.floors??[]).filter(t=>t.layer);return!e.length||this.clean?f:p`
${e.map(t=>p`this.toggleLayer(t.id)}>${this.hiddenLayers.has(t.id)?"\u25CC":"\u{1F441}"} ${t.name} `)}
-
`}syncDevices(e){let t=this.viewer,n=this.building;if(!t||!n||!this.hass)return;let i=this._travel,o=i&&!i.loading?Ht(this.hass,i.history,i.t):this.hass;if((e||!this.openingLinks||this.linkedRegistry!==o.entities)&&(this.openingLinks=De(o,n.floors),this.furnitureLinks=ut(o,n.floors),this.linkedRegistry=o.entities,this.findIndex=null,this.alertSrc=this.alerts?Ql(o,n,this.weatherEntityId,this.openingLinks):null,this.watched=oc({hass:o,building:n,openingLinks:this.openingLinks,furnitureLinks:this.furnitureLinks,needsRoomSensors:this.heatMode!=="none"||this.roomLabels,alertSources:this.alertSrc,weatherEntityId:this.weatherEntityId}),e=!0),!(e||this.watched.some(w=>this.shownStates.get(w)!==o.states[w])))return;Eo(o,n).join(",")!==this.shownFor?.key&&t.setBuilding(this.shownBuilding(o)),this.shownStates=new Map(this.watched.map(w=>[w,o.states[w]])),this.refreshToday(n),this.refreshForecast(n);let a=hn(o,n),l=Aa(o,n.floors.some(w=>w.layer&&this.hiddenLayers.has(w.id))?this.shownBuilding(o):n);this.placementInfo=new Map(l.map(w=>[w.id,{floorId:w.floorId,roomId:w.roomId,x:w.x,z:w.z,y:w.y,rotation:w.rotation??0}]));let c=this.furnitureMarkers(o,n,new Set(l.map(w=>w.id)),new Set(a.map(w=>w.powerEntity)));a.push(...c.consumers);let u=mn(o,n,a,Ne(n,w=>this.furnitureLinks?.get(w.id)?.power??null)),d=new Map(a.filter(w=>w.id!==w.powerEntity).map(w=>[w.id,w.power]));this.confirmSet=dt(o,n.floors);let m=new Set(this.liveCardsOn?this._liveCards.flatMap(w=>w.kind==="media"?[w.media.entity]:w.kind==="car"?[w.spot]:[]):[]);for(let w of n.floors)for(let y of w.outdoor??[]){if(!y.area_id&&!y.temp_entity&&!y.pump_entity)continue;let B=y.temp_entity?o.states[y.temp_entity]:void 0,D=y.pump_entity?o.states[y.pump_entity]:void 0,[O,me]=$e(y.points),tt=B&&Number.isFinite(Number(B.state))?`${W(o,se(o,tr(Number(B.state),B.attributes.unit_of_measurement)),1)} ${ne(o)}`:"",_t=!!D&&ee(D);l.push({id:y.area_id?`outdoor:${y.id}`:y.pump_entity??y.temp_entity,floorId:w.id,roomId:null,x:O,z:me,y:Zn(w,y,O,me)+.7,icon:Me(y.type==="pool"?"pool":y.type==="terrace"?"table-chair":"tree-outline"),name:y.area_id&&o.areas?.[y.area_id]?.name||A(o,`out_${y.type}`),text:[tt,_t?A(o,"pool_pump_on"):""].filter(Boolean).join(" \xB7 "),active:_t,unavailable:!1,glow:null,show:"always"})}let h=new Map;for(let w of n.floors){for(let y of w.placements)y.pin_offset&&h.set(`${w.id}:${y.entity_id}`,y.pin_offset);for(let y of w.furniture)y.pin_offset&&h.set(`f:${y.id}`,y.pin_offset)}let g=w=>{let y=w.lamp?void 0:(w.furnitureId?h.get(`f:${w.furnitureId}`):void 0)??h.get(`${w.floorId}:${w.id}`);return y?{...w,x:w.x+(y.x??0),z:w.z+(y.z??0),y:w.y+(y.y??0)}:w};t.setDevices([...[...l,...c.markers].map(g).map(w=>{let y=w.show==="no_power"||"energyDevice"in w&&w.energyDevice?null:d.get(w.id)??null,B={...w,power:y,powerText:y===null?void 0:ce(o,y),effect:this.dimmed?void 0:w.effect,text:this.subMeterText(o,n,u,w.furnitureId)??w.text},D=w.ownName&&(w.showName||this.markerNames)?w.ownName:"",O=m.has(w.id)||!!w.furnitureId&&m.has(w.furnitureId);return{...B,pin:this.showPin(B)&&!O,full:w.show==="always",caption:D}})]),t.setPickTargets(c.targets,this.openingTargets(),this.secondBlinds()),t.setScreens(c.screens),t.setFridgeDoors(la(o,n.floors)),t.setCovers(va(o,n)),t.setRobots(this.robotInfos(o,n));let _=new Map;for(let w of n.floors)for(let y of w.furniture)!Y(y.type)?.pet||!y.room_sensor||y.room_sensor==="none"||_.set(y.id,Ei(o,w.rooms.filter(B=>B.points.length>=3),null,y.room_sensor)?.id??null);_.size&&t.setPetRooms(_),t.setRoofWindows(jl(o,n)),t.setParked(ao(o,n)),t.setGateStates(dc(o,n));let b=new Map(n.floors.flatMap(w=>w.openings.map(y=>[y.id,y.type]))),v=new Map([...this.openingLinks].map(([w,y])=>[w,Fe(o,y,b.get(w))]));t.setOpeningStates(v),this.setAlerts(this.alertSrc?io(o,n,this.alertSrc,this.openingLinks):[]),this.watchLostContacts(o);let k=[...l,...c.markers].map(w=>`${w.id}:${w.glow?`${w.glow.level.toFixed(1)}/${w.glow.color.map(y=>y.toFixed(1)).join("/")}`:0}`).join(";")+"|"+[...v].map(([w,y])=>`${w}:${y.open}:${y.cover===null?"-":y.cover.toFixed(1)}`).join(";");if(k!==this.thumbSig){let w=this.thumbSig==="";this.thumbSig=k,w||this.scheduleThumbs(1500)}let S=$c(o,n,a,n.energy.advanced?w=>this.furnitureLinks?.get(w.id)?.power??null:void 0),M=this.liveCars(o,n);for(let w of M){if(!w.car.home||!w.car.charging&&!w.car.plugged)continue;let y=n.floors.flatMap(O=>O.furniture.filter(me=>me.type==="wallbox").map(me=>({floorId:O.id,x:me.x,z:me.z,y:1}))).sort((O,me)=>Math.hypot(O.x-w.at.x,O.z-w.at.z)-Math.hypot(me.x-w.at.x,me.z-w.at.z))[0],B=y&&y.floorId===w.at.floorId&&Math.hypot(y.x-w.at.x,y.z-w.at.z)<9,D=y??Sn(n);!D||!w.car.charging&&!B||S.arcs.push({key:`car:${w.spot}`,from:D,to:{...w.at,y:.8},power:w.car.charging?w.car.chargingW??7e3:0,color:[80,175,255],...B?{via:[{...D,y:.35},{floorId:w.at.floorId,x:(D.x+w.at.x)/2,z:(D.z+w.at.z)/2,y:.08},{...w.at,y:.5}],cable:!0}:{}})}let T=Sn(n);for(let w of this.liveHeatPumps(n)){let y=w.pump.heat??(w.pump.mode==="heating"||w.pump.mode==="water"?(w.pump.power??0)*(w.pump.cop??3):0);T&&y>100&&w.pump.mode!=="cooling"&&S.arcs.push({key:`heat:${w.id}`,from:{floorId:w.floorId,x:w.x,z:w.z,y:.8},to:T,power:y,color:[255,120,40]})}let z=(this.flows??this._flows)&&!this.dimmed;t.setLiveEnergy(z?S.arcs:[],z?S.sparks:[]),JSON.stringify(S)!==JSON.stringify(this._liveEnergy)&&(this._liveEnergy=S);let C=this.liveMedia(o,n).filter(w=>w.playing&&!this.dimmed);t.setLiveSound(C.filter(w=>w.rings>0).map(w=>({id:w.entity,at:w.at,color:w.color,level:w.volume??.5,size:w.rings})),Kl(C).map(([w,y])=>[w.at,y.at])),this.syncLhCards(t,n,S,M,C,o),t.setLiveScreens(this.dimmed?[]:ql(o,n,this.furnitureLinks)),t.setPictures(this.framePictures(o,n)),t.setLiveWater(this.dimmed?[]:Gl(o,n,this.furnitureLinks));let E=Dl(o,n);t.setPersons(E);let R=Fl(o,n,this.openingLinks,E);t.setFloorInfo(new Map([...R].map(([w,y])=>[w,Hl(o,y)])));let H=o.config,N=this.timeOfDay!=null&&H?.latitude!==void 0&&H.longitude!==void 0?at(wt(this.timeOfDay,H.time_zone),H.latitude,H.longitude):Zl(o);t.setSun(N),t.setLocation(H?.latitude!==void 0&&H.longitude!==void 0?{latitude:H.latitude,longitude:H.longitude,zone:H.time_zone}:null);let V=this.weather&&!this.dimmed?hc(o,Xe(o,this.weatherEntityId??n.settings.weather_entity)):null,G=V?mc(pc(V,n.settings.weather_effects),this.weatherDensity):null;this.cloud=G?.cloud??0,this._sky=Yl(N?.elevation??null,this.cloud),t.setSky(this.weather&&!this.dimmed?{weather:G,sun:N,north:n.settings.north??0,sky:this.skyColor(),disc:(n.settings.weather_effects??["sky"]).includes("sky"),low:this._low}:null),this.applyTint();let re=u.grid!==null||u.solar!==null||u.battery!==null||u.tariff!==null?u:null;JSON.stringify(re)!==JSON.stringify(this._energy)&&(this._energy=re)}watchLostContacts(e){let t=!!this.alertSrc&&!this._travel&&ec(e,this.alertSrc);t&&!this.contactTimer&&(this.contactTimer=setInterval(()=>{let n=this.building;this.alertSrc&&n&&this.hass&&this.openingLinks&&!this._travel&&this.setAlerts(io(this.hass,n,this.alertSrc,this.openingLinks))},6e4)),!t&&this.contactTimer&&(clearInterval(this.contactTimer),this.contactTimer=void 0)}setAlerts(e){let t=e.map(o=>`${o.kind}:${o.entity}`),n=e.filter((o,s)=>!this.seenAlerts.has(t[s])&&!Er.has(o.kind));this.seenAlerts=new Set(t),t.join()!==this._alerts.map(o=>`${o.kind}:${o.entity}`).join()&&(this._alerts=e);let i=e.some(o=>!Er.has(o.kind));i&&!this.alertTimer&&(this.alertTimer=setInterval(()=>!document.hidden&&this.applyTint(),this._low?200:100)),!i&&this.alertTimer&&(clearInterval(this.alertTimer),this.alertTimer=void 0),n.length&&this.alertJump&&this.jumpTo(n[0])}jumpTo(e){if(e.kind==="own"&&e.tap!=="room"){e.tap==="toggle"?this.hass.callService("homeassistant","toggle",{entity_id:e.entity}):be(this,e.entity);return}if(!e.floorId){this.fire("floor-tap",{floorId:null});return}this.floorId!==e.floorId&&this.fire("floor-tap",{floorId:e.floorId}),e.roomId&&setTimeout(()=>this.fire("room-tap",{floorId:e.floorId,roomId:e.roomId}),60)}onRoomDoubleTap(e,t){let n=this.building,i=this.hass,o=n?.floors.find(u=>u.id===e),s=o?.rooms.find(u=>u.id===t);if(!n||!i||!o||!s)return;let a=sc(n.settings.room_double_tap,this.roomDoubleTap),l=ac(i,o,s,this.furnitureLinks,this.confirmSet,a);if(!l.length)return;let c=l.some(u=>i.states[u]?.state==="on");i.callService("homeassistant",c?"turn_off":"turn_on",{entity_id:l}),this.roomFlash={roomId:t,until:performance.now()+350},this.applyTint(),setTimeout(()=>{this.roomFlash=null,this.applyTint()},380)}runScene(e){this.hass.callService(e.split(".")[0],"turn_on",{entity_id:e}),this._sceneFired=e,setTimeout(()=>this._sceneFired=null,600)}applyTint(){let e=this.viewer,t=this.building,n=this.hass;if(!e||!t||!n)return;let i=null;if(this.heatMode!=="none"&&this.heatMode!=="values"&&this.heatMode!=="wifi"){let a=this.heatMode,l=xl(n,t,a);!l.size!=!this.heatValues.size&&this.requestUpdate(),this.heatValues=l;let c=ht(new Date,n.config?.latitude??50);i=new Map([...l].map(([u,d])=>[u,yl(a,d,c)]))}let o=new Map;if(this.heatMode==="values")for(let a of t.floors)for(let l of a.rooms){let c=j(n,a,l,"temperature"),u=j(n,a,l,"humidity"),d=j(n,a,l,"co2"),m=yr(d,u,Ft(c,u)),h=[c!==null?`${W(n,se(n,c),1)} ${ne(n)}`:null,u!==null?`${W(n,u,0)} %`:null,d!==null?`${W(n,d,0)} ppm`:null,m?`\u{1F4A8} ${A(n,`air_${m}`)}`:null].filter(g=>!!g);h.length&&o.set(l.id,h.join(" \xB7 "))}if(e.setRoomInfo(o),!i)for(let a of t.floors)for(let l of a.rooms){let c=l.floor_heating?n.states[l.floor_heating]:void 0;c&&(U(n)?oe(c)===!0:c.entity_id.startsWith("climate.")?c.attributes.hvac_action==="heating":c.state==="on"||c.state==="open")&&(i??=new Map).set(l.id,[.55,.24,.08])}if(this._alerts.length){i??=new Map;let a=.55+.45*Math.sin(performance.now()/160);for(let l of this._alerts){if(Er.has(l.kind))continue;let c=tc(l.kind).map(u=>u*a);if(l.roomId)i.set(l.roomId,c);else for(let u of t.floors)for(let d of u.rooms)i.set(d.id,c)}}this.roomFlash&&performance.now()`${a}:${l.map(c=>c.toFixed(2)).join(",")}`).join(";"):"";s!==this.tintSig&&(this.tintSig=s,e.setRoomTint(i))}furnitureMarkers(e,t,n,i){let o=[],s=[],a=new Map,l=new Map,c=dn(t);for(let m of t.floors)if(!(m.layer&&this.hiddenLayers.has(m.id)))for(let h of m.furniture){if(!Vr(e,h))continue;let g=this.furnitureLinks.get(h.id),_=this.stateFaces(e,h);_.length&&a.set(h.id,{color:_[0].color,level:_[0].level,faces:_});let b=Gn(h.type);if(b&&h.care_entity){let y=this.careMarker(e,m,h,b,h.care_entity);y&&(o.push(y.marker),y.glow&&a.set(h.id,{color:y.glow,level:.9,faces:[{part:"all",color:y.glow,level:.9}]}),l.set(h.id,h.care_entity));continue}let v=Y(h.type);if(h.cover_entity&&Kn(v)&&l.set(h.id,h.cover_entity),v?.gangs){for(let B of(h.gang_entities??[]).slice(0,v.gangs)){let D=B&&B!=="none"?We(e,B):null,O=D?Z(e.states[D]):null;D&&O!==null&&!i.has(D)&&(i.add(D),s.push({id:B,powerEntity:D,floorId:m.id,x:h.x,z:h.z,power:Math.max(0,O)}))}let y=fa(e,(h.gang_entities??[]).slice(0,v.gangs),/socket/.test(h.type));y.length&&a.set(h.id,{color:y[0].color,level:y[0].level,gangs:y}),Ti(h.gang_entities,v.gangs).length&&l.set(h.id,`gang:${h.id}`);continue}if(Jn(h.type)){let y=this.lampMarker(e,m,h,g?.entity??null),B=g?.power?Z(e.states[g.power]):null;if(g?.power&&B!==null&&(B>=1&&(y.text=y.text?`${y.text} \xB7 ${mt(e,B)}`:mt(e,B)),i.has(g.power)||(i.add(g.power),s.push({id:y.id,powerEntity:g.power,floorId:m.id,x:h.x,z:h.z,power:Math.max(0,B)}))),o.push(y),h.type==="ceiling_fan"){let D=g?.fan?e.states[g.fan]:void 0;y.spin=tu(D),D&&!n.has(D.entity_id)&&(n.add(D.entity_id),o.push({...y,id:D.entity_id,y:Math.max(.5,y.y-.3),icon:h.icon?Me(h.icon):Rt("fan"),name:h.name||L(e,D.entity_id),text:pf(e,D),active:ee(D),unavailable:I(D),glow:null,lamp:null,spin:void 0,pickable:void 0,effect:void 0}))}continue}let k=Ai(h.type)?oa(e,h,y=>`${W(e,se(e,y),1)} ${ne(e)}`):null,S=Ai(h.type)?null:aa(e,h.temp_entity),M=S===null?"":`\u{1F321} ${W(e,se(e,S),1)} ${ne(e)}`,T=h.type==="home_battery"?h.soc:h.type==="wallbox"?h.status:k?h.temp_entity&&h.temp_entity!=="none"?h.temp_entity:h.temp_entity2:S!==null?h.temp_entity:null,z=T&&T!=="none"?T:(h.values??[]).find(y=>y.entity&&y.entity!=="none")?.entity??null,$=g??(z?{entity:null,power:null}:void 0);if(!$)continue;let C=h.type==="home_battery"?z??$.entity??$.power:$.entity??$.power??z;l.set(h.id,C);let E=$.entity?e.states[$.entity]:void 0,R=c.has(h.id),H=R?!!h.meter_invert:h.type==="meter"?t.energy.grid_invert&&!h.export:h.type==="home_battery"?t.energy.battery_invert&&!h.charge:!1,N=$.power?Z(e.states[$.power],H):null,V=h.type==="home_battery"&&h.charge&&h.charge!=="none"?h.charge:h.type==="meter"&&!R&&h.export&&h.export!=="none"?h.export:null,G=V?Z(e.states[V]):null;G!==null&&(N=Math.max(0,N??0)-Math.max(0,G)),$.power&&N!==null&&!i.has($.power)&&(i.add($.power),s.push({id:C,powerEntity:$.power,floorId:m.id,x:h.x,z:h.z,power:Math.max(0,N),wallbox:h.type==="wallbox"||void 0}));let q=(N??0)>10||E?.state==="on"||E?.state==="running"||er(E)&&ee(E);if((h.type==="radiator"||v)&&E&&F(E.entity_id)==="climate"){let y=E.attributes;if(y.hvac_action==="heating"){let B=typeof y.temperature=="number"&&typeof y.current_temperature=="number"?y.temperature-y.current_temperature:1,D=!!v&&!v.parts.some(O=>O.screen);a.set(h.id,{color:[1,.42,.1],level:Math.min(1,.45+.25*Math.max(0,B)),heat:D||void 0})}}else(h.type==="washer"||h.type==="dryer"||h.type==="dishwasher")&&q?a.set(h.id,{color:[.3,.85,1],level:.8}):v&&q&&!v.light&&v.parts.some(y=>y.glow||y.screen)&&a.set(h.id,{color:[.3,.85,1],level:.8,leds:!0});if(yo(h.type)){let y=wo(e,$.entity??$.power);if(y&&y.progress!==null&&(y.printing||/pause/.test(y.status))){let B=y.filaments[0]??"#38bdf8",D=[1,3,5].map(O=>parseInt(B.slice(O,O+2),16)/255);a.set(h.id,{color:D,level:.9,print:Math.max(.02,y.progress/100)})}}if(h.type==="home_battery"&&z){let y=Number(e.states[z]?.state);Number.isFinite(y)&&a.set(h.id,{color:y>60?[.29,.87,.5]:y>25?[.98,.8,.08]:[.97,.44,.44],level:.95,fill:y/100})}if(E&&sr(h.type)){let y=F(E.entity_id)==="light"?Te(E):null,B=F(E.entity_id)==="media"&&["playing","on","paused","idle"].includes(E.state),D=y?y.color:ee(E)||B?[.22,.88,1]:null;D&&a.set(h.id,{color:D,level:E.state==="playing"?1:.6,halo:h.ambilight??1})}if(n.has(C))continue;n.add(C);let re=$.entity?F($.entity):null,w=m.rooms.find(y=>y.points.length>=3&&P([h.x,h.z],y.points));o.push({id:C,floorId:m.id,roomId:w?.id??null,x:h.x,z:h.z,y:zo(h)+de(m,h),icon:h.icon?Me(h.icon):Rt(re??"switch"),name:h.name||($.entity?L(e,$.entity):fe(e,h.type)),ownName:h.name||void 0,showName:!!h.show_name,text:[k?k.text:h.type==="home_battery"?this.batteryText(e,z,N):h.type==="wallbox"?this.wallboxText(e,z,N):h.type==="meter"?R?N===null?"":ce(e,N):this.meterText(e,N):E&&(h.type==="washer"||h.type==="dryer"||h.type==="dishwasher")&&q&&Fi(e,on(e,$.entity??$.power))!==null?A(e,"care_time_left",{time:ba(Fi(e,on(e,$.entity??$.power)))}):E?[ie(e,E),N!==null&&N>5&&!er(E)?ce(e,N):""].filter(Boolean).join(" \xB7 "):N!==null?ce(e,Math.max(0,N)):"",M,sn(e,h.values)].filter(Boolean).join(" \xB7 "),active:k?.warm||S!==null&&S>=sa||(E?ee(E):(N??0)>5),unavailable:E?I(E):!1,glow:null,furnitureId:h.id,energyDevice:h.type==="inverter"||h.type==="home_battery"||h.type==="wallbox"||h.type==="meter",readout:!!k||!!h.values?.some(y=>y.entity&&y.entity!=="none")||void 0,show:h.marker??void 0,fromFurniture:!0})}let u=this.heatMode==="wifi";for(let m of o){let h=m.furnitureId?t.floors.flatMap(_=>_.furniture).find(_=>_.id===m.furnitureId):void 0;if(!h||!xo(h.type))continue;let g=ko(e,this.furnitureLinks.get(h.id)?.entity??this.furnitureLinks.get(h.id)?.power??null);g&&(g.clients!==null&&(m.text=A(e,"wifi_clients",{n:g.clients})),u&&(m.wedge={angle:360,reach:9,near:0,color:Lc(g),opacity:.4,through:!0,walls:!1},m.show="always"))}let d=lc(t,o);this.tapPins=d.pins;for(let m of t.floors.flatMap(h=>h.furniture))m.tap?.action&&l.set(m.id,`tap:${m.id}`);for(let{floor:m,item:h}of d.bare){let g=m.rooms.find(b=>b.points.length>=3&&P([h.x,h.z],b.points)),_=h.name||fe(e,h.type);o.push({id:`tap:${h.id}`,floorId:m.id,roomId:g?.id??null,x:h.x,z:h.z,y:zo(h)+de(m,h),icon:Me(h.icon||"gesture-tap-button"),name:_,ownName:h.name||void 0,showName:!!h.show_name,text:"",active:!1,unavailable:!1,glow:null,furnitureId:h.id,show:h.marker??void 0,fromFurniture:!0})}return{markers:o,consumers:s,screens:a,targets:l}}robotObstacles(e,t){let n=new Set(["rug","worktop","table","table_round","coffee_table","chair","office_chair","stool","bar_stool","bench","desk","robot_vacuum","parking","stairwell","radiator","tv_wall","kitchen_wall","led_strip"]);return e.furniture.filter(i=>{if(n.has(i.type)||i.type.startsWith("lamp_")&&i.type!=="lamp_floor"&&i.type!=="lamp_uplight"||i.h<.04||de(e,i)>.12)return!1;let o=Y(i.type);return o&&(o.hole||/table|desk|chair|stool|bench|rug|carpet|mat$/.test(i.type))?!1:P([i.x,i.z],t)||Qn(i).some(s=>P(s,t))}).map(i=>Qn(i))}robotInfos(e,t){let n=[],i=lu(e),o=cu(e,i,t.settings.vacuum_map??null),s=!1;for(let a of t.floors){for(let l of a.furniture){if(l.type!=="robot_vacuum")continue;let c=this.furnitureLinks.get(l.id)?.entity??null,u=c?e.states[c]?.state:void 0,d=u==="cleaning"?"cleaning":u==="returning"?"returning":u==="error"?"error":u==="docked"||!u?"docked":"idle",m=l.rotation*Math.PI/180,h=l.d*.14,g=[l.x-Math.sin(m)*h,l.z+Math.cos(m)*h],_=a.rooms.filter(C=>C.points.length>=3),v=(d==="cleaning"?Ei(e,_,c,ar(e,c,l.room_sensor)):null)??_.find(C=>P(g,C.points)),k=d==="cleaning"&&v?this.robotObstacles(a,v.points):[],S=i?Date.parse(e.states[i]?.last_updated??""):Number.NaN,M=!Number.isFinite(S)||Date.now()-S<120*1e3,T=c?.startsWith("vacuum.")&&o&&!s&&(M||d!=="cleaning"&&d!=="returning")?o:null;T&&(s=!0);let z=c?Date.parse(e.states[c]?.last_changed??""):Number.NaN,$=d==="cleaning"||d==="returning"?null:Number.isFinite(z)?z:null;n.push({id:l.id,floorId:a.id,rest:g,restHeading:-m,mode:d,room:v?.points??null,roomId:v?.id??null,obstacles:k,track:T?.path??null,pose:T?.pose??null,settledAt:$})}for(let l of a.furniture){if(!/:(robot_mower|mower_dock)$/.test(l.type))continue;let c=this.furnitureLinks.get(l.id)?.entity??null;if(!c?.startsWith("lawn_mower."))continue;let u=e.states[c]?.state,d=u==="mowing"?"cleaning":u==="returning"?"returning":u==="error"?"error":u==="docked"||!u?"docked":"idle",m=[l.x,l.z],h=(a.outdoor??[]).filter(b=>b.type==="lawn"&&b.points.length>=3),g=h.find(b=>P(m,b.points))??[...h].sort((b,v)=>Xt(v.points)-Xt(b.points))[0],_=g?(a.outdoor??[]).filter(b=>b!==g&&b.type!=="lawn"&&b.points.some(v=>P(v,g.points))).map(b=>b.points):[];n.push({id:l.id,floorId:a.id,rest:m,restHeading:-l.rotation*Math.PI/180,mode:d,room:g?.points??null,roomId:g?.id??null,obstacles:_,y:g?Zn(a,g,m[0],m[1]):Yn(a),mower:!0})}}return n}batteryText(e,t,n){let i=t?Number(e.states[t]?.state):Number.NaN,o=[];return Number.isFinite(i)&&o.push(`${W(e,i,0)} %`),n!==null&&Math.abs(n)>=10&&o.push(`${n<0?"\u25B2":"\u25BC"} ${ce(e,Math.abs(n))}`),o.join(" \xB7 ")}subMeterText(e,t,n,i){let o=i?cl(t,n,i):null;return o?ce(e,o.use)+(o.unmetered===null?"":` \xB7 ${A(e,"meter_unmetered",{w:ce(e,o.unmetered)})}`):null}meterText(e,t){return t===null?"":Math.abs(t)<5?ce(e,0):`${A(e,t<0?"energy_grid_export":"energy_grid_import")} ${ce(e,Math.abs(t))}`}wallboxText(e,t,n){let i=t?e.states[t]:void 0,o=String(i?.state??"").toLowerCase(),s=(n??0)>50||/charg|laden|lädt/.test(o),a=i?.entity_id.startsWith("binary_sensor.")?o==="on":/connect|plug|ready|angesteckt|verbunden|wait|paused|suspend/.test(o),l=s?A(e,"wallbox_charging"):a?A(e,"wallbox_plugged"):i&&!I(i)&&!i.entity_id.startsWith("binary_sensor.")?ie(e,i):"",c=n!==null&&n>50?ce(e,n):"";return[l,c].filter(Boolean).join(" \xB7 ")}stateFaces(e,t){let n=[],i=t.state_entity2&&t.state_entity2!=="none"?[[t.state_entity,t.state_split==="top_bottom"?"bottom":"left"],[t.state_entity2,t.state_split==="top_bottom"?"top":"right"]]:[[t.state_entity,"all"]];for(let[o,s]of i){if(!o||o==="none")continue;let a=e.states[o];if(!a||I(a)||!(ee(a)||a.state==="home"||a.state==="occupied"||a.state==="on"))continue;let c=F(o)==="light"?Te(a):null;n.push({part:s,color:c?c.color:[1,.71,.28],level:c?c.level:.85})}return n}careMarker(e,t,n,i,o){let s=e.states[o];if(!s)return null;let a="",l=!1,c=null;if(i==="bin"){let m=lr(s);a=m===null?ie(e,s):m===0?A(e,"care_bin_today"):m===1?A(e,"care_bin_tomorrow"):A(e,"care_bin_days",{n:m}),l=m!==null&&m<=1,l&&(c=[1,.72,.28])}else if(i==="mail")l=ga(s),a=A(e,l?"care_mail_yes":"care_mail_no"),l&&(c=[1,.85,.3]);else{let m=_a(s,n.thirsty_below??20);l=!!m?.thirsty,a=m?Number.isFinite(m.moisture)?`${A(e,l?"care_plant_thirsty":"care_plant_ok")} \xB7 ${Math.round(m.moisture)} %`:A(e,l?"care_plant_thirsty":"care_plant_ok"):ie(e,s),l&&(c=[1,.45,.3])}let u=t.rooms.find(m=>m.points.length>=3&&P([n.x,n.z],m.points)),d={bin:"mdi:trash-can-outline",mail:"mdi:mailbox-outline",plant:"mdi:sprout-outline"}[i];return{glow:c,marker:{id:o,floorId:t.id,roomId:u?.id??null,x:n.x,z:n.z,y:zo(n)+de(t,n),icon:n.icon?Me(n.icon):Me(d),name:n.name||fe(e,n.type),ownName:n.name||void 0,showName:!!n.show_name,text:a,active:l,unavailable:I(s),glow:null,furnitureId:n.id,show:n.marker??void 0,fromFurniture:!0,care:!0}}}lampMarker(e,t,n,i){let o=i?e.states[i]:void 0,s=(n.extra_lights??[]).map(b=>e.states[b]).filter(b=>!!b),a=s.find(b=>ee(b)),l=Y(n.type),c=Cs[n.type]??l?.light??"floor",u=t.rooms.some(b=>b.points.length>=3&&P([n.x,n.z],b.points)),d=c==="strip"&&!u?Qt(t,n.x,n.z)+(n.mount_y??0):n.mount_y!=null&&!l?n.mount_y:l||c==="wall"||c==="strip"?de(t,n):c==="table"?qn(t,n.x,n.z):c==="bollard"||c==="garden"?Qt(t,n.x,n.z):0,m=t.rooms.find(b=>b.points.length>=3&&P([n.x,n.z],b.points)),h=jn(t,n),g=l?l.mount==="ceiling"?Math.max(.5,d-.15):d+n.h+.2:{ceiling:h-.3,downlight:h-.25,spot:h-.35,panel:h-.25,pendant:Math.max(.6,h-n.h-.25),fan:Math.max(.6,h-n.h-.2),floor:d+n.h+.25,uplight:d+n.h+.25,table:d+n.h+.2,wall:d+n.h+.2,strip:n.upright?d+n.w+.15:Math.max(.3,d-.2),bollard:d+n.h+.25,garden:d+n.h+.25}[c],_={id:i??`lamp:${n.id}`,floorId:t.id,roomId:m?.id??null,x:n.x,z:n.z,y:g,icon:Rt("light"),name:n.name||(i?L(e,i):fe(e,n.type)),text:[o&&(ee(o)||!a)?ie(e,o):a?L(e,a.entity_id):"",sn(e,n.values)].filter(Boolean).join(" \xB7 "),readout:!!n.values?.some(b=>b.entity&&b.entity!=="none"),active:(o?ee(o):!1)||!!a,unavailable:o?I(o):!1,glow:o||s.length?Ci(Ks(o,s,n.color_entity&&n.color_entity!=="none"?e.states[n.color_entity]:void 0),n.glow_scale):null,lamp:c,rotation:n.rotation,mirror:!!n.mirror,roll:n.tilt??0,upright:!!n.upright,rise:n.rise??0,size:[n.w,n.d,n.h],base:d,pickable:!!i,furnitureId:n.id,pack:l?n.type:null,lightY:l?l.mount==="ceiling"?d:d+n.h*.85:void 0,ceiling:h,effect:o?.state==="on"?fr(n,$a(e,n,i)):void 0,variant:n.variant,show:n.marker??void 0,fromFurniture:!0};return o&&i?Ni(e,_,o,!1):_}showPin(e){if(this.furnish&&!e.fromFurniture)return!0;if(e.show==="never"||this.markerMode==="none")return!1;if(e.show==="always")return!0;if(e.show==="active"||this.building?.settings.motion_markers_active&&Bs(this.hass,e.id)){if(!e.active)return!1;if(e.show==="active")return!0}if(this.markersOutside&&!(this.roomId&&e.roomId===this.roomId))return this.markersOutside.includes(Ws(e.id,!!e.lamp));if(this.markerMode==="all")return!0;if(e.lamp)return!1;let t=F(e.id);return t==="light"?!1:e.fromFurniture&&t==="fan"?!0:e.care?e.active:e.id.startsWith("tap:")||e.readout?!0:e.fromFurniture?(e.power??0)>=1||t==="media"&&e.active||!!e.energyDevice&&!!e.text:!0}openingTargets(){let e=new Map;for(let[t,n]of this.openingLinks??[]){let i=n.lock??n.cover??n.contact??n.tilt;i&&e.set(t,i)}return e}downloadStl(){let e=this.viewer?.exportStl(10);if(!e)return;let t=URL.createObjectURL(new Blob([e],{type:"model/stl"})),n=document.createElement("a");n.href=t,n.download=`nextfloor-${new Date().toISOString().slice(0,10)}.stl`,n.click(),setTimeout(()=>URL.revokeObjectURL(t),5e3)}secondBlinds(){let e=new Map;for(let[t,n]of this.openingLinks??[])n.cover2&&!n.lock&&n.cover&&e.set(t,n.cover2);return e}scheduleThumbs(e=600){clearTimeout(this.thumbTimer);let t=this.building?.floors.filter(i=>i.rooms.length).length??0;if(!this.floorThumbs||t<2){this._thumbs=[];return}let n=Math.max(e,this.thumbsAt+(this._low?8e3:4e3)-Date.now());this.thumbTimer=setTimeout(()=>{if(!(!this.viewer||this.dimmed&&this._thumbs.length)){if(document.hidden){this.scheduleThumbs(3e3);return}this.thumbsAt=Date.now(),this._thumbs=this.viewer.floorThumbnails(this.narrowThumbs?104:150,this.narrowThumbs?78:112)}},n)}get narrowThumbs(){return this._narrowStage}renderThumbs(){if(!this._thumbs.length||!this.building||this._phoneStage)return f;let e=new Map(this.building.floors.map(o=>[o.id,o.name])),t=[...this._thumbs].sort((o,s)=>(this.building.floors.find(a=>a.id===s.floorId)?.elevation??0)-(this.building.floors.find(a=>a.id===o.floorId)?.elevation??0)),n=this._thumbsCompact,i=()=>{this._thumbsCompact=!n;try{localStorage.setItem("nextfloor.thumbs_compact",this._thumbsCompact?"1":"0")}catch{}};return p`
+ `}syncDevices(e){let t=this.viewer,n=this.building;if(!t||!n||!this.hass)return;let i=this._travel,o=i&&!i.loading?It(this.hass,i.history,i.t):this.hass;if((e||!this.openingLinks||this.linkedRegistry!==o.entities)&&(this.openingLinks=De(o,n.floors),this.furnitureLinks=dt(o,n.floors),this.linkedRegistry=o.entities,this.findIndex=null,this.alertSrc=this.alerts?Ql(o,n,this.weatherEntityId,this.openingLinks):null,this.watched=oc({hass:o,building:n,openingLinks:this.openingLinks,furnitureLinks:this.furnitureLinks,needsRoomSensors:this.heatMode!=="none"||this.roomLabels,alertSources:this.alertSrc,weatherEntityId:this.weatherEntityId}),e=!0),!(e||this.watched.some(w=>this.shownStates.get(w)!==o.states[w])))return;Ro(o,n).join(",")!==this.shownFor?.key&&t.setBuilding(this.shownBuilding(o)),this.shownStates=new Map(this.watched.map(w=>[w,o.states[w]])),this.refreshToday(n),this.refreshForecast(n);let a=mn(o,n),l=Ea(o,n.floors.some(w=>w.layer&&this.hiddenLayers.has(w.id))?this.shownBuilding(o):n);this.placementInfo=new Map(l.map(w=>[w.id,{floorId:w.floorId,roomId:w.roomId,x:w.x,z:w.z,y:w.y,rotation:w.rotation??0}]));let c=this.furnitureMarkers(o,n,new Set(l.map(w=>w.id)),new Set(a.map(w=>w.powerEntity)));a.push(...c.consumers);let u=pn(o,n,a,Ne(n,w=>this.furnitureLinks?.get(w.id)?.power??null)),d=new Map(a.filter(w=>w.id!==w.powerEntity).map(w=>[w.id,w.power]));this.confirmSet=ht(o,n.floors);let m=new Set(this.liveCardsOn?this._liveCards.flatMap(w=>w.kind==="media"?[w.media.entity]:w.kind==="car"?[w.spot]:[]):[]);for(let w of n.floors)for(let y of w.outdoor??[]){if(!y.area_id&&!y.temp_entity&&!y.pump_entity)continue;let B=y.temp_entity?o.states[y.temp_entity]:void 0,D=y.pump_entity?o.states[y.pump_entity]:void 0,[O,me]=$e(y.points),nt=B&&Number.isFinite(Number(B.state))?`${W(o,se(o,nr(Number(B.state),B.attributes.unit_of_measurement)),1)} ${ne(o)}`:"",bt=!!D&&ee(D);l.push({id:y.area_id?`outdoor:${y.id}`:y.pump_entity??y.temp_entity,floorId:w.id,roomId:null,x:O,z:me,y:Yn(w,y,O,me)+.7,icon:Me(y.type==="pool"?"pool":y.type==="terrace"?"table-chair":"tree-outline"),name:y.area_id&&o.areas?.[y.area_id]?.name||A(o,`out_${y.type}`),text:[nt,bt?A(o,"pool_pump_on"):""].filter(Boolean).join(" \xB7 "),active:bt,unavailable:!1,glow:null,show:"always"})}let h=new Map;for(let w of n.floors){for(let y of w.placements)y.pin_offset&&h.set(`${w.id}:${y.entity_id}`,y.pin_offset);for(let y of w.furniture)y.pin_offset&&h.set(`f:${y.id}`,y.pin_offset)}let g=w=>{let y=w.lamp?void 0:(w.furnitureId?h.get(`f:${w.furnitureId}`):void 0)??h.get(`${w.floorId}:${w.id}`);return y?{...w,x:w.x+(y.x??0),z:w.z+(y.z??0),y:w.y+(y.y??0)}:w};t.setDevices([...[...l,...c.markers].map(g).map(w=>{let y=w.show==="no_power"||"energyDevice"in w&&w.energyDevice?null:d.get(w.id)??null,B={...w,power:y,powerText:y===null?void 0:ce(o,y),effect:this.dimmed?void 0:w.effect,text:this.subMeterText(o,n,u,w.furnitureId)??w.text},D=w.ownName&&(w.showName||this.markerNames)?w.ownName:"",O=m.has(w.id)||!!w.furnitureId&&m.has(w.furnitureId);return{...B,pin:this.showPin(B)&&!O,full:w.show==="always",caption:D}})]),t.setPickTargets(c.targets,this.openingTargets(),this.secondBlinds()),t.setScreens(c.screens),t.setFridgeDoors(ca(o,n.floors)),t.setCovers(wa(o,n)),t.setRobots(this.robotInfos(o,n));let _=new Map;for(let w of n.floors)for(let y of w.furniture)!Y(y.type)?.pet||!y.room_sensor||y.room_sensor==="none"||_.set(y.id,Ri(o,w.rooms.filter(B=>B.points.length>=3),null,y.room_sensor)?.id??null);_.size&&t.setPetRooms(_),t.setRoofWindows(jl(o,n)),t.setParked(lo(o,n)),t.setGateStates(dc(o,n));let b=new Map(n.floors.flatMap(w=>w.openings.map(y=>[y.id,y.type]))),v=new Map([...this.openingLinks].map(([w,y])=>[w,Fe(o,y,b.get(w))]));t.setOpeningStates(v),this.setAlerts(this.alertSrc?oo(o,n,this.alertSrc,this.openingLinks):[]),this.watchLostContacts(o);let k=[...l,...c.markers].map(w=>`${w.id}:${w.glow?`${w.glow.level.toFixed(1)}/${w.glow.color.map(y=>y.toFixed(1)).join("/")}`:0}`).join(";")+"|"+[...v].map(([w,y])=>`${w}:${y.open}:${y.cover===null?"-":y.cover.toFixed(1)}`).join(";");if(k!==this.thumbSig){let w=this.thumbSig==="";this.thumbSig=k,w||this.scheduleThumbs(1500)}let S=$c(o,n,a,n.energy.advanced?w=>this.furnitureLinks?.get(w.id)?.power??null:void 0),$=this.liveCars(o,n);for(let w of $){if(!w.car.home||!w.car.charging&&!w.car.plugged)continue;let y=n.floors.flatMap(O=>O.furniture.filter(me=>me.type==="wallbox").map(me=>({floorId:O.id,x:me.x,z:me.z,y:1}))).sort((O,me)=>Math.hypot(O.x-w.at.x,O.z-w.at.z)-Math.hypot(me.x-w.at.x,me.z-w.at.z))[0],B=y&&y.floorId===w.at.floorId&&Math.hypot(y.x-w.at.x,y.z-w.at.z)<9,D=y??$n(n);!D||!w.car.charging&&!B||S.arcs.push({key:`car:${w.spot}`,from:D,to:{...w.at,y:.8},power:w.car.charging?w.car.chargingW??7e3:0,color:[80,175,255],...B?{via:[{...D,y:.35},{floorId:w.at.floorId,x:(D.x+w.at.x)/2,z:(D.z+w.at.z)/2,y:.08},{...w.at,y:.5}],cable:!0}:{}})}let z=$n(n);for(let w of this.liveHeatPumps(n)){let y=w.pump.heat??(w.pump.mode==="heating"||w.pump.mode==="water"?(w.pump.power??0)*(w.pump.cop??3):0);z&&y>100&&w.pump.mode!=="cooling"&&S.arcs.push({key:`heat:${w.id}`,from:{floorId:w.floorId,x:w.x,z:w.z,y:.8},to:z,power:y,color:[255,120,40]})}let R=(this.flows??this._flows)&&!this.dimmed;t.setLiveEnergy(R?S.arcs:[],R?S.sparks:[]),JSON.stringify(S)!==JSON.stringify(this._liveEnergy)&&(this._liveEnergy=S);let T=this.liveMedia(o,n).filter(w=>w.playing&&!this.dimmed);t.setLiveSound(T.filter(w=>w.rings>0).map(w=>({id:w.entity,at:w.at,color:w.color,level:w.volume??.5,size:w.rings})),Kl(T).map(([w,y])=>[w.at,y.at])),this.syncLhCards(t,n,S,$,T,o),t.setLiveScreens(this.dimmed?[]:ql(o,n,this.furnitureLinks)),t.setPictures(this.framePictures(o,n)),t.setLiveWater(this.dimmed?[]:Gl(o,n,this.furnitureLinks));let E=Dl(o,n);t.setPersons(E);let M=Fl(o,n,this.openingLinks,E);t.setFloorInfo(new Map([...M].map(([w,y])=>[w,Hl(o,y)])));let P=o.config,N=this.timeOfDay!=null&&P?.latitude!==void 0&&P.longitude!==void 0?lt(yt(this.timeOfDay,P.time_zone),P.latitude,P.longitude):Zl(o);t.setSun(N),t.setLocation(P?.latitude!==void 0&&P.longitude!==void 0?{latitude:P.latitude,longitude:P.longitude,zone:P.time_zone}:null);let V=this.weather&&!this.dimmed?hc(o,et(o,this.weatherEntityId??n.settings.weather_entity)):null,U=V?mc(pc(V,n.settings.weather_effects),this.weatherDensity):null;this.cloud=U?.cloud??0,this._sky=Yl(N?.elevation??null,this.cloud),t.setSky(this.weather&&!this.dimmed?{weather:U,sun:N,north:n.settings.north??0,sky:this.skyColor(),disc:(n.settings.weather_effects??["sky"]).includes("sky"),low:this._low}:null),this.applyTint();let re=u.grid!==null||u.solar!==null||u.battery!==null||u.tariff!==null?u:null;JSON.stringify(re)!==JSON.stringify(this._energy)&&(this._energy=re)}watchLostContacts(e){let t=!!this.alertSrc&&!this._travel&&ec(e,this.alertSrc);t&&!this.contactTimer&&(this.contactTimer=setInterval(()=>{let n=this.building;this.alertSrc&&n&&this.hass&&this.openingLinks&&!this._travel&&this.setAlerts(oo(this.hass,n,this.alertSrc,this.openingLinks))},6e4)),!t&&this.contactTimer&&(clearInterval(this.contactTimer),this.contactTimer=void 0)}setAlerts(e){let t=e.map(o=>`${o.kind}:${o.entity}`),n=e.filter((o,s)=>!this.seenAlerts.has(t[s])&&!Rr.has(o.kind));this.seenAlerts=new Set(t),t.join()!==this._alerts.map(o=>`${o.kind}:${o.entity}`).join()&&(this._alerts=e);let i=e.some(o=>!Rr.has(o.kind));i&&!this.alertTimer&&(this.alertTimer=setInterval(()=>!document.hidden&&this.applyTint(),this._low?200:100)),!i&&this.alertTimer&&(clearInterval(this.alertTimer),this.alertTimer=void 0),n.length&&this.alertJump&&this.jumpTo(n[0])}jumpTo(e){if(e.kind==="own"&&e.tap!=="room"){e.tap==="toggle"?this.hass.callService("homeassistant","toggle",{entity_id:e.entity}):be(this,e.entity);return}if(!e.floorId){this.fire("floor-tap",{floorId:null});return}this.floorId!==e.floorId&&this.fire("floor-tap",{floorId:e.floorId}),e.roomId&&setTimeout(()=>this.fire("room-tap",{floorId:e.floorId,roomId:e.roomId}),60)}onRoomDoubleTap(e,t){let n=this.building,i=this.hass,o=n?.floors.find(u=>u.id===e),s=o?.rooms.find(u=>u.id===t);if(!n||!i||!o||!s)return;let a=sc(n.settings.room_double_tap,this.roomDoubleTap),l=ac(i,o,s,this.furnitureLinks,this.confirmSet,a);if(!l.length)return;let c=l.some(u=>i.states[u]?.state==="on");i.callService("homeassistant",c?"turn_off":"turn_on",{entity_id:l}),this.roomFlash={roomId:t,until:performance.now()+350},this.applyTint(),setTimeout(()=>{this.roomFlash=null,this.applyTint()},380)}runScene(e){this.hass.callService(e.split(".")[0],"turn_on",{entity_id:e}),this._sceneFired=e,setTimeout(()=>this._sceneFired=null,600)}applyTint(){let e=this.viewer,t=this.building,n=this.hass;if(!e||!t||!n)return;let i=null;if(this.heatMode!=="none"&&this.heatMode!=="values"&&this.heatMode!=="wifi"){let a=this.heatMode,l=xl(n,t,a);!l.size!=!this.heatValues.size&&this.requestUpdate(),this.heatValues=l;let c=mt(new Date,n.config?.latitude??50);i=new Map([...l].map(([u,d])=>[u,yl(a,d,c)]))}let o=new Map;if(this.heatMode==="values")for(let a of t.floors)for(let l of a.rooms){let c=j(n,a,l,"temperature"),u=j(n,a,l,"humidity"),d=j(n,a,l,"co2"),m=xr(d,u,Pt(c,u)),h=[c!==null?`${W(n,se(n,c),1)} ${ne(n)}`:null,u!==null?`${W(n,u,0)} %`:null,d!==null?`${W(n,d,0)} ppm`:null,m?`\u{1F4A8} ${A(n,`air_${m}`)}`:null].filter(g=>!!g);h.length&&o.set(l.id,h.join(" \xB7 "))}if(e.setRoomInfo(o),!i)for(let a of t.floors)for(let l of a.rooms){let c=l.floor_heating?n.states[l.floor_heating]:void 0;c&&(G(n)?oe(c)===!0:c.entity_id.startsWith("climate.")?c.attributes.hvac_action==="heating":c.state==="on"||c.state==="open")&&(i??=new Map).set(l.id,[.55,.24,.08])}if(this._alerts.length){i??=new Map;let a=.55+.45*Math.sin(performance.now()/160);for(let l of this._alerts){if(Rr.has(l.kind))continue;let c=tc(l.kind).map(u=>u*a);if(l.roomId)i.set(l.roomId,c);else for(let u of t.floors)for(let d of u.rooms)i.set(d.id,c)}}this.roomFlash&&performance.now()`${a}:${l.map(c=>c.toFixed(2)).join(",")}`).join(";"):"";s!==this.tintSig&&(this.tintSig=s,e.setRoomTint(i))}furnitureMarkers(e,t,n,i){let o=[],s=[],a=new Map,l=new Map,c=hn(t);for(let m of t.floors)if(!(m.layer&&this.hiddenLayers.has(m.id)))for(let h of m.furniture){if(!Kr(e,h))continue;let g=this.furnitureLinks.get(h.id),_=this.stateFaces(e,h);_.length&&a.set(h.id,{color:_[0].color,level:_[0].level,faces:_});let b=Un(h.type);if(b&&h.care_entity){let y=this.careMarker(e,m,h,b,h.care_entity);y&&(o.push(y.marker),y.glow&&a.set(h.id,{color:y.glow,level:.9,faces:[{part:"all",color:y.glow,level:.9}]}),l.set(h.id,h.care_entity));continue}let v=Y(h.type);if(h.cover_entity&&Gn(v)&&l.set(h.id,h.cover_entity),v?.gangs){for(let B of(h.gang_entities??[]).slice(0,v.gangs)){let D=B&&B!=="none"?We(e,B):null,O=D?Z(e.states[D]):null;D&&O!==null&&!i.has(D)&&(i.add(D),s.push({id:B,powerEntity:D,floorId:m.id,x:h.x,z:h.z,power:Math.max(0,O)}))}let y=ga(e,(h.gang_entities??[]).slice(0,v.gangs),/socket/.test(h.type));y.length&&a.set(h.id,{color:y[0].color,level:y[0].level,gangs:y}),Di(h.gang_entities,v.gangs).length&&l.set(h.id,`gang:${h.id}`);continue}if(Qn(h.type)){let y=this.lampMarker(e,m,h,g?.entity??null),B=g?.power?Z(e.states[g.power]):null;if(g?.power&&B!==null&&(B>=1&&(y.text=y.text?`${y.text} \xB7 ${pt(e,B)}`:pt(e,B)),i.has(g.power)||(i.add(g.power),s.push({id:y.id,powerEntity:g.power,floorId:m.id,x:h.x,z:h.z,power:Math.max(0,B)}))),o.push(y),h.type==="ceiling_fan"){let D=g?.fan?e.states[g.fan]:void 0;y.spin=tu(D),D&&!n.has(D.entity_id)&&(n.add(D.entity_id),o.push({...y,id:D.entity_id,y:Math.max(.5,y.y-.3),icon:h.icon?Me(h.icon):zt("fan"),name:h.name||L(e,D.entity_id),text:pf(e,D),active:ee(D),unavailable:C(D),glow:null,lamp:null,spin:void 0,pickable:void 0,effect:void 0}))}continue}let k=Ei(h.type)?sa(e,h,y=>`${W(e,se(e,y),1)} ${ne(e)}`):null,S=Ei(h.type)?null:la(e,h.temp_entity),$=S===null?"":`\u{1F321} ${W(e,se(e,S),1)} ${ne(e)}`,z=h.type==="home_battery"?h.soc:h.type==="wallbox"?h.status:k?h.temp_entity&&h.temp_entity!=="none"?h.temp_entity:h.temp_entity2:S!==null?h.temp_entity:null,R=z&&z!=="none"?z:(h.values??[]).find(y=>y.entity&&y.entity!=="none")?.entity??null,F=g??(R?{entity:null,power:null}:void 0);if(!F)continue;let T=h.type==="home_battery"?R??F.entity??F.power:F.entity??F.power??R;l.set(h.id,T);let E=F.entity?e.states[F.entity]:void 0,M=c.has(h.id),P=M?!!h.meter_invert:h.type==="meter"?t.energy.grid_invert&&!h.export:h.type==="home_battery"?t.energy.battery_invert&&!h.charge:!1,N=F.power?Z(e.states[F.power],P):null,V=h.type==="home_battery"&&h.charge&&h.charge!=="none"?h.charge:h.type==="meter"&&!M&&h.export&&h.export!=="none"?h.export:null,U=V?Z(e.states[V]):null;U!==null&&(N=Math.max(0,N??0)-Math.max(0,U)),F.power&&N!==null&&!i.has(F.power)&&(i.add(F.power),s.push({id:T,powerEntity:F.power,floorId:m.id,x:h.x,z:h.z,power:Math.max(0,N),wallbox:h.type==="wallbox"||void 0}));let q=(N??0)>10||E?.state==="on"||E?.state==="running"||tr(E)&&ee(E);if((h.type==="radiator"||v)&&E&&H(E.entity_id)==="climate"){let y=E.attributes;if(y.hvac_action==="heating"){let B=typeof y.temperature=="number"&&typeof y.current_temperature=="number"?y.temperature-y.current_temperature:1,D=!!v&&!v.parts.some(O=>O.screen);a.set(h.id,{color:[1,.42,.1],level:Math.min(1,.45+.25*Math.max(0,B)),heat:D||void 0})}}else(h.type==="washer"||h.type==="dryer"||h.type==="dishwasher")&&q?a.set(h.id,{color:[.3,.85,1],level:.8}):v&&q&&!v.light&&v.parts.some(y=>y.glow||y.screen)&&a.set(h.id,{color:[.3,.85,1],level:.8,leds:!0});if(xo(h.type)){let y=yo(e,F.entity??F.power);if(y&&y.progress!==null&&(y.printing||/pause/.test(y.status))){let B=y.filaments[0]??"#38bdf8",D=[1,3,5].map(O=>parseInt(B.slice(O,O+2),16)/255);a.set(h.id,{color:D,level:.9,print:Math.max(.02,y.progress/100)})}}if(h.type==="home_battery"&&R){let y=Number(e.states[R]?.state);Number.isFinite(y)&&a.set(h.id,{color:y>60?[.29,.87,.5]:y>25?[.98,.8,.08]:[.97,.44,.44],level:.95,fill:y/100})}if(E&&ar(h.type)){let y=H(E.entity_id)==="light"?Te(E):null,B=H(E.entity_id)==="media"&&["playing","on","paused","idle"].includes(E.state),D=y?y.color:ee(E)||B?[.22,.88,1]:null;D&&a.set(h.id,{color:D,level:E.state==="playing"?1:.6,halo:h.ambilight??1})}if(n.has(T))continue;n.add(T);let re=F.entity?H(F.entity):null,w=m.rooms.find(y=>y.points.length>=3&&I([h.x,h.z],y.points));o.push({id:T,floorId:m.id,roomId:w?.id??null,x:h.x,z:h.z,y:To(h)+de(m,h),icon:h.icon?Me(h.icon):zt(re??"switch"),name:h.name||(F.entity?L(e,F.entity):fe(e,h.type)),ownName:h.name||void 0,showName:!!h.show_name,text:[k?k.text:h.type==="home_battery"?this.batteryText(e,R,N):h.type==="wallbox"?this.wallboxText(e,R,N):h.type==="meter"?M?N===null?"":ce(e,N):this.meterText(e,N):E&&(h.type==="washer"||h.type==="dryer"||h.type==="dishwasher")&&q&&Hi(e,an(e,F.entity??F.power))!==null?A(e,"care_time_left",{time:va(Hi(e,an(e,F.entity??F.power)))}):E?[ie(e,E),N!==null&&N>5&&!tr(E)?ce(e,N):""].filter(Boolean).join(" \xB7 "):N!==null?ce(e,Math.max(0,N)):"",$,ln(e,h.values)].filter(Boolean).join(" \xB7 "),active:k?.warm||S!==null&&S>=aa||(E?ee(E):(N??0)>5),unavailable:E?C(E):!1,glow:null,furnitureId:h.id,energyDevice:h.type==="inverter"||h.type==="home_battery"||h.type==="wallbox"||h.type==="meter",readout:!!k||!!h.values?.some(y=>y.entity&&y.entity!=="none")||void 0,show:h.marker??void 0,fromFurniture:!0})}let u=this.heatMode==="wifi";for(let m of o){let h=m.furnitureId?t.floors.flatMap(_=>_.furniture).find(_=>_.id===m.furnitureId):void 0;if(!h||!ko(h.type))continue;let g=So(e,this.furnitureLinks.get(h.id)?.entity??this.furnitureLinks.get(h.id)?.power??null);g&&(g.clients!==null&&(m.text=A(e,"wifi_clients",{n:g.clients})),u&&(m.wedge={angle:360,reach:9,near:0,color:Lc(g),opacity:.4,through:!0,walls:!1},m.show="always"))}let d=lc(t,o);this.tapPins=d.pins;for(let m of t.floors.flatMap(h=>h.furniture))m.tap?.action&&l.set(m.id,`tap:${m.id}`);for(let{floor:m,item:h}of d.bare){let g=m.rooms.find(b=>b.points.length>=3&&I([h.x,h.z],b.points)),_=h.name||fe(e,h.type);o.push({id:`tap:${h.id}`,floorId:m.id,roomId:g?.id??null,x:h.x,z:h.z,y:To(h)+de(m,h),icon:Me(h.icon||"gesture-tap-button"),name:_,ownName:h.name||void 0,showName:!!h.show_name,text:"",active:!1,unavailable:!1,glow:null,furnitureId:h.id,show:h.marker??void 0,fromFurniture:!0})}return{markers:o,consumers:s,screens:a,targets:l}}robotObstacles(e,t){let n=new Set(["rug","worktop","table","table_round","coffee_table","chair","office_chair","stool","bar_stool","bench","desk","robot_vacuum","parking","stairwell","radiator","tv_wall","kitchen_wall","led_strip"]);return e.furniture.filter(i=>{if(n.has(i.type)||i.type.startsWith("lamp_")&&i.type!=="lamp_floor"&&i.type!=="lamp_uplight"||i.h<.04||de(e,i)>.12)return!1;let o=Y(i.type);return o&&(o.hole||/table|desk|chair|stool|bench|rug|carpet|mat$/.test(i.type))?!1:I([i.x,i.z],t)||Xn(i).some(s=>I(s,t))}).map(i=>Xn(i))}robotInfos(e,t){let n=[],i=lu(e),o=cu(e,i,t.settings.vacuum_map??null),s=!1;for(let a of t.floors){for(let l of a.furniture){if(l.type!=="robot_vacuum")continue;let c=this.furnitureLinks.get(l.id)?.entity??null,u=c?e.states[c]?.state:void 0,d=u==="cleaning"?"cleaning":u==="returning"?"returning":u==="error"?"error":u==="docked"||!u?"docked":"idle",m=l.rotation*Math.PI/180,h=l.d*.14,g=[l.x-Math.sin(m)*h,l.z+Math.cos(m)*h],_=a.rooms.filter(T=>T.points.length>=3),v=(d==="cleaning"?Ri(e,_,c,lr(e,c,l.room_sensor)):null)??_.find(T=>I(g,T.points)),k=d==="cleaning"&&v?this.robotObstacles(a,v.points):[],S=i?Date.parse(e.states[i]?.last_updated??""):Number.NaN,$=!Number.isFinite(S)||Date.now()-S<120*1e3,z=c?.startsWith("vacuum.")&&o&&!s&&($||d!=="cleaning"&&d!=="returning")?o:null;z&&(s=!0);let R=c?Date.parse(e.states[c]?.last_changed??""):Number.NaN,F=d==="cleaning"||d==="returning"?null:Number.isFinite(R)?R:null;n.push({id:l.id,floorId:a.id,rest:g,restHeading:-m,mode:d,room:v?.points??null,roomId:v?.id??null,obstacles:k,track:z?.path??null,pose:z?.pose??null,settledAt:F})}for(let l of a.furniture){if(!/:(robot_mower|mower_dock)$/.test(l.type))continue;let c=this.furnitureLinks.get(l.id)?.entity??null;if(!c?.startsWith("lawn_mower."))continue;let u=e.states[c]?.state,d=u==="mowing"?"cleaning":u==="returning"?"returning":u==="error"?"error":u==="docked"||!u?"docked":"idle",m=[l.x,l.z],h=(a.outdoor??[]).filter(b=>b.type==="lawn"&&b.points.length>=3),g=h.find(b=>I(m,b.points))??[...h].sort((b,v)=>tn(v.points)-tn(b.points))[0],_=g?(a.outdoor??[]).filter(b=>b!==g&&b.type!=="lawn"&&b.points.some(v=>I(v,g.points))).map(b=>b.points):[];n.push({id:l.id,floorId:a.id,rest:m,restHeading:-l.rotation*Math.PI/180,mode:d,room:g?.points??null,roomId:g?.id??null,obstacles:_,y:g?Yn(a,g,m[0],m[1]):Jn(a),mower:!0})}}return n}batteryText(e,t,n){let i=t?Number(e.states[t]?.state):Number.NaN,o=[];return Number.isFinite(i)&&o.push(`${W(e,i,0)} %`),n!==null&&Math.abs(n)>=10&&o.push(`${n<0?"\u25B2":"\u25BC"} ${ce(e,Math.abs(n))}`),o.join(" \xB7 ")}subMeterText(e,t,n,i){let o=i?cl(t,n,i):null;return o?ce(e,o.use)+(o.unmetered===null?"":` \xB7 ${A(e,"meter_unmetered",{w:ce(e,o.unmetered)})}`):null}meterText(e,t){return t===null?"":Math.abs(t)<5?ce(e,0):`${A(e,t<0?"energy_grid_export":"energy_grid_import")} ${ce(e,Math.abs(t))}`}wallboxText(e,t,n){let i=t?e.states[t]:void 0,o=String(i?.state??"").toLowerCase(),s=(n??0)>50||/charg|laden|lädt/.test(o),a=i?.entity_id.startsWith("binary_sensor.")?o==="on":/connect|plug|ready|angesteckt|verbunden|wait|paused|suspend/.test(o),l=s?A(e,"wallbox_charging"):a?A(e,"wallbox_plugged"):i&&!C(i)&&!i.entity_id.startsWith("binary_sensor.")?ie(e,i):"",c=n!==null&&n>50?ce(e,n):"";return[l,c].filter(Boolean).join(" \xB7 ")}stateFaces(e,t){let n=[],i=t.state_entity2&&t.state_entity2!=="none"?[[t.state_entity,t.state_split==="top_bottom"?"bottom":"left"],[t.state_entity2,t.state_split==="top_bottom"?"top":"right"]]:[[t.state_entity,"all"]];for(let[o,s]of i){if(!o||o==="none")continue;let a=e.states[o];if(!a||C(a)||!(ee(a)||a.state==="home"||a.state==="occupied"||a.state==="on"))continue;let c=H(o)==="light"?Te(a):null;n.push({part:s,color:c?c.color:[1,.71,.28],level:c?c.level:.85})}return n}careMarker(e,t,n,i,o){let s=e.states[o];if(!s)return null;let a="",l=!1,c=null;if(i==="bin"){let m=cr(s);a=m===null?ie(e,s):m===0?A(e,"care_bin_today"):m===1?A(e,"care_bin_tomorrow"):A(e,"care_bin_days",{n:m}),l=m!==null&&m<=1,l&&(c=[1,.72,.28])}else if(i==="mail")l=_a(s),a=A(e,l?"care_mail_yes":"care_mail_no"),l&&(c=[1,.85,.3]);else{let m=ba(s,n.thirsty_below??20);l=!!m?.thirsty,a=m?Number.isFinite(m.moisture)?`${A(e,l?"care_plant_thirsty":"care_plant_ok")} \xB7 ${Math.round(m.moisture)} %`:A(e,l?"care_plant_thirsty":"care_plant_ok"):ie(e,s),l&&(c=[1,.45,.3])}let u=t.rooms.find(m=>m.points.length>=3&&I([n.x,n.z],m.points)),d={bin:"mdi:trash-can-outline",mail:"mdi:mailbox-outline",plant:"mdi:sprout-outline"}[i];return{glow:c,marker:{id:o,floorId:t.id,roomId:u?.id??null,x:n.x,z:n.z,y:To(n)+de(t,n),icon:n.icon?Me(n.icon):Me(d),name:n.name||fe(e,n.type),ownName:n.name||void 0,showName:!!n.show_name,text:a,active:l,unavailable:C(s),glow:null,furnitureId:n.id,show:n.marker??void 0,fromFurniture:!0,care:!0}}}lampMarker(e,t,n,i){let o=i?e.states[i]:void 0,s=(n.extra_lights??[]).map(b=>e.states[b]).filter(b=>!!b),a=s.find(b=>ee(b)),l=Y(n.type),c=Ns[n.type]??l?.light??"floor",u=t.rooms.some(b=>b.points.length>=3&&I([n.x,n.z],b.points)),d=c==="strip"&&!u?en(t,n.x,n.z)+(n.mount_y??0):n.mount_y!=null&&!l?n.mount_y:l||c==="wall"||c==="strip"?de(t,n):c==="table"?Zn(t,n.x,n.z):c==="bollard"||c==="garden"?en(t,n.x,n.z):0,m=t.rooms.find(b=>b.points.length>=3&&I([n.x,n.z],b.points)),h=qn(t,n),g=l?l.mount==="ceiling"?Math.max(.5,d-.15):d+n.h+.2:{ceiling:h-.3,downlight:h-.25,spot:h-.35,panel:h-.25,pendant:Math.max(.6,h-n.h-.25),fan:Math.max(.6,h-n.h-.2),floor:d+n.h+.25,uplight:d+n.h+.25,table:d+n.h+.2,wall:d+n.h+.2,strip:n.upright?d+n.w+.15:Math.max(.3,d-.2),bollard:d+n.h+.25,garden:d+n.h+.25}[c],_={id:i??`lamp:${n.id}`,floorId:t.id,roomId:m?.id??null,x:n.x,z:n.z,y:g,icon:zt("light"),name:n.name||(i?L(e,i):fe(e,n.type)),text:[o&&(ee(o)||!a)?ie(e,o):a?L(e,a.entity_id):"",ln(e,n.values)].filter(Boolean).join(" \xB7 "),readout:!!n.values?.some(b=>b.entity&&b.entity!=="none"),active:(o?ee(o):!1)||!!a,unavailable:o?C(o):!1,glow:o||s.length?Ni(Gs(o,s,n.color_entity&&n.color_entity!=="none"?e.states[n.color_entity]:void 0),n.glow_scale):null,lamp:c,rotation:n.rotation,mirror:!!n.mirror,roll:n.tilt??0,upright:!!n.upright,rise:n.rise??0,size:[n.w,n.d,n.h],base:d,pickable:!!i,furnitureId:n.id,pack:l?n.type:null,lightY:l?l.mount==="ceiling"?d:d+n.h*.85:void 0,ceiling:h,effect:o?.state==="on"?gr(n,Ma(e,n,i)):void 0,variant:n.variant,show:n.marker??void 0,fromFurniture:!0};return o&&i?Wi(e,_,o,!1):_}showPin(e){if(this.furnish&&!e.fromFurniture)return!0;if(e.show==="never"||this.markerMode==="none")return!1;if(e.show==="always")return!0;if(e.show==="active"||this.building?.settings.motion_markers_active&&Vs(this.hass,e.id)){if(!e.active)return!1;if(e.show==="active")return!0}if(this.markersOutside&&!(this.roomId&&e.roomId===this.roomId))return this.markersOutside.includes(Ls(e.id,!!e.lamp));if(this.markerMode==="all")return!0;if(e.lamp)return!1;let t=H(e.id);return t==="light"?!1:e.fromFurniture&&t==="fan"?!0:e.care?e.active:e.id.startsWith("tap:")||e.readout?!0:e.fromFurniture?(e.power??0)>=1||t==="media"&&e.active||!!e.energyDevice&&!!e.text:!0}openingTargets(){let e=new Map;for(let[t,n]of this.openingLinks??[]){let i=n.lock??n.cover??n.contact??n.tilt;i&&e.set(t,i)}return e}downloadStl(){let e=this.viewer?.exportStl(10);if(!e)return;let t=URL.createObjectURL(new Blob([e],{type:"model/stl"})),n=document.createElement("a");n.href=t,n.download=`nextfloor-${new Date().toISOString().slice(0,10)}.stl`,n.click(),setTimeout(()=>URL.revokeObjectURL(t),5e3)}secondBlinds(){let e=new Map;for(let[t,n]of this.openingLinks??[])n.cover2&&!n.lock&&n.cover&&e.set(t,n.cover2);return e}scheduleThumbs(e=600){clearTimeout(this.thumbTimer);let t=this.building?.floors.filter(i=>i.rooms.length).length??0;if(!this.floorThumbs||t<2){this._thumbs=[];return}let n=Math.max(e,this.thumbsAt+(this._low?8e3:4e3)-Date.now());this.thumbTimer=setTimeout(()=>{if(!(!this.viewer||this.dimmed&&this._thumbs.length)){if(document.hidden){this.scheduleThumbs(3e3);return}this.thumbsAt=Date.now(),this._thumbs=this.viewer.floorThumbnails(this.narrowThumbs?104:150,this.narrowThumbs?78:112)}},n)}get narrowThumbs(){return this._narrowStage}renderThumbs(){if(!this._thumbs.length||!this.building||this._phoneStage)return f;let e=new Map(this.building.floors.map(o=>[o.id,o.name])),t=[...this._thumbs].sort((o,s)=>(this.building.floors.find(a=>a.id===s.floorId)?.elevation??0)-(this.building.floors.find(a=>a.id===o.floorId)?.elevation??0)),n=this._thumbsCompact,i=()=>{this._thumbsCompact=!n;try{localStorage.setItem("nextfloor.thumbs_compact",this._thumbsCompact?"1":"0")}catch{}};return p`
${n?"\u25B8":"\u25C2"}
this.fire("floor-tap",{floorId:null})}>
@@ -1596,12 +1596,12 @@ ${t.sources.map(n=>this.hass.states[n]?.attributes.symcon_path||this.hass.states
${n?f:p` `}
${e.get(o.floorId)??""}
`)}
- `}onDeviceHold(e,t,n){let i=F(e);i==="light"||i==="cover"||i==="switch"||i==="fan"||i==="lock"?this._menu={entity:e,x:t,y:n}:be(this,e)}onDeviceSwipe(e,t,n,i,o){let s=this.hass?.states[e];if(t==="start"){if(!s||I(s)||this.confirmSet.has(e))return!1;let l=F(e);if(l==="light"&&Mo(s).dim){let c=s.state==="on"?typeof s.attributes.brightness=="number"?Math.round(s.attributes.brightness/2.55):100:0;return this._swipe={entity:e,kind:"light",start:c,value:c,x:i,y:o},!0}if(l==="fan"&&typeof s.attributes.percentage_step=="number"){let c=s.state==="on"&&typeof s.attributes.percentage=="number"?s.attributes.percentage:0;return this._swipe={entity:e,kind:"fan",start:c,value:c,x:i,y:o},!0}if(l==="cover"&&Ao(s)){let c=s.attributes.current_position;return this._swipe={entity:e,kind:"cover",start:c,value:c,x:i,y:o},!0}return!1}let a=this._swipe;if(!a||a.entity!==e)return!1;if(t==="move"){let l=Math.round(Math.min(100,Math.max(0,a.start-n/220*100)));l!==a.value&&(this._swipe={...a,value:l});let c=performance.now();c-this.swipeSent>350&&(this.swipeSent=c,this.applySwipe())}else this.applySwipe(),clearTimeout(this.swipeTimer),this.swipeTimer=setTimeout(()=>this._swipe=null,700);return!0}applySwipe(){let e=this._swipe;!e||!this.hass||(e.kind==="light"?e.value<=0?this.hass.callService("light","turn_off",{entity_id:e.entity}):this.hass.callService("light","turn_on",{entity_id:e.entity,brightness_pct:e.value}):e.kind==="fan"?e.value<=0?this.hass.callService("fan","turn_off",{entity_id:e.entity}):this.hass.callService("fan","set_percentage",{entity_id:e.entity,percentage:e.value}):this.hass.callService("cover","set_cover_position",{entity_id:e.entity,position:e.value}))}openRoom(e,t){this.floorId===e&&this.roomId===t||(this.floorId!==e?(this.fire("floor-tap",{floorId:e}),setTimeout(()=>this.fire("room-tap",{floorId:e,roomId:t}),60)):this.fire("room-tap",{floorId:e,roomId:t}))}goTo(e){if(this._find=null,e.kind==="room"||e.kind==="circuit"){e.roomId&&this.openRoom(e.floorId,e.roomId);return}this.floorId!==e.floorId&&this.fire("floor-tap",{floorId:e.floorId}),setTimeout(()=>this.viewer?.focus(e.floorId,e.x,e.z,e.y,e.entity),120)}listenToAnnouncements(e){if(!e){this.stopAnnouncements?.(),this.stopAnnouncements=null,clearTimeout(this.announceTimer);return}if(this.stopAnnouncements)return;let t=!1;this.stopAnnouncements=()=>t=!0,Ia(this.hass,n=>this.announce(n)).then(n=>{t?n():this.stopAnnouncements=n})}announce(e){let t=e;if(t?.reload===!0){(!t.template||t.template===this.templateName)&&setTimeout(()=>location.reload(),500+Math.random()*6e3);return}if(typeof e?.message!="string"||!e.message.trim()||!Da(e,this.screenName)||!Fa(e))return;let n=Ha(e.message);this._announcement={message:e.message,until:Date.now()+n},clearTimeout(this.announceTimer),this.announceTimer=setTimeout(()=>this._announcement=null,n),Pa(this.hass,e)}renderAnnouncement(){let e=this._announcement;return e?p`this._announcement=null}>
+ `}onDeviceHold(e,t,n){let i=H(e);i==="light"||i==="cover"||i==="switch"||i==="fan"||i==="lock"?this._menu={entity:e,x:t,y:n}:be(this,e)}onDeviceSwipe(e,t,n,i,o){let s=this.hass?.states[e];if(t==="start"){if(!s||C(s)||this.confirmSet.has(e))return!1;let l=H(e);if(l==="light"&&Ao(s).dim){let c=s.state==="on"?typeof s.attributes.brightness=="number"?Math.round(s.attributes.brightness/2.55):100:0;return this._swipe={entity:e,kind:"light",start:c,value:c,x:i,y:o},!0}if(l==="fan"&&typeof s.attributes.percentage_step=="number"){let c=s.state==="on"&&typeof s.attributes.percentage=="number"?s.attributes.percentage:0;return this._swipe={entity:e,kind:"fan",start:c,value:c,x:i,y:o},!0}if(l==="cover"&&Eo(s)){let c=s.attributes.current_position;return this._swipe={entity:e,kind:"cover",start:c,value:c,x:i,y:o},!0}return!1}let a=this._swipe;if(!a||a.entity!==e)return!1;if(t==="move"){let l=Math.round(Math.min(100,Math.max(0,a.start-n/220*100)));l!==a.value&&(this._swipe={...a,value:l});let c=performance.now();c-this.swipeSent>350&&(this.swipeSent=c,this.applySwipe())}else this.applySwipe(),clearTimeout(this.swipeTimer),this.swipeTimer=setTimeout(()=>this._swipe=null,700);return!0}applySwipe(){let e=this._swipe;!e||!this.hass||(e.kind==="light"?e.value<=0?this.hass.callService("light","turn_off",{entity_id:e.entity}):this.hass.callService("light","turn_on",{entity_id:e.entity,brightness_pct:e.value}):e.kind==="fan"?e.value<=0?this.hass.callService("fan","turn_off",{entity_id:e.entity}):this.hass.callService("fan","set_percentage",{entity_id:e.entity,percentage:e.value}):this.hass.callService("cover","set_cover_position",{entity_id:e.entity,position:e.value}))}openRoom(e,t){this.floorId===e&&this.roomId===t||(this.floorId!==e?(this.fire("floor-tap",{floorId:e}),setTimeout(()=>this.fire("room-tap",{floorId:e,roomId:t}),60)):this.fire("room-tap",{floorId:e,roomId:t}))}goTo(e){if(this._find=null,e.kind==="room"||e.kind==="circuit"){e.roomId&&this.openRoom(e.floorId,e.roomId);return}this.floorId!==e.floorId&&this.fire("floor-tap",{floorId:e.floorId}),setTimeout(()=>this.viewer?.focus(e.floorId,e.x,e.z,e.y,e.entity),120)}listenToAnnouncements(e){if(!e){this.stopAnnouncements?.(),this.stopAnnouncements=null,clearTimeout(this.announceTimer);return}if(this.stopAnnouncements)return;let t=!1;this.stopAnnouncements=()=>t=!0,Ca(this.hass,n=>this.announce(n)).then(n=>{t?n():this.stopAnnouncements=n})}announce(e){let t=e;if(t?.reload===!0){(!t.template||t.template===this.templateName)&&setTimeout(()=>location.reload(),500+Math.random()*6e3);return}if(typeof e?.message!="string"||!e.message.trim()||!Fa(e,this.screenName)||!Ha(e))return;let n=Pa(e.message);this._announcement={message:e.message,until:Date.now()+n},clearTimeout(this.announceTimer),this.announceTimer=setTimeout(()=>this._announcement=null,n),Ia(this.hass,e)}renderAnnouncement(){let e=this._announcement;return e?p`this._announcement=null}>
📢 ${e.message}
`:f}renderAlerts(){let e=this.building;if(!this._alerts.length||!e)return f;let t=this._alerts.slice(0,3);return p`
- ${t.map(n=>p`this.jumpTo(n)}>${oo(this.hass,e,n)} `)}
+ ${t.map(n=>p`this.jumpTo(n)}>${so(this.hass,e,n)} `)}
${this._alerts.length>3?p`+${this._alerts.length-3} `:f}
-
`}renderScenes(){let e=this.building;if(!this.scenes||!this.roomId||this.panelOpen||!e||!this.hass)return f;let t=e.floors.flatMap(o=>o.rooms).find(o=>o.id===this.roomId),n=t?K(this.hass,t).filter(o=>F(o)==="scene"||F(o)==="script").slice(0,6):[];if(!n.length)return f;let i=t?.area_id?this.hass.areas?.[t.area_id]?.name:void 0;return p`
+
`}renderScenes(){let e=this.building;if(!this.scenes||!this.roomId||this.panelOpen||!e||!this.hass)return f;let t=e.floors.flatMap(o=>o.rooms).find(o=>o.id===this.roomId),n=t?K(this.hass,t).filter(o=>H(o)==="scene"||H(o)==="script").slice(0,6):[];if(!n.length)return f;let i=t?.area_id?this.hass.areas?.[t.area_id]?.name:void 0;return p`
${n.map(o=>p`this.runScene(o)}>${L(this.hass,o,i)} `)}
`}renderFind(){let e=this.building;if(!e||!this.hass)return f;if(this._find===null)return p`this._find=""}>
@@ -1616,7 +1616,7 @@ ${t.sources.map(n=>this.hass.states[n]?.attributes.symcon_path||this.hass.states
this._find=null}>✕
${this._find.trim()?p`
${t.length?t.map(n=>p`
this.goTo(n)}>
-
+
${n.name} ${n.where?p`${n.where} `:f}
`):p`
${A(this.hass,"find_none")}
`}
`:f}
@@ -1628,7 +1628,7 @@ ${t.sources.map(n=>this.hass.states[n]?.attributes.symcon_path||this.hass.states
@click=${()=>{this._central=!this._central,this._armed=null}}
>
- `;if(!this._central)return i;let o=this.floorId?e.floors.find(b=>b.id===this.floorId):void 0,s=o?[o]:e.floors,a=s.flatMap(b=>Ri(t,b).lights),l=s.flatMap(b=>Ri(t,b).covers),c=a.filter(b=>t.states[b]?.state==="on").length,u=!o,d=(b,v,k,S)=>{if(S.length){if(u&&this._armed!==b){this._armed=b,clearTimeout(this.armTimer),this.armTimer=setTimeout(()=>this._armed=null,3500);return}this._armed=null,t.callService(v,k,{entity_id:S})}},m=(b,v,k,S,M)=>p`d(b,k,S,M)}>
+ `;if(!this._central)return i;let o=this.floorId?e.floors.find(b=>b.id===this.floorId):void 0,s=o?[o]:e.floors,a=s.flatMap(b=>zi(t,b).lights),l=s.flatMap(b=>zi(t,b).covers),c=a.filter(b=>t.states[b]?.state==="on").length,u=!o,d=(b,v,k,S)=>{if(S.length){if(u&&this._armed!==b){this._armed=b,clearTimeout(this.armTimer),this.armTimer=setTimeout(()=>this._armed=null,3500);return}this._armed=null,t.callService(v,k,{entity_id:S})}},m=(b,v,k,S,$)=>p`d(b,k,S,$)}>
${this._armed===b?n("central_sure"):n(v)}
`,h=e.settings.favorite_floors??{},g=(e.settings.favorites??[]).filter(b=>t.states[b]&&(!h[b]||!o||h[b]===o.id)),_=this.buttons??e.settings.buttons??[];return p`${i}
@@ -1645,10 +1645,10 @@ ${t.sources.map(n=>this.hass.states[n]?.attributes.symcon_path||this.hass.states
`:f}
${n("central_favorites")}
${g.length?p`
- ${g.map(b=>{let[v,k]=ma(b),S=t.states[b],M=v==="homeassistant"&&S?.state==="on";return p`
{let[v,k]=pa(b),S=t.states[b],$=v==="homeassistant"&&S?.state==="on";return p`{t.callService(v,k,{entity_id:b}),this._sceneFired=b,setTimeout(()=>this._sceneFired=null,600)}}
>
${L(t,b)}
@@ -1657,13 +1657,13 @@ ${t.sources.map(n=>this.hass.states[n]?.attributes.symcon_path||this.hass.states
${_.length?p`
${_.map(b=>p`{zi(t,v.currentTarget,b),b.action!=="service"&&(this._central=!1)}}
+ aria-pressed=${fa(t,b)}
+ @click=${v=>{Ti(t,v.currentTarget,b),b.action!=="service"&&(this._central=!1)}}
>
${b.icon?p` `:f}${b.label}
`)}
`:f}
- `}toggleLock(){this._locked=!this._locked;try{localStorage.setItem(uu,this._locked?"1":"0")}catch{}}async openTravel(e){if(clearInterval(this.travelTimer),this.travelTimer=void 0,e===null||!this.hass){this._travel=null,this.syncDevices(!0);return}let t=Date.now(),n=t-e*36e5;this._travel={history:new Map,from:n,to:t,t:n,playing:!1,speed:e>24?3600:600,hours:e,moments:[],loading:!0};try{let i=await gn(this.hass,Cl(this.watched),n,t);if(!this._travel||this._travel.from!==n)return;this._travel={...this._travel,history:i,moments:Nl(i,n,t),loading:!1}}catch{this._travel=null,this._error=A(this.hass,"travel_failed");return}this.syncDevices(!0)}travelTo(e){let t=this._travel;t&&(this._travel={...t,t:Math.min(t.to,Math.max(t.from,e))},this.syncDevices(!0))}playTravel(e){let t=this._travel;t&&(clearInterval(this.travelTimer),this.travelTimer=void 0,this._travel={...t,playing:e,t:e&&t.t>=t.to?t.from:t.t},e&&(this.travelTimer=setInterval(()=>{let n=this._travel;if(!n)return;let i=n.t+250*n.speed;i>=n.to&&this.playTravel(!1),this.travelTo(i)},250)))}renderTravel(){if(!this.hass||this.clean)return f;let e=a=>A(this.hass,a),t=this._travel;if(!t)return this.travelButton?p`{this.openTravel(24)}}>⏪ `:f;let n=this.hass.language??navigator.language,i=new Intl.DateTimeFormat(n,{weekday:"short",hour:"2-digit",minute:"2-digit"}).format(new Date(t.t)),o=t.to-t.from||1,s=[[60,"travel_speed_min"],[600,"travel_speed_10min"],[3600,"travel_speed_hour"]];return p`
+
`}toggleLock(){this._locked=!this._locked;try{localStorage.setItem(uu,this._locked?"1":"0")}catch{}}async openTravel(e){if(clearInterval(this.travelTimer),this.travelTimer=void 0,e===null||!this.hass){this._travel=null,this.syncDevices(!0);return}let t=Date.now(),n=t-e*36e5;this._travel={history:new Map,from:n,to:t,t:n,playing:!1,speed:e>24?3600:600,hours:e,moments:[],loading:!0};try{let i=await _n(this.hass,Cl(this.watched),n,t);if(!this._travel||this._travel.from!==n)return;this._travel={...this._travel,history:i,moments:Nl(i,n,t),loading:!1}}catch{this._travel=null,this._error=A(this.hass,"travel_failed");return}this.syncDevices(!0)}travelTo(e){let t=this._travel;t&&(this._travel={...t,t:Math.min(t.to,Math.max(t.from,e))},this.syncDevices(!0))}playTravel(e){let t=this._travel;t&&(clearInterval(this.travelTimer),this.travelTimer=void 0,this._travel={...t,playing:e,t:e&&t.t>=t.to?t.from:t.t},e&&(this.travelTimer=setInterval(()=>{let n=this._travel;if(!n)return;let i=n.t+250*n.speed;i>=n.to&&this.playTravel(!1),this.travelTo(i)},250)))}renderTravel(){if(!this.hass||this.clean)return f;let e=a=>A(this.hass,a),t=this._travel;if(!t)return this.travelButton?p`{this.openTravel(24)}}>⏪ `:f;let n=this.hass.language??navigator.language,i=new Intl.DateTimeFormat(n,{weekday:"short",hour:"2-digit",minute:"2-digit"}).format(new Date(t.t)),o=t.to-t.from||1,s=[[60,"travel_speed_min"],[600,"travel_speed_10min"],[3600,"travel_speed_hour"]];return p`
this.playTravel(!t.playing)}>${t.playing?"\u23F8":"\u25B6"}
${t.loading?e("travel_loading"):i}
@@ -1699,7 +1699,7 @@ ${t.sources.map(n=>this.hass.states[n]?.attributes.symcon_path||this.hass.states
${L(this.hass,e.entity)}
${t?A(this.hass,"swipe_off"):`${e.value} %`}
-
`}tapPlate(e,t,n){let i=this.building?.floors.flatMap(s=>s.furniture).find(s=>s.id===e),o=i?Ti(i.gang_entities,Y(i.type)?.gangs??0):[];if(o.length===1)return this.onDeviceTap(o[0],t,n);o.length>1&&(this._plate={ids:o,x:t,y:n})}renderPlate(){let e=this._plate;if(!e||!this.hass)return f;let t=this.hass,n=()=>this._plate=null;return p`
+
`}tapPlate(e,t,n){let i=this.building?.floors.flatMap(s=>s.furniture).find(s=>s.id===e),o=i?Di(i.gang_entities,Y(i.type)?.gangs??0):[];if(o.length===1)return this.onDeviceTap(o[0],t,n);o.length>1&&(this._plate={ids:o,x:t,y:n})}renderPlate(){let e=this._plate;if(!e||!this.hass)return f;let t=this.hass,n=()=>this._plate=null;return p`
`}renderMenu(){let e=this._menu;if(!e||!this.hass)return f;let t=this.renderRoot.querySelector(".nf-stage"),n=t?.clientWidth??800,i=t?.clientHeight??600,o=Math.max(8,Math.min(n-240,e.x-116)),s=Math.max(8,Math.min(i-360,e.y-170));return p`
@@ -1712,12 +1712,12 @@ ${t.sources.map(n=>this.hass.states[n]?.attributes.symcon_path||this.hass.states
.presets=${(this.building?.settings.media_presets??[]).filter(a=>!a.speakers?.length||a.speakers.includes(e.entity))}
?confirmSwitch=${this.confirmSet.has(e.entity)}
.myPosition=${this.myPositionOf(e.entity)}
- .tiltEntity=${cr(this.hass,this.building?.floors??[],e.entity)}
+ .tiltEntity=${ur(this.hass,this.building?.floors??[],e.entity)}
@close=${()=>this._menu=null}
- >`}myPositionOf(e){for(let t of this.building?.floors??[])for(let n of t.openings){let i=this.openingLinks?.get(n.id);if(n.my_position!=null&&(i?.cover===e||i?.cover2===e))return n.my_position}return null}onDeviceTap(e,t=0,n=0){if(e.startsWith("lamp:")||this._travel)return;let i=e.startsWith("tap:")?e.slice(4):this.tapPins.get(e);if(i){let s=this.building?.floors.flatMap(a=>a.furniture).find(a=>a.id===i);s?.tap&&zi(this.hass,this,s.tap);return}if(this.pluginTapped(e))return;if(e.startsWith("gang:"))return this.tapPlate(e.slice(5),t,n);if(e.startsWith("outdoor:")){this.fire("room-tap",{floorId:null,roomId:"nf-outside"});return}if(e==="grid"){let s=this.building,a=s?s.energy.grid??Ne(s,l=>this.furnitureLinks?.get(l.id)?.power??null).grid:null;a&&be(this,a);return}let o=F(e);if(o==="cover"||o==="media"){this._menu={entity:e,x:t,y:n};return}if(o==="lock"){let s=Mi(this.hass,e),a=L(this.hass,e);confirm(A(this.hass,s?"lock_confirm_lock":"lock_confirm_unlock",{name:a}))&&this.hass.callService("lock",s?"lock":"unlock",{entity_id:e});return}if(o&&Ls.has(o)){if(this.confirmSet.has(e)&&!confirm(A(this.hass,"confirm_switch",{name:L(this.hass,e)})))return;Ra(this.hass,e)}else be(this,e)}pluginTapped(e){let t=this.hass?.states[e],n=this.placementInfo.get(e);if(!t||!n)return!1;let i=this.building?.floors.find(o=>o.id===n.floorId)?.placements.find(o=>o.entity_id===e);return vs({hass:this.hass,entityId:e,state:t},n,i?.plugin??void 0,{showWindow:(o,s)=>{o&&"hass"in o&&(o.hass=this.hass),this._pluginWindow=o?{node:o,title:s?.title??""}:null},moreInfo:o=>be(this,o??e)})}renderPluginWindow(){let e=this._pluginWindow;return e?p`t.stopPropagation()}>
+ >`}myPositionOf(e){for(let t of this.building?.floors??[])for(let n of t.openings){let i=this.openingLinks?.get(n.id);if(n.my_position!=null&&(i?.cover===e||i?.cover2===e))return n.my_position}return null}onDeviceTap(e,t=0,n=0){if(e.startsWith("lamp:")||this._travel)return;let i=e.startsWith("tap:")?e.slice(4):this.tapPins.get(e);if(i){let s=this.building?.floors.flatMap(a=>a.furniture).find(a=>a.id===i);s?.tap&&Ti(this.hass,this,s.tap);return}if(this.pluginTapped(e))return;if(e.startsWith("gang:"))return this.tapPlate(e.slice(5),t,n);if(e.startsWith("outdoor:")){this.fire("room-tap",{floorId:null,roomId:"nf-outside"});return}if(e==="grid"){let s=this.building,a=s?s.energy.grid??Ne(s,l=>this.furnitureLinks?.get(l.id)?.power??null).grid:null;a&&be(this,a);return}let o=H(e);if(o==="cover"||o==="media"){this._menu={entity:e,x:t,y:n};return}if(o==="lock"){let s=Ai(this.hass,e),a=L(this.hass,e);confirm(A(this.hass,s?"lock_confirm_lock":"lock_confirm_unlock",{name:a}))&&this.hass.callService("lock",s?"lock":"unlock",{entity_id:e});return}if(o&&Os.has(o)){if(this.confirmSet.has(e)&&!confirm(A(this.hass,"confirm_switch",{name:L(this.hass,e)})))return;za(this.hass,e)}else be(this,e)}pluginTapped(e){let t=this.hass?.states[e],n=this.placementInfo.get(e);if(!t||!n)return!1;let i=this.building?.floors.find(o=>o.id===n.floorId)?.placements.find(o=>o.entity_id===e);return ws({hass:this.hass,entityId:e,state:t},n,i?.plugin??void 0,{showWindow:(o,s)=>{o&&"hass"in o&&(o.hass=this.hass),this._pluginWindow=o?{node:o,title:s?.title??""}:null},moreInfo:o=>be(this,o??e)})}renderPluginWindow(){let e=this._pluginWindow;return e?p`
t.stopPropagation()}>
${e.title} this._pluginWindow=null}>✕
${e.node}
-
`:f}startViewOf(){return this.startView??this.building?.settings.start_view??null}currentView(){return this.viewer?.currentView()??null}resetView(){this.viewer?.resetView()}fire(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0}))}toggleFlows(){this._flows=!this._flows;try{localStorage.setItem("nextfloor.flows",this._flows?"1":"0")}catch{}this.syncDevices(!0)}liveHeatPumps(e){let t=this.hass;if(!t)return[];let n=[];for(let i of e.floors)for(let o of i.furniture){if(!Nc(o.type))continue;let s=this.furnitureLinks?.get(o.id),a=Cc(t,s?.entity??s?.power??null);a&&n.push({id:o.id,name:o.name||fe(t,o.type),floorId:i.id,x:o.x,z:o.z,at:{floorId:i.id,x:o.x,z:o.z,y:de(i,o)+o.h+.5},pump:a})}return n}livePrinters(e){let t=this.hass,n=[];if(!t)return n;for(let i of e.floors)for(let o of i.furniture){if(!yo(o.type))continue;let s=this.furnitureLinks?.get(o.id),a=wo(t,s?.entity??s?.power??null);!a||!a.printing&&!/pause|finish|complete|error/.test(a.status)||n.push({id:o.id,name:o.name||fe(t,o.type),at:{floorId:i.id,x:o.x,z:o.z,y:de(i,o)+o.h+.5},printer:a})}return n}liveCars(e,t){let n=[];for(let i of t.floors)for(let o of i.furniture){if(o.type!=="parking")continue;let s=Vc(e,o);if(!s||s.soc===null&&s.range===null&&s.locked===null&&s.climateOn===null)continue;let a=so(e,o),l=a?ic(o,a):null,c=o.name||(a?fe(e,a):fe(e,o.type));n.push({spot:o.id,name:c,at:{floorId:i.id,x:o.x,z:o.z,y:de(i,o)+(l?.h??.2)+.6},car:s})}return n}liveMedia(e,t){let n=[];for(let i of t.floors){for(let o of i.furniture){let s=this.furnitureLinks?.get(o.id)?.entity;s?.startsWith("media_player.")&&n.push({entity:s,name:o.name||fe(e,o.type),at:{floorId:i.id,x:o.x,z:o.z,y:de(i,o)+o.h+.15},rings:o.sound_rings})}for(let o of i.placements)o.entity_id.startsWith("media_player.")&&n.push({entity:o.entity_id,name:o.name||L(e,o.entity_id),at:{floorId:i.id,x:o.x,z:o.z,y:(o.y??1.1)+.15},rings:o.sound_rings})}return Vl(e,n)}refreshToday(e){let t=this.hass,n=e.settings.calendars??[],i=Math.max(1,Math.min(7,e.settings.today_days??1)),o=`${new Date().toDateString()}|${i}`;!t||!n.length||Date.now()-this.todayAt<9e5&&o===this.todayDay||(this.todayAt=Date.now(),this.todayDay=o,Dc(t,n,i).then(s=>this._todayItems=s))}refreshForecast(e){let t=this.hass,n=e.settings.forecast&&t?Xe(t,this.weatherEntityId??e.settings.weather_entity):null;if(!t||!n)return;let i=`${n}|${new Date().toDateString()}`;Date.now()-this.forecastAt<18e5&&i===this.forecastKey||(this.forecastAt=Date.now(),this.forecastKey=i,Pc(t,n).then(o=>this._forecast=o))}renderForecast(e){let t=this.building,n=this.hass,i=t?.settings.forecast;if(!t||!n||!i||i.corner!==e||this.clean)return f;if(e==="top_right"&&(this.roomId||this.panelOpen))return f;let o=Hc(this._forecast,Math.max(1,Math.min(7,i.days)));if(!o.length)return f;let s=Xe(n,this.weatherEntityId??t.settings.weather_entity),a=s?n.states[s]?.attributes:void 0,l=String(a?.temperature_unit??"\xB0"),c=String(a?.precipitation_unit??"mm"),u=n.language??navigator.language,d=new Intl.DateTimeFormat(u,{weekday:"short"}),m=h=>h===null?"\u2013":`${Math.round(h)}\xB0`;return p`
`:f}startViewOf(){return this.startView??this.building?.settings.start_view??null}currentView(){return this.viewer?.currentView()??null}resetView(){this.viewer?.resetView()}fire(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0}))}toggleFlows(){this._flows=!this._flows;try{localStorage.setItem("nextfloor.flows",this._flows?"1":"0")}catch{}this.syncDevices(!0)}liveHeatPumps(e){let t=this.hass;if(!t)return[];let n=[];for(let i of e.floors)for(let o of i.furniture){if(!Nc(o.type))continue;let s=this.furnitureLinks?.get(o.id),a=Cc(t,s?.entity??s?.power??null);a&&n.push({id:o.id,name:o.name||fe(t,o.type),floorId:i.id,x:o.x,z:o.z,at:{floorId:i.id,x:o.x,z:o.z,y:de(i,o)+o.h+.5},pump:a})}return n}livePrinters(e){let t=this.hass,n=[];if(!t)return n;for(let i of e.floors)for(let o of i.furniture){if(!xo(o.type))continue;let s=this.furnitureLinks?.get(o.id),a=yo(t,s?.entity??s?.power??null);!a||!a.printing&&!/pause|finish|complete|error/.test(a.status)||n.push({id:o.id,name:o.name||fe(t,o.type),at:{floorId:i.id,x:o.x,z:o.z,y:de(i,o)+o.h+.5},printer:a})}return n}liveCars(e,t){let n=[];for(let i of t.floors)for(let o of i.furniture){if(o.type!=="parking")continue;let s=Vc(e,o);if(!s||s.soc===null&&s.range===null&&s.locked===null&&s.climateOn===null)continue;let a=ao(e,o),l=a?ic(o,a):null,c=o.name||(a?fe(e,a):fe(e,o.type));n.push({spot:o.id,name:c,at:{floorId:i.id,x:o.x,z:o.z,y:de(i,o)+(l?.h??.2)+.6},car:s})}return n}liveMedia(e,t){let n=[];for(let i of t.floors){for(let o of i.furniture){let s=this.furnitureLinks?.get(o.id)?.entity;s?.startsWith("media_player.")&&n.push({entity:s,name:o.name||fe(e,o.type),at:{floorId:i.id,x:o.x,z:o.z,y:de(i,o)+o.h+.15},rings:o.sound_rings})}for(let o of i.placements)o.entity_id.startsWith("media_player.")&&n.push({entity:o.entity_id,name:o.name||L(e,o.entity_id),at:{floorId:i.id,x:o.x,z:o.z,y:(o.y??1.1)+.15},rings:o.sound_rings})}return Vl(e,n)}refreshToday(e){let t=this.hass,n=e.settings.calendars??[],i=Math.max(1,Math.min(7,e.settings.today_days??1)),o=`${new Date().toDateString()}|${i}`;!t||!n.length||Date.now()-this.todayAt<9e5&&o===this.todayDay||(this.todayAt=Date.now(),this.todayDay=o,Dc(t,n,i).then(s=>this._todayItems=s))}refreshForecast(e){let t=this.hass,n=e.settings.forecast&&t?et(t,this.weatherEntityId??e.settings.weather_entity):null;if(!t||!n)return;let i=`${n}|${new Date().toDateString()}`;Date.now()-this.forecastAt<18e5&&i===this.forecastKey||(this.forecastAt=Date.now(),this.forecastKey=i,Pc(t,n).then(o=>this._forecast=o))}renderForecast(e){let t=this.building,n=this.hass,i=t?.settings.forecast;if(!t||!n||!i||i.corner!==e||this.clean)return f;if(e==="top_right"&&(this.roomId||this.panelOpen))return f;let o=Hc(this._forecast,Math.max(1,Math.min(7,i.days)));if(!o.length)return f;let s=et(n,this.weatherEntityId??t.settings.weather_entity),a=s?n.states[s]?.attributes:void 0,l=String(a?.temperature_unit??"\xB0"),c=String(a?.precipitation_unit??"mm"),u=n.language??navigator.language,d=new Intl.DateTimeFormat(u,{weekday:"short"}),m=h=>h===null?"\u2013":`${Math.round(h)}\xB0`;return p`
${o.map((h,g)=>p`
${g===0?A(n,"today"):d.format(new Date(h.day))}
@@ -1733,7 +1733,7 @@ ${t.sources.map(n=>this.hass.states[n]?.attributes.symcon_path||this.hass.states
${o?i.length?p``:p`${A(t,"today_none")}
`:f}
- `}week=null;weekAt=0;refreshWeek(e){let t=this.hass;if(!t||this._travel||Date.now()-this.weekAt<36e5)return;this.weekAt=Date.now();let n=Ne(e,s=>this.furnitureLinks?.get(s.id)?.power??null),i=e.energy,o={solar:i.solar?[i.solar]:n.solar,grid:i.grid??n.grid,gridInvert:!!i.grid_invert,battery:i.battery?[i.battery]:n.battery,batteryInvert:!!i.battery_invert,consumption:i.consumption};Sl(t,o).then(s=>{this.week=s,this.syncDevices(!0)}).catch(()=>this.week=null)}meterRows(e,t=null){let n=this.hass,i=[],o=this.floorId?e.floors.find(a=>a.id===this.floorId):void 0,s=o&&U(n)?ln(n,o,e.floors.flatMap(a=>a.rooms)).find(a=>a.kind==="electricity"&&a.metric==="power"&&a.unit==="W")?.value??null:o?.power_entity?Z(n?.states[o.power_entity]):null;if(o&&s!==null){let a=t&&t>0?` \xB7 ${A(n,"floor_power_share",{n:Math.round(Math.max(0,s)/t*100)})}`:"";i.push({icon:"\u26A1",label:o.name,value:`${mt(n,s)}${a}`})}for(let[a,l,c]of[["gas","\u{1F525}","energy_gas_short"],["water","\u{1F4A7}","energy_water_short"]]){let u=e.energy[a],d=u?n?.states[u]:void 0;d&&!I(d)&&i.push({icon:l,label:A(n,c),value:ie(n,d)})}return i}refreshDayCurves(e){let t=this.hass;if(!t||this._travel||Date.now()-this.curvesAt<6e5)return;this.curvesAt=Date.now();let n=a=>mn(a,e,hn(a,e),Ne(e,l=>this.furnitureLinks?.get(l.id)?.power??null)),i=Wl(t,n),o=Date.now(),s=o-24*36e5;gn(t,i,s,o,!0).then(a=>{this.dayCurves=Ll(t,a,s,o,n),this.syncDevices(!0)}).catch(()=>this.dayCurves=null)}syncLhCards(e,t,n,i,o,s){let a=[],l=n.summary,c=l.solar!==null||l.grid!==null||l.battery!==null||l.consumption!==null,u=Sn(t),d=(this.floorId?t.floors.find(m=>m.id===this.floorId):void 0)??[...t.floors].sort((m,h)=>h.elevation-m.elevation)[0];if(this.liveCardsOn&&!this.dimmed&&!this.roomId&&c&&u&&d){let m=0,h=0,g=0;for(let _ of d.rooms)for(let[b,v]of _.points)m+=b,h+=v,g++;a.push({kind:"house",at:{floorId:d.id,x:g?m/g:u.x,z:g?h/g:u.z,y:d.height+(this.floorId?1.2:3.2)},summary:l,autarky:n.autarky,curves:this.dayCurves??void 0,week:this.week??void 0,meters:this.meterRows(t,l.consumption)}),this.refreshDayCurves(t),this.refreshWeek(t)}if(this.liveCardsOn&&!this.dimmed&&!this.roomId){for(let m of i)a.push({kind:"car",at:m.at,spot:m.spot,name:m.name,car:m.car});for(let m of this.livePrinters(t))a.push({kind:"printer",at:m.at,name:m.name,printer:m.printer});for(let m of this.liveHeatPumps(t))a.push({kind:"heatpump",at:m.at,name:m.name,pump:m.pump});for(let m of o)a.push({kind:"media",at:{...m.at,y:m.at.y+.5},media:m})}this.liveCardsOn&&!this.dimmed&&a.push(...Mc(s,t,this.floorId,this.roomId)),JSON.stringify(a)!==JSON.stringify(this._liveCards)&&(this._liveCards=a),e.setLiveAnchors(a.map(m=>m.at),a.length?(m,h,g,_)=>this.placeLhCard(m,h,g,_):null)}placeLhCard(e,t,n,i){let o=this.renderRoot.querySelector(`.live-card[data-i="${e}"]`);o&&(o.dataset.x=String(t),o.dataset.y=String(n),o.style.visibility=i?"visible":"hidden",e===this._liveCards.length-1&&Gc(this.renderRoot))}toggleHouseFold(){this._houseFolded=!this._houseFolded;try{localStorage.setItem("nextfloor.house_card_folded",this._houseFolded?"1":"0")}catch{}}toggleLhCards(){this._liveCardOn=!this._liveCardOn;try{localStorage.setItem("nextfloor.cards",this._liveCardOn?"1":"0")}catch{}this.syncDevices(!0)}renderTopLeft(){let e=this.clean?f:this.renderLhEnergy(),t=this.renderForecast("top_left");return this.clock!=="top_left"&&t===f||!this.hass?e:p`${this.clock==="top_left"?this.renderClock(!0):f}${e}${t}
`}renderLhEnergy(){let e=this.ownSensors(),t=this._liveEnergy?.summary,n=!!t&&!this.roomId&&this.showEnergy&&!!this.hass&&!(t.consumption===null&&t.grid===null&&t.solar===null&&t.battery===null),o=this.building?.floors.some(c=>c.rooms.some(u=>u.climate_card))?this.renderCardToggle():f,s=this.roomNamesButton?p`{this.roomLabels=!this.roomLabels,this.dispatchEvent(new CustomEvent("room-names-change",{detail:{value:this.roomLabels},bubbles:!0,composed:!0}))}}>${A(this.hass,"room_names_short")} Aa `:f;if(!n)return e.length||o!==f||s!==f?p`${s}${e}${o}
`:f;let a=c=>A(this.hass,c),l=[];if(t.solar!==null&&l.push({cls:"solar",label:a("energy_solar"),value:ce(this.hass,t.solar)}),t.consumption!==null&&l.push({cls:"total",label:a("energy_consumption"),value:ce(this.hass,t.consumption)}),t.rest!==void 0&&t.rest!==null&&l.push({cls:"total",label:a("energy_rest"),value:ce(this.hass,t.rest)}),t.battery!==null||t.soc!==null){let c=[t.battery!==null?ce(this.hass,Math.abs(t.battery)):null,t.soc!==null?`${Math.round(t.soc)} %`:null].filter(Boolean);l.push({cls:"battery",label:a("energy_battery"),value:c.join(" \xB7 ")})}if(t.grid!==null){let c=t.grid<0;l.push({cls:c?"export":"grid",label:a(c?"energy_grid_export":"energy_grid_import"),value:ce(this.hass,Math.abs(t.grid))})}if(t.tariff&&l.push({cls:"tariff",label:a("energy_tariff"),value:`${W(this.hass,t.tariff.value,3)} ${t.tariff.unit}`.trim()}),this.building)for(let c of this.meterRows(this.building))l.push({cls:"meter",label:`${c.icon} ${c.label}`,value:c.value});return p`
+ `}week=null;weekAt=0;refreshWeek(e){let t=this.hass;if(!t||this._travel||Date.now()-this.weekAt<36e5)return;this.weekAt=Date.now();let n=Ne(e,s=>this.furnitureLinks?.get(s.id)?.power??null),i=e.energy,o={solar:i.solar?[i.solar]:n.solar,grid:i.grid??n.grid,gridInvert:!!i.grid_invert,battery:i.battery?[i.battery]:n.battery,batteryInvert:!!i.battery_invert,consumption:i.consumption};Sl(t,o).then(s=>{this.week=s,this.syncDevices(!0)}).catch(()=>this.week=null)}meterRows(e,t=null){let n=this.hass,i=[],o=this.floorId?e.floors.find(l=>l.id===this.floorId):void 0,s=o&&G(n)?cn(n,o,e.floors.flatMap(l=>l.rooms)).find(l=>l.kind==="electricity"&&l.metric==="power"&&l.unit==="W"):void 0,a=G(n)?s?.value??null:o?.power_entity?Z(n?.states[o.power_entity]):null;if(o&&(s||a!==null)){let l=!s?.incomplete&&a!==null&&t&&t>0?` \xB7 ${A(n,"floor_power_share",{n:Math.round(Math.max(0,a)/t*100)})}`:"";i.push({icon:"\u26A1",label:o.name,value:`${s?Qe(n,s):pt(n,a)}${l}`})}for(let[l,c,u]of[["gas","\u{1F525}","energy_gas_short"],["water","\u{1F4A7}","energy_water_short"]]){let d=e.energy[l],m=d?n?.states[d]:void 0;m&&!C(m)&&i.push({icon:c,label:A(n,u),value:ie(n,m)})}return i}refreshDayCurves(e){let t=this.hass;if(!t||this._travel||Date.now()-this.curvesAt<6e5)return;this.curvesAt=Date.now();let n=a=>pn(a,e,mn(a,e),Ne(e,l=>this.furnitureLinks?.get(l.id)?.power??null)),i=Wl(t,n),o=Date.now(),s=o-24*36e5;_n(t,i,s,o,!0).then(a=>{this.dayCurves=Ll(t,a,s,o,n),this.syncDevices(!0)}).catch(()=>this.dayCurves=null)}syncLhCards(e,t,n,i,o,s){let a=[],l=n.summary,c=l.solar!==null||l.grid!==null||l.battery!==null||l.consumption!==null,u=$n(t),d=(this.floorId?t.floors.find(m=>m.id===this.floorId):void 0)??[...t.floors].sort((m,h)=>h.elevation-m.elevation)[0];if(this.liveCardsOn&&!this.dimmed&&!this.roomId&&c&&u&&d){let m=0,h=0,g=0;for(let _ of d.rooms)for(let[b,v]of _.points)m+=b,h+=v,g++;a.push({kind:"house",at:{floorId:d.id,x:g?m/g:u.x,z:g?h/g:u.z,y:d.height+(this.floorId?1.2:3.2)},summary:l,autarky:n.autarky,curves:this.dayCurves??void 0,week:this.week??void 0,meters:this.meterRows(t,l.consumption)}),this.refreshDayCurves(t),this.refreshWeek(t)}if(this.liveCardsOn&&!this.dimmed&&!this.roomId){for(let m of i)a.push({kind:"car",at:m.at,spot:m.spot,name:m.name,car:m.car});for(let m of this.livePrinters(t))a.push({kind:"printer",at:m.at,name:m.name,printer:m.printer});for(let m of this.liveHeatPumps(t))a.push({kind:"heatpump",at:m.at,name:m.name,pump:m.pump});for(let m of o)a.push({kind:"media",at:{...m.at,y:m.at.y+.5},media:m})}this.liveCardsOn&&!this.dimmed&&a.push(...Mc(s,t,this.floorId,this.roomId)),JSON.stringify(a)!==JSON.stringify(this._liveCards)&&(this._liveCards=a),e.setLiveAnchors(a.map(m=>m.at),a.length?(m,h,g,_)=>this.placeLhCard(m,h,g,_):null)}placeLhCard(e,t,n,i){let o=this.renderRoot.querySelector(`.live-card[data-i="${e}"]`);o&&(o.dataset.x=String(t),o.dataset.y=String(n),o.style.visibility=i?"visible":"hidden",e===this._liveCards.length-1&&Gc(this.renderRoot))}toggleHouseFold(){this._houseFolded=!this._houseFolded;try{localStorage.setItem("nextfloor.house_card_folded",this._houseFolded?"1":"0")}catch{}}toggleLhCards(){this._liveCardOn=!this._liveCardOn;try{localStorage.setItem("nextfloor.cards",this._liveCardOn?"1":"0")}catch{}this.syncDevices(!0)}renderTopLeft(){let e=this.clean?f:this.renderLhEnergy(),t=this.renderForecast("top_left");return this.clock!=="top_left"&&t===f||!this.hass?e:p`
${this.clock==="top_left"?this.renderClock(!0):f}${e}${t}
`}renderLhEnergy(){let e=this.ownSensors(),t=this._liveEnergy?.summary,n=!!t&&!this.roomId&&this.showEnergy&&!!this.hass&&!(t.consumption===null&&t.grid===null&&t.solar===null&&t.battery===null),o=this.building?.floors.some(c=>c.rooms.some(u=>u.climate_card))?this.renderCardToggle():f,s=this.roomNamesButton?p`
{this.roomLabels=!this.roomLabels,this.dispatchEvent(new CustomEvent("room-names-change",{detail:{value:this.roomLabels},bubbles:!0,composed:!0}))}}>${A(this.hass,"room_names_short")} Aa `:f;if(!n)return e.length||o!==f||s!==f?p`
${s}${e}${o}
`:f;let a=c=>A(this.hass,c),l=[];if(t.solar!==null&&l.push({cls:"solar",label:a("energy_solar"),value:ce(this.hass,t.solar)}),t.consumption!==null&&l.push({cls:"total",label:a("energy_consumption"),value:ce(this.hass,t.consumption)}),t.rest!==void 0&&t.rest!==null&&l.push({cls:"total",label:a("energy_rest"),value:ce(this.hass,t.rest)}),t.battery!==null||t.soc!==null){let c=[t.battery!==null?ce(this.hass,Math.abs(t.battery)):null,t.soc!==null?`${Math.round(t.soc)} %`:null].filter(Boolean);l.push({cls:"battery",label:a("energy_battery"),value:c.join(" \xB7 ")})}if(t.grid!==null){let c=t.grid<0;l.push({cls:c?"export":"grid",label:a(c?"energy_grid_export":"energy_grid_import"),value:ce(this.hass,Math.abs(t.grid))})}if(t.tariff&&l.push({cls:"tariff",label:a("energy_tariff"),value:`${W(this.hass,t.tariff.value,3)} ${t.tariff.unit}`.trim()}),this.building)for(let c of this.meterRows(this.building))l.push({cls:"meter",label:`${c.icon} ${c.label}`,value:c.value});return p`
${s}
${this.liveCardsOn&&this._liveCards.some(c=>c.kind==="house")?f:l.map(c=>p`
${c.label} ${c.value}
`)}
${this.flows!==null?f:p`
this.toggleFlows()}>
@@ -1743,22 +1743,22 @@ ${t.sources.map(n=>this.hass.states[n]?.attributes.symcon_path||this.hass.states
${e}
`}renderCardToggle(){return this.holograms!==null?f:p`
this.toggleLhCards()}>
${A(this.hass,"holos")} ◫
- `}ownSensors(){let e=this.sensorBar&&this.hass?this.building?.settings.status_entities??[]:[],t=U(this.hass)?(this.building?.presence??[]).filter(a=>Wa(this.hass,a.person,[0])).map(a=>p`
${a.name||L(this.hass,a.person)} ${oe(this.hass.states[a.person])===null?"\u2013":oe(this.hass.states[a.person])?"Anwesend":"Abwesend"}
`):[],n=U(this.hass)?Object.entries(this.building?.settings.weather_variables??{}).filter(a=>!!a[1]&&a[1]!=="none").map(([a,l])=>[iu[a]||a,l]):[];U(this.hass)&&this.building?.settings.rain_sensor&&this.building.settings.rain_sensor!=="none"&&n.push(["Regensensor",this.building.settings.rain_sensor]);let i=n.length?p`
this.renderRoot.querySelector(".nf-weather-dialog")?.showModal()}>Wetter ⛅
-
a.stopPropagation()}>Wetter this.renderRoot.querySelector(".nf-weather-dialog")?.close()}>× ${n.map(([a,l])=>p`${a} ${Je(this.hass.states[l])}
`)} `:f,o=U(this.hass)?(this.building?.floors??[]).filter(a=>!this.floorId||a.id===this.floorId).map(a=>({floor:a,readings:ln(this.hass,a,this.building?.floors.flatMap(l=>l.rooms))})).filter(a=>a.readings.length):[],s=o.length?p`
this.renderRoot.querySelector(".nf-utility-dialog")?.showModal()}>Stockwerkszähler ⚡ 💧
+ `}ownSensors(){let e=this.sensorBar&&this.hass?this.building?.settings.status_entities??[]:[],t=G(this.hass)?(this.building?.presence??[]).filter(a=>La(this.hass,a.person,[0])).map(a=>p`
${a.name||L(this.hass,a.person)} ${oe(this.hass.states[a.person])===null?"\u2013":oe(this.hass.states[a.person])?"Anwesend":"Abwesend"}
`):[],n=G(this.hass)?Object.entries(this.building?.settings.weather_variables??{}).filter(a=>!!a[1]&&a[1]!=="none").map(([a,l])=>[iu[a]||a,l]):[];G(this.hass)&&this.building?.settings.rain_sensor&&this.building.settings.rain_sensor!=="none"&&n.push(["Regensensor",this.building.settings.rain_sensor]);let i=n.length?p`
this.renderRoot.querySelector(".nf-weather-dialog")?.showModal()}>Wetter ⛅
+
a.stopPropagation()}>Wetter this.renderRoot.querySelector(".nf-weather-dialog")?.close()}>× ${n.map(([a,l])=>p`${a} ${Je(this.hass.states[l])}
`)} `:f,o=G(this.hass)?(this.building?.floors??[]).filter(a=>!this.floorId||a.id===this.floorId).map(a=>({floor:a,readings:cn(this.hass,a,this.building?.floors.flatMap(l=>l.rooms))})).filter(a=>a.readings.length):[],s=o.length?p`
this.renderRoot.querySelector(".nf-utility-dialog")?.showModal()}>Stockwerkszähler ⚡ 💧
a.stopPropagation()}>Stockwerkszähler this.renderRoot.querySelector(".nf-utility-dialog")?.close()}>× ${o.map(({floor:a,readings:l})=>p`${a.name} `)} `:f;return[...t,i,s,...e.filter(a=>this.hass.states[a]).map(a=>p`
be(this,a)}>
${L(this.hass,a)} ${ie(this.hass,this.hass.states[a])}
- `)]}renderMapCredit(){let e=this.building?.settings.map;return uc(e)?p`
${co(e).text} `:f}renderLegend(){if(this.heatMode==="wifi")return this.renderWifiLegend();if(this.heatMode==="none"||this.heatMode==="values")return f;let e=ht(new Date,this.hass?.config?.latitude??50),t=kr(this.heatMode,e),n=this.heatMode==="temperature",i=n?se(this.hass,t.stops[0][0]):t.stops[0][0],o=n?se(this.hass,t.stops[t.stops.length-1][0]):t.stops[t.stops.length-1][0],s=n?ne(this.hass):t.unit,a=l=>A(this.hass,l);return p`
+ `)]}renderMapCredit(){let e=this.building?.settings.map;return uc(e)?p`
${uo(e).text} `:f}renderLegend(){if(this.heatMode==="wifi")return this.renderWifiLegend();if(this.heatMode==="none"||this.heatMode==="values")return f;let e=mt(new Date,this.hass?.config?.latitude??50),t=Sr(this.heatMode,e),n=this.heatMode==="temperature",i=n?se(this.hass,t.stops[0][0]):t.stops[0][0],o=n?se(this.hass,t.stops[t.stops.length-1][0]):t.stops[t.stops.length-1][0],s=n?ne(this.hass):t.unit,a=l=>A(this.hass,l);return p`
${a(`heat_${this.heatMode}`)}${this.heatMode==="temperature"?p` ${a(e?"heat_summer":"heat_winter")} `:f}
${W(this.hass,i,0)} ${s} ${W(this.hass,o,0)} ${s}
${this.heatValues.size?f:p`${a("heat_none_found")} `}
-
`}renderWifiLegend(){let e=this.hass,t=this.building;if(!e||!t)return f;let n=(c,u)=>A(e,c,u),i=t.floors.flatMap(c=>c.furniture.filter(u=>xo(u.type)).map(u=>ko(e,this.furnitureLinks?.get(u.id)?.entity??this.furnitureLinks?.get(u.id)?.power??null))),s=i.filter(c=>!!c).reduce((c,u)=>c+(u.clients??0),0),a=t.floors.flatMap(c=>c.placements.map(u=>e.states[u.entity_id])),l=Oc(a);return p`
+
`}renderWifiLegend(){let e=this.hass,t=this.building;if(!e||!t)return f;let n=(c,u)=>A(e,c,u),i=t.floors.flatMap(c=>c.furniture.filter(u=>ko(u.type)).map(u=>So(e,this.furnitureLinks?.get(u.id)?.entity??this.furnitureLinks?.get(u.id)?.power??null))),s=i.filter(c=>!!c).reduce((c,u)=>c+(u.clients??0),0),a=t.floors.flatMap(c=>c.placements.map(u=>e.states[u.entity_id])),l=Oc(a);return p`
📶 ${n("heat_wifi")}
${n("wifi_aps",{n:i.length,clients:s})}
${l.online+l.offline.length?p`${n("wifi_network",{online:l.online,offline:l.offline.length})} `:f}
${l.offline.length?p`${l.offline.slice(0,4).join(", ")} `:f}
${i.length?f:p`${n("wifi_none")} `}
-
`}skyColor(){let e=bn[this.theme]??bn.neon,t=this._sky;return e.night[0].map((n,i)=>Math.round(n+(e.day[0][i]-n)*t))}render(){let e=this._sky,t=(o,s)=>`rgb(${o.map((a,l)=>Math.round(a+(s[l]-a)*e)).join(",")})`,n=bn[this.theme]??bn.neon,i=`--nf-sky:${t(n.night[0],n.day[0])};--nf-ground:${t(n.night[1],n.day[1])}`+Ol(this.building?.settings.backdrop);return p`
`}skyColor(){let e=vn[this.theme]??vn.neon,t=this._sky;return e.night[0].map((n,i)=>Math.round(n+(e.day[0][i]-n)*t))}render(){let e=this._sky,t=(o,s)=>`rgb(${o.map((a,l)=>Math.round(a+(s[l]-a)*e)).join(",")})`,n=vn[this.theme]??vn.neon,i=`--nf-sky:${t(n.night[0],n.day[0])};--nf-ground:${t(n.night[1],n.day[1])}`+Ol(this.building?.settings.backdrop);return p`
@@ -3354,14 +3354,14 @@ ${t.sources.map(n=>this.hass.states[n]?.attributes.symcon_path||this.hass.states
inset: auto 16px 16px;
color: var(--nf-danger);
}
- `]};customElements.get("nf-view3d")||customElements.define("nf-view3d",To);function ce(r,e){return Math.abs(e)>=1e3?`${W(r,e/1e3,1)} kW`:`${Math.round(e)} W`}function zo(r){return r.type==="tv_board"?r.h+.9:r.type==="tv_wall"||r.type==="kitchen_wall"?r.h+.25:r.h+.35}function pf(r,e){let t=e.attributes.percentage;return e.state==="on"&&typeof t=="number"?`${Math.round(t)} %`:ie(r,e)}var hu;function mu(){let r=new URL("./nextfloor-editor.js?v=4fd9c94342a9",new URL(import.meta.url)).href;return hu??=import(r),hu}var ff=.25,pu=r=>Math.round(r*1e3)/1e3,fu=(r,e,t)=>r.rooms.find(n=>n.points.length>=3&&P([e,t],n.points));function Fo(r,e,t,n,i){let o=fu(r,e,t);if(!o)return[n,i];let s=(a,l)=>P([a,l],o.points);return s(n,i)?[n,i]:s(n,t)?[n,t]:s(e,i)?[e,i]:[e,t]}function gf(r,e,t,n){return r.rooms.some(i=>i.id!==e.id&&i.points.some((o,s)=>{let a=i.points[(s+1)%i.points.length];return Math.abs(ae(J(o,t),n))<.02&&Math.abs(ae(J(a,t),n))<.02}))}var Do=(r,e)=>Math.abs((r-e+540)%360-180);function gu(r,e,t,n=ff){let i=fu(r,e.x,e.z);if(!i)return null;let o=i.points,s=lt(o)>=0?1:-1,a=null;return o.forEach((l,c)=>{let u=o[(c+1)%o.length],d=Ce(J(u,l));if(d<.3)return;let m=[(u[0]-l[0])/d,(u[1]-l[1])/d],h=[-m[1]*s,m[0]*s],g=ae(J([e.x,e.z],l),m);if(g<0||g>d)return;let _=gf(r,i,l,h)?t/2:0,b=ae(J([e.x,e.z],l),h)-_,v=Math.atan2(-h[0],h[1])*180/Math.PI,S=[{rotation:v,extent:e.d/2},{rotation:v+90,extent:e.w/2},{rotation:v-90,extent:e.w/2}].reduce((T,z)=>Do(e.rotation,z.rotation)
50)return;let M=b-S.extent;Math.abs(M)>n||a&&Math.abs(M)>=Math.abs(a.gap)||(a={x:pu(e.x-h[0]*M),z:pu(e.z-h[1]*M),rotation:(Math.round(S.rotation)%360+360)%360,gap:M})}),a&&{x:a.x,z:a.z,rotation:a.rotation}}function Kr(r,e,t){let n=structuredClone(r);for(let i of n.floors){let o=i.furniture.find(s=>s.id===e);o&&t(o,i)}return n}function Gr(r,e,t){let n=structuredClone(r);for(let i of n.floors){let o=i.placements.find(s=>s.entity_id===e);o&&t(o,i)}return n}function _u(r,e){let t=structuredClone(r);for(let n of t.floors)n.furniture=n.furniture.filter(i=>i.id!==e);return t}function bu(r,e){let t=structuredClone(r);for(let n of t.floors)n.placements=n.placements.filter(i=>i.entity_id!==e);return t}function vu(r,e,t,n){return Gr(r,e,(i,o)=>{[i.x,i.z]=Fo(o,i.x,i.z,t,n)})}function wu(r,e,t,n){let i=r.settings.wall_interior??.12;return Kr(r,e,(o,s)=>{[o.x,o.z]=Fo(s,o.x,o.z,t,n);let a=gu(s,o,i);a&&Object.assign(o,a)})}var Ho=(r,e)=>((r+e)%360+360)%360,yu=r=>Number.parseFloat(r.replace(",",".")),Tn=(r,e)=>Math.round(r*10**e)/10**e;function Po(r){let{min:e,max:t,accepts:n=()=>!0}=r,i=o=>{let s=yu(o.target.value);!Number.isFinite(s)||!n(s)||r.apply(t===void 0?s:Math.min(t,Math.max(e,s)))};return p`=1e3?`${W(r,e/1e3,1)} kW`:`${Math.round(e)} W`}function To(r){return r.type==="tv_board"?r.h+.9:r.type==="tv_wall"||r.type==="kitchen_wall"?r.h+.25:r.h+.35}function pf(r,e){let t=e.attributes.percentage;return e.state==="on"&&typeof t=="number"?`${Math.round(t)} %`:ie(r,e)}var hu;function mu(){let r=new URL("./nextfloor-editor.js?v=7e91db04ac71",new URL(import.meta.url)).href;return hu??=import(r),hu}var ff=.25,pu=r=>Math.round(r*1e3)/1e3,fu=(r,e,t)=>r.rooms.find(n=>n.points.length>=3&&I([e,t],n.points));function Ho(r,e,t,n,i){let o=fu(r,e,t);if(!o)return[n,i];let s=(a,l)=>I([a,l],o.points);return s(n,i)?[n,i]:s(n,t)?[n,t]:s(e,i)?[e,i]:[e,t]}function gf(r,e,t,n){return r.rooms.some(i=>i.id!==e.id&&i.points.some((o,s)=>{let a=i.points[(s+1)%i.points.length];return Math.abs(ae(J(o,t),n))<.02&&Math.abs(ae(J(a,t),n))<.02}))}var Fo=(r,e)=>Math.abs((r-e+540)%360-180);function gu(r,e,t,n=ff){let i=fu(r,e.x,e.z);if(!i)return null;let o=i.points,s=ct(o)>=0?1:-1,a=null;return o.forEach((l,c)=>{let u=o[(c+1)%o.length],d=Ce(J(u,l));if(d<.3)return;let m=[(u[0]-l[0])/d,(u[1]-l[1])/d],h=[-m[1]*s,m[0]*s],g=ae(J([e.x,e.z],l),m);if(g<0||g>d)return;let _=gf(r,i,l,h)?t/2:0,b=ae(J([e.x,e.z],l),h)-_,v=Math.atan2(-h[0],h[1])*180/Math.PI,S=[{rotation:v,extent:e.d/2},{rotation:v+90,extent:e.w/2},{rotation:v-90,extent:e.w/2}].reduce((z,R)=>Fo(e.rotation,R.rotation)50)return;let $=b-S.extent;Math.abs($)>n||a&&Math.abs($)>=Math.abs(a.gap)||(a={x:pu(e.x-h[0]*$),z:pu(e.z-h[1]*$),rotation:(Math.round(S.rotation)%360+360)%360,gap:$})}),a&&{x:a.x,z:a.z,rotation:a.rotation}}function Gr(r,e,t){let n=structuredClone(r);for(let i of n.floors){let o=i.furniture.find(s=>s.id===e);o&&t(o,i)}return n}function Ur(r,e,t){let n=structuredClone(r);for(let i of n.floors){let o=i.placements.find(s=>s.entity_id===e);o&&t(o,i)}return n}function _u(r,e){let t=structuredClone(r);for(let n of t.floors)n.furniture=n.furniture.filter(i=>i.id!==e);return t}function bu(r,e){let t=structuredClone(r);for(let n of t.floors)n.placements=n.placements.filter(i=>i.entity_id!==e);return t}function vu(r,e,t,n){return Ur(r,e,(i,o)=>{[i.x,i.z]=Ho(o,i.x,i.z,t,n)})}function wu(r,e,t,n){let i=r.settings.wall_interior??.12;return Gr(r,e,(o,s)=>{[o.x,o.z]=Ho(s,o.x,o.z,t,n);let a=gu(s,o,i);a&&Object.assign(o,a)})}var Po=(r,e)=>((r+e)%360+360)%360,yu=r=>Number.parseFloat(r.replace(",",".")),Dn=(r,e)=>Math.round(r*10**e)/10**e;function Io(r){let{min:e,max:t,accepts:n=()=>!0}=r,i=o=>{let s=yu(o.target.value);!Number.isFinite(s)||!n(s)||r.apply(t===void 0?s:Math.min(t,Math.max(e,s)))};return p`${r.label}
-
- `}var ku=(r,e)=>p`${r.t("height_auto")} `,xu=(r,e)=>p`e(-r)}>↺ ${r}° e(r)}>↻ ${r}° `;function _f(r,e){let t=r.building.floors.find(s=>s.furniture.some(a=>a.id===e)),n=t?.furniture.find(s=>s.id===e);if(!t||!n)return f;let i=(s,a)=>Po({label:r.t(a),title:r.t(`size_${s}`),value:n[s],step:.05,min:.05,accepts:l=>l>0,apply:l=>r.editFurniture(e,c=>c[s]=Tn(l,3))}),o=Ps(n)?p`${Po({label:"\u2195",title:r.t("mount_height"),value:n.mount_y??de(t,n),step:.05,min:0,accepts:s=>s>=0,apply:s=>r.editFurniture(e,a=>a.mount_y=Tn(s,3))})}
- ${n.mount_y!=null?ku(r,()=>r.editFurniture(e,s=>s.mount_y=null)):f}`:f;return p`${i("w","size_short_w")}${i("d","size_short_d")}${i("h","size_short_h")} ${o}`}function bf(r,e){let t=r.building.floors.find(l=>l.placements.some(c=>c.entity_id===e)),n=t?.placements.find(l=>l.entity_id===e);if(!t||!n)return f;let i=F(e),o=(l,c,u)=>p`r.editDevice(e,m=>Object.assign(m,{mount:d.target.value,y:null}))}>
+
+ `}var ku=(r,e)=>p`${r.t("height_auto")} `,xu=(r,e)=>p`e(-r)}>↺ ${r}° e(r)}>↻ ${r}° `;function _f(r,e){let t=r.building.floors.find(s=>s.furniture.some(a=>a.id===e)),n=t?.furniture.find(s=>s.id===e);if(!t||!n)return f;let i=(s,a)=>Io({label:r.t(a),title:r.t(`size_${s}`),value:n[s],step:.05,min:.05,accepts:l=>l>0,apply:l=>r.editFurniture(e,c=>c[s]=Dn(l,3))}),o=Is(n)?p`${Io({label:"\u2195",title:r.t("mount_height"),value:n.mount_y??de(t,n),step:.05,min:0,accepts:s=>s>=0,apply:s=>r.editFurniture(e,a=>a.mount_y=Dn(s,3))})}
+ ${n.mount_y!=null?ku(r,()=>r.editFurniture(e,s=>s.mount_y=null)):f}`:f;return p`${i("w","size_short_w")}${i("d","size_short_d")}${i("h","size_short_h")} ${o}`}function bf(r,e){let t=r.building.floors.find(l=>l.placements.some(c=>c.entity_id===e)),n=t?.placements.find(l=>l.entity_id===e);if(!t||!n)return f;let i=H(e),o=(l,c,u)=>p`r.editDevice(e,m=>Object.assign(m,{mount:d.target.value,y:null}))}>
${c.map(([d,m])=>p`${m} `)}
- `,s=["ceiling","floor","table","wall"].map(l=>[l,r.t(`lamp_${l}`)]),a=i?Mt(i,_e(t,n.x,n.z),i==="light"?n.mount??"ceiling":null):1;return p`${i==="light"?o("lamp_mount",s,n.mount??"ceiling"):f}
- ${Po({label:r.t("size_short_h"),title:r.t("marker_height"),value:n.y??a,step:.05,min:0,accepts:l=>l>=0,apply:l=>r.editDevice(e,c=>c.y=Tn(l,3))})}
+ `,s=["ceiling","floor","table","wall"].map(l=>[l,r.t(`lamp_${l}`)]),a=i?At(i,_e(t,n.x,n.z),i==="light"?n.mount??"ceiling":null):1;return p`${i==="light"?o("lamp_mount",s,n.mount??"ceiling"):f}
+ ${Io({label:r.t("size_short_h"),title:r.t("marker_height"),value:n.y??a,step:.05,min:0,accepts:l=>l>=0,apply:l=>r.editDevice(e,c=>c.y=Dn(l,3))})}
${n.y!==null?ku(r,()=>r.editDevice(e,l=>l.y=null)):f}`}function Su(r,e,t){let n=r.t,i;if(e){let o=r.building.floors.flatMap(s=>s.furniture).find(s=>s.id===e)?.type;i=p`${o?fe(r.hass,o):""}
${_f(r,e)} ${xu(45,s=>r.turnFurniture(e,s))}
r.editFurniture(e,s=>s.mirror=!s.mirror)}>⇋ ${n("furn_mirror")}
@@ -3373,7 +3373,7 @@ ${t.sources.map(n=>this.hass.states[n]?.attributes.symcon_path||this.hass.states
-`;var ue=(r,e)=>({name:r,fallback:e,read:t=>e?t!=="0":t==="1",write:t=>t?"1":"0"}),Ot=(r,e,t)=>({name:r,fallback:t,read:n=>e.find(i=>i===n)??t,write:n=>n}),Io={explode:ue("explode",!0),keepRoof:ue("roof",!1),solidWalls:ue("solid_walls",!1),quality:Ot("quality",["auto","low","high"],"auto"),stats:ue("stats",!1),markers:Ot("markers",["none","important","all"],"important"),heat:Ot("heat",["none","temperature","humidity","co2","mould","comfort","power","sun","values","wifi"],"none"),theme:Ot("theme",zr,"neon"),clock:Ot("clock",["none","top_left","top_right","bottom_left","bottom_right"],"none"),accent:{name:"accent",fallback:null,read:r=>/^#[0-9a-f]{6}$/i.test(r)?r:null,write:r=>r??""},floorStack:Ot("floor_stack",["dim","stacked","single"],"dim"),roomNames:ue("room_names",!0),clean:ue("clean",!1),navWrap:ue("nav_wrap",!1),weather:ue("weather",!0),timeSlider:ue("time_slider",!1),menuOpen:ue("menu_open",!1),keepCamera:ue("keep_camera",!1),readable:ue("readable",!1),plain:ue("plain",!1),rightBack:ue("right_back",!1),zoom:{name:"zoom",fallback:100,read:r=>/^\d{2,3}$/.test(r)?Math.min(250,Math.max(60,Number(r))):100,write:r=>String(Math.round(Math.min(250,Math.max(60,r))))},screenName:{name:"screen_name",fallback:"",read:r=>r.slice(0,60),write:r=>r.trim().slice(0,60)},announceMuted:ue("announce_muted",!1),glassWalls:{name:"glass_walls",fallback:20,read:r=>/^\d{1,3}$/.test(r)?Math.min(100,Number(r)):20,write:r=>String(Math.round(Math.min(100,Math.max(0,r))))}};function Mu(r=jr()){try{return r?.getItem("nextfloor.screen_name")?.trim()||null}catch{return null}}function Au(r=jr()){try{return r?.getItem("nextfloor.announce_muted")==="1"}catch{return!1}}function jr(){try{return localStorage}catch{return null}}var Ur=class{storage;constructor(e){this.storage=e}raw(e){try{return this.storage?.getItem(`nextfloor.${e}`)??null}catch{return null}}load(e=""){let t={};for(let n of Object.keys(Io)){let i=Io[n],o=this.raw(i.name);t[n]=o===null?i.fallback:i.read(o)}return new URLSearchParams(e).has("nf_stats")&&(t.stats=!0),t}save(e,t){let n=Io[e];try{this.storage?.setItem(`nextfloor.${n.name}`,n.write(t))}catch{}}};var Eu=Q`
+`;var ue=(r,e)=>({name:r,fallback:e,read:t=>e?t!=="0":t==="1",write:t=>t?"1":"0"}),Vt=(r,e,t)=>({name:r,fallback:t,read:n=>e.find(i=>i===n)??t,write:n=>n}),Co={explode:ue("explode",!0),keepRoof:ue("roof",!1),solidWalls:ue("solid_walls",!1),quality:Vt("quality",["auto","low","high"],"auto"),stats:ue("stats",!1),markers:Vt("markers",["none","important","all"],"important"),heat:Vt("heat",["none","temperature","humidity","co2","mould","comfort","power","sun","values","wifi"],"none"),theme:Vt("theme",Tr,"neon"),clock:Vt("clock",["none","top_left","top_right","bottom_left","bottom_right"],"none"),accent:{name:"accent",fallback:null,read:r=>/^#[0-9a-f]{6}$/i.test(r)?r:null,write:r=>r??""},floorStack:Vt("floor_stack",["dim","stacked","single"],"dim"),roomNames:ue("room_names",!0),clean:ue("clean",!1),navWrap:ue("nav_wrap",!1),weather:ue("weather",!0),timeSlider:ue("time_slider",!1),menuOpen:ue("menu_open",!1),keepCamera:ue("keep_camera",!1),readable:ue("readable",!1),plain:ue("plain",!1),rightBack:ue("right_back",!1),zoom:{name:"zoom",fallback:100,read:r=>/^\d{2,3}$/.test(r)?Math.min(250,Math.max(60,Number(r))):100,write:r=>String(Math.round(Math.min(250,Math.max(60,r))))},screenName:{name:"screen_name",fallback:"",read:r=>r.slice(0,60),write:r=>r.trim().slice(0,60)},announceMuted:ue("announce_muted",!1),glassWalls:{name:"glass_walls",fallback:20,read:r=>/^\d{1,3}$/.test(r)?Math.min(100,Number(r)):20,write:r=>String(Math.round(Math.min(100,Math.max(0,r))))}};function Mu(r=qr()){try{return r?.getItem("nextfloor.screen_name")?.trim()||null}catch{return null}}function Au(r=qr()){try{return r?.getItem("nextfloor.announce_muted")==="1"}catch{return!1}}function qr(){try{return localStorage}catch{return null}}var jr=class{storage;constructor(e){this.storage=e}raw(e){try{return this.storage?.getItem(`nextfloor.${e}`)??null}catch{return null}}load(e=""){let t={};for(let n of Object.keys(Co)){let i=Co[n],o=this.raw(i.name);t[n]=o===null?i.fallback:i.read(o)}return new URLSearchParams(e).has("nf_stats")&&(t.stats=!0),t}save(e,t){let n=Co[e];try{this.storage?.setItem(`nextfloor.${n.name}`,n.write(t))}catch{}}};var Eu=Q`
.nf-dot {
display: inline-block;
width: 8px;
@@ -3865,11 +3865,11 @@ ${t.sources.map(n=>this.hass.states[n]?.attributes.symcon_path||this.hass.states
gap: 12px;
margin: auto;
}
-`;var Ru=new WeakMap,zu=new WeakMap;function gt(r,e){let t=zu.get(r)??r,n=Ru.get(t)??new WeakMap;Ru.set(t,n);let i=n.get(e);if(i)return i;let o=new Map;for(let l of e)for(let c of l.placements)c.entity_id.startsWith("cover.")&&o.set(c.entity_id,{tilt:c.cover_tilt==="none"?null:c.cover_tilt,position:c.position});for(let l of De(t,e).values())l.cover&&!o.has(l.cover)&&o.set(l.cover,{tilt:l.coverTilt,position:l.position}),l.cover2&&!o.has(l.cover2)&&o.set(l.cover2,{tilt:l.cover2Tilt});let s={...t.states};for(let[l,c]of o){let u=t.states[l];if(!u)continue;let d={...u.attributes,nf_cover_control:!0},m=At(t,c.position);m===null&&(m=typeof u.attributes.current_position=="number"?u.attributes.current_position:null),m!==null&&(d.current_position=m);let h=c.tilt?t.states[c.tilt]:u,g=typeof h?.attributes.current_tilt_position=="number"?h.attributes.current_tilt_position:c.tilt?At(t,c.tilt):null;g!==null&&(d.current_tilt_position=g,d.supported_features=Number(d.supported_features??0)|128);let _=u.state;typeof d.current_position=="number"&&_!=="unavailable"&&_!=="unknown"&&_!=="opening"&&_!=="closing"&&(_=d.current_position>0?"open":"closed"),s[l]={...u,state:_,attributes:d}}let a={...t,states:s,callService:async(l,c,u={})=>{if(l!=="cover")return t.callService(l,c,u);let d=Array.isArray(u.entity_id)?u.entity_id:[u.entity_id],m=async h=>{let g=typeof h=="string"?o.get(h):void 0;if(!g)return t.callService(l,c,{...u,entity_id:h});let _={...u,entity_id:h},b=c;(b==="toggle"||b==="toggle_cover")&&(b=s[String(h)]?.state==="closed"?"open_cover":"close_cover");let v=b.includes("tilt");v&&g.tilt&&(_.entity_id=g.tilt);let k=g.tilt?t.states[g.tilt]:void 0;return v&&g.tilt&&!k?.attributes.symcon_id&&typeof k?.attributes.current_tilt_position!="number"&&(b==="set_cover_tilt_position"?(b="set_cover_position",_.position=_.tilt_position,delete _.tilt_position):b==="open_cover_tilt"?b="open_cover":b==="close_cover_tilt"&&(b="close_cover")),t.callService(l,b,_)};return Array.isArray(u.entity_id)?Promise.all(d.map(m)):m(d[0])}};return zu.set(a,t),n.set(e,a),a}var Co=class extends X{static properties={hass:{attribute:!1},narrow:{type:Boolean},route:{attribute:!1},panel:{attribute:!1},_mode:{state:!0},_editorReady:{state:!0},_floorId:{state:!0},_roomId:{state:!0},_wallMode:{state:!0},_prefs:{state:!0},_furnish:{state:!0},_selFurniture:{state:!0},_selDevice:{state:!0},_optsOpen:{state:!0},_switchesOpen:{state:!0},_timeOfDay:{state:!0},_outside:{state:!0},_timeDrag:{state:!0},_floorUndo:{state:!0},_variablesLoading:{state:!0},_variablesNotice:{state:!0},_variablesError:{state:!0}};outsideMemo=null;floorUndoTimer;data=new $t(this);store=new Ur(jr());constructor(){super(),this.narrow=!1,this._mode="view",this._editorReady=!!customElements.get("nf-editor"),this._floorId=null,this._roomId=null,this._wallMode="auto",this._prefs=this.store.load(location.search),this._furnish=!1,this._selFurniture=null,this._selDevice=null,this._optsOpen=!1,this._switchesOpen=!1,this._timeOfDay=null,this._outside=!1,this._timeDrag=null,this._floorUndo=null,this._variablesLoading=!1,this._variablesNotice="",this._variablesError=!1}toggleTimeSlider(e){this.setPref("timeSlider",e),e||([this._timeOfDay,this._timeDrag]=[null,null])}sunState(){let e=this.hass?.config;return this._timeOfDay===null||e?.latitude===void 0||e.longitude===void 0?this.hass?.states["sun.sun"]?.state:at(wt(this._timeOfDay,e.time_zone),e.latitude,e.longitude).elevation>0?"above_horizon":"below_horizon"}renderTimeOfDay(){let e=this.t;if(this.hass?.config?.latitude===void 0)return f;let t=this._timeDrag??this._timeOfDay,n=o=>`${String(Math.floor(o)).padStart(2,"0")}:${String(Math.round(o%1*60)).padStart(2,"0")}`,i=()=>{let o=new Date;return Math.round((o.getHours()+o.getMinutes()/60)*4)/4};return p`(this._timeDrag=null,this._timeOfDay=t===null?i():null)}>☀ ${t===null?e("time_of_day"):n(t)}
+`;var Ru=new WeakMap,zu=new WeakMap;function _t(r,e){let t=zu.get(r)??r,n=Ru.get(t)??new WeakMap;Ru.set(t,n);let i=n.get(e);if(i)return i;let o=new Map;for(let l of e)for(let c of l.placements)c.entity_id.startsWith("cover.")&&o.set(c.entity_id,{tilt:c.cover_tilt==="none"?null:c.cover_tilt,position:c.position});for(let l of De(t,e).values())l.cover&&!o.has(l.cover)&&o.set(l.cover,{tilt:l.coverTilt,position:l.position}),l.cover2&&!o.has(l.cover2)&&o.set(l.cover2,{tilt:l.cover2Tilt});let s={...t.states};for(let[l,c]of o){let u=t.states[l];if(!u)continue;let d={...u.attributes,nf_cover_control:!0},m=Et(t,c.position);m===null&&(m=typeof u.attributes.current_position=="number"?u.attributes.current_position:null),m!==null&&(d.current_position=m);let h=c.tilt?t.states[c.tilt]:u,g=typeof h?.attributes.current_tilt_position=="number"?h.attributes.current_tilt_position:c.tilt?Et(t,c.tilt):null;g!==null&&(d.current_tilt_position=g,d.supported_features=Number(d.supported_features??0)|128);let _=u.state;typeof d.current_position=="number"&&_!=="unavailable"&&_!=="unknown"&&_!=="opening"&&_!=="closing"&&(_=d.current_position>0?"open":"closed"),s[l]={...u,state:_,attributes:d}}let a={...t,states:s,callService:async(l,c,u={})=>{if(l!=="cover")return t.callService(l,c,u);let d=Array.isArray(u.entity_id)?u.entity_id:[u.entity_id],m=async h=>{let g=typeof h=="string"?o.get(h):void 0;if(!g)return t.callService(l,c,{...u,entity_id:h});let _={...u,entity_id:h},b=c;(b==="toggle"||b==="toggle_cover")&&(b=s[String(h)]?.state==="closed"?"open_cover":"close_cover");let v=b.includes("tilt");v&&g.tilt&&(_.entity_id=g.tilt);let k=g.tilt?t.states[g.tilt]:void 0;return v&&g.tilt&&!k?.attributes.symcon_id&&typeof k?.attributes.current_tilt_position!="number"&&(b==="set_cover_tilt_position"?(b="set_cover_position",_.position=_.tilt_position,delete _.tilt_position):b==="open_cover_tilt"?b="open_cover":b==="close_cover_tilt"&&(b="close_cover")),t.callService(l,b,_)};return Array.isArray(u.entity_id)?Promise.all(d.map(m)):m(d[0])}};return zu.set(a,t),n.set(e,a),a}var No=class extends X{static properties={hass:{attribute:!1},narrow:{type:Boolean},route:{attribute:!1},panel:{attribute:!1},_mode:{state:!0},_editorReady:{state:!0},_floorId:{state:!0},_roomId:{state:!0},_wallMode:{state:!0},_prefs:{state:!0},_furnish:{state:!0},_selFurniture:{state:!0},_selDevice:{state:!0},_optsOpen:{state:!0},_switchesOpen:{state:!0},_timeOfDay:{state:!0},_outside:{state:!0},_timeDrag:{state:!0},_floorUndo:{state:!0},_variablesLoading:{state:!0},_variablesNotice:{state:!0},_variablesError:{state:!0}};outsideMemo=null;floorUndoTimer;data=new Mt(this);store=new jr(qr());constructor(){super(),this.narrow=!1,this._mode="view",this._editorReady=!!customElements.get("nf-editor"),this._floorId=null,this._roomId=null,this._wallMode="auto",this._prefs=this.store.load(location.search),this._furnish=!1,this._selFurniture=null,this._selDevice=null,this._optsOpen=!1,this._switchesOpen=!1,this._timeOfDay=null,this._outside=!1,this._timeDrag=null,this._floorUndo=null,this._variablesLoading=!1,this._variablesNotice="",this._variablesError=!1}toggleTimeSlider(e){this.setPref("timeSlider",e),e||([this._timeOfDay,this._timeDrag]=[null,null])}sunState(){let e=this.hass?.config;return this._timeOfDay===null||e?.latitude===void 0||e.longitude===void 0?this.hass?.states["sun.sun"]?.state:lt(yt(this._timeOfDay,e.time_zone),e.latitude,e.longitude).elevation>0?"above_horizon":"below_horizon"}renderTimeOfDay(){let e=this.t;if(this.hass?.config?.latitude===void 0)return f;let t=this._timeDrag??this._timeOfDay,n=o=>`${String(Math.floor(o)).padStart(2,"0")}:${String(Math.round(o%1*60)).padStart(2,"0")}`,i=()=>{let o=new Date;return Math.round((o.getHours()+o.getMinutes()/60)*4)/4};return p`(this._timeDrag=null,this._timeOfDay=t===null?i():null)}>☀ ${t===null?e("time_of_day"):n(t)}
${t!==null?p` this._timeDrag=Number(o.target.value)}
@change=${o=>(this._timeDrag=null,this._timeOfDay=Number(o.target.value))}
- /> `:f}`}t=(e,t)=>A(this.hass,e,t);setPref(e,t){this._prefs={...this._prefs,[e]:t},this.store.save(e,t)}willUpdate(e){this.toggleAttribute("readable",!!this._prefs?.readable),e.has("hass")&&this.hass&&(this.style.colorScheme=br(this.hass),this.data.setHass(this.hass));let t=this.data.building;t&&this._floorId&&!t.floors.some(n=>n.id===this._floorId)&&(this._floorId=null,this._roomId=null)}get isAdmin(){return this.hass?.user?.is_admin??!1}setMode(e){e!==this._mode&&(e==="view"&&this.data.flush(),this._mode=e)}openFloor(e){this._floorId=e,this._roomId=null,this._outside=!1}outsideIds(e){let t=this.outsideMemo;if(t&&t.building===e&&t.entities===this.hass.entities)return t.ids;let n=rn(this.hass,e.floors,e.settings.outside_hidden);return this.outsideMemo={building:e,entities:this.hass.entities,ids:n},n}openOutside(){let e=!this._outside;this.openFloor(null),this._outside=e}onRoomTap(e){let{floorId:t,roomId:n}=e.detail;if(n==="nf-outside")return this.openOutside();if((this.data.building?.floors.length??0)>1&&t&&this._floorId!==t)return this.openFloor(t);n&&(this._roomId=n===this._roomId?null:n,this._outside=!1)}furnishHost={hass:void 0,building:void 0,t:this.t,editFurniture:(e,t)=>this.applyEdit(n=>Kr(n,e,t)),editDevice:(e,t)=>this.applyEdit(n=>Gr(n,e,t)),turnFurniture:(e,t)=>this.applyEdit(n=>Kr(n,e,i=>i.rotation=Ho(i.rotation,t))),turnDevice:(e,t)=>this.applyEdit(n=>Gr(n,e,i=>i.rotation=Ho(i.rotation??0,t))),removeFurniture:e=>{this.applyEdit(t=>_u(t,e)),this._selFurniture=null},removeDevice:e=>{this.applyEdit(t=>bu(t,e)),this._selDevice=null},finish:()=>{this._furnish=!1,this._selFurniture=null,this._selDevice=null}};saveMoods(e,t){this.applyEdit(n=>({...n,floors:n.floors.map(i=>({...i,rooms:i.rooms.map(o=>o.id===e?{...o,moods:t.length?t:void 0}:o)}))}))}applyEdit(e){let t=this.data.building;t&&this.data.edit(e(t))}view3d(){return this.renderRoot.querySelector("nf-view3d")}back(){this._outside?this._outside=!1:this._roomId?this._roomId=null:this._floorId&&(this.data.building?.floors.length??0)>1?this._floorId=null:this.view3d()?.resetView()}onKey=e=>{e.key!=="Escape"||this._mode!=="view"||(this._prefs.clean?this.setPref("clean",!1):this.back())};connectedCallback(){super.connectedCallback(),window.addEventListener("keydown",this.onKey)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("keydown",this.onKey)}render(){if(this.hass&&hr(this.hass,this))return f;let e=this.data.building,t=this._prefs.clean&&this._mode==="view",n=f;return e&&(this._mode==="editor"&&this.isAdmin?n=this.renderEditor(e):this._mode==="extensions"&&this.isAdmin?n=this.renderExtensions():n=this.renderView(e)),p`
+ />`:f}`}t=(e,t)=>A(this.hass,e,t);setPref(e,t){this._prefs={...this._prefs,[e]:t},this.store.save(e,t)}willUpdate(e){this.toggleAttribute("readable",!!this._prefs?.readable),e.has("hass")&&this.hass&&(this.style.colorScheme=vr(this.hass),this.data.setHass(this.hass));let t=this.data.building;t&&this._floorId&&!t.floors.some(n=>n.id===this._floorId)&&(this._floorId=null,this._roomId=null)}get isAdmin(){return this.hass?.user?.is_admin??!1}setMode(e){e!==this._mode&&(e==="view"&&this.data.flush(),this._mode=e)}openFloor(e){this._floorId=e,this._roomId=null,this._outside=!1}outsideIds(e){let t=this.outsideMemo;if(t&&t.building===e&&t.entities===this.hass.entities)return t.ids;let n=sn(this.hass,e.floors,e.settings.outside_hidden);return this.outsideMemo={building:e,entities:this.hass.entities,ids:n},n}openOutside(){let e=!this._outside;this.openFloor(null),this._outside=e}onRoomTap(e){let{floorId:t,roomId:n}=e.detail;if(n==="nf-outside")return this.openOutside();if((this.data.building?.floors.length??0)>1&&t&&this._floorId!==t)return this.openFloor(t);n&&(this._roomId=n===this._roomId?null:n,this._outside=!1)}furnishHost={hass:void 0,building:void 0,t:this.t,editFurniture:(e,t)=>this.applyEdit(n=>Gr(n,e,t)),editDevice:(e,t)=>this.applyEdit(n=>Ur(n,e,t)),turnFurniture:(e,t)=>this.applyEdit(n=>Gr(n,e,i=>i.rotation=Po(i.rotation,t))),turnDevice:(e,t)=>this.applyEdit(n=>Ur(n,e,i=>i.rotation=Po(i.rotation??0,t))),removeFurniture:e=>{this.applyEdit(t=>_u(t,e)),this._selFurniture=null},removeDevice:e=>{this.applyEdit(t=>bu(t,e)),this._selDevice=null},finish:()=>{this._furnish=!1,this._selFurniture=null,this._selDevice=null}};saveMoods(e,t){this.applyEdit(n=>({...n,floors:n.floors.map(i=>({...i,rooms:i.rooms.map(o=>o.id===e?{...o,moods:t.length?t:void 0}:o)}))}))}applyEdit(e){let t=this.data.building;t&&this.data.edit(e(t))}view3d(){return this.renderRoot.querySelector("nf-view3d")}back(){this._outside?this._outside=!1:this._roomId?this._roomId=null:this._floorId&&(this.data.building?.floors.length??0)>1?this._floorId=null:this.view3d()?.resetView()}onKey=e=>{e.key!=="Escape"||this._mode!=="view"||(this._prefs.clean?this.setPref("clean",!1):this.back())};connectedCallback(){super.connectedCallback(),window.addEventListener("keydown",this.onKey)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("keydown",this.onKey)}render(){if(this.hass&&mr(this.hass,this))return f;let e=this.data.building,t=this._prefs.clean&&this._mode==="view",n=f;return e&&(this._mode==="editor"&&this.isAdmin?n=this.renderEditor(e):this._mode==="extensions"&&this.isAdmin?n=this.renderExtensions():n=this.renderView(e)),p`
${t?f:p`${this.renderHeader(e)}${this.renderNotices()}`}
${this.data.error&&!e?p`
${this.t("load_error")}: ${this.data.error}
`:f}
${!e&&!this.data.error?p`
${this.t("loading")}
`:f}
@@ -3882,7 +3882,7 @@ ${t.sources.map(n=>this.hass.states[n]?.attributes.symcon_path||this.hass.states
`}renderViewOptions(){let e=this._prefs;return p`
this._optsOpen=!this._optsOpen}>⚙
${this.choiceRow("quality",["auto","low","high"],e.quality,t=>this.t(`quality_${t}`),t=>this.setPref("quality",t))}
- ${this.choiceRow("theme",zr,e.theme,t=>this.t(`theme_${t}`),t=>this.setPref("theme",t),this.accentPicker())}
+ ${this.choiceRow("theme",Tr,e.theme,t=>this.t(`theme_${t}`),t=>this.setPref("theme",t),this.accentPicker())}
${this.choiceRow("markers",["none","important","all"],e.markers,t=>this.t(`markers_${t}`),t=>this.setPref("markers",t))}
🕒
@@ -3898,7 +3898,7 @@ ${t.sources.map(n=>this.hass.states[n]?.attributes.symcon_path||this.hass.states
>${this.t("glass_walls")}
this.setPref("glassWalls",Number(t.target.value))} />
- ${U(this.hass)?f:p`
+ ${G(this.hass)?f:p`
${e.announceMuted?"\u{1F507}":"\u{1F4E2}"}