0){o.textContent=wo?wo.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,o){let i=this.strings,s=!1;if(i===void 0)e=qt(this,e,n,0),s=!pr(e)||e!==this._$AH&&e!==Qe,s&&(this._$AH=e);else{let l=e,a,c;for(e=i[0],a=0;a{let r=n?.renderBefore??e,o=r._$litPart$;if(o===void 0){let i=n?.renderBefore??null;r._$litPart$=o=new vn(e.insertBefore(hr(),i),i,void 0,n??{})}return o._$AI(t),o};var as=globalThis,Q=class extends gt{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=sc(n,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return Qe}};Q._$litElement$=!0,Q.finalized=!0,as.litElementHydrateSupport?.({LitElement:Q});var g_=as.litElementPolyfillSupport;g_?.({LitElement:Q});(as.litElementVersions??=[]).push("4.2.2");var cs=t=>t.slice(0,t.indexOf(".")),__={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"},X=t=>__[cs(t)]??null,ds=["light","cover","climate","media","switch","fan","lock","binary","sensor","scene","script"];var ac=new Set(["light","switch","fan"]),Mt=t=>t!==null&&t!=="scene"&&t!=="script",Je=t=>!t||t.state==="unavailable"||t.state==="unknown"&&!t.entity_id.startsWith("event.");function V(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 o=r.slice(n.length+1);return o[0].toUpperCase()+o.slice(1)}var lc=t=>!!t&&t.entity_id.startsWith("sensor.")&&t.attributes.device_class==="enum";var cc=t=>Math.min(1,Math.max(0,t));function b_(t){let e=cc((t-2200)/4300),n=[1,.66,.26],r=[.78,.9,1];return[0,1,2].map(o=>n[o]+(r[o]-n[o])*e)}function ls(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(cc(n.brightness/255)):1,o=n.rgb_color;return o&&!["color_temp","brightness","onoff"].includes(String(n.color_mode))?{color:[o[0]/255,o[1]/255,o[2]/255],level:r}:typeof n.color_temp_kelvin=="number"?{color:b_(n.color_temp_kelvin),level:r}:{color:[1,.71,.28],level:r}}function dc(t,e,n){let r=ls(t,n);if(r)return r;for(let o of e){let i=ls(o);if(i)return{color:i.color,level:i.level*.6}}return null}function Ro(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=[],Eo=new Map,y_=0,ue=(t,e)=>`pack:${t}:${e}`,bt=t=>t.startsWith("pack:");function us(t){fc=t,Eo=new Map;for(let e of t)for(let n of e.items)Eo.set(ue(e.id,n.id),n);y_+=1}var gr=()=>fc;var v_={};function G(t){if(!bt(t))return;let e=Eo.get(t);if(e)return e;let[,n,...r]=t.split(":"),o=v_[n];return o?Eo.get(ue(o,r.join(":"))):void 0}var w_=.22;function uc(t,e,n,r){let o=Math.min(w_,n/3);if(r<=o*2.4||Math.abs(r-n)<1e-6)return e*(r/n)+(t-e)*(r/n);let i=e*(r/n),s=t-e;return s<=o?i+s:s>=n-o?i+r-(n-s):i+o+(s-o)*(r-2*o)/(n-2*o)}function mr(t,e,n,r,o){return[uc(t*r,n*r,r,o)/o,uc(e*r,n*r,r,o)/o]}var hc=new WeakMap;function mc(t,e,n,r){let[o,i,s]=t.size;if(t.vehicle||t.stretch||Math.abs(e-o)<1e-4&&Math.abs(n-i)<1e-4&&Math.abs(r-s)<1e-4)return t.parts;let l=`${e.toFixed(4)}|${n.toFixed(4)}|${r.toFixed(4)}`,a=hc.get(t),c=a?.get(l);if(c)return c;let d=t.parts.map(u=>{if(u.shape==="sweep")return u;let[p,h]=mr(u.x-u.w/2,u.x+u.w/2,-.5,o,e),[f,g]=mr(u.z-u.d/2,u.z+u.d/2,-.5,i,n),[y,b]=mr(u.y,u.y+u.h,0,s,r);if(u.rot)return{...u,x:(p+h)/2,z:(f+g)/2,w:u.w*o/e,d:u.d*i/n,y,h:b-y};let w={...u,x:(p+h)/2,z:(f+g)/2,w:h-p,d:g-f,y,h:b-y};if(u.shape==="loft"){let[v,x,k,S]=[u.tx??u.x,u.tz??u.z,u.tw??u.w,u.td??u.d],[A,F]=mr(v-k/2,v+k/2,-.5,o,e),[T,D]=mr(x-S/2,x+S/2,-.5,i,n);Object.assign(w,{tx:(A+F)/2,tz:(T+D)/2,tw:F-A,td:D-T})}return w});return a||hc.set(t,a=new Map),a.size>32&&a.clear(),a.set(l,d),d}var hs=t=>!!t?.parts.some(e=>e.move);var gc=t=>G(t)?.parts.find(e=>e.screen),pc=.06;function _c(t){let e=G(t);if(!e)return!1;let[n,r,o]=e.size;return e.parts.filter(i=>i.screen).some(i=>{let[s,l]=[i.w*n,i.d*r,i.h*o].sort((a,c)=>c-a);return l>=pc&&s>=pc})}function ct(t){return et[t]??G(t)?.size??[.6,.6,.8]}function Rt(t){let e=G(t);return Sc.has(t)||!!e?.electric||!!e?.light||!!e?.climate}var bc=t=>!!G(t)?.parts.some(e=>e.picture),wn=t=>!!G(t)?.climate;function yc(t,e){return t.name[e.split("-")[0]]??t.name.en??Object.values(t.name)[0]??t.id}var k_={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 vc(t,e){if(e.split("-")[0]==="de")return t.name;let n=/^nextfloor\.(.+)$/.exec(t.id)?.[1];return n&&k_[n]||t.name}function Et(t,e){return e.mount_y!=null?e.mount_y:$_(t,e)+(x_(e)?0:xc(t,e.x,e.z))}var x_=t=>t.type==="led_strip"||G(t.type)?.mount==="ceiling";function $_(t,e){if(e.type==="lamp_wall")return wc;if(e.type==="led_strip")return Math.max(0,dt(t,e.x,e.z)-.04-Math.max(.02,e.h));let n=G(e.type);if(!n)return kc(e);switch(n.mount){case"surface":return $c(t,e.x,e.z);case"wall":return n.wall_y??1;case"ceiling":return Math.max(0,Ao(t,e)-e.h);default:return 0}}function ps(t){if(t==="plant")return"plant";let e=G(t);return e?e.household?e.household:/monstera|plant|herb_garden|flower_pots|bonsai|ficus|cactus|kaktus/.test(e.id)?"plant":null:null}var Mc=["turn","slide","top"],Rc=["always","active","no_power","never"],Ec=1.3,Fo=(t,e=new Date().toISOString().slice(0,10))=>!!t.due&&t.due<=e,Ac=["gable","hip","halfhip","pyramid","mansard","pent","flat","parapet"],Fc=["brick","round","wide","steel"],To=["navigate","more_info","service","fire_dom_event"];function zo(t,e,n){return t?e?!!n.lock_plan:!!t.locked:!1}var Tc=["rain","snow","fog","clouds","lightning","sky"],zc=["rain","snow","clouds","lightning","sky"],Pc=["lawn","terrace","path","driveway","pool","bed","wild","hedge","fence","pergola"],fs={lawn:.012,terrace:.12,path:.02,driveway:.02,pool:-.25,bed:.15,wild:.03,hedge:1.2,fence:1,pergola:2.2};function ms(t){return t==="hedge"||t==="fence"||t==="pergola"}var Ic=["x","-x","z","-z"];function S_(t,e,n){let r=t.slope??0;if(!r||t.type==="pool")return 0;let o=t.slope_dir??"x",i=(c,d)=>o==="x"?c:o==="-x"?-c:o==="z"?d:-d,s=1/0,l=-1/0;for(let[c,d]of t.points){let u=i(c,d);s=Math.min(s,u),l=Math.max(l,u)}if(l-s<1e-6)return 0;let a=Math.min(1,Math.max(0,(i(e,n)-s)/(l-s)));return r*a}function M_(t,e,n,r){return Dc(t)+(e.offset??0)+fs[e.type]-S_(e,n,r)}function Dc(t){return t.elevation>.3?0:-.2}function Oc(t,e,n){let r=(t.outdoor??[]).filter(i=>!ms(i.type)&&i.type!=="pool"&&N([e,n],i.points)),o=[...r].reverse().find(i=>i.cut)??r[0];return o?M_(t,o,e,n):Dc(t)}var Hc=t=>t.cut??t.type==="pool",Lc=30,Cc={meter:null,grid:null,grid_invert:!1,solar:null,battery:null,battery_invert:!1,battery_soc:null,consumption:null,tariff:null},Nc=["wood","oak","tiles","carpet","stone","concrete"],Bc={type:"none",pitch:35,overhang:.4},Po="#d6cfc2",Io="#e8e3da",Vc={wall_exterior:.24,wall_interior:.12,grid:.05,north:0,roof:{...Bc}};function At(){return{version:1,floors:[],settings:{...Vc},energy:{...Cc},presence:[]}}function Le(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 R_=2.75;function Wc(t,e){if(e!=null&&Number.isFinite(e))return Math.round(e*R_*100)/100;let n=t.reduce((r,o)=>!r||o.elevation>r.elevation?o:r,null);return n?Math.round((n.elevation+n.height+.25)*100)/100:0}function Kc(t,e,n){let r=t.rooms.flatMap(l=>l.points.map(a=>a[0])),o=t.rooms.flatMap(l=>l.points.map(a=>a[1])),i=r.length?Math.ceil(Math.max(...r))+1:0,s=o.length?Math.floor(Math.min(...o)):0;return e.map((l,a)=>{let c=i+a%3*4.5,d=s+Math.floor(a/3)*3.5;return{id:n(),name:l.name,area_id:l.area_id,points:[[c,d],[c+4,d],[c+4,d+3],[c,d+3]],floor_material:"wood"}})}function Gc(t,e,n,r){let o=t.rotation*Math.PI/180,i=Math.cos(o),s=Math.sin(o),[l,a]=e,c=t.x-l*(t.w/2)*i+a*(t.d/2)*s,d=t.z-l*(t.w/2)*s-a*(t.d/2)*i,u=n[0]-c,p=n[1]-d,h=b=>Math.max(.1,Math.round(b/r)*r),f=h((u*i+p*s)*l),g=h((-u*s+p*i)*a),y=b=>Math.round(b*1e3)/1e3;return{x:y(c+l*(f/2)*i-a*(g/2)*s),z:y(d+l*(f/2)*s+a*(g/2)*i),w:y(f),d:y(g)}}var Do=["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"],jc={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"]},Ce=["meter","inverter","home_battery","wallbox","grid_point"],Uc=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"]),wc=1.75;function Oo(t){return gs.has(t.type)||["stairwell","parking"].includes(t.type)?!1:G(t.type)?.mount!=="ceiling"}function ce(t){return Uc.has(t)||!!G(t)?.light}var E_=new Set(["table","table_round","coffee_table","desk","nightstand","sideboard","dresser","kitchen","island","worktop","tv_board","dishwasher","washer","dryer"]);function Zc(t,e,n,r=0){let o=de(t.points),i=o.x1-o.x0-2*r,s=o.z1-o.z0-2*r,l=[];for(let a=0;aMath.round(s*1e3)/1e3,[o,i]={right:[1,0],down:[0,1],left:[-1,0],up:[0,-1]}[n];return[r(t[0]+o*e),r(t[1]+i*e)]}function kc(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 gs=new Set(["lamp_ceiling","lamp_downlight","lamp_spot","lamp_panel","lamp_pendant","ceiling_fan"]);function qc(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 _s=t=>t?.floor_offset&&Number.isFinite(t.floor_offset)?t.floor_offset:0;function xc(t,e,n){let r=t.rooms.find(o=>o.points.length>=3&&o.floor_offset&&N([e,n],o.points));return _s(r)}function dt(t,e,n){let r=t.rooms.find(o=>o.points.length>=3&&N([e,n],o.points));return r?.ceiling!=null&&r.ceiling>0?r.ceiling:t.height}var Ao=(t,e)=>e.ceiling_y!=null&&e.ceiling_y>0?e.ceiling_y:dt(t,e.x,e.z);function $c(t,e,n){let r=0;for(let o of t.furniture)!(E_.has(o.type)||G(o.type)?.surface)||!N([e,n],ws(o))||(r=Math.max(r,o.h));return r}var Sc=new Set([...Uc,"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"]),et={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 bs=["interior","front","front_glass","sidelight","sidelights","glass","sliding","passage"],ys=["standard","bars","glass_wall"],Ho=new Set(["interior","front"]);function Xt(t,e){return t.type==="door"?t.style&&bs.includes(t.style)?t.style:e?"front":"interior":t.style&&ys.includes(t.style)?t.style:"standard"}function Yc(t,e,n,r){if(e!=="sidelight"&&e!=="sidelights")return null;let o=e==="sidelights",i=t-.04,s=Math.min(1.05,Math.max(.6,i-(o?.6:.3))),l=(i-s)/(o?2:1),a=r.sidelight_width??l,c=o?r.sidelight_width2??r.sidelight_width??l:0;a=Math.max(.1,a),c=o?Math.max(.1,c):0;let d=i-.5;if(a+c>d){let p=Math.max(0,d)/(a+c);a*=p,c*=p}return o?{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 vs(t){return t==="front"||t==="front_glass"||t==="sidelight"||t==="sidelights"}var xn={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 $n(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&&vs(t.style)?"front":e?"door_double":"door":t.sill<.1?e?"terrace_double":"terrace":e?"window_double":"window"}function ze(t){t.energy={...Cc,...t.energy??{}},t.presence=t.presence??[],t.version=1,t.settings={...Vc,...t.settings,roof:{...Bc,...t.settings?.roof??{}}},t.floors.forEach((e,n)=>{let r=Le(e.id,e.name??`Floor ${n+1}`,e.elevation??n*2.8);for(let o of Object.keys(r))e[o]===void 0&&(e[o]=r[o])});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 o of n){let i=r[o.mount??"ceiling"],[s,l,a]=et[i],c=`lamp_${o.entity_id.slice(6).replace(/[^A-Za-z0-9_\-.]/g,"_")}`.slice(0,54),d=c,u=1;for(;e.furniture.some(p=>p.id===d);)d=`${c}_${u++}`;e.furniture.push({id:d,type:i,x:o.x,z:o.z,rotation:0,w:s,d:l,h:a,variant:null,entity:o.entity_id,power:null,animations_enabled:o.animations_enabled,effect_animations:structuredClone(o.effect_animations)})}e.placements=e.placements.filter(o=>!o.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 A_(t),t}function A_(t){let e=(n,r)=>{let o=new Set;for(let i of n)(typeof i.id!="string"||!i.id||o.has(i.id))&&(i.id=I(r)),o.add(i.id)};e(t.floors,"floor");for(let n of t.floors){for(let r of n.rooms)(typeof r.id!="string"||!r.id)&&(r.id=I("room"));e(n.openings,"op"),e(n.furniture,"furn"),e(n.outdoor,"out")}}function I(t){return`${t}_${Math.random().toString(36).slice(2,10)}`}function ge(t){let e=0;for(let n=0;ni+s[0],0)/o,t.reduce((i,s)=>i+s[1],0)/o]}let n=0,r=0;for(let o=0;o1e-6&&Math.abs(r-i)>1e-6)return!1}return!0}function de(t){let e=1/0,n=1/0,r=-1/0,o=-1/0;for(let[i,s]of t)e=Math.min(e,i),n=Math.min(n,s),r=Math.max(r,i),o=Math.max(o,s);return{x0:e,z0:n,x1:r,z1:o}}function ws(t){let e=t.rotation*Math.PI/180,n=Math.cos(e),r=Math.sin(e),o=t.w/2,i=t.d/2;return[[-o,-i],[o,-i],[o,i],[-o,i]].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,o=e.length-1;rt[1]!=a>t[1]&&t[0]<(l-i)*(t[1]-s)/(a-s)+i&&(n=!n)}return n}var Lo={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 ks=t=>t.trim().replace(/^\/local\/www\//i,"/local/"),xs=t=>/^(https:\/\/|\/local\/|\/hacsfiles\/)\S+\.m?js(\?\S*)?$/i.test(t.trim());var T_=globalThis,Qc=T_.__nextfloorPluginStore??={plugins:new Map,listeners:new Set},$s=Qc.plugins,Xc=Qc.listeners;var z_=5;function Jc(t,e){t.errors.lengthXc.delete(t)}var Ss=()=>[...$s.values()].map(t=>t.status),ed=()=>[...$s.values()].flatMap(t=>Object.keys(t.plugin.lightAnimations??{}));function*No(t,e){for(let{plugin:n,status:r}of $s.values())for(let o of n.devices??[]){let i=!1;try{i=o.match(t,e)}catch(s){Jc(r,s)}i&&(yield{device:o,status:r})}}function Bo(t,e){for(let{device:n}of No(t,e))return n.kind??"sensor";return null}function td(t,e){let n=t.states[e];if(!n)return null;let r=P_({hass:t,entityId:e,state:n})?.icon?.trim();return r&&/^mdi:[a-z0-9-]+$/i.test(r)?r:null}function P_(t){let e=null;for(let{device:n,status:r}of No(t.entityId,t.state))if(n.marker)try{let o=n.marker(t);if(!o)continue;e={...e??{}},typeof o.icon=="string"&&o.icon&&(e.icon=o.icon),typeof o.text=="string"&&(e.text=o.text.slice(0,60)),typeof o.active=="boolean"&&(e.active=o.active)}catch(o){Jc(r,o)}return e}function Vo(t,e){return t?typeof t=="string"?t:t[e]??t[e.split("-")[0]]??t.en??Object.values(t)[0]??"":""}function nd(t,e){let n=[];for(let{device:r,status:o}of No(t,e))r.settings?.length&&n.push({pluginId:o.id,name:o.name,settings:r.settings});return n}function rd(t,e){let n={};for(let r of t??[]){let o=e?.[r.key],i=r.type==="number"?typeof o=="number"&&Number.isFinite(o):r.type==="boolean"?typeof o=="boolean":typeof o=="string"&&(r.options??[]).some(([s])=>s===o);n[r.key]=i?o:r.default}return n}function od(t,e){for(let{device:n}of No(t,e))if(n.floorWedge)return!0;return!1}var I_=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"]),D_=new Set(["m\xB3","m3","L","l","kWh","Wh","MWh","lx"]),O_=new Set(["door","window","opening","garage_door","motion","occupancy","presence","smoke","moisture","gas","carbon_monoxide"]),H_=new Set(["battery","signal_strength","timestamp","date","duration","data_rate","data_size","frequency","enum"]);function Ft(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 sd=(t,e)=>{let n=t.entities?.[e];return!!(n?.hidden||n?.entity_category)},Ne=(t,e)=>X(e)??Bo(e,t.states[e]);function id(t,e){let n=t.states[e];if(!n||sd(t,e))return!1;if(Bo(e,n)!==null)return!0;let r=X(e);if(!r)return!1;let o=n.attributes.device_class;return e.startsWith("event.")?!o||o==="button"||o==="doorbell":r==="sensor"?o?I_.has(o):D_.has(String(n.attributes.unit_of_measurement??"")):r==="binary"?o?O_.has(o):!!t.entities?.[e]?.area_id:!0}function L_(t,e){let n=t.states[e];return X(e)!=="sensor"||!n?.attributes.unit_of_measurement||sd(t,e)||H_.has(String(n.attributes.device_class??""))?!1:Number.isFinite(Number(n.state))||Je(n)}var Ko=(t,e)=>e.startsWith("sensor.")&&t.states[e]?.attributes.device_class==="power",Ms=null;Co(()=>Ms=null);function Rs(t,e){let n=t.get(e);return n||t.set(e,n=[]),n}function C_(t){let e=new Map,n=new Map,r=new Map,o=new Map,i=[],s=d=>{(id(t,d)||L_(t,d))&&Mt(Ne(t,d))&&i.push(d)};for(let[d,u]of Object.entries(t.entities??{})){let p=u.device_id;p&&u.area_id&&(o.get(p)??o.set(p,new Set).get(p)).add(u.area_id),p&&Ko(t,d)&&Rs(n,p).push(d),p&&!u.hidden&&!u.entity_category&&(r.get(p)??r.set(p,new Set).get(p)).add(cs(d));let h=Ft(t,d);h===null?s(d):id(t,d)&&Rs(e,h).push(d)}if(t.entities)for(let d of Object.keys(t.states))t.entities[d]||s(d);let l=ds.indexOf("binary")-.5,a=d=>{let u=X(d),p=u?ds.indexOf(u):l;return p>l&&Bo(d,t.states[d])!==null?l:p};i.sort((d,u)=>a(d)-a(u)||V(t,d).localeCompare(V(t,u)));for(let[d,u]of e){let p=t.areas?.[d]?.name;u.sort((h,f)=>a(h)-a(f)||V(t,h,p).localeCompare(V(t,f,p)))}let c=new Set;for(let[d,u]of o)u.size>1&&c.add(d);return{entities:t.entities,devices:t.devices,states:t.states,stateCount:Object.keys(t.states).length,byArea:e,powerByDevice:n,withoutArea:i,domainsByDevice:r,hubs:c}}function Mn(t){let e=Ms;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:Ms=C_(t)}function be(t,e){let n=Wo(t,e.area_id);return e.sub_areas?.length?[...new Set([...n,...e.sub_areas.flatMap(r=>Wo(t,r))])]:n}function Wo(t,e){return!e||!t.entities?[]:Mn(t).byArea.get(e)??[]}function ad(t,e){if(!t.entities)return[];let n=[];for(let[r,o]of Mn(t).byArea){let i=o.filter(s=>Mt(Ne(t,s)));r!==e&&i.length>0&&n.push({areaId:r,name:t.areas?.[r]?.name??r,ids:i})}return n.sort((r,o)=>r.name.localeCompare(o.name))}var ld=t=>t.entities?Mn(t).withoutArea:[],Es=(t,e)=>!!t.entities&&Mn(t).hubs.has(e),Go=(t,e)=>t.entities?Mn(t).powerByDevice.get(e)??[]:[];function Rn(t,e){let n=new Map;for(let o of e)Rs(n,t.entities?.[o]?.device_id??`entity:${o}`).push(o);let r=new Map(e.map((o,i)=>[o,i]));return[...n.values()].map(o=>{let i=o.find(s=>!t.entities?.[s]?.name)??o[0];return{primary:i,others:o.filter(s=>s!==i)}}).sort((o,i)=>r.get(o.primary)-r.get(i.primary))}var jo=(t,e)=>Rn(t,e).map(n=>n.primary),N_={temperature:"temperature",humidity:"humidity",co2:"carbon_dioxide",illuminance:"illuminance"};function As(t,e,n,r=!1){let o=t.states[e]?.attributes;if(!o)return!1;let i=(o.symcon_variable_type===1||o.symcon_variable_type===2)&&typeof o.symcon_id=="number";if(typeof o.symcon_id=="number"&&!i||!i&&!/^(sensor|input_number|number)\./.test(e))return!1;if(r&&i)return!0;let s=String(o.unit_of_measurement??"").replace(/\s/g,"").toLowerCase();return n==="temperature"&&["\xB0c","\xB0f","\u2103","\u2109","k"].includes(s)||n==="humidity"&&!o.device_class&&["%","%rh","%r.h.","%rf","%r.f."].includes(s)||n==="co2"&&s==="ppm"&&/co[₂2]/i.test(String(o.friendly_name??""))||n==="illuminance"&&["lx","lux"].includes(s)?!0:o.device_class===N_[n]}var B_=new Set(["climate","water_heater","switch","button","camera","media_player","vacuum","light","fan","lawn_mower"]),V_=["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"],W_=new RegExp(`(${V_.join("|")})`,"i");function Fs(t,e){let n=t.entities?.[e]?.device_id,r=n&&!Es(t,n)?Mn(t).domainsByDevice.get(n):void 0;return r&&[...r].some(o=>B_.has(o))?!1:!W_.test(`${e} ${t.states[e]?.attributes.friendly_name??""}`)}function cd(t,e,n,r){let o=n.climate?.[r];if(o==="none")return[];if(o)return[o].flat().filter(c=>t.states[c]);let i=(e?.placements??[]).filter(c=>c.entity_id.startsWith("sensor.")),s=i.filter(c=>N([c.x,c.z],n.points)).map(c=>c.entity_id),l=new Set(i.filter(c=>!N([c.x,c.z],n.points)).map(c=>c.entity_id));return[...new Set([...be(t,n).filter(c=>!l.has(c)),...s])].filter(c=>c.startsWith("sensor.")&&As(t,c,r)&&Fs(t,c))}function dd(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 Uo(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 Zo(t,e){let n=e?t.states[e]:void 0;if(!n||Je(n))return null;let r=n.attributes;if(r.nf_cover_control&&typeof r.current_position=="number")return r.current_position;let o=dd(n);if(o!==null)return o;if(typeof r.current_position=="number")return Math.max(0,Math.min(100,r.current_position));if(!n.state.trim())return null;let i=Number(n.state);if(!Number.isFinite(i))return null;let s=r.unit_of_measurement==="%"||i>1||i<0?i:i*100;return Math.max(0,Math.min(100,s))}var K_=new Set([void 0,"shutter","blind","awning","shade","curtain","window"]),G_=new Set(["garage","gate"]),j_=new Set(["window","opening"]);function _r(t,e,n=!1){let r=new Map;return t.forEach((o,i)=>{let s=n&&e.length===1?e[0]:e[i];s&&r.set(o.id,s)}),r}var ud=(t,e)=>t==="none"?null:t??e??null,Tt=t=>t&&t!=="none"?t:null;function zt(t,e){let n=new Map;for(let r of e)for(let o of r.rooms){let i=r.openings.filter(g=>g.room_id===o.id).sort((g,y)=>g.edge-y.edge||g.offset-y.offset);if(i.length===0)continue;let s=be(t,o),l=g=>t.states[g]?.attributes.device_class,a=g=>s.filter(y=>X(y)==="binary"&&g(l(y)??"")),c=g=>i.filter(y=>y.type===g),d=_r(c("window"),s.filter(g=>X(g)==="cover"&&K_.has(l(g))),!0),u=_r(c("window"),a(g=>j_.has(g))),p=_r(c("door"),a(g=>g==="door")),h=_r(c("garage"),s.filter(g=>X(g)==="cover"&&G_.has(l(g)??""))),f=_r(c("garage"),a(g=>g==="garage_door"));for(let g of i){let y=g.type==="window"?d:g.type==="garage"?h:null,b=g.type==="window"?u:g.type==="garage"?f:p,w=g.leaves===2;n.set(g.id,{cover:ud(g.cover,y?.get(g.id)),contact:g.sensor==="handle"&&g.contact==null?null:ud(g.contact,b.get(g.id)),tilt:g.tilt==="none"?null:g.tilt,contact2:w?Tt(g.contact2):null,tilt2:w?Tt(g.tilt2):null,position:Tt(g.position),positionInverted:!!g.position_inverted,tiltAngle:Tt(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"?Tt(g.lock):null,cover2:g.type==="garage"?null:Tt(g.cover2),coverTilt:Tt(g.cover_tilt),cover2Tilt:Tt(g.cover2_tilt),coverInverted:!!g.cover_inverted,coverTiltInverted:!!g.cover_tilt_inverted,cover2Inverted:!!g.cover2_inverted,cover2TiltInverted:!!g.cover2_tilt_inverted})}}return n}var U_=[[/^(tilted|tilt|gekippt|kipp)/i,"tilted"],[/^(open|opened|offen|geöffnet|on)$/i,"open"],[/^(closed|close|geschlossen|zu|off)$/i,"closed"]];function Ts(t){if(!t||Je(t))return null;let e=t.attributes.window_state;for(let n of[typeof e=="string"?e:"",t.state]){let r=n.trim(),o=r&&U_.find(([i])=>i.test(r));if(o)return o[1]}return null}var hd=new WeakMap,pd=new WeakMap,Z_={open_cover:"close_cover",close_cover:"open_cover",open_cover_tilt:"close_cover_tilt",close_cover_tilt:"open_cover_tilt"};function fd(t,e){let n=pd.get(t)??t,r=hd.get(n)??new WeakMap;hd.set(n,r);let o=r.get(e);if(o)return o;let i=new Map;for(let a of e)for(let c of a.placements)c.entity_id.startsWith("cover.")&&i.set(c.entity_id,{inverted:c.cover_inverted,tiltInverted:c.cover_tilt_inverted,tilt:c.cover_tilt==="none"?null:c.cover_tilt,position:c.position,positionInverted:c.position_inverted});for(let a of zt(n,e).values())a.cover&&!i.has(a.cover)&&i.set(a.cover,{inverted:a.coverInverted,tiltInverted:a.coverTiltInverted,tilt:a.coverTilt,position:a.position,positionInverted:a.positionInverted}),a.cover2&&!i.has(a.cover2)&&i.set(a.cover2,{inverted:a.cover2Inverted,tiltInverted:a.cover2TiltInverted,tilt:a.cover2Tilt});let s={...n.states};for(let[a,c]of i){let d=n.states[a];if(!d)continue;let u={...d.attributes,nf_cover_control:!0},p=Zo(n,c.position);p!==null&&c.positionInverted&&(p=100-p),p===null&&(p=typeof d.attributes.current_position=="number"?d.attributes.current_position:null),p!==null&&(u.current_position=c.inverted?100-p:p);let h=c.tilt?n.states[c.tilt]:d,f=typeof h?.attributes.current_tilt_position=="number"?h.attributes.current_tilt_position:c.tilt?Zo(n,c.tilt):null;f!==null&&(c.tiltInverted&&(f=100-f),u.current_tilt_position=f,u.supported_features=Number(u.supported_features??0)|128);let g=d.state;c.inverted&&(g={open:"closed",closed:"open",opening:"closing",closing:"opening"}[g]??g),typeof u.current_position=="number"&&g!=="unavailable"&&g!=="unknown"&&g!=="opening"&&g!=="closing"&&(g=u.current_position>0?"open":"closed"),s[a]={...d,state:g,attributes:u}}let l={...n,states:s,callService:async(a,c,d={})=>{if(a!=="cover")return n.callService(a,c,d);let u=Array.isArray(d.entity_id)?d.entity_id:[d.entity_id],p=async h=>{let f=typeof h=="string"?i.get(h):void 0;if(!f)return n.callService(a,c,{...d,entity_id:h});let g={...d,entity_id:h},y=c;(y==="toggle"||y==="toggle_cover")&&(y=s[String(h)]?.state==="closed"?"open_cover":"close_cover");let b=y.includes("tilt");if(b&&f.tilt&&(g.entity_id=f.tilt),b?f.tiltInverted:f.inverted){y=Z_[y]??y;let v=b?"tilt_position":"position";typeof g[v]=="number"&&(g[v]=100-g[v])}let w=f.tilt?n.states[f.tilt]:void 0;return b&&f.tilt&&!w?.attributes.symcon_id&&typeof w?.attributes.current_tilt_position!="number"&&(y==="set_cover_tilt_position"?(y="set_cover_position",g.position=g.tilt_position,delete g.tilt_position):y==="open_cover_tilt"?y="open_cover":y==="close_cover_tilt"&&(y="close_cover")),n.callService(a,y,g)};return Array.isArray(d.entity_id)?Promise.all(u.map(p)):p(u[0])}};return pd.set(l,n),r.set(e,l),l}var En={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},Qt=t=>(...e)=>({_$litDirective$:t,values:e}),Pt=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 br=class extends Pt{constructor(e){if(super(e),this.it=_,e.type!==En.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===Qe)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:[]}}};br.directiveName="unsafeHTML",br.resultType=1;var md=Qt(br);var gd=/\b(tv|fernseh|television|fire ?tv|apple ?tv|chromecast|shield)/i,_d=/(kühl|fridge|gefrier|freezer)/i,bd=/(spülmaschine|geschirrspül|dishwasher)/i,q_=/(kochfeld|herd|induktion|cooktop)/i,Y_={robot_vacuum:/(saug|vacuum|robo|roomba|roborock|dreame|ecovacs|deebot)/i,tv_board:gd,tv_wall:gd,desk:/\b(pc|computer|rechner|desktop|monitor|workstation)/i,fridge:_d,fridge_smart:_d,stove:/(herd|kochfeld|cooktop|stove|induktion)/i,kitchen_tall:/(backofen|oven|ofen)/i,dishwasher:bd,washer:/(waschmaschine|washer|washing)/i,dryer:/(trockner|dryer)/i,kitchen:/(kaffee|coffee|wasserkocher|kettle)/i,island:q_,sink:bd,radiator:/(heiz|radiator|thermostat|climate|hk|trv)/i},yd={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},vd=new Set(["tv_board","tv_wall"]);var An=t=>vd.has(t)||!!gc(t),qo=t=>!!G(t)?.electric&&/speaker|multiroom|soundbar/.test(t.split(":").pop()??t),vr=t=>An(t)||t==="desk"||t==="fridge_smart",X_=t=>!!t&&t!=="none";function Q_(t,e){if(Ko(t,e))return e;let n=t.entities?.[e]?.device_id;return n?Go(t,n).find(r=>r!==e)??null:null}var J_=(t,e,n)=>t.rooms.find(r=>r.points.length>=3&&N([e,n],r.points));function yr(t,e,n,r){return t.find(o=>e?.test(n(o)))??(r?t[0]??null:null)}function Be(t,e){let n=new Map;for(let r of e){let o=new Set([...r.furniture.flatMap(i=>[i.entity,i.power,i.fan_entity]),...r.placements.map(i=>i.entity_id)].filter(X_));for(let i of r.furniture){let s=i.type in yd,l=wn(i.type),a=s?yd[i.type]:Y_[i.type];if(!a&&!l&&!qo(i.type)&&i.entity==null&&i.power==null)continue;let c=J_(r,i.x,i.z),d=(c?jo(t,be(t,c)):[]).filter(y=>!o.has(y)),u=y=>`${y} ${V(t,y)}`,p=y=>d.filter(b=>X(b)===y),h=i.entity==="none"?null:i.entity??null;if(i.entity==null){if(i.type==="ceiling_fan"){let y=(c?be(t,c):[]).filter(w=>!o.has(w)),b=new Set(y.filter(w=>X(w)==="fan").map(w=>t.entities?.[w]?.device_id).filter(Boolean));h=y.find(w=>X(w)==="light"&&b.has(t.entities?.[w]?.device_id))??yr(p("light"),a,u,!1)}else if(s)h=yr(p("light"),a,u,!0);else if(i.type==="robot_vacuum"){let y=c?.area_id??null;h=Object.keys(t.entities??{}).find(b=>b.startsWith("vacuum.")&&!o.has(b)&&Ft(t,b)===y)??null}else if(i.type==="radiator"||l)h=yr(p("climate"),a,u,!0);else if(An(i.type)){let y=p("media");h=y.find(b=>t.states[b]?.attributes.device_class==="tv")??yr(y,a,u,vd.has(i.type))}else if(qo(i.type)){let y=p("media").filter(b=>t.states[b]?.attributes.device_class!=="tv");h=yr(y,a,u,!1)??(y.length===1?y[0]:null)}else a&&(h=d.find(y=>["switch","media","fan"].includes(X(y)??"")&&a.test(u(y)))??null);h&&o.add(h)}let f=i.power==="none"?null:i.power??null;i.power==null&&(f=h?Q_(t,h):null,!f&&a&&c&&!s&&(f=be(t,c).find(y=>Ko(t,y)&&!o.has(y)&&a.test(u(y)))??null),f&&o.add(f));let g=null;if(i.type==="ceiling_fan"&&(g=i.fan_entity==="none"?null:i.fan_entity??null,i.fan_entity==null)){let y=(c?be(t,c):[]).filter(w=>X(w)==="fan"&&!o.has(w)),b=h?t.entities?.[h]?.device_id:void 0;g=(b?y.find(w=>t.entities?.[w]?.device_id===b):void 0)??y[0]??null,g&&o.add(g)}(h||f||g)&&n.set(i.id,{entity:h,power:f,...i.type==="ceiling_fan"?{fan:g}:{}})}}return n}var wd=t=>t==="fridge"||t==="fridge_smart"||/(fridge|freezer|kuehl|gefrier|chest_freezer)/.test(t.slice(t.lastIndexOf(":")+1));function kd(t,e,n=[]){let r=[];for(let o of e){let i=(l,a)=>o.rooms.some(c=>c.points.length>=3&&N([l,a],c.points)),s=Be(t,[o]);r.push(...o.placements.filter(l=>l.outside||!i(l.x,l.z)).map(l=>l.entity_id)),r.push(...o.furniture.filter(l=>!i(l.x,l.z)).flatMap(l=>[s.get(l.id)?.entity,s.get(l.id)?.power]));for(let l of o.outdoor??[])l.area_id&&r.push(...jo(t,Wo(t,l.area_id))),r.push(l.pump_entity,l.temp_entity)}return[...new Set(r.filter(o=>!!o&&!!t.states[o]&&!n.includes(o)))]}function eb(t,e){return Math.min(...e.map((n,r)=>{let o=e[(r+1)%e.length],[i,s]=[o[0]-n[0],o[1]-n[1]],l=Math.min(1,Math.max(0,((t[0]-n[0])*i+(t[1]-n[1])*s)/(i*i+s*s||1)));return Math.hypot(t[0]-n[0]-i*l,t[1]-n[1]-s*l)}))}function $d(t,e,n=[]){let r=t.points;if(r.length<3||e.length===0)return[];let o=r.map(b=>b[0]),i=r.map(b=>b[1]),[s,l,a,c]=[Math.min(...o),Math.max(...o),Math.min(...i),Math.max(...i)],d=Math.min(l-s,c-a),u=Math.max(.1,Math.min(.25,d/8)),p=Math.min(.35,d/5),h=Math.min(.7,d/4),f=_e(r),g=[];for(let b=s+u/2;b=p&&g.push({at:v,wallDistance:x})}g.length===0&&g.push({at:f,wallDistance:0});let y=[...n];return e.map(b=>{let w=X(b)==="light",v=g[0].at,x=-1/0;for(let{at:S,wallDistance:A}of g){let F=y.length?Math.min(...y.map(P=>Math.hypot(S[0]-P[0],S[1]-P[1]))):3,T=Math.hypot(S[0]-f[0],S[1]-f[1]),D=Math.min(F,3)*2;Tx+1e-9&&(x=D,v=S)}let k=[Math.round(v[0]*100)/100,Math.round(v[1]*100)/100];return y.push(k),{entity_id:b,x:k[0],z:k[1],y:null,mount:null}})}var xd=/(^|_)(current_room|current_segment|aktueller_raum|current_area)($|_)/;function Sd(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(i=>i.device_id===r&&i.entity_id.startsWith("sensor.")&&(xd.test(i.translation_key??"")||xd.test(i.entity_id.split(".")[1])))?.entity_id??null}var ye=re`
+\f\r"'\`<>=]|("|')|))|$)`,"g"),Ql=/'/g,Jl=/"/g,nc=/^(?:script|style|textarea|title)$/i,ss=t=>(e,...n)=>({_$litType$:t,strings:e,values:n}),m=ss(1),R=ss(2),Lk=ss(3),Qe=Symbol.for("lit-noChange"),_=Symbol.for("lit-nothing"),ec=new WeakMap,Ut=Zt.createTreeWalker(Zt,129);function rc(t,e){if(!is(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return ql!==void 0?ql.createHTML(e):e}var oc=(t,e)=>{let n=t.length-1,r=[],o,i=e===2?"":e===3?"":"")),r]},fr=class t{constructor({strings:e,_$litType$:n},r){let o;this.parts=[];let i=0,s=0,l=e.length-1,a=this.parts,[c,d]=oc(e,n);if(this.el=t.createElement(c,r),Ut.currentNode=this.el.content,n===2||n===3){let u=this.el.content.firstChild;u.replaceWith(...u.childNodes)}for(;(o=Ut.nextNode())!==null&&a.length0){o.textContent=wo?wo.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,o){let i=this.strings,s=!1;if(i===void 0)e=qt(this,e,n,0),s=!pr(e)||e!==this._$AH&&e!==Qe,s&&(this._$AH=e);else{let l=e,a,c;for(e=i[0],a=0;a{let r=n?.renderBefore??e,o=r._$litPart$;if(o===void 0){let i=n?.renderBefore??null;r._$litPart$=o=new vn(e.insertBefore(hr(),i),i,void 0,n??{})}return o._$AI(t),o};var as=globalThis,Q=class extends gt{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=sc(n,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return Qe}};Q._$litElement$=!0,Q.finalized=!0,as.litElementHydrateSupport?.({LitElement:Q});var g_=as.litElementPolyfillSupport;g_?.({LitElement:Q});(as.litElementVersions??=[]).push("4.2.2");var cs=t=>t.slice(0,t.indexOf(".")),__={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"},X=t=>__[cs(t)]??null,ds=["light","cover","climate","media","switch","fan","lock","binary","sensor","scene","script"];var ac=new Set(["light","switch","fan"]),Mt=t=>t!==null&&t!=="scene"&&t!=="script",Je=t=>!t||t.state==="unavailable"||t.state==="unknown"&&!t.entity_id.startsWith("event.");function V(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 o=r.slice(n.length+1);return o[0].toUpperCase()+o.slice(1)}var lc=t=>!!t&&t.entity_id.startsWith("sensor.")&&t.attributes.device_class==="enum";var cc=t=>Math.min(1,Math.max(0,t));function b_(t){let e=cc((t-2200)/4300),n=[1,.66,.26],r=[.78,.9,1];return[0,1,2].map(o=>n[o]+(r[o]-n[o])*e)}function ls(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(cc(n.brightness/255)):1,o=n.rgb_color;return o&&!["color_temp","brightness","onoff"].includes(String(n.color_mode))?{color:[o[0]/255,o[1]/255,o[2]/255],level:r}:typeof n.color_temp_kelvin=="number"?{color:b_(n.color_temp_kelvin),level:r}:{color:[1,.71,.28],level:r}}function dc(t,e,n){let r=ls(t,n);if(r)return r;for(let o of e){let i=ls(o);if(i)return{color:i.color,level:i.level*.6}}return null}function Ro(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=[],Eo=new Map,y_=0,ue=(t,e)=>`pack:${t}:${e}`,bt=t=>t.startsWith("pack:");function us(t){fc=t,Eo=new Map;for(let e of t)for(let n of e.items)Eo.set(ue(e.id,n.id),n);y_+=1}var gr=()=>fc;var v_={};function G(t){if(!bt(t))return;let e=Eo.get(t);if(e)return e;let[,n,...r]=t.split(":"),o=v_[n];return o?Eo.get(ue(o,r.join(":"))):void 0}var w_=.22;function uc(t,e,n,r){let o=Math.min(w_,n/3);if(r<=o*2.4||Math.abs(r-n)<1e-6)return e*(r/n)+(t-e)*(r/n);let i=e*(r/n),s=t-e;return s<=o?i+s:s>=n-o?i+r-(n-s):i+o+(s-o)*(r-2*o)/(n-2*o)}function mr(t,e,n,r,o){return[uc(t*r,n*r,r,o)/o,uc(e*r,n*r,r,o)/o]}var hc=new WeakMap;function mc(t,e,n,r){let[o,i,s]=t.size;if(t.vehicle||t.stretch||Math.abs(e-o)<1e-4&&Math.abs(n-i)<1e-4&&Math.abs(r-s)<1e-4)return t.parts;let l=`${e.toFixed(4)}|${n.toFixed(4)}|${r.toFixed(4)}`,a=hc.get(t),c=a?.get(l);if(c)return c;let d=t.parts.map(u=>{if(u.shape==="sweep")return u;let[p,h]=mr(u.x-u.w/2,u.x+u.w/2,-.5,o,e),[f,g]=mr(u.z-u.d/2,u.z+u.d/2,-.5,i,n),[y,b]=mr(u.y,u.y+u.h,0,s,r);if(u.rot)return{...u,x:(p+h)/2,z:(f+g)/2,w:u.w*o/e,d:u.d*i/n,y,h:b-y};let v={...u,x:(p+h)/2,z:(f+g)/2,w:h-p,d:g-f,y,h:b-y};if(u.shape==="loft"){let[w,x,k,S]=[u.tx??u.x,u.tz??u.z,u.tw??u.w,u.td??u.d],[A,F]=mr(w-k/2,w+k/2,-.5,o,e),[T,I]=mr(x-S/2,x+S/2,-.5,i,n);Object.assign(v,{tx:(A+F)/2,tz:(T+I)/2,tw:F-A,td:I-T})}return v});return a||hc.set(t,a=new Map),a.size>32&&a.clear(),a.set(l,d),d}var hs=t=>!!t?.parts.some(e=>e.move);var gc=t=>G(t)?.parts.find(e=>e.screen),pc=.06;function _c(t){let e=G(t);if(!e)return!1;let[n,r,o]=e.size;return e.parts.filter(i=>i.screen).some(i=>{let[s,l]=[i.w*n,i.d*r,i.h*o].sort((a,c)=>c-a);return l>=pc&&s>=pc})}function ct(t){return et[t]??G(t)?.size??[.6,.6,.8]}function Rt(t){let e=G(t);return Sc.has(t)||!!e?.electric||!!e?.light||!!e?.climate}var bc=t=>!!G(t)?.parts.some(e=>e.picture),wn=t=>!!G(t)?.climate;function yc(t,e){return t.name[e.split("-")[0]]??t.name.en??Object.values(t.name)[0]??t.id}var k_={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 vc(t,e){if(e.split("-")[0]==="de")return t.name;let n=/^nextfloor\.(.+)$/.exec(t.id)?.[1];return n&&k_[n]||t.name}function Et(t,e){return e.mount_y!=null?e.mount_y:$_(t,e)+(x_(e)?0:xc(t,e.x,e.z))}var x_=t=>t.type==="led_strip"||G(t.type)?.mount==="ceiling";function $_(t,e){if(e.type==="lamp_wall")return wc;if(e.type==="led_strip")return Math.max(0,dt(t,e.x,e.z)-.04-Math.max(.02,e.h));let n=G(e.type);if(!n)return kc(e);switch(n.mount){case"surface":return $c(t,e.x,e.z);case"wall":return n.wall_y??1;case"ceiling":return Math.max(0,Ao(t,e)-e.h);default:return 0}}function ps(t){if(t==="plant")return"plant";let e=G(t);return e?e.household?e.household:/monstera|plant|herb_garden|flower_pots|bonsai|ficus|cactus|kaktus/.test(e.id)?"plant":null:null}var Mc=["turn","slide","top"],Rc=["always","active","no_power","never"],Ec=1.3,Fo=(t,e=new Date().toISOString().slice(0,10))=>!!t.due&&t.due<=e,Ac=["gable","hip","halfhip","pyramid","mansard","pent","flat","parapet"],Fc=["brick","round","wide","steel"],To=["navigate","more_info","service","fire_dom_event"];function zo(t,e,n){return t?e?!!n.lock_plan:!!t.locked:!1}var Tc=["rain","snow","fog","clouds","lightning","sky"],zc=["rain","snow","clouds","lightning","sky"],Pc=["lawn","terrace","path","driveway","pool","bed","wild","hedge","fence","pergola"],fs={lawn:.012,terrace:.12,path:.02,driveway:.02,pool:-.25,bed:.15,wild:.03,hedge:1.2,fence:1,pergola:2.2};function ms(t){return t==="hedge"||t==="fence"||t==="pergola"}var Dc=["x","-x","z","-z"];function S_(t,e,n){let r=t.slope??0;if(!r||t.type==="pool")return 0;let o=t.slope_dir??"x",i=(c,d)=>o==="x"?c:o==="-x"?-c:o==="z"?d:-d,s=1/0,l=-1/0;for(let[c,d]of t.points){let u=i(c,d);s=Math.min(s,u),l=Math.max(l,u)}if(l-s<1e-6)return 0;let a=Math.min(1,Math.max(0,(i(e,n)-s)/(l-s)));return r*a}function M_(t,e,n,r){return Ic(t)+(e.offset??0)+fs[e.type]-S_(e,n,r)}function Ic(t){return t.elevation>.3?0:-.2}function Oc(t,e,n){let r=(t.outdoor??[]).filter(i=>!ms(i.type)&&i.type!=="pool"&&N([e,n],i.points)),o=[...r].reverse().find(i=>i.cut)??r[0];return o?M_(t,o,e,n):Ic(t)}var Hc=t=>t.cut??t.type==="pool",Lc=30,Cc={meter:null,grid:null,grid_invert:!1,solar:null,battery:null,battery_invert:!1,battery_soc:null,consumption:null,tariff:null},Nc=["wood","oak","tiles","carpet","stone","concrete"],Bc={type:"none",pitch:35,overhang:.4},Po="#d6cfc2",Do="#e8e3da",Vc={wall_exterior:.24,wall_interior:.12,grid:.05,north:0,roof:{...Bc}};function At(){return{version:1,floors:[],settings:{...Vc},energy:{...Cc},presence:[]}}function Le(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 R_=2.75;function Wc(t,e){if(e!=null&&Number.isFinite(e))return Math.round(e*R_*100)/100;let n=t.reduce((r,o)=>!r||o.elevation>r.elevation?o:r,null);return n?Math.round((n.elevation+n.height+.25)*100)/100:0}function Kc(t,e,n){let r=t.rooms.flatMap(l=>l.points.map(a=>a[0])),o=t.rooms.flatMap(l=>l.points.map(a=>a[1])),i=r.length?Math.ceil(Math.max(...r))+1:0,s=o.length?Math.floor(Math.min(...o)):0;return e.map((l,a)=>{let c=i+a%3*4.5,d=s+Math.floor(a/3)*3.5;return{id:n(),name:l.name,area_id:l.area_id,points:[[c,d],[c+4,d],[c+4,d+3],[c,d+3]],floor_material:"wood"}})}function Gc(t,e,n,r){let o=t.rotation*Math.PI/180,i=Math.cos(o),s=Math.sin(o),[l,a]=e,c=t.x-l*(t.w/2)*i+a*(t.d/2)*s,d=t.z-l*(t.w/2)*s-a*(t.d/2)*i,u=n[0]-c,p=n[1]-d,h=b=>Math.max(.1,Math.round(b/r)*r),f=h((u*i+p*s)*l),g=h((-u*s+p*i)*a),y=b=>Math.round(b*1e3)/1e3;return{x:y(c+l*(f/2)*i-a*(g/2)*s),z:y(d+l*(f/2)*s+a*(g/2)*i),w:y(f),d:y(g)}}var Io=["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"],jc={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"]},Ce=["meter","inverter","home_battery","wallbox","grid_point"],Uc=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"]),wc=1.75;function Oo(t){return gs.has(t.type)||["stairwell","parking"].includes(t.type)?!1:G(t.type)?.mount!=="ceiling"}function ce(t){return Uc.has(t)||!!G(t)?.light}var E_=new Set(["table","table_round","coffee_table","desk","nightstand","sideboard","dresser","kitchen","island","worktop","tv_board","dishwasher","washer","dryer"]);function Zc(t,e,n,r=0){let o=de(t.points),i=o.x1-o.x0-2*r,s=o.z1-o.z0-2*r,l=[];for(let a=0;aMath.round(s*1e3)/1e3,[o,i]={right:[1,0],down:[0,1],left:[-1,0],up:[0,-1]}[n];return[r(t[0]+o*e),r(t[1]+i*e)]}function kc(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 gs=new Set(["lamp_ceiling","lamp_downlight","lamp_spot","lamp_panel","lamp_pendant","ceiling_fan"]);function qc(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 _s=t=>t?.floor_offset&&Number.isFinite(t.floor_offset)?t.floor_offset:0;function xc(t,e,n){let r=t.rooms.find(o=>o.points.length>=3&&o.floor_offset&&N([e,n],o.points));return _s(r)}function dt(t,e,n){let r=t.rooms.find(o=>o.points.length>=3&&N([e,n],o.points));return r?.ceiling!=null&&r.ceiling>0?r.ceiling:t.height}var Ao=(t,e)=>e.ceiling_y!=null&&e.ceiling_y>0?e.ceiling_y:dt(t,e.x,e.z);function $c(t,e,n){let r=0;for(let o of t.furniture)!(E_.has(o.type)||G(o.type)?.surface)||!N([e,n],ws(o))||(r=Math.max(r,o.h));return r}var Sc=new Set([...Uc,"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"]),et={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 bs=["interior","front","front_glass","sidelight","sidelights","glass","sliding","passage"],ys=["standard","bars","glass_wall"],Ho=new Set(["interior","front"]);function Xt(t,e){return t.type==="door"?t.style&&bs.includes(t.style)?t.style:e?"front":"interior":t.style&&ys.includes(t.style)?t.style:"standard"}function Yc(t,e,n,r){if(e!=="sidelight"&&e!=="sidelights")return null;let o=e==="sidelights",i=t-.04,s=Math.min(1.05,Math.max(.6,i-(o?.6:.3))),l=(i-s)/(o?2:1),a=r.sidelight_width??l,c=o?r.sidelight_width2??r.sidelight_width??l:0;a=Math.max(.1,a),c=o?Math.max(.1,c):0;let d=i-.5;if(a+c>d){let p=Math.max(0,d)/(a+c);a*=p,c*=p}return o?{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 vs(t){return t==="front"||t==="front_glass"||t==="sidelight"||t==="sidelights"}var xn={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 $n(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&&vs(t.style)?"front":e?"door_double":"door":t.sill<.1?e?"terrace_double":"terrace":e?"window_double":"window"}function ze(t){t.energy={...Cc,...t.energy??{}},t.presence=t.presence??[],t.version=1,t.settings={...Vc,...t.settings,roof:{...Bc,...t.settings?.roof??{}}},t.floors.forEach((e,n)=>{let r=Le(e.id,e.name??`Floor ${n+1}`,e.elevation??n*2.8);for(let o of Object.keys(r))e[o]===void 0&&(e[o]=r[o])});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 o of n){let i=r[o.mount??"ceiling"],[s,l,a]=et[i],c=`lamp_${o.entity_id.slice(6).replace(/[^A-Za-z0-9_\-.]/g,"_")}`.slice(0,54),d=c,u=1;for(;e.furniture.some(p=>p.id===d);)d=`${c}_${u++}`;e.furniture.push({id:d,type:i,x:o.x,z:o.z,rotation:0,w:s,d:l,h:a,variant:null,entity:o.entity_id,power:null,animations_enabled:o.animations_enabled,effect_animations:structuredClone(o.effect_animations)})}e.placements=e.placements.filter(o=>!o.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 A_(t),t}function A_(t){let e=(n,r)=>{let o=new Set;for(let i of n)(typeof i.id!="string"||!i.id||o.has(i.id))&&(i.id=D(r)),o.add(i.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 ge(t){let e=0;for(let n=0;ni+s[0],0)/o,t.reduce((i,s)=>i+s[1],0)/o]}let n=0,r=0;for(let o=0;o1e-6&&Math.abs(r-i)>1e-6)return!1}return!0}function de(t){let e=1/0,n=1/0,r=-1/0,o=-1/0;for(let[i,s]of t)e=Math.min(e,i),n=Math.min(n,s),r=Math.max(r,i),o=Math.max(o,s);return{x0:e,z0:n,x1:r,z1:o}}function ws(t){let e=t.rotation*Math.PI/180,n=Math.cos(e),r=Math.sin(e),o=t.w/2,i=t.d/2;return[[-o,-i],[o,-i],[o,i],[-o,i]].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,o=e.length-1;rt[1]!=a>t[1]&&t[0]<(l-i)*(t[1]-s)/(a-s)+i&&(n=!n)}return n}var Lo={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 ks=t=>t.trim().replace(/^\/local\/www\//i,"/local/"),xs=t=>/^(https:\/\/|\/local\/|\/hacsfiles\/)\S+\.m?js(\?\S*)?$/i.test(t.trim());var T_=globalThis,Qc=T_.__nextfloorPluginStore??={plugins:new Map,listeners:new Set},$s=Qc.plugins,Xc=Qc.listeners;var z_=5;function Jc(t,e){t.errors.lengthXc.delete(t)}var Ss=()=>[...$s.values()].map(t=>t.status),ed=()=>[...$s.values()].flatMap(t=>Object.keys(t.plugin.lightAnimations??{}));function*No(t,e){for(let{plugin:n,status:r}of $s.values())for(let o of n.devices??[]){let i=!1;try{i=o.match(t,e)}catch(s){Jc(r,s)}i&&(yield{device:o,status:r})}}function Bo(t,e){for(let{device:n}of No(t,e))return n.kind??"sensor";return null}function td(t,e){let n=t.states[e];if(!n)return null;let r=P_({hass:t,entityId:e,state:n})?.icon?.trim();return r&&/^mdi:[a-z0-9-]+$/i.test(r)?r:null}function P_(t){let e=null;for(let{device:n,status:r}of No(t.entityId,t.state))if(n.marker)try{let o=n.marker(t);if(!o)continue;e={...e??{}},typeof o.icon=="string"&&o.icon&&(e.icon=o.icon),typeof o.text=="string"&&(e.text=o.text.slice(0,60)),typeof o.active=="boolean"&&(e.active=o.active)}catch(o){Jc(r,o)}return e}function Vo(t,e){return t?typeof t=="string"?t:t[e]??t[e.split("-")[0]]??t.en??Object.values(t)[0]??"":""}function nd(t,e){let n=[];for(let{device:r,status:o}of No(t,e))r.settings?.length&&n.push({pluginId:o.id,name:o.name,settings:r.settings});return n}function rd(t,e){let n={};for(let r of t??[]){let o=e?.[r.key],i=r.type==="number"?typeof o=="number"&&Number.isFinite(o):r.type==="boolean"?typeof o=="boolean":typeof o=="string"&&(r.options??[]).some(([s])=>s===o);n[r.key]=i?o:r.default}return n}function od(t,e){for(let{device:n}of No(t,e))if(n.floorWedge)return!0;return!1}var D_=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"]),I_=new Set(["m\xB3","m3","L","l","kWh","Wh","MWh","lx"]),O_=new Set(["door","window","opening","garage_door","motion","occupancy","presence","smoke","moisture","gas","carbon_monoxide"]),H_=new Set(["battery","signal_strength","timestamp","date","duration","data_rate","data_size","frequency","enum"]);function Ft(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 sd=(t,e)=>{let n=t.entities?.[e];return!!(n?.hidden||n?.entity_category)},Ne=(t,e)=>X(e)??Bo(e,t.states[e]);function id(t,e){let n=t.states[e];if(!n||sd(t,e))return!1;if(Bo(e,n)!==null)return!0;let r=X(e);if(!r)return!1;let o=n.attributes.device_class;return e.startsWith("event.")?!o||o==="button"||o==="doorbell":r==="sensor"?o?D_.has(o):I_.has(String(n.attributes.unit_of_measurement??"")):r==="binary"?o?O_.has(o):!!t.entities?.[e]?.area_id:!0}function L_(t,e){let n=t.states[e];return X(e)!=="sensor"||!n?.attributes.unit_of_measurement||sd(t,e)||H_.has(String(n.attributes.device_class??""))?!1:Number.isFinite(Number(n.state))||Je(n)}var Ko=(t,e)=>e.startsWith("sensor.")&&t.states[e]?.attributes.device_class==="power",Ms=null;Co(()=>Ms=null);function Rs(t,e){let n=t.get(e);return n||t.set(e,n=[]),n}function C_(t){let e=new Map,n=new Map,r=new Map,o=new Map,i=[],s=d=>{(id(t,d)||L_(t,d))&&Mt(Ne(t,d))&&i.push(d)};for(let[d,u]of Object.entries(t.entities??{})){let p=u.device_id;p&&u.area_id&&(o.get(p)??o.set(p,new Set).get(p)).add(u.area_id),p&&Ko(t,d)&&Rs(n,p).push(d),p&&!u.hidden&&!u.entity_category&&(r.get(p)??r.set(p,new Set).get(p)).add(cs(d));let h=Ft(t,d);h===null?s(d):id(t,d)&&Rs(e,h).push(d)}if(t.entities)for(let d of Object.keys(t.states))t.entities[d]||s(d);let l=ds.indexOf("binary")-.5,a=d=>{let u=X(d),p=u?ds.indexOf(u):l;return p>l&&Bo(d,t.states[d])!==null?l:p};i.sort((d,u)=>a(d)-a(u)||V(t,d).localeCompare(V(t,u)));for(let[d,u]of e){let p=t.areas?.[d]?.name;u.sort((h,f)=>a(h)-a(f)||V(t,h,p).localeCompare(V(t,f,p)))}let c=new Set;for(let[d,u]of o)u.size>1&&c.add(d);return{entities:t.entities,devices:t.devices,states:t.states,stateCount:Object.keys(t.states).length,byArea:e,powerByDevice:n,withoutArea:i,domainsByDevice:r,hubs:c}}function Mn(t){let e=Ms;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:Ms=C_(t)}function be(t,e){let n=Wo(t,e.area_id);return e.sub_areas?.length?[...new Set([...n,...e.sub_areas.flatMap(r=>Wo(t,r))])]:n}function Wo(t,e){return!e||!t.entities?[]:Mn(t).byArea.get(e)??[]}function ad(t,e){if(!t.entities)return[];let n=[];for(let[r,o]of Mn(t).byArea){let i=o.filter(s=>Mt(Ne(t,s)));r!==e&&i.length>0&&n.push({areaId:r,name:t.areas?.[r]?.name??r,ids:i})}return n.sort((r,o)=>r.name.localeCompare(o.name))}var ld=t=>t.entities?Mn(t).withoutArea:[],Es=(t,e)=>!!t.entities&&Mn(t).hubs.has(e),Go=(t,e)=>t.entities?Mn(t).powerByDevice.get(e)??[]:[];function Rn(t,e){let n=new Map;for(let o of e)Rs(n,t.entities?.[o]?.device_id??`entity:${o}`).push(o);let r=new Map(e.map((o,i)=>[o,i]));return[...n.values()].map(o=>{let i=o.find(s=>!t.entities?.[s]?.name)??o[0];return{primary:i,others:o.filter(s=>s!==i)}}).sort((o,i)=>r.get(o.primary)-r.get(i.primary))}var jo=(t,e)=>Rn(t,e).map(n=>n.primary),N_={temperature:"temperature",humidity:"humidity",co2:"carbon_dioxide",illuminance:"illuminance"};function As(t,e,n,r=!1){let o=t.states[e]?.attributes;if(!o)return!1;let i=(o.symcon_variable_type===1||o.symcon_variable_type===2)&&typeof o.symcon_id=="number";if(typeof o.symcon_id=="number"&&!i||!i&&!/^(sensor|input_number|number)\./.test(e))return!1;if(r&&i)return!0;let s=String(o.unit_of_measurement??"").replace(/\s/g,"").toLowerCase();return n==="temperature"&&["\xB0c","\xB0f","\u2103","\u2109","k"].includes(s)||n==="humidity"&&!o.device_class&&["%","%rh","%r.h.","%rf","%r.f."].includes(s)||n==="co2"&&s==="ppm"&&/co[₂2]/i.test(String(o.friendly_name??""))||n==="illuminance"&&["lx","lux"].includes(s)?!0:o.device_class===N_[n]}var B_=new Set(["climate","water_heater","switch","button","camera","media_player","vacuum","light","fan","lawn_mower"]),V_=["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"],W_=new RegExp(`(${V_.join("|")})`,"i");function Fs(t,e){let n=t.entities?.[e]?.device_id,r=n&&!Es(t,n)?Mn(t).domainsByDevice.get(n):void 0;return r&&[...r].some(o=>B_.has(o))?!1:!W_.test(`${e} ${t.states[e]?.attributes.friendly_name??""}`)}function cd(t,e,n,r){let o=n.climate?.[r];if(o==="none")return[];if(o)return[o].flat().filter(c=>t.states[c]);let i=(e?.placements??[]).filter(c=>c.entity_id.startsWith("sensor.")),s=i.filter(c=>N([c.x,c.z],n.points)).map(c=>c.entity_id),l=new Set(i.filter(c=>!N([c.x,c.z],n.points)).map(c=>c.entity_id));return[...new Set([...be(t,n).filter(c=>!l.has(c)),...s])].filter(c=>c.startsWith("sensor.")&&As(t,c,r)&&Fs(t,c))}function dd(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 Uo(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 Zo(t,e){let n=e?t.states[e]:void 0;if(!n||Je(n))return null;let r=n.attributes;if(r.nf_cover_control&&typeof r.current_position=="number")return r.current_position;let o=dd(n);if(o!==null)return o;if(typeof r.current_position=="number")return Math.max(0,Math.min(100,r.current_position));if(!n.state.trim())return null;let i=Number(n.state);if(!Number.isFinite(i))return null;let s=r.unit_of_measurement==="%"||i>1||i<0?i:i*100;return Math.max(0,Math.min(100,s))}var K_=new Set([void 0,"shutter","blind","awning","shade","curtain","window"]),G_=new Set(["garage","gate"]),j_=new Set(["window","opening"]);function _r(t,e,n=!1){let r=new Map;return t.forEach((o,i)=>{let s=n&&e.length===1?e[0]:e[i];s&&r.set(o.id,s)}),r}var ud=(t,e)=>t==="none"?null:t??e??null,Tt=t=>t&&t!=="none"?t:null;function zt(t,e){let n=new Map;for(let r of e)for(let o of r.rooms){let i=r.openings.filter(g=>g.room_id===o.id).sort((g,y)=>g.edge-y.edge||g.offset-y.offset);if(i.length===0)continue;let s=be(t,o),l=g=>t.states[g]?.attributes.device_class,a=g=>s.filter(y=>X(y)==="binary"&&g(l(y)??"")),c=g=>i.filter(y=>y.type===g),d=_r(c("window"),s.filter(g=>X(g)==="cover"&&K_.has(l(g))),!0),u=_r(c("window"),a(g=>j_.has(g))),p=_r(c("door"),a(g=>g==="door")),h=_r(c("garage"),s.filter(g=>X(g)==="cover"&&G_.has(l(g)??""))),f=_r(c("garage"),a(g=>g==="garage_door"));for(let g of i){let y=g.type==="window"?d:g.type==="garage"?h:null,b=g.type==="window"?u:g.type==="garage"?f:p,v=g.leaves===2;n.set(g.id,{cover:ud(g.cover,y?.get(g.id)),contact:g.sensor==="handle"&&g.contact==null?null:ud(g.contact,b.get(g.id)),tilt:g.tilt==="none"?null:g.tilt,contact2:v?Tt(g.contact2):null,tilt2:v?Tt(g.tilt2):null,position:Tt(g.position),positionInverted:!!g.position_inverted,tiltAngle:Tt(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"?Tt(g.lock):null,cover2:g.type==="garage"?null:Tt(g.cover2),coverTilt:Tt(g.cover_tilt),cover2Tilt:Tt(g.cover2_tilt),coverInverted:!!g.cover_inverted,coverTiltInverted:!!g.cover_tilt_inverted,cover2Inverted:!!g.cover2_inverted,cover2TiltInverted:!!g.cover2_tilt_inverted})}}return n}var U_=[[/^(tilted|tilt|gekippt|kipp)/i,"tilted"],[/^(open|opened|offen|geöffnet|on)$/i,"open"],[/^(closed|close|geschlossen|zu|off)$/i,"closed"]];function Ts(t){if(!t||Je(t))return null;let e=t.attributes.window_state;for(let n of[typeof e=="string"?e:"",t.state]){let r=n.trim(),o=r&&U_.find(([i])=>i.test(r));if(o)return o[1]}return null}var hd=new WeakMap,pd=new WeakMap;function fd(t,e){let n=pd.get(t)??t,r=hd.get(n)??new WeakMap;hd.set(n,r);let o=r.get(e);if(o)return o;let i=new Map;for(let a of e)for(let c of a.placements)c.entity_id.startsWith("cover.")&&i.set(c.entity_id,{tilt:c.cover_tilt==="none"?null:c.cover_tilt,position:c.position});for(let a of zt(n,e).values())a.cover&&!i.has(a.cover)&&i.set(a.cover,{tilt:a.coverTilt,position:a.position}),a.cover2&&!i.has(a.cover2)&&i.set(a.cover2,{tilt:a.cover2Tilt});let s={...n.states};for(let[a,c]of i){let d=n.states[a];if(!d)continue;let u={...d.attributes,nf_cover_control:!0},p=Zo(n,c.position);p===null&&(p=typeof d.attributes.current_position=="number"?d.attributes.current_position:null),p!==null&&(u.current_position=p);let h=c.tilt?n.states[c.tilt]:d,f=typeof h?.attributes.current_tilt_position=="number"?h.attributes.current_tilt_position:c.tilt?Zo(n,c.tilt):null;f!==null&&(u.current_tilt_position=f,u.supported_features=Number(u.supported_features??0)|128);let g=d.state;typeof u.current_position=="number"&&g!=="unavailable"&&g!=="unknown"&&g!=="opening"&&g!=="closing"&&(g=u.current_position>0?"open":"closed"),s[a]={...d,state:g,attributes:u}}let l={...n,states:s,callService:async(a,c,d={})=>{if(a!=="cover")return n.callService(a,c,d);let u=Array.isArray(d.entity_id)?d.entity_id:[d.entity_id],p=async h=>{let f=typeof h=="string"?i.get(h):void 0;if(!f)return n.callService(a,c,{...d,entity_id:h});let g={...d,entity_id:h},y=c;(y==="toggle"||y==="toggle_cover")&&(y=s[String(h)]?.state==="closed"?"open_cover":"close_cover");let b=y.includes("tilt");b&&f.tilt&&(g.entity_id=f.tilt);let v=f.tilt?n.states[f.tilt]:void 0;return b&&f.tilt&&!v?.attributes.symcon_id&&typeof v?.attributes.current_tilt_position!="number"&&(y==="set_cover_tilt_position"?(y="set_cover_position",g.position=g.tilt_position,delete g.tilt_position):y==="open_cover_tilt"?y="open_cover":y==="close_cover_tilt"&&(y="close_cover")),n.callService(a,y,g)};return Array.isArray(d.entity_id)?Promise.all(u.map(p)):p(u[0])}};return pd.set(l,n),r.set(e,l),l}var En={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},Qt=t=>(...e)=>({_$litDirective$:t,values:e}),Pt=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 br=class extends Pt{constructor(e){if(super(e),this.it=_,e.type!==En.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===Qe)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:[]}}};br.directiveName="unsafeHTML",br.resultType=1;var md=Qt(br);var gd=/\b(tv|fernseh|television|fire ?tv|apple ?tv|chromecast|shield)/i,_d=/(kühl|fridge|gefrier|freezer)/i,bd=/(spülmaschine|geschirrspül|dishwasher)/i,Z_=/(kochfeld|herd|induktion|cooktop)/i,q_={robot_vacuum:/(saug|vacuum|robo|roomba|roborock|dreame|ecovacs|deebot)/i,tv_board:gd,tv_wall:gd,desk:/\b(pc|computer|rechner|desktop|monitor|workstation)/i,fridge:_d,fridge_smart:_d,stove:/(herd|kochfeld|cooktop|stove|induktion)/i,kitchen_tall:/(backofen|oven|ofen)/i,dishwasher:bd,washer:/(waschmaschine|washer|washing)/i,dryer:/(trockner|dryer)/i,kitchen:/(kaffee|coffee|wasserkocher|kettle)/i,island:Z_,sink:bd,radiator:/(heiz|radiator|thermostat|climate|hk|trv)/i},yd={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},vd=new Set(["tv_board","tv_wall"]);var An=t=>vd.has(t)||!!gc(t),qo=t=>!!G(t)?.electric&&/speaker|multiroom|soundbar/.test(t.split(":").pop()??t),vr=t=>An(t)||t==="desk"||t==="fridge_smart",Y_=t=>!!t&&t!=="none";function X_(t,e){if(Ko(t,e))return e;let n=t.entities?.[e]?.device_id;return n?Go(t,n).find(r=>r!==e)??null:null}var Q_=(t,e,n)=>t.rooms.find(r=>r.points.length>=3&&N([e,n],r.points));function yr(t,e,n,r){return t.find(o=>e?.test(n(o)))??(r?t[0]??null:null)}function Be(t,e){let n=new Map;for(let r of e){let o=new Set([...r.furniture.flatMap(i=>[i.entity,i.power,i.fan_entity]),...r.placements.map(i=>i.entity_id)].filter(Y_));for(let i of r.furniture){let s=i.type in yd,l=wn(i.type),a=s?yd[i.type]:q_[i.type];if(!a&&!l&&!qo(i.type)&&i.entity==null&&i.power==null)continue;let c=Q_(r,i.x,i.z),d=(c?jo(t,be(t,c)):[]).filter(y=>!o.has(y)),u=y=>`${y} ${V(t,y)}`,p=y=>d.filter(b=>X(b)===y),h=i.entity==="none"?null:i.entity??null;if(i.entity==null){if(i.type==="ceiling_fan"){let y=(c?be(t,c):[]).filter(v=>!o.has(v)),b=new Set(y.filter(v=>X(v)==="fan").map(v=>t.entities?.[v]?.device_id).filter(Boolean));h=y.find(v=>X(v)==="light"&&b.has(t.entities?.[v]?.device_id))??yr(p("light"),a,u,!1)}else if(s)h=yr(p("light"),a,u,!0);else if(i.type==="robot_vacuum"){let y=c?.area_id??null;h=Object.keys(t.entities??{}).find(b=>b.startsWith("vacuum.")&&!o.has(b)&&Ft(t,b)===y)??null}else if(i.type==="radiator"||l)h=yr(p("climate"),a,u,!0);else if(An(i.type)){let y=p("media");h=y.find(b=>t.states[b]?.attributes.device_class==="tv")??yr(y,a,u,vd.has(i.type))}else if(qo(i.type)){let y=p("media").filter(b=>t.states[b]?.attributes.device_class!=="tv");h=yr(y,a,u,!1)??(y.length===1?y[0]:null)}else a&&(h=d.find(y=>["switch","media","fan"].includes(X(y)??"")&&a.test(u(y)))??null);h&&o.add(h)}let f=i.power==="none"?null:i.power??null;i.power==null&&(f=h?X_(t,h):null,!f&&a&&c&&!s&&(f=be(t,c).find(y=>Ko(t,y)&&!o.has(y)&&a.test(u(y)))??null),f&&o.add(f));let g=null;if(i.type==="ceiling_fan"&&(g=i.fan_entity==="none"?null:i.fan_entity??null,i.fan_entity==null)){let y=(c?be(t,c):[]).filter(v=>X(v)==="fan"&&!o.has(v)),b=h?t.entities?.[h]?.device_id:void 0;g=(b?y.find(v=>t.entities?.[v]?.device_id===b):void 0)??y[0]??null,g&&o.add(g)}(h||f||g)&&n.set(i.id,{entity:h,power:f,...i.type==="ceiling_fan"?{fan:g}:{}})}}return n}var wd=t=>t==="fridge"||t==="fridge_smart"||/(fridge|freezer|kuehl|gefrier|chest_freezer)/.test(t.slice(t.lastIndexOf(":")+1));function kd(t,e,n=[]){let r=[];for(let o of e){let i=(l,a)=>o.rooms.some(c=>c.points.length>=3&&N([l,a],c.points)),s=Be(t,[o]);r.push(...o.placements.filter(l=>l.outside||!i(l.x,l.z)).map(l=>l.entity_id)),r.push(...o.furniture.filter(l=>!i(l.x,l.z)).flatMap(l=>[s.get(l.id)?.entity,s.get(l.id)?.power]));for(let l of o.outdoor??[])l.area_id&&r.push(...jo(t,Wo(t,l.area_id))),r.push(l.pump_entity,l.temp_entity)}return[...new Set(r.filter(o=>!!o&&!!t.states[o]&&!n.includes(o)))]}function J_(t,e){return Math.min(...e.map((n,r)=>{let o=e[(r+1)%e.length],[i,s]=[o[0]-n[0],o[1]-n[1]],l=Math.min(1,Math.max(0,((t[0]-n[0])*i+(t[1]-n[1])*s)/(i*i+s*s||1)));return Math.hypot(t[0]-n[0]-i*l,t[1]-n[1]-s*l)}))}function $d(t,e,n=[]){let r=t.points;if(r.length<3||e.length===0)return[];let o=r.map(b=>b[0]),i=r.map(b=>b[1]),[s,l,a,c]=[Math.min(...o),Math.max(...o),Math.min(...i),Math.max(...i)],d=Math.min(l-s,c-a),u=Math.max(.1,Math.min(.25,d/8)),p=Math.min(.35,d/5),h=Math.min(.7,d/4),f=_e(r),g=[];for(let b=s+u/2;b=p&&g.push({at:w,wallDistance:x})}g.length===0&&g.push({at:f,wallDistance:0});let y=[...n];return e.map(b=>{let v=X(b)==="light",w=g[0].at,x=-1/0;for(let{at:S,wallDistance:A}of g){let F=y.length?Math.min(...y.map(P=>Math.hypot(S[0]-P[0],S[1]-P[1]))):3,T=Math.hypot(S[0]-f[0],S[1]-f[1]),I=Math.min(F,3)*2;Tx+1e-9&&(x=I,w=S)}let k=[Math.round(w[0]*100)/100,Math.round(w[1]*100)/100];return y.push(k),{entity_id:b,x:k[0],z:k[1],y:null,mount:null}})}var xd=/(^|_)(current_room|current_segment|aktueller_raum|current_area)($|_)/;function Sd(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(i=>i.device_id===r&&i.entity_id.startsWith("sensor.")&&(xd.test(i.translation_key??"")||xd.test(i.entity_id.split(".")[1])))?.entity_id??null}var ye=re`
: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);
}
-`,T1=re`
+`,F1=re`
:host([readable]) {
--secondary-text-color: var(--primary-text-color, #e1e1e1);
--divider-color: color-mix(in srgb, var(--primary-text-color, #e1e1e1) 40%, transparent);
@@ -203,7 +203,7 @@ var $={cs:"4be67fcd522e",da:"0fe66a82bf2a",es:"bd89dffd1355",fi:"9a17bc084f56",f
min-height: 40px;
}
}
-`;var{I:tb}=ic,Md=t=>t;var Ed=t=>t.strings===void 0,Rd=()=>document.createComment(""),Fn=(t,e,n)=>{let r=t._$AA.parentNode,o=e===void 0?t._$AB:e._$AA;if(n===void 0){let i=r.insertBefore(Rd(),o),s=r.insertBefore(Rd(),o);n=new tb(i,s,t,t.options)}else{let i=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(i!==o||l){let a=n._$AA;for(;a!==i;){let c=Md(a).nextSibling;Md(r).insertBefore(a,o),a=c}}}return n},It=(t,e,n=t)=>(t._$AI(e,n),t),nb={},Ad=(t,e=nb)=>t._$AH=e,Fd=t=>t._$AH,Yo=t=>{t._$AR(),t._$AA.remove()};var Td=(t,e,n)=>{let r=new Map;for(let o=e;o<=n;o++)r.set(t[o],o);return r},zd=Qt(class extends Pt{constructor(t){if(super(t),t.type!==En.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 o=[],i=[],s=0;for(let l of t)o[s]=r?r(l,s):s,i[s]=n(l,s),s++;return{values:i,keys:o}}render(t,e,n){return this.dt(t,e,n).values}update(t,[e,n,r]){let o=Fd(t),{values:i,keys:s}=this.dt(e,n,r);if(!Array.isArray(o))return this.ut=s,i;let l=this.ut??=[],a=[],c,d,u=0,p=o.length-1,h=0,f=i.length-1;for(;u<=p&&h<=f;)if(o[u]===null)u++;else if(o[p]===null)p--;else if(l[u]===s[h])a[h]=It(o[u],i[h]),u++,h++;else if(l[p]===s[f])a[f]=It(o[p],i[f]),p--,f--;else if(l[u]===s[f])a[f]=It(o[u],i[f]),Fn(t,a[f+1],o[u]),u++,f--;else if(l[p]===s[h])a[h]=It(o[p],i[h]),Fn(t,o[u],o[p]),p--,h++;else if(c===void 0&&(c=Td(s,h,f),d=Td(l,u,p)),c.has(l[u]))if(c.has(l[p])){let g=d.get(s[h]),y=g!==void 0?o[g]:null;if(y===null){let b=Fn(t,o[u]);It(b,i[h]),a[h]=b}else a[h]=It(y,i[h]),Fn(t,o[u],y),o[g]=null;h++}else Yo(o[p]),p--;else Yo(o[u]),u++;for(;h<=f;){let g=Fn(t,a[f+1]);It(g,i[h]),a[h++]=g}for(;u<=p;){let g=o[u++];g!==null&&Yo(g)}return this.ut=s,Ad(t,a),Qe}});var rb=new Intl.Collator("de",{numeric:!0,sensitivity:"base"}),zs=-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"}],Pd=t=>t.object_type===1&&Id.some(e=>e.type===t.module_type);function ob(t){let e=new Map(t.map(a=>[a.object_id,a])),n=t.filter(a=>{if(!Pd(a))return!1;let c=new Set([a.object_id]),d=e.get(a.parent_id);for(;d&&!c.has(d.object_id);){if(Pd(d))return!1;c.add(d.object_id),d=e.get(d.parent_id)}return!0});if(!n.length)return t;let r=new Map(e),o=new Map;for(let a of t){let c=o.get(a.parent_id)??[];c.push(a),o.set(a.parent_id,c)}let i=(a,c,d,u,p)=>({object_id:a,parent_id:c,name:d,path:u,position:p,object_type:0,hidden:!1,icon:"",virtual:!0});r.set(zs,i(zs,0,"System","System",Number.MAX_SAFE_INTEGER));let s=new Set,l=(a,c,d)=>{if(s.has(a.object_id))return;s.add(a.object_id);let u={...a,parent_id:c,path:`${d} / ${a.name}`};r.set(a.object_id,u);for(let p of o.get(a.object_id)??[])l(p,a.object_id,u.path)};return Id.forEach((a,c)=>{let d=n.filter(h=>h.module_type===a.type);if(!d.length)return;let u=-10-a.type,p=`System / ${a.name}`;r.set(u,i(u,zs,a.name,p,c));for(let h of d)l(h,u,p)}),[...r.values()]}function Ps(t){let e=ob(t),n=new Map(e.map(o=>[o.object_id,o])),r=new Map;for(let o of e){let i=n.has(o.parent_id)?o.parent_id:0,s=r.get(i)??[];s.push(o),r.set(i,s)}for(let o of r.values())o.sort((i,s)=>i.position-s.position||i.object_type-s.object_type||rb.compare(i.name,s.name));return{nodes:n,children:r}}function Is(t,e){let n=[],r=new Set([e]),o=t.nodes.get(e)?.parent_id;for(;o&&!r.has(o)&&t.nodes.has(o);)n.push(o),r.add(o),o=t.nodes.get(o)?.parent_id;return n}function Ds(t,e,n=""){let r=n.trim().toLocaleLowerCase("de").split(/\s+/).filter(Boolean),o=r.length?new Set:null;if(o){for(let a of t.nodes.values())if(r.every(c=>`${a.name} ${a.path}`.toLocaleLowerCase("de").includes(c))){o.add(a.object_id);for(let c of Is(t,a.object_id))o.add(c)}}let i=[],s=new Set,l=(a,c)=>{let d=(t.children.get(a)??[]).filter(u=>!o||o.has(u.object_id));d.forEach((u,p)=>{if(s.has(u.object_id))return;s.add(u.object_id);let h=(t.children.get(u.object_id)?.length??0)>0,f=h&&(!!o||e.has(u.object_id));i.push({node:u,depth:c,hasChildren:h,expanded:f,index:p+1,siblings:d.length}),f&&l(u.object_id,c+1)})};return l(0,0),i}var ib=["Kategorie","Instanz","Variable","Skript","Ereignis","Medium","Link"],Os=class extends Q{static properties={objects:{attribute:!1},options:{attribute:!1},fixed:{attribute:!1},value:{attribute:!1},disabled:{type:Boolean},placeholder:{attribute:!1},_query:{state:!0},_expanded:{state:!0},_pending:{state:!0},_active:{state:!0},_selected:{state:!0}};tree=Ps([]);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._query="",this._expanded=new Set,this._pending=null,this._active=null,this._selected=null}willUpdate(e){e.has("objects")&&(this.tree=Ps(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(o=>o.entity_id===n&&o.object_type===2);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="";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 Is(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()}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)}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=Ds(this.tree,this._expanded,this._query),r=Math.max(0,n.findIndex(s=>s.node.object_id===this._active)),o=n[r];if(!o)return;let i=r;if(e.key==="ArrowDown")i=Math.min(n.length-1,r+1);else if(e.key==="ArrowUp")i=Math.max(0,r-1);else if(e.key==="Home")i=0;else if(e.key==="End")i=n.length-1;else if(e.key==="ArrowRight")o.hasChildren&&!o.expanded?this.toggle(o.node.object_id):o.hasChildren&&(i=Math.min(n.length-1,r+1));else if(e.key==="ArrowLeft")o.expanded&&!this._query?this.toggle(o.node.object_id):i=Math.max(0,n.findIndex(s=>s.node.object_id===o.node.parent_id));else if(e.key===" "||e.key==="Enter")this.select(o.node),e.key==="Enter"&&this.entityFor(o.node)&&this.commit();else return;e.preventDefault(),(i!==r||this._active===null)&&(this._active=n[i].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``}renderRow(e){let{node:n}=e,r=this.entityFor(n),o=!!r;return m`t;var Ed=t=>t.strings===void 0,Rd=()=>document.createComment(""),Fn=(t,e,n)=>{let r=t._$AA.parentNode,o=e===void 0?t._$AB:e._$AA;if(n===void 0){let i=r.insertBefore(Rd(),o),s=r.insertBefore(Rd(),o);n=new eb(i,s,t,t.options)}else{let i=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(i!==o||l){let a=n._$AA;for(;a!==i;){let c=Md(a).nextSibling;Md(r).insertBefore(a,o),a=c}}}return n},Dt=(t,e,n=t)=>(t._$AI(e,n),t),tb={},Ad=(t,e=tb)=>t._$AH=e,Fd=t=>t._$AH,Yo=t=>{t._$AR(),t._$AA.remove()};var Td=(t,e,n)=>{let r=new Map;for(let o=e;o<=n;o++)r.set(t[o],o);return r},zd=Qt(class extends Pt{constructor(t){if(super(t),t.type!==En.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 o=[],i=[],s=0;for(let l of t)o[s]=r?r(l,s):s,i[s]=n(l,s),s++;return{values:i,keys:o}}render(t,e,n){return this.dt(t,e,n).values}update(t,[e,n,r]){let o=Fd(t),{values:i,keys:s}=this.dt(e,n,r);if(!Array.isArray(o))return this.ut=s,i;let l=this.ut??=[],a=[],c,d,u=0,p=o.length-1,h=0,f=i.length-1;for(;u<=p&&h<=f;)if(o[u]===null)u++;else if(o[p]===null)p--;else if(l[u]===s[h])a[h]=Dt(o[u],i[h]),u++,h++;else if(l[p]===s[f])a[f]=Dt(o[p],i[f]),p--,f--;else if(l[u]===s[f])a[f]=Dt(o[u],i[f]),Fn(t,a[f+1],o[u]),u++,f--;else if(l[p]===s[h])a[h]=Dt(o[p],i[h]),Fn(t,o[u],o[p]),p--,h++;else if(c===void 0&&(c=Td(s,h,f),d=Td(l,u,p)),c.has(l[u]))if(c.has(l[p])){let g=d.get(s[h]),y=g!==void 0?o[g]:null;if(y===null){let b=Fn(t,o[u]);Dt(b,i[h]),a[h]=b}else a[h]=Dt(y,i[h]),Fn(t,o[u],y),o[g]=null;h++}else Yo(o[p]),p--;else Yo(o[u]),u++;for(;h<=f;){let g=Fn(t,a[f+1]);Dt(g,i[h]),a[h++]=g}for(;u<=p;){let g=o[u++];g!==null&&Yo(g)}return this.ut=s,Ad(t,a),Qe}});var nb=new Intl.Collator("de",{numeric:!0,sensitivity:"base"}),zs=-1,Dd=[{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"}],Pd=t=>t.object_type===1&&Dd.some(e=>e.type===t.module_type);function rb(t){let e=new Map(t.map(a=>[a.object_id,a])),n=t.filter(a=>{if(!Pd(a))return!1;let c=new Set([a.object_id]),d=e.get(a.parent_id);for(;d&&!c.has(d.object_id);){if(Pd(d))return!1;c.add(d.object_id),d=e.get(d.parent_id)}return!0});if(!n.length)return t;let r=new Map(e),o=new Map;for(let a of t){let c=o.get(a.parent_id)??[];c.push(a),o.set(a.parent_id,c)}let i=(a,c,d,u,p)=>({object_id:a,parent_id:c,name:d,path:u,position:p,object_type:0,hidden:!1,icon:"",virtual:!0});r.set(zs,i(zs,0,"System","System",Number.MAX_SAFE_INTEGER));let s=new Set,l=(a,c,d)=>{if(s.has(a.object_id))return;s.add(a.object_id);let u={...a,parent_id:c,path:`${d} / ${a.name}`};r.set(a.object_id,u);for(let p of o.get(a.object_id)??[])l(p,a.object_id,u.path)};return Dd.forEach((a,c)=>{let d=n.filter(h=>h.module_type===a.type);if(!d.length)return;let u=-10-a.type,p=`System / ${a.name}`;r.set(u,i(u,zs,a.name,p,c));for(let h of d)l(h,u,p)}),[...r.values()]}function Ps(t){let e=rb(t),n=new Map(e.map(o=>[o.object_id,o])),r=new Map;for(let o of e){let i=n.has(o.parent_id)?o.parent_id:0,s=r.get(i)??[];s.push(o),r.set(i,s)}for(let o of r.values())o.sort((i,s)=>i.position-s.position||i.object_type-s.object_type||nb.compare(i.name,s.name));return{nodes:n,children:r}}function Ds(t,e){let n=[],r=new Set([e]),o=t.nodes.get(e)?.parent_id;for(;o&&!r.has(o)&&t.nodes.has(o);)n.push(o),r.add(o),o=t.nodes.get(o)?.parent_id;return n}function Is(t,e,n=""){let r=n.trim().toLocaleLowerCase("de").split(/\s+/).filter(Boolean),o=r.length?new Set:null;if(o){for(let a of t.nodes.values())if(r.every(c=>`${a.name} ${a.path}`.toLocaleLowerCase("de").includes(c))){o.add(a.object_id);for(let c of Ds(t,a.object_id))o.add(c)}}let i=[],s=new Set,l=(a,c)=>{let d=(t.children.get(a)??[]).filter(u=>!o||o.has(u.object_id));d.forEach((u,p)=>{if(s.has(u.object_id))return;s.add(u.object_id);let h=(t.children.get(u.object_id)?.length??0)>0,f=h&&(!!o||e.has(u.object_id));i.push({node:u,depth:c,hasChildren:h,expanded:f,index:p+1,siblings:d.length}),f&&l(u.object_id,c+1)})};return l(0,0),i}var ob=["Kategorie","Instanz","Variable","Skript","Ereignis","Medium","Link"],Os=class extends Q{static properties={objects:{attribute:!1},options:{attribute:!1},fixed:{attribute:!1},value:{attribute:!1},disabled:{type:Boolean},placeholder:{attribute:!1},_query:{state:!0},_expanded:{state:!0},_pending:{state:!0},_active:{state:!0},_selected:{state:!0}};tree=Ps([]);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._query="",this._expanded=new Set,this._pending=null,this._active=null,this._selected=null}willUpdate(e){e.has("objects")&&(this.tree=Ps(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(o=>o.entity_id===n&&o.object_type===2);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="";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 Ds(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)}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=Is(this.tree,this._expanded,this._query),r=Math.max(0,n.findIndex(s=>s.node.object_id===this._active)),o=n[r];if(!o)return;let i=r;if(e.key==="ArrowDown")i=Math.min(n.length-1,r+1);else if(e.key==="ArrowUp")i=Math.max(0,r-1);else if(e.key==="Home")i=0;else if(e.key==="End")i=n.length-1;else if(e.key==="ArrowRight")o.hasChildren&&!o.expanded?this.toggle(o.node.object_id):o.hasChildren&&(i=Math.min(n.length-1,r+1));else if(e.key==="ArrowLeft")o.expanded&&!this._query?this.toggle(o.node.object_id):i=Math.max(0,n.findIndex(s=>s.node.object_id===o.node.parent_id));else if(e.key===" "||e.key==="Enter")this.select(o.node),e.key==="Enter"&&this.entityFor(o.node)&&this.commit();else return;e.preventDefault(),(i!==r||this._active===null)&&(this._active=n[i].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`
`}renderRow(e){let{node:n}=e,r=this.entityFor(n),o=!!r;return m`
${this.icon(n.object_type)}${n.name||"(Ohne Namen)"}
- ${n.virtual?"Systembereich":ib[n.object_type]??"Objekt"}${n.hidden?" \xB7 ausgeblendet":""}
+ ${n.virtual?"Systembereich":ob[n.object_type]??"Objekt"}${n.hidden?" \xB7 ausgeblendet":""}
${o&&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??""),o=this._selected===null?void 0:this.tree.nodes.get(this._selected),i=(o&&this.entityFor(o)===this._pending?o:void 0)??this.variableNode(this._pending),s=Ds(this.tree,this._expanded,this._query),l=s.find(a=>a.node.object_id===this._active);return m`
-
`}render(){let e=this.allowed.get(this.value??""),n=this.variableNode(this.value),r=this.allowed.get(this._pending??""),o=this._selected===null?void 0:this.tree.nodes.get(this._selected),i=(o&&this.entityFor(o)===this._pending?o:void 0)??this.variableNode(this._pending),s=Is(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`${a?m``:_}
+ `}static styles=[ye,re`
- :host { display:block; min-width:0; font:inherit; color:var(--nf-text); }
+ :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; }
button:disabled { opacity:.45; cursor:default; }
button:focus-visible,input:focus-visible { outline:2px solid var(--nf-accent); outline-offset:2px; }
- .trigger { width:100%; display:flex; align-items:center; justify-content:space-between; text-align:left; gap:12px; padding:9px 11px; }
- .trigger>span:first-child { min-width:0; }
+ .field { display:flex; gap:6px; min-width:0; }
+ .trigger { flex:1; min-width:0; width:100%; display:flex; align-items:center; justify-content:space-between; text-align:left; gap:12px; padding:9px 11px; }
+ .trigger-text { flex:1; min-width:0; overflow:hidden; }
+ .trigger strong { display:block; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
+ .picker-icon { flex:none; }
+ .clear { flex:none; width:32px; padding:0; font-size:22px; }
strong { font-weight:500; } small { display:block; color:var(--nf-muted); font-size:11px; }
.trigger small { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; margin-top:3px; }
dialog { width:min(780px,calc(100vw - 32px)); max-width:none; height:min(690px,calc(100dvh - 32px)); max-height:none; box-sizing:border-box; padding:0; border:1px solid var(--nf-line); border-radius:16px; color:var(--nf-text); background:var(--nf-chrome-solid); box-shadow:0 24px 80px #0008; font:14px system-ui,sans-serif; }
@@ -288,7 +292,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",Os);var Dd=40,Hs=class extends Q{static properties={options:{attribute:!1},objectTree:{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))},o=this.fixed.filter(s=>!e||r(s)),i=e?this.options.filter(r):this.options;return[...o,...i.slice(0,Dd)]}get leftOut(){let e=this._query.trim().toLowerCase(),n=e.split(/\s+/).filter(Boolean),r=e?this.options.filter(o=>n.every(i=>`${o.label} ${o.detail??o.id}`.toLowerCase().includes(i))).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`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))},o=this.fixed.filter(s=>!e||r(s)),i=e?this.options.filter(r):this.options;return[...o,...i.slice(0,Id)]}get leftOut(){let e=this._query.trim().toLowerCase(),n=e.split(/\s+/).filter(Boolean),r=e?this.options.filter(o=>n.every(i=>`${o.label} ${o.detail??o.id}`.toLowerCase().includes(i))).length:this.options.length;return Math.max(0,r-Id)}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.value=r.detail.value}}
@@ -322,6 +326,8 @@ var $={cs:"4be67fcd522e",da:"0fe66a82bf2a",es:"bd89dffd1355",fi:"9a17bc084f56",f
:host {
display: block;
position: relative;
+ min-width: 0;
+ max-width: 100%;
}
input {
width: 100%;
@@ -438,7 +444,7 @@ var $={cs:"4be67fcd522e",da:"0fe66a82bf2a",es:"bd89dffd1355",fi:"9a17bc084f56",f
?disabled=${!t.admin}
@change=${c=>{c.stopPropagation(),i(c.detail.value==="__auto"?null:c.detail.value)}}
>
- `}function Tn(t,e,n){return n?(n.startsWith("mdi:")?n:`mdi:${n}`).replace(/[^a-z0-9:-]/gi,""):t.hass?td(t.hass,e):null}function Dt(t,e,n){let r=e?(e.startsWith("mdi:")?e:`mdi:${e}`).replace(/[^a-z0-9:-]/gi,""):"";return m`