@roomle/web-sdk 2.107.0 → 2.108.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/ConfiguratorKernel.wasm +0 -0
- package/lib/{PointLightHelper-BkdQaOKc.js → PointLightHelper-B8VP_55Z.js} +2 -2
- package/lib/{PointLightHelper-BkdQaOKc.js.map → PointLightHelper-B8VP_55Z.js.map} +1 -1
- package/lib/{PointLightHelper-qhWtXw8x.mjs → PointLightHelper-DtoZq5ME.mjs} +2 -2
- package/lib/{PointLightHelper-qhWtXw8x.mjs.map → PointLightHelper-DtoZq5ME.mjs.map} +1 -1
- package/lib/RoomleCore.js +6 -6
- package/lib/RoomleCore.wasm +0 -0
- package/lib/RoomleToolsCore.wasm +0 -0
- package/lib/{banana-for-scale-XjIfe69B.js → banana-for-scale-BVlDK4jg.js} +2 -2
- package/lib/{banana-for-scale-XjIfe69B.js.map → banana-for-scale-BVlDK4jg.js.map} +1 -1
- package/lib/{banana-for-scale-CDGM3hdN.mjs → banana-for-scale-CKSlc9Tc.mjs} +2 -2
- package/lib/{banana-for-scale-CDGM3hdN.mjs.map → banana-for-scale-CKSlc9Tc.mjs.map} +1 -1
- package/lib/camera-behaviour-CzgZxW1D.js +50 -0
- package/lib/camera-behaviour-CzgZxW1D.js.map +1 -0
- package/lib/{camera-behaviour-BLMduSEn.mjs → camera-behaviour-DWkBHxkk.mjs} +79 -75
- package/lib/camera-behaviour-DWkBHxkk.mjs.map +1 -0
- package/lib/{component-dimensioning-Do75G-kI.js → component-dimensioning-CUoDDxfk.js} +2 -2
- package/lib/{component-dimensioning-Do75G-kI.js.map → component-dimensioning-CUoDDxfk.js.map} +1 -1
- package/lib/{component-dimensioning-DvCO0pEp.mjs → component-dimensioning-CgVIP7Nu.mjs} +2 -2
- package/lib/{component-dimensioning-DvCO0pEp.mjs.map → component-dimensioning-CgVIP7Nu.mjs.map} +1 -1
- package/lib/{component-raycast-helper-Dl-pzfg_.js → component-raycast-helper-DvNtWlR5.js} +2 -2
- package/lib/{component-raycast-helper-Dl-pzfg_.js.map → component-raycast-helper-DvNtWlR5.js.map} +1 -1
- package/lib/{component-raycast-helper-CuZdUtrH.mjs → component-raycast-helper-zAwc-AuF.mjs} +2 -2
- package/lib/{component-raycast-helper-CuZdUtrH.mjs.map → component-raycast-helper-zAwc-AuF.mjs.map} +1 -1
- package/lib/{configurator-CT_ghGbX.mjs → configurator-DDhzCgxy.mjs} +6 -6
- package/lib/{configurator-CT_ghGbX.mjs.map → configurator-DDhzCgxy.mjs.map} +1 -1
- package/lib/{configurator-B01iJTNa.js → configurator-DJnpG8CG.js} +2 -2
- package/lib/{configurator-B01iJTNa.js.map → configurator-DJnpG8CG.js.map} +1 -1
- package/lib/configurator-scene-manager-Bxdyg2zz.js +2 -0
- package/lib/configurator-scene-manager-Bxdyg2zz.js.map +1 -0
- package/lib/{configurator-scene-manager-DbsYS4rm.mjs → configurator-scene-manager-DnZvFw0N.mjs} +150 -162
- package/lib/configurator-scene-manager-DnZvFw0N.mjs.map +1 -0
- package/lib/configurator.js +1 -1
- package/lib/configurator.nomodule.js +1 -1
- package/lib/{continuous-drawing-helper-DdnnCOqZ.js → continuous-drawing-helper-C6qDGAxa.js} +2 -2
- package/lib/{continuous-drawing-helper-DdnnCOqZ.js.map → continuous-drawing-helper-C6qDGAxa.js.map} +1 -1
- package/lib/{continuous-drawing-helper-DrpQFppG.mjs → continuous-drawing-helper-DbTM7uCv.mjs} +2 -2
- package/lib/{continuous-drawing-helper-DrpQFppG.mjs.map → continuous-drawing-helper-DbTM7uCv.mjs.map} +1 -1
- package/lib/{default-light-setting-D0Ie_AEw.mjs → default-light-setting-BdD0jDeP.mjs} +3 -3
- package/lib/{default-light-setting-D0Ie_AEw.mjs.map → default-light-setting-BdD0jDeP.mjs.map} +1 -1
- package/lib/{default-light-setting-DQxt3v5x.js → default-light-setting-CYiFuxeI.js} +2 -2
- package/lib/{default-light-setting-DQxt3v5x.js.map → default-light-setting-CYiFuxeI.js.map} +1 -1
- package/lib/definitions/common-core/src/light/light-source.d.ts +2 -0
- package/lib/definitions/common-core/src/utils/threejs-utils.d.ts +2 -1
- package/lib/definitions/common-core/src/webgl/roomle-component-factory.d.ts +1 -0
- package/lib/definitions/common-core/src/webgl/scene-manager.d.ts +1 -1
- package/lib/definitions/planner-core/src/lights/ceiling-light.d.ts +1 -1
- package/lib/definitions/planner-core/src/lights/light-group.d.ts +1 -2
- package/lib/definitions/planner-core/src/roomle-planner.d.ts +12 -6
- package/lib/definitions/planner-core/src/services/planner-kernel-access.d.ts +1 -1
- package/lib/definitions/planner-core/src/view-model/plan-view-model.d.ts +1 -4
- package/lib/definitions/planner-core/src/webgl/planner-scene-manager.d.ts +5 -1
- package/lib/{glb-viewer-BEWU9zxC.mjs → glb-viewer-BoZgMSrk.mjs} +6 -6
- package/lib/{glb-viewer-BEWU9zxC.mjs.map → glb-viewer-BoZgMSrk.mjs.map} +1 -1
- package/lib/{glb-viewer-camera-behaviour-Cl2bS83k.js → glb-viewer-camera-behaviour-AEWNZ6mR.js} +2 -2
- package/lib/{glb-viewer-camera-behaviour-Cl2bS83k.js.map → glb-viewer-camera-behaviour-AEWNZ6mR.js.map} +1 -1
- package/lib/{glb-viewer-camera-behaviour-DQ2sVbku.mjs → glb-viewer-camera-behaviour-CRnnMrL2.mjs} +2 -2
- package/lib/{glb-viewer-camera-behaviour-DQ2sVbku.mjs.map → glb-viewer-camera-behaviour-CRnnMrL2.mjs.map} +1 -1
- package/lib/{glb-viewer-6_OVDzVH.js → glb-viewer-vvpjnYPw.js} +2 -2
- package/lib/{glb-viewer-6_OVDzVH.js.map → glb-viewer-vvpjnYPw.js.map} +1 -1
- package/lib/glb-viewer.js +1 -1
- package/lib/glb-viewer.nomodule.js +1 -1
- package/lib/{imos-ix-poc-export-helper-r0pv9sOT.js → imos-ix-poc-export-helper-7AWayvID.js} +2 -2
- package/lib/{imos-ix-poc-export-helper-r0pv9sOT.js.map → imos-ix-poc-export-helper-7AWayvID.js.map} +1 -1
- package/lib/{imos-ix-poc-export-helper-BrpY0OHi.mjs → imos-ix-poc-export-helper-gQb0lbdn.mjs} +2 -2
- package/lib/{imos-ix-poc-export-helper-BrpY0OHi.mjs.map → imos-ix-poc-export-helper-gQb0lbdn.mjs.map} +1 -1
- package/lib/{main-05wLxbDZ.js → main-DVWEbQdM.js} +340 -149
- package/lib/{main-05wLxbDZ.js.map → main-DVWEbQdM.js.map} +1 -1
- package/lib/{main-CMu7hOEO.mjs → main-RpgY_kch.mjs} +2202 -1999
- package/lib/{main-CMu7hOEO.mjs.map → main-RpgY_kch.mjs.map} +1 -1
- package/lib/{material-viewer-B0MevA_r.mjs → material-viewer-DQjAOrWL.mjs} +4 -4
- package/lib/{material-viewer-B0MevA_r.mjs.map → material-viewer-DQjAOrWL.mjs.map} +1 -1
- package/lib/{material-viewer-CLqZXFrn.js → material-viewer-_9Sb1UCw.js} +2 -2
- package/lib/{material-viewer-CLqZXFrn.js.map → material-viewer-_9Sb1UCw.js.map} +1 -1
- package/lib/material-viewer.js +1 -1
- package/lib/material-viewer.nomodule.js +1 -1
- package/lib/planner-BcHlq0n3.js +155 -0
- package/lib/planner-BcHlq0n3.js.map +1 -0
- package/lib/{planner-B3Bt-cWy.mjs → planner-BilNNFJ0.mjs} +143 -125
- package/lib/planner-BilNNFJ0.mjs.map +1 -0
- package/lib/planner.js +1 -1
- package/lib/planner.nomodule.js +1 -1
- package/lib/roomle-sdk.js +7 -7
- package/lib/roomle-sdk.nomodule.js +1 -1
- package/lib/{script-loader-CZjzwkk2.js → script-loader-BZOMZ1AI.js} +2 -2
- package/lib/{script-loader-CZjzwkk2.js.map → script-loader-BZOMZ1AI.js.map} +1 -1
- package/lib/{script-loader-BzwDLtbS.mjs → script-loader-CHolkWhE.mjs} +2 -2
- package/lib/{script-loader-BzwDLtbS.mjs.map → script-loader-CHolkWhE.mjs.map} +1 -1
- package/lib/static/roomle-core-hsc/ConfiguratorKernel.wasm +0 -0
- package/lib/static/roomle-core-hsc/RoomleCore.js +6 -6
- package/lib/static/roomle-core-hsc/RoomleCore.wasm +0 -0
- package/lib/static/roomle-core-hsc/RoomleServiceCore.js +6 -6
- package/lib/static/roomle-core-hsc/RoomleServiceCore.wasm +0 -0
- package/lib/static/roomle-core-hsc/RoomleToolsCore.wasm +0 -0
- package/lib/static/roomle-core-hsc/configuratorCoreInterface.d.ts +2 -0
- package/lib/static/roomle-core-hsc/embind/configuratorCoreInterface.d.ts +2 -0
- package/lib/static/roomle-core-hsc/embind/plannerCoreCallback.d.ts +2 -2
- package/lib/static/roomle-core-hsc/embind/plannerCoreCallback.js +1 -1
- package/lib/static/roomle-core-hsc/embind/plannerCoreCallback.js.map +1 -1
- package/lib/static/roomle-core-hsc/embind/plannerCoreInterface.d.ts +17 -2
- package/lib/static/roomle-core-hsc/embind/plannerCoreInterface.js.map +1 -1
- package/lib/static/roomle-core-hsc/package.json +1 -1
- package/lib/static/roomle-core-hsc/plannerCoreCallback.d.ts +2 -2
- package/lib/static/roomle-core-hsc/plannerCoreCallback.js +1 -1
- package/lib/static/roomle-core-hsc/plannerCoreCallback.js.map +1 -1
- package/lib/static/roomle-core-hsc/plannerCoreInterface.d.ts +17 -2
- package/lib/static/roomle-core-hsc/plannerCoreInterface.js.map +1 -1
- package/lib/static/roomle-core-hsc/src/embind/configuratorCoreInterface.d.ts +2 -0
- package/lib/static/roomle-core-hsc/src/embind/plannerCoreCallback.d.ts +2 -2
- package/lib/static/roomle-core-hsc/src/embind/plannerCoreCallback.js +1 -1
- package/lib/static/roomle-core-hsc/src/embind/plannerCoreCallback.js.map +1 -1
- package/lib/static/roomle-core-hsc/src/embind/plannerCoreInterface.d.ts +17 -2
- package/lib/static/roomle-core-hsc/src/embind/plannerCoreInterface.js.map +1 -1
- package/lib/static/roomle-core-hsc/wasm_modern/ConfiguratorKernel.wasm +0 -0
- package/lib/static/roomle-core-hsc/wasm_modern/RoomleCore.js +6 -6
- package/lib/static/roomle-core-hsc/wasm_modern/RoomleCore.wasm +0 -0
- package/lib/static/roomle-core-hsc/wasm_modern/RoomleServiceCore.js +6 -6
- package/lib/static/roomle-core-hsc/wasm_modern/RoomleServiceCore.wasm +0 -0
- package/lib/static/roomle-core-hsc/wasm_modern/RoomleToolsCore.wasm +0 -0
- package/lib/{stats-helper-BaTpWjzi.mjs → stats-helper-BFpxduid.mjs} +2 -2
- package/lib/{stats-helper-BaTpWjzi.mjs.map → stats-helper-BFpxduid.mjs.map} +1 -1
- package/lib/{stats-helper-DylhlHS_.js → stats-helper-D4z7zVEi.js} +2 -2
- package/lib/{stats-helper-DylhlHS_.js.map → stats-helper-D4z7zVEi.js.map} +1 -1
- package/lib/{tools-core-BF9kMznR.js → tools-core-BJbLUz5-.js} +2 -2
- package/lib/{tools-core-BF9kMznR.js.map → tools-core-BJbLUz5-.js.map} +1 -1
- package/lib/{tools-core-BbL-KMAf.mjs → tools-core-COGP-hBi.mjs} +3 -3
- package/lib/{tools-core-BbL-KMAf.mjs.map → tools-core-COGP-hBi.mjs.map} +1 -1
- package/package.json +1 -1
- package/lib/camera-behaviour-BLMduSEn.mjs.map +0 -1
- package/lib/camera-behaviour-DgLVg_pP.js +0 -50
- package/lib/camera-behaviour-DgLVg_pP.js.map +0 -1
- package/lib/configurator-scene-manager-CRSHxOfd.js +0 -2
- package/lib/configurator-scene-manager-CRSHxOfd.js.map +0 -1
- package/lib/configurator-scene-manager-DbsYS4rm.mjs.map +0 -1
- package/lib/planner-B3Bt-cWy.mjs.map +0 -1
- package/lib/planner-D7lLZxgW.js +0 -155
- package/lib/planner-D7lLZxgW.js.map +0 -1
package/lib/planner-D7lLZxgW.js
DELETED
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
System.register(["./main-05wLxbDZ.js","./camera-behaviour-DgLVg_pP.js","./configurator-scene-manager-CRSHxOfd.js","./main-thread-to-worker-C8MPjAY0.js","./glb-viewer-camera-behaviour-Cl2bS83k.js","./script-loader-CZjzwkk2.js"],function(Ln,re){"use strict";var S,ot,se,R,lt,pe,ct,ht,dt,E,L,me,O,$e,fe,Ce,xe,T,M,w,be,k,Y,B,G,gt,ut,_t,X,oe,F,$,le,Pe,pt,mt,Ie,Z,f,ft,Je,m,Ct,bt,Pt,It,Oe,z,Q,Ot,qe,we,wt,ve,He,C,ce,ee,vt,he,St,Te,Mt,Et,yt,Dt,At,Rt,Lt,Se,jt,xt,Me,Ht,Ye,Tt,kt,Bt,ke,Be,Gt,Ft,Ut,Wt,Nt,de,Xe,Ge,Ze,Kt,zt,Qe,Ee,Vt,$t,Jt,qt,J,et,Yt,Xt,Zt,Qt,en,tn,nn,an,rn,sn,on,N,ln,U,te,ne,cn,hn,dn,gn,un,V,I,_n,pn,tt,mn,fn,b,Cn,bn;return{setters:[c=>{S=c.V,ot=c._,se=c.$,R=c.H,lt=c.an,pe=c.ao,ct=c.ap,ht=c.a0,dt=c.aq,E=c.ar,L=c.as,me=c.at,O=c.au,$e=c.av,fe=c.aw,Ce=c.ax,xe=c.P,T=c.M,M=c.q,w=c.ay,be=c.az,k=c.aA,Y=c.aB,B=c.aC,G=c.aD,gt=c.aE,ut=c.aF,_t=c.aG,X=c.v,oe=c.W,F=c.aH,$=c.aI,le=c.aJ,Pe=c.aK,pt=c.aL,mt=c.aM,Ie=c.aN,Z=c.aO,f=c.j,ft=c.aP,Je=c.aQ,m=c.aR,Ct=c.aS,bt=c.aT,Pt=c.aU,It=c.ab,Oe=c.e,z=c.g,Q=c.aV,Ot=c.aW,qe=c.aX,we=c.aY,wt=c.aZ,ve=c.ag,He=c.a_,C=c.B,ce=c.a$,ee=c.b0,vt=c.b1,he=c.b2,St=c.b3,Te=c.b4,Mt=c.b5,Et=c.ac,yt=c.b6,Dt=c.b7,At=c.b8,Rt=c.b9,Lt=c.ba,Se=c.bb,jt=c.bc,xt=c.bd,Me=c.be,Ht=c.bf,Ye=c.a9,Tt=c.bg,kt=c.bh,Bt=c.bi,ke=c.bj,Be=c.bk,Gt=c.bl,Ft=c.bm,Ut=c.bn,Wt=c.bo,Nt=c.bp,de=c.bq,Xe=c.br,Ge=c.bs,Ze=c.bt,Kt=c.a2,zt=c.C,Qe=c.bu,Ee=c.f,Vt=c.i,$t=c.bv,Jt=c.bw,qt=c.Y,J=c.D,et=c.b,Yt=c.x,Xt=c.bx,Zt=c.a,Qt=c.c,en=c.d,tn=c.r,nn=c.z,an=c.R,rn=c.K},c=>{sn=c.L,on=c.c,N=c.d,ln=c.B,U=c.C,te=c.e,ne=c.b,cn=c.I,hn=c.f},c=>{dn=c.S,gn=c.I,un=c.R,V=c.b,I=c.O,_n=c.C,pn=c.P,tt=c.c,mn=c.G,fn=c.a},c=>{b=c.C},c=>{Cn=c.G},c=>{bn=c.S}],execute:function(){const c=""+new URL("paper_background.png",re.meta.url).href;class Pn extends sn{constructor(e,t){super(e,t),this._center=new S(0,0,0),this._params={ambientLight:{color:"#ffffff"},hemiLight:{color:"#ffffff"},mainDirLight:{direction:{x:2,y:1,z:2},color:"#ffffff"}},this._ambientLight=new ot(new se(this._params.ambientLight.color),.4),this._ambientLight.layers.set(R.LIGHTING),this._mainDirLight=new lt(new se(this._params.mainDirLight.color),.5),this._mainDirLight.castShadow=!0,this._mainDirLight.shadow.camera.near=.5,this._mainDirLight.shadow.camera.far=100,this._mainDirLight.shadow.mapSize=new pe(1024,1024),this._mainDirLight.visible=!0,this.addToScene()}updateSunPosition(e,t){}addToScene(){this._scene.add(this._mainDirLight),this._scene.add(this._ambientLight),this._scene.add(this._mainDirLight.target)}removeFromScene(){this._scene.remove(this._mainDirLight),this._scene.remove(this._ambientLight),this._scene.remove(this._mainDirLight.target)}reload(){this.removeFromScene(),this.addToScene()}needsBounds(){return!0}updateBounds(e){this._center.copy(e.getCenter(new S));const t=new ct;e.getBoundingSphere(t);const n=t.radius,a=new S(this._params.mainDirLight.direction.x,this._params.mainDirLight.direction.y,this._params.mainDirLight.direction.z);a.normalize(),a.multiplyScalar(n),this._mainDirLight.position.copy(this._center),this._mainDirLight.position.add(a),this._mainDirLight.target.position.copy(this._center),this._mainDirLight.target.updateMatrixWorld(!0),this._mainDirLight.shadow.camera.top=n,this._mainDirLight.shadow.camera.bottom=-n,this._mainDirLight.shadow.camera.left=-n,this._mainDirLight.shadow.camera.right=n,this._mainDirLight.shadow.camera.near=.01,this._mainDirLight.shadow.camera.far=2*n,this._mainDirLight.shadow.camera.updateProjectionMatrix()}showGUI(){let e=ht();if(e){if(this._ambientLight){let t=e.addFolder("Ambient Light");t.add(this._ambientLight,"visible"),t.add(this._ambientLight,"intensity").min(0).max(5).step(.1),t.addColor(this._params.ambientLight,"color").onChange(n=>this._ambientLight.color=new se(n))}if(this._hemiLight){let t=e.addFolder("Hemi Light");t.add(this._hemiLight,"visible"),t.add(this._hemiLight,"intensity").min(0).max(5).step(.1),t.addColor(this._params.hemiLight,"color").onChange(n=>this._hemiLight.color=new se(n))}if(this._mainDirLight){let t=e.addFolder("Main Directional Light");t.add(this._mainDirLight,"visible"),t.add(this._mainDirLight,"intensity").min(0).max(10).step(.1),t.add(this._mainDirLight,"castShadow"),t.addColor(this._params.mainDirLight,"color").onChange(n=>this._mainDirLight.color=new se(n)),t.add(this._mainDirLight.position,"x").min(-10).max(10).step(.1).onChange(()=>this._mainDirLight.lookAt(this._center)),t.add(this._mainDirLight.position,"y").min(-10).max(50).step(.1).onChange(()=>this._mainDirLight.lookAt(this._center)),t.add(this._mainDirLight.position,"z").min(-10).max(10).step(.1).onChange(()=>this._mainDirLight.lookAt(this._center))}}}}var ye=(s=>(s[s.SELECT_PLAN_ELEMENT=0]="SELECT_PLAN_ELEMENT",s[s.DESELECT_PLAN_ELEMENT=1]="DESELECT_PLAN_ELEMENT",s[s.SELECT_PLAN_ELEMENT_MULTI=2]="SELECT_PLAN_ELEMENT_MULTI",s[s.SELECTION_MODE_CHANGED=3]="SELECTION_MODE_CHANGED",s))(ye||{});const Fe=s=>s instanceof L||s instanceof me;class ae{constructor(e){const{planElementViewModel:t,planElementViewModels:n,selectionMode:a,reason:i}=e;this.planElementViewModel=t,this.planElementViewModels=n,this.selectionMode=a,this.reason=i}}class jn extends dt{constructor(){super(...arguments),this._selectionMode=E.STANDARD,this._selectedPlanElementViewModels=new Map}check(e){this._selectionMode===E.STANDARD&&this._checkStandard(e),this._selectionMode===E.MULTISELECT&&this._checkMulti(e)}removeSelection(){this._selectedPlanElementViewModels.clear()}cancelSelection(e){this._selectedPlanElementViewModels.size!==0&&this._selectedPlanElementViewModels.forEach((t,n)=>{this._selectedPlanElementViewModels.delete(n),t.deselect(),this.dispatchEvent(1,new ae({planElementViewModel:t,reason:e}))})}_checkStandard(e){const t=e.getId();this._selectedPlanElementViewModels.has(t)&&this._selectedPlanElementViewModels.get(t)||(this._selectedPlanElementViewModels.size>0&&this._selectedPlanElementViewModels.forEach((a,i)=>{this._selectedPlanElementViewModels.delete(i),a.deselect(),this.dispatchEvent(1,new ae({planElementViewModel:a,reason:"select_other"}))}),this._selectedPlanElementViewModels.set(e.getId(),e),e.select(),this.dispatchEvent(0,new ae({planElementViewModel:e})))}_checkMulti(e){Fe(e)||this._selectedPlanElementViewModels.has(e.getId())||(this._selectedPlanElementViewModels.set(e.getId(),e),e.select(),this.dispatchEvent(2,new ae({planElementViewModels:this.getSelectedPlanElementViewModels()})),this.dispatchEvent(0,new ae({planElementViewModel:e})))}_deselectWallAndFloorElements(){this._selectedPlanElementViewModels.forEach((e,t)=>{Fe(e)&&(this._selectedPlanElementViewModels.delete(t),e.deselect(),this.dispatchEvent(1,new ae({planElementViewModel:e,reason:"selection_mode_changed"})))})}setSelectionMode(e){this._selectionMode!==e&&(e===E.MULTISELECT&&this._deselectWallAndFloorElements(),this._selectionMode=e,this.dispatchEvent(3,new ae({selectionMode:e})))}getSelectionMode(){return this._selectionMode}hasSelection(){return this._selectedPlanElementViewModels.size>0}hasMultiSelection(){return this._selectedPlanElementViewModels.size>1}getSelectedPlanElementViewModels(){return[...this._selectedPlanElementViewModels].map(([e,t])=>t)}getSelectedIds(){let e=[];return this._selectedPlanElementViewModels.forEach(t=>e.push(t.getId())),e}isSelected(e){return!!this._selectedPlanElementViewModels.get(e)}}var xn=Object.defineProperty,Ue=(s,e,t,n)=>{for(var a=void 0,i=s.length-1,r;i>=0;i--)(r=s[i])&&(a=r(e,t,a)||a);return a&&xn(e,t,a),a},y=(s=>(s[s.SELECT_PLAN_ELEMENT=0]="SELECT_PLAN_ELEMENT",s[s.DESELECT_PLAN_ELEMENT=1]="DESELECT_PLAN_ELEMENT",s[s.STATE_CHANGED=2]="STATE_CHANGED",s[s.HOVER_ON=3]="HOVER_ON",s[s.HOVER_OFF=4]="HOVER_OFF",s[s.DRAW=5]="DRAW",s[s.DRAWING_START=6]="DRAWING_START",s[s.DRAWING_END=7]="DRAWING_END",s[s.BEFORE_DRAG_START=8]="BEFORE_DRAG_START",s[s.DRAG_START=9]="DRAG_START",s[s.DRAG_MOVE=10]="DRAG_MOVE",s[s.DRAG_END=11]="DRAG_END",s[s.DRAG_CANCEL=12]="DRAG_CANCEL",s[s.INTERACTION=13]="INTERACTION",s[s.CLICK_OUTSIDE=14]="CLICK_OUTSIDE",s[s.SELECTION_MODE_CHANGED=15]="SELECTION_MODE_CHANGED",s[s.ADD_MEASUREMENT_LINE_START=16]="ADD_MEASUREMENT_LINE_START",s[s.ADD_MEASUREMENT_LINE_END=17]="ADD_MEASUREMENT_LINE_END",s[s.DRAG_MEASUREMENT_LINE=18]="DRAG_MEASUREMENT_LINE",s[s.ACTIVATE_PLAN_ELEMENT=19]="ACTIVATE_PLAN_ELEMENT",s))(y||{}),ie=(s=>(s[s.IDLE=0]="IDLE",s[s.DRAG=1]="DRAG",s[s.ROTATE=2]="ROTATE",s[s.DRAW=3]="DRAW",s[s.MEASURE=4]="MEASURE",s))(ie||{});class q{constructor(e){const{planElementViewModel:t,resetCamera:n,state:a,oldState:i,reason:r}=e;this.planElementViewModel=t,this.resetCamera=n===void 0?!0:n,this.state=a===void 0?0:a,this.oldState=i===void 0?0:i,this.reason=r}}class De extends dn{constructor(e,t,n,a){super(e,t,n,a),this._isDrawingEnabled=!1,this._isCurrentlyDrawing=!1,this._isMeasurementLineDrawActive=!1,this._state=0,this._inputManager.addEventListener(O.UP,()=>this._position=null,this),this._raycastHelper.setMode(gn.PLANNER),this._raycastHelper.addEventListener(un.CLICK_OUTSIDE,()=>{if(this._state===2){this.resetState();return}this._plannerSelectionHandler.cancelSelection("click_outside")},this),this._plannerSelectionHandler.addEventListener(ye.SELECT_PLAN_ELEMENT,({planElementViewModel:i})=>{this.dispatchEvent(this.isDragIn()?19:0,new q({planElementViewModel:i}))},this),this._plannerSelectionHandler.addEventListener(ye.SELECT_PLAN_ELEMENT_MULTI,({planElementViewModels:i})=>{this._roomlePlannerUiCallback.onMultiSelectionChange(i)},this),this._plannerSelectionHandler.addEventListener(ye.SELECTION_MODE_CHANGED,({selectionMode:i})=>{i===E.MULTISELECT&&this._hoveredObject&&this._hoverOnMultiSelect(this._hoveredObject),this._roomlePlannerUiCallback.onSelectionModeChange(i),this._checkRaycasterSnapping()},this),this._plannerSelectionHandler.addEventListener(ye.DESELECT_PLAN_ELEMENT,({planElementViewModel:i,reason:r})=>{this._state!==1&&this.setState(0),this.dispatchEvent(1,new q({planElementViewModel:i,reason:r}))},this),this._inputManager.addEventListener(O.MOVE,i=>this._move(i),this)}disable(){const e=new $e;e.disableAll(),this._raycastHelper.setLayers(e),this._raycastHelper.disableEvents()}get planInteractionHandler(){return this._plannerKernelAccess?.planInteractionHandler}get hoveredObjectId(){return this._hoveredObject?.getPlanElement()?this._hoveredObject.getId():null}get isCurrentlyDrawing(){return this._isCurrentlyDrawing}enable(){const e=new $e;e.disableAll(),e.enable(R.OBJECT),e.enable(R.GIZMO),e.enable(R.UI),e.enable(R.CONSTRUCTION),e.enable(R.BACKGROUND),this._raycastHelper.setLayers(e),this._raycastHelper.enableEvents()}enableConstructionEvents(e){e?this._raycastHelper.getLayers().enable(R.CONSTRUCTION):this._raycastHelper.getLayers().disable(R.CONSTRUCTION)}enableObjectEvents(e){e?this._raycastHelper.getLayers().enable(R.UI):this._raycastHelper.getLayers().disable(R.UI)}getSelectionMode(){return this._plannerSelectionHandler.getSelectionMode()}addConstructionPlanObjectHandlers(e,t){t||(t=e.getBoundingBox());const n={planElementName:e.getName(),hasListener:!0,priority:V.CONSTRUCTION,roomleId:e.getId(),snapToWall:!0};this._addPlanObjectHandlers(e,t,n)}addPlanObjectHandlers(e,t){t||(t=e.getBoundingBox());const n={planElementName:e.getName(),hasListener:!0,priority:V.DEFAULT,roomleId:e.getId()};this._addPlanObjectHandlers(e,t,n)}addWallHandlers(e){this._addPlanElementHandlers(e,e.getBoundingBox(),{planElementName:e.getName(),hasListener:!0,ignoreElementHit:!0,priority:V.WALL,roomleId:e.getId()})}addWallAtticHandlers(e){this._addPlanElementHandlers(e,e.getBoundingBox(),{planElementName:e.getName(),hasListener:!0,priority:V.WALL,roomleId:e.getId()})}addMeasurementLineHandlers(e){const t={planElementName:e.getName(),hasListener:!0,priority:V.DEFAULT,roomleId:e.getId()};this._addMeasurementLinePlanElementHandlers(e,e.getPoint1DraggableBoundingBox(),t,fe.POINT1),this._addMeasurementLinePlanElementHandlers(e,e.getPoint2DraggableBoundingBox(),t,fe.POINT2),this._addMeasurementLinePlanElementHandlers(e,e.getBoundingBox(),t,null)}addFloorHandlers(e){this._addFloorElementHandlers(e,e.getObject(),{planElementName:e.getName(),hasListener:!0,priority:V.FLOOR,roomleId:e.getId()})}addNodeHandlers(e){this._addPlanElementHandlers(e,e.getBoundingBox(),{planElementName:e.getName(),hasListener:!0,priority:V.DEFAULT,ignoreElementHit:!0,roomleId:e.getId()})}_addPlanObjectHandlers(e,t,n){t.userData.hasListener||(t.userData=Ce(t.userData,n),t.addEventListener(I.CLICK,()=>this._clickElement(e)),t.addEventListener(I.DRAG_START,()=>this._dragStart(e)),t.addEventListener(I.DRAG,a=>this._drag(e,a.attachment.position)),t.addEventListener(I.DRAG_END,a=>this._dragEnd(e,a.attachment.position)),t.addEventListener(I.HOVER_ON,()=>this._hoverOn(e)),t.addEventListener(I.HOVER_OFF,()=>this._hoverOff(e)),t.addEventListener(I.ROTATE,a=>this._rotate(e,a.attachment.rotation)))}_addFloorElementHandlers(e,t,n){this._addElementHandlers(e,t,n)}_addElementHandlers(e,t,n){t.userData.hasListener||(t.userData=Ce(t.userData,n),t.addEventListener(I.CLICK,()=>this._clickElement(e)),t.addEventListener(I.DOUBLE_CLICK,a=>{this._doubleClickElement(e,a.attachment.type,a.attachment.intersection?.point)}),t.addEventListener(I.HOVER_ON,()=>this._hoverOn(e)),t.addEventListener(I.HOVER_OFF,()=>this._hoverOff(e)))}_addPlanElementHandlers(e,t,n){t.userData.hasListener||(this._addElementHandlers(e,t,n),t.addEventListener(I.DRAG_START,()=>this._dragStart(e)),t.addEventListener(I.DRAG,a=>this._drag(e,a.attachment.position)),t.addEventListener(I.DRAG_END,a=>this._dragEnd(e,a.attachment.position)))}_addMeasurementLinePlanElementHandlers(e,t,n,a){if(t.userData.hasListener)return;t.userData=Ce(t.userData,n);const i=()=>{e.currentPoint=a};t.addEventListener(I.CLICK,()=>{this._clickElement(e),i()}),t.addEventListener(I.DRAG_START,()=>{i(),e.selectPointOnDragStart(e),this._dragStart(e)}),t.addEventListener(I.DRAG,r=>{i(),e.hideDraggablePointsOnDragStart(e,a),this._drag(e,r.attachment.position)}),t.addEventListener(I.DRAG_END,r=>{e.showDraggablePointsOnDragEnd(e,a),this._dragEnd(e,r.attachment.position),e.showDraggableNodes(),i()}),t.addEventListener(I.HOVER_ON,()=>{i(),e.showDraggablePointsOnHoverOn(e),this._hoverOn(e)}),t.addEventListener(I.HOVER_OFF,()=>{i(),e.showDraggablePointsOnHoverOff(e),this._hoverOff(e)})}_createFloorMeshWithHandler(){const e=new xe(1e3,1e3,8,8),t=new T;t.visible=!1;const n=new M(e,t);n.name="2D raycaster floor mesh",n.rotation.set(-Math.PI/2,0,0),n.layers.enable(R.BACKGROUND),n.userData.ignoreElementHit=!0;const a={planElementName:"2D raycaster floor mesh",hasListener:!0,priority:V.RAYCASTER_FLOOR,roomleId:void 0};return n.userData=Ce(n.userData,a),n.addEventListener(I.DOUBLE_CLICK,i=>{this._doubleClickOnPlane(w(i.attachment.intersection.point),i.attachment.type)}),n.addEventListener(I.CLICK,i=>{const r=w(i.attachment.intersection.point);this._isCurrentlyDrawing?this._clickOnPlane(r):this._plannerSelectionHandler.cancelSelection("click_outside")}),n}_clickOnPlane(e){this._createNode(null,e)}_doubleClickOnPlane(e,t=be.UNKNOWN){this._isMeasurementLineDrawActive||(this._closeToPoint(e)?this.stopDrawing():this._toggleDrawing(null,e,t))}_closeToPoint(e){let t=!1;for(const n of this._planViewModel.getNodePlanObjectViewModels())this._close(n.getPlanElement().getCenter(),e)&&(t=!0);return t}_close(e,t){return Math.abs(e.x-t.x)<500&&Math.abs(e.y-t.y)<500&&Math.abs(e.z-t.z)<500}_clickElement(e){if(Ke(e,this._initData)){this._plannerSelectionHandler.cancelSelection("click_outside");return}if(!this._isCurrentlyDrawing){if(e instanceof k&&e.handleDraggablePointsSelection(e),this._debug&&console.log("select",e.getId()),this._state===2){this.resetState();return}this._plannerSelectionHandler.check(e),this._roomlePlannerUiCallback.onClickElement(e),this._setCursor()}}_doubleClickElement(e,t=be.UNKNOWN,n){if(!this._isDrawingEnabled||!(e instanceof Y)&&!(e instanceof L))return;this._debug&&console.log("double click",e.getId()),e instanceof L&&this._plannerSelectionHandler.cancelSelection("double_click_wall");let a;e instanceof Y?a=e.getPlanElement().getCenter():n&&(a=w(new S(n.x,0,n.z))),this._isCurrentlyDrawing?this.endWallDrawing(null,a):this._startWallDrawing(null,a,t)}_hoverOn(e){e instanceof k&&e.showDraggablePointsOnHoverOn(e),!this._isCurrentlyDrawing&&(this._plannerSelectionHandler.getSelectionMode()===E.MULTISELECT?this._hoverOnMultiSelect(e):this._hoverOnStandard(e))}_hoverOnMultiSelect(e){Fe(this._hoveredObject)||Fe(e)?(this._hoveredObject=null,B(G.DEFAULT)):this._hoverOnStandard(e)}_hoverOnStandard(e){e.hoverOn(),this._hoveredObject=e,this.dispatchEvent(3,new q({planElementViewModel:e})),this._interaction(),this._setCursor()}_hoverOff(e){e.hoverOff(),e instanceof k&&e.showDraggablePointsOnHoverOff(e),this.dispatchEvent(4,new q({planElementViewModel:e})),this._interaction(),this._hoveredObject=null,this._setCursor()}_isHoveredObjectNonDraggable(){return this._hoveredObject instanceof me}_setCursor(){this._state===4?B(G.NODE_HOVER):this._state===2&&this.hasSelection()?B(G.ROTATE):this._state===1?B(G.DRAGGING):!this._isHoveredObjectNonDraggable&&this._plannerSelectionHandler.isSelected(this.hoveredObjectId)?B(G.MOVE):this._hoveredObject?Ke(this._hoveredObject,this._initData)?B(G.DEFAULT):B(G.HOVER):this._state===3?B(gt?G.DRAW_FALLBACK:G.DRAW):B(G.DEFAULT)}setCamera(e){this._raycastHelper.setCamera(e)}setObject(e){this._raycastHelper.setObject(e)}getSelectedIds(){return this._plannerSelectionHandler.getSelectedIds()}setSelectionMode(e){this._plannerSelectionHandler.setSelectionMode(e),e===E.MULTISELECT&&this._roomlePlannerUiCallback.onMultiSelectionChange(this._plannerSelectionHandler.getSelectedPlanElementViewModels())}setPlanViewModel(e){this._planViewModel=e}cancelSelection(e){this.isDragIn()&&e==="dock_component"||this._plannerSelectionHandler.cancelSelection(e)}removeSelection(){this._plannerSelectionHandler.removeSelection()}_dragStart(e){this._isMeasurementLineDrawActive||(!this._plannerSelectionHandler.isSelected(e.getId())&&!this._dragIn||this._state!==0)&&!this._isDrawingEnabled||(this.dispatchEvent(8),ut(_t.DRAG).then(()=>{if(this._inputManager.isMouseUp()){this.setState(0),B(G.HOVER),this.dispatchEvent(12);return}this._draggedObject=e,this.setState(1),this._roomlePlannerUiCallback.onDragElementStart(e.getId()),this.dispatchEvent(9,new q({planElementViewModel:e}))}))}_drag(e,t){if(!this._draggedObject||this._state!==1)return;const n=this.planInteractionHandler;this._lastDragPosition||(this._lastDragPosition=t);let a=t.clone().sub(this._lastDragPosition);if(this._plannerSelectionHandler.getSelectedIds().length>1){const i=new this._plannerKernelAccess.kernelContainer.PlanObjectPtrList;this._plannerSelectionHandler.getSelectedIds().forEach(o=>i.push_back(this._planViewModel.getPlanObjectForId(o).getPlanElement()));const r=w(a);this._plannerSelectionHandler.hasMultiSelection()&&(r.z=0),n.moveObjectsBy(i,r),this._lastDragPosition.copy(t)}else if(e instanceof k)this._dragMeasurementLine(e,t);else{const i=e instanceof Y||e instanceof L,r=e.getPlanElement();if(this._planViewModel.cameraType===b.CAMERA_2D&&!this._dragIn||i){const l=X(r.getCenter()),h=w(t.clone().sub(l));h.z=0,n.moveElementBy(r,h)}else n.moveElementTo(r,w(t))}this._lastDragPosition.copy(t),this.dispatchEvent(10,new q({planElementViewModel:e}))}_dragEnd(e,t){this._draggedObject&&(this._draggedObject=null,this._lastDragPosition=null,this.setState(0),this.dispatchEvent(11,new q({planElementViewModel:e})),this._dragIn&&this.setDragIn(!1),this._roomlePlannerUiCallback.onDragElementEnd(),this._setCursor())}_rotate(e,t){if(this._plannerSelectionHandler.isSelected(e.getId())){const n=this.planInteractionHandler,a=e.getPlanObject();n.setObjectRotation(e.getPlanElement(),a.rotation-t)}}setState(e){const t=this._state;this._state=e,this._setCursor(),this.dispatchEvent(2,new q({state:this._state,oldState:t})),this._position=null,this._state===2?this.planInteractionHandler?.deactivateAllSnappingActivity():t===2&&this.planInteractionHandler?.reactivateAllSnappingActivity()}resetState(){this.setState(0)}_move(e){if(!(this._state===3||this._state===4)&&this._state===2&&this.hasSelection()){this._setCursor();let t=Math.PI/180;const{x:n,y:a}=e.positionRelative;this._position?t=e.positionRelative.x*1.4*Math.PI-this._position.x*1.4*Math.PI:this._position=new S(e.positionRelative.x,e.positionRelative.y,0);const i=new this._plannerKernelAccess.kernelContainer.PlanObjectPtrList,r=new oe;this.getSelectedIds().forEach(h=>{const d=this._planViewModel?.getPlanObjectForId(h);d&&d.getObject()&&(i.push_back(d.getPlanElement()),r.expandByObject(d.getContainer()))});const o=r.getCenter(new S);this.planInteractionHandler.rotateObjectsBy(i,t,w(o)),this._position.copy(new S(n,a,0))}}hasSelection(){return this._plannerSelectionHandler.getSelectedIds().length>0}async selectPlanElement(e){(e instanceof F||e instanceof $)&&await e.isInitDone(),this._plannerSelectionHandler.check(e)}_interaction(e){this.dispatchEvent(13,new q({}))}addComponentDragInHandler(e){if(!this._dragIn)return;const t=e.getBoundingBox(),n=e instanceof Ie||e instanceof Z;this._addPlanElementHandlers(e,t,{planElementName:e.getName(),hasListener:!0,priority:V.DEFAULT,roomleId:e.getId(),snapToWall:n}),this._raycastHelper.enableDragIn(t),this._dragStart(e)}enableSnapping(){this.planInteractionHandler.enableSnap=!0,this._checkRaycasterSnapping()}disableSnapping(){this.planInteractionHandler.enableSnap=!1,this._checkRaycasterSnapping()}enableAdvancedDocking(){this.planInteractionHandler.dockWhenSnap=!0}disableAdvancedDocking(){this.planInteractionHandler.dockWhenSnap=!1}showsChildrenOfPlanObject(e){return this.planInteractionHandler.getShowChildrenOfPlanObject(e).value!==le.OFF}enableShowChildrenOfPlanObject(e){this.planInteractionHandler.setShowChildrenOfPlanObject(e,{value:le.GROUND_COMPONENTS},!1)}disableShowChildrenOfPlanObject(e){this.planInteractionHandler.setShowChildrenOfPlanObject(e,{value:le.OFF},!1)}_checkRaycasterSnapping(){const e=this.planInteractionHandler.enableSnap,t=this.getSelectionMode()===E.MULTISELECT;e&&!t?this._raycastHelper.enableOnWallSnapping():this._raycastHelper.disableOnWallSnapping()}enableWallDrawing(){return this._isDrawingEnabled=!0,this._drawingGroup=new Pe,this._drawingGroup.name="Drawing",this._drawingGroup.add(this._createFloorMeshWithHandler()),this._inputManager.addEventListener(O.MOVE,this._drawWallOnMouseMove,this),this._inputManager.addEventListener(O.TOUCH_END,this.endWallDrawing,this),this._drawingGroup}cancelWallDrawing(){return this._isDrawingEnabled=!1,this._setStateAndCursor(0),this._inputManager.removeEventListener(O.MOVE,this._drawWallOnMouseMove),this._inputManager.removeEventListener(O.TOUCH_END,this.endWallDrawing),this._raycastHelper.clear(),this._drawingGroup}stopDrawing(e=!0){this.planInteractionHandler.endInteraction(),e&&this.planInteractionHandler.cancelDrawing(),this._raycastHelper.getLayers().enable(R.CONSTRUCTION),this._isCurrentlyDrawing=!1,this._setStateAndCursor(0),this.dispatchEvent(7),this._continuousDrawingHelper?.endDrawing(),this._roomlePlannerUiCallback.onDrawingStateChanged(!1)}startDrawing(){this._isCurrentlyDrawing||(this._isCurrentlyDrawing=!0,this._raycastHelper.getLayers().disable(R.CONSTRUCTION),this.dispatchEvent(6),this._setStateAndCursor(3),this._continuousDrawingHelper?.update(),this._roomlePlannerUiCallback.onDrawingStateChanged(!0))}_toggleDrawing(e,t,n){this._isCurrentlyDrawing?this.endWallDrawing(e,t):this._startWallDrawing(e,t,n)}endWallDrawing(e,t){if(this._isCurrentlyDrawing){if(this.planInteractionHandler.getContinuousDrawingManager().shouldShowCircle()&&this.planInteractionHandler.getContinuousDrawingManager().shouldShowCircle())this.planInteractionHandler.cancelDrawing();else{const{x:n,y:a}=t||this._getIntersectionPointWithScene(e);this.planInteractionHandler.endDrawing({x:n,y:a,z:0})}this.stopDrawing(!1)}}async _startWallDrawing(e,t,n){(e&&e.type===be.TOUCH||n===be.TOUCH)&&(await this._initMobileDrawing(),this._continuousDrawingHelper.update()),this.planInteractionHandler.startInteraction();const{x:a,y:i}=t||this._getIntersectionPointWithScene(e),r=this._initData?.featureFlags?.drawPreviewMode===pt.VECTOR;this.planInteractionHandler.beginDrawing({x:a,y:i,z:0},r),this.startDrawing()}async _initMobileDrawing(){if(this.planInteractionHandler.setDrawingType(mt.CONTINOUS),this.planInteractionHandler.setSnapFeedbackWhileDrawing(!0),!this._continuousDrawingHelper){const{default:e}=await re.import("./continuous-drawing-helper-DdnnCOqZ.js");this._continuousDrawingHelper=new e,this._continuousDrawingHelper.init(this._drawingGroup,this.planInteractionHandler.getContinuousDrawingManager(),this._kernelZoomFactor)}}_drawWallOnMouseMove(e){if(!this._isCurrentlyDrawing||this._isMeasurementLineDrawActive)return;const{x:t,y:n}=this._getIntersectionPointWithScene(e);this.planInteractionHandler.currentDrawingPosition({x:t,y:n,z:0}),this._continuousDrawingHelper?.update(),this.dispatchEvent(5)}_createNode(e,t){if(!this._isCurrentlyDrawing)return;const{x:n,y:a}=t||this._getIntersectionPointWithScene(e);this.planInteractionHandler.forceNode({x:n,y:a,z:0}),this._raycastHelper.clear()}_getIntersectionPointWithScene(e){return this._raycastHelper.intersectMouseOnScene(e)}_setStateAndCursor(e){this.setState(e),this._setCursor()}setKernelZoomFactor(e){this._kernelZoomFactor=e,this._continuousDrawingHelper?.setKernelZoomFactor(e)}enableMeasurementLineDrawing(){this._setStateAndCursor(4),this._isMeasurementLineDrawActive=!0,this._enableDrawingListeners()}disableMeasurementLineDrawing(){this._disableDrawingListeners(),this.dispatchEvent(17),this.setState(0),this._isMeasurementLineDrawActive=!1,this._currentPlanMeasure=null}_handleMeasurementLineDrawingEvent(e){return e===O.MOVE?this._drawMeasurementLineOnMouseMove:e===O.CLICK||e===O.LONG_TOUCH||e===O.TOUCH_END?this._createPlanMeasure:null}_enableDrawingListeners(){[O.CLICK,O.MOVE,O.LONG_TOUCH,O.TOUCH_END].forEach(t=>{this._inputManager.addEventListener(t,this._handleMeasurementLineDrawingEvent(t),this)})}_disableDrawingListeners(){[O.CLICK,O.MOVE,O.LONG_TOUCH,O.TOUCH_END].forEach(t=>{this._inputManager.removeEventListener(t,this._handleMeasurementLineDrawingEvent(t))})}_drawMeasurementLineOnMouseMove(e){if(!this._currentPlanMeasure)return;this._state!==4&&this._setStateAndCursor(4);const{x:t,y:n}=this._getIntersectionPointWithScene(e);this.planInteractionHandler.setMeasurePoint2(this._currentPlanMeasure,{x:t,y:n,z:0},!0,!0)}_updateMeasurementLineViewModels(e){e==="hide_dragged_node"?this._planViewModel.getMeasurementLineObjectViewModels().forEach(t=>{this._currentPlanMeasure.getId()===t.getId()&&t.hidePoint2DraggableNode()}):e==="showDraggableNodes"&&this._planViewModel.getMeasurementLineObjectViewModels().forEach(t=>{this._currentPlanMeasure.getId()===t.getId()&&(t.showDraggableNodes(),t.showDraggablePointsOnDragEnd(t,"point2"))})}_createPlanMeasure(e){const{x:t,y:n}=this._getIntersectionPointWithScene(e),a={x:t,y:n,z:0};if(!this._currentPlanMeasure){this.dispatchEvent(16),this._currentPlanMeasure=this.planInteractionHandler.addMeasure(a,a),this._updateMeasurementLineViewModels("hide_dragged_node");return}this.planInteractionHandler.setMeasurePoint2(this._currentPlanMeasure,a,!0,!0),this._updateMeasurementLineViewModels("showDraggableNodes"),this.disableMeasurementLineDrawing()}_dragMeasurementLine(e,t){const n=e.getPlanElement();if(!e.currentPoint){if(!this._lastDragPosition){this._lastDragPosition=t.clone();return}const a=t.clone().sub(this._lastDragPosition),r=X(n.getCenter()).add(a);this.planInteractionHandler.moveElementTo(n,w(r)),this._lastDragPosition.copy(t),e.update(),this.dispatchEvent(18);return}e.currentPoint===fe.POINT1&&this.planInteractionHandler.setMeasurePoint1(n,w(t),!0,!0),e.currentPoint===fe.POINT2&&this.planInteractionHandler.setMeasurePoint2(n,w(t),!0,!0)}setMeasurementLineLength(e,t,n){if(!e){console.error("Measurement line not found");return}const a=t/1e3,i=n.toLowerCase()==="left",r=i?e.getPoint2Draggable().position.clone():e.getPoint1Draggable().position.clone(),l=new S().subVectors(e.getPoint2Draggable().position,e.getPoint1Draggable().position).normalize().multiplyScalar(a),h=i?r.sub(l):r.add(l);i?this.planInteractionHandler.setMeasurePoint1(e.getPlanElement(),w(h),!1,!1):this.planInteractionHandler.setMeasurePoint2(e.getPlanElement(),w(h),!1,!1)}}Ue([f],De.prototype,"_plannerSelectionHandler"),Ue([f],De.prototype,"_plannerKernelAccess"),Ue([f],De.prototype,"_roomlePlannerUiCallback"),Ue([f],De.prototype,"_initData");const Hn=(s,e,t,n)=>{const i=new oe().setFromObject(s.getContainer()).getCenter(new S);return{runtimeIds:[s.getId()],position2d:Je(m(i,e,t,n))}},In=s=>{if(s instanceof $){const e=s.getPlanObject().getObjectType();return e!=="door"&&e!=="window"?"static":e}return s instanceof F?"configuration":s instanceof L?"wall":s instanceof me?"floor":s instanceof k?"measure":s instanceof ft?"attic":"unknown"},Tn=(s,e,t)=>{const n=s.getRapiItem?.();if(n&&(n.detailType==="lamp_ceiling"||n.detailType==="lamp_standing")){if(n?.id==="brands_15:flos_aim"){const a={x:-.45,y:-.37,z:.35},i={x:.38,y:.31,z:-.17};e.handleLampLight(s,{targetPos:a,lightPos:i,active:t})}else if(n?.id==="brands_26:diesel_with_foscarini_fork"){const a={x:0,y:-.56,z:-.49},i={x:.01,y:1.62,z:0};e.handleLampLight(s,{targetPos:a,lightPos:i,color:16768955,decay:0,active:t})}}if(n?.id==="brands_26:diesel_with_foscarini_duii"){const a={x:-1.4,y:-.74,z:-.07},i={x:.07,y:.59,z:0};e.handleLampLight(s,{targetPos:a,lightPos:i,color:16777215,decay:2,active:t})}if(n?.id==="ba6d0d48:lights-kitchen"){const a={width:2.45,height:.03},i={x:0,y:1.571,z:-1.05};e.handleRectLampLight(s,{dimensions:a,lightPos:i,color:16777215,active:t});const r={width:.03,height:2.17},o={x:1.195,y:1.033,z:0};e.handleRectLampLight(s,{dimensions:r,lightPos:o,color:16777215,active:t})}if(s.getRapiItem?.()?.id==="roomle_white_furniture:Lighting_Pendant_lamp_02"){const a={x:0,y:-99,z:0},i={x:0,y:.15,z:0};e.handleLampLight(s,{targetPos:a,lightPos:i,color:16445391,decay:1,intensity:1,active:t})}};class We extends M{constructor(){const e=We.SkyShader,t=new Ct({name:e.name,uniforms:Pt.clone(e.uniforms),vertexShader:e.vertexShader,fragmentShader:e.fragmentShader,side:bt,depthWrite:!1});super(new It(1,1,1),t),this.isSky=!0}}We.SkyShader={name:"SkyShader",uniforms:{turbidity:{value:2},rayleigh:{value:1},mieCoefficient:{value:.005},mieDirectionalG:{value:.8},sunPosition:{value:new S},up:{value:new S(0,1,0)}},vertexShader:`
|
|
2
|
-
uniform vec3 sunPosition;
|
|
3
|
-
uniform float rayleigh;
|
|
4
|
-
uniform float turbidity;
|
|
5
|
-
uniform float mieCoefficient;
|
|
6
|
-
uniform vec3 up;
|
|
7
|
-
|
|
8
|
-
varying vec3 vWorldPosition;
|
|
9
|
-
varying vec3 vSunDirection;
|
|
10
|
-
varying float vSunfade;
|
|
11
|
-
varying vec3 vBetaR;
|
|
12
|
-
varying vec3 vBetaM;
|
|
13
|
-
varying float vSunE;
|
|
14
|
-
|
|
15
|
-
// constants for atmospheric scattering
|
|
16
|
-
const float e = 2.71828182845904523536028747135266249775724709369995957;
|
|
17
|
-
const float pi = 3.141592653589793238462643383279502884197169;
|
|
18
|
-
|
|
19
|
-
// wavelength of used primaries, according to preetham
|
|
20
|
-
const vec3 lambda = vec3( 680E-9, 550E-9, 450E-9 );
|
|
21
|
-
// this pre-calculation replaces older TotalRayleigh(vec3 lambda) function:
|
|
22
|
-
// (8.0 * pow(pi, 3.0) * pow(pow(n, 2.0) - 1.0, 2.0) * (6.0 + 3.0 * pn)) / (3.0 * N * pow(lambda, vec3(4.0)) * (6.0 - 7.0 * pn))
|
|
23
|
-
const vec3 totalRayleigh = vec3( 5.804542996261093E-6, 1.3562911419845635E-5, 3.0265902468824876E-5 );
|
|
24
|
-
|
|
25
|
-
// mie stuff
|
|
26
|
-
// K coefficient for the primaries
|
|
27
|
-
const float v = 4.0;
|
|
28
|
-
const vec3 K = vec3( 0.686, 0.678, 0.666 );
|
|
29
|
-
// MieConst = pi * pow( ( 2.0 * pi ) / lambda, vec3( v - 2.0 ) ) * K
|
|
30
|
-
const vec3 MieConst = vec3( 1.8399918514433978E14, 2.7798023919660528E14, 4.0790479543861094E14 );
|
|
31
|
-
|
|
32
|
-
// earth shadow hack
|
|
33
|
-
// cutoffAngle = pi / 1.95;
|
|
34
|
-
const float cutoffAngle = 1.6110731556870734;
|
|
35
|
-
const float steepness = 1.5;
|
|
36
|
-
const float EE = 1000.0;
|
|
37
|
-
|
|
38
|
-
float sunIntensity( float zenithAngleCos ) {
|
|
39
|
-
zenithAngleCos = clamp( zenithAngleCos, -1.0, 1.0 );
|
|
40
|
-
return EE * max( 0.0, 1.0 - pow( e, -( ( cutoffAngle - acos( zenithAngleCos ) ) / steepness ) ) );
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
vec3 totalMie( float T ) {
|
|
44
|
-
float c = ( 0.2 * T ) * 10E-18;
|
|
45
|
-
return 0.434 * c * MieConst;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
void main() {
|
|
49
|
-
|
|
50
|
-
vec4 worldPosition = modelMatrix * vec4( position, 1.0 );
|
|
51
|
-
vWorldPosition = worldPosition.xyz;
|
|
52
|
-
|
|
53
|
-
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
54
|
-
gl_Position.z = gl_Position.w; // set z to camera.far
|
|
55
|
-
|
|
56
|
-
vSunDirection = normalize( sunPosition );
|
|
57
|
-
|
|
58
|
-
vSunE = sunIntensity( dot( vSunDirection, up ) );
|
|
59
|
-
|
|
60
|
-
vSunfade = 1.0 - clamp( 1.0 - exp( ( sunPosition.y / 450000.0 ) ), 0.0, 1.0 );
|
|
61
|
-
|
|
62
|
-
float rayleighCoefficient = rayleigh - ( 1.0 * ( 1.0 - vSunfade ) );
|
|
63
|
-
|
|
64
|
-
// extinction (absorption + out scattering)
|
|
65
|
-
// rayleigh coefficients
|
|
66
|
-
vBetaR = totalRayleigh * rayleighCoefficient;
|
|
67
|
-
|
|
68
|
-
// mie coefficients
|
|
69
|
-
vBetaM = totalMie( turbidity ) * mieCoefficient;
|
|
70
|
-
|
|
71
|
-
}`,fragmentShader:`
|
|
72
|
-
varying vec3 vWorldPosition;
|
|
73
|
-
varying vec3 vSunDirection;
|
|
74
|
-
varying float vSunfade;
|
|
75
|
-
varying vec3 vBetaR;
|
|
76
|
-
varying vec3 vBetaM;
|
|
77
|
-
varying float vSunE;
|
|
78
|
-
|
|
79
|
-
uniform float mieDirectionalG;
|
|
80
|
-
uniform vec3 up;
|
|
81
|
-
|
|
82
|
-
// constants for atmospheric scattering
|
|
83
|
-
const float pi = 3.141592653589793238462643383279502884197169;
|
|
84
|
-
|
|
85
|
-
const float n = 1.0003; // refractive index of air
|
|
86
|
-
const float N = 2.545E25; // number of molecules per unit volume for air at 288.15K and 1013mb (sea level -45 celsius)
|
|
87
|
-
|
|
88
|
-
// optical length at zenith for molecules
|
|
89
|
-
const float rayleighZenithLength = 8.4E3;
|
|
90
|
-
const float mieZenithLength = 1.25E3;
|
|
91
|
-
// 66 arc seconds -> degrees, and the cosine of that
|
|
92
|
-
const float sunAngularDiameterCos = 0.999956676946448443553574619906976478926848692873900859324;
|
|
93
|
-
|
|
94
|
-
// 3.0 / ( 16.0 * pi )
|
|
95
|
-
const float THREE_OVER_SIXTEENPI = 0.05968310365946075;
|
|
96
|
-
// 1.0 / ( 4.0 * pi )
|
|
97
|
-
const float ONE_OVER_FOURPI = 0.07957747154594767;
|
|
98
|
-
|
|
99
|
-
float rayleighPhase( float cosTheta ) {
|
|
100
|
-
return THREE_OVER_SIXTEENPI * ( 1.0 + pow( cosTheta, 2.0 ) );
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
float hgPhase( float cosTheta, float g ) {
|
|
104
|
-
float g2 = pow( g, 2.0 );
|
|
105
|
-
float inverse = 1.0 / pow( 1.0 - 2.0 * g * cosTheta + g2, 1.5 );
|
|
106
|
-
return ONE_OVER_FOURPI * ( ( 1.0 - g2 ) * inverse );
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
void main() {
|
|
110
|
-
|
|
111
|
-
vec3 direction = normalize( vWorldPosition - cameraPosition );
|
|
112
|
-
|
|
113
|
-
// optical length
|
|
114
|
-
// cutoff angle at 90 to avoid singularity in next formula.
|
|
115
|
-
float zenithAngle = acos( max( 0.0, dot( up, direction ) ) );
|
|
116
|
-
float inverse = 1.0 / ( cos( zenithAngle ) + 0.15 * pow( 93.885 - ( ( zenithAngle * 180.0 ) / pi ), -1.253 ) );
|
|
117
|
-
float sR = rayleighZenithLength * inverse;
|
|
118
|
-
float sM = mieZenithLength * inverse;
|
|
119
|
-
|
|
120
|
-
// combined extinction factor
|
|
121
|
-
vec3 Fex = exp( -( vBetaR * sR + vBetaM * sM ) );
|
|
122
|
-
|
|
123
|
-
// in scattering
|
|
124
|
-
float cosTheta = dot( direction, vSunDirection );
|
|
125
|
-
|
|
126
|
-
float rPhase = rayleighPhase( cosTheta * 0.5 + 0.5 );
|
|
127
|
-
vec3 betaRTheta = vBetaR * rPhase;
|
|
128
|
-
|
|
129
|
-
float mPhase = hgPhase( cosTheta, mieDirectionalG );
|
|
130
|
-
vec3 betaMTheta = vBetaM * mPhase;
|
|
131
|
-
|
|
132
|
-
vec3 Lin = pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * ( 1.0 - Fex ), vec3( 1.5 ) );
|
|
133
|
-
Lin *= mix( vec3( 1.0 ), pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * Fex, vec3( 1.0 / 2.0 ) ), clamp( pow( 1.0 - dot( up, vSunDirection ), 5.0 ), 0.0, 1.0 ) );
|
|
134
|
-
|
|
135
|
-
// nightsky
|
|
136
|
-
float theta = acos( direction.y ); // elevation --> y-axis, [-pi/2, pi/2]
|
|
137
|
-
float phi = atan( direction.z, direction.x ); // azimuth --> x-axis [-pi/2, pi/2]
|
|
138
|
-
vec2 uv = vec2( phi, theta ) / vec2( 2.0 * pi, pi ) + vec2( 0.5, 0.0 );
|
|
139
|
-
vec3 L0 = vec3( 0.1 ) * Fex;
|
|
140
|
-
|
|
141
|
-
// composition + solar disc
|
|
142
|
-
float sundisk = smoothstep( sunAngularDiameterCos, sunAngularDiameterCos + 0.00002, cosTheta );
|
|
143
|
-
L0 += ( vSunE * 19000.0 * Fex ) * sundisk;
|
|
144
|
-
|
|
145
|
-
vec3 texColor = ( Lin + L0 ) * 0.04 + vec3( 0.0, 0.0003, 0.00075 );
|
|
146
|
-
|
|
147
|
-
vec3 retColor = pow( texColor, vec3( 1.0 / ( 1.2 + ( 1.2 * vSunfade ) ) ) );
|
|
148
|
-
|
|
149
|
-
gl_FragColor = vec4( retColor, 1.0 );
|
|
150
|
-
|
|
151
|
-
#include <tonemapping_fragment>
|
|
152
|
-
#include <colorspace_fragment>
|
|
153
|
-
|
|
154
|
-
}`};const kn=async(s,e)=>{const t=[],n=[],a=[],i=[];return await Promise.all(s.map(async r=>{if(r.configurationRuntimeId&&e.kernelInstance?.isExternalPlanObject(r.configurationRuntimeId))i.push([Oe(r.configurationHash),r]),t.push(z(r));else if(r.configurationType?.value!==Q.EXTERNAL){const o=z(r);if(o.configurationHash?a.push(o.configurationHash):o.catalogItemId&&n.push(o.catalogItemId),o.parts){const l=o.configurationHash||o.catalogItemId;o.parts=await e.addUiDataAndPriceToPartList(o.parts,l)}if(o.configuration){const l=await e.getConfigurationData(o.runtimeId);o.configuration=l.configuration}o.data=null,t.push(o)}})),{objects:t,itemIds:n,configurationIds:a,externalConfigurationData:i}},Bn=async(s=[],e=[],t=[],n)=>{const a=t.map(([d,u])=>d),[i,r,o]=await Promise.allSettled([n.getItems(s),n.getConfigurations(e),n.getExternalObjects(a)]),l=[],h=new Map;if(i.status==="fulfilled")for(const d of i.value)h.set(d.id,d);if(o.status==="fulfilled"&&o.value?.length>0)for(const{data:d}of o.value)h.set(d.id,d);if(r.status==="fulfilled")for(const d of r.value)h.set(d.id,d),l.push(d.rootComponentId);else console.warn("Could not fetch configuration for data property. This happens when a configuration has not been saved yet");return{data:h,rootComponentIds:l}},ge=async(s,e,t)=>{const{objects:n,itemIds:a,configurationIds:i,externalConfigurationData:r}=await kn(s,e),{data:o,rootComponentIds:l}=await Bn(a,i,r,t),h=await t.getComponents(l),d=new Map;for(const u of h)d.set(u.id,u);for(const u of n){const g=u.catalogItemId||u.configurationHash,p=o.get(u.catalogItemId)||o.get(u.configurationHash)||null;if(p&&!p.label&&d.has(p.rootComponentId)){const _=d.get(p.rootComponentId);p.label=_.label}p&&!p.label&&(p.label=g),u.data=p}return n};class Gn extends M{constructor(){const e=new xe(1e3,1e3,8,8);e.rotateX(-Math.PI/2);const t=new T;new Ot().load(c,a=>{a.wrapS=qe,a.wrapT=qe;const i=5;a.repeat.set(1e3/i,1e3/i),t.map=a,t.alphaTest=.3,t.transparent=!0}),super(e,t),this.name="2d paper background",this.position.set(0,-.1,0),this.layers.set(R.BACKGROUND),this.userData.ignoreElementHit=!0}}class Ae extends on{get cameraControl(){return this._cameraControl}}class On extends Ae{get cameraControl(){return this._cameraControl}resetCameraOnPlanCompletelyLoaded(e){this.cameraControl.zoomToFitBounds(we(e,this.cameraControl.domHelper.element.clientWidth,this.cameraControl.domHelper.element.clientHeight,1.1),!0)}externalApiResetCameraPosition(e){this.cameraControl.zoomToFitBounds(we(e,this.cameraControl.domHelper.element.clientWidth,this.cameraControl.domHelper.element.clientHeight,1.1),!0)}resetCameraOnSwitchTo2d(e){this.cameraControl.zoomToFitBounds(we(e,this.cameraControl.domHelper.element.clientWidth,this.cameraControl.domHelper.element.clientHeight,1.1),!0)}updateCameraOnDrawWalls(e){this.cameraControl.zoomToFitBounds(e,!1,!0)}updateCameraOnPlanElementInsertedOutsideCurrentCameraView(e){this.cameraControl.zoomToFitBounds(e,!1,!0)}updateCameraOnPlanElementInsertedInsideCurrentCameraView(e){}updateCameraOnPlanElementDraggedOutsidePlanBounds(e){this.cameraControl.zoomToFitBounds(e,!1,!0)}updateCameraOnPlanElementRemoved(e){}updateCameraOnBackToPlanner(e,t,n){this.cameraControl.zoomToFitBounds(e,!1,!0)}resetCameraOnEnableWallDrawing(e){this.cameraControl.zoomToFitBounds(e,!1,!0)}}class Re extends Ae{get cameraControl(){return this._cameraControl}resetCameraOnPlanCompletelyLoaded(e){this.cameraControl.updateAndReset(e,!0)}externalApiResetCameraPosition(e){this.cameraControl.updateAndReset(e,!0)}resetCameraOnSwitchTo3d(e){this.cameraControl.updateAndReset(e,!1)}disablePanningOnShiftRelease(){this.cameraControl.disablePanning()}enablePanningOnShiftClick(){this.cameraControl.enablePanning()}updateCameraOnDrawWalls(e){this.cameraControl.zoomToFitBounds(e,!0)}updateCameraOnPlanElementInsertedOutsideCurrentCameraView(e){this.cameraControl.zoomToFitBounds(e,!1)}updateCameraOnPlanElementDraggedOutsidePlanBounds(e){this.cameraControl.adjustToBoundsWithoutChangingDistance(e)}updateCameraOnPlanElementInsertedInsideCurrentCameraView(e){this.cameraControl.adjustToBoundsWithoutChangingDistance(e)}updateCameraOnPlanElementRemoved(e){this.cameraControl.adjustToBoundsWithoutChangingDistance(e)}async updateCameraOnBackToPlanner(e,t,n){if(!n)return;this.cameraControl.setObjectRotation(0),Math.abs(0-n.targetX)<=.01&&Math.abs(0-n.targetY)<=.01&&Math.abs(0-n.targetZ)<=.01?await this.cameraControl.updateAndReset(e,!0):await this._cameraControl.setToState(t,n)}resetCameraOnEnableWallDrawing(e){this.cameraControl.updateAndReset(e,!0)}async externalApiMoveCamera(e){await this.cameraControl.moveCamera(e),this._onCameraChanged()}}class Fn extends Ae{get cameraControl(){return this._cameraControl}resetCameraOnPlanCompletelyLoaded(e){this.cameraControl.updateCamera()}externalApiResetCameraPosition(e){this.cameraControl.updateCamera()}updateCameraOnDrawWalls(e){this.cameraControl.updateCamera()}updateCameraOnPlanElementInsertedOutsideCurrentCameraView(e){this.cameraControl.updateCamera()}updateCameraOnPlanElementInsertedInsideCurrentCameraView(e){this.cameraControl.updateCamera()}updateCameraOnPlanElementDraggedOutsidePlanBounds(e){this.cameraControl.updateCamera()}updateCameraOnPlanElementRemoved(e){this.cameraControl.updateCamera()}updateCameraOnBackToPlanner(e,t,n){this.cameraControl.updateCamera()}resetCameraOnEnableWallDrawing(e){this.cameraControl.updateCamera()}resetCameraOnSwitchToFirstPerson(){this.cameraControl.updateCamera()}}class Un{constructor(e,t,n){this._sceneEventHandler=e,this._roomleRenderer=t,this._planViewModel=n}_processViewModel(e,t){e instanceof L&&e.getKernelObject().getAttachedAttics?.().size()>0?e.getBoundingBox().children.forEach(a=>{a.isChildPlanObject||t.add(a)}):((e instanceof Ie||e instanceof Z)&&e.getTopViewContainer()&&t.add(e.getTopViewContainer()),e.getObject()?.children&&e.getObject().children.forEach(a=>{a.isChildPlanObject||t.add(a)}))}_processSelectedPlanElementIds(e){(this._sceneEventHandler?.getSelectedIds()||[]).forEach(n=>{const a=this._planViewModel.getPlanObjectForId(n);a&&this._processViewModel(a,e)})}_highlightPlanElementsBase(e,t){let n=new Set;t&&this._processViewModel(t,n),e?.forEach(a=>{const i=this._planViewModel.getPlanObjectForId(a);i&&this._processViewModel(i,n)}),this._processSelectedPlanElementIds(n),this._roomleRenderer?.highlightObjects(Array.from(n))}highlightPlanElements(e){this._highlightPlanElementsBase(e)}highlightPlanElement(e){this._highlightPlanElementsBase(void 0,e)}clearHighlighting(){this._highlightPlanElementsBase()}}function Wn(s,e,t,n,a,i,r,o=!0,l=!1){if(!(e.cameraControl instanceof N)||e.cameraControl.isLocked()&&o)return;const h=[],{x:d,y:u}=s.getClientDimensions(),g=a.getWallPlanObjectViewModels(),p=e.cameraControl.getKernelZoomFactor(),_=e.cameraControl.getCamera();for(const v of g){const P=v.getWallDimension(p,d,u);P.isCurrentlyDrawn=n.isCurrentlyDrawing&&v.getPlanElement().getTo().extRef.jsObject===a.latestNodePlanObjectViewModel;const{isVectorWall:W}=v.getKernelObject();P.length<=0&&!W||(Nn(P,_,d,u),P.attic&&Kn(P.attic,_,d,u),P.lengthFormatted=i.formatMMValueToUnitString(P.length),l&&zn(P,r),h.push(wt(P)))}t.onUpdateWallDimensions(h)}function Nn(s,e,t,n){s.fromPosition2d=m(s.fromPosition3d,e,t,n),s.toPosition2d=m(s.toPosition3d,e,t,n),s.textPosition2d=m(s.textPosition3d,e,t,n),s.fromWithoutPadding=m(s.fromWithoutPadding,e,t,n),s.toWithoutPadding=m(s.toWithoutPadding,e,t,n)}function Kn(s,e,t,n){s.textPosition2d=s.fromPosition3d?m(s.textPosition3d,e,t,n):void 0,s.fromPosition2d=s.fromPosition3d?m(s.fromPosition3d,e,t,n):void 0,s.toPosition2d=s.toPosition3d?m(s.toPosition3d,e,t,n):void 0,s.atticCenterPosition2d=s.atticCenterPosition3d?m(s.atticCenterPosition3d,e,t,n):void 0,s.wallCenterPosition2d=m(s.wallCenterPosition3d,e,t,n),s.labelCPosition2d=m(s.labelCPosition3d,e,t,n),s.labelHeightPosition2d=m(s.labelHeightPosition3d,e,t,n),s.shiftedWallCenter2d=m(s.shiftedWallCenter3d,e,t,n),s.heightAt2mPosition2d=m(s.heightAt2mPosition3d,e,t,n),s.attic2mCornerFrom2d=m(s.attic2mCornerFrom3d,e,t,n),s.attic2mCornerto2d=m(s.attic2mCornerto3d,e,t,n)}function zn(s,e){console.log("Wall dimension",s);const t=new ve(.1,32,16),n=new T({color:16711680}),a=new M(t,n);a.position.copy(s.fromPosition3d);const i=new M(t,n);i.position.copy(s.toPosition3d);const r=new M(t,new T({color:65280}));if(r.position.copy(s.textPosition3d),e.wallPoints.add(a),e.wallPoints.add(i),e.wallPoints.add(r),s.attic){const o=new M(t,new T({color:255}));s.attic.fromPosition3d&&o.position.copy(s.attic.fromPosition3d);const l=new M(t,new T({color:16711935}));s.attic.toPosition3d&&l.position.copy(s.attic.toPosition3d);const h=new M(t,new T({color:16776960}));s.attic.atticCenterPosition3d&&h.position.copy(s.attic.atticCenterPosition3d),e.wallPoints.add(o),e.wallPoints.add(l),e.wallPoints.add(h)}}const rt=class rt{static hasNativeClipboardWriteSupport(){return!!(navigator.clipboard&&typeof navigator.clipboard.writeText=="function")}static async hasNativeClipboardReadSupport(){return navigator.clipboard&&typeof navigator.clipboard.readText=="function"?(await navigator.permissions.query({name:"clipboard-read"})).state!=="denied":!1}static async copy(e){if(this.hasNativeClipboardWriteSupport())try{await navigator.clipboard.writeText(e)}catch(t){console.warn("Native clipboard writeText failed, attempting localStorage fallback.",t)}try{localStorage.setItem(this.LOCAL_STORAGE_KEY,e)}catch(t){console.error("Failed to copy text using localStorage:",t)}}static async paste(){if(await this.hasNativeClipboardReadSupport())try{return await navigator.clipboard.readText()}catch(e){console.warn("Native clipboard readText failed, attempting localStorage fallback.",e)}try{const e=localStorage.getItem(this.LOCAL_STORAGE_KEY);return e===null?"":e}catch(e){throw console.error("Failed to paste text using native clipboard and localStorage fallback:",e),new Error("Failed to paste text. Both clipboard and localStorage methods failed.")}}};rt.LOCAL_STORAGE_KEY="clipboardManagerFallback";let Ne=rt;var Vn=Object.defineProperty,Le=(s,e,t,n)=>{for(var a=void 0,i=s.length-1,r;i>=0;i--)(r=s[i])&&(a=r(e,t,a)||a);return a&&Vn(e,t,a),a};function Ke(s,e){const t=In(s),n=e?.lockPlan,a=s&&"getPlanElement"in s&&s.getPlanElement()&&"getAttachedWall"in s.getPlanElement();return!!(n&&(t==="wall"||t==="floor"||a))}const $n="rml_plans",je={INTERIOR:"interior",EXTERIOR:"exterior"},wn=s=>["altKey","ctrlKey","shiftKey","metaKey"].reduce((e,t)=>(s[t]&&e++,e),0);class ue extends _n{constructor(e,t,n,a){super(e,t,a),this._itemsLoadingStatePromises=[],this._staticItemGuard=new He,this._completelyLoaded=!1,this._configurableItemGuard=new He,this._planCompletelyLoadedGuard=new He,this.currentSelection=null,this._paperBackground=null,this._cameraState=null,this._debugSpheres={wallPoints:new Pe,constructionElementsPoints:new Pe,floorPoints:new Pe},this._stopRendering=!0,this._configureInRoom=!!this._initData.configureInRoom,this._configuratorContext.baseContext=C.PLANNER,this._roomlePlannerCallback=n,this._plannerMeshGenerator.maxAnisotropy=this._renderer.capabilities.getMaxAnisotropy(),this._plannerMeshGenerator.maxTextures=this._renderer.capabilities.maxTextures,this._plannerSceneEventHandler=new De(e,this._scene,this.cameraBehaviour.cameraControl.getCamera(),this._getInputManager()),this._roomleRenderer?.switchToPlanner(ce.Mode3D),this._imageRenderer.switchToPlannerSettings(),this._planElementHighlighter=new Un(this._plannerSceneEventHandler,this._roomleRenderer,this._getViewModel()),this._plannerSceneEventHandler.addEventListener(y.STATE_CHANGED,({state:i,oldState:r})=>{r===ie.ROTATE&&i!==r&&this._roomlePlannerUiCallback.onRotationCancel(),i===ie.ROTATE||i===ie.DRAG||i===ie.MEASURE||i===ie.DRAW?(this.cameraBehaviour.cameraControl.lock(),this._onCameraMove()):(this.cameraBehaviour.cameraControl.unlock(),this._onCameraIdle())},this),this._plannerSceneEventHandler.addEventListener(y.INTERACTION,()=>this._renderWithoutShadowsAndAO(),this),this._plannerSceneEventHandler.addEventListener(y.ACTIVATE_PLAN_ELEMENT,i=>this._activateElement(i),this),this._plannerSceneEventHandler.addEventListener(y.SELECT_PLAN_ELEMENT,i=>{this._activateElement(i);const r=i.planElementViewModel;this._sendElementMeasurements(),r instanceof $&&this._initData.debug&&console.log(r.getGLBUrl()),Ke(r,this._initData)||this._planElementHighlighter.highlightPlanElement(r),this._onSelectionChange(r),this._renderWithoutShadowsAndAO()},this),this._plannerSceneEventHandler.addEventListener(y.DESELECT_PLAN_ELEMENT,({planElementViewModel:i,reason:r})=>{this._planElementHighlighter.clearHighlighting(),this._onSelectionCancel(i,r),this._roomlePlannerUiCallback.onSelectionCancel(r),this._renderWithoutShadowsAndAO()},this),this._plannerSceneEventHandler.addEventListener(y.BEFORE_DRAG_START,()=>{this.cameraBehaviour.cameraControl.lock()},this),this._plannerSceneEventHandler.addEventListener(y.DRAG_START,({planElementViewModel:i})=>{this._getKernelAccess().planInteractionHandler.startInteraction(),this._sendElementMeasurements(),i instanceof L&&this._sendWallDimensions(),this._requestRender(),this._dragStartBounds=this.getBounds()},this),this._plannerSceneEventHandler.addEventListener(y.DRAG_MOVE,({planElementViewModel:i})=>{this.cameraBehaviour.cameraControl.checkNearFarDistance(i.getPosition()),this._requestRender()},this),this._plannerSceneEventHandler.addEventListener(y.DRAG_END,async({planElementViewModel:i})=>{const r=this._getKernelAccess().planInteractionHandler;r.endInteraction(),this.cameraBehaviour.cameraControl.unlock();const o=this._getDragPosition(i.getPosition());o&&r.moveElementTo(i.getPlanElement(),w(o)),this.updateEnvironment(this.getBounds(),!0),this._renderEverything();const l=this.getPlanObject(i.getId());let h;l&&(h=await ge([l],this._plannerKernelAccess,this._rapiAccess)),this._roomlePlannerUiCallback.onPlanElementChanged(ee.MOVED,h.length?h[0]:{...l,data:null});const d=i instanceof L||i instanceof k||i instanceof Y;!this._cameraBehaviourState.isWithinPlanBounds(i.getPosition(),this.getBounds())&&!d&&this.plannerCameraBehaviour.updateCameraOnPlanElementDraggedOutsidePlanBounds(this.getBounds())},this),this._plannerSceneEventHandler.addEventListener(y.DRAG_CANCEL,()=>{this.cameraBehaviour.cameraControl.unlock()},this),this._plannerSceneEventHandler.addEventListener(y.ADD_MEASUREMENT_LINE_START,()=>{this.cameraBehaviour.cameraControl.lock()},this),this._plannerSceneEventHandler.addEventListener(y.DRAG_MEASUREMENT_LINE,()=>{this._roomlePlannerUiCallback.onUpdateMeasurementLineDimensions([])},this),this._plannerSceneEventHandler.addEventListener(y.ADD_MEASUREMENT_LINE_END,()=>{this.cameraBehaviour.cameraControl.unlock(),this._roomlePlannerUiCallback.onMeasurementLineStateChange(!1)},this),this._plannerSceneEventHandler.addEventListener(y.DRAWING_START,()=>{this._setKernelZoomFactor(),this._renderWithoutShadowsAndAO(),this._roomleRenderer?.setGroundShadow(!1)},this),this._plannerSceneEventHandler.addEventListener(y.DRAW,()=>this._renderWithoutShadowsAndAO(),this),this._plannerSceneEventHandler.addEventListener(y.DRAWING_END,()=>{this._renderWithoutShadowsAndAO(),this._roomleRenderer?.setGroundShadow(!0)},this),this._getKernelAccess().addPlannerListener(this),this._plannerMeshGenerator.setMaterialLoadedListener(()=>{this._configurableItemGuard.resolve(),this._requestRender()}),window.onbeforeunload=this.clearScene.bind(this),this._getInputManager().addEventListener(O.ZOOM_IN,this._renderListener,this),this._getInputManager().addEventListener(O.ZOOM_OUT,this._renderListener,this),this._getInputManager().addEventListener(O.DOWN,this._onMouseDown,this),this.disableConfiguratorEvents(),a!==b.CAMERA_FP&&this.enablePlannerEvents(),setTimeout(()=>this._updatePaperBackground(),0),this._initData.debug&&(this._debugSpheres.wallPoints.name="Walls debug points",this._debugSpheres.constructionElementsPoints.name="Construction elements debug points",this._debugSpheres.floorPoints.name="Floor debug points",this._scene.add(this._debugSpheres.wallPoints),this._scene.add(this._debugSpheres.constructionElementsPoints),this._scene.add(this._debugSpheres.floorPoints))}get configuratorContext(){return this._configuratorContext}get hasSingleRoom(){const e=this._getViewModel().getFloorPlanObjectViewModels();return new Set(e.map(n=>n.getId())).size===1}_activateElement({planElementViewModel:e},t=()=>{}){const n=this._plannerSceneEventHandler.isDragIn()?e:null;this._sendElementMeasurements(n),e instanceof $&&this._initData.debug&&console.log(e.getGLBUrl()),Ke(e,this._initData)||this._planElementHighlighter.highlightPlanElement(e),t(),this._renderWithoutShadowsAndAO()}planCleared(){}planHistoryStateChanged(){if(this._sendRoomMeasurements(),this._completelyLoaded){const{configuratorId:e}=this._globalInitData,n=(this._plannerKernelAccess?.planInteractionHandler).getPlan()?.getPlanXML(!1,2),a=this._idbManager.getKey(vt(),e,this._initData.id);this._idbManager.setValue(a,n,this._idbManager.configStore)}}_getViewModel(){return this._viewModel||(this._viewModel=new pn(this._creator_),this._viewModel.setRequestRenderCallback(()=>this._renderEverything()),this._viewModel.setRequestRenderSceneUpdateCallback(()=>this._roomleRenderer?.clearCache()),this._viewModel.setInvalidateRenderCallback(()=>this._roomleRenderer?.forceShadowUpdates(!0))),this._viewModel}_getDragPosition(e){if(!this._plannerSceneEventHandler.isDragIn())return null;const t=this._dragStartBounds?this._dragStartBounds:this.getBounds(),n=t.getCenter(new S),a=e.distanceTo(n),i=t.getSize(new S),o=Math.max(i.x,i.z)+3;if(a>o){const l=new S().subVectors(e,n).normalize();return n.clone().add(l.multiplyScalar(o))}return null}_hideAllMeasurementsNodeOnElementChange(e){this._getViewModel().getMeasurementLineObjectViewModels().forEach(n=>n.hideDraggableNodes()),e instanceof k&&e.showDraggableNodes()}_onSelectionChange(e){this._hideAllMeasurementsNodeOnElementChange(e);const t={};if(e instanceof $&&(t.item=e.getRapiItem(),t.staticItemRuntimeId=e.getPlanElement().getId(),this._configuratorUiCallbacks.onUpdateParameters([])),e instanceof Z&&(t.staticItemRuntimeId=e.getPlanElement().getId()),e instanceof F){const r=e.getId(),o=this.getRootPlanObjectId(r),l=this._getViewModel().getPlanObjectForId(o);t.configurationRuntimeId=l.getConfigurationRuntimeId()}if(e instanceof L){const r=this.cameraBehaviour.cameraControl.getKernelZoomFactor(),{clientWidth:o,clientHeight:l}=this._domHelper.element;t.wall=e.getWallDimension(r,o,l)}e instanceof k&&(t.measurementLine=e.getMeasurementLineDimension()),e instanceof me&&(t.staticItemRuntimeId=e.getPlanElement().getId());let n=In(e);const i=(async()=>{const r={};if(e instanceof $&&(r.item=e.getRapiItem(),r.staticItemRuntimeId=e.getPlanElement().getId()),e instanceof F){await e.isInitDone();const o=e.getConfigurationRuntimeId();this._getKernelAccess().updatePlanObjectDependencies(o);const l=e.getPlanObject().getCatalogItemId();let h=l;h||(h=this._getKernelAccess().kernelInstance.getHashOfConfiguration(o));const d=this._getKernelAccess().kernelInstance.isExternalPlanObject(o);if(d){const g=this.getRootPlanObjectId(e.getId()),p=this._getViewModel().getPlanObjectForId(g);this._planObjectSelectionChanged(p.getConfigurationRuntimeId(),e.getRootComponentRuntimeId())}this._configuratorContext.planObjectId=o,this._configuratorContext.planElementId=e.getId(),this._configuratorContext.rootComponentId=e.getRootComponentRuntimeId();let u;if(!d)if(l&&de(l)){const g=await this._rapiAccess.getItem(l);r.item=g,u=g.rootComponentId?g.rootComponentId:null}else try{const g=await this._rapiAccess.getConfiguration(h);r.configuration=g,u=g.rootComponentId?g.rootComponentId:null}catch{console.warn("Could not get RAPI configuration for kernel hash "+h+", saving configuration...");const p=await this._getKernelAccess().getConfigurationData(o),_=await this._rapiAccess.saveConfiguration(p);r.configuration=_,u=_.rootComponentId?_.rootComponentId:null}if(u){const g=await this._rapiAccess.getComponent(u);r.component=g}r.configurationRuntimeId=o,n="configuration"}return r.planElementId=e.getId(),he(r)})();if(this.currentSelection=he(t),this._sendElementMeasurements(),this._sendPlanObjectPositions(),e instanceof F){const r=e.getConfigurationRuntimeId();r&&r!==-1&&this._getKernelAccess().kernelInstance.isExternalPlanObject(r)&&(n="external-configuration",t.externalConfigurationType="tc-config")}this._roomlePlannerUiCallback.onSelectionChange(he(this._plannerSceneEventHandler.getSelectionMode()),he(n),he(t),i,e),(e instanceof L||e instanceof Y)&&(this._getViewModel().getNodePlanObjectViewModels().forEach(r=>r.show()),this._updateNodeSize()),this._renderWithoutShadowsAndAO()}_onSelectionCancel(e,t){this._getViewModel().getNodePlanObjectViewModels().forEach(n=>n.hide()),this._renderWithoutShadowsAndAO(),this.resetConfiguratorContext(t),this.cancelComponentSelection(!1,t),this._handleMeasurementLineDraggablePoints(e),this.currentSelection=null}_handleMeasurementLineDraggablePoints(e){this._getViewModel().getMeasurementLineObjectViewModels().forEach(t=>{t.hideDraggableNodes(),t.deselectAllDraggablePoints()}),e instanceof k&&(e.deselectAllDraggablePoints(),e.currentPoint=null)}resetConfiguratorContext(e){try{this._configuratorContext.planObjectId&&this.getPlanObject(this._configuratorContext.planElementId).configurationType?.value===Q.EXTERNAL&&this.notifyPlannerOnComponentSelectionCancel(!0,e)}catch(t){console.error(t)}this._configuratorContext.planObjectId=0,this._configuratorContext.planElementId=0,this._configuratorContext.rootComponentId=0,this._configuratorContext.dockingRootComponentId=0}_setupScene(e,t){super._setupScene(e,t,!0),this._initData.legacyLight&&(this._lightSetting=new Pn(this._scene,this._lightSetting)),this._initData.moc||this._addSky(),t||this._setEnvironment(new ln(this._scene,this._environment,St(this._initData.colors.DEFAULT_BACKGROUND)))}onBeforeRender(){this.cameraBehaviour.cameraControl instanceof U&&Te(this.cameraBehaviour.cameraControl.getCamera(),this._getViewModel().getWallPlanObjectViewModels())&&this._roomleRenderer?.forceShadowUpdates(!0)}_getInputManager(){return this._plannerInputManager}createCameraControl(e,t){this.setMode(e)}startViewing(){this._configuratorContext.baseContext=C.GLB_VIEWER;const e=this._plannerSceneEventHandler.getSelectedIds();if(e.length===1){const t=this._getViewModel().getPlanObjectForId(e[0]);this._setCameraPosition();const n=this.cameraBehaviour.cameraControl.getCurrentCameraParameters();this._changeCameraBehaviour(new Cn(this._getCameraControl3D(n),this._cameraBehaviourState)),this.cameraBehaviour.cameraControl instanceof U&&this.cameraBehaviour.cameraControl.setObjectRotation(t.getPlanElement().rotation),this._configureInRoom||this._getViewModel().hideAllExcept(t.getId()),this.cameraBehaviour.updateCameraOnItemLoaded(this.getBounds()).then(()=>{this.updateEnvironment(this.getBounds(),!0)})}this.disablePlannerEvents(),this.updateScene()}startConfiguring(){this._configuratorContext.baseContext=C.CONFIGURATOR;let{planElementId:e}=this._configuratorContext;e=this.getRootPlanObjectId(e),this._configuratorContext.planElementId!==e&&this.selectPlanObject(e),this._selectExternalObjectModule();const t=this._getViewModel().getPlanObjectForId(e);this._getViewModel().toggleCeilingLights(!1,this._isInteriorLightActive),this._setCameraPosition();const n=this.cameraBehaviour.cameraControl.getCurrentCameraParameters();this._changeCameraBehaviour(new tt(this._getCameraControl3D(n),this._cameraBehaviourState));let a=0,i=0;if(t){this.setRootComponentId(t.getRootComponentRuntimeId());const l=t.getPlanElement().getRotationToPreferredFront();a=l.rotationRoundTo90deg,i=l.lookAtSide.value===Mt.LEFT?-1:1,this._componentRaycastHelper?.setObject(t.getObject())}const r=t?.getConfigurationRuntimeId();this._configuratorContext.planObjectId!==r&&(this._configuratorContext.planObjectId=r),this._plannerSceneEventHandler.removeSelection(),this._planElementHighlighter.clearHighlighting(),this._configureInRoom||this._getViewModel().hideAllExcept(e),this.configuratorCameraBehaviour.resetCameraOnStartConfiguring(this.getBounds(),n,a,i).then(()=>{this.updateEnvironment(this.getBounds(),!0)}),this.setEventHandlerObject(t.getContainer()),this.disablePlannerEvents(),this.enableConfiguratorEvents(),this._roomleRenderer?.switchToConfigurator(),this._imageRenderer.switchToConfiguratorSettings(),this.updateScene(),this._getKernelAccess().updatePlanObjectDependencies(r),this._getKernelAccess().requestPartListAndUpdatePricesOfParts(),this._getKernelAccess().planObjectUpdated(r,!1),this._plannerKernelAccess?.planInteractionHandler?.startInteraction()}_setCameraPosition(){this._cameraState=this.cameraBehaviour.cameraControl.getCurrentCameraParameters()}_resetCameraPosition(e){if(this.cameraBehaviour.cameraControl instanceof U){if(!this._cameraState)return;this.plannerCameraBehaviour.updateCameraOnBackToPlanner(this.getBounds(),e,this._cameraState)}}async selectPlanObject(e){if(this._plannerSceneEventHandler.getSelectedIds().includes(e))return;e=this.getRootPlanObjectId(e);const n=this._getViewModel().getPlanObjectForId(e);await this._plannerSceneEventHandler.selectPlanElement(n)}backToPlanner(){if(this._configuratorContext.baseContext===C.PLANNER)return;this._configuratorContext.baseContext===C.CONFIGURATOR&&(this._plannerKernelAccess?.planInteractionHandler?.endInteraction(),this._getKernelAccess().kernelInstance.getPlanObject(this.currentSelection?.configurationRuntimeId??0)?.externalObject&&this.notifyPlannerOnComponentSelectionCancel(!0,"isolation_mode_cancelled")),this._configuratorContext.baseContext=C.PLANNER,this._getViewModel().toggleCeilingLights(!0,this._isInteriorLightActive);const e=this.cameraBehaviour.cameraControl.getCurrentCameraParameters(),t=this._getViewModel().cameraType;this._changeCameraBehaviour(t===b.CAMERA_3D||t===b.CAMERA_FP?new Re(this._getCameraControl3D(e),this._cameraBehaviourState):new On(this._getCameraControl2D(),this._cameraBehaviourState)),this._resetCameraPosition(e),this._getViewModel().showAll(),this.setEventHandlerObject(this._scene),this.enablePlannerEvents();const n=this.cameraBehaviour.cameraControl instanceof U||this.cameraBehaviour.cameraControl instanceof te;this._getViewModel().setCameraType(n?b.CAMERA_3D:b.CAMERA_2D),this.disableConfiguratorEvents(),this._roomleRenderer?.switchToPlanner(this.cameraBehaviour.cameraControl instanceof U?ce.Mode3D:ce.Mode2D),this._imageRenderer.switchToPlannerSettings(),this.updateScene()}_getYRotationOfObject(e){let t=e.getWorldDirection(new S).clone();t.y=0,t.lengthSq()<.01&&(t=new S(0,1,0),t.applyQuaternion(e.quaternion),t.y=0),t.normalize();let n=Math.asin(t.x);return t.z<0&&(n=Math.PI-n),n<0&&(n+=Math.PI*2),n}loadStaticPlanObjects(){const e=new Map;this._getViewModel().getStaticPlanObjectViewModels().forEach(t=>{const n=t.getPlanObject();e.has(n.getCatalogItemId())?e.get(n.getCatalogItemId()).push(t):e.set(n.getCatalogItemId(),[t])}),this._rapiAccess.getItems(Array.from(e.keys())).then(t=>{const n=[];t.forEach(a=>{this._getKernelAccess().catalogItemLoaded(a),e.get(a.id).forEach(i=>{n.push(new Promise((r,o)=>{i.setRapiItem(a).then(()=>{this._requestRender(),r()},o)}))})}),Promise.all(n).then(()=>this._staticItemsLoaded())})}requestCatalogItem(e){this._rapiAccess.getItem(e).then(t=>{this._getKernelAccess().catalogItemLoaded(t)})}_staticItemsLoaded(){this._requestRender(),this._staticItemGuard.resolve(),this._roomlePlannerUiCallback.onItemsLoaded()}preload(e){this._planId=e;const t=this._localStorageHelper.getItem(this._planId,$n);t&&this._loadGLTF(t).then(n=>{this._preloadScene=n,this._preloadScene&&this._scene.add(this._preloadScene),this._requestRender()})}planXMLLoaded(e){this.endPlanConstruction(e),this.loadStaticPlanObjects()}_activateCeilingLight(){this._getViewModel().handleInitialLights(this._renderer.capabilities.maxTextures,this._roomleRenderer.sceneRenderer.getQualityLevel()),this._getViewModel().handleCeilingLights()}planCompletelyLoaded(e){this._stopRendering=!1,this._renderEverything(),setTimeout(()=>this._planCompletelyLoadedGuard.resolve(),0),this._isInteriorLightActive&&this._activateCeilingLight(),this._getViewModel().getNodePlanObjectViewModels().forEach(t=>t.hide()),this._getViewModel().getMeasurementLineObjectViewModels().forEach(t=>t.hideDraggableNodes())}handlerSwitchedPlans(e,t){if(this._completelyLoaded=!1,this._roomlePlannerUiCallback.onHandlerSwitchedPlans(),this._getViewModel().setReference(t),this._getKernelAccess().coupleReferences(this._getViewModel(),t),this._getViewModel().setPlannerSceneEventHandler(this._plannerSceneEventHandler),this._getViewModel().setGeometriesMergedListener(()=>{this._renderEverything()}),this._plannerSceneEventHandler.setPlanViewModel(this._getViewModel()),e&&this.clearScene(),!this._initData.moc){this._addSky();const a=new xe(1e3,1e3);a.rotateX(-Math.PI/2);const i=Et.createMeshStandardMaterial({color:"#f0f0f0",roughness:1,metalness:0,depthWrite:!1}),r=new M(a,i);r.name="Ground",r.position.y=-.01,r.userData.isFloor=!0,this._scene.add(r)}this._setCeiling(),this._staticItemGuard.reset(),this._configurableItemGuard.reset(),this._planCompletelyLoadedGuard.reset();const n=this._plannerMeshGenerator.materialQueue.length>0?this._configurableItemGuard.wait():Promise.resolve();Promise.all([this._staticItemGuard.wait(),n,this._planCompletelyLoadedGuard.wait()]).then(this._itemsLoaded.bind(this))}async _itemsLoaded(){const e=this._getViewModel().getCorePlan();if(this._roomleRenderer){const t=yt(e.getBounds());this._roomleRenderer.updateBounds(t),this._imageRenderer.updateBounds(t)}await Promise.allSettled(this._itemsLoadingStatePromises),this._roomlePlannerUiCallback.onCompletelyLoaded(),this.updateEnvironment(this.getBounds(),!0),this._renderEverything(),this._configuratorContext.baseContext===C.PLANNER&&this.plannerCameraBehaviour.resetCameraOnPlanCompletelyLoaded(this.getBounds()),this._completelyLoaded=!0,this._readyForRender()}beginPlanConstruction(e){}addPlanMesh(e,t,n,a,i,r,o){}endPlanConstruction(e){this._renderLoopFunction=()=>{this._scene.add(this._getViewModel().getConstructionGroup()),this._scene.add(this._getViewModel().getCeilingGroup()),this._scene.add(this._getViewModel().getFloorGroup()),this._scene.add(this._getViewModel().getMeasurementLineGroup()),this._scene.add(this._getViewModel().getWallAtticsGroup()),this._isInteriorLightActive&&this._createCeilingLightGroup(),this._lightSetting?.needsBounds()&&this._lightSetting.updateBounds(this._getViewModel().getBoundingBox()),this._scene.remove(this._preloadScene)}}async addPlanObjectToScene(e){if(!e)return Promise.resolve();let t,n;try{const a=new Promise((h,d)=>(t=h,n=d));this._itemsLoadingStatePromises.push(a);const i=e.getContainer();Dt(i),this._scene.add(i),this._plannerSceneEventHandler.isDragIn()&&(this._plannerSceneEventHandler.addComponentDragInHandler(e),this._requestRender()),this._roomlePlannerUiCallback.onPlanChanged(),await e.isInitDone(),this.updateEnvironment(this.getBounds()),this._renderEverything();const r=this.getPlanObject(e.getId());let o;r&&(o=await ge([r],this._plannerKernelAccess,this._rapiAccess)),this._roomlePlannerUiCallback.onPlanElementChanged(ee.ADDED,o.length?o[0]:{...r,data:null});const l=e instanceof F||e instanceof $;this._initData.featureFlags.interiorLights&&Tn(e,this._getViewModel(),this._isInteriorLightActive),l&&!this._plannerSceneEventHandler.isDragIn()&&this.cameraBehaviour instanceof Ae&&(At(this.cameraBehaviour.cameraControl.getCamera(),e.getBounds())?this.plannerCameraBehaviour.updateCameraOnPlanElementInsertedInsideCurrentCameraView(this.getBounds()):this.plannerCameraBehaviour.updateCameraOnPlanElementInsertedOutsideCurrentCameraView(this.getBounds()))}catch(a){console.error(a),n()}t()}removePlanObjectFromScene(e){(e instanceof L||e instanceof Y)&&this._sendWallDimensions(),e instanceof k&&this._sendMeasurementLineDimension(),this._scene.remove(e.getContainer()),e.clear(),this.updateEnvironment(this.getBounds(),!0),!(e instanceof L||e instanceof k||e instanceof Y)&&this._configuratorContext.baseContext===C.PLANNER&&this.plannerCameraBehaviour.updateCameraOnPlanElementRemoved(this.getBounds()),this._renderEverything()}planElementChanged(e,t){this._drawingEnabled&&this._sendWallDimensions(!1);const n=this._plannerSceneEventHandler.isDragIn()?t:null;if(this._sendElementMeasurements(n),this._sendRoomAreaData(),this.updateEnvironment(this.getBounds(),!0),this._renderEverything(),this._onPlanChanged(),!this._plannerSceneEventHandler.isDragIn()){const a=this.getPlanObject(t.getId());this._roomlePlannerUiCallback.onPlanElementChanged(ee.MOVED,{...a,data:null})}t instanceof L&&e.extRef&&e.extRef.jsObject&&this._isInteriorLightActive&&e.extRef.jsObject.handleCeilingLights()}exportGLB(e,t){}importGLB(e){this._loadGLB(e).then(t=>this._scene.add(t))}clearScene(){this._plannerMeshGenerator.clear(),this._getViewModel().sceneCleared(),super.clearScene()}_addSky(){const e={distance:4e5,turbidity:10,rayleigh:2,mieCoefficient:.005,mieDirectionalG:.8,inclination:.6,azimuth:0};if(!this._sky){this._sky=new We,this._sky.name="Sky",this._sky.scale.setScalar(45e4),this._sky.frustumCulled=!1,this._scene.add(this._sky),this._sky.material.uniforms.turbidity.value=e.turbidity,this._sky.material.uniforms.rayleigh.value=e.rayleigh,this._sky.material.uniforms.mieCoefficient.value=e.mieCoefficient,this._sky.material.uniforms.mieDirectionalG.value=e.mieDirectionalG;const t=Rt(e.distance,e.azimuth,e.inclination);this._sky.material.uniforms.sunPosition.value.copy(t);const n=new M(new ve(2e4,16,8),new T({color:16777215}));n.name="Sunsphere",n.position.y=-7e5,n.visible=!1,n.position.set(t.x,-t.z,t.y)}this._lightSetting instanceof Pn&&this._lightSetting.updateSunPosition(e.inclination,e.azimuth)}toggleConfigureInRoom(){this._configureInRoom=!this._configureInRoom,this._roomleRenderer.isConfiguring&&(this._configureInRoom?this._getViewModel().showAll():this._hideAllExceptSelectedElement(),this._renderEverything(),this.updateScene())}switchTo2D(){if(!(this.cameraBehaviour?.cameraControl instanceof N)){this.cameraBehaviour?.cameraControl instanceof te&&this._getCameraControlFirstPerson().cleanUp(),this._roomleRenderer?.setCameraType(b.CAMERA_2D),this._plannerSceneEventHandler?.enable();for(const e of this._getViewModel().getWallPlanObjectViewModels())e.show();this._getViewModel().setCameraType(b.CAMERA_2D).then(()=>this._planElementHighlighter.highlightPlanElement()),this._roomleRenderer?.switchToPlanner(ce.Mode2D),this._renderEverything(),this._changeCameraBehaviour(new On(this._getCameraControl2D(),this._cameraBehaviourState)),this._onCameraMove(),this.plannerCameraBehaviour.resetCameraOnSwitchTo2d(this.getBounds()),this._addCameraControlListener(),this._setCeiling(),this._roomlePlannerUiCallback.onCameraChanged(b.CAMERA_2D),this._setKernelZoomFactor(),this._onCameraMove(),this._sendRoomMeasurements()}}switchTo3D(){this.cameraBehaviour?.cameraControl instanceof U||(this._roomleRenderer?.setCameraType(b.CAMERA_3D),this._plannerSceneEventHandler?.enable(),this._getViewModel().setCameraType(b.CAMERA_3D),this._roomleRenderer?.switchToPlanner(ce.Mode3D),this._renderEverything(),this._changeCameraBehaviour(new Re(this._getCameraControl3D(),this._cameraBehaviourState)),this._onCameraMove(),this.plannerCameraBehaviour.resetCameraOnSwitchTo3d(this.getBounds()),this._addCameraControlListener(),this._setCeiling(),this._roomlePlannerUiCallback.onCameraChanged(b.CAMERA_3D))}switchToFirstPerson(){this.cameraBehaviour?.cameraControl instanceof te||(this._roomleRenderer?.setCameraType(b.CAMERA_FP),this._plannerSceneEventHandler?.disable(),this._plannerMeshGenerator.wallMeshes.forEach(e=>Lt(e.material,!1,!1)),this._getViewModel().getWallPlanObjectViewModels().forEach(e=>{e.show()}),this._getViewModel().setCameraType(b.CAMERA_FP),this._renderEverything(),this._changeCameraBehaviour(new Fn(this._getCameraControlFirstPerson(),this._cameraBehaviourState)),this._addCameraControlListener(),this._setCeiling(),this._roomlePlannerUiCallback.onCameraChanged(b.CAMERA_FP),this.plannerCameraBehaviour.resetCameraOnSwitchToFirstPerson())}onCameraChanged(){}_setCameraControlListeners(){super._setCameraControlListeners(),this.cameraBehaviour instanceof Ae&&(this.cameraBehaviour.cameraControl.addEventListener(ne.IDLE,()=>{this._onCameraIdle()},this),this.cameraBehaviour.cameraControl.addEventListener(ne.ORBIT_MOVE,()=>{this._onCameraMove()},this),this.cameraBehaviour.cameraControl.addEventListener(ne.MOVING,()=>{this._onCameraMove()},this),this.cameraBehaviour.cameraControl.addEventListener(ne.ZOOM_IN,()=>{this._onCameraMove()},this),this.cameraBehaviour.cameraControl.addEventListener(ne.ZOOM_OUT,()=>{this._onCameraMove()},this),this.cameraBehaviour.cameraControl.addEventListener(ne.ZOOM_CHANGE,()=>{this._onCameraZoomChange()},this))}_onCameraZoomChange(){this._setKernelZoomFactor()}_setKernelZoomFactor(){const e=this.cameraBehaviour.cameraControl.getKernelZoomFactor();e&&isFinite(e)&&e>=0&&this._getKernelAccess().planInteractionHandler?.setZoomFactor(e),this._plannerSceneEventHandler?.setKernelZoomFactor(e)}_setCeiling(){this._getViewModel()&&(this.cameraBehaviour.cameraControl instanceof te?this._getViewModel().getCeilingGroup().visible=!0:this._getViewModel().getCeilingGroup().visible=!1)}cameraBehaviourChanged(){super.cameraBehaviourChanged(),this._plannerSceneEventHandler?.setCamera(this.cameraBehaviour.cameraControl.getCamera()),this._updatePaperBackground()}_updatePaperBackground(){this.cameraBehaviour.cameraControl instanceof N?(this._paperBackground||(this._paperBackground=new Gn),this._scene?.add(this._paperBackground),this._requestRender()):this._paperBackground&&this._scene?.remove(this._paperBackground)}sceneChanged(){this._plannerSceneEventHandler&&this._plannerSceneEventHandler.setObject(this._scene)}_onKeyDown(e){if(super._onKeyDown(e),this._initData.debug&&this._checkNumKey(e),this._checkCopyPaste(e),this._checkUndoRedo(e),Se(e)){const t=wn(e),n=e.metaKey&&e.key==="Meta"||e.ctrlKey&&e.key==="Control",a=t>1?E.STANDARD:n?E.MULTISELECT:E.STANDARD;this._plannerSceneEventHandler.setSelectionMode(a)}this._checkPanning(e),this._plannerSceneEventHandler&&this._plannerSceneEventHandler.hasSelection()&&e.key&&(e.key==="Backspace"||e.key==="Delete")&&(this.deletePlanElementSelection(),e.preventDefault())}async _checkCopyPaste(e){if(Se(e)&&e.key==="c"){const t=this._plannerSceneEventHandler.getSelectedIds(),n=[];t.forEach(a=>{const r=this._getViewModel().getPlanObjectForId(a).getPlanElement(),o=r.getCatalogItemId()||r.getConfigurationHash();n.push(o)}),Ne.copy(n.join())}if(Se(e)&&e.key==="v"){const t=await Ne.paste();if(t){const a=t.split(",").map(i=>jt(i)||i).filter(i=>i.includes(":"));this._insertRapiItems(a)}}}_checkPanning(e){(e.shiftKey===!0||e.key&&e.key.includes("Shift"))&&this.cameraBehaviour.cameraControl instanceof U&&(this.cameraBehaviour.cameraControl.enablePanning(),e.preventDefault())}_onMouseDown(e){"event"in e&&this._checkPanning(e.event)}_checkNumKey(e){e.key&&e.key==="1"&&(this.switchTo2D(),e.preventDefault()),e.key&&e.key==="2"&&(this.switchTo3D(),e.preventDefault()),e.key&&e.key==="3"&&(this.switchToFirstPerson(),e.preventDefault())}_onKeyUp(e,t=!1){if(super._onKeyUp(e,t),Se(e,!0)){const n=wn(e);let a=E.STANDARD;!xt(e)&&n===1&&(a=E.MULTISELECT),this._plannerSceneEventHandler.setSelectionMode(a),e.preventDefault()}e.key&&e.key.includes("Shift")&&this.cameraBehaviour.cameraControl instanceof U&&(this.cameraBehaviour.cameraControl.disablePanning(),e.preventDefault()),e.key&&(e.key==="Escape"||e.key==="Esc")&&(this._drawingEnabled&&(this.escapeDrawing(!0),this._roomlePlannerUiCallback.onDrawCancel()),this.cancelDragIn())}async undo(){const e=this._getKernelAccess().planInteractionHandler;return e.cancelDrawing(),e.undo(),this.cancelPlanElementSelection("undo"),Promise.resolve()}async redo(){return this._getKernelAccess().planInteractionHandler.redo(),this.cancelPlanElementSelection("redo"),Promise.resolve()}setMode(e){switch(e){case b.CAMERA_2D:this.switchTo2D();break;case b.CAMERA_3D:this.switchTo3D();break;case b.CAMERA_FP:this.switchToFirstPerson();break}}_clearHighlighting(){this._planElementHighlighter.clearHighlighting(),this._renderWithoutShadowsAndAO()}highlightPlanElementsById(e){if(e===null){this._clearHighlighting();return}this._planElementHighlighter.highlightPlanElements(e)}highlightPlanElementById(e){if(e===null){this._clearHighlighting();return}e=this.getRootPlanObjectId(e);const t=this._getViewModel().getPlanObjectForId(e);this._planElementHighlighter.highlightPlanElement(t)}destroy(){super.destroy(),this._plannerMeshGenerator.removeMaterialLoadedListener(),this._getViewModel().removeGeometriesMergedListener()}planObjectConfigurationLoaded(e,t,n){if(n||console.error("Plan object configuration loading failed",t.getCatalogItemId()||t.getConfigurationHash()),e&&e.extRef&&t&&t.extRef){const i=t.extRef.jsObject.getPlanObject().getConfigurationRuntimeId();i>0&&this._getViewModel().constructComponents(i)}}async planObjectConfigurationChanged(e,t){const n=this.getPlanObject(t.getId());let a;n&&!(t instanceof F)&&!(t instanceof Z)&&(a=await ge([n],this._plannerKernelAccess,this._rapiAccess)),this._roomlePlannerUiCallback.onPlanElementChanged(ee.CHANGED,a?.length?a[0]:{...n,data:null})}addMesh(e,t,n,a,i,r){}updateCameraOnDrawWalls(){this.plannerCameraBehaviour.updateCameraOnDrawWalls(this.getBounds())}getBounds(){return this._getViewModel()?this._getViewModel().getBoundingBox():null}getGeometryBounds(){return this._configuratorContext.baseContext===C.CONFIGURATOR?super.getGeometryBounds():this.getBounds()}getPlanObject(e){const t=this._getKernelAccess().planInteractionHandler,n=this._plannerKernelAccess.planModelViewHelper,a=t.getPlan();return n.getPlanObject(a,e)}getRootPlanObjectId(e){if(!this._plannerKernelAccess?.kernelContainer)return e;const t=this._getKernelAccess().planInteractionHandler,n=this._plannerKernelAccess.planModelViewHelper,a=t.getPlan();return n.getRootPlanObjectId(a,e)}cancelPlanElementSelection(e){this._plannerSceneEventHandler.cancelSelection(e),this._planElementHighlighter.clearHighlighting(),this._requestRender()}async deletePlanElements(e){this.cancelPlanElementSelection("delete_object");const t=this._getKernelAccess().planInteractionHandler;t.startInteraction(),await this.deletePlanElementByIds(e),t.endInteraction()}async deletePlanElementSelection(){const e=this._plannerSceneEventHandler.getSelectedIds();await this.deletePlanElements(e)}async deletePlanElementByIds(e){for(const t of e){const n=this._getViewModel().getPlanObjectForId(t);if(n&&n.getObject()){const a=this.getPlanObject(n.getId());let i;a&&(i=await ge([a],this._plannerKernelAccess,this._rapiAccess)),this._roomlePlannerUiCallback.onPlanElementChanged(ee.REMOVED,i.length?i[0]:{...a,data:null}),this._getKernelAccess().planInteractionHandler.removeElement(n.getKernelObject())}}}rotatePlanElements(e,t){const n=new(this._getKernelAccess()).kernelContainer.PlanObjectPtrList,a=new oe;let i={x:0,y:0,z:0};if(e.forEach(r=>{const o=this._getViewModel().getPlanObjectForId(r);o&&o.getObject()&&(i=o.getPlanElement().getCenter(),n.push_back(o.getPlanElement()),a.expandByObject(o.getContainer()))}),n.size()>1){const r=a.getCenter(new S);i=w(r)}this._getKernelAccess().planInteractionHandler.rotateObjectsBy(n,t,i)}rotatePlanElementSelection(e){const t=this._plannerSceneEventHandler.getSelectedIds();this.rotatePlanElements(t,e)}planBoundsChanged(){this.updateEnvironment(this.getBounds()),this._requestRender()}planElementRemoved(e){this._configuratorContext.planElementId===e.getId()&&(this._roomlePlannerUiCallback.onSelectionCancel("delete_object"),this._configuratorContext.planElementId=0),this._onPlanChanged(),this._renderEverything()}_onPlanChanged(){this._roomlePlannerUiCallback.onPlanChanged()}prepareTopImage(e={},t){return this._configuratorContext.baseContext===C.CONFIGURATOR&&t?super.preparePerspectiveImage(e):new Promise(n=>{this._getViewModel().materialQueue.finished(!0).then(async()=>{const a=e.runtimeIds?Me.getCameraTargetForBBox(this._getViewModel().getBoundingBoxFromRuntimeIds(e.runtimeIds),.1):this._calculateBoundingBoxOfAllMeshes(.1);this._lightSetting?.removeFromScene();const i=[];if(this.cameraBehaviour.cameraControl instanceof U){await this._getViewModel().setCameraType(b.CAMERA_2D),this._getViewModel().setNodeVisibility(!1);for(const o of this._getViewModel().getWallPlanObjectViewModels())o.isVisible()||i.push(o),o.show()}e.runtimeIds&&this._getViewModel().hideAllExceptRuntimeIds(e.runtimeIds);const r=await this._imageRenderer.prepareTopImage(this._scene,null,a,e);if(e.runtimeIds&&this._getViewModel().showAll(),this.cameraBehaviour.cameraControl instanceof U&&await this._getViewModel().setCameraType(b.CAMERA_3D),i.length)for(const o of i)o.hide();this._lightSetting?.addToScene(),this._roomleRenderer?.clearCache(),this._requestRender(),n(r)})})}preparePerspectiveImageOf(e,t={}){const n=this._getViewModel().getPlanObjectForId(e);if(!n){const a="Object with runtimeId "+e+" not found";throw console.warn(a),new Error(a)}return this._preparePerspectiveImage({...t,object:n.getObject().clone()})}async _waitForAssets(){await super._waitForAssets(),await this._getViewModel().materialQueue.finished(!0)}_preparePerspectiveImage(e={},t){if(this._configuratorContext.baseContext===C.CONFIGURATOR&&t)return super.preparePerspectiveImage(e);const n=this._handlePlannerIsolationModeState(t);return new Promise((a,i)=>{this._getViewModel().materialQueue.finished(!0).then(async()=>{let r;this.cameraBehaviour.cameraControl instanceof U?r=this.cameraBehaviour.cameraControl.getCamera().clone():(r=this.getPerspectiveOffsetCamera().clone(),this._getViewModel().getCeilingGroup().visible=!1,r.layers.enableAll(),this._getViewModel().setCameraType(b.CAMERA_3D)),r.resetOffset();const o=e.object?Me.getCameraTargetForBBox(new oe().setFromObject(e.object)):e.runtimeIds?Me.getCameraTargetForBBox(this._getViewModel().getBoundingBoxFromRuntimeIds(e.runtimeIds)):this._calculateBoundingBoxOfAllMeshes();this._lightSetting?.removeFromScene();const l=e.object?Ht(this._scene):this._scene;e.object&&l.add(e.object),e.runtimeIds&&this._getViewModel().hideAllExceptRuntimeIds(e.runtimeIds);const h=await this._imageRenderer.preparePerspectiveImage(l,null,r,o,e,void 0,d=>{Te(d,this._getViewModel().getWallPlanObjectViewModels())});Ye(r),e.runtimeIds&&this._getViewModel().showAll(),e.object&&Ye(l),this.cameraBehaviour.cameraControl instanceof N?(this._getViewModel().setCameraType(b.CAMERA_2D),this._getViewModel().getWallPlanObjectViewModels().forEach(d=>d.show())):Te(this.cameraBehaviour.cameraControl.getCamera(),this._getViewModel().getWallPlanObjectViewModels()),this._lightSetting?.addToScene(),this._roomleRenderer?.clearCache(),this._requestRender(),this._setCeiling(),n(),a(h)},i)})}_handlePlannerIsolationModeState(e){if(!e){const t=this._configuratorContext.baseContext;return this._getViewModel().showAll(),this._configuratorContext.baseContext=C.PLANNER,()=>{this._configuratorContext.baseContext=t,t===C.CONFIGURATOR&&(this._configureInRoom||this._hideAllExceptSelectedElement())}}return()=>null}_hideAllExceptSelectedElement(){const{planElementId:e}=this._configuratorContext,t=this.getRootPlanObjectId(e);this._getViewModel().hideAllExcept(t)}preparePerspectiveImage(e={},t){return this._preparePerspectiveImage(e,t)}_calculateBoundingBoxOfAllMeshes(e=0){const t=this.getBounds();return Me.getCameraTargetForBBox(t,e)}enableRotation(){this._plannerSceneEventHandler.setState(ie.ROTATE)}disableRotation(){this._plannerSceneEventHandler.resetState()}enableSnapping(){this._plannerSceneEventHandler.enableSnapping()}disableSnapping(){this._plannerSceneEventHandler.disableSnapping()}enableAdvancedDocking(){this._plannerSceneEventHandler.enableAdvancedDocking()}disableAdvancedDocking(){this._plannerSceneEventHandler.disableAdvancedDocking()}showsChildrenOfPlanObject(e){if(e instanceof F){const t=e.getKernelObject();return this._plannerSceneEventHandler.showsChildrenOfPlanObject(t)}return!1}enableShowChildrenOfPlanObject(e){if(e instanceof F){const t=e.getKernelObject();this._plannerSceneEventHandler.enableShowChildrenOfPlanObject(t)}}disableShowChildrenOfPlanObject(e){if(e instanceof F){const t=e.getKernelObject();this._plannerSceneEventHandler.disableShowChildrenOfPlanObject(t)}}dragIn(e){this._plannerSceneEventHandler.getSelectedIds().length>0&&this._plannerSceneEventHandler.cancelSelection("dragIn"),this._plannerSceneEventHandler.setDragIn(!0,e)}getPlannerSceneEventHandler(){return this._plannerSceneEventHandler}disablePlannerEvents(){this._plannerSceneEventHandler.disable()}enablePlannerEvents(){this._plannerSceneEventHandler.enable()}_onCameraIdle(){return super._onCameraIdle()&&(this._sendRoomMeasurements(),this._sendPlanObjectPositions(),this._roomlePlannerUiCallback.onCameraIdle(),this._sendElementMeasurements(),this._hideAllNodeIfThereAreNoSelections(),this._sendWallDimensions()),!0}_hideAllNodeIfThereAreNoSelections(){!this.currentSelection&&!this.getPlannerSceneEventHandler().isCurrentlyDrawing&&(this._getViewModel().getMeasurementLineObjectViewModels().forEach(e=>e.hideDraggableNodes()),this._getViewModel().getNodePlanObjectViewModels().forEach(e=>e.hide()))}_onCameraMove(){return super._onCameraMove()&&(this._roomlePlannerUiCallback.disableWallDimensions(),this._roomlePlannerUiCallback.cameraStartsMoving()),this._updateNodeSize(),this._renderEverything(),!0}_showWallNodes(){this._getViewModel().getNodePlanObjectViewModels().forEach(e=>e.show())}_updateNodeSize(){if(this.cameraBehaviour.cameraControl instanceof N){const e=1/this.cameraBehaviour.cameraControl.getCamera().zoom;this._getViewModel().setNodeZoom(e)}}_sendPlanObjectPositions(){if(this.cameraBehaviour.cameraControl.isLocked())return;const{clientWidth:e,clientHeight:t}=this._domHelper.element,n=this.cameraBehaviour.cameraControl.getCamera(),a=this._plannerSceneEventHandler.getSelectedIds();a.length>1?this._sendMultiSelectionPosition(a,n,e,t):this._sendSelectedPlanObjectPositions(n,e,t)}_sendMultiSelectionPosition(e,t,n,a){const i=new oe;for(const l of e){const h=this._getViewModel().getPlanObjectForId(l);h&&i.expandByObject(h.getContainer())}const r=i.getCenter(new S),o=Je(m(r,t,n,a));this._roomlePlannerUiCallback.onUpdatePlanObjectPositions([{runtimeIds:e,position2d:o}])}_sendSelectedPlanObjectPositions(e,t,n){const a=this._getViewModel(),i=[],r=[...a.getStaticPlanObjectViewModels(),...a.getConfigurablePlanObjectViewModels(),...a.getConfigurableConstructionPlanObjectViewModels(),...a.getConstructionPlanObjectViewModels(),...a.getWallPlanObjectViewModels(),...a.getFloorPlanObjectViewModels(),...a.getNodePlanObjectViewModels()];for(const o of r)i.push(Hn(o,e,t,n));this._roomlePlannerUiCallback.onUpdatePlanObjectPositions(i)}_sendRoomAreaData(){const e=this._getViewModel().getFloorPlanObjectViewModels(),t=this.cameraBehaviour.cameraControl.getCamera(),{clientWidth:n,clientHeight:a}=this._domHelper.element,i=[],r=this.cameraBehaviour.cameraControl.getKernelZoomFactor();this._initData.debug&&this._debugSpheres.floorPoints.children.length&&this._debugSpheres.floorPoints.clear();for(const o of e){const l=o.getFloorData(r);if(!l||!l.textPosition3d)return;if(l.roomLabel=o.getKernelObject().getLabelObject(),l.formattedArea=this._unitFormatter.formatSquareMMValueToUnitString(l.area),l.textPosition2d=m(l.textPosition3d,t,n,a),i.push(Tt(l)),this._initData.debug){const h=new ve(.1,32,16),d=new T({color:255}),u=new M(h,d);u.position.copy(l.textPosition3d),this._debugSpheres.floorPoints.add(u)}}i.length>0&&this._roomlePlannerUiCallback.onFloorPlanAreasUpdated(i)}_updateMeasurementPositions(e,t,n,a){return e.fromPosition3d&&(e.fromPosition2d=m(e.fromPosition3d,t,n,a)),e.toPosition3d&&(e.toPosition2d=m(e.toPosition3d,t,n,a)),e.textPosition3d&&(e.textPosition2d=m(e.textPosition3d,t,n,a)),e}_sendElementMeasurements(e){this.cameraBehaviour.cameraControl instanceof N&&(this._sendConstructionElementDimensions(e),this._sendObjectMeasurements(e),this._sendMeasurementLineDimension())}_sendRoomMeasurements(){this.cameraBehaviour.cameraControl instanceof N&&(this._sendWallDimensions(),this._sendRoomAreaData())}_sendMeasurementLineDimension(){if(!(this.cameraBehaviour.cameraControl instanceof N))return;const e=this.cameraBehaviour.cameraControl.getCamera(),{clientWidth:t,clientHeight:n}=this._domHelper.element,a=[],i=this._getViewModel().getMeasurementLineObjectViewModels();for(const r of i){const o=r.getMeasurementLineDimension();o.fromPosition2d=m(o.fromPosition3d,e,t,n),o.toPosition2d=m(o.toPosition3d,e,t,n),o.textPosition2d=m(o.textPosition3d,e,t,n),o.lengthFormatted=this._unitFormatter.formatMMValueToUnitString(o.length),a.push(kt(o))}this._roomlePlannerUiCallback.onUpdateMeasurementLineDimensions(a)}_sendObjectMeasurements(e){if(!(this.cameraBehaviour.cameraControl instanceof N)||!this.currentSelection&&!e)return;const t=this._plannerSceneEventHandler.getSelectedIds();if(t.length===0&&!e)return;const n=e||this._getViewModel().getPlanObjectForId(t[0]);if(!n||n instanceof Ie||n instanceof Z||!(n instanceof $)&&!(n instanceof F))return;const a=this.cameraBehaviour.cameraControl.getCamera(),{clientWidth:i,clientHeight:r}=this._domHelper.element,o=this.cameraBehaviour.cameraControl.getKernelZoomFactor(),l=n.getObjectMeasurements(o,i,r),h=this.transformMeasurements(l.rectMeasurements,a,i,r),d=this.transformMeasurements(l.objectMeasurements,a,i,r),u=this.transformMeasurements(l.objectToWallsMeasurements,a,i,r);this._roomlePlannerUiCallback.onUpdateObjectMeasurements({rectMeasurements:h,objectMeasurements:d,objectToWallsMeasurements:u})}transformMeasurements(e,t,n,a){return e.map(i=>{const r=m(i.fromPosition3d,t,n,a),o=m(i.toPosition3d,t,n,a),l=m(i.textPosition3d,t,n,a);return Bt({...i,fromPosition2d:r,toPosition2d:o,textPosition2d:l})})}_sendConstructionElementDimensions(e){if(!this.currentSelection&&!e)return;const t=e||this._getViewModel().getPlanObjectForId(this.currentSelection.staticItemRuntimeId||this.currentSelection.configurationRuntimeId);if(!t||!(t instanceof Ie||t instanceof Z))return;this._initData.debug&&this._debugSpheres.constructionElementsPoints.children.length>0&&this._debugSpheres.constructionElementsPoints.clear();const n=this.cameraBehaviour.cameraControl.getCamera(),{clientWidth:a,clientHeight:i}=this._domHelper.element,r=this.cameraBehaviour.cameraControl.getKernelZoomFactor(),o=t.getConstructionElementMeasurements(r,a,i);if(!o)return;if(this._initData.debug){const h=new T({color:16711680}),d=new T({color:65280}),u=new T({color:255}),g=new ve(.1,32,16),p=new M(g,h);p.position.copy(o.leftMeasurement.fromPosition3d),p.position.y=5;const _=new M(g,h);_.position.copy(o.leftMeasurement.toPosition3d),_.position.y=5;const v=new M(g,d);v.position.copy(o.rightMeasurement.fromPosition3d),v.position.y=5;const P=new M(g,d);P.position.copy(o.rightMeasurement.toPosition3d),P.position.y=5;const W=new M(g,u);W.position.copy(o.elementRange.fromPosition3d),W.position.y=5;const K=new M(g,u);K.position.copy(o.elementRange.toPosition3d),K.position.y=5,this._debugSpheres.constructionElementsPoints.add(p),this._debugSpheres.constructionElementsPoints.add(_),this._debugSpheres.constructionElementsPoints.add(v),this._debugSpheres.constructionElementsPoints.add(P),this._debugSpheres.constructionElementsPoints.add(W),this._debugSpheres.constructionElementsPoints.add(K)}o.leftMeasurement=this._updateMeasurementPositions(o.leftMeasurement,n,a,i),o.rightMeasurement=this._updateMeasurementPositions(o.rightMeasurement,n,a,i),o.elementRange=this._updateMeasurementPositions(o.elementRange,n,a,i);const l={leftMeasurement:{...ke(o.leftMeasurement)},rightMeasurement:{...ke(o.rightMeasurement)},elementRange:{...ke(o.elementRange)}};this._roomlePlannerUiCallback.onUpdateConstructionElementsMeasurements(l)}_sendWallDimensions(e=!0){this._initData.debug&&this._debugSpheres.wallPoints.children.length>0&&this._debugSpheres.wallPoints.clear(),Wn(this._domHelper,this.cameraBehaviour,this._roomlePlannerUiCallback,this._plannerSceneEventHandler,this._getViewModel(),this._unitFormatter,this._debugSpheres,e,this._initData.debug)}enableWallDrawing(){if(this.cameraBehaviour.cameraControl instanceof N){const e=we(this.getBounds(),this._domHelper.element.clientWidth,this._domHelper.element.clientHeight);this.plannerCameraBehaviour.resetCameraOnEnableWallDrawing(e)}this._drawingEnabled||(this._drawingEnabled=!0,this._scene.add(this._plannerSceneEventHandler.enableWallDrawing()))}disableWallDrawing(){this._drawingEnabled=!1,this.cameraBehaviour.cameraControl.unlock(),this._scene.remove(this._plannerSceneEventHandler.cancelWallDrawing())}escapeDrawing(e){this._plannerSceneEventHandler.stopDrawing(e)}cancelDragIn(){if(this._plannerSceneEventHandler.isDragIn()){const e=this._plannerSceneEventHandler.getSelectedIds();this._plannerSceneEventHandler.cancelSelection("delete_object"),this._plannerSceneEventHandler.setDragIn(!1),this._getInputManager().forceMouseUp(),this.deletePlanElements(e)}}setSceneEvents(e){this.cameraBehaviour.cameraControl instanceof te||(e.construction!==void 0&&this._plannerSceneEventHandler?.enableConstructionEvents(e.construction),e.objects!==void 0&&this._plannerSceneEventHandler?.enableObjectEvents(e.objects))}startedDrawing(){this._plannerSceneEventHandler.startDrawing(),this._showWallNodes()}stoppedDrawing(){this._plannerSceneEventHandler.stopDrawing()}disableEvents(){super.disableEvents(),this.disablePlannerEvents()}enableEvents(){super.enableEvents(),this._configuratorContext.baseContext===C.PLANNER&&!(this.cameraBehaviour.cameraControl instanceof te)&&this.enablePlannerEvents()}resetCameraPositionToStart(){this.plannerCameraBehaviour.externalApiResetCameraPosition(this.getBounds())}async moveCamera(e){return this.plannerCameraBehaviour instanceof Re||this.plannerCameraBehaviour instanceof tt?this.plannerCameraBehaviour.externalApiMoveCamera(e):Promise.resolve()}_setInteriorOrExteriorWallMaterial(e,t){const a=this._getViewModel().getWallPlanObjectViewModels();if(!a.length)return;const i=this._getKernelAccess().planInteractionHandler,r=g=>{i.setWallLeftMaterial(g,Be(g.leftMaterial,t))},o=g=>{i.setWallRightMaterial(g,Be(g.rightMaterial,t))},l=a.map(g=>g.getKernelObject()),h=this._plannerKernelAccess.kernelContainer.WallType.InnerWall,d=this._plannerKernelAccess.kernelContainer.WallType.OuterWallLeft,u=this._plannerKernelAccess.kernelContainer.WallType.OuterWallRight;for(const g of l)g.wallType===h&&e===je.INTERIOR&&(r(g),o(g)),g.wallType===d&&(e===je.INTERIOR?o(g):r(g)),g.wallType===u&&(e===je.EXTERIOR?o(g):r(g))}changeInteriorWallsMaterial(e){this._setInteriorOrExteriorWallMaterial(je.INTERIOR,e)}changeExteriorWallsMaterial(e){this._setInteriorOrExteriorWallMaterial(je.EXTERIOR,e)}changeFloorsMaterial(e){const n=this._getViewModel().getFloorPlanObjectViewModels();if(!n.length)return;const a=this._getKernelAccess().planInteractionHandler,i=n.map(r=>r.getKernelObject());a.startInteraction();for(const r of i)a.setFloorMaterial(r,Be(r.material,e));a.endInteraction()}getWallAngleDegrees(e){if(!(e instanceof L))return 0;const t=this.cameraBehaviour.cameraControl.getCamera(),n=new pe(t.position.x,t.position.z),i=new pe(e.getPosition().x,e.getPosition().z).clone().sub(n).normalize(),r=e.getKernelObject(),o=new pe(Math.sin(r.getAngle()),Math.cos(r.getAngle())),l=i.angle()-o.angle();return Gt.radToDeg(l)}moveElementPosition(e,t){const n=this._getKernelAccess().planInteractionHandler;n.setObjectFixedZ(e.getPlanElement(),!0);const a=e.getPlanElement().getCenter(),i=X(t).sub(X(a));n.moveElementBy(e.getPlanElement(),w(i)),n.setObjectFixedZ(e.getPlanElement(),!1),this._sendPlanObjectPositions()}moveElementsPosition(e,t){const n=new this._plannerKernelAccess.kernelContainer.PlanObjectPtrList,a=X(t).sub(e[e.length-1].getPosition());e.forEach(o=>n.push_back(o.getPlanElement()));const i=w(a);this._getKernelAccess().planInteractionHandler.moveObjectsBy(n,i),this._sendPlanObjectPositions()}get plannerCameraBehaviour(){return this.cameraBehaviour}enableMeasurementLineDrawing(){this._roomlePlannerUiCallback.onMeasurementLineStateChange(!0),this._plannerSceneEventHandler.enableMeasurementLineDrawing()}disableMeasurementLineDrawing(){this._plannerSceneEventHandler.disableMeasurementLineDrawing()}setCompletelyLoaded(e){this._completelyLoaded=e}enablePanning(){this.plannerCameraBehaviour instanceof Re&&this.plannerCameraBehaviour.enablePanningOnShiftClick()}disablePanning(){this.plannerCameraBehaviour instanceof Re&&this.plannerCameraBehaviour.disablePanningOnShiftRelease()}setObjectToWallMeasurementLength(e,t,n){const a=this._getViewModel().getPlanObjectForId(e),i=a.getPlanElement(),o=Ft(i.getWallDistances()).find(_=>Ut(_.angle+"_"+_.length)===t);if(!o)return;const l=X(o.startPoint),h=X(o.endPoint),d=l.clone().sub(h).normalize(),u=(n-o.length)/1e3,g=a.getPosition().clone().add(d.multiplyScalar(u));this._getKernelAccess().planInteractionHandler.moveElementTo(i,w(g)),this._sendObjectMeasurements()}setWallMeasurementLength(e,t,n){const a=this.getPlannerSceneEventHandler().isCurrentlyDrawing,i=this._getKernelAccess().planInteractionHandler;let r=this._getViewModel().getPlanObjectForId(e);const o=i.isVectorPreviewModeEnabled();if(a&&!o){const l=this._getViewModel().latestNodePlanObjectViewModel,h=w(l.getPosition());i.endDrawing(h),this.escapeDrawing(!1),r=this._getViewModel().latestWallPlanObjectViewModel}if(r){const l=r.getKernelObject();i.startInteraction(),i.setLengthOfWall(l,t,l.getPreferredSide(),n,!0),i.endInteraction()}if(a&&!o){i.startInteraction();const l=this._getViewModel().latestNodePlanObjectViewModel,h=w(l.getPosition());i.beginDrawing(h,!1),this._plannerSceneEventHandler.startDrawing()}}setMeasurementLineLength(e,t,n){const a=this._getViewModel().getPlanObjectForId(e);this._plannerSceneEventHandler.setMeasurementLineLength(a,t,n)}setEventHandlerObject(e){super.setEventHandlerObject(e),this._plannerSceneEventHandler.setObject(e)}_readyForRender(){console.log("ready_for_render"),this._roomlePlannerUiCallback.onReadyForRender(),this._globalCallback.onReadyForRender()}notifyPlannerOnComponentSelectionCancel(e,t){if(e)if(this.configuratorContext.baseContext===C.CONFIGURATOR){if(t==="click_outside"){const n=this.getObjectComponent(this.configuratorContext.rootComponentId??this.configuratorContext.planObjectId);this._roomlePlannerUiCallback.onExternalObjectModuleSelected(n.externalObjectGroupId,null,null)}}else this._roomlePlannerUiCallback.onExternalObjectSelectionCancel(t);else this._roomlePlannerUiCallback.onComponentSelectionCancel()}_planObjectSelectionChanged(e,t){const n=this.getObjectComponent(t??e);if(n?.configurationType?.value!==Q.EXTERNAL)return;const a=this.getObjectComponent(this.configuratorContext.selectedRuntimeComponentId??this.configuratorContext.planObjectId);a.externalRootModuleId===n.externalRootModuleId&&a.externalSubModuleId===n.externalSubModuleId||this._getKernelAccess().planObjectSelectionChanged(e,t)}highlightExternalObject(e){this.highlightPlanElementById(e.runtimeId),this._renderWithoutShadowsAndAO()}_selectExternalObjectModule(){this._getKernelAccess()?.kernelContainer&&!this._configuratorContext.selectedRuntimeComponentId&&this.getPlanObject(this._configuratorContext.planElementId).configurationType?.value===Q.EXTERNAL&&this.selectComponent(this._configuratorContext.rootComponentId)}getObjectComponent(e){const n=this._getKernelAccess().planInteractionHandler.getPlan();return this._getKernelAccess().planModelViewHelper.getObjectComponent(n,e)}getCameraParameters3d(){return this._getViewModel().cameraType===b.CAMERA_3D?this.cameraBehaviour3d.cameraControl.getCurrentCameraParameters():null}_createCeilingLightGroup(){this._scene.children.find(t=>t.name===mn)||this._scene.add(this._getViewModel().getCeilingLightsGroup())}toggleInteriorLightsSceneSettings(e){this._isInteriorLightActive=e;const t=this.getScene();t.userData.environmentDefinition.rotation=e?cn:Wt,t.userData.environmentDefinition.intensity=e?hn:Nt,this._isInteriorLightActive&&(this._createCeilingLightGroup(),this._activateCeilingLight()),this._renderEverything()}async _insertRapiItems(e){const t=e.map((a,i)=>({id:a,index:i})),n=[];for(const{index:a,id:i}of t)n.push({index:a,id:i});return await this.insertRapiObjects(n)}async insertRapiObjects(e){const t=({id:r})=>de(r)?this._rapiAccess.getItem(r):this._rapiAccess.getConfiguration(r),n=e.map(t),a=await Promise.all(n);return(await this._plannerKernelAccess.insertItems(a)).map((r,o)=>({runtimeId:r,originalIndex:e[o].index}))}}Le([f],ue.prototype,"_rapiAccess"),Le([f],ue.prototype,"_plannerMeshGenerator"),Le([f],ue.prototype,"_plannerInputManager"),Le([f],ue.prototype,"_roomlePlannerUiCallback"),Le([f],ue.prototype,"_localStorageHelper");var Jn=Object.defineProperty,x=(s,e,t,n)=>{for(var a=void 0,i=s.length-1,r;i>=0;i--)(r=s[i])&&(a=r(e,t,a)||a);return a&&Jn(e,t,a),a};const vn="Could not retrieve configuration for external object! Did you implement onGetConfigurationForExternalObject?",qn={left:0,top:1,right:1,bottom:0};class j{constructor(e,t){this._homagIntelligence=null,this._hscInstance=null,this._glbInstance=null,this._configurator=null,this._currentMode=1,this._creator_=e,this._activePlugins=t||[],this._kernelAccessCallback.addListener(this)}setEnvironmentMap(e){const{url:t,intensity:n,rotation:a,maxLightSources:i}=e;this._sceneManager.setEnvironmentMap(t,n,a,i)}deleteSelection(){this._sceneManager.deletePlanElementSelection()}rotateSelection(e){this._sceneManager.rotatePlanElementSelection(e)}cancelSelection(e="unknown"){this._sceneManager.cancelPlanElementSelection(e)}init(e,t,n){return Xe.start("loadingTime"),this._domHelper.setDomElement(e),this._sceneManager?(this._lifeCycleManager.resume(),Promise.resolve()):(this._preloadPlanId=t,this.setOverrides(n),new Promise(this._initPromiseCallback.bind(this)))}async createPlanFromObject(e,t,n){if(!this._planInteractionHandler)throw new Error("no plan interaction handler");t&&(t=w(new S(t.x,t.y,t.z)));const a=await(de(e)?this._rapiAccess.getItem(e):this._rapiAccess.getConfiguration(e));this._plan=this._plannerKernelAccess.createPlanFromObject(a,t,n),this._sceneManager.planXMLLoaded(this._plan),this._sceneManager.updateScene(),this.resetCameraPosition();const i=z(this._plan.getPlanObjects());return i?.length?i[0].getId():-1}loadPlanXml(e,t){return this._sceneManager.setCompletelyLoaded(!1),this.setOverrides(t),new Promise(n=>{this._plan=this._planInteractionHandler.loadPlanXML(e),this._sceneManager.planXMLLoaded(this._plan),this._roomlePlannerUiCallback.onTotalFloorAreaChanged(this._planInteractionHandler.getPlan().getTotalFloorArea()),this._currentMode=1,this._initData.moc&&(t.id?this._rapiAccess.trackView(t.id,Ge.ROOM_DESIGNER):this._rapiAccess.trackView("planXML",Ge.ROOM_DESIGNER)),n()})}loadPlan(e,t){return this.setOverrides(t),new Promise((n,a)=>{const i=Ze(e);(i?this._rapiAccess.getPlanSnapshot(e):this._rapiAccess.getPlan(e)).then(o=>{this._sceneManager.backToPlanner(),this._sceneManager.setCompletelyLoaded(!1);const l=i?o.plan:o.planObjects;this._plan=this._planInteractionHandler.loadPlanXML(l),this._sceneManager.planXMLLoaded(this._plan),this._roomlePlannerUiCallback.onTotalFloorAreaChanged(this._planInteractionHandler.getPlan().getTotalFloorArea()),this._configuratorContext.lastLoadedPlanId=e,this._currentMode=1,this._initData.moc&&this._rapiAccess.trackView(e,Ge.ROOM_DESIGNER),n(o)},a)})}setOverrides(e){e&&(this._initData.setOverrides(e),this._globalInitData.setOverrides(e))}toggleConfigureInRoom(){this._sceneManager.toggleConfigureInRoom()}switch2D(){this._sceneManager.switchTo2D()}switch3D(){this._sceneManager.switchTo3D()}switchToFirstPerson(){this._sceneManager.switchToFirstPerson()}resetCameraPosition(){this._sceneManager.resetCameraPositionToStart()}exportGLB(){this._sceneManager.exportGLB()}importGLB(e){this._sceneManager.importGLB(e)}_initPromiseCallback(e,t){this._kernelReadyCallback=e;const{dls:n,ls:a,mode:i,stats:r}=this._initData;this._sceneManager||(this._sceneManager=new ue(this._creator_,qn,this,i)),this._preloadPlanId&&this._sceneManager.preload(this._preloadPlanId);const o=Kt.createDynamicLightSettingSource(n,a);r&&this.showStats(),this._sceneManager.enableHD(o),this._planInteractionHandler&&this._kernelReadyCallback()}isReady(){this._planInteractionHandler=this._plannerKernelAccess.planInteractionHandler,this._kernelReadyCallback&&this._kernelReadyCallback()}showBenchmarks(){Xe.showBenchmarks()}getConfiguratorApi(){return this._configurator||(this._configurator=new zt(this._creator_,this._activePlugins),this._configurator.setOverrides(this._initData),this._configurator.initSceneManager(this._sceneManager)),this._configurator}startViewing(){this._sceneManager.startViewing(),this._roomlePlannerUiCallback.onContextChanged(C.GLB_VIEWER)}startConfiguring(){const e=this._sceneManager.currentSelection,t=e.item?.id||e.configuration?.id;this._sceneManager.startConfiguring(),t&&this._configurator.notifyUiAboutNewLabel(t),this._roomlePlannerUiCallback.onContextChanged(C.CONFIGURATOR)}async selectPlanObjectById(e){return this._sceneManager.selectPlanObject(e)}highlightPlanElements(e){e===null?this._sceneManager.highlightPlanElementsById(null):Array.isArray(e)?this._sceneManager.highlightPlanElementsById(e):this._sceneManager.highlightPlanElementById(e)}backToPlanner(){this._sceneManager.backToPlanner(),this._roomlePlannerUiCallback.onContextChanged(C.PLANNER)}showGUI(){this._sceneManager.showGUI()}async switchToConfigurator(){const e=await this._singlePromiseFactory.create(Qe.START_HSC,"startHSC",t=>{if(this._hscInstance)return t(this._hscInstance);re.import("./configurator-B01iJTNa.js").then(({Configurator:n})=>{const a=new n(this._creator_);a.boot({kernelInstance:this._planInteractionHandler.getConfiguratorKernel(),kernelContainer:this._plannerKernelAccess.kernelContainer}),a.getApi().setOverrides(this._initData),a.getApi().initSceneManager(this._sceneManager),a.getApi().init(this._domHelper.element).then(()=>{this._hscInstance=a,t(this._hscInstance)})})});return this._currentMode=0,this.cancelSelection("isolation_mode_started"),e}async switchToViewer(){const e=await this._singlePromiseFactory.create(Qe.START_GLB,"startGLB",t=>{if(this._glbInstance)return t(this._glbInstance);re.import("./glb-viewer-6_OVDzVH.js").then(n=>{const a=new n.GlbViewer(this._creator_);a.boot(),a.getApi().setOverrides(this._initData),a.getApi().init(this._domHelper.element).then(()=>{this._glbInstance=a,t(this._glbInstance)})})});return this._currentMode=2,this.cancelSelection("isolation_mode_started"),e}switchToPlanner(e){e&&this.loadPlan(e),this._currentMode=1}updateSize(){this._sceneManager.updateCamera()}getMain(){}update(){this.updateSize(),this._glbInstance&&this._glbInstance.getApi().updateSize(),this._hscInstance&&this._hscInstance.getApi().updateSize()}get callbacks(){return this._roomlePlannerUiCallback}set callbacks(e){this._roomlePlannerUiCallback=e}get hasSingleRoom(){return this._sceneManager.hasSingleRoom}showStats(){this._sceneManager.showStats()}onCloseHSC(){this._hscInstance&&this._hscInstance.getApi().pauseKernelCallbacks()}back(){if(this._currentMode===2&&this._glbInstance&&this._glbInstance.getApi().clearScene(),this._currentMode===0&&this._hscInstance){const e=this._hscInstance.getApi();e.cancelSelection({reason:"isolation_mode_cancelled"}),e.cancelDockings(),e.hideDimensions(),e.disableMultiselect(),this._sceneManager.updateScene()}this._currentMode=1}backTo(e){console.error("backTo in planner Needs to be implemented later")}getConfigurator(){return this._hscInstance}getCurrentSkin(){return this._rapiAccess.getCurrentSkin()}getRuntimeComponentIdOfRootComponent(e){return e?this._plannerKernelAccess.planInteractionHandler?this._plannerKernelAccess.planInteractionHandler.getConfiguratorKernel().getRootPlanComponentIdFromObjectId(e):(console.warn("Can not retrieve runtime id without planInteractionHandler"),0):(console.warn("Can not retrieve runtime id without planObjectId"),0)}resumeTest(e){this._domHelper.setDomElement(e),this._lifeCycleManager.resume()}pauseTest(){this._lifeCycleManager.pause()}syncCatalog(e){return this._dataSyncer.syncCatalog(e)}loadError(e){console.log(e)}getPlanInteractionHandler(){return Promise.resolve(this._planInteractionHandler)}getPlanModelViewHelper(){return Promise.resolve(this._plannerKernelAccess.planModelViewHelper)}async insertObject(e,t,n){if(!this._planInteractionHandler)throw new Error("no plan interaction handler");if(t&&(t=w(new S(t.x,t.y,t.z))),Ee(e)){if(t||n)throw new Error("External objects do not support position and rotation");return this._insertExternalObject(e)}const a=await(de(e)?this._rapiAccess.getItem(e):this._rapiAccess.getConfiguration(e)),i=await this._plannerKernelAccess.addPlanObjectFromItem(a,t,n);return this._sceneManager.updateScene(),i}async insertItemList(e){if(e.length===0)return[];const t=e.map((d,u)=>({id:d,index:u})),n=async(d,u)=>({runtimeId:await this._insertExternalObject(d),originalIndex:u}),a=[],i=[];for(const{index:d,id:u}of t)Ee(u)?a.push(n(u,d)):i.push({index:d,id:u});const r=this._sceneManager.insertRapiObjects(i),[o,l]=await Promise.all([Promise.all(a),r]),h=[...o,...l];return h.sort((d,u)=>d.originalIndex-u.originalIndex),h.map(d=>d.runtimeId)}async insertItems(e){if(e.length===0)return[];const t=e.map(n=>typeof n=="string"?n:n.id);return this.insertItemList(t)}duplicateItems(e){return this._plannerKernelAccess.duplicateItems(e)}getScene(){return this._sceneManager.getScene()}updateScene(){this._sceneManager?.updateScene()}getCameraOffset(){return this._sceneManager.getCameraOffset()}setCameraOffset(e){this._sceneManager.setCameraOffset(e)}async getObjects(){const e=(await this.getPlanModelViewHelper()).getPlanOverview(this._plan),t=z(e.objects);return ge(t,this._plannerKernelAccess,this._rapiAccess)}async getPlanOverview(){const e=(await this.getPlanModelViewHelper()).getPlanOverview(this._plan);return z(e)}prepareTopImage(e={}){return this._sceneManager.prepareTopImage(e)}preparePerspectiveImage(e={},t=!1){return this._sceneManager.preparePerspectiveImage(e,t)}enableRotation(){this._sceneManager.enableRotation()}disableRotation(){this._sceneManager.disableRotation()}enableMultiselect(){this._sceneManager.getPlannerSceneEventHandler().setSelectionMode(E.MULTISELECT),this._configuratorContext.selectionMode=E.MULTISELECT}disableMultiselect(){this._sceneManager.getPlannerSceneEventHandler().setSelectionMode(E.STANDARD),this._configuratorContext.selectionMode=E.STANDARD}async _insertExternalObject(e,t={}){let n=e;if(Ee(e)&&(n=await this.newPosDataFromId(e),!n))throw new Error(vn);if(Vt(e)&&e.externalMeta?.refresh&&(n=await this._roomlePlannerUiCallback.onGetConfigurationForExternalObject(e.id),!n))throw new Error(vn);const a=t.findFreeSpaceInPlan??!0,i=t.dragIn??!1;return await this._loadExternalObjectGroup(n,a,i,!1),-1}async dragInObject(e,t,n="rml_id"){if(n==="rml_serialized")throw new Error("dragInObject is not supported for tc_id or rml_serialized");if(this._sceneManager.dragIn(t),n==="rml_id"){const a=de(e)?await this._rapiAccess.getItem(e):await this._rapiAccess.getConfiguration(e),i=await this.insertItems([a]);if(await this._sceneManager.selectPlanObject(i[0]),i.length!==1)throw new Error("More than one object added, abort");return i[0]}else{if(n==="tc_id"||n==="tc_serialized")return this._insertExternalObject(e,{dragIn:!0});throw new Error("dragInObject is not supported for "+n)}}cancelDragIn(){this._sceneManager.cancelDragIn()}enableSnapping(){this._sceneManager.enableSnapping()}disableSnapping(){this._sceneManager.disableSnapping()}enableAdvancedDocking(){this._sceneManager.enableAdvancedDocking()}disableAdvancedDocking(){this._sceneManager.disableAdvancedDocking()}showsChildrenOfPlanObject(e){return this._sceneManager.showsChildrenOfPlanObject(e)}enableShowChildrenOfPlanObject(e){this._sceneManager.enableShowChildrenOfPlanObject(e)}disableShowChildrenOfPlanObject(e){this._sceneManager.disableShowChildrenOfPlanObject(e)}async getPartlistOf(e){const t=this._plannerKernelAccess.kernelInstance.getHashOfConfiguration(e);if(!t){const i="Object has no partlist because it is not a configuration: "+t;return console.warn(i),Promise.reject(i)}const n=this._plannerKernelAccess.kernelInstance.getPartList(e);return await this._plannerKernelAccess.addUiDataAndPriceToPartList(n,t)}formatValueToUnitString(e,t){return this._unitFormatter.formatValueToUnitString(e,t)}drawWalls(e,t={}){const n=this._planInteractionHandler;n.startInteraction();const a=[];for(const i of e){const r=n.addNode(i.from),o=n.addNode(i.to),l=n.addWall(r,o);i.props?.height!==void 0&&n.setWallHeight(l,i.props.height),i.props?.thickness!==void 0&&n.setWallThickness(l,i.props.thickness),a.push(l)}return t.keepInteractionOpen||n.endInteraction(),this._sceneManager.updateCameraOnDrawWalls(),this._sceneManager.updateScene(),a}async removeElements(e,t={}){this._sceneManager.lockCamera();const n=this._planInteractionHandler;for(const a of e){const i=this._sceneManager.getPlanObject(a.getId());let r;i&&(r=await ge([i],this._plannerKernelAccess,this._rapiAccess)),this._roomlePlannerUiCallback.onPlanElementChanged(ee.REMOVED,r?.length?r[0]:{...i,data:null}),this._planInteractionHandler.removeElement(a)}t.keepInteractionOpen||n.endInteraction(),this._sceneManager.unlockCamera()}hasWalls(){const t=this._planInteractionHandler?.getPlan();return!(!t||t.getWallCount()<1)}enableWallDrawing(){this._sceneManager.enableWallDrawing()}disableWallDrawing(){this._sceneManager.disableWallDrawing()}getUnitFormatter(){return this._unitFormatter}getStorage(){return this._idbManager}getConfiguratorContext(){return this._configuratorContext}get PlannerCoreTypes(){return this._plannerKernelAccess.kernelContainer}setSceneEvents(e){this._sceneManager.setSceneEvents(e)}async saveExternalObjectSnapshot(e){const t=await this.getPlanModelViewHelper(),n=this._planInteractionHandler.getPlan(),a=z(t.getExternalObjectGroups(n));if(a.length===0)return null;const i=await this._savePlanSnapshotExternalObjects(e,a);return{...i,glb:`https://api.roomle.com/v2/planSnapshots/${i.id}/3dAssets/glTF/plan.glb`,usdz:`https://api.roomle.com/v2/planSnapshots/${i.id}/3dAssets/usdz/plan.usdz`}}async _savePlanSnapshotExternalObjects(e,t){const n=t.map(_=>_.uniqueId),a=t.map(_=>_.runtimeId),i=await this.getPlanModelViewHelper(),r=this._planInteractionHandler.getPlan(),o=i.getPlanOverview(r),l=r.createPlanXmlWithObjects(n,!1,2),h={parentId:e||null,planObjects:[],combinedIds:[],plan:l},d=o.objects,u=d.size();for(let _=0;_<u;_++){const v=d.get(_),P=v.configurationHash||v.catalogItemId;if(a.includes(v.runtimeId)){const{center:W,dimensions:K,rotation:st,rootComponentCenter:ba}=v,Pa=JSON.stringify({center:W,dimensions:K,rotation:st,rootComponentCenter:ba});h.planObjects.push({combinedId:P,position:Pa})}}const g=await this._rapiAccess.savePlanSnapshot(h);this._plannerKernelAccess.planSnapshotCreated(g);const p=new Promise((_,v)=>{Promise.allSettled([this.preparePerspectiveImage({runtimeIds:a}),this.prepareTopImage({runtimeIds:a})]).then(async([P,W])=>{if(P.status==="rejected"||W.status==="rejected"){v("Could not generate images of plan snapshot");return}try{const K=await this._rapiAccess.savePlanSnapshotImage(g,P.value,"perspectiveImage",W.value,"topImage");_({...K})}catch(K){v(K)}})});try{return await p}catch(_){return console.error(_),g}}async saveCurrentPlanSnapshot(e,t){const n=await this.getPlanModelViewHelper(),a=this._planInteractionHandler.getPlan(),i=n.getPlanOverview(a),r=t?a.createPlanXmlWithObjects(t,!1,2):a.getPlanXML(!1,2),o={parentId:e||null,planObjects:[],combinedIds:[],plan:r},l=i.objects,h=l.size();for(let g=0;g<h;g++){const p=l.get(g),_=p.configurationHash||p.catalogItemId;if(!t||_===t){const{center:v,dimensions:P,rotation:W,rootComponentCenter:K}=p,st=JSON.stringify({center:v,dimensions:P,rotation:W,rootComponentCenter:K});o.planObjects.push({combinedId:_,position:st})}}const d=await this._rapiAccess.savePlanSnapshot(o);this._plannerKernelAccess.planSnapshotCreated(d);const u=new Promise((g,p)=>{Promise.allSettled([this.preparePerspectiveImage(),this.prepareTopImage()]).then(async([_,v])=>{if(_.status==="rejected"||v.status==="rejected"){p("Could not generate images of plan snapshot");return}try{const P=await this._rapiAccess.savePlanSnapshotImage(d,_.value,"perspectiveImage",v.value,"topImage");g({...P})}catch(P){p(P)}})});try{return await u}catch(g){return console.error(g),d}}getPlanXmlFrom(e){return e?Ze(e.id)?e.plan:e.planObjects:null}async moveCamera(e){return this._sceneManager.moveCamera(e)}async createNewSerializedConfiguration(e){return Promise.resolve(this._plannerKernelAccess.createNewSerializedConfiguration(e))}changeInteriorWallsMaterial(e){this._sceneManager.changeInteriorWallsMaterial(e)}changeExteriorWallsMaterial(e){this._sceneManager.changeExteriorWallsMaterial(e)}changeFloorsMaterial(e){this._sceneManager.changeFloorsMaterial(e)}getWallAngleDegrees(e){return this._sceneManager.getWallAngleDegrees(e)}calcPartsPriceSum(e){return this._plannerKernelAccess.calcPartsPriceSum(e)}async swapObject(e,t){let n;typeof e=="number"?n=await this.getPlanObjectForRuntimeId(e):n=e;const a=n.getPosition(),i=n.getRotation();return await this._sceneManager.deletePlanElementByIds([n.getPlanElement().getId()]),this.cancelSelection("swap_object"),await this.insertObject(t,a,i)}exportImageFromCamera(e="image",t=!1){return this._sceneManager.clearHighlighting(),this._sceneManager.exportImageFromCamera(e,t)}exportCanvasScreenshot(e){return this._sceneManager.exportCanvasScreenshot(e)}moveElementPosition(e,t){this._sceneManager.moveElementPosition(e,t)}moveElementsPosition(e,t){this._sceneManager.moveElementsPosition(e,t)}preparePerspectiveImageOf(e,t={}){return this._sceneManager.preparePerspectiveImageOf(e,t)}async generateTCExport(e=[]){try{const t=new this._plannerKernelAccess.kernelContainer.StringArray;for(const n of e)t.push(n);return Promise.resolve(JSON.parse(this._planInteractionHandler.generateTCExport(t)))}catch(t){return console.error(t),Promise.reject("Could not create Blue Ocean MVP JSON")}}enableMeasurementLineDrawing(){this._sceneManager.enableMeasurementLineDrawing()}disableMeasurementLineDrawing(){this._sceneManager.disableMeasurementLineDrawing()}setObjectToWallMeasurementLength(e,t,n){this._sceneManager.setObjectToWallMeasurementLength(e,t,n)}setWallMeasurementLength(e,t,n){this._sceneManager.setWallMeasurementLength(e,t,n)}setMeasurementLineLength(e,t,n){this._sceneManager.setMeasurementLineLength(e,t,n)}escapeDrawing(e){this._sceneManager.escapeDrawing(e),this._roomlePlannerUiCallback.onDrawCancel()}isCurrentlyDrawing(){return this._sceneManager.getPlannerSceneEventHandler().isCurrentlyDrawing}async resolveShortUrl(e){const[,,,t]=e.split("/"),n=await this._rapiAccess.resolveShortUrl(t);if(!n)throw new Error("Failed to resolve short URL");const{url:a}=n;return a}enableEvents(){this._sceneManager.enableEvents()}disableEvents(){this._sceneManager.disableEvents()}async downloadHomagIxExportPoC(){const{downloadHomagIxExportPoC:e}=await re.import("./imos-ix-poc-export-helper-r0pv9sOT.js"),t=(await this.getPlanModelViewHelper()).getPlanOverview(this._plan);return e(t,this._plannerKernelAccess.configurationExporter,this._plannerKernelAccess.kernelInstance)}async configureExternalObjectApi(e){const t=typeof e=="string"?JSON.parse(e):e;await this._plannerKernelAccess.configureExternalObjectApi(t)}loadExternalObjectLibrary(e){const t=this._planInteractionHandler.getConfiguratorKernel(),n=typeof e=="string"?e:JSON.stringify(e);t.loadExternalAttributeDefinition(n),this.updateScene()}async loadExternalObjectGroup(e,t,n=!1,a=[]){return this._loadExternalObjectGroup(e,t,!1,n,a)}async _loadExternalObjectGroup(e,t,n,a,i=[]){this.getConfiguratorContext().baseContext===C.CONFIGURATOR?await this._loadExternalObjectGroupInConfigurator(e,t,n,a,i):await this._loadExternalObjectGroupInPlanner(e,t,n,a,i)}async _loadExternalObjectGroupInConfigurator(e,t,n,a,i=[]){await this._loadOrUpdateExternalObjectGroup(e,t,n,a,i,!0),this.updateScene()}async _loadExternalObjectGroupInPlanner(e,t,n,a,i=[]){const r=this.getConfiguratorContext(),o=this._sceneManager.getPlanObject(r.planElementId);if(await this._loadOrUpdateExternalObjectGroup(e,t,n,a,i,!1),o.configurationType?.value===Q.EXTERNAL)if(i.includes(o.configurationHash)){const l=this._createSerializedGroupCollection(e),h=JSON.parse(l[0]).id;await this._selectExternalObjectGroup(h,!1)}else await this._selectExternalObjectGroup(o.configurationHash,!1);this.updateScene()}async _loadOrUpdateExternalObjectGroup(e,t,n,a,i,r){const o=this._createSerializedGroupCollection(e);n?this._planInteractionHandler.startInteraction():this._planInteractionHandler.resumeInteraction();const l={x:0,y:0,z:0},h=n&&!r?this._getFaceTheCameraAngle(90):0,d={findFreeSpaceInPlan:t,applyGlobalChildMode:!1,isVisible:!n,correctArrangement:a},u=this._planInteractionHandler.addOrUpdateExternalPlanObjects(o,l,h,d,i);n||this._planInteractionHandler.endInteraction();const g=this._planInteractionHandler.getPlan().extRef.jsObject,p=[];for(const _ of u)_.hasConfiguration()&&p.push(g.getConfigurablePlanObjectForId(_.getId()));await Promise.all(p.map(async _=>{await _.isInitDone()}))}_createSerializedGroupCollection(e){const t=Array.isArray(e)?e:[e],n=[];for(const a of t){const i=typeof a=="string"?a:JSON.stringify(a);n.push(i)}return n}_getFaceTheCameraAngle(e){const t=this._sceneManager.getCameraParameters3d();if(!t?.yaw)return 0;const n=$t(t.yaw),a=Math.round(n/e)*e;return Jt(a)}async renderImagesOfExternalObjectGroup(e){const t=Array.isArray(e)?e:[e],n={},a=this._initData.animateCamera;this._initData.animateCamera=!1;for(const i of t){try{await this._loadExternalObjectGroup(i,!1,!1,!1),await this._selectExternalObjectModule(i.id,null,!0,!0,!1,!1),this.preparePerspectiveImage(),await this._sceneManager.waitForMaterialQueue(),this.updateScene();const r=await this.exportCanvasScreenshot();n[i.id]=r}catch(r){console.error(r)}this.backToPlanner()}for(const i of t)await this.removeExternalObjectGroup(i.id,!1);return this._initData.animateCamera=a,n}async removeExternalObjectGroup(e,t=!1){const n=await this.getPlanModelViewHelper(),a=this._planInteractionHandler.getPlan(),i=n.getExternalObjectComponent(a,e,"");this.getConfiguratorContext().planElementId===i.runtimeId&&this._sceneManager.cancelPlanElementSelection("delete_object"),i.runtimeId!==0&&(t?(this._planInteractionHandler.resumeInteraction(),this._planInteractionHandler.removeObjectWithId(e),this._planInteractionHandler.endInteraction()):(this._planInteractionHandler.startInteraction(),this._sceneManager.deletePlanElementByIds([i.runtimeId]),this._planInteractionHandler.endInteraction())),this.updateScene()}removeExternalObjectRootModule(e){this._planInteractionHandler.startInteraction(),this._planInteractionHandler.removeObjectWithId(e),this._planInteractionHandler.endInteraction(),this.updateScene()}async selectExternalObjectGroup(e){this.getConfiguratorContext().baseContext===C.CONFIGURATOR||this._planInteractionHandler.setShowChildrenOfExternalObject(e,{value:le.OFF},!1),await this._selectExternalObjectGroup(e,!0),this.updateScene()}async selectExternalObjectRootModule(e){const n=this.getConfiguratorContext().baseContext===C.CONFIGURATOR;n||this._planInteractionHandler.setShowChildrenOfExternalObject(e,{value:le.GROUND_COMPONENTS},!1),await this._selectExternalObjectModule(e,null,!n,n,!0,!0),this.updateScene()}async selectExternalObjectSubModule(e,t){const a=this.getConfiguratorContext().baseContext!==C.CONFIGURATOR;await this._selectExternalObjectModule(e,t,a,!0,!0,!0),this.updateScene()}async openOrCloseGeometryOfExternalObject(e,t,n,a){const i=await this.getPlanModelViewHelper(),r=this._planInteractionHandler.getPlan(),o=i.getExternalObjectComponent(r,e,"");if(o?.configurationRuntimeId){const l=n?"open":"close";this._sceneManager.animateElement(o.configurationRuntimeId,"openClose",l,!0,a),this.updateScene()}}async _selectKernelComponent(e){e.configurationHash&&e.configurationType.value===Q.EXTERNAL&&await this._selectExternalObjectModule(e.configurationHash,e.componentId,!0,!0,!0,!1),this.updateScene()}async _selectExternalObjectGroup(e,t){const n=await this.getPlanModelViewHelper(),a=this._planInteractionHandler.getPlan(),i=n.getExternalObjectComponent(a,e,"");i.runtimeId!==0&&(t&&await this._roomlePlannerUiCallback.onBackToPlanner(),await this._sceneManager.selectPlanObject(i.runtimeId))}async _selectExternalObjectModule(e,t,n,a,i,r){const o=await this.getPlanModelViewHelper(),l=this._planInteractionHandler.getPlan(),h=o.getExternalObjectComponent(l,e,t??"");if(h.runtimeId===0)return;const d=this.getConfiguratorContext().baseContext===C.CONFIGURATOR,u=this._getSelectedPlanObjectComponent();let g=!1,p=n;d&&(g=u?.configurationRuntimeId===h.configurationRuntimeId,p=!g,g||this._sceneManager.backToPlanner()),p&&await this._selectPlanObject(h),a&&!g&&await this._roomlePlannerUiCallback.onStartConfiguring(),h.planComponentRuntimeId!==0&&i&&this._sceneManager.selectComponent(h.planComponentRuntimeId,!1),r&&!d&&this._sceneManager.highlightExternalObject(h)}async _selectPlanObject(e){let t=e.runtimeId;const n=z(this._plan.getPlanObjects());for(const a of n)if(a.getConfigurationRuntimeId()===e.planComponentRuntimeId){t=a.getId();break}await this._sceneManager.selectPlanObject(t)}_getSelectedPlanObjectComponent(){const e=this.getConfiguratorContext(),t=e.selectedRuntimeComponentId??e.planObjectId;return this._sceneManager.getObjectComponent(t)}async getExternalObjectGroups(){const e=await this.getPlanModelViewHelper(),t=this._planInteractionHandler.getPlan(),n=[],a=z(e.getExternalObjectGroups(t));for(const i of a)n.push(JSON.parse(i.serializedDefinition));return n}async getExternalRoomInformation(){const e=await this.getPlanModelViewHelper(),t=this._planInteractionHandler.getPlan();return z(e.getExternalRoomInformation(t))}get globalCallbacks(){return this._globalCallback}_executeWithInteraction(e){const t=this._plannerKernelAccess.planInteractionHandler;t.startInteraction();const n=e();return t.endInteraction(),n}addAtticToWall(e,t,n,a){return this._executeWithInteraction(()=>this._plannerKernelAccess.planInteractionHandler.addAttic(e,t,n,a)||null)}removeAttic(e){this._executeWithInteraction(()=>this._plannerKernelAccess.planInteractionHandler.removeElement(e))}setAtticSide(e,t){this._executeWithInteraction(()=>this._plannerKernelAccess.planInteractionHandler.setAtticSide(e,t))}getAttachedAttic(e){const t=e.getAttachedAttics();return t.size()>0?t.get(0):null}updateAtticKneeHeight(e,t){this._executeWithInteraction(()=>this._plannerKernelAccess.planInteractionHandler.setAtticKneeHeight(e,t))}updateAtticWidth(e,t){this._executeWithInteraction(()=>this._plannerKernelAccess.planInteractionHandler.setAtticWidth(e,t))}async executeWithInteraction(e){const t=this._plannerKernelAccess.planInteractionHandler;t.startInteraction();try{const n=e();return n instanceof Promise?await n:n}finally{t.endInteraction()}}pauseInputListeners(){return this._sceneManager.pause()}resumeInputListeners(){return this._sceneManager.resume()}turnLightsOn(){this._planInteractionHandler.getPlan()?.extRef?.jsObject?.turnLightsOnOrOff(!0),this._sceneManager.toggleInteriorLightsSceneSettings(!0)}turnLightsOff(){this._planInteractionHandler.getPlan()?.extRef?.jsObject?.turnLightsOnOrOff(!1),this._sceneManager.toggleInteriorLightsSceneSettings(!1)}async getPlanObjectForRuntimeId(e){const t=this._planInteractionHandler.getPlan()?.extRef?.jsObject;return Promise.resolve(t.getPlanObjectForId(e)||null)}async rotateByRuntimeId(e,t){return this._sceneManager.rotatePlanElements([e],t),Promise.resolve()}async deleteByRuntimeId(e){return this._sceneManager.deletePlanElements([e]),Promise.resolve()}async moveByRuntimeId(e,t){const n=await this.getPlanObjectForRuntimeId(e);return this._sceneManager.moveElementPosition(n,t),Promise.resolve()}undo(){return this._sceneManager.undo()}redo(){return this._sceneManager.redo()}setHomagIntelligence(e){this._homagIntelligence=e}newPosDataFromId(e){return this._homagIntelligence.getEmulator().newPosDataFromId(e)}sendToOM(e=!0){return this._homagIntelligence.sendToOM(e)}async fetchPrice(e){return this._homagIntelligence.fetchPrice(e)}async getOrderManagerGroupData(e){return this._homagIntelligence.getEmulator().getGroupDataForOrder(e)}getRapiAccess(){return this._rapiAccess}}x([f],j.prototype,"_configuratorContext"),x([f],j.prototype,"_domHelper"),x([f],j.prototype,"_kernelAccessCallback"),x([f],j.prototype,"_plannerKernelAccess"),x([f],j.prototype,"_rapiAccess"),x([f],j.prototype,"_singlePromiseFactory"),x([f],j.prototype,"_roomlePlannerUiCallback"),x([f],j.prototype,"_lifeCycleManager"),x([f],j.prototype,"_dataSyncer"),x([f],j.prototype,"_initData"),x([f],j.prototype,"_idbManager"),x([f],j.prototype,"_globalInitData"),x([f],j.prototype,"_globalCallback"),x([f],j.prototype,"_unitFormatter");class Yn extends qt{_canDrag(e){return!0}}const Xn=[new J("script-loader",bn),new J("planner-input-manager",Yn,et.CONTEXT),new J("logger",Yt),new J("planner-mesh-generator",Xt),new J("configurator-view-model",fn,et.CONTEXT),new J("rapi-access",Zt),new J("global-init-data",Qt),new J("planner-selection-handler",jn)];var Zn=Object.defineProperty,Sn=(s,e,t,n)=>{for(var a=void 0,i=s.length-1,r;i>=0;i--)(r=s[i])&&(a=r(e,t,a)||a);return a&&Zn(e,t,a),a};const Mn="external:root-tag";class nt{constructor(e,t){this._externalItems=new Map,this._externalConfigurations=new Map,this._tagIds=[],this._creator_=e,this._articlesPromise=t,this._init()}setEmulator(e){this._emulator=e}_init(){const e=this._globalCallback.onCheckExternalCache;this._globalCallback.onCheckExternalCache=async(t,n)=>{const a=await e(t,n);return a!==null?a:this._onCheckExternalCache(t)},this._globalCallback.onFetchExternalData=this._onFetchExternalData.bind(this)}async _onCheckExternalCache(e){if(e==="/tags/"+Oe(Mn)){const t=await this._processedArticles();return this._tagIds=[...t.keys()].sort((n,a)=>n.localeCompare(a)),Promise.resolve({tag:{id:Oe(Mn),tags:this._tagIds,sort:1}})}for(const t of this._tagIds){if(e==="/tags/"+t){const n=await this._processedArticles();return Promise.resolve({tag:{id:t,label:n.get(t).label,sort:1}})}if(e==="/tags/"+t+"/items"){const a=(await this._processedArticles()).get(t).items;return a.sort((i,r)=>i.label.localeCompare(r.label)),Promise.resolve({items:a})}}return null}_onFetchExternalData(e,t){const n=Array.isArray(t)?t:[t],a=[];for(const i of n){const r=this._configuratorViewModel.getExternalConfigurationById(i);r?a.push(r):this._externalItems.has(i)?a.push(this._externalItems.get(i)):console.warn("ID",i,"is unknown")}return Array.isArray(t)?Promise.resolve(a):Promise.resolve(a[0])}async _processedArticles(){let e=await this._articlesPromise;return e.articles&&(e=e.articles),e.reduce((t,n)=>{const a=n.category||"Uncategorized",i=Oe(a.toLowerCase());t.has(i)||t.set(i,{id:i,label:a,items:[]});const r=t.get(i),{depth:o,width:l,height:h}=n.roots.reduce((g,{attributes:p})=>(p&&p.forEach(_=>{_.id==="mod_Depth"&&(g.depth+=parseInt(_.value,10)/10),_.id==="mod_Width"&&(g.width+=parseInt(_.value,10)/10),_.id==="mod_Height"&&(g.height+=parseInt(_.value,10)/10)}),g),{depth:0,width:0,height:0}),d=o>0&&l>0&&h>0,u=en({id:n.articleId,uiLabels:{desktop:{line1:n.name,line2:n.desc,line3:d?`${h}x${l}x${o}`:""},mobile:{line1:n.name,line2:d?`${h}x${l}x${o}`:"",line3:n.desc}},label:n.name??"external-objects.no-name",externalObject:!0,configuration:{imageUrl:n.imageUrl}});return this._externalItems.set(u.id,u),r.items.push(u),t},new Map)}}Sn([f],nt.prototype,"_globalCallback"),Sn([f],nt.prototype,"_configuratorViewModel");class Qn{}const H=(...s)=>console.log("[HI]","API Callback:",...s),_e=(...s)=>console.log("[HI]","Message:",...s),D=(...s)=>console.log("[HI]","API Call:",...s);class ea{constructor(e){this._roomlePlanner=e}loadMasterData(e){D("loadExternalObjectLibrary"),this._roomlePlanner.loadExternalObjectLibrary(e)}async loadPosGroups(e,t,n,a=[]){const i=Array.isArray(e)?e:[e];let r="";for(const o of i)r+=` '${o.id}'`;D(`loadExternalObjectGroup${r}`),await this._roomlePlanner.loadExternalObjectGroup(i,t,n,a)}async selectGroup(e){D(`selectExternalObjectGroup '${e}'`),await this._roomlePlanner.selectExternalObjectGroup(e)}async selectRoot(e){D(`selectExternalObjectRootModule '${e}'`),await this._roomlePlanner.selectExternalObjectRootModule(e)}async selectModule(e,t){D(`selectExternalObjectSubModule '${e}' '${t}'`),await this._roomlePlanner.selectExternalObjectSubModule(e,t)}async openCloseGroup(e,t,n,a){D(`openCloseExternalObject '${e}' '${t}' ${n?"open":"close"}`),await this._roomlePlanner.openOrCloseGeometryOfExternalObject(e,t??null,n,a)}async deleteGroup(e,t=!1){D(`removeExternalObjectGroup '${e}' ${t}`),await this._roomlePlanner.removeExternalObjectGroup(e,t)}deleteRootModule(e){return D(`removeExternalObjectRootModule '${e}'`),this._roomlePlanner.removeExternalObjectRootModule(e),Promise.resolve()}async getPosDataOfAllGroups(){const e=await this._roomlePlanner.getExternalObjectGroups(),t=e.map(n=>n.id);return D(`getPosDataOfAllGroups => '${t}'`),e}async getRoomInformation(){const e=await this._roomlePlanner.getExternalRoomInformation();return D("getRoomInformation"),e}async generatePlanSnapshot(){D("saveExternalObjectSnapshot"),D("saveCurrentPlanSnapshot");const[e,t]=await Promise.all([this._roomlePlanner.saveExternalObjectSnapshot(),this._roomlePlanner.saveCurrentPlanSnapshot()]);_e("Group ID",e?.id),_e("Plan ID",t.id)}async saveExternalObjectSnapshot(){return D("saveExternalObjectSnapshot"),this._roomlePlanner.saveExternalObjectSnapshot()}async saveCurrentPlanSnapshot(){return D("saveCurrentPlanSnapshot"),this._roomlePlanner.saveCurrentPlanSnapshot()}async renderPosDataImage(e){const t=Array.isArray(e)?e:[e];let n="";for(const a of t)n+=` '${a.id}'`;D(`renderImagesOfExternalObjectGroup${n}`),await this._roomlePlanner.renderImagesOfExternalObjectGroup(t)}async downloadGlb(){D("saveExternalObjectSnapshot");const e=await this._roomlePlanner.saveExternalObjectSnapshot();if(!e){_e("No plan snapshot available to download GLB.");return}window.open(e.topImage,"_blank")?.focus(),window.open(e.perspectiveImage,"_blank"),window.open(e.glb,"_blank")}}class ta{constructor(e,t){this._posDataJsonMap=new Map,this._groupMap=new Map,this._nextPosDataId=1,this._designerRequests=e,this._libraryData=t}loadPosData(e,t){e?.articles&&(e=e.articles),e.forEach(n=>{const a=n.id||n.articleId;this._posDataJsonMap.set(a,{id:a,roots:n.roots,articleId:n.articleId,articleName:n.articleName,name:n.articleName,category:n.category,imageUrl:n.imageUrl,desc:n.desc,libraryId:t})})}newPosDataFromId(e){Ee(e)&&(e=tn(e));const t=JSON.parse(JSON.stringify(this._posDataJsonMap.get(e)));return t?(t.ver=this._libraryData.posGroupVersion,t.roots.forEach(a=>{a.libraryId=t.libraryId,a.isGenerated||(a.articleName=t.articleName,a.articleId=t.articleId,a.desc=t.desc,a.imageUrl=t.imageUrl,a.category=t.category)}),this._addNewGroup(t,!1).posDataJson):void 0}async deleteGroup(e){try{this.removedGroup(e),await this._designerRequests.deleteGroup(e,!1)}catch(t){console.error(t)}}async selectGroup(e){try{await this._designerRequests.selectGroup(e)}catch(t){console.error(t)}}async selectCheckAttributes(e){try{await this._libraryData.getAttributesDropDownValues(e)}catch(t){console.error(t)}}async selectRoot(e,t){try{await this._designerRequests.selectRoot(t)}catch(n){console.error(n)}}async deleteRoot(e,t){try{await this._designerRequests.deleteRootModule(t)}catch(n){console.error(n)}}async selectSubModule(e,t,n){try{await this._designerRequests.selectModule(t,n)}catch(a){console.error(a)}}async openCloseGroup(e){try{const t=this._groupMap.get(e);if(t){const n=!t.opened;await this._designerRequests.openCloseGroup(e,null,n,!1),t.opened=n}}catch(t){console.error(t)}}deleteRootModule(e,t,n){try{const a=this._groupMap.get(e.groupId);if(a){this._setGroupPosition(a,e),this._setGroupContour(a,e),this._setRootModulesPosition(a,e);const i=a.posDataJson;i.roots=i.roots.filter(o=>o.id!==t);const r=this._splitOffGroupsFromGroups(a,n);this._calculateAndUpdateGroupMap(a),this._loadPosData(a,r)}}catch(a){console.error(a)}}async duplicateGroup(e,t){try{const n=this._groupMap.get(e);if(n){const a=JSON.parse(JSON.stringify(n.posDataJson)),i=this._addNewGroup(a,!1);this._setGroupPosition(i,t),this._designerRequests.loadPosGroups(i.posDataJson,!0,!1)}}catch(n){console.error(n)}}mergeGroups(e,t,n){try{const a=Array.isArray(t)?t:[t];if(this._groupMap.has(e.groupId)&&a.length>0){const i=[];for(const l of a){const h=this._groupMap.get(l);h&&i.push(...h.posDataJson.roots)}const r=i.filter(l=>!l.isGenerated),o=this._groupMap.get(e.groupId);if(o){const l=o.posDataJson.roots.find(h=>h.id===n);l&&this._applyImplicitRelevantAttributes(l,r),o.posDataJson.roots.push(...r),this._setGroupPosition(o,e),this._setGroupContour(o,e),this._setRootModulesPosition(o,e),this._calculateAndUpdateGroupMap(o),this._designerRequests.loadPosGroups(o.posDataJson,!1,!1,a)}}}catch(a){console.error(a)}}_applyImplicitRelevantAttributes(e,t){const n=this._libraryData.masterData;if(!n||!e||t.length===0)return;const i=n.modules.find(r=>r.id===e.name)?.assignedAttributes.filter(r=>n.attributes.find(o=>o.id===r)?.implicitRelevant===!0)??[];for(const r of t){const o=n.modules.find(l=>l.id===r.name);for(const l of i){const h=e.attributes?.find(g=>g.id===l);if(!o?.assignedAttributes.find(g=>g===l))continue;const u=r.attributes?.find(g=>g.id===l);u?(u.isInput=h?.isInput??!1,u.isInput===!0&&(u.value=h?.value)):(h?.isInput??!1)&&r.attributes?.push({id:l,value:h?.value,isInput:!0})}}}splitRootModuleFromGroup(e,t){try{const n=this._groupMap.get(e.groupId);if(n){this._setGroupPosition(n,e),this._setGroupContour(n,e),this._setRootModulesPosition(n,e);const a=Array.isArray(t)?t:[t],i=this._splitOffGroupsFromGroups(n,a);this._calculateAndUpdateGroupMap(n),this._loadPosData(n,i)}}catch(n){console.error(n)}}arrangeRootModulesOfGroup(e){try{const t=this._groupMap.get(e.groupId);if(t){for(const n of t.posDataJson.roots)e.rootModules.filter(a=>a.moduleId===n.id).forEach(a=>{n.articlePos=a.pos,n.rotationY=a.rotationY});this._calculate(t.posDataJson),this._designerRequests.loadPosGroups(t.posDataJson,!1,!1)}}catch(t){console.error(t)}}removedGroup(e){try{this._groupMap.has(e)&&this._groupMap.delete(e)}catch(t){console.error(t)}}changedGroup(e){try{const t=e.id,n=this._groupMap.get(t);n?n.posDataJson=e:this._addGroupToMap(t,e),this._calculate(e)}catch(t){console.error(t)}}changedGroupPlanningSituation(e){const t=this._groupMap.get(e.groupId);t&&(this._setGroupPosition(t,e),this._setGroupContour(t,e),this._calculate(t.posDataJson),this._designerRequests.loadPosGroups(t.posDataJson,!1,!1))}loadedGroup(e){try{const t=e.id;this._groupMap.has(t)||this._addGroupToMap(t,e)}catch(t){console.error(t)}}async getGroupDataForOrder(e){try{const t=await this._designerRequests.getPosDataOfAllGroups();let n=1;t.forEach(r=>{r.roots.forEach(o=>{o.additionalText="Additional Text "+n++})});const a=this._libraryData.getOrderData(t,e),i=await this._designerRequests.getRoomInformation();return a.rooms=i?.rooms??[],a}catch(t){return console.error(t),null}}_setGroupContour(e,t){t.contours&&(e.posDataJson.contours=t.contours)}_setGroupPosition(e,t){const n=e.posDataJson;t.pos!==void 0&&(n.pos=t.pos),t.rotationY!==void 0&&(n.rotationY=t.rotationY)}_setRootModulesPosition(e,t){for(const n of e.posDataJson.roots)t.rootModules.filter(a=>a.moduleId===n.id).forEach(a=>{n.articlePos=a.pos,n.rotationY=a.rotationY})}_loadPosData(e,t){const n=JSON.parse(JSON.stringify(e.posDataJson)),a=Array.isArray(n)?n:[n];for(const i of t??[])a.push(JSON.parse(JSON.stringify(i.posDataJson)));this._designerRequests.loadPosGroups(a,!1,!1)}_splitOffGroupsFromGroups(e,t){const n=[];for(const a of t??[]){const i=this._splitOffRootModulesFromGroup(e,a),r=this._addNewGroup(i,!0);n.push(r)}return n}_splitOffRootModulesFromGroup(e,t){const n=t.rootModules.map(o=>o.moduleId),a=e.posDataJson,i=a.roots.filter(o=>n.includes(o.id));a.roots=a.roots.filter(o=>!n.includes(o.id));const r={pos:t.pos,rotationY:t.rotationY,roots:i,ver:a.ver};for(const o of r.roots)t.rootModules.filter(l=>l.moduleId===o.id).forEach(l=>{o.articlePos=l.pos,o.rotationY=l.rotationY});return r}_calculateNewGroup(e,t){return this._replacesIDs(e,t),this._calculate(e)}_calculate(e){const t=e.roots.find(i=>i.libraryId)?.libraryId,n=JSON.parse(JSON.stringify(e)),a=this._libraryData.calculateGroup(e);return a.roots.forEach(i=>{const r=n.roots.find(o=>o.id===i.id);if(i.additionalText=r?.additionalText,i.libraryId=r?.libraryId??t,i.isGenerated){const o=this._libraryData.masterData;if(o){const l=o.modules.find(h=>h.id===i.name);l&&(r?.articleName||(i.articleName=l.name),r?.articleId||(i.articleId=l.name),r?.imageUrl||(i.imageUrl=l.imageUrl),r?.desc||(i.desc=l.desc))}}i.articleName||(i.articleName=r?.articleName??i.name),i.articleId||(i.articleId=r?.articleId??r?.articleName??i.name),i.imageUrl||(i.imageUrl=r?.imageUrl),i.desc||(i.desc=r?.desc),i.category=r?.category,i.canBeDeleted=!0}),a}_calculateAndUpdateGroupMap(e){const t=this._calculate(e.posDataJson);return e.posDataJson=t,this._groupMap.set(e.posDataJson.id,e),t}_addNewGroup(e,t){const n=this._calculateNewGroup(e,t);return this._addGroupToMap(n.id,n)}_addGroupToMap(e,t){const n={posDataJson:t,opened:!1};return this._groupMap.set(e,n),n}async updateAttribute(e,t,n,a){if(!e)return;const i=Array.from(this._groupMap.entries()).find(([,o])=>o.posDataJson.roots.some(l=>l.id===e));if(!i)throw new Error("PosGroup not found inside the calculated articles list");const[,r]=i;if(r){const o=this._modifyAttributeOfModules(r,t,n,a);this._designerRequests.loadPosGroups(o,!1,!0)}}modifyAttribute(e,t,n,a){const i=this._groupMap.get(e);if(i){const r=t.map(l=>l.subModuleId??l.rootModuleId),o=this._modifyAttributeOfModules(i,r,n,a);this._designerRequests.loadPosGroups(o,!1,!0)}}_modifyAttributeOfModules(e,t,n,a){const i=Array.isArray(t)?t:[t];for(const o of i){const l=this._findModule(e.posDataJson.roots,o);if(l){const h=this._libraryData.solveModuleAttributeConflict(l,n,a);h&&h.length>0&&h.forEach(d=>{d.value!==void 0&&this._setAttribute(l,d.id,d.value)}),this._setAttribute(l,n,a)}}return this._calculateAndUpdateGroupMap(e)}_setAttribute(e,t,n){if(e.attributes&&e.attributes.length>0){const i=e.attributes.find(r=>r.id===t);if(i){i.value=n,i.isInput=!0;return}}const a={id:t,value:n,isInput:!0};e.attributes?e.attributes.push(a):e.attributes=[a]}async savePlanSnapshot(){const[e,t]=await Promise.all([this._designerRequests.saveExternalObjectSnapshot(),this._designerRequests.saveCurrentPlanSnapshot()]);return{id:t.id,perspectiveImageLink:t.perspectiveImage,topImageLink:t.topImage,room3dLink:e?.glb,room3dFullLink:`https://api.roomle.com/v2/planSnapshots/${t.id}/3dAssets/glTF/plan.glb`}}_findModule(e,t){for(const n of e){if(n.id===t)return n;if(n.modules&&n.modules.length>0){const a=this._findModule(n.modules,t);if(a!==void 0)return a}}}_replacesIDs(e,t){if(e.id=this._getNextID(),!t)for(const n of e.roots)this._replacesModuleIDs(n)}_replacesModuleIDs(e){if(e.id=this._getNextID(),e.modules)for(const t of e.modules)this._replacesModuleIDs(t)}_getNextID(){if(window.uuidv4)return window.uuidv4();let e=(this._nextPosDataId++).toString();return e.length<4&&(e="0".repeat(4-e.length)+e),"id"+e}}const A=[];for(let s=0;s<256;++s)A.push((s+256).toString(16).slice(1));function na(s,e=0){return(A[s[e+0]]+A[s[e+1]]+A[s[e+2]]+A[s[e+3]]+"-"+A[s[e+4]]+A[s[e+5]]+"-"+A[s[e+6]]+A[s[e+7]]+"-"+A[s[e+8]]+A[s[e+9]]+"-"+A[s[e+10]]+A[s[e+11]]+A[s[e+12]]+A[s[e+13]]+A[s[e+14]]+A[s[e+15]]).toLowerCase()}let at;const aa=new Uint8Array(16);function ia(){if(!at){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");at=crypto.getRandomValues.bind(crypto)}return at(aa)}const En={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function ra(s,e,t){if(En.randomUUID&&!e&&!s)return En.randomUUID();s=s||{};const n=s.random||(s.rng||ia)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,e){t=t||0;for(let a=0;a<16;++a)e[t+a]=n[a];return e}return na(n)}const sa=s=>`(${s[0].toFixed(1)}, ${s[1].toFixed(1)}, ${s[2].toFixed(1)})`,oa=s=>`${s?.toFixed(1)??0}°`,la=(s,e)=>{s.callbacks.onMergeExternalObjectGroup=(t,n,a)=>{H(`onMergeExternalObjectGroup ${t} ${n}, ${a}`),e.mergeGroups(t,n,a)},s.callbacks.onSplitExternalObjectGroup=(t,n)=>{H("onSplitExternalObjectGroup",JSON.stringify(t),JSON.stringify(n)),e.splitRootModuleFromGroup(t,n)},s.callbacks.onExternalObjectGroupArrangementChanged=t=>{H("onExternalObjectGroupArrangementChanged",JSON.stringify(t)),e.arrangeRootModulesOfGroup(t)},s.callbacks.onDeleteExternalObjectGroup=t=>{H(`onDeleteExternalObjectGroup ${t}`),e.removedGroup(t)},s.callbacks.onDeleteExternalObjectRootModule=(t,n,a)=>{H("onDeleteExternalObjectRootModule",JSON.stringify(t),n,JSON.stringify(a)),e.deleteRootModule(t,n,a??[])},s.callbacks.onDeleteExternalObjectSubModule=(t,n)=>{H(`onDeleteExternalObjectSubModule ${t} ${n}`)},s.callbacks.onDuplicateExternalObjectGroup=(t,n)=>{H(`onDuplicateExternalObjectGroup ${t}, ${n}`),e.duplicateGroup(t,n)},s.callbacks.onChangedExternalObjectGroupPlan=t=>{H("onChangedExternalObjectGroupPlan",t.groupId,sa(t.pos),oa(t.rotationY??0)),e.changedGroupPlanningSituation(t)},s.callbacks.onExternalObjectEnvironmentChanged=t=>{H("onExternalObjectEnvironmentChanged",...t)},s.callbacks.onExternalObjectGroupChanged=t=>{const n=JSON.parse(t);H("onExternalObjectGroupChanged",n.id),e.changedGroup(n)},s.callbacks.onExternalObjectGroupLoaded=t=>{const n=JSON.parse(t);H("onExternalObjectGroupLoaded",n.id),e.loadedGroup(n)},s.callbacks.onExternalObjectAttributeChanged=(t,n,a,i)=>{if(Array.isArray(n)){for(const r of n)H("onExternalObjectAttributeChanged",r.groupId,r.rootModuleId,r.subModuleId,a,i);e.modifyAttribute(t,n,a,i)}else H("onExternalObjectAttributeChanged",t,n,a,i),e.modifyAttribute(t,[{groupId:t,rootModuleId:n,subModuleId:null}],a,i)},s.callbacks.onPlanSnapshotCreated=(...t)=>{H("onPlanSnapshotCreated",t)}},ze=(s=new Date)=>{let e=s.toISOString();e=e.slice(0,-1);const t=e.lastIndexOf(".");let n=e;t!==-1&&(n=e.substring(0,t+4)+"0000");const a=s.getTimezoneOffset(),i=Math.abs(Math.floor(a/60)),r=Math.abs(a%60),l=`${a<=0?"+":"-"}${String(i).padStart(2,"0")}:${String(r).padStart(2,"0")}`;return n+l},yn=()=>({id:window.uuidv4?window.uuidv4():"00000000-0000-0000-0000-000000000000",state:"New",orderNumber:"736362",orderName:"Bedroom & bathroom 01",orderDescription:"Lorem ipsum dolor sit amet...",project:"Single family house Müller John",personInCharge:"Joe",orderDate:ze(),deliveryDatePlanned:ze(new Date(Date.now()+336*60*60*1e3)),addresses:[{type:"Delivery, Billing",street:"Musterstraße",houseNumber:"1",postalCode:"12345",city:"Musterstadt",country:"Deutschland"}],customerName:"Müller & Co.",customerNumber:"462642",createdAt:ze(),changedAt:ze(),changedBy:"Selfish",items:[]}),Dn=s=>{const e=encodeURIComponent(s.subscriptionId),t=encodeURIComponent(s.om.key),n=encodeURIComponent(s.om.importBaseUrl);return{subscriptionId:e,headers:{headers:{"Content-Type":"application/json"}},key:t,importBaseUrl:n}},An=async(s,e,t,n="",a={})=>{const{subscriptionId:i,key:r,headers:o,importBaseUrl:l}=Dn(s),d=await(await fetch(Ve+`${encodeURIComponent(t)}&subscriptionId=${i}&apiKey=${r}&baseUrl=${l}`,{method:"POST",body:JSON.stringify(e),headers:{...o.headers,...a}})).json();return _e(n,JSON.stringify(d)),d},ca=async(s,e)=>{const t=await s.getPlanOverview(),n={},a=t.objects.reduce((o,l)=>(l.catalogItemId&&(n[l.catalogItemId]||(n[l.catalogItemId]=0,o.push(l.catalogItemId)),n[l.catalogItemId]++),o),[]),r=(Array.isArray(a)&&a.length>0?await s.getRapiAccess().getItems(a):[]).filter(o=>o.manufacturerSKU!==void 0?(o.count=n[o.id],!0):!1);if(Array.isArray(r)&&r.length>0){e.items||(e.items=[]);let o=e.items.reduce((l,h)=>h.items?.length?l+h.items.length:l,0);r.forEach(l=>{const h={};h.type="Position",h.name=(++o).toString(),h.articleNumber=l.manufacturerSKU,h.articleName=l.label,h.catalog=l.catalog,h.quantity=l.count,h.height=l.displayedHeight,h.width=l.displayedWidth,h.depth=l.displayedDepth,h.color=l.basecolor,h.procurementType="PTO",h.additionalData=[],l.perspectiveImage&&h.additionalData.push({category:"ArticleImage",downloadUri:l.perspectiveImage,type:"Image"}),e.items.push(h)})}},ha=async(s,e,t,n=!1)=>{const a=!!e._initData.hi.libraryId.match("nobilia"),i="/api/orderManager/orders/import",r=await t.savePlanSnapshot();let o,l;n?(l=(await Rn(s,t,r?.id,a)).orderData,o=l.items[0]):(o=await t.getGroupDataForOrder(r?.id),l=yn(),l.items.push(o),await ca(e,o)),Array.isArray(o.additionalData)||(o.additionalData=[]),r.perspectiveImageLink&&o.additionalData.push({type:"Image",category:"OverviewImage",downloadUri:r.perspectiveImageLink}),r.topImageLink&&o.additionalData.push({type:"Image",category:"AboveImage",downloadUri:r.topImageLink}),r.room3dLink&&o.additionalData.push({type:"ThreeD",category:"ThreeDModel",downloadUri:r.room3dLink});const h=await An(s,l,i,"ORDER-RESPONSE",{"x-aux-header":a?"nobilia":"none"}),{subscriptionId:d,key:u,headers:g,importBaseUrl:p}=Dn(s);if(h.correlationId)try{const _=await fetch(Ve+`${encodeURIComponent(i+"/"+h.correlationId)}&subscriptionId=${d}&apiKey=${u}&baseUrl=${p}`,{method:"GET",headers:{...g.headers,"x-aux-header":a?"nobilia":"none"}});console.log("Second fetch completed with status:",_.status);const v=await _.json();_e("IMPORT-STATUS",JSON.stringify(v))}catch(_){console.error("Error with second fetch:",_),_e("FETCH-ERROR",_.toString())}},Rn=async(s,e,t,n=!1)=>{const a=await e.getGroupDataForOrder(t),i=yn();return i.items.push(a),await An(s,{orderData:i},"/api/price/calculate","PRICE-RESPONSE",{"x-aux-header":n?"nobilia":"none"})};class da{constructor(e,t,n){this._roomlePlanner=e,this._gluLogic=t,this._apiOptions=n}async sendToOM(e=!1){return ha(this._apiOptions,this._roomlePlanner,this._gluLogic,e)}async fetchPrice(e){const t=!!this._roomlePlanner._initData.hi.libraryId.match("nobilia");return Rn(this._apiOptions,this._gluLogic,e,t)}}console.warn("Homag Intelligence plugin is loaded.");const Ve="https://europe-west3-rml-showcases.cloudfunctions.net/proxy_request?url=";class ga extends Qn{constructor(){super(),this._roomlePlanner=null,this._api=null,this._masterData=null,this._emulator=null,this._articles=null,this._scriptLoaded=!1,this._hiLibraryLoaded=!1,this._orders=null,window.uuidv4||(window.uuidv4=ra)}async loadHiLibrary(e,t){if(!this._hiLibraryLoaded){const{masterData:n,calcScriptLoaded:a}=await fa(e,t);this._masterData=n,this._scriptLoaded=a,this._hiLibraryLoaded=!0}return{articles:this._articles,masterData:this._masterData,calcScriptLoaded:this._scriptLoaded}}async init(e,t,n,a,i){this._roomlePlanner=n,this._roomlePlanner.setHomagIntelligence(this),this._api=new ea(this._roomlePlanner);const{masterData:r}=await this.loadHiLibrary(a,i);this._articles=e,this._masterData=r,this._loadMasterData(r);const o={masterData:r,posGroupVersion:1,calculateGroup:l=>window.exports.calc(l),getOrderData:(l,h)=>window.exports.getOrderData(l,h),getAttributesDropDownValues:async l=>{for(const h of l.attributes??[]){const d=window.exports.getAttributesDropDownValues(l,h.id);D(`checks '${d}'`)}return Promise.resolve()},solveModuleAttributeConflict:(l,h,d)=>window.exports.solveModuleAttributeConflict?window.exports.solveModuleAttributeConflict(l,h,d):void 0};return this._emulator=new ta(this._api,o),t.setEmulator(this._emulator),la(this._roomlePlanner,this._emulator),this._emulator.loadPosData(await this._articles,a),this._orders=new da(n,this._emulator,i),this}_loadMasterData(e){if(!this._api)throw new Error("API not initialized");return this._masterData=e,this._api.loadMasterData(e)}getEmulator(){return this._emulator}async sendToOM(e=!1){await this._orders.sendToOM(e)}async fetchPrice(e){return this._orders.fetchPrice(e)}}const ua=Object.freeze(Object.defineProperty({__proto__:null,HOMAG_INTELLIGENCE_ENDPOINT:Ve,HomagIntelligence:ga},Symbol.toStringTag,{value:"Module"})),it=async(s,e,t,n={property:"default"})=>{const a={headers:{"Content-Type":e==="json"?"application/json":"text/plain","Access-Control-Allow-Origin":"*"}};try{const i=performance.now(),{subscriptionId:r,endpointUrl:o}=t,l="",h=await fetch(Ve+encodeURIComponent(s)+`&subscriptionId=${encodeURIComponent(r)}`+(l?`&apiKey=${encodeURIComponent(l)}`:"")+(o?`&baseUrl=${encodeURIComponent(o)}`:""),a),u=performance.now()-i;if(!h.ok)throw console.warn(`Failed to fetch data from ${n.property}`),new Error(`Failed to fetch data from ${s}: ${h.statusText}`);return console.info(`Success to fetch data from ${n.property}`),console.info(`The data for ${n.property} was fetched in ${u} milliseconds`),h}catch(i){throw console.warn(`Failed to fetch data from ${n.property}`),console.error(i),i}},_a=async(s,e)=>{const t=s.includes("nobilia")?`api/pos/libraries/${s}/articles`:`api/pos/articles?libraryId=${s}`;return await(await it(t,"json",e,{property:"articles"})).json()},pa=async(s,e)=>{const t=s.includes("nobilia")?`api/pos/libraries/${s}/masterData`:`api/pos/masterData?libraryId=${s}`;return await(await it(t,"json",e,{property:"masterData"})).json()},ma=async(s,e)=>{const t=s.includes("nobilia")?`api/pos/libraries/${s}/calc.js`:"api/pos/calc.js?libraryId="+encodeURIComponent(s);let a=await(await it(t,"text",e,{property:"calc.js"})).text();if(!a)throw new Error("Script load error");s.includes("nobilia")&&(a=JSON.parse(a)),window.exports={};const i=new Blob([a],{type:"text/javascript"}),r=URL.createObjectURL(i);return await re.import(r),URL.revokeObjectURL(r),!0},fa=async(s,e)=>{const[t,n]=await Promise.all([pa(s,e),ma(s,e)]);return{masterData:t,calcScriptLoaded:n}};class Ca extends nn{constructor(e,t){super(e),this._activePlugins=t||[]}setupGlobals(){}setupDependencies(){an.setup(Xn),this.lookup("logger",this._context),this.lookup("planner-kernel-access",this._context).init(rn.PLANNER)}cleanUpGlobals(){throw new Error("Method not implemented.")}cleanUpDependencies(){throw new Error("Method not implemented.")}async bootFinished(){this._planner=new j(this._context,this._activePlugins),this._planner.getMain=()=>this,window.RoomlePlanner||(this._activePlugins.length===0?window.RoomlePlanner=this._planner:window.RoomlePlanner=this._planner);const e=this.lookup("init-data",this._context);if(e?.hi){const t=_a(e.hi.libraryId,e.hi.serverOptions),n=new nt(this._context,t),a=await Promise.resolve().then(()=>ua);await new a.HomagIntelligence().init(t,n,this._planner,e.hi.libraryId,e.hi.serverOptions)}}getApi(){return this._planner}getContextName(){return C.PLANNER}}Ln("Planner",Ca)}}});
|
|
155
|
-
//# sourceMappingURL=planner-D7lLZxgW.js.map
|