diff --git a/asset-manifest.json b/asset-manifest.json index 7dd8bc80e..1bf267c4a 100644 --- a/asset-manifest.json +++ b/asset-manifest.json @@ -1,8 +1,8 @@ { "files": { "main.css": "/aladdin/static/css/main.c1ee157d.chunk.css", - "main.js": "/aladdin/static/js/main.71a8bdfe.chunk.js", - "main.js.map": "/aladdin/static/js/main.71a8bdfe.chunk.js.map", + "main.js": "/aladdin/static/js/main.eb054a75.chunk.js", + "main.js.map": "/aladdin/static/js/main.eb054a75.chunk.js.map", "runtime-main.js": "/aladdin/static/js/runtime-main.b3c25317.js", "runtime-main.js.map": "/aladdin/static/js/runtime-main.b3c25317.js.map", "static/css/2.447301e6.chunk.css": "/aladdin/static/css/2.447301e6.chunk.css", @@ -203,6 +203,6 @@ "static/css/2.447301e6.chunk.css", "static/js/2.bba58f66.chunk.js", "static/css/main.c1ee157d.chunk.css", - "static/js/main.71a8bdfe.chunk.js" + "static/js/main.eb054a75.chunk.js" ] } \ No newline at end of file diff --git a/index.html b/index.html index d147c01b6..13f116d1d 100644 --- a/index.html +++ b/index.html @@ -1 +1 @@ -
0&&De&&Object(pf.jsx)(Kf,{cz:F[0].lz,points:De}),O&&!A&&Object(pf.jsxs)("group",{position:[0,0,b+.15],children:[Object(pf.jsx)(Ip,{position:[Ae.x,Ae.y,Ae.z],onPointerDown:function(){if(fe.current=!0,U(!0),jh.set(Ae.x,Ae.y,ie),l&&F[0]){var e=Xw.getState().cameraDirection,t=Math.atan2(e.z,e.y),a=F[0].relativeAngle;zh.set(-vt-t,0,a,"ZXY")}B(ge.Left),Nt.getState().setEnableOrbitController(!1)}}),Object(pf.jsx)(Ip,{position:[Pe.x,Pe.y,Pe.z],onPointerDown:function(e){if(Ce(t.id,e,X.Select),fe.current=!0,pe.current=R,U(!0),jh.set(Pe.x,Pe.y,ie),l){var a=-Math.atan2(se.position.x-n,se.position.y-c)-l.rotation[2];zh.set(-vt,0,a,"ZXY")}B(ge.Mid),Nt.getState().setEnableOrbitController(!1),I((function(e){e.resizeHandleType=K.Top,e.selectedElementHeight=ie+t.thickness}))},onPointerOver:function(){I((function(e){e.hoveredHandle=ge.Mid,e.selectedElementHeight=ie+t.thickness,e.selectedElementX=be.x,e.selectedElementY=be.y}))}}),Object(pf.jsx)(Ip,{position:[Te.x,Te.y,Te.z],onPointerDown:function(){if(fe.current=!0,U(!0),jh.set(Te.x,Te.y,ie),l&&F[0]){var e=Xw.getState().cameraDirection,t=Math.atan2(e.z,e.y),a=F[0].relativeAngle;zh.set(-vt-t,0,a,"ZXY")}B(ge.Right),Nt.getState().setEnableOrbitController(!1)}})]}),N&&Object(pf.jsx)(Lt.f,{name:"Roof Intersection Plane",ref:re,args:[1e3,100],visible:!1,position:jh,rotation:zh,onPointerMove:function(e){if(re.current&&fe.current){!function(e){ue.x=e.offsetX/ce.domElement.clientWidth*2-1,ue.y=-e.offsetY/ce.domElement.clientHeight*2+1,de.setFromCamera(ue,se)}(e);var o=de.intersectObjects([re.current]);if(o[0]&&l){var i=o[0].point;if(i.z<.001)return;var r=F[0],n=(new We.Vector3).subVectors(r.rightPoint,r.leftPoint).length();switch(G){case ge.Left:var c=Pe.clone().sub(jh).applyEuler(new We.Euler(0,0,-zh.z)),s=i.clone().sub(new We.Vector3(l.cx,l.cy,l.cz)).applyEuler(new We.Euler(0,0,-l.rotation[2])).sub(jh).applyEuler(new We.Euler(0,0,-zh.z)),d=(new We.Vector3).subVectors(s,c).x;_(Ww.clamp(-d,.1-te,n/2-.01));break;case ge.Right:var u=Pe.clone().sub(jh).applyEuler(new We.Euler(0,0,-zh.z)),f=i.clone().sub(new We.Vector3(l.cx,l.cy,l.cz)).applyEuler(new We.Euler(0,0,-l.rotation[2])).sub(jh).applyEuler(new We.Euler(0,0,-zh.z)),h=(new We.Vector3).subVectors(f,u).x;le(Ww.clamp(h,.1-Z,n/2-.01));break;case ge.Mid:var p=Math.max(0,i.z-l.lz-.3-oe);Xw.getState().updateRoofRiseById(a,p,ie+t.thickness)}}}},onPointerUp:function(){switch(G){case ge.Mid:Sp(a,pe.current,R);break;case ge.Left:case ge.Right:xe(a,Z,te),function(e,t,l,a,o){var i={name:"Resize Hip Roof Ridge",timestamp:Date.now(),resizedElementId:e,resizedElementType:V.Roof,oldLeftRidgeLength:t,oldRightRidgeLength:l,newLeftRidgeLength:a,newRightRidgeLength:o,undo:function(){xe(i.resizedElementId,i.oldLeftRidgeLength,i.oldRightRidgeLength,!0)},redo:function(){xe(i.resizedElementId,i.newLeftRidgeLength,i.newRightRidgeLength,!0)}};Xw.getState().addUndoable(i)}(a,f,p,Z,te)}fe.current=!1,U(!1),B(ge.Null),Nt.getState().setEnableOrbitController(!0)},children:Object(pf.jsx)("meshBasicMaterial",{side:We.DoubleSide,transparent:!0,opacity:.5})})]})},Wh=n.a.memo(Dh,Fp),Mh=new We.Vector3,Ih=new We.Euler,Ch=new We.Vector3(0,0,1),Fh=n.a.memo((function(e){var t=e.roofSegments,l=e.thickness,a=e.lineWidth,o=e.lineColor,i=Object(r.useMemo)((function(){return t.reduce((function(e,t){return e.concat(t.points[1])}),[t[0].points[0]])}),[t]),c=Object(r.useMemo)((function(){return t.reduce((function(e,t){return e.concat(t.points[6].clone())}),[t[0].points[7].clone()])}),[t]),s=Object(r.useMemo)((function(){return Object(pf.jsx)(Jl.a,{points:i,lineWidth:a,color:o})}),[i,a,o]);if(t.length<2)return null;var d=Math.abs(t[0].points[0].z-t[0].points[3].z)<.1;return Object(pf.jsxs)(pf.Fragment,{children:[!d&&Object(pf.jsx)(Jl.a,{points:c,lineWidth:a,color:o}),s,Object(pf.jsx)("group",{position:[0,0,l],children:s}),t.map((function(e,t){return Object(pf.jsxs)(n.a.Fragment,{children:[!d&&Object(pf.jsx)(Jl.a,{points:[e.points[7],e.points[4]],lineWidth:a,color:o}),Object(pf.jsx)(Jl.a,{points:[e.points[4],e.points[0]],lineWidth:a,color:o})]},t)}))]})})),kh=function(e){var t=e.roofModel,l=e.foundationModel,a=t.id,i=t.wallsId,c=t.cx,s=t.cy,d=t.lz,p=t.textureType,y=t.color,g=void 0===y?"white":y,m=t.sideColor,w=void 0===m?"white":m,x=t.thickness,v=void 0===x?.2:x,b=t.locked,A=t.lineColor,T=void 0===A?"black":A,P=t.lineWidth,S=void 0===P?.2:P,H=t.roofType,j=t.foundationId,z=t.ridgeWidth,R=void 0===z?1:z,D=t.rise,W=void 0===D?d:D,M=t.ceiling,I=void 0!==M&&M,C=t.frontRidge,F=t.backRidge,k=Yp(p),O=_f(a),Y=Zm.getWireframetStyle(T,S,O,b),L=Object(u.a)(Y,2);T=L[0],S=L[1];var N=Xw(si),U=Xw(Kc),E=Xw(o.shadowEnabled),J=Xw((function(e){return e.ray})),G=Xw((function(e){return e.mouse})),B=Object(r.useState)(R),q=Object(u.a)(B,2),Q=q[0],Z=q[1],_=Object(r.useState)(null),$=Object(u.a)(_,2),ee=$[0],te=$[1],le=Object(r.useState)(!1),ae=Object(u.a)(le,2),oe=ae[0],ie=ae[1],re=Object(r.useState)(ge.Null),ne=Object(u.a)(re,2),ce=ne[0],se=ne[1],de=Object(r.useState)(null),ue=Object(u.a)(de,2),fe=ue[0],pe=ue[1],ye=Object(r.useRef)(Q),me=Object(r.useRef)(W),we=Object(r.useRef)(null),xe=Object(r.useRef)(!1),ve=Object(Se.f)(),be=ve.gl,Ae=ve.camera,Te=W<.01,Pe=function(e,t){N((function(l){var a,o=Object(h.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;if(i.id===e&&i.type===V.Roof&&i.roofType===It.Mansard){i.ridgeWidth=t;break}}}catch(r){o.e(r)}finally{o.f()}}))},He=Np(j,a,i),je=He.currentWallArray,ze=He.isLoopRef,Re=Vp(je,W),De=Re.highestWallHeight,Me=Re.topZ;Xp(t,De);var Ie=Object(r.useMemo)((function(){if(je.length<2)return new We.Vector3;var e=function(e){var t,l=[],a=e.length,o=Object(h.a)(e);try{for(o.s();!(t=o.n()).done;){var i=t.value;void 0!==i.leftPoint[0]&&void 0!==i.leftPoint[1]&&l.push({x:i.leftPoint[0],y:i.leftPoint[1]})}}catch(r){o.e(r)}finally{o.f()}return ze.current||!e[a-1].rightPoint[0]&&0!==e[a-1].rightPoint[0]||!e[a-1].rightPoint[1]&&0!==e[a-1].rightPoint[1]||l.push({x:e[a-1].rightPoint[0],y:e[a-1].rightPoint[1]}),l}(je),t=Ww.calculatePolygonCentroid(e);return Number.isNaN(t.x)||Number.isNaN(t.y)?new We.Vector3:new We.Vector3(t.x,t.y,Me)}),[je,Me]),Ce=Object(r.useMemo)((function(){var e=je.map((function(e){var t;return Zm.getWallNormal(e).multiplyScalar(null!==(t=e.eavesLength)&&void 0!==t?t:0)}));if(!ze.current&&0!==e.length){var t=(new We.Vector3).subVectors(new We.Vector3(je[je.length-1].rightPoint[0],je[je.length-1].rightPoint[1]),new We.Vector3(je[0].leftPoint[0],je[0].leftPoint[1])).applyEuler(Wt).normalize().multiplyScalar(.3);e.push(t)}return e}),[je]),Fe=Object(r.useMemo)((function(){var e=je.map((function(e,t){return{leftPoint:new We.Vector3(e.leftPoint[0],e.leftPoint[1]).add(Ce[t]),rightPoint:new We.Vector3(e.rightPoint[0],e.rightPoint[1]).add(Ce[t])}}));return ze.current||0===e.length||e.push({leftPoint:new We.Vector3(je[je.length-1].rightPoint[0],je[je.length-1].rightPoint[1]).add(Ce[Ce.length-1]),rightPoint:new We.Vector3(je[0].leftPoint[0],je[0].leftPoint[1]).add(Ce[Ce.length-1])}),e}),[je,Ce]),ke=Object(r.useMemo)((function(){var e=je.map((function(e,t){var l=new We.Vector3(e.leftPoint[0],e.leftPoint[1]),a=new We.Vector3(e.rightPoint[0],e.rightPoint[1]),o=(new We.Vector3).subVectors(Ie,l).setZ(0).normalize().multiplyScalar(Q),i=(new We.Vector3).subVectors(Ie,a).setZ(0).normalize().multiplyScalar(Q);return l.add(o).setZ(Me),a.add(i).setZ(Me),{leftPoint:l,rightPoint:a}}));return ze.current||0===e.length||e.push({leftPoint:e[e.length-1].rightPoint,rightPoint:e[0].leftPoint}),e}),[je,Ie,Q]),Oe=Object(r.useMemo)((function(){return Ch.clone().multiplyScalar(v)}),[v]),Ye=Object(r.useMemo)((function(){var e=[];if(je.length<2)return e;for(var t=function(){for(var e=1/0,t=0;t 0&&Object(pf.jsx)(Fh,{roofSegments:Ye,thickness:v,lineColor:T,lineWidth:S})]})}),I&&W>0&&Object(pf.jsx)(Kf,{points:Ne,cz:je[0].lz}),O&&!b&&Object(pf.jsxs)("group",{position:[Ie.x,Ie.y,Ie.z+v],children:[Object(pf.jsx)(Ip,{position:[0,0,.3],onPointerDown:function(e){if(Ve(t.id,e,X.Select),xe.current=!0,me.current=W,ie(!0),Mh.set(Ie.x,Ie.y,Me),l){var a=-Math.atan2(Ae.position.x-c,Ae.position.y-s)-l.rotation[2];Ih.set(-vt,0,a,"ZXY")}se(ge.Top),Nt.getState().setEnableOrbitController(!1),N((function(e){e.resizeHandleType=K.Top,e.selectedElementHeight=Me+t.thickness}))},onPointerOver:function(){N((function(e){e.hoveredHandle=ge.Top,e.selectedElementHeight=Me+t.thickness,e.selectedElementX=Ie.x,e.selectedElementY=Ie.y}))}}),ke.map((function(e,t){var l=e.leftPoint.clone().sub(Ie);return Object(pf.jsx)(Ip,{position:[l.x,l.y,0],onPointerDown:function(){xe.current=!0,ie(!0),Mh.set(l.x,l.y,Me+.15),Ih.set(0,0,0),se(ge.Ridge),pe(t),te(je.reduce((function(e,t){return Math.min(e,new We.Vector3(t.leftPoint[0],t.leftPoint[1],Me).distanceTo(Ie)-1)}),1/0)),Nt.getState().setEnableOrbitController(!1),ye.current=Q}},t)}))]}),oe&&Object(pf.jsx)(Lt.f,{name:"Roof Intersection Plane",ref:we,args:[1e3,100],visible:!1,position:Mh,rotation:Ih,onPointerMove:function(e){if(we.current&&xe.current){!function(e){G.x=e.offsetX/be.domElement.clientWidth*2-1,G.y=-e.offsetY/be.domElement.clientHeight*2+1,J.setFromCamera(G,Ae)}(e);var o=J.intersectObjects([we.current]);if(o[0]&&l){var i=o[0].point;if(i.z<.001)return;switch(ce){case ge.Top:var r=Math.max(0,i.z-l.lz-.6-De);Xw.getState().updateRoofRiseById(a,r,Me+t.thickness);break;case ge.Ridge:if(l&&null!==fe){var n=i.clone().applyEuler(new We.Euler(0,0,l.rotation[2])).sub(new We.Vector3(l.cx,l.cy)).setZ(0),c=function(e){if(e 0&&c(o.id,T,a)<0&&(j[z][R]+=H*P))}else for(var M=0;M 0){var C=M-p/2+.5,F=I-y/2+.5;T.set(x.x+C*b,x.y+C*A,x.z+F*m),c(o.id,T,a)<0&&(j[M][I]+=H*P)}return{intensity:j,unitArea:g*m}}},{key:"pointWithinArch",value:function(e,t,l,a,o){if(a>0){var i=.5*t,r=Math.min(a,l,i),n=.5*(r+i*i/r),c=e.x-o.x,s=e.y-o.y,d=c*c+s*s,u=e.z-o.z;return d-l/2||d+(u=e.z-(l-n))*u 0){var C=M-p/2+.5,F=I-y/2+.5;T.set(x.x+C*b,x.y+C*A,x.z+F*m),c(o.id,T,a)<0&&(j[M][I]+=H*P)}return{intensity:j,unitArea:g*m}}},{key:"computeRoofWindowSolarRadiationEnergy",value:function(t,l,a,o,i,r,n,c){var s,d=Ww.dayOfYear(t),u=null!==(s=l.solarRadiationHeatmapGridCellSize)&&void 0!==s?s:.5,f=o.lx,h=o.lz,p=Math.max(2,Math.round(f/u)),y=Math.max(2,Math.round(h/u)),g=f/p,m=h/y,w=new We.Vector3(o.cx,o.cy,o.cz).applyEuler(new We.Euler(0,0,r.rotation[2]));w.x+=r.cx,w.y+=r.cy,w.z+=r.lz;var x=new We.Euler(o.rotation[0],o.rotation[1],o.rotation[2]+r.rotation[2],"ZXY"),v=new We.Vector3(0,0,1).applyEuler(x),b=new We.Vector3,A=Fy(a,d,n,py.SPHERE_MODEL),T=ky(l.ground,t.getMonth(),v,A),P=v.dot(a),S=Array(p).fill(0).map((function(){return Array(y).fill(0)}));if(o.windowType===Yt.Arched)for(var H=0;H 0&&c(o.id,b,a)<0&&(S[H][j]+=P*A))}else for(var W=0;W 0){var I=W-p/2+.5,C=M-y/2+.5,F=new We.Vector3(I,C,0);F.applyEuler(x),b.set(w.x+F.x,w.y+F.y,w.z+F.z),c(o.id,b,a)<0&&(S[W][M]+=P*A)}return{intensity:S,unitArea:g*m}}},{key:"computePyramidRoofSolarRadiationEnergy",value:function(t,l,a,o,i,r,n,c,s,d,f,p){var y;if(i)return e.computeFlatRoofSolarRadiationEnergy(t,l,a,o,r,n,c,s,d,f,p);var g,m=null!==(y=l.solarRadiationHeatmapGridCellSize)&&void 0!==y?y:.5,w=Ww.dayOfYear(t),x=new We.Euler(0,0,c.rotation[2],"ZYX"),v=Fy(a,w,f,py.SPHERE_MODEL),b=[],A=[],T=Object(h.a)(n.entries());try{var P=function(){var i=Object(u.a)(g.value,2),n=i[0],f=i[1],h=o.id+"-"+n,y=f[0].clone().applyEuler(x),w=f[1].clone().applyEuler(x),T=f[2].clone().applyEuler(x),P=(new We.Vector3).subVectors(w,y),S=(new We.Vector3).subVectors(T,y),H=(new We.Vector3).subVectors(T,w),j=P.length(),z=(new We.Vector3).crossVectors(S,H).length()/j,R=Math.max(2,Math.round(j/m)),D=Math.max(2,Math.round(z/m)),W=Array(R).fill(0).map((function(){return Array(D).fill(0)}));b.push(W),P.normalize();var M=R*S.dot(P)/j;S.normalize(),H.normalize();var I=(new We.Vector3).crossVectors(S,H).normalize(),C=P.multiplyScalar(.5*j/R),F=(new We.Vector3).crossVectors(I,P).normalize().multiplyScalar(.5*z/D),k=new We.Vector3(c.cx+y.x,c.cy+y.y,c.lz+y.z+Hy+(r?o.thickness:0));k.add(C).add(F),C.multiplyScalar(2),F.multiplyScalar(2),A.push(C.length()*F.length());var O=new We.Vector3,Y=[],L=.01;Y.push({x:-.01,y:-.01}),Y.push({x:R+L,y:-.01}),Y.push({x:M,y:D+L});for(var N=ky(l.ground,t.getMonth(),I,v),U=I.dot(a),E=0;E .01){i=!1;break}}}catch(re){d.e(re)}finally{d.f()}}}catch(re){n.e(re)}finally{n.f()}var p,g=i?1:a,m=[],w=y(V.Window,e.id),v=Object(h.a)(t);try{for(v.s();!(p=v.n()).done;){var b=p.value,A=0;if(3===b.length?A=Ww.getTriangleArea(b[0],b[1],b[2]):4===b.length&&(A=Ww.getTriangleArea(b[0],b[1],b[2])+Ww.getTriangleArea(b[2],b[3],b[0])),w.length>0){var T,P=Object(h.a)(w);try{for(P.s();!(T=P.n()).done;){var H=T.value;Zm.onSegment(b,H.cx,H.cy)&&(A-=H.lx*H.lz)}}catch(re){P.e(re)}finally{P.f()}A<0&&(A=0)}m.push(A)}}catch(re){v.e(re)}finally{v.f()}var j=i?[m.reduce((function(e,t){return e+t}),0)]:m,z=RT(e),D=Array(g).fill(0);if(Q.current&&Q.current.z>0){for(var W=y(V.SolarPanel,e.id),M=vO.computeHipRoofSolarRadiationEnergy(le,R,Q.current,e,i,!0,t,l,w,W,ae,ue),I=0;I 0){var d,u=Object(h.a)(i);try{for(u.s();!(d=u.n()).done;){var p=d.value;Zm.onSegment(c,p.cx,p.cy)&&(s-=p.lx*p.lz)}}catch(J){u.e(J)}finally{u.f()}s<0&&(s=0)}r.push(s)}}catch(J){n.e(J)}finally{n.f()}var g=RT(e),m=Array(a).fill(0);if(Q.current&&Q.current.z>0){for(var w=y(V.SolarPanel,e.id),v=vO.computeGableRoofSolarRadiationEnergy(le,R,Q.current,e,!0,t,l,i,w,ae,ue),b=0;b0&&(f(),j(),bf.setState((function(e){e.runStaticSimulation=!1,e.simulationInProgress=!1,e.showSolarRadiationHeatmap=!0})),Kh(me.t("message.SimulationCompleted",m)))}),[p]);var H=function(e,t,l){if(P.current.length>1){S.current.length=0,A.set(t,l);var a=P.current.filter((function(t){return t.uuid!==e}));return A.intersectObjects(a,!1,S.current),S.current.length>0}return!1},j=function(){!function(){var e=g.children.filter((function(e){return"Content"===e.name}));if(e.length>0){var t=e[0].children;P.current.length=0;var l,a=Object(h.a)(t);try{for(a.s();!(l=a.n()).done;){var o=l.value;Ww.fetchSimulationElements(o,P.current)}}catch(i){a.e(i)}finally{a.f()}}}();var e,t=Object(h.a)(i);try{for(t.s();!(e=t.n()).done;){var l=e.value;switch(l.type){case V.Foundation:var a=l;R(a),a.solarStructure===G.UpdraftTower&&D(a);break;case V.Cuboid:z(l);break;case V.SolarPanel:W(l);break;case V.Wall:M(l);break;case V.Door:I(l);break;case V.Roof:var o=l;switch(o.roofType){case It.Pyramid:C(o);break;case It.Gable:L(o);break;case It.Gambrel:k(o);break;case It.Mansard:F(o);break;case It.Hip:O(o)}}}}catch(r){t.e(r)}finally{t.f()}},z=function(e){var t=x.getFullYear(),l=x.getMonth(),a=x.getDate(),i=Ww.dayOfYear(x),r=e.lx,n=e.ly,s=e.lz,u=Math.max(2,Math.round(r/T)),f=Math.max(2,Math.round(n/T)),h=Math.max(2,Math.round(s/T)),p=r/u,y=n/f,g=s/h,m=c(e),A=e.cx,P=e.cy,S=e.cz;if(m&&m.type===V.Cuboid){var j=Ww.getWorldDataById(e.id);A=j.pos.x,P=j.pos.y,S=j.pos.z}for(var z=Array(u).fill(0).map((function(){return Array(f).fill(0)})),R=Array(u).fill(0).map((function(){return Array(h).fill(0)})),D=Array(u).fill(0).map((function(){return Array(h).fill(0)})),W=Array(f).fill(0).map((function(){return Array(h).fill(0)})),M=Array(f).fill(0).map((function(){return Array(h).fill(0)})),I=Rt,C=zt.clone().applyAxisAngle(Rt,e.rotation[2]),F=jt.clone().applyAxisAngle(Rt,e.rotation[2]),k=Ht.clone().applyAxisAngle(Rt,e.rotation[2]),O=St.clone().applyAxisAngle(Rt,e.rotation[2]),Y=new We.Vector3,L=0,U=new We.Vector2(A,P),E=new We.Vector2,J=P-n/2,G=P+n/2,X=A-r/2,B=A+r/2,K=0;K<24;K++)for(var q=0;q 0&&(H(e.id,j,F)||(z[L][U]+=Y*k)))}else for(var J=0;J 0&&(j.set(P.x+X*D,P.y+X*W,P.z+B*m),H(e.id,j,F)||(z[J][G]+=Y*k))}}}var K=R*b/60,q=K>At?w.sunshineHours[r]/(30*K*o.timesPerHour):0;N(z,q),d(e.id,z)},C=function(e){if(e.roofType!==It.Pyramid)throw new Error("roof is not pyramid");var t=s(e);if(!t)throw new Error("foundation of wall not found");var l=y(e.id);if(l&&0!==l.length){var a,i=!0,r=l[0][0].z,n=Object(h.a)(l);try{for(n.s();!(a=n.n()).done;){var c,f=a.value,p=Object(h.a)(f);try{for(p.s();!(c=p.n()).done;){var g=c.value;if(Math.abs(g.z-r)>.01){i=!1;break}}}catch(W){p.e(W)}finally{p.f()}}}catch(W){n.e(W)}finally{n.f()}if(i)Y(e,t,l);else{var m,A=x.getFullYear(),P=x.getMonth(),S=x.getDate(),j=Ww.dayOfYear(x),z=new We.Euler(0,0,t.rotation[2],"ZYX"),R=Object(h.a)(l.entries());try{var D=function(){var l=Object(u.a)(m.value,2),a=l[0],i=l[1],r=e.id+"-"+a,n=i[0].clone().applyEuler(z),c=i[1].clone().applyEuler(z),s=i[2].clone().applyEuler(z),f=(new We.Vector3).subVectors(c,n),h=(new We.Vector3).subVectors(s,n),p=(new We.Vector3).subVectors(s,c),y=f.length(),g=(new We.Vector3).crossVectors(h,p).length()/y,x=Math.max(2,Math.round(y/T)),R=Math.max(2,Math.round(g/T)),D=Array(x).fill(0).map((function(){return Array(R).fill(0)}));f.normalize(),h.normalize(),p.normalize();var W=(new We.Vector3).crossVectors(h,p).normalize(),M=f.multiplyScalar(.5*y/x),I=(new We.Vector3).crossVectors(W,f).normalize().multiplyScalar(.5*g/R),C=new We.Vector3(t.cx+n.x,t.cy+n.y,t.lz+n.z+Hy);C.add(M).add(I),M.multiplyScalar(2),I.multiplyScalar(2);for(var F=0,k=new We.Vector3,O=0;O<24;O++)for(var Y=0;Y 0){C++;for(var U=Fy(L,c,v,py.SPHERE_MODEL),E=ky(o.ground,r,Rt,U),V=Rt.dot(L),J=0;J.1,de=S>0&&T;Object(r.useEffect)((function(){var e=function(){Nt.getState().setEnableOrbitController(!0),Z.current=!1,Q(!1),D((function(e){e.rotateHandleType=null,e.moveHandleType=null,e.resizeHandleType=null}))};return window.addEventListener("pointerup",e),function(){window.removeEventListener("pointerup",e)}}),[]);var ue=function(e,t){e.intersections.length>0&&(e.intersections[0].object===e.eventObject&&(J(t),t===B.Top?k.style.cursor="move":t===q.Lower||t===q.Upper||t===q.Tilt?k.style.cursor="grab":k.style.cursor="pointer"))},fe=function(){J(null),k.style.cursor="default"},he=function(e){return E===e||Xw.getState().rotateHandleType===e?pt:ht};return Object(pf.jsxs)("group",{name:"Solar Panel Group",position:[a,o,S+n],rotation:re,children:[Object(pf.jsx)(gw,{solarPanelModel:e,groupRotation:re,panelRotation:ne}),ce&&Object(pf.jsxs)("group",{position:[0,0,-S],rotation:[0,0,ne.z],children:[Object(pf.jsx)(uy,{id:t,position:[0,-P-j/2,S],color:he(q.Upper),ratio:j,handleType:q.Upper,hoverHandle:ue,noHoverHandle:fe}),Object(pf.jsx)(uy,{id:t,position:[0,P+j/2,S],color:he(q.Lower),ratio:j,handleType:q.Lower,hoverHandle:ue,noHoverHandle:fe})]}),se&&Object(pf.jsxs)(pf.Fragment,{children:[Object(pf.jsx)(Lt.g,{name:q.Tilt,args:[z,1.1*z,18,2,-vt,Math.PI],rotation:[0,-vt,ne.z,"ZXY"],onPointerOver:function(e){ue(e,q.Tilt)},onPointerOut:function(e){fe()},onPointerDown:function(e){if(Q(!0),E){Nt.getState().setEnableOrbitController(!1),Z.current=!0,_.current=y;var t=Ww.getWorldDataById(l).rot;ee.current=t}D((function(e){e.rotateHandleType=q.Tilt}))},children:Object(pf.jsx)("meshBasicMaterial",{attach:"material",side:We.DoubleSide,color:E===q.Tilt||K?pt:ht})}),K&&Object(pf.jsxs)(pf.Fragment,{children:[Object(pf.jsx)(Lt.g,{ref:le,name:"Solar panel tilt handle",args:[z,2*z,18,2,-vt,Math.PI],rotation:[0,-vt,ne.z,"ZXY"],onPointerUp:function(e){if(Math.abs($.current-_.current)>At){var l={name:"Set Solar Panel Tilt Angle",timestamp:Date.now(),oldValue:_.current,newValue:$.current,changedElementId:t,changedElementType:V.SolarPanel,undo:function(){W(l.changedElementId,l.oldValue)},redo:function(){W(l.changedElementId,l.newValue)}};M(l)}},onPointerMove:function(e){if(Z.current&&(Y.setFromCamera(L,O),le.current)){var l=Y.intersectObjects([le.current]);if(l.length>0){var a=l[0].point,o=le.current.parent;if(o){var i=o.localToWorld(new We.Vector3),r=(new We.Vector3).subVectors(a,i),n=r.angleTo(Rt);if(!(.5*s*Math.abs(Math.sin(n))>S)){var c,d=g+(null!==(c=ee.current)&&void 0!==c?c:0),u=d%Math.PI===0?Math.sign(-r.y)*Math.sign(Math.cos(d)):Math.sign(r.x)*Math.sign(Math.sin(d));W(t,n*=u),$.current=n}}}}},children:Object(pf.jsx)("meshBasicMaterial",{attach:"material",depthTest:!1,transparent:!0,opacity:.5,side:We.DoubleSide})}),Object(pf.jsx)(Jl.a,{points:[[0,0,z],[0,0,1.75*z]],rotation:new We.Euler(y,0,ne.z,"ZXY"),lineWidth:1}),ae.map((function(e,t){return Object(pf.jsxs)("group",{rotation:new We.Euler(Math.PI/12*t-vt,0,ne.z,"ZXY"),children:[Object(pf.jsx)(Jl.a,{points:[[0,0,1.8*z],[0,0,2*z]],color:"white",transparent:!0,opacity:.5}),Object(pf.jsx)("textSprite",{userData:{unintersectable:!0},text:"".concat(15*t-90,"\xb0"),fontSize:20*z,fontFace:"Times Roman",textHeight:.15*z,position:[0,0,1.6*z]})]},t)})),Object(pf.jsx)("group",{rotation:new We.Euler(y,0,ne.z,"ZXY"),children:Object(pf.jsx)("textSprite",{userData:{unintersectable:!0},text:"".concat(Math.floor(y/Math.PI*180),"\xb0"),fontSize:20*z,fontFace:"Times Roman",textHeight:.2*z,position:[0,0,.75*z]})})]})]}),de&&ie.map((function(e,t){return Object(pf.jsx)(Lt.d,{userData:{unintersectable:!0},name:"Pole "+t,castShadow:!1,receiveShadow:!1,args:[w,w,m+2*(e.z-R)+d,4,1],position:e,rotation:[vt,0,0],children:Object(pf.jsx)("meshStandardMaterial",{attach:"material",color:b})},t)}))]})},gw=function(e){var t,l,a,n,c,s=e.solarPanelModel,d=e.groupRotation,f=e.panelRotation,h=s.id,p=s.parentId,y=s.lx,g=s.ly,m=s.lz,w=s.cx,x=s.cy,v=s.cz,b=s.normal,A=s.tiltAngle,T=s.relativeAzimuth,P=s.trackerType,S=s.drawSunBeam,H=s.selected,j=s.locked,z=s.showLabel,R=s.label,D=s.pvModelName,W=s.orientation,M=s.frameColor,I=s.backsheetColor,C=s.color,F=s.poleHeight,k=Xw(si),O=Xw(os),Y=Xw(i.date),L=Xw(i.latitude),N=Xw(zu),U=Xw(Vi),E=bf(Us),J=Xw(Yi),G=Xw(o.solarPanelShininess),Q=null!==(t=Xw(o.orthographic))&&void 0!==t&&t,Z=Object(r.useMemo)((function(){return{lng:U}}),[U]),_=xw(b),ee=_?A:0,le=_?T:0,ae=Math.max(1,(y+g)/16),oe=dt*ae*1.5,ie=st*ae*2,re=[y,g,m].map((function(e){return e/2})),ne=Object(u.a)(re,3),ce=ne[0],se=ne[1],de=ne[2],ue=[oe,oe,1.2*m],fe=J[D];fe&&(m=Math.max(fe.thickness,.02));var he=Object(r.useMemo)((function(){return new Date(Y)}),[Y]),pe=Object(r.useMemo)((function(){return(R||me.t("shared.SolarPanelElement",Z))+(j?" ("+me.t("shared.ElementLocked",Z)+")":"")+(R?"":"\n"+me.t("word.Coordinates",Z)+": ("+w.toFixed(1)+", "+x.toFixed(1)+", "+v.toFixed(1)+") "+me.t("word.MeterAbbreviation",Z))}),[R,j,U,w,x,v]),ye=Object(r.useMemo)((function(){var e=[];if(fe){var t,l;W===$.portrait?(t=Math.max(1,Math.round(y/fe.width)),l=Math.max(1,Math.round(g/fe.length))):(t=Math.max(1,Math.round(y/fe.length)),l=Math.max(1,Math.round(g/fe.width)));for(var a=y/t,o=g/l,i=0;i<=t;i++)e.push({points:[new We.Vector3(i*a-ce,-se,m),new We.Vector3(i*a-ce,se,m)]});for(var r=0;r<=l;r++)e.push({points:[new We.Vector3(-ce,r*o-se,m),new We.Vector3(ce,r*o-se,m)]})}return e}),[fe,W,D,y,g,m]),ge=Object(r.useState)(Fe()),we=Object(u.a)(ge,2),xe=we[0],ve=we[1],be=Object(r.useState)(!1),Ae=Object(u.a)(be,2),Te=Ae[0],Pe=Ae[1],He=Object(r.useState)(null),je=Object(u.a)(He,2),ze=je[0],Re=je[1],De=Object(r.useRef)(null),Me=Object(Se.f)().gl,Ie=tg(y,g,fe,W,M,I),Ce=eg(h);function Fe(){var e=new We.Euler,t=vw(p,d.z);return P===te.NO_TRACKER?e.set(-d.x-ee,0,-t-le):e.set(-d.x-f.x,-f.y,-t-f.z),Iy(he,L).applyEuler(e)}function ke(e){return ze===e||N===e?pt:ht}function Oe(e,t){Nt.getState().setEnableOrbitController(!1),k((function(l){l.resizeHandleType=e,l.resizeAnchor.copy(t)}))}return Object(Se.d)((function(){var e=Fe();e.equals(xe)||ve(e)})),Object(pf.jsxs)(pf.Fragment,{children:[Object(pf.jsxs)("group",{name:"Solar Panel Box Group",rotation:f,children:[Object(pf.jsxs)(Lt.a,{uuid:h,ref:De,args:[y,g,m],position:[0,0,de],onPointerDown:function(e){2!==e.button&&O(h,e,X.Select)},onContextMenu:function(e){O(h,e,X.Select),k((function(t){e.intersections.length>0&&(e.intersections[0].object===De.current&&(t.contextMenuObjectType=V.SolarPanel))}))},onPointerOver:function(e){e.intersections.length>0&&(e.intersections[0].object===De.current&&(Pe(!0),Me.domElement.style.cursor="move"))},onPointerOut:function(e){Pe(!1),Me.domElement.style.cursor="default"},children:[Object(pf.jsx)("meshStandardMaterial",{attachArray:"material",color:"white"}),Object(pf.jsx)("meshStandardMaterial",{attachArray:"material",color:"white"}),Object(pf.jsx)("meshStandardMaterial",{attachArray:"material",color:"white"}),Object(pf.jsx)("meshStandardMaterial",{attachArray:"material",color:"white"}),E&&Ce?Object(pf.jsx)("meshBasicMaterial",{attachArray:"material",map:Ce}):Ie?Q||0===G?Object(pf.jsx)("meshStandardMaterial",{attachArray:"material",map:Ie,color:C}):Object(pf.jsx)("meshPhongMaterial",{attachArray:"material",specular:new We.Color("Blue"===(null===fe||void 0===fe?void 0:fe.color)?at:ot),shininess:null!==G&&void 0!==G?G:tt,side:We.FrontSide,map:Ie,color:C}):Object(pf.jsx)("meshStandardMaterial",{attachArray:"material",color:C}),0===(null===fe||void 0===fe?void 0:fe.bifacialityFactor)||Q||0===F&&0===A?Object(pf.jsx)("meshStandardMaterial",{attachArray:"material",color:C}):Ie?Object(pf.jsx)("meshPhongMaterial",{attachArray:"material",specular:new We.Color("Blue"===(null===fe||void 0===fe?void 0:fe.color)?at:ot),shininess:null!==G&&void 0!==G?G:tt,side:We.FrontSide,map:Ie,color:C}):null]}),H&&!j&&Object(pf.jsxs)("group",{name:pw,onPointerDown:function(e){if(e.intersections.length>0&&e.intersections[0].eventObject.name===pw){var t=e.object.name;switch(t){case B.Default:Nt.getState().setEnableOrbitController(!1),k((function(e){e.moveHandleType=t,e.selectedElement=e.elements.find((function(t){var l;return t.id===(null===(l=e.selectedElement)||void 0===l?void 0:l.id)}))}));break;case K.Left:var l=e.object.localToWorld(new We.Vector3(y,0,0));Oe(t,l);break;case K.Right:var a=e.object.localToWorld(new We.Vector3(-y,0,0));Oe(t,a);break;case K.Lower:var o=e.object.localToWorld(new We.Vector3(0,g,0));Oe(t,o);break;case K.Upper:var i=e.object.localToWorld(new We.Vector3(0,-g,0));Oe(t,i)}}},onPointerOver:function(e){if(e.intersections.length>0&&e.eventObject.name.includes(pw)){var t=e.object.name;Re(t),t===B.Top?Me.domElement.style.cursor="move":t===q.Lower||t===q.Upper||t===q.Tilt?Me.domElement.style.cursor="grab":Me.domElement.style.cursor="pointer"}},onPointerOut:function(){Re(null),Me.domElement.style.cursor="default"},children:[Object(pf.jsx)(Lt.h,{args:[ie,6,6],name:B.Default,children:Object(pf.jsx)("meshBasicMaterial",{color:"orange"})}),Object(pf.jsx)(Lt.a,{position:[0,-se,de],args:ue,name:K.Lower,children:Object(pf.jsx)("meshBasicMaterial",{color:ke(K.Lower)})}),Object(pf.jsx)(Lt.a,{position:[0,se,de],args:ue,name:K.Upper,children:Object(pf.jsx)("meshBasicMaterial",{color:ke(K.Upper)})}),Object(pf.jsx)(Lt.a,{position:[-ce,0,de],args:ue,name:K.Left,children:Object(pf.jsx)("meshBasicMaterial",{color:ke(K.Left)})}),Object(pf.jsx)(Lt.a,{position:[ce,0,de],args:ue,name:K.Right,children:Object(pf.jsx)("meshBasicMaterial",{color:ke(K.Right)})})]}),S&&xe.z>0&&Object(pf.jsx)(mw,{sunDirection:xe}),E&&Ce&&ye.map((function(e,t){return Object(pf.jsx)(Jl.a,{name:"Solar Panel Lines",userData:{unintersectable:!0},points:e.points,castShadow:!1,receiveShadow:!1,lineWidth:.2,color:"black"},t)})),Object(pf.jsx)(Lt.f,{name:"Solar Panel Simulation Plane",uuid:h,args:[y,g],userData:{simulation:!0},receiveShadow:!1,castShadow:!1,visible:!1,children:Object(pf.jsx)("meshBasicMaterial",{side:We.DoubleSide})}),H&&j&&Object(pf.jsx)(Jl.a,{name:"Selection highlight lines",userData:{unintersectable:!0},points:[[-ce,-se,0],[-ce,se,0],[ce,se,0],[ce,-se,0],[-ce,-se,0]],castShadow:!1,receiveShadow:!1,lineWidth:2,color:yt})]}),(Te||z)&&!H&&Object(pf.jsx)("textSprite",{userData:{unintersectable:!0},name:"Label",fontFace:"Roboto",text:pe,color:null!==(l=s.labelColor)&&void 0!==l?l:"white",fontSize:null!==(a=s.labelFontSize)&&void 0!==a?a:20,textHeight:null!==(n=s.labelSize)&&void 0!==n?n:.2,position:[0,0,null!==(c=s.labelHeight)&&void 0!==c?c:Math.max(se*Math.abs(Math.sin(A))+.1,.2)]})]})},mw=n.a.memo((function(e){var t=e.sunDirection,l=Xw(Kr),a=Object(r.useMemo)((function(){return Math.max(100,10*l)}),[l]);return Object(pf.jsxs)("group",{name:"Sun Beam Group",children:[Object(pf.jsx)(Jl.a,{userData:{unintersectable:!0},points:[Rt.clone().multiplyScalar(.75),[0,0,0],t.clone().multiplyScalar(a)],name:"Sun Beam",lineWidth:.5,color:"white"}),Object(pf.jsx)(Jl.a,{userData:{unintersectable:!0},points:[t.clone().multiplyScalar(.5),Rt.clone().multiplyScalar(.5)],name:"Angle",lineWidth:.5,color:"white"}),Object(pf.jsx)("textSprite",{userData:{unintersectable:!0},name:"Angle Value",text:Ww.toDegrees(t.angleTo(Rt)).toFixed(1)+"\xb0",fontSize:20,fontFace:"Times Roman",textHeight:.1,position:t.clone().multiplyScalar(.75).add(Rt.clone().multiplyScalar(.75)).multiplyScalar(.5)}),Object(pf.jsx)("group",{position:Rt.clone().multiplyScalar(.75),rotation:[vt,0,0],children:Object(pf.jsx)(Lt.c,{userData:{unintersectable:!0},args:[.04,.2,4,2],name:"Normal Vector Arrow Head",children:Object(pf.jsx)("meshBasicMaterial",{attach:"material",color:"white"})})})]})}));function ww(e){var t=Object(u.a)(e,3),l=t[0],a=t[1];return 1===t[2]?new We.Euler(0,0,0):0!==l?new We.Euler(vt,0,l*vt,"ZXY"):0!==a?new We.Euler(-a*vt,0,0):new We.Euler}function xw(e){return Math.abs(e[2]-1)<.01}function vw(e,t){return Ww.getWorldDataById(e).rot+t}var bw=n.a.memo(yw),Aw=function(e){var t,l,a,i,n,c,s=e.id,p=e.cx,y=e.cy,g=e.lx,m=void 0===g?1:g,w=e.ly,x=void 0===w?1:w,v=e.lz,b=void 0===v?1:v,A=e.color,T=void 0===A?"silver":A,P=e.lineColor,S=void 0===P?"black":P,H=e.lineWidth,j=void 0===H?.1:H,z=e.locked,R=void 0!==z&&z,D=e.showLabel,W=void 0!==D&&D,M=e.textureTypes,I=void 0===M?[de.NoTexture,de.NoTexture,de.NoTexture,de.NoTexture,de.NoTexture,de.NoTexture]:M,C=e.stackable,F=_f(s),k=Xw(si),O=Xw(Vi),Y=Xw(o.orthographic),L=Xw(Zr),N=Xw(an),U=Xw(rs),E=Xw(Kc),J=Xw(bn),G=Xw(Pn),Q=Xw(nn),Z=Xw(cn),_=Xw(sn),ee=Xw(os),te=Xw(ic),le=Xw(Ni),ae=Xw(o.shadowEnabled),oe=Xw(Sr),ie=Xw(Mu),re=Xw(Kn),ne=Xw(Bn),ce=Xw(on),se=bf(Us),ue=Xw(o.solarRadiationHeatmapMaxValue),fe=Af(wi),he=Xw(o.groundImage),pe=Xw(Vu),ye=Object(Se.f)(),ge=ye.camera,we=ye.gl.domElement,xe=ye.raycaster,ve=ye.mouse,be=Object(r.useState)(null),Ae=Object(u.a)(be,2),Te=Ae[0],Pe=Ae[1],He=Object(r.useState)(null),je=Object(u.a)(He,2),ze=je[0],Re=je[1],De=Object(r.useState)(null),Me=Object(u.a)(De,2),Ie=Me[0],Ce=Me[1],Fe=Object(r.useState)(null),ke=Object(u.a)(Fe,2),Oe=ke[0],Ye=ke[1],Le=Object(r.useState)(null),Ne=Object(u.a)(Le,2),Ue=Ne[0],Ee=Ne[1],Ve=Object(r.useState)(!1),Je=Object(u.a)(Ve,2),Ge=Je[0],Xe=Je[1],Be=Object(r.useState)(!1),Ke=Object(u.a)(Be,2),qe=Ke[0],Qe=Ke[1],Ze=Object(r.useState)(),_e=Object(u.a)(Ze,2),$e=_e[0],et=_e[1],tt=Object(r.useRef)(null),lt=Object(r.useRef)(),at=Object(r.useRef)(null),ot=Object(r.useRef)(Rt),it=Object(r.useRef)(new We.Vector3(0,0,0)),rt=Object(r.useRef)(new We.Euler(0,0,0)),nt=Object(r.useRef)(new We.Vector3(1,1,1)),ct=Object(r.useRef)(new We.Vector3),dt=Object(r.useRef)(new We.Vector3),ut=Object(r.useRef)(new We.Vector3),ft=Object(r.useRef)(new We.Vector3),ht=Object(r.useRef)(new We.Vector3(1,1,1)),pt=Object(r.useRef)(new We.Vector3(1,1,1)),gt=Object(r.useRef)(0),mt=Object(r.useRef)(0),wt=Object(r.useRef)([]),xt=Object(r.useRef)([]),Pt=Object(r.useRef)(),Wt=Object(r.useRef)(new We.Vector3),Mt=Object(r.useRef)(0),It=Object(r.useMemo)((function(){return{lng:O}}),[O]),Ct=m/2,Ft=x/2,kt=b/2,Ot=Object(r.useMemo)((function(){return new We.Vector3}),[]);if(at.current&&at.current.type===V.SolarPanel){var Yt=xw(at.current.normal)?at.current.poleHeight:0;Ot.set(0,0,e.lz/2+Yt)}var Ut=Object(r.useMemo)((function(){return((null===e||void 0===e?void 0:e.label)?e.label:me.t("shared.CuboidElement",It))+((null===e||void 0===e?void 0:e.locked)?" ("+me.t("shared.ElementLocked",It)+")":"")+((null===e||void 0===e?void 0:e.label)?"":"\n"+me.t("word.Coordinates",It)+": ("+p.toFixed(1)+", "+y.toFixed(1)+", "+(b/2).toFixed(1)+") "+me.t("word.MeterAbbreviation",It))}),[null===e||void 0===e?void 0:e.label,R,O,p,y,b]);Object(r.useEffect)((function(){var e=function(){at.current=null,Qe(!1),Nt.getState().setEnableOrbitController(!0)};return window.addEventListener("pointerup",e),function(){window.removeEventListener("pointerup",e)}}),[]),Object(r.useEffect)((function(){Xw.getState().tempHumanPlant.length>0&&k((function(e){var t;(t=e.elements).push.apply(t,Object(f.a)(e.tempHumanPlant)),e.tempHumanPlant=[]}))}),[]),Object(r.useEffect)((function(){if(e&&se){var t=null!==ue&&void 0!==ue?ue:5,l=fe(e.id+"-top");l&&Pe(Ww.fetchHeatmapTexture(l,t));var a=fe(e.id+"-south");a&&Re(Ww.fetchHeatmapTexture(a,t));var o=fe(e.id+"-north");o&&Ce(Ww.fetchHeatmapTexture(o,t));var i=fe(e.id+"-west");i&&Ye(Ww.fetchHeatmapTexture(i,t));var r=fe(e.id+"-east");r&&Ee(Ww.fetchHeatmapTexture(r,t,!0))}}),[se,ue]);var Et=function(e){switch(e){case de.Facade01:return ew;case de.Facade02:return tw;case de.Facade03:return lw;case de.Facade04:return aw;case de.Facade05:return ow;case de.Facade06:return iw;case de.Facade07:return rw;case de.Facade08:return nw;case de.Facade09:return cw;case de.Facade10:return sw;default:return Tf}},Vt=function(e){switch(e){case de.Facade01:case de.Facade02:return{x:14,y:6.5};case de.Facade03:return{x:10,y:12};case de.Facade04:return{x:20,y:11};case de.Facade05:return{x:15,y:10};case de.Facade06:return{x:11,y:3.5};case de.Facade07:return{x:11,y:10};case de.Facade08:return{x:16,y:9};case de.Facade09:return{x:10,y:9};case de.Facade10:return{x:12,y:9};default:return{x:1,y:1}}},Jt=Object(r.useMemo)((function(){return(new We.TextureLoader).load(I?Et(I[0]):Tf,(function(e){var t=Vt(I[0]);e.repeat.set(x/t.x,b/t.y),e.rotation=vt,e.center.x=1,e.center.y=0,e.wrapS=e.wrapT=We.RepeatWrapping,Kt(e)}))}),[I[0],x,b]),Gt=Object(r.useState)(Jt),Xt=Object(u.a)(Gt,2),Bt=Xt[0],Kt=Xt[1],qt=Object(r.useMemo)((function(){return(new We.TextureLoader).load(I?Et(I[1]):Tf,(function(e){var t=Vt(I[1]);e.repeat.set(x/t.x,b/t.y),e.rotation=-vt,e.wrapS=e.wrapT=We.RepeatWrapping,$t(e)}))}),[I[1],x,b]),Qt=Object(r.useState)(qt),Zt=Object(u.a)(Qt,2),_t=Zt[0],$t=Zt[1],el=Object(r.useMemo)((function(){return(new We.TextureLoader).load(I?Et(I[2]):Tf,(function(e){var t=Vt(I[2]);e.repeat.set(m/t.x,b/t.y),e.rotation=Math.PI,e.center.x=0,e.center.y=1,e.wrapS=e.wrapT=We.RepeatWrapping,ol(e)}))}),[I[2],m,b]),tl=Object(r.useState)(el),ll=Object(u.a)(tl,2),al=ll[0],ol=ll[1],il=Object(r.useMemo)((function(){return(new We.TextureLoader).load(I?Et(I[3]):Tf,(function(e){var t=Vt(I[3]);e.repeat.set(m/t.x,b/t.y),e.wrapS=e.wrapT=We.RepeatWrapping,sl(e)}))}),[I[3],m,b]),rl=Object(r.useState)(il),nl=Object(u.a)(rl,2),cl=nl[0],sl=nl[1],dl=Object(r.useMemo)((function(){return(new We.TextureLoader).load(I?Et(I[4]):Tf,(function(e){var t=Vt(I[4]);e.repeat.set(m/t.x,x/t.y),e.wrapS=e.wrapT=We.RepeatWrapping,pl(e)}))}),[I[4],m,x]),ul=Object(r.useState)(dl),fl=Object(u.a)(ul,2),hl=fl[0],pl=fl[1];Object(r.useEffect)((function(){Object(Se.c)()}),Object(f.a)(I));var yl=function(e){ot.current=e;var t=.01;Ww.isSame(ot.current,Rt)?(it.current=new We.Vector3(0,0,kt+t),rt.current=new We.Euler(0,0,0),nt.current.set(Ct,Ft,kt)):Ww.isSame(ot.current,St)?(it.current=new We.Vector3(Ct+t,0,0),rt.current=new We.Euler(0,vt,0),nt.current.set(kt,Ft,Ct)):Ww.isSame(ot.current,Ht)?(it.current=new We.Vector3(-Ct-t,0,0),rt.current=new We.Euler(0,-vt,0),nt.current.set(kt,Ft,Ct)):Ww.isSame(ot.current,zt)?(it.current=new We.Vector3(0,-Ft-t,0),rt.current=new We.Euler(vt,0,0),nt.current.set(Ct,kt,Ft)):Ww.isSame(ot.current,jt)&&(it.current=new We.Vector3(0,Ft+t,0),rt.current=new We.Euler(-vt,0,0),nt.current.set(Ct,kt,Ft))},gl=Math.max(1,Math.max(m,x)/8),ml=st*gl,wl=Ww.isIdentical(null===(t=at.current)||void 0===t?void 0:t.normal,Tt),xl=function(t,l,a){var o=JSON.parse(JSON.stringify(t));return o.cx=l,o.cy=a,ce(o)?(Qh(me.t("message.MoveCancelledBecauseOfOverlap",It)),!1):!(Ww.isIdentical(t.normal,Tt)&&!Ww.isSolarCollectorWithinHorizontalSurface(o,e))||(Qh(me.t("message.MoveOutsideBoundaryCancelled",It)),!1)},vl=function(t,l,a,o,i){if(0!==t.tiltAngle&&.5*i*Math.abs(Math.sin(t.tiltAngle))>t.poleHeight)return!1;var r=JSON.parse(JSON.stringify(t));return r.cx=l,r.cy=a,r.lx=o,r.ly=i,!!Ww.isSolarCollectorWithinHorizontalSurface(r,e)},bl=he?Y?.25:.75:1,Al=[se&&Ue?Ue:Bt,se&&Oe?Oe:_t,se&&Ie?Ie:al,se&&ze?ze:cl,se&&Te?Te:hl,null],Tl=e&&e.faceColors?[0,1,2,3,4,5].map((function(t){return I&&I[t]!==de.NoTexture?se?Object(pf.jsx)("meshBasicMaterial",{side:We.FrontSide,attachArray:"material",color:"white",map:Al[t],transparent:Y&&he,opacity:bl},t):Object(pf.jsx)("meshStandardMaterial",{side:We.FrontSide,attachArray:"material",color:"white",map:Al[t],transparent:Y&&he,opacity:bl},t):se?Object(pf.jsx)("meshBasicMaterial",{side:We.FrontSide,attachArray:"material",color:"white",map:Al[t],transparent:Y&&he,opacity:bl},t):Object(pf.jsx)("meshStandardMaterial",{side:We.FrontSide,attachArray:"material",color:e.faceColors?e.faceColors[t]:T,map:Al[t],transparent:Y&&he,opacity:bl},t)})):Object(pf.jsx)("meshStandardMaterial",{side:We.FrontSide,attach:"material",color:T,transparent:Y&&he,opacity:bl}),Pl=Object(r.useMemo)((function(){return[Ct,Ft,kt]}),[Ct,Ft,kt]),Sl=F&&!R&&!pe;return Object(pf.jsxs)("group",{ref:tt,name:"Cuboid Group "+s,userData:{aabb:!0},children:[Object(pf.jsx)(Lt.a,{castShadow:ae,receiveShadow:ae,userData:{simulation:!0,stand:!0,stackable:C},uuid:s,ref:lt,args:[m,x,b],name:"Cuboid "+s,onContextMenu:function(e){ee(s,e,X.Select),k((function(t){t.pastePoint.copy(e.intersections[0].point);var l=e.intersections[0].face;(l&&(t.pasteNormal=l.normal.clone(),Ww.isSame(l.normal,St)?t.selectedSideIndex=0:Ww.isSame(l.normal,Ht)?t.selectedSideIndex=1:Ww.isSame(l.normal,jt)?t.selectedSideIndex=2:Ww.isSame(l.normal,zt)?t.selectedSideIndex=3:Ww.isSame(l.normal,Rt)&&(t.selectedSideIndex=4)),t.clickObjectType=V.Cuboid,e.intersections.length>0)&&(e.intersections[0].object===lt.current&&(t.contextMenuObjectType=V.Cuboid))}))},onPointerDown:function(t){if(2!==t.button){ie()||ee(s,t,X.Select);var l=N(),a=!1;if(t.intersections[0].object.name===V.Polygon&&Xw.getState().objectTypeToAdd!==V.None&&(a=!0),(null===l||void 0===l?void 0:l.id)===s||a){if(Xw.getState().groupActionMode){var o=Ww.getBaseId(s);Xw.getState().setGroupMasterId(o)}if(function(e){switch(e){case V.Polygon:case V.Sensor:case V.Light:case V.SolarPanel:case V.Human:case V.Tree:case V.Flower:return!0}return!1}(Xw.getState().objectTypeToAdd)&&e){Qe(!0);var i=function(t){var l,a=t.intersections[0];if(Xw.getState().objectTypeToAdd===V.SolarPanel){var o,i,r,n,c,d,u,f,h=a.point,p=Ww.getWorldDataById(s),y=p.pos,g=p.rot,w=(new We.Vector3).subVectors(h,y).applyEuler(new We.Euler(0,0,-g)),v=Vl.makeSolarPanel(e,Xw.getState().getPvModule(null!==(o=Xw.getState().actionState.solarPanelModelName)&&void 0!==o?o:"SPR-X21-335-BLK"),w.x/m,w.y/x,w.z/b,null!==(i=Xw.getState().actionState.solarPanelOrientation)&&void 0!==i?i:$.landscape,null!==(r=Xw.getState().actionState.solarPanelPoleHeight)&&void 0!==r?r:1,null!==(n=Xw.getState().actionState.solarPanelPoleSpacing)&&void 0!==n?n:3,null!==(c=Xw.getState().actionState.solarPanelTiltAngle)&&void 0!==c?c:0,null!==(d=Xw.getState().actionState.solarPanelRelativeAzimuth)&&void 0!==d?d:0,null===(u=a.face)||void 0===u?void 0:u.normal,[0,0,0],null!==(f=Xw.getState().actionState.solarPanelFrameColor)&&void 0!==f?f:"white");return k((function(e){e.elements.push(v)})),v}return U(e,a.point,null===(l=a.face)||void 0===l?void 0:l.normal)}(t);if(i){var r={name:"Add",timestamp:Date.now(),addedElement:i,undo:function(){E(r.addedElement.id,!1)},redo:function(){k((function(e){e.elements.push(r.addedElement),e.selectedElement=r.addedElement}))}};oe(r),k((function(e){e.objectTypeToAdd=V.None}))}}else Nt.getState().selectNone(),Nt.setState((function(e){e.cuboidRef=tt}))}else if(l&&l.parentId===s&&function(e){switch(e){case V.Polygon:case V.Sensor:case V.Light:case V.SolarPanel:return!0}return!1}(l.type)){Qe(!0);var n,c=Ww.getWorldDataById(s),u=c.rot,f=c.pos;Wt.current.copy(f),Mt.current=u,at.current=l;var p,y=Object(h.a)(t.intersections);try{for(y.s();!(p=y.n()).done;){var g=p.value;if(g.object===lt.current){n=g.face;break}}}catch(w){y.e(w)}finally{y.f()}switch(n&&(yl(n.normal),$e&&$e.equals(n.normal)||et(n.normal)),Nt.getState().setEnableOrbitController(!1),ct.current.x=l.cx,ct.current.y=l.cy,ct.current.z=l.cz,ut.current.fromArray(l.normal),ht.current.x=l.lx,ht.current.y=l.ly,ht.current.z=l.lz,l.type){case V.SolarPanel:gt.current=l.relativeAzimuth;break;case V.Polygon:wt.current=l.vertices.map((function(e){return Object(d.a)({},e)}))}}}},onPointerMove:function(t){if(at.current&&e){if(at.current.type===V.SolarPanel&&wl)return;if(at.current.parentId===s&&at.current.type&&!at.current.locked){var l=new We.Vector2(t.offsetX/we.clientWidth*2-1,1-t.offsetY/we.clientHeight*2);if(xe.setFromCamera(l,ge),lt.current){var a=xe.intersectObjects([lt.current]);if(a.length>0){var o=a[0].point,i=a[0].face;if(Xw.getState().moveHandleType){if(i){var r=i.normal;$e&&!$e.equals(r)&&et(r),yl(r),_(at.current.id,r.x,r.y,r.z)}if(o=Ww.relativeCoordinates(o.x,o.y,o.z,e),at.current.type===V.Polygon){var n=at.current;if(Xw.getState().moveHandleType===B.Default){var c,f,h=Ww.calculatePolygonCentroid(wt.current),p=(new We.Vector3).fromArray(n.normal);Ww.isSame(p,St)?(c=-(h.x+o.z),f=o.y-h.y):Ww.isSame(p,Ht)?(c=o.z-h.x,f=o.y-h.y):Ww.isSame(p,jt)?(c=o.x-h.x,f=-(h.y+o.z)):Ww.isSame(p,zt)?(c=o.x-h.x,f=o.z-h.y):(c=o.x-h.x,f=o.y-h.y);var y=wt.current.map((function(e){return Object(d.a)({},e)}));y.forEach((function(e){e.x+=c,e.y+=f})),re(n.id,y)}}else Q(at.current.id,o.x,o.y,o.z)}else if(Xw.getState().resizeHandleType)switch(at.current.type){case V.SolarPanel:var g=at.current,w=Km(g),v=Object(u.a)(w,2),A=v[0],T=v[1],P=Xw.getState().resizeAnchor,S=Xw.getState().resizeHandleType;if(S===K.Lower||S===K.Upper){var H=Math.max(1,Math.round(Math.abs(o.z-P.z)/T))*T,j=new We.Vector3(0,0,o.z-P.z).normalize().multiplyScalar(H),z=(new We.Vector3).addVectors(P,j.clone().divideScalar(2));k((function(e){var t=e.elements.find((function(e){return e.id===g.id}));t&&(t.cz=(z.z-Wt.current.z)/b,t.ly=Math.abs(j.z))}))}else if(S===K.Left||S===K.Right){var R=(new We.Vector3).subVectors(o,P).setZ(0),D=Math.max(1,Math.round(R.length()/A))*A,W=R.clone().normalize().multiplyScalar(D),M=(new We.Vector3).addVectors(P,W.clone().divideScalar(2)),I=(new We.Vector3).subVectors(M,Wt.current).applyEuler(new We.Euler(0,0,-Mt.current));k((function(e){var t=e.elements.find((function(e){return e.id===g.id}));t&&(Math.abs(Math.abs(t.normal[1])-1)<.01?t.cx=I.x/m:t.cy=I.y/x,t.lx=W.length())}))}break;case V.Polygon:if(Xw.getState().resizeHandleType===K.Default){var C,F,O=new We.Vector3(o.x-Wt.current.x,o.y-Wt.current.y,0).applyEuler(new We.Euler(0,0,-Mt.current,"ZXY")),Y=at.current,L=(new We.Vector3).fromArray(Y.normal);Ww.isSame(L,St)?(C=e.lz,F=e.ly,O.x=-o.z+Wt.current.z):Ww.isSame(L,Ht)?(C=e.lz,F=e.ly,O.x=o.z-Wt.current.z):Ww.isSame(L,jt)?(C=e.lx,F=e.lz,O.y=-o.z+Wt.current.z):Ww.isSame(L,zt)?(C=e.lx,F=e.lz,O.y=o.z-Wt.current.z):(C=e.lx,F=e.ly),(O=Xw.getState().enableFineGrid?Ww.snapToFineGrid(O):Ww.snapToNormalGrid(O)).x/=C,O.y/=F,ne(Y.id,Y.selectedIndex,O.x,O.y)}}}}}}},onPointerUp:function(){if(at.current){var t=L(at.current.id);if(t&&t.parentId===s){if(t.type===V.Polygon){if(Xw.getState().moveHandleType||Xw.getState().resizeHandleType){xt.current=t.vertices.map((function(e){return Object(d.a)({},e)}));var l={name:Xw.getState().moveHandleType?"Move Polygon":"Resize Polygon",timestamp:Date.now(),oldValue:wt.current,newValue:xt.current,changedElementId:t.id,changedElementType:t.type,undo:function(){re(l.changedElementId,l.oldValue)},redo:function(){re(l.changedElementId,l.newValue)}};oe(l)}}else if(Xw.getState().resizeHandleType){if(dt.current.x=t.cx,dt.current.y=t.cy,dt.current.z=t.cz,pt.current.x=t.lx,pt.current.y=t.ly,pt.current.z=t.lz,dt.current.distanceToSquared(ct.current)>At&&pt.current.distanceToSquared(ht.current)>At){var a={name:"Resize",timestamp:Date.now(),resizedElementId:at.current.id,resizedElementType:at.current.type,oldCx:ct.current.x,oldCy:ct.current.y,oldCz:ct.current.z,newCx:dt.current.x,newCy:dt.current.y,newCz:dt.current.z,oldLx:ht.current.x,oldLy:ht.current.y,oldLz:ht.current.z,newLx:pt.current.x,newLy:pt.current.y,newLz:pt.current.z,undo:function(){Q(a.resizedElementId,a.oldCx,a.oldCy,a.oldCz),Z(a.resizedElementId,a.oldLx,a.oldLy,a.oldLz)},redo:function(){Q(a.resizedElementId,a.newCx,a.newCy,a.newCz),Z(a.resizedElementId,a.newLx,a.newLy,a.newLz)}};oe(a)}}else if(Xw.getState().rotateHandleType){if(at.current.type===V.SolarPanel){var o=at.current;if(Math.abs(mt.current-gt.current)>At)if(function(t,l){var a=JSON.parse(JSON.stringify(t));return a.relativeAzimuth=l,ce(a)?(Qh(me.t("message.RotationCancelledBecauseOfOverlap",It)),!1):!!Ww.isSolarCollectorWithinHorizontalSurface(a,e)||(Qh(me.t("message.RotationOutsideBoundaryCancelled",It)),!1)}(o,mt.current)){k((function(e){e.selectedElementAngle=mt.current}));var i={name:"Rotate",timestamp:Date.now(),oldValue:gt.current,newValue:mt.current,changedElementId:o.id,changedElementType:o.type,undo:function(){te(i.changedElementId,i.oldValue)},redo:function(){te(i.changedElementId,i.newValue)}};oe(i)}else te(o.id,gt.current)}}else if(dt.current.x=t.cx,dt.current.y=t.cy,dt.current.z=t.cz,ft.current.fromArray(t.normal),dt.current.distanceToSquared(ct.current)>At){var r=!0;if(t.type===V.SolarPanel&&(r=xl(t,t.cx,t.cy)),r){var n,c={name:"Move",timestamp:Date.now(),movedElementId:at.current.id,movedElementType:null===(n=at.current)||void 0===n?void 0:n.type,oldCx:ct.current.x,oldCy:ct.current.y,oldCz:ct.current.z,oldNormal:ut.current.clone(),newCx:dt.current.x,newCy:dt.current.y,newCz:dt.current.z,newNormal:ft.current.clone(),undo:function(){Q(c.movedElementId,c.oldCx,c.oldCy,c.oldCz),c.oldNormal&&_(c.movedElementId,c.oldNormal.x,c.oldNormal.y,c.oldNormal.z)},redo:function(){Q(c.movedElementId,c.newCx,c.newCy,c.newCz),c.newNormal&&_(c.movedElementId,c.newNormal.x,c.newNormal.y,c.newNormal.z)}};oe(c)}else Q(t.id,ct.current.x,ct.current.y,ct.current.z)}at.current=null}}},onPointerOver:function(e){e.intersections.length>0&&(e.intersections[0].object===lt.current&&Xe(!0))},onPointerOut:function(){if(Xe(!1),at.current)switch(at.current.type){case V.Human:case V.Tree:case V.Flower:Qe(!1);break;case V.SolarPanel:var e=Xw.getState().getElementById(at.current.id);Xw.getState().moveHandleType&&!xl(e,e.cx,e.cy)&&Q(e.id,ct.current.x,ct.current.y,ct.current.z)}},onPointerEnter:function(e){at.current&&Ww.isPlantOrHuman(at.current)&&(e.intersections[0].object===lt.current&&Qe(!0))},children:Tl}),(null===(l=at.current)||void 0===l?void 0:l.type)===V.SolarPanel&&wl&&!at.current.locked&&Object(pf.jsx)(Lt.f,{ref:Pt,name:"Cuboid Intersection Plane",position:Ot,args:[m,x],visible:!1,onPointerMove:function(t){if(Pt.current&&at.current&&e){if(at.current.type!==V.SolarPanel||!wl)return;var l=at.current;if(l.parentId!==s||l.locked)return;xe.setFromCamera(ve,ge);var a=xe.intersectObjects([Pt.current]);if(a.length>0){var o=a[0].point.clone();if(Xw.getState().moveHandleType)o=Ww.relativeCoordinates(o.x,o.y,o.z-l.poleHeight,e),Q(l.id,o.x,o.y,o.z);else if(Xw.getState().rotateHandleType&&Xw.getState().rotateHandleType!==q.Tilt){var i=Mt.current,r=new We.Vector2(Wt.current.x,Wt.current.y),n=new We.Vector2(e.lx*l.cx,e.ly*l.cy).rotateAround(Dt,i),c=(new We.Vector2).addVectors(n,r),d=-i+Math.atan2(-o.x+c.x,o.y-c.y)+(Xw.getState().rotateHandleType===q.Lower?0:Math.PI),u=d+(Math.abs(d)>Math.PI?-Math.sign(d)*bt:0);te(l.id,u),mt.current=u}else if(Xw.getState().resizeHandleType){var f=Xw.getState().resizeAnchor,h=le(l.pvModelName),p=new We.Vector2(o.x,o.y),y=new We.Vector2(f.x,f.y),g=p.distanceTo(y),w=l.relativeAzimuth+Mt.current,v=(new We.Vector2).subVectors(p,y);switch(Xw.getState().resizeHandleType){case K.Lower:case K.Upper:var b=Xw.getState().resizeHandleType===K.Lower?1:-1,A=v.angle()-w+b*vt,T=g*Math.cos(A);if(l.orientation===$.portrait)T=Math.max(1,Math.ceil((T-h.length/2)/h.length))*h.length;else T=Math.max(1,Math.ceil((T-h.width/2)/h.width))*h.width;var P=f.x+b*(T*Math.sin(w))/2,S=f.y-b*(T*Math.cos(w))/2,H=new We.Vector2(P,S),j=new We.Vector2(Wt.current.x,Wt.current.y),z=(new We.Vector2).subVectors(H,j).rotateAround(Dt,-Mt.current),R=z.x/m,D=z.y/x;vl(l,R,D,l.lx,T)&&(G(l.id,T),Q(l.id,R,D));break;case K.Left:case K.Right:var W=Xw.getState().resizeHandleType===K.Left?-1:1,M=v.angle()-w+(Xw.getState().resizeHandleType===K.Left?Math.PI:0),I=g*Math.cos(M);if(l.orientation===$.portrait)I=Math.max(1,Math.ceil((I-h.width/2)/h.width))*h.width;else I=Math.max(1,Math.ceil((I-h.length/2)/h.length))*h.length;var C=f.x+W*(I*Math.cos(w))/2,F=f.y+W*(I*Math.sin(w))/2,k=new We.Vector2(C,F),O=new We.Vector2(Wt.current.x,Wt.current.y),Y=(new We.Vector2).subVectors(k,O).rotateAround(Dt,-Mt.current),L=Y.x/m,N=Y.y/x;vl(l,L,N,I,l.ly)&&(J(l.id,I),Q(l.id,L,N))}}}}}}),qe&&Object(pf.jsxs)(pf.Fragment,{children:[(Xw.getState().moveHandleType||Xw.getState().resizeHandleType)&&Object(pf.jsx)(yf,{hx:nt.current.x,hy:nt.current.y,hz:nt.current.z,position:it.current,rotation:rt.current}),Xw.getState().rotateHandleType&&at.current&&at.current.type===V.SolarPanel&&Object(pf.jsx)(sy,{element:at.current,height:at.current.poleHeight+kt})]}),F&&Object(pf.jsx)(yy,{element:e,verticalLift:ml}),(!F||he)&&Object(pf.jsx)(hy,{hx:Ct,hy:Ft,hz:kt,lineColor:he&&Y?"white":S,lineWidth:he&&Y?5*j:j}),F&&R&&Object(pf.jsx)(hy,{hx:Ct,hy:Ft,hz:kt,lineColor:yt,lineWidth:5*j}),Sl&&Object(pf.jsx)(hw,{id:s,args:Pl}),(Ge||W)&&!F&&Object(pf.jsx)("textSprite",{userData:{unintersectable:!0},name:"Label",text:Ut,color:null!==(a=null===e||void 0===e?void 0:e.labelColor)&&void 0!==a?a:"white",fontSize:null!==(i=null===e||void 0===e?void 0:e.labelFontSize)&&void 0!==i?i:20,fontFace:"Roboto",textHeight:null!==(n=null===e||void 0===e?void 0:e.labelSize)&&void 0!==n?n:.2,position:[0,0,kt+(null!==(c=null===e||void 0===e?void 0:e.labelHeight)&&void 0!==c?c:.2)]})]})},Tw=n.a.memo(Aw),Pw=function(e){var t,l,a,i,n=e.id,c=e.cx,s=e.cy,d=e.cz,f=e.lx,p=void 0===f?1:f,y=e.ly,g=void 0===y?1:y,m=e.lz,w=void 0===m?.1:m,x=e.rotation,v=void 0===x?[0,0,0]:x,b=e.normal,A=void 0===b?[0,0,1]:b,T=e.color,P=void 0===T?"white":T,S=e.lineColor,H=void 0===S?"black":S,j=e.lineWidth,z=void 0===j?.1:j,R=e.locked,D=void 0!==R&&R,W=e.showLabel,M=void 0!==W&&W,I=e.parentId,C=e.foundationId,F=(e.light,e.heatFlux,Xw(si)),k=Xw(Vi),O=Xw(o.shadowEnabled),Y=Xw(os),L=_f(n),N=Object(Se.f)().gl.domElement,U=Object(r.useState)(!1),E=Object(u.a)(U,2),J=E[0],G=E[1],K=Object(r.useRef)(),q=Object(r.useRef)(),Q=Object(r.useMemo)((function(){return{lng:k}}),[k]),Z=Xw((function(e){var t,l=Object(h.a)(e.elements);try{for(l.s();!(t=l.n()).done;){var a=t.value;if(a.id===I)return a}}catch(o){l.e(o)}finally{l.f()}})),_=Xw((function(e){var t,l=Object(h.a)(e.elements);try{for(l.s();!(t=l.n()).done;){var a=t.value;if(a.id===C)return a}}catch(o){l.e(o)}finally{l.f()}}));if(I&&Z)switch(Z.type){case V.Foundation:if(d=Z.cz+Z.lz/2,Ww.isZero(v[2]))c=Z.cx+c*Z.lx,s=Z.cy+s*Z.ly;else{var $=new We.Vector3(c*Z.lx,s*Z.ly,0);$.applyAxisAngle(Rt,v[2]),c=Z.cx+$.x,s=Z.cy+$.y}break;case V.Wall:if((null===_||void 0===_?void 0:_.type)===V.Foundation){var ee=Ww.absoluteCoordinates(c,s,d,Z,_);c=ee.x,s=ee.y,d=ee.z}break;case V.Roof:if((null===_||void 0===_?void 0:_.type)===V.Foundation){var te=Ww.absoluteCoordinates(c,s,d,Z,_);c=te.x,s=te.y,d=te.z}}var le=w/2,ae=Object(r.useMemo)((function(){if((null===Z||void 0===Z?void 0:Z.type)===V.Wall){var e=Z,t=_?_.rotation[2]+e.relativeAngle:e.relativeAngle;return new We.Euler(vt,0,t,"ZXY")}if((null===Z||void 0===Z?void 0:Z.type)===V.Roof)return new We.Euler(v[0],v[1],_?_.rotation[2]+v[2]:v[2],"ZXY");if((null===Z||void 0===Z?void 0:Z.type)===V.Cuboid)return ww(A);var l=(new We.Vector3).fromArray(A);return Ww.isSame(l,St)?new We.Euler(0,vt,v[2],"ZXY"):Ww.isSame(l,Ht)?new We.Euler(0,-vt,v[2],"ZXY"):Ww.isSame(l,jt)?new We.Euler(-vt,0,v[2],"ZXY"):Ww.isSame(l,zt)?new We.Euler(vt,0,v[2],"ZXY"):new We.Euler(0,0,v[2])}),[A,v,null===_||void 0===_?void 0:_.rotation]),oe=Object(r.useMemo)((function(){return((null===e||void 0===e?void 0:e.label)?e.label:me.t("shared.SensorElement",Q))+((null===e||void 0===e?void 0:e.locked)?" ("+me.t("shared.ElementLocked",Q)+")":"")+"\n"+me.t("word.Coordinates",Q)+": ("+c.toFixed(1)+", "+s.toFixed(1)+", "+d.toFixed(1)+") "+me.t("word.MeterAbbreviation",Q)}),[null===e||void 0===e?void 0:e.label,D,k,c,s,d]);return Object(pf.jsxs)("group",{name:"Sensor Group "+n,rotation:ae,position:[c,s,d+le],children:[Object(pf.jsx)(Lt.a,{receiveShadow:O,uuid:n,ref:K,args:[p,g,w],name:"Sensor",onPointerDown:function(e){2!==e.button&&(Y(n,e,X.Move),Nt.getState().setEnableOrbitController(!1),bf.setState((function(e){e.showWallIntersectionPlaneId=I,e.oldParentId=I,e.oldFoundationId=C})),F((function(e){e.moveHandleType=B.Default})))},onContextMenu:function(e){Y(n,e),F((function(t){e.intersections.length>0&&(e.intersections[0].object===K.current&&(t.contextMenuObjectType=V.Sensor))}))},onPointerOver:function(e){e.intersections.length>0&&(e.intersections[0].object===K.current&&(G(!0),N.style.cursor="move"))},onPointerOut:function(){G(!1),N.style.cursor="default"},children:Object(pf.jsx)("meshStandardMaterial",{attach:"material",color:(null===e||void 0===e?void 0:e.lit)?pt:P})}),Object(pf.jsx)(Lt.d,{userData:{unintersectable:!0},name:"Meter",castShadow:!1,receiveShadow:!1,args:[.3*p,.3*g,le,8,1],position:new We.Vector3(0,0,le),rotation:[vt,0,0],children:Object(pf.jsx)("meshBasicMaterial",{attach:"material",color:"black"})}),!L&&Object(pf.jsx)(hy,{hx:p/2,hy:g/2,hz:w/2,lineColor:H,lineWidth:z}),L&&D&&Object(pf.jsx)(hy,{hx:p/2,hy:g/2,hz:w/2,lineColor:yt,lineWidth:10*z}),L&&!D&&Object(pf.jsx)(Lt.h,{ref:q,position:new We.Vector3(0,0,0),args:[st,6,6,0,Math.PI],name:B.Default,onPointerDown:function(e){Y(n,e,X.Move),Nt.getState().setEnableOrbitController(!1),bf.setState((function(e){e.showWallIntersectionPlaneId=I,e.oldParentId=I,e.oldFoundationId=C})),F((function(e){e.moveHandleType=B.Default}))},children:Object(pf.jsx)("meshBasicMaterial",{attach:"material",color:"orange"})}),(J||M)&&!L&&Object(pf.jsx)("textSprite",{userData:{unintersectable:!0},name:"Label",fontFace:"Roboto",text:oe,color:null!==(t=null===e||void 0===e?void 0:e.labelColor)&&void 0!==t?t:"white",fontSize:null!==(l=null===e||void 0===e?void 0:e.labelFontSize)&&void 0!==l?l:20,textHeight:null!==(a=null===e||void 0===e?void 0:e.labelSize)&&void 0!==a?a:.2,position:[0,0,w+(null!==(i=null===e||void 0===e?void 0:e.labelHeight)&&void 0!==i?i:.2)]})]})},Sw=n.a.memo(Pw),Hw=function(e){var t,l,a,i,n=e.id,c=e.cx,s=e.cy,d=e.cz,f=e.lx,p=void 0===f?1:f,y=e.ly,g=void 0===y?1:y,m=e.lz,w=void 0===m?.1:m,x=e.rotation,v=void 0===x?[0,0,0]:x,b=e.normal,A=void 0===b?[0,0,1]:b,T=e.color,P=void 0===T?"#ffff99":T,S=(e.lineColor,e.lineWidth),H=void 0===S?.1:S,j=e.locked,z=void 0!==j&&j,R=e.showLabel,D=void 0!==R&&R,W=e.parentId,M=e.foundationId,I=e.decay,C=void 0===I?2:I,F=e.distance,k=void 0===F?5:F,O=e.intensity,Y=void 0===O?3:O,L=e.inside,N=void 0!==L&&L,U=Xw(si),E=Xw(Vi),J=Xw(o.shadowEnabled),G=Xw(os),K=Xw(Ls).z<=0,q=_f(n),Q=Object(Se.f)().gl.domElement,Z=Object(r.useState)(!1),_=Object(u.a)(Z,2),$=_[0],ee=_[1],te=Object(r.useRef)(),le=Object(r.useRef)(),ae=Object(r.useMemo)((function(){return{lng:E}}),[E]),oe=Xw((function(e){var t,l=Object(h.a)(e.elements);try{for(l.s();!(t=l.n()).done;){var a=t.value;if(a.id===W)return a}}catch(o){l.e(o)}finally{l.f()}})),ie=Xw((function(e){var t,l=Object(h.a)(e.elements);try{for(l.s();!(t=l.n()).done;){var a=t.value;if(a.id===M)return a}}catch(o){l.e(o)}finally{l.f()}})),re=.1;if(W&&oe)switch(oe.type){case V.Foundation:if(d=oe.cz+oe.lz/2,Ww.isZero(v[2]))c=oe.cx+c*oe.lx,s=oe.cy+s*oe.ly;else{var ne=new We.Vector3(c*oe.lx,s*oe.ly,0);ne.applyAxisAngle(Rt,v[2]),c=oe.cx+ne.x,s=oe.cy+ne.y}break;case V.Wall:if((null===ie||void 0===ie?void 0:ie.type)===V.Foundation){var ce=Ww.absoluteCoordinates(c,s,d,oe,ie);c=ce.x,s=ce.y,d=ce.z}re=oe.ly;break;case V.Roof:if((null===ie||void 0===ie?void 0:ie.type)===V.Foundation){var se=Ww.absoluteCoordinates(c,s,d,oe,ie);c=se.x,s=se.y,d=se.z}re=oe.thickness}var de=w/2,ue=Object(r.useMemo)((function(){if((null===oe||void 0===oe?void 0:oe.type)===V.Wall){var e=oe,t=ie?ie.rotation[2]+e.relativeAngle:e.relativeAngle;return new We.Euler(vt,0,t,"ZXY")}if((null===oe||void 0===oe?void 0:oe.type)===V.Roof)return new We.Euler(v[0],v[1],ie?ie.rotation[2]+v[2]:v[2],"ZXY");if((null===oe||void 0===oe?void 0:oe.type)===V.Cuboid)return ww(A);var l=(new We.Vector3).fromArray(A);return Ww.isSame(l,St)?new We.Euler(0,vt,v[2],"ZXY"):Ww.isSame(l,Ht)?new We.Euler(0,-vt,v[2],"ZXY"):Ww.isSame(l,jt)?new We.Euler(-vt,0,v[2],"ZXY"):Ww.isSame(l,zt)?new We.Euler(vt,0,v[2],"ZXY"):new We.Euler(0,0,v[2])}),[A,v,null===ie||void 0===ie?void 0:ie.rotation]),fe=Object(r.useMemo)((function(){return((null===e||void 0===e?void 0:e.label)?e.label:me.t("shared.LightElement",ae))+((null===e||void 0===e?void 0:e.locked)?" ("+me.t("shared.ElementLocked",ae)+")":"")+"\n"+me.t("word.Coordinates",ae)+": ("+c.toFixed(1)+", "+s.toFixed(1)+", "+d.toFixed(1)+") "+me.t("word.MeterAbbreviation",ae)}),[null===e||void 0===e?void 0:e.label,z,E,c,s,d]);return Object(pf.jsxs)("group",{name:"Light Group "+n,rotation:ue,position:[c,s,d],children:[K&&Object(pf.jsx)("pointLight",{color:P,name:"Point Light "+n,position:[0,0,N?-re-de:de],decay:C,distance:k,intensity:Y,castShadow:!0}),Object(pf.jsx)(Lt.d,{receiveShadow:J,userData:{unintersectable:!0},uuid:n,ref:te,position:[0,0,N?-re:0],rotation:[vt,0,0],args:[.5*p,.5*g,de,16,1],name:"Light Base",onPointerDown:function(e){2!==e.button&&(G(n,e,X.Move),Nt.getState().setEnableOrbitController(!1),bf.setState((function(e){e.showWallIntersectionPlaneId=W,e.oldParentId=W,e.oldFoundationId=M})))},onContextMenu:function(e){G(n,e),U((function(t){e.intersections.length>0&&(e.intersections[0].object===te.current&&(t.contextMenuObjectType=V.Light))}))},onPointerOver:function(e){e.intersections.length>0&&(e.intersections[0].object===te.current&&(ee(!0),Q.style.cursor="move"))},onPointerOut:function(){ee(!1),Q.style.cursor="default"},children:Object(pf.jsx)("meshStandardMaterial",{attach:"material",color:"lightgray"})}),Object(pf.jsx)(Lt.h,{userData:{unintersectable:!0},name:"Light Bulb",castShadow:!1,receiveShadow:J,args:[.3*p,8,8,0,bt,0,Math.PI],position:new We.Vector3(0,0,N?-re-de:de),rotation:[vt,0,0],children:K?Object(pf.jsx)("meshBasicMaterial",{attach:"material",color:"white"}):Object(pf.jsx)("meshStandardMaterial",{attach:"material",color:"white"})}),q&&z&&Object(pf.jsx)(hy,{hx:p/2,hy:g/2,hz:w/2,lineColor:yt,lineWidth:10*H}),q&&!z&&Object(pf.jsx)(Lt.h,{ref:le,position:new We.Vector3(0,0,N?-re-de:de),args:[st,6,6,N?Math.PI:0,Math.PI],name:B.Default,onPointerDown:function(e){G(n,e,X.Move),Nt.getState().setEnableOrbitController(!1),bf.setState((function(e){e.showWallIntersectionPlaneId=W,e.oldParentId=W,e.oldFoundationId=M}))},children:Object(pf.jsx)("meshBasicMaterial",{attach:"material",color:"orange"})}),($||D)&&!q&&Object(pf.jsx)("textSprite",{userData:{unintersectable:!0},name:"Label",fontFace:"Roboto",text:fe,color:null!==(t=null===e||void 0===e?void 0:e.labelColor)&&void 0!==t?t:"white",fontSize:null!==(l=null===e||void 0===e?void 0:e.labelFontSize)&&void 0!==l?l:20,textHeight:null!==(a=null===e||void 0===e?void 0:e.labelSize)&&void 0!==a?a:.2,position:[0,0,(N?-re:0)+w+(null!==(i=null===e||void 0===e?void 0:e.labelHeight)&&void 0!==i?i:.2)]})]})},jw=n.a.memo(Hw),zw="Cuboid Wrapper",Rw="Cuboid Stackable Child",Dw=function e(t){var l=t.elements,a=t.cuboidModel,o=a.id,i=a.parentId,r=a.cx,n=a.cy,c=a.lz,s=a.rotation,u=a.locked,f=Xw(Vu),h=Zf(a,f),p=h.baseGroupSet,y=h.childCuboidSet,g=h.groupMasterDimension,m=h.groupMasterPosition,w=h.groupMasterRotation,x=c/2,v=!(i!==xt||u||f!==o||!a||!g);return Object(pf.jsxs)(pf.Fragment,{children:[Object(pf.jsxs)("group",{name:zw,position:[r,n,x],rotation:[0,0,s[2]],children:[Object(pf.jsx)(Tw,Object(d.a)({},a)),l.map((function(t){if(function(e){return _m(e)&&e.parentId===a.id}(t))return Object(pf.jsx)("group",{name:Rw,position:[0,0,x],children:Object(pf.jsx)(e,{elements:l,cuboidModel:t})},t.id);if(t.parentId===a.id){var o=a.lx,i=a.ly,r=a.lz;switch(t.type){case V.SolarPanel:return Object(pf.jsx)(bw,Object(d.a)(Object(d.a)({},t),{},{cx:t.cx*o,cy:t.cy*i,cz:t.cz*r}),t.id);case V.Sensor:return Object(pf.jsx)(Sw,Object(d.a)(Object(d.a)({},t),{},{cx:t.cx*o,cy:t.cy*i,cz:t.cz*r}),t.id);case V.Light:return Object(pf.jsx)(jw,Object(d.a)(Object(d.a)({},t),{},{cx:t.cx*o,cy:t.cy*i,cz:t.cz*r}),t.id);default:return null}}}))]}),v&&Object(pf.jsx)(Zy,{baseGroupSet:p,childCuboidSet:y,initalPosition:m,initalDimension:g,initalRotation:w})]})},Ww=function(){function e(){Object(je.a)(this,e)}return Object(ke.a)(e,null,[{key:"calculateProfit",value:function(e){return.001*(e.yearlyYield*e.sellingPrice-e.panelCount*e.unitCost*365)}},{key:"calculateCost",value:function(e){return e.panelCount*e.unitCost*.365}},{key:"getLatLngKey",value:function(e,t){return e.toFixed(4)+", "+t.toFixed(4)}},{key:"getModelKey",value:function(e){return e.title+", "+e.userid}},{key:"resizeCanvas",value:function(e,t,l){var a=document.createElement("canvas");a.width=t,a.height=l||t*e.height/e.width;var o=a.getContext("2d");return o&&o.drawImage(e,0,0,e.width,e.height,0,0,a.width,a.height),a}},{key:"getEuler",value:function(e,t,l,a,o,i){var r=new We.Quaternion;r.setFromUnitVectors(e,t);var n=new We.Euler;return n.setFromQuaternion(r),l&&(n.order=l),a&&(n.x+=a),o&&(n.y+=o),i&&(n.z+=i),n}},{key:"zero2DArray",value:function(e){for(var t=0;t0&&((t.intersections.filter((function(e){return!e.eventObject.name.startsWith("Wall Intersection Plane")}))[0].object===t.eventObject||o)&&l((function(l){var o,r,n,c;l.multiSelectionsMode?l.selectedElementIdSet.has(e)?l.selectedElementIdSet.delete(e):l.selectedElementIdSet.add(e):(l.selectedElementIdSet.clear(),l.selectedElementIdSet.add(e));var s,d=Object(h.a)(l.elements);try{for(d.s();!(s=d.n()).done;){var u=s.value;u.id===e?(u.selected=!0,l.selectedElement=u,l.selectedElementHeight=u.lz):u.selected=!1}}catch(f){d.e(f)}finally{d.f()}if(l.moveHandleType=null,l.resizeHandleType=null,l.rotateHandleType=null,a)switch(a){case X.Move:(null===(o=l.selectedElement)||void 0===o?void 0:o.type)===V.Tree||(null===(r=l.selectedElement)||void 0===r?void 0:r.type)===V.Human?l.moveHandleType=B.Default:l.moveHandleType=t.eventObject.name,i(!1);break;case X.Resize:l.resizeHandleType=t.eventObject.name,i(!1);break;case X.Rotate:l.rotateHandleType=t.eventObject.name,i(!1);break;case X.Select:l.selectedElementAngle=null!==(n=null===(c=t.object.parent)||void 0===c?void 0:c.rotation.z)&&void 0!==n?n:0,i(!0);break;default:i(!0)}})))},updateAllElementLocks:function(e){l((function(t){var l,a=Object(h.a)(t.elements);try{for(a.s();!(l=a.n()).done;){l.value.locked=e}}catch(o){a.e(o)}finally{a.f()}}))},updateElementLockByFoundationId:function(e,t){l((function(l){var a,o=Object(h.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;i.foundationId!==e&&i.parentId!==e&&i.id!==e||(i.locked=t)}}catch(r){o.e(r)}finally{o.f()}}))},updateElementLockByParentId:function(e,t,a){l((function(l){var o,i=Object(h.a)(l.elements);try{for(i.s();!(o=i.n()).done;){var r=o.value;r.parentId===e&&t===r.type&&(r.locked=a)}}catch(n){i.e(n)}finally{i.f()}}))},updateElementLockById:function(e,t){l((function(l){var a,o=Object(h.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;if(i.id===e){i.locked=t;break}}}catch(r){o.e(r)}finally{o.f()}}))},updateElementReferenceById:function(e,t){l((function(l){var a,o=Object(h.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;if(i.id===e){i.referenceId=t;break}}}catch(r){o.e(r)}finally{o.f()}}))},updateElementLabelById:function(e,t){l((function(l){var a,o=Object(h.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;if(i.id===e&&!i.locked){i.label=t;break}}}catch(r){o.e(r)}finally{o.f()}}))},updateElementShowLabelById:function(e,t){l((function(l){var a,o=Object(h.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;if(i.id===e&&!i.locked){i.showLabel=t;break}}}catch(r){o.e(r)}finally{o.f()}}))},updateElementColorById:function(e,t){l((function(l){var a,o=Object(h.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;if(i.id===e&&!i.locked){i.color=t;break}}}catch(r){o.e(r)}finally{o.f()}}))},updateElementColorOnSurface:function(e,t,a,o){l((function(l){var i,r=Object(h.a)(l.elements);try{for(r.s();!(i=r.n()).done;){var n=i.value;n.type===e&&n.parentId===t&&Ww.isIdentical(n.normal,a)&&!n.locked&&(n.color=o)}}catch(c){r.e(c)}finally{r.f()}}))},updateElementColorAboveFoundation:function(e,t,a){l((function(l){var o,i=Object(h.a)(l.elements);try{for(i.s();!(o=i.n()).done;){var r=o.value;r.type!==e||r.foundationId!==t||r.locked||(r.color=a)}}catch(n){i.e(n)}finally{i.f()}}))},updateElementColorForAll:function(e,t){l((function(l){var a,o=Object(h.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;i.type!==e||i.locked||(i.color=t)}}catch(r){o.e(r)}finally{o.f()}}))},updateElementLineColorById:function(e,t){l((function(l){var a,o=Object(h.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;if(i.id===e&&!i.locked){i.lineColor=t;break}}}catch(r){o.e(r)}finally{o.f()}}))},updateElementLineColorOnSurface:function(e,t,a,o){l((function(l){var i,r=Object(h.a)(l.elements);try{for(r.s();!(i=r.n()).done;){var n=i.value;n.type===e&&n.parentId===t&&Ww.isIdentical(n.normal,a)&&!n.locked&&(n.lineColor=o)}}catch(c){r.e(c)}finally{r.f()}}))},updateElementLineColorAboveFoundation:function(e,t,a){l((function(l){var o,i=Object(h.a)(l.elements);try{for(i.s();!(o=i.n()).done;){var r=o.value;r.type!==e||r.foundationId!==t||r.locked||(r.lineColor=a)}}catch(n){i.e(n)}finally{i.f()}}))},updateElementLineColorForAll:function(e,t){l((function(l){var a,o=Object(h.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;i.type!==e||i.locked||(i.lineColor=t)}}catch(r){o.e(r)}finally{o.f()}}))},updateElementLineWidthById:function(e,t){l((function(l){var a,o=Object(h.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;if(i.id===e){i.lineWidth=t;break}}}catch(r){o.e(r)}finally{o.f()}}))},updateElementLineWidthOnSurface:function(e,t,a,o){l((function(l){var i,r=Object(h.a)(l.elements);try{for(r.s();!(i=r.n()).done;){var n=i.value;n.type===e&&n.parentId===t&&Ww.isIdentical(n.normal,a)&&!n.locked&&(n.lineWidth=o)}}catch(c){r.e(c)}finally{r.f()}}))},updateElementLineWidthAboveFoundation:function(e,t,a){l((function(l){var o,i=Object(h.a)(l.elements);try{for(i.s();!(o=i.n()).done;){var r=o.value;r.type!==e||r.foundationId!==t||r.locked||(r.lineWidth=a)}}catch(n){i.e(n)}finally{i.f()}}))},updateElementLineWidthForAll:function(e,t){l((function(l){var a,o=Object(h.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;i.type!==e||i.locked||(i.lineWidth=t)}}catch(r){o.e(r)}finally{o.f()}}))},updateElementCxById:function(e,t){l((function(l){var a,o=Object(h.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;if(i.id===e&&!i.locked){i.cx=t,i.type===V.SolarPanel&&i.parentType===V.Roof&&(l.updateElementOnRoofFlag=!0);break}}}catch(r){o.e(r)}finally{o.f()}}))},updateElementCyById:function(e,t){l((function(l){var a,o=Object(h.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;if(i.id===e&&!i.locked){i.cy=t,i.type===V.SolarPanel&&i.parentType===V.Roof&&(l.updateElementOnRoofFlag=!0);break}}}catch(r){o.e(r)}finally{o.f()}}))},updateElementCzById:function(e,t){l((function(l){var a,o=Object(h.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;if(i.id===e&&!i.locked){i.cz=t;break}}}catch(r){o.e(r)}finally{o.f()}}))},updateElementCzForAll:function(e,t){l((function(l){var a,o=Object(h.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;i.type!==e||i.locked||(i.cz=t)}}catch(r){o.e(r)}finally{o.f()}}))},updateElementLxById:function(e,t){l((function(l){var a,o=Object(h.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;if(i.id===e&&!i.locked){i.lx=t;break}}}catch(r){o.e(r)}finally{o.f()}}))},updateElementLxAboveFoundation:function(e,t,a){l((function(l){var o,i=Object(h.a)(l.elements);try{for(i.s();!(o=i.n()).done;){var r=o.value;r.type!==e||r.foundationId!==t||r.locked||(r.lx=a)}}catch(n){i.e(n)}finally{i.f()}}))},updateElementLxOnSurface:function(e,t,a,o){l((function(l){var i,r=Object(h.a)(l.elements);try{for(r.s();!(i=r.n()).done;){var n=i.value;if(n.type===e&&!n.locked){(a?n.parentId===t&&Ww.isIdentical(n.normal,a):n.parentId===t)&&(n.lx=o)}}}catch(c){r.e(c)}finally{r.f()}}))},updateElementLxForAll:function(e,t){l((function(l){var a,o=Object(h.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;i.type!==e||i.locked||(i.lx=t)}}catch(r){o.e(r)}finally{o.f()}}))},updateElementLyById:function(e,t){l((function(l){var a,o=Object(h.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;if(i.id===e&&!i.locked){i.ly=t;break}}}catch(r){o.e(r)}finally{o.f()}}))},updateElementLyAboveFoundation:function(e,t,a){l((function(l){var o,i=Object(h.a)(l.elements);try{for(i.s();!(o=i.n()).done;){var r=o.value;r.type!==e||r.foundationId!==t||r.locked||(r.ly=a)}}catch(n){i.e(n)}finally{i.f()}}))},updateElementLyOnSurface:function(e,t,a,o){l((function(l){var i,r=Object(h.a)(l.elements);try{for(r.s();!(i=r.n()).done;){var n=i.value;if(n.type===e&&!n.locked){(a?n.parentId===t&&Ww.isIdentical(n.normal,a):n.parentId===t)&&(n.ly=o)}}}catch(c){r.e(c)}finally{r.f()}}))},updateElementLyForAll:function(e,t){l((function(l){var a,o=Object(h.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;i.type!==e||i.locked||(i.ly=t)}}catch(r){o.e(r)}finally{o.f()}}))},updateElementLzById:function(e,t){l((function(l){var a,o=Object(h.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;if(i.id===e&&!i.locked){i.lz=t;break}}}catch(r){o.e(r)}finally{o.f()}}))},updateElementLzAboveFoundation:function(e,t,a){l((function(l){var o,i=Object(h.a)(l.elements);try{for(i.s();!(o=i.n()).done;){var r=o.value;r.type!==e||r.foundationId!==t||r.locked||(r.lz=a)}}catch(n){i.e(n)}finally{i.f()}}))},updateElementLzOnSurface:function(e,t,a,o){l((function(l){var i,r=Object(h.a)(l.elements);try{for(r.s();!(i=r.n()).done;){var n=i.value;if(n.type===e&&!n.locked){(a?n.parentId===t&&Ww.isIdentical(n.normal,a):n.parentId===t)&&(n.lz=o)}}}catch(c){r.e(c)}finally{r.f()}}))},updateElementLzForAll:function(e,t){l((function(l){var a,o=Object(h.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;i.type!==e||i.locked||(i.lz=t)}}catch(r){o.e(r)}finally{o.f()}}))},updateElementRotationById:function(e,t,a,o){l((function(l){var i,r=Object(h.a)(l.elements);try{for(r.s();!(i=r.n()).done;){var n=i.value;(n.id!==e||n.locked)&&(n.parentId!==e||_m(n))||(n.rotation[0]=t,n.rotation[1]=a,n.rotation[2]=o)}}catch(c){r.e(c)}finally{r.f()}l.selectedElementAngle=o}))},updateElementRotationForAll:function(e,t,a,o){l((function(l){var i,r=Object(h.a)(l.elements);try{for(r.s();!(i=r.n()).done;){var n=i.value;if(n.type===e)n.locked||(n.rotation[0]=t,n.rotation[1]=a,n.rotation[2]=o);else{var c=l.getParent(n);c&&!c.locked&&c.type===e&&(n.rotation[0]=t,n.rotation[1]=a,n.rotation[2]=o)}}}catch(s){r.e(s)}finally{r.f()}}))},updateSolarCollectorDrawSunBeamById:function(e,t){l((function(l){var a,o=Object(h.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;if(i.id===e&&!i.locked&&Ww.isSolarCollector(i)){i.drawSunBeam=t;break}}}catch(r){o.e(r)}finally{o.f()}}))},updateSolarCollectorDrawSunBeamAboveFoundation:function(e,t,a){Ww.isSolarCollectorType(e)&&l((function(l){var o,i=Object(h.a)(l.elements);try{for(i.s();!(o=i.n()).done;){var r=o.value;r.foundationId!==t||r.locked||r.type===e&&(r.drawSunBeam=a)}}catch(n){i.e(n)}finally{i.f()}}))},updateSolarCollectorDrawSunBeamForAll:function(e,t){Ww.isSolarCollectorType(e)&&l((function(l){var a,o=Object(h.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;i.locked||i.type===e&&(i.drawSunBeam=t)}}catch(r){o.e(r)}finally{o.f()}}))},updateSolarCollectorRelativeAzimuthById:function(e,t){l((function(l){var a,o=Object(h.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;if(i.id===e&&!i.locked&&Ww.isSolarCollector(i)){i.relativeAzimuth=t,l.selectedElementAngle=t;break}}}catch(r){o.e(r)}finally{o.f()}}))},updateSolarCollectorRelativeAzimuthAboveFoundation:function(e,t,a){Ww.isSolarCollectorType(e)&&l((function(l){var o,i=Object(h.a)(l.elements);try{for(i.s();!(o=i.n()).done;){var r=o.value;r.type!==e||r.foundationId!==t||r.locked||r.parentType===V.Wall||(r.relativeAzimuth=a)}}catch(n){i.e(n)}finally{i.f()}}))},updateSolarCollectorRelativeAzimuthOnSurface:function(e,t,a,o){Ww.isSolarCollectorType(e)&&l((function(l){var i,r=Object(h.a)(l.elements);try{for(r.s();!(i=r.n()).done;){var n=i.value;if(n.type===e&&!n.locked){(a?n.parentId===t&&Ww.isIdentical(n.normal,a):n.parentId===t)&&(n.relativeAzimuth=o)}}}catch(c){r.e(c)}finally{r.f()}}))},updateSolarCollectorRelativeAzimuthForAll:function(e,t){Ww.isSolarCollectorType(e)&&l((function(l){var a,o=Object(h.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;i.type!==e||i.locked||i.parentType===V.Wall||(i.relativeAzimuth=t)}}catch(r){o.e(r)}finally{o.f()}}))},updateSolarCollectorPoleHeightById:function(e,t){l((function(l){var a,o=Object(h.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;if(i.id===e&&!i.locked&&Ww.isSolarCollector(i)){i.poleHeight=t;break}}}catch(r){o.e(r)}finally{o.f()}}))},updateSolarCollectorPoleHeightAboveFoundation:function(e,t,a){Ww.isSolarCollectorType(e)&&l((function(l){var o,i=Object(h.a)(l.elements);try{for(i.s();!(o=i.n()).done;){var r=o.value;r.foundationId!==t||r.locked||r.type!==e||(r.poleHeight=a)}}catch(n){i.e(n)}finally{i.f()}}))},updateSolarCollectorPoleHeightOnSurface:function(e,t,a,o){Ww.isSolarCollectorType(e)&&l((function(l){var i,r=Object(h.a)(l.elements);try{for(r.s();!(i=r.n()).done;){var n=i.value;if(!n.locked&&n.type===e){(a?n.parentId===t&&Ww.isIdentical(n.normal,a):n.parentId===t)&&(n.poleHeight=o)}}}catch(c){r.e(c)}finally{r.f()}}))},updateSolarCollectorPoleHeightForAll:function(e,t){Ww.isSolarCollectorType(e)&&l((function(l){var a,o=Object(h.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;i.type!==e||i.locked||(i.poleHeight=t)}}catch(r){o.e(r)}finally{o.f()}}))},updateSolarCollectorPoleRadiusById:function(e,t){l((function(l){var a,o=Object(h.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;if(i.id===e&&!i.locked&&Ww.isSolarCollector(i)){i.poleRadius=t;break}}}catch(r){o.e(r)}finally{o.f()}}))},updateSolarCollectorPoleRadiusAboveFoundation:function(e,t,a){Ww.isSolarCollectorType(e)&&l((function(l){var o,i=Object(h.a)(l.elements);try{for(i.s();!(o=i.n()).done;){var r=o.value;r.foundationId!==t||r.locked||r.type!==e||(r.poleRadius=a)}}catch(n){i.e(n)}finally{i.f()}}))},updateSolarCollectorPoleRadiusOnSurface:function(e,t,a,o){Ww.isSolarCollectorType(e)&&l((function(l){var i,r=Object(h.a)(l.elements);try{for(r.s();!(i=r.n()).done;){var n=i.value;if(!n.locked&&n.type===e){(a?n.parentId===t&&Ww.isIdentical(n.normal,a):n.parentId===t)&&(n.poleRadius=o)}}}catch(c){r.e(c)}finally{r.f()}}))},updateSolarCollectorPoleRadiusForAll:function(e,t){Ww.isSolarCollectorType(e)&&l((function(l){var a,o=Object(h.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;i.type!==e||i.locked||(i.poleRadius=t)}}catch(r){o.e(r)}finally{o.f()}}))},clearAllSolarCollectorYields:function(){l((function(e){var t,l=Object(h.a)(e.elements);try{for(l.s();!(t=l.n()).done;){var a=t.value;if(Ww.isSolarCollector(a)){var o=a;o.dailyYield=0,o.yearlyYield=0}}}catch(i){l.e(i)}finally{l.f()}}))},updateSolarCollectorDailyYieldById:function(e,t){l((function(l){var a,o=Object(h.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;if(i.id===e&&Ww.isSolarCollector(i)){i.dailyYield=t;break}}}catch(r){o.e(r)}finally{o.f()}}))},updateSolarCollectorYearlyYieldById:function(e,t){l((function(l){var a,o=Object(h.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;if(i.id===e&&Ww.isSolarCollector(i)){i.yearlyYield=t;break}}}catch(r){o.e(r)}finally{o.f()}}))},updateCspReflectanceById:function(e,t){l((function(l){var a,o=Object(h.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;if(i.id===e&&Ww.isCspCollector(i)){i.reflectance=t;break}}}catch(r){o.e(r)}finally{o.f()}}))},updateCspReflectanceAboveFoundation:function(e,t,a){Ww.isCspCollectorType(e)&&l((function(l){var o,i=Object(h.a)(l.elements);try{for(i.s();!(o=i.n()).done;){var r=o.value;r.type===e&&r.foundationId===t&&(r.reflectance=a)}}catch(n){i.e(n)}finally{i.f()}}))},updateCspReflectanceForAll:function(e,t){Ww.isCspCollectorType(e)&&l((function(l){var a,o=Object(h.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;i.type===e&&(i.reflectance=t)}}catch(r){o.e(r)}finally{o.f()}}))},updateParabolicCollectorAbsorptanceById:function(e,t){l((function(l){var a,o=Object(h.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;if(i.id===e&&Ww.isParabolicCollector(i)){i.absorptance=t;break}}}catch(r){o.e(r)}finally{o.f()}}))},updateParabolicCollectorAbsorptanceAboveFoundation:function(e,t,a){Ww.isParabolaType(e)&&l((function(l){var o,i=Object(h.a)(l.elements);try{for(i.s();!(o=i.n()).done;){var r=o.value;r.type===e&&r.foundationId===t&&(r.absorptance=a)}}catch(n){i.e(n)}finally{i.f()}}))},updateParabolicCollectorAbsorptanceForAll:function(e,t){Ww.isParabolaType(e)&&l((function(l){var a,o=Object(h.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;i.type===e&&(i.absorptance=t)}}catch(r){o.e(r)}finally{o.f()}}))},updateParabolicCollectorOpticalEfficiencyById:function(e,t){l((function(l){var a,o=Object(h.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;if(i.id===e&&Ww.isParabolicCollector(i)){i.opticalEfficiency=t;break}}}catch(r){o.e(r)}finally{o.f()}}))},updateParabolicCollectorOpticalEfficiencyAboveFoundation:function(e,t,a){Ww.isParabolaType(e)&&l((function(l){var o,i=Object(h.a)(l.elements);try{for(i.s();!(o=i.n()).done;){var r=o.value;r.type===e&&r.foundationId===t&&(r.opticalEfficiency=a)}}catch(n){i.e(n)}finally{i.f()}}))},updateParabolicCollectorOpticalEfficiencyForAll:function(e,t){Ww.isParabolaType(e)&&l((function(l){var a,o=Object(h.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;i.type===e&&(i.opticalEfficiency=t)}}catch(r){o.e(r)}finally{o.f()}}))},updateParabolicCollectorThermalEfficiencyById:function(e,t){l((function(l){var a,o=Object(h.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;if(i.id===e&&Ww.isParabolicCollector(i)){i.thermalEfficiency=t;break}}}catch(r){o.e(r)}finally{o.f()}}))},updateParabolicCollectorThermalEfficiencyAboveFoundation:function(e,t,a){Ww.isParabolaType(e)&&l((function(l){var o,i=Object(h.a)(l.elements);try{for(i.s();!(o=i.n()).done;){var r=o.value;r.type===e&&r.foundationId===t&&(r.thermalEfficiency=a)}}catch(n){i.e(n)}finally{i.f()}}))},updateParabolicCollectorThermalEfficiencyForAll:function(e,t){Ww.isParabolaType(e)&&l((function(l){var a,o=Object(h.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;i.type===e&&(i.thermalEfficiency=t)}}catch(r){o.e(r)}finally{o.f()}}))},foundationActionScope:_.OnlyThisObject,setFoundationActionScope:function(e){l((function(t){t.foundationActionScope=e}))},cuboidActionScope:_.OnlyThisSide,setCuboidActionScope:function(e){l((function(t){t.cuboidActionScope=e}))},polygonActionScope:_.OnlyThisObject,setPolygonActionScope:function(e){l((function(t){t.polygonActionScope=e}))},updatePolygonVertexPositionById:function(e,t,a,o){l((function(l){var i,r=Object(h.a)(l.elements);try{for(r.s();!(i=r.n()).done;){var n=i.value;if(n.type===V.Polygon&&n.id===e){var c=n;t>=0&&t11&&(o=0),i=(c-s)/(s+Ww.daysOfMonth(o,r)/2)}return{low:t[a]+(t[o]-t[a])*i,high:l[a]+(l[o]-l[a])*i}},IT=function(e,t,l,a,o,i,r,n,c){return function(e,t,l,a,o,i){for(var r=l.length,n=0,c=-1e3,s=1e3,d=-1e3,u=1e3,f=0;f0&&(I.set(p+(C+.5)*f,y+(F+.5)*h),I.rotateAround(g,e.rotation[2]),m.set(I.x,I.y,c),H(e.id,m,R)||(A[C][F]+=M*D))}}var k=P*b/60,O=k>At?w.sunshineHours[l]/(30*k*o.timesPerHour):0;N(A,O),d(e.id,A)},D=function(e){var t=e.solarUpdraftTower;if(t){for(var l,a,i=x.getFullYear(),r=x.getMonth(),n=x.getDate(),c=Ww.dayOfYear(x),s=t.collectorRadius,u=Math.max(2,Math.round(2*s/T)),f=e.cx-s+T/2,h=e.cy-s+T/2,p=e.lz+t.collectorHeight,y=Array(u).fill(0).map((function(){return Array(u).fill(0)})),g=new We.Vector3(0,0,p),m=s*s,A=0,P=0;P<24;P++)for(var S=0;S0&&(E(e.id,v,t)||(b[j][z]+=P*A)))}else for(var M=0;M0){var C=M-s/2+.5,k=I-d/2+.5;v.set(g.x+C*w,g.y+C*x,g.z+k*f),E(e.id,v,t)||(b[M][I]+=P*A)}}},Q=function(e,t,l,a){var o,i=a[0][0].z,r=Ww.dayOfYear(S),n=Fy(e,r,H,py.SPHERE_MODEL),s=new We.Euler(0,0,l.rotation[2],"ZYX"),d=Number.MAX_VALUE,u=Number.MAX_VALUE,f=-Number.MAX_VALUE,p=-Number.MAX_VALUE,y=Object(h.a)(a);try{for(y.s();!(o=y.n()).done;){var g,m=o.value,w=Object(h.a)(m);try{for(w.s();!(g=w.n()).done;){var x=g.value.clone().applyEuler(s);x.x>f&&(f=x.x),x.x