0){i.textContent=Ii?Ii.emptyScript:"";for(let h=0;h2||r[0]!==""||r[1]!==""?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=_}_$AI(e,n=this,r,i){let o=this.strings,s=!1;if(o===void 0)e=en(this,e,n,0),s=!xr(e)||e!==this._$AH&&e!==tt,s&&(this._$AH=e);else{let l=e,a,c;for(e=o[0],a=0;a{let r=n?.renderBefore??e,i=r._$litPart$;if(i===void 0){let o=n?.renderBefore??null;r._$litPart$=i=new Mn(e.insertBefore(kr(),o),o,void 0,n??{})}return i._$AI(t),i};var Rs=globalThis,Y=class extends bt{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){let e=super.createRenderRoot();return this.renderOptions.renderBefore??=e.firstChild,e}update(e){let n=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=Hc(n,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return tt}};Y._$litElement$=!0,Y.finalized=!0,Rs.litElementHydrateSupport?.({LitElement:Y});var _b=Rs.litElementPolyfillSupport;_b?.({LitElement:Y});(Rs.litElementVersions??=[]).push("4.2.2");var As=t=>t.slice(0,t.indexOf(".")),bb={light:"light",switch:"switch",input_boolean:"switch",valve:"switch",fan:"fan",cover:"cover",climate:"climate",media_player:"media",lock:"lock",sensor:"sensor",binary_sensor:"binary",event:"sensor",scene:"scene",script:"script"},Q=t=>bb[As(t)]??null,Fs=["light","cover","climate","media","switch","fan","lock","binary","sensor","scene","script"];var Lc=new Set(["light","switch","fan"]),Ft=t=>t!==null&&t!=="scene"&&t!=="script",Ie=t=>!t||t.state==="unavailable"||t.state==="unknown"&&!t.entity_id.startsWith("event.");function B(t,e,n){let r=String(t?.states[e]?.attributes.friendly_name??t?.entities?.[e]?.name??e);if(!n||r.length<=n.length+1||!r.toLowerCase().startsWith(`${n.toLowerCase()} `))return r;let i=r.slice(n.length+1);return i[0].toUpperCase()+i.slice(1)}var Cc=t=>!!t&&t.entity_id.startsWith("sensor.")&&t.attributes.device_class==="enum";var Nc=t=>Math.min(1,Math.max(0,t));function yb(t){let e=Nc((t-2200)/4300),n=[1,.66,.26],r=[.78,.9,1];return[0,1,2].map(i=>n[i]+(r[i]-n[i])*e)}function Es(t,e){if(!t||t.state!=="on")return null;let n=e&&!["unavailable","unknown"].includes(e.state)?e.attributes:t.attributes,r=typeof n.brightness=="number"?.2+.8*Math.sqrt(Nc(n.brightness/255)):1,i=n.rgb_color;return i&&!["color_temp","brightness","onoff"].includes(String(n.color_mode))?{color:[i[0]/255,i[1]/255,i[2]/255],level:r}:typeof n.color_temp_kelvin=="number"?{color:yb(n.color_temp_kelvin),level:r}:{color:[1,.71,.28],level:r}}function Bc(t,e,n){let r=Es(t,n);if(r)return r;for(let i of e){let o=Es(i);if(o)return{color:o.color,level:o.level*.6}}return null}function Bi(t,e,n=null){if(t==="light"&&n==="floor")return 1.95;if(t==="light"&&n==="table")return 1.25;if(t==="light"&&n==="wall")return 1.95;switch(t){case"light":return Math.max(.5,e-.25);case"cover":return Math.min(2,e-.3);case"climate":return .6;case"media":return .9;case"binary":case"sensor":return 1.4;default:return 1.05}}var jc=[],Wi=new Map,vb=0,he=(t,e)=>`pack:${t}:${e}`,vt=t=>t.startsWith("pack:");function Ts(t){jc=t,Wi=new Map;for(let e of t)for(let n of e.items)Wi.set(he(e.id,n.id),n);vb+=1}var Mr=()=>jc;var wb={};function U(t){if(!vt(t))return;let e=Wi.get(t);if(e)return e;let[,n,...r]=t.split(":"),i=wb[n];return i?Wi.get(he(i,r.join(":"))):void 0}var kb=.22;function Wc(t,e,n,r){let i=Math.min(kb,n/3);if(r<=i*2.4||Math.abs(r-n)<1e-6)return e*(r/n)+(t-e)*(r/n);let o=e*(r/n),s=t-e;return s<=i?o+s:s>=n-i?o+r-(n-s):o+i+(s-i)*(r-2*i)/(n-2*i)}function Sr(t,e,n,r,i){return[Wc(t*r,n*r,r,i)/i,Wc(e*r,n*r,r,i)/i]}var Vc=new WeakMap;function Gc(t,e,n,r){let[i,o,s]=t.size;if(t.vehicle||t.stretch||Math.abs(e-i)<1e-4&&Math.abs(n-o)<1e-4&&Math.abs(r-s)<1e-4)return t.parts;let l=`${e.toFixed(4)}|${n.toFixed(4)}|${r.toFixed(4)}`,a=Vc.get(t),c=a?.get(l);if(c)return c;let u=t.parts.map(d=>{if(d.shape==="sweep")return d;let[p,h]=Sr(d.x-d.w/2,d.x+d.w/2,-.5,i,e),[f,g]=Sr(d.z-d.d/2,d.z+d.d/2,-.5,o,n),[b,y]=Sr(d.y,d.y+d.h,0,s,r);if(d.rot)return{...d,x:(p+h)/2,z:(f+g)/2,w:d.w*i/e,d:d.d*o/n,y:b,h:y-b};let v={...d,x:(p+h)/2,z:(f+g)/2,w:h-p,d:g-f,y:b,h:y-b};if(d.shape==="loft"){let[w,x,k,M]=[d.tx??d.x,d.tz??d.z,d.tw??d.w,d.td??d.d],[A,T]=Sr(w-k/2,w+k/2,-.5,i,e),[F,H]=Sr(x-M/2,x+M/2,-.5,o,n);Object.assign(v,{tx:(A+T)/2,tz:(F+H)/2,tw:T-A,td:H-F})}return v});return a||Vc.set(t,a=new Map),a.size>32&&a.clear(),a.set(l,u),u}var zs=t=>!!t?.parts.some(e=>e.move);var Uc=t=>U(t)?.parts.find(e=>e.screen),Kc=.06;function Zc(t){let e=U(t);if(!e)return!1;let[n,r,i]=e.size;return e.parts.filter(o=>o.screen).some(o=>{let[s,l]=[o.w*n,o.d*r,o.h*i].sort((a,c)=>c-a);return l>=Kc&&s>=Kc})}function dt(t){return nt[t]??U(t)?.size??[.6,.6,.8]}function Tt(t){let e=U(t);return nu.has(t)||!!e?.electric||!!e?.light||!!e?.climate}var qc=t=>!!U(t)?.parts.some(e=>e.picture),Rn=t=>!!U(t)?.climate;function Yc(t,e){return t.name[e.split("-")[0]]??t.name.en??Object.values(t.name)[0]??t.id}var xb={wohnen:"Living & Pets",kino:"Home Cinema & Gaming",kueche:"Kitchen Extras",bad:"Bathroom Extras",schlafen:"Bedroom & Kids",technik:"Office & Homelab",energie:"Energy & Building Services",garten:"Garden & Terrace (older)",fitness:"Fitness (older)",fahrzeuge:"Vehicles",ikea:"IKEA sizes",treppen:"Stairs & railings",ausbau:"Architecture & fit-out",werkstatt:"Garage & workshop",a_wohnzimmer:"Living room",a_schlafzimmer:"Bedroom",a_kueche:"Kitchen",a_bad:"Bathroom",a_kinderzimmer:"Kids' room",a_buero:"Office & gaming",a_fitness:"Fitness",a_haustiere:"Pets",a_garten:"Garden & patio",a_kino:"Home cinema & hi-fi",a_smart:"Smart home & tech",a_haustechnik:"Utility & building services",a_saison:"Season & decoration",a_smart2:"Smart home 2",a_haustechnik2:"Building services 2",a_wellness:"Wellness",a_garten2:"Garden 2",a_kueche2:"Kitchen 2",a_fahrzeuge2:"Vehicles 2",a_aussenkueche:"Outdoor kitchen & terrace",a_werkstatt2:"Workshop 2",a_japandi:"Japandi & Scandi",a_loft:"Loft & industrial",a_gruen:"Indoor greenery",a_musik:"Music & studio",a_bilder:"Pictures & frames"};function Xc(t,e){if(e.split("-")[0]==="de")return t.name;let n=/^nextfloor\.(.+)$/.exec(t.id)?.[1];return n&&xb[n]||t.name}function zt(t,e){return e.mount_y!=null?e.mount_y:Sb(t,e)+($b(e)?0:eu(t,e.x,e.z))}var $b=t=>t.type==="led_strip"||U(t.type)?.mount==="ceiling";function Sb(t,e){if(e.type==="lamp_wall")return Jc;if(e.type==="led_strip")return Math.max(0,ht(t,e.x,e.z)-.04-Math.max(.02,e.h));let n=U(e.type);if(!n)return Qc(e);switch(n.mount){case"surface":return tu(t,e.x,e.z);case"wall":return n.wall_y??1;case"ceiling":return Math.max(0,Vi(t,e)-e.h);default:return 0}}function Ps(t){if(t==="plant")return"plant";let e=U(t);return e?e.household?e.household:/monstera|plant|herb_garden|flower_pots|bonsai|ficus|cactus|kaktus/.test(e.id)?"plant":null:null}var wt=["electricity","water","gas","heating","cooling"],ru=["condition","temperature","humidity","pressure","wind_speed","wind_gust_speed","wind_bearing","cloud_coverage","precipitation","precipitation_total","illuminance","uv_index","visibility","snow","fog","lightning"],iu=["turn","slide","top"],ou=["always","active","no_power","never"],su=1.3,Ki=(t,e=new Date().toISOString().slice(0,10))=>!!t.due&&t.due<=e,au=["gable","hip","halfhip","pyramid","mansard","pent","flat","parapet"],lu=["brick","round","wide","steel"],ji=["navigate","more_info","service","fire_dom_event"];function Gi(t,e,n){return t?e?!!n.lock_plan:!!t.locked:!1}var cu=["rain","snow","fog","clouds","lightning","sky"],uu=["rain","snow","clouds","lightning","sky"],du=["lawn","terrace","path","driveway","pool","bed","wild","hedge","fence","pergola"],Ds={lawn:.012,terrace:.12,path:.02,driveway:.02,pool:-.25,bed:.15,wild:.03,hedge:1.2,fence:1,pergola:2.2};function Is(t){return t==="hedge"||t==="fence"||t==="pergola"}var hu=["x","-x","z","-z"];function Mb(t,e,n){let r=t.slope??0;if(!r||t.type==="pool")return 0;let i=t.slope_dir??"x",o=(c,u)=>i==="x"?c:i==="-x"?-c:i==="z"?u:-u,s=1/0,l=-1/0;for(let[c,u]of t.points){let d=o(c,u);s=Math.min(s,d),l=Math.max(l,d)}if(l-s<1e-6)return 0;let a=Math.min(1,Math.max(0,(o(e,n)-s)/(l-s)));return r*a}function Rb(t,e,n,r){return pu(t)+(e.offset??0)+Ds[e.type]-Mb(e,n,r)}function pu(t){return t.elevation>.3?0:-.2}function fu(t,e,n){let r=(t.outdoor??[]).filter(o=>!Is(o.type)&&o.type!=="pool"&&C([e,n],o.points)),i=[...r].reverse().find(o=>o.cut)??r[0];return i?Rb(t,i,e,n):pu(t)}var mu=t=>t.cut??t.type==="pool",gu=30,_u={meter:null,grid:null,grid_invert:!1,solar:null,battery:null,battery_invert:!1,battery_soc:null,consumption:null,tariff:null},bu=["wood","oak","tiles","carpet","stone","concrete"],yu={type:"none",pitch:35,overhang:.4},Ui="#d6cfc2",Zi="#e8e3da",vu={wall_exterior:.24,wall_interior:.12,grid:.05,north:0,roof:{...yu}};function Pt(){return{version:1,floors:[],settings:{...vu},energy:{..._u},presence:[]}}function Ve(t,e,n){return{id:t,name:e,elevation:n,height:2.5,cut_height:1.15,rooms:[],openings:[],furniture:[],placements:[],background:null,outdoor:[],walls:[],ha_floor:null}}var Eb=2.75;function wu(t,e){if(e!=null&&Number.isFinite(e))return Math.round(e*Eb*100)/100;let n=t.reduce((r,i)=>!r||i.elevation>r.elevation?i:r,null);return n?Math.round((n.elevation+n.height+.25)*100)/100:0}function ku(t,e,n){let r=t.rooms.flatMap(l=>l.points.map(a=>a[0])),i=t.rooms.flatMap(l=>l.points.map(a=>a[1])),o=r.length?Math.ceil(Math.max(...r))+1:0,s=i.length?Math.floor(Math.min(...i)):0;return e.map((l,a)=>{let c=o+a%3*4.5,u=s+Math.floor(a/3)*3.5;return{id:n(),name:l.name,area_id:l.area_id,points:[[c,u],[c+4,u],[c+4,u+3],[c,u+3]],floor_material:"wood"}})}function xu(t,e,n,r){let i=t.rotation*Math.PI/180,o=Math.cos(i),s=Math.sin(i),[l,a]=e,c=t.x-l*(t.w/2)*o+a*(t.d/2)*s,u=t.z-l*(t.w/2)*s-a*(t.d/2)*o,d=n[0]-c,p=n[1]-u,h=y=>Math.max(.1,Math.round(y/r)*r),f=h((d*o+p*s)*l),g=h((-d*s+p*o)*a),b=y=>Math.round(y*1e3)/1e3;return{x:b(c+l*(f/2)*o-a*(g/2)*s),z:b(u+l*(f/2)*s+a*(g/2)*o),w:b(f),d:b(g)}}var qi=["lamp_ceiling","lamp_downlight","lamp_spot","lamp_panel","lamp_pendant","ceiling_fan","lamp_floor","lamp_table","lamp_wall","led_strip","lamp_uplight","lamp_bollard","lamp_garden","radiator","sofa","armchair","stool","coffee_table","tv_board","tv_wall","sideboard","shelf","plant","rug","table","table_round","chair","bench","corner_bench","bar_stool","kitchen","kitchen_wall","kitchen_tall","island","worktop","sink","stove","dishwasher","fridge","bed","bunk_bed","nightstand","wardrobe","dresser","bathtub","shower","wc","washbasin","washer","dryer","desk","office_chair","tall_cabinet","coat_rack","stairs","robot_vacuum","inverter","home_battery","wallbox","meter","grid_point","parking","fridge_smart","heating_manifold","buffer_tank","freshwater_station","stairwell"],$u={lights:["lamp_ceiling","lamp_downlight","lamp_spot","lamp_panel","lamp_pendant","ceiling_fan","lamp_floor","lamp_uplight","lamp_table","lamp_wall","led_strip","lamp_bollard","lamp_garden"],living:["sofa","armchair","stool","coffee_table","tv_board","tv_wall","sideboard","shelf","plant","rug"],dining:["table","table_round","chair","bench","corner_bench","bar_stool"],kitchen:["kitchen","kitchen_wall","kitchen_tall","island","worktop","sink","stove","dishwasher","fridge"],sleeping:["bed","bunk_bed","nightstand","wardrobe","dresser"],bath:["bathtub","shower","wc","washbasin","washer","dryer"],work:["desk","worktop","office_chair","tall_cabinet","coat_rack","radiator","stairs","robot_vacuum","heating_manifold","buffer_tank","freshwater_station"],vehicles:["parking"]},Ke=["meter","inverter","home_battery","wallbox","grid_point"],Su=new Set(["lamp_ceiling","lamp_downlight","lamp_spot","lamp_panel","lamp_pendant","ceiling_fan","lamp_floor","lamp_uplight","lamp_table","lamp_wall","led_strip","lamp_bollard","lamp_garden"]),Jc=1.75;function Yi(t){return Os.has(t.type)||["stairwell","parking"].includes(t.type)?!1:U(t.type)?.mount!=="ceiling"}function ue(t){return Su.has(t)||!!U(t)?.light}var Ab=new Set(["table","table_round","coffee_table","desk","nightstand","sideboard","dresser","kitchen","island","worktop","tv_board","dishwasher","washer","dryer"]);function Mu(t,e,n,r=0){let i=de(t.points),o=i.x1-i.x0-2*r,s=i.z1-i.z0-2*r,l=[];for(let a=0;aMath.round(s*1e3)/1e3,[i,o]={right:[1,0],down:[0,1],left:[-1,0],up:[0,-1]}[n];return[r(t[0]+i*e),r(t[1]+o*e)]}function Qc(t){switch(t.type){case"home_battery":return t.variant==="wall"?.5:0;case"kitchen_wall":return 1.45;case"tv_wall":return Math.max(0,1.3-t.h/2);case"radiator":return .12;case"inverter":return 1.1;case"wallbox":return 1;case"meter":return .4;default:return 0}}var Os=new Set(["lamp_ceiling","lamp_downlight","lamp_spot","lamp_panel","lamp_pendant","ceiling_fan"]);function Ru(t,e){return t.filter(n=>n.elevationn.rooms.filter(r=>r.points.length>=3&&r.ceiling!=null&&r.ceiling>n.height+.005&&n.elevation+r.ceiling>e.elevation+.05)).map(n=>n.points)}var Hs=t=>t?.floor_offset&&Number.isFinite(t.floor_offset)?t.floor_offset:0;function eu(t,e,n){let r=t.rooms.find(i=>i.points.length>=3&&i.floor_offset&&C([e,n],i.points));return Hs(r)}function ht(t,e,n){let r=t.rooms.find(i=>i.points.length>=3&&C([e,n],i.points));return r?.ceiling!=null&&r.ceiling>0?r.ceiling:t.height}var Vi=(t,e)=>e.ceiling_y!=null&&e.ceiling_y>0?e.ceiling_y:ht(t,e.x,e.z);function tu(t,e,n){let r=0;for(let i of t.furniture)!(Ab.has(i.type)||U(i.type)?.surface)||!C([e,n],Bs(i))||(r=Math.max(r,i.h));return r}var nu=new Set([...Su,"radiator","robot_vacuum","inverter","home_battery","wallbox","meter","tv_board","tv_wall","desk","fridge","fridge_smart","stove","kitchen_tall","dishwasher","washer","dryer","kitchen","island","sink"]),nt={sofa:[2.2,.9,.82],armchair:[.85,.85,.8],table:[1.6,.9,.75],chair:[.46,.5,.9],bed:[1.6,2.05,.9],nightstand:[.45,.4,.5],wardrobe:[1.8,.6,2.1],shelf:[.9,.35,1.9],kitchen:[2.4,.62,.92],worktop:[1.2,.62,.91],inverter:[.5,.2,.65],home_battery:[.6,.25,1.1],wallbox:[.3,.15,.42],heating_manifold:[1.5,.35,1.1],buffer_tank:[.85,.85,1.85],freshwater_station:[.65,.28,.9],meter:[.55,.21,1.1],grid_point:[.4,.22,.6],fridge:[.6,.65,1.8],fridge_smart:[.91,.73,1.78],stairwell:[1,2.6,.02],stove:[.6,.62,.92],sink:[.9,.62,.92],bathtub:[1.7,.75,.58],shower:[.9,.9,2],wc:[.38,.6,.8],washbasin:[.6,.46,.85],desk:[1.4,.7,.75],tv_board:[1.8,.42,.5],plant:[.45,.45,1.1],rug:[2,1.4,.01],stairs:[1,3.2,2.75],stool:[.55,.55,.42],lamp_ceiling:[.4,.4,.08],lamp_downlight:[.1,.1,.02],lamp_spot:[.1,.1,.14],lamp_panel:[.6,.6,.03],lamp_uplight:[.35,.35,1.8],lamp_bollard:[.16,.16,.8],lamp_garden:[.12,.12,.3],radiator:[1,.1,.6],robot_vacuum:[.36,.5,.1],parking:[2.6,5.2,.02],lamp_pendant:[.4,.4,.8],ceiling_fan:[1.32,1.32,.32],lamp_floor:[.4,.4,1.7],lamp_table:[.28,.28,.45],lamp_wall:[.22,.12,.2],led_strip:[2,.04,.03],coffee_table:[1.1,.6,.42],tv_wall:[1.3,.08,.75],sideboard:[1.6,.45,.8],table_round:[1.1,1.1,.75],bench:[1.4,.45,.85],corner_bench:[2,1.6,.9],bar_stool:[.42,.42,.75],kitchen_wall:[.8,.35,.7],kitchen_tall:[.6,.62,2.1],island:[1.8,.9,.92],dishwasher:[.6,.62,.92],bunk_bed:[1,2.05,1.65],dresser:[1,.5,.9],washer:[.6,.6,.85],dryer:[.6,.6,.85],office_chair:[.65,.65,1.1],tall_cabinet:[.6,.6,2.1],coat_rack:[1,.35,1.9]};var Ls=["interior","front","front_glass","sidelight","sidelights","glass","sliding","passage"],Cs=["standard","bars","glass_wall"],Xi=new Set(["interior","front"]);function nn(t,e){return t.type==="door"?t.style&&Ls.includes(t.style)?t.style:e?"front":"interior":t.style&&Cs.includes(t.style)?t.style:"standard"}function Eu(t,e,n,r){if(e!=="sidelight"&&e!=="sidelights")return null;let i=e==="sidelights",o=t-.04,s=Math.min(1.05,Math.max(.6,o-(i?.6:.3))),l=(o-s)/(i?2:1),a=r.sidelight_width??l,c=i?r.sidelight_width2??r.sidelight_width??l:0;a=Math.max(.1,a),c=i?Math.max(.1,c):0;let u=o-.5;if(a+c>u){let p=Math.max(0,u)/(a+c);a*=p,c*=p}return i?{panels:[[.02,.02+a],[t-.02-c,t-.02]],x0:.02+a,x1:t-.02-c}:(n?!!r.sidelight_hinge:!r.sidelight_hinge)?{panels:[[.02,.02+a]],x0:.02+a,x1:t-.02}:{panels:[[t-.02-a,t-.02]],x0:.02,x1:t-.02-a}}function Ns(t){return t==="front"||t==="front_glass"||t==="sidelight"||t==="sidelights"}var An={door:{type:"door",leaves:1,width:.9,sill:0,height:2.05,style:"interior"},front:{type:"door",leaves:1,width:1,sill:0,height:2.1,style:"front"},door_double:{type:"door",leaves:2,width:1.6,sill:0,height:2.05},window:{type:"window",leaves:1,width:1.2,sill:.9,height:1.3},window_double:{type:"window",leaves:2,width:1.6,sill:.9,height:1.3},terrace:{type:"window",leaves:1,width:1,sill:0,height:2.1},terrace_double:{type:"window",leaves:2,width:1.8,sill:0,height:2.1},lift_slide:{type:"window",leaves:1,width:2.4,sill:0,height:2.15,opens:"slide"},garage:{type:"garage",leaves:1,width:2.5,sill:0,height:2.1},glass_wall:{type:"window",leaves:1,width:2,sill:0,height:2.4,style:"glass_wall"}};function Fn(t){if(t.type==="garage")return"garage";if(t.type==="window"&&t.style==="glass_wall")return"glass_wall";if(t.type==="window"&&t.opens==="slide"&&t.sill<.1)return"lift_slide";let e=t.leaves===2;return t.type==="door"?!e&&t.style&&Ns(t.style)?"front":e?"door_double":"door":t.sill<.1?e?"terrace_double":"terrace":e?"window_double":"window"}function Oe(t){t.energy={..._u,...t.energy??{}},t.presence=t.presence??[],t.version=1,t.settings={...vu,...t.settings,roof:{...yu,...t.settings?.roof??{}}},t.floors.forEach((e,n)=>{let r=Ve(e.id,e.name??`Floor ${n+1}`,e.elevation??n*2.8);for(let i of Object.keys(r))e[i]===void 0&&(e[i]=r[i])});for(let e of t.floors){e.outdoor=e.outdoor??[],e.walls=e.walls??[],e.rooms=e.rooms.map(r=>({...r,name:r.name??"",area_id:r.area_id??null,floor_material:r.floor_material??"wood",panel:r.panel??[]})),e.ha_floor=e.ha_floor??null,e.placements=e.placements.map(r=>({...r,mount:r.mount??null,rotation:r.rotation??0})),e.furniture=e.furniture.map(r=>({...r,entity:r.entity??null,power:r.power??null}));let n=e.placements.filter(r=>r.entity_id.startsWith("light."));if(n.length){let r={ceiling:"lamp_ceiling",floor:"lamp_floor",table:"lamp_table",wall:"lamp_wall"};for(let i of n){let o=r[i.mount??"ceiling"],[s,l,a]=nt[o],c=`lamp_${i.entity_id.slice(6).replace(/[^A-Za-z0-9_\-.]/g,"_")}`.slice(0,54),u=c,d=1;for(;e.furniture.some(p=>p.id===u);)u=`${c}_${d++}`;e.furniture.push({id:u,type:o,x:i.x,z:i.z,rotation:0,w:s,d:l,h:a,variant:null,entity:i.entity_id,power:null,animations_enabled:i.animations_enabled,effect_animations:structuredClone(i.effect_animations)})}e.placements=e.placements.filter(i=>!i.entity_id.startsWith("light."))}e.openings=e.openings.map(r=>({...r,type:["door","window","garage"].includes(r.type)?r.type:"door",edge:Number.isInteger(r.edge)?r.edge:0,offset:Number.isFinite(r.offset)?r.offset:.5,width:Number.isFinite(r.width)&&r.width>0?r.width:r.type==="garage"?2.5:r.type==="window"?1.2:.9,height:Number.isFinite(r.height)&&r.height>0?r.height:r.type==="window"?1.3:r.type==="garage"?2.1:2.05,sill:Number.isFinite(r.sill)?r.sill:r.type==="window"?.9:0,hinge:r.hinge??"left",leaves:r.leaves??1,swing:r.swing??"in",style:r.style??null,cover:r.cover??null,contact:r.contact??null,contact2:r.contact2??null,tilt:r.tilt??null}))}return Fb(t),t}function Fb(t){let e=(n,r)=>{let i=new Set;for(let o of n)(typeof o.id!="string"||!o.id||i.has(o.id))&&(o.id=I(r)),i.add(o.id)};e(t.floors,"floor");for(let n of t.floors){for(let r of n.rooms)(typeof r.id!="string"||!r.id)&&(r.id=I("room"));e(n.openings,"op"),e(n.furniture,"furn"),e(n.outdoor,"out")}}function I(t){return`${t}_${Math.random().toString(36).slice(2,10)}`}function _e(t){let e=0;for(let n=0;no+s[0],0)/i,t.reduce((o,s)=>o+s[1],0)/i]}let n=0,r=0;for(let i=0;i1e-6&&Math.abs(r-o)>1e-6)return!1}return!0}function de(t){let e=1/0,n=1/0,r=-1/0,i=-1/0;for(let[o,s]of t)e=Math.min(e,o),n=Math.min(n,s),r=Math.max(r,o),i=Math.max(i,s);return{x0:e,z0:n,x1:r,z1:i}}function Bs(t){let e=t.rotation*Math.PI/180,n=Math.cos(e),r=Math.sin(e),i=t.w/2,o=t.d/2;return[[-i,-o],[i,-o],[i,o],[-i,o]].map(([s,l])=>[t.x+s*n-l*r,t.z+s*r+l*n])}function C(t,e){let n=!1;for(let r=0,i=e.length-1;rt[1]!=a>t[1]&&t[0]<(l-o)*(t[1]-s)/(a-s)+o&&(n=!n)}return n}var Ji={lamp_ceiling:"ceiling",lamp_downlight:"downlight",lamp_spot:"spot",lamp_panel:"panel",lamp_uplight:"uplight",lamp_bollard:"bollard",lamp_garden:"garden",lamp_pendant:"pendant",ceiling_fan:"fan",lamp_floor:"floor",lamp_table:"table",lamp_wall:"wall",led_strip:"strip"};var Ws=t=>t.trim().replace(/^\/local\/www\//i,"/local/"),Vs=t=>/^(https:\/\/|\/local\/|\/hacsfiles\/)\S+\.m?js(\?\S*)?$/i.test(t.trim());var zb=globalThis,Fu=zb.__nextfloorPluginStore??={plugins:new Map,listeners:new Set},Ks=Fu.plugins,Au=Fu.listeners;var Pb=5;function Tu(t,e){t.errors.lengthAu.delete(t)}var js=()=>[...Ks.values()].map(t=>t.status),zu=()=>[...Ks.values()].flatMap(t=>Object.keys(t.plugin.lightAnimations??{}));function*eo(t,e){for(let{plugin:n,status:r}of Ks.values())for(let i of n.devices??[]){let o=!1;try{o=i.match(t,e)}catch(s){Tu(r,s)}o&&(yield{device:i,status:r})}}function to(t,e){for(let{device:n}of eo(t,e))return n.kind??"sensor";return null}function Pu(t,e){let n=t.states[e];if(!n)return null;let r=Db({hass:t,entityId:e,state:n})?.icon?.trim();return r&&/^mdi:[a-z0-9-]+$/i.test(r)?r:null}function Db(t){let e=null;for(let{device:n,status:r}of eo(t.entityId,t.state))if(n.marker)try{let i=n.marker(t);if(!i)continue;e={...e??{}},typeof i.icon=="string"&&i.icon&&(e.icon=i.icon),typeof i.text=="string"&&(e.text=i.text.slice(0,60)),typeof i.active=="boolean"&&(e.active=i.active)}catch(i){Tu(r,i)}return e}function no(t,e){return t?typeof t=="string"?t:t[e]??t[e.split("-")[0]]??t.en??Object.values(t)[0]??"":""}function Du(t,e){let n=[];for(let{device:r,status:i}of eo(t,e))r.settings?.length&&n.push({pluginId:i.id,name:i.name,settings:r.settings});return n}function Iu(t,e){let n={};for(let r of t??[]){let i=e?.[r.key],o=r.type==="number"?typeof i=="number"&&Number.isFinite(i):r.type==="boolean"?typeof i=="boolean":typeof i=="string"&&(r.options??[]).some(([s])=>s===i);n[r.key]=o?i:r.default}return n}function Ou(t,e){for(let{device:n}of eo(t,e))if(n.floorWedge)return!0;return!1}var Ib=new Set(["temperature","humidity","power","carbon_dioxide","energy","gas","water","volume","volume_storage","volume_flow_rate","illuminance","pressure","atmospheric_pressure","pm1","pm25","pm10","volatile_organic_compounds","volatile_organic_compounds_parts","carbon_monoxide","nitrogen_dioxide","moisture","sound_pressure"]),Ob=new Set(["m\xB3","m3","L","l","kWh","Wh","MWh","lx"]),Hb=new Set(["door","window","opening","garage_door","motion","occupancy","presence","smoke","moisture","gas","carbon_monoxide"]),Lb=new Set(["battery","signal_strength","timestamp","date","duration","data_rate","data_size","frequency","enum"]);function Dt(t,e){let n=t.entities?.[e];return n&&(n.area_id||(n.device_id?t.devices?.[n.device_id]?.area_id:null))||null}var Lu=(t,e)=>{let n=t.entities?.[e];return!!(n?.hidden||n?.entity_category)},je=(t,e)=>Q(e)??to(e,t.states[e]);function Hu(t,e){let n=t.states[e];if(!n||Lu(t,e))return!1;if(to(e,n)!==null)return!0;let r=Q(e);if(!r)return!1;let i=n.attributes.device_class;return e.startsWith("event.")?!i||i==="button"||i==="doorbell":r==="sensor"?i?Ib.has(i):Ob.has(String(n.attributes.unit_of_measurement??"")):r==="binary"?i?Hb.has(i):!!t.entities?.[e]?.area_id:!0}function Cb(t,e){let n=t.states[e];return Q(e)!=="sensor"||!n?.attributes.unit_of_measurement||Lu(t,e)||Lb.has(String(n.attributes.device_class??""))?!1:Number.isFinite(Number(n.state))||Ie(n)}var io=(t,e)=>e.startsWith("sensor.")&&t.states[e]?.attributes.device_class==="power",Gs=null;Qi(()=>Gs=null);function Us(t,e){let n=t.get(e);return n||t.set(e,n=[]),n}function Nb(t){let e=new Map,n=new Map,r=new Map,i=new Map,o=[],s=u=>{(Hu(t,u)||Cb(t,u))&&Ft(je(t,u))&&o.push(u)};for(let[u,d]of Object.entries(t.entities??{})){let p=d.device_id;p&&d.area_id&&(i.get(p)??i.set(p,new Set).get(p)).add(d.area_id),p&&io(t,u)&&Us(n,p).push(u),p&&!d.hidden&&!d.entity_category&&(r.get(p)??r.set(p,new Set).get(p)).add(As(u));let h=Dt(t,u);h===null?s(u):Hu(t,u)&&Us(e,h).push(u)}if(t.entities)for(let u of Object.keys(t.states))t.entities[u]||s(u);let l=Fs.indexOf("binary")-.5,a=u=>{let d=Q(u),p=d?Fs.indexOf(d):l;return p>l&&to(u,t.states[u])!==null?l:p};o.sort((u,d)=>a(u)-a(d)||B(t,u).localeCompare(B(t,d)));for(let[u,d]of e){let p=t.areas?.[u]?.name;d.sort((h,f)=>a(h)-a(f)||B(t,h,p).localeCompare(B(t,f,p)))}let c=new Set;for(let[u,d]of i)d.size>1&&c.add(u);return{entities:t.entities,devices:t.devices,states:t.states,stateCount:Object.keys(t.states).length,byArea:e,powerByDevice:n,withoutArea:o,domainsByDevice:r,hubs:c}}function zn(t){let e=Gs;return e&&e.entities===t.entities&&e.devices===t.devices&&(e.states===t.states||(e.states=t.states,Object.keys(t.states).length===e.stateCount))?e:Gs=Nb(t)}function ye(t,e){let n=ro(t,e.area_id);return e.sub_areas?.length?[...new Set([...n,...e.sub_areas.flatMap(r=>ro(t,r))])]:n}function ro(t,e){return!e||!t.entities?[]:zn(t).byArea.get(e)??[]}function Cu(t,e){if(!t.entities)return[];let n=[];for(let[r,i]of zn(t).byArea){let o=i.filter(s=>Ft(je(t,s)));r!==e&&o.length>0&&n.push({areaId:r,name:t.areas?.[r]?.name??r,ids:o})}return n.sort((r,i)=>r.name.localeCompare(i.name))}var Nu=t=>t.entities?zn(t).withoutArea:[],Zs=(t,e)=>!!t.entities&&zn(t).hubs.has(e),oo=(t,e)=>t.entities?zn(t).powerByDevice.get(e)??[]:[];function Pn(t,e){let n=new Map;for(let i of e)Us(n,t.entities?.[i]?.device_id??`entity:${i}`).push(i);let r=new Map(e.map((i,o)=>[i,o]));return[...n.values()].map(i=>{let o=i.find(s=>!t.entities?.[s]?.name)??i[0];return{primary:o,others:i.filter(s=>s!==o)}}).sort((i,o)=>r.get(i.primary)-r.get(o.primary))}var so=(t,e)=>Pn(t,e).map(n=>n.primary),Bb={temperature:"temperature",humidity:"humidity",co2:"carbon_dioxide",illuminance:"illuminance"};function qs(t,e,n,r=!1){let i=t.states[e]?.attributes;if(!i)return!1;let o=(i.symcon_variable_type===1||i.symcon_variable_type===2)&&typeof i.symcon_id=="number";if(typeof i.symcon_id=="number"&&!o||!o&&!/^(sensor|input_number|number)\./.test(e))return!1;if(r&&o)return!0;let s=String(i.unit_of_measurement??"").replace(/\s/g,"").toLowerCase();return n==="temperature"&&["\xB0c","\xB0f","\u2103","\u2109","k"].includes(s)||n==="humidity"&&!i.device_class&&["%","%rh","%r.h.","%rf","%r.f."].includes(s)||n==="co2"&&s==="ppm"&&/co[₂2]/i.test(String(i.friendly_name??""))||n==="illuminance"&&["lx","lux"].includes(s)?!0:i.device_class===Bb[n]}var Wb=new Set(["climate","water_heater","switch","button","camera","media_player","vacuum","light","fan","lawn_mower"]),Vb=["vorlauf","r(\xFC|ue)cklauf","flow","return","d(\xFC|ue)se","nozzle","hotend","extruder","druckbett","heatbed","(^|[^a-z])bed($|[^a-z])","chamber","cpu","gpu","chip","soc","akku","batter","wasser","water","kessel","boiler","au(\xDF|ss)en","outdoor","outside","abgas","exhaust","sole","brine","verdampfer","kondensat","verdichter","compressor","motor","k(\xFC|ue)hl","freezer","fridge","gefrier"],Kb=new RegExp(`(${Vb.join("|")})`,"i");function Ys(t,e){let n=t.entities?.[e]?.device_id,r=n&&!Zs(t,n)?zn(t).domainsByDevice.get(n):void 0;return r&&[...r].some(i=>Wb.has(i))?!1:!Kb.test(`${e} ${t.states[e]?.attributes.friendly_name??""}`)}function Bu(t,e,n,r){let i=n.climate?.[r];if(i==="none")return[];if(i)return[i].flat().filter(c=>t.states[c]);let o=(e?.placements??[]).filter(c=>c.entity_id.startsWith("sensor.")),s=o.filter(c=>C([c.x,c.z],n.points)).map(c=>c.entity_id),l=new Set(o.filter(c=>!C([c.x,c.z],n.points)).map(c=>c.entity_id));return[...new Set([...ye(t,n).filter(c=>!l.has(c)),...s])].filter(c=>c.startsWith("sensor.")&&qs(t,c,r)&&Ys(t,c))}function Wu(t){let e=t.attributes;if(typeof e.symcon_numeric_value!="number")return null;let n=typeof e.symcon_min=="number"?e.symcon_min:0,r=typeof e.symcon_max=="number"&&e.symcon_max>n?e.symcon_max:100;return Math.max(0,Math.min(100,(e.symcon_numeric_value-n)/(r-n)*100))}function ao(t,e){let n=t?.states[e];if(!n)return!1;let r=n.attributes;return typeof r.symcon_id=="number"?r.symcon_variable_type===1||r.symcon_variable_type===2:typeof r.current_position=="number"||/^(sensor|number|input_number)\./.test(e)&&!!n.state.trim()&&Number.isFinite(Number(n.state))}function lo(t,e){let n=e?t.states[e]:void 0;if(!n||Ie(n))return null;let r=n.attributes;if(r.nf_cover_control&&typeof r.current_position=="number")return r.current_position;let i=Wu(n);if(i!==null)return i;if(typeof r.current_position=="number")return Math.max(0,Math.min(100,r.current_position));if(!n.state.trim())return null;let o=Number(n.state);if(!Number.isFinite(o))return null;let s=r.unit_of_measurement==="%"||o>1||o<0?o:o*100;return Math.max(0,Math.min(100,s))}var jb=new Set([void 0,"shutter","blind","awning","shade","curtain","window"]),Gb=new Set(["garage","gate"]),Ub=new Set(["window","opening"]);function Rr(t,e,n=!1){let r=new Map;return t.forEach((i,o)=>{let s=n&&e.length===1?e[0]:e[o];s&&r.set(i.id,s)}),r}var Vu=(t,e)=>t==="none"?null:t??e??null,It=t=>t&&t!=="none"?t:null;function Ot(t,e){let n=new Map;for(let r of e)for(let i of r.rooms){let o=r.openings.filter(g=>g.room_id===i.id).sort((g,b)=>g.edge-b.edge||g.offset-b.offset);if(o.length===0)continue;let s=ye(t,i),l=g=>t.states[g]?.attributes.device_class,a=g=>s.filter(b=>Q(b)==="binary"&&g(l(b)??"")),c=g=>o.filter(b=>b.type===g),u=Rr(c("window"),s.filter(g=>Q(g)==="cover"&&jb.has(l(g))),!0),d=Rr(c("window"),a(g=>Ub.has(g))),p=Rr(c("door"),a(g=>g==="door")),h=Rr(c("garage"),s.filter(g=>Q(g)==="cover"&&Gb.has(l(g)??""))),f=Rr(c("garage"),a(g=>g==="garage_door"));for(let g of o){let b=g.type==="window"?u:g.type==="garage"?h:null,y=g.type==="window"?d:g.type==="garage"?f:p,v=g.leaves===2;n.set(g.id,{cover:Vu(g.cover,b?.get(g.id)),contact:g.sensor==="handle"&&g.contact==null?null:Vu(g.contact,y.get(g.id)),tilt:g.tilt==="none"?null:g.tilt,contact2:v?It(g.contact2):null,tilt2:v?It(g.tilt2):null,position:It(g.position),positionInverted:!!g.position_inverted,tiltAngle:It(g.tilt_angle),tiltMax:g.tilt_max??null,tiltOffset:g.tilt_offset??null,tiltInvert:!!g.tilt_invert,shut:!!g.shut,angled:g.type==="door"&&!!g.open_angle,lock:g.type==="door"?It(g.lock):null,cover2:g.type==="garage"?null:It(g.cover2),coverTilt:It(g.cover_tilt),cover2Tilt:It(g.cover2_tilt),coverInverted:!!g.cover_inverted,coverTiltInverted:!!g.cover_tilt_inverted,cover2Inverted:!!g.cover2_inverted,cover2TiltInverted:!!g.cover2_tilt_inverted})}}return n}var Zb=[[/^(tilted|tilt|gekippt|kipp)/i,"tilted"],[/^(open|opened|offen|geöffnet|on)$/i,"open"],[/^(closed|close|geschlossen|zu|off)$/i,"closed"]];function Xs(t){if(!t||Ie(t))return null;let e=t.attributes.window_state;for(let n of[typeof e=="string"?e:"",t.state]){let r=n.trim(),i=r&&Zb.find(([o])=>o.test(r));if(i)return i[1]}return null}var Ku=new WeakMap,ju=new WeakMap;function Gu(t,e){let n=ju.get(t)??t,r=Ku.get(n)??new WeakMap;Ku.set(n,r);let i=r.get(e);if(i)return i;let o=new Map;for(let a of e)for(let c of a.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 a of Ot(n,e).values())a.cover&&!o.has(a.cover)&&o.set(a.cover,{tilt:a.coverTilt,position:a.position}),a.cover2&&!o.has(a.cover2)&&o.set(a.cover2,{tilt:a.cover2Tilt});let s={...n.states};for(let[a,c]of o){let u=n.states[a];if(!u)continue;let d={...u.attributes,nf_cover_control:!0},p=lo(n,c.position);p===null&&(p=typeof u.attributes.current_position=="number"?u.attributes.current_position:null),p!==null&&(d.current_position=p);let h=c.tilt?n.states[c.tilt]:u,f=typeof h?.attributes.current_tilt_position=="number"?h.attributes.current_tilt_position:c.tilt?lo(n,c.tilt):null;f!==null&&(d.current_tilt_position=f,d.supported_features=Number(d.supported_features??0)|128);let g=u.state;typeof d.current_position=="number"&&g!=="unavailable"&&g!=="unknown"&&g!=="opening"&&g!=="closing"&&(g=d.current_position>0?"open":"closed"),s[a]={...u,state:g,attributes:d}}let l={...n,states:s,callService:async(a,c,u={})=>{if(a!=="cover")return n.callService(a,c,u);let d=Array.isArray(u.entity_id)?u.entity_id:[u.entity_id],p=async h=>{let f=typeof h=="string"?o.get(h):void 0;if(!f)return n.callService(a,c,{...u,entity_id:h});let g={...u,entity_id:h},b=c;(b==="toggle"||b==="toggle_cover")&&(b=s[String(h)]?.state==="closed"?"open_cover":"close_cover");let y=b.includes("tilt");y&&f.tilt&&(g.entity_id=f.tilt);let v=f.tilt?n.states[f.tilt]:void 0;return y&&f.tilt&&!v?.attributes.symcon_id&&typeof v?.attributes.current_tilt_position!="number"&&(b==="set_cover_tilt_position"?(b="set_cover_position",g.position=g.tilt_position,delete g.tilt_position):b==="open_cover_tilt"?b="open_cover":b==="close_cover_tilt"&&(b="close_cover")),n.callService(a,b,g)};return Array.isArray(u.entity_id)?Promise.all(d.map(p)):p(d[0])}};return ju.set(l,n),r.set(e,l),l}var X=t=>t?.symconObjects!==void 0;function He(t,e,n=[0,1,2,3]){let r=t?.states[e]?.attributes;return!!r?.symcon_id&&!r.symcon_source_entity&&n.includes(Number(r.symcon_variable_type))}function Dn(t){return!t||t.state==="unknown"||t.state==="unavailable"?null:t.attributes.symcon_value??t.attributes.symcon_numeric_value??t.state}function rn(t){let e=Dn(t);if(e===null||typeof e=="boolean"||e==="")return null;let n=Number(e);return Number.isFinite(n)?n:null}function Er(t){let e=Dn(t);if(e===null)return null;if(typeof e=="boolean")return e;if(typeof e=="number")return e>0;let n=String(e).trim().toLowerCase();if(["on","true","1","home","open","an","ein","ja","regen","rain","wet","nass"].includes(n))return!0;if(["off","false","0","not_home","closed","aus","nein","trocken","dry"].includes(n))return!1;let r=Number(n);return n!==""&&Number.isFinite(r)?r>0:null}function Uu(t){return Dn(t)===null?"\u2013":String(t?.attributes.symcon_formatted??Dn(t))}function Zu(t,e){switch(e){case"m/s":return t*3.6;case"mph":return t*1.609;case"kn":return t*1.852;case"ft/s":return t*1.097;default:return t}}var qu="weather.nextfloor_symcon",Xu={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"},Yu=new WeakMap;function qb(t){let e=t.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 Ju(t,e){if(!X(t))return t;let n=e.weather_variables??{};if(!e.rain_sensor&&!Object.values(n).some(h=>h&&h!=="none"))return t;let r=Yu.get(t)??new WeakMap;Yu.set(t,r);let i=r.get(e);if(i)return i;let o={friendly_name:"Wetter",nf_symcon_weather:!0},s=h=>n[h]&&n[h]!=="none"?t.states[n[h]]:void 0;for(let h of["temperature","humidity","pressure","cloud_coverage","precipitation","precipitation_total","illuminance","uv_index","visibility"]){let f=s(h),g=rn(f);g!==null&&(o[h]=h==="cloud_coverage"&&f?.attributes.symcon_max===1?g*100:g),f?.attributes.unit_of_measurement&&(o[`${h}_unit`]=f.attributes.unit_of_measurement)}for(let h of["wind_speed","wind_gust_speed"]){let f=s(h),g=rn(f);g!==null&&(o[h]=Zu(g,f?.attributes.unit_of_measurement))}o.wind_speed_unit="km/h";let l=Dn(s("wind_bearing"));l!==null&&(o.wind_bearing=l);let a=qb(Uu(s("condition"))),c=e.rain_sensor?t.states[e.rain_sensor]:void 0,u=Er(c);u!==null&&e.rain_sensor_inverted&&(u=!u),u===null&&typeof o.precipitation=="number"&&(u=o.precipitation>0),Er(s("lightning"))?a=u?"lightning-rainy":"lightning":Er(s("snow"))?a=u?"snowy-rainy":"snowy":Er(s("fog"))?a="fog":u===!0?a=Number(o.precipitation??0)>=8?"pouring":"rainy":u===!1&&a&&/rain|pouring/.test(a)&&(a=null),!a&&typeof o.cloud_coverage=="number"&&(a=o.cloud_coverage>70?"cloudy":o.cloud_coverage>20?"partlycloudy":"sunny"),!a&&u===!1&&(a="sunny");let d={entity_id:qu,state:a??"unknown",attributes:o},p={...t,states:{...t.states,[qu]:d}};return r.set(e,p),p}var In={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},on=t=>(...e)=>({_$litDirective$:t,values:e}),Ht=class{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,n,r){this._$Ct=e,this._$AM=n,this._$Ci=r}_$AS(e,n){return this.update(e,n)}update(e,n){return this.render(...n)}};var Ar=class extends Ht{constructor(e){if(super(e),this.it=_,e.type!==In.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===_||e==null)return this._t=void 0,this.it=e;if(e===tt)return e;if(typeof e!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(e===this.it)return this._t;this.it=e;let n=[e];return n.raw=n,this._t={_$litType$:this.constructor.resultType,strings:n,values:[]}}};Ar.directiveName="unsafeHTML",Ar.resultType=1;var Qu=on(Ar);var ed=/\b(tv|fernseh|television|fire ?tv|apple ?tv|chromecast|shield)/i,td=/(kühl|fridge|gefrier|freezer)/i,nd=/(spülmaschine|geschirrspül|dishwasher)/i,Yb=/(kochfeld|herd|induktion|cooktop)/i,Xb={robot_vacuum:/(saug|vacuum|robo|roomba|roborock|dreame|ecovacs|deebot)/i,tv_board:ed,tv_wall:ed,desk:/\b(pc|computer|rechner|desktop|monitor|workstation)/i,fridge:td,fridge_smart:td,stove:/(herd|kochfeld|cooktop|stove|induktion)/i,kitchen_tall:/(backofen|oven|ofen)/i,dishwasher:nd,washer:/(waschmaschine|washer|washing)/i,dryer:/(trockner|dryer)/i,kitchen:/(kaffee|coffee|wasserkocher|kettle)/i,island:Yb,sink:nd,radiator:/(heiz|radiator|thermostat|climate|hk|trv)/i},rd={lamp_ceiling:/(decke|ceiling|haupt|main)/i,lamp_downlight:/(spot|strahler|downlight|einbau)/i,lamp_spot:/(spot|strahler)/i,lamp_panel:/(panel|decke|ceiling)/i,lamp_uplight:/(fluter|uplight|steh)/i,lamp_bollard:/(weg|garten|garden|path|poller|außen|aussen|outdoor)/i,lamp_garden:/(garten|garden|spot|außen|aussen|outdoor|baum|tree)/i,lamp_pendant:/(pendel|pendant|hänge|esstisch|dining)/i,ceiling_fan:/(ventilator|fan)/i,lamp_floor:/(steh|floor)/i,lamp_table:/(tisch|nacht|table|bedside|lese|reading)/i,lamp_wall:/(wand|wall)/i,led_strip:/(led|strip|streifen|leiste|band)/i},id=new Set(["tv_board","tv_wall"]);var On=t=>id.has(t)||!!Uc(t),co=t=>!!U(t)?.electric&&/speaker|multiroom|soundbar/.test(t.split(":").pop()??t),Tr=t=>On(t)||t==="desk"||t==="fridge_smart",Jb=t=>!!t&&t!=="none";function Qb(t,e){if(io(t,e))return e;let n=t.entities?.[e]?.device_id;return n?oo(t,n).find(r=>r!==e)??null:null}var ey=(t,e,n)=>t.rooms.find(r=>r.points.length>=3&&C([e,n],r.points));function Fr(t,e,n,r){return t.find(i=>e?.test(n(i)))??(r?t[0]??null:null)}function Me(t,e){let n=new Map;for(let r of e){let i=new Set([...r.furniture.flatMap(o=>[o.entity,o.power,o.fan_entity]),...r.placements.map(o=>o.entity_id)].filter(Jb));for(let o of r.furniture){let s=o.type in rd,l=Rn(o.type),a=s?rd[o.type]:Xb[o.type];if(!a&&!l&&!co(o.type)&&o.entity==null&&o.power==null)continue;let c=ey(r,o.x,o.z),u=(c?so(t,ye(t,c)):[]).filter(b=>!i.has(b)),d=b=>`${b} ${B(t,b)}`,p=b=>u.filter(y=>Q(y)===b),h=o.entity==="none"?null:o.entity??null;if(o.entity==null){if(o.type==="ceiling_fan"){let b=(c?ye(t,c):[]).filter(v=>!i.has(v)),y=new Set(b.filter(v=>Q(v)==="fan").map(v=>t.entities?.[v]?.device_id).filter(Boolean));h=b.find(v=>Q(v)==="light"&&y.has(t.entities?.[v]?.device_id))??Fr(p("light"),a,d,!1)}else if(s)h=Fr(p("light"),a,d,!0);else if(o.type==="robot_vacuum"){let b=c?.area_id??null;h=Object.keys(t.entities??{}).find(y=>y.startsWith("vacuum.")&&!i.has(y)&&Dt(t,y)===b)??null}else if(o.type==="radiator"||l)h=Fr(p("climate"),a,d,!0);else if(On(o.type)){let b=p("media");h=b.find(y=>t.states[y]?.attributes.device_class==="tv")??Fr(b,a,d,id.has(o.type))}else if(co(o.type)){let b=p("media").filter(y=>t.states[y]?.attributes.device_class!=="tv");h=Fr(b,a,d,!1)??(b.length===1?b[0]:null)}else a&&(h=u.find(b=>["switch","media","fan"].includes(Q(b)??"")&&a.test(d(b)))??null);h&&i.add(h)}let f=o.power==="none"?null:o.power??null;o.power==null&&(f=h?Qb(t,h):null,!f&&a&&c&&!s&&(f=ye(t,c).find(b=>io(t,b)&&!i.has(b)&&a.test(d(b)))??null),f&&i.add(f));let g=null;if(o.type==="ceiling_fan"&&(g=o.fan_entity==="none"?null:o.fan_entity??null,o.fan_entity==null)){let b=(c?ye(t,c):[]).filter(v=>Q(v)==="fan"&&!i.has(v)),y=h?t.entities?.[h]?.device_id:void 0;g=(y?b.find(v=>t.entities?.[v]?.device_id===y):void 0)??b[0]??null,g&&i.add(g)}(h||f||g)&&n.set(o.id,{entity:h,power:f,...o.type==="ceiling_fan"?{fan:g}:{}})}}return n}var od=t=>t==="fridge"||t==="fridge_smart"||/(fridge|freezer|kuehl|gefrier|chest_freezer)/.test(t.slice(t.lastIndexOf(":")+1));function sd(t,e,n=[]){let r=[];for(let i of e){let o=(l,a)=>i.rooms.some(c=>c.points.length>=3&&C([l,a],c.points)),s=Me(t,[i]);r.push(...i.placements.filter(l=>l.outside||!o(l.x,l.z)).map(l=>l.entity_id)),r.push(...i.furniture.filter(l=>!o(l.x,l.z)).flatMap(l=>[s.get(l.id)?.entity,s.get(l.id)?.power]));for(let l of i.outdoor??[])l.area_id&&r.push(...so(t,ro(t,l.area_id))),r.push(l.pump_entity,l.temp_entity)}return[...new Set(r.filter(i=>!!i&&!!t.states[i]&&!n.includes(i)))]}function ty(t,e){return Math.min(...e.map((n,r)=>{let i=e[(r+1)%e.length],[o,s]=[i[0]-n[0],i[1]-n[1]],l=Math.min(1,Math.max(0,((t[0]-n[0])*o+(t[1]-n[1])*s)/(o*o+s*s||1)));return Math.hypot(t[0]-n[0]-o*l,t[1]-n[1]-s*l)}))}function ld(t,e,n=[]){let r=t.points;if(r.length<3||e.length===0)return[];let i=r.map(y=>y[0]),o=r.map(y=>y[1]),[s,l,a,c]=[Math.min(...i),Math.max(...i),Math.min(...o),Math.max(...o)],u=Math.min(l-s,c-a),d=Math.max(.1,Math.min(.25,u/8)),p=Math.min(.35,u/5),h=Math.min(.7,u/4),f=be(r),g=[];for(let y=s+d/2;y=p&&g.push({at:w,wallDistance:x})}g.length===0&&g.push({at:f,wallDistance:0});let b=[...n];return e.map(y=>{let v=Q(y)==="light",w=g[0].at,x=-1/0;for(let{at:M,wallDistance:A}of g){let T=b.length?Math.min(...b.map(P=>Math.hypot(M[0]-P[0],M[1]-P[1]))):3,F=Math.hypot(M[0]-f[0],M[1]-f[1]),H=Math.min(T,3)*2;Fx+1e-9&&(x=H,w=M)}let k=[Math.round(w[0]*100)/100,Math.round(w[1]*100)/100];return b.push(k),{entity_id:y,x:k[0],z:k[1],y:null,mount:null}})}var ad=/(^|_)(current_room|current_segment|aktueller_raum|current_area)($|_)/;function cd(t,e,n){if(n==="none")return null;if(n)return n;let r=e?t.entities?.[e]?.device_id:null;return!r||!t.entities?null:Object.values(t.entities).find(o=>o.device_id===r&&o.entity_id.startsWith("sensor.")&&(ad.test(o.translation_key??"")||ad.test(o.entity_id.split(".")[1])))?.entity_id??null}var me=t=>/^(sensor|input_number|number)\./.test(t),uo=t=>/^(binary_sensor|input_boolean)\./.test(t);function Hn(t,e){if(!me(e))return!1;let n=t?.states[e]?.attributes;return n?.device_class==="power"||n?.unit_of_measurement==="W"||n?.unit_of_measurement==="kW"}function ny(t,e){let n=t?.entities?.[e],r=n?.area_id??(n?.device_id?t?.devices?.[n.device_id]?.area_id:null);return r?t?.areas?.[r]?.name:void 0}function O(t,e){return Object.keys(t?.states??{}).filter(e).map(n=>{let r=ny(t,n),i=t?.states[n],o=typeof i?.attributes.symcon_path=="string"?i.attributes.symcon_path:void 0,s={id:n,label:r?`${B(t,n)} \xB7 ${r}`:B(t,n)};return o&&(s.detail=`Objektbaum: ${o}`),typeof i?.attributes.symcon_source_entity=="string"&&(s.sourceEntity=i.attributes.symcon_source_entity),s}).sort((n,r)=>n.label.localeCompare(r.label))}function ud(t,e,n){return e.unsupported?[]:O(t,r=>He(t,r,e.types)&&!e.excluded?.(r)).map(r=>{if(!e.role)return r;let i=t.states[r.id],o=`${e.role}.${i.attributes.symcon_id}`,s=n?t.states[n]:void 0,l=n&&(n===r.id||s?.attributes.symcon_source_entity===r.id)?n:t.states[o]?o:r.id;return l===r.id?r:{...r,id:l,sourceEntity:r.id}})}function ho(t,e){return t.power&&t.power!=="none"?t.power:e.get(t.id)?.power??null}var ve=ee`
+var $={cs:"4be67fcd522e",da:"0fe66a82bf2a",es:"bd89dffd1355",fi:"9a17bc084f56",fr:"6312d0f61ebf",hu:"27ba348531dc",it:"1b705e76dd00",nb:"c5ea24fb9ef6",nl:"b64142c67c2e",pl:"8527a4930402",pt:"31857a2d2277",ro:"e3cb5f449f0f",sk:"320611594db0",sl:"8071691ceda3",sv:"711b911ec8da",tr:"7c83ce1c3372",zh:"50518d9f494e"};var Pi=globalThis,Di=Pi.ShadowRoot&&(Pi.ShadyCSS===void 0||Pi.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,ys=Symbol(),wc=new WeakMap,vr=class{constructor(e,n,r){if(this._$cssResult$=!0,r!==ys)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=n}get styleSheet(){let e=this.o,n=this.t;if(Di&&e===void 0){let r=n!==void 0&&n.length===1;r&&(e=wc.get(n)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),r&&wc.set(n,e))}return e}toString(){return this.cssText}},kc=t=>new vr(typeof t=="string"?t:t+"",void 0,ys),ee=(t,...e)=>{let n=t.length===1?t[0]:e.reduce((r,i,o)=>r+(s=>{if(s._$cssResult$===!0)return s.cssText;if(typeof s=="number")return s;throw Error("Value passed to 'css' function must be a 'css' function result: "+s+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+t[o+1],t[0]);return new vr(n,t,ys)},xc=(t,e)=>{if(Di)t.adoptedStyleSheets=e.map(n=>n instanceof CSSStyleSheet?n:n.styleSheet);else for(let n of e){let r=document.createElement("style"),i=Pi.litNonce;i!==void 0&&r.setAttribute("nonce",i),r.textContent=n.cssText,t.appendChild(r)}},vs=Di?t=>t:t=>t instanceof CSSStyleSheet?(e=>{let n="";for(let r of e.cssRules)n+=r.cssText;return kc(n)})(t):t;var{is:cb,defineProperty:ub,getOwnPropertyDescriptor:db,getOwnPropertyNames:hb,getOwnPropertySymbols:pb,getPrototypeOf:fb}=Object,Ii=globalThis,$c=Ii.trustedTypes,mb=$c?$c.emptyScript:"",gb=Ii.reactiveElementPolyfillSupport,wr=(t,e)=>t,ws={toAttribute(t,e){switch(e){case Boolean:t=t?mb:null;break;case Object:case Array:t=t==null?t:JSON.stringify(t)}return t},fromAttribute(t,e){let n=t;switch(e){case Boolean:n=t!==null;break;case Number:n=t===null?null:Number(t);break;case Object:case Array:try{n=JSON.parse(t)}catch{n=null}}return n}},Mc=(t,e)=>!cb(t,e),Sc={attribute:!0,type:String,converter:ws,reflect:!1,useDefault:!1,hasChanged:Mc};Symbol.metadata??=Symbol("metadata"),Ii.litPropertyMetadata??=new WeakMap;var bt=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??=[]).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,n=Sc){if(n.state&&(n.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((n=Object.create(n)).wrapped=!0),this.elementProperties.set(e,n),!n.noAccessor){let r=Symbol(),i=this.getPropertyDescriptor(e,r,n);i!==void 0&&ub(this.prototype,e,i)}}static getPropertyDescriptor(e,n,r){let{get:i,set:o}=db(this.prototype,e)??{get(){return this[n]},set(s){this[n]=s}};return{get:i,set(s){let l=i?.call(this);o?.call(this,s),this.requestUpdate(e,l,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??Sc}static _$Ei(){if(this.hasOwnProperty(wr("elementProperties")))return;let e=fb(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(wr("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(wr("properties"))){let n=this.properties,r=[...hb(n),...pb(n)];for(let i of r)this.createProperty(i,n[i])}let e=this[Symbol.metadata];if(e!==null){let n=litPropertyMetadata.get(e);if(n!==void 0)for(let[r,i]of n)this.elementProperties.set(r,i)}this._$Eh=new Map;for(let[n,r]of this.elementProperties){let i=this._$Eu(n,r);i!==void 0&&this._$Eh.set(i,n)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){let n=[];if(Array.isArray(e)){let r=new Set(e.flat(1/0).reverse());for(let i of r)n.unshift(vs(i))}else e!==void 0&&n.push(vs(e));return n}static _$Eu(e,n){let r=n.attribute;return r===!1?void 0:typeof r=="string"?r:typeof e=="string"?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(e=>this.enableUpdating=e),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(e=>e(this))}addController(e){(this._$EO??=new Set).add(e),this.renderRoot!==void 0&&this.isConnected&&e.hostConnected?.()}removeController(e){this._$EO?.delete(e)}_$E_(){let e=new Map,n=this.constructor.elementProperties;for(let r of n.keys())this.hasOwnProperty(r)&&(e.set(r,this[r]),delete this[r]);e.size>0&&(this._$Ep=e)}createRenderRoot(){let e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return xc(e,this.constructor.elementStyles),e}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(e=>e.hostConnected?.())}enableUpdating(e){}disconnectedCallback(){this._$EO?.forEach(e=>e.hostDisconnected?.())}attributeChangedCallback(e,n,r){this._$AK(e,r)}_$ET(e,n){let r=this.constructor.elementProperties.get(e),i=this.constructor._$Eu(e,r);if(i!==void 0&&r.reflect===!0){let o=(r.converter?.toAttribute!==void 0?r.converter:ws).toAttribute(n,r.type);this._$Em=e,o==null?this.removeAttribute(i):this.setAttribute(i,o),this._$Em=null}}_$AK(e,n){let r=this.constructor,i=r._$Eh.get(e);if(i!==void 0&&this._$Em!==i){let o=r.getPropertyOptions(i),s=typeof o.converter=="function"?{fromAttribute:o.converter}:o.converter?.fromAttribute!==void 0?o.converter:ws;this._$Em=i;let l=s.fromAttribute(n,o.type);this[i]=l??this._$Ej?.get(i)??l,this._$Em=null}}requestUpdate(e,n,r,i=!1,o){if(e!==void 0){let s=this.constructor;if(i===!1&&(o=this[e]),r??=s.getPropertyOptions(e),!((r.hasChanged??Mc)(o,n)||r.useDefault&&r.reflect&&o===this._$Ej?.get(e)&&!this.hasAttribute(s._$Eu(e,r))))return;this.C(e,n,r)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(e,n,{useDefault:r,reflect:i,wrapped:o},s){r&&!(this._$Ej??=new Map).has(e)&&(this._$Ej.set(e,s??n??this[e]),o!==!0||s!==void 0)||(this._$AL.has(e)||(this.hasUpdated||r||(n=void 0),this._$AL.set(e,n)),i===!0&&this._$Em!==e&&(this._$Eq??=new Set).add(e))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(n){Promise.reject(n)}let e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(let[i,o]of this._$Ep)this[i]=o;this._$Ep=void 0}let r=this.constructor.elementProperties;if(r.size>0)for(let[i,o]of r){let{wrapped:s}=o,l=this[i];s!==!0||this._$AL.has(i)||l===void 0||this.C(i,void 0,o,l)}}let e=!1,n=this._$AL;try{e=this.shouldUpdate(n),e?(this.willUpdate(n),this._$EO?.forEach(r=>r.hostUpdate?.()),this.update(n)):this._$EM()}catch(r){throw e=!1,this._$EM(),r}e&&this._$AE(n)}willUpdate(e){}_$AE(e){this._$EO?.forEach(n=>n.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Eq&&=this._$Eq.forEach(n=>this._$ET(n,this[n])),this._$EM()}updated(e){}firstUpdated(e){}};bt.elementStyles=[],bt.shadowRootOptions={mode:"open"},bt[wr("elementProperties")]=new Map,bt[wr("finalized")]=new Map,gb?.({ReactiveElement:bt}),(Ii.reactiveElementVersions??=[]).push("2.1.2");var xs=globalThis,Rc=t=>t,Oi=xs.trustedTypes,Ec=Oi?Oi.createPolicy("lit-html",{createHTML:t=>t}):void 0,$s="$lit$",yt=`lit$${Math.random().toFixed(9).slice(2)}$`,Ss="?"+yt,_b=`<${Ss}>`,en=document,xr=()=>en.createComment(""),$r=t=>t===null||typeof t!="object"&&typeof t!="function",Ms=Array.isArray,Dc=t=>Ms(t)||typeof t?.[Symbol.iterator]=="function",ks=`[
+\f\r]`,kr=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Ac=/-->/g,Fc=/>/g,Jt=RegExp(`>|${ks}(?:([^\\s"'>=/]+)(${ks}*=${ks}*(?:[^
+\f\r"'\`<>=]|("|')|))|$)`,"g"),Tc=/'/g,zc=/"/g,Ic=/^(?:script|style|textarea|title)$/i,Rs=t=>(e,...n)=>({_$litType$:t,strings:e,values:n}),m=Rs(1),R=Rs(2),Jx=Rs(3),tt=Symbol.for("lit-noChange"),_=Symbol.for("lit-nothing"),Pc=new WeakMap,Qt=en.createTreeWalker(en,129);function Oc(t,e){if(!Ms(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return Ec!==void 0?Ec.createHTML(e):e}var Hc=(t,e)=>{let n=t.length-1,r=[],i,o=e===2?"":e===3?"":"",s=kr;for(let l=0;l"?(s=i??kr,d=-1):u[1]===void 0?d=-2:(d=s.lastIndex-u[2].length,c=u[1],s=u[3]===void 0?Jt:u[3]==='"'?zc:Tc):s===zc||s===Tc?s=Jt:s===Ac||s===Fc?s=kr:(s=Jt,i=void 0);let h=s===Jt&&t[l+1].startsWith("/>")?" ":"";o+=s===kr?a+_b:d>=0?(r.push(c),a.slice(0,d)+$s+a.slice(d)+yt+h):a+yt+(d===-2?l:h)}return[Oc(t,o+(t[n]||">")+(e===2?" ":e===3?"":"")),r]},Sr=class t{constructor({strings:e,_$litType$:n},r){let i;this.parts=[];let o=0,s=0,l=e.length-1,a=this.parts,[c,u]=Hc(e,n);if(this.el=t.createElement(c,r),Qt.currentNode=this.el.content,n===2||n===3){let d=this.el.content.firstChild;d.replaceWith(...d.childNodes)}for(;(i=Qt.nextNode())!==null&&a.length0){i.textContent=Oi?Oi.emptyScript:"";for(let h=0;h2||r[0]!==""||r[1]!==""?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=_}_$AI(e,n=this,r,i){let o=this.strings,s=!1;if(o===void 0)e=tn(this,e,n,0),s=!$r(e)||e!==this._$AH&&e!==tt,s&&(this._$AH=e);else{let l=e,a,c;for(e=o[0],a=0;a{let r=n?.renderBefore??e,i=r._$litPart$;if(i===void 0){let o=n?.renderBefore??null;r._$litPart$=i=new Rn(e.insertBefore(xr(),o),o,void 0,n??{})}return i._$AI(t),i};var Es=globalThis,Y=class extends bt{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){let e=super.createRenderRoot();return this.renderOptions.renderBefore??=e.firstChild,e}update(e){let n=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=Cc(n,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return tt}};Y._$litElement$=!0,Y.finalized=!0,Es.litElementHydrateSupport?.({LitElement:Y});var yb=Es.litElementPolyfillSupport;yb?.({LitElement:Y});(Es.litElementVersions??=[]).push("4.2.2");var Fs=t=>t.slice(0,t.indexOf(".")),vb={light:"light",switch:"switch",input_boolean:"switch",valve:"switch",fan:"fan",cover:"cover",climate:"climate",media_player:"media",lock:"lock",sensor:"sensor",binary_sensor:"binary",event:"sensor",scene:"scene",script:"script"},Q=t=>vb[Fs(t)]??null,Ts=["light","cover","climate","media","switch","fan","lock","binary","sensor","scene","script"];var Nc=new Set(["light","switch","fan"]),Ft=t=>t!==null&&t!=="scene"&&t!=="script",Ie=t=>!t||t.state==="unavailable"||t.state==="unknown"&&!t.entity_id.startsWith("event.");function B(t,e,n){let r=String(t?.states[e]?.attributes.friendly_name??t?.entities?.[e]?.name??e);if(!n||r.length<=n.length+1||!r.toLowerCase().startsWith(`${n.toLowerCase()} `))return r;let i=r.slice(n.length+1);return i[0].toUpperCase()+i.slice(1)}var Bc=t=>!!t&&t.entity_id.startsWith("sensor.")&&t.attributes.device_class==="enum";var Wc=t=>Math.min(1,Math.max(0,t));function wb(t){let e=Wc((t-2200)/4300),n=[1,.66,.26],r=[.78,.9,1];return[0,1,2].map(i=>n[i]+(r[i]-n[i])*e)}function As(t,e){if(!t||t.state!=="on")return null;let n=e&&!["unavailable","unknown"].includes(e.state)?e.attributes:t.attributes,r=typeof n.brightness=="number"?.2+.8*Math.sqrt(Wc(n.brightness/255)):1,i=n.rgb_color;return i&&!["color_temp","brightness","onoff"].includes(String(n.color_mode))?{color:[i[0]/255,i[1]/255,i[2]/255],level:r}:typeof n.color_temp_kelvin=="number"?{color:wb(n.color_temp_kelvin),level:r}:{color:[1,.71,.28],level:r}}function Vc(t,e,n){let r=As(t,n);if(r)return r;for(let i of e){let o=As(i);if(o)return{color:o.color,level:o.level*.6}}return null}function Wi(t,e,n=null){if(t==="light"&&n==="floor")return 1.95;if(t==="light"&&n==="table")return 1.25;if(t==="light"&&n==="wall")return 1.95;switch(t){case"light":return Math.max(.5,e-.25);case"cover":return Math.min(2,e-.3);case"climate":return .6;case"media":return .9;case"binary":case"sensor":return 1.4;default:return 1.05}}var Gc=[],Vi=new Map,kb=0,he=(t,e)=>`pack:${t}:${e}`,vt=t=>t.startsWith("pack:");function zs(t){Gc=t,Vi=new Map;for(let e of t)for(let n of e.items)Vi.set(he(e.id,n.id),n);kb+=1}var Rr=()=>Gc;var xb={};function G(t){if(!vt(t))return;let e=Vi.get(t);if(e)return e;let[,n,...r]=t.split(":"),i=xb[n];return i?Vi.get(he(i,r.join(":"))):void 0}var $b=.22;function Kc(t,e,n,r){let i=Math.min($b,n/3);if(r<=i*2.4||Math.abs(r-n)<1e-6)return e*(r/n)+(t-e)*(r/n);let o=e*(r/n),s=t-e;return s<=i?o+s:s>=n-i?o+r-(n-s):o+i+(s-i)*(r-2*i)/(n-2*i)}function Mr(t,e,n,r,i){return[Kc(t*r,n*r,r,i)/i,Kc(e*r,n*r,r,i)/i]}var jc=new WeakMap;function Zc(t,e,n,r){let[i,o,s]=t.size;if(t.vehicle||t.stretch||Math.abs(e-i)<1e-4&&Math.abs(n-o)<1e-4&&Math.abs(r-s)<1e-4)return t.parts;let l=`${e.toFixed(4)}|${n.toFixed(4)}|${r.toFixed(4)}`,a=jc.get(t),c=a?.get(l);if(c)return c;let u=t.parts.map(d=>{if(d.shape==="sweep")return d;let[p,h]=Mr(d.x-d.w/2,d.x+d.w/2,-.5,i,e),[f,g]=Mr(d.z-d.d/2,d.z+d.d/2,-.5,o,n),[b,y]=Mr(d.y,d.y+d.h,0,s,r);if(d.rot)return{...d,x:(p+h)/2,z:(f+g)/2,w:d.w*i/e,d:d.d*o/n,y:b,h:y-b};let v={...d,x:(p+h)/2,z:(f+g)/2,w:h-p,d:g-f,y:b,h:y-b};if(d.shape==="loft"){let[w,x,k,M]=[d.tx??d.x,d.tz??d.z,d.tw??d.w,d.td??d.d],[A,T]=Mr(w-k/2,w+k/2,-.5,i,e),[F,L]=Mr(x-M/2,x+M/2,-.5,o,n);Object.assign(v,{tx:(A+T)/2,tz:(F+L)/2,tw:T-A,td:L-F})}return v});return a||jc.set(t,a=new Map),a.size>32&&a.clear(),a.set(l,u),u}var Ps=t=>!!t?.parts.some(e=>e.move);var qc=t=>G(t)?.parts.find(e=>e.screen),Uc=.06;function Yc(t){let e=G(t);if(!e)return!1;let[n,r,i]=e.size;return e.parts.filter(o=>o.screen).some(o=>{let[s,l]=[o.w*n,o.d*r,o.h*i].sort((a,c)=>c-a);return l>=Uc&&s>=Uc})}function dt(t){return nt[t]??G(t)?.size??[.6,.6,.8]}function Tt(t){let e=G(t);return iu.has(t)||!!e?.electric||!!e?.light||!!e?.climate}var Xc=t=>!!G(t)?.parts.some(e=>e.picture),En=t=>!!G(t)?.climate;function Jc(t,e){return t.name[e.split("-")[0]]??t.name.en??Object.values(t.name)[0]??t.id}var Sb={wohnen:"Living & Pets",kino:"Home Cinema & Gaming",kueche:"Kitchen Extras",bad:"Bathroom Extras",schlafen:"Bedroom & Kids",technik:"Office & Homelab",energie:"Energy & Building Services",garten:"Garden & Terrace (older)",fitness:"Fitness (older)",fahrzeuge:"Vehicles",ikea:"IKEA sizes",treppen:"Stairs & railings",ausbau:"Architecture & fit-out",werkstatt:"Garage & workshop",a_wohnzimmer:"Living room",a_schlafzimmer:"Bedroom",a_kueche:"Kitchen",a_bad:"Bathroom",a_kinderzimmer:"Kids' room",a_buero:"Office & gaming",a_fitness:"Fitness",a_haustiere:"Pets",a_garten:"Garden & patio",a_kino:"Home cinema & hi-fi",a_smart:"Smart home & tech",a_haustechnik:"Utility & building services",a_saison:"Season & decoration",a_smart2:"Smart home 2",a_haustechnik2:"Building services 2",a_wellness:"Wellness",a_garten2:"Garden 2",a_kueche2:"Kitchen 2",a_fahrzeuge2:"Vehicles 2",a_aussenkueche:"Outdoor kitchen & terrace",a_werkstatt2:"Workshop 2",a_japandi:"Japandi & Scandi",a_loft:"Loft & industrial",a_gruen:"Indoor greenery",a_musik:"Music & studio",a_bilder:"Pictures & frames"};function Qc(t,e){if(e.split("-")[0]==="de")return t.name;let n=/^nextfloor\.(.+)$/.exec(t.id)?.[1];return n&&Sb[n]||t.name}function zt(t,e){return e.mount_y!=null?e.mount_y:Rb(t,e)+(Mb(e)?0:nu(t,e.x,e.z))}var Mb=t=>t.type==="led_strip"||G(t.type)?.mount==="ceiling";function Rb(t,e){if(e.type==="lamp_wall")return eu;if(e.type==="led_strip")return Math.max(0,ht(t,e.x,e.z)-.04-Math.max(.02,e.h));let n=G(e.type);if(!n)return tu(e);switch(n.mount){case"surface":return ru(t,e.x,e.z);case"wall":return n.wall_y??1;case"ceiling":return Math.max(0,Ki(t,e)-e.h);default:return 0}}function Ds(t){if(t==="plant")return"plant";let e=G(t);return e?e.household?e.household:/monstera|plant|herb_garden|flower_pots|bonsai|ficus|cactus|kaktus/.test(e.id)?"plant":null:null}var wt=["electricity","water","gas","heating","cooling"],ou=["condition","temperature","humidity","pressure","wind_speed","wind_gust_speed","wind_bearing","cloud_coverage","precipitation","precipitation_total","illuminance","uv_index","visibility","snow","fog","lightning"],su=["turn","slide","top"],au=["always","active","no_power","never"],lu=1.3,ji=(t,e=new Date().toISOString().slice(0,10))=>!!t.due&&t.due<=e,cu=["gable","hip","halfhip","pyramid","mansard","pent","flat","parapet"],uu=["brick","round","wide","steel"],Ui=["navigate","more_info","service","fire_dom_event"];function Gi(t,e,n){return t?e?!!n.lock_plan:!!t.locked:!1}var du=["rain","snow","fog","clouds","lightning","sky"],hu=["rain","snow","clouds","lightning","sky"],pu=["lawn","terrace","path","driveway","pool","bed","wild","hedge","fence","pergola"],Is={lawn:.012,terrace:.12,path:.02,driveway:.02,pool:-.25,bed:.15,wild:.03,hedge:1.2,fence:1,pergola:2.2};function Os(t){return t==="hedge"||t==="fence"||t==="pergola"}var fu=["x","-x","z","-z"];function Eb(t,e,n){let r=t.slope??0;if(!r||t.type==="pool")return 0;let i=t.slope_dir??"x",o=(c,u)=>i==="x"?c:i==="-x"?-c:i==="z"?u:-u,s=1/0,l=-1/0;for(let[c,u]of t.points){let d=o(c,u);s=Math.min(s,d),l=Math.max(l,d)}if(l-s<1e-6)return 0;let a=Math.min(1,Math.max(0,(o(e,n)-s)/(l-s)));return r*a}function Ab(t,e,n,r){return mu(t)+(e.offset??0)+Is[e.type]-Eb(e,n,r)}function mu(t){return t.elevation>.3?0:-.2}function gu(t,e,n){let r=(t.outdoor??[]).filter(o=>!Os(o.type)&&o.type!=="pool"&&C([e,n],o.points)),i=[...r].reverse().find(o=>o.cut)??r[0];return i?Ab(t,i,e,n):mu(t)}var _u=t=>t.cut??t.type==="pool",bu=30,yu={meter:null,grid:null,grid_invert:!1,solar:null,battery:null,battery_invert:!1,battery_soc:null,consumption:null,tariff:null},vu=["wood","oak","tiles","carpet","stone","concrete"],wu={type:"none",pitch:35,overhang:.4},Zi="#d6cfc2",qi="#e8e3da",ku={wall_exterior:.24,wall_interior:.12,grid:.05,north:0,roof:{...wu}};function Pt(){return{version:1,floors:[],settings:{...ku},energy:{...yu},presence:[]}}function Ve(t,e,n){return{id:t,name:e,elevation:n,height:2.5,cut_height:1.15,rooms:[],openings:[],furniture:[],placements:[],background:null,outdoor:[],walls:[],ha_floor:null}}var Fb=2.75;function xu(t,e){if(e!=null&&Number.isFinite(e))return Math.round(e*Fb*100)/100;let n=t.reduce((r,i)=>!r||i.elevation>r.elevation?i:r,null);return n?Math.round((n.elevation+n.height+.25)*100)/100:0}function $u(t,e,n){let r=t.rooms.flatMap(l=>l.points.map(a=>a[0])),i=t.rooms.flatMap(l=>l.points.map(a=>a[1])),o=r.length?Math.ceil(Math.max(...r))+1:0,s=i.length?Math.floor(Math.min(...i)):0;return e.map((l,a)=>{let c=o+a%3*4.5,u=s+Math.floor(a/3)*3.5;return{id:n(),name:l.name,area_id:l.area_id,points:[[c,u],[c+4,u],[c+4,u+3],[c,u+3]],floor_material:"wood"}})}function Su(t,e,n,r){let i=t.rotation*Math.PI/180,o=Math.cos(i),s=Math.sin(i),[l,a]=e,c=t.x-l*(t.w/2)*o+a*(t.d/2)*s,u=t.z-l*(t.w/2)*s-a*(t.d/2)*o,d=n[0]-c,p=n[1]-u,h=y=>Math.max(.1,Math.round(y/r)*r),f=h((d*o+p*s)*l),g=h((-d*s+p*o)*a),b=y=>Math.round(y*1e3)/1e3;return{x:b(c+l*(f/2)*o-a*(g/2)*s),z:b(u+l*(f/2)*s+a*(g/2)*o),w:b(f),d:b(g)}}var Yi=["lamp_ceiling","lamp_downlight","lamp_spot","lamp_panel","lamp_pendant","ceiling_fan","lamp_floor","lamp_table","lamp_wall","led_strip","lamp_uplight","lamp_bollard","lamp_garden","radiator","sofa","armchair","stool","coffee_table","tv_board","tv_wall","sideboard","shelf","plant","rug","table","table_round","chair","bench","corner_bench","bar_stool","kitchen","kitchen_wall","kitchen_tall","island","worktop","sink","stove","dishwasher","fridge","bed","bunk_bed","nightstand","wardrobe","dresser","bathtub","shower","wc","washbasin","washer","dryer","desk","office_chair","tall_cabinet","coat_rack","stairs","robot_vacuum","inverter","home_battery","wallbox","meter","grid_point","parking","fridge_smart","heating_manifold","buffer_tank","freshwater_station","stairwell"],Mu={lights:["lamp_ceiling","lamp_downlight","lamp_spot","lamp_panel","lamp_pendant","ceiling_fan","lamp_floor","lamp_uplight","lamp_table","lamp_wall","led_strip","lamp_bollard","lamp_garden"],living:["sofa","armchair","stool","coffee_table","tv_board","tv_wall","sideboard","shelf","plant","rug"],dining:["table","table_round","chair","bench","corner_bench","bar_stool"],kitchen:["kitchen","kitchen_wall","kitchen_tall","island","worktop","sink","stove","dishwasher","fridge"],sleeping:["bed","bunk_bed","nightstand","wardrobe","dresser"],bath:["bathtub","shower","wc","washbasin","washer","dryer"],work:["desk","worktop","office_chair","tall_cabinet","coat_rack","radiator","stairs","robot_vacuum","heating_manifold","buffer_tank","freshwater_station"],vehicles:["parking"]},Ke=["meter","inverter","home_battery","wallbox","grid_point"],Ru=new Set(["lamp_ceiling","lamp_downlight","lamp_spot","lamp_panel","lamp_pendant","ceiling_fan","lamp_floor","lamp_uplight","lamp_table","lamp_wall","led_strip","lamp_bollard","lamp_garden"]),eu=1.75;function Xi(t){return Hs.has(t.type)||["stairwell","parking"].includes(t.type)?!1:G(t.type)?.mount!=="ceiling"}function ue(t){return Ru.has(t)||!!G(t)?.light}var Tb=new Set(["table","table_round","coffee_table","desk","nightstand","sideboard","dresser","kitchen","island","worktop","tv_board","dishwasher","washer","dryer"]);function Eu(t,e,n,r=0){let i=de(t.points),o=i.x1-i.x0-2*r,s=i.z1-i.z0-2*r,l=[];for(let a=0;aMath.round(s*1e3)/1e3,[i,o]={right:[1,0],down:[0,1],left:[-1,0],up:[0,-1]}[n];return[r(t[0]+i*e),r(t[1]+o*e)]}function tu(t){switch(t.type){case"home_battery":return t.variant==="wall"?.5:0;case"kitchen_wall":return 1.45;case"tv_wall":return Math.max(0,1.3-t.h/2);case"radiator":return .12;case"inverter":return 1.1;case"wallbox":return 1;case"meter":return .4;default:return 0}}var Hs=new Set(["lamp_ceiling","lamp_downlight","lamp_spot","lamp_panel","lamp_pendant","ceiling_fan"]);function Au(t,e){return t.filter(n=>n.elevationn.rooms.filter(r=>r.points.length>=3&&r.ceiling!=null&&r.ceiling>n.height+.005&&n.elevation+r.ceiling>e.elevation+.05)).map(n=>n.points)}var Ls=t=>t?.floor_offset&&Number.isFinite(t.floor_offset)?t.floor_offset:0;function nu(t,e,n){let r=t.rooms.find(i=>i.points.length>=3&&i.floor_offset&&C([e,n],i.points));return Ls(r)}function ht(t,e,n){let r=t.rooms.find(i=>i.points.length>=3&&C([e,n],i.points));return r?.ceiling!=null&&r.ceiling>0?r.ceiling:t.height}var Ki=(t,e)=>e.ceiling_y!=null&&e.ceiling_y>0?e.ceiling_y:ht(t,e.x,e.z);function ru(t,e,n){let r=0;for(let i of t.furniture)!(Tb.has(i.type)||G(i.type)?.surface)||!C([e,n],Ws(i))||(r=Math.max(r,i.h));return r}var iu=new Set([...Ru,"radiator","robot_vacuum","inverter","home_battery","wallbox","meter","tv_board","tv_wall","desk","fridge","fridge_smart","stove","kitchen_tall","dishwasher","washer","dryer","kitchen","island","sink"]),nt={sofa:[2.2,.9,.82],armchair:[.85,.85,.8],table:[1.6,.9,.75],chair:[.46,.5,.9],bed:[1.6,2.05,.9],nightstand:[.45,.4,.5],wardrobe:[1.8,.6,2.1],shelf:[.9,.35,1.9],kitchen:[2.4,.62,.92],worktop:[1.2,.62,.91],inverter:[.5,.2,.65],home_battery:[.6,.25,1.1],wallbox:[.3,.15,.42],heating_manifold:[1.5,.35,1.1],buffer_tank:[.85,.85,1.85],freshwater_station:[.65,.28,.9],meter:[.55,.21,1.1],grid_point:[.4,.22,.6],fridge:[.6,.65,1.8],fridge_smart:[.91,.73,1.78],stairwell:[1,2.6,.02],stove:[.6,.62,.92],sink:[.9,.62,.92],bathtub:[1.7,.75,.58],shower:[.9,.9,2],wc:[.38,.6,.8],washbasin:[.6,.46,.85],desk:[1.4,.7,.75],tv_board:[1.8,.42,.5],plant:[.45,.45,1.1],rug:[2,1.4,.01],stairs:[1,3.2,2.75],stool:[.55,.55,.42],lamp_ceiling:[.4,.4,.08],lamp_downlight:[.1,.1,.02],lamp_spot:[.1,.1,.14],lamp_panel:[.6,.6,.03],lamp_uplight:[.35,.35,1.8],lamp_bollard:[.16,.16,.8],lamp_garden:[.12,.12,.3],radiator:[1,.1,.6],robot_vacuum:[.36,.5,.1],parking:[2.6,5.2,.02],lamp_pendant:[.4,.4,.8],ceiling_fan:[1.32,1.32,.32],lamp_floor:[.4,.4,1.7],lamp_table:[.28,.28,.45],lamp_wall:[.22,.12,.2],led_strip:[2,.04,.03],coffee_table:[1.1,.6,.42],tv_wall:[1.3,.08,.75],sideboard:[1.6,.45,.8],table_round:[1.1,1.1,.75],bench:[1.4,.45,.85],corner_bench:[2,1.6,.9],bar_stool:[.42,.42,.75],kitchen_wall:[.8,.35,.7],kitchen_tall:[.6,.62,2.1],island:[1.8,.9,.92],dishwasher:[.6,.62,.92],bunk_bed:[1,2.05,1.65],dresser:[1,.5,.9],washer:[.6,.6,.85],dryer:[.6,.6,.85],office_chair:[.65,.65,1.1],tall_cabinet:[.6,.6,2.1],coat_rack:[1,.35,1.9]};var Cs=["interior","front","front_glass","sidelight","sidelights","glass","sliding","passage"],Ns=["standard","bars","glass_wall"],Ji=new Set(["interior","front"]);function rn(t,e){return t.type==="door"?t.style&&Cs.includes(t.style)?t.style:e?"front":"interior":t.style&&Ns.includes(t.style)?t.style:"standard"}function Fu(t,e,n,r){if(e!=="sidelight"&&e!=="sidelights")return null;let i=e==="sidelights",o=t-.04,s=Math.min(1.05,Math.max(.6,o-(i?.6:.3))),l=(o-s)/(i?2:1),a=r.sidelight_width??l,c=i?r.sidelight_width2??r.sidelight_width??l:0;a=Math.max(.1,a),c=i?Math.max(.1,c):0;let u=o-.5;if(a+c>u){let p=Math.max(0,u)/(a+c);a*=p,c*=p}return i?{panels:[[.02,.02+a],[t-.02-c,t-.02]],x0:.02+a,x1:t-.02-c}:(n?!!r.sidelight_hinge:!r.sidelight_hinge)?{panels:[[.02,.02+a]],x0:.02+a,x1:t-.02}:{panels:[[t-.02-a,t-.02]],x0:.02,x1:t-.02-a}}function Bs(t){return t==="front"||t==="front_glass"||t==="sidelight"||t==="sidelights"}var Fn={door:{type:"door",leaves:1,width:.9,sill:0,height:2.05,style:"interior"},front:{type:"door",leaves:1,width:1,sill:0,height:2.1,style:"front"},door_double:{type:"door",leaves:2,width:1.6,sill:0,height:2.05},window:{type:"window",leaves:1,width:1.2,sill:.9,height:1.3},window_double:{type:"window",leaves:2,width:1.6,sill:.9,height:1.3},terrace:{type:"window",leaves:1,width:1,sill:0,height:2.1},terrace_double:{type:"window",leaves:2,width:1.8,sill:0,height:2.1},lift_slide:{type:"window",leaves:1,width:2.4,sill:0,height:2.15,opens:"slide"},garage:{type:"garage",leaves:1,width:2.5,sill:0,height:2.1},glass_wall:{type:"window",leaves:1,width:2,sill:0,height:2.4,style:"glass_wall"}};function Tn(t){if(t.type==="garage")return"garage";if(t.type==="window"&&t.style==="glass_wall")return"glass_wall";if(t.type==="window"&&t.opens==="slide"&&t.sill<.1)return"lift_slide";let e=t.leaves===2;return t.type==="door"?!e&&t.style&&Bs(t.style)?"front":e?"door_double":"door":t.sill<.1?e?"terrace_double":"terrace":e?"window_double":"window"}function Oe(t){t.energy={...yu,...t.energy??{}},t.presence=t.presence??[],t.version=1,t.settings={...ku,...t.settings,roof:{...wu,...t.settings?.roof??{}}},t.floors.forEach((e,n)=>{let r=Ve(e.id,e.name??`Floor ${n+1}`,e.elevation??n*2.8);for(let i of Object.keys(r))e[i]===void 0&&(e[i]=r[i])});for(let e of t.floors){e.outdoor=e.outdoor??[],e.walls=e.walls??[],e.rooms=e.rooms.map(r=>({...r,name:r.name??"",area_id:r.area_id??null,floor_material:r.floor_material??"wood",panel:r.panel??[]})),e.ha_floor=e.ha_floor??null,e.placements=e.placements.map(r=>({...r,mount:r.mount??null,rotation:r.rotation??0})),e.furniture=e.furniture.map(r=>({...r,entity:r.entity??null,power:r.power??null}));let n=e.placements.filter(r=>r.entity_id.startsWith("light."));if(n.length){let r={ceiling:"lamp_ceiling",floor:"lamp_floor",table:"lamp_table",wall:"lamp_wall"};for(let i of n){let o=r[i.mount??"ceiling"],[s,l,a]=nt[o],c=`lamp_${i.entity_id.slice(6).replace(/[^A-Za-z0-9_\-.]/g,"_")}`.slice(0,54),u=c,d=1;for(;e.furniture.some(p=>p.id===u);)u=`${c}_${d++}`;e.furniture.push({id:u,type:o,x:i.x,z:i.z,rotation:0,w:s,d:l,h:a,variant:null,entity:i.entity_id,power:null,animations_enabled:i.animations_enabled,effect_animations:structuredClone(i.effect_animations)})}e.placements=e.placements.filter(i=>!i.entity_id.startsWith("light."))}e.openings=e.openings.map(r=>({...r,type:["door","window","garage"].includes(r.type)?r.type:"door",edge:Number.isInteger(r.edge)?r.edge:0,offset:Number.isFinite(r.offset)?r.offset:.5,width:Number.isFinite(r.width)&&r.width>0?r.width:r.type==="garage"?2.5:r.type==="window"?1.2:.9,height:Number.isFinite(r.height)&&r.height>0?r.height:r.type==="window"?1.3:r.type==="garage"?2.1:2.05,sill:Number.isFinite(r.sill)?r.sill:r.type==="window"?.9:0,hinge:r.hinge??"left",leaves:r.leaves??1,swing:r.swing??"in",style:r.style??null,cover:r.cover??null,contact:r.contact??null,contact2:r.contact2??null,tilt:r.tilt??null}))}return zb(t),t}function zb(t){let e=(n,r)=>{let i=new Set;for(let o of n)(typeof o.id!="string"||!o.id||i.has(o.id))&&(o.id=I(r)),i.add(o.id)};e(t.floors,"floor");for(let n of t.floors){for(let r of n.rooms)(typeof r.id!="string"||!r.id)&&(r.id=I("room"));e(n.openings,"op"),e(n.furniture,"furn"),e(n.outdoor,"out")}}function I(t){return`${t}_${Math.random().toString(36).slice(2,10)}`}function _e(t){let e=0;for(let n=0;no+s[0],0)/i,t.reduce((o,s)=>o+s[1],0)/i]}let n=0,r=0;for(let i=0;i1e-6&&Math.abs(r-o)>1e-6)return!1}return!0}function de(t){let e=1/0,n=1/0,r=-1/0,i=-1/0;for(let[o,s]of t)e=Math.min(e,o),n=Math.min(n,s),r=Math.max(r,o),i=Math.max(i,s);return{x0:e,z0:n,x1:r,z1:i}}function Ws(t){let e=t.rotation*Math.PI/180,n=Math.cos(e),r=Math.sin(e),i=t.w/2,o=t.d/2;return[[-i,-o],[i,-o],[i,o],[-i,o]].map(([s,l])=>[t.x+s*n-l*r,t.z+s*r+l*n])}function C(t,e){let n=!1;for(let r=0,i=e.length-1;rt[1]!=a>t[1]&&t[0]<(l-o)*(t[1]-s)/(a-s)+o&&(n=!n)}return n}var Qi={lamp_ceiling:"ceiling",lamp_downlight:"downlight",lamp_spot:"spot",lamp_panel:"panel",lamp_uplight:"uplight",lamp_bollard:"bollard",lamp_garden:"garden",lamp_pendant:"pendant",ceiling_fan:"fan",lamp_floor:"floor",lamp_table:"table",lamp_wall:"wall",led_strip:"strip"};var Vs=t=>t.trim().replace(/^\/local\/www\//i,"/local/"),Ks=t=>/^(https:\/\/|\/local\/|\/hacsfiles\/)\S+\.m?js(\?\S*)?$/i.test(t.trim());var Db=globalThis,zu=Db.__nextfloorPluginStore??={plugins:new Map,listeners:new Set},js=zu.plugins,Tu=zu.listeners;var Ib=5;function Pu(t,e){t.errors.lengthTu.delete(t)}var Us=()=>[...js.values()].map(t=>t.status),Du=()=>[...js.values()].flatMap(t=>Object.keys(t.plugin.lightAnimations??{}));function*to(t,e){for(let{plugin:n,status:r}of js.values())for(let i of n.devices??[]){let o=!1;try{o=i.match(t,e)}catch(s){Pu(r,s)}o&&(yield{device:i,status:r})}}function no(t,e){for(let{device:n}of to(t,e))return n.kind??"sensor";return null}function Iu(t,e){let n=t.states[e];if(!n)return null;let r=Ob({hass:t,entityId:e,state:n})?.icon?.trim();return r&&/^mdi:[a-z0-9-]+$/i.test(r)?r:null}function Ob(t){let e=null;for(let{device:n,status:r}of to(t.entityId,t.state))if(n.marker)try{let i=n.marker(t);if(!i)continue;e={...e??{}},typeof i.icon=="string"&&i.icon&&(e.icon=i.icon),typeof i.text=="string"&&(e.text=i.text.slice(0,60)),typeof i.active=="boolean"&&(e.active=i.active)}catch(i){Pu(r,i)}return e}function ro(t,e){return t?typeof t=="string"?t:t[e]??t[e.split("-")[0]]??t.en??Object.values(t)[0]??"":""}function Ou(t,e){let n=[];for(let{device:r,status:i}of to(t,e))r.settings?.length&&n.push({pluginId:i.id,name:i.name,settings:r.settings});return n}function Hu(t,e){let n={};for(let r of t??[]){let i=e?.[r.key],o=r.type==="number"?typeof i=="number"&&Number.isFinite(i):r.type==="boolean"?typeof i=="boolean":typeof i=="string"&&(r.options??[]).some(([s])=>s===i);n[r.key]=o?i:r.default}return n}function Lu(t,e){for(let{device:n}of to(t,e))if(n.floorWedge)return!0;return!1}var Hb=new Set(["temperature","humidity","power","carbon_dioxide","energy","gas","water","volume","volume_storage","volume_flow_rate","illuminance","pressure","atmospheric_pressure","pm1","pm25","pm10","volatile_organic_compounds","volatile_organic_compounds_parts","carbon_monoxide","nitrogen_dioxide","moisture","sound_pressure"]),Lb=new Set(["m\xB3","m3","L","l","kWh","Wh","MWh","lx"]),Cb=new Set(["door","window","opening","garage_door","motion","occupancy","presence","smoke","moisture","gas","carbon_monoxide"]),Nb=new Set(["battery","signal_strength","timestamp","date","duration","data_rate","data_size","frequency","enum"]);function Dt(t,e){let n=t.entities?.[e];return n&&(n.area_id||(n.device_id?t.devices?.[n.device_id]?.area_id:null))||null}var Nu=(t,e)=>{let n=t.entities?.[e];return!!(n?.hidden||n?.entity_category)},je=(t,e)=>Q(e)??no(e,t.states[e]);function Cu(t,e){let n=t.states[e];if(!n||Nu(t,e))return!1;if(no(e,n)!==null)return!0;let r=Q(e);if(!r)return!1;let i=n.attributes.device_class;return e.startsWith("event.")?!i||i==="button"||i==="doorbell":r==="sensor"?i?Hb.has(i):Lb.has(String(n.attributes.unit_of_measurement??"")):r==="binary"?i?Cb.has(i):!!t.entities?.[e]?.area_id:!0}function Bb(t,e){let n=t.states[e];return Q(e)!=="sensor"||!n?.attributes.unit_of_measurement||Nu(t,e)||Nb.has(String(n.attributes.device_class??""))?!1:Number.isFinite(Number(n.state))||Ie(n)}var oo=(t,e)=>e.startsWith("sensor.")&&t.states[e]?.attributes.device_class==="power",Gs=null;eo(()=>Gs=null);function Zs(t,e){let n=t.get(e);return n||t.set(e,n=[]),n}function Wb(t){let e=new Map,n=new Map,r=new Map,i=new Map,o=[],s=u=>{(Cu(t,u)||Bb(t,u))&&Ft(je(t,u))&&o.push(u)};for(let[u,d]of Object.entries(t.entities??{})){let p=d.device_id;p&&d.area_id&&(i.get(p)??i.set(p,new Set).get(p)).add(d.area_id),p&&oo(t,u)&&Zs(n,p).push(u),p&&!d.hidden&&!d.entity_category&&(r.get(p)??r.set(p,new Set).get(p)).add(Fs(u));let h=Dt(t,u);h===null?s(u):Cu(t,u)&&Zs(e,h).push(u)}if(t.entities)for(let u of Object.keys(t.states))t.entities[u]||s(u);let l=Ts.indexOf("binary")-.5,a=u=>{let d=Q(u),p=d?Ts.indexOf(d):l;return p>l&&no(u,t.states[u])!==null?l:p};o.sort((u,d)=>a(u)-a(d)||B(t,u).localeCompare(B(t,d)));for(let[u,d]of e){let p=t.areas?.[u]?.name;d.sort((h,f)=>a(h)-a(f)||B(t,h,p).localeCompare(B(t,f,p)))}let c=new Set;for(let[u,d]of i)d.size>1&&c.add(u);return{entities:t.entities,devices:t.devices,states:t.states,stateCount:Object.keys(t.states).length,byArea:e,powerByDevice:n,withoutArea:o,domainsByDevice:r,hubs:c}}function Pn(t){let e=Gs;return e&&e.entities===t.entities&&e.devices===t.devices&&(e.states===t.states||(e.states=t.states,Object.keys(t.states).length===e.stateCount))?e:Gs=Wb(t)}function ye(t,e){let n=io(t,e.area_id);return e.sub_areas?.length?[...new Set([...n,...e.sub_areas.flatMap(r=>io(t,r))])]:n}function io(t,e){return!e||!t.entities?[]:Pn(t).byArea.get(e)??[]}function Bu(t,e){if(!t.entities)return[];let n=[];for(let[r,i]of Pn(t).byArea){let o=i.filter(s=>Ft(je(t,s)));r!==e&&o.length>0&&n.push({areaId:r,name:t.areas?.[r]?.name??r,ids:o})}return n.sort((r,i)=>r.name.localeCompare(i.name))}var Wu=t=>t.entities?Pn(t).withoutArea:[],qs=(t,e)=>!!t.entities&&Pn(t).hubs.has(e),so=(t,e)=>t.entities?Pn(t).powerByDevice.get(e)??[]:[];function Dn(t,e){let n=new Map;for(let i of e)Zs(n,t.entities?.[i]?.device_id??`entity:${i}`).push(i);let r=new Map(e.map((i,o)=>[i,o]));return[...n.values()].map(i=>{let o=i.find(s=>!t.entities?.[s]?.name)??i[0];return{primary:o,others:i.filter(s=>s!==o)}}).sort((i,o)=>r.get(i.primary)-r.get(o.primary))}var ao=(t,e)=>Dn(t,e).map(n=>n.primary),Vb={temperature:"temperature",humidity:"humidity",co2:"carbon_dioxide",illuminance:"illuminance"};function Ys(t,e,n,r=!1){let i=t.states[e]?.attributes;if(!i)return!1;let o=(i.symcon_variable_type===1||i.symcon_variable_type===2)&&typeof i.symcon_id=="number";if(typeof i.symcon_id=="number"&&!o||!o&&!/^(sensor|input_number|number)\./.test(e))return!1;if(r&&o)return!0;let s=String(i.unit_of_measurement??"").replace(/\s/g,"").toLowerCase();return n==="temperature"&&["\xB0c","\xB0f","\u2103","\u2109","k"].includes(s)||n==="humidity"&&!i.device_class&&["%","%rh","%r.h.","%rf","%r.f."].includes(s)||n==="co2"&&s==="ppm"&&/co[₂2]/i.test(String(i.friendly_name??""))||n==="illuminance"&&["lx","lux"].includes(s)?!0:i.device_class===Vb[n]}var Kb=new Set(["climate","water_heater","switch","button","camera","media_player","vacuum","light","fan","lawn_mower"]),jb=["vorlauf","r(\xFC|ue)cklauf","flow","return","d(\xFC|ue)se","nozzle","hotend","extruder","druckbett","heatbed","(^|[^a-z])bed($|[^a-z])","chamber","cpu","gpu","chip","soc","akku","batter","wasser","water","kessel","boiler","au(\xDF|ss)en","outdoor","outside","abgas","exhaust","sole","brine","verdampfer","kondensat","verdichter","compressor","motor","k(\xFC|ue)hl","freezer","fridge","gefrier"],Ub=new RegExp(`(${jb.join("|")})`,"i");function Xs(t,e){let n=t.entities?.[e]?.device_id,r=n&&!qs(t,n)?Pn(t).domainsByDevice.get(n):void 0;return r&&[...r].some(i=>Kb.has(i))?!1:!Ub.test(`${e} ${t.states[e]?.attributes.friendly_name??""}`)}function Vu(t,e,n,r){let i=n.climate?.[r];if(i==="none")return[];if(i)return[i].flat().filter(c=>t.states[c]);let o=(e?.placements??[]).filter(c=>c.entity_id.startsWith("sensor.")),s=o.filter(c=>C([c.x,c.z],n.points)).map(c=>c.entity_id),l=new Set(o.filter(c=>!C([c.x,c.z],n.points)).map(c=>c.entity_id));return[...new Set([...ye(t,n).filter(c=>!l.has(c)),...s])].filter(c=>c.startsWith("sensor.")&&Ys(t,c,r)&&Xs(t,c))}function Ku(t){let e=t.attributes;if(typeof e.symcon_numeric_value!="number")return null;let n=typeof e.symcon_min=="number"?e.symcon_min:0,r=typeof e.symcon_max=="number"&&e.symcon_max>n?e.symcon_max:100;return Math.max(0,Math.min(100,(e.symcon_numeric_value-n)/(r-n)*100))}function lo(t,e){let n=t?.states[e];if(!n)return!1;let r=n.attributes;return typeof r.symcon_id=="number"?r.symcon_variable_type===1||r.symcon_variable_type===2:typeof r.current_position=="number"||/^(sensor|number|input_number)\./.test(e)&&!!n.state.trim()&&Number.isFinite(Number(n.state))}function co(t,e){let n=e?t.states[e]:void 0;if(!n||Ie(n))return null;let r=n.attributes;if(r.nf_cover_control&&typeof r.current_position=="number")return r.current_position;let i=Ku(n);if(i!==null)return i;if(typeof r.current_position=="number")return Math.max(0,Math.min(100,r.current_position));if(!n.state.trim())return null;let o=Number(n.state);if(!Number.isFinite(o))return null;let s=r.unit_of_measurement==="%"||o>1||o<0?o:o*100;return Math.max(0,Math.min(100,s))}var Gb=new Set([void 0,"shutter","blind","awning","shade","curtain","window"]),Zb=new Set(["garage","gate"]),qb=new Set(["window","opening"]);function Er(t,e,n=!1){let r=new Map;return t.forEach((i,o)=>{let s=n&&e.length===1?e[0]:e[o];s&&r.set(i.id,s)}),r}var ju=(t,e)=>t==="none"?null:t??e??null,It=t=>t&&t!=="none"?t:null;function Ot(t,e){let n=new Map;for(let r of e)for(let i of r.rooms){let o=r.openings.filter(g=>g.room_id===i.id).sort((g,b)=>g.edge-b.edge||g.offset-b.offset);if(o.length===0)continue;let s=ye(t,i),l=g=>t.states[g]?.attributes.device_class,a=g=>s.filter(b=>Q(b)==="binary"&&g(l(b)??"")),c=g=>o.filter(b=>b.type===g),u=Er(c("window"),s.filter(g=>Q(g)==="cover"&&Gb.has(l(g))),!0),d=Er(c("window"),a(g=>qb.has(g))),p=Er(c("door"),a(g=>g==="door")),h=Er(c("garage"),s.filter(g=>Q(g)==="cover"&&Zb.has(l(g)??""))),f=Er(c("garage"),a(g=>g==="garage_door"));for(let g of o){let b=g.type==="window"?u:g.type==="garage"?h:null,y=g.type==="window"?d:g.type==="garage"?f:p,v=g.leaves===2;n.set(g.id,{cover:ju(g.cover,b?.get(g.id)),contact:g.sensor==="handle"&&g.contact==null?null:ju(g.contact,y.get(g.id)),tilt:g.tilt==="none"?null:g.tilt,contact2:v?It(g.contact2):null,tilt2:v?It(g.tilt2):null,position:It(g.position),positionInverted:!!g.position_inverted,tiltAngle:It(g.tilt_angle),tiltMax:g.tilt_max??null,tiltOffset:g.tilt_offset??null,tiltInvert:!!g.tilt_invert,shut:!!g.shut,angled:g.type==="door"&&!!g.open_angle,lock:g.type==="door"?It(g.lock):null,cover2:g.type==="garage"?null:It(g.cover2),coverTilt:It(g.cover_tilt),cover2Tilt:It(g.cover2_tilt),coverInverted:!!g.cover_inverted,coverTiltInverted:!!g.cover_tilt_inverted,cover2Inverted:!!g.cover2_inverted,cover2TiltInverted:!!g.cover2_tilt_inverted})}}return n}var Yb=[[/^(tilted|tilt|gekippt|kipp)/i,"tilted"],[/^(open|opened|offen|geöffnet|on)$/i,"open"],[/^(closed|close|geschlossen|zu|off)$/i,"closed"]];function Js(t){if(!t||Ie(t))return null;let e=t.attributes.window_state;for(let n of[typeof e=="string"?e:"",t.state]){let r=n.trim(),i=r&&Yb.find(([o])=>o.test(r));if(i)return i[1]}return null}var Uu=new WeakMap,Gu=new WeakMap;function Zu(t,e){let n=Gu.get(t)??t,r=Uu.get(n)??new WeakMap;Uu.set(n,r);let i=r.get(e);if(i)return i;let o=new Map;for(let a of e)for(let c of a.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 a of Ot(n,e).values())a.cover&&!o.has(a.cover)&&o.set(a.cover,{tilt:a.coverTilt,position:a.position}),a.cover2&&!o.has(a.cover2)&&o.set(a.cover2,{tilt:a.cover2Tilt});let s={...n.states};for(let[a,c]of o){let u=n.states[a];if(!u)continue;let d={...u.attributes,nf_cover_control:!0},p=co(n,c.position);p===null&&(p=typeof u.attributes.current_position=="number"?u.attributes.current_position:null),p!==null&&(d.current_position=p);let h=c.tilt?n.states[c.tilt]:u,f=typeof h?.attributes.current_tilt_position=="number"?h.attributes.current_tilt_position:c.tilt?co(n,c.tilt):null;f!==null&&(d.current_tilt_position=f,d.supported_features=Number(d.supported_features??0)|128);let g=u.state;typeof d.current_position=="number"&&g!=="unavailable"&&g!=="unknown"&&g!=="opening"&&g!=="closing"&&(g=d.current_position>0?"open":"closed"),s[a]={...u,state:g,attributes:d}}let l={...n,states:s,callService:async(a,c,u={})=>{if(a!=="cover")return n.callService(a,c,u);let d=Array.isArray(u.entity_id)?u.entity_id:[u.entity_id],p=async h=>{let f=typeof h=="string"?o.get(h):void 0;if(!f)return n.callService(a,c,{...u,entity_id:h});let g={...u,entity_id:h},b=c;(b==="toggle"||b==="toggle_cover")&&(b=s[String(h)]?.state==="closed"?"open_cover":"close_cover");let y=b.includes("tilt");y&&f.tilt&&(g.entity_id=f.tilt);let v=f.tilt?n.states[f.tilt]:void 0;return y&&f.tilt&&!v?.attributes.symcon_id&&typeof v?.attributes.current_tilt_position!="number"&&(b==="set_cover_tilt_position"?(b="set_cover_position",g.position=g.tilt_position,delete g.tilt_position):b==="open_cover_tilt"?b="open_cover":b==="close_cover_tilt"&&(b="close_cover")),n.callService(a,b,g)};return Array.isArray(u.entity_id)?Promise.all(d.map(p)):p(d[0])}};return Gu.set(l,n),r.set(e,l),l}var X=t=>t?.symconObjects!==void 0;function He(t,e,n=[0,1,2,3]){let r=t?.states[e]?.attributes;return!!r?.symcon_id&&!r.symcon_source_entity&&n.includes(Number(r.symcon_variable_type))}function on(t){return!t||t.state==="unknown"||t.state==="unavailable"?null:t.attributes.symcon_value??t.attributes.symcon_numeric_value??t.state}function Ht(t){let e=on(t);if(e===null||typeof e=="boolean"||e==="")return null;let n=Number(e);return Number.isFinite(n)?n:null}function Ar(t){let e=on(t);if(e===null)return null;if(typeof e=="boolean")return e;if(typeof e=="number")return e>0;let n=String(e).trim().toLowerCase();if(["on","true","1","home","open","an","ein","ja","regen","rain","wet","nass"].includes(n))return!0;if(["off","false","0","not_home","closed","aus","nein","trocken","dry"].includes(n))return!1;let r=Number(n);return n!==""&&Number.isFinite(r)?r>0:null}function Qs(t){return on(t)===null?"\u2013":String(t?.attributes.symcon_formatted??on(t))}function qu(t,e){switch(e){case"m/s":return t*3.6;case"mph":return t*1.609;case"kn":return t*1.852;case"ft/s":return t*1.097;default:return t}}var Yu="weather.nextfloor_symcon",Ju={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"},Xu=new WeakMap;function Xb(t){let e=t.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 Qu(t,e){if(!X(t))return t;let n=e.weather_variables??{};if(!e.rain_sensor&&!Object.values(n).some(h=>h&&h!=="none"))return t;let r=Xu.get(t)??new WeakMap;Xu.set(t,r);let i=r.get(e);if(i)return i;let o={friendly_name:"Wetter",nf_symcon_weather:!0},s=h=>n[h]&&n[h]!=="none"?t.states[n[h]]:void 0;for(let h of["temperature","humidity","pressure","cloud_coverage","precipitation","precipitation_total","illuminance","uv_index","visibility"]){let f=s(h),g=Ht(f);g!==null&&(o[h]=h==="cloud_coverage"&&f?.attributes.symcon_max===1?g*100:g),f?.attributes.unit_of_measurement&&(o[`${h}_unit`]=f.attributes.unit_of_measurement)}for(let h of["wind_speed","wind_gust_speed"]){let f=s(h),g=Ht(f);g!==null&&(o[h]=qu(g,f?.attributes.unit_of_measurement))}o.wind_speed_unit="km/h";let l=on(s("wind_bearing"));l!==null&&(o.wind_bearing=l);let a=Xb(Qs(s("condition"))),c=e.rain_sensor?t.states[e.rain_sensor]:void 0,u=Ar(c);u!==null&&e.rain_sensor_inverted&&(u=!u),u===null&&typeof o.precipitation=="number"&&(u=o.precipitation>0),Ar(s("lightning"))?a=u?"lightning-rainy":"lightning":Ar(s("snow"))?a=u?"snowy-rainy":"snowy":Ar(s("fog"))?a="fog":u===!0?a=Number(o.precipitation??0)>=8?"pouring":"rainy":u===!1&&a&&/rain|pouring/.test(a)&&(a=null),!a&&typeof o.cloud_coverage=="number"&&(a=o.cloud_coverage>70?"cloudy":o.cloud_coverage>20?"partlycloudy":"sunny"),!a&&u===!1&&(a="sunny");let d={entity_id:Yu,state:a??"unknown",attributes:o},p={...t,states:{...t.states,[Yu]:d}};return r.set(e,p),p}var In={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},sn=t=>(...e)=>({_$litDirective$:t,values:e}),Lt=class{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,n,r){this._$Ct=e,this._$AM=n,this._$Ci=r}_$AS(e,n){return this.update(e,n)}update(e,n){return this.render(...n)}};var Fr=class extends Lt{constructor(e){if(super(e),this.it=_,e.type!==In.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===_||e==null)return this._t=void 0,this.it=e;if(e===tt)return e;if(typeof e!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(e===this.it)return this._t;this.it=e;let n=[e];return n.raw=n,this._t={_$litType$:this.constructor.resultType,strings:n,values:[]}}};Fr.directiveName="unsafeHTML",Fr.resultType=1;var ed=sn(Fr);var td=/\b(tv|fernseh|television|fire ?tv|apple ?tv|chromecast|shield)/i,nd=/(kühl|fridge|gefrier|freezer)/i,rd=/(spülmaschine|geschirrspül|dishwasher)/i,Jb=/(kochfeld|herd|induktion|cooktop)/i,Qb={robot_vacuum:/(saug|vacuum|robo|roomba|roborock|dreame|ecovacs|deebot)/i,tv_board:td,tv_wall:td,desk:/\b(pc|computer|rechner|desktop|monitor|workstation)/i,fridge:nd,fridge_smart:nd,stove:/(herd|kochfeld|cooktop|stove|induktion)/i,kitchen_tall:/(backofen|oven|ofen)/i,dishwasher:rd,washer:/(waschmaschine|washer|washing)/i,dryer:/(trockner|dryer)/i,kitchen:/(kaffee|coffee|wasserkocher|kettle)/i,island:Jb,sink:rd,radiator:/(heiz|radiator|thermostat|climate|hk|trv)/i},id={lamp_ceiling:/(decke|ceiling|haupt|main)/i,lamp_downlight:/(spot|strahler|downlight|einbau)/i,lamp_spot:/(spot|strahler)/i,lamp_panel:/(panel|decke|ceiling)/i,lamp_uplight:/(fluter|uplight|steh)/i,lamp_bollard:/(weg|garten|garden|path|poller|außen|aussen|outdoor)/i,lamp_garden:/(garten|garden|spot|außen|aussen|outdoor|baum|tree)/i,lamp_pendant:/(pendel|pendant|hänge|esstisch|dining)/i,ceiling_fan:/(ventilator|fan)/i,lamp_floor:/(steh|floor)/i,lamp_table:/(tisch|nacht|table|bedside|lese|reading)/i,lamp_wall:/(wand|wall)/i,led_strip:/(led|strip|streifen|leiste|band)/i},od=new Set(["tv_board","tv_wall"]);var On=t=>od.has(t)||!!qc(t),uo=t=>!!G(t)?.electric&&/speaker|multiroom|soundbar/.test(t.split(":").pop()??t),zr=t=>On(t)||t==="desk"||t==="fridge_smart",ey=t=>!!t&&t!=="none";function ty(t,e){if(oo(t,e))return e;let n=t.entities?.[e]?.device_id;return n?so(t,n).find(r=>r!==e)??null:null}var ny=(t,e,n)=>t.rooms.find(r=>r.points.length>=3&&C([e,n],r.points));function Tr(t,e,n,r){return t.find(i=>e?.test(n(i)))??(r?t[0]??null:null)}function Me(t,e){let n=new Map;for(let r of e){let i=new Set([...r.furniture.flatMap(o=>[o.entity,o.power,o.fan_entity]),...r.placements.map(o=>o.entity_id)].filter(ey));for(let o of r.furniture){let s=o.type in id,l=En(o.type),a=s?id[o.type]:Qb[o.type];if(!a&&!l&&!uo(o.type)&&o.entity==null&&o.power==null)continue;let c=ny(r,o.x,o.z),u=(c?ao(t,ye(t,c)):[]).filter(b=>!i.has(b)),d=b=>`${b} ${B(t,b)}`,p=b=>u.filter(y=>Q(y)===b),h=o.entity==="none"?null:o.entity??null;if(o.entity==null){if(o.type==="ceiling_fan"){let b=(c?ye(t,c):[]).filter(v=>!i.has(v)),y=new Set(b.filter(v=>Q(v)==="fan").map(v=>t.entities?.[v]?.device_id).filter(Boolean));h=b.find(v=>Q(v)==="light"&&y.has(t.entities?.[v]?.device_id))??Tr(p("light"),a,d,!1)}else if(s)h=Tr(p("light"),a,d,!0);else if(o.type==="robot_vacuum"){let b=c?.area_id??null;h=Object.keys(t.entities??{}).find(y=>y.startsWith("vacuum.")&&!i.has(y)&&Dt(t,y)===b)??null}else if(o.type==="radiator"||l)h=Tr(p("climate"),a,d,!0);else if(On(o.type)){let b=p("media");h=b.find(y=>t.states[y]?.attributes.device_class==="tv")??Tr(b,a,d,od.has(o.type))}else if(uo(o.type)){let b=p("media").filter(y=>t.states[y]?.attributes.device_class!=="tv");h=Tr(b,a,d,!1)??(b.length===1?b[0]:null)}else a&&(h=u.find(b=>["switch","media","fan"].includes(Q(b)??"")&&a.test(d(b)))??null);h&&i.add(h)}let f=o.power==="none"?null:o.power??null;o.power==null&&(f=h?ty(t,h):null,!f&&a&&c&&!s&&(f=ye(t,c).find(b=>oo(t,b)&&!i.has(b)&&a.test(d(b)))??null),f&&i.add(f));let g=null;if(o.type==="ceiling_fan"&&(g=o.fan_entity==="none"?null:o.fan_entity??null,o.fan_entity==null)){let b=(c?ye(t,c):[]).filter(v=>Q(v)==="fan"&&!i.has(v)),y=h?t.entities?.[h]?.device_id:void 0;g=(y?b.find(v=>t.entities?.[v]?.device_id===y):void 0)??b[0]??null,g&&i.add(g)}(h||f||g)&&n.set(o.id,{entity:h,power:f,...o.type==="ceiling_fan"?{fan:g}:{}})}}return n}var sd=t=>t==="fridge"||t==="fridge_smart"||/(fridge|freezer|kuehl|gefrier|chest_freezer)/.test(t.slice(t.lastIndexOf(":")+1));function ad(t,e,n=[]){let r=[];for(let i of e){let o=(l,a)=>i.rooms.some(c=>c.points.length>=3&&C([l,a],c.points)),s=Me(t,[i]);r.push(...i.placements.filter(l=>l.outside||!o(l.x,l.z)).map(l=>l.entity_id)),r.push(...i.furniture.filter(l=>!o(l.x,l.z)).flatMap(l=>[s.get(l.id)?.entity,s.get(l.id)?.power]));for(let l of i.outdoor??[])l.area_id&&r.push(...ao(t,io(t,l.area_id))),r.push(l.pump_entity,l.temp_entity)}return[...new Set(r.filter(i=>!!i&&!!t.states[i]&&!n.includes(i)))]}function ry(t,e){return Math.min(...e.map((n,r)=>{let i=e[(r+1)%e.length],[o,s]=[i[0]-n[0],i[1]-n[1]],l=Math.min(1,Math.max(0,((t[0]-n[0])*o+(t[1]-n[1])*s)/(o*o+s*s||1)));return Math.hypot(t[0]-n[0]-o*l,t[1]-n[1]-s*l)}))}function cd(t,e,n=[]){let r=t.points;if(r.length<3||e.length===0)return[];let i=r.map(y=>y[0]),o=r.map(y=>y[1]),[s,l,a,c]=[Math.min(...i),Math.max(...i),Math.min(...o),Math.max(...o)],u=Math.min(l-s,c-a),d=Math.max(.1,Math.min(.25,u/8)),p=Math.min(.35,u/5),h=Math.min(.7,u/4),f=be(r),g=[];for(let y=s+d/2;y=p&&g.push({at:w,wallDistance:x})}g.length===0&&g.push({at:f,wallDistance:0});let b=[...n];return e.map(y=>{let v=Q(y)==="light",w=g[0].at,x=-1/0;for(let{at:M,wallDistance:A}of g){let T=b.length?Math.min(...b.map(P=>Math.hypot(M[0]-P[0],M[1]-P[1]))):3,F=Math.hypot(M[0]-f[0],M[1]-f[1]),L=Math.min(T,3)*2;Fx+1e-9&&(x=L,w=M)}let k=[Math.round(w[0]*100)/100,Math.round(w[1]*100)/100];return b.push(k),{entity_id:y,x:k[0],z:k[1],y:null,mount:null}})}var ld=/(^|_)(current_room|current_segment|aktueller_raum|current_area)($|_)/;function ud(t,e,n){if(n==="none")return null;if(n)return n;let r=e?t.entities?.[e]?.device_id:null;return!r||!t.entities?null:Object.values(t.entities).find(o=>o.device_id===r&&o.entity_id.startsWith("sensor.")&&(ld.test(o.translation_key??"")||ld.test(o.entity_id.split(".")[1])))?.entity_id??null}var me=t=>/^(sensor|input_number|number)\./.test(t),ho=t=>/^(binary_sensor|input_boolean)\./.test(t);function Hn(t,e){if(!me(e))return!1;let n=t?.states[e]?.attributes;return n?.device_class==="power"||n?.unit_of_measurement==="W"||n?.unit_of_measurement==="kW"}function iy(t,e){let n=t?.entities?.[e],r=n?.area_id??(n?.device_id?t?.devices?.[n.device_id]?.area_id:null);return r?t?.areas?.[r]?.name:void 0}function O(t,e){return Object.keys(t?.states??{}).filter(e).map(n=>{let r=iy(t,n),i=t?.states[n],o=typeof i?.attributes.symcon_path=="string"?i.attributes.symcon_path:void 0,s={id:n,label:r?`${B(t,n)} \xB7 ${r}`:B(t,n)};return o&&(s.detail=`Objektbaum: ${o}`),typeof i?.attributes.symcon_source_entity=="string"&&(s.sourceEntity=i.attributes.symcon_source_entity),s}).sort((n,r)=>n.label.localeCompare(r.label))}function dd(t,e,n){return e.unsupported?[]:O(t,r=>He(t,r,e.types)&&!e.excluded?.(r)).map(r=>{if(!e.role)return r;let i=t.states[r.id],o=`${e.role}.${i.attributes.symcon_id}`,s=n?t.states[n]:void 0,l=n&&(n===r.id||s?.attributes.symcon_source_entity===r.id)?n:t.states[o]?o:r.id;return l===r.id?r:{...r,id:l,sourceEntity:r.id}})}function po(t,e){return t.power&&t.power!=="none"?t.power:e.get(t.id)?.power??null}var ve=ee`
:host {
--nf-text: var(--primary-text-color, #e1e1e1);
--nf-muted: var(--secondary-text-color, #9b9b9b);
@@ -29,7 +29,7 @@ var $={cs:"4be67fcd522e",da:"0fe66a82bf2a",es:"bd89dffd1355",fi:"9a17bc084f56",f
font-family: var(--nf-font);
color: var(--nf-text);
}
-`,eS=ee`
+`,nS=ee`
:host([readable]) {
--secondary-text-color: var(--primary-text-color, #e1e1e1);
--divider-color: color-mix(in srgb, var(--primary-text-color, #e1e1e1) 40%, transparent);
@@ -203,7 +203,7 @@ var $={cs:"4be67fcd522e",da:"0fe66a82bf2a",es:"bd89dffd1355",fi:"9a17bc084f56",f
min-height: 40px;
}
}
-`;var{I:ry}=Oc,dd=t=>t;var pd=t=>t.strings===void 0,hd=()=>document.createComment(""),Ln=(t,e,n)=>{let r=t._$AA.parentNode,i=e===void 0?t._$AB:e._$AA;if(n===void 0){let o=r.insertBefore(hd(),i),s=r.insertBefore(hd(),i);n=new ry(o,s,t,t.options)}else{let o=n._$AB.nextSibling,s=n._$AM,l=s!==t;if(l){let a;n._$AQ?.(t),n._$AM=t,n._$AP!==void 0&&(a=t._$AU)!==s._$AU&&n._$AP(a)}if(o!==i||l){let a=n._$AA;for(;a!==o;){let c=dd(a).nextSibling;dd(r).insertBefore(a,i),a=c}}}return n},Lt=(t,e,n=t)=>(t._$AI(e,n),t),iy={},fd=(t,e=iy)=>t._$AH=e,md=t=>t._$AH,po=t=>{t._$AR(),t._$AA.remove()};var gd=(t,e,n)=>{let r=new Map;for(let i=e;i<=n;i++)r.set(t[i],i);return r},zr=on(class extends Ht{constructor(t){if(super(t),t.type!==In.CHILD)throw Error("repeat() can only be used in text expressions")}dt(t,e,n){let r;n===void 0?n=e:e!==void 0&&(r=e);let i=[],o=[],s=0;for(let l of t)i[s]=r?r(l,s):s,o[s]=n(l,s),s++;return{values:o,keys:i}}render(t,e,n){return this.dt(t,e,n).values}update(t,[e,n,r]){let i=md(t),{values:o,keys:s}=this.dt(e,n,r);if(!Array.isArray(i))return this.ut=s,o;let l=this.ut??=[],a=[],c,u,d=0,p=i.length-1,h=0,f=o.length-1;for(;d<=p&&h<=f;)if(i[d]===null)d++;else if(i[p]===null)p--;else if(l[d]===s[h])a[h]=Lt(i[d],o[h]),d++,h++;else if(l[p]===s[f])a[f]=Lt(i[p],o[f]),p--,f--;else if(l[d]===s[f])a[f]=Lt(i[d],o[f]),Ln(t,a[f+1],i[d]),d++,f--;else if(l[p]===s[h])a[h]=Lt(i[p],o[h]),Ln(t,i[d],i[p]),p--,h++;else if(c===void 0&&(c=gd(s,h,f),u=gd(l,d,p)),c.has(l[d]))if(c.has(l[p])){let g=u.get(s[h]),b=g!==void 0?i[g]:null;if(b===null){let y=Ln(t,i[d]);Lt(y,o[h]),a[h]=y}else a[h]=Lt(b,o[h]),Ln(t,i[d],b),i[g]=null;h++}else po(i[p]),p--;else po(i[d]),d++;for(;h<=f;){let g=Ln(t,a[f+1]);Lt(g,o[h]),a[h++]=g}for(;d<=p;){let g=i[d++];g!==null&&po(g)}return this.ut=s,fd(t,a),tt}});var oy=new Intl.Collator("de",{numeric:!0,sensitivity:"base"}),Js=-1,bd=[{type:1,name:"I/O"},{type:2,name:"Splitter"},{type:0,name:"Kerninstanzen"},{type:4,name:"Konfiguratoren"},{type:5,name:"Discovery"},{type:6,name:"Visualisierungen"}],_d=t=>t.object_type===1&&bd.some(e=>e.type===t.module_type);function sy(t){let e=new Map(t.map(a=>[a.object_id,a])),n=t.filter(a=>{if(!_d(a))return!1;let c=new Set([a.object_id]),u=e.get(a.parent_id);for(;u&&!c.has(u.object_id);){if(_d(u))return!1;c.add(u.object_id),u=e.get(u.parent_id)}return!0});if(!n.length)return t;let r=new Map(e),i=new Map;for(let a of t){let c=i.get(a.parent_id)??[];c.push(a),i.set(a.parent_id,c)}let o=(a,c,u,d,p)=>({object_id:a,parent_id:c,name:u,path:d,position:p,object_type:0,hidden:!1,icon:"",virtual:!0});r.set(Js,o(Js,0,"System","System",Number.MAX_SAFE_INTEGER));let s=new Set,l=(a,c,u)=>{if(s.has(a.object_id))return;s.add(a.object_id);let d={...a,parent_id:c,path:`${u} / ${a.name}`};r.set(a.object_id,d);for(let p of i.get(a.object_id)??[])l(p,a.object_id,d.path)};return bd.forEach((a,c)=>{let u=n.filter(h=>h.module_type===a.type);if(!u.length)return;let d=-10-a.type,p=`System / ${a.name}`;r.set(d,o(d,Js,a.name,p,c));for(let h of u)l(h,d,p)}),[...r.values()]}function Qs(t){let e=sy(t),n=new Map(e.map(i=>[i.object_id,i])),r=new Map;for(let i of e){let o=n.has(i.parent_id)?i.parent_id:0,s=r.get(o)??[];s.push(i),r.set(o,s)}for(let i of r.values())i.sort((o,s)=>o.position-s.position||o.object_type-s.object_type||oy.compare(o.name,s.name));return{nodes:n,children:r}}function ea(t,e){let n=[],r=new Set([e]),i=t.nodes.get(e)?.parent_id;for(;i&&!r.has(i)&&t.nodes.has(i);)n.push(i),r.add(i),i=t.nodes.get(i)?.parent_id;return n}function ta(t,e,n=""){let r=n.trim().toLocaleLowerCase("de").split(/\s+/).filter(Boolean),i=r.length?new Set:null;if(i){for(let a of t.nodes.values())if(r.every(c=>`${a.name} ${a.path}`.toLocaleLowerCase("de").includes(c))){i.add(a.object_id);for(let c of ea(t,a.object_id))i.add(c)}}let o=[],s=new Set,l=(a,c)=>{let u=(t.children.get(a)??[]).filter(d=>!i||i.has(d.object_id));u.forEach((d,p)=>{if(s.has(d.object_id))return;s.add(d.object_id);let h=(t.children.get(d.object_id)?.length??0)>0,f=h&&(!!i||e.has(d.object_id));o.push({node:d,depth:c,hasChildren:h,expanded:f,index:p+1,siblings:u.length}),f&&l(d.object_id,c+1)})};return l(0,0),o}var yd=["Boolean","Integer","Float","String"],ay={light:"Licht",cover:"Jalousie/Tor",switch:"Schalter",binary_sensor:"Bin\xE4rsensor",sensor:"Sensor",climate:"Heizung",lock:"Schloss",script:"Skript",schedule:"Schaltuhr",media_player:"Medienger\xE4t",fan:"L\xFCfter"};function vd(t,e={}){if(t.virtual||t.object_type===0)return"Das ist eine Kategorie. Klappe sie auf und w\xE4hle den Datenpunkt darunter aus.";if(t.object_type===1)return"Das ist eine Instanz. Klappe sie auf und w\xE4hle ihre Variable aus, zum Beispiel \u201EValue\u201C.";if(e.schedule&&t.object_type!==4)return"Hier wird eine klassische Symcon-Schaltuhr (Wochenplan-Ereignis) erwartet, keine Variable.";if(e.unsupported)return e.unsupported;if(!t.entity_id)return t.object_type===2?"Diese Variable wurde noch nicht geladen. Lade die Variablen oben in der Titelleiste neu und \xF6ffne die Auswahl erneut.":t.object_type===6?"Dieser Link verweist auf keinen unterst\xFCtzten Datenpunkt. W\xE4hle die Variable direkt im Objektbaum aus.":t.object_type===4?"Dieses Ereignis ist keine unterst\xFCtzte klassische Symcon-Schaltuhr (Wochenplan).":"Dieser Objekttyp kann in diesem Feld nicht verkn\xFCpft werden. W\xE4hle eine passende Variable aus.";let n=e.states?.[t.entity_id];if(e.states&&!n)return"Diese Variable ist im aktuellen Datenbestand nicht mehr vorhanden. Lade die Variablen oben in der Titelleiste neu.";let r=n?.attributes.symcon_variable_type,i=r===void 0?void 0:yd[Number(r)];if(n&&!n.attributes.symcon_schedule&&!i)return"Der native Datentyp dieser Variable ist nicht verf\xFCgbar. Lade die Variablen oben in der Titelleiste neu.";if(i&&e.types&&!e.types.includes(Number(r)))return`Datentyp ${i} passt hier nicht. F\xFCr \u201E${e.label||"dieses Feld"}\u201C wird ${e.types.map(c=>yd[c]).join(" oder ")} ben\xF6tigt.`;let o=e.excluded?.(t.entity_id);if(o)return o;let s=ay[t.entity_id.split(".")[0]],l=n?.attributes.unit_of_measurement,a=[i&&`Datentyp: ${i}`,l&&`Einheit: ${l}`,s&&`erkannte Funktion: ${s}`].filter(Boolean).join(" \xB7 ");return`Dieser Datenpunkt erf\xFCllt den Filter${e.label?` f\xFCr \u201E${e.label}\u201C`:" dieses Feldes"} nicht.${a?` ${a}.`:""}`}var ly=["Kategorie","Instanz","Variable","Skript","Ereignis","Medium","Link"],na=class extends Y{static properties={objects:{attribute:!1},options:{attribute:!1},fixed:{attribute:!1},value:{attribute:!1},disabled:{type:Boolean},placeholder:{attribute:!1},context:{attribute:!1},_notice:{state:!0},_query:{state:!0},_expanded:{state:!0},_pending:{state:!0},_active:{state:!0},_selected:{state:!0}};tree=Qs([]);allowed=new Map;allowedSources=new Map;constructor(){super(),this.objects=[],this.options=[],this.fixed=[],this.value=null,this.disabled=!1,this.placeholder="Datenpunkt ausw\xE4hlen",this._notice="",this._query="",this._expanded=new Set,this._pending=null,this._active=null,this._selected=null}willUpdate(e){e.has("objects")&&(this.tree=Qs(this.objects)),(e.has("options")||e.has("fixed"))&&(this.allowed=new Map([...this.fixed,...this.options].map(n=>[n.id,n])),this.allowedSources=new Map(this.options.filter(n=>n.sourceEntity).map(n=>[n.sourceEntity,n.id])))}get dialog(){return this.renderRoot.querySelector("dialog")}variableNode(e){let n=this.allowed.get(e??"")?.sourceEntity??e,r=this.objects.find(i=>i.entity_id===n&&(i.object_type===2||i.object_type===4));return r?this.tree.nodes.get(r.object_id):void 0}async open(){if(this.disabled)return;this._pending=this.allowed.has(this.value??"")?this.value:null,this._query="",this._notice="";let e=this.variableNode(this.value)??this.objects.find(r=>r.entity_id===this.value);this._active=e?.object_id??null,this._selected=e?.object_id??null;let n=new Set(this._expanded);if(e)for(let r of ea(this.tree,e.object_id))n.add(r);this._expanded=n,await this.updateComplete,this.isConnected&&(this.dialog?.open||this.dialog?.showModal(),this.renderRoot.querySelector(".search")?.focus(),this.renderRoot.querySelector("[aria-selected=true]")?.scrollIntoView({block:"nearest"}))}close(){this.dialog?.close()}clear(e){e.preventDefault(),e.stopPropagation(),!this.disabled&&(this.value=this.fixed.some(n=>n.id==="none")?"none":null,this._pending=this.value,this._selected=null,this._active=null,this.close(),this.dispatchEvent(new CustomEvent("change",{detail:{value:this.value},bubbles:!0,composed:!0})))}commit(){this.disabled||!this._pending||!this.allowed.has(this._pending)||(this.value=this._pending,this.close(),this.dispatchEvent(new CustomEvent("change",{detail:{value:this.value},bubbles:!0,composed:!0})))}toggle(e){let n=new Set(this._expanded);n.has(e)?n.delete(e):n.add(e),this._expanded=n}select(e){this._active=e.object_id;let n=this.entityFor(e);n?(this._pending=n,this._selected=e.object_id,this._notice=""):(this._pending=null,this._selected=null,this._notice=vd(e,this.context))}entityFor(e){if(e.entity_id)return this.allowed.has(e.entity_id)?e.entity_id:this.allowedSources.get(e.entity_id)}async onTreeKey(e){let n=ta(this.tree,this._expanded,this._query),r=Math.max(0,n.findIndex(s=>s.node.object_id===this._active)),i=n[r];if(!i)return;let o=r;if(e.key==="ArrowDown")o=Math.min(n.length-1,r+1);else if(e.key==="ArrowUp")o=Math.max(0,r-1);else if(e.key==="Home")o=0;else if(e.key==="End")o=n.length-1;else if(e.key==="ArrowRight")i.hasChildren&&!i.expanded?this.toggle(i.node.object_id):i.hasChildren&&(o=Math.min(n.length-1,r+1));else if(e.key==="ArrowLeft")i.expanded&&!this._query?this.toggle(i.node.object_id):o=Math.max(0,n.findIndex(s=>s.node.object_id===i.node.parent_id));else if(e.key===" "||e.key==="Enter")this.select(i.node),e.key==="Enter"&&this.entityFor(i.node)&&this.commit();else return;e.preventDefault(),(o!==r||this._active===null)&&(this._active=n[o].node.object_id),await this.updateComplete,this.renderRoot.querySelector(`#object-${this._active}`)?.scrollIntoView({block:"nearest"})}icon(e){let n=[R` `,R` `,R` `,R` `,R` `,R` `,R` `];return R`${n[e]??n[1]} `}renderRow(e){let{node:n}=e,r=this.entityFor(n),i=!!r;return m`t;var fd=t=>t.strings===void 0,pd=()=>document.createComment(""),Ln=(t,e,n)=>{let r=t._$AA.parentNode,i=e===void 0?t._$AB:e._$AA;if(n===void 0){let o=r.insertBefore(pd(),i),s=r.insertBefore(pd(),i);n=new oy(o,s,t,t.options)}else{let o=n._$AB.nextSibling,s=n._$AM,l=s!==t;if(l){let a;n._$AQ?.(t),n._$AM=t,n._$AP!==void 0&&(a=t._$AU)!==s._$AU&&n._$AP(a)}if(o!==i||l){let a=n._$AA;for(;a!==o;){let c=hd(a).nextSibling;hd(r).insertBefore(a,i),a=c}}}return n},Ct=(t,e,n=t)=>(t._$AI(e,n),t),sy={},md=(t,e=sy)=>t._$AH=e,gd=t=>t._$AH,fo=t=>{t._$AR(),t._$AA.remove()};var _d=(t,e,n)=>{let r=new Map;for(let i=e;i<=n;i++)r.set(t[i],i);return r},Pr=sn(class extends Lt{constructor(t){if(super(t),t.type!==In.CHILD)throw Error("repeat() can only be used in text expressions")}dt(t,e,n){let r;n===void 0?n=e:e!==void 0&&(r=e);let i=[],o=[],s=0;for(let l of t)i[s]=r?r(l,s):s,o[s]=n(l,s),s++;return{values:o,keys:i}}render(t,e,n){return this.dt(t,e,n).values}update(t,[e,n,r]){let i=gd(t),{values:o,keys:s}=this.dt(e,n,r);if(!Array.isArray(i))return this.ut=s,o;let l=this.ut??=[],a=[],c,u,d=0,p=i.length-1,h=0,f=o.length-1;for(;d<=p&&h<=f;)if(i[d]===null)d++;else if(i[p]===null)p--;else if(l[d]===s[h])a[h]=Ct(i[d],o[h]),d++,h++;else if(l[p]===s[f])a[f]=Ct(i[p],o[f]),p--,f--;else if(l[d]===s[f])a[f]=Ct(i[d],o[f]),Ln(t,a[f+1],i[d]),d++,f--;else if(l[p]===s[h])a[h]=Ct(i[p],o[h]),Ln(t,i[d],i[p]),p--,h++;else if(c===void 0&&(c=_d(s,h,f),u=_d(l,d,p)),c.has(l[d]))if(c.has(l[p])){let g=u.get(s[h]),b=g!==void 0?i[g]:null;if(b===null){let y=Ln(t,i[d]);Ct(y,o[h]),a[h]=y}else a[h]=Ct(b,o[h]),Ln(t,i[d],b),i[g]=null;h++}else fo(i[p]),p--;else fo(i[d]),d++;for(;h<=f;){let g=Ln(t,a[f+1]);Ct(g,o[h]),a[h++]=g}for(;d<=p;){let g=i[d++];g!==null&&fo(g)}return this.ut=s,md(t,a),tt}});var ay=new Intl.Collator("de",{numeric:!0,sensitivity:"base"}),ea=-1,yd=[{type:1,name:"I/O"},{type:2,name:"Splitter"},{type:0,name:"Kerninstanzen"},{type:4,name:"Konfiguratoren"},{type:5,name:"Discovery"},{type:6,name:"Visualisierungen"}],bd=t=>t.object_type===1&&yd.some(e=>e.type===t.module_type);function ly(t){let e=new Map(t.map(a=>[a.object_id,a])),n=t.filter(a=>{if(!bd(a))return!1;let c=new Set([a.object_id]),u=e.get(a.parent_id);for(;u&&!c.has(u.object_id);){if(bd(u))return!1;c.add(u.object_id),u=e.get(u.parent_id)}return!0});if(!n.length)return t;let r=new Map(e),i=new Map;for(let a of t){let c=i.get(a.parent_id)??[];c.push(a),i.set(a.parent_id,c)}let o=(a,c,u,d,p)=>({object_id:a,parent_id:c,name:u,path:d,position:p,object_type:0,hidden:!1,icon:"",virtual:!0});r.set(ea,o(ea,0,"System","System",Number.MAX_SAFE_INTEGER));let s=new Set,l=(a,c,u)=>{if(s.has(a.object_id))return;s.add(a.object_id);let d={...a,parent_id:c,path:`${u} / ${a.name}`};r.set(a.object_id,d);for(let p of i.get(a.object_id)??[])l(p,a.object_id,d.path)};return yd.forEach((a,c)=>{let u=n.filter(h=>h.module_type===a.type);if(!u.length)return;let d=-10-a.type,p=`System / ${a.name}`;r.set(d,o(d,ea,a.name,p,c));for(let h of u)l(h,d,p)}),[...r.values()]}function ta(t){let e=ly(t),n=new Map(e.map(i=>[i.object_id,i])),r=new Map;for(let i of e){let o=n.has(i.parent_id)?i.parent_id:0,s=r.get(o)??[];s.push(i),r.set(o,s)}for(let i of r.values())i.sort((o,s)=>o.position-s.position||o.object_type-s.object_type||ay.compare(o.name,s.name));return{nodes:n,children:r}}function na(t,e){let n=[],r=new Set([e]),i=t.nodes.get(e)?.parent_id;for(;i&&!r.has(i)&&t.nodes.has(i);)n.push(i),r.add(i),i=t.nodes.get(i)?.parent_id;return n}function ra(t,e,n=""){let r=n.trim().toLocaleLowerCase("de").split(/\s+/).filter(Boolean),i=r.length?new Set:null;if(i){for(let a of t.nodes.values())if(r.every(c=>`${a.name} ${a.path}`.toLocaleLowerCase("de").includes(c))){i.add(a.object_id);for(let c of na(t,a.object_id))i.add(c)}}let o=[],s=new Set,l=(a,c)=>{let u=(t.children.get(a)??[]).filter(d=>!i||i.has(d.object_id));u.forEach((d,p)=>{if(s.has(d.object_id))return;s.add(d.object_id);let h=(t.children.get(d.object_id)?.length??0)>0,f=h&&(!!i||e.has(d.object_id));o.push({node:d,depth:c,hasChildren:h,expanded:f,index:p+1,siblings:u.length}),f&&l(d.object_id,c+1)})};return l(0,0),o}var vd=["Boolean","Integer","Float","String"],cy={light:"Licht",cover:"Jalousie/Tor",switch:"Schalter",binary_sensor:"Bin\xE4rsensor",sensor:"Sensor",climate:"Heizung",lock:"Schloss",script:"Skript",schedule:"Schaltuhr",media_player:"Medienger\xE4t",fan:"L\xFCfter"};function wd(t,e={}){if(t.virtual||t.object_type===0)return"Das ist eine Kategorie. Klappe sie auf und w\xE4hle den Datenpunkt darunter aus.";if(t.object_type===1)return"Das ist eine Instanz. Klappe sie auf und w\xE4hle ihre Variable aus, zum Beispiel \u201EValue\u201C.";if(e.schedule&&t.object_type!==4)return"Hier wird eine klassische Symcon-Schaltuhr (Wochenplan-Ereignis) erwartet, keine Variable.";if(e.unsupported)return e.unsupported;if(!t.entity_id)return t.object_type===2?"Diese Variable wurde noch nicht geladen. Lade die Variablen oben in der Titelleiste neu und \xF6ffne die Auswahl erneut.":t.object_type===6?"Dieser Link verweist auf keinen unterst\xFCtzten Datenpunkt. W\xE4hle die Variable direkt im Objektbaum aus.":t.object_type===4?"Dieses Ereignis ist keine unterst\xFCtzte klassische Symcon-Schaltuhr (Wochenplan).":"Dieser Objekttyp kann in diesem Feld nicht verkn\xFCpft werden. W\xE4hle eine passende Variable aus.";let n=e.states?.[t.entity_id];if(e.states&&!n)return"Diese Variable ist im aktuellen Datenbestand nicht mehr vorhanden. Lade die Variablen oben in der Titelleiste neu.";let r=n?.attributes.symcon_variable_type,i=r===void 0?void 0:vd[Number(r)];if(n&&!n.attributes.symcon_schedule&&!i)return"Der native Datentyp dieser Variable ist nicht verf\xFCgbar. Lade die Variablen oben in der Titelleiste neu.";if(i&&e.types&&!e.types.includes(Number(r)))return`Datentyp ${i} passt hier nicht. F\xFCr \u201E${e.label||"dieses Feld"}\u201C wird ${e.types.map(c=>vd[c]).join(" oder ")} ben\xF6tigt.`;let o=e.excluded?.(t.entity_id);if(o)return o;let s=cy[t.entity_id.split(".")[0]],l=n?.attributes.unit_of_measurement,a=[i&&`Datentyp: ${i}`,l&&`Einheit: ${l}`,s&&`erkannte Funktion: ${s}`].filter(Boolean).join(" \xB7 ");return`Dieser Datenpunkt erf\xFCllt den Filter${e.label?` f\xFCr \u201E${e.label}\u201C`:" dieses Feldes"} nicht.${a?` ${a}.`:""}`}var uy=["Kategorie","Instanz","Variable","Skript","Ereignis","Medium","Link"],ia=class extends Y{static properties={objects:{attribute:!1},options:{attribute:!1},fixed:{attribute:!1},value:{attribute:!1},disabled:{type:Boolean},placeholder:{attribute:!1},context:{attribute:!1},_notice:{state:!0},_query:{state:!0},_expanded:{state:!0},_pending:{state:!0},_active:{state:!0},_selected:{state:!0}};tree=ta([]);allowed=new Map;allowedSources=new Map;constructor(){super(),this.objects=[],this.options=[],this.fixed=[],this.value=null,this.disabled=!1,this.placeholder="Datenpunkt ausw\xE4hlen",this._notice="",this._query="",this._expanded=new Set,this._pending=null,this._active=null,this._selected=null}willUpdate(e){e.has("objects")&&(this.tree=ta(this.objects)),(e.has("options")||e.has("fixed"))&&(this.allowed=new Map([...this.fixed,...this.options].map(n=>[n.id,n])),this.allowedSources=new Map(this.options.filter(n=>n.sourceEntity).map(n=>[n.sourceEntity,n.id])))}get dialog(){return this.renderRoot.querySelector("dialog")}variableNode(e){let n=this.allowed.get(e??"")?.sourceEntity??e,r=this.objects.find(i=>i.entity_id===n&&(i.object_type===2||i.object_type===4));return r?this.tree.nodes.get(r.object_id):void 0}async open(){if(this.disabled)return;this._pending=this.allowed.has(this.value??"")?this.value:null,this._query="",this._notice="";let e=this.variableNode(this.value)??this.objects.find(r=>r.entity_id===this.value);this._active=e?.object_id??null,this._selected=e?.object_id??null;let n=new Set(this._expanded);if(e)for(let r of na(this.tree,e.object_id))n.add(r);this._expanded=n,await this.updateComplete,this.isConnected&&(this.dialog?.open||this.dialog?.showModal(),this.renderRoot.querySelector(".search")?.focus(),this.renderRoot.querySelector("[aria-selected=true]")?.scrollIntoView({block:"nearest"}))}close(){this.dialog?.close()}clear(e){e.preventDefault(),e.stopPropagation(),!this.disabled&&(this.value=this.fixed.some(n=>n.id==="none")?"none":null,this._pending=this.value,this._selected=null,this._active=null,this.close(),this.dispatchEvent(new CustomEvent("change",{detail:{value:this.value},bubbles:!0,composed:!0})))}commit(){this.disabled||!this._pending||!this.allowed.has(this._pending)||(this.value=this._pending,this.close(),this.dispatchEvent(new CustomEvent("change",{detail:{value:this.value},bubbles:!0,composed:!0})))}toggle(e){let n=new Set(this._expanded);n.has(e)?n.delete(e):n.add(e),this._expanded=n}select(e){this._active=e.object_id;let n=this.entityFor(e);n?(this._pending=n,this._selected=e.object_id,this._notice=""):(this._pending=null,this._selected=null,this._notice=wd(e,this.context))}entityFor(e){if(e.entity_id)return this.allowed.has(e.entity_id)?e.entity_id:this.allowedSources.get(e.entity_id)}async onTreeKey(e){let n=ra(this.tree,this._expanded,this._query),r=Math.max(0,n.findIndex(s=>s.node.object_id===this._active)),i=n[r];if(!i)return;let o=r;if(e.key==="ArrowDown")o=Math.min(n.length-1,r+1);else if(e.key==="ArrowUp")o=Math.max(0,r-1);else if(e.key==="Home")o=0;else if(e.key==="End")o=n.length-1;else if(e.key==="ArrowRight")i.hasChildren&&!i.expanded?this.toggle(i.node.object_id):i.hasChildren&&(o=Math.min(n.length-1,r+1));else if(e.key==="ArrowLeft")i.expanded&&!this._query?this.toggle(i.node.object_id):o=Math.max(0,n.findIndex(s=>s.node.object_id===i.node.parent_id));else if(e.key===" "||e.key==="Enter")this.select(i.node),e.key==="Enter"&&this.entityFor(i.node)&&this.commit();else return;e.preventDefault(),(o!==r||this._active===null)&&(this._active=n[o].node.object_id),await this.updateComplete,this.renderRoot.querySelector(`#object-${this._active}`)?.scrollIntoView({block:"nearest"})}icon(e){let n=[R`
`,R`
`,R`
`,R`
`,R`
`,R`
`,R`
`];return R`
${n[e]??n[1]} `}renderRow(e){let{node:n}=e,r=this.entityFor(n),i=!!r;return m`
${this.icon(n.object_type)}${n.name||"(Ohne Namen)"}
- ${n.virtual?"Systembereich":ly[n.object_type]??"Objekt"}${n.hidden?" \xB7 ausgeblendet":""}
+ ${n.virtual?"Systembereich":uy[n.object_type]??"Objekt"}${n.hidden?" \xB7 ausgeblendet":""}
${i&&n.object_id===this._selected&&r===this._pending?m`✓ `:_}
-
`}render(){let e=this.allowed.get(this.value??""),n=this.variableNode(this.value),r=this.allowed.get(this._pending??""),i=this._selected===null?void 0:this.tree.nodes.get(this._selected),o=(i&&this.entityFor(i)===this._pending?i:void 0)??this.variableNode(this._pending),s=ta(this.tree,this._expanded,this._query),l=s.find(c=>c.node.object_id===this._active),a=!!this.value&&!this.fixed.some(c=>c.id===this.value);return m`
+
`}render(){let e=this.allowed.get(this.value??""),n=this.variableNode(this.value),r=this.allowed.get(this._pending??""),i=this._selected===null?void 0:this.tree.nodes.get(this._selected),o=(i&&this.entityFor(i)===this._pending?i:void 0)??this.variableNode(this._pending),s=ra(this.tree,this._expanded,this._query),l=s.find(c=>c.node.object_id===this._active),a=!!this.value&&!this.fixed.some(c=>c.id===this.value);return m`
${n?.name??e?.label??"Datenpunkt ausw\xE4hlen"}
${n?m`${n.path} `:_}⌘
${a?m`× `:_}
@@ -234,7 +234,7 @@ var $={cs:"4be67fcd522e",da:"0fe66a82bf2a",es:"bd89dffd1355",fi:"9a17bc084f56",f
{this._pending=c.id,this._active=null,this._selected=null,this._notice=""}}>${c.label} `)}
`:_}
- ${zr(s,c=>c.node.object_id,c=>this.renderRow(c))}
+ ${Pr(s,c=>c.node.object_id,c=>this.renderRow(c))}
${s.length?_:m`
${this.objects.length?"Keine Objekte gefunden.":"Kein Objektbaum verf\xFCgbar. Bitte das Symcon-Modul aktualisieren und den Designer neu laden."}
`}
${this._notice?m`${this._notice}
`:_}
@@ -294,7 +294,7 @@ var $={cs:"4be67fcd522e",da:"0fe66a82bf2a",es:"bd89dffd1355",fi:"9a17bc084f56",f
.tree { margin:0 8px; } .node { gap:6px; padding-left:calc(2px + var(--depth)*18px); }
.node small { display:none; } footer { padding:12px; flex-direction:column; align-items:stretch; } .actions { justify-content:flex-end; }
}
- `]};customElements.get("nf-symcon-object-picker")||customElements.define("nf-symcon-object-picker",na);var wd=40,ra=class extends Y{static properties={options:{attribute:!1},objectTree:{attribute:!1},context:{attribute:!1},fixed:{attribute:!1},value:{attribute:!1},disabled:{type:Boolean},placeholder:{attribute:!1},_query:{state:!0},_open:{state:!0},_cursor:{state:!0}};blurTimer;constructor(){super(),this.options=[],this.objectTree=void 0,this.fixed=[],this.value=null,this.disabled=!1,this.placeholder="",this._query="",this._open=!1,this._cursor=0}get current(){return[...this.fixed,...this.options].find(e=>e.id===this.value)}get hits(){let e=this._query.trim().toLowerCase(),n=e.split(/\s+/).filter(Boolean),r=s=>{let l=`${s.label} ${s.detail??s.id}`.toLowerCase();return n.every(a=>l.includes(a))},i=this.fixed.filter(s=>!e||r(s)),o=e?this.options.filter(r):this.options;return[...i,...o.slice(0,wd)]}get leftOut(){let e=this._query.trim().toLowerCase(),n=e.split(/\s+/).filter(Boolean),r=e?this.options.filter(i=>n.every(o=>`${i.label} ${i.detail??i.id}`.toLowerCase().includes(o))).length:this.options.length;return Math.max(0,r-wd)}choose(e){this.value=e,this._query="",this._open=!1,this.dispatchEvent(new CustomEvent("change",{detail:{value:e},bubbles:!0,composed:!0}))}onKey(e){let n=this.hits;e.key==="ArrowDown"?(this._open=!0,this._cursor=Math.min(n.length-1,this._cursor+1),e.preventDefault()):e.key==="ArrowUp"?(this._cursor=Math.max(0,this._cursor-1),e.preventDefault()):e.key==="Enter"?(this._open&&n[this._cursor]&&this.choose(n[this._cursor].id),e.preventDefault()):e.key==="Escape"&&(this._open=!1,this._query="")}render(){if(this.objectTree!==void 0)return m`e.id===this.value)}get hits(){let e=this._query.trim().toLowerCase(),n=e.split(/\s+/).filter(Boolean),r=s=>{let l=`${s.label} ${s.detail??s.id}`.toLowerCase();return n.every(a=>l.includes(a))},i=this.fixed.filter(s=>!e||r(s)),o=e?this.options.filter(r):this.options;return[...i,...o.slice(0,kd)]}get leftOut(){let e=this._query.trim().toLowerCase(),n=e.split(/\s+/).filter(Boolean),r=e?this.options.filter(i=>n.every(o=>`${i.label} ${i.detail??i.id}`.toLowerCase().includes(o))).length:this.options.length;return Math.max(0,r-kd)}choose(e){this.value=e,this._query="",this._open=!1,this.dispatchEvent(new CustomEvent("change",{detail:{value:e},bubbles:!0,composed:!0}))}onKey(e){let n=this.hits;e.key==="ArrowDown"?(this._open=!0,this._cursor=Math.min(n.length-1,this._cursor+1),e.preventDefault()):e.key==="ArrowUp"?(this._cursor=Math.max(0,this._cursor-1),e.preventDefault()):e.key==="Enter"?(this._open&&n[this._cursor]&&this.choose(n[this._cursor].id),e.preventDefault()):e.key==="Escape"&&(this._open=!1,this._query="")}render(){if(this.objectTree!==void 0)return m`this.dialog?.showModal()}>ⓘ
+ `]};customElements.get("nf-entity-picker")||customElements.define("nf-entity-picker",oa);var sa=class extends Y{static properties={text:{attribute:!1}};constructor(){super(),this.text=""}get dialog(){return this.renderRoot.querySelector("dialog")}render(){return m`this.dialog?.showModal()}>ⓘ
e.stopPropagation()} @click=${e=>{if(e.target!==e.currentTarget)return;let n=this.dialog.getBoundingClientRect();(e.clientXn.right||e.clientYn.bottom)&&this.dialog?.close()}}>
Information this.dialog?.close()}>×
${this.text}
@@ -408,7 +408,7 @@ var $={cs:"4be67fcd522e",da:"0fe66a82bf2a",es:"bd89dffd1355",fi:"9a17bc084f56",f
header { display:flex; align-items:center; justify-content:space-between; gap:20px; font-size:16px; }
.close { width:30px; height:30px; padding:0; font-size:23px; }
p { white-space:pre-wrap; overflow-wrap:anywhere; margin:16px 0 4px; }
- `]};customElements.get("nf-help-popup")||customElements.define("nf-help-popup",ia);var sn=t=>t.target.value,oa=t=>Number.parseFloat(t.replace(",",".")),ae=t=>Math.round(t*1e3)/1e3,kd=t=>t.wide?"nf-field nf-wide":"nf-field";function E(t,e,n,r,i=.01,o){return m`t.target.value,aa=t=>Number.parseFloat(t.replace(",",".")),ae=t=>Math.round(t*1e3)/1e3,xd=t=>t.wide?"nf-field nf-wide":"nf-field";function E(t,e,n,r,i=.01,o){return m`${e}
{let l=oa(sn(s));Number.isFinite(l)&&r(l)}}
+ @change=${s=>{let l=aa(an(s));Number.isFinite(l)&&r(l)}}
/>
- `}function V(t,e,n,r,i={}){return m``}function V(t,e,n,r,i={}){return m`${e}
- r(sn(o).trim())} />
- `}function L(t,e,n,r,i,o={}){return m`r(an(o).trim())} />
+ `}function H(t,e,n,r,i,o={}){return m`${e}
- i(sn(s))}>
+ i(an(s))}>
${r.map(([s,l])=>m`${l} `)}
`}function D(t,e,n,r,i={}){return m` r(o.target.checked)} />
${e} `}function Ge(t,e,n,r,i){return m``}function Ue(t,e,n,r,i){return m`${e}
i(o.target.value)} />
${n?m`i(null)}>${t.t("wall_paint_default")} `:_} `}function z(t,e,n,r,i,o,s={}){let l=r===void 0?null:r?t.t("entity_auto",{name:B(t.hass,r)}):t.t("entity_auto_none"),a=[...l!==null?[{id:"__auto",label:l}]:[],{id:"none",label:t.t("entity_none")}],c=n??(l!==null?"__auto":"none"),u=t.hass?.symconObjects!==void 0&&!s.schedule?ud(t.hass,s,n):i;return m``}function z(t,e,n,r,i,o,s={}){let l=r===void 0?null:r?t.t("entity_auto",{name:B(t.hass,r)}):t.t("entity_auto_none"),a=[...l!==null?[{id:"__auto",label:l}]:[],{id:"none",label:t.t("entity_none")}],c=n??(l!==null?"__auto":"none"),u=t.hass?.symconObjects!==void 0&&!s.schedule?dd(t.hass,s,n):i;return m`${e}
{d.stopPropagation(),o(d.detail.value==="__auto"?null:d.detail.value)}}
>
- `}function Cn(t,e,n){return n?(n.startsWith("mdi:")?n:`mdi:${n}`).replace(/[^a-z0-9:-]/gi,""):t.hass?Pu(t.hass,e):null}function Ct(t,e,n){let r=e?(e.startsWith("mdi:")?e:`mdi:${e}`).replace(/[^a-z0-9:-]/gi,""):"";return m``}function Cn(t,e,n){return n?(n.startsWith("mdi:")?n:`mdi:${n}`).replace(/[^a-z0-9:-]/gi,""):t.hass?Iu(t.hass,e):null}function Nt(t,e,n){let r=e?(e.startsWith("mdi:")?e:`mdi:${e}`).replace(/[^a-z0-9:-]/gi,""):"";return m`${t.t("marker_icon")}
- n(sn(i).trim().replace(/^mdi:/,"")||null)} />
- ${r?Qu(` `):_}
+ n(an(i).trim().replace(/^mdi:/,"")||null)} />
+ ${r?ed(` `):_}
`}function Nn(t,e,n){return m`${t.t("marker_show")}
- n(sn(r)||null)}>
+ n(an(r)||null)}>
${t.t("marker_show_auto")}
- ${ou.map(r=>m`${t.t(`marker_show_${r}`)} `)}
+ ${au.map(r=>m`${t.t(`marker_show_${r}`)} `)}
- `}function Nt(t,e,n){let r=e??{},i=o=>s=>{let l={...r,[o]:Math.round(Math.max(-5,Math.min(5,s))*100)/100};n(l.x||l.z||l.y?l:null)};return m`
+ `}function Bt(t,e,n){let r=e??{},i=o=>s=>{let l={...r,[o]:Math.round(Math.max(-5,Math.min(5,s))*100)/100};n(l.x||l.z||l.y?l:null)};return m`
${t.t("pin_shift")}
${E(t,"\u2194 x",r.x??0,i("x"),.05)} ${E(t,"\u2195 z",r.z??0,i("z"),.05)} ${E(t,t.t("pin_shift_up"),r.y??0,i("y"),.05)}
${e?m`n(null)}>${t.t("height_auto")} `:_}
${S(t.t("pin_shift_hint"),"nf-wide")}
- `}var J=(...t)=>m`${t}
`,S=(t,e="")=>m` `;function an(t,e,n,r={}){let i=r.lowest??10;return m``}var J=(...t)=>m`${t}
`,S=(t,e="")=>m` `;function ln(t,e,n,r={}){let i=r.lowest??10;return m`${t.t(r.label??"glow_scale")}
{let s=Number(sn(o)),l=Math.min(150,Math.max(i,sn(o).trim()===""||Number.isNaN(s)?100:s))/100;n(Math.abs(l-1)<.001?null:l)}}
+ @change=${o=>{let s=Number(an(o)),l=Math.min(150,Math.max(i,an(o).trim()===""||Number.isNaN(s)?100:s))/100;n(Math.abs(l-1)<.001?null:l)}}
/>
- `}var rt=(t,e,n={})=>t.callWS({type:`nextfloor/${e}`,...n});async function fo(t,e){return(await rt(t,"image/get",{image_id:e})).data}async function Bt(t,e,n){await rt(t,"image/set",{image_id:e,data:n})}async function xd(t){return(await rt(t,"history/list")).snapshots}async function $d(t,e){return(await rt(t,"history/snapshot",e?{name:e}:{})).id}async function Sd(t,e){return(await rt(t,"history/get",{snapshot_id:e})).building}async function Md(t,e){await rt(t,"history/delete",{snapshot_id:e})}async function Rd(t,e){return(await rt(t,"history/restore",{snapshot_id:e})).revision}var Pr=(t,e)=>rt(t,"packs/import",{pack:e});async function Ed(t,e){await rt(t,"packs/remove",{pack_id:e})}var Ad=t=>rt(t,"backup/export"),Fd=(t,e,n)=>rt(t,"backup/import",{building:e,packs:n});var G=(t,e)=>[t[0]-e[0],t[1]-e[1]],ft=(t,e)=>[t[0]+e[0],t[1]+e[1]],it=(t,e)=>[t[0]*e,t[1]*e],te=(t,e)=>t[0]*e[0]+t[1]*e[1],Re=(t,e)=>t[0]*e[1]-t[1]*e[0],ge=t=>Math.hypot(t[0],t[1]),ot=t=>{let e=ge(t)||1;return[t[0]/e,t[1]/e]},sa=t=>[-t[1],t[0]],aa=t=>[t[1],-t[0]];var cy=.05,uy=.2,dy=.12;function hy(t){let e=[];return t.forEach((n,r)=>{let i=n.points;if(i.length<3)return;let o=_e(i)>=0;i.forEach((s,l)=>{let a=i[(l+1)%i.length],c=ge(G(a,s));if(c<.05)return;let u=[(a[0]-s[0])/c,(a[1]-s[1])/c],d=o?[u[1],-u[0]]:[-u[1],u[0]];(u[1]<-1e-9||Math.abs(u[1])<=1e-9&&u[0]<0)&&(u=[-u[0],-u[1]]);let p=[-u[1],u[0]],[h,f]=[te(s,u),te(a,u)];e.push({room:r,index:l,dir:u,normal:p,offset:te(s,p),outside:te(d,p)>0?1:-1,from:Math.min(h,f),to:Math.max(h,f)})})}),e}function py(t,e,n){if(t.room===e.room||Math.abs(Re(t.dir,e.dir))>cy||t.outside===e.outside)return null;let r=(e.offset-t.offset)*t.outside;return r>n||r<-dy||Math.abs(r)<1e-4||Math.min(t.to,e.to)-Math.max(t.from,e.from)Math.round(t*1e3)/1e3;function Td(t,e=.6){let n=hy(t),r=n.map((g,b)=>b),i=g=>r[g]===g?g:r[g]=i(r[g]),o=[],s=new Set,l=[];for(let g=0;gMath.abs(g[2])-Math.abs(b[2]));let a=new Map(n.map((g,b)=>[b,[b]])),c=(g,b)=>g.some(y=>b.some(v=>n[y].room===n[v].room&&Math.abs(n[y].offset-n[v].offset)>=.002));for(let[g,b,y]of l){let[v,w]=[i(g),i(b)];if(v!==w){if(c(a.get(v),a.get(w)))continue;r[v]=w,a.set(w,[...a.get(w),...a.get(v)]),a.delete(v)}o.push(la(y)),s.add(g).add(b)}let u=new Map(n.map((g,b)=>[`${g.room}:${g.index}`,b]));for(let g=s.size>0;g;)g=!1,n.forEach((b,y)=>{let v=u.get(`${b.room}:${(b.index+1)%t[b.room].points.length}`);if(v===void 0||v===y)return;let w=n[v];!(Math.abs(Re(b.dir,w.dir))<1e-6&&Math.abs(b.offset-w.offset)<.002&&b.outside===w.outside)||s.has(y)===s.has(v)||(s.add(y).add(v),g=!0)});n.forEach((g,b)=>{let y=u.get(`${g.room}:${(g.index+1)%t[g.room].points.length}`);if(y===void 0||y===b||!s.has(b)||!s.has(y))return;let v=n[y];Math.abs(Re(g.dir,v.dir))<1e-6&&Math.abs(g.offset-v.offset)<.002&&g.outside===v.outside&&(r[i(b)]=i(y))});let d=()=>t.map(g=>({...g,points:g.points.map(b=>[b[0],b[1]])}));if(o.length===0)return{rooms:d(),gaps:o};let p=new Map;for(let g of s)p.set(i(g),[...p.get(i(g))??[],g]);let h=t.map(g=>g.points.map(()=>new Map));for(let[g,b]of p){let y=new Map(b.map(w=>[`${n[w].room}:${Math.round(n[w].offset*500)}`,n[w].offset])),v=[...y.values()].reduce((w,x)=>w+x,0)/y.size;for(let w of b){let x=n[w],k=[x.normal[0]*(v-x.offset),x.normal[1]*(v-x.offset)];h[x.room][x.index].set(g,k),h[x.room][(x.index+1)%t[x.room].points.length].set(g,k)}}return{rooms:t.map((g,b)=>({...g,points:g.points.map((y,v)=>{let w=[...h[b][v].values()].reduce((x,k)=>[x[0]+k[0],x[1]+k[1]],[y[0],y[1]]);return[la(w[0]),la(w[1])]})})),gaps:o}}function zd(t){let e=t.filter(n=>n>.04).sort((n,r)=>n-r);return e.length===0?null:Math.min(.5,Math.max(.08,Math.round(e[Math.floor(e.length/2)]*100)/100))}var fy=.25,Pd=t=>Math.round(t*1e3)/1e3,Dd=(t,e,n)=>t.rooms.find(r=>r.points.length>=3&&C([e,n],r.points));function ua(t,e,n,r,i){let o=Dd(t,e,n);if(!o)return[r,i];let s=(l,a)=>C([l,a],o.points);return s(r,i)?[r,i]:s(r,n)?[r,n]:s(e,i)?[e,i]:[e,n]}function my(t,e,n,r){return t.rooms.some(i=>i.id!==e.id&&i.points.some((o,s)=>{let l=i.points[(s+1)%i.points.length];return Math.abs(te(G(o,n),r))<.02&&Math.abs(te(G(l,n),r))<.02}))}var ca=(t,e)=>Math.abs((t-e+540)%360-180);function Dr(t,e,n,r=fy){let i=Dd(t,e.x,e.z);if(!i)return null;let o=i.points,s=_e(o)>=0?1:-1,l=null;return o.forEach((a,c)=>{let u=o[(c+1)%o.length],d=ge(G(u,a));if(d<.3)return;let p=[(u[0]-a[0])/d,(u[1]-a[1])/d],h=[-p[1]*s,p[0]*s],f=te(G([e.x,e.z],a),p);if(f<0||f>d)return;let g=my(t,i,a,h)?n/2:0,b=te(G([e.x,e.z],a),h)-g,y=Math.atan2(-h[0],h[1])*180/Math.PI,w=[{rotation:y,extent:e.d/2},{rotation:y+90,extent:e.w/2},{rotation:y-90,extent:e.w/2}].reduce((k,M)=>ca(e.rotation,M.rotation)50)return;let x=b-w.extent;Math.abs(x)>r||l&&Math.abs(x)>=Math.abs(l.gap)||(l={x:Pd(e.x-h[0]*x),z:Pd(e.z-h[1]*x),rotation:(Math.round(w.rotation)%360+360)%360,gap:x})}),l&&{x:l.x,z:l.z,rotation:l.rotation}}var Bn=Math.PI/180,st=t=>Math.tan(Math.min(80,Math.max(0,t))*Bn);function Or(t){return{x0:Math.min(t.x0,t.x1),x1:Math.max(t.x0,t.x1),z0:Math.min(t.z0,t.z1),z1:Math.max(t.z0,t.z1)}}function Id(t){if(!t.rotation)return null;let e=t.rotation*Bn;return{cx:(t.x0+t.x1)/2,cz:(t.z0+t.z1)/2,c:Math.cos(e),sn:Math.sin(e)}}function Od(t,e){let n=Id(t);if(!n)return e;let[r,i]=[e[0]-n.cx,e[1]-n.cz];return[n.cx+r*n.c-i*n.sn,n.cz+r*n.sn+i*n.c]}function da(t,e,n){let r=Id(t);if(!r)return[e,n];let[i,o]=[e-r.cx,n-r.cz];return[r.cx+i*r.c+o*r.sn,r.cz-i*r.sn+o*r.c]}function Hr(t,e=0){let{x0:n,x1:r,z0:i,z1:o}=Or(t);return[[n-e,i-e],[r+e,i-e],[r+e,o+e],[n-e,o+e]].map(s=>Od(t,s))}function xe(t){let{x0:e,x1:n,z0:r,z1:i}=Or(t),o=s=>Od(t,s);return t.axis==="x"?{u0:e,u1:n,w:i-r,at:(s,l)=>o([s,t.flip?i-l:r+l])}:{u0:r,u1:i,w:n-e,at:(s,l)=>o([t.flip?n-l:e+l,s])}}function Lr(t,e,n){let{x0:r,x1:i,z0:o,z1:s}=Or(t),[l,a]=da(t,e,n);return t.axis==="x"?[l,t.flip?s-a:a-o]:[a,t.flip?i-l:l-r]}var Ir=Math.tan(30*Bn);function Cr(t,e,n,r,i){let o=Math.min(t*.3,r>1e-6?2.4/r:t*.3),s=Math.min(t*.3,i>1e-6?2.4/i:t*.3),l=e+o*r,a=n+s*i,c=Math.min(t-s,Math.max(o,(a-l+Ir*(t-s+o))/(2*Ir))),u=l+(c-o)*Ir;return{vla:o,vlb:s,yla:l,ylb:a,vr:c,rh:u,y:p=>p<=o?e+p*r:p<=c?l+(p-o)*Ir:p<=t-s?a+(t-s-p)*Ir:n+(t-p)*i}}function Le(t){let e=xe(t).w,[n,r]=[t.eave_a,t.eave_b],[i,o]=[st(t.pitch_a),st(t.pitch_b)];switch(t.shape){case"flat":case"parapet":return{vr:e/2,rh:n,y:()=>n};case"pent":return{vr:e,rh:n+e*i,y:s=>n+s*i};case"mansard":{let s=Cr(e,n,r,i,o);return{vr:s.vr,rh:s.rh,y:s.y}}default:{let s=i+o>1e-6?Math.min(e,Math.max(0,(r-n+e*o)/(i+o))):e/2;return{vr:s,rh:n+s*i,y:l=>l<=s?n+l*i:r+(e-l)*o}}}}var ln=t=>Le(t).rh;function Hd(t){let e=t.heightEnd!==void 0;return{...t,a:t.b,b:t.a,left:t.right,right:t.left,roomLeft:t.roomRight,roomRight:t.roomLeft,height:e?t.heightEnd:t.height,heightEnd:e?t.height:void 0}}function gy(t,e){let n=t.map(r=>({...r}));for(let r of e){let i=n.find(o=>o.room_id===r.room_id&&o.edge===r.edge&&(Math.abs(o.t1-r.t0)<1e-6||Math.abs(r.t1-o.t0)<1e-6));i?(i.t0=Math.min(i.t0,r.t0),i.t1=Math.max(i.t1,r.t1)):n.push({...r})}return n}function _y(t,e,n){if(t.a===e.b)return!1;let r=ot(G(n[t.b],n[t.a])),i=ot(G(n[e.b],n[e.a]));return Math.abs(Re(r,i))>1e-6||te(r,i)<=0||t.free||e.free||t.heightEnd!==void 0||e.heightEnd!==void 0?!1:t.height===e.height&&t.exterior===e.exterior&&t.roomLeft===e.roomLeft&&t.roomRight===e.roomRight&&Math.abs(t.left-e.left)<=1e-9&&Math.abs(t.right-e.right)<=1e-9}function Ld(t,e,n=new Set){let r=t.slice();for(;;){let i=new Map;r.forEach((s,l)=>{for(let a of[s.a,s.b])i.set(a,[...i.get(a)??[],l])});let o=null;for(let[s,l]of i){if(l.length!==2||n.has(s))continue;let a=r[l[0]].b===s?r[l[0]]:Hd(r[l[0]]),c=r[l[1]].a===s?r[l[1]]:Hd(r[l[1]]);if(!_y(a,c,e))continue;let u={...a,b:c.b,sources:gy(a.sources,c.sources)};o=[...r.filter((d,p)=>p!==l[0]&&p!==l[1]),u];break}if(!o)return r;r=o}}function Cd(t,e){let n=new Map;t.forEach((i,o)=>{let s=ot(G(e[i.b],e[i.a])),l=[[i.a,{key:`${o}:a`,d:s,left:i.left,right:i.right,angle:Math.atan2(s[1],s[0])}],[i.b,{key:`${o}:b`,d:it(s,-1),left:i.right,right:i.left,angle:Math.atan2(-s[1],-s[0])}]];for(let[a,c]of l)n.set(a,[...n.get(a)??[],c])});let r=new Map;for(let[i,o]of n){let s=e[i];o.sort((a,c)=>a.angle-c.angle);for(let a of o)r.set(a.key,{left:ft(s,it(sa(a.d),a.left)),right:ft(s,it(aa(a.d),a.right))});if(o.length<2)continue;let l=4*Math.max(...o.map(a=>Math.max(a.left,a.right)))+1e-9;o.forEach((a,c)=>{let u=o[(c+1)%o.length],d=ft(s,it(sa(a.d),a.left)),p=ft(s,it(aa(u.d),u.right)),h=Re(a.d,u.d);if(Math.abs(h)<1e-4)return;let f=ft(d,it(a.d,Re(G(p,d),u.d)/h));ge(G(f,s))>l||(r.get(a.key).left=f,r.get(u.key).right=f)})}return r}function Nd(t,e){let n=t.filter((r,i)=>ge(G(r,t[(i+1)%t.length]))>e);for(;;){if(n.length<=3)return n;let r=n.findIndex((i,o)=>{let s=n[(o+n.length-1)%n.length],l=n[(o+1)%n.length],[a,c]=[G(i,s),G(l,i)];return Math.abs(Re(ot(a),ot(c)))<1e-7&&te(a,c)>0});if(r===-1)return n;n=n.filter((i,o)=>o!==r)}}function by(t){let e=[];return{points:e,idOf(n){let r=e.findIndex(i=>Math.abs(i[0]-n[0])<=t&&Math.abs(i[1]-n[1])<=t);return r>=0?r:(e.push([n[0],n[1]]),e.length-1)}}}function yy(t,e){let n=[];for(let r of t){let i=r.points;if(i.length<3||Math.abs(_e(i))<1e-6)continue;let o=_e(i)>0,s=i.map(l=>e.idOf(l));s.forEach((l,a)=>{let c=s[(a+1)%s.length];l!==c&&n.push(o?{u:l,v:c,room:r.id,edge:a,forward:!0}:{u:c,v:l,room:r.id,edge:a,forward:!1})})}return n}function vy(t,e,n){let r=[];for(let i of t){let[o,s]=[e[i.u],e[i.v]],l=G(s,o),a=ge(l),c=it(l,1/a),u=e.map((p,h)=>({id:h,rel:G(p,o)})).filter(({id:p,rel:h})=>p!==i.u&&p!==i.v&&te(h,c)>n&&te(h,c)({t:te(h,c),id:p})).sort((p,h)=>p.t-h.t),d=[{t:0,id:i.u},...u,{t:a,id:i.v}];for(let p=0;p+1({room_id:t.room,edge:t.edge,t0:t.t0,t1:t.t1});function wy(t,e){let n=new Map(t.map(l=>[l.id,l])),r=new Map;for(let l of e){let a=`${l.room}:${l.edge}`;r.set(a,[...r.get(a)??[],l.t0].sort((c,u)=>c-u))}let i=l=>{let a=n.get(l.room)?.wall_heights?.[l.edge];return Array.isArray(a)?a[(r.get(`${l.room}:${l.edge}`)??[]).indexOf(l.t0)]??null:a},o=l=>{let a=n.get(l.room),[c,u]=[a?.wall_heights?.[l.edge],a?.wall_slopes?.[l.edge]];if(!a||typeof c!="number"||typeof u!="number"||c<=0||u<=0)return null;let[d,p]=[a.points[l.edge],a.points[(l.edge+1)%a.points.length]];return{from:c,to:u,length:Math.hypot(p[0]-d[0],p[1]-d[1])}},s=l=>{let a=o(l);if(!a||a.length<1e-9){let u=i(l);return typeof u=="number"&&u>0?[u,u]:[null,null]}let c=u=>a.from+(a.to-a.from)*u/a.length;return l.forward?[c(l.t0),c(l.t1)]:[c(l.t1),c(l.t0)]};return{heightsOf(l){let[a,c]=[1/0,1/0];for(let d of l){let[p,h]=s(d),[f,g]=d===l[0]?[p,h]:[h,p];f!==null&&(a=Math.min(a,f)),g!==null&&(c=Math.min(c,g))}let u=l.map(d=>n.get(d.room)?.ceiling);if(u.every(d=>typeof d=="number"&&d>0)){let d=Math.max(...u);a===1/0&&(a=d),c===1/0&&(c=d)}return{...a<1/0?{a}:{},...c<1/0?{b:c}:{}}},thicknessOf(l){let a=l.map(c=>{let u=n.get(c.room)?.wall_thickness?.[c.edge];return Array.isArray(u)?u[(r.get(`${c.room}:${c.edge}`)??[]).indexOf(c.t0)]:u}).filter(c=>typeof c=="number"&&c>0);return a.length?Math.max(...a):void 0},hasNoWall:l=>l.some(a=>i(a)===0)}}function Wd(t){let e=n=>Math.round(n*1e6)/1e6;return t.a===void 0||t.b===void 0?t.a!==void 0?{height:e(t.a)}:t.b!==void 0?{height:e(t.b)}:{}:Math.abs(t.a-t.b)<1e-6?{height:e(t.a)}:{height:e(t.a),heightEnd:e(t.b)}}function ky(t,e,n,r){let i=wy(e,t),o=new Map;for(let a of t){let c=a.up!==c&&p.u===c.v&&p.v===c.u&&p.room!==c.room);for(let p of a)p!==c&&p!==u&&p.room!==c.room&&r.push(`overlap:${c.room}:${p.room}`);let d=u?[c,u]:[c];if(i.hasNoWall(d)){u&&l.push([c.room,u.room]);continue}if(u){let p=i.thicknessOf(d)??n.interior;s.push({a:c.u,b:c.v,left:p/2,right:p/2,exterior:!1,roomLeft:c.room,roomRight:u.room,sources:d.map(Bd),...Wd(i.heightsOf(d))})}else s.push({a:c.u,b:c.v,left:0,right:i.thicknessOf(d)??n.exterior,exterior:!0,roomLeft:c.room,roomRight:null,sources:[Bd(c)],...Wd(i.heightsOf(d))})}return{drafts:s,open:l}}function xy(t,e){let n=o=>ot(G(e[o.b],e[o.a])),r=t.filter(o=>!o.exterior&&!o.free),i=new Map;for(let o of r){if(i.has(o))continue;let s=[o];i.set(o,s);for(let l=0;l1e-6||a.add(te(s,h)>0?"left":"right")}if(a.size!==1)continue;let c=[...a][0];for(let u of o){let d=u.left+u.right,p=te(n(u),s)>0,h=c==="left"===p;[u.left,u.right]=h?[0,d]:[d,0]}}}var $y=(t,e)=>{let n=o=>Math.round(o*100),[r,i]=t[0]Math.hypot(y.b[0]-y.a[0],y.b[1]-y.a[1])>.05),a=l.map(y=>[o.idOf(y.a),o.idOf(y.b)]),c=new Set;for(let y of t){let v=y.points;v.length<3||(y.wall_splits??[]).forEach((w,x)=>{if(!w||x>=v.length)return;let k=v[x],M=G(v[(x+1)%v.length],k),A=ge(M);for(let T of w)T>r&&T{let[w,x]=a[v];if(w===x)return;let k=[(y.a[0]+y.b[0])/2,(y.a[1]+y.b[1])/2],M=t.find(T=>T.points.length>=3&&C(k,T.points))?.id??null,A=(y.thickness??e.interior)/2;h.push({free:y.id,a:w,b:x,left:A,right:A,exterior:!1,roomLeft:M,roomRight:M,sources:[],height:typeof y.height=="number"&&y.height>0?y.height:void 0,...typeof y.height=="number"&&y.height>0&&typeof y.height_end=="number"&&y.height_end>0&&Math.abs(y.height_end-y.height)>1e-6?{heightEnd:y.height_end}:{}})});let f=Ld(h,o.points,c),g=Cd(f,o.points);return{walls:f.map((y,v)=>{let[w,x]=[o.points[y.a],o.points[y.b]],[k,M]=[g.get(`${v}:a`),g.get(`${v}:b`)],A=Nd([k.right,M.left,x,M.right,k.left,w],1e-6);return{id:$y(w,x),a:[w[0],w[1]],b:[x[0],x[1]],left:y.left,right:y.right,exterior:y.exterior,roomLeft:y.roomLeft,roomRight:y.roomRight,sources:y.sources,footprint:A,...y.free?{free:y.free}:{},...y.height!==void 0?{height:y.height}:{},...y.heightEnd!==void 0?{heightEnd:y.heightEnd}:{}}}),warnings:[...new Set(i)],open:p}}function Wn(t,e,n){let r=t.points[e];return ft(r,it(ot(G(t.points[(e+1)%t.points.length],r)),n))}function Ce(t,e,n){if(t.wall){let i=n.find(l=>l.id===t.wall);if(!i||Math.hypot(i.b[0]-i.a[0],i.b[1]-i.a[1])<.05)return null;let o=ot(G(i.b,i.a));return{room:{id:t.room_id,name:"",area_id:null,points:[i.a,i.b,ft(i.a,[-o[1],o[0]])]},edge:0}}let r=e.find(i=>i.id===t.room_id);return r&&t.edgete(G(e,t.a),ot(G(t.b,t.a)));function Wt(t,e,n){if(!e.wall)return Sy(t,n.room,n.edge,e.offset);let r=t.find(i=>i.free===e.wall);return r?{wall:r,s:Vd(r,Wn(n.room,0,e.offset))}:null}function Sy(t,e,n,r){for(let i of t)if(i.sources.some(s=>s.room_id===e.id&&s.edge===n&&r>=s.t0-1e-6&&r<=s.t1+1e-6))return{wall:i,s:Vd(i,Wn(e,n,r))};return null}function Kd(t,e){let n=t.points.map(h=>h[0]),r=t.points.map(h=>h[1]);if(t.points.length!==4||new Set(n.map(h=>h.toFixed(3))).size!==2||new Set(r.map(h=>h.toFixed(3))).size!==2)return null;let[i,o,s,l]=[Math.min(...n),Math.max(...n),Math.min(...r),Math.max(...r)],a=h=>Math.max(0,...e.filter(f=>(f.roomLeft===t.id||f.roomRight===t.id)&&h(f)).map(f=>f.roomLeft===t.id?f.left:f.right)),c=(h,f)=>Math.abs(h-f)<.001,u=(h,f,g)=>c(h.a[f],g)&&c(h.b[f],g),d=o-i-a(h=>u(h,0,i))-a(h=>u(h,0,o)),p=l-s-a(h=>u(h,1,s))-a(h=>u(h,1,l));return[Math.round(d*1e3)/1e3,Math.round(p*1e3)/1e3]}var jd=([t,e])=>{let n=Math.hypot(t,e)||1;return[t/n,e/n]};function My(t){return t.reduce((e,n,r)=>e+(n[0]*t[(r+1)%t.length][1]-t[(r+1)%t.length][0]*n[1]),0)/2}function Gd(t,e){let n=t.length;if(n<3||Math.abs(e)<1e-9)return t.map(([i,o])=>[i,o]);let r=My(t)>=0?1:-1;return t.map((i,o)=>{let s=t[(o+n-1)%n],l=t[(o+1)%n],[a,c]=jd([i[0]-s[0],i[1]-s[1]]),[u,d]=jd([l[0]-i[0],l[1]-i[1]]),p=[c*r,-a*r],h=[d*r,-u*r],f=[p[0]+h[0],p[1]+h[1]],g=Math.hypot(f[0],f[1]);if(g<1e-6)return[i[0]+p[0]*e,i[1]+p[1]*e];let b=(f[0]*p[0]+f[1]*p[1])/g,y=Math.min(4,1/Math.max(.25,b));return[i[0]+f[0]/g*e*y,i[1]+f[1]/g*e*y]})}function Vt(t){let e=t.map(r=>r[0]),n=t.map(r=>r[1]);return{x0:Math.min(...e),z0:Math.min(...n),x1:Math.max(...e),z1:Math.max(...n)}}function Ry(t){let e=([o,s])=>`${Math.round(o*1e3)}:${Math.round(s*1e3)}`,n=new Map;for(let o of t)for(let s of[o.a,o.b])n.set(e(s),[...n.get(e(s))??[],o]);let r=new Set,i=null;for(let o of t){if(r.has(o))continue;r.add(o);let s=[o.a,o.b],l=o.b;for(;;){let c=(n.get(e(l))??[]).find(u=>!r.has(u));if(!c||(r.add(c),l=e(c.a)===e(l)?c.b:c.a,e(l)===e(s[0])))break;s.push(l)}s.length>=3&&e(l)===e(s[0])&&(!i||Math.abs(ke(s))>Math.abs(ke(i)))&&(i=s)}return i}function ha(t,e,n,r){let i=fe(t,{exterior:n,interior:r},e).walls.filter(l=>l.exterior&&!l.free),o=i.length?Ry(i.map(l=>({a:l.a,b:l.b}))):null;if(!o)return null;let s=o.filter((l,a)=>{let c=o[(a+o.length-1)%o.length],u=o[(a+1)%o.length];return Math.abs((l[0]-c[0])*(u[1]-l[1])-(l[1]-c[1])*(u[0]-l[0]))>1e-6});return s.length>=3?Gd(s,n):null}function cn(t,e){let n=xe(t),r=Le(t),i=n.w,[o,s]=[Math.max(0,e.a),Math.max(0,e.b)],l=n.u0-Math.max(0,e.u0),a=n.u1+Math.max(0,e.u1),c=(y,v)=>[y,v,r.y(v)],u=c(l,-o),d=c(a,-o),p=c(a,i+s),h=c(l,i+s),[f,g]=[st(t.pitch_a),st(t.pitch_b)],b=y=>[y,r.vr,r.rh];if(t.ends&&(t.shape==="gable"||t.shape==="hip"||t.shape==="halfhip")){let y=(n.u1-n.u0)/2,v=Math.min(y,Math.min(r.vr,i-r.vr)||i/2),w=Math.min(r.y(0),r.y(i)),x=w+(r.rh-w)*Math.min(.9,Math.max(.2,t.halfhip??.55)),k=f>1e-6?Math.min(r.vr,(x-t.eave_a)/f):r.vr,M=g>1e-6?Math.max(r.vr,i-(x-t.eave_b)/g):r.vr,A=Math.min(y-.1,(r.rh-x)/Math.max(.2,f)),T=[[0,r.y(0)],[r.vr,r.rh],[i,r.y(i)]],F=[[0,r.y(0)],[k,x],[M,x],[i,r.y(i)]],H=(j,Yt,Ti)=>{if(j==="hip")return{upA:[],upB:[],ridge:b(Yt===l?n.u0+v*Ti:n.u1-v*Ti),profile:null};if(j==="halfhip"){let ob=b(Yt===l?n.u0+A:n.u1-A);return{upA:[[Yt,k,x]],upB:[[Yt,M,x]],ridge:ob,profile:F}}return{upA:[],upB:[],ridge:b(Yt),profile:T}},P=H(t.ends[0],l,1),N=H(t.ends[1],a,1),W=[[u,d,...N.upA,N.ridge,P.ridge,...[...P.upA].reverse()],[P.ridge,N.ridge,...[...N.upB].reverse(),p,h,...P.upB]],q=[[P.ridge,N.ridge]];for(let[j,Yt,Ti]of[[P,u,h],[N,d,p]])j.profile===null?(W.push(j===P?[h,u,j.ridge]:[d,p,j.ridge]),q.push([Yt,j.ridge],[Ti,j.ridge])):j.upA.length&&(W.push(j===P?[j.upB[0],j.upA[0],j.ridge]:[j.upA[0],j.upB[0],j.ridge]),q.push([j.upA[0],j.ridge],[j.upB[0],j.ridge]));let we=j=>j.profile===null?[]:j.upA.length?[j.upA[0],j.upB[0]]:[j.ridge],At=[u,d,...we(N),p,h,...[...we(P)].reverse()];return{faces:W,rim:At,ridges:q,gable:T,endProfiles:[P.profile,N.profile]}}switch(t.shape){case"pent":return{faces:[[u,d,p,h]],rim:[u,d,p,h],ridges:[[p,h]],gable:[[0,r.y(0)],[i,r.y(i)]]};case"hip":case"pyramid":{let y=(n.u1-n.u0)/2,v=t.shape==="pyramid"?y:Math.min(y,Math.min(r.vr,i-r.vr)||i/2),w=b(n.u0+v),x=b(n.u1-v);return t.shape==="pyramid"?{faces:[[u,d,w],[d,p,w],[p,h,w],[h,u,w]],rim:[u,d,p,h],ridges:[[u,w],[h,w],[d,w],[p,w]],gable:null}:{faces:[[u,d,x,w],[w,x,p,h],[h,u,w],[d,p,x]],rim:[u,d,p,h],ridges:[[w,x],[u,w],[h,w],[d,x],[p,x]],gable:null}}case"halfhip":{let y=Math.min(r.y(0),r.y(i)),v=y+(r.rh-y)*Math.min(.9,Math.max(.2,t.halfhip??.55)),w=f>1e-6?Math.min(r.vr,(v-t.eave_a)/f):r.vr,x=g>1e-6?Math.max(r.vr,i-(v-t.eave_b)/g):r.vr,k=Math.min((n.u1-n.u0)/2-.1,(r.rh-v)/Math.max(.2,f)),M=b(n.u0+k),A=b(n.u1-k),T=[l,w,v],F=[l,x,v],H=[a,w,v],P=[a,x,v];return{faces:[[u,d,H,A,M,T],[M,A,P,p,h,F],[F,T,M],[H,P,A]],rim:[u,d,H,P,p,h,F,T],ridges:[[M,A],[T,M],[F,M],[H,A],[P,A]],gable:[[0,r.y(0)],[w,v],[x,v],[i,r.y(i)]]}}case"mansard":{let y=Cr(i,t.eave_a,t.eave_b,f,g),v=[l,y.vla,y.yla],w=[a,y.vla,y.yla],x=[l,i-y.vlb,y.ylb],k=[a,i-y.vlb,y.ylb],M=[l,y.vr,y.rh],A=[a,y.vr,y.rh];return{faces:[[u,d,w,v],[v,w,A,M],[M,A,k,x],[x,k,p,h]],rim:[u,d,w,A,k,p,h,x,M,v],ridges:[[M,A],[v,w],[x,k]],gable:[[0,r.y(0)],[y.vla,y.yla],[y.vr,y.rh],[i-y.vlb,y.ylb],[i,r.y(i)]]}}default:{let y=b(l),v=b(a);return{faces:[[u,d,v,y],[y,v,p,h]],rim:[u,d,v,p,h,y],ridges:[[y,v]],gable:[[0,r.y(0)],[r.vr,r.rh],[i,r.y(i)]]}}}}function Nr(t,e,n){let r=null;for(let i of t.faces){if(!C([e,n],i.map(([p,h])=>[p,h])))continue;let[o,s]=i,l=i.slice(2).find(p=>Math.abs((s[0]-o[0])*(p[1]-o[1])-(s[1]-o[1])*(p[0]-o[0]))>1e-9);if(!l)continue;let a=[s[0]-o[0],s[2]-o[2],s[1]-o[1]],c=[l[0]-o[0],l[2]-o[2],l[1]-o[1]],u=[a[1]*c[2]-a[2]*c[1],a[2]*c[0]-a[0]*c[2],a[0]*c[1]-a[1]*c[0]];if(Math.abs(u[1])<1e-9)continue;let d=o[2]-(u[0]*(e-o[0])+u[2]*(n-o[1]))/u[1];r=r===null?d:Math.min(r,d)}return r}function Br(t,e,n){let r=xe(e),i=t.floors.flatMap(d=>d.rooms.filter(p=>p.points.length>=3&&d.elevation+d.height>e.base+.05)),o=d=>d.some(p=>i.some(h=>C(p,h.points))),s=.35,l=[.15,.5,.85].map(d=>r.u0+(r.u1-r.u0)*d),a=[.15,.5,.85].map(d=>r.w*d),c=d=>d?0:n,u=(d,p)=>{let h=e.overhang_sides?.[d];return typeof h=="number"&&Number.isFinite(h)?Math.min(2,Math.max(0,h)):p};return{a:u("a",c(o(l.map(d=>r.at(d,-s))))),b:u("b",c(o(l.map(d=>r.at(d,r.w+s))))),u0:u("u0",c(o(a.map(d=>r.at(r.u0-s,d))))),u1:u("u1",c(o(a.map(d=>r.at(r.u1+s,d)))))}}var mo=t=>Math.abs((t.x1-t.x0)*(t.z1-t.z0)),Ud=t=>t.shape==="flat"||t.shape==="parapet",un=t=>Math.round(t*100)/100;function go(t,e){let[n,r]=[(e.x0+e.x1)/2,(e.z0+e.z1)/2];return t.filter(o=>{if(o===e||o.dormer||o.open||Ud(o)||mo(o)=s.x0&&n<=s.x1&&r>=s.z0&&r<=s.z1}).reduce((o,s)=>o===null||mo(s){let[o,s]=e.at(i,e.w/2),[l,a]=Lr(t,o,s);return Nr(n,l,a)??r.y(a)}}function fa(t,e){if(Ud(e))return e;let n=xe(e),r=Le(e).rh,i=Ay(t,n),o=i(n.u0)<=i(n.u1),[s,l]=o?[n.u0,n.u1]:[n.u1,n.u0],a=o?1:-1,c=l;for(let p=.5;p=r-.02){c=s+a*p;break}if(Math.abs(c-l)<.05)return e;let u={...e},d=l===n.u1;return e.axis==="x"?u[d?"x1":"x0"]=c:u[d?"z1":"z0"]=c,u}var ma=.14,Zd=t=>t.shape==="flat"||t.shape==="parapet";function ga(t,e){return!t.open&&Math.min(t.base,t.eave_a,t.eave_b)a+i||pu+i||s.points&&s.points.length>=3&&!C([e,n],s.points))continue;let[h,f]=Lr(s,e,n),g=Math.max(0,s.overhang??r),b=Zd(s)?null:Nr(cn(s,{u0:g,u1:g,a:g,b:g}),h,f);o.push((b??Le(s).y(f))-ma)}return o.length?Math.max(...o):null}function _a(t,e,n){let r=[],i=e+n+ma;for(let o of t.settings.roof.sections??[]){if(o.open||Zd(o)||o.shape==="mansard")continue;let s=xe(o),l=Le(o),[a,c]=[st(o.pitch_a),st(o.pitch_b)],u=[];a>1e-6&&u.push((i-o.eave_a)/a),o.shape==="gable"&&c>1e-6&&u.push(s.w-(i-o.eave_b)/c);for(let d of u)d<=.01||d>=s.w-.01||o.shape==="gable"&&Math.abs(l.y(d)-i)>1e-6||r.push([s.at(s.u0,d),s.at(s.u1,d)])}return r}function ba(t,e,n,r,i){let o=[];for(let l of[.2,.5,.8])for(let a of[.2,.5,.8])o.push([e+(r-e)*l,n+(i-n)*a]);let s=t.floors.filter(l=>l.rooms.some(a=>a.points.length>=3&&o.some(c=>C(c,a.points)))).map(l=>l.elevation+l.height);return s.length?Math.max(...s):null}function ya(t,e){let n=t.floors.filter(a=>a.rooms.length>0).sort((a,c)=>a.elevation-c.elevation),r=n.filter(a=>a.elevationu.rooms.some(d=>d.points.length>=3&&a.some(p=>C(p,d.points))));if(c)return c}return r.at(-1)??n[0]}var kt=t=>Math.round(t*1e3)/1e3;function va(t,e=n=>`roof_${n+1}`){let n=t.settings.roof?.pitch??35,r=t.settings.wall_exterior,i=t.floors.filter(a=>a.rooms.some(c=>c.points.length>=3)).sort((a,c)=>c.elevation-a.elevation),o=[],s=[],l=(a,c)=>a.some(u=>C(c,u.points));for(let a of i){let c=a.rooms.filter(b=>b.points.length>=3),u=[...new Set(c.flatMap(b=>b.points.map(y=>kt(y[0]))))].sort((b,y)=>b-y),d=[...new Set(c.flatMap(b=>b.points.map(y=>kt(y[1]))))].sort((b,y)=>b-y),p=d.slice(0,-1).map((b,y)=>u.slice(0,-1).map((v,w)=>{let x=[(u[w]+u[w+1])/2,(d[y]+d[y+1])/2];return l(c,x)&&!l(s,x)})),h=p.map(b=>b.map(()=>!1)),f=(b,y)=>p[y][b]&&!h[y][b],g=a.elevation+a.height;for(let b=0;bf(y+F,w+1)).every(Boolean);)w++;for(let T=b;T<=w;T++)for(let F=y;F<=v;F++)h[T][F]=!0;let[x,k]=[u[y]-r,u[v+1]+r],[M,A]=[d[b]-r,d[w+1]+r];Math.min(k-x,A-M)<.8||o.push({id:e(o.length),x0:kt(x),z0:kt(M),x1:kt(k),z1:kt(A),shape:"gable",axis:k-x>=A-M?"x":"z",eave_a:kt(g),eave_b:kt(g),pitch_a:n,pitch_b:n,base:kt(g),overhang:null})}s.push(...c)}return o}var Ee=Math.PI/180,Ue=(t,e)=>[t[0]-e[0],t[1]-e[1],t[2]-e[2]],dn=(t,e)=>t[0]*e[0]+t[1]*e[1]+t[2]*e[2],Vn=t=>Math.hypot(t[0],t[1],t[2]),hn=t=>{let e=Vn(t)||1;return[t[0]/e,t[1]/e,t[2]/e]},qd=(t,e)=>[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]],Ze=t=>Math.round(t*100)/100,Vr=([t,e],n)=>(Math.atan2(t,-e)/Ee-n+720)%360;var Xd=.25;function Jd(t,e,n,r,i,o,s){let l=i-n>=o-r,a=l?i-n:o-r;return{key:`${t}:top`,section:e,side:"top",flat:!0,o:[n,s,r],eu:l?[1,0,0]:[0,0,1],es:l?[0,0,1]:[1,0,0],n:[0,1,0],lu:a,ls:l?o-r:i-n,pitch:0,span:()=>[0,a],facing:l?[0,1]:[1,0]}}function Qd(t,e){let n=hn(qd(t,e));return n[1]<0?[-n[0],-n[1],-n[2]]:n}var eh=t=>{let e=hn([-t[0],0,-t[2]]);return[e[0],e[2]]};function xt(t,e,n,r,i,o,s,l){let a=hn(Ue(i,r)),c=hn(Ue(o,r));return{key:t,section:e,side:n,flat:!1,o:r,eu:a,es:c,n:Qd(a,c),lu:Vn(Ue(i,r)),ls:Vn(Ue(o,r)),pitch:s,span:l,facing:eh(c)}}function Yd(t,e,n,r,i,o){let s=Vn(Ue(i,r));if(s<.3)return null;let l=hn(Ue(i,r)),a=Ue(o,r),c=a[0]*l[0]+a[1]*l[1]+a[2]*l[2],u=[a[0]-l[0]*c,a[1]-l[1]*c,a[2]-l[2]*c],d=Vn(u);if(d<.3)return null;let p=hn(u),h=f=>{let g=Math.min(1,Math.max(0,f/d));return[c*g,s-(s-c)*g]};return{key:t,section:e,side:n,flat:!1,o:r,eu:l,es:p,n:Qd(l,p),lu:s,ls:d,pitch:Math.atan2(p[1],Math.hypot(p[0],p[2]))/Ee,span:h,facing:eh(p)}}function Fy(t,e){let n=xe(t),r=Le(t),i=(v,w,x)=>{let[k,M]=n.at(v,w);return[k,x,M]},[o,s]=[Math.max(0,e.a),Math.max(0,e.b)],l=n.u0-Math.max(0,e.u0),a=n.u1+Math.max(0,e.u1),c=a-l,u=r.y(-o),d=r.y(n.w+s);if(t.shape==="flat"||t.shape==="parapet"){let[v,w]=[n.at(l,-o),n.at(a,n.w+s)];return[Jd(t.id,t.id,Math.min(v[0],w[0]),Math.min(v[1],w[1]),Math.max(v[0],w[0]),Math.max(v[1],w[1]),t.eave_a+Xd)]}if(t.shape==="pent")return[xt(`${t.id}:a`,t.id,"a",i(l,-o,u),i(a,-o,u),i(l,n.w+s,d),t.pitch_a,()=>[0,c])];if(t.shape==="mansard")return Ty(t,n,l,a,o,s);let p=t.shape==="hip"||t.shape==="pyramid",h=(n.u1-n.u0)/2,f=t.shape==="pyramid"?h:p?Math.min(h,Math.min(r.vr,n.w-r.vr)||n.w/2):0,g=p?n.u0+f-l:0,b=p?a-(n.u1-f):0,y=[];if(r.vr>.3){let v=Math.hypot(r.vr+o,r.rh-u);y.push(xt(`${t.id}:a`,t.id,"a",i(l,-o,u),i(a,-o,u),i(l,r.vr,r.rh),t.pitch_a,w=>[g*(w/v),c-b*(w/v)]))}if(n.w-r.vr>.3){let v=Math.hypot(n.w+s-r.vr,r.rh-d);y.push(xt(`${t.id}:b`,t.id,"b",i(a,n.w+s,d),i(l,n.w+s,d),i(a,r.vr,r.rh),t.pitch_b,w=>[b*(w/v),c-g*(w/v)]))}if(p){let v=Yd(`${t.id}:c`,t.id,"c",i(l,n.w+s,d),i(l,-o,u),i(n.u0+f,r.vr,r.rh)),w=Yd(`${t.id}:d`,t.id,"d",i(a,-o,u),i(a,n.w+s,d),i(n.u1-f,r.vr,r.rh));y.push(...[v,w].filter(x=>x!==null))}return y}function Ty(t,e,n,r,i,o){let s=Cr(e.w,t.eave_a,t.eave_b,st(t.pitch_a),st(t.pitch_b)),l=(f,g)=>{let[b,y]=e.at(f,g);return[b,s.y(g),y]},a=r-n,c=()=>[0,a],u=(f,g)=>Math.atan2(f,g)/Ee,d=[],[p,h]=[e.w+o,e.w-s.vlb];return s.vla+i>.3&&d.push(xt(`${t.id}:a`,t.id,"a",l(n,-i),l(r,-i),l(n,s.vla),t.pitch_a,c)),s.vr-s.vla>.3&&d.push(xt(`${t.id}:au`,t.id,"a",l(n,s.vla),l(r,s.vla),l(n,s.vr),u(s.rh-s.yla,s.vr-s.vla),c)),s.vlb+o>.3&&d.push(xt(`${t.id}:b`,t.id,"b",l(r,p),l(n,p),l(r,h),t.pitch_b,c)),h-s.vr>.3&&d.push(xt(`${t.id}:bu`,t.id,"b",l(r,h),l(n,h),l(r,s.vr),u(s.rh-s.ylb,h-s.vr),c)),d}function wa(t){return t.floors.filter(n=>n.rooms.some(r=>r.points.length>=3)).sort((n,r)=>r.elevation-n.elevation)[0]??null}function Z(t){let e=t.settings.roof;if(!e||e.type==="none")return[];if(e.type==="custom")return(e.sections??[]).flatMap(w=>Fy(w,Br(t,w,w.overhang??e.overhang)));let n=wa(t);if(!n)return[];let r=n.rooms.flatMap(w=>w.points.map(x=>x[0])),i=n.rooms.flatMap(w=>w.points.map(x=>x[1])),o=t.settings.wall_exterior+e.overhang,[s,l]=[Math.min(...r)-o,Math.max(...r)+o],[a,c]=[Math.min(...i)-o,Math.max(...i)+o],u=n.elevation+n.height;if(e.type==="flat")return[Jd("main",null,s,a,l,c,u+Xd)];let d=l-s>=c-a,p=e.ridge==="short"?!d:d,h=(p?c-a:l-s)/2,f=h*Math.tan(e.pitch*Ee),g=(w,x,k)=>p?[w,u+k,(a+c)/2+x]:[(s+l)/2+x,u+k,w],[b,y]=p?[s,l]:[a,c],v=()=>[0,y-b];return[xt("main:a",null,"a",g(b,-h,0),g(y,-h,0),g(b,0,f),e.pitch,v),xt("main:b",null,"b",g(b,h,0),g(y,h,0),g(b,0,f),e.pitch,v)]}function qe(t,e){let n=[];for(let r of t.floors.filter(i=>!e||i.id===e)){let{walls:i}=fe(r.rooms,{exterior:t.settings.wall_exterior,interior:t.settings.wall_interior},r.walls??[]);for(let o of i){if(!o.exterior&&!o.free)continue;let[s,l]=[o.b[0]-o.a[0],o.b[1]-o.a[1]],a=Math.hypot(s,l);if(a<1.2)continue;let[c,u]=[l/a,-s/a],d=Math.min(r.height,o.height??r.height,o.heightEnd??1/0),p=(h,f,g,b)=>n.push({key:h,section:null,side:"top",flat:!1,o:f,eu:g,es:[0,1,0],n:b,lu:a,ls:d,pitch:90,span:()=>[0,a],facing:[b[0],b[2]],wall:{floorId:r.id}});p(`wall:${r.id}:${o.id}`,[o.a[0]+c*o.right,r.elevation,o.a[1]+u*o.right],[s/a,0,l/a],[c,0,u]),o.free&&p(`wall:${r.id}:${o.id}:back`,[o.b[0]-c*o.left,r.elevation,o.b[1]-u*o.left],[-s/a,0,-l/a],[-c,0,-u])}}return n}var Ne="ground";function _o(t){let e=t.floors.filter(n=>n.rooms.some(r=>r.points.length>=3)).sort((n,r)=>n.elevation-r.elevation);return e.find(n=>n.elevation>-.5)??e[0]??t.floors[0]??null}function bo(t,e){let n=(e.rotation??0)*Ee,r=[Math.cos(n),0,Math.sin(n)],i=[-Math.sin(n),0,Math.cos(n)],o=_o(t),s=r[0]*e.u+i[0]*e.v,l=r[2]*e.u+i[2]*e.v,a=o?o.elevation+(e.base!=null?e.base:fu(o,s,l)):e.base??0;return{key:Ne,section:null,side:"top",flat:!0,o:[0,a,0],eu:r,es:i,n:[0,1,0],lu:1e4,ls:1e4,pitch:0,span:()=>[-1e4,1e4],facing:[i[0],i[2]],unbounded:!0}}function $e(t,e,n=Z(t)){return e.face===Ne?bo(t,e):e.face.startsWith("wall:")?qe(t,e.face.split(":")[1]).find(r=>r.key===e.face)??null:n.find(r=>r.key===e.face)??null}var yo=1.13,jr=1.72,Ye=.025,at=.07;function pn(t){let e=t.module_w||yo,n=t.module_h||jr;return t.portrait===!1?[n,e]:[e,n]}function Gr(t){return t.layout?.length?t.layout.map(e=>Math.max(0,Math.min(60,Math.round(e)))):Array.from({length:Math.max(1,t.rows)},()=>Math.max(1,t.cols))}function ka(t,e){return t.flat?Math.min(45,Math.max(0,e.tilt??15))*Ee:t.wall?Math.min(90,Math.max(0,e.tilt??0))*Ee:Math.min(45,Math.max(0,e.tilt??0))*Ee}function Ur(t,e){let[,n]=pn(e),r=ka(t,e);return t.wall?n*Math.cos(r)+Ye:!t.flat&&r<.001?n+Ye:t.flat&&e.rack==="ew"?n*Math.cos(r)+.08:n*Math.cos(r)+Math.max(.3,2*n*Math.sin(r))}function Kn(t,e){let[n,r]=pn(e),i=Gr(e),o=Math.max(1,...i);return[o*n+(o-1)*Ye,(i.length-1)*Ur(t,e)+r*Math.cos(ka(t,e))]}var zy=t=>t.flat&&!t.unbounded&&!t.wall;function th(t,e){if(!zy(t)||!e.rotation)return null;let n=e.rotation*Ee,[r,i]=Kn(t,e);return{cos:Math.cos(n),sin:Math.sin(n),u:e.u+r/2,s:e.v+i/2}}function Xe(t,e,n=!1){let[r,i]=pn(e),o=ka(t,e),s=i*Math.cos(o),l=Ur(t,e),a=Gr(e),c=Math.max(1,...a),u=new Set(e.skip??[]),d=th(t,e),p=(b,y)=>d?[d.u+(b-d.u)*d.cos-(y-d.s)*d.sin,d.s+(b-d.u)*d.sin+(y-d.s)*d.cos]:[b,y],h=(b,y,v)=>{let[w,x]=p(b,y);return[0,1,2].map(k=>t.o[k]+t.eu[k]*w+t.es[k]*x+t.n[k]*v)},f=(b,y)=>{let[v,w]=p(b,y);if(t.unbounded)return!0;if(w<-1e-6||w>t.ls+1e-6)return!1;let[x,k]=t.span(w);return v>=x-1e-6&&v<=k+1e-6},g=[];return a.forEach((b,y)=>{let v=e.align==="right"?c-b:e.align==="center"?(c-b)/2:0;for(let w=0;w.001?s:i);if([[M,T],[A,T],[A,F],[M,F]].every(([H,P])=>f(H,P)))if(t.wall&&o>.001){let H=at+i*Math.sin(o),[P,N]=e.flip?[H,at]:[at,H],W=[h(M,T,P),h(A,T,P),h(A,F,N),h(M,F,N)],q=e.flip?T:F;g.push({corners:W,posts:[M+.05,A-.05].map(we=>[h(we,q,0),h(we,q,H)]),cell:x,skipped:k})}else if(!t.flat&&o>.001){let H=at+i*Math.sin(o),P=[h(M,T,at),h(A,T,at),h(A,F,H),h(M,F,H)];g.push({corners:P,posts:[M+.05,A-.05].map(N=>[h(N,F,0),h(N,F,H)]),cell:x,skipped:k})}else if(!t.flat)g.push({corners:[h(M,T,at),h(A,T,at),h(A,F,at),h(M,F,at)],posts:[],cell:x,skipped:k});else{let P=.15+i*Math.sin(o),N=e.rack==="ew"&&y%2===1?!e.flip:!!e.flip,[W,q]=N?[F,T]:[T,F],we=[h(M,W,.15),h(A,W,.15),h(A,q,P),h(M,q,P)],At=[M+.05,A-.05].flatMap(j=>[[h(j,W,0),h(j,W,.15)],[h(j,q,0),h(j,q,P)]]);g.push({corners:we,posts:At,cell:x,skipped:k})}}}),g}function mt(t,e){if(t.unbounded)return{u:e.u,v:e.v};let[n,r]=Kn(t,e),i=th(t,e);if(i){let[s,l]=[(n*Math.abs(i.cos)+r*Math.abs(i.sin))/2,(n*Math.abs(i.sin)+r*Math.abs(i.cos))/2],a=(d,p,h)=>Math.floor(Math.max(p,Math.min(d,h-p))*100+1e-6)/100,[c,u]=[e.u+n/2,e.v+r/2];return{u:Math.round((a(c,s,t.lu)-n/2)*100)/100,v:Math.round((a(u,l,t.ls)-r/2)*100)/100}}let o=s=>Math.floor(s*100+1e-6)/100;return{u:o(Math.min(Math.max(0,e.u),Math.max(0,t.lu-n))),v:o(Math.min(Math.max(0,e.v),Math.max(0,t.ls-r)))}}function Zr(t,e){let[n,r]=Kn(t,e),[i,o]=[e.u+n/2,e.v+r/2];return[t.o[0]+t.eu[0]*i+t.es[0]*o,t.o[2]+t.eu[2]*i+t.es[2]*o]}var vo=.78,qr=1.18,fn=t=>({id:t.id,face:t.face,u:t.u,v:t.v,rows:1,cols:1,portrait:!0,module_w:t.w||vo,module_h:t.h||qr});function xa(t,e){let n=Xe(t,fn(e))[0];if(!n)return null;let r=i=>[i[0]-t.n[0]*.05,i[1]-t.n[1]*.05,i[2]-t.n[2]*.05];return n.corners.map(r)}var Kr={brick:{w:.5,d:.5,h:1},round:{w:.4,d:.4,h:1},wide:{w:1,d:.5,h:1},steel:{w:.2,d:.2,h:1.2}};function mn(t){let e=t.shape??"brick",n=Kr[e]??Kr.brick;return{shape:e,w:t.w||n.w,d:t.d||n.d,h:t.h||n.h}}function $t(t,e){let{w:n,d:r}=mn(t),i=e&&!e.flat?Math.cos(e.pitch*Ee):1;return{id:t.id,face:t.face,u:t.u,v:t.v,rows:1,cols:1,portrait:!0,module_w:n,module_h:r/Math.max(.2,i),tilt:0}}function $a(t,e){let n=$t(e,t),[r,i]=[n.module_w,n.module_h],o=(u,d)=>[t.o[0]+t.eu[0]*u+t.es[0]*d,t.o[1]+t.eu[1]*u+t.es[1]*d,t.o[2]+t.eu[2]*u+t.es[2]*d],[s,l]=[o(e.u+r/2,e.v),o(e.u+r/2,e.v+i)],a=o(e.u+r/2,e.v+i/2),c=u=>{let d=Math.hypot(u[0],u[2])||1;return[u[0]/d,u[2]/d]};return{center:[a[0],a[2]],along:c(t.eu),across:c(t.es),low:Math.min(s[1],l[1]),high:Math.max(s[1],l[1])}}function Sa(t,e){let[n]=pn(e);return Ze((t.lu-(e.cols*n+(e.cols-1)*Ye))/2)}var Yr=.4;function jn(t,e){let n={id:e,face:t.key,u:0,v:0,rows:1,cols:1,portrait:!0,tilt:t.flat?15:null,flip:!1,entity:null,look:"black"},[r]=pn(n),[i,o]=t.span(t.ls/2);for(n.cols=Math.max(1,Math.floor((o-i-2*Yr+Ye)/(r+Ye))),n.rows=Math.max(1,Math.min(4,Math.floor((t.ls-2*Yr)/Ur(t,n))));n.cols>1&&Xe(t,{...n,u:Sa(t,n),v:Yr}).lengthl.lu*(1.3+Math.cos((Vr(l.facing,r)-180)*Math.PI/180)),o=qe(t,n).sort((l,a)=>i(a)-i(l))[0];if(!o)return null;let s={...jn(o,e),portrait:!1,rows:1};return s.cols=Math.max(1,Math.floor((o.lu-.8+Ye)/(jr+Ye))),s.u=Ze((o.lu-(s.cols*jr+(s.cols-1)*Ye))/2),s.v=Ze(Math.max(0,o.ls-yo-.3)),s}function Xr(t,e){let n=t.floors.flatMap(o=>o.rooms.flatMap(s=>s.points)),r=n.length?Math.max(...n.map(o=>o[0]))+3:0,i=n.length?Math.min(...n.map(o=>o[1])):0;return{id:e,face:Ne,u:Ze(r),v:Ze(i),rows:2,cols:4,portrait:!0,tilt:25,flip:!0,rotation:(t.settings.north??0)||0,look:"black",entity:null}}function Jr(t,e,n){let r=bo(t,e),[i,o]=Kn(r,e),[s,l]=[e.u+i/2,e.v+o/2],a=[r.eu[0]*s+r.es[0]*l,r.eu[2]*s+r.es[2]*l],c=n*Ee,u=a[0]*Math.cos(c)+a[1]*Math.sin(c)-i/2,d=a[0]*-Math.sin(c)+a[1]*Math.cos(c)-o/2;return{u:Ze(u),v:Ze(d),rotation:(Math.round(n)%360+360)%360}}function Qr(t,e){let[n,r]=t.span(t.ls/2);return{id:e,face:t.key,u:Ze((n+r-vo)/2),v:Ze(Math.max(0,Math.min(t.ls-qr,t.ls*.45-qr/2))),w:null,h:null,cover:null,contact:null,tilt:null}}function ei(t,e){let n=Kr.brick,[r,i]=t.span(t.ls*.8),o=$t({id:e,face:t.key,u:0,v:0},t).module_h;return{id:e,face:t.key,u:Ze((r+i-n.w)/2),v:Ze(Math.max(0,Math.min(t.ls-o,t.ls*.8-o/2))),shape:"brick",w:null,d:null,h:null}}function Gn(t,e){let[n,r]=[e[0]-t.o[0],e[1]-t.o[2]],[i,o,s,l]=[t.eu[0],t.eu[2],t.es[0],t.es[2]],a=i*l-o*s;if(Math.abs(a)<1e-9)return null;let c=(n*l-r*s)/a,u=(i*r-o*n)/a;if(u<0||u>t.ls)return null;let[d,p]=t.span(u);return c>=d&&c<=p?{u:c,s:u}:null}function Ra(t,e){let n=null;for(let r of t){if(r.wall){let[s,l]=[e[0]-r.o[0],e[1]-r.o[2]],a=s*r.eu[0]+l*r.eu[2],c=s*r.n[0]+l*r.n[2],u=a>=0&&a<=r.lu;if(u&&c>=-.05&&c<=.35)return{face:r,u:a,s:Number.NaN};u&&c>.35&&c<=.8&&!n&&(n={face:r,u:a,s:Number.NaN,y:-1/0});continue}let i=Gn(r,e);if(!i)continue;let o=r.o[1]+r.es[1]*i.s;(!n||o>n.y)&&(n={face:r,...i,y:o})}return n&&{face:n.face,u:n.u,s:n.s}}function ko(t,e,n){let r=dn(n,t.n);if(Math.abs(r)<1e-6)return null;let i=dn(Ue(t.o,e),t.n)/r;if(i<=0)return null;let o=Ue([e[0]+n[0]*i,e[1]+n[1]*i,e[2]+n[2]*i],t.o);return{t:i,u:dn(o,t.eu),s:dn(o,t.es)}}function Ea(t,e,n){if(t.unbounded)return!0;if(n<0||n>t.ls)return!1;let[r,i]=t.span(n);return e>=r&&e<=i}function Aa(t,e,n,r){return Xe(t,e).some(o=>{let s=o.corners.map(c=>{let u=Ue(c,t.o);return[dn(u,t.eu),dn(u,t.es)]}),l=s.map(c=>c[0]),a=s.map(c=>c[1]);return n>=Math.min(...l)-.05&&n<=Math.max(...l)+.05&&r>=Math.min(...a)-.05&&r<=Math.max(...a)+.05})}var Py=["n","ne","e","se","s","sw","w","nw"],Fa=(t,e)=>Py[Math.round(Vr(t.facing,e)/45)%8];function ti(t,e){let n=r=>{if(r.flat)return r.lu*r.ls*.8;let i=Math.cos((Vr(r.facing,e)-180)*Math.PI/180);return r.lu*r.ls*(1.2+i)};return[...t].sort((r,i)=>n(i)-n(r))[0]??null}var oh=["kitchen_row","kitchen_l","bath","bedroom","living","dining","office","kids","hall"],nh={kitchen_row:{rows:[["back","start",["fridge","kitchen_tall",["kitchen",[.9,.62,.92]],"sink","dishwasher","stove",["kitchen",[.6,.62,.92]]]],["back","start",[["kitchen_wall",[1.2,.35,.7]]]]],spots:[[["table",[1.2,.8,.75]],.5,.72,0],["lamp_pendant",.5,.72,0],["lamp_ceiling",.5,.3,0]]},kitchen_l:{rows:[["back","start",["fridge",["kitchen",[.9,.62,.92]],"sink","dishwasher","stove"]],["right","start",[["kitchen",[.9,.62,.92]],["kitchen",[.6,.62,.92]],"kitchen_tall"]],["back","start",[["kitchen_wall",[1.2,.35,.7]]]]],spots:[["table",.4,.68,0],["bar_stool",.72,.86,180],["lamp_ceiling",.5,.35,0]]},bath:{rows:[["back","center",["washbasin"]],["back","end",["wc"]],["front","start",["bathtub"]],["left","start",["washer"]]],spots:[["lamp_downlight",.5,.5,0]]},bedroom:{rows:[["back","center",["nightstand","bed","nightstand"]],["left","center",[["wardrobe",[2,.6,2.1]]]],["front","end",["dresser"]]],spots:[["lamp_ceiling",.5,.55,0]]},living:{rows:[["back","center",["tv_board"]],["right","start",["shelf"]]],spots:[["sofa",.5,.72,180],["coffee_table",.5,.52,0],[["rug",[2.2,1.6,.01]],.5,.55,0],["armchair",.14,.5,270],["lamp_floor",.86,.8,0],["plant",.9,.12,0],["lamp_ceiling",.5,.45,0]]},dining:{rows:[["back","center",["sideboard"]]],spots:[["table",.5,.55,0],["chair",.4,.35,0],["chair",.6,.35,0],["chair",.4,.75,180],["chair",.6,.75,180],["lamp_pendant",.5,.55,0]]},office:{rows:[["back","center",["desk"]],["left","center",["shelf","shelf"]]],spots:[["office_chair",.5,.38,180],["lamp_ceiling",.5,.55,0]]},kids:{rows:[["left","start",[["bed",[.9,2,.8]]]],["back","end",[["desk",[1.2,.6,.75]]]],["right","end",["shelf"]]],spots:[[["rug",[1.6,1.2,.01]],.55,.6,0],["lamp_ceiling",.5,.5,0]]},hall:{rows:[["left","start",["coat_rack"]]],spots:[["lamp_downlight",.5,.3,0],["lamp_downlight",.5,.7,0]]}},rh=t=>typeof t=="string"?t:t[0],xo=t=>typeof t=="string"?nt[t]:t[1],Un=.05,Dy=.02,ih=t=>Math.round(t*1e3)/1e3;function Iy(t,e,n,r){switch(e){case"back":return{x:t.x0+n,z:t.z0+r,turn:0};case"right":return{x:t.x1-r,z:t.z0+n,turn:90};case"front":return{x:t.x1-n,z:t.z1-r,turn:180};case"left":return{x:t.x0+r,z:t.z1-n,turn:270}}}function sh(t,e,n){let r=de(t.points),i=r.x1-r.x0,o=r.z1-r.z0,s=[],l=(a,c,u,d,[p,h,f])=>{s.push({id:n(),type:a,x:ih(c),z:ih(u),rotation:d,w:p,d:h,h:f,variant:null,entity:null,power:null})};for(let[a,c,u]of nh[e].rows){let d=a==="back"||a==="front"?i:o,p=0,h=[];for(let g of u){if(p+xo(g)[0]>d-.1)break;h.push(g),p+=xo(g)[0]}let f=c==="start"?Un:c==="end"?d-p-Un:(d-p)/2;for(let g of h){let b=xo(g),y=Iy(r,a,f+b[0]/2,b[1]/2+Dy);l(rh(g),y.x,y.z,y.turn,b),f+=b[0]}}for(let[a,c,u,d]of nh[e].spots){let p=xo(a),h=(b,y,v)=>Math.min(v,Math.max(y,b)),f=h(r.x0+i*c,r.x0+p[0]/2+Un,r.x1-p[0]/2-Un),g=h(r.z0+o*u,r.z0+p[1]/2+Un,r.z1-p[1]/2-Un);l(rh(a),f,g,d,p)}return s}var Oy=30*Math.PI/180,ah=.05;function Ta(t){let e=t.points.length;return t.points.map((n,r)=>{let i=t.points[(r+1)%e];return Math.hypot(i[0]-n[0],i[1]-n[1])})}function ni(t){return Ta(t).reduce((e,n)=>e+n,0)}function Hy(t,e){let n=Ta(t),r=0;for(let i=0;ih+f,0);if(i<3||!(o>0)||!(n>0))return null;let s=Math.min(n,o),l=(e%o+o)%o,a=0,c=0;for(;a=c+r[a];)c+=r[a],a++;let u=l-c,d=s,p=[];for(let h=0;h<=i&&d>1e-9;h++){let f=r[a]-u,g=Math.min(d,f);g>1e-9&&p.push({edge:a,t0:u,t1:u+g}),d-=g,u=0;let b=(a+1)%i;if(d>1e-9&&Ly(t,a)>Oy)break;a=b}for(;p.length>1&&p[0].t1-p[0].t01&&p[p.length-1].t1-p[p.length-1].t0({edge:h.edge,offset:(h.t0+h.t1)/2,width:h.t1-h.t0})):null}function Zn(t,e){let n=e[0];return n?{from:Hy(t,n.edge)+n.offset-n.width/2,width:e.reduce((r,i)=>r+i.width,0)}:null}function Kt(t,e){return e.front?t.filter(n=>n.front===e.front):[e]}function Pa(t,e){let n=t.points.length,r=1/0,i=0,o=0;for(let s=0;sI("opening")){let s=za(e,r,i);if(!s)return null;let l=Kt(t,n),a=new Set(l.map(h=>h.id)),c=s.length>1?l[0].front??`front-${l[0].id}`:null,u=s.map((h,f)=>({...n,id:f===0?l[0].id:o(),edge:h.edge,offset:h.offset,width:h.width,front:c})),d=[],p=!1;for(let h of t){if(!a.has(h.id)){d.push(h);continue}p||(d.push(...u),p=!0)}return d}var Oa=globalThis,Da=Oa.__nextfloorBuiltin?.de??{},Ia=Oa.__nextfloorBuiltin?.en??{};Oa.__nextfloorBuiltin??={de:Da,en:Ia};var Cy=()=>typeof $=="object"&&$||{},Ny=globalThis,By=Ny.__nextfloorTexts??=new Map;function Wy(t){let e=t.toLowerCase().split("-")[0];return e!=="de"&&e!=="en"&&e in Cy()?e:void 0}function lh(t){let e=Wy(t),n=e===void 0?void 0:By.get(e);return n instanceof Promise?void 0:n}function $o(t,e){return lh(t)?.[e]}function Se(t,e,n={}){let r=t?.language??navigator.language,i=r.startsWith("de"),o=(i?void 0:lh(r)?.[e])??(i?Da:Ia)[e]??Ia[e]??Da[e]??e;for(let[s,l]of Object.entries(n))o=o.replace(`{${s}}`,String(l));return o}function K(t,e,n=2){return e.toLocaleString(t?.language??void 0,{maximumFractionDigits:n})}var Vy=new Set(["on","home","open","true","active","playing","heat","heating"]);function ch(t,e){let n=e.show_when;if(!n?.entity||!t)return!0;let r=t.states[n.entity];if(!r||Ie(r))return!0;let i=String(r.state).toLowerCase(),o=(n.state??"").split(",").map(l=>l.trim().toLowerCase()).filter(Boolean),s=o.length?o.includes(i):Vy.has(i)||Number.isFinite(Number(i))&&Number(i)>0;return n.invert?!s:s}function Ae(t,e){if(!vt(e))return Se(t,`furn_${e}`);let n=U(e);return n?Je(n,e,t?.language??navigator.language):Se(t,"pack_missing_item")}function Je(t,e,n){return t.name[n.split("-")[0]]??$o(n,e)??Yc(t,n)}function Be(t,e){return $o(e,`packname:${t.id}`)??Xc(t,e)}function uh(t,e){return t.name[e.split("-")[0]]??$o(e,`color:${t.id}`)??t.name.en??Object.values(t.name)[0]}var ii=t=>t&&t!=="none"?t:null,oi=(t,e)=>{e&&!t.includes(e)&&t.push(e)},Ha=t=>new Map(t.floors.flatMap(e=>e.furniture.filter(n=>n.type==="meter").map(n=>[n.id,n])));function gn(t,e){if(!t.energy.advanced||e.type!=="meter"||!e.parent_meter)return null;let n=Ha(t),r=new Set([e.id]);for(let i=n.get(e.parent_meter);i;i=n.get(i.parent_meter??"")){if(r.has(i.id))return null;r.add(i.id)}return n.has(e.parent_meter)?e.parent_meter:null}function qn(t){return new Set([...Ha(t).values()].filter(e=>gn(t,e)).map(e=>e.id))}function si(t,e){return!t.energy.advanced||!e.parent_meter?null:qn(t).has(e.parent_meter)?e.parent_meter:null}function dh(t,e,n){if(n.type!=="meter"||n.id===e.id)return!1;let r=Ha(t),i=new Set;for(let o=n;o&&!i.has(o.id);o=r.get(o.parent_meter??"")){if(o.id===e.id)return!1;i.add(o.id)}return!0}function Mo(t,e=n=>ii(n.power)){let n={grid:null,gridExport:null,solar:[],battery:[],charge:[],batteries:[],soc:[]};for(let r of t.floors.flatMap(i=>i.furniture)){let i=e(r),o=r.type==="meter"?gn(t,r):null;if(o)(n.subMeters??=[]).push({id:r.id,parent:o,power:i,invert:!!r.meter_invert,floors:r.meter_floors??[],solar:[],batteries:[]});else if(r.type==="meter")n.grid??=i,n.gridExport??=ii(r.export);else if(r.type==="inverter")oi(n.solar,i);else if(r.type==="home_battery"){let s=ii(r.charge);oi(n.battery,i),oi(n.charge,s),oi(n.soc,ii(r.soc)),(i||s)&&n.batteries.push({power:i,charge:s})}}for(let r of n.subMeters?t.floors.flatMap(i=>i.furniture):[]){let i=r.type==="inverter"||r.type==="home_battery"?n.subMeters?.find(l=>l.id===si(t,r)):void 0,o=i?e(r):null;i&&r.type==="inverter"&&oi(i.solar,o);let s=ii(r.charge);i&&r.type==="home_battery"&&(o||s)&&i.batteries.push({power:o,charge:s})}return n}function Ky(t){for(let e of t.floors){let n=e.furniture.find(r=>r.type==="meter"&&!gn(t,r));if(n)return{floor_id:e.id,x:n.x,z:n.z}}return t.energy.meter}var jy=/(phase|_l[123]\b|_[abc]$|today|daily|heute)/,Gy=/_?(energy|energie|total|today|daily|kwh|import|export|consumption|production)/g;function So(t,e,n="power"){let r=e?t.entities?.[e]?.device_id:void 0;if(!e||!r)return null;let i=Object.keys(t.states).filter(l=>l.startsWith("sensor.")&&t.entities?.[l]?.device_id===r&&t.states[l]?.attributes.device_class===n);if(i.length<=1)return i[0]??null;let o=i.filter(l=>!jy.test(l)),s=e.replace(/^sensor\./,"").replace(Gy,"");return o.find(l=>s&&l.includes(s))??o[0]??i[0]}function hh(t,e){let n={},r=(i,o)=>{o&&!n[i]&&(n[i]=o)};for(let i of e.energy_sources??[])if(i.type==="grid")r("grid",So(t,i.flow_from?.[0]?.stat_energy_from??i.flow_to?.[0]?.stat_energy_to));else if(i.type==="solar")r("solar",So(t,i.stat_energy_from));else if(i.type==="battery"){let o=i.stat_energy_from??i.stat_energy_to;r("battery",So(t,o)),r("battery_soc",So(t,o,"battery"))}return n}function Fe(t,e=!1){let n=t?.attributes.symcon_id?rn(t):t?Number(t.state):null;if(n===null||!Number.isFinite(n))return null;let r={kW:1e3,MW:1e6}[String(t.attributes.unit_of_measurement??"W")]??1;return e?-n*r:n*r}var Uy=(t,e)=>e.startsWith("sensor.")&&t.states[e]?.attributes.device_class==="power";function ai(t,e){if(Uy(t,e))return e;let n=t.entities?.[e]?.device_id;if(!n)return null;let r=Zs(t,n),i=r?Dt(t,e):null,o=oo(t,n).filter(s=>s!==e);return(r?o.find(s=>i!==null&&Dt(t,s)===i):o[0])??null}var ph=t=>{let e=t.filter(n=>n!==null);return e.length?e.reduce((n,r)=>n+r,0):null};function Zy(t,e,n){let r=e.grid??n.grid,i=r?Fe(t.states[r],e.grid_invert):null;if(!e.grid&&n.gridExport){let o=Math.max(0,Fe(t.states[n.gridExport])??0);return Math.max(0,i??0)-o}return i}function qy(t,e,n){return e.solar?Fe(t.states[e.solar]):n.solar.length?ph(n.solar.map(r=>Fe(t.states[r]))):null}function La(t,e,n){return e.charge?(e.power?Math.max(0,Fe(t.states[e.power])??0):0)-Math.max(0,Fe(t.states[e.charge])??0):e.power?Fe(t.states[e.power],n):null}function Yy(t,e,n){return e.battery?Fe(t.states[e.battery],e.battery_invert):ph(n.batteries.map(r=>La(t,r,e.battery_invert)))}function Ca(t,e,n,r=Mo(e)){let i=e.energy,o=Zy(t,i,r),s=qy(t,i,r),l=Yy(t,i,r),a=(i.battery_soc?[i.battery_soc]:r.soc).map(f=>Number(t.states[f]?.state)).filter(Number.isFinite),c=a.length?a.reduce((f,g)=>f+g,0)/a.length:null,u=i.tariff?t.states[i.tariff]:void 0,d=Number(u?.state),p=i.consumption?Fe(t.states[i.consumption]):null;p===null&&(o!==null||s!==null||l!==null)&&(p=(o??0)+Math.max(0,s??0)+(l??0)),p===null&&n.length>0&&(p=n.reduce((f,g)=>f+g.power,0));let h={grid:o,solar:s===null?null:Math.max(0,s),battery:l,soc:c,tariff:u&&Number.isFinite(d)?{value:d,unit:String(u.attributes.unit_of_measurement??"")}:null,consumption:p===null?null:Math.max(0,p)};return r.subMeters?{...h,...Xy(t,r,h.consumption,i.battery_invert,n)}:h}function Xy(t,e,n,r,i){let o=e.subMeters??[],s=new Map;for(let p of o)for(let h of p.floors)s.has(h)||s.set(h,p.id);let l=new Set([e.grid,e.gridExport,...e.solar,...e.battery,...e.charge,...o.flatMap(p=>[p.power,...p.solar,...p.batteries.flatMap(h=>[h.power,h.charge])])]),a=p=>i.filter(h=>s.get(h.floorId)===p&&!l.has(h.powerEntity)).reduce((h,f)=>h+f.power,0),c=new Map(o.map(p=>[p.id,p.power?Fe(t.states[p.power],p.invert):null])),u=o.map(p=>{let h=c.get(p.id)??null,f=p.solar.reduce((v,w)=>v+Math.max(0,Fe(t.states[w])??0),0),g=p.batteries.reduce((v,w)=>v+(La(t,w,r)??0),0),b=o.filter(v=>v.parent===p.id).reduce((v,w)=>v+(c.get(w.id)??0),0),y=h===null?null:Math.max(0,h+f+g-b);return{id:p.id,parent:p.parent,power:h,solar:f,battery:g,use:y,unmetered:y===null?null:Math.max(0,y-a(p.id))}}),d=u.reduce((p,h)=>p+(h.use??0),0);return{subMeters:u,rest:n===null?null:Math.max(0,n-d)}}function Jy(t,e,n){let r=t.b[0]-t.a[0],i=t.b[1]-t.a[1],o=Math.hypot(r,i)||1,s=Math.min(1,Math.max(0,((e.x-t.a[0])*r+(e.z-t.a[1])*i)/(o*o))),l=t.a[0]+r*s,a=t.a[1]+i*s,c=i/o*(l-n.x)+-r/o*(a-n.z)<0?-1:1;return{x:l,z:a,nx:c*i/o,nz:-c*r/o,distance:Math.hypot(e.x-l,e.z-a)}}function fh(t){let e=Ky(t),n=e?t.floors.find(c=>c.id===e.floor_id):void 0;if(!e||!n)return null;let r={exterior:t.settings.wall_exterior,interior:t.settings.wall_interior},i=fe(n.rooms,r,n.walls??[]).walls.filter(c=>c.exterior),o=n.rooms.flatMap(c=>c.points);if(i.length===0||o.length===0)return null;let s={x:o.reduce((c,u)=>c+u[0],0)/o.length,z:o.reduce((c,u)=>c+u[1],0)/o.length},l=i.map(c=>Jy(c,e,s)).reduce((c,u)=>u.distanceQy.includes(t),Na=(t,e="Heizkreis")=>({id:t,name:e,kind:"heating",has_pump:!0,has_valve:!0});function Ba(t){return{card:!0,...t==="heating_manifold"?{circuits:[Na("c1","Heizkreis 1")]}:{},...t==="buffer_tank"?{sensors:Array.from({length:7},(e,n)=>({id:`s${n+1}`,name:`F\xFChler ${n+1}`,entity:null,level:1-n/6}))}:{}}}function Ro(t){return{...Ba(t.type),...t.hydronic}}var Xn=t=>t.has_pump!==!1,Wa=t=>t.kind!=="pump"&&t.has_valve!==!1;var li=t=>!!t&&t!=="none";var Ao=(t,e)=>String(t.states[e]?.attributes.symcon_source_entity||e);function Eo(t,e){let n=t.states[Ao(t,e)]?.attributes;return n?.device_class==="power"||/^[km]?w$/i.test(String(n?.unit_of_measurement??"").trim())}function mh(t,e){let n=new Map;if(!X(t))return n;let r=Me(t,[e]),i=(o,s,l,a,c)=>{if(!li(c))return;let u=e.rooms.find(p=>p.points.length>=3&&C([l,a],p.points));if(!u)return;let d=n.get(u.id)??[];d.push({id:o,name:s,source:Ao(t,c)}),n.set(u.id,d)};for(let o of e.furniture){if(!ch(t,o))continue;let s=o.name||Ae(t,o.type),l=(o.values??[]).find(u=>li(u.entity)&&Eo(t,u.entity)),a=r.get(o.id)?.entity,c=o.power==="none"?null:o.power||r.get(o.id)?.power||(a&&Eo(t,a)?a:null);if(i(`furniture:${o.id}`,s,o.x,o.z,c||l?.entity),!c&&!l){let u=new Set;for(let d of o.gang_entities??[]){if(!li(d))continue;let p=ai(t,d);!p||u.has(Ao(t,p))||(u.add(Ao(t,p)),i(`furniture:${o.id}:${d}`,`${s} \xB7 ${B(t,d)}`,o.x,o.z,p))}}if(Yn(o.type))for(let u of Ro(o).circuits??[])Xn(u)&&i(`furniture:${o.id}:${u.id}`,`${s} \xB7 ${u.name||"Pumpe"}`,o.x,o.z,u.power)}for(let o of e.placements){if(o.outside)continue;let s=(o.values??[]).find(a=>li(a.entity)&&Eo(t,a.entity)),l=Eo(t,o.entity_id)?o.entity_id:ai(t,o.entity_id);i(`device:${o.entity_id}`,o.name||B(t,o.entity_id),o.x,o.z,l||s?.entity)}return n}var St={electricity:"Strom",water:"Wasser",gas:"Gas",heating:"Heizen",cooling:"K\xFChlen"},Jn={electricity:"\u26A1",water:"\u{1F4A7}",gas:"\u{1F525}",heating:"\u2668",cooling:"\u2744"},To=t=>t.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/ß/g,"ss").replace(/[^a-z0-9]+/g," ").trim(),ev="{485D0419-BE97-4548-AA9C-C083EB82E61E}",tv=t=>t.object_type!==0&&!(t.object_type===1&&t.module_id?.toUpperCase()===ev)?null:{elektro:"electricity",strom:"electricity","elektro strom":"electricity","strom elektro":"electricity",wasser:"water",gas:"gas",heizen:"heating",heizung:"heating",warme:"heating",waerme:"heating",kuhlen:"cooling",kuehlen:"cooling",kuhlung:"cooling",kuehlung:"cooling",kalte:"cooling",kaelte:"cooling"}[To(t.name)]??null,Fo=t=>/^symcon-category-(\d+)$/.exec(t??"")?.[1],Ka=t=>/\b(heute|tag|tagesverbrauch|today|daily)\b/.test(t)?"day":/monat|month/.test(t)?"month":/jahr|year/.test(t)?"year":"total",zo=(t,e)=>String(t.states[e]?.attributes.symcon_source_entity||e);function bh(t){let e=String(t?.attributes.unit_of_measurement??"").trim(),n=e.replace(/[³]/g,"3").replace(/[²]/g,"2").replace(/\s+/g,"").toLowerCase();return["w","kw","mw"].includes(n)?{metric:"power",unit:"W",factor:e==="mW"?.001:n==="kw"?1e3:n==="mw"?1e6:1}:["wh","kwh","mwh","j","kj","mj","gj"].includes(n)?{metric:"energy",unit:"kWh",factor:{wh:.001,kwh:1,mwh:1e3,j:1/36e5,kj:1/3600,mj:1/3.6,gj:1e3/3.6}[n]}:["m3/h","m3h","m3/min","m3/s","l/h","l/min","l/s","liter/h","liter/min"].includes(n)?{metric:"power",unit:"m\xB3/h",factor:{"m3/h":1,m3h:1,"m3/min":60,"m3/s":3600,"l/h":.001,"l/min":.06,"l/s":3.6,"liter/h":.001,"liter/min":.06}[n]}:["m3","l","liter"].includes(n)?{metric:"energy",unit:"m\xB3",factor:n==="m3"?1:.001}:null}function nv(t,e){if(!e.entity_id||e.object_type!==2&&e.object_type!==6)return null;let n=zo(t,e.entity_id),r=t.states[n];if(!r||![1,2].includes(Number(r.attributes.symcon_variable_type)))return null;let i=To(e.name),o=bh(r),s=/^(leistung|wirkleistung|gesamtleistung|aktuelle leistung|durchfluss|volumenstrom)(\b|$)/.test(i),l=/^(verbrauch|energie|energieverbrauch|gesamtverbrauch|gesamtenergie|zahlerstand|zaehlerstand|arbeit)(\b|$)/.test(i),a=o?.metric??(s?"power":l?"energy":null);if(!a)return null;let c=a==="power"?/^(leistung|wirkleistung|gesamtleistung|durchfluss|volumenstrom)$/.test(i):/^(verbrauch|energie|energieverbrauch|gesamtverbrauch|gesamtenergie|zahlerstand|zaehlerstand|arbeit)$/.test(i),u=a==="energy"?Ka(i):"total";return{metric:a,source:n,period:u,group:`${a}|${o?.unit??String(r.attributes.unit_of_measurement??"")}|${u}`,score:/^gesamt(leistung|verbrauch|energie)$/.test(i)?110:c?100:(a==="power"?s:l)?70:20}}var gh=new WeakMap,_h=new WeakMap;function yh(t){let e=gh.get(t);if(e)return e;let n={nodes:new Map(t.map(r=>[r.object_id,r])),children:new Map};for(let r of t){let i=n.children.get(r.parent_id)??[];i.push(r),n.children.set(r.parent_id,i)}return gh.set(t,n),n}function rv(t,e,n){if(!X(t))return[];let r=[e.area_id,...e.sub_areas??[]].map(Fo).filter(p=>!!p);if(!r.length)return[];let i=new Set(n.filter(p=>p.id!==e.id).flatMap(p=>[p.area_id,...p.sub_areas??[]]).map(Fo).filter(p=>!!p&&!r.includes(p))),o=`${r.join(",")}|${[...i].sort().join(",")}`,s=_h.get(t)??new Map;_h.set(t,s);let l=s.get(o);if(l)return l;let a=yh(t.symconObjects),c=[],u=new Set,d=(p,h,f)=>{if(u.has(p)||i.has(String(p)))return;u.add(p);let g=a.nodes.get(p);if(!g)return;let b=tv(g),y=b??h,v=new Set(b&&b!==h?[]:f),w=a.children.get(p)??[];if(y){let x=w.map(k=>nv(t,k)).filter(k=>k!==null);for(let k of new Set(x.map(M=>M.group))){if(v.has(k))continue;let M=x.filter(F=>F.group===k),A=Math.max(...M.map(F=>F.score)),T=M.filter(F=>F.score===A);for(let F of A>=100?T.slice(0,1):T)c.push({kind:y,metric:F.metric,id:F.source,period:F.period});v.add(k)}}for(let x of w)(x.object_type===0||x.object_type===1)&&d(x.object_id,y,v)};for(let p of r)d(Number(p),null,new Set);return s.set(o,c),c}function ci(t,e,n=!1){let r=new Map,i=new Set;for(let o of e){let s=zo(t,o.id),l=`${o.kind}|${o.metric}|${s}`;if(i.has(l))continue;i.add(l);let a=t.states[s],c=bh(a),u=c?.metric===o.metric?c.unit:String(a?.attributes.unit_of_measurement??"").trim(),d=`${o.kind}|${o.metric}|${u}|${o.period}`,p=r.get(d)??{kind:o.kind,metric:o.metric,unit:u,value:null,period:o.period,sources:[],manual:n,incomplete:!1},h=rn(a);h===null?p.incomplete=!0:p.value=(p.value??0)+h*(c?.metric===o.metric?c.factor:1),p.sources.push(s),r.set(d,p)}return[...r.values()]}function Va(t,e){return wt.flatMap(n=>["power","energy"].flatMap(r=>{let i=e.utility_meters?.[n]?.[r];if(!i||i==="none")return[];let o=zo(t,i);return[{kind:n,metric:r,id:o,period:r==="energy"?Ka(To(String(t.states[o]?.attributes.friendly_name??""))):"total"}]}))}function iv(t,e){return X(t)?ci(t,Va(t,e),!0):[]}function ov(t,e,n=e.rooms,r=!1){if(!X(t))return[];let i=r?mh(t,e):new Map,o=new Map;for(let l of e.rooms){let a=[...new Set([l.area_id,...l.sub_areas??[]].filter(c=>!!Fo(c)))];!a.length&&(Va(t,l).length||i.get(l.id)?.length)&&a.push("unassigned");for(let c of a){let u=o.get(c)??{seed:l,members:[]};c===a[0]&&u.members.push(l),o.set(c,u)}}let s=yh(t.symconObjects).nodes;return[...o].map(([l,a])=>{let c=s.get(Number(Fo(l))),u=l==="unassigned"?[]:ci(t,rv(t,{...a.seed,area_id:l,sub_areas:null},n)),d=ci(t,a.members.flatMap(f=>Va(t,f)),!0),p=f=>u.some(g=>g.kind===f.kind&&g.metric===f.metric&&g.unit===f.unit&&g.period===f.period),h=a.members.map(f=>({id:f.id,name:f.name,readings:iv(t,f),devices:(i.get(f.id)??[]).map(g=>({id:g.id,name:g.name,readings:ci(t,[{kind:"electricity",metric:"power",id:g.source,period:"total"}],!0)}))})).filter(f=>f.readings.length||f.devices.length);return{id:l,name:l==="unassigned"?"Nicht zugeordnet":c?.name||t.areas?.[l]?.name||"Bereich nicht verf\xFCgbar",path:c?.path||"",readings:[...u,...d.filter(f=>!p(f))],rooms:h}}).filter(l=>l.readings.length||l.rooms.length)}function ja(t,e,n,r){let i=e.utility_meters?.[n],o=i&&Object.prototype.hasOwnProperty.call(i,r)?i[r]:n==="electricity"&&r==="power"?e.power_entity:null;return o&&o!=="none"?zo(t,o):null}function vh(t,e,n=e.rooms){let r=ov(t,e,n).flatMap(o=>o.readings.flatMap(s=>s.sources.map(l=>({kind:s.kind,metric:s.metric,period:s.period,id:l})))),i=[];for(let o of wt)for(let s of["power","energy"]){let l=ja(t,e,o,s);i.push(...ci(t,l?[{kind:o,metric:s,id:l,period:s==="energy"?Ka(To(String(t.states[l]?.attributes.friendly_name??""))):"total"}]:r.filter(a=>a.kind===o&&a.metric===s),!!l))}return i}function Ga(t){return t.metric==="power"?t.unit==="m\xB3/h"?"Durchfluss":"Leistung":{total:"Verbrauch",day:"Verbrauch heute",month:"Verbrauch Monat",year:"Verbrauch Jahr"}[t.period]}function wh(t,e){let n=e.incomplete?"Err: ":"";if(e.value===null)return`${n}\u2013`;let r=e.unit==="W"&&Math.abs(e.value)>=1e3?e.value/1e3:e.value,i=e.unit==="W"&&Math.abs(e.value)>=1e3?"kW":e.unit,o=Number.isInteger(r)?0:Math.min(6,Math.max(2,1-Math.floor(Math.log10(Math.abs(r)))));return`${n}${K(t,r,o)}${i?` ${i}`:""}`}var kh=[{key:"supply_vsr",label:"Zuluft-VSR",types:[0,1,2],control:!0},{key:"extract_vsr",label:"Abluft-VSR",types:[0,1,2],control:!0},{key:"supply_temperature",label:"Zulufttemperatur",types:[1,2]},{key:"extract_temperature",label:"Ablufttemperatur",types:[1,2]},{key:"reheat",label:"NHR (Nachheizregister)",types:[0,1,2],control:!0},{key:"status",label:"Raumstatus",types:[1]}];function xh(t,e,n){let r=O(t.hass,i=>He(t.hass,i,[1,2]));return m`Eigene Raumzähler
+ `}var rt=(t,e,n={})=>t.callWS({type:`nextfloor/${e}`,...n});async function mo(t,e){return(await rt(t,"image/get",{image_id:e})).data}async function Wt(t,e,n){await rt(t,"image/set",{image_id:e,data:n})}async function $d(t){return(await rt(t,"history/list")).snapshots}async function Sd(t,e){return(await rt(t,"history/snapshot",e?{name:e}:{})).id}async function Md(t,e){return(await rt(t,"history/get",{snapshot_id:e})).building}async function Rd(t,e){await rt(t,"history/delete",{snapshot_id:e})}async function Ed(t,e){return(await rt(t,"history/restore",{snapshot_id:e})).revision}var Dr=(t,e)=>rt(t,"packs/import",{pack:e});async function Ad(t,e){await rt(t,"packs/remove",{pack_id:e})}var Fd=t=>rt(t,"backup/export"),Td=(t,e,n)=>rt(t,"backup/import",{building:e,packs:n});var U=(t,e)=>[t[0]-e[0],t[1]-e[1]],ft=(t,e)=>[t[0]+e[0],t[1]+e[1]],it=(t,e)=>[t[0]*e,t[1]*e],te=(t,e)=>t[0]*e[0]+t[1]*e[1],Re=(t,e)=>t[0]*e[1]-t[1]*e[0],ge=t=>Math.hypot(t[0],t[1]),ot=t=>{let e=ge(t)||1;return[t[0]/e,t[1]/e]},la=t=>[-t[1],t[0]],ca=t=>[t[1],-t[0]];var dy=.05,hy=.2,py=.12;function fy(t){let e=[];return t.forEach((n,r)=>{let i=n.points;if(i.length<3)return;let o=_e(i)>=0;i.forEach((s,l)=>{let a=i[(l+1)%i.length],c=ge(U(a,s));if(c<.05)return;let u=[(a[0]-s[0])/c,(a[1]-s[1])/c],d=o?[u[1],-u[0]]:[-u[1],u[0]];(u[1]<-1e-9||Math.abs(u[1])<=1e-9&&u[0]<0)&&(u=[-u[0],-u[1]]);let p=[-u[1],u[0]],[h,f]=[te(s,u),te(a,u)];e.push({room:r,index:l,dir:u,normal:p,offset:te(s,p),outside:te(d,p)>0?1:-1,from:Math.min(h,f),to:Math.max(h,f)})})}),e}function my(t,e,n){if(t.room===e.room||Math.abs(Re(t.dir,e.dir))>dy||t.outside===e.outside)return null;let r=(e.offset-t.offset)*t.outside;return r>n||r<-py||Math.abs(r)<1e-4||Math.min(t.to,e.to)-Math.max(t.from,e.from)
Math.round(t*1e3)/1e3;function zd(t,e=.6){let n=fy(t),r=n.map((g,b)=>b),i=g=>r[g]===g?g:r[g]=i(r[g]),o=[],s=new Set,l=[];for(let g=0;gMath.abs(g[2])-Math.abs(b[2]));let a=new Map(n.map((g,b)=>[b,[b]])),c=(g,b)=>g.some(y=>b.some(v=>n[y].room===n[v].room&&Math.abs(n[y].offset-n[v].offset)>=.002));for(let[g,b,y]of l){let[v,w]=[i(g),i(b)];if(v!==w){if(c(a.get(v),a.get(w)))continue;r[v]=w,a.set(w,[...a.get(w),...a.get(v)]),a.delete(v)}o.push(ua(y)),s.add(g).add(b)}let u=new Map(n.map((g,b)=>[`${g.room}:${g.index}`,b]));for(let g=s.size>0;g;)g=!1,n.forEach((b,y)=>{let v=u.get(`${b.room}:${(b.index+1)%t[b.room].points.length}`);if(v===void 0||v===y)return;let w=n[v];!(Math.abs(Re(b.dir,w.dir))<1e-6&&Math.abs(b.offset-w.offset)<.002&&b.outside===w.outside)||s.has(y)===s.has(v)||(s.add(y).add(v),g=!0)});n.forEach((g,b)=>{let y=u.get(`${g.room}:${(g.index+1)%t[g.room].points.length}`);if(y===void 0||y===b||!s.has(b)||!s.has(y))return;let v=n[y];Math.abs(Re(g.dir,v.dir))<1e-6&&Math.abs(g.offset-v.offset)<.002&&g.outside===v.outside&&(r[i(b)]=i(y))});let d=()=>t.map(g=>({...g,points:g.points.map(b=>[b[0],b[1]])}));if(o.length===0)return{rooms:d(),gaps:o};let p=new Map;for(let g of s)p.set(i(g),[...p.get(i(g))??[],g]);let h=t.map(g=>g.points.map(()=>new Map));for(let[g,b]of p){let y=new Map(b.map(w=>[`${n[w].room}:${Math.round(n[w].offset*500)}`,n[w].offset])),v=[...y.values()].reduce((w,x)=>w+x,0)/y.size;for(let w of b){let x=n[w],k=[x.normal[0]*(v-x.offset),x.normal[1]*(v-x.offset)];h[x.room][x.index].set(g,k),h[x.room][(x.index+1)%t[x.room].points.length].set(g,k)}}return{rooms:t.map((g,b)=>({...g,points:g.points.map((y,v)=>{let w=[...h[b][v].values()].reduce((x,k)=>[x[0]+k[0],x[1]+k[1]],[y[0],y[1]]);return[ua(w[0]),ua(w[1])]})})),gaps:o}}function Pd(t){let e=t.filter(n=>n>.04).sort((n,r)=>n-r);return e.length===0?null:Math.min(.5,Math.max(.08,Math.round(e[Math.floor(e.length/2)]*100)/100))}var gy=.25,Dd=t=>Math.round(t*1e3)/1e3,Id=(t,e,n)=>t.rooms.find(r=>r.points.length>=3&&C([e,n],r.points));function ha(t,e,n,r,i){let o=Id(t,e,n);if(!o)return[r,i];let s=(l,a)=>C([l,a],o.points);return s(r,i)?[r,i]:s(r,n)?[r,n]:s(e,i)?[e,i]:[e,n]}function _y(t,e,n,r){return t.rooms.some(i=>i.id!==e.id&&i.points.some((o,s)=>{let l=i.points[(s+1)%i.points.length];return Math.abs(te(U(o,n),r))<.02&&Math.abs(te(U(l,n),r))<.02}))}var da=(t,e)=>Math.abs((t-e+540)%360-180);function Ir(t,e,n,r=gy){let i=Id(t,e.x,e.z);if(!i)return null;let o=i.points,s=_e(o)>=0?1:-1,l=null;return o.forEach((a,c)=>{let u=o[(c+1)%o.length],d=ge(U(u,a));if(d<.3)return;let p=[(u[0]-a[0])/d,(u[1]-a[1])/d],h=[-p[1]*s,p[0]*s],f=te(U([e.x,e.z],a),p);if(f<0||f>d)return;let g=_y(t,i,a,h)?n/2:0,b=te(U([e.x,e.z],a),h)-g,y=Math.atan2(-h[0],h[1])*180/Math.PI,w=[{rotation:y,extent:e.d/2},{rotation:y+90,extent:e.w/2},{rotation:y-90,extent:e.w/2}].reduce((k,M)=>da(e.rotation,M.rotation)50)return;let x=b-w.extent;Math.abs(x)>r||l&&Math.abs(x)>=Math.abs(l.gap)||(l={x:Dd(e.x-h[0]*x),z:Dd(e.z-h[1]*x),rotation:(Math.round(w.rotation)%360+360)%360,gap:x})}),l&&{x:l.x,z:l.z,rotation:l.rotation}}var Bn=Math.PI/180,st=t=>Math.tan(Math.min(80,Math.max(0,t))*Bn);function Hr(t){return{x0:Math.min(t.x0,t.x1),x1:Math.max(t.x0,t.x1),z0:Math.min(t.z0,t.z1),z1:Math.max(t.z0,t.z1)}}function Od(t){if(!t.rotation)return null;let e=t.rotation*Bn;return{cx:(t.x0+t.x1)/2,cz:(t.z0+t.z1)/2,c:Math.cos(e),sn:Math.sin(e)}}function Hd(t,e){let n=Od(t);if(!n)return e;let[r,i]=[e[0]-n.cx,e[1]-n.cz];return[n.cx+r*n.c-i*n.sn,n.cz+r*n.sn+i*n.c]}function pa(t,e,n){let r=Od(t);if(!r)return[e,n];let[i,o]=[e-r.cx,n-r.cz];return[r.cx+i*r.c+o*r.sn,r.cz-i*r.sn+o*r.c]}function Lr(t,e=0){let{x0:n,x1:r,z0:i,z1:o}=Hr(t);return[[n-e,i-e],[r+e,i-e],[r+e,o+e],[n-e,o+e]].map(s=>Hd(t,s))}function $e(t){let{x0:e,x1:n,z0:r,z1:i}=Hr(t),o=s=>Hd(t,s);return t.axis==="x"?{u0:e,u1:n,w:i-r,at:(s,l)=>o([s,t.flip?i-l:r+l])}:{u0:r,u1:i,w:n-e,at:(s,l)=>o([t.flip?n-l:e+l,s])}}function Cr(t,e,n){let{x0:r,x1:i,z0:o,z1:s}=Hr(t),[l,a]=pa(t,e,n);return t.axis==="x"?[l,t.flip?s-a:a-o]:[a,t.flip?i-l:l-r]}var Or=Math.tan(30*Bn);function Nr(t,e,n,r,i){let o=Math.min(t*.3,r>1e-6?2.4/r:t*.3),s=Math.min(t*.3,i>1e-6?2.4/i:t*.3),l=e+o*r,a=n+s*i,c=Math.min(t-s,Math.max(o,(a-l+Or*(t-s+o))/(2*Or))),u=l+(c-o)*Or;return{vla:o,vlb:s,yla:l,ylb:a,vr:c,rh:u,y:p=>p<=o?e+p*r:p<=c?l+(p-o)*Or:p<=t-s?a+(t-s-p)*Or:n+(t-p)*i}}function Le(t){let e=$e(t).w,[n,r]=[t.eave_a,t.eave_b],[i,o]=[st(t.pitch_a),st(t.pitch_b)];switch(t.shape){case"flat":case"parapet":return{vr:e/2,rh:n,y:()=>n};case"pent":return{vr:e,rh:n+e*i,y:s=>n+s*i};case"mansard":{let s=Nr(e,n,r,i,o);return{vr:s.vr,rh:s.rh,y:s.y}}default:{let s=i+o>1e-6?Math.min(e,Math.max(0,(r-n+e*o)/(i+o))):e/2;return{vr:s,rh:n+s*i,y:l=>l<=s?n+l*i:r+(e-l)*o}}}}var cn=t=>Le(t).rh;function Ld(t){let e=t.heightEnd!==void 0;return{...t,a:t.b,b:t.a,left:t.right,right:t.left,roomLeft:t.roomRight,roomRight:t.roomLeft,height:e?t.heightEnd:t.height,heightEnd:e?t.height:void 0}}function by(t,e){let n=t.map(r=>({...r}));for(let r of e){let i=n.find(o=>o.room_id===r.room_id&&o.edge===r.edge&&(Math.abs(o.t1-r.t0)<1e-6||Math.abs(r.t1-o.t0)<1e-6));i?(i.t0=Math.min(i.t0,r.t0),i.t1=Math.max(i.t1,r.t1)):n.push({...r})}return n}function yy(t,e,n){if(t.a===e.b)return!1;let r=ot(U(n[t.b],n[t.a])),i=ot(U(n[e.b],n[e.a]));return Math.abs(Re(r,i))>1e-6||te(r,i)<=0||t.free||e.free||t.heightEnd!==void 0||e.heightEnd!==void 0?!1:t.height===e.height&&t.exterior===e.exterior&&t.roomLeft===e.roomLeft&&t.roomRight===e.roomRight&&Math.abs(t.left-e.left)<=1e-9&&Math.abs(t.right-e.right)<=1e-9}function Cd(t,e,n=new Set){let r=t.slice();for(;;){let i=new Map;r.forEach((s,l)=>{for(let a of[s.a,s.b])i.set(a,[...i.get(a)??[],l])});let o=null;for(let[s,l]of i){if(l.length!==2||n.has(s))continue;let a=r[l[0]].b===s?r[l[0]]:Ld(r[l[0]]),c=r[l[1]].a===s?r[l[1]]:Ld(r[l[1]]);if(!yy(a,c,e))continue;let u={...a,b:c.b,sources:by(a.sources,c.sources)};o=[...r.filter((d,p)=>p!==l[0]&&p!==l[1]),u];break}if(!o)return r;r=o}}function Nd(t,e){let n=new Map;t.forEach((i,o)=>{let s=ot(U(e[i.b],e[i.a])),l=[[i.a,{key:`${o}:a`,d:s,left:i.left,right:i.right,angle:Math.atan2(s[1],s[0])}],[i.b,{key:`${o}:b`,d:it(s,-1),left:i.right,right:i.left,angle:Math.atan2(-s[1],-s[0])}]];for(let[a,c]of l)n.set(a,[...n.get(a)??[],c])});let r=new Map;for(let[i,o]of n){let s=e[i];o.sort((a,c)=>a.angle-c.angle);for(let a of o)r.set(a.key,{left:ft(s,it(la(a.d),a.left)),right:ft(s,it(ca(a.d),a.right))});if(o.length<2)continue;let l=4*Math.max(...o.map(a=>Math.max(a.left,a.right)))+1e-9;o.forEach((a,c)=>{let u=o[(c+1)%o.length],d=ft(s,it(la(a.d),a.left)),p=ft(s,it(ca(u.d),u.right)),h=Re(a.d,u.d);if(Math.abs(h)<1e-4)return;let f=ft(d,it(a.d,Re(U(p,d),u.d)/h));ge(U(f,s))>l||(r.get(a.key).left=f,r.get(u.key).right=f)})}return r}function Bd(t,e){let n=t.filter((r,i)=>ge(U(r,t[(i+1)%t.length]))>e);for(;;){if(n.length<=3)return n;let r=n.findIndex((i,o)=>{let s=n[(o+n.length-1)%n.length],l=n[(o+1)%n.length],[a,c]=[U(i,s),U(l,i)];return Math.abs(Re(ot(a),ot(c)))<1e-7&&te(a,c)>0});if(r===-1)return n;n=n.filter((i,o)=>o!==r)}}function vy(t){let e=[];return{points:e,idOf(n){let r=e.findIndex(i=>Math.abs(i[0]-n[0])<=t&&Math.abs(i[1]-n[1])<=t);return r>=0?r:(e.push([n[0],n[1]]),e.length-1)}}}function wy(t,e){let n=[];for(let r of t){let i=r.points;if(i.length<3||Math.abs(_e(i))<1e-6)continue;let o=_e(i)>0,s=i.map(l=>e.idOf(l));s.forEach((l,a)=>{let c=s[(a+1)%s.length];l!==c&&n.push(o?{u:l,v:c,room:r.id,edge:a,forward:!0}:{u:c,v:l,room:r.id,edge:a,forward:!1})})}return n}function ky(t,e,n){let r=[];for(let i of t){let[o,s]=[e[i.u],e[i.v]],l=U(s,o),a=ge(l),c=it(l,1/a),u=e.map((p,h)=>({id:h,rel:U(p,o)})).filter(({id:p,rel:h})=>p!==i.u&&p!==i.v&&te(h,c)>n&&te(h,c)({t:te(h,c),id:p})).sort((p,h)=>p.t-h.t),d=[{t:0,id:i.u},...u,{t:a,id:i.v}];for(let p=0;p+1({room_id:t.room,edge:t.edge,t0:t.t0,t1:t.t1});function xy(t,e){let n=new Map(t.map(l=>[l.id,l])),r=new Map;for(let l of e){let a=`${l.room}:${l.edge}`;r.set(a,[...r.get(a)??[],l.t0].sort((c,u)=>c-u))}let i=l=>{let a=n.get(l.room)?.wall_heights?.[l.edge];return Array.isArray(a)?a[(r.get(`${l.room}:${l.edge}`)??[]).indexOf(l.t0)]??null:a},o=l=>{let a=n.get(l.room),[c,u]=[a?.wall_heights?.[l.edge],a?.wall_slopes?.[l.edge]];if(!a||typeof c!="number"||typeof u!="number"||c<=0||u<=0)return null;let[d,p]=[a.points[l.edge],a.points[(l.edge+1)%a.points.length]];return{from:c,to:u,length:Math.hypot(p[0]-d[0],p[1]-d[1])}},s=l=>{let a=o(l);if(!a||a.length<1e-9){let u=i(l);return typeof u=="number"&&u>0?[u,u]:[null,null]}let c=u=>a.from+(a.to-a.from)*u/a.length;return l.forward?[c(l.t0),c(l.t1)]:[c(l.t1),c(l.t0)]};return{heightsOf(l){let[a,c]=[1/0,1/0];for(let d of l){let[p,h]=s(d),[f,g]=d===l[0]?[p,h]:[h,p];f!==null&&(a=Math.min(a,f)),g!==null&&(c=Math.min(c,g))}let u=l.map(d=>n.get(d.room)?.ceiling);if(u.every(d=>typeof d=="number"&&d>0)){let d=Math.max(...u);a===1/0&&(a=d),c===1/0&&(c=d)}return{...a<1/0?{a}:{},...c<1/0?{b:c}:{}}},thicknessOf(l){let a=l.map(c=>{let u=n.get(c.room)?.wall_thickness?.[c.edge];return Array.isArray(u)?u[(r.get(`${c.room}:${c.edge}`)??[]).indexOf(c.t0)]:u}).filter(c=>typeof c=="number"&&c>0);return a.length?Math.max(...a):void 0},hasNoWall:l=>l.some(a=>i(a)===0)}}function Vd(t){let e=n=>Math.round(n*1e6)/1e6;return t.a===void 0||t.b===void 0?t.a!==void 0?{height:e(t.a)}:t.b!==void 0?{height:e(t.b)}:{}:Math.abs(t.a-t.b)<1e-6?{height:e(t.a)}:{height:e(t.a),heightEnd:e(t.b)}}function $y(t,e,n,r){let i=xy(e,t),o=new Map;for(let a of t){let c=a.up!==c&&p.u===c.v&&p.v===c.u&&p.room!==c.room);for(let p of a)p!==c&&p!==u&&p.room!==c.room&&r.push(`overlap:${c.room}:${p.room}`);let d=u?[c,u]:[c];if(i.hasNoWall(d)){u&&l.push([c.room,u.room]);continue}if(u){let p=i.thicknessOf(d)??n.interior;s.push({a:c.u,b:c.v,left:p/2,right:p/2,exterior:!1,roomLeft:c.room,roomRight:u.room,sources:d.map(Wd),...Vd(i.heightsOf(d))})}else s.push({a:c.u,b:c.v,left:0,right:i.thicknessOf(d)??n.exterior,exterior:!0,roomLeft:c.room,roomRight:null,sources:[Wd(c)],...Vd(i.heightsOf(d))})}return{drafts:s,open:l}}function Sy(t,e){let n=o=>ot(U(e[o.b],e[o.a])),r=t.filter(o=>!o.exterior&&!o.free),i=new Map;for(let o of r){if(i.has(o))continue;let s=[o];i.set(o,s);for(let l=0;l1e-6||a.add(te(s,h)>0?"left":"right")}if(a.size!==1)continue;let c=[...a][0];for(let u of o){let d=u.left+u.right,p=te(n(u),s)>0,h=c==="left"===p;[u.left,u.right]=h?[0,d]:[d,0]}}}var My=(t,e)=>{let n=o=>Math.round(o*100),[r,i]=t[0]Math.hypot(y.b[0]-y.a[0],y.b[1]-y.a[1])>.05),a=l.map(y=>[o.idOf(y.a),o.idOf(y.b)]),c=new Set;for(let y of t){let v=y.points;v.length<3||(y.wall_splits??[]).forEach((w,x)=>{if(!w||x>=v.length)return;let k=v[x],M=U(v[(x+1)%v.length],k),A=ge(M);for(let T of w)T>r&&T{let[w,x]=a[v];if(w===x)return;let k=[(y.a[0]+y.b[0])/2,(y.a[1]+y.b[1])/2],M=t.find(T=>T.points.length>=3&&C(k,T.points))?.id??null,A=(y.thickness??e.interior)/2;h.push({free:y.id,a:w,b:x,left:A,right:A,exterior:!1,roomLeft:M,roomRight:M,sources:[],height:typeof y.height=="number"&&y.height>0?y.height:void 0,...typeof y.height=="number"&&y.height>0&&typeof y.height_end=="number"&&y.height_end>0&&Math.abs(y.height_end-y.height)>1e-6?{heightEnd:y.height_end}:{}})});let f=Cd(h,o.points,c),g=Nd(f,o.points);return{walls:f.map((y,v)=>{let[w,x]=[o.points[y.a],o.points[y.b]],[k,M]=[g.get(`${v}:a`),g.get(`${v}:b`)],A=Bd([k.right,M.left,x,M.right,k.left,w],1e-6);return{id:My(w,x),a:[w[0],w[1]],b:[x[0],x[1]],left:y.left,right:y.right,exterior:y.exterior,roomLeft:y.roomLeft,roomRight:y.roomRight,sources:y.sources,footprint:A,...y.free?{free:y.free}:{},...y.height!==void 0?{height:y.height}:{},...y.heightEnd!==void 0?{heightEnd:y.heightEnd}:{}}}),warnings:[...new Set(i)],open:p}}function Wn(t,e,n){let r=t.points[e];return ft(r,it(ot(U(t.points[(e+1)%t.points.length],r)),n))}function Ce(t,e,n){if(t.wall){let i=n.find(l=>l.id===t.wall);if(!i||Math.hypot(i.b[0]-i.a[0],i.b[1]-i.a[1])<.05)return null;let o=ot(U(i.b,i.a));return{room:{id:t.room_id,name:"",area_id:null,points:[i.a,i.b,ft(i.a,[-o[1],o[0]])]},edge:0}}let r=e.find(i=>i.id===t.room_id);return r&&t.edgete(U(e,t.a),ot(U(t.b,t.a)));function Vt(t,e,n){if(!e.wall)return Ry(t,n.room,n.edge,e.offset);let r=t.find(i=>i.free===e.wall);return r?{wall:r,s:Kd(r,Wn(n.room,0,e.offset))}:null}function Ry(t,e,n,r){for(let i of t)if(i.sources.some(s=>s.room_id===e.id&&s.edge===n&&r>=s.t0-1e-6&&r<=s.t1+1e-6))return{wall:i,s:Kd(i,Wn(e,n,r))};return null}function jd(t,e){let n=t.points.map(h=>h[0]),r=t.points.map(h=>h[1]);if(t.points.length!==4||new Set(n.map(h=>h.toFixed(3))).size!==2||new Set(r.map(h=>h.toFixed(3))).size!==2)return null;let[i,o,s,l]=[Math.min(...n),Math.max(...n),Math.min(...r),Math.max(...r)],a=h=>Math.max(0,...e.filter(f=>(f.roomLeft===t.id||f.roomRight===t.id)&&h(f)).map(f=>f.roomLeft===t.id?f.left:f.right)),c=(h,f)=>Math.abs(h-f)<.001,u=(h,f,g)=>c(h.a[f],g)&&c(h.b[f],g),d=o-i-a(h=>u(h,0,i))-a(h=>u(h,0,o)),p=l-s-a(h=>u(h,1,s))-a(h=>u(h,1,l));return[Math.round(d*1e3)/1e3,Math.round(p*1e3)/1e3]}var Ud=([t,e])=>{let n=Math.hypot(t,e)||1;return[t/n,e/n]};function Ey(t){return t.reduce((e,n,r)=>e+(n[0]*t[(r+1)%t.length][1]-t[(r+1)%t.length][0]*n[1]),0)/2}function Gd(t,e){let n=t.length;if(n<3||Math.abs(e)<1e-9)return t.map(([i,o])=>[i,o]);let r=Ey(t)>=0?1:-1;return t.map((i,o)=>{let s=t[(o+n-1)%n],l=t[(o+1)%n],[a,c]=Ud([i[0]-s[0],i[1]-s[1]]),[u,d]=Ud([l[0]-i[0],l[1]-i[1]]),p=[c*r,-a*r],h=[d*r,-u*r],f=[p[0]+h[0],p[1]+h[1]],g=Math.hypot(f[0],f[1]);if(g<1e-6)return[i[0]+p[0]*e,i[1]+p[1]*e];let b=(f[0]*p[0]+f[1]*p[1])/g,y=Math.min(4,1/Math.max(.25,b));return[i[0]+f[0]/g*e*y,i[1]+f[1]/g*e*y]})}function Kt(t){let e=t.map(r=>r[0]),n=t.map(r=>r[1]);return{x0:Math.min(...e),z0:Math.min(...n),x1:Math.max(...e),z1:Math.max(...n)}}function Ay(t){let e=([o,s])=>`${Math.round(o*1e3)}:${Math.round(s*1e3)}`,n=new Map;for(let o of t)for(let s of[o.a,o.b])n.set(e(s),[...n.get(e(s))??[],o]);let r=new Set,i=null;for(let o of t){if(r.has(o))continue;r.add(o);let s=[o.a,o.b],l=o.b;for(;;){let c=(n.get(e(l))??[]).find(u=>!r.has(u));if(!c||(r.add(c),l=e(c.a)===e(l)?c.b:c.a,e(l)===e(s[0])))break;s.push(l)}s.length>=3&&e(l)===e(s[0])&&(!i||Math.abs(xe(s))>Math.abs(xe(i)))&&(i=s)}return i}function fa(t,e,n,r){let i=fe(t,{exterior:n,interior:r},e).walls.filter(l=>l.exterior&&!l.free),o=i.length?Ay(i.map(l=>({a:l.a,b:l.b}))):null;if(!o)return null;let s=o.filter((l,a)=>{let c=o[(a+o.length-1)%o.length],u=o[(a+1)%o.length];return Math.abs((l[0]-c[0])*(u[1]-l[1])-(l[1]-c[1])*(u[0]-l[0]))>1e-6});return s.length>=3?Gd(s,n):null}function un(t,e){let n=$e(t),r=Le(t),i=n.w,[o,s]=[Math.max(0,e.a),Math.max(0,e.b)],l=n.u0-Math.max(0,e.u0),a=n.u1+Math.max(0,e.u1),c=(y,v)=>[y,v,r.y(v)],u=c(l,-o),d=c(a,-o),p=c(a,i+s),h=c(l,i+s),[f,g]=[st(t.pitch_a),st(t.pitch_b)],b=y=>[y,r.vr,r.rh];if(t.ends&&(t.shape==="gable"||t.shape==="hip"||t.shape==="halfhip")){let y=(n.u1-n.u0)/2,v=Math.min(y,Math.min(r.vr,i-r.vr)||i/2),w=Math.min(r.y(0),r.y(i)),x=w+(r.rh-w)*Math.min(.9,Math.max(.2,t.halfhip??.55)),k=f>1e-6?Math.min(r.vr,(x-t.eave_a)/f):r.vr,M=g>1e-6?Math.max(r.vr,i-(x-t.eave_b)/g):r.vr,A=Math.min(y-.1,(r.rh-x)/Math.max(.2,f)),T=[[0,r.y(0)],[r.vr,r.rh],[i,r.y(i)]],F=[[0,r.y(0)],[k,x],[M,x],[i,r.y(i)]],L=(j,Xt,zi)=>{if(j==="hip")return{upA:[],upB:[],ridge:b(Xt===l?n.u0+v*zi:n.u1-v*zi),profile:null};if(j==="halfhip"){let ab=b(Xt===l?n.u0+A:n.u1-A);return{upA:[[Xt,k,x]],upB:[[Xt,M,x]],ridge:ab,profile:F}}return{upA:[],upB:[],ridge:b(Xt),profile:T}},P=L(t.ends[0],l,1),N=L(t.ends[1],a,1),W=[[u,d,...N.upA,N.ridge,P.ridge,...[...P.upA].reverse()],[P.ridge,N.ridge,...[...N.upB].reverse(),p,h,...P.upB]],q=[[P.ridge,N.ridge]];for(let[j,Xt,zi]of[[P,u,h],[N,d,p]])j.profile===null?(W.push(j===P?[h,u,j.ridge]:[d,p,j.ridge]),q.push([Xt,j.ridge],[zi,j.ridge])):j.upA.length&&(W.push(j===P?[j.upB[0],j.upA[0],j.ridge]:[j.upA[0],j.upB[0],j.ridge]),q.push([j.upA[0],j.ridge],[j.upB[0],j.ridge]));let ke=j=>j.profile===null?[]:j.upA.length?[j.upA[0],j.upB[0]]:[j.ridge],At=[u,d,...ke(N),p,h,...[...ke(P)].reverse()];return{faces:W,rim:At,ridges:q,gable:T,endProfiles:[P.profile,N.profile]}}switch(t.shape){case"pent":return{faces:[[u,d,p,h]],rim:[u,d,p,h],ridges:[[p,h]],gable:[[0,r.y(0)],[i,r.y(i)]]};case"hip":case"pyramid":{let y=(n.u1-n.u0)/2,v=t.shape==="pyramid"?y:Math.min(y,Math.min(r.vr,i-r.vr)||i/2),w=b(n.u0+v),x=b(n.u1-v);return t.shape==="pyramid"?{faces:[[u,d,w],[d,p,w],[p,h,w],[h,u,w]],rim:[u,d,p,h],ridges:[[u,w],[h,w],[d,w],[p,w]],gable:null}:{faces:[[u,d,x,w],[w,x,p,h],[h,u,w],[d,p,x]],rim:[u,d,p,h],ridges:[[w,x],[u,w],[h,w],[d,x],[p,x]],gable:null}}case"halfhip":{let y=Math.min(r.y(0),r.y(i)),v=y+(r.rh-y)*Math.min(.9,Math.max(.2,t.halfhip??.55)),w=f>1e-6?Math.min(r.vr,(v-t.eave_a)/f):r.vr,x=g>1e-6?Math.max(r.vr,i-(v-t.eave_b)/g):r.vr,k=Math.min((n.u1-n.u0)/2-.1,(r.rh-v)/Math.max(.2,f)),M=b(n.u0+k),A=b(n.u1-k),T=[l,w,v],F=[l,x,v],L=[a,w,v],P=[a,x,v];return{faces:[[u,d,L,A,M,T],[M,A,P,p,h,F],[F,T,M],[L,P,A]],rim:[u,d,L,P,p,h,F,T],ridges:[[M,A],[T,M],[F,M],[L,A],[P,A]],gable:[[0,r.y(0)],[w,v],[x,v],[i,r.y(i)]]}}case"mansard":{let y=Nr(i,t.eave_a,t.eave_b,f,g),v=[l,y.vla,y.yla],w=[a,y.vla,y.yla],x=[l,i-y.vlb,y.ylb],k=[a,i-y.vlb,y.ylb],M=[l,y.vr,y.rh],A=[a,y.vr,y.rh];return{faces:[[u,d,w,v],[v,w,A,M],[M,A,k,x],[x,k,p,h]],rim:[u,d,w,A,k,p,h,x,M,v],ridges:[[M,A],[v,w],[x,k]],gable:[[0,r.y(0)],[y.vla,y.yla],[y.vr,y.rh],[i-y.vlb,y.ylb],[i,r.y(i)]]}}default:{let y=b(l),v=b(a);return{faces:[[u,d,v,y],[y,v,p,h]],rim:[u,d,v,p,h,y],ridges:[[y,v]],gable:[[0,r.y(0)],[r.vr,r.rh],[i,r.y(i)]]}}}}function Br(t,e,n){let r=null;for(let i of t.faces){if(!C([e,n],i.map(([p,h])=>[p,h])))continue;let[o,s]=i,l=i.slice(2).find(p=>Math.abs((s[0]-o[0])*(p[1]-o[1])-(s[1]-o[1])*(p[0]-o[0]))>1e-9);if(!l)continue;let a=[s[0]-o[0],s[2]-o[2],s[1]-o[1]],c=[l[0]-o[0],l[2]-o[2],l[1]-o[1]],u=[a[1]*c[2]-a[2]*c[1],a[2]*c[0]-a[0]*c[2],a[0]*c[1]-a[1]*c[0]];if(Math.abs(u[1])<1e-9)continue;let d=o[2]-(u[0]*(e-o[0])+u[2]*(n-o[1]))/u[1];r=r===null?d:Math.min(r,d)}return r}function Wr(t,e,n){let r=$e(e),i=t.floors.flatMap(d=>d.rooms.filter(p=>p.points.length>=3&&d.elevation+d.height>e.base+.05)),o=d=>d.some(p=>i.some(h=>C(p,h.points))),s=.35,l=[.15,.5,.85].map(d=>r.u0+(r.u1-r.u0)*d),a=[.15,.5,.85].map(d=>r.w*d),c=d=>d?0:n,u=(d,p)=>{let h=e.overhang_sides?.[d];return typeof h=="number"&&Number.isFinite(h)?Math.min(2,Math.max(0,h)):p};return{a:u("a",c(o(l.map(d=>r.at(d,-s))))),b:u("b",c(o(l.map(d=>r.at(d,r.w+s))))),u0:u("u0",c(o(a.map(d=>r.at(r.u0-s,d))))),u1:u("u1",c(o(a.map(d=>r.at(r.u1+s,d)))))}}var go=t=>Math.abs((t.x1-t.x0)*(t.z1-t.z0)),Zd=t=>t.shape==="flat"||t.shape==="parapet",dn=t=>Math.round(t*100)/100;function _o(t,e){let[n,r]=[(e.x0+e.x1)/2,(e.z0+e.z1)/2];return t.filter(o=>{if(o===e||o.dormer||o.open||Zd(o)||go(o)=s.x0&&n<=s.x1&&r>=s.z0&&r<=s.z1}).reduce((o,s)=>o===null||go(s){let[o,s]=e.at(i,e.w/2),[l,a]=Cr(t,o,s);return Br(n,l,a)??r.y(a)}}function ga(t,e){if(Zd(e))return e;let n=$e(e),r=Le(e).rh,i=Ty(t,n),o=i(n.u0)<=i(n.u1),[s,l]=o?[n.u0,n.u1]:[n.u1,n.u0],a=o?1:-1,c=l;for(let p=.5;p=r-.02){c=s+a*p;break}if(Math.abs(c-l)<.05)return e;let u={...e},d=l===n.u1;return e.axis==="x"?u[d?"x1":"x0"]=c:u[d?"z1":"z0"]=c,u}var _a=.14,qd=t=>t.shape==="flat"||t.shape==="parapet";function ba(t,e){return!t.open&&Math.min(t.base,t.eave_a,t.eave_b)a+i||pu+i||s.points&&s.points.length>=3&&!C([e,n],s.points))continue;let[h,f]=Cr(s,e,n),g=Math.max(0,s.overhang??r),b=qd(s)?null:Br(un(s,{u0:g,u1:g,a:g,b:g}),h,f);o.push((b??Le(s).y(f))-_a)}return o.length?Math.max(...o):null}function ya(t,e,n){let r=[],i=e+n+_a;for(let o of t.settings.roof.sections??[]){if(o.open||qd(o)||o.shape==="mansard")continue;let s=$e(o),l=Le(o),[a,c]=[st(o.pitch_a),st(o.pitch_b)],u=[];a>1e-6&&u.push((i-o.eave_a)/a),o.shape==="gable"&&c>1e-6&&u.push(s.w-(i-o.eave_b)/c);for(let d of u)d<=.01||d>=s.w-.01||o.shape==="gable"&&Math.abs(l.y(d)-i)>1e-6||r.push([s.at(s.u0,d),s.at(s.u1,d)])}return r}function va(t,e,n,r,i){let o=[];for(let l of[.2,.5,.8])for(let a of[.2,.5,.8])o.push([e+(r-e)*l,n+(i-n)*a]);let s=t.floors.filter(l=>l.rooms.some(a=>a.points.length>=3&&o.some(c=>C(c,a.points)))).map(l=>l.elevation+l.height);return s.length?Math.max(...s):null}function wa(t,e){let n=t.floors.filter(a=>a.rooms.length>0).sort((a,c)=>a.elevation-c.elevation),r=n.filter(a=>a.elevationu.rooms.some(d=>d.points.length>=3&&a.some(p=>C(p,d.points))));if(c)return c}return r.at(-1)??n[0]}var kt=t=>Math.round(t*1e3)/1e3;function ka(t,e=n=>`roof_${n+1}`){let n=t.settings.roof?.pitch??35,r=t.settings.wall_exterior,i=t.floors.filter(a=>a.rooms.some(c=>c.points.length>=3)).sort((a,c)=>c.elevation-a.elevation),o=[],s=[],l=(a,c)=>a.some(u=>C(c,u.points));for(let a of i){let c=a.rooms.filter(b=>b.points.length>=3),u=[...new Set(c.flatMap(b=>b.points.map(y=>kt(y[0]))))].sort((b,y)=>b-y),d=[...new Set(c.flatMap(b=>b.points.map(y=>kt(y[1]))))].sort((b,y)=>b-y),p=d.slice(0,-1).map((b,y)=>u.slice(0,-1).map((v,w)=>{let x=[(u[w]+u[w+1])/2,(d[y]+d[y+1])/2];return l(c,x)&&!l(s,x)})),h=p.map(b=>b.map(()=>!1)),f=(b,y)=>p[y][b]&&!h[y][b],g=a.elevation+a.height;for(let b=0;bf(y+F,w+1)).every(Boolean);)w++;for(let T=b;T<=w;T++)for(let F=y;F<=v;F++)h[T][F]=!0;let[x,k]=[u[y]-r,u[v+1]+r],[M,A]=[d[b]-r,d[w+1]+r];Math.min(k-x,A-M)<.8||o.push({id:e(o.length),x0:kt(x),z0:kt(M),x1:kt(k),z1:kt(A),shape:"gable",axis:k-x>=A-M?"x":"z",eave_a:kt(g),eave_b:kt(g),pitch_a:n,pitch_b:n,base:kt(g),overhang:null})}s.push(...c)}return o}var Ee=Math.PI/180,Ge=(t,e)=>[t[0]-e[0],t[1]-e[1],t[2]-e[2]],hn=(t,e)=>t[0]*e[0]+t[1]*e[1]+t[2]*e[2],Vn=t=>Math.hypot(t[0],t[1],t[2]),pn=t=>{let e=Vn(t)||1;return[t[0]/e,t[1]/e,t[2]/e]},Yd=(t,e)=>[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]],Ze=t=>Math.round(t*100)/100,Kr=([t,e],n)=>(Math.atan2(t,-e)/Ee-n+720)%360;var Jd=.25;function Qd(t,e,n,r,i,o,s){let l=i-n>=o-r,a=l?i-n:o-r;return{key:`${t}:top`,section:e,side:"top",flat:!0,o:[n,s,r],eu:l?[1,0,0]:[0,0,1],es:l?[0,0,1]:[1,0,0],n:[0,1,0],lu:a,ls:l?o-r:i-n,pitch:0,span:()=>[0,a],facing:l?[0,1]:[1,0]}}function eh(t,e){let n=pn(Yd(t,e));return n[1]<0?[-n[0],-n[1],-n[2]]:n}var th=t=>{let e=pn([-t[0],0,-t[2]]);return[e[0],e[2]]};function xt(t,e,n,r,i,o,s,l){let a=pn(Ge(i,r)),c=pn(Ge(o,r));return{key:t,section:e,side:n,flat:!1,o:r,eu:a,es:c,n:eh(a,c),lu:Vn(Ge(i,r)),ls:Vn(Ge(o,r)),pitch:s,span:l,facing:th(c)}}function Xd(t,e,n,r,i,o){let s=Vn(Ge(i,r));if(s<.3)return null;let l=pn(Ge(i,r)),a=Ge(o,r),c=a[0]*l[0]+a[1]*l[1]+a[2]*l[2],u=[a[0]-l[0]*c,a[1]-l[1]*c,a[2]-l[2]*c],d=Vn(u);if(d<.3)return null;let p=pn(u),h=f=>{let g=Math.min(1,Math.max(0,f/d));return[c*g,s-(s-c)*g]};return{key:t,section:e,side:n,flat:!1,o:r,eu:l,es:p,n:eh(l,p),lu:s,ls:d,pitch:Math.atan2(p[1],Math.hypot(p[0],p[2]))/Ee,span:h,facing:th(p)}}function zy(t,e){let n=$e(t),r=Le(t),i=(v,w,x)=>{let[k,M]=n.at(v,w);return[k,x,M]},[o,s]=[Math.max(0,e.a),Math.max(0,e.b)],l=n.u0-Math.max(0,e.u0),a=n.u1+Math.max(0,e.u1),c=a-l,u=r.y(-o),d=r.y(n.w+s);if(t.shape==="flat"||t.shape==="parapet"){let[v,w]=[n.at(l,-o),n.at(a,n.w+s)];return[Qd(t.id,t.id,Math.min(v[0],w[0]),Math.min(v[1],w[1]),Math.max(v[0],w[0]),Math.max(v[1],w[1]),t.eave_a+Jd)]}if(t.shape==="pent")return[xt(`${t.id}:a`,t.id,"a",i(l,-o,u),i(a,-o,u),i(l,n.w+s,d),t.pitch_a,()=>[0,c])];if(t.shape==="mansard")return Py(t,n,l,a,o,s);let p=t.shape==="hip"||t.shape==="pyramid",h=(n.u1-n.u0)/2,f=t.shape==="pyramid"?h:p?Math.min(h,Math.min(r.vr,n.w-r.vr)||n.w/2):0,g=p?n.u0+f-l:0,b=p?a-(n.u1-f):0,y=[];if(r.vr>.3){let v=Math.hypot(r.vr+o,r.rh-u);y.push(xt(`${t.id}:a`,t.id,"a",i(l,-o,u),i(a,-o,u),i(l,r.vr,r.rh),t.pitch_a,w=>[g*(w/v),c-b*(w/v)]))}if(n.w-r.vr>.3){let v=Math.hypot(n.w+s-r.vr,r.rh-d);y.push(xt(`${t.id}:b`,t.id,"b",i(a,n.w+s,d),i(l,n.w+s,d),i(a,r.vr,r.rh),t.pitch_b,w=>[b*(w/v),c-g*(w/v)]))}if(p){let v=Xd(`${t.id}:c`,t.id,"c",i(l,n.w+s,d),i(l,-o,u),i(n.u0+f,r.vr,r.rh)),w=Xd(`${t.id}:d`,t.id,"d",i(a,-o,u),i(a,n.w+s,d),i(n.u1-f,r.vr,r.rh));y.push(...[v,w].filter(x=>x!==null))}return y}function Py(t,e,n,r,i,o){let s=Nr(e.w,t.eave_a,t.eave_b,st(t.pitch_a),st(t.pitch_b)),l=(f,g)=>{let[b,y]=e.at(f,g);return[b,s.y(g),y]},a=r-n,c=()=>[0,a],u=(f,g)=>Math.atan2(f,g)/Ee,d=[],[p,h]=[e.w+o,e.w-s.vlb];return s.vla+i>.3&&d.push(xt(`${t.id}:a`,t.id,"a",l(n,-i),l(r,-i),l(n,s.vla),t.pitch_a,c)),s.vr-s.vla>.3&&d.push(xt(`${t.id}:au`,t.id,"a",l(n,s.vla),l(r,s.vla),l(n,s.vr),u(s.rh-s.yla,s.vr-s.vla),c)),s.vlb+o>.3&&d.push(xt(`${t.id}:b`,t.id,"b",l(r,p),l(n,p),l(r,h),t.pitch_b,c)),h-s.vr>.3&&d.push(xt(`${t.id}:bu`,t.id,"b",l(r,h),l(n,h),l(r,s.vr),u(s.rh-s.ylb,h-s.vr),c)),d}function xa(t){return t.floors.filter(n=>n.rooms.some(r=>r.points.length>=3)).sort((n,r)=>r.elevation-n.elevation)[0]??null}function Z(t){let e=t.settings.roof;if(!e||e.type==="none")return[];if(e.type==="custom")return(e.sections??[]).flatMap(w=>zy(w,Wr(t,w,w.overhang??e.overhang)));let n=xa(t);if(!n)return[];let r=n.rooms.flatMap(w=>w.points.map(x=>x[0])),i=n.rooms.flatMap(w=>w.points.map(x=>x[1])),o=t.settings.wall_exterior+e.overhang,[s,l]=[Math.min(...r)-o,Math.max(...r)+o],[a,c]=[Math.min(...i)-o,Math.max(...i)+o],u=n.elevation+n.height;if(e.type==="flat")return[Qd("main",null,s,a,l,c,u+Jd)];let d=l-s>=c-a,p=e.ridge==="short"?!d:d,h=(p?c-a:l-s)/2,f=h*Math.tan(e.pitch*Ee),g=(w,x,k)=>p?[w,u+k,(a+c)/2+x]:[(s+l)/2+x,u+k,w],[b,y]=p?[s,l]:[a,c],v=()=>[0,y-b];return[xt("main:a",null,"a",g(b,-h,0),g(y,-h,0),g(b,0,f),e.pitch,v),xt("main:b",null,"b",g(b,h,0),g(y,h,0),g(b,0,f),e.pitch,v)]}function qe(t,e){let n=[];for(let r of t.floors.filter(i=>!e||i.id===e)){let{walls:i}=fe(r.rooms,{exterior:t.settings.wall_exterior,interior:t.settings.wall_interior},r.walls??[]);for(let o of i){if(!o.exterior&&!o.free)continue;let[s,l]=[o.b[0]-o.a[0],o.b[1]-o.a[1]],a=Math.hypot(s,l);if(a<1.2)continue;let[c,u]=[l/a,-s/a],d=Math.min(r.height,o.height??r.height,o.heightEnd??1/0),p=(h,f,g,b)=>n.push({key:h,section:null,side:"top",flat:!1,o:f,eu:g,es:[0,1,0],n:b,lu:a,ls:d,pitch:90,span:()=>[0,a],facing:[b[0],b[2]],wall:{floorId:r.id}});p(`wall:${r.id}:${o.id}`,[o.a[0]+c*o.right,r.elevation,o.a[1]+u*o.right],[s/a,0,l/a],[c,0,u]),o.free&&p(`wall:${r.id}:${o.id}:back`,[o.b[0]-c*o.left,r.elevation,o.b[1]-u*o.left],[-s/a,0,-l/a],[-c,0,-u])}}return n}var Ne="ground";function bo(t){let e=t.floors.filter(n=>n.rooms.some(r=>r.points.length>=3)).sort((n,r)=>n.elevation-r.elevation);return e.find(n=>n.elevation>-.5)??e[0]??t.floors[0]??null}function yo(t,e){let n=(e.rotation??0)*Ee,r=[Math.cos(n),0,Math.sin(n)],i=[-Math.sin(n),0,Math.cos(n)],o=bo(t),s=r[0]*e.u+i[0]*e.v,l=r[2]*e.u+i[2]*e.v,a=o?o.elevation+(e.base!=null?e.base:gu(o,s,l)):e.base??0;return{key:Ne,section:null,side:"top",flat:!0,o:[0,a,0],eu:r,es:i,n:[0,1,0],lu:1e4,ls:1e4,pitch:0,span:()=>[-1e4,1e4],facing:[i[0],i[2]],unbounded:!0}}function Se(t,e,n=Z(t)){return e.face===Ne?yo(t,e):e.face.startsWith("wall:")?qe(t,e.face.split(":")[1]).find(r=>r.key===e.face)??null:n.find(r=>r.key===e.face)??null}var vo=1.13,Ur=1.72,Ye=.025,at=.07;function fn(t){let e=t.module_w||vo,n=t.module_h||Ur;return t.portrait===!1?[n,e]:[e,n]}function Gr(t){return t.layout?.length?t.layout.map(e=>Math.max(0,Math.min(60,Math.round(e)))):Array.from({length:Math.max(1,t.rows)},()=>Math.max(1,t.cols))}function $a(t,e){return t.flat?Math.min(45,Math.max(0,e.tilt??15))*Ee:t.wall?Math.min(90,Math.max(0,e.tilt??0))*Ee:Math.min(45,Math.max(0,e.tilt??0))*Ee}function Zr(t,e){let[,n]=fn(e),r=$a(t,e);return t.wall?n*Math.cos(r)+Ye:!t.flat&&r<.001?n+Ye:t.flat&&e.rack==="ew"?n*Math.cos(r)+.08:n*Math.cos(r)+Math.max(.3,2*n*Math.sin(r))}function Kn(t,e){let[n,r]=fn(e),i=Gr(e),o=Math.max(1,...i);return[o*n+(o-1)*Ye,(i.length-1)*Zr(t,e)+r*Math.cos($a(t,e))]}var Dy=t=>t.flat&&!t.unbounded&&!t.wall;function nh(t,e){if(!Dy(t)||!e.rotation)return null;let n=e.rotation*Ee,[r,i]=Kn(t,e);return{cos:Math.cos(n),sin:Math.sin(n),u:e.u+r/2,s:e.v+i/2}}function Xe(t,e,n=!1){let[r,i]=fn(e),o=$a(t,e),s=i*Math.cos(o),l=Zr(t,e),a=Gr(e),c=Math.max(1,...a),u=new Set(e.skip??[]),d=nh(t,e),p=(b,y)=>d?[d.u+(b-d.u)*d.cos-(y-d.s)*d.sin,d.s+(b-d.u)*d.sin+(y-d.s)*d.cos]:[b,y],h=(b,y,v)=>{let[w,x]=p(b,y);return[0,1,2].map(k=>t.o[k]+t.eu[k]*w+t.es[k]*x+t.n[k]*v)},f=(b,y)=>{let[v,w]=p(b,y);if(t.unbounded)return!0;if(w<-1e-6||w>t.ls+1e-6)return!1;let[x,k]=t.span(w);return v>=x-1e-6&&v<=k+1e-6},g=[];return a.forEach((b,y)=>{let v=e.align==="right"?c-b:e.align==="center"?(c-b)/2:0;for(let w=0;w.001?s:i);if([[M,T],[A,T],[A,F],[M,F]].every(([L,P])=>f(L,P)))if(t.wall&&o>.001){let L=at+i*Math.sin(o),[P,N]=e.flip?[L,at]:[at,L],W=[h(M,T,P),h(A,T,P),h(A,F,N),h(M,F,N)],q=e.flip?T:F;g.push({corners:W,posts:[M+.05,A-.05].map(ke=>[h(ke,q,0),h(ke,q,L)]),cell:x,skipped:k})}else if(!t.flat&&o>.001){let L=at+i*Math.sin(o),P=[h(M,T,at),h(A,T,at),h(A,F,L),h(M,F,L)];g.push({corners:P,posts:[M+.05,A-.05].map(N=>[h(N,F,0),h(N,F,L)]),cell:x,skipped:k})}else if(!t.flat)g.push({corners:[h(M,T,at),h(A,T,at),h(A,F,at),h(M,F,at)],posts:[],cell:x,skipped:k});else{let P=.15+i*Math.sin(o),N=e.rack==="ew"&&y%2===1?!e.flip:!!e.flip,[W,q]=N?[F,T]:[T,F],ke=[h(M,W,.15),h(A,W,.15),h(A,q,P),h(M,q,P)],At=[M+.05,A-.05].flatMap(j=>[[h(j,W,0),h(j,W,.15)],[h(j,q,0),h(j,q,P)]]);g.push({corners:ke,posts:At,cell:x,skipped:k})}}}),g}function mt(t,e){if(t.unbounded)return{u:e.u,v:e.v};let[n,r]=Kn(t,e),i=nh(t,e);if(i){let[s,l]=[(n*Math.abs(i.cos)+r*Math.abs(i.sin))/2,(n*Math.abs(i.sin)+r*Math.abs(i.cos))/2],a=(d,p,h)=>Math.floor(Math.max(p,Math.min(d,h-p))*100+1e-6)/100,[c,u]=[e.u+n/2,e.v+r/2];return{u:Math.round((a(c,s,t.lu)-n/2)*100)/100,v:Math.round((a(u,l,t.ls)-r/2)*100)/100}}let o=s=>Math.floor(s*100+1e-6)/100;return{u:o(Math.min(Math.max(0,e.u),Math.max(0,t.lu-n))),v:o(Math.min(Math.max(0,e.v),Math.max(0,t.ls-r)))}}function qr(t,e){let[n,r]=Kn(t,e),[i,o]=[e.u+n/2,e.v+r/2];return[t.o[0]+t.eu[0]*i+t.es[0]*o,t.o[2]+t.eu[2]*i+t.es[2]*o]}var wo=.78,Yr=1.18,mn=t=>({id:t.id,face:t.face,u:t.u,v:t.v,rows:1,cols:1,portrait:!0,module_w:t.w||wo,module_h:t.h||Yr});function Sa(t,e){let n=Xe(t,mn(e))[0];if(!n)return null;let r=i=>[i[0]-t.n[0]*.05,i[1]-t.n[1]*.05,i[2]-t.n[2]*.05];return n.corners.map(r)}var jr={brick:{w:.5,d:.5,h:1},round:{w:.4,d:.4,h:1},wide:{w:1,d:.5,h:1},steel:{w:.2,d:.2,h:1.2}};function gn(t){let e=t.shape??"brick",n=jr[e]??jr.brick;return{shape:e,w:t.w||n.w,d:t.d||n.d,h:t.h||n.h}}function $t(t,e){let{w:n,d:r}=gn(t),i=e&&!e.flat?Math.cos(e.pitch*Ee):1;return{id:t.id,face:t.face,u:t.u,v:t.v,rows:1,cols:1,portrait:!0,module_w:n,module_h:r/Math.max(.2,i),tilt:0}}function Ma(t,e){let n=$t(e,t),[r,i]=[n.module_w,n.module_h],o=(u,d)=>[t.o[0]+t.eu[0]*u+t.es[0]*d,t.o[1]+t.eu[1]*u+t.es[1]*d,t.o[2]+t.eu[2]*u+t.es[2]*d],[s,l]=[o(e.u+r/2,e.v),o(e.u+r/2,e.v+i)],a=o(e.u+r/2,e.v+i/2),c=u=>{let d=Math.hypot(u[0],u[2])||1;return[u[0]/d,u[2]/d]};return{center:[a[0],a[2]],along:c(t.eu),across:c(t.es),low:Math.min(s[1],l[1]),high:Math.max(s[1],l[1])}}function Ra(t,e){let[n]=fn(e);return Ze((t.lu-(e.cols*n+(e.cols-1)*Ye))/2)}var Xr=.4;function jn(t,e){let n={id:e,face:t.key,u:0,v:0,rows:1,cols:1,portrait:!0,tilt:t.flat?15:null,flip:!1,entity:null,look:"black"},[r]=fn(n),[i,o]=t.span(t.ls/2);for(n.cols=Math.max(1,Math.floor((o-i-2*Xr+Ye)/(r+Ye))),n.rows=Math.max(1,Math.min(4,Math.floor((t.ls-2*Xr)/Zr(t,n))));n.cols>1&&Xe(t,{...n,u:Ra(t,n),v:Xr}).lengthl.lu*(1.3+Math.cos((Kr(l.facing,r)-180)*Math.PI/180)),o=qe(t,n).sort((l,a)=>i(a)-i(l))[0];if(!o)return null;let s={...jn(o,e),portrait:!1,rows:1};return s.cols=Math.max(1,Math.floor((o.lu-.8+Ye)/(Ur+Ye))),s.u=Ze((o.lu-(s.cols*Ur+(s.cols-1)*Ye))/2),s.v=Ze(Math.max(0,o.ls-vo-.3)),s}function Jr(t,e){let n=t.floors.flatMap(o=>o.rooms.flatMap(s=>s.points)),r=n.length?Math.max(...n.map(o=>o[0]))+3:0,i=n.length?Math.min(...n.map(o=>o[1])):0;return{id:e,face:Ne,u:Ze(r),v:Ze(i),rows:2,cols:4,portrait:!0,tilt:25,flip:!0,rotation:(t.settings.north??0)||0,look:"black",entity:null}}function Qr(t,e,n){let r=yo(t,e),[i,o]=Kn(r,e),[s,l]=[e.u+i/2,e.v+o/2],a=[r.eu[0]*s+r.es[0]*l,r.eu[2]*s+r.es[2]*l],c=n*Ee,u=a[0]*Math.cos(c)+a[1]*Math.sin(c)-i/2,d=a[0]*-Math.sin(c)+a[1]*Math.cos(c)-o/2;return{u:Ze(u),v:Ze(d),rotation:(Math.round(n)%360+360)%360}}function ei(t,e){let[n,r]=t.span(t.ls/2);return{id:e,face:t.key,u:Ze((n+r-wo)/2),v:Ze(Math.max(0,Math.min(t.ls-Yr,t.ls*.45-Yr/2))),w:null,h:null,cover:null,contact:null,tilt:null}}function ti(t,e){let n=jr.brick,[r,i]=t.span(t.ls*.8),o=$t({id:e,face:t.key,u:0,v:0},t).module_h;return{id:e,face:t.key,u:Ze((r+i-n.w)/2),v:Ze(Math.max(0,Math.min(t.ls-o,t.ls*.8-o/2))),shape:"brick",w:null,d:null,h:null}}function Un(t,e){let[n,r]=[e[0]-t.o[0],e[1]-t.o[2]],[i,o,s,l]=[t.eu[0],t.eu[2],t.es[0],t.es[2]],a=i*l-o*s;if(Math.abs(a)<1e-9)return null;let c=(n*l-r*s)/a,u=(i*r-o*n)/a;if(u<0||u>t.ls)return null;let[d,p]=t.span(u);return c>=d&&c<=p?{u:c,s:u}:null}function Aa(t,e){let n=null;for(let r of t){if(r.wall){let[s,l]=[e[0]-r.o[0],e[1]-r.o[2]],a=s*r.eu[0]+l*r.eu[2],c=s*r.n[0]+l*r.n[2],u=a>=0&&a<=r.lu;if(u&&c>=-.05&&c<=.35)return{face:r,u:a,s:Number.NaN};u&&c>.35&&c<=.8&&!n&&(n={face:r,u:a,s:Number.NaN,y:-1/0});continue}let i=Un(r,e);if(!i)continue;let o=r.o[1]+r.es[1]*i.s;(!n||o>n.y)&&(n={face:r,...i,y:o})}return n&&{face:n.face,u:n.u,s:n.s}}function xo(t,e,n){let r=hn(n,t.n);if(Math.abs(r)<1e-6)return null;let i=hn(Ge(t.o,e),t.n)/r;if(i<=0)return null;let o=Ge([e[0]+n[0]*i,e[1]+n[1]*i,e[2]+n[2]*i],t.o);return{t:i,u:hn(o,t.eu),s:hn(o,t.es)}}function Fa(t,e,n){if(t.unbounded)return!0;if(n<0||n>t.ls)return!1;let[r,i]=t.span(n);return e>=r&&e<=i}function Ta(t,e,n,r){return Xe(t,e).some(o=>{let s=o.corners.map(c=>{let u=Ge(c,t.o);return[hn(u,t.eu),hn(u,t.es)]}),l=s.map(c=>c[0]),a=s.map(c=>c[1]);return n>=Math.min(...l)-.05&&n<=Math.max(...l)+.05&&r>=Math.min(...a)-.05&&r<=Math.max(...a)+.05})}var Iy=["n","ne","e","se","s","sw","w","nw"],za=(t,e)=>Iy[Math.round(Kr(t.facing,e)/45)%8];function ni(t,e){let n=r=>{if(r.flat)return r.lu*r.ls*.8;let i=Math.cos((Kr(r.facing,e)-180)*Math.PI/180);return r.lu*r.ls*(1.2+i)};return[...t].sort((r,i)=>n(i)-n(r))[0]??null}var sh=["kitchen_row","kitchen_l","bath","bedroom","living","dining","office","kids","hall"],rh={kitchen_row:{rows:[["back","start",["fridge","kitchen_tall",["kitchen",[.9,.62,.92]],"sink","dishwasher","stove",["kitchen",[.6,.62,.92]]]],["back","start",[["kitchen_wall",[1.2,.35,.7]]]]],spots:[[["table",[1.2,.8,.75]],.5,.72,0],["lamp_pendant",.5,.72,0],["lamp_ceiling",.5,.3,0]]},kitchen_l:{rows:[["back","start",["fridge",["kitchen",[.9,.62,.92]],"sink","dishwasher","stove"]],["right","start",[["kitchen",[.9,.62,.92]],["kitchen",[.6,.62,.92]],"kitchen_tall"]],["back","start",[["kitchen_wall",[1.2,.35,.7]]]]],spots:[["table",.4,.68,0],["bar_stool",.72,.86,180],["lamp_ceiling",.5,.35,0]]},bath:{rows:[["back","center",["washbasin"]],["back","end",["wc"]],["front","start",["bathtub"]],["left","start",["washer"]]],spots:[["lamp_downlight",.5,.5,0]]},bedroom:{rows:[["back","center",["nightstand","bed","nightstand"]],["left","center",[["wardrobe",[2,.6,2.1]]]],["front","end",["dresser"]]],spots:[["lamp_ceiling",.5,.55,0]]},living:{rows:[["back","center",["tv_board"]],["right","start",["shelf"]]],spots:[["sofa",.5,.72,180],["coffee_table",.5,.52,0],[["rug",[2.2,1.6,.01]],.5,.55,0],["armchair",.14,.5,270],["lamp_floor",.86,.8,0],["plant",.9,.12,0],["lamp_ceiling",.5,.45,0]]},dining:{rows:[["back","center",["sideboard"]]],spots:[["table",.5,.55,0],["chair",.4,.35,0],["chair",.6,.35,0],["chair",.4,.75,180],["chair",.6,.75,180],["lamp_pendant",.5,.55,0]]},office:{rows:[["back","center",["desk"]],["left","center",["shelf","shelf"]]],spots:[["office_chair",.5,.38,180],["lamp_ceiling",.5,.55,0]]},kids:{rows:[["left","start",[["bed",[.9,2,.8]]]],["back","end",[["desk",[1.2,.6,.75]]]],["right","end",["shelf"]]],spots:[[["rug",[1.6,1.2,.01]],.55,.6,0],["lamp_ceiling",.5,.5,0]]},hall:{rows:[["left","start",["coat_rack"]]],spots:[["lamp_downlight",.5,.3,0],["lamp_downlight",.5,.7,0]]}},ih=t=>typeof t=="string"?t:t[0],$o=t=>typeof t=="string"?nt[t]:t[1],Gn=.05,Oy=.02,oh=t=>Math.round(t*1e3)/1e3;function Hy(t,e,n,r){switch(e){case"back":return{x:t.x0+n,z:t.z0+r,turn:0};case"right":return{x:t.x1-r,z:t.z0+n,turn:90};case"front":return{x:t.x1-n,z:t.z1-r,turn:180};case"left":return{x:t.x0+r,z:t.z1-n,turn:270}}}function ah(t,e,n){let r=de(t.points),i=r.x1-r.x0,o=r.z1-r.z0,s=[],l=(a,c,u,d,[p,h,f])=>{s.push({id:n(),type:a,x:oh(c),z:oh(u),rotation:d,w:p,d:h,h:f,variant:null,entity:null,power:null})};for(let[a,c,u]of rh[e].rows){let d=a==="back"||a==="front"?i:o,p=0,h=[];for(let g of u){if(p+$o(g)[0]>d-.1)break;h.push(g),p+=$o(g)[0]}let f=c==="start"?Gn:c==="end"?d-p-Gn:(d-p)/2;for(let g of h){let b=$o(g),y=Hy(r,a,f+b[0]/2,b[1]/2+Oy);l(ih(g),y.x,y.z,y.turn,b),f+=b[0]}}for(let[a,c,u,d]of rh[e].spots){let p=$o(a),h=(b,y,v)=>Math.min(v,Math.max(y,b)),f=h(r.x0+i*c,r.x0+p[0]/2+Gn,r.x1-p[0]/2-Gn),g=h(r.z0+o*u,r.z0+p[1]/2+Gn,r.z1-p[1]/2-Gn);l(ih(a),f,g,d,p)}return s}var Ly=30*Math.PI/180,lh=.05;function Pa(t){let e=t.points.length;return t.points.map((n,r)=>{let i=t.points[(r+1)%e];return Math.hypot(i[0]-n[0],i[1]-n[1])})}function ri(t){return Pa(t).reduce((e,n)=>e+n,0)}function Cy(t,e){let n=Pa(t),r=0;for(let i=0;ih+f,0);if(i<3||!(o>0)||!(n>0))return null;let s=Math.min(n,o),l=(e%o+o)%o,a=0,c=0;for(;a=c+r[a];)c+=r[a],a++;let u=l-c,d=s,p=[];for(let h=0;h<=i&&d>1e-9;h++){let f=r[a]-u,g=Math.min(d,f);g>1e-9&&p.push({edge:a,t0:u,t1:u+g}),d-=g,u=0;let b=(a+1)%i;if(d>1e-9&&Ny(t,a)>Ly)break;a=b}for(;p.length>1&&p[0].t1-p[0].t01&&p[p.length-1].t1-p[p.length-1].t0({edge:h.edge,offset:(h.t0+h.t1)/2,width:h.t1-h.t0})):null}function Zn(t,e){let n=e[0];return n?{from:Cy(t,n.edge)+n.offset-n.width/2,width:e.reduce((r,i)=>r+i.width,0)}:null}function jt(t,e){return e.front?t.filter(n=>n.front===e.front):[e]}function Ia(t,e){let n=t.points.length,r=1/0,i=0,o=0;for(let s=0;sI("opening")){let s=Da(e,r,i);if(!s)return null;let l=jt(t,n),a=new Set(l.map(h=>h.id)),c=s.length>1?l[0].front??`front-${l[0].id}`:null,u=s.map((h,f)=>({...n,id:f===0?l[0].id:o(),edge:h.edge,offset:h.offset,width:h.width,front:c})),d=[],p=!1;for(let h of t){if(!a.has(h.id)){d.push(h);continue}p||(d.push(...u),p=!0)}return d}var La=globalThis,Oa=La.__nextfloorBuiltin?.de??{},Ha=La.__nextfloorBuiltin?.en??{};La.__nextfloorBuiltin??={de:Oa,en:Ha};var By=()=>typeof $=="object"&&$||{},Wy=globalThis,Vy=Wy.__nextfloorTexts??=new Map;function Ky(t){let e=t.toLowerCase().split("-")[0];return e!=="de"&&e!=="en"&&e in By()?e:void 0}function ch(t){let e=Ky(t),n=e===void 0?void 0:Vy.get(e);return n instanceof Promise?void 0:n}function So(t,e){return ch(t)?.[e]}function we(t,e,n={}){let r=t?.language??navigator.language,i=r.startsWith("de"),o=(i?void 0:ch(r)?.[e])??(i?Oa:Ha)[e]??Ha[e]??Oa[e]??e;for(let[s,l]of Object.entries(n))o=o.replace(`{${s}}`,String(l));return o}function K(t,e,n=2){return e.toLocaleString(t?.language??void 0,{maximumFractionDigits:n})}var jy=new Set(["on","home","open","true","active","playing","heat","heating"]);function uh(t,e){let n=e.show_when;if(!n?.entity||!t)return!0;let r=t.states[n.entity];if(!r||Ie(r))return!0;let i=String(r.state).toLowerCase(),o=(n.state??"").split(",").map(l=>l.trim().toLowerCase()).filter(Boolean),s=o.length?o.includes(i):jy.has(i)||Number.isFinite(Number(i))&&Number(i)>0;return n.invert?!s:s}function Ae(t,e){if(!vt(e))return we(t,`furn_${e}`);let n=G(e);return n?Je(n,e,t?.language??navigator.language):we(t,"pack_missing_item")}function Je(t,e,n){return t.name[n.split("-")[0]]??So(n,e)??Jc(t,n)}function Be(t,e){return So(e,`packname:${t.id}`)??Qc(t,e)}function dh(t,e){return t.name[e.split("-")[0]]??So(e,`color:${t.id}`)??t.name.en??Object.values(t.name)[0]}var oi=t=>t&&t!=="none"?t:null,si=(t,e)=>{e&&!t.includes(e)&&t.push(e)},Ca=t=>new Map(t.floors.flatMap(e=>e.furniture.filter(n=>n.type==="meter").map(n=>[n.id,n])));function _n(t,e){if(!t.energy.advanced||e.type!=="meter"||!e.parent_meter)return null;let n=Ca(t),r=new Set([e.id]);for(let i=n.get(e.parent_meter);i;i=n.get(i.parent_meter??"")){if(r.has(i.id))return null;r.add(i.id)}return n.has(e.parent_meter)?e.parent_meter:null}function qn(t){return new Set([...Ca(t).values()].filter(e=>_n(t,e)).map(e=>e.id))}function ai(t,e){return!t.energy.advanced||!e.parent_meter?null:qn(t).has(e.parent_meter)?e.parent_meter:null}function hh(t,e,n){if(n.type!=="meter"||n.id===e.id)return!1;let r=Ca(t),i=new Set;for(let o=n;o&&!i.has(o.id);o=r.get(o.parent_meter??"")){if(o.id===e.id)return!1;i.add(o.id)}return!0}function Ro(t,e=n=>oi(n.power)){let n={grid:null,gridExport:null,solar:[],battery:[],charge:[],batteries:[],soc:[]};for(let r of t.floors.flatMap(i=>i.furniture)){let i=e(r),o=r.type==="meter"?_n(t,r):null;if(o)(n.subMeters??=[]).push({id:r.id,parent:o,power:i,invert:!!r.meter_invert,floors:r.meter_floors??[],solar:[],batteries:[]});else if(r.type==="meter")n.grid??=i,n.gridExport??=oi(r.export);else if(r.type==="inverter")si(n.solar,i);else if(r.type==="home_battery"){let s=oi(r.charge);si(n.battery,i),si(n.charge,s),si(n.soc,oi(r.soc)),(i||s)&&n.batteries.push({power:i,charge:s})}}for(let r of n.subMeters?t.floors.flatMap(i=>i.furniture):[]){let i=r.type==="inverter"||r.type==="home_battery"?n.subMeters?.find(l=>l.id===ai(t,r)):void 0,o=i?e(r):null;i&&r.type==="inverter"&&si(i.solar,o);let s=oi(r.charge);i&&r.type==="home_battery"&&(o||s)&&i.batteries.push({power:o,charge:s})}return n}function Uy(t){for(let e of t.floors){let n=e.furniture.find(r=>r.type==="meter"&&!_n(t,r));if(n)return{floor_id:e.id,x:n.x,z:n.z}}return t.energy.meter}var Gy=/(phase|_l[123]\b|_[abc]$|today|daily|heute)/,Zy=/_?(energy|energie|total|today|daily|kwh|import|export|consumption|production)/g;function Mo(t,e,n="power"){let r=e?t.entities?.[e]?.device_id:void 0;if(!e||!r)return null;let i=Object.keys(t.states).filter(l=>l.startsWith("sensor.")&&t.entities?.[l]?.device_id===r&&t.states[l]?.attributes.device_class===n);if(i.length<=1)return i[0]??null;let o=i.filter(l=>!Gy.test(l)),s=e.replace(/^sensor\./,"").replace(Zy,"");return o.find(l=>s&&l.includes(s))??o[0]??i[0]}function ph(t,e){let n={},r=(i,o)=>{o&&!n[i]&&(n[i]=o)};for(let i of e.energy_sources??[])if(i.type==="grid")r("grid",Mo(t,i.flow_from?.[0]?.stat_energy_from??i.flow_to?.[0]?.stat_energy_to));else if(i.type==="solar")r("solar",Mo(t,i.stat_energy_from));else if(i.type==="battery"){let o=i.stat_energy_from??i.stat_energy_to;r("battery",Mo(t,o)),r("battery_soc",Mo(t,o,"battery"))}return n}function Fe(t,e=!1){let n=t?.attributes.symcon_id?Ht(t):t?Number(t.state):null;if(n===null||!Number.isFinite(n))return null;let r={kW:1e3,MW:1e6}[String(t.attributes.unit_of_measurement??"W")]??1;return e?-n*r:n*r}var qy=(t,e)=>e.startsWith("sensor.")&&t.states[e]?.attributes.device_class==="power";function li(t,e){if(qy(t,e))return e;let n=t.entities?.[e]?.device_id;if(!n)return null;let r=qs(t,n),i=r?Dt(t,e):null,o=so(t,n).filter(s=>s!==e);return(r?o.find(s=>i!==null&&Dt(t,s)===i):o[0])??null}var fh=t=>{let e=t.filter(n=>n!==null);return e.length?e.reduce((n,r)=>n+r,0):null};function Yy(t,e,n){let r=e.grid??n.grid,i=r?Fe(t.states[r],e.grid_invert):null;if(!e.grid&&n.gridExport){let o=Math.max(0,Fe(t.states[n.gridExport])??0);return Math.max(0,i??0)-o}return i}function Xy(t,e,n){return e.solar?Fe(t.states[e.solar]):n.solar.length?fh(n.solar.map(r=>Fe(t.states[r]))):null}function Na(t,e,n){return e.charge?(e.power?Math.max(0,Fe(t.states[e.power])??0):0)-Math.max(0,Fe(t.states[e.charge])??0):e.power?Fe(t.states[e.power],n):null}function Jy(t,e,n){return e.battery?Fe(t.states[e.battery],e.battery_invert):fh(n.batteries.map(r=>Na(t,r,e.battery_invert)))}function Ba(t,e,n,r=Ro(e)){let i=e.energy,o=Yy(t,i,r),s=Xy(t,i,r),l=Jy(t,i,r),a=(i.battery_soc?[i.battery_soc]:r.soc).map(f=>Number(t.states[f]?.state)).filter(Number.isFinite),c=a.length?a.reduce((f,g)=>f+g,0)/a.length:null,u=i.tariff?t.states[i.tariff]:void 0,d=Number(u?.state),p=i.consumption?Fe(t.states[i.consumption]):null;p===null&&(o!==null||s!==null||l!==null)&&(p=(o??0)+Math.max(0,s??0)+(l??0)),p===null&&n.length>0&&(p=n.reduce((f,g)=>f+g.power,0));let h={grid:o,solar:s===null?null:Math.max(0,s),battery:l,soc:c,tariff:u&&Number.isFinite(d)?{value:d,unit:String(u.attributes.unit_of_measurement??"")}:null,consumption:p===null?null:Math.max(0,p)};return r.subMeters?{...h,...Qy(t,r,h.consumption,i.battery_invert,n)}:h}function Qy(t,e,n,r,i){let o=e.subMeters??[],s=new Map;for(let p of o)for(let h of p.floors)s.has(h)||s.set(h,p.id);let l=new Set([e.grid,e.gridExport,...e.solar,...e.battery,...e.charge,...o.flatMap(p=>[p.power,...p.solar,...p.batteries.flatMap(h=>[h.power,h.charge])])]),a=p=>i.filter(h=>s.get(h.floorId)===p&&!l.has(h.powerEntity)).reduce((h,f)=>h+f.power,0),c=new Map(o.map(p=>[p.id,p.power?Fe(t.states[p.power],p.invert):null])),u=o.map(p=>{let h=c.get(p.id)??null,f=p.solar.reduce((v,w)=>v+Math.max(0,Fe(t.states[w])??0),0),g=p.batteries.reduce((v,w)=>v+(Na(t,w,r)??0),0),b=o.filter(v=>v.parent===p.id).reduce((v,w)=>v+(c.get(w.id)??0),0),y=h===null?null:Math.max(0,h+f+g-b);return{id:p.id,parent:p.parent,power:h,solar:f,battery:g,use:y,unmetered:y===null?null:Math.max(0,y-a(p.id))}}),d=u.reduce((p,h)=>p+(h.use??0),0);return{subMeters:u,rest:n===null?null:Math.max(0,n-d)}}function ev(t,e,n){let r=t.b[0]-t.a[0],i=t.b[1]-t.a[1],o=Math.hypot(r,i)||1,s=Math.min(1,Math.max(0,((e.x-t.a[0])*r+(e.z-t.a[1])*i)/(o*o))),l=t.a[0]+r*s,a=t.a[1]+i*s,c=i/o*(l-n.x)+-r/o*(a-n.z)<0?-1:1;return{x:l,z:a,nx:c*i/o,nz:-c*r/o,distance:Math.hypot(e.x-l,e.z-a)}}function mh(t){let e=Uy(t),n=e?t.floors.find(c=>c.id===e.floor_id):void 0;if(!e||!n)return null;let r={exterior:t.settings.wall_exterior,interior:t.settings.wall_interior},i=fe(n.rooms,r,n.walls??[]).walls.filter(c=>c.exterior),o=n.rooms.flatMap(c=>c.points);if(i.length===0||o.length===0)return null;let s={x:o.reduce((c,u)=>c+u[0],0)/o.length,z:o.reduce((c,u)=>c+u[1],0)/o.length},l=i.map(c=>ev(c,e,s)).reduce((c,u)=>u.distancetv.includes(t),Wa=(t,e="Heizkreis")=>({id:t,name:e,kind:"heating",has_pump:!0,has_valve:!0});function Va(t){return{card:!0,...t==="heating_manifold"?{circuits:[Wa("c1","Heizkreis 1")]}:{},...t==="buffer_tank"?{sensors:Array.from({length:7},(e,n)=>({id:`s${n+1}`,name:`F\xFChler ${n+1}`,entity:null,level:1-n/6}))}:{}}}function Eo(t){return{...Va(t.type),...t.hydronic}}var Xn=t=>t.has_pump!==!1,Ka=t=>t.kind!=="pump"&&t.has_valve!==!1;var ci=t=>!!t&&t!=="none";var Fo=(t,e)=>String(t.states[e]?.attributes.symcon_source_entity||e);function Ao(t,e){let n=t.states[Fo(t,e)]?.attributes;return n?.device_class==="power"||/^[km]?w$/i.test(String(n?.unit_of_measurement??"").trim())}function gh(t,e){let n=new Map;if(!X(t))return n;let r=Me(t,[e]),i=(o,s,l,a,c)=>{if(!ci(c))return;let u=e.rooms.find(p=>p.points.length>=3&&C([l,a],p.points));if(!u)return;let d=n.get(u.id)??[];d.push({id:o,name:s,source:Fo(t,c)}),n.set(u.id,d)};for(let o of e.furniture){if(!uh(t,o))continue;let s=o.name||Ae(t,o.type),l=(o.values??[]).find(u=>ci(u.entity)&&Ao(t,u.entity)),a=r.get(o.id)?.entity,c=o.power==="none"?null:o.power||r.get(o.id)?.power||(a&&Ao(t,a)?a:null);if(i(`furniture:${o.id}`,s,o.x,o.z,c||l?.entity),!c&&!l){let u=new Set;for(let d of o.gang_entities??[]){if(!ci(d))continue;let p=li(t,d);!p||u.has(Fo(t,p))||(u.add(Fo(t,p)),i(`furniture:${o.id}:${d}`,`${s} \xB7 ${B(t,d)}`,o.x,o.z,p))}}if(Yn(o.type))for(let u of Eo(o).circuits??[])Xn(u)&&i(`furniture:${o.id}:${u.id}`,`${s} \xB7 ${u.name||"Pumpe"}`,o.x,o.z,u.power)}for(let o of e.placements){if(o.outside)continue;let s=(o.values??[]).find(a=>ci(a.entity)&&Ao(t,a.entity)),l=Ao(t,o.entity_id)?o.entity_id:li(t,o.entity_id);i(`device:${o.entity_id}`,o.name||B(t,o.entity_id),o.x,o.z,l||s?.entity)}return n}var St={electricity:"Strom",water:"Wasser",gas:"Gas",heating:"Heizen",cooling:"K\xFChlen"},Jn={electricity:"\u26A1",water:"\u{1F4A7}",gas:"\u{1F525}",heating:"\u2668",cooling:"\u2744"},zo=t=>t.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/ß/g,"ss").replace(/[^a-z0-9]+/g," ").trim(),nv="{485D0419-BE97-4548-AA9C-C083EB82E61E}",rv=t=>t.object_type!==0&&!(t.object_type===1&&t.module_id?.toUpperCase()===nv)?null:{elektro:"electricity",strom:"electricity","elektro strom":"electricity","strom elektro":"electricity",wasser:"water",gas:"gas",heizen:"heating",heizung:"heating",warme:"heating",waerme:"heating",kuhlen:"cooling",kuehlen:"cooling",kuhlung:"cooling",kuehlung:"cooling",kalte:"cooling",kaelte:"cooling"}[zo(t.name)]??null,To=t=>/^symcon-category-(\d+)$/.exec(t??"")?.[1],Ua=t=>/\b(heute|tag|tagesverbrauch|today|daily)\b/.test(t)?"day":/monat|month/.test(t)?"month":/jahr|year/.test(t)?"year":"total",Po=(t,e)=>String(t.states[e]?.attributes.symcon_source_entity||e);function yh(t){let e=String(t?.attributes.unit_of_measurement??"").trim(),n=e.replace(/[³]/g,"3").replace(/[²]/g,"2").replace(/\s+/g,"").toLowerCase();return["w","kw","mw"].includes(n)?{metric:"power",unit:"W",factor:e==="mW"?.001:n==="kw"?1e3:n==="mw"?1e6:1}:["wh","kwh","mwh","j","kj","mj","gj"].includes(n)?{metric:"energy",unit:"kWh",factor:{wh:.001,kwh:1,mwh:1e3,j:1/36e5,kj:1/3600,mj:1/3.6,gj:1e3/3.6}[n]}:["m3/h","m3h","m3/min","m3/s","l/h","l/min","l/s","liter/h","liter/min"].includes(n)?{metric:"power",unit:"m\xB3/h",factor:{"m3/h":1,m3h:1,"m3/min":60,"m3/s":3600,"l/h":.001,"l/min":.06,"l/s":3.6,"liter/h":.001,"liter/min":.06}[n]}:["m3","l","liter"].includes(n)?{metric:"energy",unit:"m\xB3",factor:n==="m3"?1:.001}:null}function iv(t,e){if(!e.entity_id||e.object_type!==2&&e.object_type!==6)return null;let n=Po(t,e.entity_id),r=t.states[n];if(!r||![1,2].includes(Number(r.attributes.symcon_variable_type)))return null;let i=zo(e.name),o=yh(r),s=/^(leistung|wirkleistung|gesamtleistung|aktuelle leistung|durchfluss|volumenstrom)(\b|$)/.test(i),l=/^(verbrauch|energie|energieverbrauch|gesamtverbrauch|gesamtenergie|zahlerstand|zaehlerstand|arbeit)(\b|$)/.test(i),a=o?.metric??(s?"power":l?"energy":null);if(!a)return null;let c=a==="power"?/^(leistung|wirkleistung|gesamtleistung|durchfluss|volumenstrom)$/.test(i):/^(verbrauch|energie|energieverbrauch|gesamtverbrauch|gesamtenergie|zahlerstand|zaehlerstand|arbeit)$/.test(i),u=a==="energy"?Ua(i):"total";return{metric:a,source:n,period:u,group:`${a}|${o?.unit??String(r.attributes.unit_of_measurement??"")}|${u}`,score:/^gesamt(leistung|verbrauch|energie)$/.test(i)?110:c?100:(a==="power"?s:l)?70:20}}var _h=new WeakMap,bh=new WeakMap;function vh(t){let e=_h.get(t);if(e)return e;let n={nodes:new Map(t.map(r=>[r.object_id,r])),children:new Map};for(let r of t){let i=n.children.get(r.parent_id)??[];i.push(r),n.children.set(r.parent_id,i)}return _h.set(t,n),n}function ov(t,e,n){if(!X(t))return[];let r=[e.area_id,...e.sub_areas??[]].map(To).filter(p=>!!p);if(!r.length)return[];let i=new Set(n.filter(p=>p.id!==e.id).flatMap(p=>[p.area_id,...p.sub_areas??[]]).map(To).filter(p=>!!p&&!r.includes(p))),o=`${r.join(",")}|${[...i].sort().join(",")}`,s=bh.get(t)??new Map;bh.set(t,s);let l=s.get(o);if(l)return l;let a=vh(t.symconObjects),c=[],u=new Set,d=(p,h,f)=>{if(u.has(p)||i.has(String(p)))return;u.add(p);let g=a.nodes.get(p);if(!g)return;let b=rv(g),y=b??h,v=new Set(b&&b!==h?[]:f),w=a.children.get(p)??[];if(y){let x=w.map(k=>iv(t,k)).filter(k=>k!==null);for(let k of new Set(x.map(M=>M.group))){if(v.has(k))continue;let M=x.filter(F=>F.group===k),A=Math.max(...M.map(F=>F.score)),T=M.filter(F=>F.score===A);for(let F of A>=100?T.slice(0,1):T)c.push({kind:y,metric:F.metric,id:F.source,period:F.period});v.add(k)}}for(let x of w)(x.object_type===0||x.object_type===1)&&d(x.object_id,y,v)};for(let p of r)d(Number(p),null,new Set);return s.set(o,c),c}function ui(t,e,n=!1){let r=new Map,i=new Set;for(let o of e){let s=Po(t,o.id),l=`${o.kind}|${o.metric}|${s}`;if(i.has(l))continue;i.add(l);let a=t.states[s],c=yh(a),u=c?.metric===o.metric?c.unit:String(a?.attributes.unit_of_measurement??"").trim(),d=`${o.kind}|${o.metric}|${u}|${o.period}`,p=r.get(d)??{kind:o.kind,metric:o.metric,unit:u,value:null,period:o.period,sources:[],manual:n,incomplete:!1},h=Ht(a);h===null?p.incomplete=!0:p.value=(p.value??0)+h*(c?.metric===o.metric?c.factor:1),p.sources.push(s),r.set(d,p)}return[...r.values()]}function ja(t,e){return wt.flatMap(n=>["power","energy"].flatMap(r=>{let i=e.utility_meters?.[n]?.[r];if(!i||i==="none")return[];let o=Po(t,i);return[{kind:n,metric:r,id:o,period:r==="energy"?Ua(zo(String(t.states[o]?.attributes.friendly_name??""))):"total"}]}))}function sv(t,e){return X(t)?ui(t,ja(t,e),!0):[]}function av(t,e,n=e.rooms,r=!1){if(!X(t))return[];let i=r?gh(t,e):new Map,o=new Map;for(let l of e.rooms){let a=[...new Set([l.area_id,...l.sub_areas??[]].filter(c=>!!To(c)))];!a.length&&(ja(t,l).length||i.get(l.id)?.length)&&a.push("unassigned");for(let c of a){let u=o.get(c)??{seed:l,members:[]};c===a[0]&&u.members.push(l),o.set(c,u)}}let s=vh(t.symconObjects).nodes;return[...o].map(([l,a])=>{let c=s.get(Number(To(l))),u=l==="unassigned"?[]:ui(t,ov(t,{...a.seed,area_id:l,sub_areas:null},n)),d=ui(t,a.members.flatMap(f=>ja(t,f)),!0),p=f=>u.some(g=>g.kind===f.kind&&g.metric===f.metric&&g.unit===f.unit&&g.period===f.period),h=a.members.map(f=>({id:f.id,name:f.name,readings:sv(t,f),devices:(i.get(f.id)??[]).map(g=>({id:g.id,name:g.name,readings:ui(t,[{kind:"electricity",metric:"power",id:g.source,period:"total"}],!0)}))})).filter(f=>f.readings.length||f.devices.length);return{id:l,name:l==="unassigned"?"Nicht zugeordnet":c?.name||t.areas?.[l]?.name||"Bereich nicht verf\xFCgbar",path:c?.path||"",readings:[...u,...d.filter(f=>!p(f))],rooms:h}}).filter(l=>l.readings.length||l.rooms.length)}function Ga(t,e,n,r){let i=e.utility_meters?.[n],o=i&&Object.prototype.hasOwnProperty.call(i,r)?i[r]:n==="electricity"&&r==="power"?e.power_entity:null;return o&&o!=="none"?Po(t,o):null}function wh(t,e,n=e.rooms){let r=av(t,e,n).flatMap(o=>o.readings.flatMap(s=>s.sources.map(l=>({kind:s.kind,metric:s.metric,period:s.period,id:l})))),i=[];for(let o of wt)for(let s of["power","energy"]){let l=Ga(t,e,o,s);i.push(...ui(t,l?[{kind:o,metric:s,id:l,period:s==="energy"?Ua(zo(String(t.states[l]?.attributes.friendly_name??""))):"total"}]:r.filter(a=>a.kind===o&&a.metric===s),!!l))}return i}function Za(t){return t.metric==="power"?t.unit==="m\xB3/h"?"Durchfluss":"Leistung":{total:"Verbrauch",day:"Verbrauch heute",month:"Verbrauch Monat",year:"Verbrauch Jahr"}[t.period]}function kh(t,e){let n=e.incomplete?"Err: ":"";if(e.value===null)return`${n}\u2013`;let r=e.unit==="W"&&Math.abs(e.value)>=1e3?e.value/1e3:e.value,i=e.unit==="W"&&Math.abs(e.value)>=1e3?"kW":e.unit,o=Number.isInteger(r)?0:Math.min(6,Math.max(2,1-Math.floor(Math.log10(Math.abs(r)))));return`${n}${K(t,r,o)}${i?` ${i}`:""}`}var xh=[{key:"supply_vsr",label:"Zuluft-VSR",types:[0,1,2],control:!0},{key:"extract_vsr",label:"Abluft-VSR",types:[0,1,2],control:!0},{key:"supply_temperature",label:"Zulufttemperatur",types:[1,2]},{key:"extract_temperature",label:"Ablufttemperatur",types:[1,2]},{key:"reheat",label:"NHR (Nachheizregister)",types:[0,1,2],control:!0},{key:"status",label:"Raumstatus",types:[1]}];function $h(t,e,n){let r=O(t.hass,i=>He(t.hass,i,[1,2]));return m`Eigene Raumzähler
${S("Nur direkt zugewiesene Raumz\xE4hler erscheinen als einger\xFCckte Raumzeile unter dem verkn\xFCpften Bereich. Die Bereichswerte stehen einmal beim Bereich; vorhandene Bereichssummen enthalten die Raumwerte bereits. Fehlt dem Bereich ein passender Z\xE4hler, werden daf\xFCr die eigenen Raumz\xE4hler summiert.","nf-wide")}
${wt.map(i=>m`${Jn[i]} ${St[i]} ${["power","energy"].map(o=>z(t,o==="power"?"Leistung / Durchfluss":"Energie / Verbrauch",e.utility_meters?.[i]?.[o]??null,void 0,r,s=>{let l={...e.utility_meters,[i]:{...e.utility_meters?.[i],[o]:s==="none"?null:s}};Object.values(l[i]).some(a=>a&&a!=="none")||delete l[i],n({utility_meters:Object.keys(l).length?l:null})},{types:[1,2]}))}`)}
-
`}function $h(t,e,n){let r=s=>n({hvac:{...e.hvac,...s}}),i=e.hvac?.schedules??[],o=O(t.hass,s=>!!t.hass?.states[s]?.attributes.symcon_schedule);return m`
+ `}function Sh(t,e,n){let r=s=>n({hvac:{...e.hvac,...s}}),i=e.hvac?.schedules??[],o=O(t.hass,s=>!!t.hass?.states[s]?.attributes.symcon_schedule);return m`
${z(t,t.t("floor_heating"),e.floor_heating??null,void 0,O(t.hass,s=>He(t.hass,s,[0,1,2])),s=>n({floor_heating:s==="none"?null:s}),{types:[0,1,2]})}
- ${kh.map(s=>z(t,s.label,e.hvac?.[s.key]??null,void 0,O(t.hass,l=>He(t.hass,l,s.types)),l=>r({[s.key]:l==="none"?null:l}),{types:s.types}))}
+ ${xh.map(s=>z(t,s.label,e.hvac?.[s.key]??null,void 0,O(t.hass,l=>He(t.hass,l,s.types)),l=>r({[s.key]:l==="none"?null:l}),{types:s.types}))}
${S("Raumstatus zeigt den in Symcon hinterlegten Alias der Integer-Variable. Beschreibbare Heizungs- und L\xFCftungswerte k\xF6nnen im Raummen\xFC bedient werden.","nf-wide")}
${i.map((s,l)=>z(t,`Schaltuhr ${l+1}`,s,void 0,o.filter(a=>a.id===s||!i.includes(a.id)),a=>r({schedules:a&&a!=="none"?i.map((c,u)=>l===u?a:c):i.filter((c,u)=>l!==u)}),{schedule:!0,excluded:a=>i.includes(a)?"Diese Schaltuhr ist in diesem Raum bereits verkn\xFCpft.":void 0}))}
- ${z(t,"Schaltuhr hinzuf\xFCgen",null,void 0,o.filter(s=>!i.includes(s.id)),s=>s&&s!=="none"&&r({schedules:[...i,s]}),{schedule:!0,excluded:s=>i.includes(s)?"Diese Schaltuhr ist in diesem Raum bereits verkn\xFCpft.":void 0})}`}function Sh(t,e,n){let r=i=>i==="condition"?[0,1,2,3]:i==="wind_bearing"?[1,2,3]:["snow","fog","lightning"].includes(i)?[0,1,2]:[1,2];return m`Wettervariablen
- ${ru.map(i=>z(t,Xu[i],e.weather_variables?.[i]??null,void 0,O(t.hass,o=>He(t.hass,o,r(i))),o=>n({weather_variables:{...e.weather_variables,[i]:o==="none"?null:o}}),{types:r(i)}))}
+ ${z(t,"Schaltuhr hinzuf\xFCgen",null,void 0,o.filter(s=>!i.includes(s.id)),s=>s&&s!=="none"&&r({schedules:[...i,s]}),{schedule:!0,excluded:s=>i.includes(s)?"Diese Schaltuhr ist in diesem Raum bereits verkn\xFCpft.":void 0})}`}function Mh(t,e,n){let r=i=>i==="condition"?[0,1,2,3]:i==="wind_bearing"?[1,2,3]:["snow","fog","lightning"].includes(i)?[0,1,2]:[1,2];return m`
Wettervariablen
+ ${ou.map(i=>z(t,Ju[i],e.weather_variables?.[i]??null,void 0,O(t.hass,o=>He(t.hass,o,r(i))),o=>n({weather_variables:{...e.weather_variables,[i]:o==="none"?null:o}}),{types:r(i)}))}
${z(t,t.t("rain_sensor"),e.rain_sensor??null,void 0,O(t.hass,i=>He(t.hass,i,[0,1,2])),i=>n({rain_sensor:i==="none"?null:i}),{types:[0,1,2]})}
${e.rain_sensor?D(t,t.t("rain_sensor_inverted"),!!e.rain_sensor_inverted,i=>n({rain_sensor_inverted:i||void 0})):_}
${S("W\xE4hle die Wetterwerte einzeln aus dem Symcon-Objektbaum. Einheiten werden aus den Variablen \xFCbernommen. Der Regensensor kann Boolean oder eine numerische Regenrate sein.","nf-wide")}
-
`}function Mh(t){let e=t.doc.presence,n=s=>t.replace({...structuredClone(t.doc),presence:s}),r=(s,l)=>n(e.map((a,c)=>c===s?{...a,...l,sensor:null}:a)),i=t.doc.floors.flatMap(s=>s.rooms.map(l=>({id:l.id,name:`${s.name} \xB7 ${l.name}`}))),o=O(t.hass,s=>He(t.hass,s,[0]));return m`
${t.t("presence")}
+ `}function Rh(t){let e=t.doc.presence,n=s=>t.replace({...structuredClone(t.doc),presence:s}),r=(s,l)=>n(e.map((a,c)=>c===s?{...a,...l,sensor:null}:a)),i=t.doc.floors.flatMap(s=>s.rooms.map(l=>({id:l.id,name:`${s.name} \xB7 ${l.name}`}))),o=O(t.hass,s=>He(t.hass,s,[0]));return m`${t.t("presence")}
${e.map((s,l)=>m`
${V(t,"Person",s.name??B(t.hass,s.person),a=>r(l,{name:a}),{wide:!0,maxlength:100})}
${z(t,"Anwesenheit (Boolean)",s.person,void 0,o.filter(a=>a.id===s.person||!e.some(c=>c.person===a.id)),a=>a&&a!=="none"?r(l,{person:a}):n(e.filter((c,u)=>u!==l)),{types:[0],excluded:a=>e.some(c=>c.person===a)?"Diese Anwesenheitsvariable ist bereits mit einer Person verkn\xFCpft.":void 0})}
@@ -500,88 +500,88 @@ var $={cs:"4be67fcd522e",da:"0fe66a82bf2a",es:"bd89dffd1355",fi:"9a17bc084f56",f
`)}
${z(t,"Person hinzuf\xFCgen (Boolean)",null,void 0,o.filter(s=>!e.some(l=>l.person===s.id)),s=>s&&s!=="none"&&n([...e,{person:s,sensor:null}]),{types:[0],excluded:s=>e.some(l=>l.person===s)?"Diese Anwesenheitsvariable ist bereits mit einer Person verkn\xFCpft.":void 0})}
${S("Jede Person wird mit einer beliebigen Boolean-Variable verkn\xFCpft: true bedeutet anwesend, false abwesend. Ein Raum ist optional und bestimmt die Position der Person in 3D.")}
- `}function Rh(t,e,n){let r=t.find(a=>a.person===e),i="sensor"in n?n.sensor&&n.sensor!=="none"?n.sensor:null:r?.sensor??null,o="room"in n?n.room||null:r?.room??null,s=t.filter(a=>a.person!==e);if(!i&&!o)return s;let l=o?{person:e,sensor:i,room:o}:{person:e,sensor:i};return r?t.map(a=>a.person===e?l:a):[...s,l]}function Eh(t,e){let n=e.slice(e.indexOf(".")+1),r=i=>i.id.includes(n)&&/(area|room|raum|bermuda|espresense)/.test(i.id);return[...t.filter(r),...t.filter(i=>!r(i))]}function Ah(t){let e=t.target?`, target: { x: ${t.target.x}, y: ${t.target.y}, z: ${t.target.z} }`:"";return`start_view: { theta: ${t.theta}, phi: ${t.phi}, radius: ${t.radius}${e} }`}function Fh(t){let e=t.trim();if(!e)return{ok:!0,value:null};try{let n=JSON.parse(e);return n&&typeof n=="object"&&!Array.isArray(n)?{ok:!0,value:n}:{ok:!1}}catch{return{ok:!1}}}function Po(t,e,n){let r=[...t],[i]=r.splice(e,1);return r.splice(Math.max(0,Math.min(r.length,e+n)),0,i),r}var jt=(t,e)=>t.filter((n,r)=>r!==e),ui=(t,e,n)=>t.map((r,i)=>i===e?{...r,...n}:r),gt=t=>t.length>0?t:void 0;var sv=["scene","script","automation","button","input_button","switch","input_boolean","light","fan","cover","lock"],av=40,lv=20,cv=30,uv=["music","url","playlist","SPOTIFY","AMAZON_MUSIC","TUNEIN","APPLE_MUSIC"],Ua={navigate:"/lovelace/rollos",more_info:"cover.wohnzimmer",service:"script.turn_on",fire_dom_event:""},di=(t,e,n,r=!1)=>m`${e} `;function dv(t){let e=t.doc.settings.favorites??[],n=l=>t.change(a=>a.settings.favorites=gt(l)),r=t.doc.floors,i=t.doc.settings.favorite_floors??{},o=O(t.hass,l=>sv.includes(l.split(".")[0])&&!e.includes(l)),s=(l,a)=>m`
+ `}function Eh(t,e,n){let r=t.find(a=>a.person===e),i="sensor"in n?n.sensor&&n.sensor!=="none"?n.sensor:null:r?.sensor??null,o="room"in n?n.room||null:r?.room??null,s=t.filter(a=>a.person!==e);if(!i&&!o)return s;let l=o?{person:e,sensor:i,room:o}:{person:e,sensor:i};return r?t.map(a=>a.person===e?l:a):[...s,l]}function Ah(t,e){let n=e.slice(e.indexOf(".")+1),r=i=>i.id.includes(n)&&/(area|room|raum|bermuda|espresense)/.test(i.id);return[...t.filter(r),...t.filter(i=>!r(i))]}function Fh(t){let e=t.target?`, target: { x: ${t.target.x}, y: ${t.target.y}, z: ${t.target.z} }`:"";return`start_view: { theta: ${t.theta}, phi: ${t.phi}, radius: ${t.radius}${e} }`}function Th(t){let e=t.trim();if(!e)return{ok:!0,value:null};try{let n=JSON.parse(e);return n&&typeof n=="object"&&!Array.isArray(n)?{ok:!0,value:n}:{ok:!1}}catch{return{ok:!1}}}function Do(t,e,n){let r=[...t],[i]=r.splice(e,1);return r.splice(Math.max(0,Math.min(r.length,e+n)),0,i),r}var Ut=(t,e)=>t.filter((n,r)=>r!==e),di=(t,e,n)=>t.map((r,i)=>i===e?{...r,...n}:r),gt=t=>t.length>0?t:void 0;var lv=["scene","script","automation","button","input_button","switch","input_boolean","light","fan","cover","lock"],cv=40,uv=20,dv=30,hv=["music","url","playlist","SPOTIFY","AMAZON_MUSIC","TUNEIN","APPLE_MUSIC"],qa={navigate:"/lovelace/rollos",more_info:"cover.wohnzimmer",service:"script.turn_on",fire_dom_event:""},hi=(t,e,n,r=!1)=>m`
${e} `;function pv(t){let e=t.doc.settings.favorites??[],n=l=>t.change(a=>a.settings.favorites=gt(l)),r=t.doc.floors,i=t.doc.settings.favorite_floors??{},o=O(t.hass,l=>lv.includes(l.split(".")[0])&&!e.includes(l)),s=(l,a)=>m`
${B(t.hass,l)}
${r.length>1?m`{let u=c.target.value,d={...i};u?d[l]=u:delete d[l],t.change(p=>p.settings.favorite_floors=Object.keys(d).length?d:void 0)}}>
${t.t("favorite_all_floors")}
${r.map(c=>m`${c.name} `)}
`:_}
- ${di(t.t("move_up"),"\u2191",()=>n(Po(e,a,-1)),a===0)}
- ${di(t.t("move_down"),"\u2193",()=>n(Po(e,a,1)),a===e.length-1)}
- ${di(t.t("delete"),"\u2715",()=>n(jt(e,a)))}
+ ${hi(t.t("move_up"),"\u2191",()=>n(Do(e,a,-1)),a===0)}
+ ${hi(t.t("move_down"),"\u2193",()=>n(Do(e,a,1)),a===e.length-1)}
+ ${hi(t.t("delete"),"\u2715",()=>n(Ut(e,a)))}
`;return m`
${t.t("favorites")}${e.length>0?m` ${e.length} `:_}
${S(t.t("favorites_hint"))} ${e.map(s)}
- ${e.length
${z(t,t.t("favorites_add"),null,void 0,o,l=>l&&l!=="none"&&!e.includes(l)&&n([...e,l]),{excluded:l=>e.includes(l)?"Diese Variable ist bereits als Favorit verkn\xFCpft.":void 0})} `:_}`}function hv(t,e){let n=t.doc.settings.outside_hidden??[],r=s=>t.change(l=>l.settings.outside_hidden=gt(s)),i=new Set(t.hass?sd(t.hass,t.doc.floors):[]),o=O(t.hass,s=>!n.includes(s)&&i.has(s));return m`${e?pv(t,e):_}
+ ${e.length${z(t,t.t("favorites_add"),null,void 0,o,l=>l&&l!=="none"&&!e.includes(l)&&n([...e,l]),{excluded:l=>e.includes(l)?"Diese Variable ist bereits als Favorit verkn\xFCpft.":void 0})}`:_}`}function fv(t,e){let n=t.doc.settings.outside_hidden??[],r=s=>t.change(l=>l.settings.outside_hidden=gt(s)),i=new Set(t.hass?ad(t.hass,t.doc.floors):[]),o=O(t.hass,s=>!n.includes(s)&&i.has(s));return m`${e?mv(t,e):_}
${t.t("outside_hidden")}${n.length>0?m` ${n.length} `:_}
${S(t.t("outside_hidden_hint"))}
- ${n.map((s,l)=>m`${B(t.hass,s)} ${di(t.t("delete"),"\u2715",()=>r(jt(n,l)))}
`)}
- ${z(t,t.t("outside_hidden_add"),null,void 0,o,s=>s&&s!=="none"&&!n.includes(s)&&r([...n,s]),{excluded:s=>n.includes(s)?"Diese Variable ist hier bereits eingetragen.":void 0})}
`}function pv(t,e){let n=t.doc.settings.outside_view??null,r=()=>{let i=e();i&&t.change(o=>o.settings.outside_view=i)};return m`${S(t.t("outside_view_hint"))}
- ${J(m`${t.t("outside_view_set")} `,n?m`t.change(i=>i.settings.outside_view=null)}>${t.t("outside_view_reset")} `:_)}`}function fv(t){let e=t.doc.settings.own_alerts??[],n=s=>t.change(l=>l.settings.own_alerts=gt(s)),r=(s,l)=>n(ui(e,s,l)),i=[["",t.t("own_alert_house")],...t.doc.floors.flatMap(s=>s.rooms.map(l=>[l.id,`${l.name} \xB7 ${s.name}`]))],o=(s,l)=>m`
+ ${n.map((s,l)=>m`
${B(t.hass,s)} ${hi(t.t("delete"),"\u2715",()=>r(Ut(n,l)))}
`)}
+
${z(t,t.t("outside_hidden_add"),null,void 0,o,s=>s&&s!=="none"&&!n.includes(s)&&r([...n,s]),{excluded:s=>n.includes(s)?"Diese Variable ist hier bereits eingetragen.":void 0})}
`}function mv(t,e){let n=t.doc.settings.outside_view??null,r=()=>{let i=e();i&&t.change(o=>o.settings.outside_view=i)};return m`${S(t.t("outside_view_hint"))}
+ ${J(m`
${t.t("outside_view_set")} `,n?m`
t.change(i=>i.settings.outside_view=null)}>${t.t("outside_view_reset")} `:_)}`}function gv(t){let e=t.doc.settings.own_alerts??[],n=s=>t.change(l=>l.settings.own_alerts=gt(s)),r=(s,l)=>n(di(e,s,l)),i=[["",t.t("own_alert_house")],...t.doc.floors.flatMap(s=>s.rooms.map(l=>[l.id,`${l.name} \xB7 ${s.name}`]))],o=(s,l)=>m`
${z(t,t.t("own_alert_entity"),s.entity||null,void 0,O(t.hass,()=>!0),a=>r(l,{entity:a&&a!=="none"?a:""}))}
${V(t,t.t("own_alert_state"),s.state??"",a=>r(l,{state:a||null}),{placeholder:t.hass?.states[s.entity]?.state??"on \xB7 <20 \xB7 >80"})}
${V(t,t.t("own_alert_text"),s.text,a=>r(l,{text:a||t.t("own_alert_new")}),{wide:!0,maxlength:120})}
- ${L(t,t.t("room"),s.room_id??"",i,a=>r(l,{room_id:a||null}),{wide:!0})}
- ${Ge(t,t.t("own_alert_color"),s.color??null,"#ffb547",a=>r(l,{color:a}))}
- ${L(t,t.t("own_alert_tap"),s.tap??"",[["",t.t("own_alert_tap_info")],["toggle",t.t("own_alert_tap_toggle")],["room",t.t("own_alert_tap_room")]],a=>r(l,{tap:a||null}))}
-
n(jt(e,l))}>${t.t("delete")}
+ ${H(t,t.t("room"),s.room_id??"",i,a=>r(l,{room_id:a||null}),{wide:!0})}
+ ${Ue(t,t.t("own_alert_color"),s.color??null,"#ffb547",a=>r(l,{color:a}))}
+ ${H(t,t.t("own_alert_tap"),s.tap??"",[["",t.t("own_alert_tap_info")],["toggle",t.t("own_alert_tap_toggle")],["room",t.t("own_alert_tap_room")]],a=>r(l,{tap:a||null}))}
+
n(Ut(e,l))}>${t.t("delete")}
`;return m`
⚠ ${t.t("own_alerts")}
${S(t.t("own_alerts_hint"))} ${e.map(o)}
- ${e.length<40?J(m`
n([...e,{id:I("alert"),entity:"",state:null,text:t.t("own_alert_new")}])}>+ ${t.t("own_alert_add")} `):_}`}function mv(t){let e=t.doc.settings.circuits??[],n=l=>t.change(a=>a.settings.circuits=gt(l)),r=(l,a)=>n(ui(e,l,a)),i=t.doc.floors.flatMap(l=>l.rooms.map(a=>({id:a.id,label:t.doc.floors.length>1?`${a.name} \xB7 ${l.name}`:a.name}))),o=l=>i.find(a=>a.id===l)?.label??l,s=(l,a)=>m`
+ ${e.length<40?J(m`
n([...e,{id:I("alert"),entity:"",state:null,text:t.t("own_alert_new")}])}>+ ${t.t("own_alert_add")} `):_}`}function _v(t){let e=t.doc.settings.circuits??[],n=l=>t.change(a=>a.settings.circuits=gt(l)),r=(l,a)=>n(di(e,l,a)),i=t.doc.floors.flatMap(l=>l.rooms.map(a=>({id:a.id,label:t.doc.floors.length>1?`${a.name} \xB7 ${l.name}`:a.name}))),o=l=>i.find(a=>a.id===l)?.label??l,s=(l,a)=>m`
${V(t,t.t("circuit_name"),l.name,c=>r(a,{name:c||t.t("circuit_new")}),{wide:!0,maxlength:80})}
${l.rooms.map(c=>m`${o(c)} r(a,{rooms:l.rooms.filter(u=>u!==c)})}>✕ `)}
- ${L(t,t.t("circuit_add_room"),"",[["","\u2013"],...i.filter(c=>!l.rooms.includes(c.id)).map(c=>[c.id,c.label])],c=>c&&r(a,{rooms:[...l.rooms,c]}),{wide:!0})}
-
n(jt(e,a))}>${t.t("delete")}
+ ${H(t,t.t("circuit_add_room"),"",[["","\u2013"],...i.filter(c=>!l.rooms.includes(c.id)).map(c=>[c.id,c.label])],c=>c&&r(a,{rooms:[...l.rooms,c]}),{wide:!0})}
+
n(Ut(e,a))}>${t.t("delete")}
`;return m`
🔌 ${t.t("circuits")}
${S(t.t("circuits_hint"))} ${e.map(s)}
- ${e.length<120?J(m`
n([...e,{id:I("circuit"),name:t.t("circuit_new"),rooms:[]}])}>+ ${t.t("circuit_add")} `):_}`}function gv(t){let e=t.doc.settings.calendars??[],n=l=>t.change(a=>a.settings.calendars=gt(l)),r=O(t.hass,l=>l.startsWith("calendar.")&&!e.includes(l)),i=(l,a)=>m`
+ ${e.length<120?J(m`
n([...e,{id:I("circuit"),name:t.t("circuit_new"),rooms:[]}])}>+ ${t.t("circuit_add")} `):_}`}function bv(t){let e=t.doc.settings.calendars??[],n=l=>t.change(a=>a.settings.calendars=gt(l)),r=O(t.hass,l=>l.startsWith("calendar.")&&!e.includes(l)),i=(l,a)=>m`
${B(t.hass,l)}
- ${di(t.t("delete"),"\u2715",()=>n(jt(e,a)))}
+ ${hi(t.t("delete"),"\u2715",()=>n(Ut(e,a)))}
`,o=t.t,s=t.doc.settings.today_days??1;return m`
📅 ${o("today_calendars")}
${S(o("today_calendars_hint"))} ${e.map(i)}
${e.length<12?m`
${z(t,o("favorites_add"),null,void 0,r,l=>l&&l!=="none"&&!e.includes(l)&&n([...e,l]),{unsupported:"Dieses Feld ben\xF6tigt eine Kalenderquelle mit Terminen. Eine Symcon-Variable ist kein Kalender; Kalenderquellen werden vom Symcon-Modul derzeit nicht bereitgestellt."})}
`:_}
${e.length?m`
- ${L(t,o("today_days"),String(s),[1,2,3,5,7].map(l=>[String(l),o(l===1?"today_days_one":"today_days_n",{n:l})]),l=>t.change(a=>a.settings.today_days=Number(l)>1?Number(l):void 0))}
+ ${H(t,o("today_days"),String(s),[1,2,3,5,7].map(l=>[String(l),o(l===1?"today_days_one":"today_days_n",{n:l})]),l=>t.change(a=>a.settings.today_days=Number(l)>1?Number(l):void 0))}
`:_}
- ${_v(t)}`}function _v(t){let e=t.t,n=t.doc.settings.forecast??null,r=i=>t.change(o=>o.settings.forecast=i??void 0);return m`
🌦 ${e("forecast")}
+ ${yv(t)}`}function yv(t){let e=t.t,n=t.doc.settings.forecast??null,r=i=>t.change(o=>o.settings.forecast=i??void 0);return m`
🌦 ${e("forecast")}
${S(e("forecast_hint"))}
- ${L(t,e("forecast_days"),n?String(n.days):"0",[0,3,5,7].map(i=>[String(i),i?e("today_days_n",{n:i}):e("forecast_off")]),i=>r(Number(i)>0?{days:Number(i),corner:n?.corner??"top_right"}:null))}
- ${n?L(t,e("forecast_corner"),n.corner,[["top_right",e("clock_top_right")],["top_left",e("clock_top_left")]],i=>r({...n,corner:i==="top_left"?"top_left":"top_right"})):_}
-
`}function bv(t){let e=t.doc.settings.media_presets??[],n=s=>t.change(l=>l.settings.media_presets=gt(s)),r=(s,l)=>n(ui(e,s,l)),i=[...new Set(t.doc.floors.flatMap(s=>[...s.placements.map(l=>l.entity_id),...s.furniture.map(l=>l.entity??"")]).filter(s=>s.startsWith("media_player.")))],o=(s,l)=>m`
+ ${H(t,e("forecast_days"),n?String(n.days):"0",[0,3,5,7].map(i=>[String(i),i?e("today_days_n",{n:i}):e("forecast_off")]),i=>r(Number(i)>0?{days:Number(i),corner:n?.corner??"top_right"}:null))}
+ ${n?H(t,e("forecast_corner"),n.corner,[["top_right",e("clock_top_right")],["top_left",e("clock_top_left")]],i=>r({...n,corner:i==="top_left"?"top_left":"top_right"})):_}
+
`}function vv(t){let e=t.doc.settings.media_presets??[],n=s=>t.change(l=>l.settings.media_presets=gt(s)),r=(s,l)=>n(di(e,s,l)),i=[...new Set(t.doc.floors.flatMap(s=>[...s.placements.map(l=>l.entity_id),...s.furniture.map(l=>l.entity??"")]).filter(s=>s.startsWith("media_player.")))],o=(s,l)=>m`
`;return m`
${t.t("presets")}
${S(t.t("presets_hint"))}
-
${uv.map(s=>m` `)}
+
${hv.map(s=>m` `)}
${e.map(o)}
- ${e.length
n([...e,{id:I("preset"),label:"Radio",type:"music",content:""}])}>+ ${t.t("preset_add")}`):_}`}function Za(t,e,n){let r=e.action==="fire_dom_event"?'{"browser_mod": {"service": "browser_mod.popup", "data": {"title": "Rollos", "content": {"type": "custom:my-cover-card"}}}}':'{"entity_id": "script.party"}',i=o=>{let s=o.target;s.setCustomValidity("");let l=Fh(s.value);if(l.ok)return n(l.value);s.setCustomValidity(t.t("own_data_bad")),s.reportValidity()};return m`n([...e,{id:I("preset"),label:"Radio",type:"music",content:""}])}>+ ${t.t("preset_add")}`):_}`}function Ya(t,e,n){let r=e.action==="fire_dom_event"?'{"browser_mod": {"service": "browser_mod.popup", "data": {"title": "Rollos", "content": {"type": "custom:my-cover-card"}}}}':'{"entity_id": "script.party"}',i=o=>{let s=o.target;s.setCustomValidity("");let l=Th(s.value);if(l.ok)return n(l.value);s.setCustomValidity(t.t("own_data_bad")),s.reportValidity()};return m`${t.t("own_data")}
- `}function yv(t){let e=t.doc.settings.buttons??[],n=s=>t.change(l=>l.settings.buttons=gt(s)),r=(s,l)=>n(ui(e,s,l)),i=ji.map(s=>[s,t.t(`own_action_${s}`)]),o=(s,l)=>m`
+ `}function wv(t){let e=t.doc.settings.buttons??[],n=s=>t.change(l=>l.settings.buttons=gt(s)),r=(s,l)=>n(di(e,s,l)),i=Ui.map(s=>[s,t.t(`own_action_${s}`)]),o=(s,l)=>m`
${V(t,t.t("own_button_label"),s.label,a=>r(l,{label:a||t.t("own_button_new")}),{maxlength:60})}
- ${L(t,t.t("own_button_action"),s.action,i,a=>r(l,{action:a}))} ${Ct(t,s.icon??null,a=>r(l,{icon:a}))}
- ${s.action!=="fire_dom_event"?V(t,t.t(`own_target_${s.action}`),s.target??"",a=>r(l,{target:a||null}),{wide:!0,placeholder:Ua[s.action]}):_}
- ${s.action==="service"||s.action==="fire_dom_event"?Za(t,s,a=>r(l,{data:a})):_}
+ ${H(t,t.t("own_button_action"),s.action,i,a=>r(l,{action:a}))} ${Nt(t,s.icon??null,a=>r(l,{icon:a}))}
+ ${s.action!=="fire_dom_event"?V(t,t.t(`own_target_${s.action}`),s.target??"",a=>r(l,{target:a||null}),{wide:!0,placeholder:qa[s.action]}):_}
+ ${s.action==="service"||s.action==="fire_dom_event"?Ya(t,s,a=>r(l,{data:a})):_}
${z(t,t.t("own_button_state"),s.state_entity??null,void 0,O(t.hass,a=>/^(switch|light|input_boolean|binary_sensor|fan|cover|media_player|climate|lock|person|device_tracker)\./.test(a)),a=>r(l,{state_entity:a&&a!=="none"?a:null}))}
- n(Po(e,l,-1))}>↑
- n(jt(e,l))}>${t.t("delete")}
+ n(Do(e,l,-1))}>↑
+ n(Ut(e,l))}>${t.t("delete")}
`;return m`
${t.t("own_buttons")}
${S(t.t("own_buttons_hint"))} ${e.map(o)}
- ${e.length
n([...e,{id:I("btn"),label:t.t("own_button_new"),action:"navigate",target:null}])}>+ ${t.t("own_button_add")}`):_}`}function vv(t){let e=t.doc.settings.room_facts_off??[],n=["sun","comfort","air","circuits"].map(r=>D(t,t.t(`room_fact_${r}`),!e.includes(r),i=>t.change(o=>o.settings.room_facts_off=gt(i?e.filter(s=>s!==r):[...e,r]))));return m`${t.t("room_facts")} ${n}
`}function Th(t){return m`${dv(t)} ${yv(t)} ${fv(t)} ${mv(t)} ${gv(t)} ${bv(t)} ${vv(t)} `}function zh(t,e){return m`
+ ${e.lengthn([...e,{id:I("btn"),label:t.t("own_button_new"),action:"navigate",target:null}])}>+ ${t.t("own_button_add")}`):_}`}function kv(t){let e=t.doc.settings.room_facts_off??[],n=["sun","comfort","air","circuits"].map(r=>D(t,t.t(`room_fact_${r}`),!e.includes(r),i=>t.change(o=>o.settings.room_facts_off=gt(i?e.filter(s=>s!==r):[...e,r]))));return m`${t.t("room_facts")} ${n}
`}function zh(t){return m`${pv(t)} ${wv(t)} ${gv(t)} ${_v(t)} ${bv(t)} ${vv(t)} ${kv(t)} `}function Ph(t,e){return m`
🌳 ${t.t("outside_area")}
- ${hv(t,e)}
- `}function Ph(t,e){let n=t.doc.settings.start_view??null,r=()=>{let i=e();i&&t.change(o=>o.settings.start_view=i)};return m`
+ ${fv(t,e)}
+ `}function Dh(t,e){let n=t.doc.settings.start_view??null,r=()=>{let i=e();i&&t.change(o=>o.settings.start_view=i)};return m`
${t.t("start_view")}
${S(t.t("start_view_hint"))}
${J(m`${t.t("start_view_set")} `,n?m`t.change(i=>i.settings.start_view=null)}>${t.t("start_view_reset")} `:_)}
- ${n?m`${S(t.t("start_view_saved"))} ${S(t.t("start_view_card"))}${Ah(n)}`:_}
- `}function Dh(t){if(X(t.hass))return Mh(t);let e=t.doc.presence.map(a=>a.person),n=[...new Set([...Object.keys(t.hass?.states??{}).filter(a=>a.startsWith("person.")).sort(),...e])],r=O(t.hass,me),i=t.doc.floors.flatMap(a=>a.rooms.map(c=>({id:c.id,label:t.doc.floors.length>1?`${a.name} \xB7 ${c.name}`:c.name}))),o=(a,c)=>t.replace({...structuredClone(t.doc),presence:Rh(t.doc.presence,a,c)}),s=a=>{let c=t.doc.presence.find(d=>d.person===a),u=!a.startsWith("person.");return m`${z(t,`${B(t.hass,a)} \xB7 ${t.t("presence_sensor")}`,c?.sensor??null,void 0,Eh(r,a),d=>o(a,{sensor:d}))}
+ ${n?m`${S(t.t("start_view_saved"))} ${S(t.t("start_view_card"))}${Fh(n)}`:_}
+ `}function Ih(t){if(X(t.hass))return Rh(t);let e=t.doc.presence.map(a=>a.person),n=[...new Set([...Object.keys(t.hass?.states??{}).filter(a=>a.startsWith("person.")).sort(),...e])],r=O(t.hass,me),i=t.doc.floors.flatMap(a=>a.rooms.map(c=>({id:c.id,label:t.doc.floors.length>1?`${a.name} \xB7 ${c.name}`:c.name}))),o=(a,c)=>t.replace({...structuredClone(t.doc),presence:Eh(t.doc.presence,a,c)}),s=a=>{let c=t.doc.presence.find(d=>d.person===a),u=!a.startsWith("person.");return m`${z(t,`${B(t.hass,a)} \xB7 ${t.t("presence_sensor")}`,c?.sensor??null,void 0,Ah(r,a),d=>o(a,{sensor:d}))}
${t.t("presence_room")}
o(a,{room:d.target.value||null})}>
${t.t("presence_room_none")}
@@ -593,18 +593,18 @@ var $={cs:"4be67fcd522e",da:"0fe66a82bf2a",es:"bd89dffd1355",fi:"9a17bc084f56",f
${z(t,t.t("presence_add"),null,void 0,l,a=>a&&a!=="none"&&t.replace({...structuredClone(t.doc),presence:[...t.doc.presence,{person:a,sensor:null}]}))}
${S(t.t("presence_hint"))}
- `}function Ih(t,e){return X(t.hass)?m``:m`
+ `}function Oh(t,e){return X(t.hass)?m``:m`
${t.t("ble")}
${S(t.t("ble_hint"))}
- `}var hi=(t,e)=>{let n=t._$AN;if(n===void 0)return!1;for(let r of n)r._$AO?.(e,!1),hi(r,e);return!0},Do=t=>{let e,n;do{if((e=t._$AM)===void 0)break;n=e._$AN,n.delete(t),t=e}while(n?.size===0)},Oh=t=>{for(let e;e=t._$AM;t=e){let n=e._$AN;if(n===void 0)e._$AN=n=new Set;else if(n.has(t))break;n.add(t),xv(e)}};function wv(t){this._$AN!==void 0?(Do(this),this._$AM=t,Oh(this)):this._$AM=t}function kv(t,e=!1,n=0){let r=this._$AH,i=this._$AN;if(i!==void 0&&i.size!==0)if(e)if(Array.isArray(r))for(let o=n;o{t.type==In.CHILD&&(t._$AP??=kv,t._$AQ??=wv)},Io=class extends Ht{constructor(){super(...arguments),this._$AN=void 0}_$AT(e,n,r){super._$AT(e,n,r),Oh(this),this.isConnected=e._$AU}_$AO(e,n=!0){e!==this.isConnected&&(this.isConnected=e,e?this.reconnected?.():this.disconnected?.()),n&&(hi(this,e),Do(this))}setValue(e){if(pd(this._$Ct))this._$Ct._$AI(e,this);else{let n=[...this._$Ct._$AH];n[this._$Ci]=e,this._$Ct._$AI(n,this,0)}}disconnected(){}reconnected(){}};var qa=new WeakMap,Hh=on(class extends Io{render(t){return _}update(t,[e]){let n=e!==this.G;return n&&this.rt(void 0),(n||this.lt!==this.ct)&&(this.G=e,this.ht=t.options?.host,this.rt(this.ct=t.element)),_}rt(t){if(this.G!==void 0)if(this.isConnected||(t=void 0),typeof this.G=="function"){let e=this.ht??globalThis,n=qa.get(e);n===void 0&&(n=new WeakMap,qa.set(e,n)),n.get(this.G)!==void 0&&this.G.call(this.ht,void 0),n.set(this.G,t),t!==void 0&&this.G.call(this.ht,t)}else this.G.value=t}get lt(){return typeof this.G=="function"?qa.get(this.ht??globalThis)?.get(this.G):this.G?.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}});var Lh=t=>t.trim().toLowerCase().replace(/ä/g,"ae").replace(/ö/g,"oe").replace(/ü/g,"ue").replace(/ß/g,"ss").replace(/[^a-z0-9_-]+/g,"_").replace(/^_+|_+$/g,"").slice(0,40);function Ch(t){let e=t.t,n=t.doc.settings.card_templates??{},r=Object.keys(n),i=l=>t.change(a=>{a.settings.card_templates=Object.keys(l).length?l:void 0});t.loadCardEditor?.();let o=l=>{t.hass?.callService("nextfloor","reload_screens",l?{template:l}:{})},s=l=>{let a=Lh(l.value);!a||a in n||r.length>=20||(l.value="",i({...n,[a]:{}}))};return m`
+ `}var pi=(t,e)=>{let n=t._$AN;if(n===void 0)return!1;for(let r of n)r._$AO?.(e,!1),pi(r,e);return!0},Io=t=>{let e,n;do{if((e=t._$AM)===void 0)break;n=e._$AN,n.delete(t),t=e}while(n?.size===0)},Hh=t=>{for(let e;e=t._$AM;t=e){let n=e._$AN;if(n===void 0)e._$AN=n=new Set;else if(n.has(t))break;n.add(t),Sv(e)}};function xv(t){this._$AN!==void 0?(Io(this),this._$AM=t,Hh(this)):this._$AM=t}function $v(t,e=!1,n=0){let r=this._$AH,i=this._$AN;if(i!==void 0&&i.size!==0)if(e)if(Array.isArray(r))for(let o=n;o{t.type==In.CHILD&&(t._$AP??=$v,t._$AQ??=xv)},Oo=class extends Lt{constructor(){super(...arguments),this._$AN=void 0}_$AT(e,n,r){super._$AT(e,n,r),Hh(this),this.isConnected=e._$AU}_$AO(e,n=!0){e!==this.isConnected&&(this.isConnected=e,e?this.reconnected?.():this.disconnected?.()),n&&(pi(this,e),Io(this))}setValue(e){if(fd(this._$Ct))this._$Ct._$AI(e,this);else{let n=[...this._$Ct._$AH];n[this._$Ci]=e,this._$Ct._$AI(n,this,0)}}disconnected(){}reconnected(){}};var Xa=new WeakMap,Lh=sn(class extends Oo{render(t){return _}update(t,[e]){let n=e!==this.G;return n&&this.rt(void 0),(n||this.lt!==this.ct)&&(this.G=e,this.ht=t.options?.host,this.rt(this.ct=t.element)),_}rt(t){if(this.G!==void 0)if(this.isConnected||(t=void 0),typeof this.G=="function"){let e=this.ht??globalThis,n=Xa.get(e);n===void 0&&(n=new WeakMap,Xa.set(e,n)),n.get(this.G)!==void 0&&this.G.call(this.ht,void 0),n.set(this.G,t),t!==void 0&&this.G.call(this.ht,t)}else this.G.value=t}get lt(){return typeof this.G=="function"?Xa.get(this.ht??globalThis)?.get(this.G):this.G?.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}});var Ch=t=>t.trim().toLowerCase().replace(/ä/g,"ae").replace(/ö/g,"oe").replace(/ü/g,"ue").replace(/ß/g,"ss").replace(/[^a-z0-9_-]+/g,"_").replace(/^_+|_+$/g,"").slice(0,40);function Nh(t){let e=t.t,n=t.doc.settings.card_templates??{},r=Object.keys(n),i=l=>t.change(a=>{a.settings.card_templates=Object.keys(l).length?l:void 0});t.loadCardEditor?.();let o=l=>{t.hass?.callService("nextfloor","reload_screens",l?{template:l}:{})},s=l=>{let a=Ch(l.value);!a||a in n||r.length>=20||(l.value="",i({...n,[a]:{}}))};return m`
${e("card_templates")}${r.length?m` ${r.length} `:_}
${S(e("card_templates_hint"))}
${r.map(l=>m`
${l}
a&&a.setConfig({type:"custom:nextfloor-card",...n[l]}))}
+ ${Lh(a=>a&&a.setConfig({type:"custom:nextfloor-card",...n[l]}))}
@config-changed=${a=>{a.stopPropagation();let{type:c,template:u,...d}=a.detail.config;i({...n,[l]:d})}}
>
${t.admin?m`
@@ -620,7 +620,7 @@ var $={cs:"4be67fcd522e",da:"0fe66a82bf2a",es:"bd89dffd1355",fi:"9a17bc084f56",f
s(l.target.closest("details")?.querySelector("input[type=text]")??document.createElement("input"))}>${e("template_add")}
o()}>${e("template_reload_all")}
`:_}
- `}var Oo=.05,$v=(t,e)=>t.length===e.length&&t.every((n,r)=>Math.abs(n[0]-e[r][0])<.001&&Math.abs(n[1]-e[r][1])<.001),_n=t=>new Map(t.map(e=>[e.id,e]));function Sv(t,e,n,r){let i=e.name,[o,s]=[_n(t.rooms),_n(e.rooms)];for(let h of e.rooms){let f=o.get(h.id);f?(f.name!==h.name&&n.push({kind:"room_renamed",floor:i,name:h.name,detail:f.name}),$v(f.points,h.points)||n.push({kind:"room_reshaped",floor:i,name:h.name,detail:Math.round((ke(h.points)-ke(f.points))*10)/10})):n.push({kind:"room_added",floor:i,name:h.name})}for(let h of t.rooms)s.has(h.id)||n.push({kind:"room_removed",floor:i,name:h.name});let[l,a]=[_n(t.openings),_n(e.openings)];for(let h of e.openings)l.has(h.id)||n.push({kind:"opening_added",floor:i,name:h.type,detail:r(h.room_id)});for(let h of t.openings)a.has(h.id)||n.push({kind:"opening_removed",floor:i,name:h.type,detail:r(h.room_id)});let[c,u]=[_n(t.furniture),_n(e.furniture)];for(let h of e.furniture){let f=c.get(h.id);f?(Math.hypot(h.x-f.x,h.z-f.z)>Oo||Math.abs(h.rotation-f.rotation)>1||Math.abs(h.w-f.w)>Oo||Math.abs(h.d-f.d)>Oo)&&n.push({kind:"furniture_moved",floor:i,name:h.name||h.type}):n.push({kind:"furniture_added",floor:i,name:h.name||h.type})}for(let h of t.furniture)u.has(h.id)||n.push({kind:"furniture_removed",floor:i,name:h.name||h.type});let[d,p]=[new Map(t.placements.map(h=>[h.entity_id,h])),new Map(e.placements.map(h=>[h.entity_id,h]))];for(let h of e.placements){let f=d.get(h.entity_id);f?Math.hypot(h.x-f.x,h.z-f.z)>Oo&&n.push({kind:"device_moved",floor:i,name:h.entity_id}):n.push({kind:"device_added",floor:i,name:h.entity_id})}for(let h of t.placements)p.has(h.entity_id)||n.push({kind:"device_removed",floor:i,name:h.entity_id})}function Nh(t,e){let n=[],r=_n(t.floors),i=new Map([...t.floors,...e.floors].flatMap(l=>l.rooms.map(a=>[a.id,a.name]))),o=l=>i.get(l)??"";for(let l of e.floors){let a=r.get(l.id);a?Sv(a,l,n,o):n.push({kind:"floor_added",floor:l.name,name:l.name})}let s=new Set(e.floors.map(l=>l.id));for(let l of t.floors)s.has(l.id)||n.push({kind:"floor_removed",floor:l.name,name:l.name});return n}var bn=(t,e)=>t.getUint16(e,!0),pi=(t,e)=>t.getUint32(e,!0);function Bh(t){let e=new DataView(t.buffer,t.byteOffset,t.byteLength),n=-1;for(let l=t.length-22;l>=Math.max(0,t.length-65557);l--)if(pi(e,l)===101010256){n=l;break}if(n<0)throw new Error("not_zip");let r=bn(e,n+10),i=pi(e,n+16),o=[],s=new TextDecoder;for(let l=0;l",quot:'"',apos:"'"},Rv=t=>t.replace(/&(#x?[0-9a-f]+|\w+);/gi,(e,n)=>n[0]==="#"?String.fromCodePoint(Number.parseInt(n.slice(n[1]==="x"?2:1),n[1]==="x"?16:10)):Mv[n]??e);function Ev(t){let e={};for(let n of t.matchAll(/([\w:.-]+)\s*=\s*(?:"([^"]*)"|'([^']*)')/g))e[n[1]]=Rv(n[2]??n[3]);return e}function Av(t){let e=[],n=null;for(let r of t.matchAll(/<(\/?)(level|room|point|wall|doorOrWindow|pieceOfFurniture)\b([^>]*?)(\/?)>/g)){let[,i,o,s,l]=r;if(i){o==="room"&&(n=null);continue}let a=Ev(s);if(o==="point"){n&&n.points.push([Number(a.x)/100,Number(a.y)/100]);continue}let c={name:o,attrs:a,...o==="room"?{points:[]}:{}};e.push(c),o==="room"&&!l&&(n=c)}return e}var oe=(t,e,n)=>Number.isFinite(Number(t[e]))&&t[e]!==void 0?Number(t[e]):n,Te=t=>Math.round(t*1e3)/1e3;function Vh(t,e,n){let[r,i]=[n[0]-e[0],n[1]-e[1]],o=Math.hypot(r,i)||1e-9,s=Math.max(0,Math.min(o,((t[0]-e[0])*r+(t[1]-e[1])*i)/o)),l=[e[0]+r*s/o,e[1]+i*s/o];return{dist:Math.hypot(t[0]-l[0],t[1]-l[1]),along:s,length:o}}function Fv(t){let e=`${t.name??""} ${t.catalogId??""}`.toLowerCase();return/garage|sectional|rolltor/.test(e)?"garage":/door|tür|tuer|porte|puerta|deur|haustür/.test(e)&&!/window|fenster/.test(e)?"door":"window"}function Tv(t,e){let n=t.length,r=t.map((i,o)=>{let s=t[(o+1)%n],[l,a]=[s[0]-i[0],s[1]-i[1]],c=Math.hypot(l,a)||1e-9,u=[l/c,a/c],d=[(i[0]+s[0])/2,(i[1]+s[1])/2],p=[0,0];for(let h of e){let[f,g]=[h.b[0]-h.a[0],h.b[1]-h.a[1]],b=Math.hypot(f,g)||1e-9;if(Math.abs((u[0]*g-u[1]*f)/b)>.05)continue;let y=(h.a[0]-d[0])*-u[1]+(h.a[1]-d[1])*u[0],v=((d[0]-h.a[0])*f+(d[1]-h.a[1])*g)/b;if(!(Math.abs(y)>h.thickness/2+.06||v<-.05||v>b+.05)){p=[-u[1]*y,u[0]*y];break}}return{p:[i[0]+p[0],i[1]+p[1]],dir:u}});return r.map((i,o)=>{let s=r[(o-1+n)%n],l=s.dir[0]*i.dir[1]-s.dir[1]*i.dir[0];if(Math.abs(l)<1e-6)return i.p;let a=((i.p[0]-s.p[0])*i.dir[1]-(i.p[1]-s.p[1])*i.dir[0])/l;return[s.p[0]+s.dir[0]*a,s.p[1]+s.dir[1]*a]})}function zv(t){let e=Pt(),n={floors:0,rooms:0,openings:0,walls:0,furniture:0},r=t.filter(a=>a.name==="level"),i=r.length?r.map(a=>a.attrs.id??""):[""],o=t.filter(a=>a.name==="wall"),s=o.length?Math.max(...o.map(a=>oe(a.attrs,"height",250)))/100:2.5;return(r.length?[...r].sort((a,c)=>oe(a.attrs,"elevation",0)-oe(c.attrs,"elevation",0)||oe(a.attrs,"elevationIndex",0)-oe(c.attrs,"elevationIndex",0)):[{name:"level",attrs:{id:""}}]).forEach((a,c)=>{let u=a.attrs.id??"",d=b=>r.length?(b.attrs.level??i[0])===u:!0,p=Ve(I("floor"),a.attrs.name||(c===0?"Erdgeschoss":`Etage ${c+1}`),Te(oe(a.attrs,"elevation",0)/100));p.height=Te(oe(a.attrs,"height",s*100)/100);let h=o.filter(d).map(b=>({a:[oe(b.attrs,"xStart",0)/100,oe(b.attrs,"yStart",0)/100],b:[oe(b.attrs,"xEnd",0)/100,oe(b.attrs,"yEnd",0)/100],thickness:oe(b.attrs,"thickness",10)/100})),f=t.filter(b=>b.name==="room"&&d(b)&&(b.points?.length??0)>=3).map((b,y)=>({id:I("room"),name:b.attrs.name||`Raum ${y+1}`,area_id:null,points:Tv(b.points,h).map(([v,w])=>[Te(v),Te(w)]),floor_material:"wood",panel:[]}));p.rooms=f;for(let b of t.filter(y=>y.name==="doorOrWindow"&&d(y))){let y=[oe(b.attrs,"x",0)/100,oe(b.attrs,"y",0)/100],v=Math.max(.6,oe(b.attrs,"depth",30)/100+.3),w=null;for(let H of f)H.points.forEach((P,N)=>{let W=Vh(y,P,H.points[(N+1)%H.points.length]);W.dist<=v&&(!w||W.dist1.4?2:1,swing:"in",cover:null,contact:null,contact2:null,tilt:null})}let g=[];for(let b of o.filter(d)){let y=[oe(b.attrs,"xStart",0)/100,oe(b.attrs,"yStart",0)/100],v=[oe(b.attrs,"xEnd",0)/100,oe(b.attrs,"yEnd",0)/100];if(Math.hypot(v[0]-y[0],v[1]-y[1])<.1)continue;let w=Math.max(.15,oe(b.attrs,"thickness",10)/100),x=F=>f.some(H=>H.points.some((P,N)=>Vh(F,P,H.points[(N+1)%H.points.length]).dist[y[0]+(v[0]-y[0])*F/M,y[1]+(v[1]-y[1])*F/M],T=Array.from({length:M+1},(F,H)=>!x(A(H)));for(let F=0;F<=M;){if(!T[F]){F++;continue}let H=F;for(;H+1<=M&&T[H+1];)H++;let[P,N]=[A(Math.max(0,F-1)),A(Math.min(M,H+1))];Math.hypot(N[0]-P[0],N[1]-P[1])>=.3&&g.push({id:I("wall"),a:[Te(P[0]),Te(P[1])],b:[Te(N[0]),Te(N[1])],thickness:Te(oe(b.attrs,"thickness",10)/100),height:b.attrs.height?Te(oe(b.attrs,"height",250)/100):null}),F=H+1}}p.walls=g,n.rooms+=f.length,n.openings+=p.openings.length,n.walls+=g.length,(f.length||g.length)&&e.floors.push(p)}),n.floors=e.floors.length,n.furniture=t.filter(a=>a.name==="pieceOfFurniture").length,{building:Oe(e),report:n}}async function Kh(t){let e=Bh(t).find(i=>i.name==="Home.xml");if(!e)throw new Error("sh3d_no_xml");let n=new TextDecoder().decode(await Wh(t,e)),r=zv(Av(n));if(r.report.rooms===0&&r.report.walls===0)throw new Error("sh3d_empty");return r}function Pv(t){let e=t.split(/\r?\n/),n=[];for(let r=0;r+1r===9&&i==="$INSUNITS"),n=e>=0?Number(t[e+1]?.[1]):NaN;return{1:.0254,2:.3048,4:.001,5:.01,6:1}[n]??null}function Iv(t){let e=Pv(t),n=Dv(e),r=e.findIndex(([s,l],a)=>s===2&&l==="ENTITIES"&&e[a-1]?.[1]==="SECTION"),i=[];if(r<0)return{shapes:i,unit:n};let o=r+1;for(;oNumber(c.find(([h])=>h===p)?.[1]??NaN),d=[[u(10),u(20)],[u(11),u(21)]];d.every(([p,h])=>Number.isFinite(p)&&Number.isFinite(h))&&i.push({points:d,closed:!1})}else if(l==="LWPOLYLINE"){let u=c.filter(([f])=>f===10).map(([,f])=>Number(f)),d=c.filter(([f])=>f===20).map(([,f])=>Number(f)),p=Number(c.find(([f])=>f===70)?.[1]??0),h=u.map((f,g)=>[f,d[g]]).filter(([f,g])=>Number.isFinite(f)&&Number.isFinite(g));h.length>=2&&i.push({points:h,closed:(p&1)===1})}o=a}return{shapes:i,unit:n}}var jh=t=>Math.round(t*1e3)/1e3;function Gh(t){let{shapes:e,unit:n}=Iv(t);if(!e.length)throw new Error("dxf_empty");let r=e.flatMap(h=>h.points),i=Math.max(Math.max(...r.map(h=>h[0]))-Math.min(...r.map(h=>h[0])),Math.max(...r.map(h=>h[1]))-Math.min(...r.map(h=>h[1]))),o=n??(i>2e3?.001:i>200?.01:1),s=Math.min(...r.map(h=>h[0])),l=Math.max(...r.map(h=>h[1])),a=([h,f])=>[jh((h-s)*o),jh((l-f)*o)],c=Ve(I("floor"),"Erdgeschoss",0),u=[],d=[];for(let h of e){let f=h.points.map(a);if(h.closed&&f.length>=3)u.push({id:I("room"),name:`Raum ${u.length+1}`,area_id:null,points:f,floor_material:"wood",panel:[]});else for(let g=0;g+1.05&&d.push({id:I("wall"),a:f[g],b:f[g+1]})}c.rooms=u,c.walls=d;let p=Pt();return p.floors=[c],{building:Oe(p),report:{floors:1,rooms:u.length,openings:0,walls:d.length,furniture:0}}}var Qe=t=>Math.round(t*100)/100;function Ov(t,e){let n=t.category;return typeof n=="string"?n:n&&typeof n=="object"?Object.keys(n)[0]??e:e}function Hv(t,e){let n=t,r=n?.transform,i=n?.dimensions;if(!n||!Array.isArray(r)||r.length<16||!Array.isArray(i)||i.length<3)return null;let o=l=>Number(l),s=Math.hypot(o(r[0]),o(r[2]));return![...r.slice(0,16),...i.slice(0,3)].every(l=>Number.isFinite(o(l)))||s<1e-6?null:{centre:[o(r[12]),o(r[13]),o(r[14])],dir:[o(r[0])/s,o(r[2])/s],size:[o(i[0]),o(i[1]),o(i[2])],kind:Ov(n,e)}}var Qn=(t,e,n)=>(Array.isArray(t[e])?t[e]:[]).map(r=>Hv(r,n)).filter(r=>!!r);function Lv(t){if(t.length<3)return null;let e=t.map(a=>{let c=a.size[0]/2;return[[a.centre[0]-a.dir[0]*c,a.centre[2]-a.dir[1]*c],[a.centre[0]+a.dir[0]*c,a.centre[2]+a.dir[1]*c]]}),n=(a,c)=>Math.hypot(a[0]-c[0],a[1]-c[1]),r=.4,i=new Set([0]),o=[e[0][0]],s=[0],l=e[0][1];for(;i.sizer?null:(o[0]=[(l[0]+o[0][0])/2,(l[1]+o[0][1])/2],{points:o,edgeWall:s})}function Uh(t){let e=[],n=[];for(let l of t){let a=l.size[0]/2;for(let c of[-1,1])e.push(l.centre[0]+c*l.dir[0]*a),n.push(l.centre[2]+c*l.dir[1]*a)}let[r,i,o,s]=[Math.min(...e),Math.max(...e),Math.min(...n),Math.max(...n)];return[[r,o],[i,o],[i,s],[r,s]]}function Cv(t,e,n){let[r,i]=[n[0]-e[0],n[1]-e[1]],o=Math.hypot(r,i)||1e-9,s=Math.min(o,Math.max(0,((t[0]-e[0])*r+(t[1]-e[1])*i)/o));return{dist:Math.hypot(t[0]-(e[0]+r/o*s),t[1]-(e[1]+i/o*s)),along:s,length:o}}var Nv={sofa:"sofa",bed:"bed",table:"table",chair:"chair",bathtub:"bathtub",toilet:"wc",sink:"sink",refrigerator:"fridge",stove:"stove",oven:"stove",dishwasher:"dishwasher",washerDryer:"washer",storage:"tall_cabinet",television:"tv_board"};function Zh(t){let e=t;return!e||typeof e!="object"||"floors"in e||"settings"in e?!1:(Array.isArray(e.rooms)?e.rooms:[e]).some(r=>r&&Array.isArray(r.walls)&&Qn(r,"walls","wall").length>0)}function qh(t){let e=t,r=(Array.isArray(e.rooms)?e.rooms:[e]).filter(b=>b&&typeof b=="object").map(b=>({walls:Qn(b,"walls","wall"),doors:[...Qn(b,"doors","door"),...Qn(b,"openings","opening")],windows:Qn(b,"windows","window"),objects:Qn(b,"objects","object")})).filter(b=>b.walls.length);if(!r.length)throw new Error("roomplan_empty");let i=r.flatMap(b=>b.walls),o=Math.min(...i.map(b=>b.centre[1]-b.size[1]/2)),s=r.map(b=>Lv(b.walls)),l=r.flatMap((b,y)=>s[y]?.points??Uh(b.walls)),[a,c]=[Math.min(...l.map(b=>b[0]))-.5,Math.min(...l.map(b=>b[1]))-.5],u=([b,y])=>[Qe(b-a),Qe(y-c)],d=Ve(I("floor"),"Erdgeschoss",0);d.height=Qe(Math.max(2.2,Math.min(4,Math.max(...i.map(b=>b.size[1])))));let p=[],h=[];r.forEach((b,y)=>{let w=(s[y]?.points??Uh(b.walls)).map(u),x={id:I("room"),name:`Raum ${y+1}`,area_id:null,points:w,floor_material:"wood",panel:[]};p.push(x);for(let k of[...b.doors.map(M=>({v:M,window:!1})),...b.windows.map(M=>({v:M,window:!0}))]){let M=[k.v.centre[0]-a,k.v.centre[2]-c],A=null;if(w.forEach((P,N)=>{let W=Cv(M,P,w[(N+1)%w.length]);W.dist<=.6&&(!A||W.dist1.4?2:1,swing:"in",...H?{style:"passage"}:{},cover:null,contact:null,contact2:null,tilt:null})}for(let k of b.objects){let M=Nv[k.kind];if(!M)continue;let[A,T,F]=[k.size[0],k.size[2],k.size[1]];A<.1||T<.1||h.push({id:I("f"),type:M,x:Qe(k.centre[0]-a),z:Qe(k.centre[2]-c),rotation:Math.round((Math.atan2(k.dir[1],k.dir[0])*180/Math.PI+360)%360),w:Qe(A),d:Qe(T),h:Qe(F),variant:null,entity:null,power:null})}}),d.rooms=p,d.furniture=h;let f=Pt();f.floors=[d];let g=r.reduce((b,y)=>b+y.objects.length,0)-h.length;return{building:Oe(f),report:{floors:1,rooms:p.length,openings:d.openings.length,walls:0,furniture:g}}}var fi=t=>typeof t=="object"&&t!==null&&!Array.isArray(t)&&"ref"in t;function Bv(t){let e=0,n=()=>{for(;t[e]===" ";)e++;let i=t[e];if(i==="("){e++;let a=[];for(;eString.fromCharCode(...(n.match(/.{4}/g)??[]).map(r=>parseInt(r,16)))).replace(/\\S\\(.)/g,(e,n)=>String.fromCharCode(n.charCodeAt(0)+128))}function Vv(t){let e=new Map,n=t.slice(Math.max(0,t.indexOf("DATA;")));for(let r of n.matchAll(/#(\d+)\s*=\s*([A-Z0-9_]+)\s*\(([\s\S]*?)\)\s*;(?=\s*(?:#|ENDSEC))/g))e.set(Number(r[1]),{type:r[2],args:Bv(r[3])});return e}var Yh={x:0,y:0,z:0,c:1,s:0},Xh=(t,e)=>({x:t.x+t.c*e.x-t.s*e.y,y:t.y+t.s*e.x+t.c*e.y,z:t.z+e.z,c:t.c*e.c-t.s*e.s,s:t.s*e.c+t.c*e.s});function Jh(t){let e=Vv(t);if(!e.size)throw new Error("ifc_empty");let n=k=>fi(k)?e.get(k.ref):void 0,r=k=>typeof k=="number"?k:NaN,i=k=>(n(k)?.args[0]??[]).map(M=>r(M)),o=[...e.values()].find(k=>k.type==="IFCSIUNIT"&&k.args[1]===".LENGTHUNIT."),s=o?{".MILLI.":.001,".CENTI.":.01,".DECI.":.1}[String(o.args[2])]??1:1,l=k=>{let M=n(k);if(!M)return Yh;let[A=0,T=0,F=0]=i(M.args[0]),H=n(M.type==="IFCAXIS2PLACEMENT3D"?M.args[2]:M.args[1]),[P=1,N=0]=(H?.args[0]??[]).map(q=>r(q)),W=Math.hypot(P,N)||1;return{x:A||0,y:T||0,z:F||0,c:P/W,s:N/W}},a=(k,M=0)=>{let A=n(k);return!A||A.type!=="IFCLOCALPLACEMENT"||M>30?Yh:Xh(a(A.args[0],M+1),l(A.args[1]))},c=k=>{for(let M of n(k)?.args[2]??[])for(let A of n(M)?.args[3]??[]){let T=n(A);if(T?.type!=="IFCEXTRUDEDAREASOLID")continue;let F=n(T.args[0]),H=Xh(l(T.args[1]),l(F?.args[2])),P=[];if(F?.type==="IFCRECTANGLEPROFILEDEF"){let[N,W]=[r(F.args[3])/2,r(F.args[4])/2];P=[[-N,-W],[N,-W],[N,W],[-N,W]]}else if(F?.type==="IFCARBITRARYCLOSEDPROFILEDEF"){let N=n(F.args[2]);N?.type==="IFCPOLYLINE"&&(P=(N.args[0]??[]).map(W=>i(W)))}if(P=P.filter(N=>Number.isFinite(N[0])&&Number.isFinite(N[1])),P.length>3&&Math.hypot(P[0][0]-P[P.length-1][0],P[0][1]-P[P.length-1][1])<1e-6&&P.pop(),P.length>=3)return P.map(([N,W])=>[H.x+H.c*N-H.s*W,H.y+H.s*N+H.c*W])}return null},u=new Map;for(let[,k]of e){if(k.type==="IFCRELAGGREGATES"&&fi(k.args[4]))for(let M of k.args[5]??[])fi(M)&&u.set(M.ref,k.args[4].ref);if(k.type==="IFCRELCONTAINEDINSPATIALSTRUCTURE"&&fi(k.args[5]))for(let M of k.args[4]??[])fi(M)&&u.set(M.ref,k.args[5].ref)}let d=[...e].filter(([,k])=>k.type==="IFCBUILDINGSTOREY").map(([k,M])=>({id:k,name:String(M.args[7]||M.args[2]||"")||null,elevation:r(M.args[9])*s}));d.sort((k,M)=>(k.elevation||0)-(M.elevation||0));let p=[];for(let[k,M]of e){if(M.type!=="IFCSPACE")continue;let A=c(M.args[6]);if(!A)continue;let T=a(M.args[5]),F=A.map(([P,N])=>[(T.x+T.c*P-T.s*N)*s,(T.y+T.s*P+T.c*N)*s]),H=String(M.args[7]||M.args[2]||"")||`Raum ${p.length+1}`;p.push({storey:u.get(k)??null,name:H,ring:F})}if(!p.length)throw new Error("ifc_empty");let h=p.flatMap(k=>k.ring),f=Math.min(...h.map(k=>k[0])),g=Math.max(...h.map(k=>k[1])),b=k=>Math.round(k*1e3)/1e3,y=[],v=new Map;if(d.filter(k=>p.some(M=>M.storey===k.id)).forEach((k,M)=>{let A=Ve(I("floor"),k.name??`Etage ${M+1}`,Number.isFinite(k.elevation)?b(k.elevation):M*2.8);y.push(A),v.set(k.id,A)}),p.some(k=>k.storey===null||!v.has(k.storey))){let k=Ve(I("floor"),y.length?"Weitere R\xE4ume":"Erdgeschoss",y.length?y[y.length-1].elevation+2.8:0);y.push(k),v.set(null,k)}y.forEach((k,M)=>{let A=y[M+1];A&&A.elevation-k.elevation>1.8&&(k.height=b(A.elevation-k.elevation-.2))});for(let k of p)v.get(k.storey!==null&&v.has(k.storey)?k.storey:null).rooms.push({id:I("room"),name:k.name,area_id:null,points:k.ring.map(([A,T])=>[b(A-f),b(g-T)]),floor_material:"wood",panel:[]});let x=Pt();return x.floors=y,{building:Oe(x),report:{floors:y.length,rooms:p.length,openings:0,walls:0,furniture:0}}}var ep="nextfloor",Kv="alarm_control_panel|automation|binary_sensor|button|calendar|camera|climate|conversation|cover|date|datetime|device_tracker|event|fan|group|humidifier|image|input_boolean|input_button|input_datetime|input_number|input_select|input_text|lawn_mower|light|lock|media_player|notify|number|person|remote|scene|script|select|sensor|siren|stt|sun|switch|text|time|timer|todo|tts|update|vacuum|valve|water_heater|weather|zone",Qh=new RegExp(`^(?:${Kv})\\.[a-z0-9_]+$`),jv=/^[0-9a-f]{32}$/,Gv=new Set(["area_id","ha_floor"]),Uv=new Set(["sub_areas"]),Zv=new Set(["tap","show_when","pictures","moods"]);function Ya(t){if(typeof t=="string")return Qh.test(t)||jv.test(t)?null:t;if(Array.isArray(t))return t.map(e=>Ya(e)).filter(e=>e!==null);if(t&&typeof t=="object"){let e={};for(let[n,r]of Object.entries(t))Qh.test(n)||Zv.has(n)||(Gv.has(n)||Uv.has(n)?e[n]=null:e[n]=Ya(r));return e}return t}var qv=["wall_exterior","wall_interior","wall_paint_outside","wall_paint_inside","grid","north","roof","weather_effects","rain_warning","sun_patches","lock_plan","start_view","units","motion_markers_active","room_double_tap"];function tp(t){let e=structuredClone(t),n={};for(let i of qv)e.settings?.[i]!==void 0&&(n[i]=e.settings[i]);let r=e.settings?.backdrop;r&&(r.color||r.dim!=null)&&(n.backdrop={color:r.color??null,dim:r.dim??null}),e.settings=n,e.energy={...e.energy,grid:null,solar:null,battery:null,battery_soc:null,tariff:null,consumption:null,gas:null,water:null},e.presence=[];for(let i of e.floors){i.background=null,i.placements=[],i.power_entity=null,i.utility_meters=null,i.ha_floor=null;for(let o of i.rooms)Object.assign(o,{area_id:null,sub_areas:null,panel:[],hidden:[],no_state:[]});i.furniture.forEach(o=>{Object.assign(o,{entity:null,power:null}),delete o.effect_animations,o.picture&&!(o.picture.startsWith("image:")||o.picture.startsWith("https://"))&&(o.picture=null)}),i.openings.forEach(o=>Object.assign(o,{cover:null,contact:null,tilt:null}))}return Ya(e)}function np(t,e){return{format:ep,version:1,exported_at:new Date().toISOString(),building:e?tp(t):structuredClone(t)}}var Yv=t=>!!t&&(t.version===1||t.version===void 0)&&Array.isArray(t.floors)&&t.floors.every(e=>!!e&&typeof e=="object"),Xv="https://therealmrbk.github.io/NextFloor/preview/?shared&noshowcase";function rp(t,e,n,r,i=Xv){let o=new Set(t.floors.flatMap(c=>c.furniture.map(u=>u.type)).filter(c=>c.startsWith("pack:")).map(c=>c.split(":")[1])),s={building:tp(t),packs:e.filter(c=>!c.builtin&&o.has(c.id))},l=JSON.stringify(s).replace(/c.replace(/[&<>"]/g,u=>({"&":"&","<":"<",">":">",'"':"""})[u]);return`
+ `}var Ho=.05,Mv=(t,e)=>t.length===e.length&&t.every((n,r)=>Math.abs(n[0]-e[r][0])<.001&&Math.abs(n[1]-e[r][1])<.001),bn=t=>new Map(t.map(e=>[e.id,e]));function Rv(t,e,n,r){let i=e.name,[o,s]=[bn(t.rooms),bn(e.rooms)];for(let h of e.rooms){let f=o.get(h.id);f?(f.name!==h.name&&n.push({kind:"room_renamed",floor:i,name:h.name,detail:f.name}),Mv(f.points,h.points)||n.push({kind:"room_reshaped",floor:i,name:h.name,detail:Math.round((xe(h.points)-xe(f.points))*10)/10})):n.push({kind:"room_added",floor:i,name:h.name})}for(let h of t.rooms)s.has(h.id)||n.push({kind:"room_removed",floor:i,name:h.name});let[l,a]=[bn(t.openings),bn(e.openings)];for(let h of e.openings)l.has(h.id)||n.push({kind:"opening_added",floor:i,name:h.type,detail:r(h.room_id)});for(let h of t.openings)a.has(h.id)||n.push({kind:"opening_removed",floor:i,name:h.type,detail:r(h.room_id)});let[c,u]=[bn(t.furniture),bn(e.furniture)];for(let h of e.furniture){let f=c.get(h.id);f?(Math.hypot(h.x-f.x,h.z-f.z)>Ho||Math.abs(h.rotation-f.rotation)>1||Math.abs(h.w-f.w)>Ho||Math.abs(h.d-f.d)>Ho)&&n.push({kind:"furniture_moved",floor:i,name:h.name||h.type}):n.push({kind:"furniture_added",floor:i,name:h.name||h.type})}for(let h of t.furniture)u.has(h.id)||n.push({kind:"furniture_removed",floor:i,name:h.name||h.type});let[d,p]=[new Map(t.placements.map(h=>[h.entity_id,h])),new Map(e.placements.map(h=>[h.entity_id,h]))];for(let h of e.placements){let f=d.get(h.entity_id);f?Math.hypot(h.x-f.x,h.z-f.z)>Ho&&n.push({kind:"device_moved",floor:i,name:h.entity_id}):n.push({kind:"device_added",floor:i,name:h.entity_id})}for(let h of t.placements)p.has(h.entity_id)||n.push({kind:"device_removed",floor:i,name:h.entity_id})}function Bh(t,e){let n=[],r=bn(t.floors),i=new Map([...t.floors,...e.floors].flatMap(l=>l.rooms.map(a=>[a.id,a.name]))),o=l=>i.get(l)??"";for(let l of e.floors){let a=r.get(l.id);a?Rv(a,l,n,o):n.push({kind:"floor_added",floor:l.name,name:l.name})}let s=new Set(e.floors.map(l=>l.id));for(let l of t.floors)s.has(l.id)||n.push({kind:"floor_removed",floor:l.name,name:l.name});return n}var yn=(t,e)=>t.getUint16(e,!0),fi=(t,e)=>t.getUint32(e,!0);function Wh(t){let e=new DataView(t.buffer,t.byteOffset,t.byteLength),n=-1;for(let l=t.length-22;l>=Math.max(0,t.length-65557);l--)if(fi(e,l)===101010256){n=l;break}if(n<0)throw new Error("not_zip");let r=yn(e,n+10),i=fi(e,n+16),o=[],s=new TextDecoder;for(let l=0;l",quot:'"',apos:"'"},Av=t=>t.replace(/&(#x?[0-9a-f]+|\w+);/gi,(e,n)=>n[0]==="#"?String.fromCodePoint(Number.parseInt(n.slice(n[1]==="x"?2:1),n[1]==="x"?16:10)):Ev[n]??e);function Fv(t){let e={};for(let n of t.matchAll(/([\w:.-]+)\s*=\s*(?:"([^"]*)"|'([^']*)')/g))e[n[1]]=Av(n[2]??n[3]);return e}function Tv(t){let e=[],n=null;for(let r of t.matchAll(/<(\/?)(level|room|point|wall|doorOrWindow|pieceOfFurniture)\b([^>]*?)(\/?)>/g)){let[,i,o,s,l]=r;if(i){o==="room"&&(n=null);continue}let a=Fv(s);if(o==="point"){n&&n.points.push([Number(a.x)/100,Number(a.y)/100]);continue}let c={name:o,attrs:a,...o==="room"?{points:[]}:{}};e.push(c),o==="room"&&!l&&(n=c)}return e}var oe=(t,e,n)=>Number.isFinite(Number(t[e]))&&t[e]!==void 0?Number(t[e]):n,Te=t=>Math.round(t*1e3)/1e3;function Kh(t,e,n){let[r,i]=[n[0]-e[0],n[1]-e[1]],o=Math.hypot(r,i)||1e-9,s=Math.max(0,Math.min(o,((t[0]-e[0])*r+(t[1]-e[1])*i)/o)),l=[e[0]+r*s/o,e[1]+i*s/o];return{dist:Math.hypot(t[0]-l[0],t[1]-l[1]),along:s,length:o}}function zv(t){let e=`${t.name??""} ${t.catalogId??""}`.toLowerCase();return/garage|sectional|rolltor/.test(e)?"garage":/door|tür|tuer|porte|puerta|deur|haustür/.test(e)&&!/window|fenster/.test(e)?"door":"window"}function Pv(t,e){let n=t.length,r=t.map((i,o)=>{let s=t[(o+1)%n],[l,a]=[s[0]-i[0],s[1]-i[1]],c=Math.hypot(l,a)||1e-9,u=[l/c,a/c],d=[(i[0]+s[0])/2,(i[1]+s[1])/2],p=[0,0];for(let h of e){let[f,g]=[h.b[0]-h.a[0],h.b[1]-h.a[1]],b=Math.hypot(f,g)||1e-9;if(Math.abs((u[0]*g-u[1]*f)/b)>.05)continue;let y=(h.a[0]-d[0])*-u[1]+(h.a[1]-d[1])*u[0],v=((d[0]-h.a[0])*f+(d[1]-h.a[1])*g)/b;if(!(Math.abs(y)>h.thickness/2+.06||v<-.05||v>b+.05)){p=[-u[1]*y,u[0]*y];break}}return{p:[i[0]+p[0],i[1]+p[1]],dir:u}});return r.map((i,o)=>{let s=r[(o-1+n)%n],l=s.dir[0]*i.dir[1]-s.dir[1]*i.dir[0];if(Math.abs(l)<1e-6)return i.p;let a=((i.p[0]-s.p[0])*i.dir[1]-(i.p[1]-s.p[1])*i.dir[0])/l;return[s.p[0]+s.dir[0]*a,s.p[1]+s.dir[1]*a]})}function Dv(t){let e=Pt(),n={floors:0,rooms:0,openings:0,walls:0,furniture:0},r=t.filter(a=>a.name==="level"),i=r.length?r.map(a=>a.attrs.id??""):[""],o=t.filter(a=>a.name==="wall"),s=o.length?Math.max(...o.map(a=>oe(a.attrs,"height",250)))/100:2.5;return(r.length?[...r].sort((a,c)=>oe(a.attrs,"elevation",0)-oe(c.attrs,"elevation",0)||oe(a.attrs,"elevationIndex",0)-oe(c.attrs,"elevationIndex",0)):[{name:"level",attrs:{id:""}}]).forEach((a,c)=>{let u=a.attrs.id??"",d=b=>r.length?(b.attrs.level??i[0])===u:!0,p=Ve(I("floor"),a.attrs.name||(c===0?"Erdgeschoss":`Etage ${c+1}`),Te(oe(a.attrs,"elevation",0)/100));p.height=Te(oe(a.attrs,"height",s*100)/100);let h=o.filter(d).map(b=>({a:[oe(b.attrs,"xStart",0)/100,oe(b.attrs,"yStart",0)/100],b:[oe(b.attrs,"xEnd",0)/100,oe(b.attrs,"yEnd",0)/100],thickness:oe(b.attrs,"thickness",10)/100})),f=t.filter(b=>b.name==="room"&&d(b)&&(b.points?.length??0)>=3).map((b,y)=>({id:I("room"),name:b.attrs.name||`Raum ${y+1}`,area_id:null,points:Pv(b.points,h).map(([v,w])=>[Te(v),Te(w)]),floor_material:"wood",panel:[]}));p.rooms=f;for(let b of t.filter(y=>y.name==="doorOrWindow"&&d(y))){let y=[oe(b.attrs,"x",0)/100,oe(b.attrs,"y",0)/100],v=Math.max(.6,oe(b.attrs,"depth",30)/100+.3),w=null;for(let L of f)L.points.forEach((P,N)=>{let W=Kh(y,P,L.points[(N+1)%L.points.length]);W.dist<=v&&(!w||W.dist1.4?2:1,swing:"in",cover:null,contact:null,contact2:null,tilt:null})}let g=[];for(let b of o.filter(d)){let y=[oe(b.attrs,"xStart",0)/100,oe(b.attrs,"yStart",0)/100],v=[oe(b.attrs,"xEnd",0)/100,oe(b.attrs,"yEnd",0)/100];if(Math.hypot(v[0]-y[0],v[1]-y[1])<.1)continue;let w=Math.max(.15,oe(b.attrs,"thickness",10)/100),x=F=>f.some(L=>L.points.some((P,N)=>Kh(F,P,L.points[(N+1)%L.points.length]).dist[y[0]+(v[0]-y[0])*F/M,y[1]+(v[1]-y[1])*F/M],T=Array.from({length:M+1},(F,L)=>!x(A(L)));for(let F=0;F<=M;){if(!T[F]){F++;continue}let L=F;for(;L+1<=M&&T[L+1];)L++;let[P,N]=[A(Math.max(0,F-1)),A(Math.min(M,L+1))];Math.hypot(N[0]-P[0],N[1]-P[1])>=.3&&g.push({id:I("wall"),a:[Te(P[0]),Te(P[1])],b:[Te(N[0]),Te(N[1])],thickness:Te(oe(b.attrs,"thickness",10)/100),height:b.attrs.height?Te(oe(b.attrs,"height",250)/100):null}),F=L+1}}p.walls=g,n.rooms+=f.length,n.openings+=p.openings.length,n.walls+=g.length,(f.length||g.length)&&e.floors.push(p)}),n.floors=e.floors.length,n.furniture=t.filter(a=>a.name==="pieceOfFurniture").length,{building:Oe(e),report:n}}async function jh(t){let e=Wh(t).find(i=>i.name==="Home.xml");if(!e)throw new Error("sh3d_no_xml");let n=new TextDecoder().decode(await Vh(t,e)),r=Dv(Tv(n));if(r.report.rooms===0&&r.report.walls===0)throw new Error("sh3d_empty");return r}function Iv(t){let e=t.split(/\r?\n/),n=[];for(let r=0;r+1r===9&&i==="$INSUNITS"),n=e>=0?Number(t[e+1]?.[1]):NaN;return{1:.0254,2:.3048,4:.001,5:.01,6:1}[n]??null}function Hv(t){let e=Iv(t),n=Ov(e),r=e.findIndex(([s,l],a)=>s===2&&l==="ENTITIES"&&e[a-1]?.[1]==="SECTION"),i=[];if(r<0)return{shapes:i,unit:n};let o=r+1;for(;oNumber(c.find(([h])=>h===p)?.[1]??NaN),d=[[u(10),u(20)],[u(11),u(21)]];d.every(([p,h])=>Number.isFinite(p)&&Number.isFinite(h))&&i.push({points:d,closed:!1})}else if(l==="LWPOLYLINE"){let u=c.filter(([f])=>f===10).map(([,f])=>Number(f)),d=c.filter(([f])=>f===20).map(([,f])=>Number(f)),p=Number(c.find(([f])=>f===70)?.[1]??0),h=u.map((f,g)=>[f,d[g]]).filter(([f,g])=>Number.isFinite(f)&&Number.isFinite(g));h.length>=2&&i.push({points:h,closed:(p&1)===1})}o=a}return{shapes:i,unit:n}}var Uh=t=>Math.round(t*1e3)/1e3;function Gh(t){let{shapes:e,unit:n}=Hv(t);if(!e.length)throw new Error("dxf_empty");let r=e.flatMap(h=>h.points),i=Math.max(Math.max(...r.map(h=>h[0]))-Math.min(...r.map(h=>h[0])),Math.max(...r.map(h=>h[1]))-Math.min(...r.map(h=>h[1]))),o=n??(i>2e3?.001:i>200?.01:1),s=Math.min(...r.map(h=>h[0])),l=Math.max(...r.map(h=>h[1])),a=([h,f])=>[Uh((h-s)*o),Uh((l-f)*o)],c=Ve(I("floor"),"Erdgeschoss",0),u=[],d=[];for(let h of e){let f=h.points.map(a);if(h.closed&&f.length>=3)u.push({id:I("room"),name:`Raum ${u.length+1}`,area_id:null,points:f,floor_material:"wood",panel:[]});else for(let g=0;g+1.05&&d.push({id:I("wall"),a:f[g],b:f[g+1]})}c.rooms=u,c.walls=d;let p=Pt();return p.floors=[c],{building:Oe(p),report:{floors:1,rooms:u.length,openings:0,walls:d.length,furniture:0}}}var Qe=t=>Math.round(t*100)/100;function Lv(t,e){let n=t.category;return typeof n=="string"?n:n&&typeof n=="object"?Object.keys(n)[0]??e:e}function Cv(t,e){let n=t,r=n?.transform,i=n?.dimensions;if(!n||!Array.isArray(r)||r.length<16||!Array.isArray(i)||i.length<3)return null;let o=l=>Number(l),s=Math.hypot(o(r[0]),o(r[2]));return![...r.slice(0,16),...i.slice(0,3)].every(l=>Number.isFinite(o(l)))||s<1e-6?null:{centre:[o(r[12]),o(r[13]),o(r[14])],dir:[o(r[0])/s,o(r[2])/s],size:[o(i[0]),o(i[1]),o(i[2])],kind:Lv(n,e)}}var Qn=(t,e,n)=>(Array.isArray(t[e])?t[e]:[]).map(r=>Cv(r,n)).filter(r=>!!r);function Nv(t){if(t.length<3)return null;let e=t.map(a=>{let c=a.size[0]/2;return[[a.centre[0]-a.dir[0]*c,a.centre[2]-a.dir[1]*c],[a.centre[0]+a.dir[0]*c,a.centre[2]+a.dir[1]*c]]}),n=(a,c)=>Math.hypot(a[0]-c[0],a[1]-c[1]),r=.4,i=new Set([0]),o=[e[0][0]],s=[0],l=e[0][1];for(;i.sizer?null:(o[0]=[(l[0]+o[0][0])/2,(l[1]+o[0][1])/2],{points:o,edgeWall:s})}function Zh(t){let e=[],n=[];for(let l of t){let a=l.size[0]/2;for(let c of[-1,1])e.push(l.centre[0]+c*l.dir[0]*a),n.push(l.centre[2]+c*l.dir[1]*a)}let[r,i,o,s]=[Math.min(...e),Math.max(...e),Math.min(...n),Math.max(...n)];return[[r,o],[i,o],[i,s],[r,s]]}function Bv(t,e,n){let[r,i]=[n[0]-e[0],n[1]-e[1]],o=Math.hypot(r,i)||1e-9,s=Math.min(o,Math.max(0,((t[0]-e[0])*r+(t[1]-e[1])*i)/o));return{dist:Math.hypot(t[0]-(e[0]+r/o*s),t[1]-(e[1]+i/o*s)),along:s,length:o}}var Wv={sofa:"sofa",bed:"bed",table:"table",chair:"chair",bathtub:"bathtub",toilet:"wc",sink:"sink",refrigerator:"fridge",stove:"stove",oven:"stove",dishwasher:"dishwasher",washerDryer:"washer",storage:"tall_cabinet",television:"tv_board"};function qh(t){let e=t;return!e||typeof e!="object"||"floors"in e||"settings"in e?!1:(Array.isArray(e.rooms)?e.rooms:[e]).some(r=>r&&Array.isArray(r.walls)&&Qn(r,"walls","wall").length>0)}function Yh(t){let e=t,r=(Array.isArray(e.rooms)?e.rooms:[e]).filter(b=>b&&typeof b=="object").map(b=>({walls:Qn(b,"walls","wall"),doors:[...Qn(b,"doors","door"),...Qn(b,"openings","opening")],windows:Qn(b,"windows","window"),objects:Qn(b,"objects","object")})).filter(b=>b.walls.length);if(!r.length)throw new Error("roomplan_empty");let i=r.flatMap(b=>b.walls),o=Math.min(...i.map(b=>b.centre[1]-b.size[1]/2)),s=r.map(b=>Nv(b.walls)),l=r.flatMap((b,y)=>s[y]?.points??Zh(b.walls)),[a,c]=[Math.min(...l.map(b=>b[0]))-.5,Math.min(...l.map(b=>b[1]))-.5],u=([b,y])=>[Qe(b-a),Qe(y-c)],d=Ve(I("floor"),"Erdgeschoss",0);d.height=Qe(Math.max(2.2,Math.min(4,Math.max(...i.map(b=>b.size[1])))));let p=[],h=[];r.forEach((b,y)=>{let w=(s[y]?.points??Zh(b.walls)).map(u),x={id:I("room"),name:`Raum ${y+1}`,area_id:null,points:w,floor_material:"wood",panel:[]};p.push(x);for(let k of[...b.doors.map(M=>({v:M,window:!1})),...b.windows.map(M=>({v:M,window:!0}))]){let M=[k.v.centre[0]-a,k.v.centre[2]-c],A=null;if(w.forEach((P,N)=>{let W=Bv(M,P,w[(N+1)%w.length]);W.dist<=.6&&(!A||W.dist1.4?2:1,swing:"in",...L?{style:"passage"}:{},cover:null,contact:null,contact2:null,tilt:null})}for(let k of b.objects){let M=Wv[k.kind];if(!M)continue;let[A,T,F]=[k.size[0],k.size[2],k.size[1]];A<.1||T<.1||h.push({id:I("f"),type:M,x:Qe(k.centre[0]-a),z:Qe(k.centre[2]-c),rotation:Math.round((Math.atan2(k.dir[1],k.dir[0])*180/Math.PI+360)%360),w:Qe(A),d:Qe(T),h:Qe(F),variant:null,entity:null,power:null})}}),d.rooms=p,d.furniture=h;let f=Pt();f.floors=[d];let g=r.reduce((b,y)=>b+y.objects.length,0)-h.length;return{building:Oe(f),report:{floors:1,rooms:p.length,openings:d.openings.length,walls:0,furniture:g}}}var mi=t=>typeof t=="object"&&t!==null&&!Array.isArray(t)&&"ref"in t;function Vv(t){let e=0,n=()=>{for(;t[e]===" ";)e++;let i=t[e];if(i==="("){e++;let a=[];for(;eString.fromCharCode(...(n.match(/.{4}/g)??[]).map(r=>parseInt(r,16)))).replace(/\\S\\(.)/g,(e,n)=>String.fromCharCode(n.charCodeAt(0)+128))}function jv(t){let e=new Map,n=t.slice(Math.max(0,t.indexOf("DATA;")));for(let r of n.matchAll(/#(\d+)\s*=\s*([A-Z0-9_]+)\s*\(([\s\S]*?)\)\s*;(?=\s*(?:#|ENDSEC))/g))e.set(Number(r[1]),{type:r[2],args:Vv(r[3])});return e}var Xh={x:0,y:0,z:0,c:1,s:0},Jh=(t,e)=>({x:t.x+t.c*e.x-t.s*e.y,y:t.y+t.s*e.x+t.c*e.y,z:t.z+e.z,c:t.c*e.c-t.s*e.s,s:t.s*e.c+t.c*e.s});function Qh(t){let e=jv(t);if(!e.size)throw new Error("ifc_empty");let n=k=>mi(k)?e.get(k.ref):void 0,r=k=>typeof k=="number"?k:NaN,i=k=>(n(k)?.args[0]??[]).map(M=>r(M)),o=[...e.values()].find(k=>k.type==="IFCSIUNIT"&&k.args[1]===".LENGTHUNIT."),s=o?{".MILLI.":.001,".CENTI.":.01,".DECI.":.1}[String(o.args[2])]??1:1,l=k=>{let M=n(k);if(!M)return Xh;let[A=0,T=0,F=0]=i(M.args[0]),L=n(M.type==="IFCAXIS2PLACEMENT3D"?M.args[2]:M.args[1]),[P=1,N=0]=(L?.args[0]??[]).map(q=>r(q)),W=Math.hypot(P,N)||1;return{x:A||0,y:T||0,z:F||0,c:P/W,s:N/W}},a=(k,M=0)=>{let A=n(k);return!A||A.type!=="IFCLOCALPLACEMENT"||M>30?Xh:Jh(a(A.args[0],M+1),l(A.args[1]))},c=k=>{for(let M of n(k)?.args[2]??[])for(let A of n(M)?.args[3]??[]){let T=n(A);if(T?.type!=="IFCEXTRUDEDAREASOLID")continue;let F=n(T.args[0]),L=Jh(l(T.args[1]),l(F?.args[2])),P=[];if(F?.type==="IFCRECTANGLEPROFILEDEF"){let[N,W]=[r(F.args[3])/2,r(F.args[4])/2];P=[[-N,-W],[N,-W],[N,W],[-N,W]]}else if(F?.type==="IFCARBITRARYCLOSEDPROFILEDEF"){let N=n(F.args[2]);N?.type==="IFCPOLYLINE"&&(P=(N.args[0]??[]).map(W=>i(W)))}if(P=P.filter(N=>Number.isFinite(N[0])&&Number.isFinite(N[1])),P.length>3&&Math.hypot(P[0][0]-P[P.length-1][0],P[0][1]-P[P.length-1][1])<1e-6&&P.pop(),P.length>=3)return P.map(([N,W])=>[L.x+L.c*N-L.s*W,L.y+L.s*N+L.c*W])}return null},u=new Map;for(let[,k]of e){if(k.type==="IFCRELAGGREGATES"&&mi(k.args[4]))for(let M of k.args[5]??[])mi(M)&&u.set(M.ref,k.args[4].ref);if(k.type==="IFCRELCONTAINEDINSPATIALSTRUCTURE"&&mi(k.args[5]))for(let M of k.args[4]??[])mi(M)&&u.set(M.ref,k.args[5].ref)}let d=[...e].filter(([,k])=>k.type==="IFCBUILDINGSTOREY").map(([k,M])=>({id:k,name:String(M.args[7]||M.args[2]||"")||null,elevation:r(M.args[9])*s}));d.sort((k,M)=>(k.elevation||0)-(M.elevation||0));let p=[];for(let[k,M]of e){if(M.type!=="IFCSPACE")continue;let A=c(M.args[6]);if(!A)continue;let T=a(M.args[5]),F=A.map(([P,N])=>[(T.x+T.c*P-T.s*N)*s,(T.y+T.s*P+T.c*N)*s]),L=String(M.args[7]||M.args[2]||"")||`Raum ${p.length+1}`;p.push({storey:u.get(k)??null,name:L,ring:F})}if(!p.length)throw new Error("ifc_empty");let h=p.flatMap(k=>k.ring),f=Math.min(...h.map(k=>k[0])),g=Math.max(...h.map(k=>k[1])),b=k=>Math.round(k*1e3)/1e3,y=[],v=new Map;if(d.filter(k=>p.some(M=>M.storey===k.id)).forEach((k,M)=>{let A=Ve(I("floor"),k.name??`Etage ${M+1}`,Number.isFinite(k.elevation)?b(k.elevation):M*2.8);y.push(A),v.set(k.id,A)}),p.some(k=>k.storey===null||!v.has(k.storey))){let k=Ve(I("floor"),y.length?"Weitere R\xE4ume":"Erdgeschoss",y.length?y[y.length-1].elevation+2.8:0);y.push(k),v.set(null,k)}y.forEach((k,M)=>{let A=y[M+1];A&&A.elevation-k.elevation>1.8&&(k.height=b(A.elevation-k.elevation-.2))});for(let k of p)v.get(k.storey!==null&&v.has(k.storey)?k.storey:null).rooms.push({id:I("room"),name:k.name,area_id:null,points:k.ring.map(([A,T])=>[b(A-f),b(g-T)]),floor_material:"wood",panel:[]});let x=Pt();return x.floors=y,{building:Oe(x),report:{floors:y.length,rooms:p.length,openings:0,walls:0,furniture:0}}}var tp="nextfloor",Uv="alarm_control_panel|automation|binary_sensor|button|calendar|camera|climate|conversation|cover|date|datetime|device_tracker|event|fan|group|humidifier|image|input_boolean|input_button|input_datetime|input_number|input_select|input_text|lawn_mower|light|lock|media_player|notify|number|person|remote|scene|script|select|sensor|siren|stt|sun|switch|text|time|timer|todo|tts|update|vacuum|valve|water_heater|weather|zone",ep=new RegExp(`^(?:${Uv})\\.[a-z0-9_]+$`),Gv=/^[0-9a-f]{32}$/,Zv=new Set(["area_id","ha_floor"]),qv=new Set(["sub_areas"]),Yv=new Set(["tap","show_when","pictures","moods"]);function Ja(t){if(typeof t=="string")return ep.test(t)||Gv.test(t)?null:t;if(Array.isArray(t))return t.map(e=>Ja(e)).filter(e=>e!==null);if(t&&typeof t=="object"){let e={};for(let[n,r]of Object.entries(t))ep.test(n)||Yv.has(n)||(Zv.has(n)||qv.has(n)?e[n]=null:e[n]=Ja(r));return e}return t}var Xv=["wall_exterior","wall_interior","wall_paint_outside","wall_paint_inside","grid","north","roof","weather_effects","rain_warning","sun_patches","lock_plan","start_view","units","motion_markers_active","room_double_tap"];function np(t){let e=structuredClone(t),n={};for(let i of Xv)e.settings?.[i]!==void 0&&(n[i]=e.settings[i]);let r=e.settings?.backdrop;r&&(r.color||r.dim!=null)&&(n.backdrop={color:r.color??null,dim:r.dim??null}),e.settings=n,e.energy={...e.energy,grid:null,solar:null,battery:null,battery_soc:null,tariff:null,consumption:null,gas:null,water:null},e.presence=[];for(let i of e.floors){i.background=null,i.placements=[],i.power_entity=null,i.utility_meters=null,i.ha_floor=null;for(let o of i.rooms)Object.assign(o,{area_id:null,sub_areas:null,panel:[],hidden:[],no_state:[]});i.furniture.forEach(o=>{Object.assign(o,{entity:null,power:null}),delete o.effect_animations,o.picture&&!(o.picture.startsWith("image:")||o.picture.startsWith("https://"))&&(o.picture=null)}),i.openings.forEach(o=>Object.assign(o,{cover:null,contact:null,tilt:null}))}return Ja(e)}function rp(t,e){return{format:tp,version:1,exported_at:new Date().toISOString(),building:e?np(t):structuredClone(t)}}var Jv=t=>!!t&&(t.version===1||t.version===void 0)&&Array.isArray(t.floors)&&t.floors.every(e=>!!e&&typeof e=="object"),Qv="https://therealmrbk.github.io/NextFloor/preview/?shared&noshowcase";function ip(t,e,n,r,i=Qv){let o=new Set(t.floors.flatMap(c=>c.furniture.map(u=>u.type)).filter(c=>c.startsWith("pack:")).map(c=>c.split(":")[1])),s={building:np(t),packs:e.filter(c=>!c.builtin&&o.has(c.id))},l=JSON.stringify(s).replace(/c.replace(/[&<>"]/g,u=>({"&":"&","<":"<",">":">",'"':"""})[u]);return`
${a(n)}
@@ -633,27 +633,27 @@ addEventListener("message", (e) => {
if (e.source === frame.contentWindow && e.data && e.data.type === "nextfloor-share-ready") frame.contentWindow.postMessage({ type: "nextfloor-share", building: data.building, packs: data.packs }, "*");
});
<\/script>
-`}function ip(t){let e;try{e=JSON.parse(t)}catch{throw new Error("not_json")}let n=e,r=n?.format===ep?n.building:e;if(!Yv(r))throw new Error("not_plan");return r.floors.forEach(i=>i.background=null),Oe(r)}var Jv=t=>!/^https?:\/\//.test(t)&&!t.startsWith("camera:");function op(t){let e=new Set;for(let n of t.floors){n.background?.image_id&&e.add(n.background.image_id);let r=n.furniture.flatMap(i=>i.pictures??[]);for(let{image:i}of r)i&&Jv(i)&&e.add(i)}return[...e]}function sp(t,e,n="application/json"){let r=document.createElement("a"),i=URL.createObjectURL(new Blob([e],{type:n}));Object.assign(r,{href:i,download:t}),r.click(),setTimeout(()=>URL.revokeObjectURL(i),1e3)}var Qv={api:{listHistory:xd,restoreSnapshot:Rd,takeSnapshot:$d,getSnapshot:Sd,deleteSnapshot:Md,fetchBackup:Ad,restoreBackup:Fd,fetchImage:fo,storeImage:Bt},alert:t=>alert(t),confirm:t=>confirm(t),prompt:t=>prompt(t),download:sp,today:()=>new Date().toISOString().slice(0,10)},ew=t=>String(t?.message??t),Ho=class{host;deps;history=null;busy=!1;compare=null;constructor(e,n=Qv){this.host=e,this.deps=n}async loadHistory(){let{hass:e}=this.host;e&&(this.history=await this.deps.api.listHistory(e).catch(()=>[]),this.host.refresh())}timeOf(e){return new Date(e.saved_at*1e3).toLocaleString(this.host.hass?.language,{dateStyle:"short",timeStyle:"short"})}async restorePoint(e){let{hass:n,t:r}=this.host;!n||!this.deps.confirm(r("backup_restore_confirm",{time:this.timeOf(e)}))||(await this.deps.api.restoreSnapshot(n,e.id),this.host.say(r("backup_restored")),await this.loadHistory())}async saveVersion(){let{hass:e,t:n}=this.host,r=e?this.deps.prompt?.(n("version_name_prompt"))?.trim():null;!e||!r||(await this.deps.api.takeSnapshot(e,r.slice(0,60)),this.host.say(n("version_saved",{name:r})),await this.loadHistory())}async compareWith(e){let{hass:n}=this.host,r=this.deps.api.getSnapshot;if(!n||!r)return;if(this.compare?.snapshot.id===e.id)return this.compare=null,this.host.refresh();let i=Oe(await r(n,e.id));this.compare={snapshot:e,entries:Nh(i,this.host.doc)},this.host.refresh()}async deleteVersion(e){let{hass:n,t:r}=this.host,i=this.deps.api.deleteSnapshot;!n||!i||!this.deps.confirm(r("version_delete_confirm",{name:e.name??this.timeOf(e)}))||(await i(n,e.id),this.compare?.snapshot.id===e.id&&(this.compare=null),await this.loadHistory())}exportShareView(){let e=this.host.t,n=rp(this.host.doc,Mr(),e("share_view_title"),e("share_view_needs_js"));this.deps.download(`nextfloor-${e("share_view_file")}-${this.deps.today()}.html`,n,"text/html"),this.host.say(e("share_view_done"))}exportPlan(e){let n=this.host.t(e?"export_name_template":"export_name_backup");this.deps.download(`nextfloor-${n}-${this.deps.today()}.json`,JSON.stringify(np(this.host.doc,e),null,2))}async importPlan(e){let{hass:n,t:r}=this.host;if(!e||!n)return;let i,o=r("backup_import_confirm");try{if(/\.sh3d$/i.test(e.name)){let s=await Kh(new Uint8Array(await e.arrayBuffer()));i=s.building,o=`${r("import_sh3d_found",{...s.report})}
+`}function op(t){let e;try{e=JSON.parse(t)}catch{throw new Error("not_json")}let n=e,r=n?.format===tp?n.building:e;if(!Jv(r))throw new Error("not_plan");return r.floors.forEach(i=>i.background=null),Oe(r)}var ew=t=>!/^https?:\/\//.test(t)&&!t.startsWith("camera:");function sp(t){let e=new Set;for(let n of t.floors){n.background?.image_id&&e.add(n.background.image_id);let r=n.furniture.flatMap(i=>i.pictures??[]);for(let{image:i}of r)i&&ew(i)&&e.add(i)}return[...e]}function ap(t,e,n="application/json"){let r=document.createElement("a"),i=URL.createObjectURL(new Blob([e],{type:n}));Object.assign(r,{href:i,download:t}),r.click(),setTimeout(()=>URL.revokeObjectURL(i),1e3)}var tw={api:{listHistory:$d,restoreSnapshot:Ed,takeSnapshot:Sd,getSnapshot:Md,deleteSnapshot:Rd,fetchBackup:Fd,restoreBackup:Td,fetchImage:mo,storeImage:Wt},alert:t=>alert(t),confirm:t=>confirm(t),prompt:t=>prompt(t),download:ap,today:()=>new Date().toISOString().slice(0,10)},nw=t=>String(t?.message??t),Lo=class{host;deps;history=null;busy=!1;compare=null;constructor(e,n=tw){this.host=e,this.deps=n}async loadHistory(){let{hass:e}=this.host;e&&(this.history=await this.deps.api.listHistory(e).catch(()=>[]),this.host.refresh())}timeOf(e){return new Date(e.saved_at*1e3).toLocaleString(this.host.hass?.language,{dateStyle:"short",timeStyle:"short"})}async restorePoint(e){let{hass:n,t:r}=this.host;!n||!this.deps.confirm(r("backup_restore_confirm",{time:this.timeOf(e)}))||(await this.deps.api.restoreSnapshot(n,e.id),this.host.say(r("backup_restored")),await this.loadHistory())}async saveVersion(){let{hass:e,t:n}=this.host,r=e?this.deps.prompt?.(n("version_name_prompt"))?.trim():null;!e||!r||(await this.deps.api.takeSnapshot(e,r.slice(0,60)),this.host.say(n("version_saved",{name:r})),await this.loadHistory())}async compareWith(e){let{hass:n}=this.host,r=this.deps.api.getSnapshot;if(!n||!r)return;if(this.compare?.snapshot.id===e.id)return this.compare=null,this.host.refresh();let i=Oe(await r(n,e.id));this.compare={snapshot:e,entries:Bh(i,this.host.doc)},this.host.refresh()}async deleteVersion(e){let{hass:n,t:r}=this.host,i=this.deps.api.deleteSnapshot;!n||!i||!this.deps.confirm(r("version_delete_confirm",{name:e.name??this.timeOf(e)}))||(await i(n,e.id),this.compare?.snapshot.id===e.id&&(this.compare=null),await this.loadHistory())}exportShareView(){let e=this.host.t,n=ip(this.host.doc,Rr(),e("share_view_title"),e("share_view_needs_js"));this.deps.download(`nextfloor-${e("share_view_file")}-${this.deps.today()}.html`,n,"text/html"),this.host.say(e("share_view_done"))}exportPlan(e){let n=this.host.t(e?"export_name_template":"export_name_backup");this.deps.download(`nextfloor-${n}-${this.deps.today()}.json`,JSON.stringify(rp(this.host.doc,e),null,2))}async importPlan(e){let{hass:n,t:r}=this.host;if(!e||!n)return;let i,o=r("backup_import_confirm");try{if(/\.sh3d$/i.test(e.name)){let s=await jh(new Uint8Array(await e.arrayBuffer()));i=s.building,o=`${r("import_sh3d_found",{...s.report})}
-${o}`}else if(/\.ifc$/i.test(e.name)){let s=Jh(await e.text());i=s.building,o=`${r("import_ifc_found",{floors:s.report.floors,rooms:s.report.rooms})}
+${o}`}else if(/\.ifc$/i.test(e.name)){let s=Qh(await e.text());i=s.building,o=`${r("import_ifc_found",{floors:s.report.floors,rooms:s.report.rooms})}
${o}`}else if(/\.dxf$/i.test(e.name)){let s=Gh(await e.text());i=s.building,o=`${r("import_dxf_found",{rooms:s.report.rooms,walls:s.report.walls})}
-${o}`}else{let s=await e.text(),l=null;try{l=JSON.parse(s)}catch{}if(Zh(l)){let a=qh(l);i=a.building,o=`${r("import_roomplan_found",{rooms:a.report.rooms,openings:a.report.openings,skipped:a.report.furniture})}
+${o}`}else{let s=await e.text(),l=null;try{l=JSON.parse(s)}catch{}if(qh(l)){let a=Yh(l);i=a.building,o=`${r("import_roomplan_found",{rooms:a.report.rooms,openings:a.report.openings,skipped:a.report.furniture})}
-${o}`}else i=ip(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json",not_plan:"import_error_not_plan",not_zip:"import_error_sh3d",sh3d_no_xml:"import_error_sh3d",sh3d_empty:"import_error_sh3d_empty",dxf_empty:"import_error_dxf_empty",ifc_empty:"import_error_ifc_empty",roomplan_empty:"import_error_roomplan_empty"};this.deps.alert(a[l]?r(a[l]):r("backup_import_error",{error:l}));return}this.deps.confirm(o)&&(await this.deps.api.takeSnapshot(n).catch(()=>{}),this.host.adopt(i),this.host.say(r("backup_imported")))}async exportFull(){let{hass:e,t:n}=this.host;if(e){this.busy=!0,this.host.refresh();try{let r=await this.deps.api.fetchBackup(e),i={};for(let o of op(r.building))await this.deps.api.fetchImage(e,o).then(s=>i[o]=s,()=>{});this.deps.download(`nextfloor-${n("export_name_full")}-${this.deps.today()}.json`,JSON.stringify({...r,exported_at:new Date().toISOString(),images:i}))}catch(r){this.deps.alert(n("backup_import_error",{error:ew(r)}))}finally{this.busy=!1,this.host.refresh()}}}async importFull(e){let{hass:n,t:r}=this.host;if(!e||!n)return;let i;try{i=JSON.parse(await e.text())}catch{this.deps.alert(r("import_error_not_json"));return}if(i?.format!=="nextfloor-backup"||!i.building){this.deps.alert(r("backup_full_not_backup"));return}if(this.deps.confirm(r("backup_full_confirm"))){this.busy=!0,this.host.refresh();try{let o=await this.deps.api.restoreBackup(n,i.building,i.packs??[]),s=0;for(let[a,c]of Object.entries(i.images??{}))await this.deps.api.storeImage(n,a,c).then(()=>s++,()=>{});this.host.adopt(Oe(o.building)),this.host.packsChanged();let l=o.skipped.length>0?` ${r("backup_full_skipped",{packs:o.skipped.map(a=>a.id).join(", ")})}`:"";this.host.say(r("backup_full_restored",{packs:o.packs,pictures:s})+l)}catch(o){let{code:s,message:l}=o??{};this.deps.alert(r("backup_import_error",{error:l??s??String(o)}))}finally{this.busy=!1,this.host.refresh()}}}};var ap=(t,e,n="application/json,.json")=>m`{}),this.host.adopt(i),this.host.say(r("backup_imported")))}async exportFull(){let{hass:e,t:n}=this.host;if(e){this.busy=!0,this.host.refresh();try{let r=await this.deps.api.fetchBackup(e),i={};for(let o of sp(r.building))await this.deps.api.fetchImage(e,o).then(s=>i[o]=s,()=>{});this.deps.download(`nextfloor-${n("export_name_full")}-${this.deps.today()}.json`,JSON.stringify({...r,exported_at:new Date().toISOString(),images:i}))}catch(r){this.deps.alert(n("backup_import_error",{error:nw(r)}))}finally{this.busy=!1,this.host.refresh()}}}async importFull(e){let{hass:n,t:r}=this.host;if(!e||!n)return;let i;try{i=JSON.parse(await e.text())}catch{this.deps.alert(r("import_error_not_json"));return}if(i?.format!=="nextfloor-backup"||!i.building){this.deps.alert(r("backup_full_not_backup"));return}if(this.deps.confirm(r("backup_full_confirm"))){this.busy=!0,this.host.refresh();try{let o=await this.deps.api.restoreBackup(n,i.building,i.packs??[]),s=0;for(let[a,c]of Object.entries(i.images??{}))await this.deps.api.storeImage(n,a,c).then(()=>s++,()=>{});this.host.adopt(Oe(o.building)),this.host.packsChanged();let l=o.skipped.length>0?` ${r("backup_full_skipped",{packs:o.skipped.map(a=>a.id).join(", ")})}`:"";this.host.say(r("backup_full_restored",{packs:o.packs,pictures:s})+l)}catch(o){let{code:s,message:l}=o??{};this.deps.alert(r("backup_import_error",{error:l??s??String(o)}))}finally{this.busy=!1,this.host.refresh()}}}};var lp=(t,e,n="application/json,.json")=>m`${t} {let i=r.target,o=i.files?.[0];i.value="",e(o)}}
/>
- `,tw={added:"\uFF0B",removed:"\u2212",renamed:"\u270E",reshaped:"\u2922",moved:"\u2194"};function nw(t,e){let n=t.t;if(!e.length)return m`${n("version_same")}
`;let r=o=>o.kind.startsWith("furniture")?Ae(t.hass,o.name)||o.name:o.kind.startsWith("device")?String(t.hass?.states[o.name]?.attributes.friendly_name??o.name):o.kind.startsWith("opening")?n(o.name==="door"?"opening_door":o.name==="garage"?"opening_garage":"opening_window"):o.name,i=[...new Set(e.map(o=>o.floor))];return m`
+`,rw={added:"\uFF0B",removed:"\u2212",renamed:"\u270E",reshaped:"\u2922",moved:"\u2194"};function iw(t,e){let n=t.t;if(!e.length)return m`
${n("version_same")}
`;let r=o=>o.kind.startsWith("furniture")?Ae(t.hass,o.name)||o.name:o.kind.startsWith("device")?String(t.hass?.states[o.name]?.attributes.friendly_name??o.name):o.kind.startsWith("opening")?n(o.name==="door"?"opening_door":o.name==="garage"?"opening_garage":"opening_window"):o.name,i=[...new Set(e.map(o=>o.floor))];return m`
${S(n("version_diff_n",{n:e.length}))}
${i.map(o=>m`
${o}
- ${e.filter(s=>s.floor===o).map(s=>{let l=s.kind.slice(s.kind.indexOf("_")+1),a=typeof s.detail=="number"?`${s.detail>0?"+":""}${K(t.hass,s.detail,1)}`:s.detail??"";return m`${tw[l]??"\u2022"} ${n(`diff_${s.kind}`,{name:r(s),detail:a})} `})}
+ ${e.filter(s=>s.floor===o).map(s=>{let l=s.kind.slice(s.kind.indexOf("_")+1),a=typeof s.detail=="number"?`${s.detail>0?"+":""}${K(t.hass,s.detail,1)}`:s.detail??"";return m`${rw[l]??"\u2022"} ${n(`diff_${s.kind}`,{name:r(s),detail:a})} `})}
`)}
-
`}function lp(t,e){let n=t.t,r=e.history,i=r===null?S(n("loading")):r.length===0?S(n("backup_none")):m`
+
`}function cp(t,e){let n=t.t,r=e.history,i=r===null?S(n("loading")):r.length===0?S(n("backup_none")):m`
${r.map(o=>m`
${o.name?m`📌 ${o.name} · `:_}${e.timeOf(o)} · ${n("backup_summary",{rooms:o.rooms,furniture:o.furniture})}
@@ -662,19 +662,19 @@ ${o}`}else i=ip(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
${o.name?m`{e.deleteVersion(o)}}>✕ `:_}
- ${e.compare?.snapshot.id===o.id?nw(t,e.compare.entries):_}`)}
+ ${e.compare?.snapshot.id===o.id?iw(t,e.compare.entries):_}`)}
`;return m`
o.target.open&&void e.loadHistory()}>
${n("backup")}
${n("backup_history")}
${J(m`{e.saveVersion()}}>📌 ${n("version_save")} `)}
${i}
${n("backup_file")}
- ${J(m`e.exportPlan(!1)}>${n("backup_export")} `,m`e.exportPlan(!0)}>${n("backup_export_share")} `,m`e.exportShareView()}>🔗 ${n("share_view")} `,ap(n("backup_import"),o=>{e.importPlan(o)},"application/json,.json,.sh3d,.dxf,.ifc"))}
+ ${J(m`e.exportPlan(!1)}>${n("backup_export")} `,m`e.exportPlan(!0)}>${n("backup_export_share")} `,m`e.exportShareView()}>🔗 ${n("share_view")} `,lp(n("backup_import"),o=>{e.importPlan(o)},"application/json,.json,.sh3d,.dxf,.ifc"))}
${S(n("backup_hint"))} ${S(n("import_other_hint"))}
${n("backup_full")}
- ${J(m`e.exportFull()}>${e.busy?"\u2026":n("backup_full_export")} `,ap(n("backup_full_import"),o=>{e.importFull(o)}))}
+ ${J(m`e.exportFull()}>${e.busy?"\u2026":n("backup_full_export")} `,lp(n("backup_full_import"),o=>{e.importFull(o)}))}
${S(n("backup_full_hint"))}
- `}function cp(t,e){return t.states["weather.nextfloor_symcon"]?"weather.nextfloor_symcon":e&&t.states[e]?e:Object.keys(t.states).filter(n=>n.startsWith("weather.")).sort()[0]??null}var up=["body","wood","fabric","white","metal","dark"],dp={body:"#172238",wood:"#19233c",fabric:"#1a2644",white:"#1d2946",metal:"#2a3a60",dark:"#0b111f"};var yn=(t,e,n)=>Math.min(n,Math.max(e,t)),rw=t=>(Math.round(t)%360+360)%360,Xa=(t,e)=>rw(t+e);function hp(t,e,n){return n?[...new Set([...t,e])]:t.filter(r=>r!==e)}function pp(t,e,n){let r=t.t,i=s=>()=>n(Xa(e,s)),o=R`
+ `}function up(t,e){return t.states["weather.nextfloor_symcon"]?"weather.nextfloor_symcon":e&&t.states[e]?e:Object.keys(t.states).filter(n=>n.startsWith("weather.")).sort()[0]??null}var dp=["body","wood","fabric","white","metal","dark"],hp={body:"#172238",wood:"#19233c",fabric:"#1a2644",white:"#1d2946",metal:"#2a3a60",dark:"#0b111f"};var vn=(t,e,n)=>Math.min(n,Math.max(e,t)),ow=t=>(Math.round(t)%360+360)%360,Qa=(t,e)=>ow(t+e);function pp(t,e,n){return n?[...new Set([...t,e])]:t.filter(r=>r!==e)}function fp(t,e,n){let r=t.t,i=s=>()=>n(Qa(e,s)),o=R`
@@ -687,7 +687,7 @@ ${o}`}else i=ip(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
${o}
${r("compass_title")}
- ${E(t,r("north"),e,s=>n(Xa(s,0)),1)}
+ ${E(t,r("north"),e,s=>n(Qa(s,0)),1)}
⇅ ${r("compass_swap")}
↺ 90°
@@ -695,14 +695,14 @@ ${o}`}else i=ip(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
${S(r("compass_hint"))}
- `}var iw="https://tile.openstreetmap.org/{z}/{x}/{y}.png";var ow=40075016686e-3,Ja=Math.PI/180,mi=18,gi=.5,sw=160;function aw(t,e,n){let r=2**n,i=(e+180)/360*r,o=(1-Math.log(Math.tan(t*Ja)+1/Math.cos(t*Ja))/Math.PI)/2*r;return[i,o]}var lw=(t,e)=>ow*Math.cos(t*Ja)/2**e;function fp(t,e,n,r=sw){let[i,o]=aw(t,e,n),s=lw(t,n),l=r/s,a=2**n-1,c=[];for(let u=Math.floor(o-l);u<=Math.floor(o+l);u++)for(let d=Math.floor(i-l);d<=Math.floor(i+l);d++){if(u<0||u>a)continue;let p=(d%(a+1)+a+1)%(a+1);c.push({x:p,y:u,z:n,east:(d-i)*s,north:-(u-o)*s,size:s})}return c}function mp(t,e){return t.replace("{z}",String(e.z)).replace("{x}",String(e.x)).replace("{y}",String(e.y)).replace("{s}","abc"[(e.x+e.y)%3])}var gp=t=>t.url&&t.url.startsWith("https://")?t.url:iw;var Lo=t=>!!t&&t.on===!0&&Number.isFinite(t.lat)&&Number.isFinite(t.lon),_p=t=>({x:t.x??0,z:t.z??0,opacity:t.opacity??gi,zoom:t.zoom??mi});function cw(t){let e=[],n=[];for(let i of t.floors){for(let o of i.rooms)for(let[s,l]of o.points)e.push(s),n.push(l);for(let o of i.outdoor??[])for(let[s,l]of o.points)e.push(s),n.push(l)}if(!e.length)return[0,0];let r=i=>Math.round((Math.min(...i)+Math.max(...i))/2*100)/100;return[r(e),r(n)]}function bp(t,e){let[n,r]=cw(t);return{on:!0,lat:e?.lat??0,lon:e?.lon??0,x:n,z:r,opacity:gi,zoom:mi,url:null}}function yp(t,e,n){let r=i=>Math.round(i*100)/100;return{...t,x:r((t.x??0)+e),z:r((t.z??0)+n)}}function vp(t){let e=t.trim();return e===""?null:/^https:\/\/\S+$/.test(e)&&["{z}","{x}","{y}"].every(n=>e.includes(n))?e:void 0}var uw=["15","16","17","18","19"],dw=["1","5","20"],Co="5";function wp(t,e,n){let r=t.t,i=e.settings.map??null,o=t.hass?.config,s=Lo(i),l=u=>{if(!u)return n(i?{...i,on:!1}:null);n(i?{...i,on:!0}:bp(e,{lat:o?.latitude,lon:o?.longitude}))},a=u=>i&&n({...i,...u}),c=(u,d)=>()=>i&&n(yp(i,u*Number(Co),d*Number(Co)));return m`
+
`}var sw="https://tile.openstreetmap.org/{z}/{x}/{y}.png";var aw=40075016686e-3,el=Math.PI/180,gi=18,_i=.5,lw=160;function cw(t,e,n){let r=2**n,i=(e+180)/360*r,o=(1-Math.log(Math.tan(t*el)+1/Math.cos(t*el))/Math.PI)/2*r;return[i,o]}var uw=(t,e)=>aw*Math.cos(t*el)/2**e;function mp(t,e,n,r=lw){let[i,o]=cw(t,e,n),s=uw(t,n),l=r/s,a=2**n-1,c=[];for(let u=Math.floor(o-l);u<=Math.floor(o+l);u++)for(let d=Math.floor(i-l);d<=Math.floor(i+l);d++){if(u<0||u>a)continue;let p=(d%(a+1)+a+1)%(a+1);c.push({x:p,y:u,z:n,east:(d-i)*s,north:-(u-o)*s,size:s})}return c}function gp(t,e){return t.replace("{z}",String(e.z)).replace("{x}",String(e.x)).replace("{y}",String(e.y)).replace("{s}","abc"[(e.x+e.y)%3])}var _p=t=>t.url&&t.url.startsWith("https://")?t.url:sw;var Co=t=>!!t&&t.on===!0&&Number.isFinite(t.lat)&&Number.isFinite(t.lon),bp=t=>({x:t.x??0,z:t.z??0,opacity:t.opacity??_i,zoom:t.zoom??gi});function dw(t){let e=[],n=[];for(let i of t.floors){for(let o of i.rooms)for(let[s,l]of o.points)e.push(s),n.push(l);for(let o of i.outdoor??[])for(let[s,l]of o.points)e.push(s),n.push(l)}if(!e.length)return[0,0];let r=i=>Math.round((Math.min(...i)+Math.max(...i))/2*100)/100;return[r(e),r(n)]}function yp(t,e){let[n,r]=dw(t);return{on:!0,lat:e?.lat??0,lon:e?.lon??0,x:n,z:r,opacity:_i,zoom:gi,url:null}}function vp(t,e,n){let r=i=>Math.round(i*100)/100;return{...t,x:r((t.x??0)+e),z:r((t.z??0)+n)}}function wp(t){let e=t.trim();return e===""?null:/^https:\/\/\S+$/.test(e)&&["{z}","{x}","{y}"].every(n=>e.includes(n))?e:void 0}var hw=["15","16","17","18","19"],pw=["1","5","20"],No="5";function kp(t,e,n){let r=t.t,i=e.settings.map??null,o=t.hass?.config,s=Co(i),l=u=>{if(!u)return n(i?{...i,on:!1}:null);n(i?{...i,on:!0}:yp(e,{lat:o?.latitude,lon:o?.longitude}))},a=u=>i&&n({...i,...u}),c=(u,d)=>()=>i&&n(vp(i,u*Number(No),d*Number(No)));return m`
${D(t,r("map_on"),s,l,{title:r("map_hint")})}
${i&&i.on?m`
${E(t,r("map_lat"),i.lat,u=>a({lat:Math.max(-85,Math.min(85,u))}),1e-4)}
${E(t,r("map_lon"),i.lon,u=>a({lon:Math.max(-180,Math.min(180,u))}),1e-4)}
${o?.latitude!==void 0&&o.longitude!==void 0?m`
a({lat:o.latitude,lon:o.longitude})}>${r("map_use_ha")} `:_}
- ${E(t,r("map_opacity"),Math.round((i.opacity??gi)*100),u=>a({opacity:Math.max(5,Math.min(100,u))/100}),5,5)}
- ${L(t,r("map_zoom"),String(i.zoom??mi),uw.map(u=>[u,u==="15"?`${u} \xB7 ${r("map_zoom_coarse")}`:u==="19"?`${u} \xB7 ${r("map_zoom_fine")}`:u]),u=>a({zoom:Number(u)}))}
+ ${E(t,r("map_opacity"),Math.round((i.opacity??_i)*100),u=>a({opacity:Math.max(5,Math.min(100,u))/100}),5,5)}
+ ${H(t,r("map_zoom"),String(i.zoom??gi),hw.map(u=>[u,u==="15"?`${u} \xB7 ${r("map_zoom_coarse")}`:u==="19"?`${u} \xB7 ${r("map_zoom_fine")}`:u]),u=>a({zoom:Number(u)}))}
${r("map_move")}
@@ -711,47 +711,47 @@ ${o}`}else i=ip(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
▶
▼
- ${L(t,r("map_step"),Co,dw.map(u=>[u,`${u} m`]),u=>Co=u,{wide:!1})}
+ ${H(t,r("map_step"),No,pw.map(u=>[u,`${u} m`]),u=>No=u,{wide:!1})}
- ${V(t,r("map_url"),i.url??"",u=>{let d=vp(u);d!==void 0&&a({url:d})},{wide:!0,placeholder:"https://\u2026/{z}/{x}/{y}.png",maxlength:300})}
+ ${V(t,r("map_url"),i.url??"",u=>{let d=wp(u);d!==void 0&&a({url:d})},{wide:!0,placeholder:"https://\u2026/{z}/{x}/{y}.png",maxlength:300})}
${S(r("map_hint"),"nf-wide")}
`:_}
-
`}var hw=["none","flat","gable","custom"];function pw(t,e,n){let r=t.t,i=!!e,o=s=>n({color:null,image:null,dim:.35,...e??{},...s});return m`${r("backdrop")}
+ `}var fw=["none","flat","gable","custom"];function mw(t,e,n){let r=t.t,i=!!e,o=s=>n({color:null,image:null,dim:.35,...e??{},...s});return m`${r("backdrop")}
${D(t,r("backdrop"),i,s=>n(s?{color:"#101828",image:null,dim:.35}:null))}
${i?m`${r("backdrop_color")}
o({color:s.target.value})}
/>
- ${E(t,r("backdrop_dim"),Math.round((e?.dim??.35)*100),s=>o({dim:yn(s,0,80)/100}),5,0)}
+ ${E(t,r("backdrop_dim"),Math.round((e?.dim??.35)*100),s=>o({dim:vn(s,0,80)/100}),5,0)}
${V(t,r("backdrop_image"),e?.image??"",s=>o({image:s||null}),{wide:!0,placeholder:"/local/hintergrund.jpg"})}
- ${S(r("backdrop_hint"),"nf-wide")}`:_}`}function fw(t,e,n){let r=t.t,i=O(t.hass,o=>!e.includes(o)&&/^(sensor|binary_sensor|alarm_control_panel|weather|input_|counter|lock|climate|person|sun)\b/.test(o));return m`${r("status_entities")}
+ ${S(r("backdrop_hint"),"nf-wide")}`:_}`}function gw(t,e,n){let r=t.t,i=O(t.hass,o=>!e.includes(o)&&/^(sensor|binary_sensor|alarm_control_panel|weather|input_|counter|lock|climate|person|sun)\b/.test(o));return m`${r("status_entities")}
${e.length?m`
${e.map(o=>m`${B(t.hass,o)}
${t.admin?m`n(e.filter(s=>s!==o))}>× `:_} `)}
`:_}
${e.length<12?z(t,r("status_add"),null,void 0,i,o=>o&&o!=="none"&&n([...e,o]),{excluded:o=>e.includes(o)?"Diese Variable ist in der Statusanzeige bereits verkn\xFCpft.":void 0}):_}
- ${S(r("status_entities_hint"),"nf-wide")}`}function kp(t,e){let n=t.t,r=t.doc.settings,i=c=>t.replace({...structuredClone(t.doc),settings:{...structuredClone(t.doc.settings),...c}}),o=c=>i({roof:{...r.roof,...c}}),s=hw.map(c=>[c,n(`roof_${c}`)]),l=r.weather_effects??uu,a=r.roof.type==="gable";return m`
+ ${S(r("status_entities_hint"),"nf-wide")}`}function xp(t,e){let n=t.t,r=t.doc.settings,i=c=>t.replace({...structuredClone(t.doc),settings:{...structuredClone(t.doc.settings),...c}}),o=c=>i({roof:{...r.roof,...c}}),s=fw.map(c=>[c,n(`roof_${c}`)]),l=r.weather_effects??hu,a=r.roof.type==="gable";return m`
${n("settings")}
- ${E(t,n("wall_exterior"),r.wall_exterior,c=>i({wall_exterior:yn(c,.02,1)}),.01,.02)}
- ${E(t,n("wall_interior"),r.wall_interior,c=>i({wall_interior:yn(c,.02,1)}),.01,.02)}
- ${Ge(t,n("wall_paint_outside"),r.wall_paint_outside,Ui,c=>i({wall_paint_outside:c}))}
- ${Ge(t,n("wall_paint_inside"),r.wall_paint_inside,Zi,c=>i({wall_paint_inside:c}))}
+ ${E(t,n("wall_exterior"),r.wall_exterior,c=>i({wall_exterior:vn(c,.02,1)}),.01,.02)}
+ ${E(t,n("wall_interior"),r.wall_interior,c=>i({wall_interior:vn(c,.02,1)}),.01,.02)}
+ ${Ue(t,n("wall_paint_outside"),r.wall_paint_outside,Zi,c=>i({wall_paint_outside:c}))}
+ ${Ue(t,n("wall_paint_inside"),r.wall_paint_inside,qi,c=>i({wall_paint_inside:c}))}
${S(n("wall_paint_hint"),"nf-wide")}
- ${up.map(c=>Ge(t,n(`furn_color_${c}`),r.furniture_colors?.[c],dp[c],u=>{let d={...r.furniture_colors,[c]:u};u||delete d[c],i({furniture_colors:Object.keys(d).length?d:null})}))}
+ ${dp.map(c=>Ue(t,n(`furn_color_${c}`),r.furniture_colors?.[c],hp[c],u=>{let d={...r.furniture_colors,[c]:u};u||delete d[c],i({furniture_colors:Object.keys(d).length?d:null})}))}
${S(n("furn_color_hint"),"nf-wide")}
- ${E(t,n("grid"),r.grid,c=>i({grid:yn(c,.01,1)}),.01,.01)}
- ${L(t,n("units"),r.units==="imperial"?"imperial":"metric",[["metric",n("units_metric")],["imperial",n("units_imperial")]],c=>i({units:c==="imperial"?"imperial":null}),{title:n("units_hint")})}
- ${pp(t,r.north,c=>i({north:c}))}
- ${wp(t,t.doc,c=>i({map:c}))}
- ${L(t,n("roof"),r.roof.type,s,c=>c==="custom"?e.useRoofSections():o({type:c}),{wide:!0})}
- ${a?L(t,n("roof_ridge"),r.roof.ridge==="short"?"short":"long",[["long",n("roof_ridge_long")],["short",n("roof_ridge_short")]],c=>o({ridge:c==="short"?"short":null}),{wide:!0}):_}
- ${a?E(t,n("roof_pitch"),r.roof.pitch,c=>o({pitch:yn(c,5,60)}),1,5):_}
- ${r.roof.type!=="none"?E(t,n("roof_overhang"),r.roof.overhang,c=>o({overhang:yn(c,0,2)}),.05,0):_}
- ${X(t.hass)?Sh(t,r,i):t.hass?z(t,n("weather_entity"),r.weather_entity??null,cp(t.hass,null),O(t.hass,c=>c.startsWith("weather.")),c=>i({weather_entity:c})):_}
+ ${E(t,n("grid"),r.grid,c=>i({grid:vn(c,.01,1)}),.01,.01)}
+ ${H(t,n("units"),r.units==="imperial"?"imperial":"metric",[["metric",n("units_metric")],["imperial",n("units_imperial")]],c=>i({units:c==="imperial"?"imperial":null}),{title:n("units_hint")})}
+ ${fp(t,r.north,c=>i({north:c}))}
+ ${kp(t,t.doc,c=>i({map:c}))}
+ ${H(t,n("roof"),r.roof.type,s,c=>c==="custom"?e.useRoofSections():o({type:c}),{wide:!0})}
+ ${a?H(t,n("roof_ridge"),r.roof.ridge==="short"?"short":"long",[["long",n("roof_ridge_long")],["short",n("roof_ridge_short")]],c=>o({ridge:c==="short"?"short":null}),{wide:!0}):_}
+ ${a?E(t,n("roof_pitch"),r.roof.pitch,c=>o({pitch:vn(c,5,60)}),1,5):_}
+ ${r.roof.type!=="none"?E(t,n("roof_overhang"),r.roof.overhang,c=>o({overhang:vn(c,0,2)}),.05,0):_}
+ ${X(t.hass)?Mh(t,r,i):t.hass?z(t,n("weather_entity"),r.weather_entity??null,up(t.hass,null),O(t.hass,c=>c.startsWith("weather.")),c=>i({weather_entity:c})):_}
${n("weather_effects")}
- ${cu.map(c=>D(t,n(`weather_effect_${c}`),l.includes(c),u=>i({weather_effects:hp(l,c,u)}),{wide:!1}))}
+ ${du.map(c=>D(t,n(`weather_effect_${c}`),l.includes(c),u=>i({weather_effects:pp(l,c,u)}),{wide:!1}))}
${D(t,n("rain_warning"),r.rain_warning!==!1,c=>i({rain_warning:c}))}
${t.hass&&!X(t.hass)&&r.rain_warning!==!1?z(t,n("rain_sensor"),r.rain_sensor??null,void 0,O(t.hass,c=>/^(binary_sensor|sensor)\./.test(c)),c=>i({rain_sensor:c==="none"?null:c})):_}
${t.hass&&!X(t.hass)&&r.rain_warning!==!1&&r.rain_sensor&&r.rain_sensor!=="none"?D(t,n("rain_sensor_inverted"),!!r.rain_sensor_inverted,c=>i({rain_sensor_inverted:c||void 0}),{title:n("rain_sensor_inverted_hint")}):_}
@@ -759,9 +759,9 @@ ${o}`}else i=ip(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
${S(n("outage_hint"),"nf-wide")}
${D(t,n("contact_warning"),!!r.contact_warning,c=>i({contact_warning:c||void 0}),{title:n("contact_warning_hint")})}
${D(t,n("night_lock_warning"),!!r.night_lock_warning,c=>i({night_lock_warning:c||void 0}),{title:n("night_lock_warning_hint")})}
- ${L(t,n("room_double_tap"),r.room_double_tap??"area",[["area",n("room_double_tap_area")],["plan",n("room_double_tap_plan")],["off",n("room_double_tap_off")]],c=>i({room_double_tap:c==="plan"||c==="off"?c:null}),{title:n("room_double_tap_hint")})}
+ ${H(t,n("room_double_tap"),r.room_double_tap??"area",[["area",n("room_double_tap_area")],["plan",n("room_double_tap_plan")],["off",n("room_double_tap_off")]],c=>i({room_double_tap:c==="plan"||c==="off"?c:null}),{title:n("room_double_tap_hint")})}
${D(t,n("motion_markers_active"),!!r.motion_markers_active,c=>i({motion_markers_active:c||void 0}),{title:n("motion_markers_active_hint")})}
- ${t.hass?fw(t,r.status_entities??[],c=>i({status_entities:c.length?c:null})):_}
+ ${t.hass?gw(t,r.status_entities??[],c=>i({status_entities:c.length?c:null})):_}
${X(t.hass)?_:m`${t.hass?z(t,n("announce_tts"),r.announce_tts??null,void 0,O(t.hass,c=>c.startsWith("tts.")),c=>i({announce_tts:c==="none"?null:c})):_}
${n("announce_phrases")}
@@ -779,31 +779,31 @@ ${o}`}else i=ip(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
${S(n("announce_phrases_hint"),"nf-wide")}`}
${D(t,n("sun_patches"),r.sun_patches!==!1,c=>i({sun_patches:c}),{title:n("sun_patches_hint")})}
${D(t,n("sun_arc"),r.sun_arc===!0,c=>i({sun_arc:c}),{title:n("sun_arc_hint")})}
- ${pw(t,r.backdrop??null,c=>i({backdrop:c}))}
+ ${mw(t,r.backdrop??null,c=>i({backdrop:c}))}
${S(X(t.hass)?n("north_hint"):`${n("north_hint")} ${n("weather_entity_hint")}`)}
- `}function xp(t,e){let n=t.floors.flatMap(f=>f.furniture.map(g=>({floor:f,item:g}))),r=f=>n.filter(g=>g.item.type===f),i=f=>!!ho(f.item,e),o=f=>({kind:"device",...f}),[s,l,a,c,u]=[t.settings.roof.solar??[],r("meter"),r("inverter"),r("home_battery"),r("grid_point")],d=!!t.energy.grid||l.some(i),p=!!t.energy.solar||a.length>0&&a.every(i),h=!!t.energy.battery||c.every(f=>i(f)&&f.item.soc&&f.item.soc!=="none");return[s.length>0?{state:"ok",label:"chk_solar",target:{kind:"solar-field",id:s[0].id}}:{state:"todo",label:"chk_solar_add",target:{kind:"add-solar-field"}},l.length>0?{state:d?"ok":"todo",label:d?"chk_meter":"chk_meter_sensor",target:o(l[0])}:{state:"todo",label:"chk_meter_add",target:{kind:"add-device",type:"meter"}},a.length>0?{state:p?"ok":"todo",label:p?"chk_inverter":"chk_inverter_sensor",target:o(a.find(f=>!i(f))??a[0])}:{state:"todo",label:"chk_inverter_add",target:{kind:"add-device",type:"inverter"}},c.length>0?{state:h?"ok":"todo",label:h?"chk_battery":"chk_battery_sensor",target:o(c[0])}:{state:"opt",label:"chk_battery_opt",target:{kind:"add-device",type:"home_battery"}},u.length>0?{state:"ok",label:"chk_grid",target:o(u[0])}:{state:"opt",label:"chk_grid_opt",target:{kind:"add-device",type:"grid_point"}}]}function _i(t,e){let n=[];for(let r of t.floors)for(let i of r.furniture)i.type===e&&n.push({id:i.id,floorId:r.id,x:i.x,z:i.z,y:Math.max(.4,Math.min(1.4,i.h*.8))});return n}function mw(t){if(!t?.rooms.length)return null;let e=0,n=0,r=0;for(let i of t.rooms)for(let[o,s]of i.points)e+=o,n+=s,r++;return r?{floorId:t.id,x:e/r,z:n/r,y:1}:null}function gw(t){let e=qn(t);return _i(t,"meter").find(n=>!e.has(n.id))??_i(t,"inverter")[0]??mw(_o(t))}function _w(t,e){let n=_i(t,"grid_point")[0];if(n)return n;let r=t.floors.find(l=>l.id===e.floorId);if(!r?.rooms.length)return null;let i=1/0,o=-1/0,s=-1/0;for(let l of r.rooms)for(let[a,c]of l.points)i=Math.min(i,a),o=Math.max(o,a),s=Math.max(s,c);return{floorId:e.floorId,x:Math.max(i,Math.min(o,e.x)),z:s+3,y:.2}}function $p(t){let e=[],n=gw(t);if(!n)return e;let r=new Set(t.floors.flatMap(o=>o.furniture).filter(o=>si(t,o)).map(o=>o.id)),i=_i(t,"inverter").find(o=>!r.has(o.id));for(let o of t.settings.roof.solar??[])e.push({key:`solar:${o.id}`,kind:"solar",id:o.id});_i(t,"home_battery").some(o=>!r.has(o.id))&&e.push({key:"battery",kind:"battery",id:null}),i&&(i.floorId!==n.floorId||i.x!==n.x||i.z!==n.z)&&e.push({key:"inverter",kind:"inverter",id:null}),_w(t,n)&&e.push({key:"grid",kind:"grid",id:null});for(let o of t.floors.flatMap(s=>s.furniture))r.has(o.id)&&(o.type==="inverter"?e.push({key:`inverter:${o.id}`,kind:"inverter",id:o.id}):o.type==="home_battery"&&e.push({key:`battery:${o.id}`,kind:"battery",id:o.id}));for(let o of qn(t))e.push({key:`meter:${o}`,kind:"meter",id:o});return e}var Sp=(t,e)=>t.energy.routes?.find(n=>n.key===e&&n.points.length>0);var bw={ok:"\u2713",todo:"\u25CB",opt:"\xB7"},Rp=t=>t.hass?Me(t.hass,t.doc.floors):new Map,yw=Ke,Ep=(t,e)=>e.name||t.t(`furn_${e.type}`);function Ap(t,e){let n=xp(t.doc,Rp(t)),r=n.filter(i=>i.state==="ok").length;return m` `}function $p(t,e){let n=t.floors.flatMap(f=>f.furniture.map(g=>({floor:f,item:g}))),r=f=>n.filter(g=>g.item.type===f),i=f=>!!po(f.item,e),o=f=>({kind:"device",...f}),[s,l,a,c,u]=[t.settings.roof.solar??[],r("meter"),r("inverter"),r("home_battery"),r("grid_point")],d=!!t.energy.grid||l.some(i),p=!!t.energy.solar||a.length>0&&a.every(i),h=!!t.energy.battery||c.every(f=>i(f)&&f.item.soc&&f.item.soc!=="none");return[s.length>0?{state:"ok",label:"chk_solar",target:{kind:"solar-field",id:s[0].id}}:{state:"todo",label:"chk_solar_add",target:{kind:"add-solar-field"}},l.length>0?{state:d?"ok":"todo",label:d?"chk_meter":"chk_meter_sensor",target:o(l[0])}:{state:"todo",label:"chk_meter_add",target:{kind:"add-device",type:"meter"}},a.length>0?{state:p?"ok":"todo",label:p?"chk_inverter":"chk_inverter_sensor",target:o(a.find(f=>!i(f))??a[0])}:{state:"todo",label:"chk_inverter_add",target:{kind:"add-device",type:"inverter"}},c.length>0?{state:h?"ok":"todo",label:h?"chk_battery":"chk_battery_sensor",target:o(c[0])}:{state:"opt",label:"chk_battery_opt",target:{kind:"add-device",type:"home_battery"}},u.length>0?{state:"ok",label:"chk_grid",target:o(u[0])}:{state:"opt",label:"chk_grid_opt",target:{kind:"add-device",type:"grid_point"}}]}function bi(t,e){let n=[];for(let r of t.floors)for(let i of r.furniture)i.type===e&&n.push({id:i.id,floorId:r.id,x:i.x,z:i.z,y:Math.max(.4,Math.min(1.4,i.h*.8))});return n}function _w(t){if(!t?.rooms.length)return null;let e=0,n=0,r=0;for(let i of t.rooms)for(let[o,s]of i.points)e+=o,n+=s,r++;return r?{floorId:t.id,x:e/r,z:n/r,y:1}:null}function bw(t){let e=qn(t);return bi(t,"meter").find(n=>!e.has(n.id))??bi(t,"inverter")[0]??_w(bo(t))}function yw(t,e){let n=bi(t,"grid_point")[0];if(n)return n;let r=t.floors.find(l=>l.id===e.floorId);if(!r?.rooms.length)return null;let i=1/0,o=-1/0,s=-1/0;for(let l of r.rooms)for(let[a,c]of l.points)i=Math.min(i,a),o=Math.max(o,a),s=Math.max(s,c);return{floorId:e.floorId,x:Math.max(i,Math.min(o,e.x)),z:s+3,y:.2}}function Sp(t){let e=[],n=bw(t);if(!n)return e;let r=new Set(t.floors.flatMap(o=>o.furniture).filter(o=>ai(t,o)).map(o=>o.id)),i=bi(t,"inverter").find(o=>!r.has(o.id));for(let o of t.settings.roof.solar??[])e.push({key:`solar:${o.id}`,kind:"solar",id:o.id});bi(t,"home_battery").some(o=>!r.has(o.id))&&e.push({key:"battery",kind:"battery",id:null}),i&&(i.floorId!==n.floorId||i.x!==n.x||i.z!==n.z)&&e.push({key:"inverter",kind:"inverter",id:null}),yw(t,n)&&e.push({key:"grid",kind:"grid",id:null});for(let o of t.floors.flatMap(s=>s.furniture))r.has(o.id)&&(o.type==="inverter"?e.push({key:`inverter:${o.id}`,kind:"inverter",id:o.id}):o.type==="home_battery"&&e.push({key:`battery:${o.id}`,kind:"battery",id:o.id}));for(let o of qn(t))e.push({key:`meter:${o}`,kind:"meter",id:o});return e}var Mp=(t,e)=>t.energy.routes?.find(n=>n.key===e&&n.points.length>0);var vw={ok:"\u2713",todo:"\u25CB",opt:"\xB7"},Ep=t=>t.hass?Me(t.hass,t.doc.floors):new Map,ww=Ke,Ap=(t,e)=>e.name||t.t(`furn_${e.type}`);function Fp(t,e){let n=$p(t.doc,Ep(t)),r=n.filter(i=>i.state==="ok").length;return m`
☑ ${t.t("chk_title")} ${r}/${n.length}
${S(t.t("chk_hint"))}
${n.map(i=>m`e.follow(i.target)}>
- ${bw[i.state]} ${t.t(i.label)}
+ ${vw[i.state]} ${t.t(i.label)}
`)}
- `}function Fp(t,e){let n=t.doc.floors.flatMap(r=>r.furniture.filter(i=>yw.includes(i.type)).map(i=>({floor:r,item:i})));return m``}function Tp(t,e){let n=t.doc.floors.flatMap(r=>r.furniture.filter(i=>ww.includes(i.type)).map(i=>({floor:r,item:i})));return m`
⚡ ${t.t("energy_devices")}
${S(t.t("energy_devices_hint"))}
${n.length>0?m`
${n.map(({floor:r,item:i})=>m`
- e.openDevice(r,i)}>${Ep(t,i)} · ${r.name}
+ e.openDevice(r,i)}>${Ap(t,i)} · ${r.name}
`)}
`:_}
${Ke.map(r=>m`e.addDevice(r)}>+ ${t.t(`furn_${r}`)} `)}
- `}var Mp=(t,e,n)=>m`${t.t(e)} ${t.t("energy_sign_flip")}
`;function Tp(t,e){let{energy:n}=t.doc,r=(y,v)=>t.hass?.states[y]?.attributes[v],i=O(t.hass,y=>Hn(t.hass,y)),o=O(t.hass,y=>me(y)&&r(y,"device_class")==="battery"),s=O(t.hass,y=>me(y)&&(r(y,"device_class")==="monetary"||/\/(kWh|MWh)$/.test(r(y,"unit_of_measurement")??""))),l=Rp(t),a=Mo(t.doc,y=>ho(y,l)),c=y=>t.replace({...structuredClone(t.doc),energy:{...t.doc.energy,...y}}),u=O(t.hass,y=>me(y)&&["gas","water","volume_flow_rate"].includes(r(y,"device_class")??"")),d=y=>v=>c({[y]:v==="none"?null:v}),p=t.hass?Ca(t.hass,t.doc,[],a):null,h=!!p&&(p.solar??0)<20,f=h&&p.grid!==null&&p.grid<-50,g=h&&p.battery!==null&&p.battery<-50&&(p.grid??0)<=0,b=(y,v)=>D(t,t.t("energy_invert"),y,w=>c(v(w)));return m``}var Rp=(t,e,n)=>m`${t.t(e)} ${t.t("energy_sign_flip")}
`;function zp(t,e){let{energy:n}=t.doc,r=(y,v)=>t.hass?.states[y]?.attributes[v],i=O(t.hass,y=>Hn(t.hass,y)),o=O(t.hass,y=>me(y)&&r(y,"device_class")==="battery"),s=O(t.hass,y=>me(y)&&(r(y,"device_class")==="monetary"||/\/(kWh|MWh)$/.test(r(y,"unit_of_measurement")??""))),l=Ep(t),a=Ro(t.doc,y=>po(y,l)),c=y=>t.replace({...structuredClone(t.doc),energy:{...t.doc.energy,...y}}),u=O(t.hass,y=>me(y)&&["gas","water","volume_flow_rate"].includes(r(y,"device_class")??"")),d=y=>v=>c({[y]:v==="none"?null:v}),p=t.hass?Ba(t.hass,t.doc,[],a):null,h=!!p&&(p.solar??0)<20,f=h&&p.grid!==null&&p.grid<-50,g=h&&p.battery!==null&&p.battery<-50&&(p.grid??0)<=0,b=(y,v)=>D(t,t.t("energy_invert"),y,w=>c(v(w)));return m`
⚖ ${t.t("energy_balance")}
${S(t.t("energy_balance_hint"))}
- ${f?Mp(t,"energy_sign_grid",()=>c({grid_invert:!n.grid_invert})):_}
- ${g?Mp(t,"energy_sign_battery",()=>c({battery_invert:!n.battery_invert})):_}
+ ${f?Rp(t,"energy_sign_grid",()=>c({grid_invert:!n.grid_invert})):_}
+ ${g?Rp(t,"energy_sign_battery",()=>c({battery_invert:!n.battery_invert})):_}
${z(t,t.t("energy_grid"),n.grid,a.grid,i,d("grid"))}
${b(n.grid_invert,y=>({grid_invert:y}))}
@@ -828,19 +828,19 @@ ${o}`}else i=ip(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
${n.advanced?D(t,t.t("energy_show_unmetered"),!!n.show_unmetered,y=>c({show_unmetered:y})):_}
${n.advanced?S(t.t("energy_show_unmetered_hint")):_}
- `}var zp=t=>m``}var Pp=t=>m`
⚡ ${t.t("feature_name_energy")}
${S(t.t("feature_text_energy"))}
- `;function Pp(t){let e=(n,r,i)=>m`${r} ${t.t(i)} `;return m``;function Dp(t){let e=(n,r,i)=>m`${r} ${t.t(i)} `;return m`
${t.t("help_title")}
${S(t.t("help_hint"))}
${e("issues/new/choose","\u{1F41E}","help_issue")}${e("discussions/categories/ideas","\u{1F4A1}","help_idea")}
- `}function vw(t,e){let n=t.t,r=t.doc.floors.flatMap(o=>o.furniture).find(o=>o.id===e.id),i=r?Ep(t,r):"";switch(e.kind){case"solar":{let o=t.doc.settings.roof.solar??[],s=o.findIndex(l=>l.id===e.id);return n("route_conn_solar",{name:o[s]?.name||`${n("solar_field")} ${s+1}`})}case"battery":return e.id?n("route_conn_device",{name:i}):n("route_conn_battery");case"inverter":return e.id?n("route_conn_device",{name:i}):n("route_conn_inverter");case"grid":return n("route_conn_grid");case"meter":return n("route_conn_meter",{name:i})}}function Dp(t,e){let n=$p(t.doc);if(!n.length)return _;let r=t.t,i=e.draft;return m``}function kw(t,e){let n=t.t,r=t.doc.floors.flatMap(o=>o.furniture).find(o=>o.id===e.id),i=r?Ap(t,r):"";switch(e.kind){case"solar":{let o=t.doc.settings.roof.solar??[],s=o.findIndex(l=>l.id===e.id);return n("route_conn_solar",{name:o[s]?.name||`${n("solar_field")} ${s+1}`})}case"battery":return e.id?n("route_conn_device",{name:i}):n("route_conn_battery");case"inverter":return e.id?n("route_conn_device",{name:i}):n("route_conn_inverter");case"grid":return n("route_conn_grid");case"meter":return n("route_conn_meter",{name:i})}}function Ip(t,e){let n=Sp(t.doc);if(!n.length)return _;let r=t.t,i=e.draft;return m`
〰 ${r("energy_routes")}
${S(r("energy_routes_hint"))}
- ${n.map(o=>{let s=Sp(t.doc,o.key),l=i?.key===o.key;return m`
-
${vw(t,o)} · ${s?r("route_points",{n:s.points.length}):r("route_none")}
+ ${n.map(o=>{let s=Mp(t.doc,o.key),l=i?.key===o.key;return m`
+
${kw(t,o)} · ${s?r("route_points",{n:s.points.length}):r("route_none")}
${l?m`
${r("route_drawing",{n:i.points.length})}
e.undoPoint()}>↶ ${r("route_undo")}
@@ -853,37 +853,37 @@ ${o}`}else i=ip(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
${s?D(t,r("route_cable"),!!s.cable,a=>e.setCable(o.key,a),{title:r("route_cable_hint")}):_}`}
`})}
- `}var lt=(t,e)=>e.map(n=>t.toScreen(n).join(",")).join(" ");function No(t,e,n,r,i,o){let[[s,l],[a,c]]=[t.toScreen(e),t.toScreen(n)];if(Math.hypot(a-s,c-l)<=36)return _;let[u,d]=[(s+a)/2,(l+c)/2];return R`
`}var Ip=(t,e)=>R`
`,ww=(t,e,n)=>R`
${Ip(...t.toScreen(e))} `,kw=(t,e,n)=>R`
${Ip(...t.toScreen(e))} `;function xw(t,e,n,r){let{t:i,hass:o}=t.host,s=n.dormer?i("roof_dormer"):n.open?i("roof_open_short"):i(`roof_shape_${n.shape}`);return`${e.isFixed(n)?"\u{1F512} ":""}${r+1} \xB7 ${s} \xB7 ${K(o,ln(n),1)} m`}function Qa(t,e){let n=t.host.doc.settings.roof,r=n.type==="custom"?n.sections??[]:[],i=t.host.admin,o=(s,l)=>{let a=s.id===e.sectionId,c=xe(s),u=(s.shape==="flat"||s.shape==="parapet")&&s.points&&s.points.length>=3?s.points:null,d=go(r,s),p=d?xe(fa(d,s)):c,h=u??[p.at(p.u0,0),p.at(p.u1,0),p.at(p.u1,p.w),p.at(p.u0,p.w)],g=((s.shape==="flat"||s.shape==="parapet"?null:cn(s,{u0:0,u1:0,a:0,b:0}))?.ridges??[]).map(([N,W])=>{let[q,we]=t.toScreen(c.at(N[0],N[1])),[At,j]=t.toScreen(c.at(W[0],W[1]));return R`
`}),[b,y]=t.toScreen(c.at((c.u0+c.u1)/2,c.w/2)),v=a&&i&&!e.isFixed(s),w=[[0,0],[1,0],[1,1],[0,1]],x=s.shape==="flat"||s.shape==="parapet",[k,M,A,T]=[Math.min(s.x0,s.x1),Math.max(s.x0,s.x1),Math.min(s.z0,s.z1),Math.max(s.z0,s.z1)],F=u??(s.rotation?Hr(s):[[k,A],[M,A],[M,T],[k,T]]),H=v&&x?F.map((N,W)=>No(t,N,F[(W+1)%F.length],"roof",s.id,W)):_,P=v?R`${H}${u?u.map((N,W)=>ww(t,N,`${s.id}:${W}`)):w.map(([N,W])=>kw(t,[N?M:k,W?T:A],`${s.id}:${N}:${W}`))}`:_;return R`
+ `}var lt=(t,e)=>e.map(n=>t.toScreen(n).join(",")).join(" ");function Bo(t,e,n,r,i,o){let[[s,l],[a,c]]=[t.toScreen(e),t.toScreen(n)];if(Math.hypot(a-s,c-l)<=36)return _;let[u,d]=[(s+a)/2,(l+c)/2];return R` `}var Op=(t,e)=>R` `,xw=(t,e,n)=>R`${Op(...t.toScreen(e))} `,$w=(t,e,n)=>R`${Op(...t.toScreen(e))} `;function Sw(t,e,n,r){let{t:i,hass:o}=t.host,s=n.dormer?i("roof_dormer"):n.open?i("roof_open_short"):i(`roof_shape_${n.shape}`);return`${e.isFixed(n)?"\u{1F512} ":""}${r+1} \xB7 ${s} \xB7 ${K(o,cn(n),1)} m`}function tl(t,e){let n=t.host.doc.settings.roof,r=n.type==="custom"?n.sections??[]:[],i=t.host.admin,o=(s,l)=>{let a=s.id===e.sectionId,c=$e(s),u=(s.shape==="flat"||s.shape==="parapet")&&s.points&&s.points.length>=3?s.points:null,d=_o(r,s),p=d?$e(ga(d,s)):c,h=u??[p.at(p.u0,0),p.at(p.u1,0),p.at(p.u1,p.w),p.at(p.u0,p.w)],g=((s.shape==="flat"||s.shape==="parapet"?null:un(s,{u0:0,u1:0,a:0,b:0}))?.ridges??[]).map(([N,W])=>{let[q,ke]=t.toScreen(c.at(N[0],N[1])),[At,j]=t.toScreen(c.at(W[0],W[1]));return R` `}),[b,y]=t.toScreen(c.at((c.u0+c.u1)/2,c.w/2)),v=a&&i&&!e.isFixed(s),w=[[0,0],[1,0],[1,1],[0,1]],x=s.shape==="flat"||s.shape==="parapet",[k,M,A,T]=[Math.min(s.x0,s.x1),Math.max(s.x0,s.x1),Math.min(s.z0,s.z1),Math.max(s.z0,s.z1)],F=u??(s.rotation?Lr(s):[[k,A],[M,A],[M,T],[k,T]]),L=v&&x?F.map((N,W)=>Bo(t,N,F[(W+1)%F.length],"roof",s.id,W)):_,P=v?R`${L}${u?u.map((N,W)=>xw(t,N,`${s.id}:${W}`)):w.map(([N,W])=>$w(t,[N?M:k,W?T:A],`${s.id}:${N}:${W}`))}`:_;return R`
${g}
- ${xw(t,e,s,l)}
- ${P}`};return R`${r.map(o)} `}function $w(t,e,n,r,i){let o=r*Math.PI/180,[s,l]=t.toScreen(n),[a,c]=t.toScreen([n[0]+Math.sin(o)*i,n[1]-Math.cos(o)*i]);return R`
+ ${Sw(t,e,s,l)}
+ ${P}`};return R`${r.map(o)} `}function Mw(t,e,n,r,i){let o=r*Math.PI/180,[s,l]=t.toScreen(n),[a,c]=t.toScreen([n[0]+Math.sin(o)*i,n[1]-Math.cos(o)*i]);return R`
- `}function Op(t,e){let{doc:n,admin:r}=t.host,i=n.settings.roof.solar??[];if(i.length===0)return _;let o=Z(n),s=l=>{let a=$e(n,l,o);if(!a||a.wall&&a.wall.floorId!==t.floorId)return _;let c=l.id===e.solarId,u=_;if(c&&a.unbounded&&r&&!l.locked){let h=Zr(a,l),f=Math.max(...Xe(a,l,!0).flatMap(g=>g.corners.map(b=>Math.hypot(b[0]-h[0],b[2]-h[1]))));u=$w(t,l.id,h,l.rotation??0,.9+f*.5)}let d=h=>{let f;if(a.wall){let g=Math.max(.3,...h.corners.map(w=>(w[0]-a.o[0])*a.n[0]+(w[2]-a.o[2])*a.n[2])),[b,y]=[h.corners[0],h.corners[1]],v=w=>[w[0]+a.n[0]*g,w[2]+a.n[2]*g];f=[[b[0],b[2]],v(b),v(y),[y[0],y[2]]]}else f=h.corners.map(g=>[g[0],g[2]]);return R` `},p=`nf-solar${c?" nf-solar-sel":""}${c&&e.picking?" nf-solar-pick":""}`;return R`${Xe(a,l,c).map(d)} ${u}`};return R`${i.map(s)} `}function Hp(t,e){let n=t.host.doc.settings.roof.windows??[];if(n.length===0)return _;let r=new Map(Z(t.host.doc).map(o=>[o.key,o])),i=o=>{let s=r.get(o.face),l=s?xa(s,o):null;return l?R`[a[0],a[2]]))} /> `:_};return R`${n.map(i)} `}var Sw={inverter:"\u26A1",home_battery:"\u{1F50B}",wallbox:"\u{1F50C}",meter:"\u{1F4DF}",grid_point:"\u{1F3C1}"};function Lp(t,e,n){if(!e)return _;let r=e.furniture.filter(o=>Ke.includes(o.type)),i=o=>{let[s,l]=t.toScreen([o.x,o.z]),a=o.id===n,c=t.host.t(`furn_${o.type}`);return R`
+ `}function Hp(t,e){let{doc:n,admin:r}=t.host,i=n.settings.roof.solar??[];if(i.length===0)return _;let o=Z(n),s=l=>{let a=Se(n,l,o);if(!a||a.wall&&a.wall.floorId!==t.floorId)return _;let c=l.id===e.solarId,u=_;if(c&&a.unbounded&&r&&!l.locked){let h=qr(a,l),f=Math.max(...Xe(a,l,!0).flatMap(g=>g.corners.map(b=>Math.hypot(b[0]-h[0],b[2]-h[1]))));u=Mw(t,l.id,h,l.rotation??0,.9+f*.5)}let d=h=>{let f;if(a.wall){let g=Math.max(.3,...h.corners.map(w=>(w[0]-a.o[0])*a.n[0]+(w[2]-a.o[2])*a.n[2])),[b,y]=[h.corners[0],h.corners[1]],v=w=>[w[0]+a.n[0]*g,w[2]+a.n[2]*g];f=[[b[0],b[2]],v(b),v(y),[y[0],y[2]]]}else f=h.corners.map(g=>[g[0],g[2]]);return R` `},p=`nf-solar${c?" nf-solar-sel":""}${c&&e.picking?" nf-solar-pick":""}`;return R`${Xe(a,l,c).map(d)} ${u}`};return R`${i.map(s)} `}function Lp(t,e){let n=t.host.doc.settings.roof.windows??[];if(n.length===0)return _;let r=new Map(Z(t.host.doc).map(o=>[o.key,o])),i=o=>{let s=r.get(o.face),l=s?Sa(s,o):null;return l?R`[a[0],a[2]]))} /> `:_};return R`${n.map(i)} `}var Rw={inverter:"\u26A1",home_battery:"\u{1F50B}",wallbox:"\u{1F50C}",meter:"\u{1F4DF}",grid_point:"\u{1F3C1}"};function Cp(t,e,n){if(!e)return _;let r=e.furniture.filter(o=>Ke.includes(o.type)),i=o=>{let[s,l]=t.toScreen([o.x,o.z]),a=o.id===n,c=t.host.t(`furn_${o.type}`);return R`
- ${Sw[o.type]??"\u26A1"}
+ ${Rw[o.type]??"\u26A1"}
${a?R`${c} `:_}
${c}
- `};return R`${r.map(i)} `}function Cp(t,e){let{doc:n,hass:r}=t.host;if(!(n.settings.roof.sections??[]).some(s=>ga(s,e.elevation+e.height)))return _;let o=[1.5,2].flatMap(s=>_a({settings:n.settings},e.elevation,s).map(([l,a])=>{let[c,u]=t.toScreen(l),[d,p]=t.toScreen(a);return R`
- ${K(r,s,1)} m `}));return R`${o}`}function Np(t,e,n,r){if(!e)return _;let i=(o,s)=>{let l=[];return o.forEach((a,c)=>{if(a.floor_id!==e.id)return;let[u,d]=t.toScreen([a.x,a.z]),p=o[c+1];if(p?.floor_id===e.id){let[f,g]=t.toScreen([p.x,p.z]);l.push(R` `)}let h=p&&p.floor_id!==e.id||c>0&&o[c-1].floor_id!==e.id;l.push(R` `),s&&l.push(R`${c+1} `)}),R`${l} `};return R`${n.filter(o=>o.key!==r?.key).map(o=>i(o.points,!1))}${r?i(r.points,!0):_} `}function Bp(t,e){let n=t.host.doc.settings.roof.chimneys??[];if(n.length===0)return _;let r=new Map(Z(t.host.doc).map(o=>[o.key,o])),i=o=>{let s=r.get(o.face);if(!s)return _;let{shape:l,w:a,d:c}=mn(o),{center:u,along:d,across:p}=$a(s,o),h=l==="round"||l==="steel"?Array.from({length:16},(f,g)=>[u[0]+Math.cos(g/16*2*Math.PI)*Math.min(a,c)/2,u[1]+Math.sin(g/16*2*Math.PI)*Math.min(a,c)/2]):[[-1,-1],[1,-1],[1,1],[-1,1]].map(([f,g])=>[u[0]+d[0]*a*f/2+p[0]*c*g/2,u[1]+d[1]*a*f/2+p[1]*c*g/2]);return R` `};return R`${n.map(i)} `}function Mw(t,e,n){let[r,i]=[t+n/2,e-30];return R`
+ `};return R`${r.map(i)} `}function Np(t,e){let{doc:n,hass:r}=t.host;if(!(n.settings.roof.sections??[]).some(s=>ba(s,e.elevation+e.height)))return _;let o=[1.5,2].flatMap(s=>ya({settings:n.settings},e.elevation,s).map(([l,a])=>{let[c,u]=t.toScreen(l),[d,p]=t.toScreen(a);return R`
+ ${K(r,s,1)} m `}));return R`${o}`}function Bp(t,e,n,r){if(!e)return _;let i=(o,s)=>{let l=[];return o.forEach((a,c)=>{if(a.floor_id!==e.id)return;let[u,d]=t.toScreen([a.x,a.z]),p=o[c+1];if(p?.floor_id===e.id){let[f,g]=t.toScreen([p.x,p.z]);l.push(R` `)}let h=p&&p.floor_id!==e.id||c>0&&o[c-1].floor_id!==e.id;l.push(R` `),s&&l.push(R`${c+1} `)}),R`${l} `};return R`${n.filter(o=>o.key!==r?.key).map(o=>i(o.points,!1))}${r?i(r.points,!0):_} `}function Wp(t,e){let n=t.host.doc.settings.roof.chimneys??[];if(n.length===0)return _;let r=new Map(Z(t.host.doc).map(o=>[o.key,o])),i=o=>{let s=r.get(o.face);if(!s)return _;let{shape:l,w:a,d:c}=gn(o),{center:u,along:d,across:p}=Ma(s,o),h=l==="round"||l==="steel"?Array.from({length:16},(f,g)=>[u[0]+Math.cos(g/16*2*Math.PI)*Math.min(a,c)/2,u[1]+Math.sin(g/16*2*Math.PI)*Math.min(a,c)/2]):[[-1,-1],[1,-1],[1,1],[-1,1]].map(([f,g])=>[u[0]+d[0]*a*f/2+p[0]*c*g/2,u[1]+d[1]*a*f/2+p[1]*c*g/2]);return R` `};return R`${n.map(i)} `}function Ew(t,e,n){let[r,i]=[t+n/2,e-30];return R`
- `}function Rw(t,e){let n=e.level?.length?e.level:e.ruler;if(!n?.length)return _;let r=n.map(i=>t.toScreen(i));return R`
+ `}function Aw(t,e){let n=e.level?.length?e.level:e.ruler;if(!n?.length)return _;let r=n.map(i=>t.toScreen(i));return R`
${r.length===2?R` `:_}
${r.map(([i,o])=>R` `)}
- `}function Wp(t,e,n){let r=n?.background,i=e.picture(r?.image_id);if(!r||!i)return _;let[o,s]=t.toScreen([r.x,r.z]),l=r.width*t.scale,a=l*i.aspect,c=e.handlesShown;return R`
+ `}function Vp(t,e,n){let r=n?.background,i=e.picture(r?.image_id);if(!r||!i)return _;let[o,s]=t.toScreen([r.x,r.z]),l=r.width*t.scale,a=l*i.aspect,c=e.handlesShown;return R`
${c?R`
- ${Mw(o,s,l)}`:_}
- ${Rw(t,e)}`}var Ew="strict-origin-when-cross-origin",el=new Map,Vp=new Map,Bo=new Map;function Aw(t){let e=el.get(t);return e||(e=fetch(t,{referrerPolicy:Ew,mode:"cors",credentials:"omit"}).then(async n=>n.ok&&(n.headers.get("content-type")??"").startsWith("image/")?await n.blob():null).catch(()=>null).then(n=>(n||setTimeout(()=>el.delete(t),6e4),n)),el.set(t,e)),e}function Kp(t,e){let n=Vp.get(t);if(n)return n;let r=Bo.get(t);return r||(r=new Set,Bo.set(t,r),Aw(t).then(i=>{i&&Vp.set(t,URL.createObjectURL(i));let o=Bo.get(t)??new Set;if(Bo.delete(t),i)for(let s of o)s()})),r.add(e),null}function jp(t,e){let n=e.map;if(!Lo(n))return _;let r=_p(n),i=gp(n),[o,s]=t.toScreen([r.x,r.z]),l=t.scale;return R`
- ${fp(n.lat,n.lon,r.zoom).map(a=>({tile:a,href:Kp(mp(i,a),t.redraw)})).filter(a=>a.href).map(({tile:a,href:c})=>R` `)}
- `}var tl=t=>Math.round(t*1e3)/1e3,nl=(t,e)=>t.width*e,er=(t,e)=>[t.x+t.width/2,t.z+nl(t,e)/2];function Gp(t,e,n){let[r,i]=[t[0]-e[0],t[1]-e[1]];return[e[0]+r*Math.cos(n)-i*Math.sin(n),e[1]+r*Math.sin(n)+i*Math.cos(n)]}var Up=t=>((t+180)%360+360)%360-180;function Zp(t,e,n){return{x:tl(t[0]-e/2),z:tl(t[1]-n/2)}}function qp(t,e,n,r){if(Math.hypot(r[0]-n[0],r[1]-n[1])<.05)return null;let i=Math.atan2(r[1]-n[1],r[0]-n[0]),o=Math.round(i/(Math.PI/2))*(Math.PI/2)-i;if(Math.abs(o)<1e-4)return null;let s=Gp(er(t,e),n,o),l=Math.round(Up((t.rotation??0)+o*180/Math.PI)*100)/100;return{...t,rotation:l,...Zp(s,t.width,nl(t,e))}}function Yp(t,e,n,r,i){let o=Math.hypot(r[0]-n[0],r[1]-n[1]);if(!(i>0)||o<1e-4)return null;let s=i/o,[l,a]=er(t,e),c=[n[0]+s*(l-n[0]),n[1]+s*(a-n[1])],u=t.width*s;return{...t,width:tl(u),...Zp(c,u,nl(t,e)*s)}}function Xp(t,e,n){let r=Gp(n,er(t,e),-(t.rotation??0)*Math.PI/180);return[r[0]-t.x,r[1]-t.z]}function Jp(t,e,n,r){let i=t+(n-e)*180/Math.PI;return Up(r?Math.round(i/15)*15:Math.round(i*10)/10)}var Fw=2048;async function tr(t){let e=await createImageBitmap(t),n=Math.min(1,Fw/Math.max(e.width,e.height)),r=document.createElement("canvas");return r.width=Math.round(e.width*n),r.height=Math.round(e.height*n),r.getContext("2d").drawImage(e,0,0,r.width,r.height),{data:r.toDataURL("image/jpeg",.85),aspect:r.height/r.width}}var Wo=class{deps;editMode=!1;levelPoints=null;rulerPoints=null;rulerMetres=0;sectionOpen=!1;pictures={};loading=new Set;constructor(e){this.deps=e}get edit(){return this.editMode}set edit(e){this.editMode=e,this.deps.refresh()}get level(){return this.levelPoints}set level(e){this.levelPoints=e,this.deps.refresh()}get ruler(){return this.rulerPoints}set ruler(e){this.rulerPoints=e,this.deps.refresh()}get rulerLength(){return this.rulerMetres}set rulerLength(e){this.rulerMetres=e,this.deps.refresh()}get open(){return this.sectionOpen}set open(e){this.sectionOpen=e,this.deps.refresh()}get handlesShown(){let{host:e}=this.deps;return!!e.floor?.background&&e.admin&&this.deps.currentTool()==="select"&&this.editMode}picture(e){return e?this.pictures[e]:void 0}ensureLoaded(e){!this.pictures[e]&&!this.loading.has(e)&&this.load(e)}async load(e){let{host:n,api:r}=this.deps;if(n.hass){this.loading.add(e);try{let i=await r.fetchImage(n.hass,e),o=await this.aspectOf(i);this.pictures={...this.pictures,[e]:{url:i,aspect:o}},this.deps.refresh()}catch{}}}async aspectOf(e){let n=new Image;return n.src=e,await n.decode(),n.naturalHeight/n.naturalWidth}async upload(e){let{host:n,api:r}=this.deps;if(!e||!n.hass)return;let{data:i,aspect:o}=await this.deps.readPicture(e),s=I("img");await r.storeImage(n.hass,s,i),this.pictures={...this.pictures,[s]:{url:i,aspect:o}};let l=n.floor?.rooms??[],a=l.length>0?de(l.flatMap(u=>u.points)):null,c={image_id:s,x:a?a.x0:0,z:a?a.z0:0,width:a?Math.max(4,Math.round((a.x1-a.x0)*1e3)/1e3):12,opacity:.5};this.setBackground(c)}setBackground(e){this.deps.host.change((n,r)=>Object.assign(r,{background:e}))}toggleLevel(){this.levelPoints=this.levelPoints?null:[],this.rulerPoints=null,this.editMode=!1,this.deps.refresh()}toggleRuler(){this.rulerPoints=this.rulerPoints?null:[],this.levelPoints=null,this.editMode=!1,this.deps.refresh()}toggleEdit(){this.edit=!this.editMode,this.editMode&&this.deps.useSelectTool()}tapLevel(e){let n=[...this.levelPoints??[],e];if(n.length<2){this.level=n;return}this.level=null,this.straighten(n[0],n[1])}tapRuler(e){this.rulerPoints&&this.rulerPoints.length<2&&(this.ruler=[...this.rulerPoints,e])}straighten(e,n){let r=this.deps.host.floor?.background,i=this.picture(r?.image_id),o=r&&i?qp(r,i.aspect,e,n):null;o&&this.setBackground(o)}applyRuler(){let e=this.deps.host.floor?.background,n=this.picture(e?.image_id),r=this.rulerPoints;if(!e||!n||!r||r.length<2)return;let i=Yp(e,n.aspect,r[0],r[1],this.rulerMetres);i&&(this.setBackground(i),this.rulerPoints=null,this.rulerMetres=0,this.deps.refresh())}};var Qp=.1,rl=(t,e,n)=>m`${e} `;function Tw(t,e){let n=e.ruler;if(!n)return _;if(n.length<2)return S(t.t(n.length>0?"bg_ruler_second":"bg_ruler_first"),"nf-wide");let r=Math.hypot(n[1][0]-n[0][0],n[1][1]-n[0][1]),i=()=>e.applyRuler();return m`${S(t.t("bg_ruler_length_hint",{m:K(t.hass,r,2)}),"nf-wide")}
+ ${Ew(o,s,l)}`:_}
+ ${Aw(t,e)}`}var Fw="strict-origin-when-cross-origin",nl=new Map,Kp=new Map,Wo=new Map;function Tw(t){let e=nl.get(t);return e||(e=fetch(t,{referrerPolicy:Fw,mode:"cors",credentials:"omit"}).then(async n=>n.ok&&(n.headers.get("content-type")??"").startsWith("image/")?await n.blob():null).catch(()=>null).then(n=>(n||setTimeout(()=>nl.delete(t),6e4),n)),nl.set(t,e)),e}function jp(t,e){let n=Kp.get(t);if(n)return n;let r=Wo.get(t);return r||(r=new Set,Wo.set(t,r),Tw(t).then(i=>{i&&Kp.set(t,URL.createObjectURL(i));let o=Wo.get(t)??new Set;if(Wo.delete(t),i)for(let s of o)s()})),r.add(e),null}function Up(t,e){let n=e.map;if(!Co(n))return _;let r=bp(n),i=_p(n),[o,s]=t.toScreen([r.x,r.z]),l=t.scale;return R`
+ ${mp(n.lat,n.lon,r.zoom).map(a=>({tile:a,href:jp(gp(i,a),t.redraw)})).filter(a=>a.href).map(({tile:a,href:c})=>R` `)}
+ `}var rl=t=>Math.round(t*1e3)/1e3,il=(t,e)=>t.width*e,er=(t,e)=>[t.x+t.width/2,t.z+il(t,e)/2];function Gp(t,e,n){let[r,i]=[t[0]-e[0],t[1]-e[1]];return[e[0]+r*Math.cos(n)-i*Math.sin(n),e[1]+r*Math.sin(n)+i*Math.cos(n)]}var Zp=t=>((t+180)%360+360)%360-180;function qp(t,e,n){return{x:rl(t[0]-e/2),z:rl(t[1]-n/2)}}function Yp(t,e,n,r){if(Math.hypot(r[0]-n[0],r[1]-n[1])<.05)return null;let i=Math.atan2(r[1]-n[1],r[0]-n[0]),o=Math.round(i/(Math.PI/2))*(Math.PI/2)-i;if(Math.abs(o)<1e-4)return null;let s=Gp(er(t,e),n,o),l=Math.round(Zp((t.rotation??0)+o*180/Math.PI)*100)/100;return{...t,rotation:l,...qp(s,t.width,il(t,e))}}function Xp(t,e,n,r,i){let o=Math.hypot(r[0]-n[0],r[1]-n[1]);if(!(i>0)||o<1e-4)return null;let s=i/o,[l,a]=er(t,e),c=[n[0]+s*(l-n[0]),n[1]+s*(a-n[1])],u=t.width*s;return{...t,width:rl(u),...qp(c,u,il(t,e)*s)}}function Jp(t,e,n){let r=Gp(n,er(t,e),-(t.rotation??0)*Math.PI/180);return[r[0]-t.x,r[1]-t.z]}function Qp(t,e,n,r){let i=t+(n-e)*180/Math.PI;return Zp(r?Math.round(i/15)*15:Math.round(i*10)/10)}var zw=2048;async function tr(t){let e=await createImageBitmap(t),n=Math.min(1,zw/Math.max(e.width,e.height)),r=document.createElement("canvas");return r.width=Math.round(e.width*n),r.height=Math.round(e.height*n),r.getContext("2d").drawImage(e,0,0,r.width,r.height),{data:r.toDataURL("image/jpeg",.85),aspect:r.height/r.width}}var Vo=class{deps;editMode=!1;levelPoints=null;rulerPoints=null;rulerMetres=0;sectionOpen=!1;pictures={};loading=new Set;constructor(e){this.deps=e}get edit(){return this.editMode}set edit(e){this.editMode=e,this.deps.refresh()}get level(){return this.levelPoints}set level(e){this.levelPoints=e,this.deps.refresh()}get ruler(){return this.rulerPoints}set ruler(e){this.rulerPoints=e,this.deps.refresh()}get rulerLength(){return this.rulerMetres}set rulerLength(e){this.rulerMetres=e,this.deps.refresh()}get open(){return this.sectionOpen}set open(e){this.sectionOpen=e,this.deps.refresh()}get handlesShown(){let{host:e}=this.deps;return!!e.floor?.background&&e.admin&&this.deps.currentTool()==="select"&&this.editMode}picture(e){return e?this.pictures[e]:void 0}ensureLoaded(e){!this.pictures[e]&&!this.loading.has(e)&&this.load(e)}async load(e){let{host:n,api:r}=this.deps;if(n.hass){this.loading.add(e);try{let i=await r.fetchImage(n.hass,e),o=await this.aspectOf(i);this.pictures={...this.pictures,[e]:{url:i,aspect:o}},this.deps.refresh()}catch{}}}async aspectOf(e){let n=new Image;return n.src=e,await n.decode(),n.naturalHeight/n.naturalWidth}async upload(e){let{host:n,api:r}=this.deps;if(!e||!n.hass)return;let{data:i,aspect:o}=await this.deps.readPicture(e),s=I("img");await r.storeImage(n.hass,s,i),this.pictures={...this.pictures,[s]:{url:i,aspect:o}};let l=n.floor?.rooms??[],a=l.length>0?de(l.flatMap(u=>u.points)):null,c={image_id:s,x:a?a.x0:0,z:a?a.z0:0,width:a?Math.max(4,Math.round((a.x1-a.x0)*1e3)/1e3):12,opacity:.5};this.setBackground(c)}setBackground(e){this.deps.host.change((n,r)=>Object.assign(r,{background:e}))}toggleLevel(){this.levelPoints=this.levelPoints?null:[],this.rulerPoints=null,this.editMode=!1,this.deps.refresh()}toggleRuler(){this.rulerPoints=this.rulerPoints?null:[],this.levelPoints=null,this.editMode=!1,this.deps.refresh()}toggleEdit(){this.edit=!this.editMode,this.editMode&&this.deps.useSelectTool()}tapLevel(e){let n=[...this.levelPoints??[],e];if(n.length<2){this.level=n;return}this.level=null,this.straighten(n[0],n[1])}tapRuler(e){this.rulerPoints&&this.rulerPoints.length<2&&(this.ruler=[...this.rulerPoints,e])}straighten(e,n){let r=this.deps.host.floor?.background,i=this.picture(r?.image_id),o=r&&i?Yp(r,i.aspect,e,n):null;o&&this.setBackground(o)}applyRuler(){let e=this.deps.host.floor?.background,n=this.picture(e?.image_id),r=this.rulerPoints;if(!e||!n||!r||r.length<2)return;let i=Xp(e,n.aspect,r[0],r[1],this.rulerMetres);i&&(this.setBackground(i),this.rulerPoints=null,this.rulerMetres=0,this.deps.refresh())}};var ef=.1,ol=(t,e,n)=>m`
${e} `;function Pw(t,e){let n=e.ruler;if(!n)return _;if(n.length<2)return S(t.t(n.length>0?"bg_ruler_second":"bg_ruler_first"),"nf-wide");let r=Math.hypot(n[1][0]-n[0][0],n[1][1]-n[0][1]),i=()=>e.applyRuler();return m`${S(t.t("bg_ruler_length_hint",{m:K(t.hass,r,2)}),"nf-wide")}
${t.t("bg_ruler_length")}
e.rulerLength=oa(o.target.value)||0}
+ @input=${o=>e.rulerLength=aa(o.target.value)||0}
@keydown=${o=>o.key==="Enter"&&i()}
/>
-
0)} @click=${i}>${t.t("bg_ruler_apply")} `}function zw(t,e){if(!t.admin)return _;let n=t.t,r=e.level;return m`${rl(e.edit,n(e.edit?"background_edit_done":"background_edit"),()=>e.toggleEdit())}
+
0)} @click=${i}>${t.t("bg_ruler_apply")} `}function Dw(t,e){if(!t.admin)return _;let n=t.t,r=e.level;return m`${ol(e.edit,n(e.edit?"background_edit_done":"background_edit"),()=>e.toggleEdit())}
${S(n(e.edit?"background_handles_hint":"background_fixed_hint"),"nf-wide")}
- ${rl(!!r,`\u{1F4D0} ${n(r?"bg_level_cancel":"bg_level")}`,()=>e.toggleLevel())}
+ ${ol(!!r,`\u{1F4D0} ${n(r?"bg_level_cancel":"bg_level")}`,()=>e.toggleLevel())}
${r?S(n(r.length>0?"bg_level_second":"bg_level_first"),"nf-wide"):_}
- ${rl(!!e.ruler,`\u{1F4CF} ${n(e.ruler?"bg_ruler_cancel":"bg_ruler")}`,()=>e.toggleRuler())}
- ${Tw(t,e)}`}function ef(t,e,n){let r=n.background,i=t.t,o=s=>r&&e.setBackground({...r,...s});return m`
e.open=s.target.open}>
+ ${ol(!!e.ruler,`\u{1F4CF} ${n(e.ruler?"bg_ruler_cancel":"bg_ruler")}`,()=>e.toggleRuler())}
+ ${Pw(t,e)}`}function tf(t,e,n){let r=n.background,i=t.t,o=s=>r&&e.setBackground({...r,...s});return m`e.open=s.target.open}>
${i("background")}
${r?m`${E(t,i("x"),r.x,s=>o({x:s}))} ${E(t,i("z"),r.z,s=>o({z:s}))}
- ${E(t,i("background_width"),r.width,s=>o({width:Math.max(Qp,s)}),.01,Qp)}
+ ${E(t,i("background_width"),r.width,s=>o({width:Math.max(ef,s)}),.01,ef)}
${E(t,i("background_rotation"),r.rotation??0,s=>o({rotation:Math.round(s*10)/10}),.5)}
- ${zw(t,e)}
+ ${Dw(t,e)}
${i("background_opacity")}
o({opacity:Number.parseFloat(s.target.value)})} />
e.setBackground(null)}>${i("background_remove")} `:_}
- `}var Pw=t=>t.map((e,n)=>[e,t[(n+1)%t.length]]);function Dw(t,e,n){let r=G(n,e),i=te(r,r),o=i?Math.max(0,Math.min(1,te(G(t,e),r)/i)):0;return ge(G(t,[e[0]+r[0]*o,e[1]+r[1]*o]))}function tf(t,e,n=.03){return t.every(r=>C(r,e)||Pw(e).some(([i,o])=>Dw(r,i,o)<=n))}var il=["straight","quarter","l","half","u","spiral"],ol=["solid","stringer","mono","cantilever"],sl=["none","left","right","both"],al=["headroom","full","none"],_t={shape:"straight",turn:"right",build:"solid",risers:!0,steps:null,run_width:null,down:!1,rail:"none",opening:"headroom",landing_after:null},ll={straight:[1,3.2],quarter:[2.2,2.6],l:[2.2,2.8],half:[2,2.6],u:[2.2,2.6],spiral:[1.6,1.6]},af=2,lf=40;var Vo=(t,e)=>typeof e=="string"&&t.includes(e);function wi(t){let e=t.stair??{},n=typeof e.steps=="number"&&Number.isFinite(e.steps)?Math.round(Math.min(lf,Math.max(af,e.steps))):null,r=typeof e.run_width=="number"&&Number.isFinite(e.run_width)&&e.run_width>.2?e.run_width:null;return{shape:Vo(il,e.shape)?e.shape:_t.shape,turn:e.turn==="left"?"left":"right",build:Vo(ol,e.build)?e.build:_t.build,risers:e.risers!==!1,steps:n,run_width:r,down:e.down===!0,rail:Vo(sl,e.rail)?e.rail:_t.rail,opening:Vo(al,e.opening)?e.opening:_t.opening,landing_after:typeof e.landing_after=="number"&&Number.isFinite(e.landing_after)?Math.max(1,Math.round(e.landing_after)):null}}var yi=(t,e,n)=>[t[0]+(e[0]-t[0])*n,t[1]+(e[1]-t[1])*n],nf=(t,e)=>Math.abs(t[0]-e[0])<1e-6&&Math.abs(t[1]-e[1])<1e-6;function cf(t){let e=[];for(let n of t)(!e.length||!nf(e[e.length-1],n))&&e.push(n);for(;e.length>1&&nf(e[0],e[e.length-1]);)e.pop();return e}function vi(t,e,n=!1){return{poly:cf([...t,...[...e].reverse()]),landing:n,left:t,right:e}}function bi(t,e,n,r,i){let o=[];for(let s=0;se+1e-6&&it.reduce((e,n,r)=>r?e+Math.hypot(n[0]-t[r-1][0],n[1]-t[r-1][1]):e,0);function of(t,e,n,r,i){let o=Ow(t),s=[];for(let l=0;l=8?3:2),[p,h]=t.shape==="l"?sf(t,r)??Ko(r-d,n-a,e-a):Ko(r-d,n-a,e-a),f=bi([i,l],[i+a,l],[i,s+a],c,p),g=t.shape==="l"?[vi(u,[c],!0)]:of(u,c,c,c,d),b=bi([i+a,s],c,[o,s],[o,s+a],h);return{treads:[...f,...g,...b],flight:a,column:0}}case"half":case"u":{let a=Math.min(t.run_width??Math.min(1.1,(e-.1)/2),(e-.02)/2),c=s+a,u=[[i,c],[i,s],[o,s],[o,c]],[d,p]=[[i+a,c],[o-a,c]],h=t.shape==="u"?1:Math.min(r,r>=12?6:r>=8?4:2),[f,g]=t.shape==="u"?sf(t,r)??Ko(r-h,n-a,n-a):Ko(r-h,n-a,n-a),b=bi([i,l],[i+a,l],[i,c],d,f),y=t.shape==="u"?[vi(u,[d,p],!0)]:of(u,d,[0,c],p,h),v=bi([o,c],p,[o,l],[o-a,l],g);return{treads:[...b,...y,...v],flight:a,column:0}}case"spiral":{let a=Math.min(e,n)/2,c=Math.min(.08,a*.12),u=Math.min(.75,Math.max(.3,.22/(a*.6))),d=(h,f)=>[Math.cos(f)*h,Math.sin(f)*h],p=[];for(let h=0;hd(a,f+(g-f)*y));p.push(vi(b,[d(c,f),d(c,g)]))}return{treads:p,flight:a-c,column:c}}default:return{treads:bi([i,l],[o,l],[i,s],[o,s],r),flight:e,column:0}}}var Lw=(t,e)=>t.steps??Math.min(lf,Math.max(af,Math.round(Math.abs(e)/.18)));function vn(t,e,n,r){let i=Lw(t,r),o=Math.abs(r)/i,s=Hw(t,Math.max(.3,e),Math.max(.3,n),i),l=c=>[-c[0],c[1]];return{treads:s.treads.map((c,u)=>{let d=t.down?-o*(u+1):o*(u+1);return t.turn==="right"?{...c,top:d}:{poly:c.poly.map(l).reverse(),top:d,landing:c.landing,left:c.right.map(l),right:c.left.map(l)}}),rise:o,steps:i,column:s.column,flight:s.flight}}function jo(t){let e=t.poly.reduce((n,r)=>[n[0]+r[0],n[1]+r[1]],[0,0]);return[e[0]/t.poly.length,e[1]/t.poly.length]}var ne=t=>Math.round(t*1e3)/1e3,Cw=(t,e)=>((t+e)%360+360)%360;function uf(t,e){return{id:I("wall"),a:[ne(t[0]),ne(t[1])],b:[ne(e[0]),ne(e[1])],thickness:null}}function df(t,e){let n=Math.hypot(t.b[0]-t.a[0],t.b[1]-t.a[1])||1,r=Math.max(.1,e)/n;return[ne(t.a[0]+(t.b[0]-t.a[0])*r),ne(t.a[1]+(t.b[1]-t.a[1])*r)]}var hf=(t,e)=>({height:t>=e-.005?null:Math.max(.05,t)});function pf(t,e){return{id:I("hole"),type:"stairwell",x:ne((t[0]+e[0])/2),z:ne((t[1]+e[1])/2),w:ne(e[0]-t[0]),d:ne(e[1]-t[1]),h:.02,rotation:0,variant:null}}var ff=t=>({id:I("outdoor"),type:"lawn",points:t.map(([e,n])=>[ne(e),ne(n)])});function mf(t,e,n){t.points.splice(e+1,0,[ne(n[0]),ne(n[1])])}function gf(t,e){return t.points.length<=3||e<0||e>=t.points.length?!1:(t.points.splice(e,1),!0)}var _f=t=>({...t,id:I("outdoor"),points:t.points.map(([e,n])=>[ne(e+.5),ne(n+.5)])});function cl(t,e,n,r){let[i,o,s]=dt(t),l=e.floors.filter(u=>u.elevation>n.elevation).sort((u,d)=>u.elevation-d.elevation)[0],a=t==="stairs"?ne(l?l.elevation-n.elevation:n.height+.25):s,c={id:I("furniture"),type:t,x:ne(r[0]),z:ne(r[1]),rotation:0,w:i,d:o,h:a,variant:null};return Yn(t)&&(c.hydronic=Ba(t)),t==="stairs"&&(c.stair={..._t}),c}var bf=t=>({...structuredClone(t),id:I("furniture"),x:ne(t.x+.3),z:ne(t.z+.3)}),yf=(t,e)=>Cw(t,e);function vf(t){let[e,n,r]=dt("parking");return{id:I("furniture"),type:"parking",x:t.x,z:t.z,rotation:t.rotation,w:Math.max(e,ne(t.w+.5)),d:Math.max(n,ne(t.d+.4)),h:r,variant:null,vehicle:t.type,...t.name?{name:t.name}:{}}}function wf(t,e){let[n,r,i]=dt(e);return{id:I("furniture"),type:e,x:t.x,z:t.z,rotation:t.rotation??0,w:n,d:r,h:i,variant:null,entity:t.entity_id,name:t.name??null,animations_enabled:t.animations_enabled,effect_animations:structuredClone(t.effect_animations),...t.locked?{locked:!0}:{}}}var kf=(t,e)=>({entity_id:e,x:t.x,z:t.z,y:null,rotation:t.rotation,animations_enabled:t.animations_enabled,effect_animations:structuredClone(t.effect_animations),...t.name?{name:t.name}:{}});function xf(t,e){for(let n of t.floors)n.placements=n.placements.filter(r=>r.entity_id!==e),n.furniture=n.furniture.filter(r=>!(ue(r.type)&&r.entity===e))}function ul(t,e,n,r){let i=new Set(r);for(let s of t.floors)s.placements=s.placements.filter(l=>!i.has(l.entity_id)),s.furniture=s.furniture.filter(l=>!(ue(l.type)&&l.entity&&i.has(l.entity)));let o=[...e.placements.map(s=>[s.x,s.z]),...e.furniture.filter(s=>ue(s.type)).map(s=>[s.x,s.z])];for(let s of ld(n,r,o)){if(!s.entity_id.startsWith("light.")){e.placements.push(s);continue}let[l,a,c]=nt.lamp_ceiling;e.furniture.push({id:I("furniture"),type:"lamp_ceiling",x:s.x,z:s.z,rotation:0,w:l,d:a,h:c,variant:null,entity:s.entity_id,power:null})}}function $f(t){let[e,n]=be(t.points);return[ne(e),ne(n)]}function Sf(t,e,n,r){let i=Math.min(n,t)/2,o=r>0?Math.round(e/r)*r:e;return ne(Math.min(t-i,Math.max(i,o)))}function Mf(t,e){let n=An[e],r=Fn(t)===e?{}:{width:n.width};return{type:n.type,leaves:n.leaves,sill:n.sill,height:n.height,style:n.style??null,opens:n.opens??null,...r}}function Rf(t,e,n){let r=de(t.points),{x0:i,z0:o,x1:s,z1:l}=r;return e==="x"?[i,s]=[n,n+(s-i)]:e==="z"?[o,l]=[n,n+(l-o)]:e==="w"?s=i+Math.max(.1,n):l=o+Math.max(.1,n),[[i,o],[s,o],[s,l],[i,l]].map(([a,c])=>[ne(a),ne(c)])}function Ef(t){return t.furniture.map((e,n)=>({item:e,index:n,base:zt(t,e)})).sort((e,n)=>e.base-n.base||e.index-n.index).map(e=>e.item)}function Go(t,e,n){if(!t.admin)return _;let r=n.edit?.key===e;return m`n.setEdit(r?null:{key:e,bulge:.5,error:null})}>
+ `}var Iw=t=>t.map((e,n)=>[e,t[(n+1)%t.length]]);function Ow(t,e,n){let r=U(n,e),i=te(r,r),o=i?Math.max(0,Math.min(1,te(U(t,e),r)/i)):0;return ge(U(t,[e[0]+r[0]*o,e[1]+r[1]*o]))}function nf(t,e,n=.03){return t.every(r=>C(r,e)||Iw(e).some(([i,o])=>Ow(r,i,o)<=n))}var sl=["straight","quarter","l","half","u","spiral"],al=["solid","stringer","mono","cantilever"],ll=["none","left","right","both"],cl=["headroom","full","none"],_t={shape:"straight",turn:"right",build:"solid",risers:!0,steps:null,run_width:null,down:!1,rail:"none",opening:"headroom",landing_after:null},ul={straight:[1,3.2],quarter:[2.2,2.6],l:[2.2,2.8],half:[2,2.6],u:[2.2,2.6],spiral:[1.6,1.6]},lf=2,cf=40;var Ko=(t,e)=>typeof e=="string"&&t.includes(e);function ki(t){let e=t.stair??{},n=typeof e.steps=="number"&&Number.isFinite(e.steps)?Math.round(Math.min(cf,Math.max(lf,e.steps))):null,r=typeof e.run_width=="number"&&Number.isFinite(e.run_width)&&e.run_width>.2?e.run_width:null;return{shape:Ko(sl,e.shape)?e.shape:_t.shape,turn:e.turn==="left"?"left":"right",build:Ko(al,e.build)?e.build:_t.build,risers:e.risers!==!1,steps:n,run_width:r,down:e.down===!0,rail:Ko(ll,e.rail)?e.rail:_t.rail,opening:Ko(cl,e.opening)?e.opening:_t.opening,landing_after:typeof e.landing_after=="number"&&Number.isFinite(e.landing_after)?Math.max(1,Math.round(e.landing_after)):null}}var vi=(t,e,n)=>[t[0]+(e[0]-t[0])*n,t[1]+(e[1]-t[1])*n],rf=(t,e)=>Math.abs(t[0]-e[0])<1e-6&&Math.abs(t[1]-e[1])<1e-6;function uf(t){let e=[];for(let n of t)(!e.length||!rf(e[e.length-1],n))&&e.push(n);for(;e.length>1&&rf(e[0],e[e.length-1]);)e.pop();return e}function wi(t,e,n=!1){return{poly:uf([...t,...[...e].reverse()]),landing:n,left:t,right:e}}function yi(t,e,n,r,i){let o=[];for(let s=0;s
e+1e-6&&it.reduce((e,n,r)=>r?e+Math.hypot(n[0]-t[r-1][0],n[1]-t[r-1][1]):e,0);function sf(t,e,n,r,i){let o=Lw(t),s=[];for(let l=0;l=8?3:2),[p,h]=t.shape==="l"?af(t,r)??jo(r-d,n-a,e-a):jo(r-d,n-a,e-a),f=yi([i,l],[i+a,l],[i,s+a],c,p),g=t.shape==="l"?[wi(u,[c],!0)]:sf(u,c,c,c,d),b=yi([i+a,s],c,[o,s],[o,s+a],h);return{treads:[...f,...g,...b],flight:a,column:0}}case"half":case"u":{let a=Math.min(t.run_width??Math.min(1.1,(e-.1)/2),(e-.02)/2),c=s+a,u=[[i,c],[i,s],[o,s],[o,c]],[d,p]=[[i+a,c],[o-a,c]],h=t.shape==="u"?1:Math.min(r,r>=12?6:r>=8?4:2),[f,g]=t.shape==="u"?af(t,r)??jo(r-h,n-a,n-a):jo(r-h,n-a,n-a),b=yi([i,l],[i+a,l],[i,c],d,f),y=t.shape==="u"?[wi(u,[d,p],!0)]:sf(u,d,[0,c],p,h),v=yi([o,c],p,[o,l],[o-a,l],g);return{treads:[...b,...y,...v],flight:a,column:0}}case"spiral":{let a=Math.min(e,n)/2,c=Math.min(.08,a*.12),u=Math.min(.75,Math.max(.3,.22/(a*.6))),d=(h,f)=>[Math.cos(f)*h,Math.sin(f)*h],p=[];for(let h=0;hd(a,f+(g-f)*y));p.push(wi(b,[d(c,f),d(c,g)]))}return{treads:p,flight:a-c,column:c}}default:return{treads:yi([i,l],[o,l],[i,s],[o,s],r),flight:e,column:0}}}var Nw=(t,e)=>t.steps??Math.min(cf,Math.max(lf,Math.round(Math.abs(e)/.18)));function wn(t,e,n,r){let i=Nw(t,r),o=Math.abs(r)/i,s=Cw(t,Math.max(.3,e),Math.max(.3,n),i),l=c=>[-c[0],c[1]];return{treads:s.treads.map((c,u)=>{let d=t.down?-o*(u+1):o*(u+1);return t.turn==="right"?{...c,top:d}:{poly:c.poly.map(l).reverse(),top:d,landing:c.landing,left:c.right.map(l),right:c.left.map(l)}}),rise:o,steps:i,column:s.column,flight:s.flight}}function Uo(t){let e=t.poly.reduce((n,r)=>[n[0]+r[0],n[1]+r[1]],[0,0]);return[e[0]/t.poly.length,e[1]/t.poly.length]}var ne=t=>Math.round(t*1e3)/1e3,Bw=(t,e)=>((t+e)%360+360)%360;function df(t,e){return{id:I("wall"),a:[ne(t[0]),ne(t[1])],b:[ne(e[0]),ne(e[1])],thickness:null}}function hf(t,e){let n=Math.hypot(t.b[0]-t.a[0],t.b[1]-t.a[1])||1,r=Math.max(.1,e)/n;return[ne(t.a[0]+(t.b[0]-t.a[0])*r),ne(t.a[1]+(t.b[1]-t.a[1])*r)]}var pf=(t,e)=>({height:t>=e-.005?null:Math.max(.05,t)});function ff(t,e){return{id:I("hole"),type:"stairwell",x:ne((t[0]+e[0])/2),z:ne((t[1]+e[1])/2),w:ne(e[0]-t[0]),d:ne(e[1]-t[1]),h:.02,rotation:0,variant:null}}var mf=t=>({id:I("outdoor"),type:"lawn",points:t.map(([e,n])=>[ne(e),ne(n)])});function gf(t,e,n){t.points.splice(e+1,0,[ne(n[0]),ne(n[1])])}function _f(t,e){return t.points.length<=3||e<0||e>=t.points.length?!1:(t.points.splice(e,1),!0)}var bf=t=>({...t,id:I("outdoor"),points:t.points.map(([e,n])=>[ne(e+.5),ne(n+.5)])});function dl(t,e,n,r){let[i,o,s]=dt(t),l=e.floors.filter(u=>u.elevation>n.elevation).sort((u,d)=>u.elevation-d.elevation)[0],a=t==="stairs"?ne(l?l.elevation-n.elevation:n.height+.25):s,c={id:I("furniture"),type:t,x:ne(r[0]),z:ne(r[1]),rotation:0,w:i,d:o,h:a,variant:null};return Yn(t)&&(c.hydronic=Va(t)),t==="stairs"&&(c.stair={..._t}),c}var yf=t=>({...structuredClone(t),id:I("furniture"),x:ne(t.x+.3),z:ne(t.z+.3)}),vf=(t,e)=>Bw(t,e);function wf(t){let[e,n,r]=dt("parking");return{id:I("furniture"),type:"parking",x:t.x,z:t.z,rotation:t.rotation,w:Math.max(e,ne(t.w+.5)),d:Math.max(n,ne(t.d+.4)),h:r,variant:null,vehicle:t.type,...t.name?{name:t.name}:{}}}function kf(t,e){let[n,r,i]=dt(e);return{id:I("furniture"),type:e,x:t.x,z:t.z,rotation:t.rotation??0,w:n,d:r,h:i,variant:null,entity:t.entity_id,name:t.name??null,animations_enabled:t.animations_enabled,effect_animations:structuredClone(t.effect_animations),...t.locked?{locked:!0}:{}}}var xf=(t,e)=>({entity_id:e,x:t.x,z:t.z,y:null,rotation:t.rotation,animations_enabled:t.animations_enabled,effect_animations:structuredClone(t.effect_animations),...t.name?{name:t.name}:{}});function $f(t,e){for(let n of t.floors)n.placements=n.placements.filter(r=>r.entity_id!==e),n.furniture=n.furniture.filter(r=>!(ue(r.type)&&r.entity===e))}function hl(t,e,n,r){let i=new Set(r);for(let s of t.floors)s.placements=s.placements.filter(l=>!i.has(l.entity_id)),s.furniture=s.furniture.filter(l=>!(ue(l.type)&&l.entity&&i.has(l.entity)));let o=[...e.placements.map(s=>[s.x,s.z]),...e.furniture.filter(s=>ue(s.type)).map(s=>[s.x,s.z])];for(let s of cd(n,r,o)){if(!s.entity_id.startsWith("light.")){e.placements.push(s);continue}let[l,a,c]=nt.lamp_ceiling;e.furniture.push({id:I("furniture"),type:"lamp_ceiling",x:s.x,z:s.z,rotation:0,w:l,d:a,h:c,variant:null,entity:s.entity_id,power:null})}}function Sf(t){let[e,n]=be(t.points);return[ne(e),ne(n)]}function Mf(t,e,n,r){let i=Math.min(n,t)/2,o=r>0?Math.round(e/r)*r:e;return ne(Math.min(t-i,Math.max(i,o)))}function Rf(t,e){let n=Fn[e],r=Tn(t)===e?{}:{width:n.width};return{type:n.type,leaves:n.leaves,sill:n.sill,height:n.height,style:n.style??null,opens:n.opens??null,...r}}function Ef(t,e,n){let r=de(t.points),{x0:i,z0:o,x1:s,z1:l}=r;return e==="x"?[i,s]=[n,n+(s-i)]:e==="z"?[o,l]=[n,n+(l-o)]:e==="w"?s=i+Math.max(.1,n):l=o+Math.max(.1,n),[[i,o],[s,o],[s,l],[i,l]].map(([a,c])=>[ne(a),ne(c)])}function Af(t){return t.furniture.map((e,n)=>({item:e,index:n,base:zt(t,e)})).sort((e,n)=>e.base-n.base||e.index-n.index).map(e=>e.item)}function Go(t,e,n){if(!t.admin)return _;let r=n.edit?.key===e;return m`n.setEdit(r?null:{key:e,bulge:.5,error:null})}>
◠ ${t.t("arc")}
- `}function Uo(t,e,n){let r=n.edit;if(!t.admin||r?.key!==e)return _;let i=t.t;return m``}function Zo(t,e,n){let r=n.edit;if(!t.admin||r?.key!==e)return _;let i=t.t;return m`${E(t,i("arc_bulge"),r.bulge,o=>n.setEdit({...r,bulge:o,error:null}),.05)}
n.apply(r)}>${i("arc_apply")}
- ${r.error?m`${r.error}
`:_}`}var Zo=(t,e,n)=>Math.min(e,Math.max(t,ae(n)));function dl(t,e,n){let r=t.t,i=a=>n.update(a),o=de(e.points),s=du.map(a=>[a,r(`out_${a}`)]),l=hu.map(a=>[a,r(`slope_${a.replace("-","n")}`)]);return m`
+ ${r.error?m`${r.error}
`:_}`}var qo=(t,e,n)=>Math.min(e,Math.max(t,ae(n)));function pl(t,e,n){let r=t.t,i=a=>n.update(a),o=de(e.points),s=pu.map(a=>[a,r(`out_${a}`)]),l=fu.map(a=>[a,r(`slope_${a.replace("-","n")}`)]);return m`
${r("outdoor")} ${n.lockButton}
- ${L(t,r("outdoor_type"),e.type,s,a=>i({type:a}),{wide:!0})}
- ${L(t,r("area"),e.area_id??"",[["",r("no_area")],...Object.values(t.hass?.areas??{}).sort((a,c)=>a.name.localeCompare(c.name)).map(a=>[a.area_id,a.name])],a=>i({area_id:a||null}),{wide:!0,title:r("outdoor_area_hint")})}
+ ${H(t,r("outdoor_type"),e.type,s,a=>i({type:a}),{wide:!0})}
+ ${H(t,r("area"),e.area_id??"",[["",r("no_area")],...Object.values(t.hass?.areas??{}).sort((a,c)=>a.name.localeCompare(c.name)).map(a=>[a.area_id,a.name])],a=>i({area_id:a||null}),{wide:!0,title:r("outdoor_area_hint")})}
${e.type==="pool"||e.type==="wild"||e.type==="bed"?m`${z(t,r("pool_temp"),e.temp_entity??null,void 0,O(t.hass,a=>a.startsWith("sensor.")&&t.hass?.states[a]?.attributes.device_class==="temperature"),a=>i({temp_entity:a&&a!=="none"?a:null}))}
${z(t,r("pool_pump"),e.pump_entity??null,void 0,O(t.hass,a=>/^(switch|fan|valve|input_boolean|binary_sensor)\./.test(a)),a=>i({pump_entity:a&&a!=="none"?a:null}))}`:_}
- ${Tn(e.points)?m`${E(t,r("x"),o.x0,a=>n.setRectangle("x",a))} ${E(t,r("z"),o.z0,a=>n.setRectangle("z",a))}
+ ${zn(e.points)?m`${E(t,r("x"),o.x0,a=>n.setRectangle("x",a))} ${E(t,r("z"),o.z0,a=>n.setRectangle("z",a))}
${E(t,r("width"),o.x1-o.x0,a=>n.setRectangle("w",a),.01,.1)} ${E(t,r("depth"),o.z1-o.z0,a=>n.setRectangle("d",a),.01,.1)}`:_}
- ${Is(e.type)?E(t,r("outdoor_height"),e.height??Ds[e.type],a=>i({height:Zo(.1,6,a)}),.05,.1):_}
- ${E(t,r("outdoor_offset"),e.offset??0,a=>i({offset:Zo(-10,10,a)||null}),.05)}
- ${e.type!=="pool"?m`${E(t,r("outdoor_slope"),e.slope??0,a=>i({slope:Zo(0,20,a)||null}),.05,0)}
- ${L(t,r("outdoor_slope_dir"),e.slope_dir??"x",l,a=>i({slope_dir:a}))}`:_}
+ ${Os(e.type)?E(t,r("outdoor_height"),e.height??Is[e.type],a=>i({height:qo(.1,6,a)}),.05,.1):_}
+ ${E(t,r("outdoor_offset"),e.offset??0,a=>i({offset:qo(-10,10,a)||null}),.05)}
+ ${e.type!=="pool"?m`${E(t,r("outdoor_slope"),e.slope??0,a=>i({slope:qo(0,20,a)||null}),.05,0)}
+ ${H(t,r("outdoor_slope_dir"),e.slope_dir??"x",l,a=>i({slope_dir:a}))}`:_}
${E(t,r("outdoor_opacity"),Math.round((e.opacity??1)*100),a=>i({opacity:a>=100||!(a>0)?null:Math.max(10,Math.min(95,a))/100}),5,10)}
${D(t,r("outdoor_outline"),e.outline!==!1,a=>i({outline:a?void 0:!1}),{title:r("outdoor_outline_hint")})}
${e.type==="fence"||e.type==="pergola"?D(t,r("outdoor_open"),!!e.open,a=>i({open:a||void 0}),{title:r("outdoor_open_hint")}):_}
${e.type==="pergola"?D(t,r("outdoor_bracing"),!!e.bracing,a=>i({bracing:a||void 0})):_}
- ${D(t,r("outdoor_cut"),mu(e),a=>i({cut:a===(e.type==="pool")?void 0:a}),{title:r("outdoor_cut_hint")})}
+ ${D(t,r("outdoor_cut"),_u(e),a=>i({cut:a===(e.type==="pool")?void 0:a}),{title:r("outdoor_cut_hint")})}
- ${e.type==="fence"?Nw(t,e,i):_}
+ ${e.type==="fence"?Ww(t,e,i):_}
${t.admin?m`
${e.points.map((a,c)=>m`n.removeCorner(c)}>${c+1} × `)}
${S(r("outdoor_corners_hint"))}`:_}
${e.slope?S(r("outdoor_slope_hint")):_} ${S(r("outdoor_hint"))}
${t.admin?m`n.duplicate()}>${r("duplicate")} n.remove()}>${r("delete")}
`:_}
- `}function Nw(t,e,n){let r=t.t,i=e.gates??[],o=h=>n({gates:h.length?h:void 0}),s=e.points.map((h,f)=>[String(f),`${f+1} \u2192 ${(f+1)%e.points.length+1}`]),l=h=>{let[f,g]=[e.points[h],e.points[(h+1)%e.points.length]];return f&&g?Math.hypot(g[0]-f[0],g[1]-f[1]):0},a=(h,f)=>o(i.map((g,b)=>b===h?{...g,...f}:g)),c=O(t.hass,h=>/^(cover|switch|input_boolean|lock)\./.test(h)),u=O(t.hass,h=>h.startsWith("binary_sensor.")),d=[["single",r("gate_single")],["double",r("gate_double")],["sliding",r("gate_sliding")]],p=()=>{let f=l(0);o([...i,{id:I("gate"),edge:0,offset:ae(f/2),width:Math.min(1.2,Math.max(.5,ae(f*.4))),kind:"single"}])};return m`${r("fence_gates")}
+ `}function Ww(t,e,n){let r=t.t,i=e.gates??[],o=h=>n({gates:h.length?h:void 0}),s=e.points.map((h,f)=>[String(f),`${f+1} \u2192 ${(f+1)%e.points.length+1}`]),l=h=>{let[f,g]=[e.points[h],e.points[(h+1)%e.points.length]];return f&&g?Math.hypot(g[0]-f[0],g[1]-f[1]):0},a=(h,f)=>o(i.map((g,b)=>b===h?{...g,...f}:g)),c=O(t.hass,h=>/^(cover|switch|input_boolean|lock)\./.test(h)),u=O(t.hass,h=>h.startsWith("binary_sensor.")),d=[["single",r("gate_single")],["double",r("gate_double")],["sliding",r("gate_sliding")]],p=()=>{let f=l(0);o([...i,{id:I("gate"),edge:0,offset:ae(f/2),width:Math.min(1.2,Math.max(.5,ae(f*.4))),kind:"single"}])};return m`${r("fence_gates")}
${i.map((h,f)=>m`
- ${L(t,r("gate_edge"),String(h.edge),s,g=>a(f,{edge:Number(g)}))}
- ${L(t,r("gate_kind"),h.kind,d,g=>a(f,{kind:g,width:g==="single"&&h.width>1.6?1:h.width}))}
+ ${H(t,r("gate_edge"),String(h.edge),s,g=>a(f,{edge:Number(g)}))}
+ ${H(t,r("gate_kind"),h.kind,d,g=>a(f,{kind:g,width:g==="single"&&h.width>1.6?1:h.width}))}
${E(t,r("gate_offset"),h.offset,g=>a(f,{offset:Math.max(0,Math.min(l(h.edge),ae(g)))}),.05,0)}
${E(t,r("gate_width"),h.width,g=>a(f,{width:Math.max(.3,Math.min(12,ae(g)))}),.05,.3)}
${z(t,r("gate_entity"),h.entity??null,void 0,c,g=>a(f,{entity:g&&g!=="none"?g:null}))}
@@ -963,13 +963,13 @@ ${o}`}else i=ip(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
${t.admin?m`o(i.filter((g,b)=>b!==f))}>${r("delete")} `:_}
`)}
${t.admin&&i.length<20?m`${r("gate_add")} `:_}
- ${S(r("fence_gates_hint"))}`}var Bw=[["up","\u2191"],["left","\u2190"],["right","\u2192"],["down","\u2193"]],Ww={ArrowRight:"right",ArrowLeft:"left",ArrowUp:"up",ArrowDown:"down"};function Af(t,e,n){let r=t.t,{draft:i}=e,o=d=>K(t.hass,d,2),[s,l]=[i[0],i[i.length-1]],a=s&&i.length>1?Math.hypot(l[0]-s[0],l[1]-s[1]):0,c=d=>{let p=Ww[d.key];p?(d.preventDefault(),n.step(p)):d.key==="Enter"&&n.close()},u=s?m`${S(r("measure_from",{x:o(s[0]),z:o(s[1])}))}
+ ${S(r("fence_gates_hint"))}`}var Vw=[["up","\u2191"],["left","\u2190"],["right","\u2192"],["down","\u2193"]],Kw={ArrowRight:"right",ArrowLeft:"left",ArrowUp:"up",ArrowDown:"down"};function Ff(t,e,n){let r=t.t,{draft:i}=e,o=d=>K(t.hass,d,2),[s,l]=[i[0],i[i.length-1]],a=s&&i.length>1?Math.hypot(l[0]-s[0],l[1]-s[1]):0,c=d=>{let p=Kw[d.key];p?(d.preventDefault(),n.step(p)):d.key==="Enter"&&n.close()},u=s?m`${S(r("measure_from",{x:o(s[0]),z:o(s[1])}))}
${i.length>1?m`${i.slice(1).map((d,p)=>m`${o(Math.hypot(d[0]-i[p][0],d[1]-i[p][1]))} m `)} `:_}
@@ -986,45 +986,45 @@ ${o}`}else i=ip(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
n.addRectangle()}>${r("rect_add")}
${S(r("measure_hint"))}
- `}function hl(t,e,n){let r=t.t,i=t.floor?.height??2.5,o=Math.hypot(e.b[0]-e.a[0],e.b[1]-e.a[1]);return m``}function fl(t,e,n){let r=t.t,i=t.floor?.height??2.5,o=Math.hypot(e.b[0]-e.a[0],e.b[1]-e.a[1]);return m`
${r("free_wall")} ${n.lockButton}
- ${E(t,r("wall_length"),o,s=>n.update({b:df(e,s)}),.01,.1)}
- ${E(t,r("wall_thickness"),e.thickness??t.doc.settings.wall_interior,s=>n.update({thickness:Zo(.02,1,s)}),.01,.02)}
- ${E(t,r("wall_height"),e.height??i,s=>n.update(hf(s,i)),.05,.05)}
+ ${E(t,r("wall_length"),o,s=>n.update({b:hf(e,s)}),.01,.1)}
+ ${E(t,r("wall_thickness"),e.thickness??t.doc.settings.wall_interior,s=>n.update({thickness:qo(.02,1,s)}),.01,.02)}
+ ${E(t,r("wall_height"),e.height??i,s=>n.update(pf(s,i)),.05,.05)}
${D(t,r("free_wall_slope"),e.height_end!=null,s=>n.update(s?{height:e.height??i,height_end:Math.max(.2,(e.height??i)/2)}:{height_end:null}),{title:r("free_wall_slope_hint")})}
${e.height_end!=null?E(t,r("free_wall_height_end"),e.height_end,s=>n.update({height_end:Math.max(.05,s)}),.05,.05):_}
${t.admin?m`${Go(t,`wall:${e.id}`,n.arc)}n.remove()}>${r("delete")}
`:_}
- ${Uo(t,`wall:${e.id}`,n.arc)}
+ ${Zo(t,`wall:${e.id}`,n.arc)}
${S(r("free_wall_hint"))}
- `}var Gt=t=>Math.round(t*1e3)/1e3,Vw=2.4;function Ff(t,e,n){let r=ba(t,e[0],e[1],n[0],n[1]),i=r===null,o=Math.min(...t.floors.map(a=>a.elevation)),s=Gt(r??o+Vw),l=i?6:t.settings.roof.pitch||35;return{id:I("roof"),x0:Gt(e[0]),z0:Gt(e[1]),x1:Gt(n[0]),z1:Gt(n[1]),shape:i?"pent":"gable",axis:n[0]-e[0]>=n[1]-e[1]?"x":"z",eave_a:s,eave_b:s,pitch_a:l,pitch_b:l,base:s,overhang:i?.15:null,...i?{open:!0}:{}}}function Tf(t){let e=n=>Gt(n+1);return{...structuredClone(t),id:I("roof"),x0:e(t.x0),x1:e(t.x1),z0:e(t.z0),z1:e(t.z1)}}var zf=(t,e)=>t.findIndex(n=>n.id===e)+1;function pl(t){return t.points&&t.points.length>=3?t.points.map(([e,n])=>[e,n]):t.rotation?Hr(t):[[t.x0,t.z0],[t.x1,t.z0],[t.x1,t.z1],[t.x0,t.z1]]}function Pf(t,e,n){let r=pl(t);r.splice(e+1,0,[Gt(n[0]),Gt(n[1])]),t.points=r,Object.assign(t,Vt(r))}function Df(t,e){return!t.points||t.points.length<=3||e<0||e>=t.points.length?!1:(t.points.splice(e,1),Object.assign(t,Vt(t.points)),!0)}var Kw={light:"M8.5 17.5h7M9.5 20.5h5M12 2.5a6.5 6.5 0 0 0-3.5 12v1.5h7V14.5A6.5 6.5 0 0 0 12 2.5z",switch:"M6 5h12a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2zM12 7.5v9M9 12h6",fan:"M12 11.5c-1-3.5 0-7 2.5-7s2 4-2.5 7zm.5.5c3.5-1 7 0 7 2.5s-4 2-7-2.5zm-.5.5c1 3.5 0 7-2.5 7s-2-4 2.5-7zm-.5-.5c-3.5 1-7 0-7-2.5s4-2 7 2.5z",cover:"M3.5 3.5h17v3h-17zM6 6.5v12M18 6.5v12M8.5 9.5h7M8.5 12.5h7M8.5 15.5h7",climate:"M12 15V5.5a2.5 2.5 0 0 0-5 0V15a4.5 4.5 0 1 0 5 0zM9.5 9v7M15 5.5h5M15 9.5h4",media:"M3.5 5.5h17v11h-17zM8 20.5h8M12 16.5v4M10 8.5v5l4.5-2.5z",lock:"M5.5 10.5h13v9.5h-13zM8 10.5V7.5a4 4 0 0 1 8 0v3M12 14v3",sensor:"M12 3.5a8.5 8.5 0 1 0 0 17 8.5 8.5 0 0 0 0-17zM12 7.5v4.5l3.5 2",binary:"M5.5 20.5v-17h10v17M3.5 20.5h14M9 20.5v-13h4.5v13M12.5 14h.01",scene:"M5.5 18.5l8-8M14 3.5l1 2.5 2.5 1-2.5 1-1 2.5-1-2.5-2.5-1 2.5-1zM18.5 12l.7 1.8 1.8.7-1.8.7-.7 1.8-.7-1.8-1.8-.7 1.8-.7z",script:"M8.5 3.5h8.5a2 2 0 0 1 2 2v13a2 2 0 0 1-2 2H7.5a2 2 0 0 1-2-2v-2h9M8.5 3.5a2 2 0 0 0-2 2v10M9.5 8.5h6M9.5 11.5h4"},Ut=t=>Kw[t];function qo(t,e){let n=new Set;for(let r of t?.placements??[])C([r.x,r.z],e.points)&&n.add(r.entity_id);for(let r of t?.furniture??[])ue(r.type)&&r.entity&&C([r.x,r.z],e.points)&&n.add(r.entity);return n}function If(t,e){let n=new Map;for(let r of t.floors){let i=[...r.placements.map(o=>[o.entity_id,o.x,o.z]),...r.furniture.filter(o=>ue(o.type)&&o.entity).map(o=>[o.entity,o.x,o.z])];for(let[o,s,l]of i){let a=r.rooms.find(c=>C([s,l],c.points));a&&a.id!==e.id&&n.set(o,a.name)}}return n}var Of=(t,e)=>(t??[]).includes(e)?(t??[]).filter(n=>n!==e):[...t??[],e];function Yo(t,...e){let n=t.trim().toLowerCase();return!n||e.some(r=>(r??"").toLowerCase().includes(n))}function Hf(t,e){return t.map(n=>({o:n,r:e(n.id)})).sort((n,r)=>n.r-r.r).map(({o:n})=>n)}function Lf(t,e){let n=e,r=0;return{taken:t.map(o=>{let s=o.ids.slice(0,Math.max(0,n));return n-=s.length,r+=o.ids.length-s.length,[...s]}),left:r}}var fl=50;function ml(t,e,n,r,i,o,s){let l=e.includes(n);return m`s.patchRoom({[r]:Of(e,n)})}>${l?i[0]:i[1]} `}function jw(t,e,n,r,i,o){let[s,l,a]=[e.hidden??[],e.no_state??[],e.panel??[]];return(c,u=!1,d=i)=>{let p=n.has(c),h=p?void 0:r.get(c),f=s.includes(c),g=Cn(t,c);return m`
+ `}var Gt=t=>Math.round(t*1e3)/1e3,jw=2.4;function Tf(t,e,n){let r=va(t,e[0],e[1],n[0],n[1]),i=r===null,o=Math.min(...t.floors.map(a=>a.elevation)),s=Gt(r??o+jw),l=i?6:t.settings.roof.pitch||35;return{id:I("roof"),x0:Gt(e[0]),z0:Gt(e[1]),x1:Gt(n[0]),z1:Gt(n[1]),shape:i?"pent":"gable",axis:n[0]-e[0]>=n[1]-e[1]?"x":"z",eave_a:s,eave_b:s,pitch_a:l,pitch_b:l,base:s,overhang:i?.15:null,...i?{open:!0}:{}}}function zf(t){let e=n=>Gt(n+1);return{...structuredClone(t),id:I("roof"),x0:e(t.x0),x1:e(t.x1),z0:e(t.z0),z1:e(t.z1)}}var Pf=(t,e)=>t.findIndex(n=>n.id===e)+1;function ml(t){return t.points&&t.points.length>=3?t.points.map(([e,n])=>[e,n]):t.rotation?Lr(t):[[t.x0,t.z0],[t.x1,t.z0],[t.x1,t.z1],[t.x0,t.z1]]}function Df(t,e,n){let r=ml(t);r.splice(e+1,0,[Gt(n[0]),Gt(n[1])]),t.points=r,Object.assign(t,Kt(r))}function If(t,e){return!t.points||t.points.length<=3||e<0||e>=t.points.length?!1:(t.points.splice(e,1),Object.assign(t,Kt(t.points)),!0)}var Uw={light:"M8.5 17.5h7M9.5 20.5h5M12 2.5a6.5 6.5 0 0 0-3.5 12v1.5h7V14.5A6.5 6.5 0 0 0 12 2.5z",switch:"M6 5h12a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2zM12 7.5v9M9 12h6",fan:"M12 11.5c-1-3.5 0-7 2.5-7s2 4-2.5 7zm.5.5c3.5-1 7 0 7 2.5s-4 2-7-2.5zm-.5.5c1 3.5 0 7-2.5 7s-2-4 2.5-7zm-.5-.5c-3.5 1-7 0-7-2.5s4-2 7 2.5z",cover:"M3.5 3.5h17v3h-17zM6 6.5v12M18 6.5v12M8.5 9.5h7M8.5 12.5h7M8.5 15.5h7",climate:"M12 15V5.5a2.5 2.5 0 0 0-5 0V15a4.5 4.5 0 1 0 5 0zM9.5 9v7M15 5.5h5M15 9.5h4",media:"M3.5 5.5h17v11h-17zM8 20.5h8M12 16.5v4M10 8.5v5l4.5-2.5z",lock:"M5.5 10.5h13v9.5h-13zM8 10.5V7.5a4 4 0 0 1 8 0v3M12 14v3",sensor:"M12 3.5a8.5 8.5 0 1 0 0 17 8.5 8.5 0 0 0 0-17zM12 7.5v4.5l3.5 2",binary:"M5.5 20.5v-17h10v17M3.5 20.5h14M9 20.5v-13h4.5v13M12.5 14h.01",scene:"M5.5 18.5l8-8M14 3.5l1 2.5 2.5 1-2.5 1-1 2.5-1-2.5-2.5-1 2.5-1zM18.5 12l.7 1.8 1.8.7-1.8.7-.7 1.8-.7-1.8-1.8-.7 1.8-.7z",script:"M8.5 3.5h8.5a2 2 0 0 1 2 2v13a2 2 0 0 1-2 2H7.5a2 2 0 0 1-2-2v-2h9M8.5 3.5a2 2 0 0 0-2 2v10M9.5 8.5h6M9.5 11.5h4"},Zt=t=>Uw[t];function Yo(t,e){let n=new Set;for(let r of t?.placements??[])C([r.x,r.z],e.points)&&n.add(r.entity_id);for(let r of t?.furniture??[])ue(r.type)&&r.entity&&C([r.x,r.z],e.points)&&n.add(r.entity);return n}function Of(t,e){let n=new Map;for(let r of t.floors){let i=[...r.placements.map(o=>[o.entity_id,o.x,o.z]),...r.furniture.filter(o=>ue(o.type)&&o.entity).map(o=>[o.entity,o.x,o.z])];for(let[o,s,l]of i){let a=r.rooms.find(c=>C([s,l],c.points));a&&a.id!==e.id&&n.set(o,a.name)}}return n}var Hf=(t,e)=>(t??[]).includes(e)?(t??[]).filter(n=>n!==e):[...t??[],e];function Xo(t,...e){let n=t.trim().toLowerCase();return!n||e.some(r=>(r??"").toLowerCase().includes(n))}function Lf(t,e){return t.map(n=>({o:n,r:e(n.id)})).sort((n,r)=>n.r-r.r).map(({o:n})=>n)}function Cf(t,e){let n=e,r=0;return{taken:t.map(o=>{let s=o.ids.slice(0,Math.max(0,n));return n-=s.length,r+=o.ids.length-s.length,[...s]}),left:r}}var gl=50;function _l(t,e,n,r,i,o,s){let l=e.includes(n);return m`
s.patchRoom({[r]:Hf(e,n)})}>${l?i[0]:i[1]} `}function Gw(t,e,n,r,i,o){let[s,l,a]=[e.hidden??[],e.no_state??[],e.panel??[]];return(c,u=!1,d=i)=>{let p=n.has(c),h=p?void 0:r.get(c),f=s.includes(c),g=Cn(t,c);return m`
o.select(c)}>
- ${g?m` `:m` `}
+ ${g?m` `:m` `}
${B(t.hass,c,d)}${h?m` · ${t.t("devices_placed_in",{room:h})} `:_}
- ${t.admin?ml(t,s,c,"hidden",["\u{1F648}","\u{1F441}"],["panel_unhide","panel_hide"],o):_}
- ${t.admin&&!f?ml(t,l,c,"no_state",["\u2205","Aa"],["panel_state_show","panel_state_hide"],o):_}
- ${t.admin&&!p?ml(t,a,c,"panel",["\u2605","\u2606"],["panel_unpin","panel_pin"],o):_}
+ ${t.admin?_l(t,s,c,"hidden",["\u{1F648}","\u{1F441}"],["panel_unhide","panel_hide"],o):_}
+ ${t.admin&&!f?_l(t,l,c,"no_state",["\u2205","Aa"],["panel_state_show","panel_state_hide"],o):_}
+ ${t.admin&&!p?_l(t,a,c,"panel",["\u2605","\u2606"],["panel_unpin","panel_pin"],o):_}
${t.admin?p?m`
o.remove(c)}>${t.t("devices_remove")} `:m`
o.place([c])}>${t.t("devices_place")} `:_}
-
`}}function Gw(t,e,n,r,i){let{hass:o}=t;if(!o)return m``;let s=u=>u>0?S(t.t("devices_narrow",{n:u})):_,l=S(t.t("devices_none")),a=e.deviceQuery;if(i==="other"){let u=Cu(o,n.area_id).map(f=>({...f,ids:f.ids.filter(g=>Yo(a,`${B(o,g,f.name)} ${g} ${f.name}`))})),{taken:d,left:p}=Lf(u,fl),h=u.map((f,g)=>d[g].length>0?m`
${f.name}
${d[g].map(b=>r(b,!1,f.name))}`:_);return d.some(f=>f.length>0)?m`
${h}
${s(p)}`:l}let c=Nu(o).filter(u=>Yo(a,`${B(o,u)} ${u} `));return c.length>0?m`
${c.slice(0,fl).map(u=>r(u))}
${s(c.length-Math.min(c.length,fl))}`:l}function Uw(t,e,n,r,i,o,s){let{hass:l}=t,a=l?ye(l,n).filter(y=>Ft(je(l,y))):[];if(!n.area_id)return S(t.t("devices_none_area"));if(a.length===0)return S(t.t("devices_none"));let c=l?Pn(l,a):[],u=c.map(y=>y.primary).filter(y=>!i.has(y)),d=e.deviceQuery,p=(t.floor?.placements??[]).filter(y=>Q(y.entity_id)==="light"&&(y.mount??"ceiling")==="ceiling"&&C([y.x,y.z],n.points)).length,h=m`
e.deviceQuery=y.target.value} />`,f=y=>Yo(d,B(l,y,o),y),g=y=>{let v=y.others.filter(f),w=e.isUnfolded(y.primary)||!!d.trim()&&v.length>0;return!f(y.primary)&&v.length===0?_:m`${r(y.primary)}
+
`}}function Zw(t,e,n,r,i){let{hass:o}=t;if(!o)return m``;let s=u=>u>0?S(t.t("devices_narrow",{n:u})):_,l=S(t.t("devices_none")),a=e.deviceQuery;if(i==="other"){let u=Bu(o,n.area_id).map(f=>({...f,ids:f.ids.filter(g=>Xo(a,`${B(o,g,f.name)} ${g} ${f.name}`))})),{taken:d,left:p}=Cf(u,gl),h=u.map((f,g)=>d[g].length>0?m`${f.name}
${d[g].map(b=>r(b,!1,f.name))}`:_);return d.some(f=>f.length>0)?m`${h}
${s(p)}`:l}let c=Wu(o).filter(u=>Xo(a,`${B(o,u)} ${u} `));return c.length>0?m`${c.slice(0,gl).map(u=>r(u))}
${s(c.length-Math.min(c.length,gl))}`:l}function qw(t,e,n,r,i,o,s){let{hass:l}=t,a=l?ye(l,n).filter(y=>Ft(je(l,y))):[];if(!n.area_id)return S(t.t("devices_none_area"));if(a.length===0)return S(t.t("devices_none"));let c=l?Dn(l,a):[],u=c.map(y=>y.primary).filter(y=>!i.has(y)),d=e.deviceQuery,p=(t.floor?.placements??[]).filter(y=>Q(y.entity_id)==="light"&&(y.mount??"ceiling")==="ceiling"&&C([y.x,y.z],n.points)).length,h=m` e.deviceQuery=y.target.value} />`,f=y=>Xo(d,B(l,y,o),y),g=y=>{let v=y.others.filter(f),w=e.isUnfolded(y.primary)||!!d.trim()&&v.length>0;return!f(y.primary)&&v.length===0?_:m`${r(y.primary)}
${y.others.length>0?m`e.toggleUnfolded(y.primary)}>${w?t.t("devices_less"):t.t("devices_more",{n:y.others.length})} `:_}
${w?(d.trim()?v:y.others).map(x=>r(x,!0)):_}`},b=()=>s.confirm(t.t("devices_place_all_confirm",{n:u.length}))&&s.place(u);return m`${t.admin&&p>=2?m`s.spreadLights(n)}>${t.t("lights_spread")} `:_}
${a.length>8?h:_}
${c.map(g)}
${t.admin&&u.length>1?m`${t.t("devices_place_all_n",{n:u.length})} `:_}
- ${S(t.t("devices_hint"))}`}function gl(t,e,n,r){let{hass:i}=t,o=n.area_id?i?.areas?.[n.area_id]?.name:void 0,s=qo(t.floor,n),l=jw(t,n,s,If(t.doc,n),o,r),a=t.admin?e.deviceSource:"area",c=i?Pn(i,ye(i,n).filter(p=>Ft(je(i,p)))).length:0,u=[["area",`${t.t("devices_src_area")}${c>0?` (${c})`:""}`],["other",t.t("devices_src_other")],["none",t.t("devices_src_none")]],d=m` e.deviceQuery=p.target.value} />`;return m`
+ ${S(t.t("devices_hint"))}`}function bl(t,e,n,r){let{hass:i}=t,o=n.area_id?i?.areas?.[n.area_id]?.name:void 0,s=Yo(t.floor,n),l=Gw(t,n,s,Of(t.doc,n),o,r),a=t.admin?e.deviceSource:"area",c=i?Dn(i,ye(i,n).filter(p=>Ft(je(i,p)))).length:0,u=[["area",`${t.t("devices_src_area")}${c>0?` (${c})`:""}`],["other",t.t("devices_src_other")],["none",t.t("devices_src_none")]],d=m` e.deviceQuery=p.target.value} />`;return m`
${t.t("devices")}
${S(t.t("devices_panel_hint"))}
${t.admin?m`${u.map(([p,h])=>m`e.deviceSource=p}>${h} `)}
`:_}
- ${a!=="area"?m`${d}${Gw(t,e,n,l,a)}`:Uw(t,e,n,l,s,o,r)}
- `}function Cf(t,e,n){let{hass:r}=t;if(!r)return _;let i=!!e.floor_heating||!!e.hvac||!!e.climate&&Object.values(e.climate).some(l=>l!=null),o=(l,a)=>{let c={...e.climate??{},[l]:a};n({climate:Object.values(c).every(u=>u==null)?null:c})},s=(l,a)=>{let c=Bu(r,t.floor??null,{...e,climate:null},l),u=[e.climate?.[l]??null].flat(),d=O(r,b=>qs(r,b,l,!0)&&(!r.states[b]?.attributes.symcon_source_entity||u.includes(b))),p=Hf(d,b=>(Dt(r,b)===e.area_id?0:1)+(Ys(r,b)?0:2)),h=b=>{let y=b.filter(v=>!!v&&v!=="none");o(l,y.length>1?y:y[0]??(b.includes("none")?"none":null))},g=u[0]&&u[0]!=="none"?[...u,null]:u;return g.map((b,y)=>z(t,y?t.t("climate_more"):a,b,y?void 0:c[0]??null,p,v=>h(g.map((w,x)=>x===y?v:w)),{types:[1,2]}))};return m`
+ ${a!=="area"?m`${d}${Zw(t,e,n,l,a)}`:qw(t,e,n,l,s,o,r)}
+ `}function Nf(t,e,n){let{hass:r}=t;if(!r)return _;let i=!!e.floor_heating||!!e.hvac||!!e.climate&&Object.values(e.climate).some(l=>l!=null),o=(l,a)=>{let c={...e.climate??{},[l]:a};n({climate:Object.values(c).every(u=>u==null)?null:c})},s=(l,a)=>{let c=Vu(r,t.floor??null,{...e,climate:null},l),u=[e.climate?.[l]??null].flat(),d=O(r,b=>Ys(r,b,l,!0)&&(!r.states[b]?.attributes.symcon_source_entity||u.includes(b))),p=Lf(d,b=>(Dt(r,b)===e.area_id?0:1)+(Xs(r,b)?0:2)),h=b=>{let y=b.filter(v=>!!v&&v!=="none");o(l,y.length>1?y:y[0]??(b.includes("none")?"none":null))},g=u[0]&&u[0]!=="none"?[...u,null]:u;return g.map((b,y)=>z(t,y?t.t("climate_more"):a,b,y?void 0:c[0]??null,p,v=>h(g.map((w,x)=>x===y?v:w)),{types:[1,2]}))};return m`
${t.t("climate")}
- ${s("temperature",t.t("climate_temperature"))} ${s("humidity",t.t("climate_humidity"))} ${s("co2",t.t("climate_co2"))} ${s("illuminance",t.t("climate_illuminance"))}${X(r)?$h(t,e,n):_}
+ ${s("temperature",t.t("climate_temperature"))} ${s("humidity",t.t("climate_humidity"))} ${s("co2",t.t("climate_co2"))} ${s("illuminance",t.t("climate_illuminance"))}${X(r)?Sh(t,e,n):_}
${D(t,t.t("climate_card"),!!e.climate_card,l=>n({climate_card:l||void 0}))}
${S(t.t("climate_card_hint"))}
${S(t.t("climate_hint"))}
- `}var _l="metric",Bf=t=>{_l=t==="imperial"?"imperial":"metric"};var Nf=.3048;function pe(t,e,n=2,r=_l){if(r==="metric")return`${K(t,e,n)} m`;let i=e<0?"\u2212":"",o=Math.round(Math.abs(e)/.0254*2),s=Math.floor(o/24),l=o-s*24,a=`${Math.floor(l/2)}${l%2?"\xBD":""}`;return s?`${i}${s}\u2032 ${a}\u2033`:`${i}${a}\u2033`}function ze(t,e,n=_l){return n==="metric"?`${K(t,e,1)} m\xB2`:`${K(t,e/(Nf*Nf),0)} ft\xB2`}var Zw=.15,qw=(t,e)=>Math.abs((t-e+540)%360-180);function Yw(t,e,n,r){return t.rooms.some(i=>i.id!==e.id&&i.points.some((o,s)=>{let l=i.points[(s+1)%i.points.length];return Math.abs(te(G(o,n),r))<.02&&Math.abs(te(G(l,n),r))<.02}))}function yl(t,e,n,r){let i=e.points,[o,s]=[i[n],i[(n+1)%i.length]],l=ge(G(s,o)),a=_e(i)>=0?1:-1,c=[(s[0]-o[0])/l,(s[1]-o[1])/l],u=[-c[1]*a||0,c[0]*a||0],d=c[0]*u[1]-c[1]*u[0]>0,p=e.wall_heights?.[n],h=e.ceiling??t.height,f=typeof p=="number"?p:Array.isArray(p)?Math.max(...p.map(y=>y??h)):h,g=e.wall_slopes?.[n],b=typeof g=="number"&&typeof p=="number"?g:f;return{origin:d?o:s,along:d?c:[-c[0],-c[1]],normal:u,length:l,face:Yw(t,e,o,u)?r/2:0,heightLeft:d?f:b,heightRight:d?b:f}}function bl(t,e){let n=G(e,t.origin);return{u:te(n,t.along),depth:te(n,t.normal)-t.face}}function Xw(t,e){let n=t.rooms.find(s=>s.id===e.room_id);if(!n||e.wall)return null;let[r,i]=[n.points[e.edge],n.points[(e.edge+1)%n.points.length]];if(!r||!i)return null;let o=ge(G(i,r))||1;return[r[0]+(i[0]-r[0])*e.offset/o,r[1]+(i[1]-r[1])*e.offset/o]}var Wf=t=>U(t.type)?.mount==="wall"||t.type==="lamp_wall"||t.mount_y!=null;function Vf(t,e,n){let r=[];for(let o of t.openings){let s=Xw(t,o);if(!s)continue;let{u:l,depth:a}=bl(n,s);Math.abs(a+n.face)>.3||l<-.01||l>n.length+.01||r.push({id:o.id,kind:"opening",type:o.type,x0:l-o.width/2,x1:l+o.width/2,y0:o.sill,y1:o.sill+o.height,lifts:o.type==="window"})}let i=Math.atan2(-n.normal[0],n.normal[1])*180/Math.PI;for(let o of t.furniture){if(!C([o.x,o.z],e.points)||qw(o.rotation,i)>20)continue;let{u:s,depth:l}=bl(n,[o.x,o.z]);if(l-o.d/2>Zw||s<0||s>n.length)continue;let a=zt(t,o);r.push({id:o.id,kind:"furniture",type:o.type,x0:s-o.w/2,x1:s+o.w/2,y0:a,y1:a+o.h,lifts:Wf(o)})}return r.sort((o,s)=>+(o.kind==="furniture")-+(s.kind==="furniture")||o.x0-s.x0)}var ki=t=>Math.round(t*1e3)/1e3;function Kf(t,e,n,r){let i=bl(t,[e.x,e.z]).depth,o=Math.min(t.length-e.w/2,Math.max(e.w/2,n+e.w/2)),s=[t.origin[0]+t.along[0]*o+t.normal[0]*(i+t.face),t.origin[1]+t.along[1]*o+t.normal[1]*(i+t.face)];return{x:ki(s[0]),z:ki(s[1]),...r!==null&&Wf(e)?{mount_y:ki(Math.max(0,r))}:{}}}function jf(t,e,n,r,i){let[o]=[e.points[n.edge]],s=Math.min(t.length-n.width/2,Math.max(n.width/2,r+n.width/2)),l=ge(G(o,t.origin))<1e-6?s:t.length-s;return{offset:ki(l),...i!==null&&n.type==="window"?{sill:ki(Math.max(0,i))}:{}}}var Gf=.01,Uf=t=>Math.round(t/Gf)*Gf,vl=class extends Y{static properties={host:{attribute:!1},doc:{attribute:!1},roomId:{},edge:{type:Number},_sel:{state:!0},_drag:{state:!0}};constructor(){super(),this._sel=null,this._drag=null}get room(){return this.host.floor?.rooms.find(e=>e.id===this.roomId)}frame(){let e=this.room;return e&&this.host.floor?yl(this.host.floor,e,this.edge,this.host.doc.settings.wall_interior):null}boxes(){let e=this.room,n=this.frame();return e&&n&&this.host.floor?Vf(this.host.floor,e,n):[]}place(e,n,r){let i=this.room,o=this.frame();!i||!o||this.host.change((s,l)=>{if(e.kind==="furniture"){let a=l.furniture.find(c=>c.id===e.id);a&&Object.assign(a,Kf(o,a,n,e.lifts?r:null))}else{let a=l.openings.find(u=>u.id===e.id),c=l.rooms.find(u=>u.id===a?.room_id);a&&c&&Object.assign(a,jf(c.id===i.id?o:yl(l,c,a.edge,this.host.doc.settings.wall_interior),c,a,n,e.lifts?r:null))}})}toWall(e){let r=this.renderRoot.querySelector("svg").getScreenCTM()?.inverse();if(!r)return[0,0];let i=new DOMPoint(e.clientX,e.clientY).matrixTransform(r);return[i.x,-i.y]}down(e,n){if(this._sel=n.id,!this.host.admin)return;e.currentTarget.setPointerCapture(e.pointerId);let[r,i]=this.toWall(e);this._drag={id:n.id,x0:n.x0,y0:n.y0,startU:r,startY:i,fromX:n.x0,fromY:n.y0}}move(e,n){let r=this._drag;if(!r||r.id!==n.id)return;let[i,o]=this.toWall(e),s=this.frame(),l=n.x1-n.x0,a=Math.min((s?.length??0)-l,Math.max(0,Uf(r.fromX+i-r.startU))),c=n.lifts?Math.max(0,Uf(r.fromY+o-r.startY)):r.fromY;this._drag={...r,x0:a,y0:c}}up(e){let n=this._drag;this._drag=null,!(!n||n.id!==e.id||Math.abs(n.x0-n.fromX)<1e-6&&Math.abs(n.y0-n.fromY)<1e-6)&&this.place(e,n.x0,n.y0)}nameOf(e){if(e.kind==="furniture")return this.host.floor?.furniture.find(i=>i.id===e.id)?.name||Ae(this.host.hass,e.type);let n=this.host.floor?.openings.find(r=>r.id===e.id);return n?this.host.t(`preset_${Fn(n)}`):e.type}updated(e){(e.has("edge")||e.has("roomId"))&&(this._sel=null)}render(){let e=this.host.t,n=this.room,r=this.frame();if(!n||!r)return _;let i=n.points.length,o=h=>pe(this.host.hass,h),s=this.boxes().map(h=>this._drag?.id===h.id?{...h,x1:this._drag.x0+(h.x1-h.x0),y1:this._drag.y0+(h.y1-h.y0),x0:this._drag.x0,y0:this._drag.y0}:h),l=Math.max(r.heightLeft,r.heightRight,...s.map(h=>h.y1)),a=.35,c=`${-a} ${-(l+a)} ${r.length+2*a} ${l+2*a+.25}`,u=s.find(h=>h.id===this._sel)??null,d=h=>{let f=Math.min(.14,Math.max(.07,(h.x1-h.x0)/7));return R`${this.nameOf(h)} `},p=u?R`
+ `}var yl="metric",Wf=t=>{yl=t==="imperial"?"imperial":"metric"};var Bf=.3048;function pe(t,e,n=2,r=yl){if(r==="metric")return`${K(t,e,n)} m`;let i=e<0?"\u2212":"",o=Math.round(Math.abs(e)/.0254*2),s=Math.floor(o/24),l=o-s*24,a=`${Math.floor(l/2)}${l%2?"\xBD":""}`;return s?`${i}${s}\u2032 ${a}\u2033`:`${i}${a}\u2033`}function ze(t,e,n=yl){return n==="metric"?`${K(t,e,1)} m\xB2`:`${K(t,e/(Bf*Bf),0)} ft\xB2`}var Yw=.15,Xw=(t,e)=>Math.abs((t-e+540)%360-180);function Jw(t,e,n,r){return t.rooms.some(i=>i.id!==e.id&&i.points.some((o,s)=>{let l=i.points[(s+1)%i.points.length];return Math.abs(te(U(o,n),r))<.02&&Math.abs(te(U(l,n),r))<.02}))}function wl(t,e,n,r){let i=e.points,[o,s]=[i[n],i[(n+1)%i.length]],l=ge(U(s,o)),a=_e(i)>=0?1:-1,c=[(s[0]-o[0])/l,(s[1]-o[1])/l],u=[-c[1]*a||0,c[0]*a||0],d=c[0]*u[1]-c[1]*u[0]>0,p=e.wall_heights?.[n],h=e.ceiling??t.height,f=typeof p=="number"?p:Array.isArray(p)?Math.max(...p.map(y=>y??h)):h,g=e.wall_slopes?.[n],b=typeof g=="number"&&typeof p=="number"?g:f;return{origin:d?o:s,along:d?c:[-c[0],-c[1]],normal:u,length:l,face:Jw(t,e,o,u)?r/2:0,heightLeft:d?f:b,heightRight:d?b:f}}function vl(t,e){let n=U(e,t.origin);return{u:te(n,t.along),depth:te(n,t.normal)-t.face}}function Qw(t,e){let n=t.rooms.find(s=>s.id===e.room_id);if(!n||e.wall)return null;let[r,i]=[n.points[e.edge],n.points[(e.edge+1)%n.points.length]];if(!r||!i)return null;let o=ge(U(i,r))||1;return[r[0]+(i[0]-r[0])*e.offset/o,r[1]+(i[1]-r[1])*e.offset/o]}var Vf=t=>G(t.type)?.mount==="wall"||t.type==="lamp_wall"||t.mount_y!=null;function Kf(t,e,n){let r=[];for(let o of t.openings){let s=Qw(t,o);if(!s)continue;let{u:l,depth:a}=vl(n,s);Math.abs(a+n.face)>.3||l<-.01||l>n.length+.01||r.push({id:o.id,kind:"opening",type:o.type,x0:l-o.width/2,x1:l+o.width/2,y0:o.sill,y1:o.sill+o.height,lifts:o.type==="window"})}let i=Math.atan2(-n.normal[0],n.normal[1])*180/Math.PI;for(let o of t.furniture){if(!C([o.x,o.z],e.points)||Xw(o.rotation,i)>20)continue;let{u:s,depth:l}=vl(n,[o.x,o.z]);if(l-o.d/2>Yw||s<0||s>n.length)continue;let a=zt(t,o);r.push({id:o.id,kind:"furniture",type:o.type,x0:s-o.w/2,x1:s+o.w/2,y0:a,y1:a+o.h,lifts:Vf(o)})}return r.sort((o,s)=>+(o.kind==="furniture")-+(s.kind==="furniture")||o.x0-s.x0)}var xi=t=>Math.round(t*1e3)/1e3;function jf(t,e,n,r){let i=vl(t,[e.x,e.z]).depth,o=Math.min(t.length-e.w/2,Math.max(e.w/2,n+e.w/2)),s=[t.origin[0]+t.along[0]*o+t.normal[0]*(i+t.face),t.origin[1]+t.along[1]*o+t.normal[1]*(i+t.face)];return{x:xi(s[0]),z:xi(s[1]),...r!==null&&Vf(e)?{mount_y:xi(Math.max(0,r))}:{}}}function Uf(t,e,n,r,i){let[o]=[e.points[n.edge]],s=Math.min(t.length-n.width/2,Math.max(n.width/2,r+n.width/2)),l=ge(U(o,t.origin))<1e-6?s:t.length-s;return{offset:xi(l),...i!==null&&n.type==="window"?{sill:xi(Math.max(0,i))}:{}}}var Gf=.01,Zf=t=>Math.round(t/Gf)*Gf,kl=class extends Y{static properties={host:{attribute:!1},doc:{attribute:!1},roomId:{},edge:{type:Number},_sel:{state:!0},_drag:{state:!0}};constructor(){super(),this._sel=null,this._drag=null}get room(){return this.host.floor?.rooms.find(e=>e.id===this.roomId)}frame(){let e=this.room;return e&&this.host.floor?wl(this.host.floor,e,this.edge,this.host.doc.settings.wall_interior):null}boxes(){let e=this.room,n=this.frame();return e&&n&&this.host.floor?Kf(this.host.floor,e,n):[]}place(e,n,r){let i=this.room,o=this.frame();!i||!o||this.host.change((s,l)=>{if(e.kind==="furniture"){let a=l.furniture.find(c=>c.id===e.id);a&&Object.assign(a,jf(o,a,n,e.lifts?r:null))}else{let a=l.openings.find(u=>u.id===e.id),c=l.rooms.find(u=>u.id===a?.room_id);a&&c&&Object.assign(a,Uf(c.id===i.id?o:wl(l,c,a.edge,this.host.doc.settings.wall_interior),c,a,n,e.lifts?r:null))}})}toWall(e){let r=this.renderRoot.querySelector("svg").getScreenCTM()?.inverse();if(!r)return[0,0];let i=new DOMPoint(e.clientX,e.clientY).matrixTransform(r);return[i.x,-i.y]}down(e,n){if(this._sel=n.id,!this.host.admin)return;e.currentTarget.setPointerCapture(e.pointerId);let[r,i]=this.toWall(e);this._drag={id:n.id,x0:n.x0,y0:n.y0,startU:r,startY:i,fromX:n.x0,fromY:n.y0}}move(e,n){let r=this._drag;if(!r||r.id!==n.id)return;let[i,o]=this.toWall(e),s=this.frame(),l=n.x1-n.x0,a=Math.min((s?.length??0)-l,Math.max(0,Zf(r.fromX+i-r.startU))),c=n.lifts?Math.max(0,Zf(r.fromY+o-r.startY)):r.fromY;this._drag={...r,x0:a,y0:c}}up(e){let n=this._drag;this._drag=null,!(!n||n.id!==e.id||Math.abs(n.x0-n.fromX)<1e-6&&Math.abs(n.y0-n.fromY)<1e-6)&&this.place(e,n.x0,n.y0)}nameOf(e){if(e.kind==="furniture")return this.host.floor?.furniture.find(i=>i.id===e.id)?.name||Ae(this.host.hass,e.type);let n=this.host.floor?.openings.find(r=>r.id===e.id);return n?this.host.t(`preset_${Tn(n)}`):e.type}updated(e){(e.has("edge")||e.has("roomId"))&&(this._sel=null)}render(){let e=this.host.t,n=this.room,r=this.frame();if(!n||!r)return _;let i=n.points.length,o=h=>pe(this.host.hass,h),s=this.boxes().map(h=>this._drag?.id===h.id?{...h,x1:this._drag.x0+(h.x1-h.x0),y1:this._drag.y0+(h.y1-h.y0),x0:this._drag.x0,y0:this._drag.y0}:h),l=Math.max(r.heightLeft,r.heightRight,...s.map(h=>h.y1)),a=.35,c=`${-a} ${-(l+a)} ${r.length+2*a} ${l+2*a+.25}`,u=s.find(h=>h.id===this._sel)??null,d=h=>{let f=Math.min(.14,Math.max(.07,(h.x1-h.x0)/7));return R`${this.nameOf(h)} `},p=u?R`
${o(u.x0)}
@@ -1173,14 +1173,14 @@ ${o}`}else i=ip(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
color: inherit;
font: inherit;
}
- `};customElements.get("nf-wall-view")||customElements.define("nf-wall-view",vl);function Jw(t,e){let n=new Set([...Object.keys(t),...Object.keys(e)]);if(n.size===0)return 1/0;let r=0;for(let i of n)r+=Math.min(Math.abs((t[i]??-100)-(e[i]??-100)),40)**2;return Math.sqrt(r/n.size)}function Zf(t,e){if(Object.keys(e).length===0)return{room:null,distance:1/0,margin:0};let n=new Map;for(let s of t){let l=Jw(s.rssi,e);l<(n.get(s.room)??1/0)&&n.set(s.room,l)}let r=[...n].sort((s,l)=>s[1]-l[1]);if(r.length===0)return{room:null,distance:1/0,margin:0};let[i,o]=r[0];return o>18?{room:null,distance:o,margin:0}:{room:i,distance:o,margin:r.length>1?r[1][1]-o:18}}var Qw=t=>{let e=[...t].sort((r,i)=>r-i),n=e.length>>1;return e.length%2?e[n]:(e[n-1]+e[n])/2};function e0(t){let e={},n=new Set(t.flatMap(r=>Object.keys(r)));for(let r of n){let i=t.filter(o=>r in o).map(o=>o[r]);i.length*2>t.length&&(e[r]=Math.round(Qw(i)*10)/10)}return e}function qf(t,e,n=3){let r=e.filter(s=>Object.keys(s).length>0);if(r.length===0)return[];let i=Math.max(1,Math.min(n,Math.floor(r.length/3))),o=[];for(let s=0;s0&&o.push({room:t,rssi:a})}return o}var Yf=(t,e,n)=>[...t.filter(r=>r.room!==e),...n],Xf=t=>Math.max(0,Math.min(1,(t+95)/50));var t0=1500,kl=class extends Y{static properties={host:{attribute:!1},doc:{attribute:!1},_found:{state:!0},_pick:{state:!0},_name:{state:!0},_tag:{state:!0},_room:{state:!0},_scan:{state:!0},_samples:{state:!0},_error:{state:!0}};timer=0;recordStarted=0;constructor(){super(),this._found=null,this._pick="",this._name="",this._tag=null,this._room="",this._scan=null,this._samples=null,this._error=""}createRenderRoot(){return this}get tags(){return this.host.doc.settings.ble?.tags??[]}get rooms(){let e=this.host.doc.floors;return e.flatMap(n=>n.rooms.map(r=>({id:r.id,label:e.length>1?`${n.name} \xB7 ${r.name}`:r.name})))}connectedCallback(){super.connectedCallback(),this.loadDevices()}disconnectedCallback(){super.disconnectedCallback(),window.clearInterval(this.timer)}updated(e){e.has("_tag")&&this.restartPolling()}async loadDevices(){try{this._found=await this.host.hass.callWS({type:"nextfloor/ble/devices"})}catch(e){this._error=String(e?.message??e)}}restartPolling(){if(window.clearInterval(this.timer),this._scan=null,!this._tag)return;let e=()=>{this.pollOnce()};e(),this.timer=window.setInterval(e,t0)}async pollOnce(){let e=this.tags.find(n=>n.id===this._tag);if(!(!e||!this.host.hass))try{let n=await this.host.hass.callWS({type:"nextfloor/ble/scan",...e.entity?{entity:e.entity}:{address:e.address}});this._scan=n,this._error="",this._samples&&(this._samples=[...this._samples,Object.fromEntries(Object.entries(n.readings).map(([r,i])=>[r,i.rssi]))],Date.now()-this.recordStarted>=30*1e3&&this.finishRecording(e,n))}catch(n){this._error=String(n?.message??n)}}reading(){return Object.fromEntries(Object.entries(this._scan?.readings??{}).map(([e,n])=>[e,n.rssi]))}startRecording(){this._room&&(this.recordStarted=Date.now(),this._samples=[])}finishRecording(e,n){let r=this._samples??[];this._samples=null;let i=qf(this._room,r);if(i.length===0)return;let o=Object.fromEntries(Object.entries(n.readings).map(([s,l])=>[s,l.name]));this.update2(e.id,s=>{s.prints=Yf(s.prints,this._room,i),s.scanners={...s.scanners??{},...o}})}update2(e,n){this.host.change(r=>{let i=r.settings.ble?.tags.find(o=>o.id===e);i&&n(i)})}addTag(){let e=this._pick;if(!e)return;let n=e.startsWith("device_tracker."),r=this._found?.devices.find(s=>s.address===e),i=this._name.trim()||r?.name||this.host.hass?.states[e]?.attributes.friendly_name||e,o={id:I("ble"),name:String(i).slice(0,60),prints:[],...n?{entity:e}:{address:e}};this.host.change(s=>{s.settings.ble={tags:[...s.settings.ble?.tags??[],o]}}),this._tag=o.id,this._pick="",this._name=""}removeTag(e){this.host.change(n=>{let r=(n.settings.ble?.tags??[]).filter(i=>i.id!==e);n.settings.ble=r.length?{tags:r}:null}),this._tag===e&&(this._tag=null)}bars(e){let n=this.host.t,r=this._scan,i=Object.entries(r?.readings??{}).sort((o,s)=>s[1].rssi-o[1].rssi);return m`
+ `};customElements.get("nf-wall-view")||customElements.define("nf-wall-view",kl);function e0(t,e){let n=new Set([...Object.keys(t),...Object.keys(e)]);if(n.size===0)return 1/0;let r=0;for(let i of n)r+=Math.min(Math.abs((t[i]??-100)-(e[i]??-100)),40)**2;return Math.sqrt(r/n.size)}function qf(t,e){if(Object.keys(e).length===0)return{room:null,distance:1/0,margin:0};let n=new Map;for(let s of t){let l=e0(s.rssi,e);l<(n.get(s.room)??1/0)&&n.set(s.room,l)}let r=[...n].sort((s,l)=>s[1]-l[1]);if(r.length===0)return{room:null,distance:1/0,margin:0};let[i,o]=r[0];return o>18?{room:null,distance:o,margin:0}:{room:i,distance:o,margin:r.length>1?r[1][1]-o:18}}var t0=t=>{let e=[...t].sort((r,i)=>r-i),n=e.length>>1;return e.length%2?e[n]:(e[n-1]+e[n])/2};function n0(t){let e={},n=new Set(t.flatMap(r=>Object.keys(r)));for(let r of n){let i=t.filter(o=>r in o).map(o=>o[r]);i.length*2>t.length&&(e[r]=Math.round(t0(i)*10)/10)}return e}function Yf(t,e,n=3){let r=e.filter(s=>Object.keys(s).length>0);if(r.length===0)return[];let i=Math.max(1,Math.min(n,Math.floor(r.length/3))),o=[];for(let s=0;s
0&&o.push({room:t,rssi:a})}return o}var Xf=(t,e,n)=>[...t.filter(r=>r.room!==e),...n],Jf=t=>Math.max(0,Math.min(1,(t+95)/50));var r0=1500,$l=class extends Y{static properties={host:{attribute:!1},doc:{attribute:!1},_found:{state:!0},_pick:{state:!0},_name:{state:!0},_tag:{state:!0},_room:{state:!0},_scan:{state:!0},_samples:{state:!0},_error:{state:!0}};timer=0;recordStarted=0;constructor(){super(),this._found=null,this._pick="",this._name="",this._tag=null,this._room="",this._scan=null,this._samples=null,this._error=""}createRenderRoot(){return this}get tags(){return this.host.doc.settings.ble?.tags??[]}get rooms(){let e=this.host.doc.floors;return e.flatMap(n=>n.rooms.map(r=>({id:r.id,label:e.length>1?`${n.name} \xB7 ${r.name}`:r.name})))}connectedCallback(){super.connectedCallback(),this.loadDevices()}disconnectedCallback(){super.disconnectedCallback(),window.clearInterval(this.timer)}updated(e){e.has("_tag")&&this.restartPolling()}async loadDevices(){try{this._found=await this.host.hass.callWS({type:"nextfloor/ble/devices"})}catch(e){this._error=String(e?.message??e)}}restartPolling(){if(window.clearInterval(this.timer),this._scan=null,!this._tag)return;let e=()=>{this.pollOnce()};e(),this.timer=window.setInterval(e,r0)}async pollOnce(){let e=this.tags.find(n=>n.id===this._tag);if(!(!e||!this.host.hass))try{let n=await this.host.hass.callWS({type:"nextfloor/ble/scan",...e.entity?{entity:e.entity}:{address:e.address}});this._scan=n,this._error="",this._samples&&(this._samples=[...this._samples,Object.fromEntries(Object.entries(n.readings).map(([r,i])=>[r,i.rssi]))],Date.now()-this.recordStarted>=30*1e3&&this.finishRecording(e,n))}catch(n){this._error=String(n?.message??n)}}reading(){return Object.fromEntries(Object.entries(this._scan?.readings??{}).map(([e,n])=>[e,n.rssi]))}startRecording(){this._room&&(this.recordStarted=Date.now(),this._samples=[])}finishRecording(e,n){let r=this._samples??[];this._samples=null;let i=Yf(this._room,r);if(i.length===0)return;let o=Object.fromEntries(Object.entries(n.readings).map(([s,l])=>[s,l.name]));this.update2(e.id,s=>{s.prints=Xf(s.prints,this._room,i),s.scanners={...s.scanners??{},...o}})}update2(e,n){this.host.change(r=>{let i=r.settings.ble?.tags.find(o=>o.id===e);i&&n(i)})}addTag(){let e=this._pick;if(!e)return;let n=e.startsWith("device_tracker."),r=this._found?.devices.find(s=>s.address===e),i=this._name.trim()||r?.name||this.host.hass?.states[e]?.attributes.friendly_name||e,o={id:I("ble"),name:String(i).slice(0,60),prints:[],...n?{entity:e}:{address:e}};this.host.change(s=>{s.settings.ble={tags:[...s.settings.ble?.tags??[],o]}}),this._tag=o.id,this._pick="",this._name=""}removeTag(e){this.host.change(n=>{let r=(n.settings.ble?.tags??[]).filter(i=>i.id!==e);n.settings.ble=r.length?{tags:r}:null}),this._tag===e&&(this._tag=null)}bars(e){let n=this.host.t,r=this._scan,i=Object.entries(r?.readings??{}).sort((o,s)=>s[1].rssi-o[1].rssi);return m`
${i.length===0?m`
${r&&!r.available?n("ble_unavailable"):r?.address===null&&e.entity?n("ble_no_address"):n("ble_none_heard")}
`:i.map(([o,s])=>m`
${s.name}
-
+
${Math.round(s.rssi)}
`)}
${i.length===1?S(n("ble_one_scanner")):_}
-
`}learn(e){let n=this.host.t,r=this.rooms,i=Zf(e.prints,this.reading()),o=c=>r.find(u=>u.id===c)?.label??null,s=c=>e.prints.filter(u=>u.room===c).length,l=this._samples!==null,a=l?Math.max(0,30-Math.round((Date.now()-this.recordStarted)/1e3)):0;return m`${this.bars(e)}
+ `}learn(e){let n=this.host.t,r=this.rooms,i=qf(e.prints,this.reading()),o=c=>r.find(u=>u.id===c)?.label??null,s=c=>e.prints.filter(u=>u.room===c).length,l=this._samples!==null,a=l?Math.max(0,30-Math.round((Date.now()-this.recordStarted)/1e3)):0;return m`${this.bars(e)}
${n("ble_now")}: ${i.room?o(i.room):n("ble_unknown")}
`}};customElements.get("nf-ble-locate")||customElements.define("nf-ble-locate",$l);var i0=new URL(import.meta.url),o0=new URL("./nextfloor-3d.js?v=b12e75cc8bb7",i0).href,Qf;function kn(){return Qf??=import(o0),Qf}var em=["lights","seating","tables","storage","beds","kitchen","appliances","bath","media","office","tech","climate","energy","garden","plants","kids","fitness","pets","workshop","music","season","pictures","vehicles","building","decor"],s0={sofa:"seating",armchair:"seating",stool:"seating",chair:"seating",bench:"seating",corner_bench:"seating",bar_stool:"seating",office_chair:"office",coffee_table:"tables",table:"tables",table_round:"tables",desk:"office",worktop:"kitchen",tv_board:"media",tv_wall:"media",sideboard:"storage",shelf:"storage",tall_cabinet:"storage",wardrobe:"storage",dresser:"storage",nightstand:"beds",coat_rack:"storage",plant:"plants",rug:"decor",kitchen:"kitchen",kitchen_wall:"kitchen",kitchen_tall:"kitchen",island:"kitchen",sink:"kitchen",stove:"kitchen",dishwasher:"appliances",fridge:"appliances",washer:"appliances",dryer:"appliances",robot_vacuum:"appliances",bed:"beds",bunk_bed:"beds",bathtub:"bath",shower:"bath",wc:"bath",washbasin:"bath",radiator:"climate",stairs:"building",parking:"vehicles",ceiling_fan:"lights"},a0=[[/xmas|advent|window_star|candle_arch|reindeer|pumpkin|easter|snowman|gift_pile|lights_outdoor/,"season"],[/^frame_|^canvas$|^poster$|picture_ledge/,"pictures"],[/piano|drum_kit|guitar|synth|mic_stand|vinyl|easel|studio_monitor|mixing_desk/,"music"],[/lamp|pendant|light_pillar|light_bars|mood_spot|ceiling_panel|garden_spots|wall_light|light_cove|niche_led|shelf_led|monitor_light|workshop_light|painting_light|cabinet_light|moon_light|torch|lantern|ceiling_fan_light/,"lights"],[/cat_|dog_|pet_|litter|scratch|hamster|rabbit|bird_cage|small_animal|aquarium|terrarium/,"pets"],[/stairs|steps|landing|rail_|column|pilaster|beam|chimney|glass_wall|sliding_wall|half_wall|platform|niche_shelf|window_seat|divider_slats|gallery/,"building"],[/tree|shrub|conifer|hedge|brush|monstera|plant|herb_garden|herb_planter|flower|raised_bed|greenhouse|ficus|cactus|bonsai|living_wall|vertical_garden/,"plants"],[/kids|toy|teepee|(^|_)play_|rocking_horse|ball_pit|house_bed|cot\b|^cot|crib|changing_table|baby|loft_bed|star_projector|moon_light/,"kids"],[/treadmill|fitness|power_rack|rowing|rower|spin_bike|dumbbell|punching|yoga|elliptical|gym|exercise|wall_bars|bike_trainer|kettlebell|weight_bench|massage_chair/,"fitness"],[/heat_pump|boiler|buffer_tank|manifold|ventilation|radiator|towel_heater|thermostat|air_purifier|humidifier|dehumidifier|tower_fan|ceiling_fan|hot_water|water_softener|water_pump|fireplace|wood_stove|patio_heater|sauna|oil_|expansion_vessel|water_tank|infrared|cold_bath/,"climate"],[/wallbox|inverter|battery|solar|meter|fuse_box|grid/,"energy"],[/workbench|tool_|compressor|drill|tyre|paint_cabinet|heavy_shelf|shelf_rack|garage_opener|workshop|bike_stand|bike_holder|bike_rack|lawn_mower|mower|welder|ev_bike_charger|tool_chest|parts_cabinet/,"workshop"],[/speaker|subwoofer|soundbar|receiver|turntable|record|game_console|multiroom|hifi|cinema|acoustic|bass_trap|popcorn|projector|projection|screen|display_|smart_display|media|tv|arcade|star_ceiling|av_/,"media"],[/desk|office|filing|whiteboard|monitor|bookcase|phone_booth|sim_cockpit|chair_gaming|gaming/,"office"],[/server|nas|router|wifi|access_point|network|printer|filament|tower_pc|smoke_detector|siren|baby_monitor|sunrise_clock|light_switch|socket|co_detector|presence_|water_leak|air_quality|doorbell/,"tech"],[/grill|lounge|lounger|parasol|pergola|hot_tub|fire_bowl|torch|lantern|play_tower|garden|trampoline|sprinkler|valve|rain_barrel|outdoor|hammock|(^|_)pool|swing|bin_box|^bin_|mailbox|rotary_line|kamado|pizza_oven|fire_pit|sandbox|wood_pile|bird_house|cistern|pond|water_feature|beach_chair/,"garden"],[/vanity_\d|vanity_double|double_vanity|basin|bath|shower|toilet|bidet|towel|mirror_cabinet|mirror_round|mirror_80|mirror_led|whirlpool|washer_under|laundry|urinal|wt_\d|handtuch|seife|wc/,"bath"],[/fridge|freezer|dishwasher|washer|dryer|microwave|coffee_machine|kettle|toaster|mixer|oven|steam|vacuum|ironing|drying_rack|trash|water_cooler|drip_tray|espresso|air_fryer|water_bar|thermo_cooker/,"appliances"],[/base_|drawer_|sink|hob|cooker|hood|pantry|kitchen|island|breakfast_bar|wall_\d|wall_glass|wall_corner|row_|spice|cabinet_light|trolley|bar_cart|utility_sink/,"kitchen"],[/bed|boxspring|futon|nightstand|canopy|mattress/,"beds"],[/sofa|chair|armchair|stool|bench|pouf|bean_bag|recliner|wingback|chaise|seat|ektorp|poang|cosy_corner|swing_bench|hanging_chair|nook|floor_cushion|tatami/,"seating"],[/table|dining|coffee_|side_round|lack_|^console$|bekant|alex/,"tables"],[/wardrobe|closet|clothes_rail|chest|dresser|shelf|cabinet|sideboard|lowboard|highboard|kallax|billy|ivar|pax|besta|cube_|coat_stand|shoe_bench|divider|display_cabinet|wall_unit|malm_chest|locker/,"storage"]];function l0(t){if(t.vehicle)return"vehicles";if(t.climate)return"climate";if(!t.type.startsWith("pack:"))return t.lamp?"lights":s0[t.type]??"decor";let e=a0.find(([n])=>n.test(t.id));return e?e[1]:t.lamp?"lights":"decor"}var tm=[[/k(u|ü)che|kitchen|kochen/,["kitchen","appliances","tables","seating","storage","plants","decor"]],[/wohn|living|lounge|salon/,["seating","tables","storage","media","plants","decor","climate","tech"]],[/\bess|dining/,["tables","seating","storage","plants","decor","media"]],[/schlaf|bed|gast|guest/,["beds","storage","seating","tables","decor","plants","climate","media"]],[/kind|kids|child|baby|spiel|play|nursery/,["kids","beds","storage","seating","tables","decor"]],[/bad|bath|wc|toilet|dusch|shower|sauna/,["bath","appliances","storage","climate","plants"]],[/b(u|ü)ro|office|arbeit|study|work/,["office","tech","storage","seating","tables","plants"]],[/kino|cinema|media|game|gaming|hifi/,["media","seating","tables","storage","office"]],[/fitness|gym|sport|training/,["fitness","media","storage","climate"]],[/garage|carport|stellplatz|parking/,["vehicles","workshop","energy","storage","garden"]],[/werkstatt|workshop|hobby|keller|cellar|basement|lager|storage/,["workshop","storage","appliances","energy","climate","fitness","tech"]],[/hauswirtschaft|hwr|utility|laundry|wasch|technik|heiz|boiler/,["appliances","climate","energy","storage","tech","bath"]],[/flur|diele|hall|entr|eingang|corridor|treppe|stair/,["storage","seating","decor","plants","building"]],[/garten|garden|terrass|terrace|balkon|balcony|patio|hof|yard|pool/,["garden","plants","seating","tables","pets","kids"]]];function Sl(t){let e=(t??"").toLowerCase(),n=tm.find(([r])=>r.test(e));return n?new Set(["lights",...n[1]]):null}function Ml(t){let e=(t??"").toLowerCase();return tm.find(([n])=>n.test(e))?.[1][0]??null}var nm=t=>t==="garden"||t==="plants"||t==="vehicles",rm=/_(\d+(?:x\d+)?)$/;function im(t){let e=new Map;for(let n of t){let r=l0(n),i=n.type.startsWith("pack:")&&!n.vehicle?n.id.replace(rm,""):n.id,o=`${n.source}:${i}`,s=e.get(o);s&&s.category===r?s.entries.push(n):e.set(s?`${o}:${n.id}`:o,{key:s?`${o}:${n.id}`:o,category:r,entries:[n]})}for(let n of e.values())n.entries.sort((r,i)=>r.size[0]-i.size[0]||r.size[1]-i.size[1]);return[...e.values()]}function om(t,e){let n=i=>Math.round(i*100);return e.some(i=>i!==t&&n(i.size[0])===n(t.size[0]))?rm.exec(t.id)?.[1]??`${n(t.size[0])}\xD7${n(t.size[2])}`:`${n(t.size[0])}`}function sm(t,e,n=12){return[e,...t.filter(r=>r!==e)].slice(0,n)}var am=t=>t.toLowerCase().normalize("NFD").replace(new RegExp("\\p{M}","gu"),""),lm=t=>am(t).split(/\s+/).filter(Boolean),cm=(t,e)=>{let n=am(e);return t.every(r=>n.includes(r))};function um(){let e=navigator.deviceMemory??8,n=navigator.hardwareConcurrency||8;return e<=3||n<=4||/Silk|KF[A-Z]{2,4}\b/.test(navigator.userAgent)}var dm=112,c0="nextfloor-thumbs";function u0(t){let e=2166136261;for(let n=0;n>>0).toString(36)}function Rl(t){let e=G(t);return`${t}|${e?u0(JSON.stringify(e)):"b"}|${dm}`}function d0(){return new Promise(t=>{try{let e=indexedDB.open(c0,1);e.onupgradeneeded=()=>e.result.createObjectStore("thumbs"),e.onsuccess=()=>t(e.result),e.onerror=()=>t(null)}catch{t(null)}})}var El=class{enabled=!um();memory=new Map;waiting=new Map;queue=[];db=null;running=!1;packs=[];cached(e){return this.memory.get(Rl(e))}get(e){let n=Rl(e),r=this.memory.get(n);return r?Promise.resolve(r):new Promise(i=>{let o=this.waiting.get(n);if(o)return void o.push(i);this.waiting.set(n,[i]),this.lookUp(e,n)})}settle(e,n){n&&this.memory.set(e,n);for(let r of this.waiting.get(e)??[])r(n);this.waiting.delete(e)}async lookUp(e,n){this.db??=d0();let r=await this.db,i=r?await new Promise(o=>{try{let s=r.transaction("thumbs").objectStore("thumbs").get(n);s.onsuccess=()=>o(typeof s.result=="string"?s.result:null),s.onerror=()=>o(null)}catch{o(null)}}):null;if(i)return this.settle(n,i);this.queue.push(e),this.pump()}pump(){if(this.running)return;let e=this.queue.shift();if(!e)return;this.running=!0;let n=window.requestIdleCallback;(i=>n?n(i,{timeout:300}):setTimeout(i,16))(async()=>{let i=Rl(e),o=null;try{let[s,l,a]=dt(e);o=(await kn()).furniturePreview({type:e,w:s,d:l,h:a,variant:null,lamp:Qi[e]??null},dm,[...this.packs]),this.keep(i,o)}catch{o=null}this.settle(i,o),this.running=!1,this.pump()})}async keep(e,n){let r=await this.db;try{r?.transaction("thumbs","readwrite").objectStore("thumbs").put(n,e)}catch{}}},qt=new El,$i=null,h0=t=>{for(let e of t)e.isIntersecting&&e.target.visible()},Al=class extends Y{static properties={type:{},_url:{state:!0}};static styles=ee`
:host {
display: block;
aspect-ratio: 4 / 3;
@@ -1234,7 +1234,7 @@ ${o}`}else i=ip(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
height: 100%;
object-fit: contain;
}
- `;constructor(){super(),this.type="",this._url=null}connectedCallback(){super.connectedCallback(),Zt.enabled&&(this._url=Zt.cached(this.type)??null,!this._url&&(xi??=new IntersectionObserver(u0,{rootMargin:"120px"}),xi.observe(this)))}disconnectedCallback(){super.disconnectedCallback(),xi?.unobserve(this)}updated(e){e.has("type")&&e.get("type")!==void 0&&(this._url=Zt.cached(this.type)??null,!this._url&&Zt.enabled&&xi?.observe(this))}visible(){xi?.unobserve(this);let e=this.type;Zt.get(e).then(n=>{this.type===e&&(this._url=n)})}render(){return this._url?m` `:_}};customElements.get("nf-thumb")||customElements.define("nf-thumb",Rl);var dm="nextfloor.library2",d0={language:"en"},Xo=class{onChange;text="";saved;shown=null;picked=new Map;constructor(e){this.onChange=e,this.saved={folded:{},favourites:[],recent:[],flags:["room"]};try{let n=localStorage.getItem(dm);n&&(this.saved={...this.saved,...JSON.parse(n)})}catch{}}store(e){this.saved={...this.saved,...e},this.onChange();try{localStorage.setItem(dm,JSON.stringify(this.saved))}catch{}}get query(){return this.text}set query(e){this.text=e,this.onChange()}isOpen(e,n){return this.saved.folded[e]??n}toggle(e,n){this.store({folded:{...this.saved.folded,[e]:!this.isOpen(e,n)}})}has(e){return this.saved.flags.includes(e)}flip(e){this.store({flags:this.has(e)?this.saved.flags.filter(n=>n!==e):[...this.saved.flags,e]})}get favourites(){return this.saved.favourites}isFavourite(e){return this.saved.favourites.includes(e)}toggleFavourite(e){this.store({favourites:this.isFavourite(e)?this.saved.favourites.filter(n=>n!==e):[e,...this.saved.favourites]})}get recent(){return this.saved.recent}used(e){this.store({recent:om(this.saved.recent,e)})}pickedOf(e){let n=this.picked.get(e.key);return e.entries.find(r=>r.type===n)??e.entries[0]}pick(e,n){this.picked.set(e.key,n),this.onChange()}get preview(){return this.shown}hidePreview(){this.shown=null,this.onChange()}async showPreview(e,n,r){let i=n.getBoundingClientRect(),o={left:Math.max(8,i.left-196),top:Math.max(8,Math.min(window.innerHeight-200,i.top+i.height/2-95))};this.shown={type:e,url:null,...o},this.onChange();try{let[s,l,a]=dt(e),c=(await wn()).furniturePreview({type:e,w:s,d:l,h:a,variant:null,lamp:Ji[e]??null},180,[...r]);this.shown?.type===e&&(this.shown={type:e,url:c,...o})}catch{this.shown=null}this.onChange()}};function h0(t,e){let n=t.hass?.language??"en",i=[...[...new Set(Object.values($u).flat())].map(l=>({type:l,source:"builtin",id:l,size:nt[l],lamp:ue(l),electric:Tt(l)})),...e.flatMap(l=>l.items.map(a=>({type:he(l.id,a.id),source:l.id,id:a.id,size:a.size,lamp:!!a.light,electric:!!a.electric,vehicle:!!a.vehicle,climate:!!a.climate})))],o=new Map(e.map(l=>[l.id,Be(l,n)])),s=new Map(e.flatMap(l=>l.items.map(a=>[he(l.id,a.id),a])));return rm(i).map(l=>{let a=l.entries[0],c=s.get(a.type),u=c?Je(c,a.type,n):t.t(`furn_${a.type}`),d=l.entries.length>1&&u.replace(/\s*\(?\d+([.,]\d+)?\s*(cm|x\s*\d+|×\s*\d+)?\)?\s*$/i,"").trim()||u,p=l.entries.map(h=>{let f=s.get(h.type);return f?[...Object.values(f.name),Je(f,h.type,n)].join(" "):Se(d0,`furn_${h.type}`)}).join(" ");return{card:l,label:d,search:`${p} ${t.t(`lib_cat_${l.category}`)}`,from:o.get(a.source)??"NextFloor"}})}var p0=(t,e)=>lm(e,`${t.label} ${t.search} ${t.from} ${t.card.entries.map(n=>n.id.replace(/_/g," ")).join(" ")}`),f0=t=>t.lamp?"light":t.electric?"switch":null;function m0(t,e,n,r){let i=t.t,o=e.pickedOf(n.card),[s,l]=o.size,a=f0(o),c=p=>{e.showPreview(o.type,p.currentTarget,r.packs)},u=()=>{e.used(o.type),r.add(o.type)},d=e.isFavourite(o.type);return m`
+ `;constructor(){super(),this.type="",this._url=null}connectedCallback(){super.connectedCallback(),qt.enabled&&(this._url=qt.cached(this.type)??null,!this._url&&($i??=new IntersectionObserver(h0,{rootMargin:"120px"}),$i.observe(this)))}disconnectedCallback(){super.disconnectedCallback(),$i?.unobserve(this)}updated(e){e.has("type")&&e.get("type")!==void 0&&(this._url=qt.cached(this.type)??null,!this._url&&qt.enabled&&$i?.observe(this))}visible(){$i?.unobserve(this);let e=this.type;qt.get(e).then(n=>{this.type===e&&(this._url=n)})}render(){return this._url?m`
`:_}};customElements.get("nf-thumb")||customElements.define("nf-thumb",Al);var hm="nextfloor.library2",p0={language:"en"},Jo=class{onChange;text="";saved;shown=null;picked=new Map;constructor(e){this.onChange=e,this.saved={folded:{},favourites:[],recent:[],flags:["room"]};try{let n=localStorage.getItem(hm);n&&(this.saved={...this.saved,...JSON.parse(n)})}catch{}}store(e){this.saved={...this.saved,...e},this.onChange();try{localStorage.setItem(hm,JSON.stringify(this.saved))}catch{}}get query(){return this.text}set query(e){this.text=e,this.onChange()}isOpen(e,n){return this.saved.folded[e]??n}toggle(e,n){this.store({folded:{...this.saved.folded,[e]:!this.isOpen(e,n)}})}has(e){return this.saved.flags.includes(e)}flip(e){this.store({flags:this.has(e)?this.saved.flags.filter(n=>n!==e):[...this.saved.flags,e]})}get favourites(){return this.saved.favourites}isFavourite(e){return this.saved.favourites.includes(e)}toggleFavourite(e){this.store({favourites:this.isFavourite(e)?this.saved.favourites.filter(n=>n!==e):[e,...this.saved.favourites]})}get recent(){return this.saved.recent}used(e){this.store({recent:sm(this.saved.recent,e)})}pickedOf(e){let n=this.picked.get(e.key);return e.entries.find(r=>r.type===n)??e.entries[0]}pick(e,n){this.picked.set(e.key,n),this.onChange()}get preview(){return this.shown}hidePreview(){this.shown=null,this.onChange()}async showPreview(e,n,r){let i=n.getBoundingClientRect(),o={left:Math.max(8,i.left-196),top:Math.max(8,Math.min(window.innerHeight-200,i.top+i.height/2-95))};this.shown={type:e,url:null,...o},this.onChange();try{let[s,l,a]=dt(e),c=(await kn()).furniturePreview({type:e,w:s,d:l,h:a,variant:null,lamp:Qi[e]??null},180,[...r]);this.shown?.type===e&&(this.shown={type:e,url:c,...o})}catch{this.shown=null}this.onChange()}};function f0(t,e){let n=t.hass?.language??"en",i=[...[...new Set(Object.values(Mu).flat())].map(l=>({type:l,source:"builtin",id:l,size:nt[l],lamp:ue(l),electric:Tt(l)})),...e.flatMap(l=>l.items.map(a=>({type:he(l.id,a.id),source:l.id,id:a.id,size:a.size,lamp:!!a.light,electric:!!a.electric,vehicle:!!a.vehicle,climate:!!a.climate})))],o=new Map(e.map(l=>[l.id,Be(l,n)])),s=new Map(e.flatMap(l=>l.items.map(a=>[he(l.id,a.id),a])));return im(i).map(l=>{let a=l.entries[0],c=s.get(a.type),u=c?Je(c,a.type,n):t.t(`furn_${a.type}`),d=l.entries.length>1&&u.replace(/\s*\(?\d+([.,]\d+)?\s*(cm|x\s*\d+|×\s*\d+)?\)?\s*$/i,"").trim()||u,p=l.entries.map(h=>{let f=s.get(h.type);return f?[...Object.values(f.name),Je(f,h.type,n)].join(" "):we(p0,`furn_${h.type}`)}).join(" ");return{card:l,label:d,search:`${p} ${t.t(`lib_cat_${l.category}`)}`,from:o.get(a.source)??"NextFloor"}})}var m0=(t,e)=>cm(e,`${t.label} ${t.search} ${t.from} ${t.card.entries.map(n=>n.id.replace(/_/g," ")).join(" ")}`),g0=t=>t.lamp?"light":t.electric?"switch":null;function _0(t,e,n,r){let i=t.t,o=e.pickedOf(n.card),[s,l]=o.size,a=g0(o),c=p=>{e.showPreview(o.type,p.currentTarget,r.packs)},u=()=>{e.used(o.type),r.add(o.type)},d=e.isFavourite(o.type);return m`
e.hidePreview()}
@blur=${()=>e.hidePreview()}
>
- ${Zt.enabled?m` `:_}
+ ${qt.enabled?m` `:_}
${n.label}${a?m` `:_} ${n.label}${a?m` `:_}
${Math.round(s*100)} × ${Math.round(l*100)} cm · ${n.from}
e.toggleFavourite(o.type)}>${d?"\u2605":"\u2606"}
${n.card.entries.length>1?m`
- ${n.card.entries.map(p=>m`e.pick(n.card,p.type)}>${im(p,n.card.entries)} `)}
+ ${n.card.entries.map(p=>m`e.pick(n.card,p.type)}>${om(p,n.card.entries)} `)}
`:_}
-
`}function pm(t,e,n,r){return m`
${n.map(i=>m0(t,e,i,r))}
`}function El(t,e,n,r,i,o,s){if(i.length===0)return _;let l=e.isOpen(n,s);return m`
e.toggle(n,s)}>
+ `}function fm(t,e,n,r){return m`${n.map(i=>_0(t,e,i,r))}
`}function Fl(t,e,n,r,i,o,s){if(i.length===0)return _;let l=e.isOpen(n,s);return m`e.toggle(n,s)}>
${l?"\u25BE":"\u25B8"} ${r} ${i.length}
- ${l?pm(t,e,i,o):_}`}function hm(t,e){return t.flatMap(n=>{let r=e.find(i=>i.card.entries.some(o=>o.type===n));return r?[{...r,card:{...r.card,key:`one:${n}`,entries:r.card.entries.filter(i=>i.type===n)}}]:[]})}function g0(t){let e=$l(t),n=xl(t),r=i=>i===e?0:n?.has(i)?1:2;return[...Qf].sort((i,o)=>r(i)-r(o))}function fm(t,e,n,r){let i=t.t;Zt.packs=r.packs;let o=h0(t,r.packs),s=am(e.query),l=xl(n),a=!!l&&e.has("room")&&s.length===0,c=o.filter(p=>{let h=p.card.entries[0];return a&&!l.has(p.card.category)||e.has("linkable")&&!h.lamp&&!h.electric||e.has("lit")&&!h.lamp||e.has("outdoor")&&!tm(p.card.category)?!1:s.length===0||p0(p,s)}),u=(p,h)=>m`e.flip(p)}>${h} `,d=s.length>0;return m`
+ ${l?fm(t,e,i,o):_}`}function pm(t,e){return t.flatMap(n=>{let r=e.find(i=>i.card.entries.some(o=>o.type===n));return r?[{...r,card:{...r.card,key:`one:${n}`,entries:r.card.entries.filter(i=>i.type===n)}}]:[]})}function b0(t){let e=Ml(t),n=Sl(t),r=i=>i===e?0:n?.has(i)?1:2;return[...em].sort((i,o)=>r(i)-r(o))}function mm(t,e,n,r){let i=t.t;qt.packs=r.packs;let o=f0(t,r.packs),s=lm(e.query),l=Sl(n),a=!!l&&e.has("room")&&s.length===0,c=o.filter(p=>{let h=p.card.entries[0];return a&&!l.has(p.card.category)||e.has("linkable")&&!h.lamp&&!h.electric||e.has("lit")&&!h.lamp||e.has("outdoor")&&!nm(p.card.category)?!1:s.length===0||m0(p,s)}),u=(p,h)=>m`e.flip(p)}>${h} `,d=s.length>0;return m`
${i("furniture_add")}
${n?i("furniture_into",{room:n}):i("furniture_pick_room")}
r.studio()}>🛠️ ${i("studio_new")}
@@ -1274,61 +1274,61 @@ ${o}`}else i=ip(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
${u("outdoor",`\u{1F333} ${i("lib_outdoor")}`)}
${d&&c.length===0?m`
${i("furniture_search_none")}
`:_}
- ${d?pm(t,e,c,r):m`${El(t,e,"favourites",`\u2605 ${i("lib_favourites")}`,hm(e.favourites,o),r,!0)}
- ${El(t,e,"recent",`\u{1F558} ${i("lib_recent")}`,hm(e.recent.slice(0,6),o),r,!1)}
- ${g0(n).map(p=>El(t,e,p,i(`lib_cat_${p}`),c.filter(h=>h.card.category===p),r,p===($l(n)??"lights")))}
+ ${d?fm(t,e,c,r):m`${Fl(t,e,"favourites",`\u2605 ${i("lib_favourites")}`,pm(e.favourites,o),r,!0)}
+ ${Fl(t,e,"recent",`\u{1F558} ${i("lib_recent")}`,pm(e.recent.slice(0,6),o),r,!1)}
+ ${b0(n).map(p=>Fl(t,e,p,i(`lib_cat_${p}`),c.filter(h=>h.card.category===p),r,p===(Ml(n)??"lights")))}
${a?m`
e.flip("room")}>${i("lib_all_rooms")} `:_}`}
- `}function mm(t,e){return e?m`
+ `}function gm(t,e){return e?m`
${e.url?m`
`:m`
`}
${Ae(t.hass,e.type)}
-
`:_}function Al(t,e,n,r=24){let i=Math.hypot(e[0]-t[0],e[1]-t[1]);if(i<1e-6||Math.abs(n)<1e-4)return[];let o=Math.max(-i*2,Math.min(i*2,n)),s=[(e[0]-t[0])/i,(e[1]-t[1])/i],l=[s[1],-s[0]],a=i*i/4/(2*Math.abs(o))+Math.abs(o)/2,c=2*Math.atan(2*Math.abs(o)/i),u=Math.max(2,Math.min(r,Math.ceil(2*c/Math.PI*180/11.25))),d=[l[0]*Math.sign(o),l[1]*Math.sign(o)],p=[(t[0]+e[0])/2,(t[1]+e[1])/2],h=[p[0]-d[0]*(a-Math.abs(o)),p[1]-d[1]*(a-Math.abs(o))],f=[];for(let g=1;g
t.reduce((e,n,r)=>r?e+Math.hypot(n[0]-t[r-1][0],n[1]-t[r-1][1]):e,0);function Tl(t,e){let n=Math.max(0,e);for(let r=0;r+1Math.round(t*1e3)/1e3,zl=t=>t.map(([e,n])=>[Pe(e),Pe(n)]);function gm(t,e){return{id:I("room"),name:e,area_id:null,points:zl(t),floor_material:"wood"}}function _m(t){return{...structuredClone(t),id:I("room"),points:zl(t.points.map(([e,n])=>[e+.5,n+.5]))}}function bm(t,e){let n=t.rooms.find(r=>r.id===e);t.rooms=t.rooms.filter(r=>r.id!==e),t.openings=t.openings.filter(r=>r.room_id!==e||r.wall),n&&(t.placements=t.placements.filter(r=>!C([r.x,r.z],n.points)))}function ym(t,e,n){let r=t.rooms.find(s=>s.id===e);if(!r||r.points.length<=3)return!1;let i=(n-1+r.points.length)%r.points.length;r.points.splice(n,1),r.wall_heights?.splice(n,1),r.wall_slopes?.splice(n,1),r.wall_thickness?.splice(n,1);let o=s=>s.room_id===e&&!s.wall;return t.openings=t.openings.filter(s=>!(o(s)&&(s.edge===n||s.edge===i))).map(s=>o(s)&&s.edge>n?{...s,edge:s.edge-1}:s),!0}function vm(t,e,n){if(!Number.isFinite(n))return null;let r=de(t.points),{x0:i,z0:o,x1:s,z1:l}=r;return e==="x"?[i,s]=[n,n+(s-i)]:e==="z"?[o,l]=[n,n+(l-o)]:n>.05&&(e==="w"?s=i+n:l=o+n),zl([[i,o],[s,o],[s,l],[i,l]])}function wm(t,e,n,r){return!Number.isFinite(r)||e<0||e>=t.points.length?null:t.points.map((i,o)=>o===e?n===0?[Pe(r),i[1]]:[i[0],Pe(r)]:[i[0],i[1]])}var _0=/^(Raum|Room) \d+$/;function Pl(t,e,n,r=!0){let i=e?n[e]:void 0,o=!t.name||_0.test(t.name)||Object.values(n).some(s=>s.name===t.name);return{area_id:e||null,...r&&i&&o?{name:i.name}:{}}}function Dl(t,e){let n=/^symcon-category-(\d+)$/.exec(e)?.[1];return(n?t?.symconObjects?.find(r=>r.object_id===Number(n))?.name:void 0)??t?.areas?.[e]?.name.split(" / ").at(-1)?.trim()??""}function km(t,e){let n=e.filter(a=>Q(a.entity_id)==="light"&&(a.mount??"ceiling")==="ceiling"&&C([a.x,a.z],t.points));if(n.length<2)return[];let r=de(t.points),[i,o]=[r.x1-r.x0,r.z1-r.z0],s=Math.max(1,Math.round(Math.sqrt(n.length*i/Math.max(.1,o)))),l=Math.ceil(n.length/s);return n.map((a,c)=>{let u=Math.floor(c/s),d=u===l-1?n.length-s*(l-1):s,p=c-u*s;return{entityId:a.entity_id,x:Pe(r.x0+i/d*(p+.5)),z:Pe(r.z0+o/l*(u+.5))}})}function Il(t,e,n,r){let i=t.rooms.find(u=>u.id===e);if(!i)return;let o=i.points[n],s=i.points[(n+1)%i.points.length];i.points.splice(n+1,0,r);let[l,a]=[i.wall_heights?.[n],i.wall_slopes?.[n]];if(typeof l=="number"&&typeof a=="number"&&i.wall_slopes){let u=Math.hypot(s[0]-o[0],s[1]-o[1]),d=Pe(l+(a-l)*Math.min(1,Math.hypot(r[0]-o[0],r[1]-o[1])/(u||1)));i.wall_slopes.splice(n,1,d,a),i.wall_heights.splice(n+1,0,d)}else i.wall_heights?.splice(n+1,0,i.wall_heights[n]??null),i.wall_slopes?.splice(n+1,0,null);i.wall_thickness?.splice(n+1,0,i.wall_thickness[n]??null);let c=Math.hypot(r[0]-o[0],r[1]-o[1]);for(let u of t.openings)u.room_id!==e||u.wall||(u.edge>n?u.edge+=1:u.edge===n&&u.offset>c&&(u.edge=n+1,u.offset=Pe(u.offset-c)))}var b0=22.5;function xm(t,e,n){let r=Math.min(Math.abs(e),t*2),i=t*(1+8/3*(r/Math.max(1e-6,t))**2),o=4*Math.atan(2*r/Math.max(1e-6,t))*180/Math.PI,s=Math.max(2,Math.ceil(o/b0));if(n<=0)return 24;let l=Math.floor(i/(n+.1));return l>=s?l:0}function y0(t,e,n,r){let i=Fl(n);t.forEach((o,s)=>{let{piece:l,offset:a}=Tl(n,e[s]*i),c=Math.hypot(n[l+1][0]-n[l][0],n[l+1][1]-n[l][1]);o.edge=r+l,o.offset=Pe(c>o.width?Math.min(c-o.width/2,Math.max(o.width/2,a)):c/2)})}function $m(t,e,n,r){let i=t.rooms.find(v=>v.id===e);if(!i||n<0||n>=i.points.length||Math.abs(r)<.01)return!1;let o=i.points[n],s=i.points[(n+1)%i.points.length],l=Math.hypot(s[0]-o[0],s[1]-o[1]);if(l<.2)return!1;let[a,c]=[(s[0]-o[0])/l,(s[1]-o[1])/l],u=[(o[0]+s[0])/2+c*.02,(o[1]+s[1])/2-a*.02],p=C(u,i.points)?-r:r,h=(v,w)=>t.openings.filter(x=>x.room_id===v.id&&!x.wall&&x.edge===w),f=t.rooms.flatMap(v=>v.points.map((w,x)=>{let k=v.points[(x+1)%v.points.length],M=(A,T)=>Math.abs(A[0]-T[0])<.001&&Math.abs(A[1]-T[1])<.001;return M(w,o)&&M(k,s)?[v,x,!1]:M(w,s)&&M(k,o)?[v,x,!0]:null}).filter(w=>!!w)),g=Math.max(0,...f.flatMap(([v,w])=>h(v,w).map(x=>x.width))),b=xm(l,r,g);if(!b)return!1;let y=Al(o,s,p,b).map(([v,w])=>[Pe(v),Pe(w)]);if(!y.length)return!1;for(let[v,w,x]of f){let k=x?[...y].reverse():y,M=h(v,w),A=v.points[w],T=M.map(F=>Math.min(1,Math.max(0,F.offset/l)));for(let F of M)F.edge=-1;k.forEach((F,H)=>Il(t,v.id,w+H,F)),v.wall_splits?.splice(w+1,0,...k.map(()=>null)),v.wall_splits?.[w]&&(v.wall_splits[w]=null),y0(M,T,[A,...k,v.points[(w+k.length+1)%v.points.length]],w)}return!0}function Sm(t,e,n){let r=t.walls??[],i=r.findIndex(f=>f.id===e);if(i<0||Math.abs(n)<.01)return[];let o=r[i],s=Math.hypot(o.b[0]-o.a[0],o.b[1]-o.a[1]),l=t.openings.filter(f=>f.wall===e),a=Math.max(0,...l.map(f=>f.width)),c=xm(s,n,a);if(!c)return[];let u=Al(o.a,o.b,n,c).map(([f,g])=>[Pe(f),Pe(g)]);if(!u.length)return[];let d=[o.a,...u,o.b],p=d.slice(1).map((f,g)=>({...o,id:g===0?o.id:I("wall"),a:d[g],b:f}));r.splice(i,1,...p),t.walls=r;let h=Fl(d);for(let f of l){let{piece:g,offset:b}=Tl(d,f.offset/s*h),y=Math.hypot(d[g+1][0]-d[g][0],d[g+1][1]-d[g][1]);f.wall=p[g].id,f.offset=Pe(y>f.width?Math.min(y-f.width/2,Math.max(f.width/2,b)):y/2)}return p.map(f=>f.id)}var nr=t=>Math.round(t*1e3)/1e3;function Jo(t,e,n){return[Math.round((e[0]-t[0])/n)*n,Math.round((e[1]-t[1])/n)*n]}var kn=(t,e)=>e?.01:t,rr=(t,e,n=5)=>Math.hypot(t[0]-e[0],t[1]-e[1])>=n;function Mm(t,e,n){return n?Math.abs(e[0]-t[0])>Math.abs(e[1]-t[1])?[e[0],t[1]]:[t[0],e[1]]:e}var et=(t,e)=>[nr(t[0]+e[0]),nr(t[1]+e[1])];function Ol(t,e,n,r){return[nr(Math.round((t[0]+n[0]-e[0])/r)*r),nr(Math.round((t[1]+n[1]-e[1])/r)*r)]}function Hl(t,e,n){let r=Math.atan2(-(e[0]-t[0]),e[1]-t[1])*180/Math.PI;return(Math.round(r/n)*n%360+360)%360}function Rm(t,e,n){let r=Math.atan2(e[0]-t[0],-(e[1]-t[1]))*180/Math.PI;return Math.round(r/n)*n}function Em(t,e,n){let r=Tn([...t]),i=t[e],o=[nr(n[0]),nr(n[1])];return t.map((s,l)=>l===e?o:r?[Math.abs(s[0]-i[0])<1e-6?o[0]:s[0],Math.abs(s[1]-i[1])<1e-6?o[1]:s[1]]:[s[0],s[1]])}var Qo=t=>Math.round(t*1e3)/1e3,Am=(t,e)=>Math.hypot(t[0]-e[0],t[1]-e[1]);function v0(t,e,n){let r=null,i=n;for(let o of t){let s=Am(o,e);s{let a=o.points[(l+1)%o.points.length],[c,u]=[a[0]-s[0],a[1]-s[1]],d=c*c+u*u;if(d<1e-9)return;let p=((e[0]-s[0])*c+(e[1]-s[1])*u)/d;if(p<=0||p>=1)return;let h=[s[0]+p*c,s[1]+p*u],f=Am(h,e),g=(b,y,v)=>Math.min(Math.max(b,Math.min(y,v)),Math.max(y,v));Math.abs(u)<1e-9&&(h[0]=g(Math.round(h[0]/n.grid)*n.grid,s[0],a[0])),Math.abs(c)<1e-9&&(h[1]=g(Math.round(h[1]/n.grid)*n.grid,s[1],a[1])),fo.points.filter((s,l)=>!(e.skip&&o.id===e.skip.roomId&&(e.skip.index===void 0||e.skip.index===l)))),r=v0(n,t,e.reach);if(r)return{point:[r[0],r[1]],guides:{point:r}};let i=w0(e.rooms,t,e);return i?{point:[Qo(i[0]),Qo(i[1])],guides:{point:i}}:k0(n,t,e)}var es=(t,e)=>pe(t.host.hass,e);function x0(t,e){let[n,r]=[t.toScreen(e.start),t.toScreen(e.end)];if(e.kind==="freewall"){let s=Math.hypot(e.end[0]-e.start[0],e.end[1]-e.start[1]);return R`
+ `:_}function Tl(t,e,n,r=24){let i=Math.hypot(e[0]-t[0],e[1]-t[1]);if(i<1e-6||Math.abs(n)<1e-4)return[];let o=Math.max(-i*2,Math.min(i*2,n)),s=[(e[0]-t[0])/i,(e[1]-t[1])/i],l=[s[1],-s[0]],a=i*i/4/(2*Math.abs(o))+Math.abs(o)/2,c=2*Math.atan(2*Math.abs(o)/i),u=Math.max(2,Math.min(r,Math.ceil(2*c/Math.PI*180/11.25))),d=[l[0]*Math.sign(o),l[1]*Math.sign(o)],p=[(t[0]+e[0])/2,(t[1]+e[1])/2],h=[p[0]-d[0]*(a-Math.abs(o)),p[1]-d[1]*(a-Math.abs(o))],f=[];for(let g=1;g
t.reduce((e,n,r)=>r?e+Math.hypot(n[0]-t[r-1][0],n[1]-t[r-1][1]):e,0);function Pl(t,e){let n=Math.max(0,e);for(let r=0;r+1Math.round(t*1e3)/1e3,Dl=t=>t.map(([e,n])=>[Pe(e),Pe(n)]);function _m(t,e){return{id:I("room"),name:e,area_id:null,points:Dl(t),floor_material:"wood"}}function bm(t){return{...structuredClone(t),id:I("room"),points:Dl(t.points.map(([e,n])=>[e+.5,n+.5]))}}function ym(t,e){let n=t.rooms.find(r=>r.id===e);t.rooms=t.rooms.filter(r=>r.id!==e),t.openings=t.openings.filter(r=>r.room_id!==e||r.wall),n&&(t.placements=t.placements.filter(r=>!C([r.x,r.z],n.points)))}function vm(t,e,n){let r=t.rooms.find(s=>s.id===e);if(!r||r.points.length<=3)return!1;let i=(n-1+r.points.length)%r.points.length;r.points.splice(n,1),r.wall_heights?.splice(n,1),r.wall_slopes?.splice(n,1),r.wall_thickness?.splice(n,1);let o=s=>s.room_id===e&&!s.wall;return t.openings=t.openings.filter(s=>!(o(s)&&(s.edge===n||s.edge===i))).map(s=>o(s)&&s.edge>n?{...s,edge:s.edge-1}:s),!0}function wm(t,e,n){if(!Number.isFinite(n))return null;let r=de(t.points),{x0:i,z0:o,x1:s,z1:l}=r;return e==="x"?[i,s]=[n,n+(s-i)]:e==="z"?[o,l]=[n,n+(l-o)]:n>.05&&(e==="w"?s=i+n:l=o+n),Dl([[i,o],[s,o],[s,l],[i,l]])}function km(t,e,n,r){return!Number.isFinite(r)||e<0||e>=t.points.length?null:t.points.map((i,o)=>o===e?n===0?[Pe(r),i[1]]:[i[0],Pe(r)]:[i[0],i[1]])}var y0=/^(Raum|Room) \d+$/;function Il(t,e,n,r=!0){let i=e?n[e]:void 0,o=!t.name||y0.test(t.name)||Object.values(n).some(s=>s.name===t.name);return{area_id:e||null,...r&&i&&o?{name:i.name}:{}}}function Ol(t,e){let n=/^symcon-category-(\d+)$/.exec(e)?.[1];return(n?t?.symconObjects?.find(r=>r.object_id===Number(n))?.name:void 0)??t?.areas?.[e]?.name.split(" / ").at(-1)?.trim()??""}function xm(t,e){let n=e.filter(a=>Q(a.entity_id)==="light"&&(a.mount??"ceiling")==="ceiling"&&C([a.x,a.z],t.points));if(n.length<2)return[];let r=de(t.points),[i,o]=[r.x1-r.x0,r.z1-r.z0],s=Math.max(1,Math.round(Math.sqrt(n.length*i/Math.max(.1,o)))),l=Math.ceil(n.length/s);return n.map((a,c)=>{let u=Math.floor(c/s),d=u===l-1?n.length-s*(l-1):s,p=c-u*s;return{entityId:a.entity_id,x:Pe(r.x0+i/d*(p+.5)),z:Pe(r.z0+o/l*(u+.5))}})}function Hl(t,e,n,r){let i=t.rooms.find(u=>u.id===e);if(!i)return;let o=i.points[n],s=i.points[(n+1)%i.points.length];i.points.splice(n+1,0,r);let[l,a]=[i.wall_heights?.[n],i.wall_slopes?.[n]];if(typeof l=="number"&&typeof a=="number"&&i.wall_slopes){let u=Math.hypot(s[0]-o[0],s[1]-o[1]),d=Pe(l+(a-l)*Math.min(1,Math.hypot(r[0]-o[0],r[1]-o[1])/(u||1)));i.wall_slopes.splice(n,1,d,a),i.wall_heights.splice(n+1,0,d)}else i.wall_heights?.splice(n+1,0,i.wall_heights[n]??null),i.wall_slopes?.splice(n+1,0,null);i.wall_thickness?.splice(n+1,0,i.wall_thickness[n]??null);let c=Math.hypot(r[0]-o[0],r[1]-o[1]);for(let u of t.openings)u.room_id!==e||u.wall||(u.edge>n?u.edge+=1:u.edge===n&&u.offset>c&&(u.edge=n+1,u.offset=Pe(u.offset-c)))}var v0=22.5;function $m(t,e,n){let r=Math.min(Math.abs(e),t*2),i=t*(1+8/3*(r/Math.max(1e-6,t))**2),o=4*Math.atan(2*r/Math.max(1e-6,t))*180/Math.PI,s=Math.max(2,Math.ceil(o/v0));if(n<=0)return 24;let l=Math.floor(i/(n+.1));return l>=s?l:0}function w0(t,e,n,r){let i=zl(n);t.forEach((o,s)=>{let{piece:l,offset:a}=Pl(n,e[s]*i),c=Math.hypot(n[l+1][0]-n[l][0],n[l+1][1]-n[l][1]);o.edge=r+l,o.offset=Pe(c>o.width?Math.min(c-o.width/2,Math.max(o.width/2,a)):c/2)})}function Sm(t,e,n,r){let i=t.rooms.find(v=>v.id===e);if(!i||n<0||n>=i.points.length||Math.abs(r)<.01)return!1;let o=i.points[n],s=i.points[(n+1)%i.points.length],l=Math.hypot(s[0]-o[0],s[1]-o[1]);if(l<.2)return!1;let[a,c]=[(s[0]-o[0])/l,(s[1]-o[1])/l],u=[(o[0]+s[0])/2+c*.02,(o[1]+s[1])/2-a*.02],p=C(u,i.points)?-r:r,h=(v,w)=>t.openings.filter(x=>x.room_id===v.id&&!x.wall&&x.edge===w),f=t.rooms.flatMap(v=>v.points.map((w,x)=>{let k=v.points[(x+1)%v.points.length],M=(A,T)=>Math.abs(A[0]-T[0])<.001&&Math.abs(A[1]-T[1])<.001;return M(w,o)&&M(k,s)?[v,x,!1]:M(w,s)&&M(k,o)?[v,x,!0]:null}).filter(w=>!!w)),g=Math.max(0,...f.flatMap(([v,w])=>h(v,w).map(x=>x.width))),b=$m(l,r,g);if(!b)return!1;let y=Tl(o,s,p,b).map(([v,w])=>[Pe(v),Pe(w)]);if(!y.length)return!1;for(let[v,w,x]of f){let k=x?[...y].reverse():y,M=h(v,w),A=v.points[w],T=M.map(F=>Math.min(1,Math.max(0,F.offset/l)));for(let F of M)F.edge=-1;k.forEach((F,L)=>Hl(t,v.id,w+L,F)),v.wall_splits?.splice(w+1,0,...k.map(()=>null)),v.wall_splits?.[w]&&(v.wall_splits[w]=null),w0(M,T,[A,...k,v.points[(w+k.length+1)%v.points.length]],w)}return!0}function Mm(t,e,n){let r=t.walls??[],i=r.findIndex(f=>f.id===e);if(i<0||Math.abs(n)<.01)return[];let o=r[i],s=Math.hypot(o.b[0]-o.a[0],o.b[1]-o.a[1]),l=t.openings.filter(f=>f.wall===e),a=Math.max(0,...l.map(f=>f.width)),c=$m(s,n,a);if(!c)return[];let u=Tl(o.a,o.b,n,c).map(([f,g])=>[Pe(f),Pe(g)]);if(!u.length)return[];let d=[o.a,...u,o.b],p=d.slice(1).map((f,g)=>({...o,id:g===0?o.id:I("wall"),a:d[g],b:f}));r.splice(i,1,...p),t.walls=r;let h=zl(d);for(let f of l){let{piece:g,offset:b}=Pl(d,f.offset/s*h),y=Math.hypot(d[g+1][0]-d[g][0],d[g+1][1]-d[g][1]);f.wall=p[g].id,f.offset=Pe(y>f.width?Math.min(y-f.width/2,Math.max(f.width/2,b)):y/2)}return p.map(f=>f.id)}var nr=t=>Math.round(t*1e3)/1e3;function Qo(t,e,n){return[Math.round((e[0]-t[0])/n)*n,Math.round((e[1]-t[1])/n)*n]}var xn=(t,e)=>e?.01:t,rr=(t,e,n=5)=>Math.hypot(t[0]-e[0],t[1]-e[1])>=n;function Rm(t,e,n){return n?Math.abs(e[0]-t[0])>Math.abs(e[1]-t[1])?[e[0],t[1]]:[t[0],e[1]]:e}var et=(t,e)=>[nr(t[0]+e[0]),nr(t[1]+e[1])];function Ll(t,e,n,r){return[nr(Math.round((t[0]+n[0]-e[0])/r)*r),nr(Math.round((t[1]+n[1]-e[1])/r)*r)]}function Cl(t,e,n){let r=Math.atan2(-(e[0]-t[0]),e[1]-t[1])*180/Math.PI;return(Math.round(r/n)*n%360+360)%360}function Em(t,e,n){let r=Math.atan2(e[0]-t[0],-(e[1]-t[1]))*180/Math.PI;return Math.round(r/n)*n}function Am(t,e,n){let r=zn([...t]),i=t[e],o=[nr(n[0]),nr(n[1])];return t.map((s,l)=>l===e?o:r?[Math.abs(s[0]-i[0])<1e-6?o[0]:s[0],Math.abs(s[1]-i[1])<1e-6?o[1]:s[1]]:[s[0],s[1]])}var es=t=>Math.round(t*1e3)/1e3,Fm=(t,e)=>Math.hypot(t[0]-e[0],t[1]-e[1]);function k0(t,e,n){let r=null,i=n;for(let o of t){let s=Fm(o,e);s{let a=o.points[(l+1)%o.points.length],[c,u]=[a[0]-s[0],a[1]-s[1]],d=c*c+u*u;if(d<1e-9)return;let p=((e[0]-s[0])*c+(e[1]-s[1])*u)/d;if(p<=0||p>=1)return;let h=[s[0]+p*c,s[1]+p*u],f=Fm(h,e),g=(b,y,v)=>Math.min(Math.max(b,Math.min(y,v)),Math.max(y,v));Math.abs(u)<1e-9&&(h[0]=g(Math.round(h[0]/n.grid)*n.grid,s[0],a[0])),Math.abs(c)<1e-9&&(h[1]=g(Math.round(h[1]/n.grid)*n.grid,s[1],a[1])),fo.points.filter((s,l)=>!(e.skip&&o.id===e.skip.roomId&&(e.skip.index===void 0||e.skip.index===l)))),r=k0(n,t,e.reach);if(r)return{point:[r[0],r[1]],guides:{point:r}};let i=x0(e.rooms,t,e);return i?{point:[es(i[0]),es(i[1])],guides:{point:i}}:$0(n,t,e)}var ts=(t,e)=>pe(t.host.hass,e);function S0(t,e){let[n,r]=[t.toScreen(e.start),t.toScreen(e.end)];if(e.kind==="freewall"){let s=Math.hypot(e.end[0]-e.start[0],e.end[1]-e.start[1]);return R`
- ${es(t,s)}
+ ${ts(t,s)}
`}let[i,o]=[Math.abs(e.end[0]-e.start[0]),Math.abs(e.end[1]-e.start[1])];return R`
- ${es(t,i)} × ${es(t,o)}
- `}function $0(t,e,n,r){let i=[...e,...n?[n]:[]].map(u=>t.toScreen(u)),o=e.length>=3,s=r?e.slice(1).map((u,d)=>{let[p,h]=[t.toScreen(e[d]),t.toScreen(u)];return R`${es(t,Math.hypot(u[0]-e[d][0],u[1]-e[d][1]))} `}):_,l=e.map((u,d)=>{let[p,h]=t.toScreen(u),f=d===0&&o;return R` `}),[a,c]=n?t.toScreen(n):[0,0];return R`
+ ${ts(t,i)} × ${ts(t,o)}
+ `}function M0(t,e,n,r){let i=[...e,...n?[n]:[]].map(u=>t.toScreen(u)),o=e.length>=3,s=r?e.slice(1).map((u,d)=>{let[p,h]=[t.toScreen(e[d]),t.toScreen(u)];return R`${ts(t,Math.hypot(u[0]-e[d][0],u[1]-e[d][1]))} `}):_,l=e.map((u,d)=>{let[p,h]=t.toScreen(u),f=d===0&&o;return R` `}),[a,c]=n?t.toScreen(n):[0,0];return R`
${i.length>1?R`u.join(",")).join(" ")} />`:_}
${s}${l}
${n?R` `:_}
- `}function Tm(t,e,n){let r=e.x!==void 0?t.toScreen([e.x,0])[0]:null,i=e.z!==void 0?t.toScreen([0,e.z])[1]:null,[o,s]=e.point?t.toScreen(e.point):[0,0];return R`
+ `}function zm(t,e,n){let r=e.x!==void 0?t.toScreen([e.x,0])[0]:null,i=e.z!==void 0?t.toScreen([0,e.z])[1]:null,[o,s]=e.point?t.toScreen(e.point):[0,0];return R`
${r!==null?R` `:_}
${i!==null?R` `:_}
${e.point?R` `:_}
- `}function zm(t,e,n,r,i){return e?x0(t,e):n!=="polygon"&&n!=="measure"?_:$0(t,r,i,n==="measure")}var le=(t,e,n,r,i="")=>R` `,ie=(t,e,n,r,i="")=>R` `,Dm=(t,e="")=>R`n.join(",")).join(" ")} />`,se=(t,e,n,r="")=>R` `,Ll=(t,e,n,r,i="")=>R` `;function Cl(t,e,n){let r=[];for(let i=1;i1.2?2:1,o=(e-.2)/i,s=[le(-e/2,-n/2,e/2,-n/2+.07,"nf-sym-fill"),ie(-e/2,-n/2+(n-.1)*.36,e/2,-n/2+(n-.1)*.36)];for(let l=0;lDm(a.poly,a.landing?`nf-sym-fill ${o}`:o));i.column>0&&s.push(se(0,0,i.column,"nf-sym-fill"));let l=i.treads.map(jo);for(let a=1;a=2){let[a,c]=[l[l.length-2],l[l.length-1]],u=Math.hypot(c[0]-a[0],c[1]-a[1])||1,[d,p]=[(c[0]-a[0])/u,(c[1]-a[1])/u],h=Math.min(.2,i.flight*.3);for(let f of[-1,1])s.push(ie(c[0],c[1],c[0]-d*h+p*h*.6*f,c[1]-p*h-d*h*.6*f,"nf-sym-strong"))}return s}function M0(t,e,n){return t.symbol?.length?t.symbol.map(r=>r.shape==="rect"?le((r.x-r.w/2)*e,(r.z-r.d/2)*n,(r.x+r.w/2)*e,(r.z+r.d/2)*n,r.fill?"nf-sym-fill":""):r.shape==="circle"?se(r.x*e,r.z*n,r.r*Math.min(e,n)):ie(r.x1*e,r.z1*n,r.x2*e,r.z2*n)):Gc(t,e,n,t.size[2]).filter(r=>r.shape==="sweep"||r.w<.98||r.d<.98).map(r=>r.shape==="sweep"&&r.stations?.length?Dm([...r.stations.map(i=>[(r.x+i[3]/2)*e,i[0]*n]),...[...r.stations].reverse().map(i=>[(r.x-i[3]/2)*e,i[0]*n])]):r.shape==="cyl"&&(r.axis??"y")==="y"?se(r.x*e,r.z*n,Math.min(r.w*e,r.d*n)/2):le((r.x-r.w/2)*e,(r.z-r.d/2)*n,(r.x+r.w/2)*e,(r.z+r.d/2)*n))}var Nl=Math.PI/180,Hm=(t,e,n,r)=>{let[i,o]=r,s=R` `,l=R` ${s}`;return t==="data-rotate"?R`${l} `:R`${l} `};function R0(t,e){let n=e.rotation*Nl;return[[-1,-1],[1,-1],[1,1],[-1,1]].map(([r,i])=>{let[o,s]=t.toScreen([e.x+r*e.w*Math.cos(n)/2-i*e.d*Math.sin(n)/2,e.z+r*e.w*Math.sin(n)/2+i*e.d*Math.cos(n)/2]);return R` `})}var Om=new WeakMap;function E0(t,e){let n=Om.get(e);if(n&&n.states===t.states)return n.links;let r=Me(t,[e]);return Om.set(e,{states:t.states,links:r}),r}function A0(t,e,n){if(!t||!ue(n.type))return!1;let r=E0(t,e).get(n.id)?.entity;return!!Bc(r?t.states[r]:void 0,(n.extra_lights??[]).map(i=>t.states[i]))}function Lm(t,e,n){let{host:r,scale:i}=t,o=s=>{let l=s.id===n,a=l&&r.admin&&!s.locked,[c,u]=t.toScreen([s.x,s.z]),d=s.rotation*Nl,p=Math.min(s.w,s.d)*i>44,h=A0(r.hass,e,s),f=Ke.includes(s.type),g=`nf-furn${l?" nf-furn-sel":""}${h?" nf-furn-lit":""}${f?" nf-energy-item":""}`,b=s.d/2+Math.max(.3,26/i),y=t.toScreen([s.x-Math.sin(d)*b,s.z+Math.cos(d)*b]),v=t.toScreen([s.x-Math.sin(d)*(s.d/2),s.z+Math.cos(d)*(s.d/2)]),[w,x]=t.toScreen([s.x+Math.sin(d)*(s.d/2+18/i),s.z-Math.cos(d)*(s.d/2+18/i)]);return R`
+ `}function Pm(t,e,n,r,i){return e?S0(t,e):n!=="polygon"&&n!=="measure"?_:M0(t,r,i,n==="measure")}var le=(t,e,n,r,i="")=>R` `,ie=(t,e,n,r,i="")=>R` `,Im=(t,e="")=>R`n.join(",")).join(" ")} />`,se=(t,e,n,r="")=>R` `,Nl=(t,e,n,r,i="")=>R` `;function Bl(t,e,n){let r=[];for(let i=1;i1.2?2:1,o=(e-.2)/i,s=[le(-e/2,-n/2,e/2,-n/2+.07,"nf-sym-fill"),ie(-e/2,-n/2+(n-.1)*.36,e/2,-n/2+(n-.1)*.36)];for(let l=0;lIm(a.poly,a.landing?`nf-sym-fill ${o}`:o));i.column>0&&s.push(se(0,0,i.column,"nf-sym-fill"));let l=i.treads.map(Uo);for(let a=1;a=2){let[a,c]=[l[l.length-2],l[l.length-1]],u=Math.hypot(c[0]-a[0],c[1]-a[1])||1,[d,p]=[(c[0]-a[0])/u,(c[1]-a[1])/u],h=Math.min(.2,i.flight*.3);for(let f of[-1,1])s.push(ie(c[0],c[1],c[0]-d*h+p*h*.6*f,c[1]-p*h-d*h*.6*f,"nf-sym-strong"))}return s}function E0(t,e,n){return t.symbol?.length?t.symbol.map(r=>r.shape==="rect"?le((r.x-r.w/2)*e,(r.z-r.d/2)*n,(r.x+r.w/2)*e,(r.z+r.d/2)*n,r.fill?"nf-sym-fill":""):r.shape==="circle"?se(r.x*e,r.z*n,r.r*Math.min(e,n)):ie(r.x1*e,r.z1*n,r.x2*e,r.z2*n)):Zc(t,e,n,t.size[2]).filter(r=>r.shape==="sweep"||r.w<.98||r.d<.98).map(r=>r.shape==="sweep"&&r.stations?.length?Im([...r.stations.map(i=>[(r.x+i[3]/2)*e,i[0]*n]),...[...r.stations].reverse().map(i=>[(r.x-i[3]/2)*e,i[0]*n])]):r.shape==="cyl"&&(r.axis??"y")==="y"?se(r.x*e,r.z*n,Math.min(r.w*e,r.d*n)/2):le((r.x-r.w/2)*e,(r.z-r.d/2)*n,(r.x+r.w/2)*e,(r.z+r.d/2)*n))}var Wl=Math.PI/180,Lm=(t,e,n,r)=>{let[i,o]=r,s=R` `,l=R` ${s}`;return t==="data-rotate"?R`${l} `:R`${l} `};function A0(t,e){let n=e.rotation*Wl;return[[-1,-1],[1,-1],[1,1],[-1,1]].map(([r,i])=>{let[o,s]=t.toScreen([e.x+r*e.w*Math.cos(n)/2-i*e.d*Math.sin(n)/2,e.z+r*e.w*Math.sin(n)/2+i*e.d*Math.cos(n)/2]);return R` `})}var Hm=new WeakMap;function F0(t,e){let n=Hm.get(e);if(n&&n.states===t.states)return n.links;let r=Me(t,[e]);return Hm.set(e,{states:t.states,links:r}),r}function T0(t,e,n){if(!t||!ue(n.type))return!1;let r=F0(t,e).get(n.id)?.entity;return!!Vc(r?t.states[r]:void 0,(n.extra_lights??[]).map(i=>t.states[i]))}function Cm(t,e,n){let{host:r,scale:i}=t,o=s=>{let l=s.id===n,a=l&&r.admin&&!s.locked,[c,u]=t.toScreen([s.x,s.z]),d=s.rotation*Wl,p=Math.min(s.w,s.d)*i>44,h=T0(r.hass,e,s),f=Ke.includes(s.type),g=`nf-furn${l?" nf-furn-sel":""}${h?" nf-furn-lit":""}${f?" nf-energy-item":""}`,b=s.d/2+Math.max(.3,26/i),y=t.toScreen([s.x-Math.sin(d)*b,s.z+Math.cos(d)*b]),v=t.toScreen([s.x-Math.sin(d)*(s.d/2),s.z+Math.cos(d)*(s.d/2)]),[w,x]=t.toScreen([s.x+Math.sin(d)*(s.d/2+18/i),s.z-Math.cos(d)*(s.d/2+18/i)]);return R`
- ${Im(s.type,s.w,s.d,s)}
+ ${Om(s.type,s.w,s.d,s)}
${p?R`${Ae(r.hass,s.type)} `:_}
- ${a?R0(t,s):_}
+ ${a?A0(t,s):_}
${l?R`${pe(r.hass,s.w)} × ${pe(r.hass,s.d)} `:_}
${l&&s.locked?R`🔒 `:_}
- ${a?Hm("data-rotate",s.id,v,y):_}`};return R`${Ef(e).map(o)} `}function Cm(t,e,n){let{host:r}=t,i=o=>{let s=Q(o.entity_id)??(r.hass?je(r.hass,o.entity_id):null);if(!s)return _;let[l,a]=t.toScreen([o.x,o.z]),c=r.hass?.states[o.entity_id]?.state==="on",u=o.entity_id===n,d=(o.rotation??0)*Nl,p=u&&r.admin&&!o.locked&&Ou(o.entity_id,r.hass?.states[o.entity_id]),h=[l-Math.sin(d)*46,a+Math.cos(d)*46],f=Cn(r,o.entity_id,o.icon);return R`${p?Hm("data-aim",o.entity_id,[l,a],h):_}
+ ${a?Lm("data-rotate",s.id,v,y):_}`};return R`${Af(e).map(o)} `}function Nm(t,e,n){let{host:r}=t,i=o=>{let s=Q(o.entity_id)??(r.hass?je(r.hass,o.entity_id):null);if(!s)return _;let[l,a]=t.toScreen([o.x,o.z]),c=r.hass?.states[o.entity_id]?.state==="on",u=o.entity_id===n,d=(o.rotation??0)*Wl,p=u&&r.admin&&!o.locked&&Lu(o.entity_id,r.hass?.states[o.entity_id]),h=[l-Math.sin(d)*46,a+Math.cos(d)*46],f=Cn(r,o.entity_id,o.icon);return R`${p?Lm("data-aim",o.entity_id,[l,a],h):_}
${B(r.hass,o.entity_id)}
- ${f?R` `:R` `}
+ ${f?R` `:R` `}
- ${u&&o.locked?R`🔒 `:_}`};return R`${e.placements.map(i)} `}function Nm(t,e,n){return R`${(e.notes??[]).map(r=>{let[i,o]=t.toScreen([r.x,r.z]);return R`
+ ${u&&o.locked?R`🔒 `:_}`};return R`${e.placements.map(i)} `}function Bm(t,e,n){return R`${(e.notes??[]).map(r=>{let[i,o]=t.toScreen([r.x,r.z]);return R`
${r.text}
✎
- `})}`}var ts=(t,e,n=6)=>R` `;function Bm(t,e){let{scale:n}=t,r=n>=90?.1:n>=30?.5:1,i=n>=20?1:5,o=t.toWorld(0,0),s=t.toWorld(e.w,e.h),l=[],a=(d,p)=>{for(let h=Math.ceil(o[0]/d)*d;h<=s[0];h+=d){let f=t.toScreen([h,0])[0];l.push(R` `)}for(let h=Math.ceil(o[1]/d)*d;h<=s[1];h+=d){let f=t.toScreen([0,h])[1];l.push(R` `)}};r `),R`${l} `}function Wm(t){let e=t.host.doc.floors,n=e.findIndex(o=>o.id===t.floorId),r=n>0?e[n-1]:void 0;if(!r)return _;let i=Ru(e,e[n]);return R`${r.rooms.map(o=>R` `)}${i.map(o=>R` `)} `}function Vm(t,e){let n=t.host.floor?.height??2.5;return R`${e.map(r=>{let i=r.height!==void 0&&r.height `})} `}function Km(t,e,n){let r=i=>{let[o,s]=t.toScreen(be(i.points)),l=de(i.points),a=Math.min(l.x1-l.x0,l.z1-l.z0)*t.scale>40;return R`
+ `})}`}var ns=(t,e,n=6)=>R` `;function Wm(t,e){let{scale:n}=t,r=n>=90?.1:n>=30?.5:1,i=n>=20?1:5,o=t.toWorld(0,0),s=t.toWorld(e.w,e.h),l=[],a=(d,p)=>{for(let h=Math.ceil(o[0]/d)*d;h<=s[0];h+=d){let f=t.toScreen([h,0])[0];l.push(R` `)}for(let h=Math.ceil(o[1]/d)*d;h<=s[1];h+=d){let f=t.toScreen([0,h])[1];l.push(R` `)}};r `),R`${l} `}function Vm(t){let e=t.host.doc.floors,n=e.findIndex(o=>o.id===t.floorId),r=n>0?e[n-1]:void 0;if(!r)return _;let i=Au(e,e[n]);return R`${r.rooms.map(o=>R` `)}${i.map(o=>R` `)} `}function Km(t,e){let n=t.host.floor?.height??2.5;return R`${e.map(r=>{let i=r.height!==void 0&&r.height `})} `}function jm(t,e,n){let r=i=>{let[o,s]=t.toScreen(be(i.points)),l=de(i.points),a=Math.min(l.x1-l.x0,l.z1-l.z0)*t.scale>40;return R`
${a?R`${t.host.t(`out_${i.type}`)} `:_}
- `};return R`${e.outdoor.map(r)} `}function jm(t,e,n){let{host:r}=t;if(!e||!r.admin||n!=="select"||r.doc.settings.lock_plan)return _;let i=e.points;return R`${i.map((o,s)=>No(t,o,i[(s+1)%i.length],"out",e.id,s))}${i.map((o,s)=>R`${ts(...t.toScreen(o))} `)}`}function Gm(t,e,n,r){let i=e.rooms.find(s=>s.id===n),o=i&&r!==null&&r${e.rooms.map(s=>R` `)}
+ `};return R`${e.outdoor.map(r)} `}function Um(t,e,n){let{host:r}=t;if(!e||!r.admin||n!=="select"||r.doc.settings.lock_plan)return _;let i=e.points;return R`${i.map((o,s)=>Bo(t,o,i[(s+1)%i.length],"out",e.id,s))}${i.map((o,s)=>R`${ns(...t.toScreen(o))} `)}`}function Gm(t,e,n,r){let i=e.rooms.find(s=>s.id===n),o=i&&r!==null&&r${e.rooms.map(s=>R` `)}
${o?R` `:_}
${e.rooms.map(s=>{let[l,a]=t.toScreen(be(s.points));return R`${s.name}
- ${ze(t.host.hass,ke(s.points))} `})} `}function Um(t,e){let n=t.host.doc.energy?.meter;if(!n||n.floor_id!==e.id)return _;let[r,i]=t.toScreen([n.x,n.z]);return R`
+ ${ze(t.host.hass,xe(s.points))} `})} `}function Zm(t,e){let n=t.host.doc.energy?.meter;if(!n||n.floor_id!==e.id)return _;let[r,i]=t.toScreen([n.x,n.z]);return R`
- `}function Zm(t,e,n){let{host:r}=t,i=o=>{let[s,l]=[t.toScreen(o.a),t.toScreen(o.b)],a=o.id===n,c=a&&r.admin&&!Gi(o,!0,r.doc.settings);return R`
+ `}function qm(t,e,n){let{host:r}=t,i=o=>{let[s,l]=[t.toScreen(o.a),t.toScreen(o.b)],a=o.id===n,c=a&&r.admin&&!Gi(o,!0,r.doc.settings);return R`
- ${c?R`${ts(s[0],s[1])} ${ts(l[0],l[1])} `:_}`};return R`${(e.walls??[]).map(i)} `}function qm(t,e){let n=e.points,r=(e.wall_splits??[]).flatMap((i,o)=>{if(!i||o>=n.length)return[];let[s,l]=[n[o],n[(o+1)%n.length]],a=Math.hypot(l[0]-s[0],l[1]-s[1])||1,[c,u]=[(l[0]-s[0])/a,(l[1]-s[1])/a];return i.map(d=>{let[p,h]=t.toScreen([s[0]+c*d,s[1]+u*d]);return R` `})});return R`${r}`}function Ym(t,e,n){let r=e.points,[i,o]=t.toScreen(be(r)),s=(a,c,u)=>{let[[d,p],[h,f]]=[t.toScreen(a),t.toScreen(c)],[g,b]=[(d+h)/2,(p+f)/2],y=Math.hypot(h-d,f-p),[v,w]=[-(f-p),h-d],x=Math.hypot(v,w)||1;return[v,w]=[v/x,w/x],v*(g-i)+w*(b-o)<0&&([v,w]=[-v,-w]),R`${y>50?R`${pe(t.host.hass,Math.hypot(c[0]-a[0],c[1]-a[1]))} `:_}
- ${y>36?R` `:_}`},l=(a,c)=>{let[u,d]=t.toScreen(a);return R`${ts(u,d)} ${c+1} `};return R`${r.map((a,c)=>s(a,r[(c+1)%r.length],c))}${r.map(l)} `}function Xm(t,e){let n=e.rooms.flatMap(r=>{if(r.points.length<3)return[];let[i,o]=be(r.points);return r.points.map((s,l)=>{let a=r.points[(l+1)%r.points.length],c=Math.hypot(a[0]-s[0],a[1]-s[1]);if(c<.4)return _;let u=[(s[0]+a[0])/2,(s[1]+a[1])/2],d=Math.hypot(i-u[0],o-u[1])||1,p=Math.min(.35,d/2),h=[u[0]+(i-u[0])/d*p,u[1]+(o-u[1])/d*p],[f,g]=t.toScreen(h),b=Math.atan2(a[1]-s[1],a[0]-s[0])*180/Math.PI;return b>90&&(b-=180),b<-90&&(b+=180),R`${pe(t.host.hass,c)} `})});return R`${n} `}function Jm(t,e,n){let r=t.t;return m`
+ ${c?R`${ns(s[0],s[1])} ${ns(l[0],l[1])} `:_}`};return R`${(e.walls??[]).map(i)} `}function Ym(t,e){let n=e.points,r=(e.wall_splits??[]).flatMap((i,o)=>{if(!i||o>=n.length)return[];let[s,l]=[n[o],n[(o+1)%n.length]],a=Math.hypot(l[0]-s[0],l[1]-s[1])||1,[c,u]=[(l[0]-s[0])/a,(l[1]-s[1])/a];return i.map(d=>{let[p,h]=t.toScreen([s[0]+c*d,s[1]+u*d]);return R` `})});return R`${r}`}function Xm(t,e,n){let r=e.points,[i,o]=t.toScreen(be(r)),s=(a,c,u)=>{let[[d,p],[h,f]]=[t.toScreen(a),t.toScreen(c)],[g,b]=[(d+h)/2,(p+f)/2],y=Math.hypot(h-d,f-p),[v,w]=[-(f-p),h-d],x=Math.hypot(v,w)||1;return[v,w]=[v/x,w/x],v*(g-i)+w*(b-o)<0&&([v,w]=[-v,-w]),R`${y>50?R`${pe(t.host.hass,Math.hypot(c[0]-a[0],c[1]-a[1]))} `:_}
+ ${y>36?R` `:_}`},l=(a,c)=>{let[u,d]=t.toScreen(a);return R`${ns(u,d)} ${c+1} `};return R`${r.map((a,c)=>s(a,r[(c+1)%r.length],c))}${r.map(l)} `}function Jm(t,e){let n=e.rooms.flatMap(r=>{if(r.points.length<3)return[];let[i,o]=be(r.points);return r.points.map((s,l)=>{let a=r.points[(l+1)%r.points.length],c=Math.hypot(a[0]-s[0],a[1]-s[1]);if(c<.4)return _;let u=[(s[0]+a[0])/2,(s[1]+a[1])/2],d=Math.hypot(i-u[0],o-u[1])||1,p=Math.min(.35,d/2),h=[u[0]+(i-u[0])/d*p,u[1]+(o-u[1])/d*p],[f,g]=t.toScreen(h),b=Math.atan2(a[1]-s[1],a[0]-s[0])*180/Math.PI;return b>90&&(b-=180),b<-90&&(b+=180),R`${pe(t.host.hass,c)} `})});return R`${n} `}function Qm(t,e,n){let r=t.t;return m`
✎ ${r("note")}
${J(m`n.remove()}>${r("delete")} `)}
- `}function F0(t,e,n){let r=t.t,i=!!e.photo?.startsWith("image:"),o=async s=>{let l=s.target,a=l.files?.[0];if(l.value="",!a||!t.hass)return;let{data:c}=await tr(a),u=I("img");await Bt(t.hass,u,c),n.patch({photo:`image:${u}`})};return m`${t.admin?m`📷 ${r(i?"picture_replace":"note_photo_upload")} `:_}
+ `}function z0(t,e,n){let r=t.t,i=!!e.photo?.startsWith("image:"),o=async s=>{let l=s.target,a=l.files?.[0];if(l.value="",!a||!t.hass)return;let{data:c}=await tr(a),u=I("img");await Wt(t.hass,u,c),n.patch({photo:`image:${u}`})};return m`${t.admin?m`📷 ${r(i?"picture_replace":"note_photo_upload")} `:_}
${i?m`${r("picture_stored")} n.patch({photo:null})}>${r("delete")}
`:V(t,r("picture_url"),e.photo??"",s=>n.patch({photo:s.trim()||null}),{wide:!0,placeholder:"/local/valve.jpg"})}
- ${S(r("note_photo_hint"),"nf-wide")}`}function T0(t,e,n,r){let i=Ce(e,n.rooms,n.walls??[]);if(!i)return null;let{room:o,edge:s}=i,l=Wt(r,e,i),a=Wn(o,s,e.offset-e.width/2),c=Wn(o,s,e.offset+e.width/2),u=[(c[0]-a[0])/(e.width||1),(c[1]-a[1])/(e.width||1)],d=_e(o.points)>=0?1:-1,p=[-u[1]*d,u[0]*d],h=[.06,.06];return l&&(h=l.wall.free||l.wall.roomLeft===o.id?[l.wall.left,l.wall.right]:[l.wall.right,l.wall.left]),{room:o,edge:s,p0:a,p1:c,inward:p,direction:d,across:h,exterior:l?.wall.exterior??!1,at:(f,g)=>t.toScreen([f[0]+p[0]*g,f[1]+p[1]*g])}}var Mt=(t,e,n="")=>R` `;function z0(t,e){let n=t.across[0]-.04,r=t.across[0]+Math.min(2,e.height),[i,o,s,l]=[t.at(t.p0,n),t.at(t.p1,n),t.at(t.p0,r),t.at(t.p1,r)];return R`${Mt(i,o)} `}function P0(t,e,n){let r=n.swing==="out",i=r?-e.across[1]:e.across[0],o=(e.across[0]-e.across[1])/2,s=n.hinge==="left"==e.direction>0,l=nn(n,e.exterior),a=n.leaves===2,[c,u]=[e.p0,e.p1],d=[],p=Eu(n.width,l,s,n);if(p){let v=w=>w<=.02?e.p0:w>=n.width-.02?e.p1:Wn(e.room,e.edge,n.offset-n.width/2+w);[c,u]=[v(p.x0),v(p.x1)],d=p.panels.map(([w,x])=>[v(w),v(x)])}let h=[(c[0]+u[0])/2,(c[1]+u[1])/2],f=(a?.5:1)*Math.hypot(u[0]-c[0],u[1]-c[1]),g=d.map(([v,w])=>R`${Mt(e.at(v,o+.035),e.at(w,o+.035),"nf-open-pane")}${Mt(e.at(v,o-.035),e.at(w,o-.035),"nf-open-pane")}`),b=(v,w)=>{let[x,k]=e.at(v,i),[M,A]=e.at(w,i),T=e.at(v,i+(r?-f:f)),F=f*t.scale,H=(T[0]-x)*(A-k)-(T[1]-k)*(M-x)>0?1:0;return R` `},y;return l==="passage"?y=Mt(e.at(e.p0,o),e.at(e.p1,o),"nf-open-passage"):l==="sliding"?y=Mt(e.at(c,i),e.at(u,i)):a?y=R`${b(c,h)}${b(u,h)}`:y=s?b(c,u):b(u,c),R`${g}${y}`}function D0(t,e){let n=(t.across[0]-t.across[1])/2;if(e.opens==="slide"){let i=e.leaves===2?4:2,o=l=>[t.p0[0]+(t.p1[0]-t.p0[0])*l,t.p0[1]+(t.p1[1]-t.p0[1])*l],s=Array.from({length:i},(l,a)=>{let c=e.leaves===2?a===1||a===2?.035:-.035:a===0?.035:-.035;return Mt(t.at(o(Math.max(0,a/i-.03)),n+c),t.at(o(Math.min(1,(a+1)/i+.03)),n+c))});return R`${s}`}let r=e.leaves===2?Mt(t.at([(t.p0[0]+t.p1[0])/2,(t.p0[1]+t.p1[1])/2],t.across[0]),t.at([(t.p0[0]+t.p1[0])/2,(t.p0[1]+t.p1[1])/2],-t.across[1])):_;return R`${Mt(t.at(t.p0,n+.035),t.at(t.p1,n+.035))}${Mt(t.at(t.p0,n-.035),t.at(t.p1,n-.035))}${r}`}function Qm(t,e,n,r){let i=e.openings.find(s=>s.id===r)?.front??null,o=s=>{let l=T0(t,s,e,n);if(!l)return _;let a=[l.at(l.p0,l.across[0]+.01),l.at(l.p1,l.across[0]+.01),l.at(l.p1,-l.across[1]-.01),l.at(l.p0,-l.across[1]-.01)],c=s.type==="door"&&Ns(nn(s,l.exterior)),u=s.id===r||!!s.front&&s.front===i,d=`nf-open nf-open-${s.type}${c?" nf-open-front":""}${u?" nf-open-sel":""}`,p=s.type==="garage"?z0(l,s):s.type==="door"?P0(t,l,s):D0(l,s);return R`h.join(",")).join(" ")} />${p} `};return R`${e.openings.map(o)} `}var eg=t=>Math.round(t*1e3)/1e3,tg=t=>Math.round(t*100)/100;function ir(t,e){let n=[...t??[]].slice(0,e);for(;n.lengtht.every(e=>e===null);function $i(t,e){let[n,r]=[t.points[e],t.points[(e+1)%t.points.length]];return Math.hypot(r[0]-n[0],r[1]-n[1])}function Bl(t,e,n){let r=ir(t.wall_heights,t.points.length);r[e]=n,t.wall_heights=ns(r)?void 0:r,rs(t,e,null)}function rs(t,e,n){if(n===null&&!t.wall_slopes)return;let r=ir(t.wall_slopes,t.points.length);r[e]=n,t.wall_slopes=ns(r)?void 0:r}function ng(t,e,n,r){let[i,o]=[n,r].map(l=>Math.min(30,Math.max(.05,eg(l)))),s=ir(t.wall_heights,t.points.length);s[e]=i,t.wall_heights=s,rs(t,e,o)}function rg(t,e,n){let r=t.wall_heights?.[e];rs(t,e,null),typeof r=="number"&&r>=n-.005&&Bl(t,e,null)}function ig(t,e,n,r,i){let o=ir(t.wall_heights,t.points.length),s=o[e],l=Array.isArray(s)?[...s]:new Array(i).fill(typeof s=="number"?s:null);for(;l.lengtha===l[0])?l[0]:l,t.wall_heights=ns(o)?void 0:o,rs(t,e,null)}function og(t,e,n,r){let i=$i(t,e),o=n===void 0?0:r[n],s=n===void 0?i:r[n+1]??i;if(s-o<.4)return!1;let l=tg((o+s)/2),a=ir(t.wall_splits,t.points.length);a[e]=[...a[e]??[],l].sort((u,d)=>u-d),t.wall_splits=a;let c=t.wall_heights?.[e];return Array.isArray(c)&&c.splice((n??0)+1,0,c[n??0]??null),!0}function sg(t,e,n,r,i){let o=$i(t,e),s=i.filter(u=>Math.abs(u-n)>.001&&u>0),l=Math.max(.1,Math.min(o-.1,tg(r)));s.some(u=>Math.abs(u-l)<.1)&&(l=n);let a=t.wall_splits?.[e];if(!a)return;let c=a.findIndex(u=>Math.abs(u-n)<.001);c>=0&&(a[c]=l),a.sort((u,d)=>u-d)}function ag(t,e,n,r){let i=t.wall_splits;if(!i?.[e])return;let o=i[e].filter(l=>Math.abs(l-n)>.001);i[e]=o.length>0?o:null,i.every(l=>!l)&&(t.wall_splits=void 0);let s=t.wall_heights?.[e];Array.isArray(s)&&(s.splice(r,1),s.every(l=>l===s[0])&&(t.wall_heights[e]=s[0]??null))}function lg(t,e,n,r,i=1){let o=ir(t.wall_thickness,t.points.length);if(r===void 0||i<2)o[e]=n;else{let s=o[e],l=Array.isArray(s)?[...s]:new Array(i).fill(typeof s=="number"?s:null);for(;l.lengtha===l[0])?l[0]:l}t.wall_thickness=ns(o)?void 0:o}function cg(t,e){let n=Math.min(1.5,Math.max(.02,eg(t)));return Math.abs(n-e)<5e-4?null:n}var ug=.005,dg=(t,e)=>`room:${t.id}:${e}`;function hg(t,e,n){let r=t.t,i=e.ceiling??t.floor.height,o=e.points.length,{wall_exterior:s,wall_interior:l}=t.doc.settings,a=c=>{let u=e.wall_heights?.[c]??null,d=n.partsOf(e,c);return(d.length>1?d.map((h,f)=>f):[void 0]).map(h=>{let f=Array.isArray(u)?u[h??0]??null:u,g=e.wall_thickness?.[c]??null,b=Array.isArray(g)?g[h??0]??null:g,y=h===void 0?$i(e,c):(d[h+1]??$i(e,c))-d[h],v=P=>n.setHeight(e,c,h,P),w=n.isOuter(e,c)?s:l,x=`${r("wall_n",{a:c+1,b:(c+1)%o+1})}${h===void 0?"":` \xB7 ${r("wall_part",{n:h+1})}`}`,k=h!==void 0&&h>0&&(e.wall_splits?.[c]??[]).some(P=>Math.abs(P-d[h])<.001),M=e.wall_slopes?.[c],A=h===void 0&&typeof M=="number"&&typeof u=="number",T=f??i,F=()=>n.light(c),H=()=>n.light(null);return m`
+ ${S(r("note_photo_hint"),"nf-wide")}`}function P0(t,e,n,r){let i=Ce(e,n.rooms,n.walls??[]);if(!i)return null;let{room:o,edge:s}=i,l=Vt(r,e,i),a=Wn(o,s,e.offset-e.width/2),c=Wn(o,s,e.offset+e.width/2),u=[(c[0]-a[0])/(e.width||1),(c[1]-a[1])/(e.width||1)],d=_e(o.points)>=0?1:-1,p=[-u[1]*d,u[0]*d],h=[.06,.06];return l&&(h=l.wall.free||l.wall.roomLeft===o.id?[l.wall.left,l.wall.right]:[l.wall.right,l.wall.left]),{room:o,edge:s,p0:a,p1:c,inward:p,direction:d,across:h,exterior:l?.wall.exterior??!1,at:(f,g)=>t.toScreen([f[0]+p[0]*g,f[1]+p[1]*g])}}var Mt=(t,e,n="")=>R`
`;function D0(t,e){let n=t.across[0]-.04,r=t.across[0]+Math.min(2,e.height),[i,o,s,l]=[t.at(t.p0,n),t.at(t.p1,n),t.at(t.p0,r),t.at(t.p1,r)];return R`${Mt(i,o)}
`}function I0(t,e,n){let r=n.swing==="out",i=r?-e.across[1]:e.across[0],o=(e.across[0]-e.across[1])/2,s=n.hinge==="left"==e.direction>0,l=rn(n,e.exterior),a=n.leaves===2,[c,u]=[e.p0,e.p1],d=[],p=Fu(n.width,l,s,n);if(p){let v=w=>w<=.02?e.p0:w>=n.width-.02?e.p1:Wn(e.room,e.edge,n.offset-n.width/2+w);[c,u]=[v(p.x0),v(p.x1)],d=p.panels.map(([w,x])=>[v(w),v(x)])}let h=[(c[0]+u[0])/2,(c[1]+u[1])/2],f=(a?.5:1)*Math.hypot(u[0]-c[0],u[1]-c[1]),g=d.map(([v,w])=>R`${Mt(e.at(v,o+.035),e.at(w,o+.035),"nf-open-pane")}${Mt(e.at(v,o-.035),e.at(w,o-.035),"nf-open-pane")}`),b=(v,w)=>{let[x,k]=e.at(v,i),[M,A]=e.at(w,i),T=e.at(v,i+(r?-f:f)),F=f*t.scale,L=(T[0]-x)*(A-k)-(T[1]-k)*(M-x)>0?1:0;return R`
`},y;return l==="passage"?y=Mt(e.at(e.p0,o),e.at(e.p1,o),"nf-open-passage"):l==="sliding"?y=Mt(e.at(c,i),e.at(u,i)):a?y=R`${b(c,h)}${b(u,h)}`:y=s?b(c,u):b(u,c),R`${g}${y}`}function O0(t,e){let n=(t.across[0]-t.across[1])/2;if(e.opens==="slide"){let i=e.leaves===2?4:2,o=l=>[t.p0[0]+(t.p1[0]-t.p0[0])*l,t.p0[1]+(t.p1[1]-t.p0[1])*l],s=Array.from({length:i},(l,a)=>{let c=e.leaves===2?a===1||a===2?.035:-.035:a===0?.035:-.035;return Mt(t.at(o(Math.max(0,a/i-.03)),n+c),t.at(o(Math.min(1,(a+1)/i+.03)),n+c))});return R`${s}`}let r=e.leaves===2?Mt(t.at([(t.p0[0]+t.p1[0])/2,(t.p0[1]+t.p1[1])/2],t.across[0]),t.at([(t.p0[0]+t.p1[0])/2,(t.p0[1]+t.p1[1])/2],-t.across[1])):_;return R`${Mt(t.at(t.p0,n+.035),t.at(t.p1,n+.035))}${Mt(t.at(t.p0,n-.035),t.at(t.p1,n-.035))}${r}`}function eg(t,e,n,r){let i=e.openings.find(s=>s.id===r)?.front??null,o=s=>{let l=P0(t,s,e,n);if(!l)return _;let a=[l.at(l.p0,l.across[0]+.01),l.at(l.p1,l.across[0]+.01),l.at(l.p1,-l.across[1]-.01),l.at(l.p0,-l.across[1]-.01)],c=s.type==="door"&&Bs(rn(s,l.exterior)),u=s.id===r||!!s.front&&s.front===i,d=`nf-open nf-open-${s.type}${c?" nf-open-front":""}${u?" nf-open-sel":""}`,p=s.type==="garage"?D0(l,s):s.type==="door"?I0(t,l,s):O0(l,s);return R`
h.join(",")).join(" ")} />${p} `};return R`
${e.openings.map(o)} `}var tg=t=>Math.round(t*1e3)/1e3,ng=t=>Math.round(t*100)/100;function ir(t,e){let n=[...t??[]].slice(0,e);for(;n.length
t.every(e=>e===null);function Si(t,e){let[n,r]=[t.points[e],t.points[(e+1)%t.points.length]];return Math.hypot(r[0]-n[0],r[1]-n[1])}function Vl(t,e,n){let r=ir(t.wall_heights,t.points.length);r[e]=n,t.wall_heights=rs(r)?void 0:r,is(t,e,null)}function is(t,e,n){if(n===null&&!t.wall_slopes)return;let r=ir(t.wall_slopes,t.points.length);r[e]=n,t.wall_slopes=rs(r)?void 0:r}function rg(t,e,n,r){let[i,o]=[n,r].map(l=>Math.min(30,Math.max(.05,tg(l)))),s=ir(t.wall_heights,t.points.length);s[e]=i,t.wall_heights=s,is(t,e,o)}function ig(t,e,n){let r=t.wall_heights?.[e];is(t,e,null),typeof r=="number"&&r>=n-.005&&Vl(t,e,null)}function og(t,e,n,r,i){let o=ir(t.wall_heights,t.points.length),s=o[e],l=Array.isArray(s)?[...s]:new Array(i).fill(typeof s=="number"?s:null);for(;l.lengtha===l[0])?l[0]:l,t.wall_heights=rs(o)?void 0:o,is(t,e,null)}function sg(t,e,n,r){let i=Si(t,e),o=n===void 0?0:r[n],s=n===void 0?i:r[n+1]??i;if(s-o<.4)return!1;let l=ng((o+s)/2),a=ir(t.wall_splits,t.points.length);a[e]=[...a[e]??[],l].sort((u,d)=>u-d),t.wall_splits=a;let c=t.wall_heights?.[e];return Array.isArray(c)&&c.splice((n??0)+1,0,c[n??0]??null),!0}function ag(t,e,n,r,i){let o=Si(t,e),s=i.filter(u=>Math.abs(u-n)>.001&&u>0),l=Math.max(.1,Math.min(o-.1,ng(r)));s.some(u=>Math.abs(u-l)<.1)&&(l=n);let a=t.wall_splits?.[e];if(!a)return;let c=a.findIndex(u=>Math.abs(u-n)<.001);c>=0&&(a[c]=l),a.sort((u,d)=>u-d)}function lg(t,e,n,r){let i=t.wall_splits;if(!i?.[e])return;let o=i[e].filter(l=>Math.abs(l-n)>.001);i[e]=o.length>0?o:null,i.every(l=>!l)&&(t.wall_splits=void 0);let s=t.wall_heights?.[e];Array.isArray(s)&&(s.splice(r,1),s.every(l=>l===s[0])&&(t.wall_heights[e]=s[0]??null))}function cg(t,e,n,r,i=1){let o=ir(t.wall_thickness,t.points.length);if(r===void 0||i<2)o[e]=n;else{let s=o[e],l=Array.isArray(s)?[...s]:new Array(i).fill(typeof s=="number"?s:null);for(;l.lengtha===l[0])?l[0]:l}t.wall_thickness=rs(o)?void 0:o}function ug(t,e){let n=Math.min(1.5,Math.max(.02,tg(t)));return Math.abs(n-e)<5e-4?null:n}var dg=.005,hg=(t,e)=>`room:${t.id}:${e}`;function pg(t,e,n){let r=t.t,i=e.ceiling??t.floor.height,o=e.points.length,{wall_exterior:s,wall_interior:l}=t.doc.settings,a=c=>{let u=e.wall_heights?.[c]??null,d=n.partsOf(e,c);return(d.length>1?d.map((h,f)=>f):[void 0]).map(h=>{let f=Array.isArray(u)?u[h??0]??null:u,g=e.wall_thickness?.[c]??null,b=Array.isArray(g)?g[h??0]??null:g,y=h===void 0?Si(e,c):(d[h+1]??Si(e,c))-d[h],v=P=>n.setHeight(e,c,h,P),w=n.isOuter(e,c)?s:l,x=`${r("wall_n",{a:c+1,b:(c+1)%o+1})}${h===void 0?"":` \xB7 ${r("wall_part",{n:h+1})}`}`,k=h!==void 0&&h>0&&(e.wall_splits?.[c]??[]).some(P=>Math.abs(P-d[h])<.001),M=e.wall_slopes?.[c],A=h===void 0&&typeof M=="number"&&typeof u=="number",T=f??i,F=()=>n.light(c),L=()=>n.light(null);return m`
${x} ${pe(t.hass,y)}
${f===0?m`
${r("wall_none")} `:A?m`
${E(t,r("wall_slope_start"),u,P=>n.setSlope(e,c,P,M),.05,.05)}
${E(t,r("wall_slope_end"),M,P=>n.setSlope(e,c,u,P),.05,.05)} `:E(t,r("wall_height"),T,P=>v(P>=i-ug?null:Math.max(.05,P)),.05,.05)}
+ >`:E(t,r("wall_height"),T,P=>v(P>=i-dg?null:Math.max(.05,P)),.05,.05)}
${t.admin&&A?m`
n.clearSlope(e,c)}>▭ `:_}
${t.admin&&f!==null&&!A?m`
v(null)}>↥ `:_}
- ${t.admin&&h===void 0&&f!==0&&!A?m`
n.setSlope(e,c,T,T>=i-ug?T+1:i)}>∠ ${r("wall_slope")} `:_}
+ ${t.admin&&h===void 0&&f!==0&&!A?m`
n.setSlope(e,c,T,T>=i-dg?T+1:i)}>∠ ${r("wall_slope")} `:_}
${t.admin&&f!==0?m`
v(0)}>${r("wall_none")} `:_}
${t.admin&&y>=.4?m`
n.cut(e,c,h)}>✂ `:_}
- ${h===void 0&&y>=.4?Go(t,dg(e,c),n.arc):_}
+ ${h===void 0&&y>=.4?Go(t,hg(e,c),n.arc):_}
${(h===void 0||h===0)&&f!==0?m`
n.openWall(e,c)}>▣ ${r("wall_view")} `:_}
${f!==0?m`
${E(t,r("edge_thickness"),b??w,P=>n.setThickness(e,c,cg(P,w),h,d.length),.01,.02)}
+ >${E(t,r("edge_thickness"),b??w,P=>n.setThickness(e,c,ug(P,w),h,d.length),.01,.02)}
${t.admin&&b!=null?m`n.setThickness(e,c,null,h,d.length)}>↺ `:_} `:_}
- ${h===void 0?Uo(t,dg(e,c),n.arc):_}
+ ${h===void 0?Zo(t,hg(e,c),n.arc):_}
${k?m`
${E(t,r("wall_split_at"),d[h],P=>n.moveCut(e,c,d[h],P),.05,.1)}
${t.admin?m`n.join(e,c,d[h],h)}>⨉ `:_} `})};return m`
${r("wall_heights")}
${e.points.flatMap((c,u)=>a(u))} ${S(r("room_wall_hint"))}
- `}function pg(t){let e=t?.attributes;return{temperature:"\u{1F321}",humidity:"\u{1F4A7}",carbon_dioxide:"\u2601",illuminance:"\u2600",power:"\u26A1",energy:"\u26A1"}[String(e?.device_class)]??(e?.unit_of_measurement==="\xB0C"?"\u{1F321}":"\u25C9")}function or(t,e=[],n){let r=O(t.hass,o=>!t.hass?.states[o]?.attributes.symcon_source_entity||e.some(s=>s.entity===o)),i=(o,s)=>n(e.map(l=>l.id===o?{...l,...s}:l));return m`
+ `}function fg(t){let e=t?.attributes;return{temperature:"\u{1F321}",humidity:"\u{1F4A7}",carbon_dioxide:"\u2601",illuminance:"\u2600",power:"\u26A1",energy:"\u26A1"}[String(e?.device_class)]??(e?.unit_of_measurement==="\xB0C"?"\u{1F321}":"\u25C9")}function or(t,e=[],n){let r=O(t.hass,o=>!t.hass?.states[o]?.attributes.symcon_source_entity||e.some(s=>s.entity===o)),i=(o,s)=>n(e.map(l=>l.id===o?{...l,...s}:l));return m`
${t.t("device_values")} n([...e,{id:I("value"),entity:null}])}>+
${e.map((o,s)=>m`
${z(t,`${t.t("device_value")} ${s+1}`,o.entity,void 0,r,l=>i(o.id,{entity:l==="none"?null:l}))}
- ${V(t,t.t("device_value_icon"),o.icon??"",l=>i(o.id,{icon:l||null}),{maxlength:16,placeholder:pg(o.entity?t.hass?.states[o.entity]:void 0)})}
+ ${V(t,t.t("device_value_icon"),o.icon??"",l=>i(o.id,{icon:l||null}),{maxlength:16,placeholder:fg(o.entity?t.hass?.states[o.entity]:void 0)})}
${V(t,t.t("device_value_label"),o.label??"",l=>i(o.id,{label:l||null}),{maxlength:60})}
{let l=e.filter(a=>a.id!==o.id);n(l.length?l:void 0)}}>× ${t.t("device_value_remove")}
`)}
${S(t.t("device_values_hint"))}
-
`}function fg(t,e,n){let r=e.color_entity&&e.color_entity!=="none"?e.color_entity:n;return r?t.states[r]:void 0}var Wl=["none","rainbow","pulse","flicker"];function is(t,e,n,r){let i=e.effect_animations??{},o=zu(),s=c=>Wl.includes(c)||o.includes(c),l=[...new Set([...Object.keys(i),...Array.isArray(n)?n.filter(c=>typeof c=="string"):[]])],a=(c,u,d,p=!1)=>{let h=Object.prototype.hasOwnProperty.call(i,c),f=Array.from(c).length,g=p&&h?"light_effect_exists":u!==""&&(f<1||f>255)?"light_effect_name_limit":u!==""&&!h&&Object.keys(i).length>=100?"light_effect_count_limit":void 0;if(d.setCustomValidity?.(g?t.t(g):""),g){let y=d.closest?.("details")?.querySelector("[data-effect-feedback]");return y&&(y.textContent=t.t(g)),d.reportValidity?.(),p||(d.value=h?i[c]:""),!1}let b={...i};return u===""?delete b[c]:Object.defineProperty(b,c,{value:u,enumerable:!0,configurable:!0,writable:!0}),r({effect_animations:b}),!0};return m`
+ `}function mg(t,e,n){let r=e.color_entity&&e.color_entity!=="none"?e.color_entity:n;return r?t.states[r]:void 0}var Kl=["none","rainbow","pulse","flicker"];function os(t,e,n,r){let i=e.effect_animations??{},o=Du(),s=c=>Kl.includes(c)||o.includes(c),l=[...new Set([...Object.keys(i),...Array.isArray(n)?n.filter(c=>typeof c=="string"):[]])],a=(c,u,d,p=!1)=>{let h=Object.prototype.hasOwnProperty.call(i,c),f=Array.from(c).length,g=p&&h?"light_effect_exists":u!==""&&(f<1||f>255)?"light_effect_name_limit":u!==""&&!h&&Object.keys(i).length>=100?"light_effect_count_limit":void 0;if(d.setCustomValidity?.(g?t.t(g):""),g){let y=d.closest?.("details")?.querySelector("[data-effect-feedback]");return y&&(y.textContent=t.t(g)),d.reportValidity?.(),p||(d.value=h?i[c]:""),!1}let b={...i};return u===""?delete b[c]:Object.defineProperty(b,c,{value:u,enumerable:!0,configurable:!0,writable:!0}),r({effect_animations:b}),!0};return m`
${t.t("light_effects")}
${S(t.t("light_effects_hint"))}
{let d=u.target;a(c,d.value,d)}}>
${t.t("light_effect_unmapped")}
${Object.prototype.hasOwnProperty.call(i,c)&&!s(i[c])?m`${i[c]} (${t.t("light_effect_unmapped")}) `:_}
- ${Wl.map(u=>m`${t.t(`light_animation_${u}`)} `)}
+ ${Kl.map(u=>m`${t.t(`light_animation_${u}`)} `)}
${o.map(u=>m`${u} (${t.t("plugin")}) `)}
`)}
${t.t("light_effect_add")} {let u=c.target;a(u.value,"none",u,!0)&&(u.value="")}} />
${S(`${t.t("light_effect_name_limit")} ${t.t("light_effect_count_limit")}`)}
- `}var I0=/speaker|sound|subwoofer|receiver|smart_|display|tv|media|turntable|projector|console/;function O0(t,e,n){let r=Q(e),i=t.hass?.language??"en",o=[...qi.map(l=>({type:l,label:t.t(`furn_${l}`)})),...n.flatMap(l=>l.items.map(a=>({type:he(l.id,a.id),label:`${Je(a,he(l.id,a.id),i)} \xB7 ${Be(l,i)}`})))],s=l=>r==="light"?ue(l):r==="climate"?l==="radiator"||Rn(l):e.startsWith("vacuum.")?l==="robot_vacuum"||vt(l)&&l.endsWith(":robot_vacuum"):r==="media"?Tr(l)||Tt(l)&&I0.test(l):Tt(l)&&!ue(l);return o.filter(l=>s(l.type)).sort((l,a)=>l.label.localeCompare(a.label))}function H0(t,e,n){if(!t.admin)return _;let r=O0(t,e.entity_id,n.packs);return r.length===0?_:m`
`}var H0=/speaker|sound|subwoofer|receiver|smart_|display|tv|media|turntable|projector|console/;function L0(t,e,n){let r=Q(e),i=t.hass?.language??"en",o=[...Yi.map(l=>({type:l,label:t.t(`furn_${l}`)})),...n.flatMap(l=>l.items.map(a=>({type:he(l.id,a.id),label:`${Je(a,he(l.id,a.id),i)} \xB7 ${Be(l,i)}`})))],s=l=>r==="light"?ue(l):r==="climate"?l==="radiator"||En(l):e.startsWith("vacuum.")?l==="robot_vacuum"||vt(l)&&l.endsWith(":robot_vacuum"):r==="media"?zr(l)||Tt(l)&&H0.test(l):Tt(l)&&!ue(l);return o.filter(l=>s(l.type)).sort((l,a)=>l.label.localeCompare(a.label))}function C0(t,e,n){if(!t.admin)return _;let r=L0(t,e.entity_id,n.packs);return r.length===0?_:m`${t.t("as_furniture")}
i.target.value&&n.asFurniture(e,i.target.value)}>
${t.t("as_furniture_pick")}
${r.map(i=>m`${i.label} `)}
- `}function L0(t,e,n){let r=t.hass?.language??"en";return Du(e.entity_id,t.hass?.states[e.entity_id]).map(({pluginId:i,name:o,settings:s})=>{let l=Iu(s,e.plugin?.[i]),a=(u,d)=>n({plugin:{...e.plugin??{},[i]:{...e.plugin?.[i]??{},[u]:d}}}),c=s.map(u=>{let d=no(u.label,r),p=u.hint?no(u.hint,r):void 0;if(u.type==="boolean")return D(t,d,l[u.key]===!0,f=>a(u.key,f),{title:p});if(u.type==="select"){let f=(u.options??[]).map(([g,b])=>[g,no(b,r)]);return L(t,d,String(l[u.key]),f,g=>a(u.key,g),{wide:!0,title:p})}let h=f=>Math.min(u.max??1/0,Math.max(u.min??-1/0,f));return E(t,d,Number(l[u.key]),f=>a(u.key,h(f)),u.step??1,u.min)});return m`🔌 ${o} ${c}`})}function Vl(t,e,n){let r=t.t,i=Q(e.entity_id)??(t.hass?je(t.hass,e.entity_id):null),o=i==="light",s=e.mount??"ceiling",l=i?Bi(i,t.floor?ht(t.floor,e.x,e.z):2.5,o?s:null):1,a=p=>n.update(p),c=Cn(t,e.entity_id,e.icon),u=p=>a({mount:p,y:null}),d=["ceiling","floor","table","wall"].map(p=>[p,r(`lamp_${p}`)]);return m` `}function N0(t,e,n){let r=t.hass?.language??"en";return Ou(e.entity_id,t.hass?.states[e.entity_id]).map(({pluginId:i,name:o,settings:s})=>{let l=Hu(s,e.plugin?.[i]),a=(u,d)=>n({plugin:{...e.plugin??{},[i]:{...e.plugin?.[i]??{},[u]:d}}}),c=s.map(u=>{let d=ro(u.label,r),p=u.hint?ro(u.hint,r):void 0;if(u.type==="boolean")return D(t,d,l[u.key]===!0,f=>a(u.key,f),{title:p});if(u.type==="select"){let f=(u.options??[]).map(([g,b])=>[g,ro(b,r)]);return H(t,d,String(l[u.key]),f,g=>a(u.key,g),{wide:!0,title:p})}let h=f=>Math.min(u.max??1/0,Math.max(u.min??-1/0,f));return E(t,d,Number(l[u.key]),f=>a(u.key,h(f)),u.step??1,u.min)});return m`
🔌 ${o} ${c}`})}function jl(t,e,n){let r=t.t,i=Q(e.entity_id)??(t.hass?je(t.hass,e.entity_id):null),o=i==="light",s=e.mount??"ceiling",l=i?Wi(i,t.floor?ht(t.floor,e.x,e.z):2.5,o?s:null):1,a=p=>n.update(p),c=Cn(t,e.entity_id,e.icon),u=p=>a({mount:p,y:null}),d=["ceiling","floor","table","wall"].map(p=>[p,r(`lamp_${p}`)]);return m`
${r("device")} ${n.lockButton}
- ${c?m` `:m` `}
+ ${c?m` `:m` `}
${B(t.hass,e.entity_id)}
@@ -1416,165 +1416,178 @@ ${o}`}else i=ip(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
${i==="cover"?m`
${D(t,r("cover_direction_invert"),!!e.cover_inverted,p=>a({cover_inverted:p||void 0}))}
${D(t,r("cover_tilt_direction_invert"),!!e.cover_tilt_inverted,p=>a({cover_tilt_inverted:p||void 0}))}
- ${z(t,r("cover_position_entity"),e.position??null,void 0,O(t.hass,p=>ao(t.hass,p)),p=>a({position:p&&p!=="none"?p:null}),{types:[1,2]})}
+ ${z(t,r("cover_position_entity"),e.position??null,void 0,O(t.hass,p=>lo(t.hass,p)),p=>a({position:p&&p!=="none"?p:null}),{types:[1,2]})}
${e.position?D(t,r("cover_position_invert"),!!e.position_inverted,p=>a({position_inverted:p||void 0})):_}
${S(r("cover_direction_hint"),"nf-wide")}`:_}
- ${o?m`${L(t,r("lamp_mount"),s,d,u,{wide:!0})}${an(t,e.glow_scale,p=>a({glow_scale:p}))}`:_}
- ${o?is(t,e,t.hass?.states[e.entity_id]?.attributes.effect_list,a):_}
- ${e.entity_id.startsWith("media_player.")?an(t,e.sound_rings,p=>a({sound_rings:p}),{label:"sound_rings",hint:"sound_rings_hint",lowest:0}):_}
+ ${o?m`${H(t,r("lamp_mount"),s,d,u,{wide:!0})}${ln(t,e.glow_scale,p=>a({glow_scale:p}))}`:_}
+ ${o?os(t,e,t.hass?.states[e.entity_id]?.attributes.effect_list,a):_}
+ ${e.entity_id.startsWith("media_player.")?ln(t,e.sound_rings,p=>a({sound_rings:p}),{label:"sound_rings",hint:"sound_rings_hint",lowest:0}):_}
${E(t,r("x"),e.x,p=>a({x:p}))} ${E(t,r("z"),e.z,p=>a({z:p}))}
${E(t,r("marker_height"),e.y??l,p=>a({y:Math.max(0,p)}),.05,0)}
${E(t,r("rotation"),e.rotation??0,p=>a({rotation:(p%360+360)%360}),1)}
${o?D(t,r("device_simple"),!!e.simple,p=>a({simple:p||void 0}),{title:r("device_simple_hint")}):_}
- ${i&&Lc.has(i)?D(t,r("device_confirm"),!!e.confirm,p=>a({confirm:p}),{title:r("device_confirm_hint")}):_}
+ ${i&&Nc.has(i)?D(t,r("device_confirm"),!!e.confirm,p=>a({confirm:p}),{title:r("device_confirm_hint")}):_}
${D(t,r("device_outside"),!!e.outside,p=>a({outside:p||void 0}),{title:r("device_outside_hint")})}
${Nn(t,e.marker??null,p=>a({marker:p}))}
- ${Nt(t,e.pin_offset,p=>a({pin_offset:p}))}
+ ${Bt(t,e.pin_offset,p=>a({pin_offset:p}))}
${V(t,r("device_name"),e.name??"",p=>a({name:p||null}),{wide:!0,maxlength:60,title:r("device_name_hint"),placeholder:B(t.hass,e.entity_id)})}
${e.name?D(t,r("show_name"),!!e.show_name,p=>a({show_name:p||void 0})):_}
- ${Ct(t,e.icon,p=>a({icon:p}))}
- ${L0(t,e,a)}
+ ${Nt(t,e.icon,p=>a({icon:p}))}
+ ${N0(t,e,a)}
${or(t,e.values,p=>a({values:p}))}
${t.admin?m`
n.centre()}>${r("device_centre")}
${e.y!==null?m`a({y:null})}>${r("height_auto")} `:_}
- ${H0(t,e,n)}
+ ${C0(t,e,n)}
n.remove()}>${r("devices_remove")}
`:_}
- `}var Si=t=>Number(t);function os(t){if(Array.isArray(t)){let[o,s]=[Si(t[0]),Si(t[1])];return Number.isFinite(o)&&Number.isFinite(s)?[o,s]:null}if(!t||typeof t!="object")return null;let{x:e,y:n}=t,[r,i]=[Si(e),Si(n)];return Number.isFinite(r)&&Number.isFinite(i)?[r,i]:null}function _g(t){return t?os(t.charger)??os(t.charger_position):null}function ss(t){for(let[e,n]of Object.entries(t.states))if(e.startsWith("camera.")&&(os(n.attributes?.vacuum_position)??_g(n.attributes)))return e;return null}var Kl=(t,e)=>e?[t[0],-t[1]]:t;var bg=5e-4,yg=2,C0=1.5;function jl(t,e){let n=e?t.states[e]?.attributes:void 0;return{at:n?os(n.vacuum_position):null,dock:_g(n)}}function vg(t,e,n=!1){let r=Math.hypot(e.plan[0]-t.plan[0],e.plan[1]-t.plan[1]),i=Math.hypot(e.grid[0]-t.grid[0],e.grid[1]-t.grid[1]);if(!(i>1e-6)||!(r>=C0))return{cal:null,reason:"close"};let o=r/i;return o>=bg&&o<=yg?{cal:{a:t.plan,ga:t.grid,b:e.plan,gb:e.grid,mirror:n}}:{cal:null,reason:"scale"}}function wg(t,e){let n=e?t.states[e]?.attributes?.rooms:void 0;if(!n||typeof n!="object")return[];let r=[];for(let i of Object.values(n)){if(!i||typeof i!="object")continue;let o=i,s=typeof o.name=="string"?o.name.trim():"",l=[o.x0,o.y0,o.x1,o.y1].map(Si);!s||!l.every(Number.isFinite)||r.push({name:s,center:[(l[0]+l[2])/2,(l[1]+l[3])/2]})}return r}var mg=t=>t.toLocaleLowerCase().normalize("NFKD").replace(/[̀-ͯ]/g,"").replace(/[^\p{L}\p{N}]+/gu,"");function N0(t){let e=t.length,[n,r]=t.reduce((h,f)=>[h[0]+f.seen[0]/e,h[1]+f.seen[1]/e],[0,0]),[i,o]=t.reduce((h,f)=>[h[0]+f.plan[0]/e,h[1]+f.plan[1]/e],[0,0]),[s,l,a]=[0,0,0];for(let h of t){let[f,g]=[h.seen[0]-n,h.seen[1]-r],[b,y]=[h.plan[0]-i,h.plan[1]-o];s+=f*b+g*y,l+=f*y-g*b,a+=f*f+g*g}if(!(a>1e-9))return null;let[c,u]=[s/a,l/a],d=h=>{let[f,g]=[h[0]-n,h[1]-r];return[i+c*f-u*g,o+u*f+c*g]},p=Math.sqrt(t.reduce((h,f)=>h+Math.hypot(d(f.seen)[0]-f.plan[0],d(f.seen)[1]-f.plan[1])**2,0)/e);return{map:d,scale:Math.hypot(c,u),rms:p}}function kg(t,e,n=!1){let r=new Map(e.map(g=>[mg(g.name),g])),i=[],o=new Set;for(let g of t){let b=mg(g.name),y=r.get(b);if(!y||o.has(b)||g.points.length<3)continue;o.add(b);let v=g.points.map(x=>x[0]),w=g.points.map(x=>x[1]);i.push({name:g.name,plan:[(Math.min(...v)+Math.max(...v))/2,(Math.min(...w)+Math.max(...w))/2],grid:y.center})}let s=i.map(g=>g.name);if(i.length<2)return{cal:null,reason:"rooms",matched:s};let a=(i.length>=3?[!1,!0]:[n]).flatMap(g=>{let b=N0(i.map(y=>({plan:y.plan,seen:Kl(y.grid,g)})));return b?[{mirror:g,...b}]:[]}).sort((g,b)=>g.rms-b.rms)[0];if(!a)return{cal:null,reason:"rooms",matched:s};if(!(a.scale>=bg&&a.scale<=yg))return{cal:null,reason:"scale",matched:s};let c=Math.max(...i.map(g=>Math.hypot(g.plan[0]-i[0].plan[0],g.plan[1]-i[0].plan[1])));if(!(a.rms<=Math.max(1,c/4)))return{cal:null,reason:"fit",matched:s};let[u,d,p]=[0,1,-1];for(let g=0;g
p&&([u,d,p]=[g,b,y])}let[h,f]=[i[u].grid,i[d].grid];return{cal:{a:a.map(Kl(h,a.mirror)),ga:h,b:a.map(Kl(f,a.mirror)),gb:f,mirror:a.mirror},matched:s,rms:a.rms}}function xg(t,e){let[n,r]=[(t.a[0]+t.b[0])/2,(t.a[1]+t.b[1])/2],i=(e.turn??0)*Math.PI/180,[o,s,l]=[Math.cos(i),Math.sin(i),e.grow??1],[a,c]=e.move??[0,0],u=d=>{let[p,h]=[(d[0]-n)*l,(d[1]-r)*l];return[gg(n+p*o-h*s+a),gg(r+p*s+h*o+c)]};return{...t,a:u(t.a),b:u(t.b)}}var gg=t=>Math.round(t*1e3)/1e3;var B0=/^(binary_sensor|switch|input_boolean|light|fan|person|device_tracker|sensor)\./,Rt=t=>t==="none"?null:t;function Gl(t,e,n){let r=t.t,i=O(t.hass,a=>B0.test(a)),o=!!e.state_entity&&e.state_entity!=="none",s=o&&!!e.state_entity2&&e.state_entity2!=="none",l=[["left_right",r("furn_state_left_right")],["top_bottom",r("furn_state_top_bottom")]];return m`${z(t,r("furn_state_entity"),e.state_entity??null,void 0,i,a=>n.update({state_entity:Rt(a)}))}
+ `}var sr=t=>t==="wallbox"||/^pack:[^:]+:(wallbox|ev_charger|ev_bike_charger|charging_station)$/.test(t);function gg(t,e,n){if(!sr(e.type))return _;let r=t.t,i=e.charging??{},o=O(t.hass,()=>!0),s=u=>{let d={...i,...u};n({charging:Object.values(d).some(p=>p!=null)?d:null})},l=[["auto",r("charging_auto")],["value",r("charging_value")],["seconds",r("charging_unix_seconds")],["milliseconds",r("charging_unix_ms")]],a=[["auto",r("charging_auto")],["value",r("charging_value")],["seconds",r("charging_seconds")],["minutes",r("charging_minutes")],["hours",r("charging_hours")]],c=(u,d,p)=>z(t,d,i[u]??null,void 0,o,h=>s({[u]:h==="none"?null:h}),{types:p});return m`
+ ${r("charging_data")}
+ ${S(r("charging_hint"),"nf-wide")}
+ ${c("soc",r("furn_soc"),[1,2])}
+ ${c("start",r("charging_start"),[1,2,3])}
+ ${i.start&&i.start!=="none"?H(t,`${r("charging_start")} \xB7 ${r("charging_time_format")}`,i.start_format??"auto",l,u=>s({start_format:u}),{wide:!0}):_}
+ ${c("end",r("charging_end"),[1,2,3])}
+ ${i.end&&i.end!=="none"?H(t,`${r("charging_end")} \xB7 ${r("charging_time_format")}`,i.end_format??"auto",l,u=>s({end_format:u}),{wide:!0}):_}
+ ${c("duration",r("charging_duration"),[1,2,3])}
+ ${i.duration&&i.duration!=="none"?H(t,r("charging_duration_unit"),i.duration_unit??"auto",a,u=>s({duration_unit:u}),{wide:!0}):_}
+ ${c("energy",r("charging_energy"),[1,2])}
+ ${c("lock",r("charging_lock"),[1])}
+
`}var Mi=t=>Number(t);function ss(t){if(Array.isArray(t)){let[o,s]=[Mi(t[0]),Mi(t[1])];return Number.isFinite(o)&&Number.isFinite(s)?[o,s]:null}if(!t||typeof t!="object")return null;let{x:e,y:n}=t,[r,i]=[Mi(e),Mi(n)];return Number.isFinite(r)&&Number.isFinite(i)?[r,i]:null}function yg(t){return t?ss(t.charger)??ss(t.charger_position):null}function as(t){for(let[e,n]of Object.entries(t.states))if(e.startsWith("camera.")&&(ss(n.attributes?.vacuum_position)??yg(n.attributes)))return e;return null}var Ul=(t,e)=>e?[t[0],-t[1]]:t;var vg=5e-4,wg=2,B0=1.5;function Gl(t,e){let n=e?t.states[e]?.attributes:void 0;return{at:n?ss(n.vacuum_position):null,dock:yg(n)}}function kg(t,e,n=!1){let r=Math.hypot(e.plan[0]-t.plan[0],e.plan[1]-t.plan[1]),i=Math.hypot(e.grid[0]-t.grid[0],e.grid[1]-t.grid[1]);if(!(i>1e-6)||!(r>=B0))return{cal:null,reason:"close"};let o=r/i;return o>=vg&&o<=wg?{cal:{a:t.plan,ga:t.grid,b:e.plan,gb:e.grid,mirror:n}}:{cal:null,reason:"scale"}}function xg(t,e){let n=e?t.states[e]?.attributes?.rooms:void 0;if(!n||typeof n!="object")return[];let r=[];for(let i of Object.values(n)){if(!i||typeof i!="object")continue;let o=i,s=typeof o.name=="string"?o.name.trim():"",l=[o.x0,o.y0,o.x1,o.y1].map(Mi);!s||!l.every(Number.isFinite)||r.push({name:s,center:[(l[0]+l[2])/2,(l[1]+l[3])/2]})}return r}var _g=t=>t.toLocaleLowerCase().normalize("NFKD").replace(/[̀-ͯ]/g,"").replace(/[^\p{L}\p{N}]+/gu,"");function W0(t){let e=t.length,[n,r]=t.reduce((h,f)=>[h[0]+f.seen[0]/e,h[1]+f.seen[1]/e],[0,0]),[i,o]=t.reduce((h,f)=>[h[0]+f.plan[0]/e,h[1]+f.plan[1]/e],[0,0]),[s,l,a]=[0,0,0];for(let h of t){let[f,g]=[h.seen[0]-n,h.seen[1]-r],[b,y]=[h.plan[0]-i,h.plan[1]-o];s+=f*b+g*y,l+=f*y-g*b,a+=f*f+g*g}if(!(a>1e-9))return null;let[c,u]=[s/a,l/a],d=h=>{let[f,g]=[h[0]-n,h[1]-r];return[i+c*f-u*g,o+u*f+c*g]},p=Math.sqrt(t.reduce((h,f)=>h+Math.hypot(d(f.seen)[0]-f.plan[0],d(f.seen)[1]-f.plan[1])**2,0)/e);return{map:d,scale:Math.hypot(c,u),rms:p}}function $g(t,e,n=!1){let r=new Map(e.map(g=>[_g(g.name),g])),i=[],o=new Set;for(let g of t){let b=_g(g.name),y=r.get(b);if(!y||o.has(b)||g.points.length<3)continue;o.add(b);let v=g.points.map(x=>x[0]),w=g.points.map(x=>x[1]);i.push({name:g.name,plan:[(Math.min(...v)+Math.max(...v))/2,(Math.min(...w)+Math.max(...w))/2],grid:y.center})}let s=i.map(g=>g.name);if(i.length<2)return{cal:null,reason:"rooms",matched:s};let a=(i.length>=3?[!1,!0]:[n]).flatMap(g=>{let b=W0(i.map(y=>({plan:y.plan,seen:Ul(y.grid,g)})));return b?[{mirror:g,...b}]:[]}).sort((g,b)=>g.rms-b.rms)[0];if(!a)return{cal:null,reason:"rooms",matched:s};if(!(a.scale>=vg&&a.scale<=wg))return{cal:null,reason:"scale",matched:s};let c=Math.max(...i.map(g=>Math.hypot(g.plan[0]-i[0].plan[0],g.plan[1]-i[0].plan[1])));if(!(a.rms<=Math.max(1,c/4)))return{cal:null,reason:"fit",matched:s};let[u,d,p]=[0,1,-1];for(let g=0;gp&&([u,d,p]=[g,b,y])}let[h,f]=[i[u].grid,i[d].grid];return{cal:{a:a.map(Ul(h,a.mirror)),ga:h,b:a.map(Ul(f,a.mirror)),gb:f,mirror:a.mirror},matched:s,rms:a.rms}}function Sg(t,e){let[n,r]=[(t.a[0]+t.b[0])/2,(t.a[1]+t.b[1])/2],i=(e.turn??0)*Math.PI/180,[o,s,l]=[Math.cos(i),Math.sin(i),e.grow??1],[a,c]=e.move??[0,0],u=d=>{let[p,h]=[(d[0]-n)*l,(d[1]-r)*l];return[bg(n+p*o-h*s+a),bg(r+p*s+h*o+c)]};return{...t,a:u(t.a),b:u(t.b)}}var bg=t=>Math.round(t*1e3)/1e3;var V0=/^(binary_sensor|switch|input_boolean|light|fan|person|device_tracker|sensor)\./,Rt=t=>t==="none"?null:t;function Zl(t,e,n){let r=t.t,i=O(t.hass,a=>V0.test(a)),o=!!e.state_entity&&e.state_entity!=="none",s=o&&!!e.state_entity2&&e.state_entity2!=="none",l=[["left_right",r("furn_state_left_right")],["top_bottom",r("furn_state_top_bottom")]];return m`${z(t,r("furn_state_entity"),e.state_entity??null,void 0,i,a=>n.update({state_entity:Rt(a)}))}
${o?z(t,r("furn_state_entity2"),e.state_entity2??null,void 0,i,a=>n.update({state_entity2:Rt(a)})):_}
- ${s?L(t,r("furn_state_split"),e.state_split==="top_bottom"?"top_bottom":"left_right",l,a=>n.update({state_split:a})):_}
- ${S(r("furn_state_hint"),"nf-wide")}`}function W0(t,e){let r=On(t.type)&&(!vt(t.type)||Zc(t.type));return ue(t.type)?{accept:i=>/^(light|switch|input_boolean)\./.test(i),label:"furn_entity_light"}:t.type==="radiator"||Rn(t.type)?{accept:i=>i.startsWith("climate."),label:"furn_entity_climate"}:r?{accept:i=>/^(media_player|switch|input_boolean|light)\./.test(i),label:"furn_entity_tv"}:t.type==="robot_vacuum"?{accept:i=>i.startsWith("vacuum."),label:"furn_entity_vacuum"}:/:(robot_mower|mower_dock)$/.test(t.type)?{accept:i=>i.startsWith("lawn_mower."),label:"furn_entity_mower"}:/:(sprinkler|valve_box)$/.test(t.type)?{accept:i=>/^(valve|switch|input_boolean)\./.test(i),label:"furn_entity_water"}:{accept:i=>/^(switch|media_player|fan|input_boolean|climate|vacuum|cover|valve)\./.test(i)||Cc(e?.states[i]),label:"furn_entity"}}function as(t,e,n){if(!t.hass)return null;let r=structuredClone(t.doc.floors);for(let i of r)for(let o of i.furniture)o.id===e.id&&(o[n==="fan"?"fan_entity":n]=null);return Me(t.hass,r).get(e.id)?.[n]??null}var V0=t=>t==="meter"?"energy_grid":t==="inverter"?"energy_solar_sensor":t==="home_battery"?"energy_battery_sensor":"furn_power",ct=(...t)=>m`${t}
`;async function K0(t){let e=t.hass?ss(t.hass):null;if(!t.hass||!e)return{at:null,dock:null};let n=()=>{let i=t.hass?.states[e]?.attributes??{};return`${String(i.render_count??"")}|${JSON.stringify(i.vacuum_position??null)}`},r=n();try{await t.hass.fetchWithAuth?.(`/api/camera_proxy/${e}`)}catch{}for(let i=0;i<8&&n()===r;i++)await new Promise(o=>setTimeout(o,100));return jl(t.hass,e)}function j0(t,e){let n=t.t,r=a=>t.change(c=>{c.settings.vacuum_map=xg(e,a)}),i=(a,c,u)=>m`r(u)}>${a} `,[o,s,l]=[n("robot_cal_nudge_move"),n("robot_cal_nudge_turn"),n("robot_cal_nudge_grow")];return m`${S(n("robot_cal_nudge"),"nf-wide")}
+ ${s?H(t,r("furn_state_split"),e.state_split==="top_bottom"?"top_bottom":"left_right",l,a=>n.update({state_split:a})):_}
+ ${S(r("furn_state_hint"),"nf-wide")}`}function K0(t,e){let r=On(t.type)&&(!vt(t.type)||Yc(t.type));return ue(t.type)?{accept:i=>/^(light|switch|input_boolean)\./.test(i),label:"furn_entity_light"}:t.type==="radiator"||En(t.type)?{accept:i=>i.startsWith("climate."),label:"furn_entity_climate"}:r?{accept:i=>/^(media_player|switch|input_boolean|light)\./.test(i),label:"furn_entity_tv"}:t.type==="robot_vacuum"?{accept:i=>i.startsWith("vacuum."),label:"furn_entity_vacuum"}:/:(robot_mower|mower_dock)$/.test(t.type)?{accept:i=>i.startsWith("lawn_mower."),label:"furn_entity_mower"}:/:(sprinkler|valve_box)$/.test(t.type)?{accept:i=>/^(valve|switch|input_boolean)\./.test(i),label:"furn_entity_water"}:{accept:i=>/^(switch|media_player|fan|input_boolean|climate|vacuum|cover|valve)\./.test(i)||Bc(e?.states[i]),label:"furn_entity"}}function ls(t,e,n){if(!t.hass)return null;let r=structuredClone(t.doc.floors);for(let i of r)for(let o of i.furniture)o.id===e.id&&(o[n==="fan"?"fan_entity":n]=null);return Me(t.hass,r).get(e.id)?.[n]??null}var j0=t=>t==="meter"?"energy_grid":t==="inverter"?"energy_solar_sensor":t==="home_battery"?"energy_battery_sensor":"furn_power",ct=(...t)=>m`${t}
`;async function U0(t){let e=t.hass?as(t.hass):null;if(!t.hass||!e)return{at:null,dock:null};let n=()=>{let i=t.hass?.states[e]?.attributes??{};return`${String(i.render_count??"")}|${JSON.stringify(i.vacuum_position??null)}`},r=n();try{await t.hass.fetchWithAuth?.(`/api/camera_proxy/${e}`)}catch{}for(let i=0;i<8&&n()===r;i++)await new Promise(o=>setTimeout(o,100));return Gl(t.hass,e)}function G0(t,e){let n=t.t,r=a=>t.change(c=>{c.settings.vacuum_map=Sg(e,a)}),i=(a,c,u)=>m`r(u)}>${a} `,[o,s,l]=[n("robot_cal_nudge_move"),n("robot_cal_nudge_turn"),n("robot_cal_nudge_grow")];return m`${S(n("robot_cal_nudge"),"nf-wide")}
${i("\u2190",o,{move:[-.1,0]})}${i("\u2192",o,{move:[.1,0]})}${i("\u2191",o,{move:[0,-.1]})}${i("\u2193",o,{move:[0,.1]})}
${i("\u27F2",s,{turn:-1})}${i("\u27F3",s,{turn:1})}${i("\u2212",l,{grow:.99})}${i("+",l,{grow:1.01})}
-
`}function G0(t,e){let n=t.t,r=t.doc.settings.vacuum_map??null,i=t.hass?jl(t.hass,ss(t.hass)):{at:null,dock:null},o=r?Math.hypot(r.gb[0]-r.ga[0],r.gb[1]-r.ga[1]):0,s=r&&o>0?Math.hypot(r.b[0]-r.a[0],r.b[1]-r.a[1])/o:0,l=()=>{t.pickPoint(p=>{p&&K0(t).then(h=>{if(!h.at||!h.dock)return;let f={plan:[e.x,e.z],grid:h.dock},g=vg(f,{plan:p,grid:h.at},r?.mirror??!1);g.cal&&t.change(b=>{b.settings.vacuum_map=g.cal})})})},a=t.hass?ss(t.hass):null,c=t.hass?wg(t.hass,a):[],u=t.doc.floors.find(p=>p.furniture.some(h=>h.id===e.id)),d=()=>{if(!u)return;let p=kg(u.rooms,c,r?.mirror??!1);if(p.cal){let h=p.cal;t.change(f=>{f.settings.vacuum_map=h})}else alert(n(p.reason==="rooms"?"robot_cal_rooms_none":"robot_cal_rooms_bad",{n:p.matched.length}))};return ct(S(i.at&&i.dock?r?n("robot_cal_done",{m:s.toFixed(2)}):n("robot_cal_none"):n("robot_cal_need"),"nf-wide"),c.length>=2?m`${n("robot_cal_rooms",{n:c.length})} `:_,m`${n("robot_cal_do")} `,r?D(t,n("robot_cal_mirror"),!!r.mirror,p=>t.change(h=>{h.settings.vacuum_map={...r,mirror:p}})):_,r?j0(t,r):_,r?m`t.change(p=>{p.settings.vacuum_map=null})}>${n("robot_cal_forget")} `:_,S(n("robot_cal_hint"),"nf-wide"))}function U0(t,e,n){let r=t.t,i=t.doc;if(!i.energy.advanced)return _;let o=qn(i),s=i.floors.flatMap(l=>l.furniture.filter(a=>o.has(a.id)).map(a=>[a.id,`${a.name||r("furn_meter")} \xB7 ${l.name}`]));return ct(L(t,r("meter_parent"),si(i,e)??"",[["",r("meter_main")],...s],l=>n.update({parent_meter:l||null}),{wide:!0}),S(r("meter_device_hint"),"nf-wide"))}function Z0(t,e,n){let r=t.t,i=t.doc;if(!i.energy.advanced)return _;let o=i.floors.flatMap(c=>c.furniture.filter(u=>dh(i,e,u)).map(u=>[u.id,`${u.name||r("furn_meter")} \xB7 ${c.name}`])),s=!!gn(i,e),l=e.meter_floors??[],a=(c,u)=>n.update({meter_floors:u?[...l.filter(d=>d!==c),c]:l.filter(d=>d!==c)});return ct(L(t,r("meter_parent"),s?e.parent_meter:"",[["",r("meter_parent_none")],...o],c=>n.update({parent_meter:c||null}),{wide:!0}),s?D(t,r("energy_invert"),!!e.meter_invert,c=>n.update({meter_invert:c})):_,s?m`${r("meter_floors")}
${i.floors.map(c=>D(t,c.name,l.includes(c.id),u=>a(c.id,u)))}`:_,S(r("meter_sub_hint"),"nf-wide"))}function $g(t,e,n,r){let i=t.t,o=n==="mail"?s=>/^(binary_sensor|sensor|input_boolean)\./.test(s):s=>/^(sensor|binary_sensor|calendar)\./.test(s);return m`
+
`}function Z0(t,e){let n=t.t,r=t.doc.settings.vacuum_map??null,i=t.hass?Gl(t.hass,as(t.hass)):{at:null,dock:null},o=r?Math.hypot(r.gb[0]-r.ga[0],r.gb[1]-r.ga[1]):0,s=r&&o>0?Math.hypot(r.b[0]-r.a[0],r.b[1]-r.a[1])/o:0,l=()=>{t.pickPoint(p=>{p&&U0(t).then(h=>{if(!h.at||!h.dock)return;let f={plan:[e.x,e.z],grid:h.dock},g=kg(f,{plan:p,grid:h.at},r?.mirror??!1);g.cal&&t.change(b=>{b.settings.vacuum_map=g.cal})})})},a=t.hass?as(t.hass):null,c=t.hass?xg(t.hass,a):[],u=t.doc.floors.find(p=>p.furniture.some(h=>h.id===e.id)),d=()=>{if(!u)return;let p=$g(u.rooms,c,r?.mirror??!1);if(p.cal){let h=p.cal;t.change(f=>{f.settings.vacuum_map=h})}else alert(n(p.reason==="rooms"?"robot_cal_rooms_none":"robot_cal_rooms_bad",{n:p.matched.length}))};return ct(S(i.at&&i.dock?r?n("robot_cal_done",{m:s.toFixed(2)}):n("robot_cal_none"):n("robot_cal_need"),"nf-wide"),c.length>=2?m`${n("robot_cal_rooms",{n:c.length})} `:_,m`${n("robot_cal_do")} `,r?D(t,n("robot_cal_mirror"),!!r.mirror,p=>t.change(h=>{h.settings.vacuum_map={...r,mirror:p}})):_,r?G0(t,r):_,r?m`t.change(p=>{p.settings.vacuum_map=null})}>${n("robot_cal_forget")} `:_,S(n("robot_cal_hint"),"nf-wide"))}function q0(t,e,n){let r=t.t,i=t.doc;if(!i.energy.advanced)return _;let o=qn(i),s=i.floors.flatMap(l=>l.furniture.filter(a=>o.has(a.id)).map(a=>[a.id,`${a.name||r("furn_meter")} \xB7 ${l.name}`]));return ct(H(t,r("meter_parent"),ai(i,e)??"",[["",r("meter_main")],...s],l=>n.update({parent_meter:l||null}),{wide:!0}),S(r("meter_device_hint"),"nf-wide"))}function Y0(t,e,n){let r=t.t,i=t.doc;if(!i.energy.advanced)return _;let o=i.floors.flatMap(c=>c.furniture.filter(u=>hh(i,e,u)).map(u=>[u.id,`${u.name||r("furn_meter")} \xB7 ${c.name}`])),s=!!_n(i,e),l=e.meter_floors??[],a=(c,u)=>n.update({meter_floors:u?[...l.filter(d=>d!==c),c]:l.filter(d=>d!==c)});return ct(H(t,r("meter_parent"),s?e.parent_meter:"",[["",r("meter_parent_none")],...o],c=>n.update({parent_meter:c||null}),{wide:!0}),s?D(t,r("energy_invert"),!!e.meter_invert,c=>n.update({meter_invert:c})):_,s?m`${r("meter_floors")}
${i.floors.map(c=>D(t,c.name,l.includes(c.id),u=>a(c.id,u)))}`:_,S(r("meter_sub_hint"),"nf-wide"))}function Mg(t,e,n,r){let i=t.t,o=n==="mail"?s=>/^(binary_sensor|sensor|input_boolean)\./.test(s):s=>/^(sensor|binary_sensor|calendar)\./.test(s);return m`
${z(t,i(`care_entity_${n}`),e.care_entity??null,void 0,O(t.hass,o),s=>r.update({care_entity:Rt(s)}))}
${n==="plant"?E(t,i("care_thirsty_below"),e.thirsty_below??20,s=>r.update({thirsty_below:Math.min(90,Math.max(1,Math.round(s)))}),1,1):_}
${S(i(`care_hint_${n}`),"nf-wide")}
-
`}function Sg(t,e,n){let r=t.t;return m`
+
`}function Rg(t,e,n){let r=t.t;return m`
${z(t,r("furn_cover_entity"),e.cover_entity??null,void 0,O(t.hass,i=>i.startsWith("cover.")),i=>n.update({cover_entity:Rt(i)}),{types:[1,2],role:"cover"})}
${D(t,r("furn_cover_inverted"),!!e.cover_inverted,i=>n.update({cover_inverted:i||void 0}),{title:r("furn_cover_inverted_hint")})}
${S(r("furn_cover_hint"),"nf-wide")}
-
`}function Mg(t,e,n,r){let i=t.t,o=/socket/.test(e.type),s=O(t.hass,c=>/^(light|switch|input_boolean|fan)\./.test(c)),l=e.gang_entities??[],a=c=>u=>{let d=Array.from({length:n},(p,h)=>l[h]??null);d[c]=Rt(u),r.update({gang_entities:d})};return m`
+
`}function Eg(t,e,n,r){let i=t.t,o=/socket/.test(e.type),s=O(t.hass,c=>/^(light|switch|input_boolean|fan)\./.test(c)),l=e.gang_entities??[],a=c=>u=>{let d=Array.from({length:n},(p,h)=>l[h]??null);d[c]=Rt(u),r.update({gang_entities:d})};return m`
${Array.from({length:n},(c,u)=>z(t,n===1?i(o?"gang_socket_one":"gang_switch_one"):i(o?"gang_socket":"gang_switch",{n:u+1}),l[u]??null,void 0,s,a(u),{types:[0,1,2],role:"light"}))}
${S(i(o?"gang_socket_hint":"gang_switch_hint"),"nf-wide")}
-
`}function q0(t,e,n){let r=t.t,i=O(t.hass,o=>{let s=t.hass?.states[o]?.attributes;return o.startsWith("sensor.")&&(s?.device_class==="temperature"||s?.unit_of_measurement==="\xB0C"||s?.unit_of_measurement==="\xB0F")});return ct(z(t,r("fridge_temp"),e.temp_entity??null,void 0,i,o=>n.update({temp_entity:Rt(o)}),{types:[1,2]}),z(t,r("freezer_temp"),e.temp_entity2??null,void 0,i,o=>n.update({temp_entity2:Rt(o)}),{types:[1,2]}),S(r("fridge_temp_hint"),"nf-wide"))}function Y0(t,e,n){let r=t.t,i=O(t.hass,o=>{let s=t.hass?.states[o]?.attributes;return o.startsWith("sensor.")&&(s?.device_class==="temperature"||s?.unit_of_measurement==="\xB0C"||s?.unit_of_measurement==="\xB0F")});return ct(z(t,r("device_temp"),e.temp_entity??null,void 0,i,o=>n.update({temp_entity:Rt(o)}),{types:[1,2]}),S(r("device_temp_hint"),"nf-wide"))}function X0(t,e,n){let r=t.t,i=e.extra_lights??[],o=O(t.hass,a=>a.startsWith("light.")&&a!==e.entity&&a!==e.color_entity),s=a=>c=>{let u=[...i];c&&c!=="none"?u[a]=c:u.splice(a,1),n.update({extra_lights:u.filter(Boolean).length?u.filter(Boolean):void 0})},l=Math.min(4,i.length+1);return m`${Array.from({length:l},(a,c)=>z(t,r("lamp_extra_light",{n:c+2}),i[c]??null,void 0,o,s(c),{types:[0,1,2],role:"light"}))}${S(r("lamp_extra_hint"),"nf-wide")}`}function Rg(t,e,n){let{hass:r}=t;if(!r)return _;let i=t.t,o=ue(e.type),s=W0(e,r),l=O(r,b=>X(r)?He(r,b,[1,2]):Hn(r,b)),a=b=>y=>n.update({[b]:Rt(y)}),c=b=>O(r,b),u=(t.doc.settings.roof.strings??[]).filter(b=>b.inverter===e.id).map(b=>b.name),d=!!e.entity&&e.entity!=="none",p=as(t,e,"power"),h=e.power==="none"?null:e.power||p,f=e.type==="fridge_smart"?c(b=>b.startsWith("binary_sensor.")):[],g=e.type==="ceiling_fan"?"fan_hint":o?e.type==="lamp_pendant"?"lamp_hint_pendant":"lamp_hint":On(e.type)?"furn_links_hint_tv":e.type==="robot_vacuum"?"robot_hint":"furn_links_hint";return m`${ct(e.type==="grid_point"?S(i("grid_point_hint"),"nf-wide"):z(t,i(s.label),e.entity??null,as(t,e,"entity"),c(s.accept),b=>n.update({entity:b}),o?{types:[0,1,2],role:"light"}:{}),e.type==="ceiling_fan"?z(t,i("furn_fan_entity"),e.fan_entity??null,as(t,e,"fan"),c(b=>b.startsWith("fan.")),b=>n.update({fan_entity:b}),{types:[0,1,2]}):_,!o&&!Ke.includes(e.type)&&!Tr(e.type)?Gl(t,e,n):_,o&&d?m`${z(t,i("furn_color_entity"),e.color_entity??null,void 0,c(b=>b.startsWith("light.")&&b!==e.entity),a("color_entity"),{types:[0,1,2],role:"light"})}${S(i("furn_color_entity_hint"),"nf-wide")}`:_,o&&d?X0(t,e,n):_,o?an(t,e.glow_scale,b=>n.update({glow_scale:b})):_,o?is(t,e,fg(r,e,e.entity&&e.entity!=="none"?e.entity:as(t,e,"entity"))?.attributes.effect_list,n.update):_,Tr(e.type)?an(t,e.ambilight,b=>n.update({ambilight:b}),{label:"ambilight",hint:"ambilight_hint",lowest:0}):_,On(e.type)||co(e.type)?an(t,e.sound_rings,b=>n.update({sound_rings:b}),{label:"sound_rings",hint:"sound_rings_hint",lowest:0}):_,e.type==="grid_point"?_:m`${z(t,i(gn(t.doc,e)?"meter_sub_power":V0(e.type)),e.power??null,p,l,b=>n.update({power:b}),{types:[1,2]})}
- ${D(t,i("furniture_power_card"),!!e.power_card,b=>n.update({power_card:b||void 0}))}${S(i("furniture_power_card_hint"),"nf-wide")}`)}
- ${od(e.type)?q0(t,e,n):o||e.type==="grid_point"?_:Y0(t,e,n)}
- ${e.type==="meter"?Z0(t,e,n):_}
- ${e.type==="inverter"||e.type==="home_battery"?U0(t,e,n):_}
- ${e.type==="meter"&&!gn(t.doc,e)?ct(z(t,i("furn_export"),e.export??null,void 0,l,a("export"),{types:[1,2]}),S(i("furn_export_hint"),"nf-wide")):_}
+ `}function X0(t,e,n){let r=t.t,i=O(t.hass,o=>{let s=t.hass?.states[o]?.attributes;return o.startsWith("sensor.")&&(s?.device_class==="temperature"||s?.unit_of_measurement==="\xB0C"||s?.unit_of_measurement==="\xB0F")});return ct(z(t,r("fridge_temp"),e.temp_entity??null,void 0,i,o=>n.update({temp_entity:Rt(o)}),{types:[1,2]}),z(t,r("freezer_temp"),e.temp_entity2??null,void 0,i,o=>n.update({temp_entity2:Rt(o)}),{types:[1,2]}),S(r("fridge_temp_hint"),"nf-wide"))}function J0(t,e,n){let r=t.t,i=O(t.hass,o=>{let s=t.hass?.states[o]?.attributes;return o.startsWith("sensor.")&&(s?.device_class==="temperature"||s?.unit_of_measurement==="\xB0C"||s?.unit_of_measurement==="\xB0F")});return ct(z(t,r("device_temp"),e.temp_entity??null,void 0,i,o=>n.update({temp_entity:Rt(o)}),{types:[1,2]}),S(r("device_temp_hint"),"nf-wide"))}function Q0(t,e,n){let r=t.t,i=e.extra_lights??[],o=O(t.hass,a=>a.startsWith("light.")&&a!==e.entity&&a!==e.color_entity),s=a=>c=>{let u=[...i];c&&c!=="none"?u[a]=c:u.splice(a,1),n.update({extra_lights:u.filter(Boolean).length?u.filter(Boolean):void 0})},l=Math.min(4,i.length+1);return m`${Array.from({length:l},(a,c)=>z(t,r("lamp_extra_light",{n:c+2}),i[c]??null,void 0,o,s(c),{types:[0,1,2],role:"light"}))}${S(r("lamp_extra_hint"),"nf-wide")}`}function Ag(t,e,n){let{hass:r}=t;if(!r)return _;let i=t.t,o=ue(e.type),s=K0(e,r),l=O(r,b=>X(r)?He(r,b,[1,2]):Hn(r,b)),a=b=>y=>n.update({[b]:Rt(y)}),c=b=>O(r,b),u=(t.doc.settings.roof.strings??[]).filter(b=>b.inverter===e.id).map(b=>b.name),d=!!e.entity&&e.entity!=="none",p=ls(t,e,"power"),h=e.power==="none"?null:e.power||p,f=e.type==="fridge_smart"?c(b=>b.startsWith("binary_sensor.")):[],g=e.type==="ceiling_fan"?"fan_hint":o?e.type==="lamp_pendant"?"lamp_hint_pendant":"lamp_hint":On(e.type)?"furn_links_hint_tv":e.type==="robot_vacuum"?"robot_hint":"furn_links_hint";return m`${ct(e.type==="grid_point"?S(i("grid_point_hint"),"nf-wide"):z(t,i(s.label),e.entity??null,ls(t,e,"entity"),c(s.accept),b=>n.update({entity:b}),o?{types:[0,1,2],role:"light"}:{}),e.type==="ceiling_fan"?z(t,i("furn_fan_entity"),e.fan_entity??null,ls(t,e,"fan"),c(b=>b.startsWith("fan.")),b=>n.update({fan_entity:b}),{types:[0,1,2]}):_,!o&&!Ke.includes(e.type)&&!zr(e.type)?Zl(t,e,n):_,o&&d?m`${z(t,i("furn_color_entity"),e.color_entity??null,void 0,c(b=>b.startsWith("light.")&&b!==e.entity),a("color_entity"),{types:[0,1,2],role:"light"})}${S(i("furn_color_entity_hint"),"nf-wide")}`:_,o&&d?Q0(t,e,n):_,o?ln(t,e.glow_scale,b=>n.update({glow_scale:b})):_,o?os(t,e,mg(r,e,e.entity&&e.entity!=="none"?e.entity:ls(t,e,"entity"))?.attributes.effect_list,n.update):_,zr(e.type)?ln(t,e.ambilight,b=>n.update({ambilight:b}),{label:"ambilight",hint:"ambilight_hint",lowest:0}):_,On(e.type)||uo(e.type)?ln(t,e.sound_rings,b=>n.update({sound_rings:b}),{label:"sound_rings",hint:"sound_rings_hint",lowest:0}):_,e.type==="grid_point"?_:m`${z(t,i(_n(t.doc,e)?"meter_sub_power":j0(e.type)),e.power??null,p,l,b=>n.update({power:b}),{types:[1,2]})}
+ ${D(t,i(sr(e.type)?"charging_card":"furniture_power_card"),!!e.power_card,b=>n.update({power_card:b||void 0}))}${S(i(sr(e.type)?"charging_hint":"furniture_power_card_hint"),"nf-wide")}`)}
+ ${sd(e.type)?X0(t,e,n):o||e.type==="grid_point"?_:J0(t,e,n)}
+ ${e.type==="meter"?Y0(t,e,n):_}
+ ${e.type==="inverter"||e.type==="home_battery"?q0(t,e,n):_}
+ ${e.type==="meter"&&!_n(t.doc,e)?ct(z(t,i("furn_export"),e.export??null,void 0,l,a("export"),{types:[1,2]}),S(i("furn_export_hint"),"nf-wide")):_}
${e.type==="inverter"&&(t.doc.settings.roof.solar??[]).length>0?S(u.length>0?i("inverter_strings",{names:u.join(", ")}):i("inverter_strings_none"),"nf-wide"):_}
${e.type==="home_battery"?ct(z(t,i("furn_soc"),e.soc??null,void 0,c(b=>me(b)&&(r.states[b]?.attributes.device_class==="battery"||r.states[b]?.attributes.unit_of_measurement==="%")),a("soc"),{types:[1,2]}),z(t,i("furn_charge"),e.charge??null,void 0,l,a("charge"),{types:[1,2]}),S(i("furn_charge_hint"),"nf-wide")):_}
- ${e.type==="wallbox"?ct(z(t,i("furn_wallbox_status"),e.status??null,void 0,c(b=>uo(b)||me(b)),a("status"))):_}
+ ${sr(e.type)?ct(z(t,i("furn_wallbox_status"),e.status??null,void 0,c(b=>ho(b)||me(b)),a("status"),{types:[0,1,2,3]})):_}
+ ${gg(t,e,n.update)}
${!o||d||h?m`${D(t,i("device_confirm"),!!e.confirm,b=>n.update({confirm:b}),{title:i("device_confirm_hint")})}
- ${Nn(t,e.marker??null,b=>n.update({marker:b}))}${Ct(t,e.icon,b=>n.update({icon:b}))}${o?_:Nt(t,e.pin_offset,b=>n.update({pin_offset:b}))}
`:_}
- ${e.type==="robot_vacuum"?ct(z(t,i("furn_robot_room"),e.room_sensor??null,cd(r,Me(r,t.doc.floors).get(e.id)?.entity??null,null),c(me),b=>n.update({room_sensor:b}),{types:[1,2]})):_}
- ${e.type==="robot_vacuum"&&d?G0(t,e):_}
+ ${Nn(t,e.marker??null,b=>n.update({marker:b}))}${Nt(t,e.icon,b=>n.update({icon:b}))}${o?_:Bt(t,e.pin_offset,b=>n.update({pin_offset:b}))}
`:_}
+ ${e.type==="robot_vacuum"?ct(z(t,i("furn_robot_room"),e.room_sensor??null,ud(r,Me(r,t.doc.floors).get(e.id)?.entity??null,null),c(me),b=>n.update({room_sensor:b}),{types:[1,2]})):_}
+ ${e.type==="robot_vacuum"&&d?Z0(t,e):_}
${e.type==="fridge_smart"?m`${ct(z(t,i("furn_door_left"),e.door_left??null,void 0,f,b=>n.update({door_left:b}),{types:[0]}),z(t,i("furn_door_right"),e.door_right??null,void 0,f,b=>n.update({door_right:b}),{types:[0]}))}
${S(i("fridge_hint"))}`:_}
${or(t,e.values,b=>n.update({values:b}))}
- ${S(i(g))}`}var J0=/^(binary_sensor|device_tracker|input_boolean|switch|sensor)\./,Q0=/^(sensor|input_select|select|input_text)\./,ek=/^(device_tracker|sensor|binary_sensor|lock|climate)\./,tk=(t,e)=>t.flatMap(n=>n.items.filter(r=>r.vehicle).map(r=>({id:he(n.id,r.id),label:`${Je(r,he(n.id,r.id),e)} \xB7 ${Be(n,e)}`})));function Eg(t,e){return e.startsWith("device_tracker.")?t.hass?.states[e]?.attributes.source_type==="router"?2:0:1}function Ag(t,e,n,r){return m`r(i.target.value||null)}>
+ ${S(i(g))}`}var ek=/^(binary_sensor|device_tracker|input_boolean|switch|sensor)\./,tk=/^(sensor|input_select|select|input_text)\./,nk=/^(device_tracker|sensor|binary_sensor|lock|climate)\./,rk=(t,e)=>t.flatMap(n=>n.items.filter(r=>r.vehicle).map(r=>({id:he(n.id,r.id),label:`${Je(r,he(n.id,r.id),e)} \xB7 ${Be(n,e)}`})));function Fg(t,e){return e.startsWith("device_tracker.")?t.hass?.states[e]?.attributes.source_type==="router"?2:0:1}function Tg(t,e,n,r){return m`r(i.target.value||null)}>
${t.t("parking_vehicle_none")}
${e.map(i=>m`${i.label} `)}
- `}function nk(t,e,n,r){let i=t.t,o=e.type_entity?t.hass?.states[e.type_entity]:void 0,s=Array.isArray(o?.attributes.options)?o.attributes.options:[],l=e.types??[],a=u=>r.update({types:u}),c=(u,d)=>a(l.map((p,h)=>h===u?{...p,...d}:p));return m`
+ `}function ik(t,e,n,r){let i=t.t,o=e.type_entity?t.hass?.states[e.type_entity]:void 0,s=Array.isArray(o?.attributes.options)?o.attributes.options:[],l=e.types??[],a=u=>r.update({types:u}),c=(u,d)=>a(l.map((p,h)=>h===u?{...p,...d}:p));return m`
${i("parking_types")}
${l.map((u,d)=>m`
c(d,{state:p.target.value})} />
- ${Ag(t,n,u.vehicle,p=>c(d,{vehicle:p??""}))}
+ ${Tg(t,n,u.vehicle,p=>c(d,{vehicle:p??""}))}
a(l.filter((p,h)=>h!==d))}>✕
`)}
${s.map(u=>m` `)}
${t.admin?m`
a([...l,{state:s[l.length]??"",vehicle:n[0]?.id??""}])}>${i("parking_add_type")} `:_}
-
`}function Fg(t,e,n,r){let i=t.t,o=tk(n,t.hass?.language??"en"),s=O(t.hass,f=>J0.test(f)).sort((f,g)=>Eg(t,f.id)-Eg(t,g.id)),l=O(t.hass,f=>Q0.test(f)),a=e.car??{},c=t.floor,u=c?.rooms.find(f=>f.points.length>=3&&C([e.x,e.z],f.points)),d=e.vehicle?U(e.vehicle):void 0,p=d?d.size[2]*(e.scale??1):0,h=!!u&&!!c&&p>c.height+1e-6;return m`
+
`}function zg(t,e,n,r){let i=t.t,o=rk(n,t.hass?.language??"en"),s=O(t.hass,f=>ek.test(f)).sort((f,g)=>Fg(t,f.id)-Fg(t,g.id)),l=O(t.hass,f=>tk.test(f)),a=e.car??{},c=t.floor,u=c?.rooms.find(f=>f.points.length>=3&&C([e.x,e.z],f.points)),d=e.vehicle?G(e.vehicle):void 0,p=d?d.size[2]*(e.scale??1):0,h=!!u&&!!c&&p>c.height+1e-6;return m`
${z(t,i("parking_entity"),e.entity??null,void 0,s,f=>r.update({entity:f==="none"?null:f}))}
- ${i("parking_vehicle")} ${Ag(t,o,e.vehicle??null,f=>r.update({vehicle:f}))}
+ ${i("parking_vehicle")} ${Tg(t,o,e.vehicle??null,f=>r.update({vehicle:f}))}
${o.length>0?_:S(i("parking_no_pack"),"nf-wide")}
${E(t,i("parking_scale"),Math.round((e.scale??1)*100),f=>r.update({scale:Math.min(150,Math.max(30,f))/100}),5,30)}
${z(t,i("parking_type_entity"),e.type_entity??null,void 0,l,f=>r.update({type_entity:f==="none"?null:f}))}
- ${e.type_entity?nk(t,e,o,r):_}
+ ${e.type_entity?ik(t,e,o,r):_}
${h?m`
${i("parking_too_tall",{car:K(t.hass,p,2),room:K(t.hass,c.height,2)})}
`:_}
${S(i("parking_hint"))}
- ${t.hass?m`${z(t,i("live_car_device"),a.device??null,null,O(t.hass,f=>ek.test(f)),f=>r.update({car:{...a,device:f}}))}
+ ${t.hass?m`${z(t,i("live_car_device"),a.device??null,null,O(t.hass,f=>nk.test(f)),f=>r.update({car:{...a,device:f}}))}
${S(i("live_car_device_hint"),"nf-wide")}
- ${z(t,i("live_car_departure_entity"),a.departure??null,void 0,O(t.hass,f=>/^(sensor|input_datetime|time|datetime)\./.test(f)),f=>r.update({car:{...a,departure:f==="none"?null:f}}))}`:_}`}function Tg(t,e){let r=vn(t,e.w,e.d,e.h).treads.findIndex(i=>i.landing);return r>=0?r+1:1}function rk(t){let e=vn(wi(t),t.w,t.d,t.h),n=e.treads.map(jo),r=0;for(let o=1;o
1?r/(n.length-1):0;return{rise:e.rise,going:i,measure:2*e.rise+i,steps:e.steps}}function ik(t){let[e,n]=ll[t],r=vn({..._t,shape:t},e,n,2.8),i=26/Math.max(e,n);return m`
+ ${z(t,i("live_car_departure_entity"),a.departure??null,void 0,O(t.hass,f=>/^(sensor|input_datetime|time|datetime)\./.test(f)),f=>r.update({car:{...a,departure:f==="none"?null:f}}))}`:_}`}function Pg(t,e){let r=wn(t,e.w,e.d,e.h).treads.findIndex(i=>i.landing);return r>=0?r+1:1}function ok(t){let e=wn(ki(t),t.w,t.d,t.h),n=e.treads.map(Uo),r=0;for(let o=1;o1?r/(n.length-1):0;return{rise:e.rise,going:i,measure:2*e.rise+i,steps:e.steps}}function sk(t){let[e,n]=ul[t],r=wn({..._t,shape:t},e,n,2.8),i=26/Math.max(e,n);return m`
${r.treads.map(o=>R``${s*i},${l*i}`).join(" ")} fill=${o.landing?"currentColor":"none"} fill-opacity="0.25" stroke="currentColor" stroke-width="0.8" />`)}
- `}function zg(t,e,n){let r=t.t,i=wi(e),o=f=>n.update({stair:{...i,...f}}),s=i.shape!=="straight",l=f=>{let[g,b]=ll[f];n.update({stair:{...i,shape:f,run_width:null},w:g,d:b})},a=t.floor?t.doc.floors.filter(f=>f.elevationg.elevation-f.elevation)[0]:void 0,c=t.floor?t.doc.floors.filter(f=>f.elevation>t.floor.elevation).sort((f,g)=>f.elevation-g.elevation)[0]:void 0,u=f=>{let g=f?a&&t.floor?t.floor.elevation-a.elevation:null:c&&t.floor?c.elevation-t.floor.elevation:null;n.update({stair:{...i,down:f},...g?{h:Math.round(g*1e3)/1e3}:{}})},d=rk(e),p=f=>K(t.hass,f*100,1),h=d.measure>=.59&&d.measure<=.65&&d.rise<=.21;return m`