@roomle/web-sdk 2.105.0-alpha.6 → 2.105.0

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.
Files changed (173) hide show
  1. package/lib/{banana-for-scale-2633168c.js → banana-for-scale-33778dbb.js} +2 -2
  2. package/lib/{banana-for-scale-2633168c.js.map → banana-for-scale-33778dbb.js.map} +1 -1
  3. package/lib/{banana-for-scale-7d3eda64.nomodule.js → banana-for-scale-5e2781a3.nomodule.js} +2 -2
  4. package/lib/{banana-for-scale-7d3eda64.nomodule.js.map → banana-for-scale-5e2781a3.nomodule.js.map} +1 -1
  5. package/lib/camera-behaviour-16588b1c.js +2 -0
  6. package/lib/{camera-behaviour-b38936e8.js.map → camera-behaviour-16588b1c.js.map} +1 -1
  7. package/lib/camera-behaviour-dd7a063e.nomodule.js +2 -0
  8. package/lib/{camera-behaviour-d54a163f.nomodule.js.map → camera-behaviour-dd7a063e.nomodule.js.map} +1 -1
  9. package/lib/{component-dimensioning-bfc2cae3.js → component-dimensioning-4ee8f27d.js} +2 -2
  10. package/lib/component-dimensioning-4ee8f27d.js.map +1 -0
  11. package/lib/{component-dimensioning-40501ab3.nomodule.js → component-dimensioning-763769c4.nomodule.js} +2 -2
  12. package/lib/component-dimensioning-763769c4.nomodule.js.map +1 -0
  13. package/lib/{component-raycast-helper-9c21304e.js → component-raycast-helper-7c75e5f0.js} +2 -2
  14. package/lib/component-raycast-helper-7c75e5f0.js.map +1 -0
  15. package/lib/{component-raycast-helper-40bfa0dc.nomodule.js → component-raycast-helper-9e685f1a.nomodule.js} +2 -2
  16. package/lib/component-raycast-helper-9e685f1a.nomodule.js.map +1 -0
  17. package/lib/{configurator-1835defb.js → configurator-cca1c6b9.js} +2 -2
  18. package/lib/configurator-cca1c6b9.js.map +1 -0
  19. package/lib/{configurator-0d266f2d.nomodule.js → configurator-d5e3e975.nomodule.js} +2 -2
  20. package/lib/configurator-d5e3e975.nomodule.js.map +1 -0
  21. package/lib/configurator-main-314fd7d7.js +2 -0
  22. package/lib/configurator-main-314fd7d7.js.map +1 -0
  23. package/lib/configurator-main.nomodule.js +1 -1
  24. package/lib/{continuous-drawing-helper-966ca38e.js → continuous-drawing-helper-18cc6038.js} +2 -2
  25. package/lib/continuous-drawing-helper-18cc6038.js.map +1 -0
  26. package/lib/{continuous-drawing-helper-6f0ede86.nomodule.js → continuous-drawing-helper-7c54ed2c.nomodule.js} +2 -2
  27. package/lib/continuous-drawing-helper-7c54ed2c.nomodule.js.map +1 -0
  28. package/lib/{default-light-setting-dbac7805.js → default-light-setting-427cc173.js} +2 -2
  29. package/lib/default-light-setting-427cc173.js.map +1 -0
  30. package/lib/{default-light-setting-9a50093b.nomodule.js → default-light-setting-b7032eac.nomodule.js} +2 -2
  31. package/lib/default-light-setting-b7032eac.nomodule.js.map +1 -0
  32. package/lib/definitions/common-core/src/utils/threejs-utils.d.ts +1 -1
  33. package/lib/definitions/packages/common-core/src/utils/threejs-utils.d.ts +1 -1
  34. package/lib/{dimensioning-helper-29e6a6ef.nomodule.js → dimensioning-helper-d4726ede.nomodule.js} +2 -2
  35. package/lib/{dimensioning-helper-29e6a6ef.nomodule.js.map → dimensioning-helper-d4726ede.nomodule.js.map} +1 -1
  36. package/lib/{dimensioning-helper-6a37e332.js → dimensioning-helper-d7060dbf.js} +2 -2
  37. package/lib/{dimensioning-helper-6a37e332.js.map → dimensioning-helper-d7060dbf.js.map} +1 -1
  38. package/lib/{glb-viewer-289273d5.js → glb-viewer-56580b03.js} +2 -2
  39. package/lib/{glb-viewer-289273d5.js.map → glb-viewer-56580b03.js.map} +1 -1
  40. package/lib/{glb-viewer-camera-behaviour-7e1b1e90.nomodule.js → glb-viewer-camera-behaviour-67fa46c3.nomodule.js} +2 -2
  41. package/lib/glb-viewer-camera-behaviour-67fa46c3.nomodule.js.map +1 -0
  42. package/lib/{glb-viewer-camera-behaviour-be7c8747.js → glb-viewer-camera-behaviour-bcd098e8.js} +2 -2
  43. package/lib/glb-viewer-camera-behaviour-bcd098e8.js.map +1 -0
  44. package/lib/{glb-viewer-6772ad20.nomodule.js → glb-viewer-fe45c467.nomodule.js} +2 -2
  45. package/lib/{glb-viewer-6772ad20.nomodule.js.map → glb-viewer-fe45c467.nomodule.js.map} +1 -1
  46. package/lib/glb-viewer-main-e1a17a38.js +2 -0
  47. package/lib/glb-viewer-main-e1a17a38.js.map +1 -0
  48. package/lib/glb-viewer-main.nomodule.js +1 -1
  49. package/lib/{imos-ix-poc-export-helper-588a53ab.nomodule.js → imos-ix-poc-export-helper-56fd272c.nomodule.js} +2 -2
  50. package/lib/imos-ix-poc-export-helper-56fd272c.nomodule.js.map +1 -0
  51. package/lib/{imos-ix-poc-export-helper-37572034.js → imos-ix-poc-export-helper-68f83fb7.js} +2 -2
  52. package/lib/imos-ix-poc-export-helper-68f83fb7.js.map +1 -0
  53. package/lib/legacy/{banana-for-scale-5b011d9f.legacy.js → banana-for-scale-2fc610a6.legacy.js} +2 -2
  54. package/lib/legacy/{banana-for-scale-5b011d9f.legacy.js.map → banana-for-scale-2fc610a6.legacy.js.map} +1 -1
  55. package/lib/legacy/camera-behaviour-f5d2fa60.legacy.js +2 -0
  56. package/lib/legacy/{camera-behaviour-2088546c.legacy.js.map → camera-behaviour-f5d2fa60.legacy.js.map} +1 -1
  57. package/lib/legacy/{component-dimensioning-f04cf8d0.legacy.js → component-dimensioning-0224eda5.legacy.js} +2 -2
  58. package/lib/legacy/component-dimensioning-0224eda5.legacy.js.map +1 -0
  59. package/lib/legacy/{component-raycast-helper-967cd80e.legacy.js → component-raycast-helper-6e8975b4.legacy.js} +2 -2
  60. package/lib/legacy/component-raycast-helper-6e8975b4.legacy.js.map +1 -0
  61. package/lib/legacy/{configurator-6d32b749.legacy.js → configurator-0dafcb92.legacy.js} +2 -2
  62. package/lib/legacy/configurator-0dafcb92.legacy.js.map +1 -0
  63. package/lib/legacy/configurator-main.legacy.js +1 -1
  64. package/lib/legacy/{continuous-drawing-helper-6985bc30.legacy.js → continuous-drawing-helper-b2afe8d1.legacy.js} +2 -2
  65. package/lib/legacy/continuous-drawing-helper-b2afe8d1.legacy.js.map +1 -0
  66. package/lib/legacy/{default-light-setting-e6e3c9ef.legacy.js → default-light-setting-05238ba4.legacy.js} +2 -2
  67. package/lib/legacy/default-light-setting-05238ba4.legacy.js.map +1 -0
  68. package/lib/legacy/{dimensioning-helper-1859491f.legacy.js → dimensioning-helper-78fdeba9.legacy.js} +2 -2
  69. package/lib/legacy/{dimensioning-helper-1859491f.legacy.js.map → dimensioning-helper-78fdeba9.legacy.js.map} +1 -1
  70. package/lib/legacy/{glb-viewer-dc032024.legacy.js → glb-viewer-039e52be.legacy.js} +2 -2
  71. package/lib/legacy/{glb-viewer-dc032024.legacy.js.map → glb-viewer-039e52be.legacy.js.map} +1 -1
  72. package/lib/legacy/{glb-viewer-camera-behaviour-9a618475.legacy.js → glb-viewer-camera-behaviour-8a2d4de1.legacy.js} +2 -2
  73. package/lib/legacy/glb-viewer-camera-behaviour-8a2d4de1.legacy.js.map +1 -0
  74. package/lib/legacy/glb-viewer-main.legacy.js +1 -1
  75. package/lib/legacy/{imos-ix-poc-export-helper-e6175ea6.legacy.js → imos-ix-poc-export-helper-eff99220.legacy.js} +2 -2
  76. package/lib/legacy/imos-ix-poc-export-helper-eff99220.legacy.js.map +1 -0
  77. package/lib/legacy/{material-viewer-29935906.legacy.js → material-viewer-75848657.legacy.js} +2 -2
  78. package/lib/legacy/material-viewer-75848657.legacy.js.map +1 -0
  79. package/lib/legacy/material-viewer-main.legacy.js +1 -1
  80. package/lib/legacy/{planner-db6af31d.legacy.js → planner-96b5c06a.legacy.js} +2 -2
  81. package/lib/legacy/{planner-db6af31d.legacy.js.map → planner-96b5c06a.legacy.js.map} +1 -1
  82. package/lib/legacy/planner-main.legacy.js +1 -1
  83. package/lib/legacy/{roomle-configurator-4891f01a.legacy.js → roomle-configurator-88689bbd.legacy.js} +2 -2
  84. package/lib/legacy/{roomle-configurator-4891f01a.legacy.js.map → roomle-configurator-88689bbd.legacy.js.map} +1 -1
  85. package/lib/legacy/{roomle-dependency-injection-5672400b.legacy.js → roomle-dependency-injection-f9e80d9c.legacy.js} +2 -2
  86. package/lib/legacy/{roomle-dependency-injection-5672400b.legacy.js.map → roomle-dependency-injection-f9e80d9c.legacy.js.map} +1 -1
  87. package/lib/legacy/roomle-sdk.legacy.js +1 -1
  88. package/lib/legacy/{script-loader-1e570149.legacy.js → script-loader-c7c8f3b8.legacy.js} +2 -2
  89. package/lib/legacy/script-loader-c7c8f3b8.legacy.js.map +1 -0
  90. package/lib/legacy/{stats-helper-c5311cdc.legacy.js → stats-helper-e205d215.legacy.js} +2 -2
  91. package/lib/legacy/{stats-helper-c5311cdc.legacy.js.map → stats-helper-e205d215.legacy.js.map} +1 -1
  92. package/lib/legacy/{tools-core-26d48a74.legacy.js → tools-core-245e7016.legacy.js} +2 -2
  93. package/lib/legacy/tools-core-245e7016.legacy.js.map +1 -0
  94. package/lib/{material-viewer-28079735.nomodule.js → material-viewer-75a6946b.nomodule.js} +2 -2
  95. package/lib/material-viewer-75a6946b.nomodule.js.map +1 -0
  96. package/lib/{material-viewer-e3e02a19.js → material-viewer-b7225b36.js} +2 -2
  97. package/lib/material-viewer-b7225b36.js.map +1 -0
  98. package/lib/material-viewer-main-5d9fad42.js +2 -0
  99. package/lib/material-viewer-main-5d9fad42.js.map +1 -0
  100. package/lib/material-viewer-main.nomodule.js +1 -1
  101. package/lib/{planner-04496cd9.js → planner-0d5b3552.js} +2 -2
  102. package/lib/{planner-04496cd9.js.map → planner-0d5b3552.js.map} +1 -1
  103. package/lib/{planner-6bde1857.nomodule.js → planner-47be9e18.nomodule.js} +2 -2
  104. package/lib/{planner-6bde1857.nomodule.js.map → planner-47be9e18.nomodule.js.map} +1 -1
  105. package/lib/planner-main-6a885050.js +2 -0
  106. package/lib/planner-main-6a885050.js.map +1 -0
  107. package/lib/planner-main.nomodule.js +1 -1
  108. package/lib/{roomle-configurator-6b12a452.nomodule.js → roomle-configurator-20693b9d.nomodule.js} +2 -2
  109. package/lib/{roomle-configurator-6b12a452.nomodule.js.map → roomle-configurator-20693b9d.nomodule.js.map} +1 -1
  110. package/lib/{roomle-configurator-fee84062.js → roomle-configurator-b014274e.js} +2 -2
  111. package/lib/{roomle-configurator-fee84062.js.map → roomle-configurator-b014274e.js.map} +1 -1
  112. package/lib/{roomle-dependency-injection-04bee035.js → roomle-dependency-injection-40c9e584.js} +2 -2
  113. package/lib/{roomle-dependency-injection-04bee035.js.map → roomle-dependency-injection-40c9e584.js.map} +1 -1
  114. package/lib/{roomle-dependency-injection-f5a3c39f.nomodule.js → roomle-dependency-injection-e3763cd6.nomodule.js} +2 -2
  115. package/lib/{roomle-dependency-injection-f5a3c39f.nomodule.js.map → roomle-dependency-injection-e3763cd6.nomodule.js.map} +1 -1
  116. package/lib/{roomle-sdk-4657770f.js → roomle-sdk-b7447e02.js} +2 -2
  117. package/lib/roomle-sdk-b7447e02.js.map +1 -0
  118. package/lib/roomle-sdk.nomodule.js +1 -1
  119. package/lib/{script-loader-df273d31.js → script-loader-01e992f9.js} +2 -2
  120. package/lib/script-loader-01e992f9.js.map +1 -0
  121. package/lib/{script-loader-ac74eccd.nomodule.js → script-loader-fa13d1f5.nomodule.js} +2 -2
  122. package/lib/script-loader-fa13d1f5.nomodule.js.map +1 -0
  123. package/lib/{stats-helper-94a8807b.nomodule.js → stats-helper-d2c22957.nomodule.js} +2 -2
  124. package/lib/{stats-helper-94a8807b.nomodule.js.map → stats-helper-d2c22957.nomodule.js.map} +1 -1
  125. package/lib/{stats-helper-f1462964.js → stats-helper-dccf2916.js} +2 -2
  126. package/lib/{stats-helper-f1462964.js.map → stats-helper-dccf2916.js.map} +1 -1
  127. package/lib/{tools-core-e655b76b.nomodule.js → tools-core-262d0573.nomodule.js} +2 -2
  128. package/lib/tools-core-262d0573.nomodule.js.map +1 -0
  129. package/lib/{tools-core-bd3d5c0b.js → tools-core-290dd27f.js} +2 -2
  130. package/lib/tools-core-290dd27f.js.map +1 -0
  131. package/package.json +2 -2
  132. package/lib/camera-behaviour-b38936e8.js +0 -2
  133. package/lib/camera-behaviour-d54a163f.nomodule.js +0 -2
  134. package/lib/component-dimensioning-40501ab3.nomodule.js.map +0 -1
  135. package/lib/component-dimensioning-bfc2cae3.js.map +0 -1
  136. package/lib/component-raycast-helper-40bfa0dc.nomodule.js.map +0 -1
  137. package/lib/component-raycast-helper-9c21304e.js.map +0 -1
  138. package/lib/configurator-0d266f2d.nomodule.js.map +0 -1
  139. package/lib/configurator-1835defb.js.map +0 -1
  140. package/lib/configurator-main-08e2552a.js +0 -2
  141. package/lib/configurator-main-08e2552a.js.map +0 -1
  142. package/lib/continuous-drawing-helper-6f0ede86.nomodule.js.map +0 -1
  143. package/lib/continuous-drawing-helper-966ca38e.js.map +0 -1
  144. package/lib/default-light-setting-9a50093b.nomodule.js.map +0 -1
  145. package/lib/default-light-setting-dbac7805.js.map +0 -1
  146. package/lib/glb-viewer-camera-behaviour-7e1b1e90.nomodule.js.map +0 -1
  147. package/lib/glb-viewer-camera-behaviour-be7c8747.js.map +0 -1
  148. package/lib/glb-viewer-main-5f614eaa.js +0 -2
  149. package/lib/glb-viewer-main-5f614eaa.js.map +0 -1
  150. package/lib/imos-ix-poc-export-helper-37572034.js.map +0 -1
  151. package/lib/imos-ix-poc-export-helper-588a53ab.nomodule.js.map +0 -1
  152. package/lib/legacy/camera-behaviour-2088546c.legacy.js +0 -2
  153. package/lib/legacy/component-dimensioning-f04cf8d0.legacy.js.map +0 -1
  154. package/lib/legacy/component-raycast-helper-967cd80e.legacy.js.map +0 -1
  155. package/lib/legacy/configurator-6d32b749.legacy.js.map +0 -1
  156. package/lib/legacy/continuous-drawing-helper-6985bc30.legacy.js.map +0 -1
  157. package/lib/legacy/default-light-setting-e6e3c9ef.legacy.js.map +0 -1
  158. package/lib/legacy/glb-viewer-camera-behaviour-9a618475.legacy.js.map +0 -1
  159. package/lib/legacy/imos-ix-poc-export-helper-e6175ea6.legacy.js.map +0 -1
  160. package/lib/legacy/material-viewer-29935906.legacy.js.map +0 -1
  161. package/lib/legacy/script-loader-1e570149.legacy.js.map +0 -1
  162. package/lib/legacy/tools-core-26d48a74.legacy.js.map +0 -1
  163. package/lib/material-viewer-28079735.nomodule.js.map +0 -1
  164. package/lib/material-viewer-e3e02a19.js.map +0 -1
  165. package/lib/material-viewer-main-7df74726.js +0 -2
  166. package/lib/material-viewer-main-7df74726.js.map +0 -1
  167. package/lib/planner-main-624e6e13.js +0 -2
  168. package/lib/planner-main-624e6e13.js.map +0 -1
  169. package/lib/roomle-sdk-4657770f.js.map +0 -1
  170. package/lib/script-loader-ac74eccd.nomodule.js.map +0 -1
  171. package/lib/script-loader-df273d31.js.map +0 -1
  172. package/lib/tools-core-bd3d5c0b.js.map +0 -1
  173. package/lib/tools-core-e655b76b.nomodule.js.map +0 -1
