/*! NextFloor, MIT licence. Includes three.js (MIT) and Lit (BSD-3-Clause); see LICENSE and THIRD_PARTY_NOTICES.md */ var $={cs:"4be67fcd522e",da:"0fe66a82bf2a",es:"bd89dffd1355",fi:"9a17bc084f56",fr:"6312d0f61ebf",hu:"27ba348531dc",it:"1b705e76dd00",nb:"c5ea24fb9ef6",nl:"b64142c67c2e",pl:"8527a4930402",pt:"31857a2d2277",ro:"e3cb5f449f0f",sk:"320611594db0",sl:"8071691ceda3",sv:"711b911ec8da",tr:"7c83ce1c3372",zh:"50518d9f494e"};var Hi=globalThis,Li=Hi.ShadowRoot&&(Hi.ShadyCSS===void 0||Hi.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,xs=Symbol(),Mc=new WeakMap,xr=class{constructor(e,n,r){if(this._$cssResult$=!0,r!==xs)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=n}get styleSheet(){let e=this.o,n=this.t;if(Li&&e===void 0){let r=n!==void 0&&n.length===1;r&&(e=Mc.get(n)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),r&&Mc.set(n,e))}return e}toString(){return this.cssText}},Rc=t=>new xr(typeof t=="string"?t:t+"",void 0,xs),ee=(t,...e)=>{let n=t.length===1?t[0]:e.reduce((r,i,o)=>r+(s=>{if(s._$cssResult$===!0)return s.cssText;if(typeof s=="number")return s;throw Error("Value passed to 'css' function must be a 'css' function result: "+s+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+t[o+1],t[0]);return new xr(n,t,xs)},Ec=(t,e)=>{if(Li)t.adoptedStyleSheets=e.map(n=>n instanceof CSSStyleSheet?n:n.styleSheet);else for(let n of e){let r=document.createElement("style"),i=Hi.litNonce;i!==void 0&&r.setAttribute("nonce",i),r.textContent=n.cssText,t.appendChild(r)}},$s=Li?t=>t:t=>t instanceof CSSStyleSheet?(e=>{let n="";for(let r of e.cssRules)n+=r.cssText;return Rc(n)})(t):t;var{is:mb,defineProperty:gb,getOwnPropertyDescriptor:_b,getOwnPropertyNames:bb,getOwnPropertySymbols:yb,getPrototypeOf:vb}=Object,Ci=globalThis,Ac=Ci.trustedTypes,wb=Ac?Ac.emptyScript:"",kb=Ci.reactiveElementPolyfillSupport,$r=(t,e)=>t,Ss={toAttribute(t,e){switch(e){case Boolean:t=t?wb:null;break;case Object:case Array:t=t==null?t:JSON.stringify(t)}return t},fromAttribute(t,e){let n=t;switch(e){case Boolean:n=t!==null;break;case Number:n=t===null?null:Number(t);break;case Object:case Array:try{n=JSON.parse(t)}catch{n=null}}return n}},Tc=(t,e)=>!mb(t,e),Fc={attribute:!0,type:String,converter:Ss,reflect:!1,useDefault:!1,hasChanged:Tc};Symbol.metadata??=Symbol("metadata"),Ci.litPropertyMetadata??=new WeakMap;var yt=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??=[]).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,n=Fc){if(n.state&&(n.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((n=Object.create(n)).wrapped=!0),this.elementProperties.set(e,n),!n.noAccessor){let r=Symbol(),i=this.getPropertyDescriptor(e,r,n);i!==void 0&&gb(this.prototype,e,i)}}static getPropertyDescriptor(e,n,r){let{get:i,set:o}=_b(this.prototype,e)??{get(){return this[n]},set(s){this[n]=s}};return{get:i,set(s){let l=i?.call(this);o?.call(this,s),this.requestUpdate(e,l,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??Fc}static _$Ei(){if(this.hasOwnProperty($r("elementProperties")))return;let e=vb(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty($r("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty($r("properties"))){let n=this.properties,r=[...bb(n),...yb(n)];for(let i of r)this.createProperty(i,n[i])}let e=this[Symbol.metadata];if(e!==null){let n=litPropertyMetadata.get(e);if(n!==void 0)for(let[r,i]of n)this.elementProperties.set(r,i)}this._$Eh=new Map;for(let[n,r]of this.elementProperties){let i=this._$Eu(n,r);i!==void 0&&this._$Eh.set(i,n)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){let n=[];if(Array.isArray(e)){let r=new Set(e.flat(1/0).reverse());for(let i of r)n.unshift($s(i))}else e!==void 0&&n.push($s(e));return n}static _$Eu(e,n){let r=n.attribute;return r===!1?void 0:typeof r=="string"?r:typeof e=="string"?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(e=>this.enableUpdating=e),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(e=>e(this))}addController(e){(this._$EO??=new Set).add(e),this.renderRoot!==void 0&&this.isConnected&&e.hostConnected?.()}removeController(e){this._$EO?.delete(e)}_$E_(){let e=new Map,n=this.constructor.elementProperties;for(let r of n.keys())this.hasOwnProperty(r)&&(e.set(r,this[r]),delete this[r]);e.size>0&&(this._$Ep=e)}createRenderRoot(){let e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return Ec(e,this.constructor.elementStyles),e}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(e=>e.hostConnected?.())}enableUpdating(e){}disconnectedCallback(){this._$EO?.forEach(e=>e.hostDisconnected?.())}attributeChangedCallback(e,n,r){this._$AK(e,r)}_$ET(e,n){let r=this.constructor.elementProperties.get(e),i=this.constructor._$Eu(e,r);if(i!==void 0&&r.reflect===!0){let o=(r.converter?.toAttribute!==void 0?r.converter:Ss).toAttribute(n,r.type);this._$Em=e,o==null?this.removeAttribute(i):this.setAttribute(i,o),this._$Em=null}}_$AK(e,n){let r=this.constructor,i=r._$Eh.get(e);if(i!==void 0&&this._$Em!==i){let o=r.getPropertyOptions(i),s=typeof o.converter=="function"?{fromAttribute:o.converter}:o.converter?.fromAttribute!==void 0?o.converter:Ss;this._$Em=i;let l=s.fromAttribute(n,o.type);this[i]=l??this._$Ej?.get(i)??l,this._$Em=null}}requestUpdate(e,n,r,i=!1,o){if(e!==void 0){let s=this.constructor;if(i===!1&&(o=this[e]),r??=s.getPropertyOptions(e),!((r.hasChanged??Tc)(o,n)||r.useDefault&&r.reflect&&o===this._$Ej?.get(e)&&!this.hasAttribute(s._$Eu(e,r))))return;this.C(e,n,r)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(e,n,{useDefault:r,reflect:i,wrapped:o},s){r&&!(this._$Ej??=new Map).has(e)&&(this._$Ej.set(e,s??n??this[e]),o!==!0||s!==void 0)||(this._$AL.has(e)||(this.hasUpdated||r||(n=void 0),this._$AL.set(e,n)),i===!0&&this._$Em!==e&&(this._$Eq??=new Set).add(e))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(n){Promise.reject(n)}let e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(let[i,o]of this._$Ep)this[i]=o;this._$Ep=void 0}let r=this.constructor.elementProperties;if(r.size>0)for(let[i,o]of r){let{wrapped:s}=o,l=this[i];s!==!0||this._$AL.has(i)||l===void 0||this.C(i,void 0,o,l)}}let e=!1,n=this._$AL;try{e=this.shouldUpdate(n),e?(this.willUpdate(n),this._$EO?.forEach(r=>r.hostUpdate?.()),this.update(n)):this._$EM()}catch(r){throw e=!1,this._$EM(),r}e&&this._$AE(n)}willUpdate(e){}_$AE(e){this._$EO?.forEach(n=>n.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Eq&&=this._$Eq.forEach(n=>this._$ET(n,this[n])),this._$EM()}updated(e){}firstUpdated(e){}};yt.elementStyles=[],yt.shadowRootOptions={mode:"open"},yt[$r("elementProperties")]=new Map,yt[$r("finalized")]=new Map,kb?.({ReactiveElement:yt}),(Ci.reactiveElementVersions??=[]).push("2.1.2");var Rs=globalThis,zc=t=>t,Ni=Rs.trustedTypes,Pc=Ni?Ni.createPolicy("lit-html",{createHTML:t=>t}):void 0,Es="$lit$",vt=`lit$${Math.random().toFixed(9).slice(2)}$`,As="?"+vt,xb=`<${As}>`,tn=document,Mr=()=>tn.createComment(""),Rr=t=>t===null||typeof t!="object"&&typeof t!="function",Fs=Array.isArray,Cc=t=>Fs(t)||typeof t?.[Symbol.iterator]=="function",Ms=`[ \f\r]`,Sr=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Dc=/-->/g,Ic=/>/g,Qt=RegExp(`>|${Ms}(?:([^\\s"'>=/]+)(${Ms}*=${Ms}*(?:[^ \f\r"'\`<>=]|("|')|))|$)`,"g"),Oc=/'/g,Hc=/"/g,Nc=/^(?:script|style|textarea|title)$/i,Ts=t=>(e,...n)=>({_$litType$:t,strings:e,values:n}),m=Ts(1),R=Ts(2),o1=Ts(3),tt=Symbol.for("lit-noChange"),_=Symbol.for("lit-nothing"),Lc=new WeakMap,en=tn.createTreeWalker(tn,129);function Bc(t,e){if(!Fs(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return Pc!==void 0?Pc.createHTML(e):e}var Vc=(t,e)=>{let n=t.length-1,r=[],i,o=e===2?"":e===3?"":"",s=Sr;for(let l=0;l"?(s=i??Sr,d=-1):u[1]===void 0?d=-2:(d=s.lastIndex-u[2].length,c=u[1],s=u[3]===void 0?Qt:u[3]==='"'?Hc:Oc):s===Hc||s===Oc?s=Qt:s===Dc||s===Ic?s=Sr:(s=Qt,i=void 0);let h=s===Qt&&t[l+1].startsWith("/>")?" ":"";o+=s===Sr?a+xb:d>=0?(r.push(c),a.slice(0,d)+Es+a.slice(d)+vt+h):a+vt+(d===-2?l:h)}return[Bc(t,o+(t[n]||"")+(e===2?"":e===3?"":"")),r]},Er=class t{constructor({strings:e,_$litType$:n},r){let i;this.parts=[];let o=0,s=0,l=e.length-1,a=this.parts,[c,u]=Vc(e,n);if(this.el=t.createElement(c,r),en.currentNode=this.el.content,n===2||n===3){let d=this.el.content.firstChild;d.replaceWith(...d.childNodes)}for(;(i=en.nextNode())!==null&&a.length0){i.textContent=Ni?Ni.emptyScript:"";for(let h=0;h2||r[0]!==""||r[1]!==""?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=_}_$AI(e,n=this,r,i){let o=this.strings,s=!1;if(o===void 0)e=nn(this,e,n,0),s=!Rr(e)||e!==this._$AH&&e!==tt,s&&(this._$AH=e);else{let l=e,a,c;for(e=o[0],a=0;a{let r=n?.renderBefore??e,i=r._$litPart$;if(i===void 0){let o=n?.renderBefore??null;r._$litPart$=i=new An(e.insertBefore(Mr(),o),o,void 0,n??{})}return i._$AI(t),i};var zs=globalThis,Y=class extends yt{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){let e=super.createRenderRoot();return this.renderOptions.renderBefore??=e.firstChild,e}update(e){let n=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=Kc(n,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return tt}};Y._$litElement$=!0,Y.finalized=!0,zs.litElementHydrateSupport?.({LitElement:Y});var Sb=zs.litElementPolyfillSupport;Sb?.({LitElement:Y});(zs.litElementVersions??=[]).push("4.2.2");var Ds=t=>t.slice(0,t.indexOf(".")),Mb={light:"light",switch:"switch",input_boolean:"switch",valve:"switch",fan:"fan",cover:"cover",climate:"climate",media_player:"media",lock:"lock",sensor:"sensor",binary_sensor:"binary",event:"sensor",scene:"scene",script:"script"},Q=t=>Mb[Ds(t)]??null,Is=["light","cover","climate","media","switch","fan","lock","binary","sensor","scene","script"];var jc=new Set(["light","switch","fan"]),Tt=t=>t!==null&&t!=="scene"&&t!=="script",Ie=t=>!t||t.state==="unavailable"||t.state==="unknown"&&!t.entity_id.startsWith("event.");function B(t,e,n){let r=String(t?.states[e]?.attributes.friendly_name??t?.entities?.[e]?.name??e);if(!n||r.length<=n.length+1||!r.toLowerCase().startsWith(`${n.toLowerCase()} `))return r;let i=r.slice(n.length+1);return i[0].toUpperCase()+i.slice(1)}var Uc=t=>!!t&&t.entity_id.startsWith("sensor.")&&t.attributes.device_class==="enum";var Gc=t=>Math.min(1,Math.max(0,t));function Rb(t){let e=Gc((t-2200)/4300),n=[1,.66,.26],r=[.78,.9,1];return[0,1,2].map(i=>n[i]+(r[i]-n[i])*e)}function Ps(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(Gc(n.brightness/255)):1,i=n.rgb_color;return i&&!["color_temp","brightness","onoff"].includes(String(n.color_mode))?{color:[i[0]/255,i[1]/255,i[2]/255],level:r}:typeof n.color_temp_kelvin=="number"?{color:Rb(n.color_temp_kelvin),level:r}:{color:[1,.71,.28],level:r}}function Zc(t,e,n){let r=Ps(t,n);if(r)return r;for(let i of e){let o=Ps(i);if(o)return{color:o.color,level:o.level*.6}}return null}function Ui(t,e,n=null){if(t==="light"&&n==="floor")return 1.95;if(t==="light"&&n==="table")return 1.25;if(t==="light"&&n==="wall")return 1.95;switch(t){case"light":return Math.max(.5,e-.25);case"cover":return Math.min(2,e-.3);case"climate":return .6;case"media":return .9;case"binary":case"sensor":return 1.4;default:return 1.05}}var Jc=[],Gi=new Map,Eb=0,he=(t,e)=>`pack:${t}:${e}`,wt=t=>t.startsWith("pack:");function Os(t){Jc=t,Gi=new Map;for(let e of t)for(let n of e.items)Gi.set(he(e.id,n.id),n);Eb+=1}var Fr=()=>Jc;var Ab={};function G(t){if(!wt(t))return;let e=Gi.get(t);if(e)return e;let[,n,...r]=t.split(":"),i=Ab[n];return i?Gi.get(he(i,r.join(":"))):void 0}var Fb=.22;function qc(t,e,n,r){let i=Math.min(Fb,n/3);if(r<=i*2.4||Math.abs(r-n)<1e-6)return e*(r/n)+(t-e)*(r/n);let o=e*(r/n),s=t-e;return s<=i?o+s:s>=n-i?o+r-(n-s):o+i+(s-i)*(r-2*i)/(n-2*i)}function Ar(t,e,n,r,i){return[qc(t*r,n*r,r,i)/i,qc(e*r,n*r,r,i)/i]}var Yc=new WeakMap;function Qc(t,e,n,r){let[i,o,s]=t.size;if(t.vehicle||t.stretch||Math.abs(e-i)<1e-4&&Math.abs(n-o)<1e-4&&Math.abs(r-s)<1e-4)return t.parts;let l=`${e.toFixed(4)}|${n.toFixed(4)}|${r.toFixed(4)}`,a=Yc.get(t),c=a?.get(l);if(c)return c;let u=t.parts.map(d=>{if(d.shape==="sweep")return d;let[p,h]=Ar(d.x-d.w/2,d.x+d.w/2,-.5,i,e),[f,g]=Ar(d.z-d.d/2,d.z+d.d/2,-.5,o,n),[b,y]=Ar(d.y,d.y+d.h,0,s,r);if(d.rot)return{...d,x:(p+h)/2,z:(f+g)/2,w:d.w*i/e,d:d.d*o/n,y:b,h:y-b};let v={...d,x:(p+h)/2,z:(f+g)/2,w:h-p,d:g-f,y:b,h:y-b};if(d.shape==="loft"){let[w,x,k,M]=[d.tx??d.x,d.tz??d.z,d.tw??d.w,d.td??d.d],[E,T]=Ar(w-k/2,w+k/2,-.5,i,e),[F,L]=Ar(x-M/2,x+M/2,-.5,o,n);Object.assign(v,{tx:(E+T)/2,tz:(F+L)/2,tw:T-E,td:L-F})}return v});return a||Yc.set(t,a=new Map),a.size>32&&a.clear(),a.set(l,u),u}var Hs=t=>!!t?.parts.some(e=>e.move);var eu=t=>G(t)?.parts.find(e=>e.screen),Xc=.06;function tu(t){let e=G(t);if(!e)return!1;let[n,r,i]=e.size;return e.parts.filter(o=>o.screen).some(o=>{let[s,l]=[o.w*n,o.d*r,o.h*i].sort((a,c)=>c-a);return l>=Xc&&s>=Xc})}function dt(t){return nt[t]??G(t)?.size??[.6,.6,.8]}function zt(t){let e=G(t);return cu.has(t)||!!e?.electric||!!e?.light||!!e?.climate}var nu=t=>!!G(t)?.parts.some(e=>e.picture),Fn=t=>!!G(t)?.climate;function ru(t,e){return t.name[e.split("-")[0]]??t.name.en??Object.values(t.name)[0]??t.id}var Tb={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 iu(t,e){if(e.split("-")[0]==="de")return t.name;let n=/^nextfloor\.(.+)$/.exec(t.id)?.[1];return n&&Tb[n]||t.name}function Pt(t,e){return e.mount_y!=null?e.mount_y:Pb(t,e)+(zb(e)?0:au(t,e.x,e.z))}var zb=t=>t.type==="led_strip"||G(t.type)?.mount==="ceiling";function Pb(t,e){if(e.type==="lamp_wall")return ou;if(e.type==="led_strip")return Math.max(0,ht(t,e.x,e.z)-.04-Math.max(.02,e.h));let n=G(e.type);if(!n)return su(e);switch(n.mount){case"surface":return lu(t,e.x,e.z);case"wall":return n.wall_y??1;case"ceiling":return Math.max(0,Zi(t,e)-e.h);default:return 0}}function Ls(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 kt=["electricity","water","gas","heating","cooling"],uu=["condition","temperature","humidity","pressure","wind_speed","wind_gust_speed","wind_bearing","cloud_coverage","precipitation","precipitation_total","illuminance","uv_index","visibility","snow","fog","lightning"],du=["turn","slide","top"],hu=["always","active","no_power","never"],pu=1.3,qi=(t,e=new Date().toISOString().slice(0,10))=>!!t.due&&t.due<=e,fu=["gable","hip","halfhip","pyramid","mansard","pent","flat","parapet"],mu=["brick","round","wide","steel"],Yi=["navigate","more_info","service","fire_dom_event"];function Xi(t,e,n){return t?e?!!n.lock_plan:!!t.locked:!1}var gu=["rain","snow","fog","clouds","lightning","sky"],_u=["rain","snow","clouds","lightning","sky"],bu=["lawn","terrace","path","driveway","street","sidewalk","gravel","river","stream","pool","bed","wild","hedge","fence","pergola"],Cs={lawn:.012,terrace:.12,path:.02,driveway:.02,street:.02,sidewalk:.12,gravel:.018,river:.008,stream:.006,pool:-.25,bed:.15,wild:.03,hedge:1.2,fence:1,pergola:2.2};function Ns(t){return t==="hedge"||t==="fence"||t==="pergola"}var yu=["x","-x","z","-z"];function Db(t,e,n){let r=t.slope??0;if(!r||t.type==="pool")return 0;let i=t.slope_dir??"x",o=(c,u)=>i==="x"?c:i==="-x"?-c:i==="z"?u:-u,s=1/0,l=-1/0;for(let[c,u]of t.points){let d=o(c,u);s=Math.min(s,d),l=Math.max(l,d)}if(l-s<1e-6)return 0;let a=Math.min(1,Math.max(0,(o(e,n)-s)/(l-s)));return r*a}function Ib(t,e,n,r){return vu(t)+(e.offset??0)+Cs[e.type]-Db(e,n,r)}function vu(t){return t.elevation>.3?0:-.2}function wu(t,e,n){let r=(t.outdoor??[]).filter(o=>!Ns(o.type)&&o.type!=="pool"&&C([e,n],o.points)),i=[...r].reverse().find(o=>o.cut)??r[0];return i?Ib(t,i,e,n):vu(t)}var Bs=t=>t.cut??(t.type==="pool"||t.type==="river"||t.type==="stream"),ku=30,xu={meter:null,grid:null,grid_invert:!1,solar:null,battery:null,battery_invert:!1,battery_soc:null,consumption:null,tariff:null},$u=["wood","oak","tiles","carpet","stone","concrete"],Su={type:"none",pitch:35,overhang:.4},Ji="#d6cfc2",Qi="#e8e3da",Mu={wall_exterior:.24,wall_interior:.12,grid:.05,north:0,roof:{...Su}};function Dt(){return{version:1,floors:[],settings:{...Mu},energy:{...xu},presence:[]}}function We(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 Ob=2.75;function Ru(t,e){if(e!=null&&Number.isFinite(e))return Math.round(e*Ob*100)/100;let n=t.reduce((r,i)=>!r||i.elevation>r.elevation?i:r,null);return n?Math.round((n.elevation+n.height+.25)*100)/100:0}function Eu(t,e,n){let r=t.rooms.flatMap(l=>l.points.map(a=>a[0])),i=t.rooms.flatMap(l=>l.points.map(a=>a[1])),o=r.length?Math.ceil(Math.max(...r))+1:0,s=i.length?Math.floor(Math.min(...i)):0;return e.map((l,a)=>{let c=o+a%3*4.5,u=s+Math.floor(a/3)*3.5;return{id:n(),name:l.name,area_id:l.area_id,points:[[c,u],[c+4,u],[c+4,u+3],[c,u+3]],floor_material:"wood"}})}function Au(t,e,n,r){let i=t.rotation*Math.PI/180,o=Math.cos(i),s=Math.sin(i),[l,a]=e,c=t.x-l*(t.w/2)*o+a*(t.d/2)*s,u=t.z-l*(t.w/2)*s-a*(t.d/2)*o,d=n[0]-c,p=n[1]-u,h=y=>Math.max(.1,Math.round(y/r)*r),f=h((d*o+p*s)*l),g=h((-d*s+p*o)*a),b=y=>Math.round(y*1e3)/1e3;return{x:b(c+l*(f/2)*o-a*(g/2)*s),z:b(u+l*(f/2)*s+a*(g/2)*o),w:b(f),d:b(g)}}var eo=["lamp_ceiling","lamp_downlight","lamp_spot","lamp_panel","lamp_pendant","ceiling_fan","lamp_floor","lamp_table","lamp_wall","led_strip","lamp_uplight","lamp_bollard","lamp_garden","radiator","sofa","armchair","stool","coffee_table","tv_board","tv_wall","sideboard","shelf","plant","rug","table","table_round","chair","bench","corner_bench","bar_stool","kitchen","kitchen_wall","kitchen_tall","island","worktop","sink","stove","dishwasher","fridge","bed","bunk_bed","nightstand","wardrobe","dresser","bathtub","shower","wc","washbasin","washer","dryer","desk","office_chair","tall_cabinet","coat_rack","stairs","robot_vacuum","inverter","home_battery","wallbox","meter","grid_point","parking","fridge_smart","heating_manifold","buffer_tank","freshwater_station","stairwell"],Fu={lights:["lamp_ceiling","lamp_downlight","lamp_spot","lamp_panel","lamp_pendant","ceiling_fan","lamp_floor","lamp_uplight","lamp_table","lamp_wall","led_strip","lamp_bollard","lamp_garden"],living:["sofa","armchair","stool","coffee_table","tv_board","tv_wall","sideboard","shelf","plant","rug"],dining:["table","table_round","chair","bench","corner_bench","bar_stool"],kitchen:["kitchen","kitchen_wall","kitchen_tall","island","worktop","sink","stove","dishwasher","fridge"],sleeping:["bed","bunk_bed","nightstand","wardrobe","dresser"],bath:["bathtub","shower","wc","washbasin","washer","dryer"],work:["desk","worktop","office_chair","tall_cabinet","coat_rack","radiator","stairs","robot_vacuum","heating_manifold","buffer_tank","freshwater_station"],vehicles:["parking"]},Ke=["meter","inverter","home_battery","wallbox","grid_point"],Tu=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"]),ou=1.75;function to(t){return Vs.has(t.type)||["stairwell","parking"].includes(t.type)?!1:G(t.type)?.mount!=="ceiling"}function ue(t){return Tu.has(t)||!!G(t)?.light}var Hb=new Set(["table","table_round","coffee_table","desk","nightstand","sideboard","dresser","kitchen","island","worktop","tv_board","dishwasher","washer","dryer"]);function zu(t,e,n,r=0){let i=de(t.points),o=i.x1-i.x0-2*r,s=i.z1-i.z0-2*r,l=[];for(let a=0;aMath.round(s*1e3)/1e3,[i,o]={right:[1,0],down:[0,1],left:[-1,0],up:[0,-1]}[n];return[r(t[0]+i*e),r(t[1]+o*e)]}function su(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 Vs=new Set(["lamp_ceiling","lamp_downlight","lamp_spot","lamp_panel","lamp_pendant","ceiling_fan"]);function Pu(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 Ws=t=>t?.floor_offset&&Number.isFinite(t.floor_offset)?t.floor_offset:0;function au(t,e,n){let r=t.rooms.find(i=>i.points.length>=3&&i.floor_offset&&C([e,n],i.points));return Ws(r)}function ht(t,e,n){let r=t.rooms.find(i=>i.points.length>=3&&C([e,n],i.points));return r?.ceiling!=null&&r.ceiling>0?r.ceiling:t.height}var Zi=(t,e)=>e.ceiling_y!=null&&e.ceiling_y>0?e.ceiling_y:ht(t,e.x,e.z);function lu(t,e,n){let r=0;for(let i of t.furniture)!(Hb.has(i.type)||G(i.type)?.surface)||!C([e,n],Gs(i))||(r=Math.max(r,i.h));return r}var cu=new Set([...Tu,"radiator","robot_vacuum","inverter","home_battery","wallbox","meter","tv_board","tv_wall","desk","fridge","fridge_smart","stove","kitchen_tall","dishwasher","washer","dryer","kitchen","island","sink"]),nt={sofa:[2.2,.9,.82],armchair:[.85,.85,.8],table:[1.6,.9,.75],chair:[.46,.5,.9],bed:[1.6,2.05,.9],nightstand:[.45,.4,.5],wardrobe:[1.8,.6,2.1],shelf:[.9,.35,1.9],kitchen:[2.4,.62,.92],worktop:[1.2,.62,.91],inverter:[.5,.2,.65],home_battery:[.6,.25,1.1],wallbox:[.3,.15,.42],heating_manifold:[1.5,.35,1.1],buffer_tank:[.85,.85,1.85],freshwater_station:[.65,.28,.9],meter:[.55,.21,1.1],grid_point:[.4,.22,.6],fridge:[.6,.65,1.8],fridge_smart:[.91,.73,1.78],stairwell:[1,2.6,.02],stove:[.6,.62,.92],sink:[.9,.62,.92],bathtub:[1.7,.75,.58],shower:[.9,.9,2],wc:[.38,.6,.8],washbasin:[.6,.46,.85],desk:[1.4,.7,.75],tv_board:[1.8,.42,.5],plant:[.45,.45,1.1],rug:[2,1.4,.01],stairs:[1,3.2,2.75],stool:[.55,.55,.42],lamp_ceiling:[.4,.4,.08],lamp_downlight:[.1,.1,.02],lamp_spot:[.1,.1,.14],lamp_panel:[.6,.6,.03],lamp_uplight:[.35,.35,1.8],lamp_bollard:[.16,.16,.8],lamp_garden:[.12,.12,.3],radiator:[1,.1,.6],robot_vacuum:[.36,.5,.1],parking:[2.6,5.2,.02],lamp_pendant:[.4,.4,.8],ceiling_fan:[1.32,1.32,.32],lamp_floor:[.4,.4,1.7],lamp_table:[.28,.28,.45],lamp_wall:[.22,.12,.2],led_strip:[2,.04,.03],coffee_table:[1.1,.6,.42],tv_wall:[1.3,.08,.75],sideboard:[1.6,.45,.8],table_round:[1.1,1.1,.75],bench:[1.4,.45,.85],corner_bench:[2,1.6,.9],bar_stool:[.42,.42,.75],kitchen_wall:[.8,.35,.7],kitchen_tall:[.6,.62,2.1],island:[1.8,.9,.92],dishwasher:[.6,.62,.92],bunk_bed:[1,2.05,1.65],dresser:[1,.5,.9],washer:[.6,.6,.85],dryer:[.6,.6,.85],office_chair:[.65,.65,1.1],tall_cabinet:[.6,.6,2.1],coat_rack:[1,.35,1.9]};var Ks=["interior","front","front_glass","sidelight","sidelights","glass","sliding","passage"],js=["standard","bars","glass_wall"],no=new Set(["interior","front"]);function on(t,e){return t.type==="door"?t.style&&Ks.includes(t.style)?t.style:e?"front":"interior":t.style&&js.includes(t.style)?t.style:"standard"}function Du(t,e,n,r){if(e!=="sidelight"&&e!=="sidelights")return null;let i=e==="sidelights",o=t-.04,s=Math.min(1.05,Math.max(.6,o-(i?.6:.3))),l=(o-s)/(i?2:1),a=r.sidelight_width??l,c=i?r.sidelight_width2??r.sidelight_width??l:0;a=Math.max(.1,a),c=i?Math.max(.1,c):0;let u=o-.5;if(a+c>u){let p=Math.max(0,u)/(a+c);a*=p,c*=p}return i?{panels:[[.02,.02+a],[t-.02-c,t-.02]],x0:.02+a,x1:t-.02-c}:(n?!!r.sidelight_hinge:!r.sidelight_hinge)?{panels:[[.02,.02+a]],x0:.02+a,x1:t-.02}:{panels:[[t-.02-a,t-.02]],x0:.02,x1:t-.02-a}}function Us(t){return t==="front"||t==="front_glass"||t==="sidelight"||t==="sidelights"}var zn={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 Pn(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&&Us(t.style)?"front":e?"door_double":"door":t.sill<.1?e?"terrace_double":"terrace":e?"window_double":"window"}function Oe(t){t.energy={...xu,...t.energy??{}},t.presence=t.presence??[],t.version=1,t.settings={...Mu,...t.settings,roof:{...Su,...t.settings?.roof??{}}},t.floors.forEach((e,n)=>{let r=We(e.id,e.name??`Floor ${n+1}`,e.elevation??n*2.8);for(let i of Object.keys(r))e[i]===void 0&&(e[i]=r[i])});for(let e of t.floors){e.outdoor=e.outdoor??[],e.walls=e.walls??[],e.rooms=e.rooms.map(r=>({...r,name:r.name??"",area_id:r.area_id??null,floor_material:r.floor_material??"wood",panel:r.panel??[]})),e.ha_floor=e.ha_floor??null,e.placements=e.placements.map(r=>({...r,mount:r.mount??null,rotation:r.rotation??0})),e.furniture=e.furniture.map(r=>({...r,entity:r.entity??null,power:r.power??null}));let n=e.placements.filter(r=>r.entity_id.startsWith("light."));if(n.length){let r={ceiling:"lamp_ceiling",floor:"lamp_floor",table:"lamp_table",wall:"lamp_wall"};for(let i of n){let o=r[i.mount??"ceiling"],[s,l,a]=nt[o],c=`lamp_${i.entity_id.slice(6).replace(/[^A-Za-z0-9_\-.]/g,"_")}`.slice(0,54),u=c,d=1;for(;e.furniture.some(p=>p.id===u);)u=`${c}_${d++}`;e.furniture.push({id:u,type:o,x:i.x,z:i.z,rotation:0,w:s,d:l,h:a,variant:null,entity:i.entity_id,power:null,animations_enabled:i.animations_enabled,effect_animations:structuredClone(i.effect_animations)})}e.placements=e.placements.filter(i=>!i.entity_id.startsWith("light."))}e.openings=e.openings.map(r=>({...r,type:["door","window","garage"].includes(r.type)?r.type:"door",edge:Number.isInteger(r.edge)?r.edge:0,offset:Number.isFinite(r.offset)?r.offset:.5,width:Number.isFinite(r.width)&&r.width>0?r.width:r.type==="garage"?2.5:r.type==="window"?1.2:.9,height:Number.isFinite(r.height)&&r.height>0?r.height:r.type==="window"?1.3:r.type==="garage"?2.1:2.05,sill:Number.isFinite(r.sill)?r.sill:r.type==="window"?.9:0,hinge:r.hinge??"left",leaves:r.leaves??1,swing:r.swing??"in",style:r.style??null,cover:r.cover??null,contact:r.contact??null,contact2:r.contact2??null,tilt:r.tilt??null}))}return Lb(t),t}function Lb(t){let e=(n,r)=>{let i=new Set;for(let o of n)(typeof o.id!="string"||!o.id||i.has(o.id))&&(o.id=I(r)),i.add(o.id)};e(t.floors,"floor");for(let n of t.floors){for(let r of n.rooms)(typeof r.id!="string"||!r.id)&&(r.id=I("room"));e(n.openings,"op"),e(n.furniture,"furn"),e(n.outdoor,"out")}}function I(t){return`${t}_${Math.random().toString(36).slice(2,10)}`}function _e(t){let e=0;for(let n=0;no+s[0],0)/i,t.reduce((o,s)=>o+s[1],0)/i]}let n=0,r=0;for(let i=0;i1e-6&&Math.abs(r-o)>1e-6)return!1}return!0}function de(t){let e=1/0,n=1/0,r=-1/0,i=-1/0;for(let[o,s]of t)e=Math.min(e,o),n=Math.min(n,s),r=Math.max(r,o),i=Math.max(i,s);return{x0:e,z0:n,x1:r,z1:i}}function Gs(t){let e=t.rotation*Math.PI/180,n=Math.cos(e),r=Math.sin(e),i=t.w/2,o=t.d/2;return[[-i,-o],[i,-o],[i,o],[-i,o]].map(([s,l])=>[t.x+s*n-l*r,t.z+s*r+l*n])}function C(t,e){let n=!1;for(let r=0,i=e.length-1;rt[1]!=a>t[1]&&t[0]<(l-o)*(t[1]-s)/(a-s)+o&&(n=!n)}return n}var ro={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 Zs=t=>t.trim().replace(/^\/local\/www\//i,"/local/"),qs=t=>/^(https:\/\/|\/local\/|\/hacsfiles\/)\S+\.m?js(\?\S*)?$/i.test(t.trim());var Nb=globalThis,Ou=Nb.__nextfloorPluginStore??={plugins:new Map,listeners:new Set},Ys=Ou.plugins,Iu=Ou.listeners;var Bb=5;function Hu(t,e){t.errors.lengthIu.delete(t)}var Xs=()=>[...Ys.values()].map(t=>t.status),Lu=()=>[...Ys.values()].flatMap(t=>Object.keys(t.plugin.lightAnimations??{}));function*oo(t,e){for(let{plugin:n,status:r}of Ys.values())for(let i of n.devices??[]){let o=!1;try{o=i.match(t,e)}catch(s){Hu(r,s)}o&&(yield{device:i,status:r})}}function so(t,e){for(let{device:n}of oo(t,e))return n.kind??"sensor";return null}function Cu(t,e){let n=t.states[e];if(!n)return null;let r=Vb({hass:t,entityId:e,state:n})?.icon?.trim();return r&&/^mdi:[a-z0-9-]+$/i.test(r)?r:null}function Vb(t){let e=null;for(let{device:n,status:r}of oo(t.entityId,t.state))if(n.marker)try{let i=n.marker(t);if(!i)continue;e={...e??{}},typeof i.icon=="string"&&i.icon&&(e.icon=i.icon),typeof i.text=="string"&&(e.text=i.text.slice(0,60)),typeof i.active=="boolean"&&(e.active=i.active)}catch(i){Hu(r,i)}return e}function ao(t,e){return t?typeof t=="string"?t:t[e]??t[e.split("-")[0]]??t.en??Object.values(t)[0]??"":""}function Nu(t,e){let n=[];for(let{device:r,status:i}of oo(t,e))r.settings?.length&&n.push({pluginId:i.id,name:i.name,settings:r.settings});return n}function Bu(t,e){let n={};for(let r of t??[]){let i=e?.[r.key],o=r.type==="number"?typeof i=="number"&&Number.isFinite(i):r.type==="boolean"?typeof i=="boolean":typeof i=="string"&&(r.options??[]).some(([s])=>s===i);n[r.key]=o?i:r.default}return n}function Vu(t,e){for(let{device:n}of oo(t,e))if(n.floorWedge)return!0;return!1}var Wb=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"]),Kb=new Set(["m\xB3","m3","L","l","kWh","Wh","MWh","lx"]),jb=new Set(["door","window","opening","garage_door","motion","occupancy","presence","smoke","moisture","gas","carbon_monoxide"]),Ub=new Set(["battery","signal_strength","timestamp","date","duration","data_rate","data_size","frequency","enum"]);function It(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 Ku=(t,e)=>{let n=t.entities?.[e];return!!(n?.hidden||n?.entity_category)},je=(t,e)=>Q(e)??so(e,t.states[e]);function Wu(t,e){let n=t.states[e];if(!n||Ku(t,e))return!1;if(so(e,n)!==null)return!0;let r=Q(e);if(!r)return!1;let i=n.attributes.device_class;return e.startsWith("event.")?!i||i==="button"||i==="doorbell":r==="sensor"?i?Wb.has(i):Kb.has(String(n.attributes.unit_of_measurement??"")):r==="binary"?i?jb.has(i):!!t.entities?.[e]?.area_id:!0}function Gb(t,e){let n=t.states[e];return Q(e)!=="sensor"||!n?.attributes.unit_of_measurement||Ku(t,e)||Ub.has(String(n.attributes.device_class??""))?!1:Number.isFinite(Number(n.state))||Ie(n)}var co=(t,e)=>e.startsWith("sensor.")&&t.states[e]?.attributes.device_class==="power",Js=null;io(()=>Js=null);function Qs(t,e){let n=t.get(e);return n||t.set(e,n=[]),n}function Zb(t){let e=new Map,n=new Map,r=new Map,i=new Map,o=[],s=u=>{(Wu(t,u)||Gb(t,u))&&Tt(je(t,u))&&o.push(u)};for(let[u,d]of Object.entries(t.entities??{})){let p=d.device_id;p&&d.area_id&&(i.get(p)??i.set(p,new Set).get(p)).add(d.area_id),p&&co(t,u)&&Qs(n,p).push(u),p&&!d.hidden&&!d.entity_category&&(r.get(p)??r.set(p,new Set).get(p)).add(Ds(u));let h=It(t,u);h===null?s(u):Wu(t,u)&&Qs(e,h).push(u)}if(t.entities)for(let u of Object.keys(t.states))t.entities[u]||s(u);let l=Is.indexOf("binary")-.5,a=u=>{let d=Q(u),p=d?Is.indexOf(d):l;return p>l&&so(u,t.states[u])!==null?l:p};o.sort((u,d)=>a(u)-a(d)||B(t,u).localeCompare(B(t,d)));for(let[u,d]of e){let p=t.areas?.[u]?.name;d.sort((h,f)=>a(h)-a(f)||B(t,h,p).localeCompare(B(t,f,p)))}let c=new Set;for(let[u,d]of i)d.size>1&&c.add(u);return{entities:t.entities,devices:t.devices,states:t.states,stateCount:Object.keys(t.states).length,byArea:e,powerByDevice:n,withoutArea:o,domainsByDevice:r,hubs:c}}function In(t){let e=Js;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:Js=Zb(t)}function ye(t,e){let n=lo(t,e.area_id);return e.sub_areas?.length?[...new Set([...n,...e.sub_areas.flatMap(r=>lo(t,r))])]:n}function lo(t,e){return!e||!t.entities?[]:In(t).byArea.get(e)??[]}function ju(t,e){if(!t.entities)return[];let n=[];for(let[r,i]of In(t).byArea){let o=i.filter(s=>Tt(je(t,s)));r!==e&&o.length>0&&n.push({areaId:r,name:t.areas?.[r]?.name??r,ids:o})}return n.sort((r,i)=>r.name.localeCompare(i.name))}var Uu=t=>t.entities?In(t).withoutArea:[],ea=(t,e)=>!!t.entities&&In(t).hubs.has(e),uo=(t,e)=>t.entities?In(t).powerByDevice.get(e)??[]:[];function On(t,e){let n=new Map;for(let i of e)Qs(n,t.entities?.[i]?.device_id??`entity:${i}`).push(i);let r=new Map(e.map((i,o)=>[i,o]));return[...n.values()].map(i=>{let o=i.find(s=>!t.entities?.[s]?.name)??i[0];return{primary:o,others:i.filter(s=>s!==o)}}).sort((i,o)=>r.get(i.primary)-r.get(o.primary))}var ho=(t,e)=>On(t,e).map(n=>n.primary),qb={temperature:"temperature",humidity:"humidity",co2:"carbon_dioxide",illuminance:"illuminance"};function ta(t,e,n,r=!1){let i=t.states[e]?.attributes;if(!i)return!1;let o=(i.symcon_variable_type===1||i.symcon_variable_type===2)&&typeof i.symcon_id=="number";if(typeof i.symcon_id=="number"&&!o||!o&&!/^(sensor|input_number|number)\./.test(e))return!1;if(r&&o)return!0;let s=String(i.unit_of_measurement??"").replace(/\s/g,"").toLowerCase();return n==="temperature"&&["\xB0c","\xB0f","\u2103","\u2109","k"].includes(s)||n==="humidity"&&!i.device_class&&["%","%rh","%r.h.","%rf","%r.f."].includes(s)||n==="co2"&&s==="ppm"&&/co[₂2]/i.test(String(i.friendly_name??""))||n==="illuminance"&&["lx","lux"].includes(s)?!0:i.device_class===qb[n]}var Yb=new Set(["climate","water_heater","switch","button","camera","media_player","vacuum","light","fan","lawn_mower"]),Xb=["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"],Jb=new RegExp(`(${Xb.join("|")})`,"i");function na(t,e){let n=t.entities?.[e]?.device_id,r=n&&!ea(t,n)?In(t).domainsByDevice.get(n):void 0;return r&&[...r].some(i=>Yb.has(i))?!1:!Jb.test(`${e} ${t.states[e]?.attributes.friendly_name??""}`)}function Gu(t,e,n,r){let i=n.climate?.[r];if(i==="none")return[];if(i)return[i].flat().filter(c=>t.states[c]);let o=(e?.placements??[]).filter(c=>c.entity_id.startsWith("sensor.")),s=o.filter(c=>C([c.x,c.z],n.points)).map(c=>c.entity_id),l=new Set(o.filter(c=>!C([c.x,c.z],n.points)).map(c=>c.entity_id));return[...new Set([...ye(t,n).filter(c=>!l.has(c)),...s])].filter(c=>c.startsWith("sensor.")&&ta(t,c,r)&&na(t,c))}function Zu(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 po(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 fo(t,e){let n=e?t.states[e]:void 0;if(!n||Ie(n))return null;let r=n.attributes;if(r.nf_cover_control&&typeof r.current_position=="number")return r.current_position;let i=Zu(n);if(i!==null)return i;if(typeof r.current_position=="number")return Math.max(0,Math.min(100,r.current_position));if(!n.state.trim())return null;let o=Number(n.state);if(!Number.isFinite(o))return null;let s=r.unit_of_measurement==="%"||o>1||o<0?o:o*100;return Math.max(0,Math.min(100,s))}var Qb=new Set([void 0,"shutter","blind","awning","shade","curtain","window"]),ey=new Set(["garage","gate"]),ty=new Set(["window","opening"]);function Tr(t,e,n=!1){let r=new Map;return t.forEach((i,o)=>{let s=n&&e.length===1?e[0]:e[o];s&&r.set(i.id,s)}),r}var qu=(t,e)=>t==="none"?null:t??e??null,Ot=t=>t&&t!=="none"?t:null;function Ht(t,e){let n=new Map;for(let r of e)for(let i of r.rooms){let o=r.openings.filter(g=>g.room_id===i.id).sort((g,b)=>g.edge-b.edge||g.offset-b.offset);if(o.length===0)continue;let s=ye(t,i),l=g=>t.states[g]?.attributes.device_class,a=g=>s.filter(b=>Q(b)==="binary"&&g(l(b)??"")),c=g=>o.filter(b=>b.type===g),u=Tr(c("window"),s.filter(g=>Q(g)==="cover"&&Qb.has(l(g))),!0),d=Tr(c("window"),a(g=>ty.has(g))),p=Tr(c("door"),a(g=>g==="door")),h=Tr(c("garage"),s.filter(g=>Q(g)==="cover"&&ey.has(l(g)??""))),f=Tr(c("garage"),a(g=>g==="garage_door"));for(let g of o){let b=g.type==="window"?u:g.type==="garage"?h:null,y=g.type==="window"?d:g.type==="garage"?f:p,v=g.leaves===2;n.set(g.id,{cover:qu(g.cover,b?.get(g.id)),contact:g.sensor==="handle"&&g.contact==null?null:qu(g.contact,y.get(g.id)),tilt:g.tilt==="none"?null:g.tilt,contact2:v?Ot(g.contact2):null,tilt2:v?Ot(g.tilt2):null,position:Ot(g.position),positionInverted:!!g.position_inverted,tiltAngle:Ot(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"?Ot(g.lock):null,cover2:g.type==="garage"?null:Ot(g.cover2),coverTilt:Ot(g.cover_tilt),cover2Tilt:Ot(g.cover2_tilt),coverInverted:!!g.cover_inverted,coverTiltInverted:!!g.cover_tilt_inverted,cover2Inverted:!!g.cover2_inverted,cover2TiltInverted:!!g.cover2_tilt_inverted})}}return n}var ny=[[/^(tilted|tilt|gekippt|kipp)/i,"tilted"],[/^(open|opened|offen|geöffnet|on)$/i,"open"],[/^(closed|close|geschlossen|zu|off)$/i,"closed"]];function ra(t){if(!t||Ie(t))return null;let e=t.attributes.window_state;for(let n of[typeof e=="string"?e:"",t.state]){let r=n.trim(),i=r&&ny.find(([o])=>o.test(r));if(i)return i[1]}return null}var Yu=new WeakMap,Xu=new WeakMap;function Ju(t,e){let n=Xu.get(t)??t,r=Yu.get(n)??new WeakMap;Yu.set(n,r);let i=r.get(e);if(i)return i;let o=new Map;for(let a of e)for(let c of a.placements)c.entity_id.startsWith("cover.")&&o.set(c.entity_id,{tilt:c.cover_tilt==="none"?null:c.cover_tilt,position:c.position});for(let a of Ht(n,e).values())a.cover&&!o.has(a.cover)&&o.set(a.cover,{tilt:a.coverTilt,position:a.position}),a.cover2&&!o.has(a.cover2)&&o.set(a.cover2,{tilt:a.cover2Tilt});let s={...n.states};for(let[a,c]of o){let u=n.states[a];if(!u)continue;let d={...u.attributes,nf_cover_control:!0},p=fo(n,c.position);p===null&&(p=typeof u.attributes.current_position=="number"?u.attributes.current_position:null),p!==null&&(d.current_position=p);let h=c.tilt?n.states[c.tilt]:u,f=typeof h?.attributes.current_tilt_position=="number"?h.attributes.current_tilt_position:c.tilt?fo(n,c.tilt):null;f!==null&&(d.current_tilt_position=f,d.supported_features=Number(d.supported_features??0)|128);let g=u.state;typeof d.current_position=="number"&&g!=="unavailable"&&g!=="unknown"&&g!=="opening"&&g!=="closing"&&(g=d.current_position>0?"open":"closed"),s[a]={...u,state:g,attributes:d}}let l={...n,states:s,callService:async(a,c,u={})=>{if(a!=="cover")return n.callService(a,c,u);let d=Array.isArray(u.entity_id)?u.entity_id:[u.entity_id],p=async h=>{let f=typeof h=="string"?o.get(h):void 0;if(!f)return n.callService(a,c,{...u,entity_id:h});let g={...u,entity_id:h},b=c;(b==="toggle"||b==="toggle_cover")&&(b=s[String(h)]?.state==="closed"?"open_cover":"close_cover");let y=b.includes("tilt");y&&f.tilt&&(g.entity_id=f.tilt);let v=f.tilt?n.states[f.tilt]:void 0;return y&&f.tilt&&!v?.attributes.symcon_id&&typeof v?.attributes.current_tilt_position!="number"&&(b==="set_cover_tilt_position"?(b="set_cover_position",g.position=g.tilt_position,delete g.tilt_position):b==="open_cover_tilt"?b="open_cover":b==="close_cover_tilt"&&(b="close_cover")),n.callService(a,b,g)};return Array.isArray(u.entity_id)?Promise.all(d.map(p)):p(d[0])}};return Xu.set(l,n),r.set(e,l),l}var X=t=>t?.symconObjects!==void 0;function He(t,e,n=[0,1,2,3]){let r=t?.states[e]?.attributes;return!!r?.symcon_id&&!r.symcon_source_entity&&n.includes(Number(r.symcon_variable_type))}function sn(t){return!t||t.state==="unknown"||t.state==="unavailable"?null:t.attributes.symcon_value??t.attributes.symcon_numeric_value??t.state}function Lt(t){let e=sn(t);if(e===null||typeof e=="boolean"||e==="")return null;let n=Number(e);return Number.isFinite(n)?n:null}function zr(t){let e=sn(t);if(e===null)return null;if(typeof e=="boolean")return e;if(typeof e=="number")return e>0;let n=String(e).trim().toLowerCase();if(["on","true","1","home","open","an","ein","ja","regen","rain","wet","nass"].includes(n))return!0;if(["off","false","0","not_home","closed","aus","nein","trocken","dry"].includes(n))return!1;let r=Number(n);return n!==""&&Number.isFinite(r)?r>0:null}function ia(t){return sn(t)===null?"\u2013":String(t?.attributes.symcon_formatted??sn(t))}function Qu(t,e){switch(e){case"m/s":return t*3.6;case"mph":return t*1.609;case"kn":return t*1.852;case"ft/s":return t*1.097;default:return t}}var ed="weather.nextfloor_symcon",nd={condition:"Wetterzustand",temperature:"Au\xDFentemperatur",humidity:"Au\xDFenluftfeuchte",pressure:"Luftdruck",wind_speed:"Windgeschwindigkeit",wind_gust_speed:"Windb\xF6en",wind_bearing:"Windrichtung",cloud_coverage:"Bew\xF6lkung",precipitation:"Niederschlagsrate",precipitation_total:"Niederschlagsmenge",illuminance:"Au\xDFenhelligkeit",uv_index:"UV-Index",visibility:"Sichtweite",snow:"Schnee",fog:"Nebel",lightning:"Gewitter"},td=new WeakMap;function ry(t){let e=t.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").trim();return["sunny","clear-night","partlycloudy","cloudy","fog","rainy","pouring","lightning-rainy","lightning","hail","snowy","snowy-rainy","windy","windy-variant"].includes(e)?e:/kein regen|trocken|wolkenlos|klar|sonnig/.test(e)?"sunny":/gewitter|blitz/.test(e)?"lightning-rainy":/schneeregen/.test(e)?"snowy-rainy":/schnee/.test(e)?"snowy":/hagel/.test(e)?"hail":/starkregen/.test(e)?"pouring":/regen|niesel/.test(e)?"rainy":/nebel/.test(e)?"fog":/teil.*wolk|heiter|leicht.*wolk/.test(e)?"partlycloudy":/wolk|bedeckt/.test(e)?"cloudy":/wind|sturm/.test(e)?"windy":null}function rd(t,e){if(!X(t))return t;let n=e.weather_variables??{};if(!e.rain_sensor&&!Object.values(n).some(h=>h&&h!=="none"))return t;let r=td.get(t)??new WeakMap;td.set(t,r);let i=r.get(e);if(i)return i;let o={friendly_name:"Wetter",nf_symcon_weather:!0},s=h=>n[h]&&n[h]!=="none"?t.states[n[h]]:void 0;for(let h of["temperature","humidity","pressure","cloud_coverage","precipitation","precipitation_total","illuminance","uv_index","visibility"]){let f=s(h),g=Lt(f);g!==null&&(o[h]=h==="cloud_coverage"&&f?.attributes.symcon_max===1?g*100:g),f?.attributes.unit_of_measurement&&(o[`${h}_unit`]=f.attributes.unit_of_measurement)}for(let h of["wind_speed","wind_gust_speed"]){let f=s(h),g=Lt(f);g!==null&&(o[h]=Qu(g,f?.attributes.unit_of_measurement))}o.wind_speed_unit="km/h";let l=sn(s("wind_bearing"));l!==null&&(o.wind_bearing=l);let a=ry(ia(s("condition"))),c=e.rain_sensor?t.states[e.rain_sensor]:void 0,u=zr(c);u!==null&&e.rain_sensor_inverted&&(u=!u),u===null&&typeof o.precipitation=="number"&&(u=o.precipitation>0),zr(s("lightning"))?a=u?"lightning-rainy":"lightning":zr(s("snow"))?a=u?"snowy-rainy":"snowy":zr(s("fog"))?a="fog":u===!0?a=Number(o.precipitation??0)>=8?"pouring":"rainy":u===!1&&a&&/rain|pouring/.test(a)&&(a=null),!a&&typeof o.cloud_coverage=="number"&&(a=o.cloud_coverage>70?"cloudy":o.cloud_coverage>20?"partlycloudy":"sunny"),!a&&u===!1&&(a="sunny");let d={entity_id:ed,state:a??"unknown",attributes:o},p={...t,states:{...t.states,[ed]:d}};return r.set(e,p),p}var Hn={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},an=t=>(...e)=>({_$litDirective$:t,values:e}),Ct=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 Pr=class extends Ct{constructor(e){if(super(e),this.it=_,e.type!==Hn.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===_||e==null)return this._t=void 0,this.it=e;if(e===tt)return e;if(typeof e!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(e===this.it)return this._t;this.it=e;let n=[e];return n.raw=n,this._t={_$litType$:this.constructor.resultType,strings:n,values:[]}}};Pr.directiveName="unsafeHTML",Pr.resultType=1;var id=an(Pr);var od=/\b(tv|fernseh|television|fire ?tv|apple ?tv|chromecast|shield)/i,sd=/(kühl|fridge|gefrier|freezer)/i,ad=/(spülmaschine|geschirrspül|dishwasher)/i,iy=/(kochfeld|herd|induktion|cooktop)/i,oy={robot_vacuum:/(saug|vacuum|robo|roomba|roborock|dreame|ecovacs|deebot)/i,tv_board:od,tv_wall:od,desk:/\b(pc|computer|rechner|desktop|monitor|workstation)/i,fridge:sd,fridge_smart:sd,stove:/(herd|kochfeld|cooktop|stove|induktion)/i,kitchen_tall:/(backofen|oven|ofen)/i,dishwasher:ad,washer:/(waschmaschine|washer|washing)/i,dryer:/(trockner|dryer)/i,kitchen:/(kaffee|coffee|wasserkocher|kettle)/i,island:iy,sink:ad,radiator:/(heiz|radiator|thermostat|climate|hk|trv)/i},ld={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},cd=new Set(["tv_board","tv_wall"]);var Ln=t=>cd.has(t)||!!eu(t),mo=t=>!!G(t)?.electric&&/speaker|multiroom|soundbar/.test(t.split(":").pop()??t),Ir=t=>Ln(t)||t==="desk"||t==="fridge_smart",sy=t=>!!t&&t!=="none";function ay(t,e){if(co(t,e))return e;let n=t.entities?.[e]?.device_id;return n?uo(t,n).find(r=>r!==e)??null:null}var ly=(t,e,n)=>t.rooms.find(r=>r.points.length>=3&&C([e,n],r.points));function Dr(t,e,n,r){return t.find(i=>e?.test(n(i)))??(r?t[0]??null:null)}function Me(t,e){let n=new Map;for(let r of e){let i=new Set([...r.furniture.flatMap(o=>[o.entity,o.power,o.fan_entity]),...r.placements.map(o=>o.entity_id)].filter(sy));for(let o of r.furniture){let s=o.type in ld,l=Fn(o.type),a=s?ld[o.type]:oy[o.type];if(!a&&!l&&!mo(o.type)&&o.entity==null&&o.power==null)continue;let c=ly(r,o.x,o.z),u=(c?ho(t,ye(t,c)):[]).filter(b=>!i.has(b)),d=b=>`${b} ${B(t,b)}`,p=b=>u.filter(y=>Q(y)===b),h=o.entity==="none"?null:o.entity??null;if(o.entity==null){if(o.type==="ceiling_fan"){let b=(c?ye(t,c):[]).filter(v=>!i.has(v)),y=new Set(b.filter(v=>Q(v)==="fan").map(v=>t.entities?.[v]?.device_id).filter(Boolean));h=b.find(v=>Q(v)==="light"&&y.has(t.entities?.[v]?.device_id))??Dr(p("light"),a,d,!1)}else if(s)h=Dr(p("light"),a,d,!0);else if(o.type==="robot_vacuum"){let b=c?.area_id??null;h=Object.keys(t.entities??{}).find(y=>y.startsWith("vacuum.")&&!i.has(y)&&It(t,y)===b)??null}else if(o.type==="radiator"||l)h=Dr(p("climate"),a,d,!0);else if(Ln(o.type)){let b=p("media");h=b.find(y=>t.states[y]?.attributes.device_class==="tv")??Dr(b,a,d,cd.has(o.type))}else if(mo(o.type)){let b=p("media").filter(y=>t.states[y]?.attributes.device_class!=="tv");h=Dr(b,a,d,!1)??(b.length===1?b[0]:null)}else a&&(h=u.find(b=>["switch","media","fan"].includes(Q(b)??"")&&a.test(d(b)))??null);h&&i.add(h)}let f=o.power==="none"?null:o.power??null;o.power==null&&(f=h?ay(t,h):null,!f&&a&&c&&!s&&(f=ye(t,c).find(b=>co(t,b)&&!i.has(b)&&a.test(d(b)))??null),f&&i.add(f));let g=null;if(o.type==="ceiling_fan"&&(g=o.fan_entity==="none"?null:o.fan_entity??null,o.fan_entity==null)){let b=(c?ye(t,c):[]).filter(v=>Q(v)==="fan"&&!i.has(v)),y=h?t.entities?.[h]?.device_id:void 0;g=(y?b.find(v=>t.entities?.[v]?.device_id===y):void 0)??b[0]??null,g&&i.add(g)}(h||f||g)&&n.set(o.id,{entity:h,power:f,...o.type==="ceiling_fan"?{fan:g}:{}})}}return n}var ud=t=>t==="fridge"||t==="fridge_smart"||/(fridge|freezer|kuehl|gefrier|chest_freezer)/.test(t.slice(t.lastIndexOf(":")+1));function dd(t,e,n=[]){let r=[];for(let i of e){let o=(l,a)=>i.rooms.some(c=>c.points.length>=3&&C([l,a],c.points)),s=Me(t,[i]);r.push(...i.placements.filter(l=>l.outside||!o(l.x,l.z)).map(l=>l.entity_id)),r.push(...i.furniture.filter(l=>!o(l.x,l.z)).flatMap(l=>[s.get(l.id)?.entity,s.get(l.id)?.power]));for(let l of i.outdoor??[])l.area_id&&r.push(...ho(t,lo(t,l.area_id))),r.push(l.pump_entity,l.temp_entity)}return[...new Set(r.filter(i=>!!i&&!!t.states[i]&&!n.includes(i)))]}function cy(t,e){return Math.min(...e.map((n,r)=>{let i=e[(r+1)%e.length],[o,s]=[i[0]-n[0],i[1]-n[1]],l=Math.min(1,Math.max(0,((t[0]-n[0])*o+(t[1]-n[1])*s)/(o*o+s*s||1)));return Math.hypot(t[0]-n[0]-o*l,t[1]-n[1]-s*l)}))}function pd(t,e,n=[]){let r=t.points;if(r.length<3||e.length===0)return[];let i=r.map(y=>y[0]),o=r.map(y=>y[1]),[s,l,a,c]=[Math.min(...i),Math.max(...i),Math.min(...o),Math.max(...o)],u=Math.min(l-s,c-a),d=Math.max(.1,Math.min(.25,u/8)),p=Math.min(.35,u/5),h=Math.min(.7,u/4),f=be(r),g=[];for(let y=s+d/2;y=p&&g.push({at:w,wallDistance:x})}g.length===0&&g.push({at:f,wallDistance:0});let b=[...n];return e.map(y=>{let v=Q(y)==="light",w=g[0].at,x=-1/0;for(let{at:M,wallDistance:E}of g){let T=b.length?Math.min(...b.map(P=>Math.hypot(M[0]-P[0],M[1]-P[1]))):3,F=Math.hypot(M[0]-f[0],M[1]-f[1]),L=Math.min(T,3)*2;Fx+1e-9&&(x=L,w=M)}let k=[Math.round(w[0]*100)/100,Math.round(w[1]*100)/100];return b.push(k),{entity_id:y,x:k[0],z:k[1],y:null,mount:null}})}var hd=/(^|_)(current_room|current_segment|aktueller_raum|current_area)($|_)/;function fd(t,e,n){if(n==="none")return null;if(n)return n;let r=e?t.entities?.[e]?.device_id:null;return!r||!t.entities?null:Object.values(t.entities).find(o=>o.device_id===r&&o.entity_id.startsWith("sensor.")&&(hd.test(o.translation_key??"")||hd.test(o.entity_id.split(".")[1])))?.entity_id??null}var me=t=>/^(sensor|input_number|number)\./.test(t),go=t=>/^(binary_sensor|input_boolean)\./.test(t);function Cn(t,e){if(!me(e))return!1;let n=t?.states[e]?.attributes;return n?.device_class==="power"||n?.unit_of_measurement==="W"||n?.unit_of_measurement==="kW"}function uy(t,e){let n=t?.entities?.[e],r=n?.area_id??(n?.device_id?t?.devices?.[n.device_id]?.area_id:null);return r?t?.areas?.[r]?.name:void 0}function O(t,e){return Object.keys(t?.states??{}).filter(e).map(n=>{let r=uy(t,n),i=t?.states[n],o=typeof i?.attributes.symcon_path=="string"?i.attributes.symcon_path:void 0,s={id:n,label:r?`${B(t,n)} \xB7 ${r}`:B(t,n)};return o&&(s.detail=`Objektbaum: ${o}`),typeof i?.attributes.symcon_source_entity=="string"&&(s.sourceEntity=i.attributes.symcon_source_entity),s}).sort((n,r)=>n.label.localeCompare(r.label))}function md(t,e,n){return e.unsupported?[]:O(t,r=>He(t,r,e.types)&&!e.excluded?.(r)).map(r=>{if(!e.role)return r;let i=t.states[r.id],o=`${e.role}.${i.attributes.symcon_id}`,s=n?t.states[n]:void 0,l=n&&(n===r.id||s?.attributes.symcon_source_entity===r.id)?n:t.states[o]?o:r.id;return l===r.id?r:{...r,id:l,sourceEntity:r.id}})}function _o(t,e){return t.power&&t.power!=="none"?t.power:e.get(t.id)?.power??null}var ve=ee` :host { --nf-text: var(--primary-text-color, #e1e1e1); --nf-muted: var(--secondary-text-color, #9b9b9b); --nf-accent: var(--primary-color, #03a9f4); --nf-accent-text: var(--text-primary-color, #ffffff); --nf-surface: var(--ha-card-background, var(--card-background-color, #1c1c1c)); --nf-bg: var(--primary-background-color, #111111); --nf-bg2: var(--secondary-background-color, #1c1c1c); /* floating bars and cards over the 3D view: the card colour, a little see-through */ --nf-chrome: color-mix(in srgb, var(--nf-surface) var(--nf-chrome-mix, 84%), transparent); --nf-chrome-solid: var(--nf-surface); --nf-line: var(--divider-color, rgba(255, 255, 255, 0.12)); /* quiet fills for buttons and fields, and the tonal accent of an active control */ --nf-fill: color-mix(in srgb, var(--nf-text) 7%, transparent); --nf-fill-strong: color-mix(in srgb, var(--nf-text) 13%, transparent); --nf-tonal: color-mix(in srgb, var(--nf-accent) 20%, transparent); --nf-soft: var(--info-color, #4a90e2); --nf-warm: var(--state-light-active-color, #ffa726); --nf-danger: var(--error-color, #db4437); --nf-good: var(--success-color, #43a047); --nf-radius: var(--ha-card-border-radius, 12px); --nf-shadow: var(--ha-card-box-shadow, 0 1px 2px rgba(0, 0, 0, 0.18), 0 6px 20px rgba(0, 0, 0, 0.2)); --nf-font: var(--primary-font-family, Roboto, "Noto Sans", system-ui, -apple-system, "Segoe UI", sans-serif); --nf-title-font: var(--nf-font); font-family: var(--nf-font); color: var(--nf-text); } `,cS=ee` :host([readable]) { --secondary-text-color: var(--primary-text-color, #e1e1e1); --divider-color: color-mix(in srgb, var(--primary-text-color, #e1e1e1) 40%, transparent); --nf-chrome-mix: 97%; } :host([readable]) nf-room-panel, :host([readable]) .nf-nav, :host([readable]) .nf-overlay { zoom: 1.2; } `,pt=ee` /* a group of switches: one rounded pill, the active one tinted with the accent */ .nf-seg { display: inline-flex; padding: 4px; gap: 2px; border-radius: 999px; background: var(--nf-chrome); box-shadow: var(--nf-shadow); backdrop-filter: blur(10px); } .nf-seg button, .nf-chip { font: inherit; font-size: 14px; font-weight: 500; border: none; background: none; color: var(--nf-muted); padding: 7px 14px; border-radius: 999px; cursor: pointer; white-space: nowrap; min-height: 36px; transition: background 0.15s, color 0.15s; } .nf-seg button:hover:not(:disabled), .nf-chip:hover { background: var(--nf-fill); color: var(--nf-text); } /* on a small stage (a small window, a zoomed browser, a dashboard column) the switches at the bottom take less room */ @container nf ((max-width: 1360px) or (max-height: 640px)) { :is(.nf-overlay, .nf-card-controls) .nf-seg { padding: 3px; } :is(.nf-overlay, .nf-card-controls) :is(.nf-seg button, .nf-chip) { font-size: 12.5px; padding: 5px 10px; } } .nf-time-slider { display: inline-flex; align-items: center; padding: 4px 10px; } .nf-time-slider input { width: 160px; accent-color: var(--nf-accent); } .nf-seg button[aria-pressed="true"], .nf-chip[aria-pressed="true"] { background: color-mix(in srgb, var(--nf-accent) 24%, var(--nf-chrome-solid)); color: var(--nf-accent); font-weight: 600; } .nf-seg button:disabled { opacity: 0.4; cursor: default; } /* a single pill, like the chips of the Mushroom cards */ .nf-chip { background: var(--nf-chrome); color: var(--nf-text); box-shadow: var(--nf-shadow); backdrop-filter: blur(10px); } button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--nf-accent); outline-offset: 2px; } /* the round icon badge every row and card starts with */ .nf-ico { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 38px; height: 38px; border-radius: 50%; background: var(--nf-tonal); color: var(--nf-accent); --mdc-icon-size: 20px; } .nf-ico.nf-warm { background: color-mix(in srgb, var(--nf-warm) 22%, transparent); color: var(--nf-warm); } .nf-ico.nf-off { background: var(--nf-fill); color: var(--nf-muted); } .nf-btn { font: inherit; font-size: 14px; font-weight: 500; border: none; background: var(--nf-fill); color: var(--nf-text); border-radius: var(--nf-radius); padding: 7px 14px; cursor: pointer; min-height: 36px; transition: background 0.15s; } .nf-btn:hover { background: var(--nf-fill-strong); } .nf-btn.nf-danger { color: var(--nf-danger); } .nf-btn.nf-primary { background: var(--nf-accent); color: var(--nf-accent-text); } .nf-btn.nf-primary:hover { background: color-mix(in srgb, var(--nf-accent) 88%, var(--nf-text)); } .nf-field { display: grid; gap: 4px; font-size: 12px; color: var(--nf-muted); } .nf-field input, .nf-field select, .nf-field textarea { font: inherit; font-size: 14px; color: var(--nf-text); background: var(--nf-fill); border: none; border-bottom: 1px solid var(--nf-line); border-radius: 10px 10px 4px 4px; padding: 8px 10px; min-width: 0; } .nf-field input:focus, .nf-field select:focus, .nf-field textarea:focus { border-bottom-color: var(--nf-accent); } .nf-field input[type="range"] { padding: 0; accent-color: var(--nf-accent); } .nf-field select option { background: var(--nf-chrome-solid); color: var(--nf-text); } /* fingers need 40 px */ @media (pointer: coarse) { .nf-seg button, .nf-chip, .nf-btn { min-height: 40px; } } `;var{I:dy}=Wc,gd=t=>t;var bd=t=>t.strings===void 0,_d=()=>document.createComment(""),Nn=(t,e,n)=>{let r=t._$AA.parentNode,i=e===void 0?t._$AB:e._$AA;if(n===void 0){let o=r.insertBefore(_d(),i),s=r.insertBefore(_d(),i);n=new dy(o,s,t,t.options)}else{let o=n._$AB.nextSibling,s=n._$AM,l=s!==t;if(l){let a;n._$AQ?.(t),n._$AM=t,n._$AP!==void 0&&(a=t._$AU)!==s._$AU&&n._$AP(a)}if(o!==i||l){let a=n._$AA;for(;a!==o;){let c=gd(a).nextSibling;gd(r).insertBefore(a,i),a=c}}}return n},Nt=(t,e,n=t)=>(t._$AI(e,n),t),hy={},yd=(t,e=hy)=>t._$AH=e,vd=t=>t._$AH,bo=t=>{t._$AR(),t._$AA.remove()};var wd=(t,e,n)=>{let r=new Map;for(let i=e;i<=n;i++)r.set(t[i],i);return r},ln=an(class extends Ct{constructor(t){if(super(t),t.type!==Hn.CHILD)throw Error("repeat() can only be used in text expressions")}dt(t,e,n){let r;n===void 0?n=e:e!==void 0&&(r=e);let i=[],o=[],s=0;for(let l of t)i[s]=r?r(l,s):s,o[s]=n(l,s),s++;return{values:o,keys:i}}render(t,e,n){return this.dt(t,e,n).values}update(t,[e,n,r]){let i=vd(t),{values:o,keys:s}=this.dt(e,n,r);if(!Array.isArray(i))return this.ut=s,o;let l=this.ut??=[],a=[],c,u,d=0,p=i.length-1,h=0,f=o.length-1;for(;d<=p&&h<=f;)if(i[d]===null)d++;else if(i[p]===null)p--;else if(l[d]===s[h])a[h]=Nt(i[d],o[h]),d++,h++;else if(l[p]===s[f])a[f]=Nt(i[p],o[f]),p--,f--;else if(l[d]===s[f])a[f]=Nt(i[d],o[f]),Nn(t,a[f+1],i[d]),d++,f--;else if(l[p]===s[h])a[h]=Nt(i[p],o[h]),Nn(t,i[d],i[p]),p--,h++;else if(c===void 0&&(c=wd(s,h,f),u=wd(l,d,p)),c.has(l[d]))if(c.has(l[p])){let g=u.get(s[h]),b=g!==void 0?i[g]:null;if(b===null){let y=Nn(t,i[d]);Nt(y,o[h]),a[h]=y}else a[h]=Nt(b,o[h]),Nn(t,i[d],b),i[g]=null;h++}else bo(i[p]),p--;else bo(i[d]),d++;for(;h<=f;){let g=Nn(t,a[f+1]);Nt(g,o[h]),a[h++]=g}for(;d<=p;){let g=i[d++];g!==null&&bo(g)}return this.ut=s,yd(t,a),tt}});var py=new Intl.Collator("de",{numeric:!0,sensitivity:"base"}),oa=-1,xd=[{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"}],kd=t=>t.object_type===1&&xd.some(e=>e.type===t.module_type);function fy(t){let e=new Map(t.map(a=>[a.object_id,a])),n=t.filter(a=>{if(!kd(a))return!1;let c=new Set([a.object_id]),u=e.get(a.parent_id);for(;u&&!c.has(u.object_id);){if(kd(u))return!1;c.add(u.object_id),u=e.get(u.parent_id)}return!0});if(!n.length)return t;let r=new Map(e),i=new Map;for(let a of t){let c=i.get(a.parent_id)??[];c.push(a),i.set(a.parent_id,c)}let o=(a,c,u,d,p)=>({object_id:a,parent_id:c,name:u,path:d,position:p,object_type:0,hidden:!1,icon:"",virtual:!0});r.set(oa,o(oa,0,"System","System",Number.MAX_SAFE_INTEGER));let s=new Set,l=(a,c,u)=>{if(s.has(a.object_id))return;s.add(a.object_id);let d={...a,parent_id:c,path:`${u} / ${a.name}`};r.set(a.object_id,d);for(let p of i.get(a.object_id)??[])l(p,a.object_id,d.path)};return xd.forEach((a,c)=>{let u=n.filter(h=>h.module_type===a.type);if(!u.length)return;let d=-10-a.type,p=`System / ${a.name}`;r.set(d,o(d,oa,a.name,p,c));for(let h of u)l(h,d,p)}),[...r.values()]}function sa(t){let e=fy(t),n=new Map(e.map(i=>[i.object_id,i])),r=new Map;for(let i of e){let o=n.has(i.parent_id)?i.parent_id:0,s=r.get(o)??[];s.push(i),r.set(o,s)}for(let i of r.values())i.sort((o,s)=>o.position-s.position||o.object_type-s.object_type||py.compare(o.name,s.name));return{nodes:n,children:r}}function aa(t,e){let n=[],r=new Set([e]),i=t.nodes.get(e)?.parent_id;for(;i&&!r.has(i)&&t.nodes.has(i);)n.push(i),r.add(i),i=t.nodes.get(i)?.parent_id;return n}function la(t,e,n=""){let r=n.trim().toLocaleLowerCase("de").split(/\s+/).filter(Boolean),i=r.length?new Set:null;if(i){for(let a of t.nodes.values())if(r.every(c=>`${a.name} ${a.path}`.toLocaleLowerCase("de").includes(c))){i.add(a.object_id);for(let c of aa(t,a.object_id))i.add(c)}}let o=[],s=new Set,l=(a,c)=>{let u=(t.children.get(a)??[]).filter(d=>!i||i.has(d.object_id));u.forEach((d,p)=>{if(s.has(d.object_id))return;s.add(d.object_id);let h=(t.children.get(d.object_id)?.length??0)>0,f=h&&(!!i||e.has(d.object_id));o.push({node:d,depth:c,hasChildren:h,expanded:f,index:p+1,siblings:u.length}),f&&l(d.object_id,c+1)})};return l(0,0),o}var $d=["Boolean","Integer","Float","String"],my={light:"Licht",cover:"Jalousie/Tor",switch:"Schalter",binary_sensor:"Bin\xE4rsensor",sensor:"Sensor",climate:"Heizung",lock:"Schloss",script:"Skript",schedule:"Schaltuhr",media_player:"Medienger\xE4t",fan:"L\xFCfter"};function Sd(t,e={}){if(t.virtual||t.object_type===0)return"Das ist eine Kategorie. Klappe sie auf und w\xE4hle den Datenpunkt darunter aus.";if(t.object_type===1)return"Das ist eine Instanz. Klappe sie auf und w\xE4hle ihre Variable aus, zum Beispiel \u201EValue\u201C.";if(e.schedule&&t.object_type!==4)return"Hier wird eine klassische Symcon-Schaltuhr (Wochenplan-Ereignis) erwartet, keine Variable.";if(e.unsupported)return e.unsupported;if(!t.entity_id)return t.object_type===2?"Diese Variable wurde noch nicht geladen. Lade die Variablen oben in der Titelleiste neu und \xF6ffne die Auswahl erneut.":t.object_type===6?"Dieser Link verweist auf keinen unterst\xFCtzten Datenpunkt. W\xE4hle die Variable direkt im Objektbaum aus.":t.object_type===4?"Dieses Ereignis ist keine unterst\xFCtzte klassische Symcon-Schaltuhr (Wochenplan).":"Dieser Objekttyp kann in diesem Feld nicht verkn\xFCpft werden. W\xE4hle eine passende Variable aus.";let n=e.states?.[t.entity_id];if(e.states&&!n)return"Diese Variable ist im aktuellen Datenbestand nicht mehr vorhanden. Lade die Variablen oben in der Titelleiste neu.";let r=n?.attributes.symcon_variable_type,i=r===void 0?void 0:$d[Number(r)];if(n&&!n.attributes.symcon_schedule&&!i)return"Der native Datentyp dieser Variable ist nicht verf\xFCgbar. Lade die Variablen oben in der Titelleiste neu.";if(i&&e.types&&!e.types.includes(Number(r)))return`Datentyp ${i} passt hier nicht. F\xFCr \u201E${e.label||"dieses Feld"}\u201C wird ${e.types.map(c=>$d[c]).join(" oder ")} ben\xF6tigt.`;let o=e.excluded?.(t.entity_id);if(o)return o;let s=my[t.entity_id.split(".")[0]],l=n?.attributes.unit_of_measurement,a=[i&&`Datentyp: ${i}`,l&&`Einheit: ${l}`,s&&`erkannte Funktion: ${s}`].filter(Boolean).join(" \xB7 ");return`Dieser Datenpunkt erf\xFCllt den Filter${e.label?` f\xFCr \u201E${e.label}\u201C`:" dieses Feldes"} nicht.${a?` ${a}.`:""}`}var gy=["Kategorie","Instanz","Variable","Skript","Ereignis","Medium","Link"],ca=class extends Y{static properties={objects:{attribute:!1},options:{attribute:!1},fixed:{attribute:!1},value:{attribute:!1},disabled:{type:Boolean},placeholder:{attribute:!1},context:{attribute:!1},_notice:{state:!0},_query:{state:!0},_expanded:{state:!0},_pending:{state:!0},_active:{state:!0},_selected:{state:!0}};tree=sa([]);allowed=new Map;allowedSources=new Map;constructor(){super(),this.objects=[],this.options=[],this.fixed=[],this.value=null,this.disabled=!1,this.placeholder="Datenpunkt ausw\xE4hlen",this._notice="",this._query="",this._expanded=new Set,this._pending=null,this._active=null,this._selected=null}willUpdate(e){e.has("objects")&&(this.tree=sa(this.objects)),(e.has("options")||e.has("fixed"))&&(this.allowed=new Map([...this.fixed,...this.options].map(n=>[n.id,n])),this.allowedSources=new Map(this.options.filter(n=>n.sourceEntity).map(n=>[n.sourceEntity,n.id])))}get dialog(){return this.renderRoot.querySelector("dialog")}variableNode(e){let n=this.allowed.get(e??"")?.sourceEntity??e,r=this.objects.find(i=>i.entity_id===n&&(i.object_type===2||i.object_type===4));return r?this.tree.nodes.get(r.object_id):void 0}async open(){if(this.disabled)return;this._pending=this.allowed.has(this.value??"")?this.value:null,this._query="",this._notice="";let e=this.variableNode(this.value)??this.objects.find(r=>r.entity_id===this.value);this._active=e?.object_id??null,this._selected=e?.object_id??null;let n=new Set(this._expanded);if(e)for(let r of aa(this.tree,e.object_id))n.add(r);this._expanded=n,await this.updateComplete,this.isConnected&&(this.dialog?.open||this.dialog?.showModal(),this.renderRoot.querySelector(".search")?.focus(),this.renderRoot.querySelector("[aria-selected=true]")?.scrollIntoView({block:"nearest"}))}close(){this.dialog?.close()}clear(e){e.preventDefault(),e.stopPropagation(),!this.disabled&&(this.value=this.fixed.some(n=>n.id==="none")?"none":null,this._pending=this.value,this._selected=null,this._active=null,this.close(),this.dispatchEvent(new CustomEvent("change",{detail:{value:this.value},bubbles:!0,composed:!0})))}commit(){this.disabled||!this._pending||!this.allowed.has(this._pending)||(this.value=this._pending,this.close(),this.dispatchEvent(new CustomEvent("change",{detail:{value:this.value},bubbles:!0,composed:!0})))}toggle(e){let n=new Set(this._expanded);n.has(e)?n.delete(e):n.add(e),this._expanded=n}select(e){this._active=e.object_id;let n=this.entityFor(e);n?(this._pending=n,this._selected=e.object_id,this._notice=""):(this._pending=null,this._selected=null,this._notice=Sd(e,this.context))}entityFor(e){if(e.entity_id)return this.allowed.has(e.entity_id)?e.entity_id:this.allowedSources.get(e.entity_id)}async onTreeKey(e){let n=la(this.tree,this._expanded,this._query),r=Math.max(0,n.findIndex(s=>s.node.object_id===this._active)),i=n[r];if(!i)return;let o=r;if(e.key==="ArrowDown")o=Math.min(n.length-1,r+1);else if(e.key==="ArrowUp")o=Math.max(0,r-1);else if(e.key==="Home")o=0;else if(e.key==="End")o=n.length-1;else if(e.key==="ArrowRight")i.hasChildren&&!i.expanded?this.toggle(i.node.object_id):i.hasChildren&&(o=Math.min(n.length-1,r+1));else if(e.key==="ArrowLeft")i.expanded&&!this._query?this.toggle(i.node.object_id):o=Math.max(0,n.findIndex(s=>s.node.object_id===i.node.parent_id));else if(e.key===" "||e.key==="Enter")this.select(i.node),e.key==="Enter"&&this.entityFor(i.node)&&this.commit();else return;e.preventDefault(),(o!==r||this._active===null)&&(this._active=n[o].node.object_id),await this.updateComplete,this.renderRoot.querySelector(`#object-${this._active}`)?.scrollIntoView({block:"nearest"})}icon(e){let n=[R``,R``,R``,R``,R``,R``,R``];return R``}renderRow(e){let{node:n}=e,r=this.entityFor(n),i=!!r;return m`
{this.select(n),this.renderRoot.querySelector(".tree")?.focus()}} @dblclick=${()=>{i?(this.select(n),this.commit()):e.hasChildren&&this.toggle(n.object_id)}}> ${this.icon(n.object_type)}${n.name||"(Ohne Namen)"} ${n.virtual?"Systembereich":gy[n.object_type]??"Objekt"}${n.hidden?" \xB7 ausgeblendet":""} ${i&&n.object_id===this._selected&&r===this._pending?m``:_}
`}render(){let e=this.allowed.get(this.value??""),n=this.variableNode(this.value),r=this.allowed.get(this._pending??""),i=this._selected===null?void 0:this.tree.nodes.get(this._selected),o=(i&&this.entityFor(i)===this._pending?i:void 0)??this.variableNode(this._pending),s=la(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``:_}
{if(c.stopPropagation(),c.target===this.dialog){let u=this.dialog.getBoundingClientRect();(c.clientXu.right||c.clientYu.bottom)&&this.close()}}} @keydown=${c=>c.stopPropagation()} @change=${c=>c.stopPropagation()}>

Datenpunkt auswählen

IP-Symcon · ${this.context?.label||"Objektbaum"}

${this.fixed.length?m`
${this.fixed.map(c=>m` `)}
`:_}
${ln(s,c=>c.node.object_id,c=>this.renderRow(c))} ${s.length?_:m`

${this.objects.length?"Keine Objekte gefunden.":"Kein Objektbaum verf\xFCgbar. Bitte das Symcon-Modul aktualisieren und den Designer neu laden."}

`}
${this._notice?m`
${this._notice}
`:_}
${o?.name??r?.label??"Noch kein Datenpunkt ausgew\xE4hlt"} ${o?.path??"Nur passende Datenpunkte k\xF6nnen ausgew\xE4hlt werden."}
`}static styles=[ve,ee` :host { display:block; min-width:0; max-width:100%; font:inherit; color:var(--nf-text); } button,input { font:inherit; box-sizing:border-box; } button { cursor:pointer; color:var(--nf-text); border:1px solid var(--nf-line); background:var(--nf-chrome-solid); border-radius:9px; padding:8px 12px; } button:disabled { opacity:.45; cursor:default; } button:focus-visible,input:focus-visible { outline:2px solid var(--nf-accent); outline-offset:2px; } .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; } dialog[open] { display:flex; flex-direction:column; } dialog::backdrop { background:#050b16a6; backdrop-filter:blur(3px); } header { display:flex; align-items:center; justify-content:space-between; padding:20px 22px 16px; border-bottom:1px solid var(--nf-line); } h2 { font-size:18px; font-weight:600; margin:0 0 4px; } header p { margin:0; color:var(--nf-muted); font-size:12px; } .close { font-size:25px; padding:0; width:32px; height:32px; border-color:transparent; } .search-bar { display:flex; align-items:center; gap:12px; padding:16px 20px 10px; } .search { flex:1; min-width:0; border:1px solid var(--nf-line); border-radius:9px; padding:10px 12px; background:var(--nf-bg); color:var(--nf-text); } .text-button { border:0; background:transparent; color:var(--nf-muted); font-size:12px; padding:6px 0; white-space:nowrap; } .fixed { display:flex; flex-wrap:wrap; gap:6px; padding:0 20px 10px; } .fixed button { padding:5px 10px; font-size:12px; } .fixed [aria-pressed=true] { color:var(--nf-accent); border-color:var(--nf-accent); } .tree { flex:1; min-height:80px; overflow:auto; overscroll-behavior:contain; margin:0 12px; padding:4px 0 12px; outline-offset:-2px; } .node { display:flex; align-items:center; gap:8px; min-height:34px; border-radius:6px; padding:2px 10px 2px calc(4px + var(--depth)*22px); box-sizing:border-box; width:max-content; min-width:100%; } .node:hover { background:color-mix(in srgb,var(--nf-accent) 8%,transparent); } .node.active { outline:1px solid color-mix(in srgb,var(--nf-accent) 40%,transparent); outline-offset:-1px; } .node[aria-selected=true] { background:color-mix(in srgb,var(--nf-accent) 16%,transparent); color:var(--nf-accent); } .node.selectable { cursor:pointer; } .node[aria-disabled=true] .node-name { color:var(--nf-muted); } .node.hidden-object .node-name { font-style:italic; } .node-name { flex:1; white-space:nowrap; } .node small { margin-left:20px; white-space:nowrap; } .twisty { border:0; background:transparent; border-radius:4px; padding:0; width:20px; height:26px; flex:none; font-size:18px; } .icon { flex:none; width:17px; height:17px; color:#8796a9; } .type-0 { color:#c69a42; } .type-1 { color:#8d9ac6; } .type-2 { color:#55a58c; } .selected-mark { margin-left:8px; } .empty { padding:20px; color:var(--nf-muted); } .rejection { flex:none; margin:0 20px 12px; padding:8px 10px; border-left:2px solid #e5b56d; border-radius:4px; background:#e5b56d0c; color:var(--nf-text); font-size:12px; line-height:1.4; overflow-wrap:anywhere; } footer { display:flex; align-items:center; justify-content:space-between; gap:16px; border-top:1px solid var(--nf-line); padding:15px 20px; } .selection { min-width:0; } .selection small { margin-top:4px; overflow-wrap:anywhere; } .actions { display:flex; gap:8px; flex-shrink:0; } .apply { color:white; background:var(--nf-accent); border-color:transparent; } @media(max-width:580px) { dialog { width:calc(100vw - 16px); height:calc(100dvh - 32px); border-radius:12px; } header { padding:16px; } .search-bar { padding:12px; gap:8px; } .fixed { padding:0 12px 8px; } .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",ca);var Md=40,ua=class extends Y{static properties={options:{attribute:!1},objectTree:{attribute:!1},context:{attribute:!1},fixed:{attribute:!1},value:{attribute:!1},disabled:{type:Boolean},placeholder:{attribute:!1},_query:{state:!0},_open:{state:!0},_cursor:{state:!0}};blurTimer;constructor(){super(),this.options=[],this.objectTree=void 0,this.fixed=[],this.value=null,this.disabled=!1,this.placeholder="",this._query="",this._open=!1,this._cursor=0}get current(){return[...this.fixed,...this.options].find(e=>e.id===this.value)}get hits(){let e=this._query.trim().toLowerCase(),n=e.split(/\s+/).filter(Boolean),r=s=>{let l=`${s.label} ${s.detail??s.id}`.toLowerCase();return n.every(a=>l.includes(a))},i=this.fixed.filter(s=>!e||r(s)),o=e?this.options.filter(r):this.options;return[...i,...o.slice(0,Md)]}get leftOut(){let e=this._query.trim().toLowerCase(),n=e.split(/\s+/).filter(Boolean),r=e?this.options.filter(i=>n.every(o=>`${i.label} ${i.detail??i.id}`.toLowerCase().includes(o))).length:this.options.length;return Math.max(0,r-Md)}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}} >`;let e=this.current,n=this._open?this.hits:[];return m`
{clearTimeout(this.blurTimer),this._open=!0,this._query="",this._cursor=0}} @blur=${()=>{this.blurTimer=setTimeout(()=>this._open=!1,150)}} @input=${r=>{this._query=r.target.value,this._cursor=0,this._open=!0}} @keydown=${this.onKey} /> ${this._open?m`
    ${n.length?_:m`
  • –
  • `} ${n.map((r,i)=>m`
  • o.preventDefault()} @click=${()=>this.choose(r.id)} > ${r.label}${r.detail||r.id.includes(".")?m`${r.detail??r.id}`:_}
  • `)} ${this.leftOut>0?m`
  • … +${this.leftOut} · ${this.placeholder}
  • `:_}
`:_}
`}static styles=[ve,ee` :host { display: block; position: relative; min-width: 0; max-width: 100%; } input { width: 100%; box-sizing: border-box; font: inherit; color: var(--nf-text); background: var(--nf-chrome-solid); border: 1px solid var(--nf-line); border-radius: 10px; padding: 8px 10px; } input::placeholder { color: var(--nf-text); opacity: 0.9; } input:focus::placeholder { color: var(--nf-muted); } input:focus { outline: 2px solid var(--nf-accent); outline-offset: -1px; } .list { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 20; margin: 0; padding: 4px; list-style: none; max-height: 280px; overflow-y: auto; background: var(--nf-chrome-solid); border: 1px solid var(--nf-line); border-radius: 10px; box-shadow: var(--nf-shadow); } li { display: flex; flex-direction: column; gap: 1px; padding: 6px 8px; border-radius: 6px; cursor: pointer; font-size: 13.5px; } li small { color: var(--nf-muted); font-size: 11px; } li.cursor, li:hover { background: color-mix(in srgb, var(--nf-accent) 18%, transparent); } li.chosen { color: var(--nf-accent); } li.empty { color: var(--nf-muted); cursor: default; } `]};customElements.get("nf-entity-picker")||customElements.define("nf-entity-picker",ua);var da=class extends Y{static properties={text:{attribute:!1}};constructor(){super(),this.text=""}get dialog(){return this.renderRoot.querySelector("dialog")}render(){return m` e.stopPropagation()} @click=${e=>{if(e.target!==e.currentTarget)return;let n=this.dialog.getBoundingClientRect();(e.clientXn.right||e.clientYn.bottom)&&this.dialog?.close()}}>
Information

${this.text}

`}static styles=[ve,ee` :host { display:inline-block; margin:4px 0; vertical-align:middle; } button { font:inherit; cursor:pointer; color:var(--nf-muted); background:transparent; border:1px solid var(--nf-line); border-radius:50%; pointer-events:auto; } .info { width:26px; height:26px; padding:0; font-size:18px; line-height:24px; } button:hover { color:var(--nf-accent); } button:focus-visible { outline:2px solid var(--nf-accent); outline-offset:2px; } dialog { box-sizing:border-box; width:min(560px,calc(100vw - 32px)); max-height:80vh; max-height:80dvh; overflow:auto; padding:18px 22px; border:1px solid var(--nf-line); border-radius:14px; background:var(--nf-chrome-solid); color:var(--nf-text); font:14px/1.5 system-ui,sans-serif; box-shadow:var(--nf-shadow); pointer-events:auto; } dialog::backdrop { background:#050b16a6; } header { display:flex; align-items:center; justify-content:space-between; gap:20px; font-size:16px; } .close { width:30px; height:30px; padding:0; font-size:23px; } p { white-space:pre-wrap; overflow-wrap:anywhere; margin:16px 0 4px; } `]};customElements.get("nf-help-popup")||customElements.define("nf-help-popup",da);var cn=t=>t.target.value,ha=t=>Number.parseFloat(t.replace(",",".")),ae=t=>Math.round(t*1e3)/1e3,Rd=t=>t.wide?"nf-field nf-wide":"nf-field";function A(t,e,n,r,i=.01,o){return m``}function W(t,e,n,r,i={}){return m``}function H(t,e,n,r,i,o={}){return m``}function D(t,e,n,r,i={}){return m``}function Ue(t,e,n,r,i){return m``}function z(t,e,n,r,i,o,s={}){let l=r===void 0?null:r?t.t("entity_auto",{name:B(t.hass,r)}):t.t("entity_auto_none"),a=[...l!==null?[{id:"__auto",label:l}]:[],{id:"none",label:t.t("entity_none")}],c=n??(l!==null?"__auto":"none"),u=t.hass?.symconObjects!==void 0&&!s.schedule?md(t.hass,s,n):i;return m``}function Bn(t,e,n){return n?(n.startsWith("mdi:")?n:`mdi:${n}`).replace(/[^a-z0-9:-]/gi,""):t.hass?Cu(t.hass,e):null}function Bt(t,e,n){let r=e?(e.startsWith("mdi:")?e:`mdi:${e}`).replace(/[^a-z0-9:-]/gi,""):"";return m``}function Vn(t,e,n){return m``}function Vt(t,e,n){let r=e??{},i=o=>s=>{let l={...r,[o]:Math.round(Math.max(-5,Math.min(5,s))*100)/100};n(l.x||l.z||l.y?l:null)};return m`
${t.t("pin_shift")}
${A(t,"\u2194 x",r.x??0,i("x"),.05)} ${A(t,"\u2195 z",r.z??0,i("z"),.05)} ${A(t,t.t("pin_shift_up"),r.y??0,i("y"),.05)} ${e?m``:_} ${S(t.t("pin_shift_hint"),"nf-wide")}
`}var J=(...t)=>m`
${t}
`,S=(t,e="")=>m``;function un(t,e,n,r={}){let i=r.lowest??10;return m``}var rt=(t,e,n={})=>t.callWS({type:`nextfloor/${e}`,...n});async function yo(t,e){return(await rt(t,"image/get",{image_id:e})).data}async function Wt(t,e,n){await rt(t,"image/set",{image_id:e,data:n})}async function Ed(t){return(await rt(t,"history/list")).snapshots}async function Ad(t,e){return(await rt(t,"history/snapshot",e?{name:e}:{})).id}async function Fd(t,e){return(await rt(t,"history/get",{snapshot_id:e})).building}async function Td(t,e){await rt(t,"history/delete",{snapshot_id:e})}async function zd(t,e){return(await rt(t,"history/restore",{snapshot_id:e})).revision}var Or=(t,e)=>rt(t,"packs/import",{pack:e});async function Pd(t,e){await rt(t,"packs/remove",{pack_id:e})}var Dd=t=>rt(t,"backup/export"),Id=(t,e,n)=>rt(t,"backup/import",{building:e,packs:n});var U=(t,e)=>[t[0]-e[0],t[1]-e[1]],ft=(t,e)=>[t[0]+e[0],t[1]+e[1]],it=(t,e)=>[t[0]*e,t[1]*e],te=(t,e)=>t[0]*e[0]+t[1]*e[1],Re=(t,e)=>t[0]*e[1]-t[1]*e[0],ge=t=>Math.hypot(t[0],t[1]),ot=t=>{let e=ge(t)||1;return[t[0]/e,t[1]/e]},pa=t=>[-t[1],t[0]],fa=t=>[t[1],-t[0]];var _y=.05,by=.2,yy=.12;function vy(t){let e=[];return t.forEach((n,r)=>{let i=n.points;if(i.length<3)return;let o=_e(i)>=0;i.forEach((s,l)=>{let a=i[(l+1)%i.length],c=ge(U(a,s));if(c<.05)return;let u=[(a[0]-s[0])/c,(a[1]-s[1])/c],d=o?[u[1],-u[0]]:[-u[1],u[0]];(u[1]<-1e-9||Math.abs(u[1])<=1e-9&&u[0]<0)&&(u=[-u[0],-u[1]]);let p=[-u[1],u[0]],[h,f]=[te(s,u),te(a,u)];e.push({room:r,index:l,dir:u,normal:p,offset:te(s,p),outside:te(d,p)>0?1:-1,from:Math.min(h,f),to:Math.max(h,f)})})}),e}function wy(t,e,n){if(t.room===e.room||Math.abs(Re(t.dir,e.dir))>_y||t.outside===e.outside)return null;let r=(e.offset-t.offset)*t.outside;return r>n||r<-yy||Math.abs(r)<1e-4||Math.min(t.to,e.to)-Math.max(t.from,e.from)Math.round(t*1e3)/1e3;function Od(t,e=.6){let n=vy(t),r=n.map((g,b)=>b),i=g=>r[g]===g?g:r[g]=i(r[g]),o=[],s=new Set,l=[];for(let g=0;gMath.abs(g[2])-Math.abs(b[2]));let a=new Map(n.map((g,b)=>[b,[b]])),c=(g,b)=>g.some(y=>b.some(v=>n[y].room===n[v].room&&Math.abs(n[y].offset-n[v].offset)>=.002));for(let[g,b,y]of l){let[v,w]=[i(g),i(b)];if(v!==w){if(c(a.get(v),a.get(w)))continue;r[v]=w,a.set(w,[...a.get(w),...a.get(v)]),a.delete(v)}o.push(ma(y)),s.add(g).add(b)}let u=new Map(n.map((g,b)=>[`${g.room}:${g.index}`,b]));for(let g=s.size>0;g;)g=!1,n.forEach((b,y)=>{let v=u.get(`${b.room}:${(b.index+1)%t[b.room].points.length}`);if(v===void 0||v===y)return;let w=n[v];!(Math.abs(Re(b.dir,w.dir))<1e-6&&Math.abs(b.offset-w.offset)<.002&&b.outside===w.outside)||s.has(y)===s.has(v)||(s.add(y).add(v),g=!0)});n.forEach((g,b)=>{let y=u.get(`${g.room}:${(g.index+1)%t[g.room].points.length}`);if(y===void 0||y===b||!s.has(b)||!s.has(y))return;let v=n[y];Math.abs(Re(g.dir,v.dir))<1e-6&&Math.abs(g.offset-v.offset)<.002&&g.outside===v.outside&&(r[i(b)]=i(y))});let d=()=>t.map(g=>({...g,points:g.points.map(b=>[b[0],b[1]])}));if(o.length===0)return{rooms:d(),gaps:o};let p=new Map;for(let g of s)p.set(i(g),[...p.get(i(g))??[],g]);let h=t.map(g=>g.points.map(()=>new Map));for(let[g,b]of p){let y=new Map(b.map(w=>[`${n[w].room}:${Math.round(n[w].offset*500)}`,n[w].offset])),v=[...y.values()].reduce((w,x)=>w+x,0)/y.size;for(let w of b){let x=n[w],k=[x.normal[0]*(v-x.offset),x.normal[1]*(v-x.offset)];h[x.room][x.index].set(g,k),h[x.room][(x.index+1)%t[x.room].points.length].set(g,k)}}return{rooms:t.map((g,b)=>({...g,points:g.points.map((y,v)=>{let w=[...h[b][v].values()].reduce((x,k)=>[x[0]+k[0],x[1]+k[1]],[y[0],y[1]]);return[ma(w[0]),ma(w[1])]})})),gaps:o}}function Hd(t){let e=t.filter(n=>n>.04).sort((n,r)=>n-r);return e.length===0?null:Math.min(.5,Math.max(.08,Math.round(e[Math.floor(e.length/2)]*100)/100))}var ky=.25,Ld=t=>Math.round(t*1e3)/1e3,Cd=(t,e,n)=>t.rooms.find(r=>r.points.length>=3&&C([e,n],r.points));function _a(t,e,n,r,i){let o=Cd(t,e,n);if(!o)return[r,i];let s=(l,a)=>C([l,a],o.points);return s(r,i)?[r,i]:s(r,n)?[r,n]:s(e,i)?[e,i]:[e,n]}function xy(t,e,n,r){return t.rooms.some(i=>i.id!==e.id&&i.points.some((o,s)=>{let l=i.points[(s+1)%i.points.length];return Math.abs(te(U(o,n),r))<.02&&Math.abs(te(U(l,n),r))<.02}))}var ga=(t,e)=>Math.abs((t-e+540)%360-180);function Hr(t,e,n,r=ky){let i=Cd(t,e.x,e.z);if(!i)return null;let o=i.points,s=_e(o)>=0?1:-1,l=null;return o.forEach((a,c)=>{let u=o[(c+1)%o.length],d=ge(U(u,a));if(d<.3)return;let p=[(u[0]-a[0])/d,(u[1]-a[1])/d],h=[-p[1]*s,p[0]*s],f=te(U([e.x,e.z],a),p);if(f<0||f>d)return;let g=xy(t,i,a,h)?n/2:0,b=te(U([e.x,e.z],a),h)-g,y=Math.atan2(-h[0],h[1])*180/Math.PI,w=[{rotation:y,extent:e.d/2},{rotation:y+90,extent:e.w/2},{rotation:y-90,extent:e.w/2}].reduce((k,M)=>ga(e.rotation,M.rotation)50)return;let x=b-w.extent;Math.abs(x)>r||l&&Math.abs(x)>=Math.abs(l.gap)||(l={x:Ld(e.x-h[0]*x),z:Ld(e.z-h[1]*x),rotation:(Math.round(w.rotation)%360+360)%360,gap:x})}),l&&{x:l.x,z:l.z,rotation:l.rotation}}var Wn=Math.PI/180,st=t=>Math.tan(Math.min(80,Math.max(0,t))*Wn);function Cr(t){return{x0:Math.min(t.x0,t.x1),x1:Math.max(t.x0,t.x1),z0:Math.min(t.z0,t.z1),z1:Math.max(t.z0,t.z1)}}function Nd(t){if(!t.rotation)return null;let e=t.rotation*Wn;return{cx:(t.x0+t.x1)/2,cz:(t.z0+t.z1)/2,c:Math.cos(e),sn:Math.sin(e)}}function Bd(t,e){let n=Nd(t);if(!n)return e;let[r,i]=[e[0]-n.cx,e[1]-n.cz];return[n.cx+r*n.c-i*n.sn,n.cz+r*n.sn+i*n.c]}function ba(t,e,n){let r=Nd(t);if(!r)return[e,n];let[i,o]=[e-r.cx,n-r.cz];return[r.cx+i*r.c+o*r.sn,r.cz-i*r.sn+o*r.c]}function Nr(t,e=0){let{x0:n,x1:r,z0:i,z1:o}=Cr(t);return[[n-e,i-e],[r+e,i-e],[r+e,o+e],[n-e,o+e]].map(s=>Bd(t,s))}function $e(t){let{x0:e,x1:n,z0:r,z1:i}=Cr(t),o=s=>Bd(t,s);return t.axis==="x"?{u0:e,u1:n,w:i-r,at:(s,l)=>o([s,t.flip?i-l:r+l])}:{u0:r,u1:i,w:n-e,at:(s,l)=>o([t.flip?n-l:e+l,s])}}function Br(t,e,n){let{x0:r,x1:i,z0:o,z1:s}=Cr(t),[l,a]=ba(t,e,n);return t.axis==="x"?[l,t.flip?s-a:a-o]:[a,t.flip?i-l:l-r]}var Lr=Math.tan(30*Wn);function Vr(t,e,n,r,i){let o=Math.min(t*.3,r>1e-6?2.4/r:t*.3),s=Math.min(t*.3,i>1e-6?2.4/i:t*.3),l=e+o*r,a=n+s*i,c=Math.min(t-s,Math.max(o,(a-l+Lr*(t-s+o))/(2*Lr))),u=l+(c-o)*Lr;return{vla:o,vlb:s,yla:l,ylb:a,vr:c,rh:u,y:p=>p<=o?e+p*r:p<=c?l+(p-o)*Lr:p<=t-s?a+(t-s-p)*Lr:n+(t-p)*i}}function Le(t){let e=$e(t).w,[n,r]=[t.eave_a,t.eave_b],[i,o]=[st(t.pitch_a),st(t.pitch_b)];switch(t.shape){case"flat":case"parapet":return{vr:e/2,rh:n,y:()=>n};case"pent":return{vr:e,rh:n+e*i,y:s=>n+s*i};case"mansard":{let s=Vr(e,n,r,i,o);return{vr:s.vr,rh:s.rh,y:s.y}}default:{let s=i+o>1e-6?Math.min(e,Math.max(0,(r-n+e*o)/(i+o))):e/2;return{vr:s,rh:n+s*i,y:l=>l<=s?n+l*i:r+(e-l)*o}}}}var dn=t=>Le(t).rh;function Vd(t){let e=t.heightEnd!==void 0;return{...t,a:t.b,b:t.a,left:t.right,right:t.left,roomLeft:t.roomRight,roomRight:t.roomLeft,height:e?t.heightEnd:t.height,heightEnd:e?t.height:void 0}}function $y(t,e){let n=t.map(r=>({...r}));for(let r of e){let i=n.find(o=>o.room_id===r.room_id&&o.edge===r.edge&&(Math.abs(o.t1-r.t0)<1e-6||Math.abs(r.t1-o.t0)<1e-6));i?(i.t0=Math.min(i.t0,r.t0),i.t1=Math.max(i.t1,r.t1)):n.push({...r})}return n}function Sy(t,e,n){if(t.a===e.b)return!1;let r=ot(U(n[t.b],n[t.a])),i=ot(U(n[e.b],n[e.a]));return Math.abs(Re(r,i))>1e-6||te(r,i)<=0||t.free||e.free||t.heightEnd!==void 0||e.heightEnd!==void 0?!1:t.height===e.height&&t.exterior===e.exterior&&t.roomLeft===e.roomLeft&&t.roomRight===e.roomRight&&Math.abs(t.left-e.left)<=1e-9&&Math.abs(t.right-e.right)<=1e-9}function Wd(t,e,n=new Set){let r=t.slice();for(;;){let i=new Map;r.forEach((s,l)=>{for(let a of[s.a,s.b])i.set(a,[...i.get(a)??[],l])});let o=null;for(let[s,l]of i){if(l.length!==2||n.has(s))continue;let a=r[l[0]].b===s?r[l[0]]:Vd(r[l[0]]),c=r[l[1]].a===s?r[l[1]]:Vd(r[l[1]]);if(!Sy(a,c,e))continue;let u={...a,b:c.b,sources:$y(a.sources,c.sources)};o=[...r.filter((d,p)=>p!==l[0]&&p!==l[1]),u];break}if(!o)return r;r=o}}function Kd(t,e){let n=new Map;t.forEach((i,o)=>{let s=ot(U(e[i.b],e[i.a])),l=[[i.a,{key:`${o}:a`,d:s,left:i.left,right:i.right,angle:Math.atan2(s[1],s[0])}],[i.b,{key:`${o}:b`,d:it(s,-1),left:i.right,right:i.left,angle:Math.atan2(-s[1],-s[0])}]];for(let[a,c]of l)n.set(a,[...n.get(a)??[],c])});let r=new Map;for(let[i,o]of n){let s=e[i];o.sort((a,c)=>a.angle-c.angle);for(let a of o)r.set(a.key,{left:ft(s,it(pa(a.d),a.left)),right:ft(s,it(fa(a.d),a.right))});if(o.length<2)continue;let l=4*Math.max(...o.map(a=>Math.max(a.left,a.right)))+1e-9;o.forEach((a,c)=>{let u=o[(c+1)%o.length],d=ft(s,it(pa(a.d),a.left)),p=ft(s,it(fa(u.d),u.right)),h=Re(a.d,u.d);if(Math.abs(h)<1e-4)return;let f=ft(d,it(a.d,Re(U(p,d),u.d)/h));ge(U(f,s))>l||(r.get(a.key).left=f,r.get(u.key).right=f)})}return r}function jd(t,e){let n=t.filter((r,i)=>ge(U(r,t[(i+1)%t.length]))>e);for(;;){if(n.length<=3)return n;let r=n.findIndex((i,o)=>{let s=n[(o+n.length-1)%n.length],l=n[(o+1)%n.length],[a,c]=[U(i,s),U(l,i)];return Math.abs(Re(ot(a),ot(c)))<1e-7&&te(a,c)>0});if(r===-1)return n;n=n.filter((i,o)=>o!==r)}}function My(t){let e=[];return{points:e,idOf(n){let r=e.findIndex(i=>Math.abs(i[0]-n[0])<=t&&Math.abs(i[1]-n[1])<=t);return r>=0?r:(e.push([n[0],n[1]]),e.length-1)}}}function Ry(t,e){let n=[];for(let r of t){let i=r.points;if(i.length<3||Math.abs(_e(i))<1e-6)continue;let o=_e(i)>0,s=i.map(l=>e.idOf(l));s.forEach((l,a)=>{let c=s[(a+1)%s.length];l!==c&&n.push(o?{u:l,v:c,room:r.id,edge:a,forward:!0}:{u:c,v:l,room:r.id,edge:a,forward:!1})})}return n}function Ey(t,e,n){let r=[];for(let i of t){let[o,s]=[e[i.u],e[i.v]],l=U(s,o),a=ge(l),c=it(l,1/a),u=e.map((p,h)=>({id:h,rel:U(p,o)})).filter(({id:p,rel:h})=>p!==i.u&&p!==i.v&&te(h,c)>n&&te(h,c)({t:te(h,c),id:p})).sort((p,h)=>p.t-h.t),d=[{t:0,id:i.u},...u,{t:a,id:i.v}];for(let p=0;p+1({room_id:t.room,edge:t.edge,t0:t.t0,t1:t.t1});function Ay(t,e){let n=new Map(t.map(l=>[l.id,l])),r=new Map;for(let l of e){let a=`${l.room}:${l.edge}`;r.set(a,[...r.get(a)??[],l.t0].sort((c,u)=>c-u))}let i=l=>{let a=n.get(l.room)?.wall_heights?.[l.edge];return Array.isArray(a)?a[(r.get(`${l.room}:${l.edge}`)??[]).indexOf(l.t0)]??null:a},o=l=>{let a=n.get(l.room),[c,u]=[a?.wall_heights?.[l.edge],a?.wall_slopes?.[l.edge]];if(!a||typeof c!="number"||typeof u!="number"||c<=0||u<=0)return null;let[d,p]=[a.points[l.edge],a.points[(l.edge+1)%a.points.length]];return{from:c,to:u,length:Math.hypot(p[0]-d[0],p[1]-d[1])}},s=l=>{let a=o(l);if(!a||a.length<1e-9){let u=i(l);return typeof u=="number"&&u>0?[u,u]:[null,null]}let c=u=>a.from+(a.to-a.from)*u/a.length;return l.forward?[c(l.t0),c(l.t1)]:[c(l.t1),c(l.t0)]};return{heightsOf(l){let[a,c]=[1/0,1/0];for(let d of l){let[p,h]=s(d),[f,g]=d===l[0]?[p,h]:[h,p];f!==null&&(a=Math.min(a,f)),g!==null&&(c=Math.min(c,g))}let u=l.map(d=>n.get(d.room)?.ceiling);if(u.every(d=>typeof d=="number"&&d>0)){let d=Math.max(...u);a===1/0&&(a=d),c===1/0&&(c=d)}return{...a<1/0?{a}:{},...c<1/0?{b:c}:{}}},thicknessOf(l){let a=l.map(c=>{let u=n.get(c.room)?.wall_thickness?.[c.edge];return Array.isArray(u)?u[(r.get(`${c.room}:${c.edge}`)??[]).indexOf(c.t0)]:u}).filter(c=>typeof c=="number"&&c>0);return a.length?Math.max(...a):void 0},hasNoWall:l=>l.some(a=>i(a)===0)}}function Gd(t){let e=n=>Math.round(n*1e6)/1e6;return t.a===void 0||t.b===void 0?t.a!==void 0?{height:e(t.a)}:t.b!==void 0?{height:e(t.b)}:{}:Math.abs(t.a-t.b)<1e-6?{height:e(t.a)}:{height:e(t.a),heightEnd:e(t.b)}}function Fy(t,e,n,r){let i=Ay(e,t),o=new Map;for(let a of t){let c=a.up!==c&&p.u===c.v&&p.v===c.u&&p.room!==c.room);for(let p of a)p!==c&&p!==u&&p.room!==c.room&&r.push(`overlap:${c.room}:${p.room}`);let d=u?[c,u]:[c];if(i.hasNoWall(d)){u&&l.push([c.room,u.room]);continue}if(u){let p=i.thicknessOf(d)??n.interior;s.push({a:c.u,b:c.v,left:p/2,right:p/2,exterior:!1,roomLeft:c.room,roomRight:u.room,sources:d.map(Ud),...Gd(i.heightsOf(d))})}else s.push({a:c.u,b:c.v,left:0,right:i.thicknessOf(d)??n.exterior,exterior:!0,roomLeft:c.room,roomRight:null,sources:[Ud(c)],...Gd(i.heightsOf(d))})}return{drafts:s,open:l}}function Ty(t,e){let n=o=>ot(U(e[o.b],e[o.a])),r=t.filter(o=>!o.exterior&&!o.free),i=new Map;for(let o of r){if(i.has(o))continue;let s=[o];i.set(o,s);for(let l=0;l1e-6||a.add(te(s,h)>0?"left":"right")}if(a.size!==1)continue;let c=[...a][0];for(let u of o){let d=u.left+u.right,p=te(n(u),s)>0,h=c==="left"===p;[u.left,u.right]=h?[0,d]:[d,0]}}}var zy=(t,e)=>{let n=o=>Math.round(o*100),[r,i]=t[0]Math.hypot(y.b[0]-y.a[0],y.b[1]-y.a[1])>.05),a=l.map(y=>[o.idOf(y.a),o.idOf(y.b)]),c=new Set;for(let y of t){let v=y.points;v.length<3||(y.wall_splits??[]).forEach((w,x)=>{if(!w||x>=v.length)return;let k=v[x],M=U(v[(x+1)%v.length],k),E=ge(M);for(let T of w)T>r&&T{let[w,x]=a[v];if(w===x)return;let k=[(y.a[0]+y.b[0])/2,(y.a[1]+y.b[1])/2],M=t.find(T=>T.points.length>=3&&C(k,T.points))?.id??null,E=(y.thickness??e.interior)/2;h.push({free:y.id,a:w,b:x,left:E,right:E,exterior:!1,roomLeft:M,roomRight:M,sources:[],height:typeof y.height=="number"&&y.height>0?y.height:void 0,...typeof y.height=="number"&&y.height>0&&typeof y.height_end=="number"&&y.height_end>0&&Math.abs(y.height_end-y.height)>1e-6?{heightEnd:y.height_end}:{}})});let f=Wd(h,o.points,c),g=Kd(f,o.points);return{walls:f.map((y,v)=>{let[w,x]=[o.points[y.a],o.points[y.b]],[k,M]=[g.get(`${v}:a`),g.get(`${v}:b`)],E=jd([k.right,M.left,x,M.right,k.left,w],1e-6);return{id:zy(w,x),a:[w[0],w[1]],b:[x[0],x[1]],left:y.left,right:y.right,exterior:y.exterior,roomLeft:y.roomLeft,roomRight:y.roomRight,sources:y.sources,footprint:E,...y.free?{free:y.free}:{},...y.height!==void 0?{height:y.height}:{},...y.heightEnd!==void 0?{heightEnd:y.heightEnd}:{}}}),warnings:[...new Set(i)],open:p}}function Kn(t,e,n){let r=t.points[e];return ft(r,it(ot(U(t.points[(e+1)%t.points.length],r)),n))}function Ce(t,e,n){if(t.wall){let i=n.find(l=>l.id===t.wall);if(!i||Math.hypot(i.b[0]-i.a[0],i.b[1]-i.a[1])<.05)return null;let o=ot(U(i.b,i.a));return{room:{id:t.room_id,name:"",area_id:null,points:[i.a,i.b,ft(i.a,[-o[1],o[0]])]},edge:0}}let r=e.find(i=>i.id===t.room_id);return r&&t.edgete(U(e,t.a),ot(U(t.b,t.a)));function Kt(t,e,n){if(!e.wall)return Py(t,n.room,n.edge,e.offset);let r=t.find(i=>i.free===e.wall);return r?{wall:r,s:Zd(r,Kn(n.room,0,e.offset))}:null}function Py(t,e,n,r){for(let i of t)if(i.sources.some(s=>s.room_id===e.id&&s.edge===n&&r>=s.t0-1e-6&&r<=s.t1+1e-6))return{wall:i,s:Zd(i,Kn(e,n,r))};return null}function qd(t,e){let n=t.points.map(h=>h[0]),r=t.points.map(h=>h[1]);if(t.points.length!==4||new Set(n.map(h=>h.toFixed(3))).size!==2||new Set(r.map(h=>h.toFixed(3))).size!==2)return null;let[i,o,s,l]=[Math.min(...n),Math.max(...n),Math.min(...r),Math.max(...r)],a=h=>Math.max(0,...e.filter(f=>(f.roomLeft===t.id||f.roomRight===t.id)&&h(f)).map(f=>f.roomLeft===t.id?f.left:f.right)),c=(h,f)=>Math.abs(h-f)<.001,u=(h,f,g)=>c(h.a[f],g)&&c(h.b[f],g),d=o-i-a(h=>u(h,0,i))-a(h=>u(h,0,o)),p=l-s-a(h=>u(h,1,s))-a(h=>u(h,1,l));return[Math.round(d*1e3)/1e3,Math.round(p*1e3)/1e3]}var Yd=([t,e])=>{let n=Math.hypot(t,e)||1;return[t/n,e/n]};function Dy(t){return t.reduce((e,n,r)=>e+(n[0]*t[(r+1)%t.length][1]-t[(r+1)%t.length][0]*n[1]),0)/2}function Xd(t,e){let n=t.length;if(n<3||Math.abs(e)<1e-9)return t.map(([i,o])=>[i,o]);let r=Dy(t)>=0?1:-1;return t.map((i,o)=>{let s=t[(o+n-1)%n],l=t[(o+1)%n],[a,c]=Yd([i[0]-s[0],i[1]-s[1]]),[u,d]=Yd([l[0]-i[0],l[1]-i[1]]),p=[c*r,-a*r],h=[d*r,-u*r],f=[p[0]+h[0],p[1]+h[1]],g=Math.hypot(f[0],f[1]);if(g<1e-6)return[i[0]+p[0]*e,i[1]+p[1]*e];let b=(f[0]*p[0]+f[1]*p[1])/g,y=Math.min(4,1/Math.max(.25,b));return[i[0]+f[0]/g*e*y,i[1]+f[1]/g*e*y]})}function jt(t){let e=t.map(r=>r[0]),n=t.map(r=>r[1]);return{x0:Math.min(...e),z0:Math.min(...n),x1:Math.max(...e),z1:Math.max(...n)}}function Iy(t){let e=([o,s])=>`${Math.round(o*1e3)}:${Math.round(s*1e3)}`,n=new Map;for(let o of t)for(let s of[o.a,o.b])n.set(e(s),[...n.get(e(s))??[],o]);let r=new Set,i=null;for(let o of t){if(r.has(o))continue;r.add(o);let s=[o.a,o.b],l=o.b;for(;;){let c=(n.get(e(l))??[]).find(u=>!r.has(u));if(!c||(r.add(c),l=e(c.a)===e(l)?c.b:c.a,e(l)===e(s[0])))break;s.push(l)}s.length>=3&&e(l)===e(s[0])&&(!i||Math.abs(xe(s))>Math.abs(xe(i)))&&(i=s)}return i}function ya(t,e,n,r){let i=fe(t,{exterior:n,interior:r},e).walls.filter(l=>l.exterior&&!l.free),o=i.length?Iy(i.map(l=>({a:l.a,b:l.b}))):null;if(!o)return null;let s=o.filter((l,a)=>{let c=o[(a+o.length-1)%o.length],u=o[(a+1)%o.length];return Math.abs((l[0]-c[0])*(u[1]-l[1])-(l[1]-c[1])*(u[0]-l[0]))>1e-6});return s.length>=3?Xd(s,n):null}function hn(t,e){let n=$e(t),r=Le(t),i=n.w,[o,s]=[Math.max(0,e.a),Math.max(0,e.b)],l=n.u0-Math.max(0,e.u0),a=n.u1+Math.max(0,e.u1),c=(y,v)=>[y,v,r.y(v)],u=c(l,-o),d=c(a,-o),p=c(a,i+s),h=c(l,i+s),[f,g]=[st(t.pitch_a),st(t.pitch_b)],b=y=>[y,r.vr,r.rh];if(t.ends&&(t.shape==="gable"||t.shape==="hip"||t.shape==="halfhip")){let y=(n.u1-n.u0)/2,v=Math.min(y,Math.min(r.vr,i-r.vr)||i/2),w=Math.min(r.y(0),r.y(i)),x=w+(r.rh-w)*Math.min(.9,Math.max(.2,t.halfhip??.55)),k=f>1e-6?Math.min(r.vr,(x-t.eave_a)/f):r.vr,M=g>1e-6?Math.max(r.vr,i-(x-t.eave_b)/g):r.vr,E=Math.min(y-.1,(r.rh-x)/Math.max(.2,f)),T=[[0,r.y(0)],[r.vr,r.rh],[i,r.y(i)]],F=[[0,r.y(0)],[k,x],[M,x],[i,r.y(i)]],L=(j,Jt,Oi)=>{if(j==="hip")return{upA:[],upB:[],ridge:b(Jt===l?n.u0+v*Oi:n.u1-v*Oi),profile:null};if(j==="halfhip"){let pb=b(Jt===l?n.u0+E:n.u1-E);return{upA:[[Jt,k,x]],upB:[[Jt,M,x]],ridge:pb,profile:F}}return{upA:[],upB:[],ridge:b(Jt),profile:T}},P=L(t.ends[0],l,1),N=L(t.ends[1],a,1),V=[[u,d,...N.upA,N.ridge,P.ridge,...[...P.upA].reverse()],[P.ridge,N.ridge,...[...N.upB].reverse(),p,h,...P.upB]],q=[[P.ridge,N.ridge]];for(let[j,Jt,Oi]of[[P,u,h],[N,d,p]])j.profile===null?(V.push(j===P?[h,u,j.ridge]:[d,p,j.ridge]),q.push([Jt,j.ridge],[Oi,j.ridge])):j.upA.length&&(V.push(j===P?[j.upB[0],j.upA[0],j.ridge]:[j.upA[0],j.upB[0],j.ridge]),q.push([j.upA[0],j.ridge],[j.upB[0],j.ridge]));let ke=j=>j.profile===null?[]:j.upA.length?[j.upA[0],j.upB[0]]:[j.ridge],Ft=[u,d,...ke(N),p,h,...[...ke(P)].reverse()];return{faces:V,rim:Ft,ridges:q,gable:T,endProfiles:[P.profile,N.profile]}}switch(t.shape){case"pent":return{faces:[[u,d,p,h]],rim:[u,d,p,h],ridges:[[p,h]],gable:[[0,r.y(0)],[i,r.y(i)]]};case"hip":case"pyramid":{let y=(n.u1-n.u0)/2,v=t.shape==="pyramid"?y:Math.min(y,Math.min(r.vr,i-r.vr)||i/2),w=b(n.u0+v),x=b(n.u1-v);return t.shape==="pyramid"?{faces:[[u,d,w],[d,p,w],[p,h,w],[h,u,w]],rim:[u,d,p,h],ridges:[[u,w],[h,w],[d,w],[p,w]],gable:null}:{faces:[[u,d,x,w],[w,x,p,h],[h,u,w],[d,p,x]],rim:[u,d,p,h],ridges:[[w,x],[u,w],[h,w],[d,x],[p,x]],gable:null}}case"halfhip":{let y=Math.min(r.y(0),r.y(i)),v=y+(r.rh-y)*Math.min(.9,Math.max(.2,t.halfhip??.55)),w=f>1e-6?Math.min(r.vr,(v-t.eave_a)/f):r.vr,x=g>1e-6?Math.max(r.vr,i-(v-t.eave_b)/g):r.vr,k=Math.min((n.u1-n.u0)/2-.1,(r.rh-v)/Math.max(.2,f)),M=b(n.u0+k),E=b(n.u1-k),T=[l,w,v],F=[l,x,v],L=[a,w,v],P=[a,x,v];return{faces:[[u,d,L,E,M,T],[M,E,P,p,h,F],[F,T,M],[L,P,E]],rim:[u,d,L,P,p,h,F,T],ridges:[[M,E],[T,M],[F,M],[L,E],[P,E]],gable:[[0,r.y(0)],[w,v],[x,v],[i,r.y(i)]]}}case"mansard":{let y=Vr(i,t.eave_a,t.eave_b,f,g),v=[l,y.vla,y.yla],w=[a,y.vla,y.yla],x=[l,i-y.vlb,y.ylb],k=[a,i-y.vlb,y.ylb],M=[l,y.vr,y.rh],E=[a,y.vr,y.rh];return{faces:[[u,d,w,v],[v,w,E,M],[M,E,k,x],[x,k,p,h]],rim:[u,d,w,E,k,p,h,x,M,v],ridges:[[M,E],[v,w],[x,k]],gable:[[0,r.y(0)],[y.vla,y.yla],[y.vr,y.rh],[i-y.vlb,y.ylb],[i,r.y(i)]]}}default:{let y=b(l),v=b(a);return{faces:[[u,d,v,y],[y,v,p,h]],rim:[u,d,v,p,h,y],ridges:[[y,v]],gable:[[0,r.y(0)],[r.vr,r.rh],[i,r.y(i)]]}}}}function Wr(t,e,n){let r=null;for(let i of t.faces){if(!C([e,n],i.map(([p,h])=>[p,h])))continue;let[o,s]=i,l=i.slice(2).find(p=>Math.abs((s[0]-o[0])*(p[1]-o[1])-(s[1]-o[1])*(p[0]-o[0]))>1e-9);if(!l)continue;let a=[s[0]-o[0],s[2]-o[2],s[1]-o[1]],c=[l[0]-o[0],l[2]-o[2],l[1]-o[1]],u=[a[1]*c[2]-a[2]*c[1],a[2]*c[0]-a[0]*c[2],a[0]*c[1]-a[1]*c[0]];if(Math.abs(u[1])<1e-9)continue;let d=o[2]-(u[0]*(e-o[0])+u[2]*(n-o[1]))/u[1];r=r===null?d:Math.min(r,d)}return r}function Kr(t,e,n){let r=$e(e),i=t.floors.flatMap(d=>d.rooms.filter(p=>p.points.length>=3&&d.elevation+d.height>e.base+.05)),o=d=>d.some(p=>i.some(h=>C(p,h.points))),s=.35,l=[.15,.5,.85].map(d=>r.u0+(r.u1-r.u0)*d),a=[.15,.5,.85].map(d=>r.w*d),c=d=>d?0:n,u=(d,p)=>{let h=e.overhang_sides?.[d];return typeof h=="number"&&Number.isFinite(h)?Math.min(2,Math.max(0,h)):p};return{a:u("a",c(o(l.map(d=>r.at(d,-s))))),b:u("b",c(o(l.map(d=>r.at(d,r.w+s))))),u0:u("u0",c(o(a.map(d=>r.at(r.u0-s,d))))),u1:u("u1",c(o(a.map(d=>r.at(r.u1+s,d)))))}}var vo=t=>Math.abs((t.x1-t.x0)*(t.z1-t.z0)),Jd=t=>t.shape==="flat"||t.shape==="parapet",pn=t=>Math.round(t*100)/100;function wo(t,e){let[n,r]=[(e.x0+e.x1)/2,(e.z0+e.z1)/2];return t.filter(o=>{if(o===e||o.dormer||o.open||Jd(o)||vo(o)=s.x0&&n<=s.x1&&r>=s.z0&&r<=s.z1}).reduce((o,s)=>o===null||vo(s){let[o,s]=e.at(i,e.w/2),[l,a]=Br(t,o,s);return Wr(n,l,a)??r.y(a)}}function wa(t,e){if(Jd(e))return e;let n=$e(e),r=Le(e).rh,i=Hy(t,n),o=i(n.u0)<=i(n.u1),[s,l]=o?[n.u0,n.u1]:[n.u1,n.u0],a=o?1:-1,c=l;for(let p=.5;p=r-.02){c=s+a*p;break}if(Math.abs(c-l)<.05)return e;let u={...e},d=l===n.u1;return e.axis==="x"?u[d?"x1":"x0"]=c:u[d?"z1":"z0"]=c,u}var ka=.14,Qd=t=>t.shape==="flat"||t.shape==="parapet";function xa(t,e){return!t.open&&Math.min(t.base,t.eave_a,t.eave_b)a+i||pu+i||s.points&&s.points.length>=3&&!C([e,n],s.points))continue;let[h,f]=Br(s,e,n),g=Math.max(0,s.overhang??r),b=Qd(s)?null:Wr(hn(s,{u0:g,u1:g,a:g,b:g}),h,f);o.push((b??Le(s).y(f))-ka)}return o.length?Math.max(...o):null}function $a(t,e,n){let r=[],i=e+n+ka;for(let o of t.settings.roof.sections??[]){if(o.open||Qd(o)||o.shape==="mansard")continue;let s=$e(o),l=Le(o),[a,c]=[st(o.pitch_a),st(o.pitch_b)],u=[];a>1e-6&&u.push((i-o.eave_a)/a),o.shape==="gable"&&c>1e-6&&u.push(s.w-(i-o.eave_b)/c);for(let d of u)d<=.01||d>=s.w-.01||o.shape==="gable"&&Math.abs(l.y(d)-i)>1e-6||r.push([s.at(s.u0,d),s.at(s.u1,d)])}return r}function Sa(t,e,n,r,i){let o=[];for(let l of[.2,.5,.8])for(let a of[.2,.5,.8])o.push([e+(r-e)*l,n+(i-n)*a]);let s=t.floors.filter(l=>l.rooms.some(a=>a.points.length>=3&&o.some(c=>C(c,a.points)))).map(l=>l.elevation+l.height);return s.length?Math.max(...s):null}function Ma(t,e){let n=t.floors.filter(a=>a.rooms.length>0).sort((a,c)=>a.elevation-c.elevation),r=n.filter(a=>a.elevationu.rooms.some(d=>d.points.length>=3&&a.some(p=>C(p,d.points))));if(c)return c}return r.at(-1)??n[0]}var xt=t=>Math.round(t*1e3)/1e3;function Ra(t,e=n=>`roof_${n+1}`){let n=t.settings.roof?.pitch??35,r=t.settings.wall_exterior,i=t.floors.filter(a=>a.rooms.some(c=>c.points.length>=3)).sort((a,c)=>c.elevation-a.elevation),o=[],s=[],l=(a,c)=>a.some(u=>C(c,u.points));for(let a of i){let c=a.rooms.filter(b=>b.points.length>=3),u=[...new Set(c.flatMap(b=>b.points.map(y=>xt(y[0]))))].sort((b,y)=>b-y),d=[...new Set(c.flatMap(b=>b.points.map(y=>xt(y[1]))))].sort((b,y)=>b-y),p=d.slice(0,-1).map((b,y)=>u.slice(0,-1).map((v,w)=>{let x=[(u[w]+u[w+1])/2,(d[y]+d[y+1])/2];return l(c,x)&&!l(s,x)})),h=p.map(b=>b.map(()=>!1)),f=(b,y)=>p[y][b]&&!h[y][b],g=a.elevation+a.height;for(let b=0;bf(y+F,w+1)).every(Boolean);)w++;for(let T=b;T<=w;T++)for(let F=y;F<=v;F++)h[T][F]=!0;let[x,k]=[u[y]-r,u[v+1]+r],[M,E]=[d[b]-r,d[w+1]+r];Math.min(k-x,E-M)<.8||o.push({id:e(o.length),x0:xt(x),z0:xt(M),x1:xt(k),z1:xt(E),shape:"gable",axis:k-x>=E-M?"x":"z",eave_a:xt(g),eave_b:xt(g),pitch_a:n,pitch_b:n,base:xt(g),overhang:null})}s.push(...c)}return o}var Ee=Math.PI/180,Ge=(t,e)=>[t[0]-e[0],t[1]-e[1],t[2]-e[2]],fn=(t,e)=>t[0]*e[0]+t[1]*e[1]+t[2]*e[2],jn=t=>Math.hypot(t[0],t[1],t[2]),mn=t=>{let e=jn(t)||1;return[t[0]/e,t[1]/e,t[2]/e]},eh=(t,e)=>[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]],Ze=t=>Math.round(t*100)/100,Ur=([t,e],n)=>(Math.atan2(t,-e)/Ee-n+720)%360;var nh=.25;function rh(t,e,n,r,i,o,s){let l=i-n>=o-r,a=l?i-n:o-r;return{key:`${t}:top`,section:e,side:"top",flat:!0,o:[n,s,r],eu:l?[1,0,0]:[0,0,1],es:l?[0,0,1]:[1,0,0],n:[0,1,0],lu:a,ls:l?o-r:i-n,pitch:0,span:()=>[0,a],facing:l?[0,1]:[1,0]}}function ih(t,e){let n=mn(eh(t,e));return n[1]<0?[-n[0],-n[1],-n[2]]:n}var oh=t=>{let e=mn([-t[0],0,-t[2]]);return[e[0],e[2]]};function $t(t,e,n,r,i,o,s,l){let a=mn(Ge(i,r)),c=mn(Ge(o,r));return{key:t,section:e,side:n,flat:!1,o:r,eu:a,es:c,n:ih(a,c),lu:jn(Ge(i,r)),ls:jn(Ge(o,r)),pitch:s,span:l,facing:oh(c)}}function th(t,e,n,r,i,o){let s=jn(Ge(i,r));if(s<.3)return null;let l=mn(Ge(i,r)),a=Ge(o,r),c=a[0]*l[0]+a[1]*l[1]+a[2]*l[2],u=[a[0]-l[0]*c,a[1]-l[1]*c,a[2]-l[2]*c],d=jn(u);if(d<.3)return null;let p=mn(u),h=f=>{let g=Math.min(1,Math.max(0,f/d));return[c*g,s-(s-c)*g]};return{key:t,section:e,side:n,flat:!1,o:r,eu:l,es:p,n:ih(l,p),lu:s,ls:d,pitch:Math.atan2(p[1],Math.hypot(p[0],p[2]))/Ee,span:h,facing:oh(p)}}function Ly(t,e){let n=$e(t),r=Le(t),i=(v,w,x)=>{let[k,M]=n.at(v,w);return[k,x,M]},[o,s]=[Math.max(0,e.a),Math.max(0,e.b)],l=n.u0-Math.max(0,e.u0),a=n.u1+Math.max(0,e.u1),c=a-l,u=r.y(-o),d=r.y(n.w+s);if(t.shape==="flat"||t.shape==="parapet"){let[v,w]=[n.at(l,-o),n.at(a,n.w+s)];return[rh(t.id,t.id,Math.min(v[0],w[0]),Math.min(v[1],w[1]),Math.max(v[0],w[0]),Math.max(v[1],w[1]),t.eave_a+nh)]}if(t.shape==="pent")return[$t(`${t.id}:a`,t.id,"a",i(l,-o,u),i(a,-o,u),i(l,n.w+s,d),t.pitch_a,()=>[0,c])];if(t.shape==="mansard")return Cy(t,n,l,a,o,s);let p=t.shape==="hip"||t.shape==="pyramid",h=(n.u1-n.u0)/2,f=t.shape==="pyramid"?h:p?Math.min(h,Math.min(r.vr,n.w-r.vr)||n.w/2):0,g=p?n.u0+f-l:0,b=p?a-(n.u1-f):0,y=[];if(r.vr>.3){let v=Math.hypot(r.vr+o,r.rh-u);y.push($t(`${t.id}:a`,t.id,"a",i(l,-o,u),i(a,-o,u),i(l,r.vr,r.rh),t.pitch_a,w=>[g*(w/v),c-b*(w/v)]))}if(n.w-r.vr>.3){let v=Math.hypot(n.w+s-r.vr,r.rh-d);y.push($t(`${t.id}:b`,t.id,"b",i(a,n.w+s,d),i(l,n.w+s,d),i(a,r.vr,r.rh),t.pitch_b,w=>[b*(w/v),c-g*(w/v)]))}if(p){let v=th(`${t.id}:c`,t.id,"c",i(l,n.w+s,d),i(l,-o,u),i(n.u0+f,r.vr,r.rh)),w=th(`${t.id}:d`,t.id,"d",i(a,-o,u),i(a,n.w+s,d),i(n.u1-f,r.vr,r.rh));y.push(...[v,w].filter(x=>x!==null))}return y}function Cy(t,e,n,r,i,o){let s=Vr(e.w,t.eave_a,t.eave_b,st(t.pitch_a),st(t.pitch_b)),l=(f,g)=>{let[b,y]=e.at(f,g);return[b,s.y(g),y]},a=r-n,c=()=>[0,a],u=(f,g)=>Math.atan2(f,g)/Ee,d=[],[p,h]=[e.w+o,e.w-s.vlb];return s.vla+i>.3&&d.push($t(`${t.id}:a`,t.id,"a",l(n,-i),l(r,-i),l(n,s.vla),t.pitch_a,c)),s.vr-s.vla>.3&&d.push($t(`${t.id}:au`,t.id,"a",l(n,s.vla),l(r,s.vla),l(n,s.vr),u(s.rh-s.yla,s.vr-s.vla),c)),s.vlb+o>.3&&d.push($t(`${t.id}:b`,t.id,"b",l(r,p),l(n,p),l(r,h),t.pitch_b,c)),h-s.vr>.3&&d.push($t(`${t.id}:bu`,t.id,"b",l(r,h),l(n,h),l(r,s.vr),u(s.rh-s.ylb,h-s.vr),c)),d}function Ea(t){return t.floors.filter(n=>n.rooms.some(r=>r.points.length>=3)).sort((n,r)=>r.elevation-n.elevation)[0]??null}function Z(t){let e=t.settings.roof;if(!e||e.type==="none")return[];if(e.type==="custom")return(e.sections??[]).flatMap(w=>Ly(w,Kr(t,w,w.overhang??e.overhang)));let n=Ea(t);if(!n)return[];let r=n.rooms.flatMap(w=>w.points.map(x=>x[0])),i=n.rooms.flatMap(w=>w.points.map(x=>x[1])),o=t.settings.wall_exterior+e.overhang,[s,l]=[Math.min(...r)-o,Math.max(...r)+o],[a,c]=[Math.min(...i)-o,Math.max(...i)+o],u=n.elevation+n.height;if(e.type==="flat")return[rh("main",null,s,a,l,c,u+nh)];let d=l-s>=c-a,p=e.ridge==="short"?!d:d,h=(p?c-a:l-s)/2,f=h*Math.tan(e.pitch*Ee),g=(w,x,k)=>p?[w,u+k,(a+c)/2+x]:[(s+l)/2+x,u+k,w],[b,y]=p?[s,l]:[a,c],v=()=>[0,y-b];return[$t("main:a",null,"a",g(b,-h,0),g(y,-h,0),g(b,0,f),e.pitch,v),$t("main:b",null,"b",g(b,h,0),g(y,h,0),g(b,0,f),e.pitch,v)]}function qe(t,e){let n=[];for(let r of t.floors.filter(i=>!e||i.id===e)){let{walls:i}=fe(r.rooms,{exterior:t.settings.wall_exterior,interior:t.settings.wall_interior},r.walls??[]);for(let o of i){if(!o.exterior&&!o.free)continue;let[s,l]=[o.b[0]-o.a[0],o.b[1]-o.a[1]],a=Math.hypot(s,l);if(a<1.2)continue;let[c,u]=[l/a,-s/a],d=Math.min(r.height,o.height??r.height,o.heightEnd??1/0),p=(h,f,g,b)=>n.push({key:h,section:null,side:"top",flat:!1,o:f,eu:g,es:[0,1,0],n:b,lu:a,ls:d,pitch:90,span:()=>[0,a],facing:[b[0],b[2]],wall:{floorId:r.id}});p(`wall:${r.id}:${o.id}`,[o.a[0]+c*o.right,r.elevation,o.a[1]+u*o.right],[s/a,0,l/a],[c,0,u]),o.free&&p(`wall:${r.id}:${o.id}:back`,[o.b[0]-c*o.left,r.elevation,o.b[1]-u*o.left],[-s/a,0,-l/a],[-c,0,-u])}}return n}var Ne="ground";function ko(t){let e=t.floors.filter(n=>n.rooms.some(r=>r.points.length>=3)).sort((n,r)=>n.elevation-r.elevation);return e.find(n=>n.elevation>-.5)??e[0]??t.floors[0]??null}function xo(t,e){let n=(e.rotation??0)*Ee,r=[Math.cos(n),0,Math.sin(n)],i=[-Math.sin(n),0,Math.cos(n)],o=ko(t),s=r[0]*e.u+i[0]*e.v,l=r[2]*e.u+i[2]*e.v,a=o?o.elevation+(e.base!=null?e.base:wu(o,s,l)):e.base??0;return{key:Ne,section:null,side:"top",flat:!0,o:[0,a,0],eu:r,es:i,n:[0,1,0],lu:1e4,ls:1e4,pitch:0,span:()=>[-1e4,1e4],facing:[i[0],i[2]],unbounded:!0}}function Se(t,e,n=Z(t)){return e.face===Ne?xo(t,e):e.face.startsWith("wall:")?qe(t,e.face.split(":")[1]).find(r=>r.key===e.face)??null:n.find(r=>r.key===e.face)??null}var $o=1.13,Zr=1.72,Ye=.025,at=.07;function gn(t){let e=t.module_w||$o,n=t.module_h||Zr;return t.portrait===!1?[n,e]:[e,n]}function qr(t){return t.layout?.length?t.layout.map(e=>Math.max(0,Math.min(60,Math.round(e)))):Array.from({length:Math.max(1,t.rows)},()=>Math.max(1,t.cols))}function Aa(t,e){return t.flat?Math.min(45,Math.max(0,e.tilt??15))*Ee:t.wall?Math.min(90,Math.max(0,e.tilt??0))*Ee:Math.min(45,Math.max(0,e.tilt??0))*Ee}function Yr(t,e){let[,n]=gn(e),r=Aa(t,e);return t.wall?n*Math.cos(r)+Ye:!t.flat&&r<.001?n+Ye:t.flat&&e.rack==="ew"?n*Math.cos(r)+.08:n*Math.cos(r)+Math.max(.3,2*n*Math.sin(r))}function Un(t,e){let[n,r]=gn(e),i=qr(e),o=Math.max(1,...i);return[o*n+(o-1)*Ye,(i.length-1)*Yr(t,e)+r*Math.cos(Aa(t,e))]}var Ny=t=>t.flat&&!t.unbounded&&!t.wall;function sh(t,e){if(!Ny(t)||!e.rotation)return null;let n=e.rotation*Ee,[r,i]=Un(t,e);return{cos:Math.cos(n),sin:Math.sin(n),u:e.u+r/2,s:e.v+i/2}}function Xe(t,e,n=!1){let[r,i]=gn(e),o=Aa(t,e),s=i*Math.cos(o),l=Yr(t,e),a=qr(e),c=Math.max(1,...a),u=new Set(e.skip??[]),d=sh(t,e),p=(b,y)=>d?[d.u+(b-d.u)*d.cos-(y-d.s)*d.sin,d.s+(b-d.u)*d.sin+(y-d.s)*d.cos]:[b,y],h=(b,y,v)=>{let[w,x]=p(b,y);return[0,1,2].map(k=>t.o[k]+t.eu[k]*w+t.es[k]*x+t.n[k]*v)},f=(b,y)=>{let[v,w]=p(b,y);if(t.unbounded)return!0;if(w<-1e-6||w>t.ls+1e-6)return!1;let[x,k]=t.span(w);return v>=x-1e-6&&v<=k+1e-6},g=[];return a.forEach((b,y)=>{let v=e.align==="right"?c-b:e.align==="center"?(c-b)/2:0;for(let w=0;w.001?s:i);if([[M,T],[E,T],[E,F],[M,F]].every(([L,P])=>f(L,P)))if(t.wall&&o>.001){let L=at+i*Math.sin(o),[P,N]=e.flip?[L,at]:[at,L],V=[h(M,T,P),h(E,T,P),h(E,F,N),h(M,F,N)],q=e.flip?T:F;g.push({corners:V,posts:[M+.05,E-.05].map(ke=>[h(ke,q,0),h(ke,q,L)]),cell:x,skipped:k})}else if(!t.flat&&o>.001){let L=at+i*Math.sin(o),P=[h(M,T,at),h(E,T,at),h(E,F,L),h(M,F,L)];g.push({corners:P,posts:[M+.05,E-.05].map(N=>[h(N,F,0),h(N,F,L)]),cell:x,skipped:k})}else if(!t.flat)g.push({corners:[h(M,T,at),h(E,T,at),h(E,F,at),h(M,F,at)],posts:[],cell:x,skipped:k});else{let P=.15+i*Math.sin(o),N=e.rack==="ew"&&y%2===1?!e.flip:!!e.flip,[V,q]=N?[F,T]:[T,F],ke=[h(M,V,.15),h(E,V,.15),h(E,q,P),h(M,q,P)],Ft=[M+.05,E-.05].flatMap(j=>[[h(j,V,0),h(j,V,.15)],[h(j,q,0),h(j,q,P)]]);g.push({corners:ke,posts:Ft,cell:x,skipped:k})}}}),g}function mt(t,e){if(t.unbounded)return{u:e.u,v:e.v};let[n,r]=Un(t,e),i=sh(t,e);if(i){let[s,l]=[(n*Math.abs(i.cos)+r*Math.abs(i.sin))/2,(n*Math.abs(i.sin)+r*Math.abs(i.cos))/2],a=(d,p,h)=>Math.floor(Math.max(p,Math.min(d,h-p))*100+1e-6)/100,[c,u]=[e.u+n/2,e.v+r/2];return{u:Math.round((a(c,s,t.lu)-n/2)*100)/100,v:Math.round((a(u,l,t.ls)-r/2)*100)/100}}let o=s=>Math.floor(s*100+1e-6)/100;return{u:o(Math.min(Math.max(0,e.u),Math.max(0,t.lu-n))),v:o(Math.min(Math.max(0,e.v),Math.max(0,t.ls-r)))}}function Xr(t,e){let[n,r]=Un(t,e),[i,o]=[e.u+n/2,e.v+r/2];return[t.o[0]+t.eu[0]*i+t.es[0]*o,t.o[2]+t.eu[2]*i+t.es[2]*o]}var So=.78,Jr=1.18,_n=t=>({id:t.id,face:t.face,u:t.u,v:t.v,rows:1,cols:1,portrait:!0,module_w:t.w||So,module_h:t.h||Jr});function Fa(t,e){let n=Xe(t,_n(e))[0];if(!n)return null;let r=i=>[i[0]-t.n[0]*.05,i[1]-t.n[1]*.05,i[2]-t.n[2]*.05];return n.corners.map(r)}var Gr={brick:{w:.5,d:.5,h:1},round:{w:.4,d:.4,h:1},wide:{w:1,d:.5,h:1},steel:{w:.2,d:.2,h:1.2}};function bn(t){let e=t.shape??"brick",n=Gr[e]??Gr.brick;return{shape:e,w:t.w||n.w,d:t.d||n.d,h:t.h||n.h}}function St(t,e){let{w:n,d:r}=bn(t),i=e&&!e.flat?Math.cos(e.pitch*Ee):1;return{id:t.id,face:t.face,u:t.u,v:t.v,rows:1,cols:1,portrait:!0,module_w:n,module_h:r/Math.max(.2,i),tilt:0}}function Ta(t,e){let n=St(e,t),[r,i]=[n.module_w,n.module_h],o=(u,d)=>[t.o[0]+t.eu[0]*u+t.es[0]*d,t.o[1]+t.eu[1]*u+t.es[1]*d,t.o[2]+t.eu[2]*u+t.es[2]*d],[s,l]=[o(e.u+r/2,e.v),o(e.u+r/2,e.v+i)],a=o(e.u+r/2,e.v+i/2),c=u=>{let d=Math.hypot(u[0],u[2])||1;return[u[0]/d,u[2]/d]};return{center:[a[0],a[2]],along:c(t.eu),across:c(t.es),low:Math.min(s[1],l[1]),high:Math.max(s[1],l[1])}}function za(t,e){let[n]=gn(e);return Ze((t.lu-(e.cols*n+(e.cols-1)*Ye))/2)}var Qr=.4;function Gn(t,e){let n={id:e,face:t.key,u:0,v:0,rows:1,cols:1,portrait:!0,tilt:t.flat?15:null,flip:!1,entity:null,look:"black"},[r]=gn(n),[i,o]=t.span(t.ls/2);for(n.cols=Math.max(1,Math.floor((o-i-2*Qr+Ye)/(r+Ye))),n.rows=Math.max(1,Math.min(4,Math.floor((t.ls-2*Qr)/Yr(t,n))));n.cols>1&&Xe(t,{...n,u:za(t,n),v:Qr}).lengthl.lu*(1.3+Math.cos((Ur(l.facing,r)-180)*Math.PI/180)),o=qe(t,n).sort((l,a)=>i(a)-i(l))[0];if(!o)return null;let s={...Gn(o,e),portrait:!1,rows:1};return s.cols=Math.max(1,Math.floor((o.lu-.8+Ye)/(Zr+Ye))),s.u=Ze((o.lu-(s.cols*Zr+(s.cols-1)*Ye))/2),s.v=Ze(Math.max(0,o.ls-$o-.3)),s}function ei(t,e){let n=t.floors.flatMap(o=>o.rooms.flatMap(s=>s.points)),r=n.length?Math.max(...n.map(o=>o[0]))+3:0,i=n.length?Math.min(...n.map(o=>o[1])):0;return{id:e,face:Ne,u:Ze(r),v:Ze(i),rows:2,cols:4,portrait:!0,tilt:25,flip:!0,rotation:(t.settings.north??0)||0,look:"black",entity:null}}function ti(t,e,n){let r=xo(t,e),[i,o]=Un(r,e),[s,l]=[e.u+i/2,e.v+o/2],a=[r.eu[0]*s+r.es[0]*l,r.eu[2]*s+r.es[2]*l],c=n*Ee,u=a[0]*Math.cos(c)+a[1]*Math.sin(c)-i/2,d=a[0]*-Math.sin(c)+a[1]*Math.cos(c)-o/2;return{u:Ze(u),v:Ze(d),rotation:(Math.round(n)%360+360)%360}}function ni(t,e){let[n,r]=t.span(t.ls/2);return{id:e,face:t.key,u:Ze((n+r-So)/2),v:Ze(Math.max(0,Math.min(t.ls-Jr,t.ls*.45-Jr/2))),w:null,h:null,cover:null,contact:null,tilt:null}}function ri(t,e){let n=Gr.brick,[r,i]=t.span(t.ls*.8),o=St({id:e,face:t.key,u:0,v:0},t).module_h;return{id:e,face:t.key,u:Ze((r+i-n.w)/2),v:Ze(Math.max(0,Math.min(t.ls-o,t.ls*.8-o/2))),shape:"brick",w:null,d:null,h:null}}function Zn(t,e){let[n,r]=[e[0]-t.o[0],e[1]-t.o[2]],[i,o,s,l]=[t.eu[0],t.eu[2],t.es[0],t.es[2]],a=i*l-o*s;if(Math.abs(a)<1e-9)return null;let c=(n*l-r*s)/a,u=(i*r-o*n)/a;if(u<0||u>t.ls)return null;let[d,p]=t.span(u);return c>=d&&c<=p?{u:c,s:u}:null}function Da(t,e){let n=null;for(let r of t){if(r.wall){let[s,l]=[e[0]-r.o[0],e[1]-r.o[2]],a=s*r.eu[0]+l*r.eu[2],c=s*r.n[0]+l*r.n[2],u=a>=0&&a<=r.lu;if(u&&c>=-.05&&c<=.35)return{face:r,u:a,s:Number.NaN};u&&c>.35&&c<=.8&&!n&&(n={face:r,u:a,s:Number.NaN,y:-1/0});continue}let i=Zn(r,e);if(!i)continue;let o=r.o[1]+r.es[1]*i.s;(!n||o>n.y)&&(n={face:r,...i,y:o})}return n&&{face:n.face,u:n.u,s:n.s}}function Ro(t,e,n){let r=fn(n,t.n);if(Math.abs(r)<1e-6)return null;let i=fn(Ge(t.o,e),t.n)/r;if(i<=0)return null;let o=Ge([e[0]+n[0]*i,e[1]+n[1]*i,e[2]+n[2]*i],t.o);return{t:i,u:fn(o,t.eu),s:fn(o,t.es)}}function Ia(t,e,n){if(t.unbounded)return!0;if(n<0||n>t.ls)return!1;let[r,i]=t.span(n);return e>=r&&e<=i}function Oa(t,e,n,r){return Xe(t,e).some(o=>{let s=o.corners.map(c=>{let u=Ge(c,t.o);return[fn(u,t.eu),fn(u,t.es)]}),l=s.map(c=>c[0]),a=s.map(c=>c[1]);return n>=Math.min(...l)-.05&&n<=Math.max(...l)+.05&&r>=Math.min(...a)-.05&&r<=Math.max(...a)+.05})}var By=["n","ne","e","se","s","sw","w","nw"],Ha=(t,e)=>By[Math.round(Ur(t.facing,e)/45)%8];function ii(t,e){let n=r=>{if(r.flat)return r.lu*r.ls*.8;let i=Math.cos((Ur(r.facing,e)-180)*Math.PI/180);return r.lu*r.ls*(1.2+i)};return[...t].sort((r,i)=>n(i)-n(r))[0]??null}var uh=["kitchen_row","kitchen_l","bath","bedroom","living","dining","office","kids","hall"],ah={kitchen_row:{rows:[["back","start",["fridge","kitchen_tall",["kitchen",[.9,.62,.92]],"sink","dishwasher","stove",["kitchen",[.6,.62,.92]]]],["back","start",[["kitchen_wall",[1.2,.35,.7]]]]],spots:[[["table",[1.2,.8,.75]],.5,.72,0],["lamp_pendant",.5,.72,0],["lamp_ceiling",.5,.3,0]]},kitchen_l:{rows:[["back","start",["fridge",["kitchen",[.9,.62,.92]],"sink","dishwasher","stove"]],["right","start",[["kitchen",[.9,.62,.92]],["kitchen",[.6,.62,.92]],"kitchen_tall"]],["back","start",[["kitchen_wall",[1.2,.35,.7]]]]],spots:[["table",.4,.68,0],["bar_stool",.72,.86,180],["lamp_ceiling",.5,.35,0]]},bath:{rows:[["back","center",["washbasin"]],["back","end",["wc"]],["front","start",["bathtub"]],["left","start",["washer"]]],spots:[["lamp_downlight",.5,.5,0]]},bedroom:{rows:[["back","center",["nightstand","bed","nightstand"]],["left","center",[["wardrobe",[2,.6,2.1]]]],["front","end",["dresser"]]],spots:[["lamp_ceiling",.5,.55,0]]},living:{rows:[["back","center",["tv_board"]],["right","start",["shelf"]]],spots:[["sofa",.5,.72,180],["coffee_table",.5,.52,0],[["rug",[2.2,1.6,.01]],.5,.55,0],["armchair",.14,.5,270],["lamp_floor",.86,.8,0],["plant",.9,.12,0],["lamp_ceiling",.5,.45,0]]},dining:{rows:[["back","center",["sideboard"]]],spots:[["table",.5,.55,0],["chair",.4,.35,0],["chair",.6,.35,0],["chair",.4,.75,180],["chair",.6,.75,180],["lamp_pendant",.5,.55,0]]},office:{rows:[["back","center",["desk"]],["left","center",["shelf","shelf"]]],spots:[["office_chair",.5,.38,180],["lamp_ceiling",.5,.55,0]]},kids:{rows:[["left","start",[["bed",[.9,2,.8]]]],["back","end",[["desk",[1.2,.6,.75]]]],["right","end",["shelf"]]],spots:[[["rug",[1.6,1.2,.01]],.55,.6,0],["lamp_ceiling",.5,.5,0]]},hall:{rows:[["left","start",["coat_rack"]]],spots:[["lamp_downlight",.5,.3,0],["lamp_downlight",.5,.7,0]]}},lh=t=>typeof t=="string"?t:t[0],Eo=t=>typeof t=="string"?nt[t]:t[1],qn=.05,Vy=.02,ch=t=>Math.round(t*1e3)/1e3;function Wy(t,e,n,r){switch(e){case"back":return{x:t.x0+n,z:t.z0+r,turn:0};case"right":return{x:t.x1-r,z:t.z0+n,turn:90};case"front":return{x:t.x1-n,z:t.z1-r,turn:180};case"left":return{x:t.x0+r,z:t.z1-n,turn:270}}}function dh(t,e,n){let r=de(t.points),i=r.x1-r.x0,o=r.z1-r.z0,s=[],l=(a,c,u,d,[p,h,f])=>{s.push({id:n(),type:a,x:ch(c),z:ch(u),rotation:d,w:p,d:h,h:f,variant:null,entity:null,power:null})};for(let[a,c,u]of ah[e].rows){let d=a==="back"||a==="front"?i:o,p=0,h=[];for(let g of u){if(p+Eo(g)[0]>d-.1)break;h.push(g),p+=Eo(g)[0]}let f=c==="start"?qn:c==="end"?d-p-qn:(d-p)/2;for(let g of h){let b=Eo(g),y=Wy(r,a,f+b[0]/2,b[1]/2+Vy);l(lh(g),y.x,y.z,y.turn,b),f+=b[0]}}for(let[a,c,u,d]of ah[e].spots){let p=Eo(a),h=(b,y,v)=>Math.min(v,Math.max(y,b)),f=h(r.x0+i*c,r.x0+p[0]/2+qn,r.x1-p[0]/2-qn),g=h(r.z0+o*u,r.z0+p[1]/2+qn,r.z1-p[1]/2-qn);l(lh(a),f,g,d,p)}return s}var Ky=30*Math.PI/180,hh=.05;function La(t){let e=t.points.length;return t.points.map((n,r)=>{let i=t.points[(r+1)%e];return Math.hypot(i[0]-n[0],i[1]-n[1])})}function oi(t){return La(t).reduce((e,n)=>e+n,0)}function jy(t,e){let n=La(t),r=0;for(let i=0;ih+f,0);if(i<3||!(o>0)||!(n>0))return null;let s=Math.min(n,o),l=(e%o+o)%o,a=0,c=0;for(;a=c+r[a];)c+=r[a],a++;let u=l-c,d=s,p=[];for(let h=0;h<=i&&d>1e-9;h++){let f=r[a]-u,g=Math.min(d,f);g>1e-9&&p.push({edge:a,t0:u,t1:u+g}),d-=g,u=0;let b=(a+1)%i;if(d>1e-9&&Uy(t,a)>Ky)break;a=b}for(;p.length>1&&p[0].t1-p[0].t01&&p[p.length-1].t1-p[p.length-1].t0({edge:h.edge,offset:(h.t0+h.t1)/2,width:h.t1-h.t0})):null}function Yn(t,e){let n=e[0];return n?{from:jy(t,n.edge)+n.offset-n.width/2,width:e.reduce((r,i)=>r+i.width,0)}:null}function Ut(t,e){return e.front?t.filter(n=>n.front===e.front):[e]}function Na(t,e){let n=t.points.length,r=1/0,i=0,o=0;for(let s=0;sI("opening")){let s=Ca(e,r,i);if(!s)return null;let l=Ut(t,n),a=new Set(l.map(h=>h.id)),c=s.length>1?l[0].front??`front-${l[0].id}`:null,u=s.map((h,f)=>({...n,id:f===0?l[0].id:o(),edge:h.edge,offset:h.offset,width:h.width,front:c})),d=[],p=!1;for(let h of t){if(!a.has(h.id)){d.push(h);continue}p||(d.push(...u),p=!0)}return d}var Wa=globalThis,Ba=Wa.__nextfloorBuiltin?.de??{},Va=Wa.__nextfloorBuiltin?.en??{};Wa.__nextfloorBuiltin??={de:Ba,en:Va};var Gy=()=>typeof $=="object"&&$||{},Zy=globalThis,qy=Zy.__nextfloorTexts??=new Map;function Yy(t){let e=t.toLowerCase().split("-")[0];return e!=="de"&&e!=="en"&&e in Gy()?e:void 0}function ph(t){let e=Yy(t),n=e===void 0?void 0:qy.get(e);return n instanceof Promise?void 0:n}function Ao(t,e){return ph(t)?.[e]}function we(t,e,n={}){let r=t?.language??navigator.language,i=r.startsWith("de"),o=(i?void 0:ph(r)?.[e])??(i?Ba:Va)[e]??Va[e]??Ba[e]??e;for(let[s,l]of Object.entries(n))o=o.replace(`{${s}}`,String(l));return o}function K(t,e,n=2){return e.toLocaleString(t?.language??void 0,{maximumFractionDigits:n})}var Xy=new Set(["on","home","open","true","active","playing","heat","heating"]);function fh(t,e){let n=e.show_when;if(!n?.entity||!t)return!0;let r=t.states[n.entity];if(!r||Ie(r))return!0;let i=String(r.state).toLowerCase(),o=(n.state??"").split(",").map(l=>l.trim().toLowerCase()).filter(Boolean),s=o.length?o.includes(i):Xy.has(i)||Number.isFinite(Number(i))&&Number(i)>0;return n.invert?!s:s}function Ae(t,e){if(!wt(e))return we(t,`furn_${e}`);let n=G(e);return n?Je(n,e,t?.language??navigator.language):we(t,"pack_missing_item")}function Je(t,e,n){return t.name[n.split("-")[0]]??Ao(n,e)??ru(t,n)}function Be(t,e){return Ao(e,`packname:${t.id}`)??iu(t,e)}function mh(t,e){return t.name[e.split("-")[0]]??Ao(e,`color:${t.id}`)??t.name.en??Object.values(t.name)[0]}var ai=t=>t&&t!=="none"?t:null,li=(t,e)=>{e&&!t.includes(e)&&t.push(e)},Ka=t=>new Map(t.floors.flatMap(e=>e.furniture.filter(n=>n.type==="meter").map(n=>[n.id,n])));function yn(t,e){if(!t.energy.advanced||e.type!=="meter"||!e.parent_meter)return null;let n=Ka(t),r=new Set([e.id]);for(let i=n.get(e.parent_meter);i;i=n.get(i.parent_meter??"")){if(r.has(i.id))return null;r.add(i.id)}return n.has(e.parent_meter)?e.parent_meter:null}function Xn(t){return new Set([...Ka(t).values()].filter(e=>yn(t,e)).map(e=>e.id))}function ci(t,e){return!t.energy.advanced||!e.parent_meter?null:Xn(t).has(e.parent_meter)?e.parent_meter:null}function gh(t,e,n){if(n.type!=="meter"||n.id===e.id)return!1;let r=Ka(t),i=new Set;for(let o=n;o&&!i.has(o.id);o=r.get(o.parent_meter??"")){if(o.id===e.id)return!1;i.add(o.id)}return!0}function To(t,e=n=>ai(n.power)){let n={grid:null,gridExport:null,solar:[],battery:[],charge:[],batteries:[],soc:[]};for(let r of t.floors.flatMap(i=>i.furniture)){let i=e(r),o=r.type==="meter"?yn(t,r):null;if(o)(n.subMeters??=[]).push({id:r.id,parent:o,power:i,invert:!!r.meter_invert,floors:r.meter_floors??[],solar:[],batteries:[]});else if(r.type==="meter")n.grid??=i,n.gridExport??=ai(r.export);else if(r.type==="inverter")li(n.solar,i);else if(r.type==="home_battery"){let s=ai(r.charge);li(n.battery,i),li(n.charge,s),li(n.soc,ai(r.soc)),(i||s)&&n.batteries.push({power:i,charge:s})}}for(let r of n.subMeters?t.floors.flatMap(i=>i.furniture):[]){let i=r.type==="inverter"||r.type==="home_battery"?n.subMeters?.find(l=>l.id===ci(t,r)):void 0,o=i?e(r):null;i&&r.type==="inverter"&&li(i.solar,o);let s=ai(r.charge);i&&r.type==="home_battery"&&(o||s)&&i.batteries.push({power:o,charge:s})}return n}function Jy(t){for(let e of t.floors){let n=e.furniture.find(r=>r.type==="meter"&&!yn(t,r));if(n)return{floor_id:e.id,x:n.x,z:n.z}}return t.energy.meter}var Qy=/(phase|_l[123]\b|_[abc]$|today|daily|heute)/,ev=/_?(energy|energie|total|today|daily|kwh|import|export|consumption|production)/g;function Fo(t,e,n="power"){let r=e?t.entities?.[e]?.device_id:void 0;if(!e||!r)return null;let i=Object.keys(t.states).filter(l=>l.startsWith("sensor.")&&t.entities?.[l]?.device_id===r&&t.states[l]?.attributes.device_class===n);if(i.length<=1)return i[0]??null;let o=i.filter(l=>!Qy.test(l)),s=e.replace(/^sensor\./,"").replace(ev,"");return o.find(l=>s&&l.includes(s))??o[0]??i[0]}function _h(t,e){let n={},r=(i,o)=>{o&&!n[i]&&(n[i]=o)};for(let i of e.energy_sources??[])if(i.type==="grid")r("grid",Fo(t,i.flow_from?.[0]?.stat_energy_from??i.flow_to?.[0]?.stat_energy_to));else if(i.type==="solar")r("solar",Fo(t,i.stat_energy_from));else if(i.type==="battery"){let o=i.stat_energy_from??i.stat_energy_to;r("battery",Fo(t,o)),r("battery_soc",Fo(t,o,"battery"))}return n}function Fe(t,e=!1){let n=t?.attributes.symcon_id?Lt(t):t?Number(t.state):null;if(n===null||!Number.isFinite(n))return null;let r={kW:1e3,MW:1e6}[String(t.attributes.unit_of_measurement??"W")]??1;return e?-n*r:n*r}var tv=(t,e)=>e.startsWith("sensor.")&&t.states[e]?.attributes.device_class==="power";function ui(t,e){if(tv(t,e))return e;let n=t.entities?.[e]?.device_id;if(!n)return null;let r=ea(t,n),i=r?It(t,e):null,o=uo(t,n).filter(s=>s!==e);return(r?o.find(s=>i!==null&&It(t,s)===i):o[0])??null}var bh=t=>{let e=t.filter(n=>n!==null);return e.length?e.reduce((n,r)=>n+r,0):null};function nv(t,e,n){let r=e.grid??n.grid,i=r?Fe(t.states[r],e.grid_invert):null;if(!e.grid&&n.gridExport){let o=Math.max(0,Fe(t.states[n.gridExport])??0);return Math.max(0,i??0)-o}return i}function rv(t,e,n){return e.solar?Fe(t.states[e.solar]):n.solar.length?bh(n.solar.map(r=>Fe(t.states[r]))):null}function ja(t,e,n){return e.charge?(e.power?Math.max(0,Fe(t.states[e.power])??0):0)-Math.max(0,Fe(t.states[e.charge])??0):e.power?Fe(t.states[e.power],n):null}function iv(t,e,n){return e.battery?Fe(t.states[e.battery],e.battery_invert):bh(n.batteries.map(r=>ja(t,r,e.battery_invert)))}function Ua(t,e,n,r=To(e)){let i=e.energy,o=nv(t,i,r),s=rv(t,i,r),l=iv(t,i,r),a=(i.battery_soc?[i.battery_soc]:r.soc).map(f=>Number(t.states[f]?.state)).filter(Number.isFinite),c=a.length?a.reduce((f,g)=>f+g,0)/a.length:null,u=i.tariff?t.states[i.tariff]:void 0,d=Number(u?.state),p=i.consumption?Fe(t.states[i.consumption]):null;p===null&&(o!==null||s!==null||l!==null)&&(p=(o??0)+Math.max(0,s??0)+(l??0)),p===null&&n.length>0&&(p=n.reduce((f,g)=>f+g.power,0));let h={grid:o,solar:s===null?null:Math.max(0,s),battery:l,soc:c,tariff:u&&Number.isFinite(d)?{value:d,unit:String(u.attributes.unit_of_measurement??"")}:null,consumption:p===null?null:Math.max(0,p)};return r.subMeters?{...h,...ov(t,r,h.consumption,i.battery_invert,n)}:h}function ov(t,e,n,r,i){let o=e.subMeters??[],s=new Map;for(let p of o)for(let h of p.floors)s.has(h)||s.set(h,p.id);let l=new Set([e.grid,e.gridExport,...e.solar,...e.battery,...e.charge,...o.flatMap(p=>[p.power,...p.solar,...p.batteries.flatMap(h=>[h.power,h.charge])])]),a=p=>i.filter(h=>s.get(h.floorId)===p&&!l.has(h.powerEntity)).reduce((h,f)=>h+f.power,0),c=new Map(o.map(p=>[p.id,p.power?Fe(t.states[p.power],p.invert):null])),u=o.map(p=>{let h=c.get(p.id)??null,f=p.solar.reduce((v,w)=>v+Math.max(0,Fe(t.states[w])??0),0),g=p.batteries.reduce((v,w)=>v+(ja(t,w,r)??0),0),b=o.filter(v=>v.parent===p.id).reduce((v,w)=>v+(c.get(w.id)??0),0),y=h===null?null:Math.max(0,h+f+g-b);return{id:p.id,parent:p.parent,power:h,solar:f,battery:g,use:y,unmetered:y===null?null:Math.max(0,y-a(p.id))}}),d=u.reduce((p,h)=>p+(h.use??0),0);return{subMeters:u,rest:n===null?null:Math.max(0,n-d)}}function sv(t,e,n){let r=t.b[0]-t.a[0],i=t.b[1]-t.a[1],o=Math.hypot(r,i)||1,s=Math.min(1,Math.max(0,((e.x-t.a[0])*r+(e.z-t.a[1])*i)/(o*o))),l=t.a[0]+r*s,a=t.a[1]+i*s,c=i/o*(l-n.x)+-r/o*(a-n.z)<0?-1:1;return{x:l,z:a,nx:c*i/o,nz:-c*r/o,distance:Math.hypot(e.x-l,e.z-a)}}function yh(t){let e=Jy(t),n=e?t.floors.find(c=>c.id===e.floor_id):void 0;if(!e||!n)return null;let r={exterior:t.settings.wall_exterior,interior:t.settings.wall_interior},i=fe(n.rooms,r,n.walls??[]).walls.filter(c=>c.exterior),o=n.rooms.flatMap(c=>c.points);if(i.length===0||o.length===0)return null;let s={x:o.reduce((c,u)=>c+u[0],0)/o.length,z:o.reduce((c,u)=>c+u[1],0)/o.length},l=i.map(c=>sv(c,e,s)).reduce((c,u)=>u.distance({id:t,name:e,has_valve:!0}),zo=t=>t.has_valve!==!1;function di(t){let e=t.hydronic??{};return e.stations?.length?e.stations.slice(0,16):[{...Ga("station-1"),flow:e.flow,return:e.return,hot_water:e.hot_water,cold_water:e.cold_water,pump:e.pump}]}function vh(t,e){let n={...t,stations:e};for(let r of["flow","return","hot_water","cold_water","pump"])delete n[r];return n}var av=["heating_manifold","buffer_tank","freshwater_station"],Jn=t=>av.includes(t),Za=(t,e="Heizkreis")=>({id:t,name:e,kind:"heating",has_pump:!0,has_valve:!0});function qa(t){return{card:!0,...t==="heating_manifold"?{circuits:[Za("c1","Heizkreis 1")]}:{},...t==="buffer_tank"?{sensors:Array.from({length:7},(e,n)=>({id:`s${n+1}`,name:`F\xFChler ${n+1}`,entity:null,level:1-n/6}))}:{}}}function Qn(t){return{...qa(t.type),...t.hydronic}}var er=t=>t.has_pump!==!1,Po=t=>t.kind!=="pump"&&t.has_valve!==!1;var hi=t=>!!t&&t!=="none";var Io=(t,e)=>String(t.states[e]?.attributes.symcon_source_entity||e);function Do(t,e){let n=t.states[Io(t,e)]?.attributes;return n?.device_class==="power"||/^[km]?w$/i.test(String(n?.unit_of_measurement??"").trim())}function wh(t,e){let n=new Map;if(!X(t))return n;let r=Me(t,[e]),i=(o,s,l,a,c)=>{if(!hi(c))return;let u=e.rooms.find(p=>p.points.length>=3&&C([l,a],p.points));if(!u)return;let d=n.get(u.id)??[];d.push({id:o,name:s,source:Io(t,c)}),n.set(u.id,d)};for(let o of e.furniture){if(!fh(t,o))continue;let s=o.name||Ae(t,o.type),l=(o.values??[]).find(u=>hi(u.entity)&&Do(t,u.entity)),a=r.get(o.id)?.entity,c=o.power==="none"?null:o.power||r.get(o.id)?.power||(a&&Do(t,a)?a:null);if(i(`furniture:${o.id}`,s,o.x,o.z,c||l?.entity),!c&&!l){let u=new Set;for(let d of o.gang_entities??[]){if(!hi(d))continue;let p=ui(t,d);!p||u.has(Io(t,p))||(u.add(Io(t,p)),i(`furniture:${o.id}:${d}`,`${s} \xB7 ${B(t,d)}`,o.x,o.z,p))}}if(Jn(o.type))for(let u of Qn(o).circuits??[])er(u)&&i(`furniture:${o.id}:${u.id}`,`${s} \xB7 ${u.name||"Pumpe"}`,o.x,o.z,u.power);if(o.type==="freshwater_station")for(let u of di(o))i(`furniture:${o.id}:station:${u.id}`,`${s} \xB7 ${u.name}`,o.x,o.z,u.power)}for(let o of e.placements){if(o.outside)continue;let s=(o.values??[]).find(a=>hi(a.entity)&&Do(t,a.entity)),l=Do(t,o.entity_id)?o.entity_id:ui(t,o.entity_id);i(`device:${o.entity_id}`,o.name||B(t,o.entity_id),o.x,o.z,l||s?.entity)}return n}var Mt={electricity:"Strom",water:"Wasser",gas:"Gas",heating:"Heizen",cooling:"K\xFChlen"},tr={electricity:"\u26A1",water:"\u{1F4A7}",gas:"\u{1F525}",heating:"\u2668",cooling:"\u2744"},Ho=t=>t.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/ß/g,"ss").replace(/[^a-z0-9]+/g," ").trim(),lv="{485D0419-BE97-4548-AA9C-C083EB82E61E}",cv=t=>t.object_type!==0&&!(t.object_type===1&&t.module_id?.toUpperCase()===lv)?null:{elektro:"electricity",strom:"electricity","elektro strom":"electricity","strom elektro":"electricity",wasser:"water",gas:"gas",heizen:"heating",heizung:"heating",warme:"heating",waerme:"heating",kuhlen:"cooling",kuehlen:"cooling",kuhlung:"cooling",kuehlung:"cooling",kalte:"cooling",kaelte:"cooling"}[Ho(t.name)]??null,Oo=t=>/^symcon-category-(\d+)$/.exec(t??"")?.[1],Xa=t=>/\b(heute|tag|tagesverbrauch|today|daily)\b/.test(t)?"day":/monat|month/.test(t)?"month":/jahr|year/.test(t)?"year":"total",Lo=(t,e)=>String(t.states[e]?.attributes.symcon_source_entity||e);function $h(t){let e=String(t?.attributes.unit_of_measurement??"").trim(),n=e.replace(/[³]/g,"3").replace(/[²]/g,"2").replace(/\s+/g,"").toLowerCase();return["w","kw","mw"].includes(n)?{metric:"power",unit:"W",factor:e==="mW"?.001:n==="kw"?1e3:n==="mw"?1e6:1}:["wh","kwh","mwh","j","kj","mj","gj"].includes(n)?{metric:"energy",unit:"kWh",factor:{wh:.001,kwh:1,mwh:1e3,j:1/36e5,kj:1/3600,mj:1/3.6,gj:1e3/3.6}[n]}:["m3/h","m3h","m3/min","m3/s","l/h","l/min","l/s","liter/h","liter/min"].includes(n)?{metric:"power",unit:"m\xB3/h",factor:{"m3/h":1,m3h:1,"m3/min":60,"m3/s":3600,"l/h":.001,"l/min":.06,"l/s":3.6,"liter/h":.001,"liter/min":.06}[n]}:["m3","l","liter"].includes(n)?{metric:"energy",unit:"m\xB3",factor:n==="m3"?1:.001}:null}function uv(t,e){if(!e.entity_id||e.object_type!==2&&e.object_type!==6)return null;let n=Lo(t,e.entity_id),r=t.states[n];if(!r||![1,2].includes(Number(r.attributes.symcon_variable_type)))return null;let i=Ho(e.name),o=$h(r),s=/^(leistung|wirkleistung|gesamtleistung|aktuelle leistung|durchfluss|volumenstrom)(\b|$)/.test(i),l=/^(verbrauch|energie|energieverbrauch|gesamtverbrauch|gesamtenergie|zahlerstand|zaehlerstand|arbeit)(\b|$)/.test(i),a=o?.metric??(s?"power":l?"energy":null);if(!a)return null;let c=a==="power"?/^(leistung|wirkleistung|gesamtleistung|durchfluss|volumenstrom)$/.test(i):/^(verbrauch|energie|energieverbrauch|gesamtverbrauch|gesamtenergie|zahlerstand|zaehlerstand|arbeit)$/.test(i),u=a==="energy"?Xa(i):"total";return{metric:a,source:n,period:u,group:`${a}|${o?.unit??String(r.attributes.unit_of_measurement??"")}|${u}`,score:/^gesamt(leistung|verbrauch|energie)$/.test(i)?110:c?100:(a==="power"?s:l)?70:20}}var kh=new WeakMap,xh=new WeakMap;function Sh(t){let e=kh.get(t);if(e)return e;let n={nodes:new Map(t.map(r=>[r.object_id,r])),children:new Map};for(let r of t){let i=n.children.get(r.parent_id)??[];i.push(r),n.children.set(r.parent_id,i)}return kh.set(t,n),n}function dv(t,e,n){if(!X(t))return[];let r=[e.area_id,...e.sub_areas??[]].map(Oo).filter(p=>!!p);if(!r.length)return[];let i=new Set(n.filter(p=>p.id!==e.id).flatMap(p=>[p.area_id,...p.sub_areas??[]]).map(Oo).filter(p=>!!p&&!r.includes(p))),o=`${r.join(",")}|${[...i].sort().join(",")}`,s=xh.get(t)??new Map;xh.set(t,s);let l=s.get(o);if(l)return l;let a=Sh(t.symconObjects),c=[],u=new Set,d=(p,h,f)=>{if(u.has(p)||i.has(String(p)))return;u.add(p);let g=a.nodes.get(p);if(!g)return;let b=cv(g),y=b??h,v=new Set(b&&b!==h?[]:f),w=a.children.get(p)??[];if(y){let x=w.map(k=>uv(t,k)).filter(k=>k!==null);for(let k of new Set(x.map(M=>M.group))){if(v.has(k))continue;let M=x.filter(F=>F.group===k),E=Math.max(...M.map(F=>F.score)),T=M.filter(F=>F.score===E);for(let F of E>=100?T.slice(0,1):T)c.push({kind:y,metric:F.metric,id:F.source,period:F.period});v.add(k)}}for(let x of w)(x.object_type===0||x.object_type===1)&&d(x.object_id,y,v)};for(let p of r)d(Number(p),null,new Set);return s.set(o,c),c}function pi(t,e,n=!1){let r=new Map,i=new Set;for(let o of e){let s=Lo(t,o.id),l=`${o.kind}|${o.metric}|${s}`;if(i.has(l))continue;i.add(l);let a=t.states[s],c=$h(a),u=c?.metric===o.metric?c.unit:String(a?.attributes.unit_of_measurement??"").trim(),d=`${o.kind}|${o.metric}|${u}|${o.period}`,p=r.get(d)??{kind:o.kind,metric:o.metric,unit:u,value:null,period:o.period,sources:[],manual:n,incomplete:!1},h=Lt(a);h===null?p.incomplete=!0:p.value=(p.value??0)+h*(c?.metric===o.metric?c.factor:1),p.sources.push(s),r.set(d,p)}return[...r.values()]}function Ya(t,e){return kt.flatMap(n=>["power","energy"].flatMap(r=>{let i=e.utility_meters?.[n]?.[r];if(!i||i==="none")return[];let o=Lo(t,i);return[{kind:n,metric:r,id:o,period:r==="energy"?Xa(Ho(String(t.states[o]?.attributes.friendly_name??""))):"total"}]}))}function hv(t,e){return X(t)?pi(t,Ya(t,e),!0):[]}function pv(t,e,n=e.rooms,r=!1){if(!X(t))return[];let i=r?wh(t,e):new Map,o=new Map;for(let l of e.rooms){let a=[...new Set([l.area_id,...l.sub_areas??[]].filter(c=>!!Oo(c)))];!a.length&&(Ya(t,l).length||i.get(l.id)?.length)&&a.push("unassigned");for(let c of a){let u=o.get(c)??{seed:l,members:[]};c===a[0]&&u.members.push(l),o.set(c,u)}}let s=Sh(t.symconObjects).nodes;return[...o].map(([l,a])=>{let c=s.get(Number(Oo(l))),u=l==="unassigned"?[]:pi(t,dv(t,{...a.seed,area_id:l,sub_areas:null},n)),d=pi(t,a.members.flatMap(f=>Ya(t,f)),!0),p=f=>u.some(g=>g.kind===f.kind&&g.metric===f.metric&&g.unit===f.unit&&g.period===f.period),h=a.members.map(f=>({id:f.id,name:f.name,readings:hv(t,f),devices:(i.get(f.id)??[]).map(g=>({id:g.id,name:g.name,readings:pi(t,[{kind:"electricity",metric:"power",id:g.source,period:"total"}],!0)}))})).filter(f=>f.readings.length||f.devices.length);return{id:l,name:l==="unassigned"?"Nicht zugeordnet":c?.name||t.areas?.[l]?.name||"Bereich nicht verf\xFCgbar",path:c?.path||"",readings:[...u,...d.filter(f=>!p(f))],rooms:h}}).filter(l=>l.readings.length||l.rooms.length)}function Ja(t,e,n,r){let i=e.utility_meters?.[n],o=i&&Object.prototype.hasOwnProperty.call(i,r)?i[r]:n==="electricity"&&r==="power"?e.power_entity:null;return o&&o!=="none"?Lo(t,o):null}function Mh(t,e,n=e.rooms){let r=pv(t,e,n).flatMap(o=>o.readings.flatMap(s=>s.sources.map(l=>({kind:s.kind,metric:s.metric,period:s.period,id:l})))),i=[];for(let o of kt)for(let s of["power","energy"]){let l=Ja(t,e,o,s);i.push(...pi(t,l?[{kind:o,metric:s,id:l,period:s==="energy"?Xa(Ho(String(t.states[l]?.attributes.friendly_name??""))):"total"}]:r.filter(a=>a.kind===o&&a.metric===s),!!l))}return i}function Qa(t){return t.metric==="power"?t.unit==="m\xB3/h"?"Durchfluss":"Leistung":{total:"Verbrauch",day:"Verbrauch heute",month:"Verbrauch Monat",year:"Verbrauch Jahr"}[t.period]}function Rh(t,e){let n=e.incomplete?"Err: ":"";if(e.value===null)return`${n}\u2013`;let r=e.unit==="W"&&Math.abs(e.value)>=1e3?e.value/1e3:e.value,i=e.unit==="W"&&Math.abs(e.value)>=1e3?"kW":e.unit,o=Number.isInteger(r)?0:Math.min(6,Math.max(2,1-Math.floor(Math.log10(Math.abs(r)))));return`${n}${K(t,r,o)}${i?` ${i}`:""}`}var Eh=[{key:"supply_vsr",label:"Zuluft-VSR",types:[0,1,2],control:!0},{key:"extract_vsr",label:"Abluft-VSR",types:[0,1,2],control:!0},{key:"supply_temperature",label:"Zulufttemperatur",types:[1,2]},{key:"extract_temperature",label:"Ablufttemperatur",types:[1,2]},{key:"reheat",label:"NHR (Nachheizregister)",types:[0,1,2],control:!0},{key:"status",label:"Raumstatus",types:[1]}];function Ah(t,e,n){let r=O(t.hass,i=>He(t.hass,i,[1,2]));return m`
Eigene Raumzähler
${S("Nur direkt zugewiesene Raumz\xE4hler erscheinen als einger\xFCckte Raumzeile unter dem verkn\xFCpften Bereich. Die Bereichswerte stehen einmal beim Bereich; vorhandene Bereichssummen enthalten die Raumwerte bereits. Fehlt dem Bereich ein passender Z\xE4hler, werden daf\xFCr die eigenen Raumz\xE4hler summiert.","nf-wide")} ${kt.map(i=>m`${tr[i]} ${Mt[i]}${["power","energy"].map(o=>z(t,o==="power"?"Leistung / Durchfluss":"Energie / Verbrauch",e.utility_meters?.[i]?.[o]??null,void 0,r,s=>{let l={...e.utility_meters,[i]:{...e.utility_meters?.[i],[o]:s==="none"?null:s}};Object.values(l[i]).some(a=>a&&a!=="none")||delete l[i],n({utility_meters:Object.keys(l).length?l:null})},{types:[1,2]}))}`)}
`}function Fh(t,e,n){let r=s=>n({hvac:{...e.hvac,...s}}),i=e.hvac?.schedules??[],o=O(t.hass,s=>!!t.hass?.states[s]?.attributes.symcon_schedule);return m` ${z(t,t.t("floor_heating"),e.floor_heating??null,void 0,O(t.hass,s=>He(t.hass,s,[0,1,2])),s=>n({floor_heating:s==="none"?null:s}),{types:[0,1,2]})} ${Eh.map(s=>z(t,s.label,e.hvac?.[s.key]??null,void 0,O(t.hass,l=>He(t.hass,l,s.types)),l=>r({[s.key]:l==="none"?null:l}),{types:s.types}))} ${S("Raumstatus zeigt den in Symcon hinterlegten Alias der Integer-Variable. Beschreibbare Heizungs- und L\xFCftungswerte k\xF6nnen im Raummen\xFC bedient werden.","nf-wide")} ${i.map((s,l)=>z(t,`Schaltuhr ${l+1}`,s,void 0,o.filter(a=>a.id===s||!i.includes(a.id)),a=>r({schedules:a&&a!=="none"?i.map((c,u)=>l===u?a:c):i.filter((c,u)=>l!==u)}),{schedule:!0,excluded:a=>i.includes(a)?"Diese Schaltuhr ist in diesem Raum bereits verkn\xFCpft.":void 0}))} ${z(t,"Schaltuhr hinzuf\xFCgen",null,void 0,o.filter(s=>!i.includes(s.id)),s=>s&&s!=="none"&&r({schedules:[...i,s]}),{schedule:!0,excluded:s=>i.includes(s)?"Diese Schaltuhr ist in diesem Raum bereits verkn\xFCpft.":void 0})}`}function Th(t,e,n){let r=i=>i==="condition"?[0,1,2,3]:i==="wind_bearing"?[1,2,3]:["snow","fog","lightning"].includes(i)?[0,1,2]:[1,2];return m`
Wettervariablen
${uu.map(i=>z(t,nd[i],e.weather_variables?.[i]??null,void 0,O(t.hass,o=>He(t.hass,o,r(i))),o=>n({weather_variables:{...e.weather_variables,[i]:o==="none"?null:o}}),{types:r(i)}))} ${z(t,t.t("rain_sensor"),e.rain_sensor??null,void 0,O(t.hass,i=>He(t.hass,i,[0,1,2])),i=>n({rain_sensor:i==="none"?null:i}),{types:[0,1,2]})} ${e.rain_sensor?D(t,t.t("rain_sensor_inverted"),!!e.rain_sensor_inverted,i=>n({rain_sensor_inverted:i||void 0})):_} ${S("W\xE4hle die Wetterwerte einzeln aus dem Symcon-Objektbaum. Einheiten werden aus den Variablen \xFCbernommen. Der Regensensor kann Boolean oder eine numerische Regenrate sein.","nf-wide")}
`}function zh(t){let e=t.doc.presence,n=s=>t.replace({...structuredClone(t.doc),presence:s}),r=(s,l)=>n(e.map((a,c)=>c===s?{...a,...l,sensor:null}:a)),i=t.doc.floors.flatMap(s=>s.rooms.map(l=>({id:l.id,name:`${s.name} \xB7 ${l.name}`}))),o=O(t.hass,s=>He(t.hass,s,[0]));return m`
${t.t("presence")} ${e.map((s,l)=>m`
${W(t,"Person",s.name??B(t.hass,s.person),a=>r(l,{name:a}),{wide:!0,maxlength:100})} ${z(t,"Anwesenheit (Boolean)",s.person,void 0,o.filter(a=>a.id===s.person||!e.some(c=>c.person===a.id)),a=>a&&a!=="none"?r(l,{person:a}):n(e.filter((c,u)=>u!==l)),{types:[0],excluded:a=>e.some(c=>c.person===a)?"Diese Anwesenheitsvariable ist bereits mit einer Person verkn\xFCpft.":void 0})}
`)}
${z(t,"Person hinzuf\xFCgen (Boolean)",null,void 0,o.filter(s=>!e.some(l=>l.person===s.id)),s=>s&&s!=="none"&&n([...e,{person:s,sensor:null}]),{types:[0],excluded:s=>e.some(l=>l.person===s)?"Diese Anwesenheitsvariable ist bereits mit einer Person verkn\xFCpft.":void 0})}
${S("Jede Person wird mit einer beliebigen Boolean-Variable verkn\xFCpft: true bedeutet anwesend, false abwesend. Ein Raum ist optional und bestimmt die Position der Person in 3D.")}
`}function Ph(t,e,n){let r=t.find(a=>a.person===e),i="sensor"in n?n.sensor&&n.sensor!=="none"?n.sensor:null:r?.sensor??null,o="room"in n?n.room||null:r?.room??null,s=t.filter(a=>a.person!==e);if(!i&&!o)return s;let l=o?{person:e,sensor:i,room:o}:{person:e,sensor:i};return r?t.map(a=>a.person===e?l:a):[...s,l]}function Dh(t,e){let n=e.slice(e.indexOf(".")+1),r=i=>i.id.includes(n)&&/(area|room|raum|bermuda|espresense)/.test(i.id);return[...t.filter(r),...t.filter(i=>!r(i))]}function Ih(t){let e=t.target?`, target: { x: ${t.target.x}, y: ${t.target.y}, z: ${t.target.z} }`:"";return`start_view: { theta: ${t.theta}, phi: ${t.phi}, radius: ${t.radius}${e} }`}function Oh(t){let e=t.trim();if(!e)return{ok:!0,value:null};try{let n=JSON.parse(e);return n&&typeof n=="object"&&!Array.isArray(n)?{ok:!0,value:n}:{ok:!1}}catch{return{ok:!1}}}function Co(t,e,n){let r=[...t],[i]=r.splice(e,1);return r.splice(Math.max(0,Math.min(r.length,e+n)),0,i),r}var Gt=(t,e)=>t.filter((n,r)=>r!==e),fi=(t,e,n)=>t.map((r,i)=>i===e?{...r,...n}:r),gt=t=>t.length>0?t:void 0;var fv=["scene","script","automation","button","input_button","switch","input_boolean","light","fan","cover","lock"],mv=40,gv=20,_v=30,bv=["music","url","playlist","SPOTIFY","AMAZON_MUSIC","TUNEIN","APPLE_MUSIC"],el={navigate:"/lovelace/rollos",more_info:"cover.wohnzimmer",service:"script.turn_on",fire_dom_event:""},mi=(t,e,n,r=!1)=>m``;function yv(t){let e=t.doc.settings.favorites??[],n=l=>t.change(a=>a.settings.favorites=gt(l)),r=t.doc.floors,i=t.doc.settings.favorite_floors??{},o=O(t.hass,l=>fv.includes(l.split(".")[0])&&!e.includes(l)),s=(l,a)=>m`
${B(t.hass,l)} ${r.length>1?m``:_} ${mi(t.t("move_up"),"\u2191",()=>n(Co(e,a,-1)),a===0)} ${mi(t.t("move_down"),"\u2193",()=>n(Co(e,a,1)),a===e.length-1)} ${mi(t.t("delete"),"\u2715",()=>n(Gt(e,a)))}
`;return m`${t.t("favorites")}${e.length>0?m` ${e.length}`:_} ${S(t.t("favorites_hint"))} ${e.map(s)} ${e.length${z(t,t.t("favorites_add"),null,void 0,o,l=>l&&l!=="none"&&!e.includes(l)&&n([...e,l]),{excluded:l=>e.includes(l)?"Diese Variable ist bereits als Favorit verkn\xFCpft.":void 0})}`:_}`}function vv(t,e){let n=t.doc.settings.outside_hidden??[],r=s=>t.change(l=>l.settings.outside_hidden=gt(s)),i=new Set(t.hass?dd(t.hass,t.doc.floors):[]),o=O(t.hass,s=>!n.includes(s)&&i.has(s));return m`${e?wv(t,e):_}

${t.t("outside_hidden")}${n.length>0?m` ${n.length}`:_}

${S(t.t("outside_hidden_hint"))} ${n.map((s,l)=>m`
${B(t.hass,s)}${mi(t.t("delete"),"\u2715",()=>r(Gt(n,l)))}
`)}
${z(t,t.t("outside_hidden_add"),null,void 0,o,s=>s&&s!=="none"&&!n.includes(s)&&r([...n,s]),{excluded:s=>n.includes(s)?"Diese Variable ist hier bereits eingetragen.":void 0})}
`}function wv(t,e){let n=t.doc.settings.outside_view??null,r=()=>{let i=e();i&&t.change(o=>o.settings.outside_view=i)};return m`${S(t.t("outside_view_hint"))} ${J(m``,n?m``:_)}`}function kv(t){let e=t.doc.settings.own_alerts??[],n=s=>t.change(l=>l.settings.own_alerts=gt(s)),r=(s,l)=>n(fi(e,s,l)),i=[["",t.t("own_alert_house")],...t.doc.floors.flatMap(s=>s.rooms.map(l=>[l.id,`${l.name} \xB7 ${s.name}`]))],o=(s,l)=>m`
${z(t,t.t("own_alert_entity"),s.entity||null,void 0,O(t.hass,()=>!0),a=>r(l,{entity:a&&a!=="none"?a:""}))} ${W(t,t.t("own_alert_state"),s.state??"",a=>r(l,{state:a||null}),{placeholder:t.hass?.states[s.entity]?.state??"on \xB7 <20 \xB7 >80"})} ${W(t,t.t("own_alert_text"),s.text,a=>r(l,{text:a||t.t("own_alert_new")}),{wide:!0,maxlength:120})} ${H(t,t.t("room"),s.room_id??"",i,a=>r(l,{room_id:a||null}),{wide:!0})} ${Ue(t,t.t("own_alert_color"),s.color??null,"#ffb547",a=>r(l,{color:a}))} ${H(t,t.t("own_alert_tap"),s.tap??"",[["",t.t("own_alert_tap_info")],["toggle",t.t("own_alert_tap_toggle")],["room",t.t("own_alert_tap_room")]],a=>r(l,{tap:a||null}))}
`;return m`

⚠ ${t.t("own_alerts")}

${S(t.t("own_alerts_hint"))} ${e.map(o)} ${e.length<40?J(m``):_}`}function xv(t){let e=t.doc.settings.circuits??[],n=l=>t.change(a=>a.settings.circuits=gt(l)),r=(l,a)=>n(fi(e,l,a)),i=t.doc.floors.flatMap(l=>l.rooms.map(a=>({id:a.id,label:t.doc.floors.length>1?`${a.name} \xB7 ${l.name}`:a.name}))),o=l=>i.find(a=>a.id===l)?.label??l,s=(l,a)=>m`
${W(t,t.t("circuit_name"),l.name,c=>r(a,{name:c||t.t("circuit_new")}),{wide:!0,maxlength:80})}
${l.rooms.map(c=>m`${o(c)} `)}
${H(t,t.t("circuit_add_room"),"",[["","\u2013"],...i.filter(c=>!l.rooms.includes(c.id)).map(c=>[c.id,c.label])],c=>c&&r(a,{rooms:[...l.rooms,c]}),{wide:!0})}
`;return m`

🔌 ${t.t("circuits")}

${S(t.t("circuits_hint"))} ${e.map(s)} ${e.length<120?J(m``):_}`}function $v(t){let e=t.doc.settings.calendars??[],n=l=>t.change(a=>a.settings.calendars=gt(l)),r=O(t.hass,l=>l.startsWith("calendar.")&&!e.includes(l)),i=(l,a)=>m`
${B(t.hass,l)} ${mi(t.t("delete"),"\u2715",()=>n(Gt(e,a)))}
`,o=t.t,s=t.doc.settings.today_days??1;return m`

📅 ${o("today_calendars")}

${S(o("today_calendars_hint"))} ${e.map(i)} ${e.length<12?m`
${z(t,o("favorites_add"),null,void 0,r,l=>l&&l!=="none"&&!e.includes(l)&&n([...e,l]),{unsupported:"Dieses Feld ben\xF6tigt eine Kalenderquelle mit Terminen. Eine Symcon-Variable ist kein Kalender; Kalenderquellen werden vom Symcon-Modul derzeit nicht bereitgestellt."})}
`:_} ${e.length?m`
${H(t,o("today_days"),String(s),[1,2,3,5,7].map(l=>[String(l),o(l===1?"today_days_one":"today_days_n",{n:l})]),l=>t.change(a=>a.settings.today_days=Number(l)>1?Number(l):void 0))}
`:_} ${Sv(t)}`}function Sv(t){let e=t.t,n=t.doc.settings.forecast??null,r=i=>t.change(o=>o.settings.forecast=i??void 0);return m`

🌦 ${e("forecast")}

${S(e("forecast_hint"))}
${H(t,e("forecast_days"),n?String(n.days):"0",[0,3,5,7].map(i=>[String(i),i?e("today_days_n",{n:i}):e("forecast_off")]),i=>r(Number(i)>0?{days:Number(i),corner:n?.corner??"top_right"}:null))} ${n?H(t,e("forecast_corner"),n.corner,[["top_right",e("clock_top_right")],["top_left",e("clock_top_left")]],i=>r({...n,corner:i==="top_left"?"top_left":"top_right"})):_}
`}function Mv(t){let e=t.doc.settings.media_presets??[],n=s=>t.change(l=>l.settings.media_presets=gt(s)),r=(s,l)=>n(fi(e,s,l)),i=[...new Set(t.doc.floors.flatMap(s=>[...s.placements.map(l=>l.entity_id),...s.furniture.map(l=>l.entity??"")]).filter(s=>s.startsWith("media_player.")))],o=(s,l)=>m`
${W(t,t.t("own_button_label"),s.label,a=>r(l,{label:a||"Radio"}),{maxlength:60})} ${W(t,t.t("preset_type"),s.type,a=>r(l,{type:a||"music"}),{title:t.t("preset_type_hint")})} ${W(t,t.t("preset_content"),s.content,a=>r(l,{content:a}),{wide:!0,title:t.t("preset_content_hint"),placeholder:"https://\u2026 \xB7 spotify:playlist:\u2026 \xB7 Rock Antenne"})} ${i.length>1?m`
${t.t("preset_speakers")}
${i.map(a=>D(t,B(t.hass,a),!!s.speakers?.includes(a),c=>r(l,{speakers:gt(c?[...s.speakers??[],a]:(s.speakers??[]).filter(u=>u!==a))}),{wide:!1}))}`:_}
`;return m`

${t.t("presets")}

${S(t.t("presets_hint"))} ${bv.map(s=>m``)} ${e.map(o)} ${e.length<_v?J(m``):_}`}function tl(t,e,n){let r=e.action==="fire_dom_event"?'{"browser_mod": {"service": "browser_mod.popup", "data": {"title": "Rollos", "content": {"type": "custom:my-cover-card"}}}}':'{"entity_id": "script.party"}',i=o=>{let s=o.target;s.setCustomValidity("");let l=Oh(s.value);if(l.ok)return n(l.value);s.setCustomValidity(t.t("own_data_bad")),s.reportValidity()};return m``}function Rv(t){let e=t.doc.settings.buttons??[],n=s=>t.change(l=>l.settings.buttons=gt(s)),r=(s,l)=>n(fi(e,s,l)),i=Yi.map(s=>[s,t.t(`own_action_${s}`)]),o=(s,l)=>m`
${W(t,t.t("own_button_label"),s.label,a=>r(l,{label:a||t.t("own_button_new")}),{maxlength:60})} ${H(t,t.t("own_button_action"),s.action,i,a=>r(l,{action:a}))} ${Bt(t,s.icon??null,a=>r(l,{icon:a}))} ${s.action!=="fire_dom_event"?W(t,t.t(`own_target_${s.action}`),s.target??"",a=>r(l,{target:a||null}),{wide:!0,placeholder:el[s.action]}):_} ${s.action==="service"||s.action==="fire_dom_event"?tl(t,s,a=>r(l,{data:a})):_} ${z(t,t.t("own_button_state"),s.state_entity??null,void 0,O(t.hass,a=>/^(switch|light|input_boolean|binary_sensor|fan|cover|media_player|climate|lock|person|device_tracker)\./.test(a)),a=>r(l,{state_entity:a&&a!=="none"?a:null}))}
`;return m`

${t.t("own_buttons")}

${S(t.t("own_buttons_hint"))} ${e.map(o)} ${e.lengthn([...e,{id:I("btn"),label:t.t("own_button_new"),action:"navigate",target:null}])}>+ ${t.t("own_button_add")}`):_}`}function Ev(t){let e=t.doc.settings.room_facts_off??[],n=["sun","comfort","air","circuits"].map(r=>D(t,t.t(`room_fact_${r}`),!e.includes(r),i=>t.change(o=>o.settings.room_facts_off=gt(i?e.filter(s=>s!==r):[...e,r]))));return m`

${t.t("room_facts")}

${n}
`}function Hh(t){return m`
${yv(t)} ${Rv(t)} ${kv(t)} ${xv(t)} ${$v(t)} ${Mv(t)} ${Ev(t)}
`}function Lh(t,e){return m`
🌳 ${t.t("outside_area")} ${vv(t,e)}
`}function Ch(t,e){let n=t.doc.settings.start_view??null,r=()=>{let i=e();i&&t.change(o=>o.settings.start_view=i)};return m`
${t.t("start_view")} ${S(t.t("start_view_hint"))} ${J(m``,n?m``:_)} ${n?m`${S(t.t("start_view_saved"))} ${S(t.t("start_view_card"))}${Ih(n)}`:_}
`}function Nh(t){if(X(t.hass))return zh(t);let e=t.doc.presence.map(a=>a.person),n=[...new Set([...Object.keys(t.hass?.states??{}).filter(a=>a.startsWith("person.")).sort(),...e])],r=O(t.hass,me),i=t.doc.floors.flatMap(a=>a.rooms.map(c=>({id:c.id,label:t.doc.floors.length>1?`${a.name} \xB7 ${c.name}`:c.name}))),o=(a,c)=>t.replace({...structuredClone(t.doc),presence:Ph(t.doc.presence,a,c)}),s=a=>{let c=t.doc.presence.find(d=>d.person===a),u=!a.startsWith("person.");return m`${z(t,`${B(t.hass,a)} \xB7 ${t.t("presence_sensor")}`,c?.sensor??null,void 0,Dh(r,a),d=>o(a,{sensor:d}))} ${u?m``:_}`},l=O(t.hass,a=>/^(input_boolean|binary_sensor|device_tracker)\./.test(a)&&!n.includes(a));return m`
${t.t("presence")}
${n.length>0?n.map(s):m`

${t.t("no_persons")}

`}
${z(t,t.t("presence_add"),null,void 0,l,a=>a&&a!=="none"&&t.replace({...structuredClone(t.doc),presence:[...t.doc.presence,{person:a,sensor:null}]}))}
${S(t.t("presence_hint"))}
`}function Bh(t,e){return X(t.hass)?m``:m`
${t.t("ble")} ${S(t.t("ble_hint"))}
`}var gi=(t,e)=>{let n=t._$AN;if(n===void 0)return!1;for(let r of n)r._$AO?.(e,!1),gi(r,e);return!0},No=t=>{let e,n;do{if((e=t._$AM)===void 0)break;n=e._$AN,n.delete(t),t=e}while(n?.size===0)},Vh=t=>{for(let e;e=t._$AM;t=e){let n=e._$AN;if(n===void 0)e._$AN=n=new Set;else if(n.has(t))break;n.add(t),Tv(e)}};function Av(t){this._$AN!==void 0?(No(this),this._$AM=t,Vh(this)):this._$AM=t}function Fv(t,e=!1,n=0){let r=this._$AH,i=this._$AN;if(i!==void 0&&i.size!==0)if(e)if(Array.isArray(r))for(let o=n;o{t.type==Hn.CHILD&&(t._$AP??=Fv,t._$AQ??=Av)},Bo=class extends Ct{constructor(){super(...arguments),this._$AN=void 0}_$AT(e,n,r){super._$AT(e,n,r),Vh(this),this.isConnected=e._$AU}_$AO(e,n=!0){e!==this.isConnected&&(this.isConnected=e,e?this.reconnected?.():this.disconnected?.()),n&&(gi(this,e),No(this))}setValue(e){if(bd(this._$Ct))this._$Ct._$AI(e,this);else{let n=[...this._$Ct._$AH];n[this._$Ci]=e,this._$Ct._$AI(n,this,0)}}disconnected(){}reconnected(){}};var nl=new WeakMap,Wh=an(class extends Bo{render(t){return _}update(t,[e]){let n=e!==this.G;return n&&this.rt(void 0),(n||this.lt!==this.ct)&&(this.G=e,this.ht=t.options?.host,this.rt(this.ct=t.element)),_}rt(t){if(this.G!==void 0)if(this.isConnected||(t=void 0),typeof this.G=="function"){let e=this.ht??globalThis,n=nl.get(e);n===void 0&&(n=new WeakMap,nl.set(e,n)),n.get(this.G)!==void 0&&this.G.call(this.ht,void 0),n.set(this.G,t),t!==void 0&&this.G.call(this.ht,t)}else this.G.value=t}get lt(){return typeof this.G=="function"?nl.get(this.ht??globalThis)?.get(this.G):this.G?.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}});var Kh=t=>t.trim().toLowerCase().replace(/ä/g,"ae").replace(/ö/g,"oe").replace(/ü/g,"ue").replace(/ß/g,"ss").replace(/[^a-z0-9_-]+/g,"_").replace(/^_+|_+$/g,"").slice(0,40);function jh(t){let e=t.t,n=t.doc.settings.card_templates??{},r=Object.keys(n),i=l=>t.change(a=>{a.settings.card_templates=Object.keys(l).length?l:void 0});t.loadCardEditor?.();let o=l=>{t.hass?.callService("nextfloor","reload_screens",l?{template:l}:{})},s=l=>{let a=Kh(l.value);!a||a in n||r.length>=20||(l.value="",i({...n,[a]:{}}))};return m`
${e("card_templates")}${r.length?m` ${r.length}`:_} ${S(e("card_templates_hint"))} ${r.map(l=>m`
${l} a&&a.setConfig({type:"custom:nextfloor-card",...n[l]}))} @config-changed=${a=>{a.stopPropagation();let{type:c,template:u,...d}=a.detail.config;i({...n,[l]:d})}} > ${t.admin?m`
`:_} ${S(e("template_use",{name:l}))}
`)} ${t.admin?m`
`:_}
`}var Vo=.05,zv=(t,e)=>t.length===e.length&&t.every((n,r)=>Math.abs(n[0]-e[r][0])<.001&&Math.abs(n[1]-e[r][1])<.001),vn=t=>new Map(t.map(e=>[e.id,e]));function Pv(t,e,n,r){let i=e.name,[o,s]=[vn(t.rooms),vn(e.rooms)];for(let h of e.rooms){let f=o.get(h.id);f?(f.name!==h.name&&n.push({kind:"room_renamed",floor:i,name:h.name,detail:f.name}),zv(f.points,h.points)||n.push({kind:"room_reshaped",floor:i,name:h.name,detail:Math.round((xe(h.points)-xe(f.points))*10)/10})):n.push({kind:"room_added",floor:i,name:h.name})}for(let h of t.rooms)s.has(h.id)||n.push({kind:"room_removed",floor:i,name:h.name});let[l,a]=[vn(t.openings),vn(e.openings)];for(let h of e.openings)l.has(h.id)||n.push({kind:"opening_added",floor:i,name:h.type,detail:r(h.room_id)});for(let h of t.openings)a.has(h.id)||n.push({kind:"opening_removed",floor:i,name:h.type,detail:r(h.room_id)});let[c,u]=[vn(t.furniture),vn(e.furniture)];for(let h of e.furniture){let f=c.get(h.id);f?(Math.hypot(h.x-f.x,h.z-f.z)>Vo||Math.abs(h.rotation-f.rotation)>1||Math.abs(h.w-f.w)>Vo||Math.abs(h.d-f.d)>Vo)&&n.push({kind:"furniture_moved",floor:i,name:h.name||h.type}):n.push({kind:"furniture_added",floor:i,name:h.name||h.type})}for(let h of t.furniture)u.has(h.id)||n.push({kind:"furniture_removed",floor:i,name:h.name||h.type});let[d,p]=[new Map(t.placements.map(h=>[h.entity_id,h])),new Map(e.placements.map(h=>[h.entity_id,h]))];for(let h of e.placements){let f=d.get(h.entity_id);f?Math.hypot(h.x-f.x,h.z-f.z)>Vo&&n.push({kind:"device_moved",floor:i,name:h.entity_id}):n.push({kind:"device_added",floor:i,name:h.entity_id})}for(let h of t.placements)p.has(h.entity_id)||n.push({kind:"device_removed",floor:i,name:h.entity_id})}function Uh(t,e){let n=[],r=vn(t.floors),i=new Map([...t.floors,...e.floors].flatMap(l=>l.rooms.map(a=>[a.id,a.name]))),o=l=>i.get(l)??"";for(let l of e.floors){let a=r.get(l.id);a?Pv(a,l,n,o):n.push({kind:"floor_added",floor:l.name,name:l.name})}let s=new Set(e.floors.map(l=>l.id));for(let l of t.floors)s.has(l.id)||n.push({kind:"floor_removed",floor:l.name,name:l.name});return n}var wn=(t,e)=>t.getUint16(e,!0),_i=(t,e)=>t.getUint32(e,!0);function Gh(t){let e=new DataView(t.buffer,t.byteOffset,t.byteLength),n=-1;for(let l=t.length-22;l>=Math.max(0,t.length-65557);l--)if(_i(e,l)===101010256){n=l;break}if(n<0)throw new Error("not_zip");let r=wn(e,n+10),i=_i(e,n+16),o=[],s=new TextDecoder;for(let l=0;l",quot:'"',apos:"'"},Iv=t=>t.replace(/&(#x?[0-9a-f]+|\w+);/gi,(e,n)=>n[0]==="#"?String.fromCodePoint(Number.parseInt(n.slice(n[1]==="x"?2:1),n[1]==="x"?16:10)):Dv[n]??e);function Ov(t){let e={};for(let n of t.matchAll(/([\w:.-]+)\s*=\s*(?:"([^"]*)"|'([^']*)')/g))e[n[1]]=Iv(n[2]??n[3]);return e}function Hv(t){let e=[],n=null;for(let r of t.matchAll(/<(\/?)(level|room|point|wall|doorOrWindow|pieceOfFurniture)\b([^>]*?)(\/?)>/g)){let[,i,o,s,l]=r;if(i){o==="room"&&(n=null);continue}let a=Ov(s);if(o==="point"){n&&n.points.push([Number(a.x)/100,Number(a.y)/100]);continue}let c={name:o,attrs:a,...o==="room"?{points:[]}:{}};e.push(c),o==="room"&&!l&&(n=c)}return e}var oe=(t,e,n)=>Number.isFinite(Number(t[e]))&&t[e]!==void 0?Number(t[e]):n,Te=t=>Math.round(t*1e3)/1e3;function qh(t,e,n){let[r,i]=[n[0]-e[0],n[1]-e[1]],o=Math.hypot(r,i)||1e-9,s=Math.max(0,Math.min(o,((t[0]-e[0])*r+(t[1]-e[1])*i)/o)),l=[e[0]+r*s/o,e[1]+i*s/o];return{dist:Math.hypot(t[0]-l[0],t[1]-l[1]),along:s,length:o}}function Lv(t){let e=`${t.name??""} ${t.catalogId??""}`.toLowerCase();return/garage|sectional|rolltor/.test(e)?"garage":/door|tür|tuer|porte|puerta|deur|haustür/.test(e)&&!/window|fenster/.test(e)?"door":"window"}function Cv(t,e){let n=t.length,r=t.map((i,o)=>{let s=t[(o+1)%n],[l,a]=[s[0]-i[0],s[1]-i[1]],c=Math.hypot(l,a)||1e-9,u=[l/c,a/c],d=[(i[0]+s[0])/2,(i[1]+s[1])/2],p=[0,0];for(let h of e){let[f,g]=[h.b[0]-h.a[0],h.b[1]-h.a[1]],b=Math.hypot(f,g)||1e-9;if(Math.abs((u[0]*g-u[1]*f)/b)>.05)continue;let y=(h.a[0]-d[0])*-u[1]+(h.a[1]-d[1])*u[0],v=((d[0]-h.a[0])*f+(d[1]-h.a[1])*g)/b;if(!(Math.abs(y)>h.thickness/2+.06||v<-.05||v>b+.05)){p=[-u[1]*y,u[0]*y];break}}return{p:[i[0]+p[0],i[1]+p[1]],dir:u}});return r.map((i,o)=>{let s=r[(o-1+n)%n],l=s.dir[0]*i.dir[1]-s.dir[1]*i.dir[0];if(Math.abs(l)<1e-6)return i.p;let a=((i.p[0]-s.p[0])*i.dir[1]-(i.p[1]-s.p[1])*i.dir[0])/l;return[s.p[0]+s.dir[0]*a,s.p[1]+s.dir[1]*a]})}function Nv(t){let e=Dt(),n={floors:0,rooms:0,openings:0,walls:0,furniture:0},r=t.filter(a=>a.name==="level"),i=r.length?r.map(a=>a.attrs.id??""):[""],o=t.filter(a=>a.name==="wall"),s=o.length?Math.max(...o.map(a=>oe(a.attrs,"height",250)))/100:2.5;return(r.length?[...r].sort((a,c)=>oe(a.attrs,"elevation",0)-oe(c.attrs,"elevation",0)||oe(a.attrs,"elevationIndex",0)-oe(c.attrs,"elevationIndex",0)):[{name:"level",attrs:{id:""}}]).forEach((a,c)=>{let u=a.attrs.id??"",d=b=>r.length?(b.attrs.level??i[0])===u:!0,p=We(I("floor"),a.attrs.name||(c===0?"Erdgeschoss":`Etage ${c+1}`),Te(oe(a.attrs,"elevation",0)/100));p.height=Te(oe(a.attrs,"height",s*100)/100);let h=o.filter(d).map(b=>({a:[oe(b.attrs,"xStart",0)/100,oe(b.attrs,"yStart",0)/100],b:[oe(b.attrs,"xEnd",0)/100,oe(b.attrs,"yEnd",0)/100],thickness:oe(b.attrs,"thickness",10)/100})),f=t.filter(b=>b.name==="room"&&d(b)&&(b.points?.length??0)>=3).map((b,y)=>({id:I("room"),name:b.attrs.name||`Raum ${y+1}`,area_id:null,points:Cv(b.points,h).map(([v,w])=>[Te(v),Te(w)]),floor_material:"wood",panel:[]}));p.rooms=f;for(let b of t.filter(y=>y.name==="doorOrWindow"&&d(y))){let y=[oe(b.attrs,"x",0)/100,oe(b.attrs,"y",0)/100],v=Math.max(.6,oe(b.attrs,"depth",30)/100+.3),w=null;for(let L of f)L.points.forEach((P,N)=>{let V=qh(y,P,L.points[(N+1)%L.points.length]);V.dist<=v&&(!w||V.dist1.4?2:1,swing:"in",cover:null,contact:null,contact2:null,tilt:null})}let g=[];for(let b of o.filter(d)){let y=[oe(b.attrs,"xStart",0)/100,oe(b.attrs,"yStart",0)/100],v=[oe(b.attrs,"xEnd",0)/100,oe(b.attrs,"yEnd",0)/100];if(Math.hypot(v[0]-y[0],v[1]-y[1])<.1)continue;let w=Math.max(.15,oe(b.attrs,"thickness",10)/100),x=F=>f.some(L=>L.points.some((P,N)=>qh(F,P,L.points[(N+1)%L.points.length]).dist[y[0]+(v[0]-y[0])*F/M,y[1]+(v[1]-y[1])*F/M],T=Array.from({length:M+1},(F,L)=>!x(E(L)));for(let F=0;F<=M;){if(!T[F]){F++;continue}let L=F;for(;L+1<=M&&T[L+1];)L++;let[P,N]=[E(Math.max(0,F-1)),E(Math.min(M,L+1))];Math.hypot(N[0]-P[0],N[1]-P[1])>=.3&&g.push({id:I("wall"),a:[Te(P[0]),Te(P[1])],b:[Te(N[0]),Te(N[1])],thickness:Te(oe(b.attrs,"thickness",10)/100),height:b.attrs.height?Te(oe(b.attrs,"height",250)/100):null}),F=L+1}}p.walls=g,n.rooms+=f.length,n.openings+=p.openings.length,n.walls+=g.length,(f.length||g.length)&&e.floors.push(p)}),n.floors=e.floors.length,n.furniture=t.filter(a=>a.name==="pieceOfFurniture").length,{building:Oe(e),report:n}}async function Yh(t){let e=Gh(t).find(i=>i.name==="Home.xml");if(!e)throw new Error("sh3d_no_xml");let n=new TextDecoder().decode(await Zh(t,e)),r=Nv(Hv(n));if(r.report.rooms===0&&r.report.walls===0)throw new Error("sh3d_empty");return r}function Bv(t){let e=t.split(/\r?\n/),n=[];for(let r=0;r+1r===9&&i==="$INSUNITS"),n=e>=0?Number(t[e+1]?.[1]):NaN;return{1:.0254,2:.3048,4:.001,5:.01,6:1}[n]??null}function Wv(t){let e=Bv(t),n=Vv(e),r=e.findIndex(([s,l],a)=>s===2&&l==="ENTITIES"&&e[a-1]?.[1]==="SECTION"),i=[];if(r<0)return{shapes:i,unit:n};let o=r+1;for(;oNumber(c.find(([h])=>h===p)?.[1]??NaN),d=[[u(10),u(20)],[u(11),u(21)]];d.every(([p,h])=>Number.isFinite(p)&&Number.isFinite(h))&&i.push({points:d,closed:!1})}else if(l==="LWPOLYLINE"){let u=c.filter(([f])=>f===10).map(([,f])=>Number(f)),d=c.filter(([f])=>f===20).map(([,f])=>Number(f)),p=Number(c.find(([f])=>f===70)?.[1]??0),h=u.map((f,g)=>[f,d[g]]).filter(([f,g])=>Number.isFinite(f)&&Number.isFinite(g));h.length>=2&&i.push({points:h,closed:(p&1)===1})}o=a}return{shapes:i,unit:n}}var Xh=t=>Math.round(t*1e3)/1e3;function Jh(t){let{shapes:e,unit:n}=Wv(t);if(!e.length)throw new Error("dxf_empty");let r=e.flatMap(h=>h.points),i=Math.max(Math.max(...r.map(h=>h[0]))-Math.min(...r.map(h=>h[0])),Math.max(...r.map(h=>h[1]))-Math.min(...r.map(h=>h[1]))),o=n??(i>2e3?.001:i>200?.01:1),s=Math.min(...r.map(h=>h[0])),l=Math.max(...r.map(h=>h[1])),a=([h,f])=>[Xh((h-s)*o),Xh((l-f)*o)],c=We(I("floor"),"Erdgeschoss",0),u=[],d=[];for(let h of e){let f=h.points.map(a);if(h.closed&&f.length>=3)u.push({id:I("room"),name:`Raum ${u.length+1}`,area_id:null,points:f,floor_material:"wood",panel:[]});else for(let g=0;g+1.05&&d.push({id:I("wall"),a:f[g],b:f[g+1]})}c.rooms=u,c.walls=d;let p=Dt();return p.floors=[c],{building:Oe(p),report:{floors:1,rooms:u.length,openings:0,walls:d.length,furniture:0}}}var Qe=t=>Math.round(t*100)/100;function Kv(t,e){let n=t.category;return typeof n=="string"?n:n&&typeof n=="object"?Object.keys(n)[0]??e:e}function jv(t,e){let n=t,r=n?.transform,i=n?.dimensions;if(!n||!Array.isArray(r)||r.length<16||!Array.isArray(i)||i.length<3)return null;let o=l=>Number(l),s=Math.hypot(o(r[0]),o(r[2]));return![...r.slice(0,16),...i.slice(0,3)].every(l=>Number.isFinite(o(l)))||s<1e-6?null:{centre:[o(r[12]),o(r[13]),o(r[14])],dir:[o(r[0])/s,o(r[2])/s],size:[o(i[0]),o(i[1]),o(i[2])],kind:Kv(n,e)}}var nr=(t,e,n)=>(Array.isArray(t[e])?t[e]:[]).map(r=>jv(r,n)).filter(r=>!!r);function Uv(t){if(t.length<3)return null;let e=t.map(a=>{let c=a.size[0]/2;return[[a.centre[0]-a.dir[0]*c,a.centre[2]-a.dir[1]*c],[a.centre[0]+a.dir[0]*c,a.centre[2]+a.dir[1]*c]]}),n=(a,c)=>Math.hypot(a[0]-c[0],a[1]-c[1]),r=.4,i=new Set([0]),o=[e[0][0]],s=[0],l=e[0][1];for(;i.sizer?null:(o[0]=[(l[0]+o[0][0])/2,(l[1]+o[0][1])/2],{points:o,edgeWall:s})}function Qh(t){let e=[],n=[];for(let l of t){let a=l.size[0]/2;for(let c of[-1,1])e.push(l.centre[0]+c*l.dir[0]*a),n.push(l.centre[2]+c*l.dir[1]*a)}let[r,i,o,s]=[Math.min(...e),Math.max(...e),Math.min(...n),Math.max(...n)];return[[r,o],[i,o],[i,s],[r,s]]}function Gv(t,e,n){let[r,i]=[n[0]-e[0],n[1]-e[1]],o=Math.hypot(r,i)||1e-9,s=Math.min(o,Math.max(0,((t[0]-e[0])*r+(t[1]-e[1])*i)/o));return{dist:Math.hypot(t[0]-(e[0]+r/o*s),t[1]-(e[1]+i/o*s)),along:s,length:o}}var Zv={sofa:"sofa",bed:"bed",table:"table",chair:"chair",bathtub:"bathtub",toilet:"wc",sink:"sink",refrigerator:"fridge",stove:"stove",oven:"stove",dishwasher:"dishwasher",washerDryer:"washer",storage:"tall_cabinet",television:"tv_board"};function ep(t){let e=t;return!e||typeof e!="object"||"floors"in e||"settings"in e?!1:(Array.isArray(e.rooms)?e.rooms:[e]).some(r=>r&&Array.isArray(r.walls)&&nr(r,"walls","wall").length>0)}function tp(t){let e=t,r=(Array.isArray(e.rooms)?e.rooms:[e]).filter(b=>b&&typeof b=="object").map(b=>({walls:nr(b,"walls","wall"),doors:[...nr(b,"doors","door"),...nr(b,"openings","opening")],windows:nr(b,"windows","window"),objects:nr(b,"objects","object")})).filter(b=>b.walls.length);if(!r.length)throw new Error("roomplan_empty");let i=r.flatMap(b=>b.walls),o=Math.min(...i.map(b=>b.centre[1]-b.size[1]/2)),s=r.map(b=>Uv(b.walls)),l=r.flatMap((b,y)=>s[y]?.points??Qh(b.walls)),[a,c]=[Math.min(...l.map(b=>b[0]))-.5,Math.min(...l.map(b=>b[1]))-.5],u=([b,y])=>[Qe(b-a),Qe(y-c)],d=We(I("floor"),"Erdgeschoss",0);d.height=Qe(Math.max(2.2,Math.min(4,Math.max(...i.map(b=>b.size[1])))));let p=[],h=[];r.forEach((b,y)=>{let w=(s[y]?.points??Qh(b.walls)).map(u),x={id:I("room"),name:`Raum ${y+1}`,area_id:null,points:w,floor_material:"wood",panel:[]};p.push(x);for(let k of[...b.doors.map(M=>({v:M,window:!1})),...b.windows.map(M=>({v:M,window:!0}))]){let M=[k.v.centre[0]-a,k.v.centre[2]-c],E=null;if(w.forEach((P,N)=>{let V=Gv(M,P,w[(N+1)%w.length]);V.dist<=.6&&(!E||V.dist1.4?2:1,swing:"in",...L?{style:"passage"}:{},cover:null,contact:null,contact2:null,tilt:null})}for(let k of b.objects){let M=Zv[k.kind];if(!M)continue;let[E,T,F]=[k.size[0],k.size[2],k.size[1]];E<.1||T<.1||h.push({id:I("f"),type:M,x:Qe(k.centre[0]-a),z:Qe(k.centre[2]-c),rotation:Math.round((Math.atan2(k.dir[1],k.dir[0])*180/Math.PI+360)%360),w:Qe(E),d:Qe(T),h:Qe(F),variant:null,entity:null,power:null})}}),d.rooms=p,d.furniture=h;let f=Dt();f.floors=[d];let g=r.reduce((b,y)=>b+y.objects.length,0)-h.length;return{building:Oe(f),report:{floors:1,rooms:p.length,openings:d.openings.length,walls:0,furniture:g}}}var bi=t=>typeof t=="object"&&t!==null&&!Array.isArray(t)&&"ref"in t;function qv(t){let e=0,n=()=>{for(;t[e]===" ";)e++;let i=t[e];if(i==="("){e++;let a=[];for(;eString.fromCharCode(...(n.match(/.{4}/g)??[]).map(r=>parseInt(r,16)))).replace(/\\S\\(.)/g,(e,n)=>String.fromCharCode(n.charCodeAt(0)+128))}function Xv(t){let e=new Map,n=t.slice(Math.max(0,t.indexOf("DATA;")));for(let r of n.matchAll(/#(\d+)\s*=\s*([A-Z0-9_]+)\s*\(([\s\S]*?)\)\s*;(?=\s*(?:#|ENDSEC))/g))e.set(Number(r[1]),{type:r[2],args:qv(r[3])});return e}var np={x:0,y:0,z:0,c:1,s:0},rp=(t,e)=>({x:t.x+t.c*e.x-t.s*e.y,y:t.y+t.s*e.x+t.c*e.y,z:t.z+e.z,c:t.c*e.c-t.s*e.s,s:t.s*e.c+t.c*e.s});function ip(t){let e=Xv(t);if(!e.size)throw new Error("ifc_empty");let n=k=>bi(k)?e.get(k.ref):void 0,r=k=>typeof k=="number"?k:NaN,i=k=>(n(k)?.args[0]??[]).map(M=>r(M)),o=[...e.values()].find(k=>k.type==="IFCSIUNIT"&&k.args[1]===".LENGTHUNIT."),s=o?{".MILLI.":.001,".CENTI.":.01,".DECI.":.1}[String(o.args[2])]??1:1,l=k=>{let M=n(k);if(!M)return np;let[E=0,T=0,F=0]=i(M.args[0]),L=n(M.type==="IFCAXIS2PLACEMENT3D"?M.args[2]:M.args[1]),[P=1,N=0]=(L?.args[0]??[]).map(q=>r(q)),V=Math.hypot(P,N)||1;return{x:E||0,y:T||0,z:F||0,c:P/V,s:N/V}},a=(k,M=0)=>{let E=n(k);return!E||E.type!=="IFCLOCALPLACEMENT"||M>30?np:rp(a(E.args[0],M+1),l(E.args[1]))},c=k=>{for(let M of n(k)?.args[2]??[])for(let E of n(M)?.args[3]??[]){let T=n(E);if(T?.type!=="IFCEXTRUDEDAREASOLID")continue;let F=n(T.args[0]),L=rp(l(T.args[1]),l(F?.args[2])),P=[];if(F?.type==="IFCRECTANGLEPROFILEDEF"){let[N,V]=[r(F.args[3])/2,r(F.args[4])/2];P=[[-N,-V],[N,-V],[N,V],[-N,V]]}else if(F?.type==="IFCARBITRARYCLOSEDPROFILEDEF"){let N=n(F.args[2]);N?.type==="IFCPOLYLINE"&&(P=(N.args[0]??[]).map(V=>i(V)))}if(P=P.filter(N=>Number.isFinite(N[0])&&Number.isFinite(N[1])),P.length>3&&Math.hypot(P[0][0]-P[P.length-1][0],P[0][1]-P[P.length-1][1])<1e-6&&P.pop(),P.length>=3)return P.map(([N,V])=>[L.x+L.c*N-L.s*V,L.y+L.s*N+L.c*V])}return null},u=new Map;for(let[,k]of e){if(k.type==="IFCRELAGGREGATES"&&bi(k.args[4]))for(let M of k.args[5]??[])bi(M)&&u.set(M.ref,k.args[4].ref);if(k.type==="IFCRELCONTAINEDINSPATIALSTRUCTURE"&&bi(k.args[5]))for(let M of k.args[4]??[])bi(M)&&u.set(M.ref,k.args[5].ref)}let d=[...e].filter(([,k])=>k.type==="IFCBUILDINGSTOREY").map(([k,M])=>({id:k,name:String(M.args[7]||M.args[2]||"")||null,elevation:r(M.args[9])*s}));d.sort((k,M)=>(k.elevation||0)-(M.elevation||0));let p=[];for(let[k,M]of e){if(M.type!=="IFCSPACE")continue;let E=c(M.args[6]);if(!E)continue;let T=a(M.args[5]),F=E.map(([P,N])=>[(T.x+T.c*P-T.s*N)*s,(T.y+T.s*P+T.c*N)*s]),L=String(M.args[7]||M.args[2]||"")||`Raum ${p.length+1}`;p.push({storey:u.get(k)??null,name:L,ring:F})}if(!p.length)throw new Error("ifc_empty");let h=p.flatMap(k=>k.ring),f=Math.min(...h.map(k=>k[0])),g=Math.max(...h.map(k=>k[1])),b=k=>Math.round(k*1e3)/1e3,y=[],v=new Map;if(d.filter(k=>p.some(M=>M.storey===k.id)).forEach((k,M)=>{let E=We(I("floor"),k.name??`Etage ${M+1}`,Number.isFinite(k.elevation)?b(k.elevation):M*2.8);y.push(E),v.set(k.id,E)}),p.some(k=>k.storey===null||!v.has(k.storey))){let k=We(I("floor"),y.length?"Weitere R\xE4ume":"Erdgeschoss",y.length?y[y.length-1].elevation+2.8:0);y.push(k),v.set(null,k)}y.forEach((k,M)=>{let E=y[M+1];E&&E.elevation-k.elevation>1.8&&(k.height=b(E.elevation-k.elevation-.2))});for(let k of p)v.get(k.storey!==null&&v.has(k.storey)?k.storey:null).rooms.push({id:I("room"),name:k.name,area_id:null,points:k.ring.map(([E,T])=>[b(E-f),b(g-T)]),floor_material:"wood",panel:[]});let x=Dt();return x.floors=y,{building:Oe(x),report:{floors:y.length,rooms:p.length,openings:0,walls:0,furniture:0}}}var sp="nextfloor",Jv="alarm_control_panel|automation|binary_sensor|button|calendar|camera|climate|conversation|cover|date|datetime|device_tracker|event|fan|group|humidifier|image|input_boolean|input_button|input_datetime|input_number|input_select|input_text|lawn_mower|light|lock|media_player|notify|number|person|remote|scene|script|select|sensor|siren|stt|sun|switch|text|time|timer|todo|tts|update|vacuum|valve|water_heater|weather|zone",op=new RegExp(`^(?:${Jv})\\.[a-z0-9_]+$`),Qv=/^[0-9a-f]{32}$/,ew=new Set(["area_id","ha_floor"]),tw=new Set(["sub_areas"]),nw=new Set(["tap","show_when","pictures","moods"]);function rl(t){if(typeof t=="string")return op.test(t)||Qv.test(t)?null:t;if(Array.isArray(t))return t.map(e=>rl(e)).filter(e=>e!==null);if(t&&typeof t=="object"){let e={};for(let[n,r]of Object.entries(t))op.test(n)||nw.has(n)||(ew.has(n)||tw.has(n)?e[n]=null:e[n]=rl(r));return e}return t}var rw=["wall_exterior","wall_interior","wall_paint_outside","wall_paint_inside","grid","north","roof","weather_effects","rain_warning","sun_patches","lock_plan","start_view","units","motion_markers_active","room_double_tap"];function ap(t){let e=structuredClone(t),n={};for(let i of rw)e.settings?.[i]!==void 0&&(n[i]=e.settings[i]);let r=e.settings?.backdrop;r&&(r.color||r.dim!=null)&&(n.backdrop={color:r.color??null,dim:r.dim??null}),e.settings=n,e.energy={...e.energy,grid:null,solar:null,battery:null,battery_soc:null,tariff:null,consumption:null,gas:null,water:null},e.presence=[];for(let i of e.floors){i.background=null,i.placements=[],i.power_entity=null,i.utility_meters=null,i.ha_floor=null;for(let o of i.rooms)Object.assign(o,{area_id:null,sub_areas:null,panel:[],hidden:[],no_state:[]});i.furniture.forEach(o=>{Object.assign(o,{entity:null,power:null}),delete o.effect_animations,o.picture&&!(o.picture.startsWith("image:")||o.picture.startsWith("https://"))&&(o.picture=null)}),i.openings.forEach(o=>Object.assign(o,{cover:null,contact:null,tilt:null}))}return rl(e)}function lp(t,e){return{format:sp,version:1,exported_at:new Date().toISOString(),building:e?ap(t):structuredClone(t)}}var iw=t=>!!t&&(t.version===1||t.version===void 0)&&Array.isArray(t.floors)&&t.floors.every(e=>!!e&&typeof e=="object"),ow="https://therealmrbk.github.io/NextFloor/preview/?shared&noshowcase";function cp(t,e,n,r,i=ow){let o=new Set(t.floors.flatMap(c=>c.furniture.map(u=>u.type)).filter(c=>c.startsWith("pack:")).map(c=>c.split(":")[1])),s={building:ap(t),packs:e.filter(c=>!c.builtin&&o.has(c.id))},l=JSON.stringify(s).replace(/c.replace(/[&<>"]/g,u=>({"&":"&","<":"<",">":">",'"':"""})[u]);return` ${a(n)}