0){i.textContent=Ri?Ri.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=Xt(this,e,n,0),s=!yr(e)||e!==this._$AH&&e!==et,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 $n(e.insertBefore(br(),o),o,void 0,n??{})}return i._$AI(t),i};var ms=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=kc(n,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return et}};Y._$litElement$=!0,Y.finalized=!0,ms.litElementHydrateSupport?.({LitElement:Y});var tb=ms.litElementPolyfillSupport;tb?.({LitElement:Y});(ms.litElementVersions??=[]).push("4.2.2");var _s=t=>t.slice(0,t.indexOf(".")),nb={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"},J=t=>nb[_s(t)]??null,bs=["light","cover","climate","media","switch","fan","lock","binary","sensor","scene","script"];var xc=new Set(["light","switch","fan"]),Et=t=>t!==null&&t!=="scene"&&t!=="script",tt=t=>!t||t.state==="unavailable"||t.state==="unknown"&&!t.entity_id.startsWith("event.");function W(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 $c=t=>!!t&&t.entity_id.startsWith("sensor.")&&t.attributes.device_class==="enum";var Sc=t=>Math.min(1,Math.max(0,t));function rb(t){let e=Sc((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 gs(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(Sc(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:rb(n.color_temp_kelvin),level:r}:{color:[1,.71,.28],level:r}}function Mc(t,e,n){let r=gs(t,n);if(r)return r;for(let i of e){let o=gs(i);if(o)return{color:o.color,level:o.level*.6}}return null}function Pi(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 Fc=[],Di=new Map,ib=0,he=(t,e)=>`pack:${t}:${e}`,vt=t=>t.startsWith("pack:");function ys(t){Fc=t,Di=new Map;for(let e of t)for(let n of e.items)Di.set(he(e.id,n.id),n);ib+=1}var kr=()=>Fc;var ob={};function U(t){if(!vt(t))return;let e=Di.get(t);if(e)return e;let[,n,...r]=t.split(":"),i=ob[n];return i?Di.get(he(i,r.join(":"))):void 0}var sb=.22;function Rc(t,e,n,r){let i=Math.min(sb,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 wr(t,e,n,r,i){return[Rc(t*r,n*r,r,i)/i,Rc(e*r,n*r,r,i)/i]}var Ec=new WeakMap;function Tc(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=Ec.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]=wr(d.x-d.w/2,d.x+d.w/2,-.5,i,e),[f,g]=wr(d.z-d.d/2,d.z+d.d/2,-.5,o,n),[b,y]=wr(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],[E,T]=wr(w-k/2,w+k/2,-.5,i,e),[F,O]=wr(x-M/2,x+M/2,-.5,o,n);Object.assign(v,{tx:(E+T)/2,tz:(F+O)/2,tw:T-E,td:O-F})}return v});return a||Ec.set(t,a=new Map),a.size>32&&a.clear(),a.set(l,u),u}var vs=t=>!!t?.parts.some(e=>e.move);var zc=t=>U(t)?.parts.find(e=>e.screen),Ac=.06;function Pc(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>=Ac&&s>=Ac})}function dt(t){return nt[t]??U(t)?.size??[.6,.6,.8]}function At(t){let e=U(t);return Bc.has(t)||!!e?.electric||!!e?.light||!!e?.climate}var Dc=t=>!!U(t)?.parts.some(e=>e.picture),Sn=t=>!!U(t)?.climate;function Ic(t,e){return t.name[e.split("-")[0]]??t.name.en??Object.values(t.name)[0]??t.id}var ab={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 Oc(t,e){if(e.split("-")[0]==="de")return t.name;let n=/^nextfloor\.(.+)$/.exec(t.id)?.[1];return n&&ab[n]||t.name}function Ft(t,e){return e.mount_y!=null?e.mount_y:cb(t,e)+(lb(e)?0:Cc(t,e.x,e.z))}var lb=t=>t.type==="led_strip"||U(t.type)?.mount==="ceiling";function cb(t,e){if(e.type==="lamp_wall")return Hc;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 Lc(e);switch(n.mount){case"surface":return Nc(t,e.x,e.z);case"wall":return n.wall_y??1;case"ceiling":return Math.max(0,Ii(t,e)-e.h);default:return 0}}function ws(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 Mn=["electricity","water","gas","heating","cooling"],Wc=["condition","temperature","humidity","pressure","wind_speed","wind_gust_speed","wind_bearing","cloud_coverage","precipitation","precipitation_total","illuminance","uv_index","visibility","snow","fog","lightning"],Vc=["turn","slide","top"],Kc=["always","active","no_power","never"],jc=1.3,Oi=(t,e=new Date().toISOString().slice(0,10))=>!!t.due&&t.due<=e,Gc=["gable","hip","halfhip","pyramid","mansard","pent","flat","parapet"],Uc=["brick","round","wide","steel"],Hi=["navigate","more_info","service","fire_dom_event"];function Li(t,e,n){return t?e?!!n.lock_plan:!!t.locked:!1}var Zc=["rain","snow","fog","clouds","lightning","sky"],qc=["rain","snow","clouds","lightning","sky"],Yc=["lawn","terrace","path","driveway","pool","bed","wild","hedge","fence","pergola"],ks={lawn:.012,terrace:.12,path:.02,driveway:.02,pool:-.25,bed:.15,wild:.03,hedge:1.2,fence:1,pergola:2.2};function xs(t){return t==="hedge"||t==="fence"||t==="pergola"}var Xc=["x","-x","z","-z"];function ub(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 db(t,e,n,r){return Jc(t)+(e.offset??0)+ks[e.type]-ub(e,n,r)}function Jc(t){return t.elevation>.3?0:-.2}function Qc(t,e,n){let r=(t.outdoor??[]).filter(o=>!xs(o.type)&&o.type!=="pool"&&N([e,n],o.points)),i=[...r].reverse().find(o=>o.cut)??r[0];return i?db(t,i,e,n):Jc(t)}var eu=t=>t.cut??t.type==="pool",tu=30,nu={meter:null,grid:null,grid_invert:!1,solar:null,battery:null,battery_invert:!1,battery_soc:null,consumption:null,tariff:null},ru=["wood","oak","tiles","carpet","stone","concrete"],iu={type:"none",pitch:35,overhang:.4},Ci="#d6cfc2",Ni="#e8e3da",ou={wall_exterior:.24,wall_interior:.12,grid:.05,north:0,roof:{...iu}};function Tt(){return{version:1,floors:[],settings:{...ou},energy:{...nu},presence:[]}}function Ce(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 hb=2.75;function su(t,e){if(e!=null&&Number.isFinite(e))return Math.round(e*hb*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 au(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 lu(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 Bi=["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","stairwell"],cu={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"],vehicles:["parking"]},Ne=["meter","inverter","home_battery","wallbox","grid_point"],uu=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"]),Hc=1.75;function Wi(t){return $s.has(t.type)||["stairwell","parking"].includes(t.type)?!1:U(t.type)?.mount!=="ceiling"}function ue(t){return uu.has(t)||!!U(t)?.light}var pb=new Set(["table","table_round","coffee_table","desk","nightstand","sideboard","dresser","kitchen","island","worktop","tv_board","dishwasher","washer","dryer"]);function du(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 Lc(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 $s=new Set(["lamp_ceiling","lamp_downlight","lamp_spot","lamp_panel","lamp_pendant","ceiling_fan"]);function hu(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 Ss=t=>t?.floor_offset&&Number.isFinite(t.floor_offset)?t.floor_offset:0;function Cc(t,e,n){let r=t.rooms.find(i=>i.points.length>=3&&i.floor_offset&&N([e,n],i.points));return Ss(r)}function ht(t,e,n){let r=t.rooms.find(i=>i.points.length>=3&&N([e,n],i.points));return r?.ceiling!=null&&r.ceiling>0?r.ceiling:t.height}var Ii=(t,e)=>e.ceiling_y!=null&&e.ceiling_y>0?e.ceiling_y:ht(t,e.x,e.z);function Nc(t,e,n){let r=0;for(let i of t.furniture)!(pb.has(i.type)||U(i.type)?.surface)||!N([e,n],As(i))||(r=Math.max(r,i.h));return r}var Bc=new Set([...uu,"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],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 Ms=["interior","front","front_glass","sidelight","sidelights","glass","sliding","passage"],Rs=["standard","bars","glass_wall"],Vi=new Set(["interior","front"]);function Qt(t,e){return t.type==="door"?t.style&&Ms.includes(t.style)?t.style:e?"front":"interior":t.style&&Rs.includes(t.style)?t.style:"standard"}function pu(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 Es(t){return t==="front"||t==="front_glass"||t==="sidelight"||t==="sidelights"}var En={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 An(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&&Es(t.style)?"front":e?"door_double":"door":t.sill<.1?e?"terrace_double":"terrace":e?"window_double":"window"}function Pe(t){t.energy={...nu,...t.energy??{}},t.presence=t.presence??[],t.version=1,t.settings={...ou,...t.settings,roof:{...iu,...t.settings?.roof??{}}},t.floors.forEach((e,n)=>{let r=Ce(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=D(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=D("room"));e(n.openings,"op"),e(n.furniture,"furn"),e(n.outdoor,"out")}}function D(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 As(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 N(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 Ki={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 Fs=t=>t.trim().replace(/^\/local\/www\//i,"/local/"),Ts=t=>/^(https:\/\/|\/local\/|\/hacsfiles\/)\S+\.m?js(\?\S*)?$/i.test(t.trim());var gb=globalThis,mu=gb.__nextfloorPluginStore??={plugins:new Map,listeners:new Set},zs=mu.plugins,fu=mu.listeners;var _b=5;function gu(t,e){t.errors.length<_b&&t.errors.push(e instanceof Error?e.message:String(e))}function ji(t){return fu.add(t),()=>fu.delete(t)}var Ps=()=>[...zs.values()].map(t=>t.status),_u=()=>[...zs.values()].flatMap(t=>Object.keys(t.plugin.lightAnimations??{}));function*Gi(t,e){for(let{plugin:n,status:r}of zs.values())for(let i of n.devices??[]){let o=!1;try{o=i.match(t,e)}catch(s){gu(r,s)}o&&(yield{device:i,status:r})}}function Ui(t,e){for(let{device:n}of Gi(t,e))return n.kind??"sensor";return null}function bu(t,e){let n=t.states[e];if(!n)return null;let r=bb({hass:t,entityId:e,state:n})?.icon?.trim();return r&&/^mdi:[a-z0-9-]+$/i.test(r)?r:null}function bb(t){let e=null;for(let{device:n,status:r}of Gi(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){gu(r,i)}return e}function Zi(t,e){return t?typeof t=="string"?t:t[e]??t[e.split("-")[0]]??t.en??Object.values(t)[0]??"":""}function yu(t,e){let n=[];for(let{device:r,status:i}of Gi(t,e))r.settings?.length&&n.push({pluginId:i.id,name:i.name,settings:r.settings});return n}function vu(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 wu(t,e){for(let{device:n}of Gi(t,e))if(n.floorWedge)return!0;return!1}var yb=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"]),vb=new Set(["m\xB3","m3","L","l","kWh","Wh","MWh","lx"]),wb=new Set(["door","window","opening","garage_door","motion","occupancy","presence","smoke","moisture","gas","carbon_monoxide"]),kb=new Set(["battery","signal_strength","timestamp","date","duration","data_rate","data_size","frequency","enum"]);function zt(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 xu=(t,e)=>{let n=t.entities?.[e];return!!(n?.hidden||n?.entity_category)},Be=(t,e)=>J(e)??Ui(e,t.states[e]);function ku(t,e){let n=t.states[e];if(!n||xu(t,e))return!1;if(Ui(e,n)!==null)return!0;let r=J(e);if(!r)return!1;let i=n.attributes.device_class;return e.startsWith("event.")?!i||i==="button"||i==="doorbell":r==="sensor"?i?yb.has(i):vb.has(String(n.attributes.unit_of_measurement??"")):r==="binary"?i?wb.has(i):!!t.entities?.[e]?.area_id:!0}function xb(t,e){let n=t.states[e];return J(e)!=="sensor"||!n?.attributes.unit_of_measurement||xu(t,e)||kb.has(String(n.attributes.device_class??""))?!1:Number.isFinite(Number(n.state))||tt(n)}var Yi=(t,e)=>e.startsWith("sensor.")&&t.states[e]?.attributes.device_class==="power",Ds=null;ji(()=>Ds=null);function Is(t,e){let n=t.get(e);return n||t.set(e,n=[]),n}function $b(t){let e=new Map,n=new Map,r=new Map,i=new Map,o=[],s=u=>{(ku(t,u)||xb(t,u))&&Et(Be(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&&Yi(t,u)&&Is(n,p).push(u),p&&!d.hidden&&!d.entity_category&&(r.get(p)??r.set(p,new Set).get(p)).add(_s(u));let h=zt(t,u);h===null?s(u):ku(t,u)&&Is(e,h).push(u)}if(t.entities)for(let u of Object.keys(t.states))t.entities[u]||s(u);let l=bs.indexOf("binary")-.5,a=u=>{let d=J(u),p=d?bs.indexOf(d):l;return p>l&&Ui(u,t.states[u])!==null?l:p};o.sort((u,d)=>a(u)-a(d)||W(t,u).localeCompare(W(t,d)));for(let[u,d]of e){let p=t.areas?.[u]?.name;d.sort((h,f)=>a(h)-a(f)||W(t,h,p).localeCompare(W(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 Tn(t){let e=Ds;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:Ds=$b(t)}function ye(t,e){let n=qi(t,e.area_id);return e.sub_areas?.length?[...new Set([...n,...e.sub_areas.flatMap(r=>qi(t,r))])]:n}function qi(t,e){return!e||!t.entities?[]:Tn(t).byArea.get(e)??[]}function $u(t,e){if(!t.entities)return[];let n=[];for(let[r,i]of Tn(t).byArea){let o=i.filter(s=>Et(Be(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 Su=t=>t.entities?Tn(t).withoutArea:[],Os=(t,e)=>!!t.entities&&Tn(t).hubs.has(e),Xi=(t,e)=>t.entities?Tn(t).powerByDevice.get(e)??[]:[];function zn(t,e){let n=new Map;for(let i of e)Is(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 Ji=(t,e)=>zn(t,e).map(n=>n.primary),Sb={temperature:"temperature",humidity:"humidity",co2:"carbon_dioxide",illuminance:"illuminance"};function Hs(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===Sb[n]}var Mb=new Set(["climate","water_heater","switch","button","camera","media_player","vacuum","light","fan","lawn_mower"]),Rb=["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"],Eb=new RegExp(`(${Rb.join("|")})`,"i");function Ls(t,e){let n=t.entities?.[e]?.device_id,r=n&&!Os(t,n)?Tn(t).domainsByDevice.get(n):void 0;return r&&[...r].some(i=>Mb.has(i))?!1:!Eb.test(`${e} ${t.states[e]?.attributes.friendly_name??""}`)}function Mu(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=>N([c.x,c.z],n.points)).map(c=>c.entity_id),l=new Set(o.filter(c=>!N([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.")&&Hs(t,c,r)&&Ls(t,c))}function Ru(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 Qi(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 eo(t,e){let n=e?t.states[e]:void 0;if(!n||tt(n))return null;let r=n.attributes;if(r.nf_cover_control&&typeof r.current_position=="number")return r.current_position;let i=Ru(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 Ab=new Set([void 0,"shutter","blind","awning","shade","curtain","window"]),Fb=new Set(["garage","gate"]),Tb=new Set(["window","opening"]);function xr(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 Eu=(t,e)=>t==="none"?null:t??e??null,Pt=t=>t&&t!=="none"?t:null;function Dt(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=>J(b)==="binary"&&g(l(b)??"")),c=g=>o.filter(b=>b.type===g),u=xr(c("window"),s.filter(g=>J(g)==="cover"&&Ab.has(l(g))),!0),d=xr(c("window"),a(g=>Tb.has(g))),p=xr(c("door"),a(g=>g==="door")),h=xr(c("garage"),s.filter(g=>J(g)==="cover"&&Fb.has(l(g)??""))),f=xr(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:Eu(g.cover,b?.get(g.id)),contact:g.sensor==="handle"&&g.contact==null?null:Eu(g.contact,y.get(g.id)),tilt:g.tilt==="none"?null:g.tilt,contact2:v?Pt(g.contact2):null,tilt2:v?Pt(g.tilt2):null,position:Pt(g.position),positionInverted:!!g.position_inverted,tiltAngle:Pt(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"?Pt(g.lock):null,cover2:g.type==="garage"?null:Pt(g.cover2),coverTilt:Pt(g.cover_tilt),cover2Tilt:Pt(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 Cs(t){if(!t||tt(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 Au=new WeakMap,Fu=new WeakMap;function Tu(t,e){let n=Fu.get(t)??t,r=Au.get(n)??new WeakMap;Au.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 Dt(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=eo(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?eo(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 Fu.set(l,n),r.set(e,l),l}var re=t=>t?.symconObjects!==void 0;function We(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 Pn(t){return!t||t.state==="unknown"||t.state==="unavailable"?null:t.attributes.symcon_value??t.attributes.symcon_numeric_value??t.state}function en(t){let e=Pn(t);if(e===null||typeof e=="boolean"||e==="")return null;let n=Number(e);return Number.isFinite(n)?n:null}function $r(t){let e=Pn(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 zu(t){return Pn(t)===null?"\u2013":String(t?.attributes.symcon_formatted??Pn(t))}function Pu(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 Du="weather.nextfloor_symcon",Ou={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"},Iu=new WeakMap;function Pb(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 Hu(t,e){if(!re(t))return t;let n=e.weather_variables??{};if(!e.rain_sensor&&!Object.values(n).some(h=>h&&h!=="none"))return t;let r=Iu.get(t)??new WeakMap;Iu.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=en(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=en(f);g!==null&&(o[h]=Pu(g,f?.attributes.unit_of_measurement))}o.wind_speed_unit="km/h";let l=Pn(s("wind_bearing"));l!==null&&(o.wind_bearing=l);let a=Pb(zu(s("condition"))),c=e.rain_sensor?t.states[e.rain_sensor]:void 0,u=$r(c);u!==null&&e.rain_sensor_inverted&&(u=!u),u===null&&typeof o.precipitation=="number"&&(u=o.precipitation>0),$r(s("lightning"))?a=u?"lightning-rainy":"lightning":$r(s("snow"))?a=u?"snowy-rainy":"snowy":$r(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:Du,state:a??"unknown",attributes:o},p={...t,states:{...t.states,[Du]:d}};return r.set(e,p),p}var Dn={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},tn=t=>(...e)=>({_$litDirective$:t,values:e}),It=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 Sr=class extends It{constructor(e){if(super(e),this.it=_,e.type!==Dn.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===et)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:[]}}};Sr.directiveName="unsafeHTML",Sr.resultType=1;var Lu=tn(Sr);var Cu=/\b(tv|fernseh|television|fire ?tv|apple ?tv|chromecast|shield)/i,Nu=/(kühl|fridge|gefrier|freezer)/i,Bu=/(spülmaschine|geschirrspül|dishwasher)/i,Db=/(kochfeld|herd|induktion|cooktop)/i,Ib={robot_vacuum:/(saug|vacuum|robo|roomba|roborock|dreame|ecovacs|deebot)/i,tv_board:Cu,tv_wall:Cu,desk:/\b(pc|computer|rechner|desktop|monitor|workstation)/i,fridge:Nu,fridge_smart:Nu,stove:/(herd|kochfeld|cooktop|stove|induktion)/i,kitchen_tall:/(backofen|oven|ofen)/i,dishwasher:Bu,washer:/(waschmaschine|washer|washing)/i,dryer:/(trockner|dryer)/i,kitchen:/(kaffee|coffee|wasserkocher|kettle)/i,island:Db,sink:Bu,radiator:/(heiz|radiator|thermostat|climate|hk|trv)/i},Wu={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},Vu=new Set(["tv_board","tv_wall"]);var In=t=>Vu.has(t)||!!zc(t),to=t=>!!U(t)?.electric&&/speaker|multiroom|soundbar/.test(t.split(":").pop()??t),Rr=t=>In(t)||t==="desk"||t==="fridge_smart",Ob=t=>!!t&&t!=="none";function Hb(t,e){if(Yi(t,e))return e;let n=t.entities?.[e]?.device_id;return n?Xi(t,n).find(r=>r!==e)??null:null}var Lb=(t,e,n)=>t.rooms.find(r=>r.points.length>=3&&N([e,n],r.points));function Mr(t,e,n,r){return t.find(i=>e?.test(n(i)))??(r?t[0]??null:null)}function Ve(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(Ob));for(let o of r.furniture){let s=o.type in Wu,l=Sn(o.type),a=s?Wu[o.type]:Ib[o.type];if(!a&&!l&&!to(o.type)&&o.entity==null&&o.power==null)continue;let c=Lb(r,o.x,o.z),u=(c?Ji(t,ye(t,c)):[]).filter(b=>!i.has(b)),d=b=>`${b} ${W(t,b)}`,p=b=>u.filter(y=>J(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=>J(v)==="fan").map(v=>t.entities?.[v]?.device_id).filter(Boolean));h=b.find(v=>J(v)==="light"&&y.has(t.entities?.[v]?.device_id))??Mr(p("light"),a,d,!1)}else if(s)h=Mr(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)&&zt(t,y)===b)??null}else if(o.type==="radiator"||l)h=Mr(p("climate"),a,d,!0);else if(In(o.type)){let b=p("media");h=b.find(y=>t.states[y]?.attributes.device_class==="tv")??Mr(b,a,d,Vu.has(o.type))}else if(to(o.type)){let b=p("media").filter(y=>t.states[y]?.attributes.device_class!=="tv");h=Mr(b,a,d,!1)??(b.length===1?b[0]:null)}else a&&(h=u.find(b=>["switch","media","fan"].includes(J(b)??"")&&a.test(d(b)))??null);h&&i.add(h)}let f=o.power==="none"?null:o.power??null;o.power==null&&(f=h?Hb(t,h):null,!f&&a&&c&&!s&&(f=ye(t,c).find(b=>Yi(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=>J(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 Ku=t=>t==="fridge"||t==="fridge_smart"||/(fridge|freezer|kuehl|gefrier|chest_freezer)/.test(t.slice(t.lastIndexOf(":")+1));function ju(t,e,n=[]){let r=[];for(let i of e){let o=(l,a)=>i.rooms.some(c=>c.points.length>=3&&N([l,a],c.points)),s=Ve(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(...Ji(t,qi(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 Cb(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 Uu(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=J(y)==="light",w=g[0].at,x=-1/0;for(let{at:M,wallDistance:E}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]),O=Math.min(T,3)*2;Fx+1e-9&&(x=O,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 Gu=/(^|_)(current_room|current_segment|aktueller_raum|current_area)($|_)/;function Zu(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.")&&(Gu.test(o.translation_key??"")||Gu.test(o.entity_id.split(".")[1])))?.entity_id??null}var me=t=>/^(sensor|input_number|number)\./.test(t),no=t=>/^(binary_sensor|input_boolean)\./.test(t);function On(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 Nb(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 H(t,e){return Object.keys(t?.states??{}).filter(e).map(n=>{let r=Nb(t,n),i=t?.states[n],o=typeof i?.attributes.symcon_path=="string"?i.attributes.symcon_path:void 0,s={id:n,label:r?`${W(t,n)} \xB7 ${r}`:W(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 qu(t,e,n){return e.unsupported?[]:H(t,r=>We(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 ro(t,e){return t.power&&t.power!=="none"?t.power:e.get(t.id)?.power??null}var ve=Q`
+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 Si=globalThis,Mi=Si.ShadowRoot&&(Si.ShadyCSS===void 0||Si.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,us=Symbol(),lc=new WeakMap,gr=class{constructor(e,n,r){if(this._$cssResult$=!0,r!==us)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(Mi&&e===void 0){let r=n!==void 0&&n.length===1;r&&(e=lc.get(n)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),r&&lc.set(n,e))}return e}toString(){return this.cssText}},cc=t=>new gr(typeof t=="string"?t:t+"",void 0,us),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 gr(n,t,us)},uc=(t,e)=>{if(Mi)t.adoptedStyleSheets=e.map(n=>n instanceof CSSStyleSheet?n:n.styleSheet);else for(let n of e){let r=document.createElement("style"),i=Si.litNonce;i!==void 0&&r.setAttribute("nonce",i),r.textContent=n.cssText,t.appendChild(r)}},ds=Mi?t=>t:t=>t instanceof CSSStyleSheet?(e=>{let n="";for(let r of e.cssRules)n+=r.cssText;return cc(n)})(t):t;var{is:q_,defineProperty:Y_,getOwnPropertyDescriptor:X_,getOwnPropertyNames:J_,getOwnPropertySymbols:Q_,getPrototypeOf:eb}=Object,Ri=globalThis,dc=Ri.trustedTypes,tb=dc?dc.emptyScript:"",nb=Ri.reactiveElementPolyfillSupport,_r=(t,e)=>t,hs={toAttribute(t,e){switch(e){case Boolean:t=t?tb: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}},pc=(t,e)=>!q_(t,e),hc={attribute:!0,type:String,converter:hs,reflect:!1,useDefault:!1,hasChanged:pc};Symbol.metadata??=Symbol("metadata"),Ri.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=hc){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&&Y_(this.prototype,e,i)}}static getPropertyDescriptor(e,n,r){let{get:i,set:o}=X_(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)??hc}static _$Ei(){if(this.hasOwnProperty(_r("elementProperties")))return;let e=eb(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(_r("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(_r("properties"))){let n=this.properties,r=[...J_(n),...Q_(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(ds(i))}else e!==void 0&&n.push(ds(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 uc(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:hs).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:hs;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??pc)(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[_r("elementProperties")]=new Map,bt[_r("finalized")]=new Map,nb?.({ReactiveElement:bt}),(Ri.reactiveElementVersions??=[]).push("2.1.2");var fs=globalThis,fc=t=>t,Ei=fs.trustedTypes,mc=Ei?Ei.createPolicy("lit-html",{createHTML:t=>t}):void 0,ms="$lit$",yt=`lit$${Math.random().toFixed(9).slice(2)}$`,gs="?"+yt,rb=`<${gs}>`,Jt=document,yr=()=>Jt.createComment(""),vr=t=>t===null||typeof t!="object"&&typeof t!="function",_s=Array.isArray,wc=t=>_s(t)||typeof t?.[Symbol.iterator]=="function",ps=`[
+\f\r]`,br=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,gc=/-->/g,_c=/>/g,Yt=RegExp(`>|${ps}(?:([^\\s"'>=/]+)(${ps}*=${ps}*(?:[^
+\f\r"'\`<>=]|("|')|))|$)`,"g"),bc=/'/g,yc=/"/g,kc=/^(?:script|style|textarea|title)$/i,bs=t=>(e,...n)=>({_$litType$:t,strings:e,values:n}),m=bs(1),R=bs(2),Ox=bs(3),et=Symbol.for("lit-noChange"),_=Symbol.for("lit-nothing"),vc=new WeakMap,Xt=Jt.createTreeWalker(Jt,129);function xc(t,e){if(!_s(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return mc!==void 0?mc.createHTML(e):e}var $c=(t,e)=>{let n=t.length-1,r=[],i,o=e===2?"":e===3?"":"",s=br;for(let l=0;l"?(s=i??br,d=-1):u[1]===void 0?d=-2:(d=s.lastIndex-u[2].length,c=u[1],s=u[3]===void 0?Yt:u[3]==='"'?yc:bc):s===yc||s===bc?s=Yt:s===gc||s===_c?s=br:(s=Yt,i=void 0);let h=s===Yt&&t[l+1].startsWith("/>")?" ":"";o+=s===br?a+rb:d>=0?(r.push(c),a.slice(0,d)+ms+a.slice(d)+yt+h):a+yt+(d===-2?l:h)}return[xc(t,o+(t[n]||">")+(e===2?" ":e===3?"":"")),r]},wr=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]=$c(e,n);if(this.el=t.createElement(c,r),Xt.currentNode=this.el.content,n===2||n===3){let d=this.el.content.firstChild;d.replaceWith(...d.childNodes)}for(;(i=Xt.nextNode())!==null&&a.length0){i.textContent=Ei?Ei.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=Qt(this,e,n,0),s=!vr(e)||e!==this._$AH&&e!==et,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 Sn(e.insertBefore(yr(),o),o,void 0,n??{})}return i._$AI(t),i};var ys=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=Mc(n,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return et}};Y._$litElement$=!0,Y.finalized=!0,ys.litElementHydrateSupport?.({LitElement:Y});var ob=ys.litElementPolyfillSupport;ob?.({LitElement:Y});(ys.litElementVersions??=[]).push("4.2.2");var ws=t=>t.slice(0,t.indexOf(".")),sb={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"},J=t=>sb[ws(t)]??null,ks=["light","cover","climate","media","switch","fan","lock","binary","sensor","scene","script"];var Rc=new Set(["light","switch","fan"]),Ft=t=>t!==null&&t!=="scene"&&t!=="script",tt=t=>!t||t.state==="unavailable"||t.state==="unknown"&&!t.entity_id.startsWith("event.");function W(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 Ec=t=>!!t&&t.entity_id.startsWith("sensor.")&&t.attributes.device_class==="enum";var Ac=t=>Math.min(1,Math.max(0,t));function ab(t){let e=Ac((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 vs(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(Ac(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:ab(n.color_temp_kelvin),level:r}:{color:[1,.71,.28],level:r}}function Fc(t,e,n){let r=vs(t,n);if(r)return r;for(let i of e){let o=vs(i);if(o)return{color:o.color,level:o.level*.6}}return null}function Di(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 Dc=[],Ii=new Map,lb=0,he=(t,e)=>`pack:${t}:${e}`,vt=t=>t.startsWith("pack:");function xs(t){Dc=t,Ii=new Map;for(let e of t)for(let n of e.items)Ii.set(he(e.id,n.id),n);lb+=1}var xr=()=>Dc;var cb={};function U(t){if(!vt(t))return;let e=Ii.get(t);if(e)return e;let[,n,...r]=t.split(":"),i=cb[n];return i?Ii.get(he(i,r.join(":"))):void 0}var ub=.22;function Tc(t,e,n,r){let i=Math.min(ub,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 kr(t,e,n,r,i){return[Tc(t*r,n*r,r,i)/i,Tc(e*r,n*r,r,i)/i]}var zc=new WeakMap;function Ic(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=zc.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]=kr(d.x-d.w/2,d.x+d.w/2,-.5,i,e),[f,g]=kr(d.z-d.d/2,d.z+d.d/2,-.5,o,n),[b,y]=kr(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],[E,T]=kr(w-k/2,w+k/2,-.5,i,e),[F,H]=kr(x-M/2,x+M/2,-.5,o,n);Object.assign(v,{tx:(E+T)/2,tz:(F+H)/2,tw:T-E,td:H-F})}return v});return a||zc.set(t,a=new Map),a.size>32&&a.clear(),a.set(l,u),u}var $s=t=>!!t?.parts.some(e=>e.move);var Oc=t=>U(t)?.parts.find(e=>e.screen),Pc=.06;function Hc(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>=Pc&&s>=Pc})}function dt(t){return nt[t]??U(t)?.size??[.6,.6,.8]}function Tt(t){let e=U(t);return jc.has(t)||!!e?.electric||!!e?.light||!!e?.climate}var Lc=t=>!!U(t)?.parts.some(e=>e.picture),Mn=t=>!!U(t)?.climate;function Cc(t,e){return t.name[e.split("-")[0]]??t.name.en??Object.values(t.name)[0]??t.id}var db={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 Nc(t,e){if(e.split("-")[0]==="de")return t.name;let n=/^nextfloor\.(.+)$/.exec(t.id)?.[1];return n&&db[n]||t.name}function zt(t,e){return e.mount_y!=null?e.mount_y:pb(t,e)+(hb(e)?0:Vc(t,e.x,e.z))}var hb=t=>t.type==="led_strip"||U(t.type)?.mount==="ceiling";function pb(t,e){if(e.type==="lamp_wall")return Bc;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 Wc(e);switch(n.mount){case"surface":return Kc(t,e.x,e.z);case"wall":return n.wall_y??1;case"ceiling":return Math.max(0,Oi(t,e)-e.h);default:return 0}}function Ss(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"],Gc=["condition","temperature","humidity","pressure","wind_speed","wind_gust_speed","wind_bearing","cloud_coverage","precipitation","precipitation_total","illuminance","uv_index","visibility","snow","fog","lightning"],Uc=["turn","slide","top"],Zc=["always","active","no_power","never"],qc=1.3,Hi=(t,e=new Date().toISOString().slice(0,10))=>!!t.due&&t.due<=e,Yc=["gable","hip","halfhip","pyramid","mansard","pent","flat","parapet"],Xc=["brick","round","wide","steel"],Li=["navigate","more_info","service","fire_dom_event"];function Ci(t,e,n){return t?e?!!n.lock_plan:!!t.locked:!1}var Jc=["rain","snow","fog","clouds","lightning","sky"],Qc=["rain","snow","clouds","lightning","sky"],eu=["lawn","terrace","path","driveway","pool","bed","wild","hedge","fence","pergola"],Ms={lawn:.012,terrace:.12,path:.02,driveway:.02,pool:-.25,bed:.15,wild:.03,hedge:1.2,fence:1,pergola:2.2};function Rs(t){return t==="hedge"||t==="fence"||t==="pergola"}var tu=["x","-x","z","-z"];function fb(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 mb(t,e,n,r){return nu(t)+(e.offset??0)+Ms[e.type]-fb(e,n,r)}function nu(t){return t.elevation>.3?0:-.2}function ru(t,e,n){let r=(t.outdoor??[]).filter(o=>!Rs(o.type)&&o.type!=="pool"&&N([e,n],o.points)),i=[...r].reverse().find(o=>o.cut)??r[0];return i?mb(t,i,e,n):nu(t)}var iu=t=>t.cut??t.type==="pool",ou=30,su={meter:null,grid:null,grid_invert:!1,solar:null,battery:null,battery_invert:!1,battery_soc:null,consumption:null,tariff:null},au=["wood","oak","tiles","carpet","stone","concrete"],lu={type:"none",pitch:35,overhang:.4},Ni="#d6cfc2",Bi="#e8e3da",cu={wall_exterior:.24,wall_interior:.12,grid:.05,north:0,roof:{...lu}};function Pt(){return{version:1,floors:[],settings:{...cu},energy:{...su},presence:[]}}function Ne(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 gb=2.75;function uu(t,e){if(e!=null&&Number.isFinite(e))return Math.round(e*gb*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 du(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 hu(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 Wi=["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","stairwell"],pu={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"],vehicles:["parking"]},Be=["meter","inverter","home_battery","wallbox","grid_point"],fu=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"]),Bc=1.75;function Vi(t){return Es.has(t.type)||["stairwell","parking"].includes(t.type)?!1:U(t.type)?.mount!=="ceiling"}function ue(t){return fu.has(t)||!!U(t)?.light}var _b=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 Wc(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 Es=new Set(["lamp_ceiling","lamp_downlight","lamp_spot","lamp_panel","lamp_pendant","ceiling_fan"]);function gu(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 As=t=>t?.floor_offset&&Number.isFinite(t.floor_offset)?t.floor_offset:0;function Vc(t,e,n){let r=t.rooms.find(i=>i.points.length>=3&&i.floor_offset&&N([e,n],i.points));return As(r)}function ht(t,e,n){let r=t.rooms.find(i=>i.points.length>=3&&N([e,n],i.points));return r?.ceiling!=null&&r.ceiling>0?r.ceiling:t.height}var Oi=(t,e)=>e.ceiling_y!=null&&e.ceiling_y>0?e.ceiling_y:ht(t,e.x,e.z);function Kc(t,e,n){let r=0;for(let i of t.furniture)!(_b.has(i.type)||U(i.type)?.surface)||!N([e,n],Ps(i))||(r=Math.max(r,i.h));return r}var jc=new Set([...fu,"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],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 Fs=["interior","front","front_glass","sidelight","sidelights","glass","sliding","passage"],Ts=["standard","bars","glass_wall"],Ki=new Set(["interior","front"]);function tn(t,e){return t.type==="door"?t.style&&Fs.includes(t.style)?t.style:e?"front":"interior":t.style&&Ts.includes(t.style)?t.style:"standard"}function _u(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 zs(t){return t==="front"||t==="front_glass"||t==="sidelight"||t==="sidelights"}var En={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 An(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&&zs(t.style)?"front":e?"door_double":"door":t.sill<.1?e?"terrace_double":"terrace":e?"window_double":"window"}function Pe(t){t.energy={...su,...t.energy??{}},t.presence=t.presence??[],t.version=1,t.settings={...cu,...t.settings,roof:{...lu,...t.settings?.roof??{}}},t.floors.forEach((e,n)=>{let r=Ne(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 bb(t),t}function bb(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=D(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=D("room"));e(n.openings,"op"),e(n.furniture,"furn"),e(n.outdoor,"out")}}function D(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 Ps(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 N(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 Ds=t=>t.trim().replace(/^\/local\/www\//i,"/local/"),Is=t=>/^(https:\/\/|\/local\/|\/hacsfiles\/)\S+\.m?js(\?\S*)?$/i.test(t.trim());var vb=globalThis,yu=vb.__nextfloorPluginStore??={plugins:new Map,listeners:new Set},Os=yu.plugins,bu=yu.listeners;var wb=5;function vu(t,e){t.errors.lengthbu.delete(t)}var Hs=()=>[...Os.values()].map(t=>t.status),wu=()=>[...Os.values()].flatMap(t=>Object.keys(t.plugin.lightAnimations??{}));function*Ui(t,e){for(let{plugin:n,status:r}of Os.values())for(let i of n.devices??[]){let o=!1;try{o=i.match(t,e)}catch(s){vu(r,s)}o&&(yield{device:i,status:r})}}function Zi(t,e){for(let{device:n}of Ui(t,e))return n.kind??"sensor";return null}function ku(t,e){let n=t.states[e];if(!n)return null;let r=kb({hass:t,entityId:e,state:n})?.icon?.trim();return r&&/^mdi:[a-z0-9-]+$/i.test(r)?r:null}function kb(t){let e=null;for(let{device:n,status:r}of Ui(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){vu(r,i)}return e}function qi(t,e){return t?typeof t=="string"?t:t[e]??t[e.split("-")[0]]??t.en??Object.values(t)[0]??"":""}function xu(t,e){let n=[];for(let{device:r,status:i}of Ui(t,e))r.settings?.length&&n.push({pluginId:i.id,name:i.name,settings:r.settings});return n}function $u(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 Su(t,e){for(let{device:n}of Ui(t,e))if(n.floorWedge)return!0;return!1}var xb=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"]),$b=new Set(["m\xB3","m3","L","l","kWh","Wh","MWh","lx"]),Sb=new Set(["door","window","opening","garage_door","motion","occupancy","presence","smoke","moisture","gas","carbon_monoxide"]),Mb=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 Ru=(t,e)=>{let n=t.entities?.[e];return!!(n?.hidden||n?.entity_category)},We=(t,e)=>J(e)??Zi(e,t.states[e]);function Mu(t,e){let n=t.states[e];if(!n||Ru(t,e))return!1;if(Zi(e,n)!==null)return!0;let r=J(e);if(!r)return!1;let i=n.attributes.device_class;return e.startsWith("event.")?!i||i==="button"||i==="doorbell":r==="sensor"?i?xb.has(i):$b.has(String(n.attributes.unit_of_measurement??"")):r==="binary"?i?Sb.has(i):!!t.entities?.[e]?.area_id:!0}function Rb(t,e){let n=t.states[e];return J(e)!=="sensor"||!n?.attributes.unit_of_measurement||Ru(t,e)||Mb.has(String(n.attributes.device_class??""))?!1:Number.isFinite(Number(n.state))||tt(n)}var Xi=(t,e)=>e.startsWith("sensor.")&&t.states[e]?.attributes.device_class==="power",Ls=null;Gi(()=>Ls=null);function Cs(t,e){let n=t.get(e);return n||t.set(e,n=[]),n}function Eb(t){let e=new Map,n=new Map,r=new Map,i=new Map,o=[],s=u=>{(Mu(t,u)||Rb(t,u))&&Ft(We(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&&Xi(t,u)&&Cs(n,p).push(u),p&&!d.hidden&&!d.entity_category&&(r.get(p)??r.set(p,new Set).get(p)).add(ws(u));let h=Dt(t,u);h===null?s(u):Mu(t,u)&&Cs(e,h).push(u)}if(t.entities)for(let u of Object.keys(t.states))t.entities[u]||s(u);let l=ks.indexOf("binary")-.5,a=u=>{let d=J(u),p=d?ks.indexOf(d):l;return p>l&&Zi(u,t.states[u])!==null?l:p};o.sort((u,d)=>a(u)-a(d)||W(t,u).localeCompare(W(t,d)));for(let[u,d]of e){let p=t.areas?.[u]?.name;d.sort((h,f)=>a(h)-a(f)||W(t,h,p).localeCompare(W(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 Tn(t){let e=Ls;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:Ls=Eb(t)}function ye(t,e){let n=Yi(t,e.area_id);return e.sub_areas?.length?[...new Set([...n,...e.sub_areas.flatMap(r=>Yi(t,r))])]:n}function Yi(t,e){return!e||!t.entities?[]:Tn(t).byArea.get(e)??[]}function Eu(t,e){if(!t.entities)return[];let n=[];for(let[r,i]of Tn(t).byArea){let o=i.filter(s=>Ft(We(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 Au=t=>t.entities?Tn(t).withoutArea:[],Ns=(t,e)=>!!t.entities&&Tn(t).hubs.has(e),Ji=(t,e)=>t.entities?Tn(t).powerByDevice.get(e)??[]:[];function zn(t,e){let n=new Map;for(let i of e)Cs(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 Qi=(t,e)=>zn(t,e).map(n=>n.primary),Ab={temperature:"temperature",humidity:"humidity",co2:"carbon_dioxide",illuminance:"illuminance"};function Bs(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===Ab[n]}var Fb=new Set(["climate","water_heater","switch","button","camera","media_player","vacuum","light","fan","lawn_mower"]),Tb=["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"],zb=new RegExp(`(${Tb.join("|")})`,"i");function Ws(t,e){let n=t.entities?.[e]?.device_id,r=n&&!Ns(t,n)?Tn(t).domainsByDevice.get(n):void 0;return r&&[...r].some(i=>Fb.has(i))?!1:!zb.test(`${e} ${t.states[e]?.attributes.friendly_name??""}`)}function Fu(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=>N([c.x,c.z],n.points)).map(c=>c.entity_id),l=new Set(o.filter(c=>!N([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.")&&Bs(t,c,r)&&Ws(t,c))}function Tu(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 eo(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 to(t,e){let n=e?t.states[e]:void 0;if(!n||tt(n))return null;let r=n.attributes;if(r.nf_cover_control&&typeof r.current_position=="number")return r.current_position;let i=Tu(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 Pb=new Set([void 0,"shutter","blind","awning","shade","curtain","window"]),Db=new Set(["garage","gate"]),Ib=new Set(["window","opening"]);function $r(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 zu=(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=>J(b)==="binary"&&g(l(b)??"")),c=g=>o.filter(b=>b.type===g),u=$r(c("window"),s.filter(g=>J(g)==="cover"&&Pb.has(l(g))),!0),d=$r(c("window"),a(g=>Ib.has(g))),p=$r(c("door"),a(g=>g==="door")),h=$r(c("garage"),s.filter(g=>J(g)==="cover"&&Db.has(l(g)??""))),f=$r(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:zu(g.cover,b?.get(g.id)),contact:g.sensor==="handle"&&g.contact==null?null:zu(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 Ob=[[/^(tilted|tilt|gekippt|kipp)/i,"tilted"],[/^(open|opened|offen|geöffnet|on)$/i,"open"],[/^(closed|close|geschlossen|zu|off)$/i,"closed"]];function Vs(t){if(!t||tt(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&&Ob.find(([o])=>o.test(r));if(i)return i[1]}return null}var Pu=new WeakMap,Du=new WeakMap;function Iu(t,e){let n=Du.get(t)??t,r=Pu.get(n)??new WeakMap;Pu.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=to(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?to(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 Du.set(l,n),r.set(e,l),l}var Q=t=>t?.symconObjects!==void 0;function De(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 Pn(t){return!t||t.state==="unknown"||t.state==="unavailable"?null:t.attributes.symcon_value??t.attributes.symcon_numeric_value??t.state}function nn(t){let e=Pn(t);if(e===null||typeof e=="boolean"||e==="")return null;let n=Number(e);return Number.isFinite(n)?n:null}function Sr(t){let e=Pn(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 Ou(t){return Pn(t)===null?"\u2013":String(t?.attributes.symcon_formatted??Pn(t))}function Hu(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 Lu="weather.nextfloor_symcon",Nu={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"},Cu=new WeakMap;function Hb(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 Bu(t,e){if(!Q(t))return t;let n=e.weather_variables??{};if(!e.rain_sensor&&!Object.values(n).some(h=>h&&h!=="none"))return t;let r=Cu.get(t)??new WeakMap;Cu.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=nn(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=nn(f);g!==null&&(o[h]=Hu(g,f?.attributes.unit_of_measurement))}o.wind_speed_unit="km/h";let l=Pn(s("wind_bearing"));l!==null&&(o.wind_bearing=l);let a=Hb(Ou(s("condition"))),c=e.rain_sensor?t.states[e.rain_sensor]:void 0,u=Sr(c);u!==null&&e.rain_sensor_inverted&&(u=!u),u===null&&typeof o.precipitation=="number"&&(u=o.precipitation>0),Sr(s("lightning"))?a=u?"lightning-rainy":"lightning":Sr(s("snow"))?a=u?"snowy-rainy":"snowy":Sr(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:Lu,state:a??"unknown",attributes:o},p={...t,states:{...t.states,[Lu]:d}};return r.set(e,p),p}var Dn={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},rn=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 Mr=class extends Ht{constructor(e){if(super(e),this.it=_,e.type!==Dn.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===et)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:[]}}};Mr.directiveName="unsafeHTML",Mr.resultType=1;var Wu=rn(Mr);var Vu=/\b(tv|fernseh|television|fire ?tv|apple ?tv|chromecast|shield)/i,Ku=/(kühl|fridge|gefrier|freezer)/i,ju=/(spülmaschine|geschirrspül|dishwasher)/i,Lb=/(kochfeld|herd|induktion|cooktop)/i,Cb={robot_vacuum:/(saug|vacuum|robo|roomba|roborock|dreame|ecovacs|deebot)/i,tv_board:Vu,tv_wall:Vu,desk:/\b(pc|computer|rechner|desktop|monitor|workstation)/i,fridge:Ku,fridge_smart:Ku,stove:/(herd|kochfeld|cooktop|stove|induktion)/i,kitchen_tall:/(backofen|oven|ofen)/i,dishwasher:ju,washer:/(waschmaschine|washer|washing)/i,dryer:/(trockner|dryer)/i,kitchen:/(kaffee|coffee|wasserkocher|kettle)/i,island:Lb,sink:ju,radiator:/(heiz|radiator|thermostat|climate|hk|trv)/i},Gu={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},Uu=new Set(["tv_board","tv_wall"]);var In=t=>Uu.has(t)||!!Oc(t),no=t=>!!U(t)?.electric&&/speaker|multiroom|soundbar/.test(t.split(":").pop()??t),Er=t=>In(t)||t==="desk"||t==="fridge_smart",Nb=t=>!!t&&t!=="none";function Bb(t,e){if(Xi(t,e))return e;let n=t.entities?.[e]?.device_id;return n?Ji(t,n).find(r=>r!==e)??null:null}var Wb=(t,e,n)=>t.rooms.find(r=>r.points.length>=3&&N([e,n],r.points));function Rr(t,e,n,r){return t.find(i=>e?.test(n(i)))??(r?t[0]??null:null)}function Ve(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(Nb));for(let o of r.furniture){let s=o.type in Gu,l=Mn(o.type),a=s?Gu[o.type]:Cb[o.type];if(!a&&!l&&!no(o.type)&&o.entity==null&&o.power==null)continue;let c=Wb(r,o.x,o.z),u=(c?Qi(t,ye(t,c)):[]).filter(b=>!i.has(b)),d=b=>`${b} ${W(t,b)}`,p=b=>u.filter(y=>J(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=>J(v)==="fan").map(v=>t.entities?.[v]?.device_id).filter(Boolean));h=b.find(v=>J(v)==="light"&&y.has(t.entities?.[v]?.device_id))??Rr(p("light"),a,d,!1)}else if(s)h=Rr(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=Rr(p("climate"),a,d,!0);else if(In(o.type)){let b=p("media");h=b.find(y=>t.states[y]?.attributes.device_class==="tv")??Rr(b,a,d,Uu.has(o.type))}else if(no(o.type)){let b=p("media").filter(y=>t.states[y]?.attributes.device_class!=="tv");h=Rr(b,a,d,!1)??(b.length===1?b[0]:null)}else a&&(h=u.find(b=>["switch","media","fan"].includes(J(b)??"")&&a.test(d(b)))??null);h&&i.add(h)}let f=o.power==="none"?null:o.power??null;o.power==null&&(f=h?Bb(t,h):null,!f&&a&&c&&!s&&(f=ye(t,c).find(b=>Xi(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=>J(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 Zu=t=>t==="fridge"||t==="fridge_smart"||/(fridge|freezer|kuehl|gefrier|chest_freezer)/.test(t.slice(t.lastIndexOf(":")+1));function qu(t,e,n=[]){let r=[];for(let i of e){let o=(l,a)=>i.rooms.some(c=>c.points.length>=3&&N([l,a],c.points)),s=Ve(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(...Qi(t,Yi(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 Vb(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 Xu(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=J(y)==="light",w=g[0].at,x=-1/0;for(let{at:M,wallDistance:E}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 Yu=/(^|_)(current_room|current_segment|aktueller_raum|current_area)($|_)/;function Ju(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.")&&(Yu.test(o.translation_key??"")||Yu.test(o.entity_id.split(".")[1])))?.entity_id??null}var me=t=>/^(sensor|input_number|number)\./.test(t),ro=t=>/^(binary_sensor|input_boolean)\./.test(t);function On(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 Kb(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=Kb(t,n),i=t?.states[n],o=typeof i?.attributes.symcon_path=="string"?i.attributes.symcon_path:void 0,s={id:n,label:r?`${W(t,n)} \xB7 ${r}`:W(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 Qu(t,e,n){return e.unsupported?[]:O(t,r=>De(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 io(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);
}
-`,O$=Q`
+`,N$=ee`
:host([readable]) {
--secondary-text-color: var(--primary-text-color, #e1e1e1);
--divider-color: color-mix(in srgb, var(--primary-text-color, #e1e1e1) 40%, transparent);
@@ -40,7 +40,7 @@ var $={cs:"4be67fcd522e",da:"0fe66a82bf2a",es:"bd89dffd1355",fi:"9a17bc084f56",f
:host([readable]) .nf-overlay {
zoom: 1.2;
}
-`,pt=Q`
+`,pt=ee`
/* a group of switches: one rounded pill, the active one tinted with the accent */
.nf-seg {
display: inline-flex;
@@ -203,7 +203,7 @@ var $={cs:"4be67fcd522e",da:"0fe66a82bf2a",es:"bd89dffd1355",fi:"9a17bc084f56",f
min-height: 40px;
}
}
-`;var{I:Bb}=wc,Yu=t=>t;var Ju=t=>t.strings===void 0,Xu=()=>document.createComment(""),Hn=(t,e,n)=>{let r=t._$AA.parentNode,i=e===void 0?t._$AB:e._$AA;if(n===void 0){let o=r.insertBefore(Xu(),i),s=r.insertBefore(Xu(),i);n=new Bb(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=Yu(a).nextSibling;Yu(r).insertBefore(a,i),a=c}}}return n},Ot=(t,e,n=t)=>(t._$AI(e,n),t),Wb={},Qu=(t,e=Wb)=>t._$AH=e,ed=t=>t._$AH,io=t=>{t._$AR(),t._$AA.remove()};var td=(t,e,n)=>{let r=new Map;for(let i=e;i<=n;i++)r.set(t[i],i);return r},nd=tn(class extends It{constructor(t){if(super(t),t.type!==Dn.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=ed(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]=Ot(i[d],o[h]),d++,h++;else if(l[p]===s[f])a[f]=Ot(i[p],o[f]),p--,f--;else if(l[d]===s[f])a[f]=Ot(i[d],o[f]),Hn(t,a[f+1],i[d]),d++,f--;else if(l[p]===s[h])a[h]=Ot(i[p],o[h]),Hn(t,i[d],i[p]),p--,h++;else if(c===void 0&&(c=td(s,h,f),u=td(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=Hn(t,i[d]);Ot(y,o[h]),a[h]=y}else a[h]=Ot(b,o[h]),Hn(t,i[d],b),i[g]=null;h++}else io(i[p]),p--;else io(i[d]),d++;for(;h<=f;){let g=Hn(t,a[f+1]);Ot(g,o[h]),a[h++]=g}for(;d<=p;){let g=i[d++];g!==null&&io(g)}return this.ut=s,Qu(t,a),et}});var Vb=new Intl.Collator("de",{numeric:!0,sensitivity:"base"}),Ns=-1,id=[{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"}],rd=t=>t.object_type===1&&id.some(e=>e.type===t.module_type);function Kb(t){let e=new Map(t.map(a=>[a.object_id,a])),n=t.filter(a=>{if(!rd(a))return!1;let c=new Set([a.object_id]),u=e.get(a.parent_id);for(;u&&!c.has(u.object_id);){if(rd(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(Ns,o(Ns,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 id.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,Ns,a.name,p,c));for(let h of u)l(h,d,p)}),[...r.values()]}function Bs(t){let e=Kb(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||Vb.compare(o.name,s.name));return{nodes:n,children:r}}function Ws(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 Vs(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 Ws(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 od=["Boolean","Integer","Float","String"],jb={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 sd(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:od[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=>od[c]).join(" oder ")} ben\xF6tigt.`;let o=e.excluded?.(t.entity_id);if(o)return o;let s=jb[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 Gb=["Kategorie","Instanz","Variable","Skript","Ereignis","Medium","Link"],Ks=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=Bs([]);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=Bs(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 Ws(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=sd(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=Vs(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 nd=t=>t.strings===void 0,td=()=>document.createComment(""),Hn=(t,e,n)=>{let r=t._$AA.parentNode,i=e===void 0?t._$AB:e._$AA;if(n===void 0){let o=r.insertBefore(td(),i),s=r.insertBefore(td(),i);n=new jb(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=ed(a).nextSibling;ed(r).insertBefore(a,i),a=c}}}return n},Lt=(t,e,n=t)=>(t._$AI(e,n),t),Gb={},rd=(t,e=Gb)=>t._$AH=e,id=t=>t._$AH,oo=t=>{t._$AR(),t._$AA.remove()};var od=(t,e,n)=>{let r=new Map;for(let i=e;i<=n;i++)r.set(t[i],i);return r},sd=rn(class extends Ht{constructor(t){if(super(t),t.type!==Dn.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=id(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]),Hn(t,a[f+1],i[d]),d++,f--;else if(l[p]===s[h])a[h]=Lt(i[p],o[h]),Hn(t,i[d],i[p]),p--,h++;else if(c===void 0&&(c=od(s,h,f),u=od(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=Hn(t,i[d]);Lt(y,o[h]),a[h]=y}else a[h]=Lt(b,o[h]),Hn(t,i[d],b),i[g]=null;h++}else oo(i[p]),p--;else oo(i[d]),d++;for(;h<=f;){let g=Hn(t,a[f+1]);Lt(g,o[h]),a[h++]=g}for(;d<=p;){let g=i[d++];g!==null&&oo(g)}return this.ut=s,rd(t,a),et}});var Ub=new Intl.Collator("de",{numeric:!0,sensitivity:"base"}),Ks=-1,ld=[{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"}],ad=t=>t.object_type===1&&ld.some(e=>e.type===t.module_type);function Zb(t){let e=new Map(t.map(a=>[a.object_id,a])),n=t.filter(a=>{if(!ad(a))return!1;let c=new Set([a.object_id]),u=e.get(a.parent_id);for(;u&&!c.has(u.object_id);){if(ad(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(Ks,o(Ks,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 ld.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,Ks,a.name,p,c));for(let h of u)l(h,d,p)}),[...r.values()]}function js(t){let e=Zb(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||Ub.compare(o.name,s.name));return{nodes:n,children:r}}function Gs(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 Us(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 Gs(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 cd=["Boolean","Integer","Float","String"],qb={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 ud(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:cd[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=>cd[c]).join(" oder ")} ben\xF6tigt.`;let o=e.excluded?.(t.entity_id);if(o)return o;let s=qb[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 Yb=["Kategorie","Instanz","Variable","Skript","Ereignis","Medium","Link"],Zs=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=js([]);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=js(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 Gs(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=ud(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=Us(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":Gb[n.object_type]??"Objekt"}${n.hidden?" \xB7 ausgeblendet":""}
+ ${n.virtual?"Systembereich":Yb[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=Vs(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=Us(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} `)}
`:_}
- ${nd(s,c=>c.node.object_id,c=>this.renderRow(c))}
+ ${sd(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}
`:_}
@@ -243,7 +243,7 @@ var $={cs:"4be67fcd522e",da:"0fe66a82bf2a",es:"bd89dffd1355",fi:"9a17bc084f56",f
Abbrechen
Übernehmen
- `}static styles=[ve,Q`
+ `}static styles=[ve,ee`
:host { display:block; min-width:0; max-width:100%; font:inherit; color:var(--nf-text); }
button,input { font:inherit; box-sizing:border-box; }
button { cursor:pointer; color:var(--nf-text); border:1px solid var(--nf-line); background:var(--nf-chrome-solid); border-radius:9px; padding:8px 12px; }
@@ -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",Ks);var ad=40,js=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,ad)]}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-ad)}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,dd)]}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-dd)}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.leftOut>0?m`… +${this.leftOut} · ${this.placeholder} `:_}
`:_}
- `}static styles=[ve,Q`
+ `}static styles=[ve,ee`
:host {
display: block;
position: relative;
@@ -393,11 +393,11 @@ var $={cs:"4be67fcd522e",da:"0fe66a82bf2a",es:"bd89dffd1355",fi:"9a17bc084f56",f
color: var(--nf-muted);
cursor: default;
}
- `]};customElements.get("nf-entity-picker")||customElements.define("nf-entity-picker",js);var Gs=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()}>ⓘ
+ `]};customElements.get("nf-entity-picker")||customElements.define("nf-entity-picker",qs);var Ys=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}
- `}static styles=[ve,Q`
+ `}static styles=[ve,ee`
:host { display:inline-block; margin:4px 0; vertical-align:middle; }
button { font:inherit; cursor:pointer; color:var(--nf-muted); background:transparent; border:1px solid var(--nf-line); border-radius:50%; pointer-events:auto; }
.info { width:26px; height:26px; padding:0; font-size:18px; line-height:24px; }
@@ -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",Gs);var nn=t=>t.target.value,Us=t=>Number.parseFloat(t.replace(",",".")),ae=t=>Math.round(t*1e3)/1e3,ld=t=>t.wide?"nf-field nf-wide":"nf-field";function A(t,e,n,r,i=.01,o){return m`t.target.value,Xs=t=>Number.parseFloat(t.replace(",",".")),ae=t=>Math.round(t*1e3)/1e3,hd=t=>t.wide?"nf-field nf-wide":"nf-field";function A(t,e,n,r,i=.01,o){return m`${e}
{let l=Us(nn(s));Number.isFinite(l)&&r(l)}}
+ @change=${s=>{let l=Xs(on(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(nn(o).trim())} />
- `}function L(t,e,n,r,i,o={}){return m`r(on(o).trim())} />
+ `}function L(t,e,n,r,i,o={}){return m`${e}
- i(nn(s))}>
+ i(on(s))}>
${r.map(([s,l])=>m`${l} `)}
`}function I(t,e,n,r,i={}){return m` 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:W(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?qu(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:W(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?Qu(t.hass,s,n):i;return m`${e}
{d.stopPropagation(),o(d.detail.value==="__auto"?null:d.detail.value)}}
>
- `}function Ln(t,e,n){return n?(n.startsWith("mdi:")?n:`mdi:${n}`).replace(/[^a-z0-9:-]/gi,""):t.hass?bu(t.hass,e):null}function Ht(t,e,n){let r=e?(e.startsWith("mdi:")?e:`mdi:${e}`).replace(/[^a-z0-9:-]/gi,""):"";return m``}function Ln(t,e,n){return n?(n.startsWith("mdi:")?n:`mdi:${n}`).replace(/[^a-z0-9:-]/gi,""):t.hass?ku(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`${t.t("marker_icon")}
- n(nn(i).trim().replace(/^mdi:/,"")||null)} />
- ${r?Lu(` `):_}
+ n(on(i).trim().replace(/^mdi:/,"")||null)} />
+ ${r?Wu(` `):_}
`}function Cn(t,e,n){return m`${t.t("marker_show")}
- n(nn(r)||null)}>
+ n(on(r)||null)}>
${t.t("marker_show_auto")}
- ${Kc.map(r=>m`${t.t(`marker_show_${r}`)} `)}
+ ${Zc.map(r=>m`${t.t(`marker_show_${r}`)} `)}
`}function Nn(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")}
@@ -467,7 +467,7 @@ var $={cs:"4be67fcd522e",da:"0fe66a82bf2a",es:"bd89dffd1355",fi:"9a17bc084f56",f
${e?m`n(null)}>${t.t("height_auto")} `:_}
${S(t.t("pin_shift_hint"),"nf-wide")}
- `}var X=(...t)=>m`${t}
`,S=(t,e="")=>m` `;function rn(t,e,n,r={}){let i=r.lowest??10;return m``}var X=(...t)=>m`${t}
`,S=(t,e="")=>m` `;function sn(t,e,n,r={}){let i=r.lowest??10;return m`${t.t(r.label??"glow_scale")}
{let s=Number(nn(o)),l=Math.min(150,Math.max(i,nn(o).trim()===""||Number.isNaN(s)?100:s))/100;n(Math.abs(l-1)<.001?null:l)}}
+ @change=${o=>{let s=Number(on(o)),l=Math.min(150,Math.max(i,on(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 oo(t,e){return(await rt(t,"image/get",{image_id:e})).data}async function Lt(t,e,n){await rt(t,"image/set",{image_id:e,data:n})}async function cd(t){return(await rt(t,"history/list")).snapshots}async function ud(t,e){return(await rt(t,"history/snapshot",e?{name:e}:{})).id}async function dd(t,e){return(await rt(t,"history/get",{snapshot_id:e})).building}async function hd(t,e){await rt(t,"history/delete",{snapshot_id:e})}async function pd(t,e){return(await rt(t,"history/restore",{snapshot_id:e})).revision}var Er=(t,e)=>rt(t,"packs/import",{pack:e});async function fd(t,e){await rt(t,"packs/remove",{pack_id:e})}var md=t=>rt(t,"backup/export"),gd=(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],ee=(t,e)=>t[0]*e[0]+t[1]*e[1],Me=(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]},Zs=t=>[-t[1],t[0]],qs=t=>[t[1],-t[0]];var Ub=.05,Zb=.2,qb=.12;function Yb(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]=[ee(s,u),ee(a,u)];e.push({room:r,index:l,dir:u,normal:p,offset:ee(s,p),outside:ee(d,p)>0?1:-1,from:Math.min(h,f),to:Math.max(h,f)})})}),e}function Xb(t,e,n){if(t.room===e.room||Math.abs(Me(t.dir,e.dir))>Ub||t.outside===e.outside)return null;let r=(e.offset-t.offset)*t.outside;return r>n||r<-qb||Math.abs(r)<1e-4||Math.min(t.to,e.to)-Math.max(t.from,e.from)Math.round(t*1e3)/1e3;function _d(t,e=.6){let n=Yb(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(Ys(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(Me(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(Me(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[Ys(w[0]),Ys(w[1])]})})),gaps:o}}function bd(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 Jb=.25,yd=t=>Math.round(t*1e3)/1e3,vd=(t,e,n)=>t.rooms.find(r=>r.points.length>=3&&N([e,n],r.points));function Js(t,e,n,r,i){let o=vd(t,e,n);if(!o)return[r,i];let s=(l,a)=>N([l,a],o.points);return s(r,i)?[r,i]:s(r,n)?[r,n]:s(e,i)?[e,i]:[e,n]}function Qb(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(ee(G(o,n),r))<.02&&Math.abs(ee(G(l,n),r))<.02}))}var Xs=(t,e)=>Math.abs((t-e+540)%360-180);function Ar(t,e,n,r=Jb){let i=vd(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=ee(G([e.x,e.z],a),p);if(f<0||f>d)return;let g=Qb(t,i,a,h)?n/2:0,b=ee(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)=>Xs(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:yd(e.x-h[0]*x),z:yd(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 Tr(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 wd(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 kd(t,e){let n=wd(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 Qs(t,e,n){let r=wd(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 zr(t,e=0){let{x0:n,x1:r,z0:i,z1:o}=Tr(t);return[[n-e,i-e],[r+e,i-e],[r+e,o+e],[n-e,o+e]].map(s=>kd(t,s))}function xe(t){let{x0:e,x1:n,z0:r,z1:i}=Tr(t),o=s=>kd(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 Pr(t,e,n){let{x0:r,x1:i,z0:o,z1:s}=Tr(t),[l,a]=Qs(t,e,n);return t.axis==="x"?[l,t.flip?s-a:a-o]:[a,t.flip?i-l:l-r]}var Fr=Math.tan(30*Bn);function Dr(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+Fr*(t-s+o))/(2*Fr))),u=l+(c-o)*Fr;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)*Fr:p<=t-s?a+(t-s-p)*Fr:n+(t-p)*i}}function De(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=Dr(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 on=t=>De(t).rh;function xd(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 ey(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 ty(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(Me(r,i))>1e-6||ee(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 $d(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]]:xd(r[l[0]]),c=r[l[1]].a===s?r[l[1]]:xd(r[l[1]]);if(!ty(a,c,e))continue;let u={...a,b:c.b,sources:ey(a.sources,c.sources)};o=[...r.filter((d,p)=>p!==l[0]&&p!==l[1]),u];break}if(!o)return r;r=o}}function Sd(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(Zs(a.d),a.left)),right:ft(s,it(qs(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(Zs(a.d),a.left)),p=ft(s,it(qs(u.d),u.right)),h=Me(a.d,u.d);if(Math.abs(h)<1e-4)return;let f=ft(d,it(a.d,Me(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 Md(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(Me(ot(a),ot(c)))<1e-7&&ee(a,c)>0});if(r===-1)return n;n=n.filter((i,o)=>o!==r)}}function ny(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 ry(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 iy(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&&ee(h,c)>n&&ee(h,c)({t:ee(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 oy(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 Ed(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 sy(t,e,n,r){let i=oy(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(Rd),...Ed(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:[Rd(c)],...Ed(i.heightsOf(d))})}return{drafts:s,open:l}}function ay(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(ee(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=ee(n(u),s)>0,h=c==="left"===p;[u.left,u.right]=h?[0,d]:[d,0]}}}var ly=(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),E=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&&N(k,T.points))?.id??null,E=(y.thickness??e.interior)/2;h.push({free:y.id,a:w,b:x,left:E,right:E,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=$d(h,o.points,c),g=Sd(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`)],E=Md([k.right,M.left,x,M.right,k.left,w],1e-6);return{id:ly(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:E,...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 Ie(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.edgeee(G(e,t.a),ot(G(t.b,t.a)));function Ct(t,e,n){if(!e.wall)return cy(t,n.room,n.edge,e.offset);let r=t.find(i=>i.free===e.wall);return r?{wall:r,s:Ad(r,Wn(n.room,0,e.offset))}:null}function cy(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:Ad(i,Wn(e,n,r))};return null}function Fd(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 Td=([t,e])=>{let n=Math.hypot(t,e)||1;return[t/n,e/n]};function uy(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 zd(t,e){let n=t.length;if(n<3||Math.abs(e)<1e-9)return t.map(([i,o])=>[i,o]);let r=uy(t)>=0?1:-1;return t.map((i,o)=>{let s=t[(o+n-1)%n],l=t[(o+1)%n],[a,c]=Td([i[0]-s[0],i[1]-s[1]]),[u,d]=Td([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 Nt(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 dy(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 ea(t,e,n,r){let i=fe(t,{exterior:n,interior:r},e).walls.filter(l=>l.exterior&&!l.free),o=i.length?dy(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?zd(s,n):null}function sn(t,e){let n=xe(t),r=De(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,E=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)]],O=(j,Ut,xi)=>{if(j==="hip")return{upA:[],upB:[],ridge:b(Ut===l?n.u0+v*xi:n.u1-v*xi),profile:null};if(j==="halfhip"){let V_=b(Ut===l?n.u0+E:n.u1-E);return{upA:[[Ut,k,x]],upB:[[Ut,M,x]],ridge:V_,profile:F}}return{upA:[],upB:[],ridge:b(Ut),profile:T}},P=O(t.ends[0],l,1),C=O(t.ends[1],a,1),B=[[u,d,...C.upA,C.ridge,P.ridge,...[...P.upA].reverse()],[P.ridge,C.ridge,...[...C.upB].reverse(),p,h,...P.upB]],q=[[P.ridge,C.ridge]];for(let[j,Ut,xi]of[[P,u,h],[C,d,p]])j.profile===null?(B.push(j===P?[h,u,j.ridge]:[d,p,j.ridge]),q.push([Ut,j.ridge],[xi,j.ridge])):j.upA.length&&(B.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],Rt=[u,d,...we(C),p,h,...[...we(P)].reverse()];return{faces:B,rim:Rt,ridges:q,gable:T,endProfiles:[P.profile,C.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),E=b(n.u1-k),T=[l,w,v],F=[l,x,v],O=[a,w,v],P=[a,x,v];return{faces:[[u,d,O,E,M,T],[M,E,P,p,h,F],[F,T,M],[O,P,E]],rim:[u,d,O,P,p,h,F,T],ridges:[[M,E],[T,M],[F,M],[O,E],[P,E]],gable:[[0,r.y(0)],[w,v],[x,v],[i,r.y(i)]]}}case"mansard":{let y=Dr(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],E=[a,y.vr,y.rh];return{faces:[[u,d,w,v],[v,w,E,M],[M,E,k,x],[x,k,p,h]],rim:[u,d,w,E,k,p,h,x,M,v],ridges:[[M,E],[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 Ir(t,e,n){let r=null;for(let i of t.faces){if(!N([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 Or(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=>N(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 so=t=>Math.abs((t.x1-t.x0)*(t.z1-t.z0)),Pd=t=>t.shape==="flat"||t.shape==="parapet",an=t=>Math.round(t*100)/100;function ao(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||Pd(o)||so(o)=s.x0&&n<=s.x1&&r>=s.z0&&r<=s.z1}).reduce((o,s)=>o===null||so(s){let[o,s]=e.at(i,e.w/2),[l,a]=Pr(t,o,s);return Ir(n,l,a)??r.y(a)}}function na(t,e){if(Pd(e))return e;let n=xe(e),r=De(e).rh,i=py(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 ra=.14,Dd=t=>t.shape==="flat"||t.shape==="parapet";function ia(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&&!N([e,n],s.points))continue;let[h,f]=Pr(s,e,n),g=Math.max(0,s.overhang??r),b=Dd(s)?null:Ir(sn(s,{u0:g,u1:g,a:g,b:g}),h,f);o.push((b??De(s).y(f))-ra)}return o.length?Math.max(...o):null}function oa(t,e,n){let r=[],i=e+n+ra;for(let o of t.settings.roof.sections??[]){if(o.open||Dd(o)||o.shape==="mansard")continue;let s=xe(o),l=De(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 sa(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=>N(c,a.points)))).map(l=>l.elevation+l.height);return s.length?Math.max(...s):null}function aa(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=>N(p,d.points))));if(c)return c}return r.at(-1)??n[0]}var wt=t=>Math.round(t*1e3)/1e3;function la(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=>N(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=>wt(y[0]))))].sort((b,y)=>b-y),d=[...new Set(c.flatMap(b=>b.points.map(y=>wt(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,E]=[d[b]-r,d[w+1]+r];Math.min(k-x,E-M)<.8||o.push({id:e(o.length),x0:wt(x),z0:wt(M),x1:wt(k),z1:wt(E),shape:"gable",axis:k-x>=E-M?"x":"z",eave_a:wt(g),eave_b:wt(g),pitch_a:n,pitch_b:n,base:wt(g),overhang:null})}s.push(...c)}return o}var Re=Math.PI/180,je=(t,e)=>[t[0]-e[0],t[1]-e[1],t[2]-e[2]],ln=(t,e)=>t[0]*e[0]+t[1]*e[1]+t[2]*e[2],Vn=t=>Math.hypot(t[0],t[1],t[2]),cn=t=>{let e=Vn(t)||1;return[t[0]/e,t[1]/e,t[2]/e]},Id=(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]],Ge=t=>Math.round(t*100)/100,Lr=([t,e],n)=>(Math.atan2(t,-e)/Re-n+720)%360;var Hd=.25;function Ld(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 Cd(t,e){let n=cn(Id(t,e));return n[1]<0?[-n[0],-n[1],-n[2]]:n}var Nd=t=>{let e=cn([-t[0],0,-t[2]]);return[e[0],e[2]]};function kt(t,e,n,r,i,o,s,l){let a=cn(je(i,r)),c=cn(je(o,r));return{key:t,section:e,side:n,flat:!1,o:r,eu:a,es:c,n:Cd(a,c),lu:Vn(je(i,r)),ls:Vn(je(o,r)),pitch:s,span:l,facing:Nd(c)}}function Od(t,e,n,r,i,o){let s=Vn(je(i,r));if(s<.3)return null;let l=cn(je(i,r)),a=je(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=cn(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:Cd(l,p),lu:s,ls:d,pitch:Math.atan2(p[1],Math.hypot(p[0],p[2]))/Re,span:h,facing:Nd(p)}}function fy(t,e){let n=xe(t),r=De(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[Ld(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+Hd)]}if(t.shape==="pent")return[kt(`${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 my(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(kt(`${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(kt(`${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=Od(`${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=Od(`${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 my(t,e,n,r,i,o){let s=Dr(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)/Re,d=[],[p,h]=[e.w+o,e.w-s.vlb];return s.vla+i>.3&&d.push(kt(`${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(kt(`${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(kt(`${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(kt(`${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 ca(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,Or(t,w,w.overhang??e.overhang)));let n=ca(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[Ld("main",null,s,a,l,c,u+Hd)];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*Re),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[kt("main:a",null,"a",g(b,-h,0),g(y,-h,0),g(b,0,f),e.pitch,v),kt("main:b",null,"b",g(b,h,0),g(y,h,0),g(b,0,f),e.pitch,v)]}function Ue(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 Oe="ground";function lo(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 co(t,e){let n=(e.rotation??0)*Re,r=[Math.cos(n),0,Math.sin(n)],i=[-Math.sin(n),0,Math.cos(n)],o=lo(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:Qc(o,s,l)):e.base??0;return{key:Oe,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===Oe?co(t,e):e.face.startsWith("wall:")?Ue(t,e.face.split(":")[1]).find(r=>r.key===e.face)??null:n.find(r=>r.key===e.face)??null}var uo=1.13,Nr=1.72,Ze=.025,at=.07;function un(t){let e=t.module_w||uo,n=t.module_h||Nr;return t.portrait===!1?[n,e]:[e,n]}function Br(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 ua(t,e){return t.flat?Math.min(45,Math.max(0,e.tilt??15))*Re:t.wall?Math.min(90,Math.max(0,e.tilt??0))*Re:Math.min(45,Math.max(0,e.tilt??0))*Re}function Wr(t,e){let[,n]=un(e),r=ua(t,e);return t.wall?n*Math.cos(r)+Ze:!t.flat&&r<.001?n+Ze: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]=un(e),i=Br(e),o=Math.max(1,...i);return[o*n+(o-1)*Ze,(i.length-1)*Wr(t,e)+r*Math.cos(ua(t,e))]}var gy=t=>t.flat&&!t.unbounded&&!t.wall;function Bd(t,e){if(!gy(t)||!e.rotation)return null;let n=e.rotation*Re,[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 qe(t,e,n=!1){let[r,i]=un(e),o=ua(t,e),s=i*Math.cos(o),l=Wr(t,e),a=Br(e),c=Math.max(1,...a),u=new Set(e.skip??[]),d=Bd(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],[E,T],[E,F],[M,F]].every(([O,P])=>f(O,P)))if(t.wall&&o>.001){let O=at+i*Math.sin(o),[P,C]=e.flip?[O,at]:[at,O],B=[h(M,T,P),h(E,T,P),h(E,F,C),h(M,F,C)],q=e.flip?T:F;g.push({corners:B,posts:[M+.05,E-.05].map(we=>[h(we,q,0),h(we,q,O)]),cell:x,skipped:k})}else if(!t.flat&&o>.001){let O=at+i*Math.sin(o),P=[h(M,T,at),h(E,T,at),h(E,F,O),h(M,F,O)];g.push({corners:P,posts:[M+.05,E-.05].map(C=>[h(C,F,0),h(C,F,O)]),cell:x,skipped:k})}else if(!t.flat)g.push({corners:[h(M,T,at),h(E,T,at),h(E,F,at),h(M,F,at)],posts:[],cell:x,skipped:k});else{let P=.15+i*Math.sin(o),C=e.rack==="ew"&&y%2===1?!e.flip:!!e.flip,[B,q]=C?[F,T]:[T,F],we=[h(M,B,.15),h(E,B,.15),h(E,q,P),h(M,q,P)],Rt=[M+.05,E-.05].flatMap(j=>[[h(j,B,0),h(j,B,.15)],[h(j,q,0),h(j,q,P)]]);g.push({corners:we,posts:Rt,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=Bd(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 Vr(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 ho=.78,Kr=1.18,dn=t=>({id:t.id,face:t.face,u:t.u,v:t.v,rows:1,cols:1,portrait:!0,module_w:t.w||ho,module_h:t.h||Kr});function da(t,e){let n=qe(t,dn(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 Cr={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 hn(t){let e=t.shape??"brick",n=Cr[e]??Cr.brick;return{shape:e,w:t.w||n.w,d:t.d||n.d,h:t.h||n.h}}function xt(t,e){let{w:n,d:r}=hn(t),i=e&&!e.flat?Math.cos(e.pitch*Re):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 ha(t,e){let n=xt(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 pa(t,e){let[n]=un(e);return Ge((t.lu-(e.cols*n+(e.cols-1)*Ze))/2)}var jr=.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]=un(n),[i,o]=t.span(t.ls/2);for(n.cols=Math.max(1,Math.floor((o-i-2*jr+Ze)/(r+Ze))),n.rows=Math.max(1,Math.min(4,Math.floor((t.ls-2*jr)/Wr(t,n))));n.cols>1&&qe(t,{...n,u:pa(t,n),v:jr}).lengthl.lu*(1.3+Math.cos((Lr(l.facing,r)-180)*Math.PI/180)),o=Ue(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+Ze)/(Nr+Ze))),s.u=Ge((o.lu-(s.cols*Nr+(s.cols-1)*Ze))/2),s.v=Ge(Math.max(0,o.ls-uo-.3)),s}function Gr(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:Oe,u:Ge(r),v:Ge(i),rows:2,cols:4,portrait:!0,tilt:25,flip:!0,rotation:(t.settings.north??0)||0,look:"black",entity:null}}function Ur(t,e,n){let r=co(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*Re,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:Ge(u),v:Ge(d),rotation:(Math.round(n)%360+360)%360}}function Zr(t,e){let[n,r]=t.span(t.ls/2);return{id:e,face:t.key,u:Ge((n+r-ho)/2),v:Ge(Math.max(0,Math.min(t.ls-Kr,t.ls*.45-Kr/2))),w:null,h:null,cover:null,contact:null,tilt:null}}function qr(t,e){let n=Cr.brick,[r,i]=t.span(t.ls*.8),o=xt({id:e,face:t.key,u:0,v:0},t).module_h;return{id:e,face:t.key,u:Ge((r+i-n.w)/2),v:Ge(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 ma(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 fo(t,e,n){let r=ln(n,t.n);if(Math.abs(r)<1e-6)return null;let i=ln(je(t.o,e),t.n)/r;if(i<=0)return null;let o=je([e[0]+n[0]*i,e[1]+n[1]*i,e[2]+n[2]*i],t.o);return{t:i,u:ln(o,t.eu),s:ln(o,t.es)}}function ga(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 _a(t,e,n,r){return qe(t,e).some(o=>{let s=o.corners.map(c=>{let u=je(c,t.o);return[ln(u,t.eu),ln(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 _y=["n","ne","e","se","s","sw","w","nw"],ba=(t,e)=>_y[Math.round(Lr(t.facing,e)/45)%8];function Yr(t,e){let n=r=>{if(r.flat)return r.lu*r.ls*.8;let i=Math.cos((Lr(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 jd=["kitchen_row","kitchen_l","bath","bedroom","living","dining","office","kids","hall"],Wd={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]]}},Vd=t=>typeof t=="string"?t:t[0],mo=t=>typeof t=="string"?nt[t]:t[1],Un=.05,by=.02,Kd=t=>Math.round(t*1e3)/1e3;function yy(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 Gd(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:Kd(c),z:Kd(u),rotation:d,w:p,d:h,h:f,variant:null,entity:null,power:null})};for(let[a,c,u]of Wd[e].rows){let d=a==="back"||a==="front"?i:o,p=0,h=[];for(let g of u){if(p+mo(g)[0]>d-.1)break;h.push(g),p+=mo(g)[0]}let f=c==="start"?Un:c==="end"?d-p-Un:(d-p)/2;for(let g of h){let b=mo(g),y=yy(r,a,f+b[0]/2,b[1]/2+by);l(Vd(g),y.x,y.z,y.turn,b),f+=b[0]}}for(let[a,c,u,d]of Wd[e].spots){let p=mo(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(Vd(a),f,g,d,p)}return s}var vy=30*Math.PI/180,Ud=.05;function ya(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 Xr(t){return ya(t).reduce((e,n)=>e+n,0)}function wy(t,e){let n=ya(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&&ky(t,a)>vy)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:wy(t,n.edge)+n.offset-n.width/2,width:e.reduce((r,i)=>r+i.width,0)}:null}function Bt(t,e){return e.front?t.filter(n=>n.front===e.front):[e]}function wa(t,e){let n=t.points.length,r=1/0,i=0,o=0;for(let s=0;sD("opening")){let s=va(e,r,i);if(!s)return null;let l=Bt(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 $a=globalThis,ka=$a.__nextfloorBuiltin?.de??{},xa=$a.__nextfloorBuiltin?.en??{};$a.__nextfloorBuiltin??={de:ka,en:xa};var xy=()=>typeof $=="object"&&$||{},$y=globalThis,Sy=$y.__nextfloorTexts??=new Map;function My(t){let e=t.toLowerCase().split("-")[0];return e!=="de"&&e!=="en"&&e in xy()?e:void 0}function Zd(t){let e=My(t),n=e===void 0?void 0:Sy.get(e);return n instanceof Promise?void 0:n}function go(t,e){return Zd(t)?.[e]}function Se(t,e,n={}){let r=t?.language??navigator.language,i=r.startsWith("de"),o=(i?void 0:Zd(r)?.[e])??(i?ka:xa)[e]??xa[e]??ka[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 qd=[{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 Yd(t,e,n){let r=s=>n({hvac:{...e.hvac,...s}}),i=e.hvac?.schedules??[],o=H(t.hass,s=>!!t.hass?.states[s]?.attributes.symcon_schedule);return m`
- ${z(t,t.t("floor_heating"),e.floor_heating??null,void 0,H(t.hass,s=>We(t.hass,s,[0,1,2])),s=>n({floor_heating:s==="none"?null:s}),{types:[0,1,2]})}
- ${qd.map(s=>z(t,s.label,e.hvac?.[s.key]??null,void 0,H(t.hass,l=>We(t.hass,l,s.types)),l=>r({[s.key]:l==="none"?null:l}),{types:s.types}))}
+ `}var rt=(t,e,n={})=>t.callWS({type:`nextfloor/${e}`,...n});async function so(t,e){return(await rt(t,"image/get",{image_id:e})).data}async function Nt(t,e,n){await rt(t,"image/set",{image_id:e,data:n})}async function pd(t){return(await rt(t,"history/list")).snapshots}async function fd(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 gd(t,e){await rt(t,"history/delete",{snapshot_id:e})}async function _d(t,e){return(await rt(t,"history/restore",{snapshot_id:e})).revision}var Ar=(t,e)=>rt(t,"packs/import",{pack:e});async function bd(t,e){await rt(t,"packs/remove",{pack_id:e})}var yd=t=>rt(t,"backup/export"),vd=(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],Me=(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]},Js=t=>[-t[1],t[0]],Qs=t=>[t[1],-t[0]];var Xb=.05,Jb=.2,Qb=.12;function ey(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 ty(t,e,n){if(t.room===e.room||Math.abs(Me(t.dir,e.dir))>Xb||t.outside===e.outside)return null;let r=(e.offset-t.offset)*t.outside;return r>n||r<-Qb||Math.abs(r)<1e-4||Math.min(t.to,e.to)-Math.max(t.from,e.from)Math.round(t*1e3)/1e3;function wd(t,e=.6){let n=ey(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(ea(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(Me(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(Me(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[ea(w[0]),ea(w[1])]})})),gaps:o}}function kd(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 ny=.25,xd=t=>Math.round(t*1e3)/1e3,$d=(t,e,n)=>t.rooms.find(r=>r.points.length>=3&&N([e,n],r.points));function na(t,e,n,r,i){let o=$d(t,e,n);if(!o)return[r,i];let s=(l,a)=>N([l,a],o.points);return s(r,i)?[r,i]:s(r,n)?[r,n]:s(e,i)?[e,i]:[e,n]}function ry(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 ta=(t,e)=>Math.abs((t-e+540)%360-180);function Fr(t,e,n,r=ny){let i=$d(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=ry(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)=>ta(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:xd(e.x-h[0]*x),z:xd(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 zr(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 Sd(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 Md(t,e){let n=Sd(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 ra(t,e,n){let r=Sd(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 Pr(t,e=0){let{x0:n,x1:r,z0:i,z1:o}=zr(t);return[[n-e,i-e],[r+e,i-e],[r+e,o+e],[n-e,o+e]].map(s=>Md(t,s))}function xe(t){let{x0:e,x1:n,z0:r,z1:i}=zr(t),o=s=>Md(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 Dr(t,e,n){let{x0:r,x1:i,z0:o,z1:s}=zr(t),[l,a]=ra(t,e,n);return t.axis==="x"?[l,t.flip?s-a:a-o]:[a,t.flip?i-l:l-r]}var Tr=Math.tan(30*Bn);function Ir(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+Tr*(t-s+o))/(2*Tr))),u=l+(c-o)*Tr;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)*Tr:p<=t-s?a+(t-s-p)*Tr:n+(t-p)*i}}function Ie(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=Ir(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 an=t=>Ie(t).rh;function Rd(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 iy(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 oy(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(Me(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 Ed(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]]:Rd(r[l[0]]),c=r[l[1]].a===s?r[l[1]]:Rd(r[l[1]]);if(!oy(a,c,e))continue;let u={...a,b:c.b,sources:iy(a.sources,c.sources)};o=[...r.filter((d,p)=>p!==l[0]&&p!==l[1]),u];break}if(!o)return r;r=o}}function Ad(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(Js(a.d),a.left)),right:ft(s,it(Qs(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(Js(a.d),a.left)),p=ft(s,it(Qs(u.d),u.right)),h=Me(a.d,u.d);if(Math.abs(h)<1e-4)return;let f=ft(d,it(a.d,Me(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 Fd(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(Me(ot(a),ot(c)))<1e-7&&te(a,c)>0});if(r===-1)return n;n=n.filter((i,o)=>o!==r)}}function sy(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 ay(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 ly(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 cy(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 zd(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 uy(t,e,n,r){let i=cy(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(Td),...zd(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:[Td(c)],...zd(i.heightsOf(d))})}return{drafts:s,open:l}}function dy(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 hy=(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),E=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&&N(k,T.points))?.id??null,E=(y.thickness??e.interior)/2;h.push({free:y.id,a:w,b:x,left:E,right:E,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=Ed(h,o.points,c),g=Ad(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`)],E=Fd([k.right,M.left,x,M.right,k.left,w],1e-6);return{id:hy(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:E,...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 Oe(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 Bt(t,e,n){if(!e.wall)return py(t,n.room,n.edge,e.offset);let r=t.find(i=>i.free===e.wall);return r?{wall:r,s:Pd(r,Wn(n.room,0,e.offset))}:null}function py(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:Pd(i,Wn(e,n,r))};return null}function Dd(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 Id=([t,e])=>{let n=Math.hypot(t,e)||1;return[t/n,e/n]};function fy(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 Od(t,e){let n=t.length;if(n<3||Math.abs(e)<1e-9)return t.map(([i,o])=>[i,o]);let r=fy(t)>=0?1:-1;return t.map((i,o)=>{let s=t[(o+n-1)%n],l=t[(o+1)%n],[a,c]=Id([i[0]-s[0],i[1]-s[1]]),[u,d]=Id([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 Wt(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 my(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 ia(t,e,n,r){let i=fe(t,{exterior:n,interior:r},e).walls.filter(l=>l.exterior&&!l.free),o=i.length?my(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?Od(s,n):null}function ln(t,e){let n=xe(t),r=Ie(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,E=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,qt,$i)=>{if(j==="hip")return{upA:[],upB:[],ridge:b(qt===l?n.u0+v*$i:n.u1-v*$i),profile:null};if(j==="halfhip"){let U_=b(qt===l?n.u0+E:n.u1-E);return{upA:[[qt,k,x]],upB:[[qt,M,x]],ridge:U_,profile:F}}return{upA:[],upB:[],ridge:b(qt),profile:T}},P=H(t.ends[0],l,1),C=H(t.ends[1],a,1),B=[[u,d,...C.upA,C.ridge,P.ridge,...[...P.upA].reverse()],[P.ridge,C.ridge,...[...C.upB].reverse(),p,h,...P.upB]],q=[[P.ridge,C.ridge]];for(let[j,qt,$i]of[[P,u,h],[C,d,p]])j.profile===null?(B.push(j===P?[h,u,j.ridge]:[d,p,j.ridge]),q.push([qt,j.ridge],[$i,j.ridge])):j.upA.length&&(B.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(C),p,h,...[...we(P)].reverse()];return{faces:B,rim:At,ridges:q,gable:T,endProfiles:[P.profile,C.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),E=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,E,M,T],[M,E,P,p,h,F],[F,T,M],[H,P,E]],rim:[u,d,H,P,p,h,F,T],ridges:[[M,E],[T,M],[F,M],[H,E],[P,E]],gable:[[0,r.y(0)],[w,v],[x,v],[i,r.y(i)]]}}case"mansard":{let y=Ir(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],E=[a,y.vr,y.rh];return{faces:[[u,d,w,v],[v,w,E,M],[M,E,k,x],[x,k,p,h]],rim:[u,d,w,E,k,p,h,x,M,v],ridges:[[M,E],[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 Or(t,e,n){let r=null;for(let i of t.faces){if(!N([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 Hr(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=>N(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 ao=t=>Math.abs((t.x1-t.x0)*(t.z1-t.z0)),Hd=t=>t.shape==="flat"||t.shape==="parapet",cn=t=>Math.round(t*100)/100;function lo(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||Hd(o)||ao(o)=s.x0&&n<=s.x1&&r>=s.z0&&r<=s.z1}).reduce((o,s)=>o===null||ao(s){let[o,s]=e.at(i,e.w/2),[l,a]=Dr(t,o,s);return Or(n,l,a)??r.y(a)}}function sa(t,e){if(Hd(e))return e;let n=xe(e),r=Ie(e).rh,i=_y(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 aa=.14,Ld=t=>t.shape==="flat"||t.shape==="parapet";function la(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&&!N([e,n],s.points))continue;let[h,f]=Dr(s,e,n),g=Math.max(0,s.overhang??r),b=Ld(s)?null:Or(ln(s,{u0:g,u1:g,a:g,b:g}),h,f);o.push((b??Ie(s).y(f))-aa)}return o.length?Math.max(...o):null}function ca(t,e,n){let r=[],i=e+n+aa;for(let o of t.settings.roof.sections??[]){if(o.open||Ld(o)||o.shape==="mansard")continue;let s=xe(o),l=Ie(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 ua(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=>N(c,a.points)))).map(l=>l.elevation+l.height);return s.length?Math.max(...s):null}function da(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=>N(p,d.points))));if(c)return c}return r.at(-1)??n[0]}var kt=t=>Math.round(t*1e3)/1e3;function ha(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=>N(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,E]=[d[b]-r,d[w+1]+r];Math.min(k-x,E-M)<.8||o.push({id:e(o.length),x0:kt(x),z0:kt(M),x1:kt(k),z1:kt(E),shape:"gable",axis:k-x>=E-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 Re=Math.PI/180,je=(t,e)=>[t[0]-e[0],t[1]-e[1],t[2]-e[2]],un=(t,e)=>t[0]*e[0]+t[1]*e[1]+t[2]*e[2],Vn=t=>Math.hypot(t[0],t[1],t[2]),dn=t=>{let e=Vn(t)||1;return[t[0]/e,t[1]/e,t[2]/e]},Cd=(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]],Ge=t=>Math.round(t*100)/100,Cr=([t,e],n)=>(Math.atan2(t,-e)/Re-n+720)%360;var Bd=.25;function Wd(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 Vd(t,e){let n=dn(Cd(t,e));return n[1]<0?[-n[0],-n[1],-n[2]]:n}var Kd=t=>{let e=dn([-t[0],0,-t[2]]);return[e[0],e[2]]};function xt(t,e,n,r,i,o,s,l){let a=dn(je(i,r)),c=dn(je(o,r));return{key:t,section:e,side:n,flat:!1,o:r,eu:a,es:c,n:Vd(a,c),lu:Vn(je(i,r)),ls:Vn(je(o,r)),pitch:s,span:l,facing:Kd(c)}}function Nd(t,e,n,r,i,o){let s=Vn(je(i,r));if(s<.3)return null;let l=dn(je(i,r)),a=je(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=dn(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:Vd(l,p),lu:s,ls:d,pitch:Math.atan2(p[1],Math.hypot(p[0],p[2]))/Re,span:h,facing:Kd(p)}}function by(t,e){let n=xe(t),r=Ie(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[Wd(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+Bd)]}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 yy(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=Nd(`${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=Nd(`${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 yy(t,e,n,r,i,o){let s=Ir(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)/Re,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 pa(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=>by(w,Hr(t,w,w.overhang??e.overhang)));let n=pa(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[Wd("main",null,s,a,l,c,u+Bd)];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*Re),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 Ue(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 He="ground";function co(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 uo(t,e){let n=(e.rotation??0)*Re,r=[Math.cos(n),0,Math.sin(n)],i=[-Math.sin(n),0,Math.cos(n)],o=co(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:ru(o,s,l)):e.base??0;return{key:He,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===He?uo(t,e):e.face.startsWith("wall:")?Ue(t,e.face.split(":")[1]).find(r=>r.key===e.face)??null:n.find(r=>r.key===e.face)??null}var ho=1.13,Br=1.72,Ze=.025,at=.07;function hn(t){let e=t.module_w||ho,n=t.module_h||Br;return t.portrait===!1?[n,e]:[e,n]}function Wr(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 fa(t,e){return t.flat?Math.min(45,Math.max(0,e.tilt??15))*Re:t.wall?Math.min(90,Math.max(0,e.tilt??0))*Re:Math.min(45,Math.max(0,e.tilt??0))*Re}function Vr(t,e){let[,n]=hn(e),r=fa(t,e);return t.wall?n*Math.cos(r)+Ze:!t.flat&&r<.001?n+Ze: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]=hn(e),i=Wr(e),o=Math.max(1,...i);return[o*n+(o-1)*Ze,(i.length-1)*Vr(t,e)+r*Math.cos(fa(t,e))]}var vy=t=>t.flat&&!t.unbounded&&!t.wall;function jd(t,e){if(!vy(t)||!e.rotation)return null;let n=e.rotation*Re,[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 qe(t,e,n=!1){let[r,i]=hn(e),o=fa(t,e),s=i*Math.cos(o),l=Vr(t,e),a=Wr(e),c=Math.max(1,...a),u=new Set(e.skip??[]),d=jd(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],[E,T],[E,F],[M,F]].every(([H,P])=>f(H,P)))if(t.wall&&o>.001){let H=at+i*Math.sin(o),[P,C]=e.flip?[H,at]:[at,H],B=[h(M,T,P),h(E,T,P),h(E,F,C),h(M,F,C)],q=e.flip?T:F;g.push({corners:B,posts:[M+.05,E-.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(E,T,at),h(E,F,H),h(M,F,H)];g.push({corners:P,posts:[M+.05,E-.05].map(C=>[h(C,F,0),h(C,F,H)]),cell:x,skipped:k})}else if(!t.flat)g.push({corners:[h(M,T,at),h(E,T,at),h(E,F,at),h(M,F,at)],posts:[],cell:x,skipped:k});else{let P=.15+i*Math.sin(o),C=e.rack==="ew"&&y%2===1?!e.flip:!!e.flip,[B,q]=C?[F,T]:[T,F],we=[h(M,B,.15),h(E,B,.15),h(E,q,P),h(M,q,P)],At=[M+.05,E-.05].flatMap(j=>[[h(j,B,0),h(j,B,.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=jd(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 Kr(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 po=.78,jr=1.18,pn=t=>({id:t.id,face:t.face,u:t.u,v:t.v,rows:1,cols:1,portrait:!0,module_w:t.w||po,module_h:t.h||jr});function ma(t,e){let n=qe(t,pn(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 Nr={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 fn(t){let e=t.shape??"brick",n=Nr[e]??Nr.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}=fn(t),i=e&&!e.flat?Math.cos(e.pitch*Re):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 ga(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 _a(t,e){let[n]=hn(e);return Ge((t.lu-(e.cols*n+(e.cols-1)*Ze))/2)}var Gr=.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]=hn(n),[i,o]=t.span(t.ls/2);for(n.cols=Math.max(1,Math.floor((o-i-2*Gr+Ze)/(r+Ze))),n.rows=Math.max(1,Math.min(4,Math.floor((t.ls-2*Gr)/Vr(t,n))));n.cols>1&&qe(t,{...n,u:_a(t,n),v:Gr}).lengthl.lu*(1.3+Math.cos((Cr(l.facing,r)-180)*Math.PI/180)),o=Ue(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+Ze)/(Br+Ze))),s.u=Ge((o.lu-(s.cols*Br+(s.cols-1)*Ze))/2),s.v=Ge(Math.max(0,o.ls-ho-.3)),s}function Ur(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:He,u:Ge(r),v:Ge(i),rows:2,cols:4,portrait:!0,tilt:25,flip:!0,rotation:(t.settings.north??0)||0,look:"black",entity:null}}function Zr(t,e,n){let r=uo(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*Re,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:Ge(u),v:Ge(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:Ge((n+r-po)/2),v:Ge(Math.max(0,Math.min(t.ls-jr,t.ls*.45-jr/2))),w:null,h:null,cover:null,contact:null,tilt:null}}function Yr(t,e){let n=Nr.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:Ge((r+i-n.w)/2),v:Ge(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 ya(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 mo(t,e,n){let r=un(n,t.n);if(Math.abs(r)<1e-6)return null;let i=un(je(t.o,e),t.n)/r;if(i<=0)return null;let o=je([e[0]+n[0]*i,e[1]+n[1]*i,e[2]+n[2]*i],t.o);return{t:i,u:un(o,t.eu),s:un(o,t.es)}}function va(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 wa(t,e,n,r){return qe(t,e).some(o=>{let s=o.corners.map(c=>{let u=je(c,t.o);return[un(u,t.eu),un(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 wy=["n","ne","e","se","s","sw","w","nw"],ka=(t,e)=>wy[Math.round(Cr(t.facing,e)/45)%8];function Xr(t,e){let n=r=>{if(r.flat)return r.lu*r.ls*.8;let i=Math.cos((Cr(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 qd=["kitchen_row","kitchen_l","bath","bedroom","living","dining","office","kids","hall"],Gd={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]]}},Ud=t=>typeof t=="string"?t:t[0],go=t=>typeof t=="string"?nt[t]:t[1],Un=.05,ky=.02,Zd=t=>Math.round(t*1e3)/1e3;function xy(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 Yd(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:Zd(c),z:Zd(u),rotation:d,w:p,d:h,h:f,variant:null,entity:null,power:null})};for(let[a,c,u]of Gd[e].rows){let d=a==="back"||a==="front"?i:o,p=0,h=[];for(let g of u){if(p+go(g)[0]>d-.1)break;h.push(g),p+=go(g)[0]}let f=c==="start"?Un:c==="end"?d-p-Un:(d-p)/2;for(let g of h){let b=go(g),y=xy(r,a,f+b[0]/2,b[1]/2+ky);l(Ud(g),y.x,y.z,y.turn,b),f+=b[0]}}for(let[a,c,u,d]of Gd[e].spots){let p=go(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(Ud(a),f,g,d,p)}return s}var $y=30*Math.PI/180,Xd=.05;function xa(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 Jr(t){return xa(t).reduce((e,n)=>e+n,0)}function Sy(t,e){let n=xa(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&&My(t,a)>$y)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:Sy(t,n.edge)+n.offset-n.width/2,width:e.reduce((r,i)=>r+i.width,0)}:null}function Vt(t,e){return e.front?t.filter(n=>n.front===e.front):[e]}function Sa(t,e){let n=t.points.length,r=1/0,i=0,o=0;for(let s=0;sD("opening")){let s=$a(e,r,i);if(!s)return null;let l=Vt(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 Ea=globalThis,Ma=Ea.__nextfloorBuiltin?.de??{},Ra=Ea.__nextfloorBuiltin?.en??{};Ea.__nextfloorBuiltin??={de:Ma,en:Ra};var Ry=()=>typeof $=="object"&&$||{},Ey=globalThis,Ay=Ey.__nextfloorTexts??=new Map;function Fy(t){let e=t.toLowerCase().split("-")[0];return e!=="de"&&e!=="en"&&e in Ry()?e:void 0}function Jd(t){let e=Fy(t),n=e===void 0?void 0:Ay.get(e);return n instanceof Promise?void 0:n}function _o(t,e){return Jd(t)?.[e]}function Se(t,e,n={}){let r=t?.language??navigator.language,i=r.startsWith("de"),o=(i?void 0:Jd(r)?.[e])??(i?Ma:Ra)[e]??Ra[e]??Ma[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 St={electricity:"Strom",water:"Wasser",gas:"Gas",heating:"Heizen",cooling:"K\xFChlen"},qn={electricity:"\u26A1",water:"\u{1F4A7}",gas:"\u{1F525}",heating:"\u2668",cooling:"\u2744"},vo=t=>t.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/ß/g,"ss").replace(/[^a-z0-9]+/g," ").trim(),Ty="{485D0419-BE97-4548-AA9C-C083EB82E61E}",zy=t=>t.object_type!==0&&!(t.object_type===1&&t.module_id?.toUpperCase()===Ty)?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"}[vo(t.name)]??null,bo=t=>/^symcon-category-(\d+)$/.exec(t??"")?.[1],Fa=t=>/\b(heute|tag|tagesverbrauch|today|daily)\b/.test(t)?"day":/monat|month/.test(t)?"month":/jahr|year/.test(t)?"year":"total",wo=(t,e)=>String(t.states[e]?.attributes.symcon_source_entity||e);function th(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 Py(t,e){if(!e.entity_id||e.object_type!==2&&e.object_type!==6)return null;let n=wo(t,e.entity_id),r=t.states[n];if(!r||![1,2].includes(Number(r.attributes.symcon_variable_type)))return null;let i=vo(e.name),o=th(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"?Fa(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 Qd=new WeakMap,eh=new WeakMap;function nh(t){let e=Qd.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 Qd.set(t,n),n}function Dy(t,e,n){if(!Q(t))return[];let r=[e.area_id,...e.sub_areas??[]].map(bo).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(bo).filter(p=>!!p&&!r.includes(p))),o=`${r.join(",")}|${[...i].sort().join(",")}`,s=eh.get(t)??new Map;eh.set(t,s);let l=s.get(o);if(l)return l;let a=nh(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=zy(g),y=b??h,v=new Set(b&&b!==h?[]:f),w=a.children.get(p)??[];if(y){let x=w.map(k=>Py(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),E=Math.max(...M.map(F=>F.score)),T=M.filter(F=>F.score===E);for(let F of E>=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 yo(t,e,n=!1){let r=new Map,i=new Set;for(let o of e){let s=wo(t,o.id),l=`${o.kind}|${o.metric}|${s}`;if(i.has(l))continue;i.add(l);let a=t.states[s],c=th(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=nn(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 Aa(t,e){return wt.flatMap(n=>["power","energy"].flatMap(r=>{let i=e.utility_meters?.[n]?.[r];if(!i||i==="none")return[];let o=wo(t,i);return[{kind:n,metric:r,id:o,period:r==="energy"?Fa(vo(String(t.states[o]?.attributes.friendly_name??""))):"total"}]}))}function Iy(t,e){return Q(t)?yo(t,Aa(t,e),!0):[]}function Oy(t,e,n=e.rooms){if(!Q(t))return[];let r=new Map;for(let o of e.rooms){let s=[...new Set([o.area_id,...o.sub_areas??[]].filter(l=>!!bo(l)))];!s.length&&Aa(t,o).length&&s.push("unassigned");for(let l of s){let a=r.get(l)??{seed:o,members:[]};l===s[0]&&a.members.push(o),r.set(l,a)}}let i=nh(t.symconObjects).nodes;return[...r].map(([o,s])=>{let l=i.get(Number(bo(o))),a=o==="unassigned"?[]:yo(t,Dy(t,{...s.seed,area_id:o,sub_areas:null},n)),c=yo(t,s.members.flatMap(p=>Aa(t,p)),!0),u=p=>a.some(h=>h.kind===p.kind&&h.metric===p.metric&&h.unit===p.unit&&h.period===p.period),d=s.members.map(p=>({id:p.id,name:p.name,readings:Iy(t,p)})).filter(p=>p.readings.length);return{id:o,name:o==="unassigned"?"Nicht zugeordnet":l?.name||t.areas?.[o]?.name||"Bereich nicht verf\xFCgbar",path:l?.path||"",readings:[...a,...c.filter(p=>!u(p))],rooms:d}}).filter(o=>o.readings.length||o.rooms.length)}function Ta(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"?wo(t,o):null}function rh(t,e,n=e.rooms){let r=Oy(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=Ta(t,e,o,s);i.push(...yo(t,l?[{kind:o,metric:s,id:l,period:s==="energy"?Fa(vo(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 ih(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 oh=[{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 sh(t,e,n){let r=O(t.hass,i=>De(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`${qn[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 ah(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=>De(t.hass,s,[0,1,2])),s=>n({floor_heating:s==="none"?null:s}),{types:[0,1,2]})}
+ ${oh.map(s=>z(t,s.label,e.hvac?.[s.key]??null,void 0,O(t.hass,l=>De(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 Xd(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
- ${Wc.map(i=>z(t,Ou[i],e.weather_variables?.[i]??null,void 0,H(t.hass,o=>We(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,H(t.hass,i=>We(t.hass,i,[0,1,2])),i=>n({rain_sensor:i==="none"?null:i}),{types:[0,1,2]})}
+ ${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 lh(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
+ ${Gc.map(i=>z(t,Nu[i],e.weather_variables?.[i]??null,void 0,O(t.hass,o=>De(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=>De(t.hass,i,[0,1,2])),i=>n({rain_sensor:i==="none"?null:i}),{types:[0,1,2]})}
${e.rain_sensor?I(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 Jd(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=H(t.hass,s=>We(t.hass,s,[0]));return m`
${t.t("presence")}
+ `}function ch(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=>De(t.hass,s,[0]));return m`${t.t("presence")}
${e.map((s,l)=>m`
${V(t,"Person",s.name??W(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})}
@@ -497,111 +500,111 @@ 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 Qd(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 th(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 nh(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 _o(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 Wt=(t,e)=>t.filter((n,r)=>r!==e),Qr=(t,e,n)=>t.map((r,i)=>i===e?{...r,...n}:r),gt=t=>t.length>0?t:void 0;var Ry=["scene","script","automation","button","input_button","switch","input_boolean","light","fan","cover","lock"],Ey=40,Ay=20,Fy=30,Ty=["music","url","playlist","SPOTIFY","AMAZON_MUSIC","TUNEIN","APPLE_MUSIC"],Sa={navigate:"/lovelace/rollos",more_info:"cover.wohnzimmer",service:"script.turn_on",fire_dom_event:""},ei=(t,e,n,r=!1)=>m`${e} `;function zy(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=H(t.hass,l=>Ry.includes(l.split(".")[0])&&!e.includes(l)),s=(l,a)=>m`
+ `}function uh(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 dh(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 hh(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 ph(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 ko(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 Kt=(t,e)=>t.filter((n,r)=>r!==e),ei=(t,e,n)=>t.map((r,i)=>i===e?{...r,...n}:r),gt=t=>t.length>0?t:void 0;var Hy=["scene","script","automation","button","input_button","switch","input_boolean","light","fan","cover","lock"],Ly=40,Cy=20,Ny=30,By=["music","url","playlist","SPOTIFY","AMAZON_MUSIC","TUNEIN","APPLE_MUSIC"],Pa={navigate:"/lovelace/rollos",more_info:"cover.wohnzimmer",service:"script.turn_on",fire_dom_event:""},ti=(t,e,n,r=!1)=>m`
${e} `;function Wy(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=>Hy.includes(l.split(".")[0])&&!e.includes(l)),s=(l,a)=>m`
${W(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} `)}
`:_}
- ${ei(t.t("move_up"),"\u2191",()=>n(_o(e,a,-1)),a===0)}
- ${ei(t.t("move_down"),"\u2193",()=>n(_o(e,a,1)),a===e.length-1)}
- ${ei(t.t("delete"),"\u2715",()=>n(Wt(e,a)))}
+ ${ti(t.t("move_up"),"\u2191",()=>n(ko(e,a,-1)),a===0)}
+ ${ti(t.t("move_down"),"\u2193",()=>n(ko(e,a,1)),a===e.length-1)}
+ ${ti(t.t("delete"),"\u2715",()=>n(Kt(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 Py(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?ju(t.hass,t.doc.floors):[]),o=H(t.hass,s=>!n.includes(s)&&i.has(s));return m`${e?Dy(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 Vy(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?qu(t.hass,t.doc.floors):[]),o=O(t.hass,s=>!n.includes(s)&&i.has(s));return m`${e?Ky(t,e):_}
${t.t("outside_hidden")}${n.length>0?m` ${n.length} `:_}
${S(t.t("outside_hidden_hint"))}
- ${n.map((s,l)=>m`${W(t.hass,s)} ${ei(t.t("delete"),"\u2715",()=>r(Wt(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 Dy(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"))}
- ${X(m`${t.t("outside_view_set")} `,n?m`t.change(i=>i.settings.outside_view=null)}>${t.t("outside_view_reset")} `:_)}`}function Iy(t){let e=t.doc.settings.own_alerts??[],n=s=>t.change(l=>l.settings.own_alerts=gt(s)),r=(s,l)=>n(Qr(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,H(t.hass,()=>!0),a=>r(l,{entity:a&&a!=="none"?a:""}))}
+ ${n.map((s,l)=>m`
${W(t.hass,s)} ${ti(t.t("delete"),"\u2715",()=>r(Kt(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 Ky(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"))}
+ ${X(m`
${t.t("outside_view_set")} `,n?m`
t.change(i=>i.settings.outside_view=null)}>${t.t("outside_view_reset")} `:_)}`}function jy(t){let e=t.doc.settings.own_alerts??[],n=s=>t.change(l=>l.settings.own_alerts=gt(s)),r=(s,l)=>n(ei(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})}
${Ke(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(Wt(e,l))}>${t.t("delete")}
+
n(Kt(e,l))}>${t.t("delete")}
`;return m`
⚠ ${t.t("own_alerts")}
${S(t.t("own_alerts_hint"))} ${e.map(o)}
- ${e.length<40?X(m`
n([...e,{id:D("alert"),entity:"",state:null,text:t.t("own_alert_new")}])}>+ ${t.t("own_alert_add")} `):_}`}function Oy(t){let e=t.doc.settings.circuits??[],n=l=>t.change(a=>a.settings.circuits=gt(l)),r=(l,a)=>n(Qr(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?X(m`
n([...e,{id:D("alert"),entity:"",state:null,text:t.t("own_alert_new")}])}>+ ${t.t("own_alert_add")} `):_}`}function Gy(t){let e=t.doc.settings.circuits??[],n=l=>t.change(a=>a.settings.circuits=gt(l)),r=(l,a)=>n(ei(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`
`;return m`
🔌 ${t.t("circuits")}
${S(t.t("circuits_hint"))} ${e.map(s)}
- ${e.length<120?X(m`
n([...e,{id:D("circuit"),name:t.t("circuit_new"),rooms:[]}])}>+ ${t.t("circuit_add")} `):_}`}function Hy(t){let e=t.doc.settings.calendars??[],n=l=>t.change(a=>a.settings.calendars=gt(l)),r=H(t.hass,l=>l.startsWith("calendar.")&&!e.includes(l)),i=(l,a)=>m`
+ ${e.length<120?X(m`
n([...e,{id:D("circuit"),name:t.t("circuit_new"),rooms:[]}])}>+ ${t.t("circuit_add")} `):_}`}function Uy(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`
${W(t.hass,l)}
- ${ei(t.t("delete"),"\u2715",()=>n(Wt(e,a)))}
+ ${ti(t.t("delete"),"\u2715",()=>n(Kt(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))}
`:_}
- ${Ly(t)}`}function Ly(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")}
+ ${Zy(t)}`}function Zy(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 Cy(t){let e=t.doc.settings.media_presets??[],n=s=>t.change(l=>l.settings.media_presets=gt(s)),r=(s,l)=>n(Qr(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`
+
`}function qy(t){let e=t.doc.settings.media_presets??[],n=s=>t.change(l=>l.settings.media_presets=gt(s)),r=(s,l)=>n(ei(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"))}
-
${Ty.map(s=>m` `)}
+
${By.map(s=>m` `)}
${e.map(o)}
- ${e.length
n([...e,{id:D("preset"),label:"Radio",type:"music",content:""}])}>+ ${t.t("preset_add")}`):_}`}function Ma(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=nh(s.value);if(l.ok)return n(l.value);s.setCustomValidity(t.t("own_data_bad")),s.reportValidity()};return m`n([...e,{id:D("preset"),label:"Radio",type:"music",content:""}])}>+ ${t.t("preset_add")}`):_}`}function Da(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=ph(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 Ny(t){let e=t.doc.settings.buttons??[],n=s=>t.change(l=>l.settings.buttons=gt(s)),r=(s,l)=>n(Qr(e,s,l)),i=Hi.map(s=>[s,t.t(`own_action_${s}`)]),o=(s,l)=>m`
+ `}function Yy(t){let e=t.doc.settings.buttons??[],n=s=>t.change(l=>l.settings.buttons=gt(s)),r=(s,l)=>n(ei(e,s,l)),i=Li.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}))} ${Ht(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:Sa[s.action]}):_}
- ${s.action==="service"||s.action==="fire_dom_event"?Ma(t,s,a=>r(l,{data:a})):_}
- ${z(t,t.t("own_button_state"),s.state_entity??null,void 0,H(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}))}
+ ${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:Pa[s.action]}):_}
+ ${s.action==="service"||s.action==="fire_dom_event"?Da(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(_o(e,l,-1))}>↑
- n(Wt(e,l))}>${t.t("delete")}
+ n(ko(e,l,-1))}>↑
+ n(Kt(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:D("btn"),label:t.t("own_button_new"),action:"navigate",target:null}])}>+ ${t.t("own_button_add")}`):_}`}function By(t){let e=t.doc.settings.room_facts_off??[],n=["sun","comfort","air","circuits"].map(r=>I(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 rh(t){return m`${zy(t)} ${Ny(t)} ${Iy(t)} ${Oy(t)} ${Hy(t)} ${Cy(t)} ${By(t)} `}function ih(t,e){return m`
+ ${e.lengthn([...e,{id:D("btn"),label:t.t("own_button_new"),action:"navigate",target:null}])}>+ ${t.t("own_button_add")}`):_}`}function Xy(t){let e=t.doc.settings.room_facts_off??[],n=["sun","comfort","air","circuits"].map(r=>I(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 fh(t){return m`${Wy(t)} ${Yy(t)} ${jy(t)} ${Gy(t)} ${Uy(t)} ${qy(t)} ${Xy(t)} `}function mh(t,e){return m`
🌳 ${t.t("outside_area")}
- ${Py(t,e)}
- `}function oh(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`
+ ${Vy(t,e)}
+ `}function gh(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"))}
${X(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"))}${th(n)}`:_}
- `}function sh(t){if(re(t.hass))return Jd(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=H(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:Qd(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,`${W(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"))}${hh(n)}`:_}
+ `}function _h(t){if(Q(t.hass))return ch(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:uh(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,`${W(t.hass,a)} \xB7 ${t.t("presence_sensor")}`,c?.sensor??null,void 0,dh(r,a),d=>o(a,{sensor:d}))}
${t.t("presence_room")}
o(a,{room:d.target.value||null})}>
${t.t("presence_room_none")}
${i.map(d=>m`${d.label} `)}
- ${u?m`t.replace({...structuredClone(t.doc),presence:t.doc.presence.filter(d=>d.person!==a)})}>${t.t("delete")} `:_}`},l=H(t.hass,a=>/^(input_boolean|binary_sensor|device_tracker)\./.test(a)&&!n.includes(a));return m`
+ ${u?m`t.replace({...structuredClone(t.doc),presence:t.doc.presence.filter(d=>d.person!==a)})}>${t.t("delete")} `:_}`},l=O(t.hass,a=>/^(input_boolean|binary_sensor|device_tracker)\./.test(a)&&!n.includes(a));return m`
${t.t("presence")}
${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 ah(t,e){return re(t.hass)?m``:m`
+ `}function bh(t,e){return Q(t.hass)?m``:m`
${t.t("ble")}
${S(t.t("ble_hint"))}
- `}var ti=(t,e)=>{let n=t._$AN;if(n===void 0)return!1;for(let r of n)r._$AO?.(e,!1),ti(r,e);return!0},bo=t=>{let e,n;do{if((e=t._$AM)===void 0)break;n=e._$AN,n.delete(t),t=e}while(n?.size===0)},lh=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),Ky(e)}};function Wy(t){this._$AN!==void 0?(bo(this),this._$AM=t,lh(this)):this._$AM=t}function Vy(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==Dn.CHILD&&(t._$AP??=Vy,t._$AQ??=Wy)},yo=class extends It{constructor(){super(...arguments),this._$AN=void 0}_$AT(e,n,r){super._$AT(e,n,r),lh(this),this.isConnected=e._$AU}_$AO(e,n=!0){e!==this.isConnected&&(this.isConnected=e,e?this.reconnected?.():this.disconnected?.()),n&&(ti(this,e),bo(this))}setValue(e){if(Ju(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 Ra=new WeakMap,ch=tn(class extends yo{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=Ra.get(e);n===void 0&&(n=new WeakMap,Ra.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"?Ra.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 uh=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 dh(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=uh(l.value);!a||a in n||r.length>=20||(l.value="",i({...n,[a]:{}}))};return m`
+ `}var ni=(t,e)=>{let n=t._$AN;if(n===void 0)return!1;for(let r of n)r._$AO?.(e,!1),ni(r,e);return!0},xo=t=>{let e,n;do{if((e=t._$AM)===void 0)break;n=e._$AN,n.delete(t),t=e}while(n?.size===0)},yh=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),ev(e)}};function Jy(t){this._$AN!==void 0?(xo(this),this._$AM=t,yh(this)):this._$AM=t}function Qy(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==Dn.CHILD&&(t._$AP??=Qy,t._$AQ??=Jy)},$o=class extends Ht{constructor(){super(...arguments),this._$AN=void 0}_$AT(e,n,r){super._$AT(e,n,r),yh(this),this.isConnected=e._$AU}_$AO(e,n=!0){e!==this.isConnected&&(this.isConnected=e,e?this.reconnected?.():this.disconnected?.()),n&&(ni(this,e),xo(this))}setValue(e){if(nd(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 Ia=new WeakMap,vh=rn(class extends $o{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=Ia.get(e);n===void 0&&(n=new WeakMap,Ia.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"?Ia.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 wh=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 kh(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=wh(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]}))}
+ ${vh(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`
@@ -617,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 vo=.05,jy=(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),pn=t=>new Map(t.map(e=>[e.id,e]));function Gy(t,e,n,r){let i=e.name,[o,s]=[pn(t.rooms),pn(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}),jy(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]=[pn(t.openings),pn(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]=[pn(t.furniture),pn(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)>vo||Math.abs(h.rotation-f.rotation)>1||Math.abs(h.w-f.w)>vo||Math.abs(h.d-f.d)>vo)&&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)>vo&&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 hh(t,e){let n=[],r=pn(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?Gy(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 fn=(t,e)=>t.getUint16(e,!0),ni=(t,e)=>t.getUint32(e,!0);function ph(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(ni(e,l)===101010256){n=l;break}if(n<0)throw new Error("not_zip");let r=fn(e,n+10),i=ni(e,n+16),o=[],s=new TextDecoder;for(let l=0;l",quot:'"',apos:"'"},Zy=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)):Uy[n]??e);function qy(t){let e={};for(let n of t.matchAll(/([\w:.-]+)\s*=\s*(?:"([^"]*)"|'([^']*)')/g))e[n[1]]=Zy(n[2]??n[3]);return e}function Yy(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=qy(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,Ee=t=>Math.round(t*1e3)/1e3;function mh(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 Xy(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 Jy(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 Qy(t){let e=Tt(),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=Ce(D("floor"),a.attrs.name||(c===0?"Erdgeschoss":`Etage ${c+1}`),Ee(oe(a.attrs,"elevation",0)/100));p.height=Ee(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:D("room"),name:b.attrs.name||`Raum ${y+1}`,area_id:null,points:Jy(b.points,h).map(([v,w])=>[Ee(v),Ee(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 O of f)O.points.forEach((P,C)=>{let B=mh(y,P,O.points[(C+1)%O.points.length]);B.dist<=v&&(!w||B.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(O=>O.points.some((P,C)=>mh(F,P,O.points[(C+1)%O.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,O)=>!x(E(O)));for(let F=0;F<=M;){if(!T[F]){F++;continue}let O=F;for(;O+1<=M&&T[O+1];)O++;let[P,C]=[E(Math.max(0,F-1)),E(Math.min(M,O+1))];Math.hypot(C[0]-P[0],C[1]-P[1])>=.3&&g.push({id:D("wall"),a:[Ee(P[0]),Ee(P[1])],b:[Ee(C[0]),Ee(C[1])],thickness:Ee(oe(b.attrs,"thickness",10)/100),height:b.attrs.height?Ee(oe(b.attrs,"height",250)/100):null}),F=O+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:Pe(e),report:n}}async function gh(t){let e=ph(t).find(i=>i.name==="Home.xml");if(!e)throw new Error("sh3d_no_xml");let n=new TextDecoder().decode(await fh(t,e)),r=Qy(Yy(n));if(r.report.rooms===0&&r.report.walls===0)throw new Error("sh3d_empty");return r}function ev(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 nv(t){let e=ev(t),n=tv(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 _h=t=>Math.round(t*1e3)/1e3;function bh(t){let{shapes:e,unit:n}=nv(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])=>[_h((h-s)*o),_h((l-f)*o)],c=Ce(D("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:D("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:D("wall"),a:f[g],b:f[g+1]})}c.rooms=u,c.walls=d;let p=Tt();return p.floors=[c],{building:Pe(p),report:{floors:1,rooms:u.length,openings:0,walls:d.length,furniture:0}}}var Ye=t=>Math.round(t*100)/100;function rv(t,e){let n=t.category;return typeof n=="string"?n:n&&typeof n=="object"?Object.keys(n)[0]??e:e}function iv(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:rv(n,e)}}var qn=(t,e,n)=>(Array.isArray(t[e])?t[e]:[]).map(r=>iv(r,n)).filter(r=>!!r);function ov(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 yh(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 sv(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 av={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 vh(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 wh(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=>ov(b.walls)),l=r.flatMap((b,y)=>s[y]?.points??yh(b.walls)),[a,c]=[Math.min(...l.map(b=>b[0]))-.5,Math.min(...l.map(b=>b[1]))-.5],u=([b,y])=>[Ye(b-a),Ye(y-c)],d=Ce(D("floor"),"Erdgeschoss",0);d.height=Ye(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??yh(b.walls)).map(u),x={id:D("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],E=null;if(w.forEach((P,C)=>{let B=sv(M,P,w[(C+1)%w.length]);B.dist<=.6&&(!E||B.dist1.4?2:1,swing:"in",...O?{style:"passage"}:{},cover:null,contact:null,contact2:null,tilt:null})}for(let k of b.objects){let M=av[k.kind];if(!M)continue;let[E,T,F]=[k.size[0],k.size[2],k.size[1]];E<.1||T<.1||h.push({id:D("f"),type:M,x:Ye(k.centre[0]-a),z:Ye(k.centre[2]-c),rotation:Math.round((Math.atan2(k.dir[1],k.dir[0])*180/Math.PI+360)%360),w:Ye(E),d:Ye(T),h:Ye(F),variant:null,entity:null,power:null})}}),d.rooms=p,d.furniture=h;let f=Tt();f.floors=[d];let g=r.reduce((b,y)=>b+y.objects.length,0)-h.length;return{building:Pe(f),report:{floors:1,rooms:p.length,openings:d.openings.length,walls:0,furniture:g}}}var ri=t=>typeof t=="object"&&t!==null&&!Array.isArray(t)&&"ref"in t;function lv(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 uv(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:lv(r[3])});return e}var kh={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 $h(t){let e=uv(t);if(!e.size)throw new Error("ifc_empty");let n=k=>ri(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 kh;let[E=0,T=0,F=0]=i(M.args[0]),O=n(M.type==="IFCAXIS2PLACEMENT3D"?M.args[2]:M.args[1]),[P=1,C=0]=(O?.args[0]??[]).map(q=>r(q)),B=Math.hypot(P,C)||1;return{x:E||0,y:T||0,z:F||0,c:P/B,s:C/B}},a=(k,M=0)=>{let E=n(k);return!E||E.type!=="IFCLOCALPLACEMENT"||M>30?kh:xh(a(E.args[0],M+1),l(E.args[1]))},c=k=>{for(let M of n(k)?.args[2]??[])for(let E of n(M)?.args[3]??[]){let T=n(E);if(T?.type!=="IFCEXTRUDEDAREASOLID")continue;let F=n(T.args[0]),O=xh(l(T.args[1]),l(F?.args[2])),P=[];if(F?.type==="IFCRECTANGLEPROFILEDEF"){let[C,B]=[r(F.args[3])/2,r(F.args[4])/2];P=[[-C,-B],[C,-B],[C,B],[-C,B]]}else if(F?.type==="IFCARBITRARYCLOSEDPROFILEDEF"){let C=n(F.args[2]);C?.type==="IFCPOLYLINE"&&(P=(C.args[0]??[]).map(B=>i(B)))}if(P=P.filter(C=>Number.isFinite(C[0])&&Number.isFinite(C[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(([C,B])=>[O.x+O.c*C-O.s*B,O.y+O.s*C+O.c*B])}return null},u=new Map;for(let[,k]of e){if(k.type==="IFCRELAGGREGATES"&&ri(k.args[4]))for(let M of k.args[5]??[])ri(M)&&u.set(M.ref,k.args[4].ref);if(k.type==="IFCRELCONTAINEDINSPATIALSTRUCTURE"&&ri(k.args[5]))for(let M of k.args[4]??[])ri(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 E=c(M.args[6]);if(!E)continue;let T=a(M.args[5]),F=E.map(([P,C])=>[(T.x+T.c*P-T.s*C)*s,(T.y+T.s*P+T.c*C)*s]),O=String(M.args[7]||M.args[2]||"")||`Raum ${p.length+1}`;p.push({storey:u.get(k)??null,name:O,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 E=Ce(D("floor"),k.name??`Etage ${M+1}`,Number.isFinite(k.elevation)?b(k.elevation):M*2.8);y.push(E),v.set(k.id,E)}),p.some(k=>k.storey===null||!v.has(k.storey))){let k=Ce(D("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 E=y[M+1];E&&E.elevation-k.elevation>1.8&&(k.height=b(E.elevation-k.elevation-.2))});for(let k of p)v.get(k.storey!==null&&v.has(k.storey)?k.storey:null).rooms.push({id:D("room"),name:k.name,area_id:null,points:k.ring.map(([E,T])=>[b(E-f),b(g-T)]),floor_material:"wood",panel:[]});let x=Tt();return x.floors=y,{building:Pe(x),report:{floors:y.length,rooms:p.length,openings:0,walls:0,furniture:0}}}var Mh="nextfloor",dv="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",Sh=new RegExp(`^(?:${dv})\\.[a-z0-9_]+$`),hv=/^[0-9a-f]{32}$/,pv=new Set(["area_id","ha_floor"]),fv=new Set(["sub_areas"]),mv=new Set(["tap","show_when","pictures","moods"]);function Ea(t){if(typeof t=="string")return Sh.test(t)||hv.test(t)?null:t;if(Array.isArray(t))return t.map(e=>Ea(e)).filter(e=>e!==null);if(t&&typeof t=="object"){let e={};for(let[n,r]of Object.entries(t))Sh.test(n)||mv.has(n)||(pv.has(n)||fv.has(n)?e[n]=null:e[n]=Ea(r));return e}return t}var gv=["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 Rh(t){let e=structuredClone(t),n={};for(let i of gv)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 Ea(e)}function Eh(t,e){return{format:Mh,version:1,exported_at:new Date().toISOString(),building:e?Rh(t):structuredClone(t)}}var _v=t=>!!t&&(t.version===1||t.version===void 0)&&Array.isArray(t.floors)&&t.floors.every(e=>!!e&&typeof e=="object"),bv="https://therealmrbk.github.io/NextFloor/preview/?shared&noshowcase";function Ah(t,e,n,r,i=bv){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:Rh(t),packs:e.filter(c=>!c.builtin&&o.has(c.id))},l=JSON.stringify(s).replace(/c.replace(/[&<>"]/g,u=>({"&":"&","<":"<",">":">",'"':"""})[u]);return`
+ `}var So=.05,tv=(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),mn=t=>new Map(t.map(e=>[e.id,e]));function nv(t,e,n,r){let i=e.name,[o,s]=[mn(t.rooms),mn(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}),tv(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]=[mn(t.openings),mn(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]=[mn(t.furniture),mn(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)>So||Math.abs(h.rotation-f.rotation)>1||Math.abs(h.w-f.w)>So||Math.abs(h.d-f.d)>So)&&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)>So&&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 xh(t,e){let n=[],r=mn(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?nv(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 gn=(t,e)=>t.getUint16(e,!0),ri=(t,e)=>t.getUint32(e,!0);function $h(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(ri(e,l)===101010256){n=l;break}if(n<0)throw new Error("not_zip");let r=gn(e,n+10),i=ri(e,n+16),o=[],s=new TextDecoder;for(let l=0;l",quot:'"',apos:"'"},iv=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)):rv[n]??e);function ov(t){let e={};for(let n of t.matchAll(/([\w:.-]+)\s*=\s*(?:"([^"]*)"|'([^']*)')/g))e[n[1]]=iv(n[2]??n[3]);return e}function sv(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=ov(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,Ee=t=>Math.round(t*1e3)/1e3;function Mh(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 av(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 lv(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 cv(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=Ne(D("floor"),a.attrs.name||(c===0?"Erdgeschoss":`Etage ${c+1}`),Ee(oe(a.attrs,"elevation",0)/100));p.height=Ee(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:D("room"),name:b.attrs.name||`Raum ${y+1}`,area_id:null,points:lv(b.points,h).map(([v,w])=>[Ee(v),Ee(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,C)=>{let B=Mh(y,P,H.points[(C+1)%H.points.length]);B.dist<=v&&(!w||B.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,C)=>Mh(F,P,H.points[(C+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(E(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,C]=[E(Math.max(0,F-1)),E(Math.min(M,H+1))];Math.hypot(C[0]-P[0],C[1]-P[1])>=.3&&g.push({id:D("wall"),a:[Ee(P[0]),Ee(P[1])],b:[Ee(C[0]),Ee(C[1])],thickness:Ee(oe(b.attrs,"thickness",10)/100),height:b.attrs.height?Ee(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:Pe(e),report:n}}async function Rh(t){let e=$h(t).find(i=>i.name==="Home.xml");if(!e)throw new Error("sh3d_no_xml");let n=new TextDecoder().decode(await Sh(t,e)),r=cv(sv(n));if(r.report.rooms===0&&r.report.walls===0)throw new Error("sh3d_empty");return r}function uv(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=uv(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 Eh=t=>Math.round(t*1e3)/1e3;function Ah(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])=>[Eh((h-s)*o),Eh((l-f)*o)],c=Ne(D("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:D("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:D("wall"),a:f[g],b:f[g+1]})}c.rooms=u,c.walls=d;let p=Pt();return p.floors=[c],{building:Pe(p),report:{floors:1,rooms:u.length,openings:0,walls:d.length,furniture:0}}}var Ye=t=>Math.round(t*100)/100;function pv(t,e){let n=t.category;return typeof n=="string"?n:n&&typeof n=="object"?Object.keys(n)[0]??e:e}function fv(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:pv(n,e)}}var Yn=(t,e,n)=>(Array.isArray(t[e])?t[e]:[]).map(r=>fv(r,n)).filter(r=>!!r);function mv(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 Fh(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 gv(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 _v={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 Th(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)&&Yn(r,"walls","wall").length>0)}function zh(t){let e=t,r=(Array.isArray(e.rooms)?e.rooms:[e]).filter(b=>b&&typeof b=="object").map(b=>({walls:Yn(b,"walls","wall"),doors:[...Yn(b,"doors","door"),...Yn(b,"openings","opening")],windows:Yn(b,"windows","window"),objects:Yn(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=>mv(b.walls)),l=r.flatMap((b,y)=>s[y]?.points??Fh(b.walls)),[a,c]=[Math.min(...l.map(b=>b[0]))-.5,Math.min(...l.map(b=>b[1]))-.5],u=([b,y])=>[Ye(b-a),Ye(y-c)],d=Ne(D("floor"),"Erdgeschoss",0);d.height=Ye(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??Fh(b.walls)).map(u),x={id:D("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],E=null;if(w.forEach((P,C)=>{let B=gv(M,P,w[(C+1)%w.length]);B.dist<=.6&&(!E||B.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=_v[k.kind];if(!M)continue;let[E,T,F]=[k.size[0],k.size[2],k.size[1]];E<.1||T<.1||h.push({id:D("f"),type:M,x:Ye(k.centre[0]-a),z:Ye(k.centre[2]-c),rotation:Math.round((Math.atan2(k.dir[1],k.dir[0])*180/Math.PI+360)%360),w:Ye(E),d:Ye(T),h:Ye(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:Pe(f),report:{floors:1,rooms:p.length,openings:d.openings.length,walls:0,furniture:g}}}var ii=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 Ph={x:0,y:0,z:0,c:1,s:0},Dh=(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 Ih(t){let e=vv(t);if(!e.size)throw new Error("ifc_empty");let n=k=>ii(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 Ph;let[E=0,T=0,F=0]=i(M.args[0]),H=n(M.type==="IFCAXIS2PLACEMENT3D"?M.args[2]:M.args[1]),[P=1,C=0]=(H?.args[0]??[]).map(q=>r(q)),B=Math.hypot(P,C)||1;return{x:E||0,y:T||0,z:F||0,c:P/B,s:C/B}},a=(k,M=0)=>{let E=n(k);return!E||E.type!=="IFCLOCALPLACEMENT"||M>30?Ph:Dh(a(E.args[0],M+1),l(E.args[1]))},c=k=>{for(let M of n(k)?.args[2]??[])for(let E of n(M)?.args[3]??[]){let T=n(E);if(T?.type!=="IFCEXTRUDEDAREASOLID")continue;let F=n(T.args[0]),H=Dh(l(T.args[1]),l(F?.args[2])),P=[];if(F?.type==="IFCRECTANGLEPROFILEDEF"){let[C,B]=[r(F.args[3])/2,r(F.args[4])/2];P=[[-C,-B],[C,-B],[C,B],[-C,B]]}else if(F?.type==="IFCARBITRARYCLOSEDPROFILEDEF"){let C=n(F.args[2]);C?.type==="IFCPOLYLINE"&&(P=(C.args[0]??[]).map(B=>i(B)))}if(P=P.filter(C=>Number.isFinite(C[0])&&Number.isFinite(C[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(([C,B])=>[H.x+H.c*C-H.s*B,H.y+H.s*C+H.c*B])}return null},u=new Map;for(let[,k]of e){if(k.type==="IFCRELAGGREGATES"&&ii(k.args[4]))for(let M of k.args[5]??[])ii(M)&&u.set(M.ref,k.args[4].ref);if(k.type==="IFCRELCONTAINEDINSPATIALSTRUCTURE"&&ii(k.args[5]))for(let M of k.args[4]??[])ii(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 E=c(M.args[6]);if(!E)continue;let T=a(M.args[5]),F=E.map(([P,C])=>[(T.x+T.c*P-T.s*C)*s,(T.y+T.s*P+T.c*C)*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 E=Ne(D("floor"),k.name??`Etage ${M+1}`,Number.isFinite(k.elevation)?b(k.elevation):M*2.8);y.push(E),v.set(k.id,E)}),p.some(k=>k.storey===null||!v.has(k.storey))){let k=Ne(D("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 E=y[M+1];E&&E.elevation-k.elevation>1.8&&(k.height=b(E.elevation-k.elevation-.2))});for(let k of p)v.get(k.storey!==null&&v.has(k.storey)?k.storey:null).rooms.push({id:D("room"),name:k.name,area_id:null,points:k.ring.map(([E,T])=>[b(E-f),b(g-T)]),floor_material:"wood",panel:[]});let x=Pt();return x.floors=y,{building:Pe(x),report:{floors:y.length,rooms:p.length,openings:0,walls:0,furniture:0}}}var Hh="nextfloor",wv="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",Oh=new RegExp(`^(?:${wv})\\.[a-z0-9_]+$`),kv=/^[0-9a-f]{32}$/,xv=new Set(["area_id","ha_floor"]),$v=new Set(["sub_areas"]),Sv=new Set(["tap","show_when","pictures","moods"]);function Oa(t){if(typeof t=="string")return Oh.test(t)||kv.test(t)?null:t;if(Array.isArray(t))return t.map(e=>Oa(e)).filter(e=>e!==null);if(t&&typeof t=="object"){let e={};for(let[n,r]of Object.entries(t))Oh.test(n)||Sv.has(n)||(xv.has(n)||$v.has(n)?e[n]=null:e[n]=Oa(r));return e}return t}var Mv=["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 Lh(t){let e=structuredClone(t),n={};for(let i of Mv)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 Oa(e)}function Ch(t,e){return{format:Hh,version:1,exported_at:new Date().toISOString(),building:e?Lh(t):structuredClone(t)}}var Rv=t=>!!t&&(t.version===1||t.version===void 0)&&Array.isArray(t.floors)&&t.floors.every(e=>!!e&&typeof e=="object"),Ev="https://therealmrbk.github.io/NextFloor/preview/?shared&noshowcase";function Nh(t,e,n,r,i=Ev){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:Lh(t),packs:e.filter(c=>!c.builtin&&o.has(c.id))},l=JSON.stringify(s).replace(/c.replace(/[&<>"]/g,u=>({"&":"&","<":"<",">":">",'"':"""})[u]);return`
${a(n)}
@@ -630,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 Fh(t){let e;try{e=JSON.parse(t)}catch{throw new Error("not_json")}let n=e,r=n?.format===Mh?n.building:e;if(!_v(r))throw new Error("not_plan");return r.floors.forEach(i=>i.background=null),Pe(r)}var yv=t=>!/^https?:\/\//.test(t)&&!t.startsWith("camera:");function Th(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&&yv(i)&&e.add(i)}return[...e]}function zh(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 vv={api:{listHistory:cd,restoreSnapshot:pd,takeSnapshot:ud,getSnapshot:dd,deleteSnapshot:hd,fetchBackup:md,restoreBackup:gd,fetchImage:oo,storeImage:Lt},alert:t=>alert(t),confirm:t=>confirm(t),prompt:t=>prompt(t),download:zh,today:()=>new Date().toISOString().slice(0,10)},wv=t=>String(t?.message??t),wo=class{host;deps;history=null;busy=!1;compare=null;constructor(e,n=vv){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=Pe(await r(n,e.id));this.compare={snapshot:e,entries:hh(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=Ah(this.host.doc,kr(),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(Eh(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 gh(new Uint8Array(await e.arrayBuffer()));i=s.building,o=`${r("import_sh3d_found",{...s.report})}
+`}function Bh(t){let e;try{e=JSON.parse(t)}catch{throw new Error("not_json")}let n=e,r=n?.format===Hh?n.building:e;if(!Rv(r))throw new Error("not_plan");return r.floors.forEach(i=>i.background=null),Pe(r)}var Av=t=>!/^https?:\/\//.test(t)&&!t.startsWith("camera:");function Wh(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&&Av(i)&&e.add(i)}return[...e]}function Vh(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 Fv={api:{listHistory:pd,restoreSnapshot:_d,takeSnapshot:fd,getSnapshot:md,deleteSnapshot:gd,fetchBackup:yd,restoreBackup:vd,fetchImage:so,storeImage:Nt},alert:t=>alert(t),confirm:t=>confirm(t),prompt:t=>prompt(t),download:Vh,today:()=>new Date().toISOString().slice(0,10)},Tv=t=>String(t?.message??t),Mo=class{host;deps;history=null;busy=!1;compare=null;constructor(e,n=Fv){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=Pe(await r(n,e.id));this.compare={snapshot:e,entries:xh(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=Nh(this.host.doc,xr(),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(Ch(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 Rh(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=$h(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=Ih(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=bh(await e.text());i=s.building,o=`${r("import_dxf_found",{rooms:s.report.rooms,walls:s.report.walls})}
+${o}`}else if(/\.dxf$/i.test(e.name)){let s=Ah(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(vh(l)){let a=wh(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(Th(l)){let a=zh(l);i=a.building,o=`${r("import_roomplan_found",{rooms:a.report.rooms,openings:a.report.openings,skipped:a.report.furniture})}
-${o}`}else i=Fh(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 Th(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:wv(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(Pe(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()}}}};function Xe(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]]??go(n,e)??Ic(t,n)}function He(t,e){return go(e,`packname:${t.id}`)??Oc(t,e)}function Ph(t,e){return t.name[e.split("-")[0]]??go(e,`color:${t.id}`)??t.name.en??Object.values(t.name)[0]}var Dh=(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 Wh(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:Tv(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(Pe(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()}}}};function Xe(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)??Cc(t,n)}function Le(t,e){return _o(e,`packname:${t.id}`)??Nc(t,e)}function Kh(t,e){return t.name[e.split("-")[0]]??_o(e,`color:${t.id}`)??t.name.en??Object.values(t.name)[0]}var jh=(t,e,n="application/json,.json")=>m`${t} {let i=r.target,o=i.files?.[0];i.value="",e(o)}}
/>
- `,kv={added:"\uFF0B",removed:"\u2212",renamed:"\u270E",reshaped:"\u2922",moved:"\u2194"};function xv(t,e){let n=t.t;if(!e.length)return m`${n("version_same")}
`;let r=o=>o.kind.startsWith("furniture")?Xe(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`
+`,zv={added:"\uFF0B",removed:"\u2212",renamed:"\u270E",reshaped:"\u2922",moved:"\u2194"};function Pv(t,e){let n=t.t;if(!e.length)return m`
${n("version_same")}
`;let r=o=>o.kind.startsWith("furniture")?Xe(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`${kv[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`${zv[l]??"\u2022"} ${n(`diff_${s.kind}`,{name:r(s),detail:a})} `})}
`)}
-
`}function Ih(t,e){let n=t.t,r=e.history,i=r===null?S(n("loading")):r.length===0?S(n("backup_none")):m`
+
`}function Gh(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})}
@@ -659,19 +662,19 @@ ${o}`}else i=Fh(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?xv(t,e.compare.entries):_}`)}
+ ${e.compare?.snapshot.id===o.id?Pv(t,e.compare.entries):_}`)}
`;return m`
o.target.open&&void e.loadHistory()}>
${n("backup")}
${n("backup_history")}
${X(m`{e.saveVersion()}}>📌 ${n("version_save")} `)}
${i}
${n("backup_file")}
- ${X(m`e.exportPlan(!1)}>${n("backup_export")} `,m`e.exportPlan(!0)}>${n("backup_export_share")} `,m`e.exportShareView()}>🔗 ${n("share_view")} `,Dh(n("backup_import"),o=>{e.importPlan(o)},"application/json,.json,.sh3d,.dxf,.ifc"))}
+ ${X(m`e.exportPlan(!1)}>${n("backup_export")} `,m`e.exportPlan(!0)}>${n("backup_export_share")} `,m`e.exportShareView()}>🔗 ${n("share_view")} `,jh(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")}
- ${X(m`e.exportFull()}>${e.busy?"\u2026":n("backup_full_export")} `,Dh(n("backup_full_import"),o=>{e.importFull(o)}))}
+ ${X(m`e.exportFull()}>${e.busy?"\u2026":n("backup_full_export")} `,jh(n("backup_full_import"),o=>{e.importFull(o)}))}
${S(n("backup_full_hint"))}
- `}function Oh(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 Hh=["body","wood","fabric","white","metal","dark"],Lh={body:"#172238",wood:"#19233c",fabric:"#1a2644",white:"#1d2946",metal:"#2a3a60",dark:"#0b111f"};var mn=(t,e,n)=>Math.min(n,Math.max(e,t)),$v=t=>(Math.round(t)%360+360)%360,Aa=(t,e)=>$v(t+e);function Ch(t,e,n){return n?[...new Set([...t,e])]:t.filter(r=>r!==e)}function Nh(t,e,n){let r=t.t,i=s=>()=>n(Aa(e,s)),o=R`
+ `}function Uh(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 Zh=["body","wood","fabric","white","metal","dark"],qh={body:"#172238",wood:"#19233c",fabric:"#1a2644",white:"#1d2946",metal:"#2a3a60",dark:"#0b111f"};var _n=(t,e,n)=>Math.min(n,Math.max(e,t)),Dv=t=>(Math.round(t)%360+360)%360,Ha=(t,e)=>Dv(t+e);function Yh(t,e,n){return n?[...new Set([...t,e])]:t.filter(r=>r!==e)}function Xh(t,e,n){let r=t.t,i=s=>()=>n(Ha(e,s)),o=R`
@@ -684,7 +687,7 @@ ${o}`}else i=Fh(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
${o}
${r("compass_title")}
- ${A(t,r("north"),e,s=>n(Aa(s,0)),1)}
+ ${A(t,r("north"),e,s=>n(Ha(s,0)),1)}
⇅ ${r("compass_swap")}
↺ 90°
@@ -692,14 +695,14 @@ ${o}`}else i=Fh(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
${S(r("compass_hint"))}
- `}var Sv="https://tile.openstreetmap.org/{z}/{x}/{y}.png";var Mv=40075016686e-3,Fa=Math.PI/180,ii=18,oi=.5,Rv=160;function Ev(t,e,n){let r=2**n,i=(e+180)/360*r,o=(1-Math.log(Math.tan(t*Fa)+1/Math.cos(t*Fa))/Math.PI)/2*r;return[i,o]}var Av=(t,e)=>Mv*Math.cos(t*Fa)/2**e;function Bh(t,e,n,r=Rv){let[i,o]=Ev(t,e,n),s=Av(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 Wh(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 Vh=t=>t.url&&t.url.startsWith("https://")?t.url:Sv;var ko=t=>!!t&&t.on===!0&&Number.isFinite(t.lat)&&Number.isFinite(t.lon),Kh=t=>({x:t.x??0,z:t.z??0,opacity:t.opacity??oi,zoom:t.zoom??ii});function Fv(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 jh(t,e){let[n,r]=Fv(t);return{on:!0,lat:e?.lat??0,lon:e?.lon??0,x:n,z:r,opacity:oi,zoom:ii,url:null}}function Gh(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 Uh(t){let e=t.trim();return e===""?null:/^https:\/\/\S+$/.test(e)&&["{z}","{x}","{y}"].every(n=>e.includes(n))?e:void 0}var Tv=["15","16","17","18","19"],zv=["1","5","20"],xo="5";function Zh(t,e,n){let r=t.t,i=e.settings.map??null,o=t.hass?.config,s=ko(i),l=u=>{if(!u)return n(i?{...i,on:!1}:null);n(i?{...i,on:!0}:jh(e,{lat:o?.latitude,lon:o?.longitude}))},a=u=>i&&n({...i,...u}),c=(u,d)=>()=>i&&n(Gh(i,u*Number(xo),d*Number(xo)));return m`
+
`}var Iv="https://tile.openstreetmap.org/{z}/{x}/{y}.png";var Ov=40075016686e-3,La=Math.PI/180,oi=18,si=.5,Hv=160;function Lv(t,e,n){let r=2**n,i=(e+180)/360*r,o=(1-Math.log(Math.tan(t*La)+1/Math.cos(t*La))/Math.PI)/2*r;return[i,o]}var Cv=(t,e)=>Ov*Math.cos(t*La)/2**e;function Jh(t,e,n,r=Hv){let[i,o]=Lv(t,e,n),s=Cv(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 Qh(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 ep=t=>t.url&&t.url.startsWith("https://")?t.url:Iv;var Ro=t=>!!t&&t.on===!0&&Number.isFinite(t.lat)&&Number.isFinite(t.lon),tp=t=>({x:t.x??0,z:t.z??0,opacity:t.opacity??si,zoom:t.zoom??oi});function Nv(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 np(t,e){let[n,r]=Nv(t);return{on:!0,lat:e?.lat??0,lon:e?.lon??0,x:n,z:r,opacity:si,zoom:oi,url:null}}function rp(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 ip(t){let e=t.trim();return e===""?null:/^https:\/\/\S+$/.test(e)&&["{z}","{x}","{y}"].every(n=>e.includes(n))?e:void 0}var Bv=["15","16","17","18","19"],Wv=["1","5","20"],Eo="5";function op(t,e,n){let r=t.t,i=e.settings.map??null,o=t.hass?.config,s=Ro(i),l=u=>{if(!u)return n(i?{...i,on:!1}:null);n(i?{...i,on:!0}:np(e,{lat:o?.latitude,lon:o?.longitude}))},a=u=>i&&n({...i,...u}),c=(u,d)=>()=>i&&n(rp(i,u*Number(Eo),d*Number(Eo)));return m`
${I(t,r("map_on"),s,l,{title:r("map_hint")})}
${i&&i.on?m`
${A(t,r("map_lat"),i.lat,u=>a({lat:Math.max(-85,Math.min(85,u))}),1e-4)}
${A(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")} `:_}
- ${A(t,r("map_opacity"),Math.round((i.opacity??oi)*100),u=>a({opacity:Math.max(5,Math.min(100,u))/100}),5,5)}
- ${L(t,r("map_zoom"),String(i.zoom??ii),Tv.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)}))}
+ ${A(t,r("map_opacity"),Math.round((i.opacity??si)*100),u=>a({opacity:Math.max(5,Math.min(100,u))/100}),5,5)}
+ ${L(t,r("map_zoom"),String(i.zoom??oi),Bv.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")}
@@ -708,58 +711,58 @@ ${o}`}else i=Fh(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
▶
▼
- ${L(t,r("map_step"),xo,zv.map(u=>[u,`${u} m`]),u=>xo=u,{wide:!1})}
+ ${L(t,r("map_step"),Eo,Wv.map(u=>[u,`${u} m`]),u=>Eo=u,{wide:!1})}
- ${V(t,r("map_url"),i.url??"",u=>{let d=Uh(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=ip(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 Pv=["none","flat","gable","custom"];function Dv(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 Vv=["none","flat","gable","custom"];function Kv(t,e,n){let r=t.t,i=!!e,o=s=>n({color:null,image:null,dim:.35,...e??{},...s});return m`${r("backdrop")}
${I(t,r("backdrop"),i,s=>n(s?{color:"#101828",image:null,dim:.35}:null))}
${i?m`${r("backdrop_color")}
o({color:s.target.value})}
/>
- ${A(t,r("backdrop_dim"),Math.round((e?.dim??.35)*100),s=>o({dim:mn(s,0,80)/100}),5,0)}
+ ${A(t,r("backdrop_dim"),Math.round((e?.dim??.35)*100),s=>o({dim:_n(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 Iv(t,e,n){let r=t.t,i=H(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 jv(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`${W(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 qh(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=Pv.map(c=>[c,n(`roof_${c}`)]),l=r.weather_effects??qc,a=r.roof.type==="gable";return m`
+ ${S(r("status_entities_hint"),"nf-wide")}`}function sp(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=Vv.map(c=>[c,n(`roof_${c}`)]),l=r.weather_effects??Qc,a=r.roof.type==="gable";return m`
${n("settings")}
- ${A(t,n("wall_exterior"),r.wall_exterior,c=>i({wall_exterior:mn(c,.02,1)}),.01,.02)}
- ${A(t,n("wall_interior"),r.wall_interior,c=>i({wall_interior:mn(c,.02,1)}),.01,.02)}
- ${Ke(t,n("wall_paint_outside"),r.wall_paint_outside,Ci,c=>i({wall_paint_outside:c}))}
- ${Ke(t,n("wall_paint_inside"),r.wall_paint_inside,Ni,c=>i({wall_paint_inside:c}))}
+ ${A(t,n("wall_exterior"),r.wall_exterior,c=>i({wall_exterior:_n(c,.02,1)}),.01,.02)}
+ ${A(t,n("wall_interior"),r.wall_interior,c=>i({wall_interior:_n(c,.02,1)}),.01,.02)}
+ ${Ke(t,n("wall_paint_outside"),r.wall_paint_outside,Ni,c=>i({wall_paint_outside:c}))}
+ ${Ke(t,n("wall_paint_inside"),r.wall_paint_inside,Bi,c=>i({wall_paint_inside:c}))}
${S(n("wall_paint_hint"),"nf-wide")}
- ${Hh.map(c=>Ke(t,n(`furn_color_${c}`),r.furniture_colors?.[c],Lh[c],u=>{let d={...r.furniture_colors,[c]:u};u||delete d[c],i({furniture_colors:Object.keys(d).length?d:null})}))}
+ ${Zh.map(c=>Ke(t,n(`furn_color_${c}`),r.furniture_colors?.[c],qh[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")}
- ${A(t,n("grid"),r.grid,c=>i({grid:mn(c,.01,1)}),.01,.01)}
+ ${A(t,n("grid"),r.grid,c=>i({grid:_n(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")})}
- ${Nh(t,r.north,c=>i({north:c}))}
- ${Zh(t,t.doc,c=>i({map:c}))}
+ ${Xh(t,r.north,c=>i({north:c}))}
+ ${op(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?A(t,n("roof_pitch"),r.roof.pitch,c=>o({pitch:mn(c,5,60)}),1,5):_}
- ${r.roof.type!=="none"?A(t,n("roof_overhang"),r.roof.overhang,c=>o({overhang:mn(c,0,2)}),.05,0):_}
- ${re(t.hass)?Xd(t,r,i):t.hass?z(t,n("weather_entity"),r.weather_entity??null,Oh(t.hass,null),H(t.hass,c=>c.startsWith("weather.")),c=>i({weather_entity:c})):_}
+ ${a?A(t,n("roof_pitch"),r.roof.pitch,c=>o({pitch:_n(c,5,60)}),1,5):_}
+ ${r.roof.type!=="none"?A(t,n("roof_overhang"),r.roof.overhang,c=>o({overhang:_n(c,0,2)}),.05,0):_}
+ ${Q(t.hass)?lh(t,r,i):t.hass?z(t,n("weather_entity"),r.weather_entity??null,Uh(t.hass,null),O(t.hass,c=>c.startsWith("weather.")),c=>i({weather_entity:c})):_}
${n("weather_effects")}
- ${Zc.map(c=>I(t,n(`weather_effect_${c}`),l.includes(c),u=>i({weather_effects:Ch(l,c,u)}),{wide:!1}))}
+ ${Jc.map(c=>I(t,n(`weather_effect_${c}`),l.includes(c),u=>i({weather_effects:Yh(l,c,u)}),{wide:!1}))}
${I(t,n("rain_warning"),r.rain_warning!==!1,c=>i({rain_warning:c}))}
- ${t.hass&&!re(t.hass)&&r.rain_warning!==!1?z(t,n("rain_sensor"),r.rain_sensor??null,void 0,H(t.hass,c=>/^(binary_sensor|sensor)\./.test(c)),c=>i({rain_sensor:c==="none"?null:c})):_}
- ${t.hass&&!re(t.hass)&&r.rain_warning!==!1&&r.rain_sensor&&r.rain_sensor!=="none"?I(t,n("rain_sensor_inverted"),!!r.rain_sensor_inverted,c=>i({rain_sensor_inverted:c||void 0}),{title:n("rain_sensor_inverted_hint")}):_}
- ${t.hass?z(t,n("outage_sensor"),r.outage_sensor??null,void 0,H(t.hass,c=>/^(binary_sensor|sensor)\./.test(c)),c=>i({outage_sensor:c==="none"?null:c})):_}
+ ${t.hass&&!Q(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&&!Q(t.hass)&&r.rain_warning!==!1&&r.rain_sensor&&r.rain_sensor!=="none"?I(t,n("rain_sensor_inverted"),!!r.rain_sensor_inverted,c=>i({rain_sensor_inverted:c||void 0}),{title:n("rain_sensor_inverted_hint")}):_}
+ ${t.hass?z(t,n("outage_sensor"),r.outage_sensor??null,void 0,O(t.hass,c=>/^(binary_sensor|sensor)\./.test(c)),c=>i({outage_sensor:c==="none"?null:c})):_}
${S(n("outage_hint"),"nf-wide")}
${I(t,n("contact_warning"),!!r.contact_warning,c=>i({contact_warning:c||void 0}),{title:n("contact_warning_hint")})}
${I(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")})}
${I(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?Iv(t,r.status_entities??[],c=>i({status_entities:c.length?c:null})):_}
- ${re(t.hass)?_:m`${t.hass?z(t,n("announce_tts"),r.announce_tts??null,void 0,H(t.hass,c=>c.startsWith("tts.")),c=>i({announce_tts:c==="none"?null:c})):_}
+ ${t.hass?jv(t,r.status_entities??[],c=>i({status_entities:c.length?c:null})):_}
+ ${Q(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")}
- ${S(re(t.hass)?n("north_hint"):`${n("north_hint")} ${n("weather_entity_hint")}`)}
- `}var si=t=>t&&t!=="none"?t:null,ai=(t,e)=>{e&&!t.includes(e)&&t.push(e)},Ta=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=Ta(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 Yn(t){return new Set([...Ta(t).values()].filter(e=>gn(t,e)).map(e=>e.id))}function li(t,e){return!t.energy.advanced||!e.parent_meter?null:Yn(t).has(e.parent_meter)?e.parent_meter:null}function Yh(t,e,n){if(n.type!=="meter"||n.id===e.id)return!1;let r=Ta(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 So(t,e=n=>si(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??=si(r.export);else if(r.type==="inverter")ai(n.solar,i);else if(r.type==="home_battery"){let s=si(r.charge);ai(n.battery,i),ai(n.charge,s),ai(n.soc,si(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===li(t,r)):void 0,o=i?e(r):null;i&&r.type==="inverter"&&ai(i.solar,o);let s=si(r.charge);i&&r.type==="home_battery"&&(o||s)&&i.batteries.push({power:o,charge:s})}return n}function Ov(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 Hv=/(phase|_l[123]\b|_[abc]$|today|daily|heute)/,Lv=/_?(energy|energie|total|today|daily|kwh|import|export|consumption|production)/g;function $o(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=>!Hv.test(l)),s=e.replace(/^sensor\./,"").replace(Lv,"");return o.find(l=>s&&l.includes(s))??o[0]??i[0]}function Xh(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",$o(t,i.flow_from?.[0]?.stat_energy_from??i.flow_to?.[0]?.stat_energy_to));else if(i.type==="solar")r("solar",$o(t,i.stat_energy_from));else if(i.type==="battery"){let o=i.stat_energy_from??i.stat_energy_to;r("battery",$o(t,o)),r("battery_soc",$o(t,o,"battery"))}return n}function Ae(t,e=!1){let n=t?.attributes.symcon_id?en(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 Cv=(t,e)=>e.startsWith("sensor.")&&t.states[e]?.attributes.device_class==="power";function Jh(t,e){if(Cv(t,e))return e;let n=t.entities?.[e]?.device_id;if(!n)return null;let r=Os(t,n),i=r?zt(t,e):null,o=Xi(t,n).filter(s=>s!==e);return(r?o.find(s=>i!==null&&zt(t,s)===i):o[0])??null}var Qh=t=>{let e=t.filter(n=>n!==null);return e.length?e.reduce((n,r)=>n+r,0):null};function Nv(t,e,n){let r=e.grid??n.grid,i=r?Ae(t.states[r],e.grid_invert):null;if(!e.grid&&n.gridExport){let o=Math.max(0,Ae(t.states[n.gridExport])??0);return Math.max(0,i??0)-o}return i}function Bv(t,e,n){return e.solar?Ae(t.states[e.solar]):n.solar.length?Qh(n.solar.map(r=>Ae(t.states[r]))):null}function za(t,e,n){return e.charge?(e.power?Math.max(0,Ae(t.states[e.power])??0):0)-Math.max(0,Ae(t.states[e.charge])??0):e.power?Ae(t.states[e.power],n):null}function Wv(t,e,n){return e.battery?Ae(t.states[e.battery],e.battery_invert):Qh(n.batteries.map(r=>za(t,r,e.battery_invert)))}function Pa(t,e,n,r=So(e)){let i=e.energy,o=Nv(t,i,r),s=Bv(t,i,r),l=Wv(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?Ae(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,...Vv(t,r,h.consumption,i.battery_invert,n)}:h}function Vv(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?Ae(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,Ae(t.states[w])??0),0),g=p.batteries.reduce((v,w)=>v+(za(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 Kv(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 ep(t){let e=Ov(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=>Kv(c,e,s)).reduce((c,u)=>u.distancef.furniture.map(g=>({floor:f,item:g}))),r=f=>n.filter(g=>g.item.type===f),i=f=>!!ro(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 ci(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 jv(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 Gv(t){let e=Yn(t);return ci(t,"meter").find(n=>!e.has(n.id))??ci(t,"inverter")[0]??jv(lo(t))}function Uv(t,e){let n=ci(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 np(t){let e=[],n=Gv(t);if(!n)return e;let r=new Set(t.floors.flatMap(o=>o.furniture).filter(o=>li(t,o)).map(o=>o.id)),i=ci(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});ci(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}),Uv(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 Yn(t))e.push({key:`meter:${o}`,kind:"meter",id:o});return e}var rp=(t,e)=>t.energy.routes?.find(n=>n.key===e&&n.points.length>0);var Zv={ok:"\u2713",todo:"\u25CB",opt:"\xB7"},op=t=>t.hass?Ve(t.hass,t.doc.floors):new Map,qv=Ne,sp=(t,e)=>e.name||t.t(`furn_${e.type}`);function ap(t,e){let n=tp(t.doc,op(t)),r=n.filter(i=>i.state==="ok").length;return m`
+ ${S(Q(t.hass)?n("north_hint"):`${n("north_hint")} ${n("weather_entity_hint")}`)}
+ `}var ai=t=>t&&t!=="none"?t:null,li=(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 bn(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 Xn(t){return new Set([...Ca(t).values()].filter(e=>bn(t,e)).map(e=>e.id))}function ci(t,e){return!t.energy.advanced||!e.parent_meter?null:Xn(t).has(e.parent_meter)?e.parent_meter:null}function ap(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 Fo(t,e=n=>ai(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"?bn(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??=ai(r.export);else if(r.type==="inverter")li(n.solar,i);else if(r.type==="home_battery"){let s=ai(r.charge);li(n.battery,i),li(n.charge,s),li(n.soc,ai(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===ci(t,r)):void 0,o=i?e(r):null;i&&r.type==="inverter"&&li(i.solar,o);let s=ai(r.charge);i&&r.type==="home_battery"&&(o||s)&&i.batteries.push({power:o,charge:s})}return n}function Gv(t){for(let e of t.floors){let n=e.furniture.find(r=>r.type==="meter"&&!bn(t,r));if(n)return{floor_id:e.id,x:n.x,z:n.z}}return t.energy.meter}var Uv=/(phase|_l[123]\b|_[abc]$|today|daily|heute)/,Zv=/_?(energy|energie|total|today|daily|kwh|import|export|consumption|production)/g;function Ao(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=>!Uv.test(l)),s=e.replace(/^sensor\./,"").replace(Zv,"");return o.find(l=>s&&l.includes(s))??o[0]??i[0]}function lp(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",Ao(t,i.flow_from?.[0]?.stat_energy_from??i.flow_to?.[0]?.stat_energy_to));else if(i.type==="solar")r("solar",Ao(t,i.stat_energy_from));else if(i.type==="battery"){let o=i.stat_energy_from??i.stat_energy_to;r("battery",Ao(t,o)),r("battery_soc",Ao(t,o,"battery"))}return n}function Ae(t,e=!1){let n=t?.attributes.symcon_id?nn(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 qv=(t,e)=>e.startsWith("sensor.")&&t.states[e]?.attributes.device_class==="power";function cp(t,e){if(qv(t,e))return e;let n=t.entities?.[e]?.device_id;if(!n)return null;let r=Ns(t,n),i=r?Dt(t,e):null,o=Ji(t,n).filter(s=>s!==e);return(r?o.find(s=>i!==null&&Dt(t,s)===i):o[0])??null}var up=t=>{let e=t.filter(n=>n!==null);return e.length?e.reduce((n,r)=>n+r,0):null};function Yv(t,e,n){let r=e.grid??n.grid,i=r?Ae(t.states[r],e.grid_invert):null;if(!e.grid&&n.gridExport){let o=Math.max(0,Ae(t.states[n.gridExport])??0);return Math.max(0,i??0)-o}return i}function Xv(t,e,n){return e.solar?Ae(t.states[e.solar]):n.solar.length?up(n.solar.map(r=>Ae(t.states[r]))):null}function Na(t,e,n){return e.charge?(e.power?Math.max(0,Ae(t.states[e.power])??0):0)-Math.max(0,Ae(t.states[e.charge])??0):e.power?Ae(t.states[e.power],n):null}function Jv(t,e,n){return e.battery?Ae(t.states[e.battery],e.battery_invert):up(n.batteries.map(r=>Na(t,r,e.battery_invert)))}function Ba(t,e,n,r=Fo(e)){let i=e.energy,o=Yv(t,i,r),s=Xv(t,i,r),l=Jv(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?Ae(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,...Qv(t,r,h.consumption,i.battery_invert,n)}:h}function Qv(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?Ae(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,Ae(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 ew(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 dp(t){let e=Gv(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=>ew(c,e,s)).reduce((c,u)=>u.distancef.furniture.map(g=>({floor:f,item:g}))),r=f=>n.filter(g=>g.item.type===f),i=f=>!!io(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 ui(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 tw(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 nw(t){let e=Xn(t);return ui(t,"meter").find(n=>!e.has(n.id))??ui(t,"inverter")[0]??tw(co(t))}function rw(t,e){let n=ui(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 pp(t){let e=[],n=nw(t);if(!n)return e;let r=new Set(t.floors.flatMap(o=>o.furniture).filter(o=>ci(t,o)).map(o=>o.id)),i=ui(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});ui(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}),rw(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 Xn(t))e.push({key:`meter:${o}`,kind:"meter",id:o});return e}var fp=(t,e)=>t.energy.routes?.find(n=>n.key===e&&n.points.length>0);var iw={ok:"\u2713",todo:"\u25CB",opt:"\xB7"},gp=t=>t.hass?Ve(t.hass,t.doc.floors):new Map,ow=Be,_p=(t,e)=>e.name||t.t(`furn_${e.type}`);function bp(t,e){let n=hp(t.doc,gp(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)}>
- ${Zv[i.state]} ${t.t(i.label)}
+ ${iw[i.state]} ${t.t(i.label)}
`)}
- `}function lp(t,e){let n=t.doc.floors.flatMap(r=>r.furniture.filter(i=>qv.includes(i.type)).map(i=>({floor:r,item:i})));return m``}function yp(t,e){let n=t.doc.floors.flatMap(r=>r.furniture.filter(i=>ow.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)}>${sp(t,i)} · ${r.name}
+ e.openDevice(r,i)}>${_p(t,i)} · ${r.name}
`)}
`:_}
- ${Ne.map(r=>m`e.addDevice(r)}>+ ${t.t(`furn_${r}`)} `)}
+ ${Be.map(r=>m`e.addDevice(r)}>+ ${t.t(`furn_${r}`)} `)}
- `}var ip=(t,e,n)=>m`${t.t(e)} ${t.t("energy_sign_flip")}
`;function cp(t,e){let{energy:n}=t.doc,r=(y,v)=>t.hass?.states[y]?.attributes[v],i=H(t.hass,y=>On(t.hass,y)),o=H(t.hass,y=>me(y)&&r(y,"device_class")==="battery"),s=H(t.hass,y=>me(y)&&(r(y,"device_class")==="monetary"||/\/(kWh|MWh)$/.test(r(y,"unit_of_measurement")??""))),l=op(t),a=So(t.doc,y=>ro(y,l)),c=y=>t.replace({...structuredClone(t.doc),energy:{...t.doc.energy,...y}}),u=H(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?Pa(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)=>I(t,t.t("energy_invert"),y,w=>c(v(w)));return m``}var mp=(t,e,n)=>m`${t.t(e)} ${t.t("energy_sign_flip")}
`;function vp(t,e){let{energy:n}=t.doc,r=(y,v)=>t.hass?.states[y]?.attributes[v],i=O(t.hass,y=>On(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=gp(t),a=Fo(t.doc,y=>io(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)=>I(t,t.t("energy_invert"),y,w=>c(v(w)));return m`
⚖ ${t.t("energy_balance")}
${S(t.t("energy_balance_hint"))}
- ${f?ip(t,"energy_sign_grid",()=>c({grid_invert:!n.grid_invert})):_}
- ${g?ip(t,"energy_sign_battery",()=>c({battery_invert:!n.battery_invert})):_}
+ ${f?mp(t,"energy_sign_grid",()=>c({grid_invert:!n.grid_invert})):_}
+ ${g?mp(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}))}
@@ -825,19 +828,19 @@ ${o}`}else i=Fh(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
${n.advanced?I(t,t.t("energy_show_unmetered"),!!n.show_unmetered,y=>c({show_unmetered:y})):_}
${n.advanced?S(t.t("energy_show_unmetered_hint")):_}
- `}var up=t=>m``}var wp=t=>m`
⚡ ${t.t("feature_name_energy")}
${S(t.t("feature_text_energy"))}
- `;function dp(t){let e=(n,r,i)=>m`${r} ${t.t(i)} `;return m``;function kp(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 Yv(t,e){let n=t.t,r=t.doc.floors.flatMap(o=>o.furniture).find(o=>o.id===e.id),i=r?sp(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 hp(t,e){let n=np(t.doc);if(!n.length)return _;let r=t.t,i=e.draft;return m``}function sw(t,e){let n=t.t,r=t.doc.floors.flatMap(o=>o.furniture).find(o=>o.id===e.id),i=r?_p(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 xp(t,e){let n=pp(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=rp(t.doc,o.key),l=i?.key===o.key;return m`
-
${Yv(t,o)} · ${s?r("route_points",{n:s.points.length}):r("route_none")}
+ ${n.map(o=>{let s=fp(t.doc,o.key),l=i?.key===o.key;return m`
+
${sw(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")}
@@ -850,37 +853,37 @@ ${o}`}else i=Fh(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
${s?I(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 Mo(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 pp=(t,e)=>R`
`,Xv=(t,e,n)=>R`
${pp(...t.toScreen(e))} `,Jv=(t,e,n)=>R`
${pp(...t.toScreen(e))} `;function Qv(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,on(n),1)} m`}function Da(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=ao(r,s),p=d?xe(na(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:sn(s,{u0:0,u1:0,a:0,b:0}))?.ridges??[]).map(([C,B])=>{let[q,we]=t.toScreen(c.at(C[0],C[1])),[Rt,j]=t.toScreen(c.at(B[0],B[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,E,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?zr(s):[[k,E],[M,E],[M,T],[k,T]]),O=v&&x?F.map((C,B)=>Mo(t,C,F[(B+1)%F.length],"roof",s.id,B)):_,P=v?R`${O}${u?u.map((C,B)=>Xv(t,C,`${s.id}:${B}`)):w.map(([C,B])=>Jv(t,[C?M:k,B?T:E],`${s.id}:${C}:${B}`))}`:_;return R`
+ `}var lt=(t,e)=>e.map(n=>t.toScreen(n).join(",")).join(" ");function To(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 $p=(t,e)=>R` `,aw=(t,e,n)=>R`${$p(...t.toScreen(e))} `,lw=(t,e,n)=>R`${$p(...t.toScreen(e))} `;function cw(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,an(n),1)} m`}function Wa(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=lo(r,s),p=d?xe(sa(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:ln(s,{u0:0,u1:0,a:0,b:0}))?.ridges??[]).map(([C,B])=>{let[q,we]=t.toScreen(c.at(C[0],C[1])),[At,j]=t.toScreen(c.at(B[0],B[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,E,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?Pr(s):[[k,E],[M,E],[M,T],[k,T]]),H=v&&x?F.map((C,B)=>To(t,C,F[(B+1)%F.length],"roof",s.id,B)):_,P=v?R`${H}${u?u.map((C,B)=>aw(t,C,`${s.id}:${B}`)):w.map(([C,B])=>lw(t,[C?M:k,B?T:E],`${s.id}:${C}:${B}`))}`:_;return R`
${g}
- ${Qv(t,e,s,l)}
- ${P}`};return R`${r.map(o)} `}function e0(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`
+ ${cw(t,e,s,l)}
+ ${P}`};return R`${r.map(o)} `}function uw(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 fp(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=Vr(a,l),f=Math.max(...qe(a,l,!0).flatMap(g=>g.corners.map(b=>Math.hypot(b[0]-h[0],b[2]-h[1]))));u=e0(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`${qe(a,l,c).map(d)} ${u}`};return R`${i.map(s)} `}function mp(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?da(s,o):null;return l?R`[a[0],a[2]]))} /> `:_};return R`${n.map(i)} `}var t0={inverter:"\u26A1",home_battery:"\u{1F50B}",wallbox:"\u{1F50C}",meter:"\u{1F4DF}",grid_point:"\u{1F3C1}"};function gp(t,e,n){if(!e)return _;let r=e.furniture.filter(o=>Ne.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 Sp(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=Kr(a,l),f=Math.max(...qe(a,l,!0).flatMap(g=>g.corners.map(b=>Math.hypot(b[0]-h[0],b[2]-h[1]))));u=uw(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`${qe(a,l,c).map(d)} ${u}`};return R`${i.map(s)} `}function Mp(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?ma(s,o):null;return l?R`[a[0],a[2]]))} /> `:_};return R`${n.map(i)} `}var dw={inverter:"\u26A1",home_battery:"\u{1F50B}",wallbox:"\u{1F50C}",meter:"\u{1F4DF}",grid_point:"\u{1F3C1}"};function Rp(t,e,n){if(!e)return _;let r=e.furniture.filter(o=>Be.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`
- ${t0[o.type]??"\u26A1"}
+ ${dw[o.type]??"\u26A1"}
${a?R`${c} `:_}
${c}
- `};return R`${r.map(i)} `}function _p(t,e){let{doc:n,hass:r}=t.host;if(!(n.settings.roof.sections??[]).some(s=>ia(s,e.elevation+e.height)))return _;let o=[1.5,2].flatMap(s=>oa({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 yp(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}=hn(o),{center:u,along:d,across:p}=ha(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 n0(t,e,n){let[r,i]=[t+n/2,e-30];return R`
+ `};return R`${r.map(i)} `}function Ep(t,e){let{doc:n,hass:r}=t.host;if(!(n.settings.roof.sections??[]).some(s=>la(s,e.elevation+e.height)))return _;let o=[1.5,2].flatMap(s=>ca({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 Ap(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 Fp(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}=fn(o),{center:u,along:d,across:p}=ga(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 hw(t,e,n){let[r,i]=[t+n/2,e-30];return R`
- `}function r0(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 pw(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 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`
+ `}function Tp(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`
- ${n0(o,s,l)}`:_}
- ${r0(t,e)}`}var i0="strict-origin-when-cross-origin",Ia=new Map,wp=new Map,Ro=new Map;function o0(t){let e=Ia.get(t);return e||(e=fetch(t,{referrerPolicy:i0,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(()=>Ia.delete(t),6e4),n)),Ia.set(t,e)),e}function kp(t,e){let n=wp.get(t);if(n)return n;let r=Ro.get(t);return r||(r=new Set,Ro.set(t,r),o0(t).then(i=>{i&&wp.set(t,URL.createObjectURL(i));let o=Ro.get(t)??new Set;if(Ro.delete(t),i)for(let s of o)s()})),r.add(e),null}function xp(t,e){let n=e.map;if(!ko(n))return _;let r=Kh(n),i=Vh(n),[o,s]=t.toScreen([r.x,r.z]),l=t.scale;return R`
- ${Bh(n.lat,n.lon,r.zoom).map(a=>({tile:a,href:kp(Wh(i,a),t.redraw)})).filter(a=>a.href).map(({tile:a,href:c})=>R` `)}
- `}var Oa=t=>Math.round(t*1e3)/1e3,Ha=(t,e)=>t.width*e,Xn=(t,e)=>[t.x+t.width/2,t.z+Ha(t,e)/2];function $p(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 Sp=t=>((t+180)%360+360)%360-180;function Mp(t,e,n){return{x:Oa(t[0]-e/2),z:Oa(t[1]-n/2)}}function Rp(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=$p(Xn(t,e),n,o),l=Math.round(Sp((t.rotation??0)+o*180/Math.PI)*100)/100;return{...t,rotation:l,...Mp(s,t.width,Ha(t,e))}}function Ep(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]=Xn(t,e),c=[n[0]+s*(l-n[0]),n[1]+s*(a-n[1])],u=t.width*s;return{...t,width:Oa(u),...Mp(c,u,Ha(t,e)*s)}}function Ap(t,e,n){let r=$p(n,Xn(t,e),-(t.rotation??0)*Math.PI/180);return[r[0]-t.x,r[1]-t.z]}function Fp(t,e,n,r){let i=t+(n-e)*180/Math.PI;return Sp(r?Math.round(i/15)*15:Math.round(i*10)/10)}var s0=2048;async function Jn(t){let e=await createImageBitmap(t),n=Math.min(1,s0/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 Eo=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=D("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?Rp(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=Ep(e,n.aspect,r[0],r[1],this.rulerMetres);i&&(this.setBackground(i),this.rulerPoints=null,this.rulerMetres=0,this.deps.refresh())}};var Tp=.1,La=(t,e,n)=>m`${e} `;function a0(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")}
+ ${hw(o,s,l)}`:_}
+ ${pw(t,e)}`}var fw="strict-origin-when-cross-origin",Va=new Map,zp=new Map,zo=new Map;function mw(t){let e=Va.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(()=>Va.delete(t),6e4),n)),Va.set(t,e)),e}function Pp(t,e){let n=zp.get(t);if(n)return n;let r=zo.get(t);return r||(r=new Set,zo.set(t,r),mw(t).then(i=>{i&&zp.set(t,URL.createObjectURL(i));let o=zo.get(t)??new Set;if(zo.delete(t),i)for(let s of o)s()})),r.add(e),null}function Dp(t,e){let n=e.map;if(!Ro(n))return _;let r=tp(n),i=ep(n),[o,s]=t.toScreen([r.x,r.z]),l=t.scale;return R`
+ ${Jh(n.lat,n.lon,r.zoom).map(a=>({tile:a,href:Pp(Qh(i,a),t.redraw)})).filter(a=>a.href).map(({tile:a,href:c})=>R` `)}
+ `}var Ka=t=>Math.round(t*1e3)/1e3,ja=(t,e)=>t.width*e,Jn=(t,e)=>[t.x+t.width/2,t.z+ja(t,e)/2];function Ip(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 Op=t=>((t+180)%360+360)%360-180;function Hp(t,e,n){return{x:Ka(t[0]-e/2),z:Ka(t[1]-n/2)}}function Lp(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=Ip(Jn(t,e),n,o),l=Math.round(Op((t.rotation??0)+o*180/Math.PI)*100)/100;return{...t,rotation:l,...Hp(s,t.width,ja(t,e))}}function Cp(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]=Jn(t,e),c=[n[0]+s*(l-n[0]),n[1]+s*(a-n[1])],u=t.width*s;return{...t,width:Ka(u),...Hp(c,u,ja(t,e)*s)}}function Np(t,e,n){let r=Ip(n,Jn(t,e),-(t.rotation??0)*Math.PI/180);return[r[0]-t.x,r[1]-t.z]}function Bp(t,e,n,r){let i=t+(n-e)*180/Math.PI;return Op(r?Math.round(i/15)*15:Math.round(i*10)/10)}var gw=2048;async function Qn(t){let e=await createImageBitmap(t),n=Math.min(1,gw/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 Po=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=D("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?Lp(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=Cp(e,n.aspect,r[0],r[1],this.rulerMetres);i&&(this.setBackground(i),this.rulerPoints=null,this.rulerMetres=0,this.deps.refresh())}};var Wp=.1,Ga=(t,e,n)=>m`
${e} `;function _w(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=Us(o.target.value)||0}
+ @input=${o=>e.rulerLength=Xs(o.target.value)||0}
@keydown=${o=>o.key==="Enter"&&i()}
/>
-
0)} @click=${i}>${t.t("bg_ruler_apply")} `}function l0(t,e){if(!t.admin)return _;let n=t.t,r=e.level;return m`${La(e.edit,n(e.edit?"background_edit_done":"background_edit"),()=>e.toggleEdit())}
+
0)} @click=${i}>${t.t("bg_ruler_apply")} `}function bw(t,e){if(!t.admin)return _;let n=t.t,r=e.level;return m`${Ga(e.edit,n(e.edit?"background_edit_done":"background_edit"),()=>e.toggleEdit())}
${S(n(e.edit?"background_handles_hint":"background_fixed_hint"),"nf-wide")}
- ${La(!!r,`\u{1F4D0} ${n(r?"bg_level_cancel":"bg_level")}`,()=>e.toggleLevel())}
+ ${Ga(!!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"):_}
- ${La(!!e.ruler,`\u{1F4CF} ${n(e.ruler?"bg_ruler_cancel":"bg_ruler")}`,()=>e.toggleRuler())}
- ${a0(t,e)}`}function zp(t,e,n){let r=n.background,i=t.t,o=s=>r&&e.setBackground({...r,...s});return m`
e.open=s.target.open}>
+ ${Ga(!!e.ruler,`\u{1F4CF} ${n(e.ruler?"bg_ruler_cancel":"bg_ruler")}`,()=>e.toggleRuler())}
+ ${_w(t,e)}`}function Vp(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`${A(t,i("x"),r.x,s=>o({x:s}))} ${A(t,i("z"),r.z,s=>o({z:s}))}
- ${A(t,i("background_width"),r.width,s=>o({width:Math.max(Tp,s)}),.01,Tp)}
+ ${A(t,i("background_width"),r.width,s=>o({width:Math.max(Wp,s)}),.01,Wp)}
${A(t,i("background_rotation"),r.rotation??0,s=>o({rotation:Math.round(s*10)/10}),.5)}
- ${l0(t,e)}
+ ${bw(t,e)}
${i("background_opacity")}
o({opacity:Number.parseFloat(s.target.value)})} />
e.setBackground(null)}>${i("background_remove")} `:_}
- `}var c0=t=>t.map((e,n)=>[e,t[(n+1)%t.length]]);function u0(t,e,n){let r=G(n,e),i=ee(r,r),o=i?Math.max(0,Math.min(1,ee(G(t,e),r)/i)):0;return ge(G(t,[e[0]+r[0]*o,e[1]+r[1]*o]))}function Pp(t,e,n=.03){return t.every(r=>N(r,e)||c0(e).some(([i,o])=>u0(r,i,o)<=n))}var Ca=["straight","quarter","l","half","u","spiral"],Na=["solid","stringer","mono","cantilever"],Ba=["none","left","right","both"],Wa=["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},Va={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]},Lp=2,Cp=40;var Ao=(t,e)=>typeof e=="string"&&t.includes(e);function pi(t){let e=t.stair??{},n=typeof e.steps=="number"&&Number.isFinite(e.steps)?Math.round(Math.min(Cp,Math.max(Lp,e.steps))):null,r=typeof e.run_width=="number"&&Number.isFinite(e.run_width)&&e.run_width>.2?e.run_width:null;return{shape:Ao(Ca,e.shape)?e.shape:_t.shape,turn:e.turn==="left"?"left":"right",build:Ao(Na,e.build)?e.build:_t.build,risers:e.risers!==!1,steps:n,run_width:r,down:e.down===!0,rail:Ao(Ba,e.rail)?e.rail:_t.rail,opening:Ao(Wa,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 di=(t,e,n)=>[t[0]+(e[0]-t[0])*n,t[1]+(e[1]-t[1])*n],Dp=(t,e)=>Math.abs(t[0]-e[0])<1e-6&&Math.abs(t[1]-e[1])<1e-6;function Np(t){let e=[];for(let n of t)(!e.length||!Dp(e[e.length-1],n))&&e.push(n);for(;e.length>1&&Dp(e[0],e[e.length-1]);)e.pop();return e}function hi(t,e,n=!1){return{poly:Np([...t,...[...e].reverse()]),landing:n,left:t,right:e}}function ui(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 Op(t,e,n,r,i){let o=h0(t),s=[];for(let l=0;l=8?3:2),[p,h]=t.shape==="l"?Hp(t,r)??Fo(r-d,n-a,e-a):Fo(r-d,n-a,e-a),f=ui([i,l],[i+a,l],[i,s+a],c,p),g=t.shape==="l"?[hi(u,[c],!0)]:Op(u,c,c,c,d),b=ui([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"?Hp(t,r)??Fo(r-h,n-a,n-a):Fo(r-h,n-a,n-a),b=ui([i,l],[i+a,l],[i,c],d,f),y=t.shape==="u"?[hi(u,[d,p],!0)]:Op(u,d,[0,c],p,h),v=ui([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(hi(b,[d(c,f),d(c,g)]))}return{treads:p,flight:a-c,column:c}}default:return{treads:ui([i,l],[o,l],[i,s],[o,s],r),flight:e,column:0}}}var f0=(t,e)=>t.steps??Math.min(Cp,Math.max(Lp,Math.round(Math.abs(e)/.18)));function _n(t,e,n,r){let i=f0(t,r),o=Math.abs(r)/i,s=p0(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 To(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 te=t=>Math.round(t*1e3)/1e3,m0=(t,e)=>((t+e)%360+360)%360;function Bp(t,e){return{id:D("wall"),a:[te(t[0]),te(t[1])],b:[te(e[0]),te(e[1])],thickness:null}}function Wp(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[te(t.a[0]+(t.b[0]-t.a[0])*r),te(t.a[1]+(t.b[1]-t.a[1])*r)]}var Vp=(t,e)=>({height:t>=e-.005?null:Math.max(.05,t)});function Kp(t,e){return{id:D("hole"),type:"stairwell",x:te((t[0]+e[0])/2),z:te((t[1]+e[1])/2),w:te(e[0]-t[0]),d:te(e[1]-t[1]),h:.02,rotation:0,variant:null}}var jp=t=>({id:D("outdoor"),type:"lawn",points:t.map(([e,n])=>[te(e),te(n)])});function Gp(t,e,n){t.points.splice(e+1,0,[te(n[0]),te(n[1])])}function Up(t,e){return t.points.length<=3||e<0||e>=t.points.length?!1:(t.points.splice(e,1),!0)}var Zp=t=>({...t,id:D("outdoor"),points:t.points.map(([e,n])=>[te(e+.5),te(n+.5)])});function Ka(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"?te(l?l.elevation-n.elevation:n.height+.25):s,c={id:D("furniture"),type:t,x:te(r[0]),z:te(r[1]),rotation:0,w:i,d:o,h:a,variant:null};return t==="stairs"&&(c.stair={..._t}),c}var qp=t=>({...structuredClone(t),id:D("furniture"),x:te(t.x+.3),z:te(t.z+.3)}),Yp=(t,e)=>m0(t,e);function Xp(t){let[e,n,r]=dt("parking");return{id:D("furniture"),type:"parking",x:t.x,z:t.z,rotation:t.rotation,w:Math.max(e,te(t.w+.5)),d:Math.max(n,te(t.d+.4)),h:r,variant:null,vehicle:t.type,...t.name?{name:t.name}:{}}}function Jp(t,e){let[n,r,i]=dt(e);return{id:D("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 Qp=(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 ef(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 ja(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 Uu(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:D("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 tf(t){let[e,n]=be(t.points);return[te(e),te(n)]}function nf(t,e,n,r){let i=Math.min(n,t)/2,o=r>0?Math.round(e/r)*r:e;return te(Math.min(t-i,Math.max(i,o)))}function rf(t,e){let n=En[e],r=An(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 of(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])=>[te(a),te(c)])}function sf(t){return t.furniture.map((e,n)=>({item:e,index:n,base:Ft(t,e)})).sort((e,n)=>e.base-n.base||e.index-n.index).map(e=>e.item)}function zo(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 yw=t=>t.map((e,n)=>[e,t[(n+1)%t.length]]);function vw(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 Kp(t,e,n=.03){return t.every(r=>N(r,e)||yw(e).some(([i,o])=>vw(r,i,o)<=n))}var Ua=["straight","quarter","l","half","u","spiral"],Za=["solid","stringer","mono","cantilever"],qa=["none","left","right","both"],Ya=["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},Xa={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]},qp=2,Yp=40;var Do=(t,e)=>typeof e=="string"&&t.includes(e);function fi(t){let e=t.stair??{},n=typeof e.steps=="number"&&Number.isFinite(e.steps)?Math.round(Math.min(Yp,Math.max(qp,e.steps))):null,r=typeof e.run_width=="number"&&Number.isFinite(e.run_width)&&e.run_width>.2?e.run_width:null;return{shape:Do(Ua,e.shape)?e.shape:_t.shape,turn:e.turn==="left"?"left":"right",build:Do(Za,e.build)?e.build:_t.build,risers:e.risers!==!1,steps:n,run_width:r,down:e.down===!0,rail:Do(qa,e.rail)?e.rail:_t.rail,opening:Do(Ya,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 hi=(t,e,n)=>[t[0]+(e[0]-t[0])*n,t[1]+(e[1]-t[1])*n],jp=(t,e)=>Math.abs(t[0]-e[0])<1e-6&&Math.abs(t[1]-e[1])<1e-6;function Xp(t){let e=[];for(let n of t)(!e.length||!jp(e[e.length-1],n))&&e.push(n);for(;e.length>1&&jp(e[0],e[e.length-1]);)e.pop();return e}function pi(t,e,n=!1){return{poly:Xp([...t,...[...e].reverse()]),landing:n,left:t,right:e}}function di(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 Up(t,e,n,r,i){let o=kw(t),s=[];for(let l=0;l=8?3:2),[p,h]=t.shape==="l"?Zp(t,r)??Io(r-d,n-a,e-a):Io(r-d,n-a,e-a),f=di([i,l],[i+a,l],[i,s+a],c,p),g=t.shape==="l"?[pi(u,[c],!0)]:Up(u,c,c,c,d),b=di([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"?Zp(t,r)??Io(r-h,n-a,n-a):Io(r-h,n-a,n-a),b=di([i,l],[i+a,l],[i,c],d,f),y=t.shape==="u"?[pi(u,[d,p],!0)]:Up(u,d,[0,c],p,h),v=di([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(pi(b,[d(c,f),d(c,g)]))}return{treads:p,flight:a-c,column:c}}default:return{treads:di([i,l],[o,l],[i,s],[o,s],r),flight:e,column:0}}}var $w=(t,e)=>t.steps??Math.min(Yp,Math.max(qp,Math.round(Math.abs(e)/.18)));function yn(t,e,n,r){let i=$w(t,r),o=Math.abs(r)/i,s=xw(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 Oo(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,Sw=(t,e)=>((t+e)%360+360)%360;function Jp(t,e){return{id:D("wall"),a:[ne(t[0]),ne(t[1])],b:[ne(e[0]),ne(e[1])],thickness:null}}function Qp(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 ef=(t,e)=>({height:t>=e-.005?null:Math.max(.05,t)});function tf(t,e){return{id:D("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 nf=t=>({id:D("outdoor"),type:"lawn",points:t.map(([e,n])=>[ne(e),ne(n)])});function rf(t,e,n){t.points.splice(e+1,0,[ne(n[0]),ne(n[1])])}function of(t,e){return t.points.length<=3||e<0||e>=t.points.length?!1:(t.points.splice(e,1),!0)}var sf=t=>({...t,id:D("outdoor"),points:t.points.map(([e,n])=>[ne(e+.5),ne(n+.5)])});function Ja(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:D("furniture"),type:t,x:ne(r[0]),z:ne(r[1]),rotation:0,w:i,d:o,h:a,variant:null};return t==="stairs"&&(c.stair={..._t}),c}var af=t=>({...structuredClone(t),id:D("furniture"),x:ne(t.x+.3),z:ne(t.z+.3)}),lf=(t,e)=>Sw(t,e);function cf(t){let[e,n,r]=dt("parking");return{id:D("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 uf(t,e){let[n,r,i]=dt(e);return{id:D("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 df=(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 hf(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 Qa(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 Xu(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:D("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 pf(t){let[e,n]=be(t.points);return[ne(e),ne(n)]}function ff(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=En[e],r=An(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 gf(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 _f(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 Ho(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 Po(t,e,n){let r=n.edit;if(!t.admin||r?.key!==e)return _;let i=t.t;return m``}function Lo(t,e,n){let r=n.edit;if(!t.admin||r?.key!==e)return _;let i=t.t;return m`${A(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 Do=(t,e,n)=>Math.min(e,Math.max(t,ae(n)));function Ga(t,e,n){let r=t.t,i=a=>n.update(a),o=de(e.points),s=Yc.map(a=>[a,r(`out_${a}`)]),l=Xc.map(a=>[a,r(`slope_${a.replace("-","n")}`)]);return m`
+ ${r.error?m`${r.error}
`:_}`}var Co=(t,e,n)=>Math.min(e,Math.max(t,ae(n)));function el(t,e,n){let r=t.t,i=a=>n.update(a),o=de(e.points),s=eu.map(a=>[a,r(`out_${a}`)]),l=tu.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")})}
- ${e.type==="pool"||e.type==="wild"||e.type==="bed"?m`${z(t,r("pool_temp"),e.temp_entity??null,void 0,H(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,H(t.hass,a=>/^(switch|fan|valve|input_boolean|binary_sensor)\./.test(a)),a=>i({pump_entity:a&&a!=="none"?a:null}))}`:_}
+ ${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}))}`:_}
${Fn(e.points)?m`${A(t,r("x"),o.x0,a=>n.setRectangle("x",a))} ${A(t,r("z"),o.z0,a=>n.setRectangle("z",a))}
${A(t,r("width"),o.x1-o.x0,a=>n.setRectangle("w",a),.01,.1)} ${A(t,r("depth"),o.z1-o.z0,a=>n.setRectangle("d",a),.01,.1)}`:_}
- ${xs(e.type)?A(t,r("outdoor_height"),e.height??ks[e.type],a=>i({height:Do(.1,6,a)}),.05,.1):_}
- ${A(t,r("outdoor_offset"),e.offset??0,a=>i({offset:Do(-10,10,a)||null}),.05)}
- ${e.type!=="pool"?m`${A(t,r("outdoor_slope"),e.slope??0,a=>i({slope:Do(0,20,a)||null}),.05,0)}
+ ${Rs(e.type)?A(t,r("outdoor_height"),e.height??Ms[e.type],a=>i({height:Co(.1,6,a)}),.05,.1):_}
+ ${A(t,r("outdoor_offset"),e.offset??0,a=>i({offset:Co(-10,10,a)||null}),.05)}
+ ${e.type!=="pool"?m`${A(t,r("outdoor_slope"),e.slope??0,a=>i({slope:Co(0,20,a)||null}),.05,0)}
${L(t,r("outdoor_slope_dir"),e.slope_dir??"x",l,a=>i({slope_dir:a}))}`:_}
${A(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)}
${I(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"?I(t,r("outdoor_open"),!!e.open,a=>i({open:a||void 0}),{title:r("outdoor_open_hint")}):_}
${e.type==="pergola"?I(t,r("outdoor_bracing"),!!e.bracing,a=>i({bracing:a||void 0})):_}
- ${I(t,r("outdoor_cut"),eu(e),a=>i({cut:a===(e.type==="pool")?void 0:a}),{title:r("outdoor_cut_hint")})}
+ ${I(t,r("outdoor_cut"),iu(e),a=>i({cut:a===(e.type==="pool")?void 0:a}),{title:r("outdoor_cut_hint")})}
- ${e.type==="fence"?g0(t,e,i):_}
+ ${e.type==="fence"?Mw(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 g0(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=H(t.hass,h=>/^(cover|switch|input_boolean|lock)\./.test(h)),u=H(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:D("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 Mw(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:D("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}))}
@@ -960,13 +963,13 @@ ${o}`}else i=Fh(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 _0=[["up","\u2191"],["left","\u2190"],["right","\u2192"],["down","\u2193"]],b0={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=b0[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 Rw=[["up","\u2191"],["left","\u2190"],["right","\u2192"],["down","\u2193"]],Ew={ArrowRight:"right",ArrowLeft:"left",ArrowUp:"up",ArrowDown:"down"};function bf(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=Ew[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 `)} `:_}
@@ -983,45 +986,45 @@ ${o}`}else i=Fh(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
n.addRectangle()}>${r("rect_add")}
${S(r("measure_hint"))}
- `}function Ua(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 tl(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}
- ${A(t,r("wall_length"),o,s=>n.update({b:Wp(e,s)}),.01,.1)}
- ${A(t,r("wall_thickness"),e.thickness??t.doc.settings.wall_interior,s=>n.update({thickness:Do(.02,1,s)}),.01,.02)}
- ${A(t,r("wall_height"),e.height??i,s=>n.update(Vp(s,i)),.05,.05)}
+ ${A(t,r("wall_length"),o,s=>n.update({b:Qp(e,s)}),.01,.1)}
+ ${A(t,r("wall_thickness"),e.thickness??t.doc.settings.wall_interior,s=>n.update({thickness:Co(.02,1,s)}),.01,.02)}
+ ${A(t,r("wall_height"),e.height??i,s=>n.update(ef(s,i)),.05,.05)}
${I(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?A(t,r("free_wall_height_end"),e.height_end,s=>n.update({height_end:Math.max(.05,s)}),.05,.05):_}
- ${t.admin?m`${zo(t,`wall:${e.id}`,n.arc)}n.remove()}>${r("delete")}
`:_}
- ${Po(t,`wall:${e.id}`,n.arc)}
+ ${t.admin?m`${Ho(t,`wall:${e.id}`,n.arc)}n.remove()}>${r("delete")}
`:_}
+ ${Lo(t,`wall:${e.id}`,n.arc)}
${S(r("free_wall_hint"))}
- `}var Vt=t=>Math.round(t*1e3)/1e3,y0=2.4;function lf(t,e,n){let r=sa(t,e[0],e[1],n[0],n[1]),i=r===null,o=Math.min(...t.floors.map(a=>a.elevation)),s=Vt(r??o+y0),l=i?6:t.settings.roof.pitch||35;return{id:D("roof"),x0:Vt(e[0]),z0:Vt(e[1]),x1:Vt(n[0]),z1:Vt(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 cf(t){let e=n=>Vt(n+1);return{...structuredClone(t),id:D("roof"),x0:e(t.x0),x1:e(t.x1),z0:e(t.z0),z1:e(t.z1)}}var uf=(t,e)=>t.findIndex(n=>n.id===e)+1;function Za(t){return t.points&&t.points.length>=3?t.points.map(([e,n])=>[e,n]):t.rotation?zr(t):[[t.x0,t.z0],[t.x1,t.z0],[t.x1,t.z1],[t.x0,t.z1]]}function df(t,e,n){let r=Za(t);r.splice(e+1,0,[Vt(n[0]),Vt(n[1])]),t.points=r,Object.assign(t,Nt(r))}function hf(t,e){return!t.points||t.points.length<=3||e<0||e>=t.points.length?!1:(t.points.splice(e,1),Object.assign(t,Nt(t.points)),!0)}var v0={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"},Kt=t=>v0[t];function Io(t,e){let n=new Set;for(let r of t?.placements??[])N([r.x,r.z],e.points)&&n.add(r.entity_id);for(let r of t?.furniture??[])ue(r.type)&&r.entity&&N([r.x,r.z],e.points)&&n.add(r.entity);return n}function pf(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=>N([s,l],c.points));a&&a.id!==e.id&&n.set(o,a.name)}}return n}var ff=(t,e)=>(t??[]).includes(e)?(t??[]).filter(n=>n!==e):[...t??[],e];function Oo(t,...e){let n=t.trim().toLowerCase();return!n||e.some(r=>(r??"").toLowerCase().includes(n))}function mf(t,e){return t.map(n=>({o:n,r:e(n.id)})).sort((n,r)=>n.r-r.r).map(({o:n})=>n)}function gf(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 qa=50;function Ya(t,e,n,r,i,o,s){let l=e.includes(n);return m`s.patchRoom({[r]:ff(e,n)})}>${l?i[0]:i[1]} `}function w0(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=Ln(t,c);return m`
+ `}var jt=t=>Math.round(t*1e3)/1e3,Aw=2.4;function yf(t,e,n){let r=ua(t,e[0],e[1],n[0],n[1]),i=r===null,o=Math.min(...t.floors.map(a=>a.elevation)),s=jt(r??o+Aw),l=i?6:t.settings.roof.pitch||35;return{id:D("roof"),x0:jt(e[0]),z0:jt(e[1]),x1:jt(n[0]),z1:jt(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 vf(t){let e=n=>jt(n+1);return{...structuredClone(t),id:D("roof"),x0:e(t.x0),x1:e(t.x1),z0:e(t.z0),z1:e(t.z1)}}var wf=(t,e)=>t.findIndex(n=>n.id===e)+1;function nl(t){return t.points&&t.points.length>=3?t.points.map(([e,n])=>[e,n]):t.rotation?Pr(t):[[t.x0,t.z0],[t.x1,t.z0],[t.x1,t.z1],[t.x0,t.z1]]}function kf(t,e,n){let r=nl(t);r.splice(e+1,0,[jt(n[0]),jt(n[1])]),t.points=r,Object.assign(t,Wt(r))}function xf(t,e){return!t.points||t.points.length<=3||e<0||e>=t.points.length?!1:(t.points.splice(e,1),Object.assign(t,Wt(t.points)),!0)}var Fw={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"},Gt=t=>Fw[t];function No(t,e){let n=new Set;for(let r of t?.placements??[])N([r.x,r.z],e.points)&&n.add(r.entity_id);for(let r of t?.furniture??[])ue(r.type)&&r.entity&&N([r.x,r.z],e.points)&&n.add(r.entity);return n}function $f(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=>N([s,l],c.points));a&&a.id!==e.id&&n.set(o,a.name)}}return n}var Sf=(t,e)=>(t??[]).includes(e)?(t??[]).filter(n=>n!==e):[...t??[],e];function Bo(t,...e){let n=t.trim().toLowerCase();return!n||e.some(r=>(r??"").toLowerCase().includes(n))}function Mf(t,e){return t.map(n=>({o:n,r:e(n.id)})).sort((n,r)=>n.r-r.r).map(({o:n})=>n)}function Rf(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 rl=50;function il(t,e,n,r,i,o,s){let l=e.includes(n);return m`
s.patchRoom({[r]:Sf(e,n)})}>${l?i[0]:i[1]} `}function Tw(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=Ln(t,c);return m`
o.select(c)}>
- ${g?m` `:m` `}
+ ${g?m` `:m` `}
${W(t.hass,c,d)}${h?m` · ${t.t("devices_placed_in",{room:h})} `:_}
- ${t.admin?Ya(t,s,c,"hidden",["\u{1F648}","\u{1F441}"],["panel_unhide","panel_hide"],o):_}
- ${t.admin&&!f?Ya(t,l,c,"no_state",["\u2205","Aa"],["panel_state_show","panel_state_hide"],o):_}
- ${t.admin&&!p?Ya(t,a,c,"panel",["\u2605","\u2606"],["panel_unpin","panel_pin"],o):_}
+ ${t.admin?il(t,s,c,"hidden",["\u{1F648}","\u{1F441}"],["panel_unhide","panel_hide"],o):_}
+ ${t.admin&&!f?il(t,l,c,"no_state",["\u2205","Aa"],["panel_state_show","panel_state_hide"],o):_}
+ ${t.admin&&!p?il(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 k0(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=$u(o,n.area_id).map(f=>({...f,ids:f.ids.filter(g=>Oo(a,`${W(o,g,f.name)} ${g} ${f.name}`))})),{taken:d,left:p}=gf(u,qa),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=Su(o).filter(u=>Oo(a,`${W(o,u)} ${u} `));return c.length>0?m`
${c.slice(0,qa).map(u=>r(u))}
${s(c.length-Math.min(c.length,qa))}`:l}function x0(t,e,n,r,i,o,s){let{hass:l}=t,a=l?ye(l,n).filter(y=>Et(Be(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?zn(l,a):[],u=c.map(y=>y.primary).filter(y=>!i.has(y)),d=e.deviceQuery,p=(t.floor?.placements??[]).filter(y=>J(y.entity_id)==="light"&&(y.mount??"ceiling")==="ceiling"&&N([y.x,y.z],n.points)).length,h=m`
e.deviceQuery=y.target.value} />`,f=y=>Oo(d,W(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=Eu(o,n.area_id).map(f=>({...f,ids:f.ids.filter(g=>Bo(a,`${W(o,g,f.name)} ${g} ${f.name}`))})),{taken:d,left:p}=Rf(u,rl),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=Au(o).filter(u=>Bo(a,`${W(o,u)} ${u} `));return c.length>0?m`${c.slice(0,rl).map(u=>r(u))}
${s(c.length-Math.min(c.length,rl))}`:l}function Pw(t,e,n,r,i,o,s){let{hass:l}=t,a=l?ye(l,n).filter(y=>Ft(We(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?zn(l,a):[],u=c.map(y=>y.primary).filter(y=>!i.has(y)),d=e.deviceQuery,p=(t.floor?.placements??[]).filter(y=>J(y.entity_id)==="light"&&(y.mount??"ceiling")==="ceiling"&&N([y.x,y.z],n.points)).length,h=m` e.deviceQuery=y.target.value} />`,f=y=>Bo(d,W(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 Xa(t,e,n,r){let{hass:i}=t,o=n.area_id?i?.areas?.[n.area_id]?.name:void 0,s=Io(t.floor,n),l=w0(t,n,s,pf(t.doc,n),o,r),a=t.admin?e.deviceSource:"area",c=i?zn(i,ye(i,n).filter(p=>Et(Be(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 ol(t,e,n,r){let{hass:i}=t,o=n.area_id?i?.areas?.[n.area_id]?.name:void 0,s=No(t.floor,n),l=Tw(t,n,s,$f(t.doc,n),o,r),a=t.admin?e.deviceSource:"area",c=i?zn(i,ye(i,n).filter(p=>Ft(We(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}${k0(t,e,n,l,a)}`:x0(t,e,n,l,s,o,r)}
- `}function _f(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=Mu(r,t.floor??null,{...e,climate:null},l),u=[e.climate?.[l]??null].flat(),d=H(r,b=>Hs(r,b,l,!0)&&(!r.states[b]?.attributes.symcon_source_entity||u.includes(b))),p=mf(d,b=>(zt(r,b)===e.area_id?0:1)+(Ls(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)}`:Pw(t,e,n,l,s,o,r)}
+ `}function Ef(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=Fu(r,t.floor??null,{...e,climate:null},l),u=[e.climate?.[l]??null].flat(),d=O(r,b=>Bs(r,b,l,!0)&&(!r.states[b]?.attributes.symcon_source_entity||u.includes(b))),p=Mf(d,b=>(Dt(r,b)===e.area_id?0:1)+(Ws(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"))}${re(r)?Yd(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"))}${Q(r)?ah(t,e,n):_}
${I(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 Ja="metric",yf=t=>{Ja=t==="imperial"?"imperial":"metric"};var bf=.3048;function pe(t,e,n=2,r=Ja){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 Fe(t,e,n=Ja){return n==="metric"?`${K(t,e,1)} m\xB2`:`${K(t,e/(bf*bf),0)} ft\xB2`}var $0=.15,S0=(t,e)=>Math.abs((t-e+540)%360-180);function M0(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(ee(G(o,n),r))<.02&&Math.abs(ee(G(l,n),r))<.02}))}function el(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:M0(t,e,o,u)?r/2:0,heightLeft:d?f:b,heightRight:d?b:f}}function Qa(t,e){let n=G(e,t.origin);return{u:ee(n,t.along),depth:ee(n,t.normal)-t.face}}function R0(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 vf=t=>U(t.type)?.mount==="wall"||t.type==="lamp_wall"||t.mount_y!=null;function wf(t,e,n){let r=[];for(let o of t.openings){let s=R0(t,o);if(!s)continue;let{u:l,depth:a}=Qa(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(!N([o.x,o.z],e.points)||S0(o.rotation,i)>20)continue;let{u:s,depth:l}=Qa(n,[o.x,o.z]);if(l-o.d/2>$0||s<0||s>n.length)continue;let a=Ft(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 fi=t=>Math.round(t*1e3)/1e3;function kf(t,e,n,r){let i=Qa(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:fi(s[0]),z:fi(s[1]),...r!==null&&vf(e)?{mount_y:fi(Math.max(0,r))}:{}}}function xf(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:fi(l),...i!==null&&n.type==="window"?{sill:fi(Math.max(0,i))}:{}}}var $f=.01,Sf=t=>Math.round(t/$f)*$f,tl=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?el(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?wf(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,xf(c.id===i.id?o:el(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,Sf(r.fromX+i-r.startU))),c=n.lifts?Math.max(0,Sf(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||Xe(this.host.hass,e.type);let n=this.host.floor?.openings.find(r=>r.id===e.id);return n?this.host.t(`preset_${An(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 sl="metric",Ff=t=>{sl=t==="imperial"?"imperial":"metric"};var Af=.3048;function pe(t,e,n=2,r=sl){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 Fe(t,e,n=sl){return n==="metric"?`${K(t,e,1)} m\xB2`:`${K(t,e/(Af*Af),0)} ft\xB2`}var Dw=.15,Iw=(t,e)=>Math.abs((t-e+540)%360-180);function Ow(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 ll(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:Ow(t,e,o,u)?r/2:0,heightLeft:d?f:b,heightRight:d?b:f}}function al(t,e){let n=G(e,t.origin);return{u:te(n,t.along),depth:te(n,t.normal)-t.face}}function Hw(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 Tf=t=>U(t.type)?.mount==="wall"||t.type==="lamp_wall"||t.mount_y!=null;function zf(t,e,n){let r=[];for(let o of t.openings){let s=Hw(t,o);if(!s)continue;let{u:l,depth:a}=al(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(!N([o.x,o.z],e.points)||Iw(o.rotation,i)>20)continue;let{u:s,depth:l}=al(n,[o.x,o.z]);if(l-o.d/2>Dw||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:Tf(o)})}return r.sort((o,s)=>+(o.kind==="furniture")-+(s.kind==="furniture")||o.x0-s.x0)}var mi=t=>Math.round(t*1e3)/1e3;function Pf(t,e,n,r){let i=al(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:mi(s[0]),z:mi(s[1]),...r!==null&&Tf(e)?{mount_y:mi(Math.max(0,r))}:{}}}function Df(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:mi(l),...i!==null&&n.type==="window"?{sill:mi(Math.max(0,i))}:{}}}var If=.01,Of=t=>Math.round(t/If)*If,cl=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?ll(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?zf(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,Pf(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,Df(c.id===i.id?o:ll(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,Of(r.fromX+i-r.startU))),c=n.lifts?Math.max(0,Of(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||Xe(this.host.hass,e.type);let n=this.host.floor?.openings.find(r=>r.id===e.id);return n?this.host.t(`preset_${An(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)}
@@ -1062,7 +1065,7 @@ ${o}`}else i=Fh(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
/>`:_}`:S(e("wall_view_hint"))}
-
`}close(){this.dispatchEvent(new CustomEvent("close"))}static styles=Q`
+ `}close(){this.dispatchEvent(new CustomEvent("close"))}static styles=ee`
.backdrop {
position: fixed;
inset: 0;
@@ -1170,14 +1173,14 @@ ${o}`}else i=Fh(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",tl);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 Mf(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 A0=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 F0(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(A0(i)*10)/10)}return e}function Rf(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 Ef=(t,e,n)=>[...t.filter(r=>r.room!==e),...n],Af=t=>Math.max(0,Math.min(1,(t+95)/50));var T0=1500,rl=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=Rf(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=Ef(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:D("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",cl);function Lw(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 Hf(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=Lw(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 Cw=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 Nw(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(Cw(i)*10)/10)}return e}function Lf(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 Cf=(t,e,n)=>[...t.filter(r=>r.room!==e),...n],Nf=t=>Math.max(0,Math.min(1,(t+95)/50));var Bw=1500,dl=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,Bw)}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=Lf(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=Cf(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:D("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=Mf(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=Hf(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",dl);var Ww=new URL(import.meta.url),Vw=new URL("./nextfloor-3d.js?v=74227cd20cc3",Ww).href,Bf;function vn(){return Bf??=import(Vw),Bf}var Wf=["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"],Kw={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"},jw=[[/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 Gw(t){if(t.vehicle)return"vehicles";if(t.climate)return"climate";if(!t.type.startsWith("pack:"))return t.lamp?"lights":Kw[t.type]??"decor";let e=jw.find(([n])=>n.test(t.id));return e?e[1]:t.lamp?"lights":"decor"}var Vf=[[/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 hl(t){let e=(t??"").toLowerCase(),n=Vf.find(([r])=>r.test(e));return n?new Set(["lights",...n[1]]):null}function pl(t){let e=(t??"").toLowerCase();return Vf.find(([n])=>n.test(e))?.[1][0]??null}var Kf=t=>t==="garden"||t==="plants"||t==="vehicles",jf=/_(\d+(?:x\d+)?)$/;function Gf(t){let e=new Map;for(let n of t){let r=Gw(n),i=n.type.startsWith("pack:")&&!n.vehicle?n.id.replace(jf,""):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 Uf(t,e){let n=i=>Math.round(i*100);return e.some(i=>i!==t&&n(i.size[0])===n(t.size[0]))?jf.exec(t.id)?.[1]??`${n(t.size[0])}\xD7${n(t.size[2])}`:`${n(t.size[0])}`}function Zf(t,e,n=12){return[e,...t.filter(r=>r!==e)].slice(0,n)}var qf=t=>t.toLowerCase().normalize("NFD").replace(new RegExp("\\p{M}","gu"),""),Yf=t=>qf(t).split(/\s+/).filter(Boolean),Xf=(t,e)=>{let n=qf(e);return t.every(r=>n.includes(r))};function Jf(){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 Qf=112,Uw="nextfloor-thumbs";function Zw(t){let e=2166136261;for(let n=0;n
>>0).toString(36)}function fl(t){let e=U(t);return`${t}|${e?Zw(JSON.stringify(e)):"b"}|${Qf}`}function qw(){return new Promise(t=>{try{let e=indexedDB.open(Uw,1);e.onupgradeneeded=()=>e.result.createObjectStore("thumbs"),e.onsuccess=()=>t(e.result),e.onerror=()=>t(null)}catch{t(null)}})}var ml=class{enabled=!Jf();memory=new Map;waiting=new Map;queue=[];db=null;running=!1;packs=[];cached(e){return this.memory.get(fl(e))}get(e){let n=fl(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??=qw();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=fl(e),o=null;try{let[s,l,a]=dt(e);o=(await vn()).furniturePreview({type:e,w:s,d:l,h:a,variant:null,lamp:ji[e]??null},Qf,[...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{}}},Ut=new ml,gi=null,Yw=t=>{for(let e of t)e.isIntersecting&&e.target.visible()},gl=class extends Y{static properties={type:{},_url:{state:!0}};static styles=ee`
:host {
display: block;
aspect-ratio: 4 / 3;
@@ -1231,7 +1234,7 @@ ${o}`}else i=Fh(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(),jt.enabled&&(this._url=jt.cached(this.type)??null,!this._url&&(mi??=new IntersectionObserver(N0,{rootMargin:"120px"}),mi.observe(this)))}disconnectedCallback(){super.disconnectedCallback(),mi?.unobserve(this)}updated(e){e.has("type")&&e.get("type")!==void 0&&(this._url=jt.cached(this.type)??null,!this._url&&jt.enabled&&mi?.observe(this))}visible(){mi?.unobserve(this);let e=this.type;jt.get(e).then(n=>{this.type===e&&(this._url=n)})}render(){return this._url?m` `:_}};customElements.get("nf-thumb")||customElements.define("nf-thumb",ll);var Vf="nextfloor.library2",B0={language:"en"},Ho=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(Vf);n&&(this.saved={...this.saved,...JSON.parse(n)})}catch{}}store(e){this.saved={...this.saved,...e},this.onChange();try{localStorage.setItem(Vf,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:Hf(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 bn()).furniturePreview({type:e,w:s,d:l,h:a,variant:null,lamp:Ki[e]??null},180,[...r]);this.shown?.type===e&&(this.shown={type:e,url:c,...o})}catch{this.shown=null}this.onChange()}};function W0(t,e){let n=t.hass?.language??"en",i=[...[...new Set(Object.values(cu).flat())].map(l=>({type:l,source:"builtin",id:l,size:nt[l],lamp:ue(l),electric:At(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,He(l,n)])),s=new Map(e.flatMap(l=>l.items.map(a=>[he(l.id,a.id),a])));return If(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(B0,`furn_${h.type}`)}).join(" ");return{card:l,label:d,search:`${p} ${t.t(`lib_cat_${l.category}`)}`,from:o.get(a.source)??"NextFloor"}})}var V0=(t,e)=>Nf(e,`${t.label} ${t.search} ${t.from} ${t.card.entries.map(n=>n.id.replace(/_/g," ")).join(" ")}`),K0=t=>t.lamp?"light":t.electric?"switch":null;function j0(t,e,n,r){let i=t.t,o=e.pickedOf(n.card),[s,l]=o.size,a=K0(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(),Ut.enabled&&(this._url=Ut.cached(this.type)??null,!this._url&&(gi??=new IntersectionObserver(Yw,{rootMargin:"120px"}),gi.observe(this)))}disconnectedCallback(){super.disconnectedCallback(),gi?.unobserve(this)}updated(e){e.has("type")&&e.get("type")!==void 0&&(this._url=Ut.cached(this.type)??null,!this._url&&Ut.enabled&&gi?.observe(this))}visible(){gi?.unobserve(this);let e=this.type;Ut.get(e).then(n=>{this.type===e&&(this._url=n)})}render(){return this._url?m`
`:_}};customElements.get("nf-thumb")||customElements.define("nf-thumb",gl);var em="nextfloor.library2",Xw={language:"en"},Wo=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(em);n&&(this.saved={...this.saved,...JSON.parse(n)})}catch{}}store(e){this.saved={...this.saved,...e},this.onChange();try{localStorage.setItem(em,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:Zf(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 vn()).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 Jw(t,e){let n=t.hass?.language??"en",i=[...[...new Set(Object.values(pu).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,Le(l,n)])),s=new Map(e.flatMap(l=>l.items.map(a=>[he(l.id,a.id),a])));return Gf(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(Xw,`furn_${h.type}`)}).join(" ");return{card:l,label:d,search:`${p} ${t.t(`lib_cat_${l.category}`)}`,from:o.get(a.source)??"NextFloor"}})}var Qw=(t,e)=>Xf(e,`${t.label} ${t.search} ${t.from} ${t.card.entries.map(n=>n.id.replace(/_/g," ")).join(" ")}`),e0=t=>t.lamp?"light":t.electric?"switch":null;function t0(t,e,n,r){let i=t.t,o=e.pickedOf(n.card),[s,l]=o.size,a=e0(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()}
>
- ${jt.enabled?m` `:_}
+ ${Ut.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)}>${Of(p,n.card.entries)} `)}
+ ${n.card.entries.map(p=>m`e.pick(n.card,p.type)}>${Uf(p,n.card.entries)} `)}
`:_}
-
`}function jf(t,e,n,r){return m`
${n.map(i=>j0(t,e,i,r))}
`}function cl(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 nm(t,e,n,r){return m`${n.map(i=>t0(t,e,i,r))}
`}function _l(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?jf(t,e,i,o):_}`}function Kf(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=ol(t),n=il(t),r=i=>i===e?0:n?.has(i)?1:2;return[...Tf].sort((i,o)=>r(i)-r(o))}function Gf(t,e,n,r){let i=t.t;jt.packs=r.packs;let o=W0(t,r.packs),s=Cf(e.query),l=il(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")&&!Pf(p.card.category)?!1:s.length===0||V0(p,s)}),u=(p,h)=>m`e.flip(p)}>${h} `,d=s.length>0;return m`
+ ${l?nm(t,e,i,o):_}`}function tm(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 n0(t){let e=pl(t),n=hl(t),r=i=>i===e?0:n?.has(i)?1:2;return[...Wf].sort((i,o)=>r(i)-r(o))}function rm(t,e,n,r){let i=t.t;Ut.packs=r.packs;let o=Jw(t,r.packs),s=Yf(e.query),l=hl(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")&&!Kf(p.card.category)?!1:s.length===0||Qw(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")}
@@ -1271,61 +1274,61 @@ ${o}`}else i=Fh(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?jf(t,e,c,r):m`${cl(t,e,"favourites",`\u2605 ${i("lib_favourites")}`,Kf(e.favourites,o),r,!0)}
- ${cl(t,e,"recent",`\u{1F558} ${i("lib_recent")}`,Kf(e.recent.slice(0,6),o),r,!1)}
- ${G0(n).map(p=>cl(t,e,p,i(`lib_cat_${p}`),c.filter(h=>h.card.category===p),r,p===(ol(n)??"lights")))}
+ ${d?nm(t,e,c,r):m`${_l(t,e,"favourites",`\u2605 ${i("lib_favourites")}`,tm(e.favourites,o),r,!0)}
+ ${_l(t,e,"recent",`\u{1F558} ${i("lib_recent")}`,tm(e.recent.slice(0,6),o),r,!1)}
+ ${n0(n).map(p=>_l(t,e,p,i(`lib_cat_${p}`),c.filter(h=>h.card.category===p),r,p===(pl(n)??"lights")))}
${a?m`
e.flip("room")}>${i("lib_all_rooms")} `:_}`}
- `}function Uf(t,e){return e?m`
+ `}function im(t,e){return e?m`
${e.url?m`
`:m`
`}
${Xe(t.hass,e.type)}
-
`:_}function ul(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 hl(t,e){let n=Math.max(0,e);for(let r=0;r+1Math.round(t*1e3)/1e3,pl=t=>t.map(([e,n])=>[Te(e),Te(n)]);function Zf(t,e){return{id:D("room"),name:e,area_id:null,points:pl(t),floor_material:"wood"}}function qf(t){return{...structuredClone(t),id:D("room"),points:pl(t.points.map(([e,n])=>[e+.5,n+.5]))}}function Yf(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=>!N([r.x,r.z],n.points)))}function Xf(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 Jf(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),pl([[i,o],[s,o],[s,l],[i,l]])}function Qf(t,e,n,r){return!Number.isFinite(r)||e<0||e>=t.points.length?null:t.points.map((i,o)=>o===e?n===0?[Te(r),i[1]]:[i[0],Te(r)]:[i[0],i[1]])}var U0=/^(Raum|Room) \d+$/;function fl(t,e,n,r=!0){let i=e?n[e]:void 0,o=!t.name||U0.test(t.name)||Object.values(n).some(s=>s.name===t.name);return{area_id:e||null,...r&&i&&o?{name:i.name}:{}}}function ml(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 em(t,e){let n=e.filter(a=>J(a.entity_id)==="light"&&(a.mount??"ceiling")==="ceiling"&&N([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:Te(r.x0+i/d*(p+.5)),z:Te(r.z0+o/l*(u+.5))}})}function gl(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=Te(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=Te(u.offset-c)))}var Z0=22.5;function tm(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/Z0));if(n<=0)return 24;let l=Math.floor(i/(n+.1));return l>=s?l:0}function q0(t,e,n,r){let i=dl(n);t.forEach((o,s)=>{let{piece:l,offset:a}=hl(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=Te(c>o.width?Math.min(c-o.width/2,Math.max(o.width/2,a)):c/2)})}function nm(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=N(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=(E,T)=>Math.abs(E[0]-T[0])<.001&&Math.abs(E[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=tm(l,r,g);if(!b)return!1;let y=ul(o,s,p,b).map(([v,w])=>[Te(v),Te(w)]);if(!y.length)return!1;for(let[v,w,x]of f){let k=x?[...y].reverse():y,M=h(v,w),E=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,O)=>gl(t,v.id,w+O,F)),v.wall_splits?.splice(w+1,0,...k.map(()=>null)),v.wall_splits?.[w]&&(v.wall_splits[w]=null),q0(M,T,[E,...k,v.points[(w+k.length+1)%v.points.length]],w)}return!0}function rm(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=tm(s,n,a);if(!c)return[];let u=ul(o.a,o.b,n,c).map(([f,g])=>[Te(f),Te(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:D("wall"),a:d[g],b:f}));r.splice(i,1,...p),t.walls=r;let h=dl(d);for(let f of l){let{piece:g,offset:b}=hl(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=Te(y>f.width?Math.min(y-f.width/2,Math.max(f.width/2,b)):y/2)}return p.map(f=>f.id)}var Qn=t=>Math.round(t*1e3)/1e3;function Lo(t,e,n){return[Math.round((e[0]-t[0])/n)*n,Math.round((e[1]-t[1])/n)*n]}var yn=(t,e)=>e?.01:t,er=(t,e,n=5)=>Math.hypot(t[0]-e[0],t[1]-e[1])>=n;function im(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 Qe=(t,e)=>[Qn(t[0]+e[0]),Qn(t[1]+e[1])];function _l(t,e,n,r){return[Qn(Math.round((t[0]+n[0]-e[0])/r)*r),Qn(Math.round((t[1]+n[1]-e[1])/r)*r)]}function bl(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 om(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 sm(t,e,n){let r=Fn([...t]),i=t[e],o=[Qn(n[0]),Qn(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 Co=t=>Math.round(t*1e3)/1e3,am=(t,e)=>Math.hypot(t[0]-e[0],t[1]-e[1]);function Y0(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=Y0(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:[Co(i[0]),Co(i[1])],guides:{point:i}}:J0(n,t,e)}var No=(t,e)=>pe(t.host.hass,e);function Q0(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 bl(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 vl(t,e){let n=Math.max(0,e);for(let r=0;r+1Math.round(t*1e3)/1e3,wl=t=>t.map(([e,n])=>[Te(e),Te(n)]);function om(t,e){return{id:D("room"),name:e,area_id:null,points:wl(t),floor_material:"wood"}}function sm(t){return{...structuredClone(t),id:D("room"),points:wl(t.points.map(([e,n])=>[e+.5,n+.5]))}}function am(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=>!N([r.x,r.z],n.points)))}function lm(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 cm(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),wl([[i,o],[s,o],[s,l],[i,l]])}function um(t,e,n,r){return!Number.isFinite(r)||e<0||e>=t.points.length?null:t.points.map((i,o)=>o===e?n===0?[Te(r),i[1]]:[i[0],Te(r)]:[i[0],i[1]])}var r0=/^(Raum|Room) \d+$/;function kl(t,e,n,r=!0){let i=e?n[e]:void 0,o=!t.name||r0.test(t.name)||Object.values(n).some(s=>s.name===t.name);return{area_id:e||null,...r&&i&&o?{name:i.name}:{}}}function xl(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 dm(t,e){let n=e.filter(a=>J(a.entity_id)==="light"&&(a.mount??"ceiling")==="ceiling"&&N([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:Te(r.x0+i/d*(p+.5)),z:Te(r.z0+o/l*(u+.5))}})}function $l(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=Te(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=Te(u.offset-c)))}var i0=22.5;function hm(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/i0));if(n<=0)return 24;let l=Math.floor(i/(n+.1));return l>=s?l:0}function o0(t,e,n,r){let i=yl(n);t.forEach((o,s)=>{let{piece:l,offset:a}=vl(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=Te(c>o.width?Math.min(c-o.width/2,Math.max(o.width/2,a)):c/2)})}function pm(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=N(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=(E,T)=>Math.abs(E[0]-T[0])<.001&&Math.abs(E[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=hm(l,r,g);if(!b)return!1;let y=bl(o,s,p,b).map(([v,w])=>[Te(v),Te(w)]);if(!y.length)return!1;for(let[v,w,x]of f){let k=x?[...y].reverse():y,M=h(v,w),E=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)=>$l(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),o0(M,T,[E,...k,v.points[(w+k.length+1)%v.points.length]],w)}return!0}function fm(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=hm(s,n,a);if(!c)return[];let u=bl(o.a,o.b,n,c).map(([f,g])=>[Te(f),Te(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:D("wall"),a:d[g],b:f}));r.splice(i,1,...p),t.walls=r;let h=yl(d);for(let f of l){let{piece:g,offset:b}=vl(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=Te(y>f.width?Math.min(y-f.width/2,Math.max(f.width/2,b)):y/2)}return p.map(f=>f.id)}var er=t=>Math.round(t*1e3)/1e3;function Vo(t,e,n){return[Math.round((e[0]-t[0])/n)*n,Math.round((e[1]-t[1])/n)*n]}var wn=(t,e)=>e?.01:t,tr=(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 Qe=(t,e)=>[er(t[0]+e[0]),er(t[1]+e[1])];function Sl(t,e,n,r){return[er(Math.round((t[0]+n[0]-e[0])/r)*r),er(Math.round((t[1]+n[1]-e[1])/r)*r)]}function Ml(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 gm(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 _m(t,e,n){let r=Fn([...t]),i=t[e],o=[er(n[0]),er(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 Ko=t=>Math.round(t*1e3)/1e3,bm=(t,e)=>Math.hypot(t[0]-e[0],t[1]-e[1]);function s0(t,e,n){let r=null,i=n;for(let o of t){let s=bm(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=bm(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=s0(n,t,e.reach);if(r)return{point:[r[0],r[1]],guides:{point:r}};let i=a0(e.rooms,t,e);return i?{point:[Ko(i[0]),Ko(i[1])],guides:{point:i}}:l0(n,t,e)}var jo=(t,e)=>pe(t.host.hass,e);function c0(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`
- ${No(t,s)}
+ ${jo(t,s)}
`}let[i,o]=[Math.abs(e.end[0]-e.start[0]),Math.abs(e.end[1]-e.start[1])];return R`
- ${No(t,i)} × ${No(t,o)}
- `}function ew(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`${No(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`
+ ${jo(t,i)} × ${jo(t,o)}
+ `}function u0(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`${jo(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 cm(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 vm(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 um(t,e,n,r,i){return e?Q0(t,e):n!=="polygon"&&n!=="measure"?_:ew(t,r,i,n==="measure")}var le=(t,e,n,r,i="")=>R` `,ie=(t,e,n,r,i="")=>R` `,hm=(t,e="")=>R`n.join(",")).join(" ")} />`,se=(t,e,n,r="")=>R` `,yl=(t,e,n,r,i="")=>R` `;function vl(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;lhm(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(To);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 nw(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)):Tc(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?hm([...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,mm=(t,e,n,r)=>{let[i,o]=r,s=R` `,l=R` ${s}`;return t==="data-rotate"?R`${l} `:R`${l} `};function rw(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 fm=new WeakMap;function iw(t,e){let n=fm.get(e);if(n&&n.states===t.states)return n.links;let r=Ve(t,[e]);return fm.set(e,{states:t.states,links:r}),r}function ow(t,e,n){if(!t||!ue(n.type))return!1;let r=iw(t,e).get(n.id)?.entity;return!!Mc(r?t.states[r]:void 0,(n.extra_lights??[]).map(i=>t.states[i]))}function gm(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=ow(r.hass,e,s),f=Ne.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 wm(t,e,n,r,i){return e?c0(t,e):n!=="polygon"&&n!=="measure"?_:u0(t,r,i,n==="measure")}var le=(t,e,n,r,i="")=>R` `,ie=(t,e,n,r,i="")=>R` `,xm=(t,e="")=>R`n.join(",")).join(" ")} />`,se=(t,e,n,r="")=>R` `,Rl=(t,e,n,r,i="")=>R` `;function El(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;lxm(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(Oo);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 h0(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)):Ic(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?xm([...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 Al=Math.PI/180,Mm=(t,e,n,r)=>{let[i,o]=r,s=R` `,l=R` ${s}`;return t==="data-rotate"?R`${l} `:R`${l} `};function p0(t,e){let n=e.rotation*Al;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 Sm=new WeakMap;function f0(t,e){let n=Sm.get(e);if(n&&n.states===t.states)return n.links;let r=Ve(t,[e]);return Sm.set(e,{states:t.states,links:r}),r}function m0(t,e,n){if(!t||!ue(n.type))return!1;let r=f0(t,e).get(n.id)?.entity;return!!Fc(r?t.states[r]:void 0,(n.extra_lights??[]).map(i=>t.states[i]))}function Rm(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*Al,p=Math.min(s.w,s.d)*i>44,h=m0(r.hass,e,s),f=Be.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`
- ${pm(s.type,s.w,s.d,s)}
+ ${$m(s.type,s.w,s.d,s)}
${p?R`${Xe(r.hass,s.type)} `:_}
- ${a?rw(t,s):_}
+ ${a?p0(t,s):_}
${l?R`${pe(r.hass,s.w)} × ${pe(r.hass,s.d)} `:_}
${l&&s.locked?R`🔒 `:_}
- ${a?mm("data-rotate",s.id,v,y):_}`};return R`${sf(e).map(o)} `}function _m(t,e,n){let{host:r}=t,i=o=>{let s=J(o.entity_id)??(r.hass?Be(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&&wu(o.entity_id,r.hass?.states[o.entity_id]),h=[l-Math.sin(d)*46,a+Math.cos(d)*46],f=Ln(r,o.entity_id,o.icon);return R`${p?mm("data-aim",o.entity_id,[l,a],h):_}
+ ${a?Mm("data-rotate",s.id,v,y):_}`};return R`${_f(e).map(o)} `}function Em(t,e,n){let{host:r}=t,i=o=>{let s=J(o.entity_id)??(r.hass?We(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)*Al,p=u&&r.admin&&!o.locked&&Su(o.entity_id,r.hass?.states[o.entity_id]),h=[l-Math.sin(d)*46,a+Math.cos(d)*46],f=Ln(r,o.entity_id,o.icon);return R`${p?Mm("data-aim",o.entity_id,[l,a],h):_}
${W(r.hass,o.entity_id)}
- ${f?R` `:R` `}
+ ${f?R` `: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`
+ ${u&&o.locked?R`🔒 `:_}`};return R`${e.placements.map(i)} `}function Am(t,e,n){return R`${(e.notes??[]).map(r=>{let[i,o]=t.toScreen([r.x,r.z]);return R`
${r.text}
✎
- `})}`}var Bo=(t,e,n=6)=>R` `;function ym(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=hu(e,e[n]);return R`${r.rooms.map(o=>R` `)}${i.map(o=>R` `)} `}function wm(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 Go=(t,e,n=6)=>R` `;function Fm(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 Tm(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=gu(e,e[n]);return R`${r.rooms.map(o=>R` `)}${i.map(o=>R` `)} `}function zm(t,e){let n=t.host.floor?.height??2.5;return R`${e.map(r=>{let i=r.height!==void 0&&r.height `})} `}function Pm(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 xm(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)=>Mo(t,o,i[(s+1)%i.length],"out",e.id,s))}${i.map((o,s)=>R`${Bo(...t.toScreen(o))} `)}`}function $m(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 Dm(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)=>To(t,o,i[(s+1)%i.length],"out",e.id,s))}${i.map((o,s)=>R`${Go(...t.toScreen(o))} `)}`}function Im(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}
- ${Fe(t.host.hass,ke(s.points))} `})} `}function Sm(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`
+ ${Fe(t.host.hass,ke(s.points))} `})} `}function Om(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 Mm(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&&!Li(o,!0,r.doc.settings);return R`
+ `}function Hm(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&&!Ci(o,!0,r.doc.settings);return R`
- ${c?R`${Bo(s[0],s[1])} ${Bo(l[0],l[1])} `:_}`};return R`${(e.walls??[]).map(i)} `}function Rm(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 Em(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`${Bo(u,d)} ${c+1} `};return R`${r.map((a,c)=>s(a,r[(c+1)%r.length],c))}${r.map(l)} `}function Am(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 Fm(t,e,n){let r=t.t;return m`
+ ${c?R`${Go(s[0],s[1])} ${Go(l[0],l[1])} `:_}`};return R`${(e.walls??[]).map(i)} `}function Lm(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 Cm(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`${Go(u,d)} ${c+1} `};return R`${r.map((a,c)=>s(a,r[(c+1)%r.length],c))}${r.map(l)} `}function Nm(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 Bm(t,e,n){let r=t.t;return m`
✎ ${r("note")}
${X(m`n.remove()}>${r("delete")} `)}
- `}function sw(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 Jn(a),u=D("img");await Lt(t.hass,u,c),n.patch({photo:`image:${u}`})};return m`${t.admin?m`📷 ${r(i?"picture_replace":"note_photo_upload")} `:_}
+ `}function g0(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 Qn(a),u=D("img");await Nt(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 aw(t,e,n,r){let i=Ie(e,n.rooms,n.walls??[]);if(!i)return null;let{room:o,edge:s}=i,l=Ct(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 $t=(t,e,n="")=>R` `;function lw(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`${$t(i,o)} `}function cw(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=Qt(n,e.exterior),a=n.leaves===2,[c,u]=[e.p0,e.p1],d=[],p=pu(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`${$t(e.at(v,o+.035),e.at(w,o+.035),"nf-open-pane")}${$t(e.at(v,o-.035),e.at(w,o-.035),"nf-open-pane")}`),b=(v,w)=>{let[x,k]=e.at(v,i),[M,E]=e.at(w,i),T=e.at(v,i+(r?-f:f)),F=f*t.scale,O=(T[0]-x)*(E-k)-(T[1]-k)*(M-x)>0?1:0;return R` `},y;return l==="passage"?y=$t(e.at(e.p0,o),e.at(e.p1,o),"nf-open-passage"):l==="sliding"?y=$t(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 uw(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 $t(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?$t(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`${$t(t.at(t.p0,n+.035),t.at(t.p1,n+.035))}${$t(t.at(t.p0,n-.035),t.at(t.p1,n-.035))}${r}`}function Tm(t,e,n,r){let i=e.openings.find(s=>s.id===r)?.front??null,o=s=>{let l=aw(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"&&Es(Qt(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"?lw(l,s):s.type==="door"?cw(t,l,s):uw(l,s);return R`h.join(",")).join(" ")} />${p} `};return R`${e.openings.map(o)} `}var zm=t=>Math.round(t*1e3)/1e3,Pm=t=>Math.round(t*100)/100;function tr(t,e){let n=[...t??[]].slice(0,e);for(;n.lengtht.every(e=>e===null);function gi(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 kl(t,e,n){let r=tr(t.wall_heights,t.points.length);r[e]=n,t.wall_heights=Wo(r)?void 0:r,Vo(t,e,null)}function Vo(t,e,n){if(n===null&&!t.wall_slopes)return;let r=tr(t.wall_slopes,t.points.length);r[e]=n,t.wall_slopes=Wo(r)?void 0:r}function Dm(t,e,n,r){let[i,o]=[n,r].map(l=>Math.min(30,Math.max(.05,zm(l)))),s=tr(t.wall_heights,t.points.length);s[e]=i,t.wall_heights=s,Vo(t,e,o)}function Im(t,e,n){let r=t.wall_heights?.[e];Vo(t,e,null),typeof r=="number"&&r>=n-.005&&kl(t,e,null)}function Om(t,e,n,r,i){let o=tr(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=Wo(o)?void 0:o,Vo(t,e,null)}function Hm(t,e,n,r){let i=gi(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=Pm((o+s)/2),a=tr(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 Lm(t,e,n,r,i){let o=gi(t,e),s=i.filter(u=>Math.abs(u-n)>.001&&u>0),l=Math.max(.1,Math.min(o-.1,Pm(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 Cm(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 Nm(t,e,n,r,i=1){let o=tr(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=Wo(o)?void 0:o}function Bm(t,e){let n=Math.min(1.5,Math.max(.02,zm(t)));return Math.abs(n-e)<5e-4?null:n}var Wm=.005,Vm=(t,e)=>`room:${t.id}:${e}`;function Km(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?gi(e,c):(d[h+1]??gi(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],E=h===void 0&&typeof M=="number"&&typeof u=="number",T=f??i,F=()=>n.light(c),O=()=>n.light(null);return m`
+ ${S(r("note_photo_hint"),"nf-wide")}`}function _0(t,e,n,r){let i=Oe(e,n.rooms,n.walls??[]);if(!i)return null;let{room:o,edge:s}=i,l=Bt(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 b0(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 y0(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=tn(n,e.exterior),a=n.leaves===2,[c,u]=[e.p0,e.p1],d=[],p=_u(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,E]=e.at(w,i),T=e.at(v,i+(r?-f:f)),F=f*t.scale,H=(T[0]-x)*(E-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 v0(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 Wm(t,e,n,r){let i=e.openings.find(s=>s.id===r)?.front??null,o=s=>{let l=_0(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"&&zs(tn(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"?b0(l,s):s.type==="door"?y0(t,l,s):v0(l,s);return R`
h.join(",")).join(" ")} />${p} `};return R`
${e.openings.map(o)} `}var Vm=t=>Math.round(t*1e3)/1e3,Km=t=>Math.round(t*100)/100;function nr(t,e){let n=[...t??[]].slice(0,e);for(;n.length
t.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 Fl(t,e,n){let r=nr(t.wall_heights,t.points.length);r[e]=n,t.wall_heights=Uo(r)?void 0:r,Zo(t,e,null)}function Zo(t,e,n){if(n===null&&!t.wall_slopes)return;let r=nr(t.wall_slopes,t.points.length);r[e]=n,t.wall_slopes=Uo(r)?void 0:r}function jm(t,e,n,r){let[i,o]=[n,r].map(l=>Math.min(30,Math.max(.05,Vm(l)))),s=nr(t.wall_heights,t.points.length);s[e]=i,t.wall_heights=s,Zo(t,e,o)}function Gm(t,e,n){let r=t.wall_heights?.[e];Zo(t,e,null),typeof r=="number"&&r>=n-.005&&Fl(t,e,null)}function Um(t,e,n,r,i){let o=nr(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=Uo(o)?void 0:o,Zo(t,e,null)}function Zm(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=Km((o+s)/2),a=nr(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 qm(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,Km(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 Ym(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 Xm(t,e,n,r,i=1){let o=nr(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=Uo(o)?void 0:o}function Jm(t,e){let n=Math.min(1.5,Math.max(.02,Vm(t)));return Math.abs(n-e)<5e-4?null:n}var Qm=.005,eg=(t,e)=>`room:${t.id}:${e}`;function tg(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],E=h===void 0&&typeof M=="number"&&typeof u=="number",T=f??i,F=()=>n.light(c),H=()=>n.light(null);return m`
${x} ${pe(t.hass,y)}
${f===0?m`
${r("wall_none")} `:E?m`
${A(t,r("wall_slope_start"),u,P=>n.setSlope(e,c,P,M),.05,.05)}
${A(t,r("wall_slope_end"),M,P=>n.setSlope(e,c,u,P),.05,.05)} `:A(t,r("wall_height"),T,P=>v(P>=i-Wm?null:Math.max(.05,P)),.05,.05)}
+ >`:A(t,r("wall_height"),T,P=>v(P>=i-Qm?null:Math.max(.05,P)),.05,.05)}
${t.admin&&E?m`
n.clearSlope(e,c)}>▭ `:_}
${t.admin&&f!==null&&!E?m`
v(null)}>↥ `:_}
- ${t.admin&&h===void 0&&f!==0&&!E?m`
n.setSlope(e,c,T,T>=i-Wm?T+1:i)}>∠ ${r("wall_slope")} `:_}
+ ${t.admin&&h===void 0&&f!==0&&!E?m`
n.setSlope(e,c,T,T>=i-Qm?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?zo(t,Vm(e,c),n.arc):_}
+ ${h===void 0&&y>=.4?Ho(t,eg(e,c),n.arc):_}
${(h===void 0||h===0)&&f!==0?m`
n.openWall(e,c)}>▣ ${r("wall_view")} `:_}
${f!==0?m`
${A(t,r("edge_thickness"),b??w,P=>n.setThickness(e,c,Bm(P,w),h,d.length),.01,.02)}
+ >${A(t,r("edge_thickness"),b??w,P=>n.setThickness(e,c,Jm(P,w),h,d.length),.01,.02)}
${t.admin&&b!=null?m`n.setThickness(e,c,null,h,d.length)}>↺ `:_} `:_}
- ${h===void 0?Po(t,Vm(e,c),n.arc):_}
+ ${h===void 0?Lo(t,eg(e,c),n.arc):_}
${k?m`
${A(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 jm(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 Ko(t,e=[],n){let r=H(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 ng(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 qo(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:D("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:jm(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:ng(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 Gm(t,e,n){let r=e.color_entity&&e.color_entity!=="none"?e.color_entity:n;return r?t.states[r]:void 0}var xl=["none","rainbow","pulse","flicker"];function jo(t,e,n,r){let i=e.effect_animations??{},o=_u(),s=c=>xl.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 rg(t,e,n){let r=e.color_entity&&e.color_entity!=="none"?e.color_entity:n;return r?t.states[r]:void 0}var Tl=["none","rainbow","pulse","flicker"];function Yo(t,e,n,r){let i=e.effect_animations??{},o=wu(),s=c=>Tl.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")}) `:_}
- ${xl.map(u=>m`${t.t(`light_animation_${u}`)} `)}
+ ${Tl.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 dw=/speaker|sound|subwoofer|receiver|smart_|display|tv|media|turntable|projector|console/;function hw(t,e,n){let r=J(e),i=t.hass?.language??"en",o=[...Bi.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 ${He(l,i)}`})))],s=l=>r==="light"?ue(l):r==="climate"?l==="radiator"||Sn(l):e.startsWith("vacuum.")?l==="robot_vacuum"||vt(l)&&l.endsWith(":robot_vacuum"):r==="media"?Rr(l)||At(l)&&dw.test(l):At(l)&&!ue(l);return o.filter(l=>s(l.type)).sort((l,a)=>l.label.localeCompare(a.label))}function pw(t,e,n){if(!t.admin)return _;let r=hw(t,e.entity_id,n.packs);return r.length===0?_:m`
`}var w0=/speaker|sound|subwoofer|receiver|smart_|display|tv|media|turntable|projector|console/;function k0(t,e,n){let r=J(e),i=t.hass?.language??"en",o=[...Wi.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 ${Le(l,i)}`})))],s=l=>r==="light"?ue(l):r==="climate"?l==="radiator"||Mn(l):e.startsWith("vacuum.")?l==="robot_vacuum"||vt(l)&&l.endsWith(":robot_vacuum"):r==="media"?Er(l)||Tt(l)&&w0.test(l):Tt(l)&&!ue(l);return o.filter(l=>s(l.type)).sort((l,a)=>l.label.localeCompare(a.label))}function x0(t,e,n){if(!t.admin)return _;let r=k0(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 fw(t,e,n){let r=t.hass?.language??"en";return yu(e.entity_id,t.hass?.states[e.entity_id]).map(({pluginId:i,name:o,settings:s})=>{let l=vu(s,e.plugin?.[i]),a=(u,d)=>n({plugin:{...e.plugin??{},[i]:{...e.plugin?.[i]??{},[u]:d}}}),c=s.map(u=>{let d=Zi(u.label,r),p=u.hint?Zi(u.hint,r):void 0;if(u.type==="boolean")return I(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,Zi(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 A(t,d,Number(l[u.key]),f=>a(u.key,h(f)),u.step??1,u.min)});return m`🔌 ${o} ${c}`})}function $l(t,e,n){let r=t.t,i=J(e.entity_id)??(t.hass?Be(t.hass,e.entity_id):null),o=i==="light",s=e.mount??"ceiling",l=i?Pi(i,t.floor?ht(t.floor,e.x,e.z):2.5,o?s:null):1,a=p=>n.update(p),c=Ln(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 $0(t,e,n){let r=t.hass?.language??"en";return xu(e.entity_id,t.hass?.states[e.entity_id]).map(({pluginId:i,name:o,settings:s})=>{let l=$u(s,e.plugin?.[i]),a=(u,d)=>n({plugin:{...e.plugin??{},[i]:{...e.plugin?.[i]??{},[u]:d}}}),c=s.map(u=>{let d=qi(u.label,r),p=u.hint?qi(u.hint,r):void 0;if(u.type==="boolean")return I(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,qi(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 A(t,d,Number(l[u.key]),f=>a(u.key,h(f)),u.step??1,u.min)});return m`
🔌 ${o} ${c}`})}function zl(t,e,n){let r=t.t,i=J(e.entity_id)??(t.hass?We(t.hass,e.entity_id):null),o=i==="light",s=e.mount??"ceiling",l=i?Di(i,t.floor?ht(t.floor,e.x,e.z):2.5,o?s:null):1,a=p=>n.update(p),c=Ln(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` `}
${W(t.hass,e.entity_id)}
- ${i==="cover"?z(t,r("cover_tilt_entity"),e.cover_tilt??null,void 0,H(t.hass,p=>p.startsWith("cover.")),p=>a({cover_tilt:p&&p!=="none"?p:null}),{types:[1,2],role:"cover"}):_}
+ ${i==="cover"?z(t,r("cover_tilt_entity"),e.cover_tilt??null,void 0,O(t.hass,p=>p.startsWith("cover.")),p=>a({cover_tilt:p&&p!=="none"?p:null}),{types:[1,2],role:"cover"}):_}
${i==="cover"?m`
${I(t,r("cover_direction_invert"),!!e.cover_inverted,p=>a({cover_inverted:p||void 0}))}
${I(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,H(t.hass,p=>Qi(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=>eo(t.hass,p)),p=>a({position:p&&p!=="none"?p:null}),{types:[1,2]})}
${e.position?I(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})}${rn(t,e.glow_scale,p=>a({glow_scale:p}))}`:_}
- ${o?jo(t,e,t.hass?.states[e.entity_id]?.attributes.effect_list,a):_}
- ${e.entity_id.startsWith("media_player.")?rn(t,e.sound_rings,p=>a({sound_rings:p}),{label:"sound_rings",hint:"sound_rings_hint",lowest:0}):_}
+ ${o?m`${L(t,r("lamp_mount"),s,d,u,{wide:!0})}${sn(t,e.glow_scale,p=>a({glow_scale:p}))}`:_}
+ ${o?Yo(t,e,t.hass?.states[e.entity_id]?.attributes.effect_list,a):_}
+ ${e.entity_id.startsWith("media_player.")?sn(t,e.sound_rings,p=>a({sound_rings:p}),{label:"sound_rings",hint:"sound_rings_hint",lowest:0}):_}
${A(t,r("x"),e.x,p=>a({x:p}))} ${A(t,r("z"),e.z,p=>a({z:p}))}
${A(t,r("marker_height"),e.y??l,p=>a({y:Math.max(0,p)}),.05,0)}
${A(t,r("rotation"),e.rotation??0,p=>a({rotation:(p%360+360)%360}),1)}
${o?I(t,r("device_simple"),!!e.simple,p=>a({simple:p||void 0}),{title:r("device_simple_hint")}):_}
- ${i&&xc.has(i)?I(t,r("device_confirm"),!!e.confirm,p=>a({confirm:p}),{title:r("device_confirm_hint")}):_}
+ ${i&&Rc.has(i)?I(t,r("device_confirm"),!!e.confirm,p=>a({confirm:p}),{title:r("device_confirm_hint")}):_}
${I(t,r("device_outside"),!!e.outside,p=>a({outside:p||void 0}),{title:r("device_outside_hint")})}
${Cn(t,e.marker??null,p=>a({marker:p}))}
${Nn(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:W(t.hass,e.entity_id)})}
${e.name?I(t,r("show_name"),!!e.show_name,p=>a({show_name:p||void 0})):_}
- ${Ht(t,e.icon,p=>a({icon:p}))}
- ${fw(t,e,a)}
- ${Ko(t,e.values,p=>a({values:p}))}
+ ${Ct(t,e.icon,p=>a({icon:p}))}
+ ${$0(t,e,a)}
+ ${qo(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")} `:_}
- ${pw(t,e,n)}
+ ${x0(t,e,n)}
n.remove()}>${r("devices_remove")}
`:_}
- `}var _i=t=>Number(t);function Go(t){if(Array.isArray(t)){let[o,s]=[_i(t[0]),_i(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]=[_i(e),_i(n)];return Number.isFinite(r)&&Number.isFinite(i)?[r,i]:null}function qm(t){return t?Go(t.charger)??Go(t.charger_position):null}function Uo(t){for(let[e,n]of Object.entries(t.states))if(e.startsWith("camera.")&&(Go(n.attributes?.vacuum_position)??qm(n.attributes)))return e;return null}var Sl=(t,e)=>e?[t[0],-t[1]]:t;var Ym=5e-4,Xm=2,mw=1.5;function Ml(t,e){let n=e?t.states[e]?.attributes:void 0;return{at:n?Go(n.vacuum_position):null,dock:qm(n)}}function Jm(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>=mw))return{cal:null,reason:"close"};let o=r/i;return o>=Ym&&o<=Xm?{cal:{a:t.plan,ga:t.grid,b:e.plan,gb:e.grid,mirror:n}}:{cal:null,reason:"scale"}}function Qm(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(_i);!s||!l.every(Number.isFinite)||r.push({name:s,center:[(l[0]+l[2])/2,(l[1]+l[3])/2]})}return r}var Um=t=>t.toLocaleLowerCase().normalize("NFKD").replace(/[̀-ͯ]/g,"").replace(/[^\p{L}\p{N}]+/gu,"");function gw(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 eg(t,e,n=!1){let r=new Map(e.map(g=>[Um(g.name),g])),i=[],o=new Set;for(let g of t){let b=Um(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=gw(i.map(y=>({plan:y.plan,seen:Sl(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>=Ym&&a.scale<=Xm))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(Sl(h,a.mirror)),ga:h,b:a.map(Sl(f,a.mirror)),gb:f,mirror:a.mirror},matched:s,rms:a.rms}}function tg(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[Zm(n+p*o-h*s+a),Zm(r+p*s+h*o+c)]};return{...t,a:u(t.a),b:u(t.b)}}var Zm=t=>Math.round(t*1e3)/1e3;var _w=/^(binary_sensor|switch|input_boolean|light|fan|person|device_tracker|sensor)\./,St=t=>t==="none"?null:t;function Rl(t,e,n){let r=t.t,i=H(t.hass,a=>_w.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:St(a)}))}
- ${o?z(t,r("furn_state_entity2"),e.state_entity2??null,void 0,i,a=>n.update({state_entity2:St(a)})):_}
+ `}var bi=t=>Number(t);function Xo(t){if(Array.isArray(t)){let[o,s]=[bi(t[0]),bi(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]=[bi(e),bi(n)];return Number.isFinite(r)&&Number.isFinite(i)?[r,i]:null}function sg(t){return t?Xo(t.charger)??Xo(t.charger_position):null}function Jo(t){for(let[e,n]of Object.entries(t.states))if(e.startsWith("camera.")&&(Xo(n.attributes?.vacuum_position)??sg(n.attributes)))return e;return null}var Pl=(t,e)=>e?[t[0],-t[1]]:t;var ag=5e-4,lg=2,S0=1.5;function Dl(t,e){let n=e?t.states[e]?.attributes:void 0;return{at:n?Xo(n.vacuum_position):null,dock:sg(n)}}function cg(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>=S0))return{cal:null,reason:"close"};let o=r/i;return o>=ag&&o<=lg?{cal:{a:t.plan,ga:t.grid,b:e.plan,gb:e.grid,mirror:n}}:{cal:null,reason:"scale"}}function ug(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(bi);!s||!l.every(Number.isFinite)||r.push({name:s,center:[(l[0]+l[2])/2,(l[1]+l[3])/2]})}return r}var ig=t=>t.toLocaleLowerCase().normalize("NFKD").replace(/[̀-ͯ]/g,"").replace(/[^\p{L}\p{N}]+/gu,"");function M0(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 dg(t,e,n=!1){let r=new Map(e.map(g=>[ig(g.name),g])),i=[],o=new Set;for(let g of t){let b=ig(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=M0(i.map(y=>({plan:y.plan,seen:Pl(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>=ag&&a.scale<=lg))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(Pl(h,a.mirror)),ga:h,b:a.map(Pl(f,a.mirror)),gb:f,mirror:a.mirror},matched:s,rms:a.rms}}function hg(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[og(n+p*o-h*s+a),og(r+p*s+h*o+c)]};return{...t,a:u(t.a),b:u(t.b)}}var og=t=>Math.round(t*1e3)/1e3;var R0=/^(binary_sensor|switch|input_boolean|light|fan|person|device_tracker|sensor)\./,Rt=t=>t==="none"?null:t;function Il(t,e,n){let r=t.t,i=O(t.hass,a=>R0.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 bw(t,e){let r=In(t.type)&&(!vt(t.type)||Pc(t.type));return ue(t.type)?{accept:i=>/^(light|switch|input_boolean)\./.test(i),label:"furn_entity_light"}:t.type==="radiator"||Sn(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)||$c(e?.states[i]),label:"furn_entity"}}function Zo(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 Ve(t.hass,r).get(e.id)?.[n]??null}var yw=t=>t==="meter"?"energy_grid":t==="inverter"?"energy_solar_sensor":t==="home_battery"?"energy_battery_sensor":"furn_power",ct=(...t)=>m`${t}
`;async function vw(t){let e=t.hass?Uo(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 Ml(t.hass,e)}function ww(t,e){let n=t.t,r=a=>t.change(c=>{c.settings.vacuum_map=tg(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(r("furn_state_hint"),"nf-wide")}`}function E0(t,e){let r=In(t.type)&&(!vt(t.type)||Hc(t.type));return ue(t.type)?{accept:i=>/^(light|switch|input_boolean)\./.test(i),label:"furn_entity_light"}:t.type==="radiator"||Mn(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)||Ec(e?.states[i]),label:"furn_entity"}}function Qo(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 Ve(t.hass,r).get(e.id)?.[n]??null}var A0=t=>t==="meter"?"energy_grid":t==="inverter"?"energy_solar_sensor":t==="home_battery"?"energy_battery_sensor":"furn_power",ct=(...t)=>m`${t}
`;async function F0(t){let e=t.hass?Jo(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 Dl(t.hass,e)}function T0(t,e){let n=t.t,r=a=>t.change(c=>{c.settings.vacuum_map=hg(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 kw(t,e){let n=t.t,r=t.doc.settings.vacuum_map??null,i=t.hass?Ml(t.hass,Uo(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&&vw(t).then(h=>{if(!h.at||!h.dock)return;let f={plan:[e.x,e.z],grid:h.dock},g=Jm(f,{plan:p,grid:h.at},r?.mirror??!1);g.cal&&t.change(b=>{b.settings.vacuum_map=g.cal})})})},a=t.hass?Uo(t.hass):null,c=t.hass?Qm(t.hass,a):[],u=t.doc.floors.find(p=>p.furniture.some(h=>h.id===e.id)),d=()=>{if(!u)return;let p=eg(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?I(t,n("robot_cal_mirror"),!!r.mirror,p=>t.change(h=>{h.settings.vacuum_map={...r,mirror:p}})):_,r?ww(t,r):_,r?m`t.change(p=>{p.settings.vacuum_map=null})}>${n("robot_cal_forget")} `:_,S(n("robot_cal_hint"),"nf-wide"))}function xw(t,e,n){let r=t.t,i=t.doc;if(!i.energy.advanced)return _;let o=Yn(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"),li(i,e)??"",[["",r("meter_main")],...s],l=>n.update({parent_meter:l||null}),{wide:!0}),S(r("meter_device_hint"),"nf-wide"))}function $w(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=>Yh(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?I(t,r("energy_invert"),!!e.meter_invert,c=>n.update({meter_invert:c})):_,s?m`${r("meter_floors")}
${i.floors.map(c=>I(t,c.name,l.includes(c.id),u=>a(c.id,u)))}`:_,S(r("meter_sub_hint"),"nf-wide"))}function ng(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,H(t.hass,o),s=>r.update({care_entity:St(s)}))}
+
`}function z0(t,e){let n=t.t,r=t.doc.settings.vacuum_map??null,i=t.hass?Dl(t.hass,Jo(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&&F0(t).then(h=>{if(!h.at||!h.dock)return;let f={plan:[e.x,e.z],grid:h.dock},g=cg(f,{plan:p,grid:h.at},r?.mirror??!1);g.cal&&t.change(b=>{b.settings.vacuum_map=g.cal})})})},a=t.hass?Jo(t.hass):null,c=t.hass?ug(t.hass,a):[],u=t.doc.floors.find(p=>p.furniture.some(h=>h.id===e.id)),d=()=>{if(!u)return;let p=dg(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?I(t,n("robot_cal_mirror"),!!r.mirror,p=>t.change(h=>{h.settings.vacuum_map={...r,mirror:p}})):_,r?T0(t,r):_,r?m`t.change(p=>{p.settings.vacuum_map=null})}>${n("robot_cal_forget")} `:_,S(n("robot_cal_hint"),"nf-wide"))}function P0(t,e,n){let r=t.t,i=t.doc;if(!i.energy.advanced)return _;let o=Xn(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"),ci(i,e)??"",[["",r("meter_main")],...s],l=>n.update({parent_meter:l||null}),{wide:!0}),S(r("meter_device_hint"),"nf-wide"))}function D0(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=>ap(i,e,u)).map(u=>[u.id,`${u.name||r("furn_meter")} \xB7 ${c.name}`])),s=!!bn(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?I(t,r("energy_invert"),!!e.meter_invert,c=>n.update({meter_invert:c})):_,s?m`${r("meter_floors")}
${i.floors.map(c=>I(t,c.name,l.includes(c.id),u=>a(c.id,u)))}`:_,S(r("meter_sub_hint"),"nf-wide"))}function pg(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"?A(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 rg(t,e,n){let r=t.t;return m`
- ${z(t,r("furn_cover_entity"),e.cover_entity??null,void 0,H(t.hass,i=>i.startsWith("cover.")),i=>n.update({cover_entity:St(i)}),{types:[1,2],role:"cover"})}
+
`}function fg(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"})}
${I(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 ig(t,e,n,r){let i=t.t,o=/socket/.test(e.type),s=H(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]=St(u),r.update({gang_entities:d})};return m`
+
`}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`
${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 Sw(t,e,n){let r=t.t,i=H(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:St(o)}),{types:[1,2]}),z(t,r("freezer_temp"),e.temp_entity2??null,void 0,i,o=>n.update({temp_entity2:St(o)}),{types:[1,2]}),S(r("fridge_temp_hint"),"nf-wide"))}function Mw(t,e,n){let r=t.t,i=H(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:St(o)}),{types:[1,2]}),S(r("device_temp_hint"),"nf-wide"))}function Rw(t,e,n){let r=t.t,i=e.extra_lights??[],o=H(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 og(t,e,n){let{hass:r}=t;if(!r)return _;let i=t.t,o=ue(e.type),s=bw(e,r),l=H(r,b=>re(r)?We(r,b,[1,2]):On(r,b)),a=b=>y=>n.update({[b]:St(y)}),c=b=>H(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=Zo(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":In(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,Zo(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,Zo(t,e,"fan"),c(b=>b.startsWith("fan.")),b=>n.update({fan_entity:b}),{types:[0,1,2]}):_,!o&&!Ne.includes(e.type)&&!Rr(e.type)?Rl(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?Rw(t,e,n):_,o?rn(t,e.glow_scale,b=>n.update({glow_scale:b})):_,o?jo(t,e,Gm(r,e,e.entity&&e.entity!=="none"?e.entity:Zo(t,e,"entity"))?.attributes.effect_list,n.update):_,Rr(e.type)?rn(t,e.ambilight,b=>n.update({ambilight:b}),{label:"ambilight",hint:"ambilight_hint",lowest:0}):_,In(e.type)||to(e.type)?rn(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":yw(e.type)),e.power??null,p,l,b=>n.update({power:b}),{types:[1,2]})}
+ `}function I0(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 O0(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 H0(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 gg(t,e,n){let{hass:r}=t;if(!r)return _;let i=t.t,o=ue(e.type),s=E0(e,r),l=O(r,b=>Q(r)?De(r,b,[1,2]):On(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=Qo(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":In(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,Qo(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,Qo(t,e,"fan"),c(b=>b.startsWith("fan.")),b=>n.update({fan_entity:b}),{types:[0,1,2]}):_,!o&&!Be.includes(e.type)&&!Er(e.type)?Il(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?H0(t,e,n):_,o?sn(t,e.glow_scale,b=>n.update({glow_scale:b})):_,o?Yo(t,e,rg(r,e,e.entity&&e.entity!=="none"?e.entity:Qo(t,e,"entity"))?.attributes.effect_list,n.update):_,Er(e.type)?sn(t,e.ambilight,b=>n.update({ambilight:b}),{label:"ambilight",hint:"ambilight_hint",lowest:0}):_,In(e.type)||no(e.type)?sn(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(bn(t.doc,e)?"meter_sub_power":A0(e.type)),e.power??null,p,l,b=>n.update({power:b}),{types:[1,2]})}
${I(t,i("furniture_power_card"),!!e.power_card,b=>n.update({power_card:b||void 0}))}${S(i("furniture_power_card_hint"),"nf-wide")}`)}
- ${Ku(e.type)?Sw(t,e,n):o||e.type==="grid_point"?_:Mw(t,e,n)}
- ${e.type==="meter"?$w(t,e,n):_}
- ${e.type==="inverter"||e.type==="home_battery"?xw(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")):_}
+ ${Zu(e.type)?I0(t,e,n):o||e.type==="grid_point"?_:O0(t,e,n)}
+ ${e.type==="meter"?D0(t,e,n):_}
+ ${e.type==="inverter"||e.type==="home_battery"?P0(t,e,n):_}
+ ${e.type==="meter"&&!bn(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=>no(b)||me(b)),a("status"))):_}
+ ${e.type==="wallbox"?ct(z(t,i("furn_wallbox_status"),e.status??null,void 0,c(b=>ro(b)||me(b)),a("status"))):_}
${!o||d||h?m`${I(t,i("device_confirm"),!!e.confirm,b=>n.update({confirm:b}),{title:i("device_confirm_hint")})}
- ${Cn(t,e.marker??null,b=>n.update({marker:b}))}${Ht(t,e.icon,b=>n.update({icon:b}))}${o?_:Nn(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,Zu(r,Ve(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?kw(t,e):_}
+ ${Cn(t,e.marker??null,b=>n.update({marker:b}))}${Ct(t,e.icon,b=>n.update({icon:b}))}${o?_:Nn(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,Ju(r,Ve(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"))}`:_}
- ${Ko(t,e.values,b=>n.update({values:b}))}
- ${S(i(g))}`}var Ew=/^(binary_sensor|device_tracker|input_boolean|switch|sensor)\./,Aw=/^(sensor|input_select|select|input_text)\./,Fw=/^(device_tracker|sensor|binary_sensor|lock|climate)\./,Tw=(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 ${He(n,e)}`})));function sg(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)}>
+ ${qo(t,e.values,b=>n.update({values:b}))}
+ ${S(i(g))}`}var L0=/^(binary_sensor|device_tracker|input_boolean|switch|sensor)\./,C0=/^(sensor|input_select|select|input_text)\./,N0=/^(device_tracker|sensor|binary_sensor|lock|climate)\./,B0=(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 ${Le(n,e)}`})));function _g(t,e){return e.startsWith("device_tracker.")?t.hass?.states[e]?.attributes.source_type==="router"?2:0:1}function bg(t,e,n,r){return m`r(i.target.value||null)}>
${t.t("parking_vehicle_none")}
${e.map(i=>m`${i.label} `)}
- `}function zw(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 W0(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??""}))}
+ ${bg(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 lg(t,e,n,r){let i=t.t,o=Tw(n,t.hass?.language??"en"),s=H(t.hass,f=>Ew.test(f)).sort((f,g)=>sg(t,f.id)-sg(t,g.id)),l=H(t.hass,f=>Aw.test(f)),a=e.car??{},c=t.floor,u=c?.rooms.find(f=>f.points.length>=3&&N([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 yg(t,e,n,r){let i=t.t,o=B0(n,t.hass?.language??"en"),s=O(t.hass,f=>L0.test(f)).sort((f,g)=>_g(t,f.id)-_g(t,g.id)),l=O(t.hass,f=>C0.test(f)),a=e.car??{},c=t.floor,u=c?.rooms.find(f=>f.points.length>=3&&N([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`
${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")} ${bg(t,o,e.vehicle??null,f=>r.update({vehicle:f}))}
${o.length>0?_:S(i("parking_no_pack"),"nf-wide")}
${A(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?zw(t,e,o,r):_}
+ ${e.type_entity?W0(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,H(t.hass,f=>Fw.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=>N0.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,H(t.hass,f=>/^(sensor|input_datetime|time|datetime)\./.test(f)),f=>r.update({car:{...a,departure:f==="none"?null:f}}))}`:_}`}function cg(t,e){let r=_n(t,e.w,e.d,e.h).treads.findIndex(i=>i.landing);return r>=0?r+1:1}function Pw(t){let e=_n(pi(t),t.w,t.d,t.h),n=e.treads.map(To),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 Dw(t){let[e,n]=Va[t],r=_n({..._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 vg(t,e){let r=yn(t,e.w,e.d,e.h).treads.findIndex(i=>i.landing);return r>=0?r+1:1}function V0(t){let e=yn(fi(t),t.w,t.d,t.h),n=e.treads.map(Oo),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 K0(t){let[e,n]=Xa[t],r=yn({..._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 ug(t,e,n){let r=t.t,i=pi(e),o=f=>n.update({stair:{...i,...f}}),s=i.shape!=="straight",l=f=>{let[g,b]=Va[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=Pw(e),p=f=>K(t.hass,f*100,1),h=d.measure>=.59&&d.measure<=.65&&d.rise<=.21;return m`