@@ -1,2 +1,2 @@
1
- System.register(["./script-loader-1e570149.legacy.js","./roomle-dependency-injection-5672400b.legacy.js","./camera-behaviour-2088546c.legacy.js","./main-thread-to-worker-83f62641.legacy.js","./roomle-configurator-4891f01a.legacy.js","./glb-viewer-camera-behaviour-9a618475.legacy.js","./external-objects-b826c1cf.legacy.js","./query-params-helper-1160ef5b.legacy.js","./Object3D-978403f4.legacy.js","./default-light-setting-e6e3c9ef.legacy.js"],(function(e,t){var n,a,i,r,s,o,l,c,h,d,g,u,m,_,p,v,C,f,w,b,P,E,M,I,S,O,y,D,j,H,L,x,A,R,k,B,V,T,F,W,K,U,G,N,z,Z,q,X,J,Q,Y,$,ee,te,ne,ae,ie,re,se,oe,le,ce,he,de,ge,ue,me,_e,pe,ve,Ce,fe,we,be,Pe,Ee,Me,Ie,Se,Oe,ye,De,je,He,Le,xe,Ae,Re,ke,Be,Ve,Te,Fe,We,Ke,Ue,Ge,Ne,ze,Ze,qe,Xe,Je,Qe,Ye,$e,et,tt,nt,at,it,rt,st,ot,lt,ct,ht,dt;return{setters:[function(e){n=e.S,a=e.M},function(e){i=e.n,r=e.E,s=e.q,o=e.F,l=e._,c=e.i,h=e.ax,d=e.y,g=e.M,u=e.N,m=e.ay,_=e.o,p=e.S,v=e.az,C=e.aA,f=e.s,w=e.aB,b=e.p,P=e.C,E=e.aC,M=e.G,I=e.W,S=e.aD,O=e.a5,y=e.aE,D=e.aF,j=e.j,H=e.aG,L=e.aH,x=e.Y,A=e.aI,R=e.aJ,k=e.af,B=e.k,V=e.aK,T=e.aL,F=e.aM,W=e.aN,K=e.Q,U=e.T,G=e.U,N=e.aO,z=e.aP,Z=e.aQ,q=e.aR,X=e.aS,J=e.au,Q=e.at,Y=e.a1,$=e.B,ee=e.aT,te=e.aU,ne=e.K,ae=e.Z,ie=e.z,re=e.aV,se=e.D,oe=e.L,le=e.aW,ce=e.R,he=e.b},function(e){de=e.L,ge=e.b,ue=e.d,me=e.B,_e=e.C,pe=e.e,ve=e.I,Ce=e.f,fe=e.T},function(e){we=e.a,be=e.A,Pe=e.C,Ee=e.D,Me=e.V,Ie=e.al,Se=e.bK,Oe=e.aK,ye=e.bi,De=e.h,je=e.x,He=e.bY,Le=e.b1,xe=e.ak,Ae=e.H,Re=e._,ke=e.e,Be=e.k,Ve=e.ax,Te=e.ay,Fe=e.bq,We=e.a0,Ke=e.aY,Ue=e.ad,Ge=e.g,Ne=e.q,ze=e.a$,Ze=e.aM,qe=e.ca,Xe=e.aN,Je=e.bT,Qe=e.cb,Ye=e.cc,$e=e.cd,et=e.K,tt=e.aZ},function(e){nt=e.S,at=e.b,it=e.C,rt=e.P,st=e.c,ot=e.G,lt=e.R},function(e){ct=e.G},function(e){ht=e.i,dt=e.a},function(){},function(){},function(){}],execute:function(){class gt extends de{constructor(e,t){super(e,t),this._center=new we(0,0,0),this._params={ambientLight:{color:"#ffffff"},hemiLight:{color:"#ffffff"},mainDirLight:{direction:{x:2,y:1,z:2},color:"#ffffff"}},this._ambientLight=new be(new Pe(this._params.ambientLight.color),.4),this._ambientLight.layers.set(1),this._mainDirLight=new Ee(new Pe(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 Me(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 we));const t=new Ie;e.getBoundingSphere(t);const n=t.radius,a=new we(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=i();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(e=>this._ambientLight.color=new Pe(e))}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(e=>this._hemiLight.color=new Pe(e))}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(e=>this._mainDirLight.color=new Pe(e)),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))}}}}const ut=e=>e instanceof s||e instanceof o;class mt{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 _t{constructor(e){const{planElementViewModel:t,resetCamera:n,state:a,oldState:i,reason:r}=e;this.planElementViewModel=t,this.resetCamera=void 0===n||n,this.state=void 0===a?0:a,this.oldState=void 0===i?0:i,this.reason=r}}class pt extends nt{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(4,()=>this._position=null,this),this._raycastHelper.setMode(0),this._raycastHelper.addEventListener(0,()=>{2!==this._state?this._plannerSelectionHandler.cancelSelection("click_outside"):this.resetState()},this),this._plannerSelectionHandler.addEventListener(0,({planElementViewModel:e})=>{this.dispatchEvent(this.isDragIn()?19:0,new _t({planElementViewModel:e}))},this),this._plannerSelectionHandler.addEventListener(2,({planElementViewModels:e})=>{this._roomlePlannerUiCallback.onMultiSelectionChange(e)},this),this._plannerSelectionHandler.addEventListener(3,({selectionMode:e})=>{"multiselect"===e&&this._hoveredObject&&this._hoverOnMultiSelect(this._hoveredObject),this._roomlePlannerUiCallback.onSelectionModeChange(e),this._checkRaycasterSnapping()},this),this._plannerSelectionHandler.addEventListener(1,({planElementViewModel:e,reason:t})=>{1!==this._state&&this.setState(0),this.dispatchEvent(1,new _t({planElementViewModel:e,reason:t}))},this),this._inputManager.addEventListener(6,e=>this._move(e),this)}disable(){const e=new Se;e.disableAll(),this._raycastHelper.setLayers(e),this._raycastHelper.disableEvents()}get planInteractionHandler(){var e;return null===(e=this._plannerKernelAccess)||void 0===e?void 0:e.planInteractionHandler}get hoveredObjectId(){var e;return(null===(e=this._hoveredObject)||void 0===e?void 0:e.getPlanElement())?this._hoveredObject.getId():null}get isCurrentlyDrawing(){return this._isCurrentlyDrawing}enable(){const e=new Se;e.disableAll(),e.enable(3),e.enable(7),e.enable(6),e.enable(9),e.enable(2),this._raycastHelper.setLayers(e),this._raycastHelper.enableEvents()}enableConstructionEvents(e){e?this._raycastHelper.getLayers().enable(9):this._raycastHelper.getLayers().disable(9)}enableObjectEvents(e){e?this._raycastHelper.getLayers().enable(6):this._raycastHelper.getLayers().disable(6)}getSelectionMode(){return this._plannerSelectionHandler.getSelectionMode()}addConstructionPlanObjectHandlers(e,t){t||(t=e.getBoundingBox());const n={planElementName:e.getName(),hasListener:!0,priority:at.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:at.DEFAULT,roomleId:e.getId()};this._addPlanObjectHandlers(e,t,n)}addWallHandlers(e){this._addPlanElementHandlers(e,e.getBoundingBox(),{planElementName:e.getName(),hasListener:!0,ignoreElementHit:!0,priority:at.WALL,roomleId:e.getId()})}addWallAtticHandlers(e){this._addPlanElementHandlers(e,e.getBoundingBox(),{planElementName:e.getName(),hasListener:!0,priority:at.WALL,roomleId:e.getId()})}addMeasurementLineHandlers(e){const t={planElementName:e.getName(),hasListener:!0,priority:at.DEFAULT,roomleId:e.getId()};this._addMeasurementLinePlanElementHandlers(e,e.getPoint1DraggableBoundingBox(),t,h.POINT1),this._addMeasurementLinePlanElementHandlers(e,e.getPoint2DraggableBoundingBox(),t,h.POINT2),this._addMeasurementLinePlanElementHandlers(e,e.getBoundingBox(),t,null)}addFloorHandlers(e){this._addFloorElementHandlers(e,e.getObject(),{planElementName:e.getName(),hasListener:!0,priority:at.FLOOR,roomleId:e.getId()})}addNodeHandlers(e){this._addPlanElementHandlers(e,e.getBoundingBox(),{planElementName:e.getName(),hasListener:!0,priority:at.DEFAULT,ignoreElementHit:!0,roomleId:e.getId()})}_addPlanObjectHandlers(e,t,n){t.userData.hasListener||(t.userData=Oe(t.userData,n),t.addEventListener("select",()=>this._clickElement(e)),t.addEventListener("drag_start",()=>this._dragStart(e)),t.addEventListener("drag",t=>this._drag(e,t.attachment.position)),t.addEventListener("drag_end",t=>this._dragEnd(e,t.attachment.position)),t.addEventListener("hover_on",()=>this._hoverOn(e)),t.addEventListener("hover_off",()=>this._hoverOff(e)),t.addEventListener("rotate",t=>this._rotate(e,t.attachment.rotation)))}_addFloorElementHandlers(e,t,n){this._addElementHandlers(e,t,n)}_addElementHandlers(e,t,n){t.userData.hasListener||(t.userData=Oe(t.userData,n),t.addEventListener("select",()=>this._clickElement(e)),t.addEventListener("double_click",t=>{var n;this._doubleClickElement(e,t.attachment.type,null===(n=t.attachment.intersection)||void 0===n?void 0:n.point)}),t.addEventListener("hover_on",()=>this._hoverOn(e)),t.addEventListener("hover_off",()=>this._hoverOff(e)))}_addPlanElementHandlers(e,t,n){t.userData.hasListener||(this._addElementHandlers(e,t,n),t.addEventListener("drag_start",()=>this._dragStart(e)),t.addEventListener("drag",t=>this._drag(e,t.attachment.position)),t.addEventListener("drag_end",t=>this._dragEnd(e,t.attachment.position)))}_addMeasurementLinePlanElementHandlers(e,t,n,a){if(t.userData.hasListener)return;t.userData=Oe(t.userData,n);const i=()=>{e.currentPoint=a};t.addEventListener("select",()=>{this._clickElement(e),i()}),t.addEventListener("drag_start",()=>{i(),e.selectPointOnDragStart(e),this._dragStart(e)}),t.addEventListener("drag",t=>{i(),e.hideDraggablePointsOnDragStart(e,a),this._drag(e,t.attachment.position)}),t.addEventListener("drag_end",t=>{e.showDraggablePointsOnDragEnd(e,a),this._dragEnd(e,t.attachment.position),e.showDraggableNodes(),i()}),t.addEventListener("hover_on",()=>{i(),e.showDraggablePointsOnHoverOn(e),this._hoverOn(e)}),t.addEventListener("hover_off",()=>{i(),e.showDraggablePointsOnHoverOff(e),this._hoverOff(e)})}_createFloorMeshWithHandler(){const e=new ye(1e3,1e3,8,8),t=new De;t.visible=!1;const n=new je(e,t);n.name="2D raycaster floor mesh",n.rotation.set(-Math.PI/2,0,0),n.layers.enable(2),n.userData.ignoreElementHit=!0;const a={planElementName:"2D raycaster floor mesh",hasListener:!0,priority:at.RAYCASTER_FLOOR,roomleId:void 0};return n.userData=Oe(n.userData,a),n.addEventListener("double_click",e=>{this._doubleClickOnPlane(d(e.attachment.intersection.point),e.attachment.type)}),n.addEventListener("select",e=>{const t=d(e.attachment.intersection.point);this._isCurrentlyDrawing?this._clickOnPlane(t):this._plannerSelectionHandler.cancelSelection("click_outside")}),n}_clickOnPlane(e){this._createNode(null,e)}_doubleClickOnPlane(e,t=0){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){Ht(e,this._initData)?this._plannerSelectionHandler.cancelSelection("click_outside"):this._isCurrentlyDrawing||(e instanceof g&&e.handleDraggablePointsSelection(e),this._debug&&e.getId(),2!==this._state?(this._plannerSelectionHandler.check(e),this._roomlePlannerUiCallback.onClickElement(e),this._setCursor()):this.resetState())}_doubleClickElement(e,t=0,n){if(!this._isDrawingEnabled||!(e instanceof u||e instanceof s))return;let a;this._debug&&e.getId(),e instanceof s&&this._plannerSelectionHandler.cancelSelection("double_click_wall"),e instanceof u?a=e.getPlanElement().getCenter():n&&(a=d(new we(n.x,0,n.z))),this._isCurrentlyDrawing?this.endWallDrawing(null,a):this._startWallDrawing(null,a,t)}_hoverOn(e){e instanceof g&&e.showDraggablePointsOnHoverOn(e),this._isCurrentlyDrawing||("multiselect"===this._plannerSelectionHandler.getSelectionMode()?this._hoverOnMultiSelect(e):this._hoverOnStandard(e))}_hoverOnMultiSelect(e){ut(this._hoveredObject)||ut(e)?(this._hoveredObject=null,He("default")):this._hoverOnStandard(e)}_hoverOnStandard(e){e.hoverOn(),this._hoveredObject=e,this.dispatchEvent(3,new _t({planElementViewModel:e})),this._interaction(),this._setCursor()}_hoverOff(e){e.hoverOff(),e instanceof g&&e.showDraggablePointsOnHoverOff(e),this.dispatchEvent(4,new _t({planElementViewModel:e})),this._interaction(),this._hoveredObject=null,this._setCursor()}_isHoveredObjectNonDraggable(){return this._hoveredObject instanceof o}_setCursor(){4===this._state?He("crosshair"):2===this._state&&this.hasSelection()?He("ew-resize"):1===this._state?He("grabbing"):!this._isHoveredObjectNonDraggable&&this._plannerSelectionHandler.isSelected(this.hoveredObjectId)?He("move"):this._hoveredObject?Ht(this._hoveredObject,this._initData)?He("default"):He("pointer"):3===this._state?He(m?"url('https://res.cloudinary.com/roomle/image/upload/v1664957371/pencil_j5vkhm.svg') 0 15, auto":"url('https://res.cloudinary.com/roomle/image/upload/v1664957371/pencil_j5vkhm.svg') 3 20, auto"):He("default")}setCamera(e){this._raycastHelper.setCamera(e)}setObject(e){this._raycastHelper.setObject(e)}getSelectedIds(){return this._plannerSelectionHandler.getSelectedIds()}setSelectionMode(e){this._plannerSelectionHandler.setSelectionMode(e),"multiselect"===e&&this._roomlePlannerUiCallback.onMultiSelectionChange(this._plannerSelectionHandler.getSelectedPlanElementViewModels())}setPlanViewModel(e){this._planViewModel=e}cancelSelection(e){this.isDragIn()&&"dock_component"===e||this._plannerSelectionHandler.cancelSelection(e)}removeSelection(){this._plannerSelectionHandler.removeSelection()}_dragStart(e){this._isMeasurementLineDrawActive||((this._plannerSelectionHandler.isSelected(e.getId())||this._dragIn)&&0===this._state||this._isDrawingEnabled)&&(this.dispatchEvent(8),Le(w.DRAG).then(()=>{if(this._inputManager.isMouseUp())return this.setState(0),He("pointer"),void this.dispatchEvent(12);this._draggedObject=e,this.setState(1),this._roomlePlannerUiCallback.onDragElementStart(e.getId()),this.dispatchEvent(9,new _t({planElementViewModel:e}))}))}_drag(e,t){if(!this._draggedObject||1!==this._state)return;const n=this.planInteractionHandler;this._lastDragPosition||(this._lastDragPosition=t);let a=t.clone().sub(this._lastDragPosition);if(this._plannerSelectionHandler.getSelectedIds().length>1){const e=new this._plannerKernelAccess.kernelContainer.PlanObjectPtrList;this._plannerSelectionHandler.getSelectedIds().forEach(t=>e.push_back(this._planViewModel.getPlanObjectForId(t).getPlanElement()));const i=d(a);this._plannerSelectionHandler.hasMultiSelection()&&(i.z=0),n.moveObjectsBy(e,i),this._lastDragPosition.copy(t)}else if(e instanceof g)this._dragMeasurementLine(e,t);else if(e instanceof u||e instanceof s){const t=d(a);t.z=0,n.moveElementBy(e.getPlanElement(),t)}else n.moveElementTo(e.getPlanElement(),d(t));this._lastDragPosition.copy(t),this.dispatchEvent(10,new _t({planElementViewModel:e}))}_dragEnd(e,t){this._draggedObject&&(this._draggedObject=null,this._lastDragPosition=null,this.setState(0),this.dispatchEvent(11,new _t({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){var t,n;const a=this._state;this._state=e,this._setCursor(),this.dispatchEvent(2,new _t({state:this._state,oldState:a})),this._position=null,2===this._state?null===(t=this.planInteractionHandler)||void 0===t||t.deactivateAllSnappingActivity():2===a&&(null===(n=this.planInteractionHandler)||void 0===n||n.reactivateAllSnappingActivity())}resetState(){this.setState(0)}_move(e){if(3!==this._state&&4!==this._state&&2===this._state&&this.hasSelection()){this._setCursor();let t=Math.PI/180;const{x:n,y:a}=e.positionRelative;this._position?t=1.4*e.positionRelative.x*Math.PI-1.4*this._position.x*Math.PI:this._position=new we(e.positionRelative.x,e.positionRelative.y,0);const i=new this._plannerKernelAccess.kernelContainer.PlanObjectPtrList,r=new xe;this.getSelectedIds().forEach(e=>{var t;const n=null===(t=this._planViewModel)||void 0===t?void 0:t.getPlanObjectForId(e);n&&n.getObject()&&(i.push_back(n.getPlanElement()),r.expandByObject(n.getContainer()))});const s=r.getCenter(new we);this.planInteractionHandler.rotateObjectsBy(i,t,d(s)),this._position.copy(new we(n,a,0))}}hasSelection(){return this._plannerSelectionHandler.getSelectedIds().length>0}async selectPlanElement(e){(e instanceof _||e instanceof p)&&await e.isInitDone(),this._plannerSelectionHandler.check(e)}_interaction(e){this.dispatchEvent(13,new _t({}))}addComponentDragInHandler(e){if(!this._dragIn)return;const t=e.getBoundingBox(),n=e instanceof b||e instanceof P;this._addPlanElementHandlers(e,t,{planElementName:e.getName(),hasListener:!0,priority:at.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!==v.OFF}enableShowChildrenOfPlanObject(e){this.planInteractionHandler.setShowChildrenOfPlanObject(e,{value:v.GROUND_COMPONENTS},!1)}disableShowChildrenOfPlanObject(e){this.planInteractionHandler.setShowChildrenOfPlanObject(e,{value:v.OFF},!1)}_checkRaycasterSnapping(){const e=this.planInteractionHandler.enableSnap,t="multiselect"===this.getSelectionMode();e&&!t?this._raycastHelper.enableOnWallSnapping():this._raycastHelper.disableOnWallSnapping()}enableWallDrawing(){return this._isDrawingEnabled=!0,this._drawingGroup=new Ae,this._drawingGroup.name="Drawing",this._drawingGroup.add(this._createFloorMeshWithHandler()),this._inputManager.addEventListener(6,this._drawWallOnMouseMove,this),this._inputManager.addEventListener(13,this.endWallDrawing,this),this._drawingGroup}cancelWallDrawing(){return this._isDrawingEnabled=!1,this._setStateAndCursor(0),this._inputManager.removeEventListener(6,this._drawWallOnMouseMove),this._inputManager.removeEventListener(13,this.endWallDrawing),this._raycastHelper.clear(),this._drawingGroup}stopDrawing(e=!0){var t;this.planInteractionHandler.endInteraction(),e&&this.planInteractionHandler.cancelDrawing(),this._raycastHelper.getLayers().enable(9),this._isCurrentlyDrawing=!1,this._setStateAndCursor(0),this.dispatchEvent(7),null===(t=this._continuousDrawingHelper)||void 0===t||t.endDrawing(),this._roomlePlannerUiCallback.onDrawingStateChanged(!1)}startDrawing(){var e;this._isCurrentlyDrawing||(this._isCurrentlyDrawing=!0,this._raycastHelper.getLayers().disable(9),this.dispatchEvent(6),this._setStateAndCursor(3),null===(e=this._continuousDrawingHelper)||void 0===e||e.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){var a,i;(e&&2===e.type||2===n)&&(await this._initMobileDrawing(),this._continuousDrawingHelper.update()),this.planInteractionHandler.startInteraction();const{x:r,y:s}=t||this._getIntersectionPointWithScene(e),o=(null===(i=null===(a=this._initData)||void 0===a?void 0:a.featureFlags)||void 0===i?void 0:i.drawPreviewMode)===C.VECTOR;this.planInteractionHandler.beginDrawing({x:r,y:s,z:0},o),this.startDrawing()}async _initMobileDrawing(){if(this.planInteractionHandler.setDrawingType(0),this.planInteractionHandler.setSnapFeedbackWhileDrawing(!0),!this._continuousDrawingHelper){const{default:e}=await t.import("./continuous-drawing-helper-6985bc30.legacy.js");this._continuousDrawingHelper=new e,this._continuousDrawingHelper.init(this._drawingGroup,this.planInteractionHandler.getContinuousDrawingManager(),this._kernelZoomFactor)}}_drawWallOnMouseMove(e){var t;if(!this._isCurrentlyDrawing||this._isMeasurementLineDrawActive)return;const{x:n,y:a}=this._getIntersectionPointWithScene(e);this.planInteractionHandler.currentDrawingPosition({x:n,y:a,z:0}),null===(t=this._continuousDrawingHelper)||void 0===t||t.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){var t;this._kernelZoomFactor=e,null===(t=this._continuousDrawingHelper)||void 0===t||t.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 6===e?this._drawMeasurementLineOnMouseMove:5===e||14===e||13===e?this._createPlanMeasure:null}_enableDrawingListeners(){[5,6,14,13].forEach(e=>{this._inputManager.addEventListener(e,this._handleMeasurementLineDrawingEvent(e),this)})}_disableDrawingListeners(){[5,6,14,13].forEach(e=>{this._inputManager.removeEventListener(e,this._handleMeasurementLineDrawingEvent(e))})}_drawMeasurementLineOnMouseMove(e){if(!this._currentPlanMeasure)return;4!==this._state&&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){"hide_dragged_node"===e?this._planViewModel.getMeasurementLineObjectViewModels().forEach(e=>{this._currentPlanMeasure.getId()===e.getId()&&e.hidePoint2DraggableNode()}):"showDraggableNodes"===e&&this._planViewModel.getMeasurementLineObjectViewModels().forEach(e=>{this._currentPlanMeasure.getId()===e.getId()&&(e.showDraggableNodes(),e.showDraggablePointsOnDragEnd(e,"point2"))})}_createPlanMeasure(e){const{x:t,y:n}=this._getIntersectionPointWithScene(e),a={x:t,y:n,z:0};if(!this._currentPlanMeasure)return this.dispatchEvent(16),this._currentPlanMeasure=this.planInteractionHandler.addMeasure(a,a),void this._updateMeasurementLineViewModels("hide_dragged_node");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)return void(this._lastDragPosition=t.clone());const a=t.clone().sub(this._lastDragPosition),i=f(n.getCenter()).add(a);return this.planInteractionHandler.moveElementTo(n,d(i)),this._lastDragPosition.copy(t),e.update(),void this.dispatchEvent(18)}e.currentPoint===h.POINT1&&this.planInteractionHandler.setMeasurePoint1(n,d(t),!0,!0),e.currentPoint===h.POINT2&&this.planInteractionHandler.setMeasurePoint2(n,d(t),!0,!0)}setMeasurementLineLength(e,t,n){if(!e)return void console.error("Measurement line not found");const a=t/1e3,i="left"===n.toLowerCase(),r=i?e.getPoint2Draggable().position.clone():e.getPoint1Draggable().position.clone(),s=(new we).subVectors(e.getPoint2Draggable().position,e.getPoint1Draggable().position).normalize().multiplyScalar(a),o=i?r.sub(s):r.add(s);i?this.planInteractionHandler.setMeasurePoint1(e.getPlanElement(),d(o),!1,!1):this.planInteractionHandler.setMeasurePoint2(e.getPlanElement(),d(o),!1,!1)}}l([c],pt.prototype,"_plannerSelectionHandler",void 0),l([c],pt.prototype,"_plannerKernelAccess",void 0),l([c],pt.prototype,"_roomlePlannerUiCallback",void 0),l([c],pt.prototype,"_initData",void 0);const vt=(e,t,n,a)=>{const i=(new xe).setFromObject(e.getContainer()).getCenter(new we);return{runtimeIds:[e.getId()],position2d:E(M(i,t,n,a))}},Ct=e=>{if(e instanceof p){const t=e.getPlanObject().getObjectType();return"door"!==t&&"window"!==t?"static":t}return e instanceof _?"configuration":e instanceof s?"wall":e instanceof o?"floor":e instanceof g?"measure":e instanceof I?"attic":"unknown"};var ft=function(e){function t(){var e;Be(this,t);var n=t.SkyShader,a=new Ve({name:n.name,uniforms:Te.clone(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Fe,depthWrite:!1});return(e=We(this,t,[new Ke(1,1,1),a])).isSky=!0,e}return Re(t,e),ke(t)}(je);ft.SkyShader={name:"SkyShader",uniforms:{turbidity:{value:2},rayleigh:{value:1},mieCoefficient:{value:.005},mieDirectionalG:{value:.8},sunPosition:{value:new we},up:{value:new we(0,1,0)}},vertexShader:"\n\t\tuniform vec3 sunPosition;\n\t\tuniform float rayleigh;\n\t\tuniform float turbidity;\n\t\tuniform float mieCoefficient;\n\t\tuniform vec3 up;\n\n\t\tvarying vec3 vWorldPosition;\n\t\tvarying vec3 vSunDirection;\n\t\tvarying float vSunfade;\n\t\tvarying vec3 vBetaR;\n\t\tvarying vec3 vBetaM;\n\t\tvarying float vSunE;\n\n\t\t// constants for atmospheric scattering\n\t\tconst float e = 2.71828182845904523536028747135266249775724709369995957;\n\t\tconst float pi = 3.141592653589793238462643383279502884197169;\n\n\t\t// wavelength of used primaries, according to preetham\n\t\tconst vec3 lambda = vec3( 680E-9, 550E-9, 450E-9 );\n\t\t// this pre-calculation replaces older TotalRayleigh(vec3 lambda) function:\n\t\t// (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))\n\t\tconst vec3 totalRayleigh = vec3( 5.804542996261093E-6, 1.3562911419845635E-5, 3.0265902468824876E-5 );\n\n\t\t// mie stuff\n\t\t// K coefficient for the primaries\n\t\tconst float v = 4.0;\n\t\tconst vec3 K = vec3( 0.686, 0.678, 0.666 );\n\t\t// MieConst = pi * pow( ( 2.0 * pi ) / lambda, vec3( v - 2.0 ) ) * K\n\t\tconst vec3 MieConst = vec3( 1.8399918514433978E14, 2.7798023919660528E14, 4.0790479543861094E14 );\n\n\t\t// earth shadow hack\n\t\t// cutoffAngle = pi / 1.95;\n\t\tconst float cutoffAngle = 1.6110731556870734;\n\t\tconst float steepness = 1.5;\n\t\tconst float EE = 1000.0;\n\n\t\tfloat sunIntensity( float zenithAngleCos ) {\n\t\t\tzenithAngleCos = clamp( zenithAngleCos, -1.0, 1.0 );\n\t\t\treturn EE * max( 0.0, 1.0 - pow( e, -( ( cutoffAngle - acos( zenithAngleCos ) ) / steepness ) ) );\n\t\t}\n\n\t\tvec3 totalMie( float T ) {\n\t\t\tfloat c = ( 0.2 * T ) * 10E-18;\n\t\t\treturn 0.434 * c * MieConst;\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvec4 worldPosition = modelMatrix * vec4( position, 1.0 );\n\t\t\tvWorldPosition = worldPosition.xyz;\n\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\tgl_Position.z = gl_Position.w; // set z to camera.far\n\n\t\t\tvSunDirection = normalize( sunPosition );\n\n\t\t\tvSunE = sunIntensity( dot( vSunDirection, up ) );\n\n\t\t\tvSunfade = 1.0 - clamp( 1.0 - exp( ( sunPosition.y / 450000.0 ) ), 0.0, 1.0 );\n\n\t\t\tfloat rayleighCoefficient = rayleigh - ( 1.0 * ( 1.0 - vSunfade ) );\n\n\t\t\t// extinction (absorption + out scattering)\n\t\t\t// rayleigh coefficients\n\t\t\tvBetaR = totalRayleigh * rayleighCoefficient;\n\n\t\t\t// mie coefficients\n\t\t\tvBetaM = totalMie( turbidity ) * mieCoefficient;\n\n\t\t}",fragmentShader:"\n\t\tvarying vec3 vWorldPosition;\n\t\tvarying vec3 vSunDirection;\n\t\tvarying float vSunfade;\n\t\tvarying vec3 vBetaR;\n\t\tvarying vec3 vBetaM;\n\t\tvarying float vSunE;\n\n\t\tuniform float mieDirectionalG;\n\t\tuniform vec3 up;\n\n\t\t// constants for atmospheric scattering\n\t\tconst float pi = 3.141592653589793238462643383279502884197169;\n\n\t\tconst float n = 1.0003; // refractive index of air\n\t\tconst float N = 2.545E25; // number of molecules per unit volume for air at 288.15K and 1013mb (sea level -45 celsius)\n\n\t\t// optical length at zenith for molecules\n\t\tconst float rayleighZenithLength = 8.4E3;\n\t\tconst float mieZenithLength = 1.25E3;\n\t\t// 66 arc seconds -> degrees, and the cosine of that\n\t\tconst float sunAngularDiameterCos = 0.999956676946448443553574619906976478926848692873900859324;\n\n\t\t// 3.0 / ( 16.0 * pi )\n\t\tconst float THREE_OVER_SIXTEENPI = 0.05968310365946075;\n\t\t// 1.0 / ( 4.0 * pi )\n\t\tconst float ONE_OVER_FOURPI = 0.07957747154594767;\n\n\t\tfloat rayleighPhase( float cosTheta ) {\n\t\t\treturn THREE_OVER_SIXTEENPI * ( 1.0 + pow( cosTheta, 2.0 ) );\n\t\t}\n\n\t\tfloat hgPhase( float cosTheta, float g ) {\n\t\t\tfloat g2 = pow( g, 2.0 );\n\t\t\tfloat inverse = 1.0 / pow( 1.0 - 2.0 * g * cosTheta + g2, 1.5 );\n\t\t\treturn ONE_OVER_FOURPI * ( ( 1.0 - g2 ) * inverse );\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvec3 direction = normalize( vWorldPosition - cameraPosition );\n\n\t\t\t// optical length\n\t\t\t// cutoff angle at 90 to avoid singularity in next formula.\n\t\t\tfloat zenithAngle = acos( max( 0.0, dot( up, direction ) ) );\n\t\t\tfloat inverse = 1.0 / ( cos( zenithAngle ) + 0.15 * pow( 93.885 - ( ( zenithAngle * 180.0 ) / pi ), -1.253 ) );\n\t\t\tfloat sR = rayleighZenithLength * inverse;\n\t\t\tfloat sM = mieZenithLength * inverse;\n\n\t\t\t// combined extinction factor\n\t\t\tvec3 Fex = exp( -( vBetaR * sR + vBetaM * sM ) );\n\n\t\t\t// in scattering\n\t\t\tfloat cosTheta = dot( direction, vSunDirection );\n\n\t\t\tfloat rPhase = rayleighPhase( cosTheta * 0.5 + 0.5 );\n\t\t\tvec3 betaRTheta = vBetaR * rPhase;\n\n\t\t\tfloat mPhase = hgPhase( cosTheta, mieDirectionalG );\n\t\t\tvec3 betaMTheta = vBetaM * mPhase;\n\n\t\t\tvec3 Lin = pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * ( 1.0 - Fex ), vec3( 1.5 ) );\n\t\t\tLin *= 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 ) );\n\n\t\t\t// nightsky\n\t\t\tfloat theta = acos( direction.y ); // elevation --\x3e y-axis, [-pi/2, pi/2]\n\t\t\tfloat phi = atan( direction.z, direction.x ); // azimuth --\x3e x-axis [-pi/2, pi/2]\n\t\t\tvec2 uv = vec2( phi, theta ) / vec2( 2.0 * pi, pi ) + vec2( 0.5, 0.0 );\n\t\t\tvec3 L0 = vec3( 0.1 ) * Fex;\n\n\t\t\t// composition + solar disc\n\t\t\tfloat sundisk = smoothstep( sunAngularDiameterCos, sunAngularDiameterCos + 0.00002, cosTheta );\n\t\t\tL0 += ( vSunE * 19000.0 * Fex ) * sundisk;\n\n\t\t\tvec3 texColor = ( Lin + L0 ) * 0.04 + vec3( 0.0, 0.0003, 0.00075 );\n\n\t\t\tvec3 retColor = pow( texColor, vec3( 1.0 / ( 1.2 + ( 1.2 * vSunfade ) ) ) );\n\n\t\t\tgl_FragColor = vec4( retColor, 1.0 );\n\n\t\t\t#include <tonemapping_fragment>\n\t\t\t#include <colorspace_fragment>\n\n\t\t}"};const wt=async(e,t,n)=>{const{objects:a,itemIds:i,configurationIds:r}=await(async(e,t)=>{const n=[],a=[],i=[];return await Promise.all(e.map(async e=>{var r;if((null===(r=e.configurationType)||void 0===r?void 0:r.value)!==S.EXTERNAL){const r=O(e);if(r.configurationHash?i.push(r.configurationHash):r.catalogItemId&&a.push(r.catalogItemId),r.parts){const e=r.configurationHash||r.catalogItemId;r.parts=await t.addUiDataAndPriceToPartList(r.parts,e)}if(r.configuration){const e=await t.getConfigurationData(r.runtimeId);r.configuration=e.configuration}r.data=null,n.push(r)}})),{objects:n,itemIds:a,configurationIds:i}})(e,t),{data:s,rootComponentIds:o}=await(async(e=[],t=[],n)=>{const[a,i]=await Promise.allSettled([n.getItems(e),n.getConfigurations(t)]),r=[],s=new Map;if("fulfilled"===a.status)for(const e of a.value)s.set(e.id,e);if("fulfilled"===i.status)for(const e of i.value)s.set(e.id,e),r.push(e.rootComponentId);else console.warn("Could not fetch configuration for data property. This happens when a configuration has not been saved yet");return{data:s,rootComponentIds:r}})(i,r,n),l=await n.getComponents(o),c=new Map;for(const e of l)c.set(e.id,e);for(const e of a){const t=e.catalogItemId||e.configurationHash,n=s.get(e.catalogItemId)||s.get(e.configurationHash)||null;if(n&&!n.label&&c.has(n.rootComponentId)){const e=c.get(n.rootComponentId);n.label=e.label}n&&!n.label&&(n.label=t),e.data=n}return a};class bt extends je{constructor(){const e=new ye(1e3,1e3,8,8);e.rotateX(-Math.PI/2);const t=new De,n=new Ue;n.setPath("static/paper_background-119811362010cc9d.png".startsWith("http")?"":Ge()),n.load("static/paper_background-119811362010cc9d.png",e=>{e.wrapS=Ne,e.wrapT=Ne,e.repeat.set(200,200),t.map=e,t.alphaTest=.3,t.transparent=!0}),super(e,t),this.name="2d paper background",this.position.set(0,-.1,0),this.layers.set(2),this.userData.ignoreElementHit=!0}}class Pt extends ge{get cameraControl(){return this._cameraControl}}class Et extends Pt{get cameraControl(){return this._cameraControl}resetCameraOnPlanCompletelyLoaded(e){this.cameraControl.zoomToFitBounds(y(e,this.cameraControl.domHelper.element.clientWidth,this.cameraControl.domHelper.element.clientHeight,1.1),!0)}externalApiResetCameraPosition(e){this.cameraControl.zoomToFitBounds(y(e,this.cameraControl.domHelper.element.clientWidth,this.cameraControl.domHelper.element.clientHeight,1.1),!0)}resetCameraOnSwitchTo2d(e){this.cameraControl.zoomToFitBounds(y(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 Mt extends Pt{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){n&&(this.cameraControl.setObjectRotation(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 It extends Pt{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 St{constructor(e,t,n){this._sceneEventHandler=e,this._roomleRenderer=t,this._planViewModel=n}_processViewModel(e,t){var n,a,i;e instanceof s&&(null===(a=(n=e.getKernelObject()).getAttachedAttics)||void 0===a?void 0:a.call(n).size())>0?e.getBoundingBox().children.forEach(e=>{e.isChildPlanObject||t.add(e)}):((e instanceof b||e instanceof P)&&e.getTopViewContainer()&&t.add(e.getTopViewContainer()),(null===(i=e.getObject())||void 0===i?void 0:i.children)&&e.getObject().children.forEach(e=>{e.isChildPlanObject||t.add(e)}))}_processSelectedPlanElementIds(e){var t;((null===(t=this._sceneEventHandler)||void 0===t?void 0:t.getSelectedIds())||[]).forEach(t=>{const n=this._planViewModel.getPlanObjectForId(t);n&&this._processViewModel(n,e)})}_highlightPlanElementsBase(e,t){var n;let a=new Set;t&&this._processViewModel(t,a),null==e||e.forEach(e=>{const t=this._planViewModel.getPlanObjectForId(e);t&&this._processViewModel(t,a)}),this._processSelectedPlanElementIds(a),null===(n=this._roomleRenderer)||void 0===n||n.highlightObjects(Array.from(a))}highlightPlanElements(e){this._highlightPlanElementsBase(e)}highlightPlanElement(e){this._highlightPlanElementsBase(void 0,e)}clearHighlighting(){this._highlightPlanElementsBase()}}function Ot(e,t,n,a){e.fromPosition2d=M(e.fromPosition3d,t,n,a),e.toPosition2d=M(e.toPosition3d,t,n,a),e.textPosition2d=M(e.textPosition3d,t,n,a),e.fromWithoutPadding=M(e.fromWithoutPadding,t,n,a),e.toWithoutPadding=M(e.toWithoutPadding,t,n,a)}function yt(e,t,n,a){e.textPosition2d=e.fromPosition3d?M(e.textPosition3d,t,n,a):void 0,e.fromPosition2d=e.fromPosition3d?M(e.fromPosition3d,t,n,a):void 0,e.toPosition2d=e.toPosition3d?M(e.toPosition3d,t,n,a):void 0,e.atticCenterPosition2d=e.atticCenterPosition3d?M(e.atticCenterPosition3d,t,n,a):void 0,e.wallCenterPosition2d=M(e.wallCenterPosition3d,t,n,a),e.labelCPosition2d=M(e.labelCPosition3d,t,n,a),e.labelHeightPosition2d=M(e.labelHeightPosition3d,t,n,a),e.shiftedWallCenter2d=M(e.shiftedWallCenter3d,t,n,a),e.heightAt2mPosition2d=M(e.heightAt2mPosition3d,t,n,a),e.attic2mCornerFrom2d=M(e.attic2mCornerFrom3d,t,n,a),e.attic2mCornerto2d=M(e.attic2mCornerto3d,t,n,a)}function Dt(e,t){const n=new ze(.1,32,16),a=new De({color:16711680}),i=new je(n,a);i.position.copy(e.fromPosition3d);const r=new je(n,a);r.position.copy(e.toPosition3d);const s=new je(n,new De({color:65280}));if(s.position.copy(e.textPosition3d),t.wallPoints.add(i),t.wallPoints.add(r),t.wallPoints.add(s),e.attic){const a=new je(n,new De({color:255}));e.attic.fromPosition3d&&a.position.copy(e.attic.fromPosition3d);const i=new je(n,new De({color:16711935}));e.attic.toPosition3d&&i.position.copy(e.attic.toPosition3d);const r=new je(n,new De({color:16776960}));e.attic.atticCenterPosition3d&&r.position.copy(e.attic.atticCenterPosition3d),t.wallPoints.add(a),t.wallPoints.add(i),t.wallPoints.add(r)}}class jt{static hasNativeClipboardWriteSupport(){return!(!navigator.clipboard||"function"!=typeof navigator.clipboard.writeText)}static async hasNativeClipboardReadSupport(){return!(!navigator.clipboard||"function"!=typeof navigator.clipboard.readText)&&"denied"!==(await navigator.permissions.query({name:"clipboard-read"})).state}static async copy(e){if(this.hasNativeClipboardWriteSupport())try{await navigator.clipboard.writeText(e)}catch(e){console.warn("Native clipboard writeText failed, attempting localStorage fallback.",e)}try{localStorage.setItem(this.LOCAL_STORAGE_KEY,e)}catch(e){console.error("Failed to copy text using localStorage:",e)}}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 null===e?"":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.")}}}function Ht(e,t){const n=Ct(e),a=null==t?void 0:t.lockPlan,i=e&&"getPlanElement"in e&&e.getPlanElement()&&"getAttachedWall"in e.getPlanElement();return!(!a||"wall"!==n&&"floor"!==n&&!i)}jt.LOCAL_STORAGE_KEY="clipboardManagerFallback";const Lt=e=>["altKey","ctrlKey","shiftKey","metaKey"].reduce((t,n)=>(e[n]&&t++,t),0);class xt extends it{constructor(e,t,n,a){var i;super(e,t,a),this._itemsLoadingStatePromises=[],this._staticItemGuard=new j,this._completelyLoaded=!1,this._configurableItemGuard=new j,this._planCompletelyLoadedGuard=new j,this.currentSelection=null,this._paperBackground=null,this._cameraState=null,this._debugSpheres={wallPoints:new Ae,constructionElementsPoints:new Ae,floorPoints:new Ae},this._stopRendering=!0,this._configureInRoom=this._initData.configureInRoom,this._configuratorContext.baseContext="planner",this._roomlePlannerCallback=n,this._plannerMeshGenerator.maxAnisotropy=this._renderer.capabilities.getMaxAnisotropy(),this._plannerMeshGenerator.maxTextures=this._renderer.capabilities.maxTextures,this._plannerSceneEventHandler=new pt(e,this._scene,this.cameraBehaviour.cameraControl.getCamera(),this._getInputManager()),null===(i=this._roomleRenderer)||void 0===i||i.switchToPlanner(H.Mode3D),this._imageRenderer.switchToPlannerSettings(),this._planElementHighlighter=new St(this._plannerSceneEventHandler,this._roomleRenderer,this._getViewModel()),this._plannerSceneEventHandler.addEventListener(2,({state:e,oldState:t})=>{2===t&&e!==t&&this._roomlePlannerUiCallback.onRotationCancel(),2===e||1===e||4===e||3===e?(this.cameraBehaviour.cameraControl.lock(),this._onCameraMove()):(this.cameraBehaviour.cameraControl.unlock(),this._onCameraIdle())},this),this._plannerSceneEventHandler.addEventListener(13,()=>this._renderWithoutShadowsAndAO(),this),this._plannerSceneEventHandler.addEventListener(19,e=>this._activateElement(e),this),this._plannerSceneEventHandler.addEventListener(0,e=>{this._activateElement(e);const t=e.planElementViewModel;this._sendElementMeasurements(),t instanceof p&&this._initData.debug&&t.getGLBUrl(),Ht(t,this._initData)||this._planElementHighlighter.highlightPlanElement(t),this._onSelectionChange(t),this._renderWithoutShadowsAndAO()},this),this._plannerSceneEventHandler.addEventListener(1,({planElementViewModel:e,reason:t})=>{this._planElementHighlighter.clearHighlighting(),this._onSelectionCancel(e,t),this._roomlePlannerUiCallback.onSelectionCancel(t),this._renderWithoutShadowsAndAO()},this),this._plannerSceneEventHandler.addEventListener(8,()=>{this.cameraBehaviour.cameraControl.lock()},this),this._plannerSceneEventHandler.addEventListener(9,({planElementViewModel:e})=>{this._getKernelAccess().planInteractionHandler.startInteraction(),this._sendElementMeasurements(),e instanceof s&&this._sendWallDimensions(),this._requestRender(),this._dragStartBounds=this.getBounds()},this),this._plannerSceneEventHandler.addEventListener(10,({planElementViewModel:e})=>{this.cameraBehaviour.cameraControl.checkNearFarDistance(e.getPosition()),this._requestRender()},this),this._plannerSceneEventHandler.addEventListener(11,async({planElementViewModel:e})=>{const t=this._getKernelAccess().planInteractionHandler;t.endInteraction(),this.cameraBehaviour.cameraControl.unlock();const n=this._getDragPosition(e.getPosition());n&&t.moveElementTo(e.getPlanElement(),d(n)),this.updateEnvironment(this.getBounds(),!0),this._renderEverything();const a=this.getPlanObject(e.getId());let i;a&&(i=await wt([a],this._plannerKernelAccess,this._rapiAccess)),this._roomlePlannerUiCallback.onPlanElementChanged(L.MOVED,i.length?i[0]:{...a,data:null});const r=e instanceof s||e instanceof g||e instanceof u;this._cameraBehaviourState.isWithinPlanBounds(e.getPosition(),this.getBounds())||r||this.plannerCameraBehaviour.updateCameraOnPlanElementDraggedOutsidePlanBounds(this.getBounds())},this),this._plannerSceneEventHandler.addEventListener(12,()=>{this.cameraBehaviour.cameraControl.unlock()},this),this._plannerSceneEventHandler.addEventListener(16,()=>{this.cameraBehaviour.cameraControl.lock()},this),this._plannerSceneEventHandler.addEventListener(18,()=>{this._roomlePlannerUiCallback.onUpdateMeasurementLineDimensions([])},this),this._plannerSceneEventHandler.addEventListener(17,()=>{this.cameraBehaviour.cameraControl.unlock(),this._roomlePlannerUiCallback.onMeasurementLineStateChange(!1)},this),this._plannerSceneEventHandler.addEventListener(6,()=>{var e;this._setKernelZoomFactor(),this._renderWithoutShadowsAndAO(),null===(e=this._roomleRenderer)||void 0===e||e.setGroundShadow(!1)},this),this._plannerSceneEventHandler.addEventListener(5,()=>this._renderWithoutShadowsAndAO(),this),this._plannerSceneEventHandler.addEventListener(7,()=>{var e;this._renderWithoutShadowsAndAO(),null===(e=this._roomleRenderer)||void 0===e||e.setGroundShadow(!0)},this),this._getKernelAccess().addPlannerListener(this),this._plannerMeshGenerator.setMaterialLoadedListener(()=>{this._configurableItemGuard.resolve(),this._requestRender()}),window.onbeforeunload=this.clearScene.bind(this),this._getInputManager().addEventListener(7,this._renderListener,this),this._getInputManager().addEventListener(8,this._renderListener,this),this._getInputManager().addEventListener(3,this._onMouseDown,this),this.disableConfiguratorEvents(),a!==Ze.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 1===new Set(e.map(e=>e.getId())).size}_activateElement({planElementViewModel:e},t=(()=>{})){const n=this._plannerSceneEventHandler.isDragIn()?e:null;this._sendElementMeasurements(n),e instanceof p&&this._initData.debug&&e.getGLBUrl(),Ht(e,this._initData)||this._planElementHighlighter.highlightPlanElement(e),t(),this._renderWithoutShadowsAndAO()}planCleared(){}planHistoryStateChanged(){var e,t;if(this._sendRoomMeasurements(),this._completelyLoaded){const{configuratorId:n}=this._globalInitData,a=null===(t=(null===(e=this._plannerKernelAccess)||void 0===e?void 0:e.planInteractionHandler).getPlan())||void 0===t?void 0:t.getPlanXML(!1,2),i=this._idbManager.getKey(x(),n,this._initData.id);this._idbManager.setValue(i,a,this._idbManager.configStore)}}_getViewModel(){return this._viewModel||(this._viewModel=new rt(this._creator_),this._viewModel.setRequestRenderCallback(()=>this._renderEverything()),this._viewModel.setRequestRenderSceneUpdateCallback(()=>{var e;return null===(e=this._roomleRenderer)||void 0===e?void 0:e.clearCache()}),this._viewModel.setInvalidateRenderCallback(()=>{var e;return null===(e=this._roomleRenderer)||void 0===e?void 0:e.forceShadowUpdates(!0)})),this._viewModel}_getDragPosition(e){if(!this._plannerSceneEventHandler.isDragIn())return null;const t=this._dragStartBounds?this._dragStartBounds:this.getBounds(),n=t.getCenter(new we),a=e.distanceTo(n),i=t.getSize(new we),r=Math.max(i.x,i.z)+3;if(a>r){const t=(new we).subVectors(e,n).normalize();return n.clone().add(t.multiplyScalar(r))}return null}_hideAllMeasurementsNodeOnElementChange(e){this._getViewModel().getMeasurementLineObjectViewModels().forEach(e=>e.hideDraggableNodes()),e instanceof g&&e.showDraggableNodes()}_onSelectionChange(e){this._hideAllMeasurementsNodeOnElementChange(e);const t={};if(e instanceof p&&(t.item=e.getRapiItem(),t.staticItemRuntimeId=e.getPlanElement().getId(),this._configuratorUiCallbacks.onUpdateParameters([])),e instanceof P&&(t.staticItemRuntimeId=e.getPlanElement().getId()),e instanceof _){const n=e.getId(),a=this.getRootPlanObjectId(n),i=this._getViewModel().getPlanObjectForId(a);t.configurationRuntimeId=i.getConfigurationRuntimeId()}if(e instanceof s){const n=this.cameraBehaviour.cameraControl.getKernelZoomFactor(),{clientWidth:a,clientHeight:i}=this._domHelper.element;t.wall=e.getWallDimension(n,a,i)}e instanceof g&&(t.measurementLine=e.getMeasurementLineDimension()),e instanceof o&&(t.staticItemRuntimeId=e.getPlanElement().getId());let n=Ct(e);const a=(async()=>{const t={};if(e instanceof p&&(t.item=e.getRapiItem(),t.staticItemRuntimeId=e.getPlanElement().getId()),e instanceof _){await e.isInitDone();const a=e.getConfigurationRuntimeId();this._getKernelAccess().updatePlanObjectDependencies(a);const i=e.getPlanObject().getCatalogItemId();let r=i;r||(r=this._getKernelAccess().kernelInstance.getHashOfConfiguration(a));const s=this._getKernelAccess().kernelInstance.isExternalPlanObject(a);if(s){const t=this.getRootPlanObjectId(e.getId()),n=this._getViewModel().getPlanObjectForId(t);this._planObjectSelectionChanged(n.getConfigurationRuntimeId(),e.getRootComponentRuntimeId())}let o;if(this._configuratorContext.planObjectId=a,this._configuratorContext.planElementId=e.getId(),this._configuratorContext.rootComponentId=e.getRootComponentRuntimeId(),!s)if(i&&Y(i)){const e=await this._rapiAccess.getItem(i);t.item=e,o=e.rootComponentId?e.rootComponentId:null}else try{const e=await this._rapiAccess.getConfiguration(r);t.configuration=e,o=e.rootComponentId?e.rootComponentId:null}catch(e){console.warn("Could not get RAPI configuration for kernel hash "+r+", saving configuration...");const n=await this._getKernelAccess().getConfigurationData(a),i=await this._rapiAccess.saveConfiguration(n);t.configuration=i,o=i.rootComponentId?i.rootComponentId:null}if(o){const e=await this._rapiAccess.getComponent(o);t.component=e}t.configurationRuntimeId=a,n="configuration"}return t.planElementId=e.getId(),qe(t)})();if(this.currentSelection=qe(t),this._sendElementMeasurements(),this._sendPlanObjectPositions(),e instanceof _){const a=e.getConfigurationRuntimeId();a&&-1!==a&&this._getKernelAccess().kernelInstance.isExternalPlanObject(a)&&(n="external-configuration",t.externalConfigurationType="tc-config")}this._roomlePlannerUiCallback.onSelectionChange(qe(this._plannerSceneEventHandler.getSelectionMode()),qe(n),qe(t),a,e),(e instanceof s||e instanceof u)&&(this._getViewModel().getNodePlanObjectViewModels().forEach(e=>e.show()),this._updateNodeSize()),this._renderWithoutShadowsAndAO()}_onSelectionCancel(e,t){this._getViewModel().getNodePlanObjectViewModels().forEach(e=>e.hide()),this._renderWithoutShadowsAndAO(),this.resetConfiguratorContext(t),this.cancelComponentSelection(!1,t),this._handleMeasurementLineDraggablePoints(e),this.currentSelection=null}_handleMeasurementLineDraggablePoints(e){this._getViewModel().getMeasurementLineObjectViewModels().forEach(e=>{e.hideDraggableNodes(),e.deselectAllDraggablePoints()}),e instanceof g&&(e.deselectAllDraggablePoints(),e.currentPoint=null)}resetConfiguratorContext(e){var t;try{this._configuratorContext.planObjectId&&(null===(t=this.getPlanObject(this._configuratorContext.planElementId).configurationType)||void 0===t?void 0:t.value)===S.EXTERNAL&&this.notifyPlannerOnComponentSelectionCancel(!0,e)}catch(e){console.error(e)}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 gt(this._scene,this._lightSetting)),this._initData.moc||this._addSky(),t||this._setEnvironment(new me(this._scene,this._environment,Xe(this._initData.colors.DEFAULT_BACKGROUND)))}onBeforeRender(){var e;this.cameraBehaviour.cameraControl instanceof _e&&A(this.cameraBehaviour.cameraControl.getCamera(),this._getViewModel().getWallPlanObjectViewModels())&&(null===(e=this._roomleRenderer)||void 0===e||e.forceShadowUpdates(!0))}_getInputManager(){return this._plannerInputManager}createCameraControl(e,t){this.setMode(e)}startViewing(){this._configuratorContext.baseContext="glb-viewer";const e=this._plannerSceneEventHandler.getSelectedIds();if(1===e.length){const t=this._getViewModel().getPlanObjectForId(e[0]);this._setCameraPosition();const n=this.cameraBehaviour.cameraControl.getCurrentCameraParameters();this._changeCameraBehaviour(new ct(this._getCameraControl3D(n),this._cameraBehaviourState)),this.cameraBehaviour.cameraControl instanceof _e&&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(){var e,t,n;this._configuratorContext.baseContext="configurator";let{planElementId:a}=this._configuratorContext;a=this.getRootPlanObjectId(a),this._configuratorContext.planElementId!==a&&this.selectPlanObject(a),this._selectExternalObjectModule();const i=this._getViewModel().getPlanObjectForId(a);this._getViewModel().toggleCeilingLights(!1,this._isInteriorLightActive),this._setCameraPosition();const r=this.cameraBehaviour.cameraControl.getCurrentCameraParameters();this._changeCameraBehaviour(new st(this._getCameraControl3D(r),this._cameraBehaviourState));let s=0,o=0;if(i){this.setRootComponentId(i.getRootComponentRuntimeId());const t=i.getPlanElement().getRotationToPreferredFront();s=t.rotationRoundTo90deg,o=t.lookAtSide.value===R.LEFT?-1:1,null===(e=this._componentRaycastHelper)||void 0===e||e.setObject(i.getObject())}const l=null==i?void 0:i.getConfigurationRuntimeId();this._configuratorContext.planObjectId!==l&&(this._configuratorContext.planObjectId=l),this._plannerSceneEventHandler.removeSelection(),this._planElementHighlighter.clearHighlighting(),this._configureInRoom||this._getViewModel().hideAllExcept(a),this.configuratorCameraBehaviour.resetCameraOnStartConfiguring(this.getBounds(),r,s,o).then(()=>{this.updateEnvironment(this.getBounds(),!0)}),this.setEventHandlerObject(i.getContainer()),this.disablePlannerEvents(),this.enableConfiguratorEvents(),null===(t=this._roomleRenderer)||void 0===t||t.switchToConfigurator(),this._imageRenderer.switchToConfiguratorSettings(),this.updateScene(),this._getKernelAccess().updatePlanObjectDependencies(l),this._getKernelAccess().requestPartListAndUpdatePricesOfParts(),this._getKernelAccess().planObjectUpdated(l,!1);const c=null===(n=this._plannerKernelAccess)||void 0===n?void 0:n.planInteractionHandler;null==c||c.startInteraction()}_setCameraPosition(){this._cameraState=this.cameraBehaviour.cameraControl.getCurrentCameraParameters()}_resetCameraPosition(e){if(this.cameraBehaviour.cameraControl instanceof _e){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 t=this._getViewModel().getPlanObjectForId(e);await this._plannerSceneEventHandler.selectPlanElement(t)}backToPlanner(){var e,t,n,a,i;if("planner"===this._configuratorContext.baseContext)return;if("configurator"===this._configuratorContext.baseContext){const i=null===(e=this._plannerKernelAccess)||void 0===e?void 0:e.planInteractionHandler;null==i||i.endInteraction(),(null===(a=this._getKernelAccess().kernelInstance.getPlanObject(null!==(n=null===(t=this.currentSelection)||void 0===t?void 0:t.configurationRuntimeId)&&void 0!==n?n:0))||void 0===a?void 0:a.externalObject)&&this.notifyPlannerOnComponentSelectionCancel(!0,"isolation_mode_cancelled")}this._configuratorContext.baseContext="planner",this._getViewModel().toggleCeilingLights(!0,this._isInteriorLightActive);const r=this.cameraBehaviour.cameraControl.getCurrentCameraParameters(),s=this._getViewModel().cameraType;this._changeCameraBehaviour(s===Ze.CAMERA_3D||s===Ze.CAMERA_FP?new Mt(this._getCameraControl3D(r),this._cameraBehaviourState):new Et(this._getCameraControl2D(),this._cameraBehaviourState)),this._resetCameraPosition(r),this._getViewModel().showAll(),this.setEventHandlerObject(this._scene),this.enablePlannerEvents();const o=this.cameraBehaviour.cameraControl instanceof _e||this.cameraBehaviour.cameraControl instanceof pe;this._getViewModel().setCameraType(o?Ze.CAMERA_3D:Ze.CAMERA_2D),this.disableConfiguratorEvents(),null===(i=this._roomleRenderer)||void 0===i||i.switchToPlanner(this.cameraBehaviour.cameraControl instanceof _e?H.Mode3D:H.Mode2D),this._imageRenderer.switchToPlannerSettings(),this.updateScene()}_getYRotationOfObject(e){let t=e.getWorldDirection(new we).clone();t.y=0,t.lengthSq()<.01&&(t=new we(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+=2*Math.PI),n}loadStaticPlanObjects(){let e=new Map;this._getViewModel().getStaticPlanObjectViewModels().forEach(t=>{let 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=>{let n=[];t.forEach(t=>{this._getKernelAccess().catalogItemLoaded(t),e.get(t.id).forEach(e=>{n.push(new Promise((n,a)=>{e.setRapiItem(t).then(()=>{this._requestRender(),n()},a)}))})}),Promise.all(n).then(()=>this._staticItemsLoaded())})}requestCatalogItem(e){this._rapiAccess.getItem(e).then(e=>{this._getKernelAccess().catalogItemLoaded(e)})}_staticItemsLoaded(){this._requestRender(),this._staticItemGuard.resolve(),this._roomlePlannerUiCallback.onItemsLoaded()}preload(e){this._planId=e;let t=this._localStorageHelper.getItem(this._planId,"rml_plans");t&&this._loadGLTF(t).then(e=>{this._preloadScene=e,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(e=>e.hide()),this._getViewModel().getMeasurementLineObjectViewModels().forEach(e=>e.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();let e=new ye(1e3,1e3);e.rotateX(-Math.PI/2);let t=k.createMeshStandardMaterial({color:"#f0f0f0",roughness:1,metalness:0,depthWrite:!1}),n=new je(e,t);n.name="Ground",n.position.y=-.01,n.userData.isFloor=!0,this._scene.add(n)}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=B(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(),"planner"===this._configuratorContext.baseContext&&this.plannerCameraBehaviour.resetCameraOnPlanCompletelyLoaded(this.getBounds()),this._completelyLoaded=!0,this._readyForRender()}beginPlanConstruction(e){}addPlanMesh(e,t,n,a,i,r,s){}endPlanConstruction(e){this._renderLoopFunction=()=>{var e;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(),(null===(e=this._lightSetting)||void 0===e?void 0:e.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((e,a)=>(t=e,n=a));this._itemsLoadingStatePromises.push(a);const i=e.getContainer();V(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 s;r&&(s=await wt([r],this._plannerKernelAccess,this._rapiAccess)),this._roomlePlannerUiCallback.onPlanElementChanged(L.ADDED,s.length?s[0]:{...r,data:null});const o=e instanceof _||e instanceof p;this._initData.featureFlags.interiorLights&&((e,t,n)=>{var a,i,r;const s=null===(a=e.getRapiItem)||void 0===a?void 0:a.call(e);if(s&&("lamp_ceiling"===s.detailType||"lamp_standing"===s.detailType))if("brands_15:flos_aim"===(null==s?void 0:s.id)){const a={x:-.45,y:-.37,z:.35},i={x:.38,y:.31,z:-.17};t.handleLampLight(e,{targetPos:a,lightPos:i,active:n})}else if("brands_26:diesel_with_foscarini_fork"===(null==s?void 0:s.id)){const a={x:0,y:-.56,z:-.49},i={x:.01,y:1.62,z:0};t.handleLampLight(e,{targetPos:a,lightPos:i,color:16768955,decay:0,active:n})}if("brands_26:diesel_with_foscarini_duii"===(null==s?void 0:s.id)){const a={x:-1.4,y:-.74,z:-.07},i={x:.07,y:.59,z:0};t.handleLampLight(e,{targetPos:a,lightPos:i,color:16777215,decay:2,active:n})}if("ba6d0d48:lights-kitchen"===(null==s?void 0:s.id)){const a={width:2.45,height:.03},i={x:0,y:1.571,z:-1.05};t.handleRectLampLight(e,{dimensions:a,lightPos:i,color:16777215,active:n});const r={width:.03,height:2.17},s={x:1.195,y:1.033,z:0};t.handleRectLampLight(e,{dimensions:r,lightPos:s,color:16777215,active:n})}if("roomle_white_furniture:Lighting_Pendant_lamp_02"===(null===(r=null===(i=e.getRapiItem)||void 0===i?void 0:i.call(e))||void 0===r?void 0:r.id)){const a={x:0,y:-99,z:0},i={x:0,y:.15,z:0};t.handleLampLight(e,{targetPos:a,lightPos:i,color:16445391,decay:1,intensity:1,active:n})}})(e,this._getViewModel(),this._isInteriorLightActive),o&&!this._plannerSceneEventHandler.isDragIn()&&this.cameraBehaviour instanceof Pt&&(T(this.cameraBehaviour.cameraControl.getCamera(),e.getBounds())?this.plannerCameraBehaviour.updateCameraOnPlanElementInsertedInsideCurrentCameraView(this.getBounds()):this.plannerCameraBehaviour.updateCameraOnPlanElementInsertedOutsideCurrentCameraView(this.getBounds()))}catch(e){console.error(e),n()}t()}removePlanObjectFromScene(e){(e instanceof s||e instanceof u)&&this._sendWallDimensions(),e instanceof g&&this._sendMeasurementLineDimension(),this._scene.remove(e.getContainer()),e.clear(),this.updateEnvironment(this.getBounds(),!0),e instanceof s||e instanceof g||e instanceof u||"planner"!==this._configuratorContext.baseContext||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 e=this.getPlanObject(t.getId());this._roomlePlannerUiCallback.onPlanElementChanged(L.MOVED,{...e,data:null})}t instanceof s&&e.extRef&&e.extRef.jsObject&&this._isInteriorLightActive&&e.extRef.jsObject.handleCeilingLights()}exportGLB(e,t){}importGLB(e){this._loadGLB(e).then(e=>this._scene.add(e))}clearScene(){this._plannerMeshGenerator.clear(),this._getViewModel().sceneCleared(),super.clearScene()}_addSky(){if(!this._sky){this._sky=new ft,this._sky.name="Sky",this._sky.scale.setScalar(45e4),this._sky.frustumCulled=!1,this._scene.add(this._sky),this._sky.material.uniforms.turbidity.value=10,this._sky.material.uniforms.rayleigh.value=2,this._sky.material.uniforms.mieCoefficient.value=.005,this._sky.material.uniforms.mieDirectionalG.value=.8;let e=F(4e5,0,.6);this._sky.material.uniforms.sunPosition.value.copy(e);let t=new je(new ze(2e4,16,8),new De({color:16777215}));t.name="Sunsphere",t.position.y=-7e5,t.visible=!1,t.position.set(e.x,-e.z,e.y)}this._lightSetting instanceof gt&&this._lightSetting.updateSunPosition(.6,0)}toggleConfigureInRoom(){this._configureInRoom=!this._configureInRoom,this._roomleRenderer.isConfiguring&&(this._configureInRoom?this._getViewModel().showAll():this._hideAllExceptSelectedElement(),this._renderEverything(),this.updateScene())}switchTo2D(){var e,t,n,a,i;if(!((null===(e=this.cameraBehaviour)||void 0===e?void 0:e.cameraControl)instanceof ue)){(null===(t=this.cameraBehaviour)||void 0===t?void 0:t.cameraControl)instanceof pe&&this._getCameraControlFirstPerson().cleanUp(),null===(n=this._roomleRenderer)||void 0===n||n.setCameraType(Ze.CAMERA_2D),null===(a=this._plannerSceneEventHandler)||void 0===a||a.enable();for(const e of this._getViewModel().getWallPlanObjectViewModels())e.show();this._getViewModel().setCameraType(Ze.CAMERA_2D).then(()=>this._planElementHighlighter.highlightPlanElement()),null===(i=this._roomleRenderer)||void 0===i||i.switchToPlanner(H.Mode2D),this._renderEverything(),this._changeCameraBehaviour(new Et(this._getCameraControl2D(),this._cameraBehaviourState)),this._onCameraMove(),this.plannerCameraBehaviour.resetCameraOnSwitchTo2d(this.getBounds()),this._addCameraControlListener(),this._setCeiling(),this._roomlePlannerUiCallback.onCameraChanged(Ze.CAMERA_2D),this._setKernelZoomFactor(),this._onCameraMove(),this._sendRoomMeasurements()}}switchTo3D(){var e,t,n,a;(null===(e=this.cameraBehaviour)||void 0===e?void 0:e.cameraControl)instanceof _e||(null===(t=this._roomleRenderer)||void 0===t||t.setCameraType(Ze.CAMERA_3D),null===(n=this._plannerSceneEventHandler)||void 0===n||n.enable(),this._getViewModel().setCameraType(Ze.CAMERA_3D),null===(a=this._roomleRenderer)||void 0===a||a.switchToPlanner(H.Mode3D),this._renderEverything(),this._changeCameraBehaviour(new Mt(this._getCameraControl3D(),this._cameraBehaviourState)),this._onCameraMove(),this.plannerCameraBehaviour.resetCameraOnSwitchTo3d(this.getBounds()),this._addCameraControlListener(),this._setCeiling(),this._roomlePlannerUiCallback.onCameraChanged(Ze.CAMERA_3D))}switchToFirstPerson(){var e,t,n;(null===(e=this.cameraBehaviour)||void 0===e?void 0:e.cameraControl)instanceof pe||(null===(t=this._roomleRenderer)||void 0===t||t.setCameraType(Ze.CAMERA_FP),null===(n=this._plannerSceneEventHandler)||void 0===n||n.disable(),this._plannerMeshGenerator.wallMeshes.forEach(e=>W(e.material,!1,!1)),this._getViewModel().getWallPlanObjectViewModels().forEach(e=>{e.show()}),this._getViewModel().setCameraType(Ze.CAMERA_FP),this._renderEverything(),this._changeCameraBehaviour(new It(this._getCameraControlFirstPerson(),this._cameraBehaviourState)),this._addCameraControlListener(),this._setCeiling(),this._roomlePlannerUiCallback.onCameraChanged(Ze.CAMERA_FP),this.plannerCameraBehaviour.resetCameraOnSwitchToFirstPerson())}onCameraChanged(){}_setCameraControlListeners(){super._setCameraControlListeners(),this.cameraBehaviour instanceof Pt&&(this.cameraBehaviour.cameraControl.addEventListener(8,()=>{this._onCameraIdle()},this),this.cameraBehaviour.cameraControl.addEventListener(1,()=>{this._onCameraMove()},this),this.cameraBehaviour.cameraControl.addEventListener(7,()=>{this._onCameraMove()},this),this.cameraBehaviour.cameraControl.addEventListener(3,()=>{this._onCameraMove()},this),this.cameraBehaviour.cameraControl.addEventListener(4,()=>{this._onCameraMove()},this),this.cameraBehaviour.cameraControl.addEventListener(5,()=>{this._onCameraZoomChange()},this))}_onCameraZoomChange(){this._setKernelZoomFactor()}_setKernelZoomFactor(){var e,t;const n=this.cameraBehaviour.cameraControl.getKernelZoomFactor();n&&isFinite(n)&&n>=0&&(null===(e=this._getKernelAccess().planInteractionHandler)||void 0===e||e.setZoomFactor(n)),null===(t=this._plannerSceneEventHandler)||void 0===t||t.setKernelZoomFactor(n)}_setCeiling(){this._getViewModel()&&(this.cameraBehaviour.cameraControl instanceof pe?this._getViewModel().getCeilingGroup().visible=!0:this._getViewModel().getCeilingGroup().visible=!1)}cameraBehaviourChanged(){var e;super.cameraBehaviourChanged(),null===(e=this._plannerSceneEventHandler)||void 0===e||e.setCamera(this.cameraBehaviour.cameraControl.getCamera()),this._updatePaperBackground()}_updatePaperBackground(){var e,t;this.cameraBehaviour.cameraControl instanceof ue?(this._paperBackground||(this._paperBackground=new bt),null===(e=this._scene)||void 0===e||e.add(this._paperBackground),this._requestRender()):this._paperBackground&&(null===(t=this._scene)||void 0===t||t.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),Je(e)){const t=Lt(e),n=e.metaKey&&"Meta"===e.key||e.ctrlKey&&"Control"===e.key,a=t>1?"standard":n?"multiselect":"standard";this._plannerSceneEventHandler.setSelectionMode(a)}this._checkPanning(e),this._plannerSceneEventHandler&&this._plannerSceneEventHandler.hasSelection()&&e.key&&("Backspace"===e.key||"Delete"===e.key)&&(this.deletePlanElementSelection(),e.preventDefault())}async _checkCopyPaste(e){if(Je(e)&&"c"===e.key){const e=this._plannerSceneEventHandler.getSelectedIds(),t=[];e.forEach(e=>{const n=this._getViewModel().getPlanObjectForId(e).getPlanElement(),a=n.getCatalogItemId()||n.getConfigurationHash();t.push(a)}),jt.copy(t.join())}if(Je(e)&&"v"===e.key){const e=await jt.paste();if(e){const t=e.split(",").map(e=>Qe(e)||e).filter(e=>e.includes(":"));this._insertRapiItems(t)}}}_checkPanning(e){(!0===e.shiftKey||e.key&&e.key.includes("Shift"))&&this.cameraBehaviour.cameraControl instanceof _e&&(this.cameraBehaviour.cameraControl.enablePanning(),e.preventDefault())}_onMouseDown(e){"event"in e&&this._checkPanning(e.event)}_checkNumKey(e){e.key&&"1"===e.key&&(this.switchTo2D(),e.preventDefault()),e.key&&"2"===e.key&&(this.switchTo3D(),e.preventDefault()),e.key&&"3"===e.key&&(this.switchToFirstPerson(),e.preventDefault())}_onKeyUp(e,t=!1){if(super._onKeyUp(e,t),Je(e,!0)){const t=Lt(e);let n="standard";Ye(e)||1!==t||(n="multiselect"),this._plannerSceneEventHandler.setSelectionMode(n),e.preventDefault()}e.key&&e.key.includes("Shift")&&this.cameraBehaviour.cameraControl instanceof _e&&(this.cameraBehaviour.cameraControl.disablePanning(),e.preventDefault()),!e.key||"Escape"!==e.key&&"Esc"!==e.key||this._drawingEnabled&&(this.escapeDrawing(!0),this._roomlePlannerUiCallback.onDrawCancel())}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 Ze.CAMERA_2D:this.switchTo2D();break;case Ze.CAMERA_3D:this.switchTo3D();break;case Ze.CAMERA_FP:this.switchToFirstPerson()}}_clearHighlighting(){this._planElementHighlighter.clearHighlighting(),this._renderWithoutShadowsAndAO()}highlightPlanElementsById(e){null!==e?this._planElementHighlighter.highlightPlanElements(e):this._clearHighlighting()}highlightPlanElementById(e){if(null===e)return void this._clearHighlighting();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){let e=t.extRef.jsObject.getPlanObject().getConfigurationRuntimeId();e>0&&this._getViewModel().constructComponents(e)}}async planObjectConfigurationChanged(e,t){const n=this.getPlanObject(t.getId());let a;!n||t instanceof _||t instanceof P||(a=await wt([n],this._plannerKernelAccess,this._rapiAccess)),this._roomlePlannerUiCallback.onPlanElementChanged(L.CHANGED,(null==a?void 0: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"configurator"===this._configuratorContext.baseContext?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){var t;if(!(null===(t=this._plannerKernelAccess)||void 0===t?void 0:t.kernelContainer))return e;const n=this._getKernelAccess().planInteractionHandler,a=this._plannerKernelAccess.planModelViewHelper,i=n.getPlan();return a.getRootPlanObjectId(i,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 e=this._getViewModel().getPlanObjectForId(t);if(e&&e.getObject()){const t=this.getPlanObject(e.getId());let n;t&&(n=await wt([t],this._plannerKernelAccess,this._rapiAccess)),this._roomlePlannerUiCallback.onPlanElementChanged(L.REMOVED,n.length?n[0]:{...t,data:null}),this._getKernelAccess().planInteractionHandler.removeElement(e.getKernelObject())}}}rotatePlanElements(e,t){const n=new(this._getKernelAccess().kernelContainer.PlanObjectPtrList),a=new xe;let i={x:0,y:0,z:0};if(e.forEach(e=>{const t=this._getViewModel().getPlanObjectForId(e);t&&t.getObject()&&(i=t.getPlanElement().getCenter(),n.push_back(t.getPlanElement()),a.expandByObject(t.getContainer()))}),n.size()>1){const e=a.getCenter(new we);i=d(e)}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"configurator"===this._configuratorContext.baseContext&&t?super.preparePerspectiveImage(e):new Promise(t=>{this._getViewModel().materialQueue.finished(!0).then(async()=>{var n,a,i;let r=e.runtimeIds?K.getCameraTargetForBBox(this._getViewModel().getBoundingBoxFromRuntimeIds(e.runtimeIds),.1):this._calculateBoundingBoxOfAllMeshes(.1);null===(n=this._lightSetting)||void 0===n||n.removeFromScene();const s=[];if(this.cameraBehaviour.cameraControl instanceof _e){await this._getViewModel().setCameraType(Ze.CAMERA_2D),this._getViewModel().setNodeVisibility(!1);for(const e of this._getViewModel().getWallPlanObjectViewModels())e.isVisible()||s.push(e),e.show()}e.runtimeIds&&this._getViewModel().hideAllExceptRuntimeIds(e.runtimeIds);let o=await this._imageRenderer.prepareTopImage(this._scene,null,r,e);if(e.runtimeIds&&this._getViewModel().showAll(),this.cameraBehaviour.cameraControl instanceof _e&&await this._getViewModel().setCameraType(Ze.CAMERA_3D),s.length)for(const e of s)e.hide();null===(a=this._lightSetting)||void 0===a||a.addToScene(),null===(i=this._roomleRenderer)||void 0===i||i.clearCache(),this._requestRender(),t(o)})})}preparePerspectiveImageOf(e,t={}){const n=this._getViewModel().getPlanObjectForId(e);if(!n){const t="Object with runtimeId "+e+" not found";throw console.warn(t),new Error(t)}return this._preparePerspectiveImage({...t,object:n.getObject().clone()})}async _waitForAssets(){await super._waitForAssets(),await this._getViewModel().materialQueue.finished(!0)}_preparePerspectiveImage(e={},t){if("configurator"===this._configuratorContext.baseContext&&t)return super.preparePerspectiveImage(e);const n=this._handlePlannerIsolationModeState(t);return new Promise((t,a)=>{this._getViewModel().materialQueue.finished(!0).then(async()=>{var a,i,r;let s;this.cameraBehaviour.cameraControl instanceof _e?s=this.cameraBehaviour.cameraControl.getCamera().clone():(s=this.getPerspectiveOffsetCamera().clone(),this._getViewModel().getCeilingGroup().visible=!1,s.layers.enableAll(),this._getViewModel().setCameraType(Ze.CAMERA_3D)),s.resetOffset();let o=e.object?K.getCameraTargetForBBox((new xe).setFromObject(e.object)):e.runtimeIds?K.getCameraTargetForBBox(this._getViewModel().getBoundingBoxFromRuntimeIds(e.runtimeIds)):this._calculateBoundingBoxOfAllMeshes();null===(a=this._lightSetting)||void 0===a||a.removeFromScene();let l=e.object?U(this._scene):this._scene;e.object&&l.add(e.object),e.runtimeIds&&this._getViewModel().hideAllExceptRuntimeIds(e.runtimeIds);const c=await this._imageRenderer.preparePerspectiveImage(l,null,s,o,e,void 0,e=>{A(e,this._getViewModel().getWallPlanObjectViewModels())});G(s),e.runtimeIds&&this._getViewModel().showAll(),e.object&&G(l),this.cameraBehaviour.cameraControl instanceof ue?(this._getViewModel().setCameraType(Ze.CAMERA_2D),this._getViewModel().getWallPlanObjectViewModels().forEach(e=>e.show())):A(this.cameraBehaviour.cameraControl.getCamera(),this._getViewModel().getWallPlanObjectViewModels()),null===(i=this._lightSetting)||void 0===i||i.addToScene(),null===(r=this._roomleRenderer)||void 0===r||r.clearCache(),this._requestRender(),this._setCeiling(),n(),t(c)},a)})}_handlePlannerIsolationModeState(e){if(!e){const e=this._configuratorContext.baseContext;return this._getViewModel().showAll(),this._configuratorContext.baseContext="planner",()=>{this._configuratorContext.baseContext=e,"configurator"===e&&(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 K.getCameraTargetForBBox(t,e)}enableRotation(){this._plannerSceneEventHandler.setState(2)}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 _){const t=e.getKernelObject();return this._plannerSceneEventHandler.showsChildrenOfPlanObject(t)}return!1}enableShowChildrenOfPlanObject(e){if(e instanceof _){const t=e.getKernelObject();this._plannerSceneEventHandler.enableShowChildrenOfPlanObject(t)}}disableShowChildrenOfPlanObject(e){if(e instanceof _){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 ue){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 xe;for(const t of e){const e=this._getViewModel().getPlanObjectForId(t);e&&i.expandByObject(e.getContainer())}const r=i.getCenter(new we),s=E(M(r,t,n,a));this._roomlePlannerUiCallback.onUpdatePlanObjectPositions([{runtimeIds:e,position2d:s}])}_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 a of r)i.push(vt(a,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 s of e){const e=s.getFloorData(r);if(!e||!e.textPosition3d)return;if(e.roomLabel=s.getKernelObject().getLabelObject(),e.formattedArea=this._unitFormatter.formatSquareMMValueToUnitString(e.area),e.textPosition2d=M(e.textPosition3d,t,n,a),i.push(N(e)),this._initData.debug){const t=new ze(.1,32,16),n=new De({color:255}),a=new je(t,n);a.position.copy(e.textPosition3d),this._debugSpheres.floorPoints.add(a)}}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 ue&&(this._sendConstructionElementDimensions(e),this._sendObjectMeasurements(e),this._sendMeasurementLineDimension())}_sendRoomMeasurements(){this.cameraBehaviour.cameraControl instanceof ue&&(this._sendWallDimensions(),this._sendRoomAreaData())}_sendMeasurementLineDimension(){if(!(this.cameraBehaviour.cameraControl instanceof ue))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 i=r.getMeasurementLineDimension();i.fromPosition2d=M(i.fromPosition3d,e,t,n),i.toPosition2d=M(i.toPosition3d,e,t,n),i.textPosition2d=M(i.textPosition3d,e,t,n),i.lengthFormatted=this._unitFormatter.formatMMValueToUnitString(i.length),a.push(z(i))}this._roomlePlannerUiCallback.onUpdateMeasurementLineDimensions(a)}_sendObjectMeasurements(e){if(!(this.cameraBehaviour.cameraControl instanceof ue))return;if(!this.currentSelection&&!e)return;const t=this._plannerSceneEventHandler.getSelectedIds();if(0===t.length&&!e)return;const n=e||this._getViewModel().getPlanObjectForId(t[0]);if(!n||n instanceof b||n instanceof P||!(n instanceof p)&&!(n instanceof _))return;const a=this.cameraBehaviour.cameraControl.getCamera(),{clientWidth:i,clientHeight:r}=this._domHelper.element,s=this.cameraBehaviour.cameraControl.getKernelZoomFactor(),o=n.getObjectMeasurements(s,i,r),l=this.transformMeasurements(o.rectMeasurements,a,i,r),c=this.transformMeasurements(o.objectMeasurements,a,i,r),h=this.transformMeasurements(o.objectToWallsMeasurements,a,i,r);this._roomlePlannerUiCallback.onUpdateObjectMeasurements({rectMeasurements:l,objectMeasurements:c,objectToWallsMeasurements:h})}transformMeasurements(e,t,n,a){return e.map(e=>{const i=M(e.fromPosition3d,t,n,a),r=M(e.toPosition3d,t,n,a),s=M(e.textPosition3d,t,n,a);return Z({...e,fromPosition2d:i,toPosition2d:r,textPosition2d:s})})}_sendConstructionElementDimensions(e){if(!this.currentSelection&&!e)return;const t=e||this._getViewModel().getPlanObjectForId(this.currentSelection.staticItemRuntimeId||this.currentSelection.configurationRuntimeId);if(!t||!(t instanceof b||t instanceof P))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(),s=t.getConstructionElementMeasurements(r,a,i);if(!s)return;if(this._initData.debug){const e=new De({color:16711680}),t=new De({color:65280}),n=new De({color:255}),a=new ze(.1,32,16),i=new je(a,e);i.position.copy(s.leftMeasurement.fromPosition3d),i.position.y=5;const r=new je(a,e);r.position.copy(s.leftMeasurement.toPosition3d),r.position.y=5;const o=new je(a,t);o.position.copy(s.rightMeasurement.fromPosition3d),o.position.y=5;const l=new je(a,t);l.position.copy(s.rightMeasurement.toPosition3d),l.position.y=5;const c=new je(a,n);c.position.copy(s.elementRange.fromPosition3d),c.position.y=5;const h=new je(a,n);h.position.copy(s.elementRange.toPosition3d),h.position.y=5,this._debugSpheres.constructionElementsPoints.add(i),this._debugSpheres.constructionElementsPoints.add(r),this._debugSpheres.constructionElementsPoints.add(o),this._debugSpheres.constructionElementsPoints.add(l),this._debugSpheres.constructionElementsPoints.add(c),this._debugSpheres.constructionElementsPoints.add(h)}s.leftMeasurement=this._updateMeasurementPositions(s.leftMeasurement,n,a,i),s.rightMeasurement=this._updateMeasurementPositions(s.rightMeasurement,n,a,i),s.elementRange=this._updateMeasurementPositions(s.elementRange,n,a,i);const o={leftMeasurement:{...q(s.leftMeasurement)},rightMeasurement:{...q(s.rightMeasurement)},elementRange:{...q(s.elementRange)}};this._roomlePlannerUiCallback.onUpdateConstructionElementsMeasurements(o)}_sendWallDimensions(e=!0){this._initData.debug&&this._debugSpheres.wallPoints.children.length>0&&this._debugSpheres.wallPoints.clear(),function(e,t,n,a,i,r,s,o=!0,l=!1){if(!(t.cameraControl instanceof ue))return;if(t.cameraControl.isLocked()&&o)return;const c=[],{x:h,y:d}=e.getClientDimensions(),g=i.getWallPlanObjectViewModels(),u=t.cameraControl.getKernelZoomFactor(),m=t.cameraControl.getCamera();for(const e of g){const t=e.getWallDimension(u,h,d);t.isCurrentlyDrawn=a.isCurrentlyDrawing&&e.getPlanElement().getTo().extRef.jsObject===i.latestNodePlanObjectViewModel;const{isVectorWall:n}=e.getKernelObject();t.length<=0&&!n||(Ot(t,m,h,d),t.attic&&yt(t.attic,m,h,d),t.lengthFormatted=r.formatMMValueToUnitString(t.length),l&&Dt(t,s),c.push(D(t)))}n.onUpdateWallDimensions(c)}(this._domHelper,this.cameraBehaviour,this._roomlePlannerUiCallback,this._plannerSceneEventHandler,this._getViewModel(),this._unitFormatter,this._debugSpheres,e,this._initData.debug)}enableWallDrawing(){if(this.cameraBehaviour.cameraControl instanceof ue){const e=y(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)}setSceneEvents(e){var t,n;this.cameraBehaviour.cameraControl instanceof pe||(void 0!==e.construction&&(null===(t=this._plannerSceneEventHandler)||void 0===t||t.enableConstructionEvents(e.construction)),void 0!==e.objects&&(null===(n=this._plannerSceneEventHandler)||void 0===n||n.enableObjectEvents(e.objects)))}startedDrawing(){this._plannerSceneEventHandler.startDrawing(),this._showWallNodes()}stoppedDrawing(){this._plannerSceneEventHandler.stopDrawing()}disableEvents(){super.disableEvents(),this.disablePlannerEvents()}enableEvents(){super.enableEvents(),"planner"!==this._configuratorContext.baseContext||this.cameraBehaviour.cameraControl instanceof pe||this.enablePlannerEvents()}resetCameraPositionToStart(){this.plannerCameraBehaviour.externalApiResetCameraPosition(this.getBounds())}async moveCamera(e){return this.plannerCameraBehaviour instanceof Mt||this.plannerCameraBehaviour instanceof st?this.plannerCameraBehaviour.externalApiMoveCamera(e):Promise.resolve()}_setInteriorOrExteriorWallMaterial(e,t){const n=this._getViewModel().getWallPlanObjectViewModels();if(!n.length)return;const a=this._getKernelAccess().planInteractionHandler,i=e=>{a.setWallLeftMaterial(e,$e(e.leftMaterial,t))},r=e=>{a.setWallRightMaterial(e,$e(e.rightMaterial,t))},s=n.map(e=>e.getKernelObject()),o=this._plannerKernelAccess.kernelContainer.WallType.InnerWall,l=this._plannerKernelAccess.kernelContainer.WallType.OuterWallLeft,c=this._plannerKernelAccess.kernelContainer.WallType.OuterWallRight;for(const t of s)t.wallType===o&&"interior"===e&&(i(t),r(t)),t.wallType===l&&("interior"===e?r(t):i(t)),t.wallType===c&&("exterior"===e?r(t):i(t))}changeInteriorWallsMaterial(e){this._setInteriorOrExteriorWallMaterial("interior",e)}changeExteriorWallsMaterial(e){this._setInteriorOrExteriorWallMaterial("exterior",e)}changeFloorsMaterial(e){const t=this._getViewModel().getFloorPlanObjectViewModels();if(!t.length)return;const n=this._getKernelAccess().planInteractionHandler,a=t.map(e=>e.getKernelObject());n.startInteraction();for(const t of a)n.setFloorMaterial(t,$e(t.material,e));n.endInteraction()}getWallAngleDegrees(e){if(!(e instanceof s))return 0;const t=this.cameraBehaviour.cameraControl.getCamera(),n=new Me(t.position.x,t.position.z),a=new Me(e.getPosition().x,e.getPosition().z).clone().sub(n).normalize(),i=e.getKernelObject(),r=new Me(Math.sin(i.getAngle()),Math.cos(i.getAngle())),o=a.angle()-r.angle();return et.radToDeg(o)}moveElementPosition(e,t){const n=this._getKernelAccess().planInteractionHandler;n.setObjectFixedZ(e.getPlanElement(),!0);const a=e.getPlanElement().getCenter(),i=f(t).sub(f(a));n.moveElementBy(e.getPlanElement(),d(i)),n.setObjectFixedZ(e.getPlanElement(),!1),this._sendPlanObjectPositions()}moveElementsPosition(e,t){const n=new this._plannerKernelAccess.kernelContainer.PlanObjectPtrList;let a=f(t).sub(e[e.length-1].getPosition());e.forEach(e=>n.push_back(e.getPlanElement()));const i=d(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 Mt&&this.plannerCameraBehaviour.enablePanningOnShiftClick()}disablePanning(){this.plannerCameraBehaviour instanceof Mt&&this.plannerCameraBehaviour.disablePanningOnShiftRelease()}setObjectToWallMeasurementLength(e,t,n){const a=this._getViewModel().getPlanObjectForId(e),i=a.getPlanElement(),r=X(i.getWallDistances()).find(e=>tt(e.angle+"_"+e.length)===t);if(!r)return;const s=f(r.startPoint),o=f(r.endPoint),l=s.clone().sub(o).normalize(),c=(n-r.length)/1e3,h=a.getPosition().clone().add(l.multiplyScalar(c));this._getKernelAccess().planInteractionHandler.moveElementTo(i,d(h)),this._sendObjectMeasurements()}setWallMeasurementLength(e,t,n){const a=this.getPlannerSceneEventHandler().isCurrentlyDrawing,i=this._getKernelAccess().planInteractionHandler;let r=this._getViewModel().getPlanObjectForId(e);const s=i.isVectorPreviewModeEnabled();if(a&&!s){const e=this._getViewModel().latestNodePlanObjectViewModel,t=d(e.getPosition());i.endDrawing(t),this.escapeDrawing(!1),r=this._getViewModel().latestWallPlanObjectViewModel}if(r){const e=r.getKernelObject();i.startInteraction(),i.setLengthOfWall(e,t,e.getPreferredSide(),n,!0),i.endInteraction()}if(a&&!s){i.startInteraction();const e=this._getViewModel().latestNodePlanObjectViewModel,t=d(e.getPosition());i.beginDrawing(t,!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(){this._roomlePlannerUiCallback.onReadyForRender(),this._globalCallback.onReadyForRender()}notifyPlannerOnComponentSelectionCancel(e,t){var n;if(e)if("configurator"===this.configuratorContext.baseContext){if("click_outside"===t){let e=this.getObjectComponent(null!==(n=this.configuratorContext.rootComponentId)&&void 0!==n?n:this.configuratorContext.planObjectId);this._roomlePlannerUiCallback.onExternalObjectModuleSelected(e.externalObjectGroupId,null,null)}}else this._roomlePlannerUiCallback.onExternalObjectSelectionCancel(t);else this._roomlePlannerUiCallback.onComponentSelectionCancel()}_planObjectSelectionChanged(e,t){var n,a;const i=this.getObjectComponent(null!=t?t:e);if((null===(n=null==i?void 0:i.configurationType)||void 0===n?void 0:n.value)!==S.EXTERNAL)return;let r=this.getObjectComponent(null!==(a=this.configuratorContext.selectedRuntimeComponentId)&&void 0!==a?a:this.configuratorContext.planObjectId);r.externalRootModuleId===i.externalRootModuleId&&r.externalSubModuleId===i.externalSubModuleId||this._getKernelAccess().planObjectSelectionChanged(e,t)}highlightExternalObject(e){this.highlightPlanElementById(e.runtimeId),this._renderWithoutShadowsAndAO()}_selectExternalObjectModule(){var e,t;(null===(e=this._getKernelAccess())||void 0===e?void 0:e.kernelContainer)&&!this._configuratorContext.selectedRuntimeComponentId&&(null===(t=this.getPlanObject(this._configuratorContext.planElementId).configurationType)||void 0===t?void 0:t.value)===S.EXTERNAL&&this.selectComponent(this._configuratorContext.rootComponentId)}getObjectComponent(e){const t=this._getKernelAccess().planInteractionHandler.getPlan();return this._getKernelAccess().planModelViewHelper.getObjectComponent(t,e)}getCameraParameters3d(){return this._getViewModel().cameraType===Ze.CAMERA_3D?this.cameraBehaviour3d.cameraControl.getCurrentCameraParameters():null}_createCeilingLightGroup(){this._scene.children.find(e=>e.name===ot)||this._scene.add(this._getViewModel().getCeilingLightsGroup())}toggleInteriorLightsSceneSettings(e){this._isInteriorLightActive=e;const t=this.getScene();t.userData.environmentDefinition.rotation=e?ve:J,t.userData.environmentDefinition.intensity=e?Ce:Q,this._isInteriorLightActive&&(this._createCeilingLightGroup(),this._activateCeilingLight()),this._renderEverything()}async _insertRapiItems(e){const t=e.map((e,t)=>({id:e,index:t})),n=[];for(const{index:e,id:a}of t)n.push({index:e,id:a});return await this.insertRapiObjects(n)}async insertRapiObjects(e){const t=e.map(({id:e})=>Y(e)?this._rapiAccess.getItem(e):this._rapiAccess.getConfiguration(e)),n=await Promise.all(t);return(await this._plannerKernelAccess.insertItems(n)).map((t,n)=>({runtimeId:t,originalIndex:e[n].index}))}}l([c],xt.prototype,"_rapiAccess",void 0),l([c],xt.prototype,"_plannerMeshGenerator",void 0),l([c],xt.prototype,"_plannerInputManager",void 0),l([c],xt.prototype,"_roomlePlannerUiCallback",void 0),l([c],xt.prototype,"_localStorageHelper",void 0),l([c],xt.prototype,"_unitFormatter",void 0);const At="Could not retrieve configuration for external object! Did you implement onGetConfigurationForExternalObject?",Rt={left:0,top:1,right:1,bottom:0};class kt{constructor(e,t){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 $.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=d(new we(t.x,t.y,t.z)));const a=await(Y(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=O(this._plan.getPlanObjects());return(null==i?void 0: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,ee.ROOM_DESIGNER):this._rapiAccess.trackView("planXML",ee.ROOM_DESIGNER)),n()})}loadPlan(e,t){return this.setOverrides(t),new Promise((t,n)=>{const a=te(e);(a?this._rapiAccess.getPlanSnapshot(e):this._rapiAccess.getPlan(e)).then(n=>{this._sceneManager.backToPlanner(),this._sceneManager.setCompletelyLoaded(!1);const i=a?n.plan:n.planObjects;this._plan=this._planInteractionHandler.loadPlanXML(i),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,ee.ROOM_DESIGNER),t(n)},n)})}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){Promise.all([this._scriptLoader.fetch(fe,{id:"tween-js"})]).then(()=>{this._kernelReadyCallback=e;const{dls:t,ls:n,mode:a,stats:i}=this._initData;this._sceneManager||(this._sceneManager=new xt(this._creator_,Rt,this,a)),this._preloadPlanId&&this._sceneManager.preload(this._preloadPlanId);const r=ne.createDynamicLightSettingSource(t,n);i&&this.showStats(),this._sceneManager.enableHD(r),this._planInteractionHandler&&this._kernelReadyCallback()})}isReady(){this._planInteractionHandler=this._plannerKernelAccess.planInteractionHandler,this._kernelReadyCallback&&this._kernelReadyCallback()}showBenchmarks(){$.showBenchmarks()}getConfiguratorApi(){return this._configurator||(this._configurator=new lt(this._creator_,this._activePlugins),this._configurator.setOverrides(this._initData),this._configurator.initSceneManager(this._sceneManager)),this._configurator}startViewing(){this._sceneManager.startViewing(),this._roomlePlannerUiCallback.onContextChanged("glb-viewer")}startConfiguring(){var e,t;const n=this._sceneManager.currentSelection,a=(null===(e=n.item)||void 0===e?void 0:e.id)||(null===(t=n.configuration)||void 0===t?void 0:t.id);this._sceneManager.startConfiguring(),a&&this._configurator.notifyUiAboutNewLabel(a),this._roomlePlannerUiCallback.onContextChanged("configurator")}async selectPlanObjectById(e){return this._sceneManager.selectPlanObject(e)}highlightPlanElements(e){null===e?this._sceneManager.highlightPlanElementsById(null):Array.isArray(e)?this._sceneManager.highlightPlanElementsById(e):this._sceneManager.highlightPlanElementById(e)}backToPlanner(){this._sceneManager.backToPlanner(),this._roomlePlannerUiCallback.onContextChanged("planner")}showGUI(){this._sceneManager.showGUI()}async switchToConfigurator(){const e=await this._singlePromiseFactory.create(3,"startHSC",e=>{if(this._hscInstance)return e(this._hscInstance);t.import("./configurator-6d32b749.legacy.js").then(({Configurator:t})=>{const n=new t(this._creator_);n.boot({kernelInstance:this._planInteractionHandler.getConfiguratorKernel(),kernelContainer:this._plannerKernelAccess.kernelContainer}),n.getApi().setOverrides(this._initData),n.getApi().initSceneManager(this._sceneManager),n.getApi().init(this._domHelper.element).then(()=>{this._hscInstance=n,e(this._hscInstance)})})});return this._currentMode=0,this.cancelSelection("isolation_mode_started"),e}async switchToViewer(){const e=await this._singlePromiseFactory.create(4,"startGLB",e=>{if(this._glbInstance)return e(this._glbInstance);t.import("./glb-viewer-dc032024.legacy.js").then(t=>{const n=new t.GlbViewer(this._creator_);n.boot(),n.getApi().setOverrides(this._initData),n.getApi().init(this._domHelper.element).then(()=>{this._glbInstance=n,e(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(2===this._currentMode&&this._glbInstance&&this._glbInstance.getApi().clearScene(),0===this._currentMode&&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){}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=d(new we(t.x,t.y,t.z))),ht(e)){if(t||n)throw new Error("External objects do not support position and rotation");return this._insertExternalObject(e)}const a=await(Y(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(0===e.length)return[];const t=e.map((e,t)=>({id:e,index:t})),n=async(e,t)=>({runtimeId:await this._insertExternalObject(e),originalIndex:t}),a=[],i=[];for(const{index:e,id:r}of t)ht(r)?a.push(n(r,e)):i.push({index:e,id:r});const r=this._sceneManager.insertRapiObjects(i),[s,o]=await Promise.all([Promise.all(a),r]),l=[...s,...o];return l.sort((e,t)=>e.originalIndex-t.originalIndex),l.map(e=>e.runtimeId)}async insertItems(e){if(0===e.length)return[];const t=e.map(e=>"string"==typeof e?e:e.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=O(e.objects);return wt(t,this._plannerKernelAccess,this._rapiAccess)}async getPlanOverview(){const e=(await this.getPlanModelViewHelper()).getPlanOverview(this._plan);return O(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("multiselect"),this._configuratorContext.selectionMode="multiselect"}disableMultiselect(){this._sceneManager.getPlannerSceneEventHandler().setSelectionMode("standard"),this._configuratorContext.selectionMode="standard"}async _insertExternalObject(e,t={}){var n,a,i;let r=e;if(ht(e)&&(r=await this._roomlePlannerUiCallback.onGetConfigurationForExternalObject(e),!r))throw new Error(At);if(dt(e)&&(null===(n=e.externalMeta)||void 0===n?void 0:n.refresh)&&(r=await this._roomlePlannerUiCallback.onGetConfigurationForExternalObject(e.id),!r))throw new Error(At);const s=null===(a=t.findFreeSpaceInPlan)||void 0===a||a,o=null!==(i=t.dragIn)&&void 0!==i&&i;return await this._loadExternalObjectGroup(r,s,o,!1),-1}async dragInObject(e,t,n="rml_id"){if("rml_serialized"===n)throw new Error("dragInObject is not supported for tc_id or rml_serialized");if(this._sceneManager.dragIn(t),"rml_id"===n){const t=Y(e)?await this._rapiAccess.getItem(e):await this._rapiAccess.getConfiguration(e),n=await this.insertItems([t]);if(1!==n.length)throw new Error("More than one object added, abort");return n[0]}if("tc_id"===n||"tc_serialized"===n)return this._insertExternalObject(e,{dragIn:!0});throw new Error("dragInObject is not supported for "+n)}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 e="Object has no partlist because it is not a configuration: "+t;return console.warn(e),Promise.reject(e)}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={}){var n,a;const i=this._planInteractionHandler;i.startInteraction();const r=[];for(const t of e){const e=i.addNode(t.from),s=i.addNode(t.to),o=i.addWall(e,s);void 0!==(null===(n=t.props)||void 0===n?void 0:n.height)&&i.setWallHeight(o,t.props.height),void 0!==(null===(a=t.props)||void 0===a?void 0:a.thickness)&&i.setWallThickness(o,t.props.thickness),r.push(o)}return t.keepInteractionOpen||i.endInteraction(),this._sceneManager.updateCameraOnDrawWalls(),this._sceneManager.updateScene(),r}async removeElements(e,t={}){this._sceneManager.lockCamera();const n=this._planInteractionHandler;for(const t of e){const e=this._sceneManager.getPlanObject(t.getId());let n;e&&(n=await wt([e],this._plannerKernelAccess,this._rapiAccess)),this._roomlePlannerUiCallback.onPlanElementChanged(L.REMOVED,(null==n?void 0:n.length)?n[0]:{...e,data:null}),this._planInteractionHandler.removeElement(t)}t.keepInteractionOpen||n.endInteraction(),this._sceneManager.unlockCamera()}hasWalls(){const e=this._planInteractionHandler,t=null==e?void 0:e.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=O(t.getExternalObjectGroups(n));if(0===a.length)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(e=>e.uniqueId),a=t.map(e=>e.runtimeId),i=await this.getPlanModelViewHelper(),r=this._planInteractionHandler.getPlan(),s=i.getPlanOverview(r),o={parentId:e||null,planObjects:[],combinedIds:[],plan:r.createPlanXmlWithObjects(n,!1,2)},l=s.objects,c=l.size();for(let e=0;e<c;e++){const t=l.get(e),n=t.configurationHash||t.catalogItemId;if(a.includes(t.runtimeId)){const{center:e,dimensions:a,rotation:i,rootComponentCenter:r}=t,s=JSON.stringify({center:e,dimensions:a,rotation:i,rootComponentCenter:r});o.planObjects.push({combinedId:n,position:s})}}const h=await this._rapiAccess.savePlanSnapshot(o);this._plannerKernelAccess.planSnapshotCreated(h);const d=new Promise((e,t)=>{Promise.allSettled([this.preparePerspectiveImage({runtimeIds:a}),this.prepareTopImage({runtimeIds:a})]).then(async([n,a])=>{if("rejected"!==n.status&&"rejected"!==a.status)try{const t=await this._rapiAccess.savePlanSnapshotImage(h,n.value,"perspectiveImage",a.value,"topImage");e({...t})}catch(e){t(e)}else t("Could not generate images of plan snapshot")})});try{return await d}catch(e){return console.error(e),h}}async saveCurrentPlanSnapshot(e,t){const n=await this.getPlanModelViewHelper(),a=this._planInteractionHandler.getPlan(),i=n.getPlanOverview(a),r={parentId:e||null,planObjects:[],combinedIds:[],plan:t?a.createPlanXmlWithObjects(t,!1,2):a.getPlanXML(!1,2)},s=i.objects,o=s.size();for(let e=0;e<o;e++){const n=s.get(e),a=n.configurationHash||n.catalogItemId;if(!t||a===t){const{center:e,dimensions:t,rotation:i,rootComponentCenter:s}=n,o=JSON.stringify({center:e,dimensions:t,rotation:i,rootComponentCenter:s});r.planObjects.push({combinedId:a,position:o})}}const l=await this._rapiAccess.savePlanSnapshot(r);this._plannerKernelAccess.planSnapshotCreated(l);const c=new Promise((e,t)=>{Promise.allSettled([this.preparePerspectiveImage(),this.prepareTopImage()]).then(async([n,a])=>{if("rejected"!==n.status&&"rejected"!==a.status)try{const t=await this._rapiAccess.savePlanSnapshotImage(l,n.value,"perspectiveImage",a.value,"topImage");e({...t})}catch(e){t(e)}else t("Could not generate images of plan snapshot")})});try{return await c}catch(e){return console.error(e),l}}getPlanXmlFrom(e){return e?te(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){const n=e.getPosition(),a=e.getRotation();return await this._sceneManager.deletePlanElementByIds([e.getPlanElement().getId()]),this.cancelSelection("swap_object"),await this.insertObject(t,n,a)}exportImageFromCamera(e="image",t=!1){return 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(e){return console.error(e),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 t.import("./imos-ix-poc-export-helper-e6175ea6.legacy.js");return e((await this.getPlanModelViewHelper()).getPlanOverview(this._plan),this._plannerKernelAccess.configurationExporter,this._plannerKernelAccess.kernelInstance)}async configureExternalObjectApi(e){let t="string"==typeof e?JSON.parse(e):e;await this._plannerKernelAccess.configureExternalObjectApi(t)}loadExternalObjectLibrary(e){const t=this._planInteractionHandler.getConfiguratorKernel(),n="string"==typeof e?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=[]){"configurator"===this.getConfiguratorContext().baseContext?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=[]){var r;const s=this.getConfiguratorContext(),o=this._sceneManager.getPlanObject(s.planElementId);if(await this._loadOrUpdateExternalObjectGroup(e,t,n,a,i,!1),(null===(r=o.configurationType)||void 0===r?void 0:r.value)===S.EXTERNAL)if(i.includes(o.configurationHash)){const t=this._createSerializedGroupCollection(e),n=JSON.parse(t[0]).id;await this._selectExternalObjectGroup(n,!1)}else await this._selectExternalObjectGroup(o.configurationHash,!1);this.updateScene()}async _loadOrUpdateExternalObjectGroup(e,t,n,a,i,r){const s=this._createSerializedGroupCollection(e);n?this._planInteractionHandler.startInteraction():this._planInteractionHandler.resumeInteraction();const o=n&&!r?this._getFaceTheCameraAngle(90):0,l={findFreeSpaceInPlan:t,applyGlobalChildMode:!1,isVisible:!n,correctArrangement:a},c=this._planInteractionHandler.addOrUpdateExternalPlanObjects(s,{x:0,y:0,z:0},o,l,i);n||this._planInteractionHandler.endInteraction();const h=this._planInteractionHandler.getPlan().extRef.jsObject,d=[];for(const e of c)e.hasConfiguration()&&d.push(h.getConfigurablePlanObjectForId(e.getId()));await Promise.all(d.map(async e=>{await e.isInitDone()}))}_createSerializedGroupCollection(e){const t=Array.isArray(e)?e:[e],n=[];for(const e of t){const t="string"==typeof e?e:JSON.stringify(e);n.push(t)}return n}_getFaceTheCameraAngle(e){const t=this._sceneManager.getCameraParameters3d();if(!(null==t?void 0:t.yaw))return 0;const n=ae(t.yaw),a=Math.round(n/e)*e;return ie(a)}async renderImagesOfExternalObjectGroup(e){const t=Array.isArray(e)?e:[e],n={},a=this._initData.animateCamera;this._initData.animateCamera=!1;for(const e of t){try{await this._loadExternalObjectGroup(e,!1,!1,!1),await this._selectExternalObjectModule(e.id,null,!0,!0,!1,!1),this.preparePerspectiveImage(),await this._sceneManager.waitForMaterialQueue(),this.updateScene();const t=await this.exportCanvasScreenshot();n[e.id]=t}catch(e){console.error(e)}this.backToPlanner()}for(const e of t)await this.removeExternalObjectGroup(e.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"),0!==i.runtimeId&&(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){"configurator"===this.getConfiguratorContext().baseContext||this._planInteractionHandler.setShowChildrenOfExternalObject(e,{value:v.OFF},!1),await this._selectExternalObjectGroup(e,!0),this.updateScene()}async selectExternalObjectRootModule(e){const t="configurator"===this.getConfiguratorContext().baseContext;t||this._planInteractionHandler.setShowChildrenOfExternalObject(e,{value:v.GROUND_COMPONENTS},!1),await this._selectExternalObjectModule(e,null,!t,t,!0,!0),this.updateScene()}async selectExternalObjectSubModule(e,t){const n="configurator"!==this.getConfiguratorContext().baseContext;await this._selectExternalObjectModule(e,t,n,!0,!0,!0),this.updateScene()}async openOrCloseGeometryOfExternalObject(e,t,n,a){const i=await this.getPlanModelViewHelper(),r=this._planInteractionHandler.getPlan(),s=i.getExternalObjectComponent(r,e,"");if(null==s?void 0:s.configurationRuntimeId){const e=n?"open":"close";this._sceneManager.animateElement(s.configurationRuntimeId,"openClose",e,!0,a),this.updateScene()}}async _selectKernelComponent(e){e.configurationHash&&e.configurationType.value===S.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,"");0!==i.runtimeId&&(t&&await this._roomlePlannerUiCallback.onBackToPlanner(),await this._sceneManager.selectPlanObject(i.runtimeId))}async _selectExternalObjectModule(e,t,n,a,i,r){const s=await this.getPlanModelViewHelper(),o=this._planInteractionHandler.getPlan(),l=s.getExternalObjectComponent(o,e,null!=t?t:"");if(0===l.runtimeId)return;const c="configurator"===this.getConfiguratorContext().baseContext,h=this._getSelectedPlanObjectComponent();let d=!1,g=n;c&&(d=(null==h?void 0:h.configurationRuntimeId)===l.configurationRuntimeId,g=!d,d||this._sceneManager.backToPlanner()),g&&await this._selectPlanObject(l),a&&!d&&await this._roomlePlannerUiCallback.onStartConfiguring(),0!==l.planComponentRuntimeId&&i&&this._sceneManager.selectComponent(l.planComponentRuntimeId,!1),r&&!c&&this._sceneManager.highlightExternalObject(l)}async _selectPlanObject(e){let t=e.runtimeId;const n=O(this._plan.getPlanObjects());for(const a of n)if(a.getConfigurationRuntimeId()===e.planComponentRuntimeId){t=a.getId();break}await this._sceneManager.selectPlanObject(t)}_getSelectedPlanObjectComponent(){var e;const t=this.getConfiguratorContext(),n=null!==(e=t.selectedRuntimeComponentId)&&void 0!==e?e:t.planObjectId;return this._sceneManager.getObjectComponent(n)}async getExternalObjectGroups(){const e=await this.getPlanModelViewHelper(),t=this._planInteractionHandler.getPlan(),n=[],a=O(e.getExternalObjectGroups(t));for(const e of a)n.push(JSON.parse(e.serializedDefinition));return n}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(){var e,t;const n=null===(t=null===(e=this._planInteractionHandler.getPlan())||void 0===e?void 0:e.extRef)||void 0===t?void 0:t.jsObject;null==n||n.turnLightsOnOrOff(!0),this._sceneManager.toggleInteriorLightsSceneSettings(!0)}turnLightsOff(){var e,t;const n=null===(t=null===(e=this._planInteractionHandler.getPlan())||void 0===e?void 0:e.extRef)||void 0===t?void 0:t.jsObject;null==n||n.turnLightsOnOrOff(!1),this._sceneManager.toggleInteriorLightsSceneSettings(!1)}async getPlanObjectForRuntimeId(e){var t,n;const a=null===(n=null===(t=this._planInteractionHandler.getPlan())||void 0===t?void 0:t.extRef)||void 0===n?void 0:n.jsObject;return Promise.resolve(a.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()}}l([c],kt.prototype,"_configuratorContext",void 0),l([c],kt.prototype,"_domHelper",void 0),l([c],kt.prototype,"_scriptLoader",void 0),l([c],kt.prototype,"_kernelAccessCallback",void 0),l([c],kt.prototype,"_plannerKernelAccess",void 0),l([c],kt.prototype,"_rapiAccess",void 0),l([c],kt.prototype,"_singlePromiseFactory",void 0),l([c],kt.prototype,"_roomlePlannerUiCallback",void 0),l([c],kt.prototype,"_lifeCycleManager",void 0),l([c],kt.prototype,"_dataSyncer",void 0),l([c],kt.prototype,"_initData",void 0),l([c],kt.prototype,"_idbManager",void 0),l([c],kt.prototype,"_globalInitData",void 0),l([c],kt.prototype,"_globalCallback",void 0),l([c],kt.prototype,"_unitFormatter",void 0);const Bt=[new se("script-loader",n),new se("planner-input-manager",class extends re{_canDrag(e){return!0}},1),new se("logger",oe),new se("planner-mesh-generator",le),new se("rapi-access",ce),new se("planner-selection-handler",class extends r{constructor(){super(...arguments),this._selectionMode="standard",this._selectedPlanElementViewModels=new Map}check(e){"standard"===this._selectionMode&&this._checkStandard(e),"multiselect"===this._selectionMode&&this._checkMulti(e)}removeSelection(){this._selectedPlanElementViewModels.clear()}cancelSelection(e){0!==this._selectedPlanElementViewModels.size&&this._selectedPlanElementViewModels.forEach((t,n)=>{this._selectedPlanElementViewModels.delete(n),t.deselect(),this.dispatchEvent(1,new mt({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((e,t)=>{this._selectedPlanElementViewModels.delete(t),e.deselect(),this.dispatchEvent(1,new mt({planElementViewModel:e,reason:"select_other"}))}),this._selectedPlanElementViewModels.set(e.getId(),e),e.select(),this.dispatchEvent(0,new mt({planElementViewModel:e})))}_checkMulti(e){ut(e)||this._selectedPlanElementViewModels.has(e.getId())||(this._selectedPlanElementViewModels.set(e.getId(),e),e.select(),this.dispatchEvent(2,new mt({planElementViewModels:this.getSelectedPlanElementViewModels()})),this.dispatchEvent(0,new mt({planElementViewModel:e})))}_deselectWallAndFloorElements(){this._selectedPlanElementViewModels.forEach((e,t)=>{ut(e)&&(this._selectedPlanElementViewModels.delete(t),e.deselect(),this.dispatchEvent(1,new mt({planElementViewModel:e,reason:"selection_mode_changed"})))})}setSelectionMode(e){this._selectionMode!==e&&("multiselect"===e&&this._deselectWallAndFloorElements(),this._selectionMode=e,this.dispatchEvent(3,new mt({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)}})];e("Planner",class extends a{constructor(e,t){super(e),this._activePlugins=t||[]}setupGlobals(){}setupDependencies(){he.setup(Bt),this.lookup("logger",this._context),this.lookup("planner-kernel-access",this._context).init(0)}cleanUpGlobals(){throw new Error("Method not implemented.")}cleanUpDependencies(){throw new Error("Method not implemented.")}bootFinished(){this._planner=new kt(this._context,this._activePlugins),this._planner.getMain=()=>this,window.RoomlePlanner||(this._activePlugins.length,window.RoomlePlanner=this._planner)}getApi(){return this._planner}getContextName(){return"planner"}})}}}));
2
- //# sourceMappingURL=planner-db6af31d.legacy.js.map
1
+ System.register(["./script-loader-c7c8f3b8.legacy.js","./roomle-dependency-injection-f9e80d9c.legacy.js","./camera-behaviour-f5d2fa60.legacy.js","./main-thread-to-worker-83f62641.legacy.js","./roomle-configurator-88689bbd.legacy.js","./glb-viewer-camera-behaviour-8a2d4de1.legacy.js","./external-objects-b826c1cf.legacy.js","./query-params-helper-1160ef5b.legacy.js","./Object3D-978403f4.legacy.js","./default-light-setting-05238ba4.legacy.js"],(function(e,t){var n,a,i,r,s,o,l,c,h,d,g,u,m,_,p,v,C,f,w,b,P,E,M,I,S,O,y,D,j,H,L,x,A,R,k,B,V,T,F,W,K,U,G,N,z,Z,q,X,J,Q,Y,$,ee,te,ne,ae,ie,re,se,oe,le,ce,he,de,ge,ue,me,_e,pe,ve,Ce,fe,we,be,Pe,Ee,Me,Ie,Se,Oe,ye,De,je,He,Le,xe,Ae,Re,ke,Be,Ve,Te,Fe,We,Ke,Ue,Ge,Ne,ze,Ze,qe,Xe,Je,Qe,Ye,$e,et,tt,nt,at,it,rt,st,ot,lt,ct,ht,dt;return{setters:[function(e){n=e.S,a=e.M},function(e){i=e.n,r=e.E,s=e.q,o=e.F,l=e._,c=e.i,h=e.ax,d=e.y,g=e.M,u=e.N,m=e.ay,_=e.o,p=e.S,v=e.az,C=e.aA,f=e.s,w=e.aB,b=e.p,P=e.C,E=e.aC,M=e.G,I=e.W,S=e.aD,O=e.a5,y=e.aE,D=e.aF,j=e.j,H=e.aG,L=e.aH,x=e.Y,A=e.aI,R=e.aJ,k=e.af,B=e.k,V=e.aK,T=e.aL,F=e.aM,W=e.aN,K=e.Q,U=e.T,G=e.U,N=e.aO,z=e.aP,Z=e.aQ,q=e.aR,X=e.aS,J=e.au,Q=e.at,Y=e.a1,$=e.B,ee=e.aT,te=e.aU,ne=e.K,ae=e.Z,ie=e.z,re=e.aV,se=e.D,oe=e.L,le=e.aW,ce=e.R,he=e.b},function(e){de=e.L,ge=e.b,ue=e.d,me=e.B,_e=e.C,pe=e.e,ve=e.I,Ce=e.f,fe=e.T},function(e){we=e.a,be=e.A,Pe=e.C,Ee=e.D,Me=e.V,Ie=e.al,Se=e.bK,Oe=e.aK,ye=e.bi,De=e.h,je=e.x,He=e.bY,Le=e.b1,xe=e.ak,Ae=e.H,Re=e._,ke=e.e,Be=e.k,Ve=e.ax,Te=e.ay,Fe=e.bq,We=e.a0,Ke=e.aY,Ue=e.ad,Ge=e.g,Ne=e.q,ze=e.a$,Ze=e.aM,qe=e.ca,Xe=e.aN,Je=e.bT,Qe=e.cb,Ye=e.cc,$e=e.cd,et=e.K,tt=e.aZ},function(e){nt=e.S,at=e.b,it=e.C,rt=e.P,st=e.c,ot=e.G,lt=e.R},function(e){ct=e.G},function(e){ht=e.i,dt=e.a},function(){},function(){},function(){}],execute:function(){class gt extends de{constructor(e,t){super(e,t),this._center=new we(0,0,0),this._params={ambientLight:{color:"#ffffff"},hemiLight:{color:"#ffffff"},mainDirLight:{direction:{x:2,y:1,z:2},color:"#ffffff"}},this._ambientLight=new be(new Pe(this._params.ambientLight.color),.4),this._ambientLight.layers.set(1),this._mainDirLight=new Ee(new Pe(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 Me(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 we));const t=new Ie;e.getBoundingSphere(t);const n=t.radius,a=new we(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=i();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(e=>this._ambientLight.color=new Pe(e))}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(e=>this._hemiLight.color=new Pe(e))}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(e=>this._mainDirLight.color=new Pe(e)),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))}}}}const ut=e=>e instanceof s||e instanceof o;class mt{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 _t{constructor(e){const{planElementViewModel:t,resetCamera:n,state:a,oldState:i,reason:r}=e;this.planElementViewModel=t,this.resetCamera=void 0===n||n,this.state=void 0===a?0:a,this.oldState=void 0===i?0:i,this.reason=r}}class pt extends nt{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(4,()=>this._position=null,this),this._raycastHelper.setMode(0),this._raycastHelper.addEventListener(0,()=>{2!==this._state?this._plannerSelectionHandler.cancelSelection("click_outside"):this.resetState()},this),this._plannerSelectionHandler.addEventListener(0,({planElementViewModel:e})=>{this.dispatchEvent(this.isDragIn()?19:0,new _t({planElementViewModel:e}))},this),this._plannerSelectionHandler.addEventListener(2,({planElementViewModels:e})=>{this._roomlePlannerUiCallback.onMultiSelectionChange(e)},this),this._plannerSelectionHandler.addEventListener(3,({selectionMode:e})=>{"multiselect"===e&&this._hoveredObject&&this._hoverOnMultiSelect(this._hoveredObject),this._roomlePlannerUiCallback.onSelectionModeChange(e),this._checkRaycasterSnapping()},this),this._plannerSelectionHandler.addEventListener(1,({planElementViewModel:e,reason:t})=>{1!==this._state&&this.setState(0),this.dispatchEvent(1,new _t({planElementViewModel:e,reason:t}))},this),this._inputManager.addEventListener(6,e=>this._move(e),this)}disable(){const e=new Se;e.disableAll(),this._raycastHelper.setLayers(e),this._raycastHelper.disableEvents()}get planInteractionHandler(){var e;return null===(e=this._plannerKernelAccess)||void 0===e?void 0:e.planInteractionHandler}get hoveredObjectId(){var e;return(null===(e=this._hoveredObject)||void 0===e?void 0:e.getPlanElement())?this._hoveredObject.getId():null}get isCurrentlyDrawing(){return this._isCurrentlyDrawing}enable(){const e=new Se;e.disableAll(),e.enable(3),e.enable(7),e.enable(6),e.enable(9),e.enable(2),this._raycastHelper.setLayers(e),this._raycastHelper.enableEvents()}enableConstructionEvents(e){e?this._raycastHelper.getLayers().enable(9):this._raycastHelper.getLayers().disable(9)}enableObjectEvents(e){e?this._raycastHelper.getLayers().enable(6):this._raycastHelper.getLayers().disable(6)}getSelectionMode(){return this._plannerSelectionHandler.getSelectionMode()}addConstructionPlanObjectHandlers(e,t){t||(t=e.getBoundingBox());const n={planElementName:e.getName(),hasListener:!0,priority:at.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:at.DEFAULT,roomleId:e.getId()};this._addPlanObjectHandlers(e,t,n)}addWallHandlers(e){this._addPlanElementHandlers(e,e.getBoundingBox(),{planElementName:e.getName(),hasListener:!0,ignoreElementHit:!0,priority:at.WALL,roomleId:e.getId()})}addWallAtticHandlers(e){this._addPlanElementHandlers(e,e.getBoundingBox(),{planElementName:e.getName(),hasListener:!0,priority:at.WALL,roomleId:e.getId()})}addMeasurementLineHandlers(e){const t={planElementName:e.getName(),hasListener:!0,priority:at.DEFAULT,roomleId:e.getId()};this._addMeasurementLinePlanElementHandlers(e,e.getPoint1DraggableBoundingBox(),t,h.POINT1),this._addMeasurementLinePlanElementHandlers(e,e.getPoint2DraggableBoundingBox(),t,h.POINT2),this._addMeasurementLinePlanElementHandlers(e,e.getBoundingBox(),t,null)}addFloorHandlers(e){this._addFloorElementHandlers(e,e.getObject(),{planElementName:e.getName(),hasListener:!0,priority:at.FLOOR,roomleId:e.getId()})}addNodeHandlers(e){this._addPlanElementHandlers(e,e.getBoundingBox(),{planElementName:e.getName(),hasListener:!0,priority:at.DEFAULT,ignoreElementHit:!0,roomleId:e.getId()})}_addPlanObjectHandlers(e,t,n){t.userData.hasListener||(t.userData=Oe(t.userData,n),t.addEventListener("select",()=>this._clickElement(e)),t.addEventListener("drag_start",()=>this._dragStart(e)),t.addEventListener("drag",t=>this._drag(e,t.attachment.position)),t.addEventListener("drag_end",t=>this._dragEnd(e,t.attachment.position)),t.addEventListener("hover_on",()=>this._hoverOn(e)),t.addEventListener("hover_off",()=>this._hoverOff(e)),t.addEventListener("rotate",t=>this._rotate(e,t.attachment.rotation)))}_addFloorElementHandlers(e,t,n){this._addElementHandlers(e,t,n)}_addElementHandlers(e,t,n){t.userData.hasListener||(t.userData=Oe(t.userData,n),t.addEventListener("select",()=>this._clickElement(e)),t.addEventListener("double_click",t=>{var n;this._doubleClickElement(e,t.attachment.type,null===(n=t.attachment.intersection)||void 0===n?void 0:n.point)}),t.addEventListener("hover_on",()=>this._hoverOn(e)),t.addEventListener("hover_off",()=>this._hoverOff(e)))}_addPlanElementHandlers(e,t,n){t.userData.hasListener||(this._addElementHandlers(e,t,n),t.addEventListener("drag_start",()=>this._dragStart(e)),t.addEventListener("drag",t=>this._drag(e,t.attachment.position)),t.addEventListener("drag_end",t=>this._dragEnd(e,t.attachment.position)))}_addMeasurementLinePlanElementHandlers(e,t,n,a){if(t.userData.hasListener)return;t.userData=Oe(t.userData,n);const i=()=>{e.currentPoint=a};t.addEventListener("select",()=>{this._clickElement(e),i()}),t.addEventListener("drag_start",()=>{i(),e.selectPointOnDragStart(e),this._dragStart(e)}),t.addEventListener("drag",t=>{i(),e.hideDraggablePointsOnDragStart(e,a),this._drag(e,t.attachment.position)}),t.addEventListener("drag_end",t=>{e.showDraggablePointsOnDragEnd(e,a),this._dragEnd(e,t.attachment.position),e.showDraggableNodes(),i()}),t.addEventListener("hover_on",()=>{i(),e.showDraggablePointsOnHoverOn(e),this._hoverOn(e)}),t.addEventListener("hover_off",()=>{i(),e.showDraggablePointsOnHoverOff(e),this._hoverOff(e)})}_createFloorMeshWithHandler(){const e=new ye(1e3,1e3,8,8),t=new De;t.visible=!1;const n=new je(e,t);n.name="2D raycaster floor mesh",n.rotation.set(-Math.PI/2,0,0),n.layers.enable(2),n.userData.ignoreElementHit=!0;const a={planElementName:"2D raycaster floor mesh",hasListener:!0,priority:at.RAYCASTER_FLOOR,roomleId:void 0};return n.userData=Oe(n.userData,a),n.addEventListener("double_click",e=>{this._doubleClickOnPlane(d(e.attachment.intersection.point),e.attachment.type)}),n.addEventListener("select",e=>{const t=d(e.attachment.intersection.point);this._isCurrentlyDrawing?this._clickOnPlane(t):this._plannerSelectionHandler.cancelSelection("click_outside")}),n}_clickOnPlane(e){this._createNode(null,e)}_doubleClickOnPlane(e,t=0){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){Ht(e,this._initData)?this._plannerSelectionHandler.cancelSelection("click_outside"):this._isCurrentlyDrawing||(e instanceof g&&e.handleDraggablePointsSelection(e),this._debug&&e.getId(),2!==this._state?(this._plannerSelectionHandler.check(e),this._roomlePlannerUiCallback.onClickElement(e),this._setCursor()):this.resetState())}_doubleClickElement(e,t=0,n){if(!this._isDrawingEnabled||!(e instanceof u||e instanceof s))return;let a;this._debug&&e.getId(),e instanceof s&&this._plannerSelectionHandler.cancelSelection("double_click_wall"),e instanceof u?a=e.getPlanElement().getCenter():n&&(a=d(new we(n.x,0,n.z))),this._isCurrentlyDrawing?this.endWallDrawing(null,a):this._startWallDrawing(null,a,t)}_hoverOn(e){e instanceof g&&e.showDraggablePointsOnHoverOn(e),this._isCurrentlyDrawing||("multiselect"===this._plannerSelectionHandler.getSelectionMode()?this._hoverOnMultiSelect(e):this._hoverOnStandard(e))}_hoverOnMultiSelect(e){ut(this._hoveredObject)||ut(e)?(this._hoveredObject=null,He("default")):this._hoverOnStandard(e)}_hoverOnStandard(e){e.hoverOn(),this._hoveredObject=e,this.dispatchEvent(3,new _t({planElementViewModel:e})),this._interaction(),this._setCursor()}_hoverOff(e){e.hoverOff(),e instanceof g&&e.showDraggablePointsOnHoverOff(e),this.dispatchEvent(4,new _t({planElementViewModel:e})),this._interaction(),this._hoveredObject=null,this._setCursor()}_isHoveredObjectNonDraggable(){return this._hoveredObject instanceof o}_setCursor(){4===this._state?He("crosshair"):2===this._state&&this.hasSelection()?He("ew-resize"):1===this._state?He("grabbing"):!this._isHoveredObjectNonDraggable&&this._plannerSelectionHandler.isSelected(this.hoveredObjectId)?He("move"):this._hoveredObject?Ht(this._hoveredObject,this._initData)?He("default"):He("pointer"):3===this._state?He(m?"url('https://res.cloudinary.com/roomle/image/upload/v1664957371/pencil_j5vkhm.svg') 0 15, auto":"url('https://res.cloudinary.com/roomle/image/upload/v1664957371/pencil_j5vkhm.svg') 3 20, auto"):He("default")}setCamera(e){this._raycastHelper.setCamera(e)}setObject(e){this._raycastHelper.setObject(e)}getSelectedIds(){return this._plannerSelectionHandler.getSelectedIds()}setSelectionMode(e){this._plannerSelectionHandler.setSelectionMode(e),"multiselect"===e&&this._roomlePlannerUiCallback.onMultiSelectionChange(this._plannerSelectionHandler.getSelectedPlanElementViewModels())}setPlanViewModel(e){this._planViewModel=e}cancelSelection(e){this.isDragIn()&&"dock_component"===e||this._plannerSelectionHandler.cancelSelection(e)}removeSelection(){this._plannerSelectionHandler.removeSelection()}_dragStart(e){this._isMeasurementLineDrawActive||((this._plannerSelectionHandler.isSelected(e.getId())||this._dragIn)&&0===this._state||this._isDrawingEnabled)&&(this.dispatchEvent(8),Le(w.DRAG).then(()=>{if(this._inputManager.isMouseUp())return this.setState(0),He("pointer"),void this.dispatchEvent(12);this._draggedObject=e,this.setState(1),this._roomlePlannerUiCallback.onDragElementStart(e.getId()),this.dispatchEvent(9,new _t({planElementViewModel:e}))}))}_drag(e,t){if(!this._draggedObject||1!==this._state)return;const n=this.planInteractionHandler;this._lastDragPosition||(this._lastDragPosition=t);let a=t.clone().sub(this._lastDragPosition);if(this._plannerSelectionHandler.getSelectedIds().length>1){const e=new this._plannerKernelAccess.kernelContainer.PlanObjectPtrList;this._plannerSelectionHandler.getSelectedIds().forEach(t=>e.push_back(this._planViewModel.getPlanObjectForId(t).getPlanElement()));const i=d(a);this._plannerSelectionHandler.hasMultiSelection()&&(i.z=0),n.moveObjectsBy(e,i),this._lastDragPosition.copy(t)}else if(e instanceof g)this._dragMeasurementLine(e,t);else if(e instanceof u||e instanceof s){const t=d(a);t.z=0,n.moveElementBy(e.getPlanElement(),t)}else n.moveElementTo(e.getPlanElement(),d(t));this._lastDragPosition.copy(t),this.dispatchEvent(10,new _t({planElementViewModel:e}))}_dragEnd(e,t){this._draggedObject&&(this._draggedObject=null,this._lastDragPosition=null,this.setState(0),this.dispatchEvent(11,new _t({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){var t,n;const a=this._state;this._state=e,this._setCursor(),this.dispatchEvent(2,new _t({state:this._state,oldState:a})),this._position=null,2===this._state?null===(t=this.planInteractionHandler)||void 0===t||t.deactivateAllSnappingActivity():2===a&&(null===(n=this.planInteractionHandler)||void 0===n||n.reactivateAllSnappingActivity())}resetState(){this.setState(0)}_move(e){if(3!==this._state&&4!==this._state&&2===this._state&&this.hasSelection()){this._setCursor();let t=Math.PI/180;const{x:n,y:a}=e.positionRelative;this._position?t=1.4*e.positionRelative.x*Math.PI-1.4*this._position.x*Math.PI:this._position=new we(e.positionRelative.x,e.positionRelative.y,0);const i=new this._plannerKernelAccess.kernelContainer.PlanObjectPtrList,r=new xe;this.getSelectedIds().forEach(e=>{var t;const n=null===(t=this._planViewModel)||void 0===t?void 0:t.getPlanObjectForId(e);n&&n.getObject()&&(i.push_back(n.getPlanElement()),r.expandByObject(n.getContainer()))});const s=r.getCenter(new we);this.planInteractionHandler.rotateObjectsBy(i,t,d(s)),this._position.copy(new we(n,a,0))}}hasSelection(){return this._plannerSelectionHandler.getSelectedIds().length>0}async selectPlanElement(e){(e instanceof _||e instanceof p)&&await e.isInitDone(),this._plannerSelectionHandler.check(e)}_interaction(e){this.dispatchEvent(13,new _t({}))}addComponentDragInHandler(e){if(!this._dragIn)return;const t=e.getBoundingBox(),n=e instanceof b||e instanceof P;this._addPlanElementHandlers(e,t,{planElementName:e.getName(),hasListener:!0,priority:at.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!==v.OFF}enableShowChildrenOfPlanObject(e){this.planInteractionHandler.setShowChildrenOfPlanObject(e,{value:v.GROUND_COMPONENTS},!1)}disableShowChildrenOfPlanObject(e){this.planInteractionHandler.setShowChildrenOfPlanObject(e,{value:v.OFF},!1)}_checkRaycasterSnapping(){const e=this.planInteractionHandler.enableSnap,t="multiselect"===this.getSelectionMode();e&&!t?this._raycastHelper.enableOnWallSnapping():this._raycastHelper.disableOnWallSnapping()}enableWallDrawing(){return this._isDrawingEnabled=!0,this._drawingGroup=new Ae,this._drawingGroup.name="Drawing",this._drawingGroup.add(this._createFloorMeshWithHandler()),this._inputManager.addEventListener(6,this._drawWallOnMouseMove,this),this._inputManager.addEventListener(13,this.endWallDrawing,this),this._drawingGroup}cancelWallDrawing(){return this._isDrawingEnabled=!1,this._setStateAndCursor(0),this._inputManager.removeEventListener(6,this._drawWallOnMouseMove),this._inputManager.removeEventListener(13,this.endWallDrawing),this._raycastHelper.clear(),this._drawingGroup}stopDrawing(e=!0){var t;this.planInteractionHandler.endInteraction(),e&&this.planInteractionHandler.cancelDrawing(),this._raycastHelper.getLayers().enable(9),this._isCurrentlyDrawing=!1,this._setStateAndCursor(0),this.dispatchEvent(7),null===(t=this._continuousDrawingHelper)||void 0===t||t.endDrawing(),this._roomlePlannerUiCallback.onDrawingStateChanged(!1)}startDrawing(){var e;this._isCurrentlyDrawing||(this._isCurrentlyDrawing=!0,this._raycastHelper.getLayers().disable(9),this.dispatchEvent(6),this._setStateAndCursor(3),null===(e=this._continuousDrawingHelper)||void 0===e||e.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){var a,i;(e&&2===e.type||2===n)&&(await this._initMobileDrawing(),this._continuousDrawingHelper.update()),this.planInteractionHandler.startInteraction();const{x:r,y:s}=t||this._getIntersectionPointWithScene(e),o=(null===(i=null===(a=this._initData)||void 0===a?void 0:a.featureFlags)||void 0===i?void 0:i.drawPreviewMode)===C.VECTOR;this.planInteractionHandler.beginDrawing({x:r,y:s,z:0},o),this.startDrawing()}async _initMobileDrawing(){if(this.planInteractionHandler.setDrawingType(0),this.planInteractionHandler.setSnapFeedbackWhileDrawing(!0),!this._continuousDrawingHelper){const{default:e}=await t.import("./continuous-drawing-helper-b2afe8d1.legacy.js");this._continuousDrawingHelper=new e,this._continuousDrawingHelper.init(this._drawingGroup,this.planInteractionHandler.getContinuousDrawingManager(),this._kernelZoomFactor)}}_drawWallOnMouseMove(e){var t;if(!this._isCurrentlyDrawing||this._isMeasurementLineDrawActive)return;const{x:n,y:a}=this._getIntersectionPointWithScene(e);this.planInteractionHandler.currentDrawingPosition({x:n,y:a,z:0}),null===(t=this._continuousDrawingHelper)||void 0===t||t.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){var t;this._kernelZoomFactor=e,null===(t=this._continuousDrawingHelper)||void 0===t||t.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 6===e?this._drawMeasurementLineOnMouseMove:5===e||14===e||13===e?this._createPlanMeasure:null}_enableDrawingListeners(){[5,6,14,13].forEach(e=>{this._inputManager.addEventListener(e,this._handleMeasurementLineDrawingEvent(e),this)})}_disableDrawingListeners(){[5,6,14,13].forEach(e=>{this._inputManager.removeEventListener(e,this._handleMeasurementLineDrawingEvent(e))})}_drawMeasurementLineOnMouseMove(e){if(!this._currentPlanMeasure)return;4!==this._state&&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){"hide_dragged_node"===e?this._planViewModel.getMeasurementLineObjectViewModels().forEach(e=>{this._currentPlanMeasure.getId()===e.getId()&&e.hidePoint2DraggableNode()}):"showDraggableNodes"===e&&this._planViewModel.getMeasurementLineObjectViewModels().forEach(e=>{this._currentPlanMeasure.getId()===e.getId()&&(e.showDraggableNodes(),e.showDraggablePointsOnDragEnd(e,"point2"))})}_createPlanMeasure(e){const{x:t,y:n}=this._getIntersectionPointWithScene(e),a={x:t,y:n,z:0};if(!this._currentPlanMeasure)return this.dispatchEvent(16),this._currentPlanMeasure=this.planInteractionHandler.addMeasure(a,a),void this._updateMeasurementLineViewModels("hide_dragged_node");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)return void(this._lastDragPosition=t.clone());const a=t.clone().sub(this._lastDragPosition),i=f(n.getCenter()).add(a);return this.planInteractionHandler.moveElementTo(n,d(i)),this._lastDragPosition.copy(t),e.update(),void this.dispatchEvent(18)}e.currentPoint===h.POINT1&&this.planInteractionHandler.setMeasurePoint1(n,d(t),!0,!0),e.currentPoint===h.POINT2&&this.planInteractionHandler.setMeasurePoint2(n,d(t),!0,!0)}setMeasurementLineLength(e,t,n){if(!e)return void console.error("Measurement line not found");const a=t/1e3,i="left"===n.toLowerCase(),r=i?e.getPoint2Draggable().position.clone():e.getPoint1Draggable().position.clone(),s=(new we).subVectors(e.getPoint2Draggable().position,e.getPoint1Draggable().position).normalize().multiplyScalar(a),o=i?r.sub(s):r.add(s);i?this.planInteractionHandler.setMeasurePoint1(e.getPlanElement(),d(o),!1,!1):this.planInteractionHandler.setMeasurePoint2(e.getPlanElement(),d(o),!1,!1)}}l([c],pt.prototype,"_plannerSelectionHandler",void 0),l([c],pt.prototype,"_plannerKernelAccess",void 0),l([c],pt.prototype,"_roomlePlannerUiCallback",void 0),l([c],pt.prototype,"_initData",void 0);const vt=(e,t,n,a)=>{const i=(new xe).setFromObject(e.getContainer()).getCenter(new we);return{runtimeIds:[e.getId()],position2d:E(M(i,t,n,a))}},Ct=e=>{if(e instanceof p){const t=e.getPlanObject().getObjectType();return"door"!==t&&"window"!==t?"static":t}return e instanceof _?"configuration":e instanceof s?"wall":e instanceof o?"floor":e instanceof g?"measure":e instanceof I?"attic":"unknown"};var ft=function(e){function t(){var e;Be(this,t);var n=t.SkyShader,a=new Ve({name:n.name,uniforms:Te.clone(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Fe,depthWrite:!1});return(e=We(this,t,[new Ke(1,1,1),a])).isSky=!0,e}return Re(t,e),ke(t)}(je);ft.SkyShader={name:"SkyShader",uniforms:{turbidity:{value:2},rayleigh:{value:1},mieCoefficient:{value:.005},mieDirectionalG:{value:.8},sunPosition:{value:new we},up:{value:new we(0,1,0)}},vertexShader:"\n\t\tuniform vec3 sunPosition;\n\t\tuniform float rayleigh;\n\t\tuniform float turbidity;\n\t\tuniform float mieCoefficient;\n\t\tuniform vec3 up;\n\n\t\tvarying vec3 vWorldPosition;\n\t\tvarying vec3 vSunDirection;\n\t\tvarying float vSunfade;\n\t\tvarying vec3 vBetaR;\n\t\tvarying vec3 vBetaM;\n\t\tvarying float vSunE;\n\n\t\t// constants for atmospheric scattering\n\t\tconst float e = 2.71828182845904523536028747135266249775724709369995957;\n\t\tconst float pi = 3.141592653589793238462643383279502884197169;\n\n\t\t// wavelength of used primaries, according to preetham\n\t\tconst vec3 lambda = vec3( 680E-9, 550E-9, 450E-9 );\n\t\t// this pre-calculation replaces older TotalRayleigh(vec3 lambda) function:\n\t\t// (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))\n\t\tconst vec3 totalRayleigh = vec3( 5.804542996261093E-6, 1.3562911419845635E-5, 3.0265902468824876E-5 );\n\n\t\t// mie stuff\n\t\t// K coefficient for the primaries\n\t\tconst float v = 4.0;\n\t\tconst vec3 K = vec3( 0.686, 0.678, 0.666 );\n\t\t// MieConst = pi * pow( ( 2.0 * pi ) / lambda, vec3( v - 2.0 ) ) * K\n\t\tconst vec3 MieConst = vec3( 1.8399918514433978E14, 2.7798023919660528E14, 4.0790479543861094E14 );\n\n\t\t// earth shadow hack\n\t\t// cutoffAngle = pi / 1.95;\n\t\tconst float cutoffAngle = 1.6110731556870734;\n\t\tconst float steepness = 1.5;\n\t\tconst float EE = 1000.0;\n\n\t\tfloat sunIntensity( float zenithAngleCos ) {\n\t\t\tzenithAngleCos = clamp( zenithAngleCos, -1.0, 1.0 );\n\t\t\treturn EE * max( 0.0, 1.0 - pow( e, -( ( cutoffAngle - acos( zenithAngleCos ) ) / steepness ) ) );\n\t\t}\n\n\t\tvec3 totalMie( float T ) {\n\t\t\tfloat c = ( 0.2 * T ) * 10E-18;\n\t\t\treturn 0.434 * c * MieConst;\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvec4 worldPosition = modelMatrix * vec4( position, 1.0 );\n\t\t\tvWorldPosition = worldPosition.xyz;\n\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\tgl_Position.z = gl_Position.w; // set z to camera.far\n\n\t\t\tvSunDirection = normalize( sunPosition );\n\n\t\t\tvSunE = sunIntensity( dot( vSunDirection, up ) );\n\n\t\t\tvSunfade = 1.0 - clamp( 1.0 - exp( ( sunPosition.y / 450000.0 ) ), 0.0, 1.0 );\n\n\t\t\tfloat rayleighCoefficient = rayleigh - ( 1.0 * ( 1.0 - vSunfade ) );\n\n\t\t\t// extinction (absorption + out scattering)\n\t\t\t// rayleigh coefficients\n\t\t\tvBetaR = totalRayleigh * rayleighCoefficient;\n\n\t\t\t// mie coefficients\n\t\t\tvBetaM = totalMie( turbidity ) * mieCoefficient;\n\n\t\t}",fragmentShader:"\n\t\tvarying vec3 vWorldPosition;\n\t\tvarying vec3 vSunDirection;\n\t\tvarying float vSunfade;\n\t\tvarying vec3 vBetaR;\n\t\tvarying vec3 vBetaM;\n\t\tvarying float vSunE;\n\n\t\tuniform float mieDirectionalG;\n\t\tuniform vec3 up;\n\n\t\t// constants for atmospheric scattering\n\t\tconst float pi = 3.141592653589793238462643383279502884197169;\n\n\t\tconst float n = 1.0003; // refractive index of air\n\t\tconst float N = 2.545E25; // number of molecules per unit volume for air at 288.15K and 1013mb (sea level -45 celsius)\n\n\t\t// optical length at zenith for molecules\n\t\tconst float rayleighZenithLength = 8.4E3;\n\t\tconst float mieZenithLength = 1.25E3;\n\t\t// 66 arc seconds -> degrees, and the cosine of that\n\t\tconst float sunAngularDiameterCos = 0.999956676946448443553574619906976478926848692873900859324;\n\n\t\t// 3.0 / ( 16.0 * pi )\n\t\tconst float THREE_OVER_SIXTEENPI = 0.05968310365946075;\n\t\t// 1.0 / ( 4.0 * pi )\n\t\tconst float ONE_OVER_FOURPI = 0.07957747154594767;\n\n\t\tfloat rayleighPhase( float cosTheta ) {\n\t\t\treturn THREE_OVER_SIXTEENPI * ( 1.0 + pow( cosTheta, 2.0 ) );\n\t\t}\n\n\t\tfloat hgPhase( float cosTheta, float g ) {\n\t\t\tfloat g2 = pow( g, 2.0 );\n\t\t\tfloat inverse = 1.0 / pow( 1.0 - 2.0 * g * cosTheta + g2, 1.5 );\n\t\t\treturn ONE_OVER_FOURPI * ( ( 1.0 - g2 ) * inverse );\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvec3 direction = normalize( vWorldPosition - cameraPosition );\n\n\t\t\t// optical length\n\t\t\t// cutoff angle at 90 to avoid singularity in next formula.\n\t\t\tfloat zenithAngle = acos( max( 0.0, dot( up, direction ) ) );\n\t\t\tfloat inverse = 1.0 / ( cos( zenithAngle ) + 0.15 * pow( 93.885 - ( ( zenithAngle * 180.0 ) / pi ), -1.253 ) );\n\t\t\tfloat sR = rayleighZenithLength * inverse;\n\t\t\tfloat sM = mieZenithLength * inverse;\n\n\t\t\t// combined extinction factor\n\t\t\tvec3 Fex = exp( -( vBetaR * sR + vBetaM * sM ) );\n\n\t\t\t// in scattering\n\t\t\tfloat cosTheta = dot( direction, vSunDirection );\n\n\t\t\tfloat rPhase = rayleighPhase( cosTheta * 0.5 + 0.5 );\n\t\t\tvec3 betaRTheta = vBetaR * rPhase;\n\n\t\t\tfloat mPhase = hgPhase( cosTheta, mieDirectionalG );\n\t\t\tvec3 betaMTheta = vBetaM * mPhase;\n\n\t\t\tvec3 Lin = pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * ( 1.0 - Fex ), vec3( 1.5 ) );\n\t\t\tLin *= 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 ) );\n\n\t\t\t// nightsky\n\t\t\tfloat theta = acos( direction.y ); // elevation --\x3e y-axis, [-pi/2, pi/2]\n\t\t\tfloat phi = atan( direction.z, direction.x ); // azimuth --\x3e x-axis [-pi/2, pi/2]\n\t\t\tvec2 uv = vec2( phi, theta ) / vec2( 2.0 * pi, pi ) + vec2( 0.5, 0.0 );\n\t\t\tvec3 L0 = vec3( 0.1 ) * Fex;\n\n\t\t\t// composition + solar disc\n\t\t\tfloat sundisk = smoothstep( sunAngularDiameterCos, sunAngularDiameterCos + 0.00002, cosTheta );\n\t\t\tL0 += ( vSunE * 19000.0 * Fex ) * sundisk;\n\n\t\t\tvec3 texColor = ( Lin + L0 ) * 0.04 + vec3( 0.0, 0.0003, 0.00075 );\n\n\t\t\tvec3 retColor = pow( texColor, vec3( 1.0 / ( 1.2 + ( 1.2 * vSunfade ) ) ) );\n\n\t\t\tgl_FragColor = vec4( retColor, 1.0 );\n\n\t\t\t#include <tonemapping_fragment>\n\t\t\t#include <colorspace_fragment>\n\n\t\t}"};const wt=async(e,t,n)=>{const{objects:a,itemIds:i,configurationIds:r}=await(async(e,t)=>{const n=[],a=[],i=[];return await Promise.all(e.map(async e=>{var r;if((null===(r=e.configurationType)||void 0===r?void 0:r.value)!==S.EXTERNAL){const r=O(e);if(r.configurationHash?i.push(r.configurationHash):r.catalogItemId&&a.push(r.catalogItemId),r.parts){const e=r.configurationHash||r.catalogItemId;r.parts=await t.addUiDataAndPriceToPartList(r.parts,e)}if(r.configuration){const e=await t.getConfigurationData(r.runtimeId);r.configuration=e.configuration}r.data=null,n.push(r)}})),{objects:n,itemIds:a,configurationIds:i}})(e,t),{data:s,rootComponentIds:o}=await(async(e=[],t=[],n)=>{const[a,i]=await Promise.allSettled([n.getItems(e),n.getConfigurations(t)]),r=[],s=new Map;if("fulfilled"===a.status)for(const e of a.value)s.set(e.id,e);if("fulfilled"===i.status)for(const e of i.value)s.set(e.id,e),r.push(e.rootComponentId);else console.warn("Could not fetch configuration for data property. This happens when a configuration has not been saved yet");return{data:s,rootComponentIds:r}})(i,r,n),l=await n.getComponents(o),c=new Map;for(const e of l)c.set(e.id,e);for(const e of a){const t=e.catalogItemId||e.configurationHash,n=s.get(e.catalogItemId)||s.get(e.configurationHash)||null;if(n&&!n.label&&c.has(n.rootComponentId)){const e=c.get(n.rootComponentId);n.label=e.label}n&&!n.label&&(n.label=t),e.data=n}return a};class bt extends je{constructor(){const e=new ye(1e3,1e3,8,8);e.rotateX(-Math.PI/2);const t=new De,n=new Ue;n.setPath("static/paper_background-119811362010cc9d.png".startsWith("http")?"":Ge()),n.load("static/paper_background-119811362010cc9d.png",e=>{e.wrapS=Ne,e.wrapT=Ne,e.repeat.set(200,200),t.map=e,t.alphaTest=.3,t.transparent=!0}),super(e,t),this.name="2d paper background",this.position.set(0,-.1,0),this.layers.set(2),this.userData.ignoreElementHit=!0}}class Pt extends ge{get cameraControl(){return this._cameraControl}}class Et extends Pt{get cameraControl(){return this._cameraControl}resetCameraOnPlanCompletelyLoaded(e){this.cameraControl.zoomToFitBounds(y(e,this.cameraControl.domHelper.element.clientWidth,this.cameraControl.domHelper.element.clientHeight,1.1),!0)}externalApiResetCameraPosition(e){this.cameraControl.zoomToFitBounds(y(e,this.cameraControl.domHelper.element.clientWidth,this.cameraControl.domHelper.element.clientHeight,1.1),!0)}resetCameraOnSwitchTo2d(e){this.cameraControl.zoomToFitBounds(y(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 Mt extends Pt{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){n&&(this.cameraControl.setObjectRotation(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 It extends Pt{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 St{constructor(e,t,n){this._sceneEventHandler=e,this._roomleRenderer=t,this._planViewModel=n}_processViewModel(e,t){var n,a,i;e instanceof s&&(null===(a=(n=e.getKernelObject()).getAttachedAttics)||void 0===a?void 0:a.call(n).size())>0?e.getBoundingBox().children.forEach(e=>{e.isChildPlanObject||t.add(e)}):((e instanceof b||e instanceof P)&&e.getTopViewContainer()&&t.add(e.getTopViewContainer()),(null===(i=e.getObject())||void 0===i?void 0:i.children)&&e.getObject().children.forEach(e=>{e.isChildPlanObject||t.add(e)}))}_processSelectedPlanElementIds(e){var t;((null===(t=this._sceneEventHandler)||void 0===t?void 0:t.getSelectedIds())||[]).forEach(t=>{const n=this._planViewModel.getPlanObjectForId(t);n&&this._processViewModel(n,e)})}_highlightPlanElementsBase(e,t){var n;let a=new Set;t&&this._processViewModel(t,a),null==e||e.forEach(e=>{const t=this._planViewModel.getPlanObjectForId(e);t&&this._processViewModel(t,a)}),this._processSelectedPlanElementIds(a),null===(n=this._roomleRenderer)||void 0===n||n.highlightObjects(Array.from(a))}highlightPlanElements(e){this._highlightPlanElementsBase(e)}highlightPlanElement(e){this._highlightPlanElementsBase(void 0,e)}clearHighlighting(){this._highlightPlanElementsBase()}}function Ot(e,t,n,a){e.fromPosition2d=M(e.fromPosition3d,t,n,a),e.toPosition2d=M(e.toPosition3d,t,n,a),e.textPosition2d=M(e.textPosition3d,t,n,a),e.fromWithoutPadding=M(e.fromWithoutPadding,t,n,a),e.toWithoutPadding=M(e.toWithoutPadding,t,n,a)}function yt(e,t,n,a){e.textPosition2d=e.fromPosition3d?M(e.textPosition3d,t,n,a):void 0,e.fromPosition2d=e.fromPosition3d?M(e.fromPosition3d,t,n,a):void 0,e.toPosition2d=e.toPosition3d?M(e.toPosition3d,t,n,a):void 0,e.atticCenterPosition2d=e.atticCenterPosition3d?M(e.atticCenterPosition3d,t,n,a):void 0,e.wallCenterPosition2d=M(e.wallCenterPosition3d,t,n,a),e.labelCPosition2d=M(e.labelCPosition3d,t,n,a),e.labelHeightPosition2d=M(e.labelHeightPosition3d,t,n,a),e.shiftedWallCenter2d=M(e.shiftedWallCenter3d,t,n,a),e.heightAt2mPosition2d=M(e.heightAt2mPosition3d,t,n,a),e.attic2mCornerFrom2d=M(e.attic2mCornerFrom3d,t,n,a),e.attic2mCornerto2d=M(e.attic2mCornerto3d,t,n,a)}function Dt(e,t){const n=new ze(.1,32,16),a=new De({color:16711680}),i=new je(n,a);i.position.copy(e.fromPosition3d);const r=new je(n,a);r.position.copy(e.toPosition3d);const s=new je(n,new De({color:65280}));if(s.position.copy(e.textPosition3d),t.wallPoints.add(i),t.wallPoints.add(r),t.wallPoints.add(s),e.attic){const a=new je(n,new De({color:255}));e.attic.fromPosition3d&&a.position.copy(e.attic.fromPosition3d);const i=new je(n,new De({color:16711935}));e.attic.toPosition3d&&i.position.copy(e.attic.toPosition3d);const r=new je(n,new De({color:16776960}));e.attic.atticCenterPosition3d&&r.position.copy(e.attic.atticCenterPosition3d),t.wallPoints.add(a),t.wallPoints.add(i),t.wallPoints.add(r)}}class jt{static hasNativeClipboardWriteSupport(){return!(!navigator.clipboard||"function"!=typeof navigator.clipboard.writeText)}static async hasNativeClipboardReadSupport(){return!(!navigator.clipboard||"function"!=typeof navigator.clipboard.readText)&&"denied"!==(await navigator.permissions.query({name:"clipboard-read"})).state}static async copy(e){if(this.hasNativeClipboardWriteSupport())try{await navigator.clipboard.writeText(e)}catch(e){console.warn("Native clipboard writeText failed, attempting localStorage fallback.",e)}try{localStorage.setItem(this.LOCAL_STORAGE_KEY,e)}catch(e){console.error("Failed to copy text using localStorage:",e)}}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 null===e?"":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.")}}}function Ht(e,t){const n=Ct(e),a=null==t?void 0:t.lockPlan,i=e&&"getPlanElement"in e&&e.getPlanElement()&&"getAttachedWall"in e.getPlanElement();return!(!a||"wall"!==n&&"floor"!==n&&!i)}jt.LOCAL_STORAGE_KEY="clipboardManagerFallback";const Lt=e=>["altKey","ctrlKey","shiftKey","metaKey"].reduce((t,n)=>(e[n]&&t++,t),0);class xt extends it{constructor(e,t,n,a){var i;super(e,t,a),this._itemsLoadingStatePromises=[],this._staticItemGuard=new j,this._completelyLoaded=!1,this._configurableItemGuard=new j,this._planCompletelyLoadedGuard=new j,this.currentSelection=null,this._paperBackground=null,this._cameraState=null,this._debugSpheres={wallPoints:new Ae,constructionElementsPoints:new Ae,floorPoints:new Ae},this._stopRendering=!0,this._configureInRoom=this._initData.configureInRoom,this._configuratorContext.baseContext="planner",this._roomlePlannerCallback=n,this._plannerMeshGenerator.maxAnisotropy=this._renderer.capabilities.getMaxAnisotropy(),this._plannerMeshGenerator.maxTextures=this._renderer.capabilities.maxTextures,this._plannerSceneEventHandler=new pt(e,this._scene,this.cameraBehaviour.cameraControl.getCamera(),this._getInputManager()),null===(i=this._roomleRenderer)||void 0===i||i.switchToPlanner(H.Mode3D),this._imageRenderer.switchToPlannerSettings(),this._planElementHighlighter=new St(this._plannerSceneEventHandler,this._roomleRenderer,this._getViewModel()),this._plannerSceneEventHandler.addEventListener(2,({state:e,oldState:t})=>{2===t&&e!==t&&this._roomlePlannerUiCallback.onRotationCancel(),2===e||1===e||4===e||3===e?(this.cameraBehaviour.cameraControl.lock(),this._onCameraMove()):(this.cameraBehaviour.cameraControl.unlock(),this._onCameraIdle())},this),this._plannerSceneEventHandler.addEventListener(13,()=>this._renderWithoutShadowsAndAO(),this),this._plannerSceneEventHandler.addEventListener(19,e=>this._activateElement(e),this),this._plannerSceneEventHandler.addEventListener(0,e=>{this._activateElement(e);const t=e.planElementViewModel;this._sendElementMeasurements(),t instanceof p&&this._initData.debug&&t.getGLBUrl(),Ht(t,this._initData)||this._planElementHighlighter.highlightPlanElement(t),this._onSelectionChange(t),this._renderWithoutShadowsAndAO()},this),this._plannerSceneEventHandler.addEventListener(1,({planElementViewModel:e,reason:t})=>{this._planElementHighlighter.clearHighlighting(),this._onSelectionCancel(e,t),this._roomlePlannerUiCallback.onSelectionCancel(t),this._renderWithoutShadowsAndAO()},this),this._plannerSceneEventHandler.addEventListener(8,()=>{this.cameraBehaviour.cameraControl.lock()},this),this._plannerSceneEventHandler.addEventListener(9,({planElementViewModel:e})=>{this._getKernelAccess().planInteractionHandler.startInteraction(),this._sendElementMeasurements(),e instanceof s&&this._sendWallDimensions(),this._requestRender(),this._dragStartBounds=this.getBounds()},this),this._plannerSceneEventHandler.addEventListener(10,({planElementViewModel:e})=>{this.cameraBehaviour.cameraControl.checkNearFarDistance(e.getPosition()),this._requestRender()},this),this._plannerSceneEventHandler.addEventListener(11,async({planElementViewModel:e})=>{const t=this._getKernelAccess().planInteractionHandler;t.endInteraction(),this.cameraBehaviour.cameraControl.unlock();const n=this._getDragPosition(e.getPosition());n&&t.moveElementTo(e.getPlanElement(),d(n)),this.updateEnvironment(this.getBounds(),!0),this._renderEverything();const a=this.getPlanObject(e.getId());let i;a&&(i=await wt([a],this._plannerKernelAccess,this._rapiAccess)),this._roomlePlannerUiCallback.onPlanElementChanged(L.MOVED,i.length?i[0]:{...a,data:null});const r=e instanceof s||e instanceof g||e instanceof u;this._cameraBehaviourState.isWithinPlanBounds(e.getPosition(),this.getBounds())||r||this.plannerCameraBehaviour.updateCameraOnPlanElementDraggedOutsidePlanBounds(this.getBounds())},this),this._plannerSceneEventHandler.addEventListener(12,()=>{this.cameraBehaviour.cameraControl.unlock()},this),this._plannerSceneEventHandler.addEventListener(16,()=>{this.cameraBehaviour.cameraControl.lock()},this),this._plannerSceneEventHandler.addEventListener(18,()=>{this._roomlePlannerUiCallback.onUpdateMeasurementLineDimensions([])},this),this._plannerSceneEventHandler.addEventListener(17,()=>{this.cameraBehaviour.cameraControl.unlock(),this._roomlePlannerUiCallback.onMeasurementLineStateChange(!1)},this),this._plannerSceneEventHandler.addEventListener(6,()=>{var e;this._setKernelZoomFactor(),this._renderWithoutShadowsAndAO(),null===(e=this._roomleRenderer)||void 0===e||e.setGroundShadow(!1)},this),this._plannerSceneEventHandler.addEventListener(5,()=>this._renderWithoutShadowsAndAO(),this),this._plannerSceneEventHandler.addEventListener(7,()=>{var e;this._renderWithoutShadowsAndAO(),null===(e=this._roomleRenderer)||void 0===e||e.setGroundShadow(!0)},this),this._getKernelAccess().addPlannerListener(this),this._plannerMeshGenerator.setMaterialLoadedListener(()=>{this._configurableItemGuard.resolve(),this._requestRender()}),window.onbeforeunload=this.clearScene.bind(this),this._getInputManager().addEventListener(7,this._renderListener,this),this._getInputManager().addEventListener(8,this._renderListener,this),this._getInputManager().addEventListener(3,this._onMouseDown,this),this.disableConfiguratorEvents(),a!==Ze.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 1===new Set(e.map(e=>e.getId())).size}_activateElement({planElementViewModel:e},t=(()=>{})){const n=this._plannerSceneEventHandler.isDragIn()?e:null;this._sendElementMeasurements(n),e instanceof p&&this._initData.debug&&e.getGLBUrl(),Ht(e,this._initData)||this._planElementHighlighter.highlightPlanElement(e),t(),this._renderWithoutShadowsAndAO()}planCleared(){}planHistoryStateChanged(){var e,t;if(this._sendRoomMeasurements(),this._completelyLoaded){const{configuratorId:n}=this._globalInitData,a=null===(t=(null===(e=this._plannerKernelAccess)||void 0===e?void 0:e.planInteractionHandler).getPlan())||void 0===t?void 0:t.getPlanXML(!1,2),i=this._idbManager.getKey(x(),n,this._initData.id);this._idbManager.setValue(i,a,this._idbManager.configStore)}}_getViewModel(){return this._viewModel||(this._viewModel=new rt(this._creator_),this._viewModel.setRequestRenderCallback(()=>this._renderEverything()),this._viewModel.setRequestRenderSceneUpdateCallback(()=>{var e;return null===(e=this._roomleRenderer)||void 0===e?void 0:e.clearCache()}),this._viewModel.setInvalidateRenderCallback(()=>{var e;return null===(e=this._roomleRenderer)||void 0===e?void 0:e.forceShadowUpdates(!0)})),this._viewModel}_getDragPosition(e){if(!this._plannerSceneEventHandler.isDragIn())return null;const t=this._dragStartBounds?this._dragStartBounds:this.getBounds(),n=t.getCenter(new we),a=e.distanceTo(n),i=t.getSize(new we),r=Math.max(i.x,i.z)+3;if(a>r){const t=(new we).subVectors(e,n).normalize();return n.clone().add(t.multiplyScalar(r))}return null}_hideAllMeasurementsNodeOnElementChange(e){this._getViewModel().getMeasurementLineObjectViewModels().forEach(e=>e.hideDraggableNodes()),e instanceof g&&e.showDraggableNodes()}_onSelectionChange(e){this._hideAllMeasurementsNodeOnElementChange(e);const t={};if(e instanceof p&&(t.item=e.getRapiItem(),t.staticItemRuntimeId=e.getPlanElement().getId(),this._configuratorUiCallbacks.onUpdateParameters([])),e instanceof P&&(t.staticItemRuntimeId=e.getPlanElement().getId()),e instanceof _){const n=e.getId(),a=this.getRootPlanObjectId(n),i=this._getViewModel().getPlanObjectForId(a);t.configurationRuntimeId=i.getConfigurationRuntimeId()}if(e instanceof s){const n=this.cameraBehaviour.cameraControl.getKernelZoomFactor(),{clientWidth:a,clientHeight:i}=this._domHelper.element;t.wall=e.getWallDimension(n,a,i)}e instanceof g&&(t.measurementLine=e.getMeasurementLineDimension()),e instanceof o&&(t.staticItemRuntimeId=e.getPlanElement().getId());let n=Ct(e);const a=(async()=>{const t={};if(e instanceof p&&(t.item=e.getRapiItem(),t.staticItemRuntimeId=e.getPlanElement().getId()),e instanceof _){await e.isInitDone();const a=e.getConfigurationRuntimeId();this._getKernelAccess().updatePlanObjectDependencies(a);const i=e.getPlanObject().getCatalogItemId();let r=i;r||(r=this._getKernelAccess().kernelInstance.getHashOfConfiguration(a));const s=this._getKernelAccess().kernelInstance.isExternalPlanObject(a);if(s){const t=this.getRootPlanObjectId(e.getId()),n=this._getViewModel().getPlanObjectForId(t);this._planObjectSelectionChanged(n.getConfigurationRuntimeId(),e.getRootComponentRuntimeId())}let o;if(this._configuratorContext.planObjectId=a,this._configuratorContext.planElementId=e.getId(),this._configuratorContext.rootComponentId=e.getRootComponentRuntimeId(),!s)if(i&&Y(i)){const e=await this._rapiAccess.getItem(i);t.item=e,o=e.rootComponentId?e.rootComponentId:null}else try{const e=await this._rapiAccess.getConfiguration(r);t.configuration=e,o=e.rootComponentId?e.rootComponentId:null}catch(e){console.warn("Could not get RAPI configuration for kernel hash "+r+", saving configuration...");const n=await this._getKernelAccess().getConfigurationData(a),i=await this._rapiAccess.saveConfiguration(n);t.configuration=i,o=i.rootComponentId?i.rootComponentId:null}if(o){const e=await this._rapiAccess.getComponent(o);t.component=e}t.configurationRuntimeId=a,n="configuration"}return t.planElementId=e.getId(),qe(t)})();if(this.currentSelection=qe(t),this._sendElementMeasurements(),this._sendPlanObjectPositions(),e instanceof _){const a=e.getConfigurationRuntimeId();a&&-1!==a&&this._getKernelAccess().kernelInstance.isExternalPlanObject(a)&&(n="external-configuration",t.externalConfigurationType="tc-config")}this._roomlePlannerUiCallback.onSelectionChange(qe(this._plannerSceneEventHandler.getSelectionMode()),qe(n),qe(t),a,e),(e instanceof s||e instanceof u)&&(this._getViewModel().getNodePlanObjectViewModels().forEach(e=>e.show()),this._updateNodeSize()),this._renderWithoutShadowsAndAO()}_onSelectionCancel(e,t){this._getViewModel().getNodePlanObjectViewModels().forEach(e=>e.hide()),this._renderWithoutShadowsAndAO(),this.resetConfiguratorContext(t),this.cancelComponentSelection(!1,t),this._handleMeasurementLineDraggablePoints(e),this.currentSelection=null}_handleMeasurementLineDraggablePoints(e){this._getViewModel().getMeasurementLineObjectViewModels().forEach(e=>{e.hideDraggableNodes(),e.deselectAllDraggablePoints()}),e instanceof g&&(e.deselectAllDraggablePoints(),e.currentPoint=null)}resetConfiguratorContext(e){var t;try{this._configuratorContext.planObjectId&&(null===(t=this.getPlanObject(this._configuratorContext.planElementId).configurationType)||void 0===t?void 0:t.value)===S.EXTERNAL&&this.notifyPlannerOnComponentSelectionCancel(!0,e)}catch(e){console.error(e)}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 gt(this._scene,this._lightSetting)),this._initData.moc||this._addSky(),t||this._setEnvironment(new me(this._scene,this._environment,Xe(this._initData.colors.DEFAULT_BACKGROUND)))}onBeforeRender(){var e;this.cameraBehaviour.cameraControl instanceof _e&&A(this.cameraBehaviour.cameraControl.getCamera(),this._getViewModel().getWallPlanObjectViewModels())&&(null===(e=this._roomleRenderer)||void 0===e||e.forceShadowUpdates(!0))}_getInputManager(){return this._plannerInputManager}createCameraControl(e,t){this.setMode(e)}startViewing(){this._configuratorContext.baseContext="glb-viewer";const e=this._plannerSceneEventHandler.getSelectedIds();if(1===e.length){const t=this._getViewModel().getPlanObjectForId(e[0]);this._setCameraPosition();const n=this.cameraBehaviour.cameraControl.getCurrentCameraParameters();this._changeCameraBehaviour(new ct(this._getCameraControl3D(n),this._cameraBehaviourState)),this.cameraBehaviour.cameraControl instanceof _e&&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(){var e,t,n;this._configuratorContext.baseContext="configurator";let{planElementId:a}=this._configuratorContext;a=this.getRootPlanObjectId(a),this._configuratorContext.planElementId!==a&&this.selectPlanObject(a),this._selectExternalObjectModule();const i=this._getViewModel().getPlanObjectForId(a);this._getViewModel().toggleCeilingLights(!1,this._isInteriorLightActive),this._setCameraPosition();const r=this.cameraBehaviour.cameraControl.getCurrentCameraParameters();this._changeCameraBehaviour(new st(this._getCameraControl3D(r),this._cameraBehaviourState));let s=0,o=0;if(i){this.setRootComponentId(i.getRootComponentRuntimeId());const t=i.getPlanElement().getRotationToPreferredFront();s=t.rotationRoundTo90deg,o=t.lookAtSide.value===R.LEFT?-1:1,null===(e=this._componentRaycastHelper)||void 0===e||e.setObject(i.getObject())}const l=null==i?void 0:i.getConfigurationRuntimeId();this._configuratorContext.planObjectId!==l&&(this._configuratorContext.planObjectId=l),this._plannerSceneEventHandler.removeSelection(),this._planElementHighlighter.clearHighlighting(),this._configureInRoom||this._getViewModel().hideAllExcept(a),this.configuratorCameraBehaviour.resetCameraOnStartConfiguring(this.getBounds(),r,s,o).then(()=>{this.updateEnvironment(this.getBounds(),!0)}),this.setEventHandlerObject(i.getContainer()),this.disablePlannerEvents(),this.enableConfiguratorEvents(),null===(t=this._roomleRenderer)||void 0===t||t.switchToConfigurator(),this._imageRenderer.switchToConfiguratorSettings(),this.updateScene(),this._getKernelAccess().updatePlanObjectDependencies(l),this._getKernelAccess().requestPartListAndUpdatePricesOfParts(),this._getKernelAccess().planObjectUpdated(l,!1);const c=null===(n=this._plannerKernelAccess)||void 0===n?void 0:n.planInteractionHandler;null==c||c.startInteraction()}_setCameraPosition(){this._cameraState=this.cameraBehaviour.cameraControl.getCurrentCameraParameters()}_resetCameraPosition(e){if(this.cameraBehaviour.cameraControl instanceof _e){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 t=this._getViewModel().getPlanObjectForId(e);await this._plannerSceneEventHandler.selectPlanElement(t)}backToPlanner(){var e,t,n,a,i;if("planner"===this._configuratorContext.baseContext)return;if("configurator"===this._configuratorContext.baseContext){const i=null===(e=this._plannerKernelAccess)||void 0===e?void 0:e.planInteractionHandler;null==i||i.endInteraction(),(null===(a=this._getKernelAccess().kernelInstance.getPlanObject(null!==(n=null===(t=this.currentSelection)||void 0===t?void 0:t.configurationRuntimeId)&&void 0!==n?n:0))||void 0===a?void 0:a.externalObject)&&this.notifyPlannerOnComponentSelectionCancel(!0,"isolation_mode_cancelled")}this._configuratorContext.baseContext="planner",this._getViewModel().toggleCeilingLights(!0,this._isInteriorLightActive);const r=this.cameraBehaviour.cameraControl.getCurrentCameraParameters(),s=this._getViewModel().cameraType;this._changeCameraBehaviour(s===Ze.CAMERA_3D||s===Ze.CAMERA_FP?new Mt(this._getCameraControl3D(r),this._cameraBehaviourState):new Et(this._getCameraControl2D(),this._cameraBehaviourState)),this._resetCameraPosition(r),this._getViewModel().showAll(),this.setEventHandlerObject(this._scene),this.enablePlannerEvents();const o=this.cameraBehaviour.cameraControl instanceof _e||this.cameraBehaviour.cameraControl instanceof pe;this._getViewModel().setCameraType(o?Ze.CAMERA_3D:Ze.CAMERA_2D),this.disableConfiguratorEvents(),null===(i=this._roomleRenderer)||void 0===i||i.switchToPlanner(this.cameraBehaviour.cameraControl instanceof _e?H.Mode3D:H.Mode2D),this._imageRenderer.switchToPlannerSettings(),this.updateScene()}_getYRotationOfObject(e){let t=e.getWorldDirection(new we).clone();t.y=0,t.lengthSq()<.01&&(t=new we(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+=2*Math.PI),n}loadStaticPlanObjects(){let e=new Map;this._getViewModel().getStaticPlanObjectViewModels().forEach(t=>{let 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=>{let n=[];t.forEach(t=>{this._getKernelAccess().catalogItemLoaded(t),e.get(t.id).forEach(e=>{n.push(new Promise((n,a)=>{e.setRapiItem(t).then(()=>{this._requestRender(),n()},a)}))})}),Promise.all(n).then(()=>this._staticItemsLoaded())})}requestCatalogItem(e){this._rapiAccess.getItem(e).then(e=>{this._getKernelAccess().catalogItemLoaded(e)})}_staticItemsLoaded(){this._requestRender(),this._staticItemGuard.resolve(),this._roomlePlannerUiCallback.onItemsLoaded()}preload(e){this._planId=e;let t=this._localStorageHelper.getItem(this._planId,"rml_plans");t&&this._loadGLTF(t).then(e=>{this._preloadScene=e,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(e=>e.hide()),this._getViewModel().getMeasurementLineObjectViewModels().forEach(e=>e.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();let e=new ye(1e3,1e3);e.rotateX(-Math.PI/2);let t=k.createMeshStandardMaterial({color:"#f0f0f0",roughness:1,metalness:0,depthWrite:!1}),n=new je(e,t);n.name="Ground",n.position.y=-.01,n.userData.isFloor=!0,this._scene.add(n)}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=B(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(),"planner"===this._configuratorContext.baseContext&&this.plannerCameraBehaviour.resetCameraOnPlanCompletelyLoaded(this.getBounds()),this._completelyLoaded=!0,this._readyForRender()}beginPlanConstruction(e){}addPlanMesh(e,t,n,a,i,r,s){}endPlanConstruction(e){this._renderLoopFunction=()=>{var e;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(),(null===(e=this._lightSetting)||void 0===e?void 0:e.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((e,a)=>(t=e,n=a));this._itemsLoadingStatePromises.push(a);const i=e.getContainer();V(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 s;r&&(s=await wt([r],this._plannerKernelAccess,this._rapiAccess)),this._roomlePlannerUiCallback.onPlanElementChanged(L.ADDED,s.length?s[0]:{...r,data:null});const o=e instanceof _||e instanceof p;this._initData.featureFlags.interiorLights&&((e,t,n)=>{var a,i,r;const s=null===(a=e.getRapiItem)||void 0===a?void 0:a.call(e);if(s&&("lamp_ceiling"===s.detailType||"lamp_standing"===s.detailType))if("brands_15:flos_aim"===(null==s?void 0:s.id)){const a={x:-.45,y:-.37,z:.35},i={x:.38,y:.31,z:-.17};t.handleLampLight(e,{targetPos:a,lightPos:i,active:n})}else if("brands_26:diesel_with_foscarini_fork"===(null==s?void 0:s.id)){const a={x:0,y:-.56,z:-.49},i={x:.01,y:1.62,z:0};t.handleLampLight(e,{targetPos:a,lightPos:i,color:16768955,decay:0,active:n})}if("brands_26:diesel_with_foscarini_duii"===(null==s?void 0:s.id)){const a={x:-1.4,y:-.74,z:-.07},i={x:.07,y:.59,z:0};t.handleLampLight(e,{targetPos:a,lightPos:i,color:16777215,decay:2,active:n})}if("ba6d0d48:lights-kitchen"===(null==s?void 0:s.id)){const a={width:2.45,height:.03},i={x:0,y:1.571,z:-1.05};t.handleRectLampLight(e,{dimensions:a,lightPos:i,color:16777215,active:n});const r={width:.03,height:2.17},s={x:1.195,y:1.033,z:0};t.handleRectLampLight(e,{dimensions:r,lightPos:s,color:16777215,active:n})}if("roomle_white_furniture:Lighting_Pendant_lamp_02"===(null===(r=null===(i=e.getRapiItem)||void 0===i?void 0:i.call(e))||void 0===r?void 0:r.id)){const a={x:0,y:-99,z:0},i={x:0,y:.15,z:0};t.handleLampLight(e,{targetPos:a,lightPos:i,color:16445391,decay:1,intensity:1,active:n})}})(e,this._getViewModel(),this._isInteriorLightActive),o&&!this._plannerSceneEventHandler.isDragIn()&&this.cameraBehaviour instanceof Pt&&(T(this.cameraBehaviour.cameraControl.getCamera(),e.getBounds())?this.plannerCameraBehaviour.updateCameraOnPlanElementInsertedInsideCurrentCameraView(this.getBounds()):this.plannerCameraBehaviour.updateCameraOnPlanElementInsertedOutsideCurrentCameraView(this.getBounds()))}catch(e){console.error(e),n()}t()}removePlanObjectFromScene(e){(e instanceof s||e instanceof u)&&this._sendWallDimensions(),e instanceof g&&this._sendMeasurementLineDimension(),this._scene.remove(e.getContainer()),e.clear(),this.updateEnvironment(this.getBounds(),!0),e instanceof s||e instanceof g||e instanceof u||"planner"!==this._configuratorContext.baseContext||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 e=this.getPlanObject(t.getId());this._roomlePlannerUiCallback.onPlanElementChanged(L.MOVED,{...e,data:null})}t instanceof s&&e.extRef&&e.extRef.jsObject&&this._isInteriorLightActive&&e.extRef.jsObject.handleCeilingLights()}exportGLB(e,t){}importGLB(e){this._loadGLB(e).then(e=>this._scene.add(e))}clearScene(){this._plannerMeshGenerator.clear(),this._getViewModel().sceneCleared(),super.clearScene()}_addSky(){if(!this._sky){this._sky=new ft,this._sky.name="Sky",this._sky.scale.setScalar(45e4),this._sky.frustumCulled=!1,this._scene.add(this._sky),this._sky.material.uniforms.turbidity.value=10,this._sky.material.uniforms.rayleigh.value=2,this._sky.material.uniforms.mieCoefficient.value=.005,this._sky.material.uniforms.mieDirectionalG.value=.8;let e=F(4e5,0,.6);this._sky.material.uniforms.sunPosition.value.copy(e);let t=new je(new ze(2e4,16,8),new De({color:16777215}));t.name="Sunsphere",t.position.y=-7e5,t.visible=!1,t.position.set(e.x,-e.z,e.y)}this._lightSetting instanceof gt&&this._lightSetting.updateSunPosition(.6,0)}toggleConfigureInRoom(){this._configureInRoom=!this._configureInRoom,this._roomleRenderer.isConfiguring&&(this._configureInRoom?this._getViewModel().showAll():this._hideAllExceptSelectedElement(),this._renderEverything(),this.updateScene())}switchTo2D(){var e,t,n,a,i;if(!((null===(e=this.cameraBehaviour)||void 0===e?void 0:e.cameraControl)instanceof ue)){(null===(t=this.cameraBehaviour)||void 0===t?void 0:t.cameraControl)instanceof pe&&this._getCameraControlFirstPerson().cleanUp(),null===(n=this._roomleRenderer)||void 0===n||n.setCameraType(Ze.CAMERA_2D),null===(a=this._plannerSceneEventHandler)||void 0===a||a.enable();for(const e of this._getViewModel().getWallPlanObjectViewModels())e.show();this._getViewModel().setCameraType(Ze.CAMERA_2D).then(()=>this._planElementHighlighter.highlightPlanElement()),null===(i=this._roomleRenderer)||void 0===i||i.switchToPlanner(H.Mode2D),this._renderEverything(),this._changeCameraBehaviour(new Et(this._getCameraControl2D(),this._cameraBehaviourState)),this._onCameraMove(),this.plannerCameraBehaviour.resetCameraOnSwitchTo2d(this.getBounds()),this._addCameraControlListener(),this._setCeiling(),this._roomlePlannerUiCallback.onCameraChanged(Ze.CAMERA_2D),this._setKernelZoomFactor(),this._onCameraMove(),this._sendRoomMeasurements()}}switchTo3D(){var e,t,n,a;(null===(e=this.cameraBehaviour)||void 0===e?void 0:e.cameraControl)instanceof _e||(null===(t=this._roomleRenderer)||void 0===t||t.setCameraType(Ze.CAMERA_3D),null===(n=this._plannerSceneEventHandler)||void 0===n||n.enable(),this._getViewModel().setCameraType(Ze.CAMERA_3D),null===(a=this._roomleRenderer)||void 0===a||a.switchToPlanner(H.Mode3D),this._renderEverything(),this._changeCameraBehaviour(new Mt(this._getCameraControl3D(),this._cameraBehaviourState)),this._onCameraMove(),this.plannerCameraBehaviour.resetCameraOnSwitchTo3d(this.getBounds()),this._addCameraControlListener(),this._setCeiling(),this._roomlePlannerUiCallback.onCameraChanged(Ze.CAMERA_3D))}switchToFirstPerson(){var e,t,n;(null===(e=this.cameraBehaviour)||void 0===e?void 0:e.cameraControl)instanceof pe||(null===(t=this._roomleRenderer)||void 0===t||t.setCameraType(Ze.CAMERA_FP),null===(n=this._plannerSceneEventHandler)||void 0===n||n.disable(),this._plannerMeshGenerator.wallMeshes.forEach(e=>W(e.material,!1,!1)),this._getViewModel().getWallPlanObjectViewModels().forEach(e=>{e.show()}),this._getViewModel().setCameraType(Ze.CAMERA_FP),this._renderEverything(),this._changeCameraBehaviour(new It(this._getCameraControlFirstPerson(),this._cameraBehaviourState)),this._addCameraControlListener(),this._setCeiling(),this._roomlePlannerUiCallback.onCameraChanged(Ze.CAMERA_FP),this.plannerCameraBehaviour.resetCameraOnSwitchToFirstPerson())}onCameraChanged(){}_setCameraControlListeners(){super._setCameraControlListeners(),this.cameraBehaviour instanceof Pt&&(this.cameraBehaviour.cameraControl.addEventListener(8,()=>{this._onCameraIdle()},this),this.cameraBehaviour.cameraControl.addEventListener(1,()=>{this._onCameraMove()},this),this.cameraBehaviour.cameraControl.addEventListener(7,()=>{this._onCameraMove()},this),this.cameraBehaviour.cameraControl.addEventListener(3,()=>{this._onCameraMove()},this),this.cameraBehaviour.cameraControl.addEventListener(4,()=>{this._onCameraMove()},this),this.cameraBehaviour.cameraControl.addEventListener(5,()=>{this._onCameraZoomChange()},this))}_onCameraZoomChange(){this._setKernelZoomFactor()}_setKernelZoomFactor(){var e,t;const n=this.cameraBehaviour.cameraControl.getKernelZoomFactor();n&&isFinite(n)&&n>=0&&(null===(e=this._getKernelAccess().planInteractionHandler)||void 0===e||e.setZoomFactor(n)),null===(t=this._plannerSceneEventHandler)||void 0===t||t.setKernelZoomFactor(n)}_setCeiling(){this._getViewModel()&&(this.cameraBehaviour.cameraControl instanceof pe?this._getViewModel().getCeilingGroup().visible=!0:this._getViewModel().getCeilingGroup().visible=!1)}cameraBehaviourChanged(){var e;super.cameraBehaviourChanged(),null===(e=this._plannerSceneEventHandler)||void 0===e||e.setCamera(this.cameraBehaviour.cameraControl.getCamera()),this._updatePaperBackground()}_updatePaperBackground(){var e,t;this.cameraBehaviour.cameraControl instanceof ue?(this._paperBackground||(this._paperBackground=new bt),null===(e=this._scene)||void 0===e||e.add(this._paperBackground),this._requestRender()):this._paperBackground&&(null===(t=this._scene)||void 0===t||t.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),Je(e)){const t=Lt(e),n=e.metaKey&&"Meta"===e.key||e.ctrlKey&&"Control"===e.key,a=t>1?"standard":n?"multiselect":"standard";this._plannerSceneEventHandler.setSelectionMode(a)}this._checkPanning(e),this._plannerSceneEventHandler&&this._plannerSceneEventHandler.hasSelection()&&e.key&&("Backspace"===e.key||"Delete"===e.key)&&(this.deletePlanElementSelection(),e.preventDefault())}async _checkCopyPaste(e){if(Je(e)&&"c"===e.key){const e=this._plannerSceneEventHandler.getSelectedIds(),t=[];e.forEach(e=>{const n=this._getViewModel().getPlanObjectForId(e).getPlanElement(),a=n.getCatalogItemId()||n.getConfigurationHash();t.push(a)}),jt.copy(t.join())}if(Je(e)&&"v"===e.key){const e=await jt.paste();if(e){const t=e.split(",").map(e=>Qe(e)||e).filter(e=>e.includes(":"));this._insertRapiItems(t)}}}_checkPanning(e){(!0===e.shiftKey||e.key&&e.key.includes("Shift"))&&this.cameraBehaviour.cameraControl instanceof _e&&(this.cameraBehaviour.cameraControl.enablePanning(),e.preventDefault())}_onMouseDown(e){"event"in e&&this._checkPanning(e.event)}_checkNumKey(e){e.key&&"1"===e.key&&(this.switchTo2D(),e.preventDefault()),e.key&&"2"===e.key&&(this.switchTo3D(),e.preventDefault()),e.key&&"3"===e.key&&(this.switchToFirstPerson(),e.preventDefault())}_onKeyUp(e,t=!1){if(super._onKeyUp(e,t),Je(e,!0)){const t=Lt(e);let n="standard";Ye(e)||1!==t||(n="multiselect"),this._plannerSceneEventHandler.setSelectionMode(n),e.preventDefault()}e.key&&e.key.includes("Shift")&&this.cameraBehaviour.cameraControl instanceof _e&&(this.cameraBehaviour.cameraControl.disablePanning(),e.preventDefault()),!e.key||"Escape"!==e.key&&"Esc"!==e.key||this._drawingEnabled&&(this.escapeDrawing(!0),this._roomlePlannerUiCallback.onDrawCancel())}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 Ze.CAMERA_2D:this.switchTo2D();break;case Ze.CAMERA_3D:this.switchTo3D();break;case Ze.CAMERA_FP:this.switchToFirstPerson()}}_clearHighlighting(){this._planElementHighlighter.clearHighlighting(),this._renderWithoutShadowsAndAO()}highlightPlanElementsById(e){null!==e?this._planElementHighlighter.highlightPlanElements(e):this._clearHighlighting()}highlightPlanElementById(e){if(null===e)return void this._clearHighlighting();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){let e=t.extRef.jsObject.getPlanObject().getConfigurationRuntimeId();e>0&&this._getViewModel().constructComponents(e)}}async planObjectConfigurationChanged(e,t){const n=this.getPlanObject(t.getId());let a;!n||t instanceof _||t instanceof P||(a=await wt([n],this._plannerKernelAccess,this._rapiAccess)),this._roomlePlannerUiCallback.onPlanElementChanged(L.CHANGED,(null==a?void 0: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"configurator"===this._configuratorContext.baseContext?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){var t;if(!(null===(t=this._plannerKernelAccess)||void 0===t?void 0:t.kernelContainer))return e;const n=this._getKernelAccess().planInteractionHandler,a=this._plannerKernelAccess.planModelViewHelper,i=n.getPlan();return a.getRootPlanObjectId(i,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 e=this._getViewModel().getPlanObjectForId(t);if(e&&e.getObject()){const t=this.getPlanObject(e.getId());let n;t&&(n=await wt([t],this._plannerKernelAccess,this._rapiAccess)),this._roomlePlannerUiCallback.onPlanElementChanged(L.REMOVED,n.length?n[0]:{...t,data:null}),this._getKernelAccess().planInteractionHandler.removeElement(e.getKernelObject())}}}rotatePlanElements(e,t){const n=new(this._getKernelAccess().kernelContainer.PlanObjectPtrList),a=new xe;let i={x:0,y:0,z:0};if(e.forEach(e=>{const t=this._getViewModel().getPlanObjectForId(e);t&&t.getObject()&&(i=t.getPlanElement().getCenter(),n.push_back(t.getPlanElement()),a.expandByObject(t.getContainer()))}),n.size()>1){const e=a.getCenter(new we);i=d(e)}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"configurator"===this._configuratorContext.baseContext&&t?super.preparePerspectiveImage(e):new Promise(t=>{this._getViewModel().materialQueue.finished(!0).then(async()=>{var n,a,i;let r=e.runtimeIds?K.getCameraTargetForBBox(this._getViewModel().getBoundingBoxFromRuntimeIds(e.runtimeIds),.1):this._calculateBoundingBoxOfAllMeshes(.1);null===(n=this._lightSetting)||void 0===n||n.removeFromScene();const s=[];if(this.cameraBehaviour.cameraControl instanceof _e){await this._getViewModel().setCameraType(Ze.CAMERA_2D),this._getViewModel().setNodeVisibility(!1);for(const e of this._getViewModel().getWallPlanObjectViewModels())e.isVisible()||s.push(e),e.show()}e.runtimeIds&&this._getViewModel().hideAllExceptRuntimeIds(e.runtimeIds);let o=await this._imageRenderer.prepareTopImage(this._scene,null,r,e);if(e.runtimeIds&&this._getViewModel().showAll(),this.cameraBehaviour.cameraControl instanceof _e&&await this._getViewModel().setCameraType(Ze.CAMERA_3D),s.length)for(const e of s)e.hide();null===(a=this._lightSetting)||void 0===a||a.addToScene(),null===(i=this._roomleRenderer)||void 0===i||i.clearCache(),this._requestRender(),t(o)})})}preparePerspectiveImageOf(e,t={}){const n=this._getViewModel().getPlanObjectForId(e);if(!n){const t="Object with runtimeId "+e+" not found";throw console.warn(t),new Error(t)}return this._preparePerspectiveImage({...t,object:n.getObject().clone()})}async _waitForAssets(){await super._waitForAssets(),await this._getViewModel().materialQueue.finished(!0)}_preparePerspectiveImage(e={},t){if("configurator"===this._configuratorContext.baseContext&&t)return super.preparePerspectiveImage(e);const n=this._handlePlannerIsolationModeState(t);return new Promise((t,a)=>{this._getViewModel().materialQueue.finished(!0).then(async()=>{var a,i,r;let s;this.cameraBehaviour.cameraControl instanceof _e?s=this.cameraBehaviour.cameraControl.getCamera().clone():(s=this.getPerspectiveOffsetCamera().clone(),this._getViewModel().getCeilingGroup().visible=!1,s.layers.enableAll(),this._getViewModel().setCameraType(Ze.CAMERA_3D)),s.resetOffset();let o=e.object?K.getCameraTargetForBBox((new xe).setFromObject(e.object)):e.runtimeIds?K.getCameraTargetForBBox(this._getViewModel().getBoundingBoxFromRuntimeIds(e.runtimeIds)):this._calculateBoundingBoxOfAllMeshes();null===(a=this._lightSetting)||void 0===a||a.removeFromScene();let l=e.object?U(this._scene):this._scene;e.object&&l.add(e.object),e.runtimeIds&&this._getViewModel().hideAllExceptRuntimeIds(e.runtimeIds);const c=await this._imageRenderer.preparePerspectiveImage(l,null,s,o,e,void 0,e=>{A(e,this._getViewModel().getWallPlanObjectViewModels())});G(s),e.runtimeIds&&this._getViewModel().showAll(),e.object&&G(l),this.cameraBehaviour.cameraControl instanceof ue?(this._getViewModel().setCameraType(Ze.CAMERA_2D),this._getViewModel().getWallPlanObjectViewModels().forEach(e=>e.show())):A(this.cameraBehaviour.cameraControl.getCamera(),this._getViewModel().getWallPlanObjectViewModels()),null===(i=this._lightSetting)||void 0===i||i.addToScene(),null===(r=this._roomleRenderer)||void 0===r||r.clearCache(),this._requestRender(),this._setCeiling(),n(),t(c)},a)})}_handlePlannerIsolationModeState(e){if(!e){const e=this._configuratorContext.baseContext;return this._getViewModel().showAll(),this._configuratorContext.baseContext="planner",()=>{this._configuratorContext.baseContext=e,"configurator"===e&&(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 K.getCameraTargetForBBox(t,e)}enableRotation(){this._plannerSceneEventHandler.setState(2)}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 _){const t=e.getKernelObject();return this._plannerSceneEventHandler.showsChildrenOfPlanObject(t)}return!1}enableShowChildrenOfPlanObject(e){if(e instanceof _){const t=e.getKernelObject();this._plannerSceneEventHandler.enableShowChildrenOfPlanObject(t)}}disableShowChildrenOfPlanObject(e){if(e instanceof _){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 ue){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 xe;for(const t of e){const e=this._getViewModel().getPlanObjectForId(t);e&&i.expandByObject(e.getContainer())}const r=i.getCenter(new we),s=E(M(r,t,n,a));this._roomlePlannerUiCallback.onUpdatePlanObjectPositions([{runtimeIds:e,position2d:s}])}_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 a of r)i.push(vt(a,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 s of e){const e=s.getFloorData(r);if(!e||!e.textPosition3d)return;if(e.roomLabel=s.getKernelObject().getLabelObject(),e.formattedArea=this._unitFormatter.formatSquareMMValueToUnitString(e.area),e.textPosition2d=M(e.textPosition3d,t,n,a),i.push(N(e)),this._initData.debug){const t=new ze(.1,32,16),n=new De({color:255}),a=new je(t,n);a.position.copy(e.textPosition3d),this._debugSpheres.floorPoints.add(a)}}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 ue&&(this._sendConstructionElementDimensions(e),this._sendObjectMeasurements(e),this._sendMeasurementLineDimension())}_sendRoomMeasurements(){this.cameraBehaviour.cameraControl instanceof ue&&(this._sendWallDimensions(),this._sendRoomAreaData())}_sendMeasurementLineDimension(){if(!(this.cameraBehaviour.cameraControl instanceof ue))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 i=r.getMeasurementLineDimension();i.fromPosition2d=M(i.fromPosition3d,e,t,n),i.toPosition2d=M(i.toPosition3d,e,t,n),i.textPosition2d=M(i.textPosition3d,e,t,n),i.lengthFormatted=this._unitFormatter.formatMMValueToUnitString(i.length),a.push(z(i))}this._roomlePlannerUiCallback.onUpdateMeasurementLineDimensions(a)}_sendObjectMeasurements(e){if(!(this.cameraBehaviour.cameraControl instanceof ue))return;if(!this.currentSelection&&!e)return;const t=this._plannerSceneEventHandler.getSelectedIds();if(0===t.length&&!e)return;const n=e||this._getViewModel().getPlanObjectForId(t[0]);if(!n||n instanceof b||n instanceof P||!(n instanceof p)&&!(n instanceof _))return;const a=this.cameraBehaviour.cameraControl.getCamera(),{clientWidth:i,clientHeight:r}=this._domHelper.element,s=this.cameraBehaviour.cameraControl.getKernelZoomFactor(),o=n.getObjectMeasurements(s,i,r),l=this.transformMeasurements(o.rectMeasurements,a,i,r),c=this.transformMeasurements(o.objectMeasurements,a,i,r),h=this.transformMeasurements(o.objectToWallsMeasurements,a,i,r);this._roomlePlannerUiCallback.onUpdateObjectMeasurements({rectMeasurements:l,objectMeasurements:c,objectToWallsMeasurements:h})}transformMeasurements(e,t,n,a){return e.map(e=>{const i=M(e.fromPosition3d,t,n,a),r=M(e.toPosition3d,t,n,a),s=M(e.textPosition3d,t,n,a);return Z({...e,fromPosition2d:i,toPosition2d:r,textPosition2d:s})})}_sendConstructionElementDimensions(e){if(!this.currentSelection&&!e)return;const t=e||this._getViewModel().getPlanObjectForId(this.currentSelection.staticItemRuntimeId||this.currentSelection.configurationRuntimeId);if(!t||!(t instanceof b||t instanceof P))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(),s=t.getConstructionElementMeasurements(r,a,i);if(!s)return;if(this._initData.debug){const e=new De({color:16711680}),t=new De({color:65280}),n=new De({color:255}),a=new ze(.1,32,16),i=new je(a,e);i.position.copy(s.leftMeasurement.fromPosition3d),i.position.y=5;const r=new je(a,e);r.position.copy(s.leftMeasurement.toPosition3d),r.position.y=5;const o=new je(a,t);o.position.copy(s.rightMeasurement.fromPosition3d),o.position.y=5;const l=new je(a,t);l.position.copy(s.rightMeasurement.toPosition3d),l.position.y=5;const c=new je(a,n);c.position.copy(s.elementRange.fromPosition3d),c.position.y=5;const h=new je(a,n);h.position.copy(s.elementRange.toPosition3d),h.position.y=5,this._debugSpheres.constructionElementsPoints.add(i),this._debugSpheres.constructionElementsPoints.add(r),this._debugSpheres.constructionElementsPoints.add(o),this._debugSpheres.constructionElementsPoints.add(l),this._debugSpheres.constructionElementsPoints.add(c),this._debugSpheres.constructionElementsPoints.add(h)}s.leftMeasurement=this._updateMeasurementPositions(s.leftMeasurement,n,a,i),s.rightMeasurement=this._updateMeasurementPositions(s.rightMeasurement,n,a,i),s.elementRange=this._updateMeasurementPositions(s.elementRange,n,a,i);const o={leftMeasurement:{...q(s.leftMeasurement)},rightMeasurement:{...q(s.rightMeasurement)},elementRange:{...q(s.elementRange)}};this._roomlePlannerUiCallback.onUpdateConstructionElementsMeasurements(o)}_sendWallDimensions(e=!0){this._initData.debug&&this._debugSpheres.wallPoints.children.length>0&&this._debugSpheres.wallPoints.clear(),function(e,t,n,a,i,r,s,o=!0,l=!1){if(!(t.cameraControl instanceof ue))return;if(t.cameraControl.isLocked()&&o)return;const c=[],{x:h,y:d}=e.getClientDimensions(),g=i.getWallPlanObjectViewModels(),u=t.cameraControl.getKernelZoomFactor(),m=t.cameraControl.getCamera();for(const e of g){const t=e.getWallDimension(u,h,d);t.isCurrentlyDrawn=a.isCurrentlyDrawing&&e.getPlanElement().getTo().extRef.jsObject===i.latestNodePlanObjectViewModel;const{isVectorWall:n}=e.getKernelObject();t.length<=0&&!n||(Ot(t,m,h,d),t.attic&&yt(t.attic,m,h,d),t.lengthFormatted=r.formatMMValueToUnitString(t.length),l&&Dt(t,s),c.push(D(t)))}n.onUpdateWallDimensions(c)}(this._domHelper,this.cameraBehaviour,this._roomlePlannerUiCallback,this._plannerSceneEventHandler,this._getViewModel(),this._unitFormatter,this._debugSpheres,e,this._initData.debug)}enableWallDrawing(){if(this.cameraBehaviour.cameraControl instanceof ue){const e=y(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)}setSceneEvents(e){var t,n;this.cameraBehaviour.cameraControl instanceof pe||(void 0!==e.construction&&(null===(t=this._plannerSceneEventHandler)||void 0===t||t.enableConstructionEvents(e.construction)),void 0!==e.objects&&(null===(n=this._plannerSceneEventHandler)||void 0===n||n.enableObjectEvents(e.objects)))}startedDrawing(){this._plannerSceneEventHandler.startDrawing(),this._showWallNodes()}stoppedDrawing(){this._plannerSceneEventHandler.stopDrawing()}disableEvents(){super.disableEvents(),this.disablePlannerEvents()}enableEvents(){super.enableEvents(),"planner"!==this._configuratorContext.baseContext||this.cameraBehaviour.cameraControl instanceof pe||this.enablePlannerEvents()}resetCameraPositionToStart(){this.plannerCameraBehaviour.externalApiResetCameraPosition(this.getBounds())}async moveCamera(e){return this.plannerCameraBehaviour instanceof Mt||this.plannerCameraBehaviour instanceof st?this.plannerCameraBehaviour.externalApiMoveCamera(e):Promise.resolve()}_setInteriorOrExteriorWallMaterial(e,t){const n=this._getViewModel().getWallPlanObjectViewModels();if(!n.length)return;const a=this._getKernelAccess().planInteractionHandler,i=e=>{a.setWallLeftMaterial(e,$e(e.leftMaterial,t))},r=e=>{a.setWallRightMaterial(e,$e(e.rightMaterial,t))},s=n.map(e=>e.getKernelObject()),o=this._plannerKernelAccess.kernelContainer.WallType.InnerWall,l=this._plannerKernelAccess.kernelContainer.WallType.OuterWallLeft,c=this._plannerKernelAccess.kernelContainer.WallType.OuterWallRight;for(const t of s)t.wallType===o&&"interior"===e&&(i(t),r(t)),t.wallType===l&&("interior"===e?r(t):i(t)),t.wallType===c&&("exterior"===e?r(t):i(t))}changeInteriorWallsMaterial(e){this._setInteriorOrExteriorWallMaterial("interior",e)}changeExteriorWallsMaterial(e){this._setInteriorOrExteriorWallMaterial("exterior",e)}changeFloorsMaterial(e){const t=this._getViewModel().getFloorPlanObjectViewModels();if(!t.length)return;const n=this._getKernelAccess().planInteractionHandler,a=t.map(e=>e.getKernelObject());n.startInteraction();for(const t of a)n.setFloorMaterial(t,$e(t.material,e));n.endInteraction()}getWallAngleDegrees(e){if(!(e instanceof s))return 0;const t=this.cameraBehaviour.cameraControl.getCamera(),n=new Me(t.position.x,t.position.z),a=new Me(e.getPosition().x,e.getPosition().z).clone().sub(n).normalize(),i=e.getKernelObject(),r=new Me(Math.sin(i.getAngle()),Math.cos(i.getAngle())),o=a.angle()-r.angle();return et.radToDeg(o)}moveElementPosition(e,t){const n=this._getKernelAccess().planInteractionHandler;n.setObjectFixedZ(e.getPlanElement(),!0);const a=e.getPlanElement().getCenter(),i=f(t).sub(f(a));n.moveElementBy(e.getPlanElement(),d(i)),n.setObjectFixedZ(e.getPlanElement(),!1),this._sendPlanObjectPositions()}moveElementsPosition(e,t){const n=new this._plannerKernelAccess.kernelContainer.PlanObjectPtrList;let a=f(t).sub(e[e.length-1].getPosition());e.forEach(e=>n.push_back(e.getPlanElement()));const i=d(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 Mt&&this.plannerCameraBehaviour.enablePanningOnShiftClick()}disablePanning(){this.plannerCameraBehaviour instanceof Mt&&this.plannerCameraBehaviour.disablePanningOnShiftRelease()}setObjectToWallMeasurementLength(e,t,n){const a=this._getViewModel().getPlanObjectForId(e),i=a.getPlanElement(),r=X(i.getWallDistances()).find(e=>tt(e.angle+"_"+e.length)===t);if(!r)return;const s=f(r.startPoint),o=f(r.endPoint),l=s.clone().sub(o).normalize(),c=(n-r.length)/1e3,h=a.getPosition().clone().add(l.multiplyScalar(c));this._getKernelAccess().planInteractionHandler.moveElementTo(i,d(h)),this._sendObjectMeasurements()}setWallMeasurementLength(e,t,n){const a=this.getPlannerSceneEventHandler().isCurrentlyDrawing,i=this._getKernelAccess().planInteractionHandler;let r=this._getViewModel().getPlanObjectForId(e);const s=i.isVectorPreviewModeEnabled();if(a&&!s){const e=this._getViewModel().latestNodePlanObjectViewModel,t=d(e.getPosition());i.endDrawing(t),this.escapeDrawing(!1),r=this._getViewModel().latestWallPlanObjectViewModel}if(r){const e=r.getKernelObject();i.startInteraction(),i.setLengthOfWall(e,t,e.getPreferredSide(),n,!0),i.endInteraction()}if(a&&!s){i.startInteraction();const e=this._getViewModel().latestNodePlanObjectViewModel,t=d(e.getPosition());i.beginDrawing(t,!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(){this._roomlePlannerUiCallback.onReadyForRender(),this._globalCallback.onReadyForRender()}notifyPlannerOnComponentSelectionCancel(e,t){var n;if(e)if("configurator"===this.configuratorContext.baseContext){if("click_outside"===t){let e=this.getObjectComponent(null!==(n=this.configuratorContext.rootComponentId)&&void 0!==n?n:this.configuratorContext.planObjectId);this._roomlePlannerUiCallback.onExternalObjectModuleSelected(e.externalObjectGroupId,null,null)}}else this._roomlePlannerUiCallback.onExternalObjectSelectionCancel(t);else this._roomlePlannerUiCallback.onComponentSelectionCancel()}_planObjectSelectionChanged(e,t){var n,a;const i=this.getObjectComponent(null!=t?t:e);if((null===(n=null==i?void 0:i.configurationType)||void 0===n?void 0:n.value)!==S.EXTERNAL)return;let r=this.getObjectComponent(null!==(a=this.configuratorContext.selectedRuntimeComponentId)&&void 0!==a?a:this.configuratorContext.planObjectId);r.externalRootModuleId===i.externalRootModuleId&&r.externalSubModuleId===i.externalSubModuleId||this._getKernelAccess().planObjectSelectionChanged(e,t)}highlightExternalObject(e){this.highlightPlanElementById(e.runtimeId),this._renderWithoutShadowsAndAO()}_selectExternalObjectModule(){var e,t;(null===(e=this._getKernelAccess())||void 0===e?void 0:e.kernelContainer)&&!this._configuratorContext.selectedRuntimeComponentId&&(null===(t=this.getPlanObject(this._configuratorContext.planElementId).configurationType)||void 0===t?void 0:t.value)===S.EXTERNAL&&this.selectComponent(this._configuratorContext.rootComponentId)}getObjectComponent(e){const t=this._getKernelAccess().planInteractionHandler.getPlan();return this._getKernelAccess().planModelViewHelper.getObjectComponent(t,e)}getCameraParameters3d(){return this._getViewModel().cameraType===Ze.CAMERA_3D?this.cameraBehaviour3d.cameraControl.getCurrentCameraParameters():null}_createCeilingLightGroup(){this._scene.children.find(e=>e.name===ot)||this._scene.add(this._getViewModel().getCeilingLightsGroup())}toggleInteriorLightsSceneSettings(e){this._isInteriorLightActive=e;const t=this.getScene();t.userData.environmentDefinition.rotation=e?ve:J,t.userData.environmentDefinition.intensity=e?Ce:Q,this._isInteriorLightActive&&(this._createCeilingLightGroup(),this._activateCeilingLight()),this._renderEverything()}async _insertRapiItems(e){const t=e.map((e,t)=>({id:e,index:t})),n=[];for(const{index:e,id:a}of t)n.push({index:e,id:a});return await this.insertRapiObjects(n)}async insertRapiObjects(e){const t=e.map(({id:e})=>Y(e)?this._rapiAccess.getItem(e):this._rapiAccess.getConfiguration(e)),n=await Promise.all(t);return(await this._plannerKernelAccess.insertItems(n)).map((t,n)=>({runtimeId:t,originalIndex:e[n].index}))}}l([c],xt.prototype,"_rapiAccess",void 0),l([c],xt.prototype,"_plannerMeshGenerator",void 0),l([c],xt.prototype,"_plannerInputManager",void 0),l([c],xt.prototype,"_roomlePlannerUiCallback",void 0),l([c],xt.prototype,"_localStorageHelper",void 0),l([c],xt.prototype,"_unitFormatter",void 0);const At="Could not retrieve configuration for external object! Did you implement onGetConfigurationForExternalObject?",Rt={left:0,top:1,right:1,bottom:0};class kt{constructor(e,t){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 $.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=d(new we(t.x,t.y,t.z)));const a=await(Y(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=O(this._plan.getPlanObjects());return(null==i?void 0: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,ee.ROOM_DESIGNER):this._rapiAccess.trackView("planXML",ee.ROOM_DESIGNER)),n()})}loadPlan(e,t){return this.setOverrides(t),new Promise((t,n)=>{const a=te(e);(a?this._rapiAccess.getPlanSnapshot(e):this._rapiAccess.getPlan(e)).then(n=>{this._sceneManager.backToPlanner(),this._sceneManager.setCompletelyLoaded(!1);const i=a?n.plan:n.planObjects;this._plan=this._planInteractionHandler.loadPlanXML(i),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,ee.ROOM_DESIGNER),t(n)},n)})}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){Promise.all([this._scriptLoader.fetch(fe,{id:"tween-js"})]).then(()=>{this._kernelReadyCallback=e;const{dls:t,ls:n,mode:a,stats:i}=this._initData;this._sceneManager||(this._sceneManager=new xt(this._creator_,Rt,this,a)),this._preloadPlanId&&this._sceneManager.preload(this._preloadPlanId);const r=ne.createDynamicLightSettingSource(t,n);i&&this.showStats(),this._sceneManager.enableHD(r),this._planInteractionHandler&&this._kernelReadyCallback()})}isReady(){this._planInteractionHandler=this._plannerKernelAccess.planInteractionHandler,this._kernelReadyCallback&&this._kernelReadyCallback()}showBenchmarks(){$.showBenchmarks()}getConfiguratorApi(){return this._configurator||(this._configurator=new lt(this._creator_,this._activePlugins),this._configurator.setOverrides(this._initData),this._configurator.initSceneManager(this._sceneManager)),this._configurator}startViewing(){this._sceneManager.startViewing(),this._roomlePlannerUiCallback.onContextChanged("glb-viewer")}startConfiguring(){var e,t;const n=this._sceneManager.currentSelection,a=(null===(e=n.item)||void 0===e?void 0:e.id)||(null===(t=n.configuration)||void 0===t?void 0:t.id);this._sceneManager.startConfiguring(),a&&this._configurator.notifyUiAboutNewLabel(a),this._roomlePlannerUiCallback.onContextChanged("configurator")}async selectPlanObjectById(e){return this._sceneManager.selectPlanObject(e)}highlightPlanElements(e){null===e?this._sceneManager.highlightPlanElementsById(null):Array.isArray(e)?this._sceneManager.highlightPlanElementsById(e):this._sceneManager.highlightPlanElementById(e)}backToPlanner(){this._sceneManager.backToPlanner(),this._roomlePlannerUiCallback.onContextChanged("planner")}showGUI(){this._sceneManager.showGUI()}async switchToConfigurator(){const e=await this._singlePromiseFactory.create(3,"startHSC",e=>{if(this._hscInstance)return e(this._hscInstance);t.import("./configurator-0dafcb92.legacy.js").then(({Configurator:t})=>{const n=new t(this._creator_);n.boot({kernelInstance:this._planInteractionHandler.getConfiguratorKernel(),kernelContainer:this._plannerKernelAccess.kernelContainer}),n.getApi().setOverrides(this._initData),n.getApi().initSceneManager(this._sceneManager),n.getApi().init(this._domHelper.element).then(()=>{this._hscInstance=n,e(this._hscInstance)})})});return this._currentMode=0,this.cancelSelection("isolation_mode_started"),e}async switchToViewer(){const e=await this._singlePromiseFactory.create(4,"startGLB",e=>{if(this._glbInstance)return e(this._glbInstance);t.import("./glb-viewer-039e52be.legacy.js").then(t=>{const n=new t.GlbViewer(this._creator_);n.boot(),n.getApi().setOverrides(this._initData),n.getApi().init(this._domHelper.element).then(()=>{this._glbInstance=n,e(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(2===this._currentMode&&this._glbInstance&&this._glbInstance.getApi().clearScene(),0===this._currentMode&&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){}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=d(new we(t.x,t.y,t.z))),ht(e)){if(t||n)throw new Error("External objects do not support position and rotation");return this._insertExternalObject(e)}const a=await(Y(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(0===e.length)return[];const t=e.map((e,t)=>({id:e,index:t})),n=async(e,t)=>({runtimeId:await this._insertExternalObject(e),originalIndex:t}),a=[],i=[];for(const{index:e,id:r}of t)ht(r)?a.push(n(r,e)):i.push({index:e,id:r});const r=this._sceneManager.insertRapiObjects(i),[s,o]=await Promise.all([Promise.all(a),r]),l=[...s,...o];return l.sort((e,t)=>e.originalIndex-t.originalIndex),l.map(e=>e.runtimeId)}async insertItems(e){if(0===e.length)return[];const t=e.map(e=>"string"==typeof e?e:e.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=O(e.objects);return wt(t,this._plannerKernelAccess,this._rapiAccess)}async getPlanOverview(){const e=(await this.getPlanModelViewHelper()).getPlanOverview(this._plan);return O(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("multiselect"),this._configuratorContext.selectionMode="multiselect"}disableMultiselect(){this._sceneManager.getPlannerSceneEventHandler().setSelectionMode("standard"),this._configuratorContext.selectionMode="standard"}async _insertExternalObject(e,t={}){var n,a,i;let r=e;if(ht(e)&&(r=await this._roomlePlannerUiCallback.onGetConfigurationForExternalObject(e),!r))throw new Error(At);if(dt(e)&&(null===(n=e.externalMeta)||void 0===n?void 0:n.refresh)&&(r=await this._roomlePlannerUiCallback.onGetConfigurationForExternalObject(e.id),!r))throw new Error(At);const s=null===(a=t.findFreeSpaceInPlan)||void 0===a||a,o=null!==(i=t.dragIn)&&void 0!==i&&i;return await this._loadExternalObjectGroup(r,s,o,!1),-1}async dragInObject(e,t,n="rml_id"){if("rml_serialized"===n)throw new Error("dragInObject is not supported for tc_id or rml_serialized");if(this._sceneManager.dragIn(t),"rml_id"===n){const t=Y(e)?await this._rapiAccess.getItem(e):await this._rapiAccess.getConfiguration(e),n=await this.insertItems([t]);if(1!==n.length)throw new Error("More than one object added, abort");return n[0]}if("tc_id"===n||"tc_serialized"===n)return this._insertExternalObject(e,{dragIn:!0});throw new Error("dragInObject is not supported for "+n)}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 e="Object has no partlist because it is not a configuration: "+t;return console.warn(e),Promise.reject(e)}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={}){var n,a;const i=this._planInteractionHandler;i.startInteraction();const r=[];for(const t of e){const e=i.addNode(t.from),s=i.addNode(t.to),o=i.addWall(e,s);void 0!==(null===(n=t.props)||void 0===n?void 0:n.height)&&i.setWallHeight(o,t.props.height),void 0!==(null===(a=t.props)||void 0===a?void 0:a.thickness)&&i.setWallThickness(o,t.props.thickness),r.push(o)}return t.keepInteractionOpen||i.endInteraction(),this._sceneManager.updateCameraOnDrawWalls(),this._sceneManager.updateScene(),r}async removeElements(e,t={}){this._sceneManager.lockCamera();const n=this._planInteractionHandler;for(const t of e){const e=this._sceneManager.getPlanObject(t.getId());let n;e&&(n=await wt([e],this._plannerKernelAccess,this._rapiAccess)),this._roomlePlannerUiCallback.onPlanElementChanged(L.REMOVED,(null==n?void 0:n.length)?n[0]:{...e,data:null}),this._planInteractionHandler.removeElement(t)}t.keepInteractionOpen||n.endInteraction(),this._sceneManager.unlockCamera()}hasWalls(){const e=this._planInteractionHandler,t=null==e?void 0:e.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=O(t.getExternalObjectGroups(n));if(0===a.length)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(e=>e.uniqueId),a=t.map(e=>e.runtimeId),i=await this.getPlanModelViewHelper(),r=this._planInteractionHandler.getPlan(),s=i.getPlanOverview(r),o={parentId:e||null,planObjects:[],combinedIds:[],plan:r.createPlanXmlWithObjects(n,!1,2)},l=s.objects,c=l.size();for(let e=0;e<c;e++){const t=l.get(e),n=t.configurationHash||t.catalogItemId;if(a.includes(t.runtimeId)){const{center:e,dimensions:a,rotation:i,rootComponentCenter:r}=t,s=JSON.stringify({center:e,dimensions:a,rotation:i,rootComponentCenter:r});o.planObjects.push({combinedId:n,position:s})}}const h=await this._rapiAccess.savePlanSnapshot(o);this._plannerKernelAccess.planSnapshotCreated(h);const d=new Promise((e,t)=>{Promise.allSettled([this.preparePerspectiveImage({runtimeIds:a}),this.prepareTopImage({runtimeIds:a})]).then(async([n,a])=>{if("rejected"!==n.status&&"rejected"!==a.status)try{const t=await this._rapiAccess.savePlanSnapshotImage(h,n.value,"perspectiveImage",a.value,"topImage");e({...t})}catch(e){t(e)}else t("Could not generate images of plan snapshot")})});try{return await d}catch(e){return console.error(e),h}}async saveCurrentPlanSnapshot(e,t){const n=await this.getPlanModelViewHelper(),a=this._planInteractionHandler.getPlan(),i=n.getPlanOverview(a),r={parentId:e||null,planObjects:[],combinedIds:[],plan:t?a.createPlanXmlWithObjects(t,!1,2):a.getPlanXML(!1,2)},s=i.objects,o=s.size();for(let e=0;e<o;e++){const n=s.get(e),a=n.configurationHash||n.catalogItemId;if(!t||a===t){const{center:e,dimensions:t,rotation:i,rootComponentCenter:s}=n,o=JSON.stringify({center:e,dimensions:t,rotation:i,rootComponentCenter:s});r.planObjects.push({combinedId:a,position:o})}}const l=await this._rapiAccess.savePlanSnapshot(r);this._plannerKernelAccess.planSnapshotCreated(l);const c=new Promise((e,t)=>{Promise.allSettled([this.preparePerspectiveImage(),this.prepareTopImage()]).then(async([n,a])=>{if("rejected"!==n.status&&"rejected"!==a.status)try{const t=await this._rapiAccess.savePlanSnapshotImage(l,n.value,"perspectiveImage",a.value,"topImage");e({...t})}catch(e){t(e)}else t("Could not generate images of plan snapshot")})});try{return await c}catch(e){return console.error(e),l}}getPlanXmlFrom(e){return e?te(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){const n=e.getPosition(),a=e.getRotation();return await this._sceneManager.deletePlanElementByIds([e.getPlanElement().getId()]),this.cancelSelection("swap_object"),await this.insertObject(t,n,a)}exportImageFromCamera(e="image",t=!1){return 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(e){return console.error(e),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 t.import("./imos-ix-poc-export-helper-eff99220.legacy.js");return e((await this.getPlanModelViewHelper()).getPlanOverview(this._plan),this._plannerKernelAccess.configurationExporter,this._plannerKernelAccess.kernelInstance)}async configureExternalObjectApi(e){let t="string"==typeof e?JSON.parse(e):e;await this._plannerKernelAccess.configureExternalObjectApi(t)}loadExternalObjectLibrary(e){const t=this._planInteractionHandler.getConfiguratorKernel(),n="string"==typeof e?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=[]){"configurator"===this.getConfiguratorContext().baseContext?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=[]){var r;const s=this.getConfiguratorContext(),o=this._sceneManager.getPlanObject(s.planElementId);if(await this._loadOrUpdateExternalObjectGroup(e,t,n,a,i,!1),(null===(r=o.configurationType)||void 0===r?void 0:r.value)===S.EXTERNAL)if(i.includes(o.configurationHash)){const t=this._createSerializedGroupCollection(e),n=JSON.parse(t[0]).id;await this._selectExternalObjectGroup(n,!1)}else await this._selectExternalObjectGroup(o.configurationHash,!1);this.updateScene()}async _loadOrUpdateExternalObjectGroup(e,t,n,a,i,r){const s=this._createSerializedGroupCollection(e);n?this._planInteractionHandler.startInteraction():this._planInteractionHandler.resumeInteraction();const o=n&&!r?this._getFaceTheCameraAngle(90):0,l={findFreeSpaceInPlan:t,applyGlobalChildMode:!1,isVisible:!n,correctArrangement:a},c=this._planInteractionHandler.addOrUpdateExternalPlanObjects(s,{x:0,y:0,z:0},o,l,i);n||this._planInteractionHandler.endInteraction();const h=this._planInteractionHandler.getPlan().extRef.jsObject,d=[];for(const e of c)e.hasConfiguration()&&d.push(h.getConfigurablePlanObjectForId(e.getId()));await Promise.all(d.map(async e=>{await e.isInitDone()}))}_createSerializedGroupCollection(e){const t=Array.isArray(e)?e:[e],n=[];for(const e of t){const t="string"==typeof e?e:JSON.stringify(e);n.push(t)}return n}_getFaceTheCameraAngle(e){const t=this._sceneManager.getCameraParameters3d();if(!(null==t?void 0:t.yaw))return 0;const n=ae(t.yaw),a=Math.round(n/e)*e;return ie(a)}async renderImagesOfExternalObjectGroup(e){const t=Array.isArray(e)?e:[e],n={},a=this._initData.animateCamera;this._initData.animateCamera=!1;for(const e of t){try{await this._loadExternalObjectGroup(e,!1,!1,!1),await this._selectExternalObjectModule(e.id,null,!0,!0,!1,!1),this.preparePerspectiveImage(),await this._sceneManager.waitForMaterialQueue(),this.updateScene();const t=await this.exportCanvasScreenshot();n[e.id]=t}catch(e){console.error(e)}this.backToPlanner()}for(const e of t)await this.removeExternalObjectGroup(e.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"),0!==i.runtimeId&&(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){"configurator"===this.getConfiguratorContext().baseContext||this._planInteractionHandler.setShowChildrenOfExternalObject(e,{value:v.OFF},!1),await this._selectExternalObjectGroup(e,!0),this.updateScene()}async selectExternalObjectRootModule(e){const t="configurator"===this.getConfiguratorContext().baseContext;t||this._planInteractionHandler.setShowChildrenOfExternalObject(e,{value:v.GROUND_COMPONENTS},!1),await this._selectExternalObjectModule(e,null,!t,t,!0,!0),this.updateScene()}async selectExternalObjectSubModule(e,t){const n="configurator"!==this.getConfiguratorContext().baseContext;await this._selectExternalObjectModule(e,t,n,!0,!0,!0),this.updateScene()}async openOrCloseGeometryOfExternalObject(e,t,n,a){const i=await this.getPlanModelViewHelper(),r=this._planInteractionHandler.getPlan(),s=i.getExternalObjectComponent(r,e,"");if(null==s?void 0:s.configurationRuntimeId){const e=n?"open":"close";this._sceneManager.animateElement(s.configurationRuntimeId,"openClose",e,!0,a),this.updateScene()}}async _selectKernelComponent(e){e.configurationHash&&e.configurationType.value===S.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,"");0!==i.runtimeId&&(t&&await this._roomlePlannerUiCallback.onBackToPlanner(),await this._sceneManager.selectPlanObject(i.runtimeId))}async _selectExternalObjectModule(e,t,n,a,i,r){const s=await this.getPlanModelViewHelper(),o=this._planInteractionHandler.getPlan(),l=s.getExternalObjectComponent(o,e,null!=t?t:"");if(0===l.runtimeId)return;const c="configurator"===this.getConfiguratorContext().baseContext,h=this._getSelectedPlanObjectComponent();let d=!1,g=n;c&&(d=(null==h?void 0:h.configurationRuntimeId)===l.configurationRuntimeId,g=!d,d||this._sceneManager.backToPlanner()),g&&await this._selectPlanObject(l),a&&!d&&await this._roomlePlannerUiCallback.onStartConfiguring(),0!==l.planComponentRuntimeId&&i&&this._sceneManager.selectComponent(l.planComponentRuntimeId,!1),r&&!c&&this._sceneManager.highlightExternalObject(l)}async _selectPlanObject(e){let t=e.runtimeId;const n=O(this._plan.getPlanObjects());for(const a of n)if(a.getConfigurationRuntimeId()===e.planComponentRuntimeId){t=a.getId();break}await this._sceneManager.selectPlanObject(t)}_getSelectedPlanObjectComponent(){var e;const t=this.getConfiguratorContext(),n=null!==(e=t.selectedRuntimeComponentId)&&void 0!==e?e:t.planObjectId;return this._sceneManager.getObjectComponent(n)}async getExternalObjectGroups(){const e=await this.getPlanModelViewHelper(),t=this._planInteractionHandler.getPlan(),n=[],a=O(e.getExternalObjectGroups(t));for(const e of a)n.push(JSON.parse(e.serializedDefinition));return n}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(){var e,t;const n=null===(t=null===(e=this._planInteractionHandler.getPlan())||void 0===e?void 0:e.extRef)||void 0===t?void 0:t.jsObject;null==n||n.turnLightsOnOrOff(!0),this._sceneManager.toggleInteriorLightsSceneSettings(!0)}turnLightsOff(){var e,t;const n=null===(t=null===(e=this._planInteractionHandler.getPlan())||void 0===e?void 0:e.extRef)||void 0===t?void 0:t.jsObject;null==n||n.turnLightsOnOrOff(!1),this._sceneManager.toggleInteriorLightsSceneSettings(!1)}async getPlanObjectForRuntimeId(e){var t,n;const a=null===(n=null===(t=this._planInteractionHandler.getPlan())||void 0===t?void 0:t.extRef)||void 0===n?void 0:n.jsObject;return Promise.resolve(a.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()}}l([c],kt.prototype,"_configuratorContext",void 0),l([c],kt.prototype,"_domHelper",void 0),l([c],kt.prototype,"_scriptLoader",void 0),l([c],kt.prototype,"_kernelAccessCallback",void 0),l([c],kt.prototype,"_plannerKernelAccess",void 0),l([c],kt.prototype,"_rapiAccess",void 0),l([c],kt.prototype,"_singlePromiseFactory",void 0),l([c],kt.prototype,"_roomlePlannerUiCallback",void 0),l([c],kt.prototype,"_lifeCycleManager",void 0),l([c],kt.prototype,"_dataSyncer",void 0),l([c],kt.prototype,"_initData",void 0),l([c],kt.prototype,"_idbManager",void 0),l([c],kt.prototype,"_globalInitData",void 0),l([c],kt.prototype,"_globalCallback",void 0),l([c],kt.prototype,"_unitFormatter",void 0);const Bt=[new se("script-loader",n),new se("planner-input-manager",class extends re{_canDrag(e){return!0}},1),new se("logger",oe),new se("planner-mesh-generator",le),new se("rapi-access",ce),new se("planner-selection-handler",class extends r{constructor(){super(...arguments),this._selectionMode="standard",this._selectedPlanElementViewModels=new Map}check(e){"standard"===this._selectionMode&&this._checkStandard(e),"multiselect"===this._selectionMode&&this._checkMulti(e)}removeSelection(){this._selectedPlanElementViewModels.clear()}cancelSelection(e){0!==this._selectedPlanElementViewModels.size&&this._selectedPlanElementViewModels.forEach((t,n)=>{this._selectedPlanElementViewModels.delete(n),t.deselect(),this.dispatchEvent(1,new mt({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((e,t)=>{this._selectedPlanElementViewModels.delete(t),e.deselect(),this.dispatchEvent(1,new mt({planElementViewModel:e,reason:"select_other"}))}),this._selectedPlanElementViewModels.set(e.getId(),e),e.select(),this.dispatchEvent(0,new mt({planElementViewModel:e})))}_checkMulti(e){ut(e)||this._selectedPlanElementViewModels.has(e.getId())||(this._selectedPlanElementViewModels.set(e.getId(),e),e.select(),this.dispatchEvent(2,new mt({planElementViewModels:this.getSelectedPlanElementViewModels()})),this.dispatchEvent(0,new mt({planElementViewModel:e})))}_deselectWallAndFloorElements(){this._selectedPlanElementViewModels.forEach((e,t)=>{ut(e)&&(this._selectedPlanElementViewModels.delete(t),e.deselect(),this.dispatchEvent(1,new mt({planElementViewModel:e,reason:"selection_mode_changed"})))})}setSelectionMode(e){this._selectionMode!==e&&("multiselect"===e&&this._deselectWallAndFloorElements(),this._selectionMode=e,this.dispatchEvent(3,new mt({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)}})];e("Planner",class extends a{constructor(e,t){super(e),this._activePlugins=t||[]}setupGlobals(){}setupDependencies(){he.setup(Bt),this.lookup("logger",this._context),this.lookup("planner-kernel-access",this._context).init(0)}cleanUpGlobals(){throw new Error("Method not implemented.")}cleanUpDependencies(){throw new Error("Method not implemented.")}bootFinished(){this._planner=new kt(this._context,this._activePlugins),this._planner.getMain=()=>this,window.RoomlePlanner||(this._activePlugins.length,window.RoomlePlanner=this._planner)}getApi(){return this._planner}getContextName(){return"planner"}})}}}));
2
+ //# sourceMappingURL=planner-96b5c06a.legacy.js.map