@2112-lab/central-plant 0.1.3 โ†’ 0.1.4

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 (115) hide show
  1. package/dist/bundle/index.js +1 -1
  2. package/dist/cjs/_virtual/_rollupPluginBabelHelpers.js +1 -1
  3. package/dist/cjs/node_modules/three/examples/jsm/controls/OrbitControls.js +1 -1
  4. package/dist/cjs/node_modules/three/examples/jsm/exporters/GLTFExporter.js +1 -0
  5. package/dist/cjs/node_modules/three/examples/jsm/exporters/OBJExporter.js +1 -0
  6. package/dist/cjs/node_modules/three/examples/jsm/exporters/PLYExporter.js +1 -0
  7. package/dist/cjs/node_modules/three/examples/jsm/exporters/STLExporter.js +1 -0
  8. package/dist/cjs/node_modules/three/examples/jsm/loaders/DRACOLoader.js +1 -0
  9. package/dist/cjs/node_modules/three/examples/jsm/loaders/GLTFLoader.js +1 -1
  10. package/dist/cjs/node_modules/three/examples/jsm/loaders/RGBELoader.js +1 -1
  11. package/dist/cjs/node_modules/three/examples/jsm/renderers/CSS2DRenderer.js +1 -0
  12. package/dist/cjs/src/analysis/analysis.js +1 -0
  13. package/dist/cjs/src/analysis/testing.js +1 -0
  14. package/dist/cjs/src/core/centralPlant.js +1 -0
  15. package/dist/cjs/src/core/debugLogger.js +1 -0
  16. package/dist/cjs/src/core/mathUtils.js +1 -0
  17. package/dist/cjs/src/core/nameUtils.js +1 -0
  18. package/dist/cjs/src/data/export.js +1 -0
  19. package/dist/cjs/src/data/import.js +1 -0
  20. package/dist/cjs/src/data/numerics.js +1 -0
  21. package/dist/cjs/src/helpers/sceneHelper.js +1 -0
  22. package/dist/cjs/src/index.js +1 -1
  23. package/dist/cjs/src/managers/components/animationManager.js +1 -0
  24. package/dist/cjs/src/managers/components/componentManager.js +1 -0
  25. package/dist/cjs/src/managers/components/pathfindingManager.js +1 -0
  26. package/dist/cjs/src/managers/controls/TransformControls.js +1 -0
  27. package/dist/cjs/src/managers/controls/cameraControlsManager.js +1 -0
  28. package/dist/cjs/src/managers/controls/dragDropManager.js +1 -0
  29. package/dist/cjs/src/managers/controls/keyboardControlsManager.js +1 -0
  30. package/dist/cjs/src/managers/controls/transformControlsManager.js +1 -0
  31. package/dist/cjs/src/managers/environment/environmentManager.js +1 -0
  32. package/dist/cjs/src/managers/environment/textureConfig.js +1 -0
  33. package/dist/cjs/src/managers/scene/sceneExportManager.js +1 -0
  34. package/dist/cjs/src/managers/scene/sceneInitializationManager.js +1 -0
  35. package/dist/cjs/src/managers/scene/sceneOperationsManager.js +1 -0
  36. package/dist/cjs/src/managers/scene/sceneTooltipsManager.js +1 -0
  37. package/dist/cjs/src/managers/system/disposalManager.js +1 -0
  38. package/dist/cjs/src/managers/system/hotReloadManager.js +1 -0
  39. package/dist/cjs/src/managers/system/performanceMonitor.js +1 -0
  40. package/dist/cjs/src/rendering/modelPreloader.js +1 -0
  41. package/dist/cjs/src/rendering/rendering2D.js +1 -0
  42. package/dist/cjs/src/rendering/rendering3D.js +1 -0
  43. package/dist/esm/_virtual/_rollupPluginBabelHelpers.js +1 -1
  44. package/dist/esm/node_modules/three/examples/jsm/controls/OrbitControls.js +1 -1
  45. package/dist/esm/node_modules/three/examples/jsm/exporters/GLTFExporter.js +1 -0
  46. package/dist/esm/node_modules/three/examples/jsm/exporters/OBJExporter.js +1 -0
  47. package/dist/esm/node_modules/three/examples/jsm/exporters/PLYExporter.js +1 -0
  48. package/dist/esm/node_modules/three/examples/jsm/exporters/STLExporter.js +1 -0
  49. package/dist/esm/node_modules/three/examples/jsm/loaders/DRACOLoader.js +1 -0
  50. package/dist/esm/node_modules/three/examples/jsm/loaders/GLTFLoader.js +1 -1
  51. package/dist/esm/node_modules/three/examples/jsm/loaders/RGBELoader.js +1 -1
  52. package/dist/esm/node_modules/three/examples/jsm/renderers/CSS2DRenderer.js +1 -0
  53. package/dist/esm/src/analysis/analysis.js +1 -0
  54. package/dist/esm/src/analysis/testing.js +1 -0
  55. package/dist/esm/src/core/centralPlant.js +1 -0
  56. package/dist/esm/src/core/debugLogger.js +1 -0
  57. package/dist/esm/src/core/mathUtils.js +1 -0
  58. package/dist/esm/src/core/nameUtils.js +1 -0
  59. package/dist/esm/src/data/export.js +1 -0
  60. package/dist/esm/src/data/import.js +1 -0
  61. package/dist/esm/src/data/numerics.js +1 -0
  62. package/dist/esm/src/helpers/sceneHelper.js +1 -0
  63. package/dist/esm/src/index.js +1 -1
  64. package/dist/esm/src/managers/components/animationManager.js +1 -0
  65. package/dist/esm/src/managers/components/componentManager.js +1 -0
  66. package/dist/esm/src/managers/components/pathfindingManager.js +1 -0
  67. package/dist/esm/src/managers/controls/TransformControls.js +1 -0
  68. package/dist/esm/src/managers/controls/cameraControlsManager.js +1 -0
  69. package/dist/esm/src/managers/controls/dragDropManager.js +1 -0
  70. package/dist/esm/src/managers/controls/keyboardControlsManager.js +1 -0
  71. package/dist/esm/src/managers/controls/transformControlsManager.js +1 -0
  72. package/dist/esm/src/managers/environment/environmentManager.js +1 -0
  73. package/dist/esm/src/managers/environment/textureConfig.js +1 -0
  74. package/dist/esm/src/managers/scene/sceneExportManager.js +1 -0
  75. package/dist/esm/src/managers/scene/sceneInitializationManager.js +1 -0
  76. package/dist/esm/src/managers/scene/sceneOperationsManager.js +1 -0
  77. package/dist/esm/src/managers/scene/sceneTooltipsManager.js +1 -0
  78. package/dist/esm/src/managers/system/disposalManager.js +1 -0
  79. package/dist/esm/src/managers/system/hotReloadManager.js +1 -0
  80. package/dist/esm/src/managers/system/performanceMonitor.js +1 -0
  81. package/dist/esm/src/rendering/modelPreloader.js +1 -0
  82. package/dist/esm/src/rendering/rendering2D.js +1 -0
  83. package/dist/esm/src/rendering/rendering3D.js +1 -0
  84. package/dist/index.d.ts +52 -255
  85. package/package.json +3 -6
  86. package/dist/cjs/node_modules/three/examples/jsm/controls/TransformControls.js +0 -1
  87. package/dist/cjs/src/animationManager.js +0 -1
  88. package/dist/cjs/src/componentManager.js +0 -1
  89. package/dist/cjs/src/debugLogger.js +0 -1
  90. package/dist/cjs/src/disposalManager.js +0 -1
  91. package/dist/cjs/src/environmentManager.js +0 -1
  92. package/dist/cjs/src/hotReloadManager.js +0 -1
  93. package/dist/cjs/src/keyboardControlsManager.js +0 -1
  94. package/dist/cjs/src/nameUtils.js +0 -1
  95. package/dist/cjs/src/pathfindingManager.js +0 -1
  96. package/dist/cjs/src/performanceMonitor.js +0 -1
  97. package/dist/cjs/src/sceneExportManager.js +0 -1
  98. package/dist/cjs/src/sceneInitializationManager.js +0 -1
  99. package/dist/cjs/src/textureConfig.js +0 -1
  100. package/dist/cjs/src/transformControlsManager.js +0 -1
  101. package/dist/esm/node_modules/three/examples/jsm/controls/TransformControls.js +0 -1
  102. package/dist/esm/src/animationManager.js +0 -1
  103. package/dist/esm/src/componentManager.js +0 -1
  104. package/dist/esm/src/debugLogger.js +0 -1
  105. package/dist/esm/src/disposalManager.js +0 -1
  106. package/dist/esm/src/environmentManager.js +0 -1
  107. package/dist/esm/src/hotReloadManager.js +0 -1
  108. package/dist/esm/src/keyboardControlsManager.js +0 -1
  109. package/dist/esm/src/nameUtils.js +0 -1
  110. package/dist/esm/src/pathfindingManager.js +0 -1
  111. package/dist/esm/src/performanceMonitor.js +0 -1
  112. package/dist/esm/src/sceneExportManager.js +0 -1
  113. package/dist/esm/src/sceneInitializationManager.js +0 -1
  114. package/dist/esm/src/textureConfig.js +0 -1
  115. package/dist/esm/src/transformControlsManager.js +0 -1
@@ -1 +1 @@
1
- Object.defineProperty(exports,"t",{value:!0});var t=require("three");function e(t){if(t&&t.t)return t;var e=Object.create(null);return t&&Object.keys(t).forEach(function(n){if("default"!==n){var i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,i.get?i:{enumerable:!0,get:function(){return t[n]}})}}),e.default=t,Object.freeze(e)}var n=e(t);function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n<e;n++)i[n]=t[n];return i}function r(t,e,n,i,r,s,o){try{var a=t[s](o),u=a.value}catch(t){return void n(t)}a.done?e(u):Promise.resolve(u).then(i,r)}function s(t){return function(){var e=this,n=arguments;return new Promise(function(i,s){var o=t.apply(e,n);function a(t){r(o,i,s,a,u,"next",t)}function u(t){r(o,i,s,a,u,"throw",t)}a(void 0)})}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function a(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,g(i.key),i)}}function u(t,e,n){return e&&a(t.prototype,e),n&&a(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function h(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=A(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var i=0,r=function(){};return{s:r,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,o=!0,a=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return o=t.done,t},e:function(t){a=!0,s=t},f:function(){try{o||null==n.return||n.return()}finally{if(a)throw s}}}}function c(t,e,n){return(e=g(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function l(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(l=function(){return!!t})()}function f(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,i)}return n}function d(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?f(Object(n),!0).forEach(function(e){c(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):f(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function w(){var t,e,n="function"==typeof Symbol?Symbol:{},i=n.iterator||"@@iterator",r=n.toStringTag||"@@toStringTag";function s(n,i,r,s){var u=i&&i.prototype instanceof a?i:a,h=Object.create(u.prototype);return v(h,"_invoke",function(n,i,r){var s,a,u,h=0,c=r||[],l=!1,f={p:0,n:0,v:t,a:d,f:d.bind(t,4),d:function(e,n){return s=e,a=0,u=t,f.n=n,o}};function d(n,i){for(a=n,u=i,e=0;!l&&h&&!r&&e<c.length;e++){var r,s=c[e],d=f.p,w=s[2];n>3?(r=w===i)&&(u=s[(a=s[4])?5:(a=3,3)],s[4]=s[5]=t):s[0]<=d&&((r=n<2&&d<s[1])?(a=0,f.v=i,f.n=s[1]):d<w&&(r=n<3||s[0]>i||i>w)&&(s[4]=n,s[5]=i,f.n=w,a=0))}if(r||n>1)return o;throw l=!0,i}return function(r,c,w){if(h>1)throw TypeError("Generator is already running");for(l&&1===c&&d(c,w),a=c,u=w;(e=a<2?t:u)||!l;){s||(a?a<3?(a>1&&(f.n=-1),d(a,u)):f.n=u:f.v=u);try{if(h=2,s){if(a||(r="next"),e=s[r]){if(!(e=e.call(s,u)))throw TypeError("iterator result is not an object");if(!e.done)return e;u=e.value,a<2&&(a=0)}else 1===a&&(e=s.return)&&e.call(s),a<2&&(u=TypeError("The iterator does not provide a '"+r+"' method"),a=1);s=t}else if((e=(l=f.n<0)?u:n.call(i,f))!==o)break}catch(e){s=t,a=1,u=e}finally{h=1}}return{value:e,done:l}}}(n,r,s),!0),h}var o={};function a(){}function u(){}function h(){}e=Object.getPrototypeOf;var c=[][i]?e(e([][i]())):(v(e={},i,function(){return this}),e),l=h.prototype=a.prototype=Object.create(c);function f(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,h):(t.__proto__=h,v(t,r,"GeneratorFunction")),t.prototype=Object.create(l),t}return u.prototype=h,v(l,"constructor",h),v(h,"constructor",u),u.displayName="GeneratorFunction",v(h,r,"GeneratorFunction"),v(l),v(l,r,"Generator"),v(l,i,function(){return this}),v(l,"toString",function(){return"[object Generator]"}),(w=function(){return{w:s,m:f}})()}function v(t,e,n,i){var r=Object.defineProperty;try{r({},"",{})}catch(t){r=0}v=function(t,e,n,i){if(e)r?r(t,e,{value:n,enumerable:!i,configurable:!i,writable:!i}):t[e]=n;else{function s(e,n){v(t,e,function(t){return this.i(e,n,t)})}s("next",0),s("throw",1),s("return",2)}},v(t,e,n,i)}function p(t){if(null!=t){var e=t["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],n=0;if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length))return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}}}throw new TypeError(typeof t+" is not iterable")}function m(t,e){return m=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},m(t,e)}function y(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var i,r,s,o,a=[],u=!0,h=!1;try{if(s=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;u=!1}else for(;!(u=(i=s.call(n)).done)&&(a.push(i.value),a.length!==e);u=!0);}catch(t){h=!0,r=t}finally{try{if(!u&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(h)throw r}}return a}}(t,e)||A(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function b(t){return function(t){if(Array.isArray(t))return i(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||A(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function g(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,e||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}function A(t,e){if(t){if("string"==typeof t)return i(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?i(t,e):void 0}}var M=function(){return u(function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"SceneViewer",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"info";o(this,t),this.namespace=e,this.debugLevel=n,this.isProduction="undefined"!=typeof process&&"production"===process.env.NODE_ENV,this.enabled=!this.isProduction,this.levels={error:0,warn:1,info:2,debug:3,verbose:4},this.currentLevel=this.levels[n]||this.levels.info},[{key:"setLevel",value:function(t){return this.currentLevel=this.levels[t]||this.levels.info,this}},{key:"enable",value:function(){return this.enabled=!0,this}},{key:"disable",value:function(){return this.enabled=!1,this}},{key:"_shouldLog",value:function(t){return this.enabled&&this.levels[t]<=this.currentLevel}},{key:"_formatMessage",value:function(t,e){for(var n="[".concat(this.namespace,":").concat(t.toUpperCase(),"]"),i=arguments.length,r=new Array(i>2?i-2:0),s=2;s<i;s++)r[s-2]=arguments[s];return[n,e].concat(r)}},{key:"error",value:function(t){if(this.o("error")){for(var e,n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];(e=console).error.apply(e,b(this.u.apply(this,["error",t].concat(i))))}}},{key:"warn",value:function(t){if(this.o("warn")){for(var e,n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];(e=console).warn.apply(e,b(this.u.apply(this,["warn",t].concat(i))))}}},{key:"info",value:function(t){if(this.o("info")){for(var e,n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];(e=console).log.apply(e,b(this.u.apply(this,["info",t].concat(i))))}}},{key:"debug",value:function(t){if(this.o("debug")){for(var e,n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];(e=console).debug.apply(e,b(this.u.apply(this,["debug",t].concat(i))))}}},{key:"verbose",value:function(t){if(this.o("verbose")){for(var e,n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];(e=console).debug.apply(e,b(this.u.apply(this,["verbose",t].concat(i))))}}},{key:"phase",value:function(t,e){for(var n=arguments.length,i=new Array(n>2?n-2:0),r=2;r<n;r++)i[r-2]=arguments[r];this.info.apply(this,["๐Ÿ” PHASE ".concat(t,": ").concat(e)].concat(i))}},{key:"success",value:function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];this.info.apply(this,["โœ… ".concat(t)].concat(n))}},{key:"failure",value:function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];this.error.apply(this,["โŒ ".concat(t)].concat(n))}},{key:"loading",value:function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];this.debug.apply(this,["๐Ÿ”„ ".concat(t)].concat(n))}},{key:"timing",value:function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];this.debug.apply(this,["โฑ๏ธ ".concat(t)].concat(n))}}])}(),k=new M("SceneViewer","info"),T=new M("Transform","warn"),_=new M("Pathfinder","info"),E=new M("Models","info"),x=new M("Materials","warn"),S=Object.freeze({__proto__:null,DebugLogger:M,logger:k,transformLogger:T,pathfinderLogger:_,modelLogger:E,materialLogger:x}),O=null,P=!1,R=0,C=[];function L(t){if(!P){P=!0,R=performance.now();var e=function(n){if(P){var i=(n-R)/1e3;R=n,function(t,e){C.forEach(function(n){try{n(t,e)}catch(t){k.error("Error in animation callback:",t)}})}(n,i),t&&t.renderer&&t.scene&&t.camera&&t.renderer.render(t.scene,t.camera),t&&t.controls&&t.controls.update&&t.controls.update(),O=requestAnimationFrame(e)}};O=requestAnimationFrame(e),k.info("Animation loop started")}}function I(){P&&(null!==O&&(cancelAnimationFrame(O),O=null),P=!1,k.info("Animation loop stopped"))}function j(t){if("function"==typeof t)return C.push(t),t;k.warn("Invalid animation callback")}function N(t){var e=C.indexOf(t);return-1!==e&&(C.splice(e,1),!0)}function U(){return P}var H={startAnimation:L,stopAnimation:I,addAnimationCallback:j,removeAnimationCallback:N,isAnimationRunning:U},B=Object.freeze({__proto__:null,startAnimation:L,stopAnimation:I,addAnimationCallback:j,removeAnimationCallback:N,isAnimationRunning:U,default:H});function F(t){return G.apply(this,arguments)}function G(){return(G=s(w().m(function t(e){var i;return w().w(function(t){for(;;)if(0===t.n)return k.info("Loading component: ".concat(e.id||"Unknown")),i={id:e.id||"unknown-component",type:e.type||"generic",data:e,object:new n.Group,position:e.position||{x:0,y:0,z:0},rotation:e.rotation||{x:0,y:0,z:0},scale:e.scale||{x:1,y:1,z:1}},t.a(2,i)},t)}))).apply(this,arguments)}function X(t,e,n,i){return t&&t.object?(e&&t.object.position.set(e.x||0,e.y||0,e.z||0),n&&t.object.rotation.set(n.x||0,n.y||0,n.z||0),i&&i.add&&i.add(t.object),t):(k.error("Cannot place component: invalid component object"),null)}function D(t,e){if(!e)return k.error("Cannot remove component: scene not provided"),!1;var n=null;return e.traverse(function(e){e.userData&&e.userData.id===t&&(n=e)}),n&&n.parent?(n.parent.remove(n),k.info("Component removed: ".concat(t)),!0):(k.warn("Component not found: ".concat(t)),!1)}function Y(t,e){if(!e)return k.error("Cannot get component: scene not provided"),null;var n=null;return e.traverse(function(e){e.userData&&e.userData.id===t&&(n=e)}),n}var z={loadComponent:F,placeComponent:X,removeComponent:D,getComponentById:Y},Z=Object.freeze({__proto__:null,loadComponent:F,placeComponent:X,removeComponent:D,getComponentById:Y,default:z});function K(t){t&&(t.geometry&&t.geometry.dispose(),t.material&&(Array.isArray(t.material)?t.material.forEach(function(t){return V(t)}):V(t.material)),t.children&&t.children.length>0&&b(t.children).forEach(function(t){return K(t)}))}function V(t){t&&(Object.keys(t).forEach(function(e){var i=t[e];i&&i instanceof n.Texture&&i.dispose()}),t.dispose())}function W(t){if(t){for(;t.children.length>0;){var e=t.children[0];t.remove(e),K(e)}k.info("Scene cleared and disposed")}else k.warn("Cannot cleanup: scene not provided")}function $(t){if(t){t.dispose();var e=t.domElement;e&&e.parentNode&&e.parentNode.removeChild(e),k.info("Renderer disposed")}else k.warn("Cannot cleanup: renderer not provided")}function J(){"undefined"!=typeof window&&window.$nuxt&&window.$nuxt.$off&&k.info("Nuxt event listeners cleaned up")}function q(t){t&&(t.stopAnimation&&t.stopAnimation(),t.controls&&(t.controls.dispose&&t.controls.dispose(),t.controls=null),t.scene&&(W(t.scene),t.scene=null),t.renderer&&($(t.renderer),t.renderer=null),t.camera=null,t.textureLoader=null,t.gltfLoader=null,k.info("All Three.js resources cleaned up"))}var Q,tt={disposeObject:K,disposeMaterial:V,cleanupScene:W,cleanupRenderer:$,cleanupNuxtEventListeners:J,cleanupThreeJsResources:q},et=Object.freeze({__proto__:null,disposeObject:K,disposeMaterial:V,cleanupScene:W,cleanupRenderer:$,cleanupNuxtEventListeners:J,cleanupThreeJsResources:q,default:tt});function nt(t){if(t.startsWith("/")&&(t=t.substring(1)),"undefined"!=typeof window){var e="undefined"!=typeof CentralPlantUtils;if("localhost"===window.location.hostname&&("3000"===window.location.port||"3001"===window.location.port))return"/".concat(t);if(e){var n="undefined"==typeof document?new(require("url").URL)("file:"+__filename).href:document.currentScript&&"SCRIPT"===document.currentScript.tagName.toUpperCase()&&document.currentScript.src||new URL("index.js",document.baseURI).href;return new URL("./assets/".concat(t),n).href}var i="undefined"==typeof document?new(require("url").URL)("file:"+__filename).href:document.currentScript&&"SCRIPT"===document.currentScript.tagName.toUpperCase()&&document.currentScript.src||new URL("index.js",document.baseURI).href;return new URL("../assets/".concat(t),i).href}return"assets/".concat(t)}function it(){return rt.apply(this,arguments)}function rt(){return(rt=s(w().m(function t(){var e;return w().w(function(t){for(;;)switch(t.n){case 0:if("undefined"==typeof window){t.n=4;break}return t.p=1,t.n=2,Promise.resolve().then(function(){return je});case 2:return e=t.v,Q=e.RGBELoader,t.a(2,!0);case 3:throw t.p=3,t.v,new Error("Failed to load Three.js loaders");case 4:return t.a(2,!1)}},t,null,[[1,3]])}))).apply(this,arguments)}var st={loadTextureSetAndCreateMaterial:null,checkThreeJSCompatibility:null,forceUpdateMaterials:null};function ot(){return at.apply(this,arguments)}function at(){return(at=s(w().m(function t(){var e;return w().w(function(t){for(;;)switch(t.n){case 0:if("undefined"==typeof window){t.n=4;break}return t.p=1,t.n=2,Promise.resolve().then(function(){return xe});case 2:return e=t.v,st.loadTextureSetAndCreateMaterial=e.loadTextureSetAndCreateMaterial,st.checkThreeJSCompatibility=e.checkThreeJSCompatibility,st.forceUpdateMaterials=e.forceUpdateMaterials,Object.entries(st).filter(function(t){var e=y(t,2);return e[0],"function"==typeof e[1]}).map(function(t){return y(t,1)[0]}),"function"==typeof st.checkThreeJSCompatibility&&st.checkThreeJSCompatibility(),t.a(2,!0);case 3:return t.p=3,t.v,t.a(2,!1);case 4:return t.a(2,!1)}},t,null,[[1,3]])}))).apply(this,arguments)}var ut=function(){return u(function t(e){o(this,t),this.component=e,this.loadersInitialized=!1,this.initLoaders()},[{key:"initLoaders",value:(c=s(w().m(function t(){return w().w(function(t){for(;;)switch(t.n){case 0:return t.p=1,t.n=2,Promise.all([it(),ot()]);case 2:this.loadersInitialized=!0,t.n=4;break;case 3:t.p=3,t.v;case 4:return t.a(2)}},t,this,[[1,3]])})),function(){return c.apply(this,arguments)})},{key:"createSkybox",value:(a=s(w().m(function t(){var e,i,r,s,o,a,u,c,l,f,d,v,m,y,b=this;return w().w(function(t){for(;;)switch(t.n){case 0:if((e=this.component)&&e.renderer&&e.scene){t.n=1;break}return k.warn("Cannot create skybox: component, renderer or scene not available"),t.a(2);case 1:if(Q){t.n=5;break}return t.p=2,t.n=3,it();case 3:t.n=5;break;case 4:return t.p=4,t.v,this.createFallbackEnvironment(),t.a(2);case 5:if(t.p=5,i=!(!e.renderer.context||"function"!=typeof e.renderer.context.isContextLost)&&e.renderer.context.isContextLost(),e.renderer.capabilities&&!i){t.n=6;break}return k.warn("WebGL context is lost or invalid, using fallback environment"),this.createFallbackEnvironment(),t.a(2);case 6:if(t.p=6,r=new n.PMREMGenerator(e.renderer)){t.n=7;break}throw new Error("PMREMGenerator could not be created");case 7:r.compileEquirectangularShader(),t.n=9;break;case 8:return t.p=8,m=t.v,k.warn("Failed to initialize PMREMGenerator:",m),this.createFallbackEnvironment(),t.a(2);case 9:s=nt("skyboxes/kloofendal_48d_partly_cloudy_puresky_2k.hdr"),o=nt("skyboxes/kloofendal_48d_partly_cloudy_puresky_1k.hdr"),a=nt("skyboxes/sky_fallback.jpg"),(u=[{type:"hdr",loader:new Q,paths:[s,o]},{type:"jpeg",loader:e.textureLoader||new n.TextureLoader,paths:[a]}]).forEach(function(t){var e=t.loader;e&&"function"==typeof e.setCrossOrigin&&e.setCrossOrigin("anonymous")}),c=function(t,i){try{var s,o;t.mapping=n.EquirectangularReflectionMapping,void 0!==t.colorSpace?t.colorSpace=e.renderer.outputColorSpace||n.SRGBColorSpace:void 0!==t.encoding&&(t.encoding=e.renderer.outputEncoding||n.sRGBEncoding);var a=r.fromEquirectangular(t).texture;return k.info("Generating environment map:\n - Type: ".concat(i,"\n - Texture valid: ").concat(null!==t,"\n - Processed map valid: ").concat(null!==a,"\n - Renderer encoding: ").concat(e.renderer.outputEncoding||e.renderer.outputColorSpace,"\n - Texture encoding: ").concat(t.encoding||t.colorSpace)),null!==(s=e.scene.environment)&&void 0!==s&&s.dispose&&e.scene.environment.dispose(),null!==(o=e.scene.background)&&void 0!==o&&o.dispose&&e.scene.background.dispose(),e.scene.environment=a,e.scene.background=a,t.dispose(),e.renderer&&(e.renderer.toneMappingExposure=1,e.renderer.render(e.scene,e.camera)),k.info("Environment map (".concat(i,") applied successfully")),!0}catch(t){return k.warn("Failed to apply ".concat(i," environment map:"),t),!1}},l=w().m(function t(){var e,n,i,s,o,a,u,l,f;return w().w(function(t){for(;;)switch(t.n){case 0:e=v[d],n=e.type,i=e.loader,s=e.paths,o=h(s),t.p=1,u=w().m(function t(){var e,s,o;return w().w(function(t){for(;;)switch(t.n){case 0:if(e=a.value,t.p=1,!e.startsWith("/")||e.includes("://")){t.n=3;break}return t.n=2,b.checkLocalTextureExists(e);case 2:if(t.v){t.n=3;break}return t.a(2,0);case 3:return k.info("Attempting to load ".concat(n," texture: ").concat(e)),t.n=4,new Promise(function(t,n){var r=setTimeout(function(){return n(new Error("Timeout loading ".concat(e)))},1e4);i.load(e,function(e){clearTimeout(r),t(e)},function(t){t.lengthComputable&&(t.loaded,t.total)},function(t){clearTimeout(r),n(t)})});case 4:if(s=t.v,!c(s,n)){t.n=5;break}return r.dispose(),t.a(2,{v:{v:void 0}});case 5:t.n=7;break;case 6:t.p=6,o=t.v,k.warn("Failed to load ".concat(e,":"),o.message);case 7:return t.a(2)}},t,null,[[1,6]])}),o.s();case 2:if((a=o.n()).done){t.n=6;break}return t.d(p(u()),3);case 3:if(0!==(l=t.v)){t.n=4;break}return t.a(3,5);case 4:if(!l){t.n=5;break}return t.a(2,l.v);case 5:t.n=2;break;case 6:t.n=8;break;case 7:t.p=7,f=t.v,o.e(f);case 8:return t.p=8,o.f(),t.f(8);case 9:return t.a(2)}},t,null,[[1,7,8,9]])}),d=0,v=u;case 10:if(!(d<v.length)){t.n=13;break}return t.d(p(l()),11);case 11:if(!(f=t.v)){t.n=12;break}return t.a(2,f.v);case 12:d++,t.n=10;break;case 13:this.createProceduralSky(r),t.n=15;break;case 14:t.p=14,y=t.v,k.error("Error creating skybox:",y),this.createFallbackEnvironment();case 15:return t.a(2)}},t,this,[[6,8],[5,14],[2,4]])})),function(){return a.apply(this,arguments)})},{key:"createFallbackEnvironment",value:function(){var t=this.component;if(t&&t.scene){k.info("Creating basic fallback environment");var e=new n.AmbientLight(16777215,.6);t.scene.add(e);var i=new n.DirectionalLight(16777215,.8);i.position.set(1,2,3),t.scene.add(i),t.scene.background=new n.Color(8900331)}}},{key:"createProceduralSky",value:function(t){var e=this.component;if(e&&e.scene){k.info("Using procedural sky fallback");var i=new n.AmbientLight(16777215,.6);e.scene.add(i);var r=new n.DirectionalLight(16777215,.8);r.position.set(1,1,1),e.scene.add(r);try{if(t&&"function"==typeof t.fromScene){var s=new n.Scene;s.add(new n.HemisphereLight(8900331,4473975,1));var o=t.fromScene(s);o&&o.texture&&(e.scene.environment=o.texture)}e.scene.background=new n.Color(8900331)}catch(t){k.warn("Failed to create procedural sky, using simple background",t),e.scene.background=new n.Color(8900331)}finally{t&&"function"==typeof t.dispose&&t.dispose()}}}},{key:"setupLighting",value:function(){var t=this.component;if(t&&t.scene){var e=[];t.scene.traverse(function(t){t instanceof n.Light&&e.push(t)}),e.forEach(function(e){t.scene.remove(e)});var i=new n.DirectionalLight(16777215,.8);i.position.set(5,10,7),i.castShadow=!0,i.shadow.mapSize.width=1024,i.shadow.mapSize.height=1024,i.shadow.camera.near=1,i.shadow.camera.far=30,i.shadow.camera.left=-10,i.shadow.camera.right=10,i.shadow.camera.top=10,i.shadow.camera.bottom=-10,i.shadow.bias=-.001,t.scene.add(i);var r=new n.AmbientLight(16777215,.3);t.scene.add(r);var s=new n.HemisphereLight(16777215,4473975,.3);t.scene.add(s),k.info("Scene lighting setup complete")}else k.warn("Cannot setup lighting: component or scene not available")}},{key:"createGround",value:function(){var t=this.component;if(!t||!t.scene)return k.warn("Cannot create ground: component or scene not available"),null;var e=new n.PlaneGeometry(100,100),i=new n.MeshStandardMaterial({color:13421772,roughness:.8,metalness:.2,side:n.DoubleSide}),r=new n.Mesh(e,i);return r.rotation.x=-Math.PI/2,r.position.y=-.01,r.receiveShadow=!0,r.userData={isEnvironmentObject:!0,type:"ground"},t.scene.add(r),k.info("Ground plane created"),r}},{key:"createWalls",value:function(){var t=this.component;if(!t||!t.scene)return k.warn("Cannot create walls: component or scene not available"),[];for(var e=[],i=20,r=50,s=new n.MeshStandardMaterial({color:14540253,roughness:.9,metalness:.1,side:n.DoubleSide}),o=[new n.BoxGeometry(r,i,1),new n.BoxGeometry(1,i,r),new n.BoxGeometry(r,i,1),new n.BoxGeometry(1,i,r)],a=[[0,10,-25],[25,10,0],[0,10,25],[-25,10,0]],u=["north-wall","east-wall","south-wall","west-wall"],h=0;h<4;h++){var c,l=new n.Mesh(o[h],s);(c=l.position).set.apply(c,b(a[h])),l.receiveShadow=!0,l.castShadow=!0,l.userData={isEnvironmentObject:!0,type:"wall",name:u[h]},t.scene.add(l),e.push(l)}return k.info("Environment walls created"),e}},{key:"setFog",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:13421772,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.01,i=this.component;i&&i.scene?(i.scene.fog=new n.FogExp2(t,e),k.info("Scene fog applied")):k.warn("Cannot set fog: component or scene not available")}},{key:"initializeEnvironment",value:(r=s(w().m(function t(){var e,i,r=this;return w().w(function(t){for(;;)switch(t.n){case 0:return e=this.component,t.p=1,t.n=2,it();case 2:return t.v,t.n=3,ot();case 3:t.v,t.n=5;break;case 4:t.p=4,t.v;case 5:if(e){t.n=6;break}return k.error("โŒ Cannot initialize environment: component is null"),t.a(2);case 6:if(e.renderer){t.n=7;break}return k.error("โŒ Cannot initialize environment: renderer is null"),t.a(2);case 7:return e.renderer.toneMapping||(e.renderer.toneMapping=n.ACESFilmicToneMapping),e.renderer.toneMappingExposure=1,void 0!==e.renderer.outputColorSpace?e.renderer.outputColorSpace=n.SRGBColorSpace:void 0!==e.renderer.outputEncoding&&(e.renderer.outputEncoding=n.sRGBEncoding),k.info("Renderer configured for HDR:\n - Tone mapping: ".concat(e.renderer.toneMapping,"\n - Color space: ").concat(e.renderer.outputColorSpace||e.renderer.outputEncoding)),t.n=8,this.createSkybox();case 8:return this.setupLighting(),t.n=9,this.addTexturedGround();case 9:return t.v?k.info("โœ… Ground created successfully"):k.error("โŒ Failed to create textured ground"),t.n=10,this.addBrickWalls();case 10:(i=t.v)&&0!==i.length?k.info("โœ… Created ".concat(i.length," walls")):k.warn("โš ๏ธ No walls were created"),this.addHorizonFog(),k.info("Environment initialization complete"),this.forceRefreshMaterials(),e.renderer&&e.scene&&e.camera&&(e.renderer.render(e.scene,e.camera),setTimeout(function(){e.renderer&&!e.isDestroyed&&(r.forceRefreshMaterials(),e.renderer.render(e.scene,e.camera))},1e3));case 11:return t.a(2)}},t,this,[[1,4]])})),function(){return r.apply(this,arguments)})},{key:"addTexturedGround",value:(i=s(w().m(function t(){var e,i,r,s,o,a,u,h,c,l;return w().w(function(t){for(;;)switch(t.n){case 0:if(st.loadTextureSetAndCreateMaterial){t.n=2;break}return t.n=1,ot();case 1:if(st.loadTextureSetAndCreateMaterial){t.n=2;break}return t.a(2,this.createGround());case 2:if((e=this.component)&&e.scene){t.n=3;break}return k.warn("Cannot create textured ground: component or scene not available"),t.a(2,null);case 3:return e.textureLoader||(e.textureLoader=new n.TextureLoader,e.textureLoader.setCrossOrigin("anonymous")),e.scene.traverse(function(t){t.userData&&"ground"===t.userData.type&&e.scene.remove(t)}),t.p=4,t.n=5,st.loadTextureSetAndCreateMaterial(e,"gravel_embedded_concrete");case 5:if(i=t.v){t.n=6;break}throw new Error("Failed to create ground material");case 6:return r=new n.MeshBasicMaterial({color:2293538,wireframe:!1,side:n.DoubleSide}),s=new n.PlaneGeometry(100,100),(o=new n.Mesh(s,i)).rotation.x=-Math.PI/2,o.position.y=-.01,o.receiveShadow=!0,(a=new n.Mesh(s,r)).rotation.x=-Math.PI/2,a.position.y=-.02,a.visible=!1,o.userData={isEnvironmentObject:!0,isBaseGround:!0,type:"ground"},a.userData={isEnvironmentObject:!0,type:"ground-debug"},e.scene.add(o),e.scene.add(a),k.info("Textured ground created"),t.a(2,o);case 7:return t.p=7,l=t.v,k.error("Error creating textured ground:",l),u=new n.PlaneGeometry(100,100),h=new n.MeshBasicMaterial({color:16711680,wireframe:!0,side:n.DoubleSide}),(c=new n.Mesh(u,h)).rotation.x=-Math.PI/2,c.position.y=-.01,c.userData={isEnvironmentObject:!0,isBaseGround:!0,type:"ground-error"},e.scene.add(c),t.a(2,c)}},t,this,[[4,7]])})),function(){return i.apply(this,arguments)})},{key:"addBrickWalls",value:(e=s(w().m(function t(){var e,i,r,s,o,a,u,h,c,l,f,d;return w().w(function(t){for(;;)switch(t.n){case 0:if(st.loadTextureSetAndCreateMaterial){t.n=2;break}return t.n=1,ot();case 1:if(st.loadTextureSetAndCreateMaterial){t.n=2;break}return t.a(2,this.createWalls());case 2:if((e=this.component)&&e.scene){t.n=3;break}return k.warn("Cannot create brick walls: component or scene not available"),t.a(2,[]);case 3:return e.scene.traverse(function(t){t.userData&&"wall"===t.userData.type&&e.scene.remove(t)}),t.p=4,t.n=5,st.loadTextureSetAndCreateMaterial(e,"brick");case 5:for(i=t.v,r=[],s=20,o=50,a=[new n.BoxGeometry(o,s,1),new n.BoxGeometry(1,s,o),new n.BoxGeometry(o,s,1),new n.BoxGeometry(1,s,o)],u=[[0,10,-25],[25,10,0],[0,10,25],[-25,10,0]],h=["north-wall","east-wall","south-wall","west-wall"],c=0;c<4;c++)f=new n.Mesh(a[c],i),(l=f.position).set.apply(l,b(u[c])),f.receiveShadow=!0,f.castShadow=!0,f.userData={isEnvironmentObject:!0,type:"wall",name:h[c]},e.scene.add(f),r.push(f);return k.info("Textured environment walls created"),t.a(2,r);case 6:return t.p=6,d=t.v,k.error("Error creating brick walls:",d),t.a(2,this.createWalls())}},t,this,[[4,6]])})),function(){return e.apply(this,arguments)})},{key:"addHorizonFog",value:function(){var t=this.component;if(t&&t.scene){t.scene.fog=new n.FogExp2(14213375,.005),k.info("Horizon fog applied")}else k.warn("Cannot set horizon fog: component or scene not available")}},{key:"checkLocalTextureExists",value:(t=s(w().m(function t(e){return w().w(function(t){for(;;)switch(t.n){case 0:if(e.startsWith("/")&&(e=e.substring(1)),"undefined"==typeof window){t.n=1;break}return t.a(2,new Promise(function(t){var n=new Image;n.onload=function(){return t(!0)},n.onerror=function(){return t(!1)},n.src=e,setTimeout(function(){return t(!1)},2e3)}));case 1:return t.a(2,!1)}},t)})),function(e){return t.apply(this,arguments)})},{key:"forceRefreshMaterials",value:function(){var t=this.component;if(t&&t.scene){var e=st.hasValidImageData||function(t){return t&&t.image},i=st.createPlaceholderTexture||function(){return null};t.scene.traverse(function(t){t.isMesh&&t.material&&(Array.isArray(t.material)?t.material:[t.material]).forEach(function(t){if(t){t.needsUpdate=!0,t.color&&"function"==typeof t.color.convertSRGBToLinear&&t.color.convertSRGBToLinear();["map","normalMap","roughnessMap","metalnessMap","aoMap","bumpMap"].forEach(function(r){var s=t[r];if(s)if(e(s))s.needsUpdate=!0,"map"===r&&void 0!==s.colorSpace?s.colorSpace=n.SRGBColorSpace:"map"===r&&void 0!==s.encoding&&(s.encoding=n.sRGBEncoding);else if(i){var o=i("normalMap"===r?8421631:13421772);o&&(t[r]=o)}})}})}),st.forceUpdateMaterials&&st.forceUpdateMaterials(t.scene),t.renderer&&t.camera&&t.renderer.render(t.scene,t.camera)}else k.warn("Cannot refresh materials: component or scene not available")}}]);var t,e,i,r,a,c}(),ht=null;function ct(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return(!ht||t&&ht.component!==t)&&(ht=new ut(t)),ht}var lt,ft={EnvironmentManager:ut,getEnvironmentManager:ct,initializeEnvironment:(lt=s(w().m(function t(e){var n;return w().w(function(t){for(;;)switch(t.n){case 0:return n=ct(e),t.n=1,n.initializeEnvironment();case 1:return t.a(2,n)}},t)})),function(t){return lt.apply(this,arguments)})},dt=Object.freeze({__proto__:null,EnvironmentManager:ut,getEnvironmentManager:ct,default:ft}),wt="undefined"!=typeof window,vt=wt&&"development"===process.env.NODE_ENV,pt=function(){return u(function t(e){o(this,t),this.component=e,this.isDev=vt,this.instanceId=Date.now()+Math.random(),this.hotReloadCleanupHandler=null,this.visibilityChangeHandler=null,this.nuxtHotReloadHandler=null,this.memoryCheckInterval=null,this.timeoutIds=new Set,this.intervalIds=new Set},[{key:"setupHotReloadHandling",value:function(){var t=this;wt&&this.isDev&&(window._sceneViewerInstances||(window._sceneViewerInstances=new Set),window._sceneViewerInstances.add(this.component),this.hotReloadCleanupHandler=function(){t.component&&"function"==typeof t.component.enhancedDisposal&&t.component.enhancedDisposal(),window._sceneViewerInstances&&window._sceneViewerInstances.delete(t.component)},window.addEventListener("beforeunload",this.hotReloadCleanupHandler),window.addEventListener("pagehide",this.hotReloadCleanupHandler))}},{key:"cleanupHotReloadHandlers",value:function(){wt&&this.isDev&&(this.hotReloadCleanupHandler&&(window.removeEventListener("beforeunload",this.hotReloadCleanupHandler),window.removeEventListener("pagehide",this.hotReloadCleanupHandler),this.hotReloadCleanupHandler=null),this.visibilityChangeHandler&&(document.removeEventListener("visibilitychange",this.visibilityChangeHandler),this.visibilityChangeHandler=null),this.nuxtHotReloadHandler&&window.$nuxt&&window.$nuxt.$off&&(window.$nuxt.$off("routeChanged",this.nuxtHotReloadHandler),window.$nuxt.$off("$nuxtReady",this.nuxtHotReloadHandler),this.nuxtHotReloadHandler=null),this.memoryCheckInterval&&(clearInterval(this.memoryCheckInterval),this.memoryCheckInterval=null),window._sceneViewerInstances&&window._sceneViewerInstances.delete(this.component))}},{key:"trackTimeout",value:function(t){return t&&this.timeoutIds.add(t),t}},{key:"trackInterval",value:function(t){return t&&this.intervalIds.add(t),t}},{key:"clearTrackedTimeout",value:function(t){return!!this.timeoutIds.has(t)&&(clearTimeout(t),this.timeoutIds.delete(t),!0)}},{key:"clearTrackedInterval",value:function(t){return!!this.intervalIds.has(t)&&(clearInterval(t),this.intervalIds.delete(t),!0)}},{key:"clearAllTrackedTimers",value:function(){this.timeoutIds.forEach(function(t){clearTimeout(t)}),this.timeoutIds.clear(),this.intervalIds.forEach(function(t){clearInterval(t)}),this.intervalIds.clear()}}])}();function mt(t,e){if(wt&&vt){window._hotReloadRegistry||(window._hotReloadRegistry=new Map);var n=window._hotReloadRegistry.get(t);n&&"function"==typeof n.cleanup&&n.cleanup(),window._hotReloadRegistry.set(t,{timestamp:Date.now(),cleanup:e})}}function yt(){return vt&&wt&&window._hotReloadRegistry&&window._hotReloadRegistry.size>0}function bt(t){if(wt&&vt&&window._hotReloadRegistry){var e=window._hotReloadRegistry.get(t);e&&"function"==typeof e.cleanup&&(e.cleanup(),window._hotReloadRegistry.delete(t))}}var gt={HotReloadManager:pt,handleHotReload:mt,isHotReloading:yt,cleanupForHotReload:bt},At=Object.freeze({__proto__:null,HotReloadManager:pt,handleHotReload:mt,isHotReloading:yt,cleanupForHotReload:bt,default:gt}),Mt=new Map,kt=!1;function Tt(){"undefined"!=typeof window?kt||(window.addEventListener("keydown",Et),window.addEventListener("keyup",xt),kt=!0,k.info("Keyboard controls initialized")):k.warn("Cannot initialize keyboard controls: window is not defined")}function _t(){"undefined"!=typeof window&&kt&&(window.removeEventListener("keydown",Et),window.removeEventListener("keyup",xt),Mt.clear(),kt=!1,k.info("Keyboard controls cleaned up"))}function Et(t){var e=Ct(t),n=Mt.get(e);n&&(t.preventDefault(),n.callback(t))}function xt(t){var e=Ct(t),n=Mt.get(e);n&&n.onKeyUp&&(t.preventDefault(),n.onKeyUp(t))}function St(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=Rt(t);return Mt.set(i,{callback:e,onKeyUp:n.onKeyUp||null,description:n.description||""}),kt||Tt(),i}function Ot(t){var e=Rt(t);return Mt.delete(e)}function Pt(){var t=[];return Mt.forEach(function(e,n){t.push({key:n,description:e.description})}),t}function Rt(t){return t.toLowerCase()}function Ct(t){var e="";return t.ctrlKey&&(e+="ctrl+"),t.altKey&&(e+="alt+"),t.shiftKey&&(e+="shift+"),t.metaKey&&(e+="meta+"),e+=t.key.toLowerCase()}function Lt(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};St("r",function(){t.camera&&t.controls&&(t.camera.position.set(-10,10,10),t.controls.target.set(0,0,0),t.controls.update(),k.info("Camera reset"))},{description:"Reset camera view"}),St("w",function(){if(t.scene){var n=!e.wireframeEnabled;e.wireframeEnabled=n,t.scene.traverse(function(t){t.isMesh&&t.material&&(Array.isArray(t.material)?t.material.forEach(function(t){t.wireframe=n}):t.material.wireframe=n)}),k.info("Wireframe mode: ".concat(n?"enabled":"disabled"))}},{description:"Toggle wireframe mode"}),St("p",function(){t.performanceUI&&t.performanceUI.toggle()},{description:"Toggle performance monitor"}),k.info("Common keyboard controls setup")}var It={initKeyboardControls:Tt,cleanupKeyboardControls:_t,registerKeyHandler:St,unregisterKeyHandler:Ot,getRegisteredKeyHandlers:Pt,setupCommonControls:Lt},jt=Object.freeze({__proto__:null,initKeyboardControls:Tt,cleanupKeyboardControls:_t,registerKeyHandler:St,unregisterKeyHandler:Ot,getRegisteredKeyHandlers:Pt,setupCommonControls:Lt,default:It});function Nt(t){if(!t)return null;var e=t.toUpperCase().replace(/\s+COMPONENT$/i,"").replace(/\s+/g,"-").replace(/[^A-Z0-9\-]/g,"");return e=e.replace(/-COMPONENT$/,"")}function Ut(t,e){if(!t||!e)return null;var n=null;return t.traverse(function(t){var i;if(!n)if(t.uuid!==e)if((null===(i=t.userData)||void 0===i?void 0:i.originalUuid)!==e){if(t.name&&Nt(t.name)===e)return void(n=t)}else n=t;else n=t}),n}function Ht(t){var e;return t?null!==(e=t.userData)&&void 0!==e&&e.originalUuid?t.userData.originalUuid:t.uuid&&!t.uuid.includes("-")&&t.uuid.length>10?t.uuid:t.name?Nt(t.name):null:null}var Bt=Object.freeze({__proto__:null,generateUuidFromName:Nt,namesGenerateSameUuid:function(t,e){var n=Nt(t),i=Nt(e);return n&&i&&n===i},findObjectByHardcodedUuid:Ut,getHardcodedUuid:Ht});class Ft{constructor(t=0,e=0,n=0){this.x=t,this.y=e,this.z=n}clone(){return new Ft(this.x,this.y,this.z)}toArray(){return[this.x,this.y,this.z]}normalize(){const t=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z);return t>0&&(this.x/=t,this.y/=t,this.z/=t),this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}}class Gt{constructor(t){this.scene=t}getRoot(){return this.scene.object}getWorldPosition(t){if(!t.userData?.worldBoundingBox)return new Ft;const{min:e,max:n}=t.userData.worldBoundingBox;return new Ft((e[0]+n[0])/2,(e[1]+n[1])/2,(e[2]+n[2])/2)}getBoundingBox(t){if(!t.userData?.worldBoundingBox)return null;const{min:e,max:n}=t.userData.worldBoundingBox;return{min:new Ft(e[0],e[1],e[2]),max:new Ft(n[0],n[1],n[2])}}findObjectByUUID(t){return this.h(this.getRoot(),t)}h(t,e){if(t.uuid===e)return t;if(t.children)for(const n of t.children){const t=this.h(n,e);if(t)return t}return null}findParentObject(t){return t.userData&&Array.isArray(t.userData.direction)?{isDirectionParent:!0}:this.l(this.getRoot(),t)}l(t,e){if(t.children){for(const n of t.children)if(n.uuid===e.uuid)return"Scene"===t.type?null:t;for(const n of t.children){const t=this.l(n,e);if(t)return t}}return null}isVoxelOccupiedByMesh(t,e){const[n,i,r]=t.split(",").map(Number),s=new Ft(n*e,i*e,r*e);return this.A(this.getRoot(),s)}A(t,e){if("Mesh"===t.type){const n=this.getBoundingBox(t);if(n&&e.x>=n.min.x&&e.x<=n.max.x&&e.y>=n.min.y&&e.y<=n.max.y&&e.z>=n.min.z&&e.z<=n.max.z)return!0}if(t.children)for(const n of t.children)if(this.A(n,e))return!0;return!1}}class Xt{constructor(t=.5,e=0){this.gridSize=t,this.safetyMargin=e}voxelKey(t){return[Math.round(t.x/this.gridSize),Math.round(t.y/this.gridSize),Math.round(t.z/this.gridSize)].join(",")}voxelToVec3(t){const[e,n,i]=t.split(",").map(Number);return new Ft(e*this.gridSize,n*this.gridSize,i*this.gridSize)}getNeighbors(t){const[e,n,i]=t.split(",").map(Number);return[[e+1,n,i],[e-1,n,i],[e,n+1,i],[e,n-1,i],[e,n,i+1],[e,n,i-1]].map(t=>t.join(","))}manhattan(t,e){const[n,i,r]=t.split(",").map(Number),[s,o,a]=e.split(",").map(Number);return Math.abs(n-s)+Math.abs(i-o)+Math.abs(r-a)}worldToVoxelDistance(t){return Math.ceil(t/this.gridSize)}voxelToWorldDistance(t){return t*this.gridSize}getSafetyMarginVoxels(){return this.worldToVoxelDistance(this.safetyMargin)}isVoxelInSafetyMargin(t,e){const n=this.voxelToVec3(t),i=this.safetyMargin;return n.x>=e.min.x-i&&n.x<=e.max.x+i&&n.y>=e.min.y-i&&n.y<=e.max.y+i&&n.z>=e.min.z-i&&n.z<=e.max.z+i}getVoxelsInBoundingBox(t){const e=this.getSafetyMarginVoxels(),n=t.min,i=t.max,r=[];for(let t=Math.round(n.x/this.gridSize)-e;t<=Math.round(i.x/this.gridSize)+e;t++)for(let s=Math.round(n.y/this.gridSize)-e;s<=Math.round(i.y/this.gridSize)+e;s++)for(let o=Math.round(n.z/this.gridSize)-e;o<=Math.round(i.z/this.gridSize)+e;o++)r.push(`${t},${s},${o}`);return r}}class Dt{constructor(t,e,n,i){this.config=t,this.MIN_SEGMENT_LENGTH=e,this.sceneManager=n,this.gridSystem=i}isConnector(t){return!!this.config.connections&&this.config.connections.some(e=>e.from===t.uuid||e.to===t.uuid)}getConnectorDirection(t){if(t.userData&&Array.isArray(t.userData.direction)){const[e,n,i]=t.userData.direction;return new Ft(e,n,i)}if(!t.parent)return null;const e=this.sceneManager.getWorldPosition(t);let n;const i=this.sceneManager.getBoundingBox(t.parent);n=i?new Ft((i.min.x+i.max.x)/2,(i.min.y+i.max.y)/2,(i.min.z+i.max.z)/2):this.sceneManager.getWorldPosition(t.parent);const r=new Ft(e.x-n.x,e.y-n.y,e.z-n.z).normalize(),s=Math.abs(r.x),o=Math.abs(r.y),a=Math.abs(r.z);return s>=o&&s>=a?(r.y=0,r.z=0,r.x=Math.sign(r.x)):o>=s&&o>=a?(r.x=0,r.z=0,r.y=Math.sign(r.y)):(r.x=0,r.y=0,r.z=Math.sign(r.z)),r}createVirtualSegment(t,e){const n=this.getConnectorDirection(t);if(!n)return null;const i=new Ft(e.x+n.x*this.MIN_SEGMENT_LENGTH,e.y+n.y*this.MIN_SEGMENT_LENGTH,e.z+n.z*this.MIN_SEGMENT_LENGTH);return{startPos:e,endPos:i,direction:n,startKey:this.gridSystem.voxelKey(e),endKey:this.gridSystem.voxelKey(i)}}processConnectors(t,e,n,i){this.M(t,e,n,i)}M(t,e,n,i){if("Mesh"===t.type){if(t.uuid===n||t.uuid===i)return;const r=this.sceneManager.getWorldPosition(t),s=this.createVirtualSegment(t,r);s&&this.k(s,r,e)}if(t.children)for(const r of t.children)this.M(r,e,n,i)}k(t,e,n){const i=t.direction,r=this.gridSystem.worldToVoxelDistance(this.MIN_SEGMENT_LENGTH+2*this.gridSystem.safetyMargin);for(let t=0;t<=r;t++){const r=`${Math.round(e.x/this.gridSystem.gridSize+i.x*t)},${Math.round(e.y/this.gridSystem.gridSize+i.y*t)},${Math.round(e.z/this.gridSystem.gridSize+i.z*t)}`;n.add(r)}}clusterConnections(t){const e=new Map,n=new Map;let i=0;t.forEach(t=>{const{from:r,to:s}=t;if(e.has(r)||e.has(s)){if(e.has(r)&&!e.has(s)){const t=e.get(r);e.set(s,t),n.get(t).add(s)}else if(!e.has(r)&&e.has(s)){const t=e.get(s);e.set(r,t),n.get(t).add(r)}else if(e.has(r)&&e.has(s)){const t=e.get(r),i=e.get(s);if(t!==i){n.get(i).forEach(i=>{e.set(i,t),n.get(t).add(i)}),n.delete(i)}}}else{const t=i++;e.set(r,t),e.set(s,t),n.set(t,new Set([r,s]))}});const r=Array.from(n.entries()).map(([t,e])=>({clusterId:t,objects:Array.from(e)})).filter(t=>!t.objects.some(t=>t.includes("GATEWAY")));return r.forEach(t=>{t.objectPoints=t.objects.map(t=>{const e=this.sceneManager.findObjectByUUID(t);if(e&&e.userData.worldBoundingBox){return{uuid:t,point:this.sceneManager.getWorldPosition(e),direction:e.userData.direction?new Ft(...e.userData.direction):null}}return null}).filter(t=>null!==t),t.displacedPoints=t.objectPoints.map(t=>{const e=t.direction?t.point.clone().add(t.direction.multiplyScalar(.5)):t.point.clone();return{uuid:t.uuid,originalPoint:t.point,displacedPoint:e,direction:t.direction}})}),r}}class Yt{constructor(t,e,n,i,r){this.sceneManager=t,this.gridSystem=e,this.connectorManager=n,this.MIN_SEGMENT_LENGTH=i,this.ASTAR_TIMEOUT=r}astar(t,e,n){const i=new Set([t]),r={},s={[t]:0},o={[t]:this.gridSystem.manhattan(t,e)},a=Date.now();for(;i.size>0;){if(Date.now()-a>this.ASTAR_TIMEOUT)return null;let t=null,u=1/0;for(const e of i)o[e]<u&&(u=o[e],t=e);if(t===e){const e=[t];for(;r[t];)t=r[t],e.unshift(t);return e}i.delete(t);for(const a of this.gridSystem.getNeighbors(t)){if(n.has(a))continue;const u=s[t]+1;u<(s[a]??1/0)&&(r[a]=t,s[a]=u,o[a]=u+this.gridSystem.manhattan(a,e),i.add(a))}}return null}findPathWithVirtualSegments(t,e,n,i,r){let s=t,o=e;const a=new Set(n);if(i){s=i.endKey;const t=i.startPos,e=i.direction,n=this.gridSystem.worldToVoxelDistance(this.MIN_SEGMENT_LENGTH);for(let i=0;i<n;i++){const n=`${Math.round(t.x/this.gridSystem.gridSize+e.x*i)},${Math.round(t.y/this.gridSystem.gridSize+e.y*i)},${Math.round(t.z/this.gridSystem.gridSize+e.z*i)}`;a.add(n)}}if(r){o=r.endKey;const t=r.startPos,e=r.direction,n=this.gridSystem.worldToVoxelDistance(this.MIN_SEGMENT_LENGTH);for(let i=0;i<n;i++){const n=`${Math.round(t.x/this.gridSystem.gridSize+e.x*i)},${Math.round(t.y/this.gridSystem.gridSize+e.y*i)},${Math.round(t.z/this.gridSystem.gridSize+e.z*i)}`;a.add(n)}}const u=this.astar(s,o,a);if(!u)return null;let h=[];return i&&h.push(i.startKey),h=h.concat(u),r&&h.push(r.startKey),h}markAllMeshesAsOccupiedVoxels(t){const e=new Set,n=new Map,i=t=>{if("Mesh"!==t.type)return;const r=this.sceneManager.getBoundingBox(t);if(!r)return;const s=this.gridSystem.getVoxelsInBoundingBox(r),o=new Set(s);for(const t of s)e.add(t);if(n.set(t.uuid,o),t.children)for(const e of t.children)i(e)};if(t.children)for(const e of t.children)i(e);return{occupied:e,occupiedByUUID:n}}processConnection(t,e,n){const i=this.sceneManager.findObjectByUUID(t.from),r=this.sceneManager.findObjectByUUID(t.to);if(!i||!r)return null;if("Mesh"!==i.type||"Mesh"!==r.type)return null;i.parent=this.sceneManager.findParentObject(i),r.parent=this.sceneManager.findParentObject(r);const s=this.sceneManager.getWorldPosition(i),o=this.sceneManager.getWorldPosition(r),a=this.connectorManager.createVirtualSegment(i,s),u=this.connectorManager.createVirtualSegment(r,o),h=new Set(e),c=Array.from(h).map(t=>this.gridSystem.voxelToVec3(t)),l=this.sceneManager.getBoundingBox(i),f=this.sceneManager.getBoundingBox(r);if(!l||!f)return null;if(!a){const t=this.gridSystem.getVoxelsInBoundingBox(l);for(const e of t)h.delete(e)}if(!u){const t=this.gridSystem.getVoxelsInBoundingBox(f);for(const e of t)h.delete(e)}if(a){const t=a.direction,e=this.gridSystem.worldToVoxelDistance(this.MIN_SEGMENT_LENGTH+2*this.gridSystem.safetyMargin);for(let n=0;n<=e;n++){const e=Math.round(s.x/this.gridSystem.gridSize+t.x*n),i=Math.round(s.y/this.gridSystem.gridSize+t.y*n),r=Math.round(s.z/this.gridSystem.gridSize+t.z*n);h.delete(`${e},${i},${r}`)}}if(u){const t=u.direction,e=this.gridSystem.worldToVoxelDistance(this.MIN_SEGMENT_LENGTH+2*this.gridSystem.safetyMargin);for(let n=0;n<=e;n++){const e=Math.round(o.x/this.gridSystem.gridSize+t.x*n),i=Math.round(o.y/this.gridSystem.gridSize+t.y*n),r=Math.round(o.z/this.gridSystem.gridSize+t.z*n);h.delete(`${e},${i},${r}`)}}this.connectorManager.processConnectors(this.sceneManager.getRoot(),h,i.uuid,r.uuid);const d=Array.from(h).map(t=>this.gridSystem.voxelToVec3(t)),w=this.gridSystem.voxelKey(s),v=this.gridSystem.voxelKey(o),p=this.findPathWithVirtualSegments(w,v,h,a,u),m=Array.from(h).map(t=>this.gridSystem.voxelToVec3(t));if(p){const i=p.map(t=>this.gridSystem.voxelToVec3(t)),r=new Set;for(const t of i){const n=this.gridSystem.voxelKey(t);e.add(n),r.add(n)}const s=`path_${t.from}_${t.to}`;return n.set(s,r),{from:t.from,to:t.to,path:i,occupied:m,debug:{initial:c,afterSegments:d},occupiedByUUID:n}}return{from:t.from,to:t.to,path:null,start:s,end:o,occupied:m,debug:{initial:c,afterSegments:d},occupiedByUUID:n}}findPaths(t){if(!this.sceneManager.getRoot())return[];const{occupied:e,occupiedByUUID:n}=this.markAllMeshesAsOccupiedVoxels(this.sceneManager.getRoot()),i=[];for(const r of t){const t=this.processConnection(r,e,n);t&&i.push(t)}return i}}class zt{constructor(){}distance(t,e){const n=e.x-t.x,i=e.y-t.y,r=e.z-t.z;return Math.sqrt(n*n+i*i+r*r)}findMST(t){const e=t.length,n=[],i=new Set;for(i.add(0);i.size<e;){let r=1/0,s=null;for(const n of i)for(let o=0;o<e;o++)if(!i.has(o)){const e=this.distance(t[n],t[o]);e<r&&(r=e,s=[n,o])}if(!s)break;n.push(s),i.add(s[1])}return n}findSteinerPoint(t){if(t.length<=2)return null;const e=this.findMST(t);if(0===e.length)return null;let n=null,i=1/0;if(e.forEach(([e,r])=>{const s=this.distance(t[e],t[r]);s<i&&(i=s,n=[t[e],t[r]])}),!n)return null;const r=new Ft(.5*(n[0].x+n[1].x),.5*(n[0].y+n[1].y),.5*(n[0].z+n[1].z)),s=t=>Math.round(2*t)/2;return r.x=s(r.x),r.y=s(r.y),r.z=s(r.z),r}}class Zt{constructor(t={}){this.config=t;const e=t.grid||{};this.gridSystem=new Xt(e.size??.5,e.safetyMargin??0),this.MIN_SEGMENT_LENGTH=e.minSegmentLength??.5,this.ASTAR_TIMEOUT=e.timeout??1e3,this.connectorManager=new Dt({grid:e},this.MIN_SEGMENT_LENGTH,null,this.gridSystem),this.pathManager=new Yt(null,this.gridSystem,this.connectorManager,this.MIN_SEGMENT_LENGTH,this.ASTAR_TIMEOUT),this.steinerTreeManager=new zt}findPaths(t,e){const n=new Gt(t);this.connectorManager.sceneManager=n,this.pathManager.sceneManager=n;const i=this.connectorManager.clusterConnections(e),r=i.filter(t=>t.objects.length>2);r.forEach((t,e)=>{const n=t.displacedPoints.map(t=>t.displacedPoint);t.mst=this.steinerTreeManager.findMST(n),t.steinerPoint=this.steinerTreeManager.findSteinerPoint(n)});let s=1;const o=new Map;r.forEach(t=>{if(t.steinerPoint){const e=s++;o.set(t.clusterId,e)}}),r.forEach(e=>{if(e.steinerPoint){const n={uuid:`GATEWAY-${o.get(e.clusterId)}`,type:"Mesh",userData:{worldBoundingBox:{min:[e.steinerPoint.x-.25,e.steinerPoint.y-.25,e.steinerPoint.z-.25],max:[e.steinerPoint.x+.25,e.steinerPoint.y+.25,e.steinerPoint.z+.25]}}};t.object.children.push(n)}});const a=[],u=new Set;e.filter(t=>{const e=i.find(e=>e.objects.includes(t.from)),n=i.find(e=>e.objects.includes(t.to));return!e||!n||e.objects.length<=2||n.objects.length<=2}).forEach(t=>{u.has(JSON.stringify(t))||(a.push(t),u.add(JSON.stringify(t)))});const h=[];e.forEach(t=>{const e=i.find(e=>e.objects.includes(t.from))?.clusterId,n=i.find(e=>e.objects.includes(t.to))?.clusterId;if(void 0!==e&&void 0!==n){const i=`GATEWAY-${o.get(e)}`,r=`GATEWAY-${o.get(n)}`;if(i&&r)if(e===n){const e={from:t.from,to:i},n={from:i,to:t.to};u.has(JSON.stringify(e))||(h.push(e),u.add(JSON.stringify(e))),u.has(JSON.stringify(n))||(h.push(n),u.add(JSON.stringify(n)))}else{const e={from:t.from,to:i},n={from:i,to:r},s={from:r,to:t.to};u.has(JSON.stringify(e))||(h.push(e),u.add(JSON.stringify(e))),u.has(JSON.stringify(n))||(h.push(n),u.add(JSON.stringify(n))),u.has(JSON.stringify(s))||(h.push(s),u.add(JSON.stringify(s)))}}}),h.sort((t,e)=>{const i=n.findObjectByUUID(t.from),r=n.findObjectByUUID(t.to),s=n.findObjectByUUID(e.from),o=n.findObjectByUUID(e.to);if(!(i&&r&&s&&o))return 0;return this.steinerTreeManager.distance(n.getWorldPosition(i),n.getWorldPosition(r))-this.steinerTreeManager.distance(n.getWorldPosition(s),n.getWorldPosition(o))}),a.push(...h);return{paths:this.pathManager.findPaths(a||[]),rewiredConnections:a,gateways:Array.from(o.entries()).map(([t,e])=>({clusterId:t,id:e,position:i.find(e=>e.clusterId===t)?.steinerPoint}))}}}var Kt=function(){return u(function t(e){o(this,t),this.component=e,this.pathfinder=null,this.crosscubeTextureSet=null,this.pathfinderVersionInfo=null},[{key:"getPathfinderVersionInfo",value:(a=s(w().m(function t(){var e;return w().w(function(t){for(;;)switch(t.n){case 0:if(!this.pathfinderVersionInfo){t.n=1;break}return t.a(2,this.pathfinderVersionInfo);case 1:return e={version:"1.0.15",detectionMethod:"hardcoded-fallback",timestamp:(new Date).toISOString()},this.pathfinderVersionInfo=e,t.a(2,e)}},t,this)})),function(){return a.apply(this,arguments)})},{key:"logPathfinderVersion",value:(r=s(w().m(function t(){var e,n,i,r=arguments;return w().w(function(t){for(;;)switch(t.n){case 0:return e=r.length>0&&void 0!==r[0]?r[0]:"Unknown Context",t.p=1,t.n=2,this.getPathfinderVersionInfo();case 2:n=t.v,_.info("[".concat(e,"] Pathfinder Module Information:"),{version:n.version,detectionMethod:n.detectionMethod,context:e,timestamp:n.timestamp,pathfinderInstance:!!this.pathfinder}),t.n=4;break;case 3:t.p=3,i=t.v,_.error("[".concat(e,"] Failed to get pathfinder version:"),i);case 4:return t.a(2)}},t,this,[[1,3]])})),function(){return r.apply(this,arguments)})},{key:"getPathColor",value:function(t){var e=["#468e49","#245e29","#2e80d2","#1d51a1"];return e[t%e.length]}},{key:"initializePathfinder",value:(i=s(w().m(function t(e,n){var i,r;return w().w(function(t){for(;;)switch(t.n){case 0:return i=this.component,this.crosscubeTextureSet=n,t.n=1,this.logPathfinderVersion("Scene Loading");case 1:this.pathfinder=new Zt(e),i.pathfinder=this.pathfinder,r=this.pathfinder.findPaths(),this.createPipePaths(r,n);case 2:return t.a(2)}},t,this)})),function(t,e){return i.apply(this,arguments)})},{key:"removeAllPaths",value:function(){var t=this.component,e=[];t.scene.traverse(function(t){t.name&&t.name.includes("Polyline")&&e.push(t)});for(var n=0,i=e;n<i.length;n++){var r=i[n];t.scene.remove(r),r.geometry&&r.geometry.dispose(),r.material&&(Array.isArray(r.material)?r.material.forEach(function(t){return t.dispose()}):r.material.dispose())}}},{key:"createPipeMaterial",value:function(t,e){if(t){var i=d(d({},t.config.materialProps),{},{color:this.getPathColor(e),map:t.textures.diffuse,normalMap:t.textures.normal,roughnessMap:t.textures.roughness,metalness:.2,roughness:.9,clearcoat:.2,clearcoatRoughness:.2,envMapIntensity:.6,reflectivity:.4});i.normalScale&&Array.isArray(i.normalScale)&&(i.normalScale=function(t,e,n){if(l())return Reflect.construct.apply(null,arguments);var i=[null];i.push.apply(i,e);var r=new(t.bind.apply(t,i));return n&&m(r,n.prototype),r}(n.Vector2,b(i.normalScale)));var r=new n.MeshPhysicalMaterial(i);return[r.map,r.normalMap,r.roughnessMap].filter(Boolean).forEach(function(e){e.wrapS=e.wrapT=n.RepeatWrapping,e.repeat.set(2*t.config.repeat.x,2*t.config.repeat.y)}),r}return new n.MeshPhysicalMaterial({color:this.getPathColor(e),metalness:.9,roughness:.7,clearcoat:.1,clearcoatRoughness:.3,envMapIntensity:1.5,reflectivity:.3})}},{key:"createPipePaths",value:function(t,e){var i=this,r=this.component;t.forEach(function(t,s){if(t.path){var o=new n.Object3D;o.name="Polyline ".concat(t.from,"-").concat(t.to);for(var a=i.createPipeMaterial(e,s),u=0;u<t.path.length-1;u++){var h=t.path[u],c=t.path[u+1],l=(new n.Vector3).subVectors(c,h),f=l.length(),d=new n.CylinderGeometry(.1,.1,f,8,1,!1),w=new n.Mesh(d,a);w.position.copy(h).add(c).multiplyScalar(.5);var v=new n.Quaternion,p=new n.Vector3(0,1,0);if(v.setFromUnitVectors(p,l.normalize()),w.quaternion.copy(v),w.castShadow=!0,w.receiveShadow=!0,o.add(w),u<t.path.length-2){var m=t.path[u+1],y=t.path[u+2],b=l.normalize(),g=(new n.Vector3).subVectors(y,m).normalize(),A=Math.acos(b.dot(g));if(Math.abs(A-Math.PI/2)<.1){var M=new n.SphereGeometry(.1,16,16),k=new n.Mesh(M,a);k.position.copy(c),k.castShadow=!0,k.receiveShadow=!0,o.add(k)}}}o.name="Polyline",r.scene.add(o)}})}},{key:"recomputeWorldBoundingBoxes",value:function(t){this.component.scene.traverse(function(e){if(e.isMesh){var i=null,r=function(t){var n,i=h(t);try{for(i.s();!(n=i.n()).done;){var s,o,a=n.value;if(a.uuid===e.uuid||a.uuid===(null===(s=e.userData)||void 0===s?void 0:s.originalUuid)||e.uuid===(null===(o=a.userData)||void 0===o?void 0:o.originalUuid))return a;if(e.name&&a.name){var u=Nt(e.name),c=Nt(a.name);if(u===c||u===a.uuid||c===e.uuid)return a}if(e.name&&a.name&&e.name===a.name)return a;if(a.children){var l=r(a.children);if(l)return l}}}catch(t){i.e(t)}finally{i.f()}return null};if(i=r(t.scene.object.children)){var s=(new n.Box3).setFromObject(e);i.userData||(i.userData={}),i.userData.worldBoundingBox={min:s.min.toArray(),max:s.max.toArray()}}}})}},{key:"updatePathfindingWithConnections",value:(e=s(w().m(function t(e){var n,i,r;return w().w(function(t){for(;;)switch(t.n){case 0:if((n=this.component).currentSceneData){t.n=1;break}return t.a(2,!1);case 1:return this.removeAllPaths(),(i=JSON.parse(JSON.stringify(n.currentSceneData))).connections=b(e),t.n=2,this.logPathfinderVersion("Connections Update");case 2:return this.pathfinder=new Zt(i),n.pathfinder=this.pathfinder,r=this.pathfinder.findPaths(),this.createPipePaths(r,this.crosscubeTextureSet),n.currentSceneData=i,t.a(2,!0)}},t,this)})),function(t){return e.apply(this,arguments)})},{key:"updatePathfindingAfterTransform",value:(t=s(w().m(function t(e){var n;return w().w(function(t){for(;;)switch(t.n){case 0:return this.removeAllPaths(),t.n=1,this.logPathfinderVersion("Transform Update");case 1:this.pathfinder=new Zt(e),this.component.pathfinder=this.pathfinder,n=this.pathfinder.findPaths(),this.createPipePaths(n,this.crosscubeTextureSet);case 2:return t.a(2)}},t,this)})),function(e){return t.apply(this,arguments)})},{key:"dispose",value:function(){this.removeAllPaths(),this.pathfinder=null,this.crosscubeTextureSet=null,this.pathfinderVersionInfo=null,k.info("PathfindingManager disposed")}}]);var t,e,i,r,a}(),Vt=Object.freeze({__proto__:null,PathfindingManager:Kt}),Wt=function(){return u(function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;o(this,t),this.renderer=e,this.stats={fps:{current:0,average:0,min:1/0,max:0,history:[]},frameTime:{current:0,average:0,min:1/0,max:0,history:[]},memory:{geometries:0,textures:0,programs:0,heapUsed:0,heapTotal:0},drawCalls:{current:0,average:0,triangles:0,points:0,lines:0},gpu:{memoryUsage:0,extensions:[]},scene:{objects:0,lights:0,meshes:0,materials:0,visible:0}},this.frameCount=0,this.historySize=120,this.isRunning=!1,this.lastUpdateTime=0,this.warningThresholds={fps:30,frameTime:16,drawCalls:1e3,triangles:1e6,geometries:1e3,textures:100},this.callbacks={update:[],warning:[]},this.T=this.T.bind(this)},[{key:"start",value:function(){this.isRunning||(this.isRunning=!0,this.lastUpdateTime=performance.now(),this._(),requestAnimationFrame(this.T),k.info("Performance monitoring started"))}},{key:"stop",value:function(){this.isRunning=!1,k.info("Performance monitoring stopped")}},{key:"reset",value:function(){this.stats.fps={current:0,average:0,min:1/0,max:0,history:[]},this.stats.frameTime={current:0,average:0,min:1/0,max:0,history:[]},this.frameCount=0,k.info("Performance statistics reset")}},{key:"_update",value:function(){if(this.isRunning){var t=performance.now(),e=t-this.lastUpdateTime;this.lastUpdateTime=t;var n=1e3/e;this.S("frameTime",e),this.S("fps",n),this.renderer&&this.O(),this.P(),this.frameCount++,this.R(),this.C("update",this.stats),requestAnimationFrame(this.T)}}},{key:"_updateStat",value:function(t,e){if(this.stats[t]){var n=this.stats[t];n.current=e,n.min=Math.min(n.min,e),n.max=Math.max(n.max,e),n.history.push(e),n.history.length>this.historySize&&n.history.shift(),n.average=n.history.reduce(function(t,e){return t+e},0)/n.history.length}}},{key:"_getWebGLInfo",value:function(){var t,e,n,i,r;if(this.renderer){var s=this.renderer.info;this.stats.drawCalls.current=(null===(t=s.render)||void 0===t?void 0:t.calls)||0,this.stats.drawCalls.triangles=(null===(e=s.render)||void 0===e?void 0:e.triangles)||0,this.stats.drawCalls.history||(this.stats.drawCalls.history=[]),this.stats.drawCalls.history.push(this.stats.drawCalls.current),this.stats.drawCalls.history.length>this.historySize&&this.stats.drawCalls.history.shift(),this.stats.drawCalls.average=this.stats.drawCalls.history.reduce(function(t,e){return t+e},0)/this.stats.drawCalls.history.length,this.stats.memory.geometries=(null===(n=s.memory)||void 0===n?void 0:n.geometries)||0,this.stats.memory.textures=(null===(i=s.memory)||void 0===i?void 0:i.textures)||0,this.stats.memory.programs=(null===(r=s.programs)||void 0===r?void 0:r.length)||0}}},{key:"_getMemoryInfo",value:function(){"undefined"!=typeof window&&window.performance&&window.performance.memory?(this.stats.memory.heapUsed=window.performance.memory.usedJSHeapSize,this.stats.memory.heapTotal=window.performance.memory.totalJSHeapSize):"undefined"!=typeof navigator&&navigator.deviceMemory&&(this.stats.memory.deviceMemory=navigator.deviceMemory)}},{key:"_getGPUInfo",value:function(){if(this.renderer){var t=this.renderer.getContext(),e=t.getExtension("WEBGL_debug_renderer_info");e?(this.stats.gpu.vendor=t.getParameter(e.UNMASKED_VENDOR_WEBGL),this.stats.gpu.renderer=t.getParameter(e.UNMASKED_RENDERER_WEBGL)):(this.stats.gpu.vendor=t.getParameter(t.VENDOR),this.stats.gpu.renderer=t.getParameter(t.RENDERER)),this.stats.gpu.extensions=t.getSupportedExtensions()}}},{key:"_checkWarnings",value:function(){var t=[];this.stats.fps.average<this.warningThresholds.fps&&t.push({type:"fps",message:"Low FPS: ".concat(this.stats.fps.average.toFixed(1)," (threshold: ").concat(this.warningThresholds.fps,")"),value:this.stats.fps.average,threshold:this.warningThresholds.fps}),this.stats.frameTime.average>this.warningThresholds.frameTime&&t.push({type:"frameTime",message:"High frame time: ".concat(this.stats.frameTime.average.toFixed(1),"ms (threshold: ").concat(this.warningThresholds.frameTime,"ms)"),value:this.stats.frameTime.average,threshold:this.warningThresholds.frameTime}),this.stats.drawCalls.average>this.warningThresholds.drawCalls&&t.push({type:"drawCalls",message:"High draw calls: ".concat(this.stats.drawCalls.average.toFixed(0)," (threshold: ").concat(this.warningThresholds.drawCalls,")"),value:this.stats.drawCalls.average,threshold:this.warningThresholds.drawCalls}),this.stats.drawCalls.triangles>this.warningThresholds.triangles&&t.push({type:"triangles",message:"High triangle count: ".concat(this.stats.drawCalls.triangles.toFixed(0)," (threshold: ").concat(this.warningThresholds.triangles,")"),value:this.stats.drawCalls.triangles,threshold:this.warningThresholds.triangles}),this.stats.memory.geometries>this.warningThresholds.geometries&&t.push({type:"geometries",message:"High geometry count: ".concat(this.stats.memory.geometries," (threshold: ").concat(this.warningThresholds.geometries,")"),value:this.stats.memory.geometries,threshold:this.warningThresholds.geometries}),this.stats.memory.textures>this.warningThresholds.textures&&t.push({type:"textures",message:"High texture count: ".concat(this.stats.memory.textures," (threshold: ").concat(this.warningThresholds.textures,")"),value:this.stats.memory.textures,threshold:this.warningThresholds.textures}),t.length>0&&this.C("warning",t)}},{key:"on",value:function(t,e){this.callbacks[t]&&this.callbacks[t].push(e)}},{key:"off",value:function(t,e){if(this.callbacks[t]){var n=this.callbacks[t].indexOf(e);-1!==n&&this.callbacks[t].splice(n,1)}}},{key:"_triggerCallbacks",value:function(t,e){this.callbacks[t]&&this.callbacks[t].forEach(function(t){try{t(e)}catch(t){}})}},{key:"logSummary",value:function(){return this.stats.gpu.renderer,this.stats}},{key:"exportData",value:function(){return{timestamp:(new Date).toISOString(),frameCount:this.frameCount,stats:JSON.parse(JSON.stringify(this.stats)),gpu:this.stats.gpu,warnings:this.L()}}},{key:"_getActiveWarnings",value:function(){var t=[];return this.stats.fps.average<this.warningThresholds.fps&&t.push({type:"fps",value:this.stats.fps.average}),this.stats.frameTime.average>this.warningThresholds.frameTime&&t.push({type:"frameTime",value:this.stats.frameTime.average}),this.stats.drawCalls.average>this.warningThresholds.drawCalls&&t.push({type:"drawCalls",value:this.stats.drawCalls.average}),this.stats.drawCalls.triangles>this.warningThresholds.triangles&&t.push({type:"triangles",value:this.stats.drawCalls.triangles}),this.stats.memory.geometries>this.warningThresholds.geometries&&t.push({type:"geometries",value:this.stats.memory.geometries}),this.stats.memory.textures>this.warningThresholds.textures&&t.push({type:"textures",value:this.stats.memory.textures}),t}},{key:"setWarningThresholds",value:function(t){Object.assign(this.warningThresholds,t)}}])}(),$t=function(){return u(function t(e,n){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"dark";o(this,t),this.monitor=e,this.container=n,this.theme=i,this.isVisible=!1,this.element=null,this.graphs={},this.I(),this.j()},[{key:"_createUI",value:function(){var t=this;this.element=document.createElement("div"),this.element.className="performance-monitor",this.element.style.position="absolute",this.element.style.top="10px",this.element.style.right="10px",this.element.style.zIndex="1000",this.element.style.padding="10px",this.element.style.borderRadius="5px",this.element.style.fontFamily="monospace",this.element.style.fontSize="12px",this.element.style.lineHeight="1.2",this.element.style.transition="opacity 0.3s ease",this.element.style.userSelect="none",this.setTheme(this.theme);var e=document.createElement("div");e.style.display="flex",e.style.justifyContent="space-between",e.style.marginBottom="5px";var n=document.createElement("div");n.textContent="Performance Monitor",n.style.fontWeight="bold";var i=document.createElement("div");i.textContent="ร—",i.style.cursor="pointer",i.style.paddingLeft="10px",i.onclick=function(){return t.hide()},e.appendChild(n),e.appendChild(i),this.element.appendChild(e);var r=document.createElement("div");this.statsElement=r,this.element.appendChild(r),this.element.style.opacity="0",this.element.style.pointerEvents="none"}},{key:"setTheme",value:function(t){this.theme=t,"dark"===t?(this.element.style.backgroundColor="rgba(0, 0, 0, 0.7)",this.element.style.color="white",this.element.style.boxShadow="0 0 10px rgba(0, 0, 0, 0.5)"):(this.element.style.backgroundColor="rgba(255, 255, 255, 0.85)",this.element.style.color="black",this.element.style.boxShadow="0 0 10px rgba(0, 0, 0, 0.1)")}},{key:"_setupUpdateLoop",value:function(){var t=this;setInterval(function(){if(t.isVisible&&t.monitor){var e="",n=t.N(t.monitor.stats.fps.current,60,30);e+='<div>FPS: <span style="color: '.concat(n,'">').concat(t.monitor.stats.fps.current.toFixed(1),"</span> "),e+="(avg: ".concat(t.monitor.stats.fps.average.toFixed(1),")</div>");var i=t.N(16-t.monitor.stats.frameTime.current,0,16,!0);e+='<div>Frame: <span style="color: '.concat(i,'">').concat(t.monitor.stats.frameTime.current.toFixed(1),"ms</span></div>");var r=t.N(1e3-t.monitor.stats.drawCalls.current,0,1e3,!0);e+='<div>Calls: <span style="color: '.concat(r,'">').concat(t.monitor.stats.drawCalls.current,"</span> "),e+="Tris: ".concat(t.U(t.monitor.stats.drawCalls.triangles),"</div>"),e+="<div>Geo: ".concat(t.monitor.stats.memory.geometries," "),e+="Tex: ".concat(t.monitor.stats.memory.textures,"</div>"),t.statsElement.innerHTML=e}},500)}},{key:"_getMetricColor",value:function(t,e,n){var i=arguments.length>3&&void 0!==arguments[3]&&arguments[3],r=(t-n)/(e-n);r=Math.max(0,Math.min(1,r)),i&&(r=1-r);var s=r<.5?255:Math.floor(255*(1-r)*2),o=r>.5?255:Math.floor(255*r*2);return"rgb(".concat(s,", ").concat(o,", ").concat(0,")")}},{key:"_formatNumber",value:function(t){return t>=1e6?(t/1e6).toFixed(1)+"M":t>=1e3?(t/1e3).toFixed(1)+"K":t.toString()}},{key:"show",value:function(){this.isVisible||(this.isVisible=!0,this.element.style.opacity="1",this.element.style.pointerEvents="auto",this.element.parentElement||this.container.appendChild(this.element))}},{key:"hide",value:function(){this.isVisible&&(this.isVisible=!1,this.element.style.opacity="0",this.element.style.pointerEvents="none")}},{key:"toggle",value:function(){this.isVisible?this.hide():this.show()}},{key:"dispose",value:function(){this.element.parentElement&&this.element.parentElement.removeChild(this.element)}}])}(),Jt={PerformanceMonitor:Wt,PerformanceUI:$t},qt=Object.freeze({__proto__:null,PerformanceMonitor:Wt,PerformanceUI:$t,default:Jt}),Qt=function(){return u(function t(e){o(this,t),this.component=e},[{key:"exportSceneData",value:function(){var t=this;if(!this.component.scene)return null;var e=function(t){var n,i,r,s,o,a,u,h,c=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!t||null!==(n=t.name)&&void 0!==n&&n.includes("Polyline")||null!==(i=t.userData)&&void 0!==i&&i.isBrickWall||null!==(r=t.userData)&&void 0!==r&&r.isBaseGround||null!==(s=t.userData)&&void 0!==s&&s.isBaseGrid||t.isLight||null!==(o=t.userData)&&void 0!==o&&o.isTransformControls||t.isTransformControls||t.type&&t.type.includes("TransformControls"))return null;if(!(c||null!==(a=t.userData)&&void 0!==a&&a.componentType))return null;if(c&&(null===(u=t.userData)||void 0===u||!u.forExport))return null;if(c&&null!==(h=t.userData)&&void 0!==h&&h.forExport);var l,f,d,w={uuid:Ht(t),name:t.name||"Unnamed Object",type:t.type||"Object3D"};(t.userData&&Object.keys(t.userData).length>0&&(w.userData={},Object.keys(t.userData).forEach(function(e){"worldBoundingBox"!==e&&"isBaseGround"!==e&&"isBrickWall"!==e&&"isBaseGrid"!==e&&"isTransformControls"!==e&&(w.userData[e]=t.userData[e])}),0===Object.keys(w.userData).length&&delete w.userData),w.position={x:parseFloat(t.position.x.toFixed(6)),y:parseFloat(t.position.y.toFixed(6)),z:parseFloat(t.position.z.toFixed(6))},w.rotation={x:parseFloat((t.rotation.x*(180/Math.PI)).toFixed(6)),y:parseFloat((t.rotation.y*(180/Math.PI)).toFixed(6)),z:parseFloat((t.rotation.z*(180/Math.PI)).toFixed(6))},w.scale={x:parseFloat(t.scale.x.toFixed(6)),y:parseFloat(t.scale.y.toFixed(6)),z:parseFloat(t.scale.z.toFixed(6))},t.geometry)&&(null!==(l=t.name)&&void 0!==l&&l.toLowerCase().includes("connector")?w.geometry="CONNECTOR-GEO":null!==(f=t.name)&&void 0!==f&&f.toLowerCase().includes("gateway")?w.geometry="GATEWAY-GEO":null!==(d=t.userData)&&void 0!==d&&d.libraryId&&(w.geometry="".concat(t.userData.libraryId,"-GEO")));if(t.children&&t.children.length>0){var v=[];t.children.forEach(function(t){var n=e(t,!0);n&&v.push(n)}),v.length>0&&(w.children=v)}return w},n=[];this.component.scene.children.forEach(function(t){var i=e(t);i&&n.push(i)});var i,r,s={connections:(r=[],null!==(i=t.component.currentSceneData)&&void 0!==i&&i.connections&&r.push.apply(r,b(t.component.currentSceneData.connections)),r),scene:{object:{uuid:"PLANT-SCENE",name:"Scene",type:"Scene",children:n}}};return s.H={exportedAt:(new Date).toISOString(),exportedFrom:"SceneViewerEnhanced",version:"1.0.0",objectCount:n.length},s}},{key:"downloadSceneExport",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e=this.exportSceneData();if(!e)return!1;t||(t="cp-export.json");try{var n=JSON.stringify(e,null,2);if("undefined"!=typeof window&&"undefined"!=typeof document){var i=new Blob([n],{type:"application/json"}),r=URL.createObjectURL(i),s=document.createElement("a");return s.href=r,s.download=t,document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(r),!0}return!1}catch(t){return!1}}},{key:"exportSceneDataAsString",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=this.exportSceneData();return e?t?JSON.stringify(e,null,2):JSON.stringify(e):null}},{key:"getExportMetadata",value:function(){var t;if(!this.component.scene)return null;var e=0;return this.component.scene.traverse(function(){return e++}),{totalObjects:e,hasCurrentSceneData:!!this.component.currentSceneData,connectionsCount:(null===(t=this.component.currentSceneData)||void 0===t||null===(t=t.connections)||void 0===t?void 0:t.length)||0,exportTimestamp:(new Date).toISOString()}}}])}();function te(t){return new Qt(t)}var ee,ne,ie,re,se=Object.freeze({__proto__:null,SceneExportManager:Qt,getSceneExportManager:te,default:Qt});function oe(){return ae.apply(this,arguments)}function ae(){return(ae=s(w().m(function t(){var n,i,r,s;return w().w(function(t){for(;;)switch(t.n){case 0:if("undefined"==typeof window){t.n=15;break}return t.p=1,t.p=2,t.n=3,Promise.resolve().then(function(){return Fe});case 3:n=t.v,ee=n.OrbitControls,t.n=9;break;case 4:if(t.p=4,t.v,t.p=5,"string"!=typeof window.__orbitControlsCustomPath){t.n=7;break}return t.n=6,function(t){return Promise.resolve().then(function(){return e(require(t))})}(window.__orbitControlsCustomPath);case 6:i=t.v,ee=i.OrbitControls;case 7:t.n=9;break;case 8:t.p=8,t.v;case 9:return t.p=9,t.n=10,Promise.resolve().then(function(){return Hn});case 10:r=t.v,ne=r.GLTFLoader,t.n=12;break;case 11:t.p=11,t.v;case 12:return t.n=13,Promise.resolve().then(function(){return qt});case 13:s=t.v,ie=s.PerformanceMonitor,re=s.PerformanceUI,t.n=15;break;case 14:t.p=14,t.v;case 15:return t.a(2)}},t,null,[[9,11],[5,8],[2,4],[1,14]])}))).apply(this,arguments)}var ue=function(){return u(function t(e){o(this,t),this.component=e,this.textureLoader=null,this.gltfLoader=null,oe()},[{key:"initializeScene",value:(i=s(w().m(function t(){var e,i,r,s,o,a;return w().w(function(t){for(;;)switch(t.n){case 0:if(r=this.component){t.n=1;break}return k.error("Cannot initialize scene: component not available"),t.a(2);case 1:if(r.scene=new n.Scene,s=(null===(e=r.$refs)||void 0===e||null===(e=e.container)||void 0===e?void 0:e.getBoundingClientRect())||{width:800,height:600},o=s.width,a=s.height,r.camera=new n.PerspectiveCamera(50,o/a,.01,1e3),r.camera.position.set(-8,4,9),null===(i=r.$refs)||void 0===i||!i.container){t.n=2;break}return t.n=2,this.setupRenderer(r.$refs.container,o,a);case 2:return k.info("Scene and camera initialized"),t.a(2,{scene:r.scene,camera:r.camera})}},t,this)})),function(){return i.apply(this,arguments)})},{key:"setupRenderer",value:(e=s(w().m(function t(e,i,r){var s,o;return w().w(function(t){for(;;)switch(t.n){case 0:if(s=this.component){t.n=1;break}return k.error("Cannot setup renderer: component not available"),t.a(2,null);case 1:if(i&&r||(o=e.getBoundingClientRect(),i=o.width,r=o.height),s.renderer=new n.WebGLRenderer({antialias:!0}),s.renderer.setSize(i,r),s.renderer.setPixelRatio(Math.min(window.devicePixelRatio,2)),s.renderer.shadowMap.enabled=!0,s.renderer.shadowMap.type=n.PCFSoftShadowMap,s.renderer.physicallyCorrectLights=!0,s.renderer.outputColorSpace=n.SRGBColorSpace,s.renderer.toneMapping=n.LinearToneMapping,s.renderer.toneMappingExposure=1.5,e.appendChild(s.renderer.domElement),this.setupResizeHandler(),s.textureLoader=new n.TextureLoader,this.textureLoader=s.textureLoader,!ne){t.n=2;break}s.gltfLoader=new ne,this.gltfLoader=s.gltfLoader,t.n=4;break;case 2:return t.n=3,oe();case 3:ne&&(s.gltfLoader=new ne,this.gltfLoader=s.gltfLoader);case 4:return k.info("Renderer initialized"),t.a(2,s.renderer)}},t,this)})),function(t,n,i){return e.apply(this,arguments)})},{key:"setupControls",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=this.component;return i&&i.camera&&i.renderer?ee?this.setupControlsInternal(t,n):(k.info("OrbitControls not available, will try to import"),oe().then(function(){ee&&e.setupControlsInternal(t,n)}),null):(k.error("Cannot setup controls: camera or renderer not available"),null)}},{key:"setupControlsInternal",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=this.component,i=t||n.renderer.domElement;return n.controls=new ee(n.camera,i),n.controls.enableDamping=!1!==e.enableDamping,n.controls.dampingFactor=e.dampingFactor||.05,n.controls.screenSpacePanning=!1!==e.screenSpacePanning,n.controls.maxPolarAngle=e.maxPolarAngle||Math.PI/1.5,n.controls.minDistance=e.minDistance||2,n.controls.maxDistance=e.maxDistance||50,e.target&&n.controls.target.copy(e.target),e.autoRotate&&(n.controls.autoRotate=!0,n.controls.autoRotateSpeed=e.autoRotateSpeed||1),k.info("Orbit controls initialized"),n.controls}},{key:"initializePerformanceMonitoring",value:(t=s(w().m(function t(){var e,n;return w().w(function(t){for(;;)switch(t.n){case 0:if((n=this.component)&&n.renderer){t.n=1;break}return k.error("Cannot initialize performance monitoring: renderer not available"),t.a(2);case 1:if(ie){t.n=3;break}return t.n=2,oe();case 2:if(ie){t.n=3;break}return k.error("Performance monitoring not available"),t.a(2);case 3:return n.performanceMonitor=new ie(n.renderer),null!==(e=n.$refs)&&void 0!==e&&e.container&&(n.performanceUI=new re(n.performanceMonitor,n.$refs.container,"light")),n.performanceMonitor.on("warning",function(t){}),n.performanceMonitor.start(),n.performanceUI&&n.performanceUI.show(),this.exposePerformanceMonitoringGlobally(),k.info("Performance monitoring initialized"),t.a(2,{monitor:n.performanceMonitor,ui:n.performanceUI})}},t,this)})),function(){return t.apply(this,arguments)})},{key:"exposePerformanceMonitoringGlobally",value:function(){var t=this.component;t&&t.performanceMonitor&&"undefined"!=typeof window&&(window._performanceMonitor=t.performanceMonitor,window._performanceUI=t.performanceUI,window.performance3D={show:function(){var e;return null===(e=t.performanceUI)||void 0===e?void 0:e.show()},hide:function(){var e;return null===(e=t.performanceUI)||void 0===e?void 0:e.hide()},toggle:function(){var e,n,i;return null!==(e=t.performanceUI)&&void 0!==e&&e.isVisible?null===(n=t.performanceUI)||void 0===n?void 0:n.hide():null===(i=t.performanceUI)||void 0===i?void 0:i.show()},setTheme:function(e){var n;return null===(n=t.performanceUI)||void 0===n?void 0:n.setTheme(e)},log:function(){var e;return null===(e=t.performanceMonitor)||void 0===e?void 0:e.logSummary()},reset:function(){var e;return null===(e=t.performanceMonitor)||void 0===e?void 0:e.reset()},export:function(){var e;return null===(e=t.performanceMonitor)||void 0===e?void 0:e.exportData()},help:function(){}},k.info("Performance monitoring exposed to global scope"))}},{key:"setupResizeHandler",value:function(){var t,e=this.component;if(e&&null!==(t=e.$refs)&&void 0!==t&&t.container){var n=function(){if(e.renderer&&e.camera){var t=e.$refs.container,n=t.clientWidth,i=t.clientHeight;e.camera.aspect=n/i,e.camera.updateProjectionMatrix(),e.renderer.setSize(n,i),e.renderer.setPixelRatio(Math.min(window.devicePixelRatio,2))}};n(),window.addEventListener("resize",n),this.B=n,k.info("Resize handler initialized")}}},{key:"cleanupResizeHandler",value:function(){this.B&&(window.removeEventListener("resize",this.B),this.B=null)}}]);var t,e,i}(),he=null;function ce(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return(!he||t&&he.component!==t)&&(he=new ue(t)),he}function le(t,e){return fe.apply(this,arguments)}function fe(){return(fe=s(w().m(function t(e,n){var i;return w().w(function(t){for(;;)switch(t.n){case 0:return i=ce(e),t.n=1,i.initializeScene();case 1:if(!n){t.n=3;break}return t.n=2,i.setupRenderer(n);case 2:i.setupControls(n);case 3:return t.a(2,i)}},t)}))).apply(this,arguments)}var de={SceneInitializationManager:ue,getSceneInitializationManager:ce,setupScene:le},we=Object.freeze({__proto__:null,SceneInitializationManager:ue,getSceneInitializationManager:ce,setupScene:le,default:de});function ve(t){if(t.startsWith("/")&&(t=t.substring(1)),"undefined"!=typeof window){var e="undefined"!=typeof CentralPlantUtils;if("localhost"===window.location.hostname&&("3000"===window.location.port||"3001"===window.location.port))return"/".concat(t);if(e){var n="undefined"==typeof document?new(require("url").URL)("file:"+__filename).href:document.currentScript&&"SCRIPT"===document.currentScript.tagName.toUpperCase()&&document.currentScript.src||new URL("index.js",document.baseURI).href;return new URL("./assets/".concat(t),n).href}var i="undefined"==typeof document?new(require("url").URL)("file:"+__filename).href:document.currentScript&&"SCRIPT"===document.currentScript.tagName.toUpperCase()&&document.currentScript.src||new URL("index.js",document.baseURI).href;return new URL("../assets/".concat(t),i).href}return"assets/".concat(t)}var pe={light_metal:{localPath:"textures/gravel_embedded_concrete_1k",path:"https://central-plant-assets.s3.us-east-1.amazonaws.com/textures/gravel_embedded_concrete_1k",files:{diffuse:"diffuse.jpg",normal:"normal.jpg",roughness:"rough.jpg"},repeat:{x:2,y:2},materialProps:{color:12105912,metalness:.3,roughness:.3,normalScale:[.4,.4],clearcoat:.3,clearcoatRoughness:.2,envMapIntensity:1.6,reflectivity:.5}},brick:{localPath:"textures/pavement_03_1k",path:"https://central-plant-assets.s3.us-east-1.amazonaws.com/textures/pavement_03_1k",files:{diffuse:"diffuse.jpg",normal:"normal.jpg",roughness:"rough.jpg"},repeat:{x:7.5,y:.75},materialProps:{color:10061960,roughness:.9,metalness:.1,normalScale:[1.5,1.5],bumpScale:.05,clearcoat:.05,clearcoatRoughness:.4}},gravel_embedded_concrete:{localPath:"textures/gravel_embedded_concrete_1k",path:"https://central-plant-assets.s3.us-east-1.amazonaws.com/textures/gravel_embedded_concrete_1k",files:{diffuse:"diffuse.jpg",normal:"normal.jpg",roughness:"rough.jpg"},repeat:{x:3,y:3},materialProps:{color:16777215,roughness:.9,metalness:.1,normalScale:[1,1],bumpScale:.1}}};function me(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{x:1,y:1};t||(t=new n.TextureLoader);try{var r=Ae(13421772),s=new Promise(function(r,s){t.load(e,function(t){!t.image||!(t.image instanceof HTMLImageElement&&t.image.complete)&&t.image instanceof HTMLImageElement?s(new Error("Texture loaded but image data not ready")):(void 0!==t.colorSpace?t.colorSpace=n.SRGBColorSpace:void 0!==t.encoding&&(t.encoding=n.sRGBEncoding),t.wrapS=n.RepeatWrapping,t.wrapT=n.RepeatWrapping,t.repeat.set(i.x,i.y),t.needsUpdate=!0,r(t))},function(t){if(t.lengthComputable)t.loaded,t.total},function(t){s(t)})});return r.wrapS=n.RepeatWrapping,r.wrapT=n.RepeatWrapping,r.repeat.set(i.x,i.y),r.loadPromise=s,r.url=e,s.then(function(t){Object.keys(t).forEach(function(e){["uuid","id","version","isTexture"].includes(e)||(r[e]=t[e])}),r.image=t.image,r.source=t.source,r.needsUpdate=!0}).catch(function(){}),r}catch(t){return Ae(14496563)}}function ye(t,e){return be.apply(this,arguments)}function be(){return be=s(w().m(function t(e,i){var r,o,a,u,h,c,l,f,v,p,m,b,g,A,M,k,T,_;return w().w(function(t){for(;;)switch(t.n){case 0:if(e){t.n=1;break}return t.a(2,new n.MeshStandardMaterial({color:11184810}));case 1:if(o=pe[i]){t.n=2;break}return t.a(2,new n.MeshStandardMaterial({color:11184810}));case 2:return"function"==typeof(a=e.textureLoader||new n.TextureLoader).setCrossOrigin&&a.setCrossOrigin("anonymous"),u=o.repeat||{x:1,y:1},h={},c=function(){var t=s(w().m(function t(e){return w().w(function(t){for(;;)switch(t.n){case 0:if("undefined"==typeof window){t.n=1;break}return t.a(2,new Promise(function(t){var n=new Image;n.onload=function(){return t(!0)},n.onerror=function(){return t(!1)},n.src=e,setTimeout(function(){return t(!1)},2e3)}));case 1:return t.a(2,!1)}},t)}));return function(e){return t.apply(this,arguments)}}(),l=function(){var t=s(w().m(function t(e){var n,r,s,h;return w().w(function(t){for(;;)switch(t.n){case 0:if(o.files[e]){t.n=1;break}return t.a(2,null);case 1:n=[],o.localPath&&n.push(ve("".concat(o.localPath,"/").concat(o.files[e]))),n.push("/textures/".concat(i,"_1k/").concat(o.files[e])),o.path&&n.push("".concat(o.path,"/").concat(o.files[e])),r=0,s=n;case 2:if(!(r<s.length)){t.n=6;break}return h=s[r],t.n=3,c(h);case 3:if(!t.v){t.n=4;break}return t.a(2,me(a,h,u));case 4:case 5:r++,t.n=2;break;case 6:return t.a(2,null)}},t)}));return function(e){return t.apply(this,arguments)}}(),f=Object.keys(o.files).map(function(){var t=s(w().m(function t(e){return w().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,l(e);case 1:return h[e]=t.v,t.a(2,{type:e,texture:h[e]})}},t)}));return function(e){return t.apply(this,arguments)}}()),t.n=3,Promise.all(f);case 3:if(Object.entries(h).forEach(function(t){var e=y(t,2);e[0],e[1]}),v=Object.values(h).some(function(t){return null!==t}),v){t.n=4;break}return m=(null===(p=o.materialProps)||void 0===p?void 0:p.color)||11184810,t.a(2,new n.MeshStandardMaterial({color:m,roughness:.8,metalness:.2,side:n.DoubleSide}));case 4:for(b={},g=0,A=Object.entries(h);g<A.length;g++)M=y(A[g],2),k=M[0],((T=M[1])&&ge(T)||T)&&(b[k]=T);return(_=new n.MeshStandardMaterial(d(d({map:b.diffuse,normalMap:b.normal,roughnessMap:b.roughness,metalnessMap:b.metalness,aoMap:b.ao,displacementMap:b.displacement},o.materialProps),{},{side:n.DoubleSide}))).map&&ge(_.map)||null===(r=o.materialProps)||void 0===r||!r.color||(_.color=new n.Color(o.materialProps.color)),_.needsUpdate=!0,e.scene&&e.scene.environment&&(_.envMap=e.scene.environment),Object.entries(b).forEach(function(t){var e=y(t,2),n=(e[0],e[1]);n&&n.loadPromise&&n.loadPromise.then(function(){_.needsUpdate=!0}).catch(function(t){})}),t.a(2,_)}},t)})),be.apply(this,arguments)}function ge(t){return!!t&&(!!t.image&&(t.image instanceof HTMLImageElement||t.image instanceof HTMLCanvasElement?t.image.width>0&&t.image.height>0:!(!t.image.data||!Array.isArray(t.image.data))&&t.image.data.length>0))}function Ae(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:13421772,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:64,i=document.createElement("canvas");i.width=e,i.height=e;var r=i.getContext("2d");if(r){var s="#"+t.toString(16).padStart(6,"0");r.fillStyle=s,r.fillRect(0,0,e,e),r.fillStyle="#"+(t+2236962&16777215).toString(16),r.fillRect(0,0,e/2,e/2),r.fillRect(e/2,e/2,e/2,e/2)}var o=new n.CanvasTexture(i);return o.needsUpdate=!0,void 0!==o.colorSpace?o.colorSpace=n.SRGBColorSpace:void 0!==o.encoding&&(o.encoding=n.sRGBEncoding),o}function Me(){return{version:n.REVISION,hasNewColorSpace:void 0!==n.SRGBColorSpace,hasOldEncoding:void 0!==n.sRGBEncoding,hasTextureLoader:"function"==typeof n.TextureLoader}}function ke(t){if(t){t.traverse(function(t){t.isMesh&&t.material&&(Array.isArray(t.material)?t.material:[t.material]).forEach(function(t){t&&(t.needsUpdate=!0,t.map&&(t.map.needsUpdate=!0),t.normalMap&&(t.normalMap.needsUpdate=!0),t.roughnessMap&&(t.roughnessMap.needsUpdate=!0))})})}}var Te,_e,Ee={TEXTURE_SETS:pe,createTexture:me,loadTextureSetAndCreateMaterial:ye,checkThreeJSCompatibility:Me,forceUpdateMaterials:ke,hasValidImageData:ge,createPlaceholderTexture:Ae},xe=Object.freeze({__proto__:null,TEXTURE_SETS:pe,createTexture:me,loadTextureSetAndCreateMaterial:ye,checkThreeJSCompatibility:Me,forceUpdateMaterials:ke,default:Ee});function Se(){return Oe.apply(this,arguments)}function Oe(){return(Oe=s(w().m(function t(){var n,i;return w().w(function(t){for(;;)switch(t.n){case 0:if("undefined"==typeof window){t.n=9;break}return t.p=1,t.n=2,Promise.resolve().then(function(){return e(require("three"))});case 2:return Te=t.v,t.p=3,t.n=4,Promise.resolve().then(function(){return mi});case 4:n=t.v,_e=n.TransformControls,t.n=7;break;case 5:if(t.p=5,t.v,"string"!=typeof window.__transformControlsCustomPath){t.n=7;break}return t.n=6,function(t){return Promise.resolve().then(function(){return e(require(t))})}(window.__transformControlsCustomPath);case 6:i=t.v,_e=i.TransformControls;case 7:t.n=9;break;case 8:throw t.p=8,t.v,new Error("TransformControlsManager: Required dependencies could not be loaded");case 9:return t.a(2)}},t,null,[[3,5],[1,8]])}))).apply(this,arguments)}var Pe=function(){return u(function t(e,n,i){var r=this,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;o(this,t),this.scene=e,this.camera=n,this.renderer=i,this.orbitControls=s,this.transformControls=null,this.boundingBoxHelper=null,this.boundingBoxCache=new WeakMap,this.selectedObject=null,this.currentMode="translate",this.currentSpace="world",this.forceInvisible=!1,this.eventHandlers={keydown:null,pointerdown:null,pointerup:null,transformStart:null,transformEnd:null,transforming:null},this.transformState={isTransforming:!1,initialTransform:null,currentTransform:null},this.config={size:1,enabled:!0,showX:!0,showY:!0,showZ:!0,snap:null,translationSnap:null,rotationSnap:null,scaleSnap:null,showBoundingBox:!0,boundingBoxColor:65280,useBoundingBoxSelection:!0},this.callbacks={onObjectSelect:null,onTransformStart:null,onTransform:null,onTransformEnd:null,onModeChange:null},"undefined"!=typeof window&&Se().then(function(){return r.init()})},[{key:"init",value:(t=s(w().m(function t(){return w().w(function(t){for(;;)switch(t.n){case 0:if("undefined"==typeof window||Te){t.n=1;break}return t.n=1,Se();case 1:this.createTransformControls(),this.setupEventListeners(),this.setupKeyboardControls();case 2:return t.a(2)}},t,this)})),function(){return t.apply(this,arguments)})},{key:"on",value:function(t){t.onObjectSelect&&(this.callbacks.onObjectSelect=t.onObjectSelect),t.onTransformStart&&(this.callbacks.onTransformStart=t.onTransformStart),t.onTransform&&(this.callbacks.onTransform=t.onTransform),t.onTransformEnd&&(this.callbacks.onTransformEnd=t.onTransformEnd),t.onModeChange&&(this.callbacks.onModeChange=t.onModeChange)}},{key:"createTransformControls",value:function(){Te&&_e&&(this.transformControls||(this.transformControls=new _e(this.camera,this.renderer.domElement),this.transformControls.size=this.config.size,this.transformControls.enabled=this.config.enabled,this.transformControls.visible=this.config.enabled&&!this.forceInvisible,this.transformControls.setMode(this.currentMode),this.transformControls.setSpace(this.currentSpace),this.transformControls.userData={isTransformControls:!0},this.scene.add(this.transformControls)))}},{key:"setupEventListeners",value:function(){var t=this;this.transformControls&&(this.removeEventListeners(),this.eventHandlers.transformStart=function(e){t.transformState.isTransforming=!0,t.selectedObject&&(t.transformState.initialTransform=t.captureObjectTransform(t.selectedObject),t.callbacks.onTransformStart&&t.callbacks.onTransformStart(t.selectedObject,t.transformState.initialTransform))},this.eventHandlers.transforming=function(e){t.selectedObject&&t.transformState.isTransforming&&(t.transformState.currentTransform=t.captureObjectTransform(t.selectedObject),t.callbacks.onTransform&&t.callbacks.onTransform(t.selectedObject,t.transformState.currentTransform,t.transformState.initialTransform),t.updateBoundingBox())},this.eventHandlers.transformEnd=function(e){if(t.selectedObject){var n=t.captureObjectTransform(t.selectedObject);t.callbacks.onTransformEnd&&t.callbacks.onTransformEnd(t.selectedObject,n,t.transformState.initialTransform)}t.transformState.isTransforming=!1},this.transformControls.addEventListener("mouseDown",this.eventHandlers.transformStart),this.transformControls.addEventListener("objectChange",this.eventHandlers.transforming),this.transformControls.addEventListener("mouseUp",this.eventHandlers.transformEnd),this.orbitControls&&this.transformControls.addEventListener("dragging-changed",function(e){t.orbitControls.enabled=!e.value}))}},{key:"setupKeyboardControls",value:function(){var t=this;"undefined"!=typeof window&&"undefined"!=typeof document&&(this.eventHandlers.keydown&&document.removeEventListener("keydown",this.eventHandlers.keydown),this.eventHandlers.keydown=function(e){if(t.config.enabled&&t.selectedObject)switch(e.key.toLowerCase()){case"g":t.setMode("translate");break;case"r":t.setMode("rotate");break;case"s":t.setMode("scale");break;case" ":t.toggleVisibility();break;case"escape":t.deselectObject();break;case"x":e.shiftKey?(t.config.showX=!t.config.showX,t.updateAxisVisibility()):(t.transformControls.showX=!0,t.transformControls.showY=!1,t.transformControls.showZ=!1);break;case"y":e.shiftKey?(t.config.showY=!t.config.showY,t.updateAxisVisibility()):(t.transformControls.showX=!1,t.transformControls.showY=!0,t.transformControls.showZ=!1);break;case"z":e.shiftKey?(t.config.showZ=!t.config.showZ,t.updateAxisVisibility()):(t.transformControls.showX=!1,t.transformControls.showY=!1,t.transformControls.showZ=!0);break;case"q":t.toggleSpace()}},document.addEventListener("keydown",this.eventHandlers.keydown))}},{key:"removeEventListeners",value:function(){this.transformControls&&(this.transformControls.removeEventListener("mouseDown",this.eventHandlers.transformStart),this.transformControls.removeEventListener("objectChange",this.eventHandlers.transforming),this.transformControls.removeEventListener("mouseUp",this.eventHandlers.transformEnd)),"undefined"!=typeof document&&this.eventHandlers.keydown&&document.removeEventListener("keydown",this.eventHandlers.keydown)}},{key:"selectObject",value:function(t){if(this.config.enabled&&this.transformControls&&t)return this.deselectObject(),this.selectedObject=t,this.transformControls.attach(t),this.config.showBoundingBox&&this.showBoundingBox(t),this.callbacks.onObjectSelect&&this.callbacks.onObjectSelect(t,!0),this.forceInvisible||(this.transformControls.visible=!0),t}},{key:"deselectObject",value:function(){if(this.selectedObject){this.transformControls&&this.transformControls.detach(),this.hideBoundingBox(),this.callbacks.onObjectSelect&&this.callbacks.onObjectSelect(this.selectedObject,!1);var t=this.selectedObject;return this.selectedObject=null,this.ensureSceneAttachment(!1),t}return null}},{key:"setMode",value:function(t){if(this.transformControls&&["translate","rotate","scale"].includes(t)){switch(this.currentMode=t,this.transformControls.setMode(t),t){case"translate":this.transformControls.setTranslationSnap(this.config.translationSnap);break;case"rotate":this.transformControls.setRotationSnap(this.config.rotationSnap);break;case"scale":this.transformControls.setScaleSnap(this.config.scaleSnap)}this.callbacks.onModeChange&&this.callbacks.onModeChange(t)}}},{key:"toggleSpace",value:function(){this.transformControls&&(this.currentSpace="world"===this.currentSpace?"local":"world",this.transformControls.setSpace(this.currentSpace))}},{key:"toggleVisibility",value:function(){this.transformControls&&(this.forceInvisible||(this.transformControls.visible=!this.transformControls.visible))}},{key:"setEnabled",value:function(t){this.config.enabled=t,this.transformControls&&(this.transformControls.enabled=t,t?this.selectedObject&&!this.forceInvisible&&(this.transformControls.visible=!0):(this.deselectObject(),this.transformControls.visible=!1))}},{key:"updateAxisVisibility",value:function(){this.transformControls&&(this.transformControls.showX=this.config.showX,this.transformControls.showY=this.config.showY,this.transformControls.showZ=this.config.showZ)}},{key:"showBoundingBox",value:function(t){if(t&&Te){this.hideBoundingBox();var e=this.boundingBoxCache.get(t);e||(e=(new Te.Box3).setFromObject(t),this.boundingBoxCache.set(t,e)),this.boundingBoxHelper?this.boundingBoxHelper.box=e:(this.boundingBoxHelper=new Te.Box3Helper(e,this.config.boundingBoxColor),this.scene.add(this.boundingBoxHelper)),t.userData.worldBoundingBox=e}}},{key:"hideBoundingBox",value:function(){this.boundingBoxHelper&&(this.scene.remove(this.boundingBoxHelper),this.boundingBoxHelper=null)}},{key:"updateBoundingBox",value:function(){if(this.selectedObject&&this.config.showBoundingBox){var t=(new Te.Box3).setFromObject(this.selectedObject);this.boundingBoxCache.set(this.selectedObject,t),this.boundingBoxHelper&&(this.boundingBoxHelper.box=t),this.selectedObject.userData.worldBoundingBox=t}}},{key:"captureObjectTransform",value:function(t){return t?{position:{x:t.position.x,y:t.position.y,z:t.position.z},rotation:{x:t.rotation.x,y:t.rotation.y,z:t.rotation.z},scale:{x:t.scale.x,y:t.scale.y,z:t.scale.z}}:null}},{key:"setSnapValues",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(this.transformControls){if(void 0!==t.translation&&(this.config.translationSnap=t.translation,"translate"===this.currentMode&&this.transformControls.setTranslationSnap(t.translation)),void 0!==t.rotation){var e=t.rotation*(Math.PI/180);this.config.rotationSnap=e,"rotate"===this.currentMode&&this.transformControls.setRotationSnap(e)}void 0!==t.scale&&(this.config.scaleSnap=t.scale,"scale"===this.currentMode&&this.transformControls.setScaleSnap(t.scale))}}},{key:"setSize",value:function(t){this.config.size=t,this.transformControls&&(this.transformControls.size=t)}},{key:"dispose",value:function(){this.removeEventListeners(),this.hideBoundingBox(),this.transformControls&&(this.transformControls.detach(),this.scene.remove(this.transformControls),this.transformControls=null),this.selectedObject=null,this.boundingBoxCache=new WeakMap}},{key:"ensureSceneAttachment",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return!(!this.transformControls||!this.scene)&&(!this.scene.children.includes(this.transformControls)&&(this.scene.add(this.transformControls),this.transformControls.visible=t&&!this.forceInvisible&&this.config.enabled,!0))}},{key:"getTransformData",value:function(){if(!this.selectedObject)return null;var t=new Te.Vector3;this.selectedObject.getWorldPosition(t);var e=new Te.Quaternion;this.selectedObject.getWorldQuaternion(e);var n=(new Te.Euler).setFromQuaternion(e),i=new Te.Vector3;return this.selectedObject.getWorldScale(i),{uuid:this.selectedObject.uuid,position:{x:this.selectedObject.position.x,y:this.selectedObject.position.y,z:this.selectedObject.position.z},rotation:{x:this.selectedObject.rotation.x,y:this.selectedObject.rotation.y,z:this.selectedObject.rotation.z},scale:{x:this.selectedObject.scale.x,y:this.selectedObject.scale.y,z:this.selectedObject.scale.z},worldPosition:{x:t.x,y:t.y,z:t.z},worldRotation:{x:n.x,y:n.y,z:n.z},worldScale:{x:i.x,y:i.y,z:i.z}}}}]);var t}();function Re(t,e,n,i){return new Pe(t,e,n,i)}var Ce=Object.freeze({__proto__:null,TransformControlsManager:Pe,getTransformControlsManager:Re,default:Pe}),Le={animation:B,component:Z,debug:S,disposal:et,environment:dt,hotReload:At,keyboardControls:jt,name:Bt,pathfinding:Vt,performance:qt,sceneExport:se,sceneInitialization:we,texture:xe,transformControls:Ce};class Ie extends t.DataTextureLoader{constructor(e){super(e),this.type=t.HalfFloatType}parse(e){const n=function(t,e){return-1},i=function(t,e,n){e=e||1024;let i=t.pos,r=-1,s=0,o="",a=String.fromCharCode.apply(null,new Uint16Array(t.subarray(i,i+128)));for(;0>(r=a.indexOf("\n"))&&s<e&&i<t.byteLength;)o+=a,s+=a.length,i+=128,a+=String.fromCharCode.apply(null,new Uint16Array(t.subarray(i,i+128)));return-1<r&&(!1!==n&&(t.pos+=s+r+1),o+a.slice(0,r))},r=function(t,e,n,i){const r=t[e+3],s=Math.pow(2,r-128)/255;n[i+0]=t[e+0]*s,n[i+1]=t[e+1]*s,n[i+2]=t[e+2]*s,n[i+3]=1},s=function(e,n,i,r){const s=e[n+3],o=Math.pow(2,s-128)/255;i[r+0]=t.DataUtils.toHalfFloat(Math.min(e[n+0]*o,65504)),i[r+1]=t.DataUtils.toHalfFloat(Math.min(e[n+1]*o,65504)),i[r+2]=t.DataUtils.toHalfFloat(Math.min(e[n+2]*o,65504)),i[r+3]=t.DataUtils.toHalfFloat(1)},o=new Uint8Array(e);o.pos=0;const a=function(t){const e=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,n=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,r=/^\s*FORMAT=(\S+)\s*$/,s=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,o={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let a,u;if(t.pos>=t.byteLength||!(a=i(t)))return-1;if(!(u=a.match(/^#\?(\S+)/)))return-1;for(o.valid|=1,o.programtype=u[1],o.string+=a+"\n";a=i(t),!1!==a;)if(o.string+=a+"\n","#"!==a.charAt(0)){if((u=a.match(e))&&(o.gamma=parseFloat(u[1])),(u=a.match(n))&&(o.exposure=parseFloat(u[1])),(u=a.match(r))&&(o.valid|=2,o.format=u[1]),(u=a.match(s))&&(o.valid|=4,o.height=parseInt(u[1],10),o.width=parseInt(u[2],10)),2&o.valid&&4&o.valid)break}else o.comments+=a+"\n";return 2&o.valid&&4&o.valid?o:-1}(o);if(-1!==a){const e=a.width,i=a.height,u=function(t,e,i){const r=e;if(r<8||r>32767||2!==t[0]||2!==t[1]||128&t[2])return new Uint8Array(t);if(r!==(t[2]<<8|t[3]))return-1;const s=new Uint8Array(4*e*i);if(!s.length)return-1;let o=0,a=0;const u=4*r,h=new Uint8Array(4),c=new Uint8Array(u);let l=i;for(;l>0&&a<t.byteLength;){if(a+4>t.byteLength)return n();if(h[0]=t[a++],h[1]=t[a++],h[2]=t[a++],h[3]=t[a++],2!=h[0]||2!=h[1]||(h[2]<<8|h[3])!=r)return n();let e,i=0;for(;i<u&&a<t.byteLength;){e=t[a++];const r=e>128;if(r&&(e-=128),0===e||i+e>u)return n();if(r){const n=t[a++];for(let t=0;t<e;t++)c[i++]=n}else c.set(t.subarray(a,a+e),i),i+=e,a+=e}const f=r;for(let t=0;t<f;t++){let e=0;s[o]=c[t+e],e+=r,s[o+1]=c[t+e],e+=r,s[o+2]=c[t+e],e+=r,s[o+3]=c[t+e],o+=4}l--}return s}(o.subarray(o.pos),e,i);if(-1!==u){let n,o,h;switch(this.type){case t.FloatType:h=u.length/4;const e=new Float32Array(4*h);for(let t=0;t<h;t++)r(u,4*t,e,4*t);n=e,o=t.FloatType;break;case t.HalfFloatType:h=u.length/4;const i=new Uint16Array(4*h);for(let t=0;t<h;t++)s(u,4*t,i,4*t);n=i,o=t.HalfFloatType}return{width:e,height:i,data:n,header:a.string,gamma:a.gamma,exposure:a.exposure,type:o}}}return null}setDataType(t){return this.type=t,this}load(e,n,i,r){return super.load(e,function(e,i){switch(e.type){case t.FloatType:case t.HalfFloatType:e.encoding=t.LinearEncoding,e.minFilter=t.LinearFilter,e.magFilter=t.LinearFilter,e.generateMipmaps=!1,e.flipY=!0}n&&n(e,i)},i,r)}}var je=Object.freeze({__proto__:null,RGBELoader:Ie});const Ne={type:"change"},Ue={type:"start"},He={type:"end"};class Be extends t.EventDispatcher{constructor(e,n){super(),this.object=e,this.domElement=n,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new t.Vector3,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:t.MOUSE.ROTATE,MIDDLE:t.MOUSE.DOLLY,RIGHT:t.MOUSE.PAN},this.touches={ONE:t.TOUCH.ROTATE,TWO:t.TOUCH.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.F=null,this.getPolarAngle=function(){return a.phi},this.getAzimuthalAngle=function(){return a.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function(t){t.addEventListener("keydown",Y),this.F=t},this.stopListenToKeyEvents=function(){this.F.removeEventListener("keydown",Y),this.F=null},this.saveState=function(){i.target0.copy(i.target),i.position0.copy(i.object.position),i.zoom0=i.object.zoom},this.reset=function(){i.target.copy(i.target0),i.object.position.copy(i.position0),i.object.zoom=i.zoom0,i.object.updateProjectionMatrix(),i.dispatchEvent(Ne),i.update(),s=r.NONE},this.update=function(){const n=new t.Vector3,f=(new t.Quaternion).setFromUnitVectors(e.up,new t.Vector3(0,1,0)),d=f.clone().invert(),w=new t.Vector3,v=new t.Quaternion,p=2*Math.PI;return function(){const t=i.object.position;n.copy(t).sub(i.target),n.applyQuaternion(f),a.setFromVector3(n),i.autoRotate&&s===r.NONE&&T(2*Math.PI/60/60*i.autoRotateSpeed),i.enableDamping?(a.theta+=u.theta*i.dampingFactor,a.phi+=u.phi*i.dampingFactor):(a.theta+=u.theta,a.phi+=u.phi);let e=i.minAzimuthAngle,m=i.maxAzimuthAngle;return isFinite(e)&&isFinite(m)&&(e<-Math.PI?e+=p:e>Math.PI&&(e-=p),m<-Math.PI?m+=p:m>Math.PI&&(m-=p),a.theta=e<=m?Math.max(e,Math.min(m,a.theta)):a.theta>(e+m)/2?Math.max(e,a.theta):Math.min(m,a.theta)),a.phi=Math.max(i.minPolarAngle,Math.min(i.maxPolarAngle,a.phi)),a.makeSafe(),a.radius*=h,a.radius=Math.max(i.minDistance,Math.min(i.maxDistance,a.radius)),!0===i.enableDamping?i.target.addScaledVector(c,i.dampingFactor):i.target.add(c),n.setFromSpherical(a),n.applyQuaternion(d),t.copy(i.target).add(n),i.object.lookAt(i.target),!0===i.enableDamping?(u.theta*=1-i.dampingFactor,u.phi*=1-i.dampingFactor,c.multiplyScalar(1-i.dampingFactor)):(u.set(0,0,0),c.set(0,0,0)),h=1,!!(l||w.distanceToSquared(i.object.position)>o||8*(1-v.dot(i.object.quaternion))>o)&&(i.dispatchEvent(Ne),w.copy(i.object.position),v.copy(i.object.quaternion),l=!1,!0)}}(),this.dispose=function(){i.domElement.removeEventListener("contextmenu",z),i.domElement.removeEventListener("pointerdown",B),i.domElement.removeEventListener("pointercancel",X),i.domElement.removeEventListener("wheel",D),i.domElement.removeEventListener("pointermove",F),i.domElement.removeEventListener("pointerup",G),null!==i.F&&(i.F.removeEventListener("keydown",Y),i.F=null)};const i=this,r={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let s=r.NONE;const o=1e-6,a=new t.Spherical,u=new t.Spherical;let h=1;const c=new t.Vector3;let l=!1;const f=new t.Vector2,d=new t.Vector2,w=new t.Vector2,v=new t.Vector2,p=new t.Vector2,m=new t.Vector2,y=new t.Vector2,b=new t.Vector2,g=new t.Vector2,A=[],M={};function k(){return Math.pow(.95,i.zoomSpeed)}function T(t){u.theta-=t}function _(t){u.phi-=t}const E=function(){const e=new t.Vector3;return function(t,n){e.setFromMatrixColumn(n,0),e.multiplyScalar(-t),c.add(e)}}(),x=function(){const e=new t.Vector3;return function(t,n){!0===i.screenSpacePanning?e.setFromMatrixColumn(n,1):(e.setFromMatrixColumn(n,0),e.crossVectors(i.object.up,e)),e.multiplyScalar(t),c.add(e)}}(),S=function(){const e=new t.Vector3;return function(t,n){const r=i.domElement;if(i.object.isPerspectiveCamera){const s=i.object.position;e.copy(s).sub(i.target);let o=e.length();o*=Math.tan(i.object.fov/2*Math.PI/180),E(2*t*o/r.clientHeight,i.object.matrix),x(2*n*o/r.clientHeight,i.object.matrix)}else i.object.isOrthographicCamera?(E(t*(i.object.right-i.object.left)/i.object.zoom/r.clientWidth,i.object.matrix),x(n*(i.object.top-i.object.bottom)/i.object.zoom/r.clientHeight,i.object.matrix)):i.enablePan=!1}}();function O(t){i.object.isPerspectiveCamera?h/=t:i.object.isOrthographicCamera?(i.object.zoom=Math.max(i.minZoom,Math.min(i.maxZoom,i.object.zoom*t)),i.object.updateProjectionMatrix(),l=!0):i.enableZoom=!1}function P(t){i.object.isPerspectiveCamera?h*=t:i.object.isOrthographicCamera?(i.object.zoom=Math.max(i.minZoom,Math.min(i.maxZoom,i.object.zoom/t)),i.object.updateProjectionMatrix(),l=!0):i.enableZoom=!1}function R(t){f.set(t.clientX,t.clientY)}function C(t){v.set(t.clientX,t.clientY)}function L(){if(1===A.length)f.set(A[0].pageX,A[0].pageY);else{const t=.5*(A[0].pageX+A[1].pageX),e=.5*(A[0].pageY+A[1].pageY);f.set(t,e)}}function I(){if(1===A.length)v.set(A[0].pageX,A[0].pageY);else{const t=.5*(A[0].pageX+A[1].pageX),e=.5*(A[0].pageY+A[1].pageY);v.set(t,e)}}function j(){const t=A[0].pageX-A[1].pageX,e=A[0].pageY-A[1].pageY,n=Math.sqrt(t*t+e*e);y.set(0,n)}function N(t){if(1==A.length)d.set(t.pageX,t.pageY);else{const e=V(t),n=.5*(t.pageX+e.x),i=.5*(t.pageY+e.y);d.set(n,i)}w.subVectors(d,f).multiplyScalar(i.rotateSpeed);const e=i.domElement;T(2*Math.PI*w.x/e.clientHeight),_(2*Math.PI*w.y/e.clientHeight),f.copy(d)}function U(t){if(1===A.length)p.set(t.pageX,t.pageY);else{const e=V(t),n=.5*(t.pageX+e.x),i=.5*(t.pageY+e.y);p.set(n,i)}m.subVectors(p,v).multiplyScalar(i.panSpeed),S(m.x,m.y),v.copy(p)}function H(t){const e=V(t),n=t.pageX-e.x,r=t.pageY-e.y,s=Math.sqrt(n*n+r*r);b.set(0,s),g.set(0,Math.pow(b.y/y.y,i.zoomSpeed)),O(g.y),y.copy(b)}function B(e){!1!==i.enabled&&(0===A.length&&(i.domElement.setPointerCapture(e.pointerId),i.domElement.addEventListener("pointermove",F),i.domElement.addEventListener("pointerup",G)),function(t){A.push(t)}(e),"touch"===e.pointerType?function(e){switch(K(e),A.length){case 1:switch(i.touches.ONE){case t.TOUCH.ROTATE:if(!1===i.enableRotate)return;L(),s=r.TOUCH_ROTATE;break;case t.TOUCH.PAN:if(!1===i.enablePan)return;I(),s=r.TOUCH_PAN;break;default:s=r.NONE}break;case 2:switch(i.touches.TWO){case t.TOUCH.DOLLY_PAN:if(!1===i.enableZoom&&!1===i.enablePan)return;i.enableZoom&&j(),i.enablePan&&I(),s=r.TOUCH_DOLLY_PAN;break;case t.TOUCH.DOLLY_ROTATE:if(!1===i.enableZoom&&!1===i.enableRotate)return;i.enableZoom&&j(),i.enableRotate&&L(),s=r.TOUCH_DOLLY_ROTATE;break;default:s=r.NONE}break;default:s=r.NONE}s!==r.NONE&&i.dispatchEvent(Ue)}(e):function(e){let n;switch(e.button){case 0:n=i.mouseButtons.LEFT;break;case 1:n=i.mouseButtons.MIDDLE;break;case 2:n=i.mouseButtons.RIGHT;break;default:n=-1}switch(n){case t.MOUSE.DOLLY:if(!1===i.enableZoom)return;!function(t){y.set(t.clientX,t.clientY)}(e),s=r.DOLLY;break;case t.MOUSE.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(!1===i.enablePan)return;C(e),s=r.PAN}else{if(!1===i.enableRotate)return;R(e),s=r.ROTATE}break;case t.MOUSE.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(!1===i.enableRotate)return;R(e),s=r.ROTATE}else{if(!1===i.enablePan)return;C(e),s=r.PAN}break;default:s=r.NONE}s!==r.NONE&&i.dispatchEvent(Ue)}(e))}function F(t){!1!==i.enabled&&("touch"===t.pointerType?function(t){switch(K(t),s){case r.TOUCH_ROTATE:if(!1===i.enableRotate)return;N(t),i.update();break;case r.TOUCH_PAN:if(!1===i.enablePan)return;U(t),i.update();break;case r.TOUCH_DOLLY_PAN:if(!1===i.enableZoom&&!1===i.enablePan)return;!function(t){i.enableZoom&&H(t),i.enablePan&&U(t)}(t),i.update();break;case r.TOUCH_DOLLY_ROTATE:if(!1===i.enableZoom&&!1===i.enableRotate)return;!function(t){i.enableZoom&&H(t),i.enableRotate&&N(t)}(t),i.update();break;default:s=r.NONE}}(t):function(t){switch(s){case r.ROTATE:if(!1===i.enableRotate)return;!function(t){d.set(t.clientX,t.clientY),w.subVectors(d,f).multiplyScalar(i.rotateSpeed);const e=i.domElement;T(2*Math.PI*w.x/e.clientHeight),_(2*Math.PI*w.y/e.clientHeight),f.copy(d),i.update()}(t);break;case r.DOLLY:if(!1===i.enableZoom)return;!function(t){b.set(t.clientX,t.clientY),g.subVectors(b,y),g.y>0?O(k()):g.y<0&&P(k()),y.copy(b),i.update()}(t);break;case r.PAN:if(!1===i.enablePan)return;!function(t){p.set(t.clientX,t.clientY),m.subVectors(p,v).multiplyScalar(i.panSpeed),S(m.x,m.y),v.copy(p),i.update()}(t)}}(t))}function G(t){Z(t),0===A.length&&(i.domElement.releasePointerCapture(t.pointerId),i.domElement.removeEventListener("pointermove",F),i.domElement.removeEventListener("pointerup",G)),i.dispatchEvent(He),s=r.NONE}function X(t){Z(t)}function D(t){!1!==i.enabled&&!1!==i.enableZoom&&s===r.NONE&&(t.preventDefault(),i.dispatchEvent(Ue),function(t){t.deltaY<0?P(k()):t.deltaY>0&&O(k()),i.update()}(t),i.dispatchEvent(He))}function Y(t){!1!==i.enabled&&!1!==i.enablePan&&function(t){let e=!1;switch(t.code){case i.keys.UP:t.ctrlKey||t.metaKey||t.shiftKey?_(2*Math.PI*i.rotateSpeed/i.domElement.clientHeight):S(0,i.keyPanSpeed),e=!0;break;case i.keys.BOTTOM:t.ctrlKey||t.metaKey||t.shiftKey?_(-2*Math.PI*i.rotateSpeed/i.domElement.clientHeight):S(0,-i.keyPanSpeed),e=!0;break;case i.keys.LEFT:t.ctrlKey||t.metaKey||t.shiftKey?T(2*Math.PI*i.rotateSpeed/i.domElement.clientHeight):S(i.keyPanSpeed,0),e=!0;break;case i.keys.RIGHT:t.ctrlKey||t.metaKey||t.shiftKey?T(-2*Math.PI*i.rotateSpeed/i.domElement.clientHeight):S(-i.keyPanSpeed,0),e=!0}e&&(t.preventDefault(),i.update())}(t)}function z(t){!1!==i.enabled&&t.preventDefault()}function Z(t){delete M[t.pointerId];for(let e=0;e<A.length;e++)if(A[e].pointerId==t.pointerId)return void A.splice(e,1)}function K(e){let n=M[e.pointerId];void 0===n&&(n=new t.Vector2,M[e.pointerId]=n),n.set(e.pageX,e.pageY)}function V(t){const e=t.pointerId===A[0].pointerId?A[1]:A[0];return M[e.pointerId]}i.domElement.addEventListener("contextmenu",z),i.domElement.addEventListener("pointerdown",B),i.domElement.addEventListener("pointercancel",X),i.domElement.addEventListener("wheel",D,{passive:!1}),this.update()}}var Fe=Object.freeze({__proto__:null,OrbitControls:Be,MapControls:class extends Be{constructor(e,n){super(e,n),this.screenSpacePanning=!1,this.mouseButtons.LEFT=t.MOUSE.PAN,this.mouseButtons.RIGHT=t.MOUSE.ROTATE,this.touches.ONE=t.TOUCH.PAN,this.touches.TWO=t.TOUCH.DOLLY_ROTATE}}});function Ge(e,n){if(n===t.TrianglesDrawMode)return e;if(n===t.TriangleFanDrawMode||n===t.TriangleStripDrawMode){let i=e.getIndex();if(null===i){const t=[],n=e.getAttribute("position");if(void 0===n)return e;for(let e=0;e<n.count;e++)t.push(e);e.setIndex(t),i=e.getIndex()}const r=i.count-2,s=[];if(n===t.TriangleFanDrawMode)for(let t=1;t<=r;t++)s.push(i.getX(0)),s.push(i.getX(t)),s.push(i.getX(t+1));else for(let t=0;t<r;t++)t%2==0?(s.push(i.getX(t)),s.push(i.getX(t+1)),s.push(i.getX(t+2))):(s.push(i.getX(t+2)),s.push(i.getX(t+1)),s.push(i.getX(t)));s.length;const o=e.clone();return o.setIndex(s),o.clearGroups(),o}return e}class Xe extends t.Loader{constructor(t){super(t),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new Ve(t)}),this.register(function(t){return new en(t)}),this.register(function(t){return new nn(t)}),this.register(function(t){return new rn(t)}),this.register(function(t){return new $e(t)}),this.register(function(t){return new Je(t)}),this.register(function(t){return new qe(t)}),this.register(function(t){return new Qe(t)}),this.register(function(t){return new Ke(t)}),this.register(function(t){return new tn(t)}),this.register(function(t){return new We(t)}),this.register(function(t){return new ze(t)}),this.register(function(t){return new sn(t)}),this.register(function(t){return new on(t)})}load(e,n,i,r){const s=this;let o;o=""!==this.resourcePath?this.resourcePath:""!==this.path?this.path:t.LoaderUtils.extractUrlBase(e),this.manager.itemStart(e);const a=function(t){r&&r(t),s.manager.itemError(e),s.manager.itemEnd(e)},u=new t.FileLoader(this.manager);u.setPath(this.path),u.setResponseType("arraybuffer"),u.setRequestHeader(this.requestHeader),u.setWithCredentials(this.withCredentials),u.load(e,function(t){try{s.parse(t,o,function(t){n(t),s.manager.itemEnd(e)},a)}catch(t){a(t)}},i,a)}setDRACOLoader(t){return this.dracoLoader=t,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(t){return this.ktx2Loader=t,this}setMeshoptDecoder(t){return this.meshoptDecoder=t,this}register(t){return-1===this.pluginCallbacks.indexOf(t)&&this.pluginCallbacks.push(t),this}unregister(t){return-1!==this.pluginCallbacks.indexOf(t)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(t),1),this}parse(t,e,n,i){let r;const s={},o={},a=new TextDecoder;if("string"==typeof t)r=JSON.parse(t);else if(t instanceof ArrayBuffer){if(a.decode(new Uint8Array(t,0,4))===an){try{s[Ye.KHR_BINARY_GLTF]=new cn(t)}catch(t){return void(i&&i(t))}r=JSON.parse(s[Ye.KHR_BINARY_GLTF].content)}else r=JSON.parse(a.decode(t))}else r=t;if(void 0===r.asset||r.asset.version[0]<2)return void(i&&i(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const u=new Nn(r,{path:e||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});u.fileLoader.setRequestHeader(this.requestHeader);for(let t=0;t<this.pluginCallbacks.length;t++){const e=this.pluginCallbacks[t](u);o[e.name]=e,s[e.name]=!0}if(r.extensionsUsed)for(let t=0;t<r.extensionsUsed.length;++t){const e=r.extensionsUsed[t],n=r.extensionsRequired||[];switch(e){case Ye.KHR_MATERIALS_UNLIT:s[e]=new Ze;break;case Ye.KHR_DRACO_MESH_COMPRESSION:s[e]=new ln(r,this.dracoLoader);break;case Ye.KHR_TEXTURE_TRANSFORM:s[e]=new fn;break;case Ye.KHR_MESH_QUANTIZATION:s[e]=new dn;break;default:n.indexOf(e)>=0&&o[e]}}u.setExtensions(s),u.setPlugins(o),u.parse(n,i)}parseAsync(t,e){const n=this;return new Promise(function(i,r){n.parse(t,e,i,r)})}}function De(){let t={};return{get:function(e){return t[e]},add:function(e,n){t[e]=n},remove:function(e){delete t[e]},removeAll:function(){t={}}}}const Ye={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class ze{constructor(t){this.parser=t,this.name=Ye.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}G(){const t=this.parser,e=this.parser.json.nodes||[];for(let n=0,i=e.length;n<i;n++){const i=e[n];i.extensions&&i.extensions[this.name]&&void 0!==i.extensions[this.name].light&&t.D(this.cache,i.extensions[this.name].light)}}K(e){const n=this.parser,i="light:"+e;let r=n.cache.get(i);if(r)return r;const s=n.json,o=((s.extensions&&s.extensions[this.name]||{}).lights||[])[e];let a;const u=new t.Color(16777215);void 0!==o.color&&u.fromArray(o.color);const h=void 0!==o.range?o.range:0;switch(o.type){case"directional":a=new t.DirectionalLight(u),a.target.position.set(0,0,-1),a.add(a.target);break;case"point":a=new t.PointLight(u),a.distance=h;break;case"spot":a=new t.SpotLight(u),a.distance=h,o.spot=o.spot||{},o.spot.innerConeAngle=void 0!==o.spot.innerConeAngle?o.spot.innerConeAngle:0,o.spot.outerConeAngle=void 0!==o.spot.outerConeAngle?o.spot.outerConeAngle:Math.PI/4,a.angle=o.spot.outerConeAngle,a.penumbra=1-o.spot.innerConeAngle/o.spot.outerConeAngle,a.target.position.set(0,0,-1),a.add(a.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+o.type)}return a.position.set(0,0,0),a.decay=2,Pn(a,o),void 0!==o.intensity&&(a.intensity=o.intensity),a.name=n.createUniqueName(o.name||"light_"+e),r=Promise.resolve(a),n.cache.add(i,r),r}getDependency(t,e){if("light"===t)return this.K(e)}createNodeAttachment(t){const e=this,n=this.parser,i=n.json.nodes[t],r=(i.extensions&&i.extensions[this.name]||{}).light;return void 0===r?null:this.K(r).then(function(t){return n.V(e.cache,r,t)})}}class Ze{constructor(){this.name=Ye.KHR_MATERIALS_UNLIT}getMaterialType(){return t.MeshBasicMaterial}extendParams(e,n,i){const r=[];e.color=new t.Color(1,1,1),e.opacity=1;const s=n.pbrMetallicRoughness;if(s){if(Array.isArray(s.baseColorFactor)){const t=s.baseColorFactor;e.color.fromArray(t),e.opacity=t[3]}void 0!==s.baseColorTexture&&r.push(i.assignTexture(e,"map",s.baseColorTexture,t.sRGBEncoding))}return Promise.all(r)}}class Ke{constructor(t){this.parser=t,this.name=Ye.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(t,e){const n=this.parser.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name].emissiveStrength;return void 0!==i&&(e.emissiveIntensity=i),Promise.resolve()}}class Ve{constructor(t){this.parser=t,this.name=Ye.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const n=this.parser.json.materials[e];return n.extensions&&n.extensions[this.name]?t.MeshPhysicalMaterial:null}extendMaterialParams(e,n){const i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const s=[],o=r.extensions[this.name];if(void 0!==o.clearcoatFactor&&(n.clearcoat=o.clearcoatFactor),void 0!==o.clearcoatTexture&&s.push(i.assignTexture(n,"clearcoatMap",o.clearcoatTexture)),void 0!==o.clearcoatRoughnessFactor&&(n.clearcoatRoughness=o.clearcoatRoughnessFactor),void 0!==o.clearcoatRoughnessTexture&&s.push(i.assignTexture(n,"clearcoatRoughnessMap",o.clearcoatRoughnessTexture)),void 0!==o.clearcoatNormalTexture&&(s.push(i.assignTexture(n,"clearcoatNormalMap",o.clearcoatNormalTexture)),void 0!==o.clearcoatNormalTexture.scale)){const e=o.clearcoatNormalTexture.scale;n.clearcoatNormalScale=new t.Vector2(e,e)}return Promise.all(s)}}class We{constructor(t){this.parser=t,this.name=Ye.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const n=this.parser.json.materials[e];return n.extensions&&n.extensions[this.name]?t.MeshPhysicalMaterial:null}extendMaterialParams(t,e){const n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];return void 0!==s.iridescenceFactor&&(e.iridescence=s.iridescenceFactor),void 0!==s.iridescenceTexture&&r.push(n.assignTexture(e,"iridescenceMap",s.iridescenceTexture)),void 0!==s.iridescenceIor&&(e.iridescenceIOR=s.iridescenceIor),void 0===e.iridescenceThicknessRange&&(e.iridescenceThicknessRange=[100,400]),void 0!==s.iridescenceThicknessMinimum&&(e.iridescenceThicknessRange[0]=s.iridescenceThicknessMinimum),void 0!==s.iridescenceThicknessMaximum&&(e.iridescenceThicknessRange[1]=s.iridescenceThicknessMaximum),void 0!==s.iridescenceThicknessTexture&&r.push(n.assignTexture(e,"iridescenceThicknessMap",s.iridescenceThicknessTexture)),Promise.all(r)}}class $e{constructor(t){this.parser=t,this.name=Ye.KHR_MATERIALS_SHEEN}getMaterialType(e){const n=this.parser.json.materials[e];return n.extensions&&n.extensions[this.name]?t.MeshPhysicalMaterial:null}extendMaterialParams(e,n){const i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const s=[];n.sheenColor=new t.Color(0,0,0),n.sheenRoughness=0,n.sheen=1;const o=r.extensions[this.name];return void 0!==o.sheenColorFactor&&n.sheenColor.fromArray(o.sheenColorFactor),void 0!==o.sheenRoughnessFactor&&(n.sheenRoughness=o.sheenRoughnessFactor),void 0!==o.sheenColorTexture&&s.push(i.assignTexture(n,"sheenColorMap",o.sheenColorTexture,t.sRGBEncoding)),void 0!==o.sheenRoughnessTexture&&s.push(i.assignTexture(n,"sheenRoughnessMap",o.sheenRoughnessTexture)),Promise.all(s)}}class Je{constructor(t){this.parser=t,this.name=Ye.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const n=this.parser.json.materials[e];return n.extensions&&n.extensions[this.name]?t.MeshPhysicalMaterial:null}extendMaterialParams(t,e){const n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];return void 0!==s.transmissionFactor&&(e.transmission=s.transmissionFactor),void 0!==s.transmissionTexture&&r.push(n.assignTexture(e,"transmissionMap",s.transmissionTexture)),Promise.all(r)}}class qe{constructor(t){this.parser=t,this.name=Ye.KHR_MATERIALS_VOLUME}getMaterialType(e){const n=this.parser.json.materials[e];return n.extensions&&n.extensions[this.name]?t.MeshPhysicalMaterial:null}extendMaterialParams(e,n){const i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const s=[],o=r.extensions[this.name];n.thickness=void 0!==o.thicknessFactor?o.thicknessFactor:0,void 0!==o.thicknessTexture&&s.push(i.assignTexture(n,"thicknessMap",o.thicknessTexture)),n.attenuationDistance=o.attenuationDistance||1/0;const a=o.attenuationColor||[1,1,1];return n.attenuationColor=new t.Color(a[0],a[1],a[2]),Promise.all(s)}}class Qe{constructor(t){this.parser=t,this.name=Ye.KHR_MATERIALS_IOR}getMaterialType(e){const n=this.parser.json.materials[e];return n.extensions&&n.extensions[this.name]?t.MeshPhysicalMaterial:null}extendMaterialParams(t,e){const n=this.parser.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name];return e.ior=void 0!==i.ior?i.ior:1.5,Promise.resolve()}}class tn{constructor(t){this.parser=t,this.name=Ye.KHR_MATERIALS_SPECULAR}getMaterialType(e){const n=this.parser.json.materials[e];return n.extensions&&n.extensions[this.name]?t.MeshPhysicalMaterial:null}extendMaterialParams(e,n){const i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const s=[],o=r.extensions[this.name];n.specularIntensity=void 0!==o.specularFactor?o.specularFactor:1,void 0!==o.specularTexture&&s.push(i.assignTexture(n,"specularIntensityMap",o.specularTexture));const a=o.specularColorFactor||[1,1,1];return n.specularColor=new t.Color(a[0],a[1],a[2]),void 0!==o.specularColorTexture&&s.push(i.assignTexture(n,"specularColorMap",o.specularColorTexture,t.sRGBEncoding)),Promise.all(s)}}class en{constructor(t){this.parser=t,this.name=Ye.KHR_TEXTURE_BASISU}loadTexture(t){const e=this.parser,n=e.json,i=n.textures[t];if(!i.extensions||!i.extensions[this.name])return null;const r=i.extensions[this.name],s=e.options.ktx2Loader;if(!s){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return e.loadTextureImage(t,r.source,s)}}class nn{constructor(t){this.parser=t,this.name=Ye.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(t){const e=this.name,n=this.parser,i=n.json,r=i.textures[t];if(!r.extensions||!r.extensions[e])return null;const s=r.extensions[e],o=i.images[s.source];let a=n.textureLoader;if(o.uri){const t=n.options.manager.getHandler(o.uri);null!==t&&(a=t)}return this.detectSupport().then(function(r){if(r)return n.loadTextureImage(t,s.source,a);if(i.extensionsRequired&&i.extensionsRequired.indexOf(e)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(t)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(t){const e=new Image;e.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",e.onload=e.onerror=function(){t(1===e.height)}})),this.isSupported}}class rn{constructor(t){this.parser=t,this.name=Ye.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(t){const e=this.name,n=this.parser,i=n.json,r=i.textures[t];if(!r.extensions||!r.extensions[e])return null;const s=r.extensions[e],o=i.images[s.source];let a=n.textureLoader;if(o.uri){const t=n.options.manager.getHandler(o.uri);null!==t&&(a=t)}return this.detectSupport().then(function(r){if(r)return n.loadTextureImage(t,s.source,a);if(i.extensionsRequired&&i.extensionsRequired.indexOf(e)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.loadTexture(t)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(t){const e=new Image;e.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",e.onload=e.onerror=function(){t(1===e.height)}})),this.isSupported}}class sn{constructor(t){this.name=Ye.EXT_MESHOPT_COMPRESSION,this.parser=t}loadBufferView(t){const e=this.parser.json,n=e.bufferViews[t];if(n.extensions&&n.extensions[this.name]){const t=n.extensions[this.name],i=this.parser.getDependency("buffer",t.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.supported){if(e.extensionsRequired&&e.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return i.then(function(e){const n=t.byteOffset||0,i=t.byteLength||0,s=t.count,o=t.byteStride,a=new Uint8Array(e,n,i);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(s,o,a,t.mode,t.filter).then(function(t){return t.buffer}):r.ready.then(function(){const e=new ArrayBuffer(s*o);return r.decodeGltfBuffer(new Uint8Array(e),s,o,a,t.mode,t.filter),e})})}return null}}class on{constructor(t){this.name=Ye.EXT_MESH_GPU_INSTANCING,this.parser=t}createNodeMesh(e){const n=this.parser.json,i=n.nodes[e];if(!i.extensions||!i.extensions[this.name]||void 0===i.mesh)return null;const r=n.meshes[i.mesh];for(const t of r.primitives)if(t.mode!==mn.TRIANGLES&&t.mode!==mn.TRIANGLE_STRIP&&t.mode!==mn.TRIANGLE_FAN&&void 0!==t.mode)return null;const s=i.extensions[this.name].attributes,o=[],a={};for(const t in s)o.push(this.parser.getDependency("accessor",s[t]).then(e=>(a[t]=e,a[t])));return o.length<1?null:(o.push(this.parser.createNodeMesh(e)),Promise.all(o).then(e=>{const n=e.pop(),i=n.isGroup?n.children:[n],r=e[0].count,s=[];for(const e of i){const n=new t.Matrix4,i=new t.Vector3,o=new t.Quaternion,u=new t.Vector3(1,1,1),h=new t.InstancedMesh(e.geometry,e.material,r);for(let t=0;t<r;t++)a.TRANSLATION&&i.fromBufferAttribute(a.TRANSLATION,t),a.ROTATION&&o.fromBufferAttribute(a.ROTATION,t),a.SCALE&&u.fromBufferAttribute(a.SCALE,t),h.setMatrixAt(t,n.compose(i,o,u));for(const t in a)"TRANSLATION"!==t&&"ROTATION"!==t&&"SCALE"!==t&&e.geometry.setAttribute(t,a[t]);t.Object3D.prototype.copy.call(h,e),h.frustumCulled=!1,this.parser.assignFinalMaterial(h),s.push(h)}return n.isGroup?(n.clear(),n.add(...s),n):s[0]}))}}const an="glTF",un=1313821514,hn=5130562;class cn{constructor(t){this.name=Ye.KHR_BINARY_GLTF,this.content=null,this.body=null;const e=new DataView(t,0,12),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(t.slice(0,4))),version:e.getUint32(4,!0),length:e.getUint32(8,!0)},this.header.magic!==an)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const i=this.header.length-12,r=new DataView(t,12);let s=0;for(;s<i;){const e=r.getUint32(s,!0);s+=4;const i=r.getUint32(s,!0);if(s+=4,i===un){const i=new Uint8Array(t,12+s,e);this.content=n.decode(i)}else if(i===hn){const n=12+s;this.body=t.slice(n,n+e)}s+=e}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class ln{constructor(t,e){if(!e)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=Ye.KHR_DRACO_MESH_COMPRESSION,this.json=t,this.dracoLoader=e,this.dracoLoader.preload()}decodePrimitive(t,e){const n=this.json,i=this.dracoLoader,r=t.extensions[this.name].bufferView,s=t.extensions[this.name].attributes,o={},a={},u={};for(const t in s){const e=Mn[t]||t.toLowerCase();o[e]=s[t]}for(const e in t.attributes){const i=Mn[e]||e.toLowerCase();if(void 0!==s[e]){const r=n.accessors[t.attributes[e]],s=yn[r.componentType];u[i]=s.name,a[i]=!0===r.normalized}}return e.getDependency("bufferView",r).then(function(t){return new Promise(function(e){i.decodeDracoFile(t,function(t){for(const e in t.attributes){const n=t.attributes[e],i=a[e];void 0!==i&&(n.normalized=i)}e(t)},o,u)})})}}class fn{constructor(){this.name=Ye.KHR_TEXTURE_TRANSFORM}extendTexture(t,e){return e.texCoord,void 0===e.offset&&void 0===e.rotation&&void 0===e.scale||(t=t.clone(),void 0!==e.offset&&t.offset.fromArray(e.offset),void 0!==e.rotation&&(t.rotation=e.rotation),void 0!==e.scale&&t.repeat.fromArray(e.scale),t.needsUpdate=!0),t}}class dn{constructor(){this.name=Ye.KHR_MESH_QUANTIZATION}}class wn extends t.Interpolant{constructor(t,e,n,i){super(t,e,n,i)}copySampleValue_(t){const e=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=t*i*3+i;for(let t=0;t!==i;t++)e[t]=n[r+t];return e}interpolate_(t,e,n,i){const r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=2*o,u=3*o,h=i-e,c=(n-e)/h,l=c*c,f=l*c,d=t*u,w=d-u,v=-2*f+3*l,p=f-l,m=1-v,y=p-l+c;for(let t=0;t!==o;t++){const e=s[w+t+o],n=s[w+t+a]*h,i=s[d+t+o],u=s[d+t]*h;r[t]=m*e+y*n+v*i+p*u}return r}}const vn=new t.Quaternion;class pn extends wn{interpolate_(t,e,n,i){const r=super.interpolate_(t,e,n,i);return vn.fromArray(r).normalize().toArray(r),r}}const mn={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},yn={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},bn={9728:t.NearestFilter,9729:t.LinearFilter,9984:t.NearestMipmapNearestFilter,9985:t.LinearMipmapNearestFilter,9986:t.NearestMipmapLinearFilter,9987:t.LinearMipmapLinearFilter},gn={33071:t.ClampToEdgeWrapping,33648:t.MirroredRepeatWrapping,10497:t.RepeatWrapping},An={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Mn={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},kn={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Tn={CUBICSPLINE:void 0,LINEAR:t.InterpolateLinear,STEP:t.InterpolateDiscrete},_n="OPAQUE",En="MASK",xn="BLEND";function Sn(e){return void 0===e.DefaultMaterial&&(e.DefaultMaterial=new t.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:t.FrontSide})),e.DefaultMaterial}function On(t,e,n){for(const i in n.extensions)void 0===t[i]&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[i]=n.extensions[i])}function Pn(t,e){void 0!==e.extras&&"object"==typeof e.extras&&Object.assign(t.userData,e.extras)}function Rn(t,e){if(t.updateMorphTargets(),void 0!==e.weights)for(let n=0,i=e.weights.length;n<i;n++)t.morphTargetInfluences[n]=e.weights[n];if(e.extras&&Array.isArray(e.extras.targetNames)){const n=e.extras.targetNames;if(t.morphTargetInfluences.length===n.length){t.morphTargetDictionary={};for(let e=0,i=n.length;e<i;e++)t.morphTargetDictionary[n[e]]=e}}}function Cn(t){const e=t.extensions&&t.extensions[Ye.KHR_DRACO_MESH_COMPRESSION];let n;return n=e?"draco:"+e.bufferView+":"+e.indices+":"+Ln(e.attributes):t.indices+":"+Ln(t.attributes)+":"+t.mode,n}function Ln(t){let e="";const n=Object.keys(t).sort();for(let i=0,r=n.length;i<r;i++)e+=n[i]+":"+t[n[i]]+";";return e}function In(t){switch(t){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}const jn=new t.Matrix4;class Nn{constructor(e={},n={}){this.json=e,this.extensions={},this.plugins={},this.options=n,this.cache=new De,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let i=!1,r=!1,s=-1;"undefined"!=typeof navigator&&(i=!0===/^((?!chrome|android).)*safari/i.test(navigator.userAgent),r=navigator.userAgent.indexOf("Firefox")>-1,s=r?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),"undefined"==typeof createImageBitmap||i||r&&s<98?this.textureLoader=new t.TextureLoader(this.options.manager):this.textureLoader=new t.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new t.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(t){this.extensions=t}setPlugins(t){this.plugins=t}parse(t,e){const n=this,i=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this.W(function(t){return t.G&&t.G()}),Promise.all(this.W(function(t){return t.beforeRoot&&t.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(e){const s={scene:e[0][i.scene||0],scenes:e[0],animations:e[1],cameras:e[2],asset:i.asset,parser:n,userData:{}};On(r,s,i),Pn(s,i),Promise.all(n.W(function(t){return t.afterRoot&&t.afterRoot(s)})).then(function(){t(s)})}).catch(e)}G(){const t=this.json.nodes||[],e=this.json.skins||[],n=this.json.meshes||[];for(let n=0,i=e.length;n<i;n++){const i=e[n].joints;for(let e=0,n=i.length;e<n;e++)t[i[e]].isBone=!0}for(let e=0,i=t.length;e<i;e++){const i=t[e];void 0!==i.mesh&&(this.D(this.meshCache,i.mesh),void 0!==i.skin&&(n[i.mesh].isSkinnedMesh=!0)),void 0!==i.camera&&this.D(this.cameraCache,i.camera)}}D(t,e){void 0!==e&&(void 0===t.refs[e]&&(t.refs[e]=t.uses[e]=0),t.refs[e]++)}V(t,e,n){if(t.refs[e]<=1)return n;const i=n.clone(),r=(t,e)=>{const n=this.associations.get(t);null!=n&&this.associations.set(e,n);for(const[n,i]of t.children.entries())r(i,e.children[n])};return r(n,i),i.name+="_instance_"+t.uses[e]++,i}$(t){const e=Object.values(this.plugins);e.push(this);for(let n=0;n<e.length;n++){const i=t(e[n]);if(i)return i}return null}W(t){const e=Object.values(this.plugins);e.unshift(this);const n=[];for(let i=0;i<e.length;i++){const r=t(e[i]);r&&n.push(r)}return n}getDependency(t,e){const n=t+":"+e;let i=this.cache.get(n);if(!i){switch(t){case"scene":i=this.loadScene(e);break;case"node":i=this.$(function(t){return t.loadNode&&t.loadNode(e)});break;case"mesh":i=this.$(function(t){return t.loadMesh&&t.loadMesh(e)});break;case"accessor":i=this.loadAccessor(e);break;case"bufferView":i=this.$(function(t){return t.loadBufferView&&t.loadBufferView(e)});break;case"buffer":i=this.loadBuffer(e);break;case"material":i=this.$(function(t){return t.loadMaterial&&t.loadMaterial(e)});break;case"texture":i=this.$(function(t){return t.loadTexture&&t.loadTexture(e)});break;case"skin":i=this.loadSkin(e);break;case"animation":i=this.$(function(t){return t.loadAnimation&&t.loadAnimation(e)});break;case"camera":i=this.loadCamera(e);break;default:if(i=this.$(function(n){return n!=this&&n.getDependency&&n.getDependency(t,e)}),!i)throw new Error("Unknown type: "+t)}this.cache.add(n,i)}return i}getDependencies(t){let e=this.cache.get(t);if(!e){const n=this,i=this.json[t+("mesh"===t?"es":"s")]||[];e=Promise.all(i.map(function(e,i){return n.getDependency(t,i)})),this.cache.add(t,e)}return e}loadBuffer(e){const n=this.json.buffers[e],i=this.fileLoader;if(n.type&&"arraybuffer"!==n.type)throw new Error("THREE.GLTFLoader: "+n.type+" buffer type is not supported.");if(void 0===n.uri&&0===e)return Promise.resolve(this.extensions[Ye.KHR_BINARY_GLTF].body);const r=this.options;return new Promise(function(e,s){i.load(t.LoaderUtils.resolveURL(n.uri,r.path),e,void 0,function(){s(new Error('THREE.GLTFLoader: Failed to load buffer "'+n.uri+'".'))})})}loadBufferView(t){const e=this.json.bufferViews[t];return this.getDependency("buffer",e.buffer).then(function(t){const n=e.byteLength||0,i=e.byteOffset||0;return t.slice(i,i+n)})}loadAccessor(e){const n=this,i=this.json,r=this.json.accessors[e];if(void 0===r.bufferView&&void 0===r.sparse){const e=An[r.type],n=yn[r.componentType],i=!0===r.normalized,s=new n(r.count*e);return Promise.resolve(new t.BufferAttribute(s,e,i))}const s=[];return void 0!==r.bufferView?s.push(this.getDependency("bufferView",r.bufferView)):s.push(null),void 0!==r.sparse&&(s.push(this.getDependency("bufferView",r.sparse.indices.bufferView)),s.push(this.getDependency("bufferView",r.sparse.values.bufferView))),Promise.all(s).then(function(e){const s=e[0],o=An[r.type],a=yn[r.componentType],u=a.BYTES_PER_ELEMENT,h=u*o,c=r.byteOffset||0,l=void 0!==r.bufferView?i.bufferViews[r.bufferView].byteStride:void 0,f=!0===r.normalized;let d,w;if(l&&l!==h){const e=Math.floor(c/l),i="InterleavedBuffer:"+r.bufferView+":"+r.componentType+":"+e+":"+r.count;let h=n.cache.get(i);h||(d=new a(s,e*l,r.count*l/u),h=new t.InterleavedBuffer(d,l/u),n.cache.add(i,h)),w=new t.InterleavedBufferAttribute(h,o,c%l/u,f)}else d=null===s?new a(r.count*o):new a(s,c,r.count*o),w=new t.BufferAttribute(d,o,f);if(void 0!==r.sparse){const n=An.SCALAR,i=yn[r.sparse.indices.componentType],u=r.sparse.indices.byteOffset||0,h=r.sparse.values.byteOffset||0,c=new i(e[1],u,r.sparse.count*n),l=new a(e[2],h,r.sparse.count*o);null!==s&&(w=new t.BufferAttribute(w.array.slice(),w.itemSize,w.normalized));for(let t=0,e=c.length;t<e;t++){const e=c[t];if(w.setX(e,l[t*o]),o>=2&&w.setY(e,l[t*o+1]),o>=3&&w.setZ(e,l[t*o+2]),o>=4&&w.setW(e,l[t*o+3]),o>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return w})}loadTexture(t){const e=this.json,n=this.options,i=e.textures[t].source,r=e.images[i];let s=this.textureLoader;if(r.uri){const t=n.manager.getHandler(r.uri);null!==t&&(s=t)}return this.loadTextureImage(t,i,s)}loadTextureImage(e,n,i){const r=this,s=this.json,o=s.textures[e],a=s.images[n],u=(a.uri||a.bufferView)+":"+o.sampler;if(this.textureCache[u])return this.textureCache[u];const h=this.loadImageSource(n,i).then(function(n){n.flipY=!1,n.name=o.name||a.name||"";const i=(s.samplers||{})[o.sampler]||{};return n.magFilter=bn[i.magFilter]||t.LinearFilter,n.minFilter=bn[i.minFilter]||t.LinearMipmapLinearFilter,n.wrapS=gn[i.wrapS]||t.RepeatWrapping,n.wrapT=gn[i.wrapT]||t.RepeatWrapping,r.associations.set(n,{textures:e}),n}).catch(function(){return null});return this.textureCache[u]=h,h}loadImageSource(e,n){const i=this,r=this.json,s=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then(t=>t.clone());const o=r.images[e],a=self.URL||self.webkitURL;let u=o.uri||"",h=!1;if(void 0!==o.bufferView)u=i.getDependency("bufferView",o.bufferView).then(function(t){h=!0;const e=new Blob([t],{type:o.mimeType});return u=a.createObjectURL(e),u});else if(void 0===o.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const c=Promise.resolve(u).then(function(e){return new Promise(function(i,r){let o=i;!0===n.isImageBitmapLoader&&(o=function(e){const n=new t.Texture(e);n.needsUpdate=!0,i(n)}),n.load(t.LoaderUtils.resolveURL(e,s.path),o,void 0,r)})}).then(function(t){var e;return!0===h&&a.revokeObjectURL(u),t.userData.mimeType=o.mimeType||((e=o.uri).search(/\.jpe?g($|\?)/i)>0||0===e.search(/^data\:image\/jpeg/)?"image/jpeg":e.search(/\.webp($|\?)/i)>0||0===e.search(/^data\:image\/webp/)?"image/webp":"image/png"),t}).catch(function(t){throw t});return this.sourceCache[e]=c,c}assignTexture(t,e,n,i){const r=this;return this.getDependency("texture",n.index).then(function(s){if(!s)return null;if(void 0!==n.texCoord&&0!=n.texCoord&&("aoMap"!==e||n.texCoord),r.extensions[Ye.KHR_TEXTURE_TRANSFORM]){const t=void 0!==n.extensions?n.extensions[Ye.KHR_TEXTURE_TRANSFORM]:void 0;if(t){const e=r.associations.get(s);s=r.extensions[Ye.KHR_TEXTURE_TRANSFORM].extendTexture(s,t),r.associations.set(s,e)}}return void 0!==i&&(s.encoding=i),t[e]=s,s})}assignFinalMaterial(e){const n=e.geometry;let i=e.material;const r=void 0===n.attributes.tangent,s=void 0!==n.attributes.color,o=void 0===n.attributes.normal;if(e.isPoints){const e="PointsMaterial:"+i.uuid;let n=this.cache.get(e);n||(n=new t.PointsMaterial,t.Material.prototype.copy.call(n,i),n.color.copy(i.color),n.map=i.map,n.sizeAttenuation=!1,this.cache.add(e,n)),i=n}else if(e.isLine){const e="LineBasicMaterial:"+i.uuid;let n=this.cache.get(e);n||(n=new t.LineBasicMaterial,t.Material.prototype.copy.call(n,i),n.color.copy(i.color),this.cache.add(e,n)),i=n}if(r||s||o){let t="ClonedMaterial:"+i.uuid+":";r&&(t+="derivative-tangents:"),s&&(t+="vertex-colors:"),o&&(t+="flat-shading:");let e=this.cache.get(t);e||(e=i.clone(),s&&(e.vertexColors=!0),o&&(e.flatShading=!0),r&&(e.normalScale&&(e.normalScale.y*=-1),e.clearcoatNormalScale&&(e.clearcoatNormalScale.y*=-1)),this.cache.add(t,e),this.associations.set(e,this.associations.get(i))),i=e}i.aoMap&&void 0===n.attributes.uv2&&void 0!==n.attributes.uv&&n.setAttribute("uv2",n.attributes.uv),e.material=i}getMaterialType(){return t.MeshStandardMaterial}loadMaterial(e){const n=this,i=this.json,r=this.extensions,s=i.materials[e];let o;const a={},u=[];if((s.extensions||{})[Ye.KHR_MATERIALS_UNLIT]){const t=r[Ye.KHR_MATERIALS_UNLIT];o=t.getMaterialType(),u.push(t.extendParams(a,s,n))}else{const i=s.pbrMetallicRoughness||{};if(a.color=new t.Color(1,1,1),a.opacity=1,Array.isArray(i.baseColorFactor)){const t=i.baseColorFactor;a.color.fromArray(t),a.opacity=t[3]}void 0!==i.baseColorTexture&&u.push(n.assignTexture(a,"map",i.baseColorTexture,t.sRGBEncoding)),a.metalness=void 0!==i.metallicFactor?i.metallicFactor:1,a.roughness=void 0!==i.roughnessFactor?i.roughnessFactor:1,void 0!==i.metallicRoughnessTexture&&(u.push(n.assignTexture(a,"metalnessMap",i.metallicRoughnessTexture)),u.push(n.assignTexture(a,"roughnessMap",i.metallicRoughnessTexture))),o=this.$(function(t){return t.getMaterialType&&t.getMaterialType(e)}),u.push(Promise.all(this.W(function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,a)})))}!0===s.doubleSided&&(a.side=t.DoubleSide);const h=s.alphaMode||_n;if(h===xn?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,h===En&&(a.alphaTest=void 0!==s.alphaCutoff?s.alphaCutoff:.5)),void 0!==s.normalTexture&&o!==t.MeshBasicMaterial&&(u.push(n.assignTexture(a,"normalMap",s.normalTexture)),a.normalScale=new t.Vector2(1,1),void 0!==s.normalTexture.scale)){const t=s.normalTexture.scale;a.normalScale.set(t,t)}return void 0!==s.occlusionTexture&&o!==t.MeshBasicMaterial&&(u.push(n.assignTexture(a,"aoMap",s.occlusionTexture)),void 0!==s.occlusionTexture.strength&&(a.aoMapIntensity=s.occlusionTexture.strength)),void 0!==s.emissiveFactor&&o!==t.MeshBasicMaterial&&(a.emissive=(new t.Color).fromArray(s.emissiveFactor)),void 0!==s.emissiveTexture&&o!==t.MeshBasicMaterial&&u.push(n.assignTexture(a,"emissiveMap",s.emissiveTexture,t.sRGBEncoding)),Promise.all(u).then(function(){const t=new o(a);return s.name&&(t.name=s.name),Pn(t,s),n.associations.set(t,{materials:e}),s.extensions&&On(r,t,s),t})}createUniqueName(e){const n=t.PropertyBinding.sanitizeNodeName(e||"");let i=n;for(let t=1;this.nodeNamesUsed[i];++t)i=n+"_"+t;return this.nodeNamesUsed[i]=!0,i}loadGeometries(e){const n=this,i=this.extensions,r=this.primitiveCache;function s(t){return i[Ye.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(t,n).then(function(e){return Un(e,t,n)})}const o=[];for(let i=0,a=e.length;i<a;i++){const a=e[i],u=Cn(a),h=r[u];if(h)o.push(h.promise);else{let e;e=a.extensions&&a.extensions[Ye.KHR_DRACO_MESH_COMPRESSION]?s(a):Un(new t.BufferGeometry,a,n),r[u]={primitive:a,promise:e},o.push(e)}}return Promise.all(o)}loadMesh(e){const n=this,i=this.json,r=this.extensions,s=i.meshes[e],o=s.primitives,a=[];for(let t=0,e=o.length;t<e;t++){const e=void 0===o[t].material?Sn(this.cache):this.getDependency("material",o[t].material);a.push(e)}return a.push(n.loadGeometries(o)),Promise.all(a).then(function(i){const a=i.slice(0,i.length-1),u=i[i.length-1],h=[];for(let i=0,c=u.length;i<c;i++){const c=u[i],l=o[i];let f;const d=a[i];if(l.mode===mn.TRIANGLES||l.mode===mn.TRIANGLE_STRIP||l.mode===mn.TRIANGLE_FAN||void 0===l.mode)f=!0===s.isSkinnedMesh?new t.SkinnedMesh(c,d):new t.Mesh(c,d),!0===f.isSkinnedMesh&&f.normalizeSkinWeights(),l.mode===mn.TRIANGLE_STRIP?f.geometry=Ge(f.geometry,t.TriangleStripDrawMode):l.mode===mn.TRIANGLE_FAN&&(f.geometry=Ge(f.geometry,t.TriangleFanDrawMode));else if(l.mode===mn.LINES)f=new t.LineSegments(c,d);else if(l.mode===mn.LINE_STRIP)f=new t.Line(c,d);else if(l.mode===mn.LINE_LOOP)f=new t.LineLoop(c,d);else{if(l.mode!==mn.POINTS)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+l.mode);f=new t.Points(c,d)}Object.keys(f.geometry.morphAttributes).length>0&&Rn(f,s),f.name=n.createUniqueName(s.name||"mesh_"+e),Pn(f,s),l.extensions&&On(r,f,l),n.assignFinalMaterial(f),h.push(f)}for(let t=0,i=h.length;t<i;t++)n.associations.set(h[t],{meshes:e,primitives:t});if(1===h.length)return h[0];const c=new t.Group;n.associations.set(c,{meshes:e});for(let t=0,e=h.length;t<e;t++)c.add(h[t]);return c})}loadCamera(e){let n;const i=this.json.cameras[e],r=i[i.type];if(r)return"perspective"===i.type?n=new t.PerspectiveCamera(t.MathUtils.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):"orthographic"===i.type&&(n=new t.OrthographicCamera(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),i.name&&(n.name=this.createUniqueName(i.name)),Pn(n,i),Promise.resolve(n)}loadSkin(e){const n=this.json.skins[e],i=[];for(let t=0,e=n.joints.length;t<e;t++)i.push(this.J(n.joints[t]));return void 0!==n.inverseBindMatrices?i.push(this.getDependency("accessor",n.inverseBindMatrices)):i.push(null),Promise.all(i).then(function(e){const n=e.pop(),i=e,r=[],s=[];for(let e=0,o=i.length;e<o;e++){const o=i[e];if(o){r.push(o);const i=new t.Matrix4;null!==n&&i.fromArray(n.array,16*e),s.push(i)}}return new t.Skeleton(r,s)})}loadAnimation(e){const n=this.json.animations[e],i=[],r=[],s=[],o=[],a=[];for(let t=0,e=n.channels.length;t<e;t++){const e=n.channels[t],u=n.samplers[e.sampler],h=e.target,c=h.node,l=void 0!==n.parameters?n.parameters[u.input]:u.input,f=void 0!==n.parameters?n.parameters[u.output]:u.output;i.push(this.getDependency("node",c)),r.push(this.getDependency("accessor",l)),s.push(this.getDependency("accessor",f)),o.push(u),a.push(h)}return Promise.all([Promise.all(i),Promise.all(r),Promise.all(s),Promise.all(o),Promise.all(a)]).then(function(i){const r=i[0],s=i[1],o=i[2],a=i[3],u=i[4],h=[];for(let e=0,n=r.length;e<n;e++){const n=r[e],i=s[e],c=o[e],l=a[e],f=u[e];if(void 0===n)continue;let d;switch(n.updateMatrix(),kn[f.path]){case kn.weights:d=t.NumberKeyframeTrack;break;case kn.rotation:d=t.QuaternionKeyframeTrack;break;default:d=t.VectorKeyframeTrack}const w=n.name?n.name:n.uuid,v=void 0!==l.interpolation?Tn[l.interpolation]:t.InterpolateLinear,p=[];kn[f.path]===kn.weights?n.traverse(function(t){t.morphTargetInfluences&&p.push(t.name?t.name:t.uuid)}):p.push(w);let m=c.array;if(c.normalized){const t=In(m.constructor),e=new Float32Array(m.length);for(let n=0,i=m.length;n<i;n++)e[n]=m[n]*t;m=e}for(let e=0,n=p.length;e<n;e++){const n=new d(p[e]+"."+kn[f.path],i.array,m,v);"CUBICSPLINE"===l.interpolation&&(n.createInterpolant=function(e){return new(this instanceof t.QuaternionKeyframeTrack?pn:wn)(this.times,this.values,this.getValueSize()/3,e)},n.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0),h.push(n)}}const c=n.name?n.name:"animation_"+e;return new t.AnimationClip(c,void 0,h)})}createNodeMesh(t){const e=this.json,n=this,i=e.nodes[t];return void 0===i.mesh?null:n.getDependency("mesh",i.mesh).then(function(t){const e=n.V(n.meshCache,i.mesh,t);return void 0!==i.weights&&e.traverse(function(t){if(t.isMesh)for(let e=0,n=i.weights.length;e<n;e++)t.morphTargetInfluences[e]=i.weights[e]}),e})}loadNode(t){const e=this,n=this.json.nodes[t],i=e.J(t),r=[],s=n.children||[];for(let t=0,n=s.length;t<n;t++)r.push(e.getDependency("node",s[t]));const o=void 0===n.skin?Promise.resolve(null):e.getDependency("skin",n.skin);return Promise.all([i,Promise.all(r),o]).then(function(t){const e=t[0],n=t[1],i=t[2];null!==i&&e.traverse(function(t){t.isSkinnedMesh&&t.bind(i,jn)});for(let t=0,i=n.length;t<i;t++)e.add(n[t]);return e})}J(e){const n=this.json,i=this.extensions,r=this;if(void 0!==this.nodeCache[e])return this.nodeCache[e];const s=n.nodes[e],o=s.name?r.createUniqueName(s.name):"",a=[],u=r.$(function(t){return t.createNodeMesh&&t.createNodeMesh(e)});return u&&a.push(u),void 0!==s.camera&&a.push(r.getDependency("camera",s.camera).then(function(t){return r.V(r.cameraCache,s.camera,t)})),r.W(function(t){return t.createNodeAttachment&&t.createNodeAttachment(e)}).forEach(function(t){a.push(t)}),this.nodeCache[e]=Promise.all(a).then(function(n){let a;if(a=!0===s.isBone?new t.Bone:n.length>1?new t.Group:1===n.length?n[0]:new t.Object3D,a!==n[0])for(let t=0,e=n.length;t<e;t++)a.add(n[t]);if(s.name&&(a.userData.name=s.name,a.name=o),Pn(a,s),s.extensions&&On(i,a,s),void 0!==s.matrix){const e=new t.Matrix4;e.fromArray(s.matrix),a.applyMatrix4(e)}else void 0!==s.translation&&a.position.fromArray(s.translation),void 0!==s.rotation&&a.quaternion.fromArray(s.rotation),void 0!==s.scale&&a.scale.fromArray(s.scale);return r.associations.has(a)||r.associations.set(a,{}),r.associations.get(a).nodes=e,a}),this.nodeCache[e]}loadScene(e){const n=this.extensions,i=this.json.scenes[e],r=this,s=new t.Group;i.name&&(s.name=r.createUniqueName(i.name)),Pn(s,i),i.extensions&&On(n,s,i);const o=i.nodes||[],a=[];for(let t=0,e=o.length;t<e;t++)a.push(r.getDependency("node",o[t]));return Promise.all(a).then(function(e){for(let t=0,n=e.length;t<n;t++)s.add(e[t]);return r.associations=(e=>{const n=new Map;for(const[e,i]of r.associations)(e instanceof t.Material||e instanceof t.Texture)&&n.set(e,i);return e.traverse(t=>{const e=r.associations.get(t);null!=e&&n.set(t,e)}),n})(s),s})}}function Un(e,n,i){const r=n.attributes,s=[];function o(t,n){return i.getDependency("accessor",t).then(function(t){e.setAttribute(n,t)})}for(const t in r){const n=Mn[t]||t.toLowerCase();n in e.attributes||s.push(o(r[t],n))}if(void 0!==n.indices&&!e.index){const t=i.getDependency("accessor",n.indices).then(function(t){e.setIndex(t)});s.push(t)}return Pn(e,n),function(e,n,i){const r=n.attributes,s=new t.Box3;if(void 0===r.POSITION)return;{const e=i.json.accessors[r.POSITION],n=e.min,o=e.max;if(void 0===n||void 0===o)return;if(s.set(new t.Vector3(n[0],n[1],n[2]),new t.Vector3(o[0],o[1],o[2])),e.normalized){const t=In(yn[e.componentType]);s.min.multiplyScalar(t),s.max.multiplyScalar(t)}}const o=n.targets;if(void 0!==o){const e=new t.Vector3,n=new t.Vector3;for(let t=0,r=o.length;t<r;t++){const r=o[t];if(void 0!==r.POSITION){const t=i.json.accessors[r.POSITION],s=t.min,o=t.max;if(void 0!==s&&void 0!==o){if(n.setX(Math.max(Math.abs(s[0]),Math.abs(o[0]))),n.setY(Math.max(Math.abs(s[1]),Math.abs(o[1]))),n.setZ(Math.max(Math.abs(s[2]),Math.abs(o[2]))),t.normalized){const e=In(yn[t.componentType]);n.multiplyScalar(e)}e.max(n)}}}s.expandByVector(e)}e.boundingBox=s;const a=new t.Sphere;s.getCenter(a.center),a.radius=s.min.distanceTo(s.max)/2,e.boundingSphere=a}(e,n,i),Promise.all(s).then(function(){return void 0!==n.targets?function(t,e,n){let i=!1,r=!1,s=!1;for(let t=0,n=e.length;t<n;t++){const n=e[t];if(void 0!==n.POSITION&&(i=!0),void 0!==n.NORMAL&&(r=!0),void 0!==n.COLOR_0&&(s=!0),i&&r&&s)break}if(!i&&!r&&!s)return Promise.resolve(t);const o=[],a=[],u=[];for(let h=0,c=e.length;h<c;h++){const c=e[h];if(i){const e=void 0!==c.POSITION?n.getDependency("accessor",c.POSITION):t.attributes.position;o.push(e)}if(r){const e=void 0!==c.NORMAL?n.getDependency("accessor",c.NORMAL):t.attributes.normal;a.push(e)}if(s){const e=void 0!==c.COLOR_0?n.getDependency("accessor",c.COLOR_0):t.attributes.color;u.push(e)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(u)]).then(function(e){const n=e[0],o=e[1],a=e[2];return i&&(t.morphAttributes.position=n),r&&(t.morphAttributes.normal=o),s&&(t.morphAttributes.color=a),t.morphTargetsRelative=!0,t})}(e,n.targets,i):e})}var Hn=Object.freeze({__proto__:null,GLTFLoader:Xe});const Bn=new t.Raycaster,Fn=new t.Vector3,Gn=new t.Vector3,Xn=new t.Quaternion,Dn={X:new t.Vector3(1,0,0),Y:new t.Vector3(0,1,0),Z:new t.Vector3(0,0,1)},Yn={type:"change"},zn={type:"mouseDown"},Zn={type:"mouseUp",mode:null},Kn={type:"objectChange"};class Vn extends t.Object3D{constructor(e,n){super(),void 0===n&&(n=document),this.isTransformControls=!0,this.visible=!1,this.domElement=n,this.domElement.style.touchAction="none";const i=new vi;this.q=i,this.add(i);const r=new pi;this.tt=r,this.add(r);const s=this;function o(t,e){let n=e;Object.defineProperty(s,t,{get:function(){return void 0!==n?n:e},set:function(e){n!==e&&(n=e,r[t]=e,i[t]=e,s.dispatchEvent({type:t+"-changed",value:e}),s.dispatchEvent(Yn))}}),s[t]=e,r[t]=e,i[t]=e}o("camera",e),o("object",void 0),o("enabled",!0),o("axis",null),o("mode","translate"),o("translationSnap",null),o("rotationSnap",null),o("scaleSnap",null),o("space","world"),o("size",1),o("dragging",!1),o("showX",!0),o("showY",!0),o("showZ",!0);const a=new t.Vector3,u=new t.Vector3,h=new t.Quaternion,c=new t.Quaternion,l=new t.Vector3,f=new t.Quaternion,d=new t.Vector3,w=new t.Vector3,v=new t.Vector3,p=new t.Vector3;o("worldPosition",a),o("worldPositionStart",u),o("worldQuaternion",h),o("worldQuaternionStart",c),o("cameraPosition",l),o("cameraQuaternion",f),o("pointStart",d),o("pointEnd",w),o("rotationAxis",v),o("rotationAngle",0),o("eye",p),this.et=new t.Vector3,this.nt=new t.Vector3,this.it=new t.Vector3,this.rt=new t.Vector3,this.st=new t.Vector3,this.ot=new t.Quaternion,this.ut=new t.Quaternion,this.ht=new t.Vector3,this.ct=new t.Vector3,this.lt=new t.Quaternion,this.ft=new t.Vector3,this.dt=new t.Vector3,this.wt=new t.Quaternion,this.vt=new t.Vector3,this.yt=Wn.bind(this),this.bt=Jn.bind(this),this.gt=$n.bind(this),this.At=qn.bind(this),this.Mt=Qn.bind(this),this.domElement.addEventListener("pointerdown",this.bt),this.domElement.addEventListener("pointermove",this.gt),this.domElement.addEventListener("pointerup",this.Mt)}updateMatrixWorld(){void 0!==this.object&&(this.object.updateMatrixWorld(),null===this.object.parent||this.object.parent.matrixWorld.decompose(this.st,this.ot,this.ht),this.object.matrixWorld.decompose(this.worldPosition,this.worldQuaternion,this.ft),this.ut.copy(this.ot).invert(),this.lt.copy(this.worldQuaternion).invert()),this.camera.updateMatrixWorld(),this.camera.matrixWorld.decompose(this.cameraPosition,this.cameraQuaternion,this.rt),this.camera.isOrthographicCamera?this.camera.getWorldDirection(this.eye).negate():this.eye.copy(this.cameraPosition).sub(this.worldPosition).normalize(),super.updateMatrixWorld(this)}pointerHover(t){if(void 0===this.object||!0===this.dragging)return;Bn.setFromCamera(t,this.camera);const e=ti(this.q.picker[this.mode],Bn);this.axis=e?e.object.name:null}pointerDown(t){if(void 0!==this.object&&!0!==this.dragging&&0===t.button&&null!==this.axis){Bn.setFromCamera(t,this.camera);const e=ti(this.tt,Bn,!0);e&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this.dt.copy(this.object.position),this.wt.copy(this.object.quaternion),this.vt.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this.ct),this.pointStart.copy(e.point).sub(this.worldPositionStart)),this.dragging=!0,zn.mode=this.mode,this.dispatchEvent(zn)}}pointerMove(t){const e=this.axis,n=this.mode,i=this.object;let r=this.space;if("scale"===n?r="local":"E"!==e&&"XYZE"!==e&&"XYZ"!==e||(r="world"),void 0===i||null===e||!1===this.dragging||-1!==t.button)return;Bn.setFromCamera(t,this.camera);const s=ti(this.tt,Bn,!0);if(s){if(this.pointEnd.copy(s.point).sub(this.worldPositionStart),"translate"===n)this.et.copy(this.pointEnd).sub(this.pointStart),"local"===r&&"XYZ"!==e&&this.et.applyQuaternion(this.lt),-1===e.indexOf("X")&&(this.et.x=0),-1===e.indexOf("Y")&&(this.et.y=0),-1===e.indexOf("Z")&&(this.et.z=0),"local"===r&&"XYZ"!==e?this.et.applyQuaternion(this.wt).divide(this.ht):this.et.applyQuaternion(this.ut).divide(this.ht),i.position.copy(this.et).add(this.dt),this.translationSnap&&("local"===r&&(i.position.applyQuaternion(Xn.copy(this.wt).invert()),-1!==e.search("X")&&(i.position.x=Math.round(i.position.x/this.translationSnap)*this.translationSnap),-1!==e.search("Y")&&(i.position.y=Math.round(i.position.y/this.translationSnap)*this.translationSnap),-1!==e.search("Z")&&(i.position.z=Math.round(i.position.z/this.translationSnap)*this.translationSnap),i.position.applyQuaternion(this.wt)),"world"===r&&(i.parent&&i.position.add(Fn.setFromMatrixPosition(i.parent.matrixWorld)),-1!==e.search("X")&&(i.position.x=Math.round(i.position.x/this.translationSnap)*this.translationSnap),-1!==e.search("Y")&&(i.position.y=Math.round(i.position.y/this.translationSnap)*this.translationSnap),-1!==e.search("Z")&&(i.position.z=Math.round(i.position.z/this.translationSnap)*this.translationSnap),i.parent&&i.position.sub(Fn.setFromMatrixPosition(i.parent.matrixWorld))));else if("scale"===n){if(-1!==e.search("XYZ")){let t=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(t*=-1),Gn.set(t,t,t)}else Fn.copy(this.pointStart),Gn.copy(this.pointEnd),Fn.applyQuaternion(this.lt),Gn.applyQuaternion(this.lt),Gn.divide(Fn),-1===e.search("X")&&(Gn.x=1),-1===e.search("Y")&&(Gn.y=1),-1===e.search("Z")&&(Gn.z=1);i.scale.copy(this.vt).multiply(Gn),this.scaleSnap&&(-1!==e.search("X")&&(i.scale.x=Math.round(i.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),-1!==e.search("Y")&&(i.scale.y=Math.round(i.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),-1!==e.search("Z")&&(i.scale.z=Math.round(i.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if("rotate"===n){this.et.copy(this.pointEnd).sub(this.pointStart);const t=20/this.worldPosition.distanceTo(Fn.setFromMatrixPosition(this.camera.matrixWorld));"E"===e?(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this.nt.copy(this.pointStart).normalize(),this.it.copy(this.pointEnd).normalize(),this.rotationAngle*=this.it.cross(this.nt).dot(this.eye)<0?1:-1):"XYZE"===e?(this.rotationAxis.copy(this.et).cross(this.eye).normalize(),this.rotationAngle=this.et.dot(Fn.copy(this.rotationAxis).cross(this.eye))*t):"X"!==e&&"Y"!==e&&"Z"!==e||(this.rotationAxis.copy(Dn[e]),Fn.copy(Dn[e]),"local"===r&&Fn.applyQuaternion(this.worldQuaternion),this.rotationAngle=this.et.dot(Fn.cross(this.eye).normalize())*t),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),"local"===r&&"E"!==e&&"XYZE"!==e?(i.quaternion.copy(this.wt),i.quaternion.multiply(Xn.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this.ut),i.quaternion.copy(Xn.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),i.quaternion.multiply(this.wt).normalize())}this.dispatchEvent(Yn),this.dispatchEvent(Kn)}}pointerUp(t){0===t.button&&(this.dragging&&null!==this.axis&&(Zn.mode=this.mode,this.dispatchEvent(Zn)),this.dragging=!1,this.axis=null)}dispose(){this.domElement.removeEventListener("pointerdown",this.bt),this.domElement.removeEventListener("pointermove",this.gt),this.domElement.removeEventListener("pointermove",this.At),this.domElement.removeEventListener("pointerup",this.Mt),this.traverse(function(t){t.geometry&&t.geometry.dispose(),t.material&&t.material.dispose()})}attach(t){return this.object=t,this.visible=!0,this}detach(){return this.object=void 0,this.visible=!1,this.axis=null,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this.dt),this.object.quaternion.copy(this.wt),this.object.scale.copy(this.vt),this.dispatchEvent(Yn),this.dispatchEvent(Kn),this.pointStart.copy(this.pointEnd))}getRaycaster(){return Bn}getMode(){return this.mode}setMode(t){this.mode=t}setTranslationSnap(t){this.translationSnap=t}setRotationSnap(t){this.rotationSnap=t}setScaleSnap(t){this.scaleSnap=t}setSize(t){this.size=t}setSpace(t){this.space=t}}function Wn(t){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:t.button};{const e=this.domElement.getBoundingClientRect();return{x:(t.clientX-e.left)/e.width*2-1,y:-(t.clientY-e.top)/e.height*2+1,button:t.button}}}function $n(t){if(this.enabled)switch(t.pointerType){case"mouse":case"pen":this.pointerHover(this.yt(t))}}function Jn(t){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(t.pointerId),this.domElement.addEventListener("pointermove",this.At),this.pointerHover(this.yt(t)),this.pointerDown(this.yt(t)))}function qn(t){this.enabled&&this.pointerMove(this.yt(t))}function Qn(t){this.enabled&&(this.domElement.releasePointerCapture(t.pointerId),this.domElement.removeEventListener("pointermove",this.At),this.pointerUp(this.yt(t)))}function ti(t,e,n){const i=e.intersectObject(t,!0);for(let t=0;t<i.length;t++)if(i[t].object.visible||n)return i[t];return!1}const ei=new t.Euler,ni=new t.Vector3(0,1,0),ii=new t.Vector3(0,0,0),ri=new t.Matrix4,si=new t.Quaternion,oi=new t.Quaternion,ai=new t.Vector3,ui=new t.Matrix4,hi=new t.Vector3(1,0,0),ci=new t.Vector3(0,1,0),li=new t.Vector3(0,0,1),fi=new t.Vector3,di=new t.Vector3,wi=new t.Vector3;class vi extends t.Object3D{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const e=new t.MeshBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),n=new t.LineBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),i=e.clone();i.opacity=.15;const r=n.clone();r.opacity=.5;const s=e.clone();s.color.setHex(16711680);const o=e.clone();o.color.setHex(65280);const a=e.clone();a.color.setHex(255);const u=e.clone();u.color.setHex(16711680),u.opacity=.5;const h=e.clone();h.color.setHex(65280),h.opacity=.5;const c=e.clone();c.color.setHex(255),c.opacity=.5;const l=e.clone();l.opacity=.25;const f=e.clone();f.color.setHex(16776960),f.opacity=.25;e.clone().color.setHex(16776960);const d=e.clone();d.color.setHex(7895160);const w=new t.CylinderGeometry(0,.04,.1,12);w.translate(0,.05,0);const v=new t.BoxGeometry(.08,.08,.08);v.translate(0,.04,0);const p=new t.BufferGeometry;p.setAttribute("position",new t.Float32BufferAttribute([0,0,0,1,0,0],3));const m=new t.CylinderGeometry(.0075,.0075,.5,3);function y(e,n){const i=new t.TorusGeometry(e,.0075,3,64,n*Math.PI*2);return i.rotateY(Math.PI/2),i.rotateX(Math.PI/2),i}m.translate(0,.25,0);const b={X:[[new t.Mesh(w,s),[.5,0,0],[0,0,-Math.PI/2]],[new t.Mesh(w,s),[-.5,0,0],[0,0,Math.PI/2]],[new t.Mesh(m,s),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new t.Mesh(w,o),[0,.5,0]],[new t.Mesh(w,o),[0,-.5,0],[Math.PI,0,0]],[new t.Mesh(m,o)]],Z:[[new t.Mesh(w,a),[0,0,.5],[Math.PI/2,0,0]],[new t.Mesh(w,a),[0,0,-.5],[-Math.PI/2,0,0]],[new t.Mesh(m,a),null,[Math.PI/2,0,0]]],XYZ:[[new t.Mesh(new t.OctahedronGeometry(.1,0),l.clone()),[0,0,0]]],XY:[[new t.Mesh(new t.BoxGeometry(.15,.15,.01),c.clone()),[.15,.15,0]]],YZ:[[new t.Mesh(new t.BoxGeometry(.15,.15,.01),u.clone()),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new t.Mesh(new t.BoxGeometry(.15,.15,.01),h.clone()),[.15,0,.15],[-Math.PI/2,0,0]]]},g={X:[[new t.Mesh(new t.CylinderGeometry(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new t.Mesh(new t.CylinderGeometry(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new t.Mesh(new t.CylinderGeometry(.2,0,.6,4),i),[0,.3,0]],[new t.Mesh(new t.CylinderGeometry(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new t.Mesh(new t.CylinderGeometry(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new t.Mesh(new t.CylinderGeometry(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new t.Mesh(new t.OctahedronGeometry(.2,0),i)]],XY:[[new t.Mesh(new t.BoxGeometry(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new t.Mesh(new t.BoxGeometry(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new t.Mesh(new t.BoxGeometry(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]]},A={START:[[new t.Mesh(new t.OctahedronGeometry(.01,2),r),null,null,null,"helper"]],END:[[new t.Mesh(new t.OctahedronGeometry(.01,2),r),null,null,null,"helper"]],DELTA:[[new t.Line(function(){const e=new t.BufferGeometry;return e.setAttribute("position",new t.Float32BufferAttribute([0,0,0,1,1,1],3)),e}(),r),null,null,null,"helper"]],X:[[new t.Line(p,r.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new t.Line(p,r.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new t.Line(p,r.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},M={XYZE:[[new t.Mesh(y(.5,1),d),null,[0,Math.PI/2,0]]],X:[[new t.Mesh(y(.5,.5),s)]],Y:[[new t.Mesh(y(.5,.5),o),null,[0,0,-Math.PI/2]]],Z:[[new t.Mesh(y(.5,.5),a),null,[0,Math.PI/2,0]]],E:[[new t.Mesh(y(.75,1),f),null,[0,Math.PI/2,0]]]},k={AXIS:[[new t.Line(p,r.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},T={XYZE:[[new t.Mesh(new t.SphereGeometry(.25,10,8),i)]],X:[[new t.Mesh(new t.TorusGeometry(.5,.1,4,24),i),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new t.Mesh(new t.TorusGeometry(.5,.1,4,24),i),[0,0,0],[Math.PI/2,0,0]]],Z:[[new t.Mesh(new t.TorusGeometry(.5,.1,4,24),i),[0,0,0],[0,0,-Math.PI/2]]],E:[[new t.Mesh(new t.TorusGeometry(.75,.1,2,24),i)]]},_={X:[[new t.Mesh(v,s),[.5,0,0],[0,0,-Math.PI/2]],[new t.Mesh(m,s),[0,0,0],[0,0,-Math.PI/2]],[new t.Mesh(v,s),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new t.Mesh(v,o),[0,.5,0]],[new t.Mesh(m,o)],[new t.Mesh(v,o),[0,-.5,0],[0,0,Math.PI]]],Z:[[new t.Mesh(v,a),[0,0,.5],[Math.PI/2,0,0]],[new t.Mesh(m,a),[0,0,0],[Math.PI/2,0,0]],[new t.Mesh(v,a),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new t.Mesh(new t.BoxGeometry(.15,.15,.01),c),[.15,.15,0]]],YZ:[[new t.Mesh(new t.BoxGeometry(.15,.15,.01),u),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new t.Mesh(new t.BoxGeometry(.15,.15,.01),h),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new t.Mesh(new t.BoxGeometry(.1,.1,.1),l.clone())]]},E={X:[[new t.Mesh(new t.CylinderGeometry(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new t.Mesh(new t.CylinderGeometry(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new t.Mesh(new t.CylinderGeometry(.2,0,.6,4),i),[0,.3,0]],[new t.Mesh(new t.CylinderGeometry(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new t.Mesh(new t.CylinderGeometry(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new t.Mesh(new t.CylinderGeometry(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new t.Mesh(new t.BoxGeometry(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new t.Mesh(new t.BoxGeometry(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new t.Mesh(new t.BoxGeometry(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new t.Mesh(new t.BoxGeometry(.2,.2,.2),i),[0,0,0]]]},x={X:[[new t.Line(p,r.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new t.Line(p,r.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new t.Line(p,r.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function S(e){const n=new t.Object3D;for(const t in e)for(let i=e[t].length;i--;){const r=e[t][i][0].clone(),s=e[t][i][1],o=e[t][i][2],a=e[t][i][3],u=e[t][i][4];r.name=t,r.tag=u,s&&r.position.set(s[0],s[1],s[2]),o&&r.rotation.set(o[0],o[1],o[2]),a&&r.scale.set(a[0],a[1],a[2]),r.updateMatrix();const h=r.geometry.clone();h.applyMatrix4(r.matrix),r.geometry=h,r.renderOrder=1/0,r.position.set(0,0,0),r.rotation.set(0,0,0),r.scale.set(1,1,1),n.add(r)}return n}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=S(b)),this.add(this.gizmo.rotate=S(M)),this.add(this.gizmo.scale=S(_)),this.add(this.picker.translate=S(g)),this.add(this.picker.rotate=S(T)),this.add(this.picker.scale=S(E)),this.add(this.helper.translate=S(A)),this.add(this.helper.rotate=S(k)),this.add(this.helper.scale=S(x)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(t){const e="local"===("scale"===this.mode?"local":this.space)?this.worldQuaternion:oi;this.gizmo.translate.visible="translate"===this.mode,this.gizmo.rotate.visible="rotate"===this.mode,this.gizmo.scale.visible="scale"===this.mode,this.helper.translate.visible="translate"===this.mode,this.helper.rotate.visible="rotate"===this.mode,this.helper.scale.visible="scale"===this.mode;let n=[];n=n.concat(this.picker[this.mode].children),n=n.concat(this.gizmo[this.mode].children),n=n.concat(this.helper[this.mode].children);for(let t=0;t<n.length;t++){const i=n[t];let r;if(i.visible=!0,i.rotation.set(0,0,0),i.position.copy(this.worldPosition),r=this.camera.isOrthographicCamera?(this.camera.top-this.camera.bottom)/this.camera.zoom:this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),i.scale.set(1,1,1).multiplyScalar(r*this.size/4),"helper"!==i.tag){if(i.quaternion.copy(e),"translate"===this.mode||"scale"===this.mode){const t=.99,n=.2;"X"===i.name&&Math.abs(ni.copy(hi).applyQuaternion(e).dot(this.eye))>t&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),"Y"===i.name&&Math.abs(ni.copy(ci).applyQuaternion(e).dot(this.eye))>t&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),"Z"===i.name&&Math.abs(ni.copy(li).applyQuaternion(e).dot(this.eye))>t&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),"XY"===i.name&&Math.abs(ni.copy(li).applyQuaternion(e).dot(this.eye))<n&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),"YZ"===i.name&&Math.abs(ni.copy(hi).applyQuaternion(e).dot(this.eye))<n&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),"XZ"===i.name&&Math.abs(ni.copy(ci).applyQuaternion(e).dot(this.eye))<n&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1)}else"rotate"===this.mode&&(si.copy(e),ni.copy(this.eye).applyQuaternion(Xn.copy(e).invert()),-1!==i.name.search("E")&&i.quaternion.setFromRotationMatrix(ri.lookAt(this.eye,ii,ci)),"X"===i.name&&(Xn.setFromAxisAngle(hi,Math.atan2(-ni.y,ni.z)),Xn.multiplyQuaternions(si,Xn),i.quaternion.copy(Xn)),"Y"===i.name&&(Xn.setFromAxisAngle(ci,Math.atan2(ni.x,ni.z)),Xn.multiplyQuaternions(si,Xn),i.quaternion.copy(Xn)),"Z"===i.name&&(Xn.setFromAxisAngle(li,Math.atan2(ni.y,ni.x)),Xn.multiplyQuaternions(si,Xn),i.quaternion.copy(Xn)));i.visible=i.visible&&(-1===i.name.indexOf("X")||this.showX),i.visible=i.visible&&(-1===i.name.indexOf("Y")||this.showY),i.visible=i.visible&&(-1===i.name.indexOf("Z")||this.showZ),i.visible=i.visible&&(-1===i.name.indexOf("E")||this.showX&&this.showY&&this.showZ),i.material.kt=i.material.kt||i.material.color.clone(),i.material.Tt=i.material.Tt||i.material.opacity,i.material.color.copy(i.material.kt),i.material.opacity=i.material.Tt,this.enabled&&this.axis&&(i.name===this.axis||this.axis.split("").some(function(t){return i.name===t}))&&(i.material.color.setHex(16776960),i.material.opacity=1)}else i.visible=!1,"AXIS"===i.name?(i.visible=!!this.axis,"X"===this.axis&&(Xn.setFromEuler(ei.set(0,0,0)),i.quaternion.copy(e).multiply(Xn),Math.abs(ni.copy(hi).applyQuaternion(e).dot(this.eye))>.9&&(i.visible=!1)),"Y"===this.axis&&(Xn.setFromEuler(ei.set(0,0,Math.PI/2)),i.quaternion.copy(e).multiply(Xn),Math.abs(ni.copy(ci).applyQuaternion(e).dot(this.eye))>.9&&(i.visible=!1)),"Z"===this.axis&&(Xn.setFromEuler(ei.set(0,Math.PI/2,0)),i.quaternion.copy(e).multiply(Xn),Math.abs(ni.copy(li).applyQuaternion(e).dot(this.eye))>.9&&(i.visible=!1)),"XYZE"===this.axis&&(Xn.setFromEuler(ei.set(0,Math.PI/2,0)),ni.copy(this.rotationAxis),i.quaternion.setFromRotationMatrix(ri.lookAt(ii,ni,ci)),i.quaternion.multiply(Xn),i.visible=this.dragging),"E"===this.axis&&(i.visible=!1)):"START"===i.name?(i.position.copy(this.worldPositionStart),i.visible=this.dragging):"END"===i.name?(i.position.copy(this.worldPosition),i.visible=this.dragging):"DELTA"===i.name?(i.position.copy(this.worldPositionStart),i.quaternion.copy(this.worldQuaternionStart),Fn.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),Fn.applyQuaternion(this.worldQuaternionStart.clone().invert()),i.scale.copy(Fn),i.visible=this.dragging):(i.quaternion.copy(e),this.dragging?i.position.copy(this.worldPositionStart):i.position.copy(this.worldPosition),this.axis&&(i.visible=-1!==this.axis.search(i.name)))}super.updateMatrixWorld(t)}}class pi extends t.Mesh{constructor(){super(new t.PlaneGeometry(1e5,1e5,2,2),new t.MeshBasicMaterial({visible:!1,wireframe:!0,side:t.DoubleSide,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(t){let e=this.space;switch(this.position.copy(this.worldPosition),"scale"===this.mode&&(e="local"),fi.copy(hi).applyQuaternion("local"===e?this.worldQuaternion:oi),di.copy(ci).applyQuaternion("local"===e?this.worldQuaternion:oi),wi.copy(li).applyQuaternion("local"===e?this.worldQuaternion:oi),ni.copy(di),this.mode){case"translate":case"scale":switch(this.axis){case"X":ni.copy(this.eye).cross(fi),ai.copy(fi).cross(ni);break;case"Y":ni.copy(this.eye).cross(di),ai.copy(di).cross(ni);break;case"Z":ni.copy(this.eye).cross(wi),ai.copy(wi).cross(ni);break;case"XY":ai.copy(wi);break;case"YZ":ai.copy(fi);break;case"XZ":ni.copy(wi),ai.copy(di);break;case"XYZ":case"E":ai.set(0,0,0)}break;default:ai.set(0,0,0)}0===ai.length()?this.quaternion.copy(this.cameraQuaternion):(ui.lookAt(Fn.set(0,0,0),ai,ni),this.quaternion.setFromRotationMatrix(ui)),super.updateMatrixWorld(t)}}var mi=Object.freeze({__proto__:null,TransformControls:Vn,TransformControlsGizmo:vi,TransformControlsPlane:pi});exports.animationManager=B,exports.componentManager=Z,exports.debugLogger=S,exports.default=Le,exports.disposalManager=et,exports.environmentManager=dt,exports.findObjectByHardcodedUuid=Ut,exports.generateUuidFromName=Nt,exports.getHardcodedUuid=Ht,exports.getSceneExportManager=te,exports.getTransformControlsManager=Re,exports.hotReloadManager=At,exports.keyboardControlsManager=jt,exports.logger=k,exports.modelLogger=E,exports.nameUtils=Bt,exports.pathfinderLogger=_,exports.pathfindingManager=Vt,exports.sceneExportManager=se,exports.sceneInitializationManager=we,exports.textureConfig=xe,exports.transformControlsManager=Ce,exports.transformLogger=T;
1
+ Object.defineProperty(exports,"t",{value:!0});var t=require("three");function e(t){if(t&&t.t)return t;var e=Object.create(null);return t&&Object.keys(t).forEach(function(n){if("default"!==n){var i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,i.get?i:{enumerable:!0,get:function(){return t[n]}})}}),e.default=t,Object.freeze(e)}var n=e(t);function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n<e;n++)i[n]=t[n];return i}function r(t,e,n,i,r,s,o){try{var a=t[s](o),u=a.value}catch(t){return void n(t)}a.done?e(u):Promise.resolve(u).then(i,r)}function s(t){return function(){var e=this,n=arguments;return new Promise(function(i,s){var o=t.apply(e,n);function a(t){r(o,i,s,a,u,"next",t)}function u(t){r(o,i,s,a,u,"throw",t)}a(void 0)})}}function o(t,e,n){return e=v(e),function(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,w()?Reflect.construct(e,n||[],v(t).constructor):e.apply(t,n))}function a(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function u(t,e,n){if(w())return Reflect.construct.apply(null,arguments);var i=[null];i.push.apply(i,e);var r=new(t.bind.apply(t,i));return n&&M(r,n.prototype),r}function h(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,E(i.key),i)}}function c(t,e,n){return e&&h(t.prototype,e),n&&h(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function l(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=_(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var i=0,r=function(){};return{s:r,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,o=!0,a=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return o=t.done,t},e:function(t){a=!0,s=t},f:function(){try{o||null==n.return||n.return()}finally{if(a)throw s}}}}function f(t,e,n){return(e=E(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function d(){return d="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var i=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=v(t)););return t}(t,e);if(i){var r=Object.getOwnPropertyDescriptor(i,e);return r.get?r.get.call(arguments.length<3?t:n):r.value}},d.apply(null,arguments)}function v(t){return v=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},v(t)}function p(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&M(t,e)}function w(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(w=function(){return!!t})()}function m(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,i)}return n}function y(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?m(Object(n),!0).forEach(function(e){f(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):m(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function g(){var t,e,n="function"==typeof Symbol?Symbol:{},i=n.iterator||"@@iterator",r=n.toStringTag||"@@toStringTag";function s(n,i,r,s){var u=i&&i.prototype instanceof a?i:a,h=Object.create(u.prototype);return b(h,"_invoke",function(n,i,r){var s,a,u,h=0,c=r||[],l=!1,f={p:0,n:0,v:t,a:d,f:d.bind(t,4),d:function(e,n){return s=e,a=0,u=t,f.n=n,o}};function d(n,i){for(a=n,u=i,e=0;!l&&h&&!r&&e<c.length;e++){var r,s=c[e],d=f.p,v=s[2];n>3?(r=v===i)&&(u=s[(a=s[4])?5:(a=3,3)],s[4]=s[5]=t):s[0]<=d&&((r=n<2&&d<s[1])?(a=0,f.v=i,f.n=s[1]):d<v&&(r=n<3||s[0]>i||i>v)&&(s[4]=n,s[5]=i,f.n=v,a=0))}if(r||n>1)return o;throw l=!0,i}return function(r,c,v){if(h>1)throw TypeError("Generator is already running");for(l&&1===c&&d(c,v),a=c,u=v;(e=a<2?t:u)||!l;){s||(a?a<3?(a>1&&(f.n=-1),d(a,u)):f.n=u:f.v=u);try{if(h=2,s){if(a||(r="next"),e=s[r]){if(!(e=e.call(s,u)))throw TypeError("iterator result is not an object");if(!e.done)return e;u=e.value,a<2&&(a=0)}else 1===a&&(e=s.return)&&e.call(s),a<2&&(u=TypeError("The iterator does not provide a '"+r+"' method"),a=1);s=t}else if((e=(l=f.n<0)?u:n.call(i,f))!==o)break}catch(e){s=t,a=1,u=e}finally{h=1}}return{value:e,done:l}}}(n,r,s),!0),h}var o={};function a(){}function u(){}function h(){}e=Object.getPrototypeOf;var c=[][i]?e(e([][i]())):(b(e={},i,function(){return this}),e),l=h.prototype=a.prototype=Object.create(c);function f(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,h):(t.__proto__=h,b(t,r,"GeneratorFunction")),t.prototype=Object.create(l),t}return u.prototype=h,b(l,"constructor",h),b(h,"constructor",u),u.displayName="GeneratorFunction",b(h,r,"GeneratorFunction"),b(l),b(l,r,"Generator"),b(l,i,function(){return this}),b(l,"toString",function(){return"[object Generator]"}),(g=function(){return{w:s,m:f}})()}function b(t,e,n,i){var r=Object.defineProperty;try{r({},"",{})}catch(t){r=0}b=function(t,e,n,i){if(e)r?r(t,e,{value:n,enumerable:!i,configurable:!i,writable:!i}):t[e]=n;else{function s(e,n){b(t,e,function(t){return this.i(e,n,t)})}s("next",0),s("throw",1),s("return",2)}},b(t,e,n,i)}function k(t){if(null!=t){var e=t["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],n=0;if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length))return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}}}throw new TypeError(typeof t+" is not iterable")}function M(t,e){return M=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},M(t,e)}function x(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var i,r,s,o,a=[],u=!0,h=!1;try{if(s=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;u=!1}else for(;!(u=(i=s.call(n)).done)&&(a.push(i.value),a.length!==e);u=!0);}catch(t){h=!0,r=t}finally{try{if(!u&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(h)throw r}}return a}}(t,e)||_(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function T(t,e,n,i){var r=d(v(1&i?t.prototype:t),e,n);return 2&i&&"function"==typeof r?function(t){return r.apply(n,t)}:r}function S(t){return function(t){if(Array.isArray(t))return i(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||_(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function E(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,e||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}function A(t){return A="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},A(t)}function _(t,e){if(t){if("string"==typeof t)return i(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?i(t,e):void 0}}var O=new t.Raycaster,C=new t.Vector3,R=new t.Vector3,P=new t.Quaternion,j={X:new t.Vector3(1,0,0),Y:new t.Vector3(0,1,0),Z:new t.Vector3(0,0,1)},D={type:"change"},I={type:"mouseDown"},N={type:"mouseUp",mode:null},L={type:"objectChange"},B=function(){function e(n,i){var r;a(this,e),r=o(this,e),void 0===i&&(i=document),r.isTransformControls=!0,r.visible=!1,r.domElement=i,r.domElement.style.touchAction="none";var s=new st;r.o=s,r.add(s);var u=new ot;r.u=u,r.add(u);var h=r;function c(t,e){var n=e;Object.defineProperty(h,t,{get:function(){return void 0!==n?n:e},set:function(e){n!==e&&(n=e,u[t]=e,s[t]=e,h.dispatchEvent({type:t+"-changed",value:e}),h.dispatchEvent(D))}}),h[t]=e,u[t]=e,s[t]=e}c("camera",n),c("object",void 0),c("enabled",!0),c("axis",null),c("mode","translate"),c("translationSnap",null),c("rotationSnap",null),c("scaleSnap",null),c("space","world"),c("size",1),c("dragging",!1),c("showX",!0),c("showY",!0),c("showZ",!0),c("showXY",!0),c("showYZ",!0),c("showXZ",!0),r.clickDelay=null,r.lastInteractionTime=0;var l=new t.Vector3,f=new t.Vector3,d=new t.Quaternion,v=new t.Quaternion,p=new t.Vector3,w=new t.Quaternion,m=new t.Vector3,y=new t.Vector3,g=new t.Vector3,b=new t.Vector3;return c("worldPosition",l),c("worldPositionStart",f),c("worldQuaternion",d),c("worldQuaternionStart",v),c("cameraPosition",p),c("cameraQuaternion",w),c("pointStart",m),c("pointEnd",y),c("rotationAxis",g),c("rotationAngle",0),c("eye",b),r.h=new t.Vector3,r.l=new t.Vector3,r.k=new t.Vector3,r.M=new t.Vector3,r.T=new t.Vector3,r.S=new t.Quaternion,r.A=new t.Quaternion,r._=new t.Vector3,r.O=new t.Vector3,r.C=new t.Quaternion,r.R=new t.Vector3,r.P=new t.Vector3,r.j=new t.Quaternion,r.D=new t.Vector3,r.I=F.bind(r),r.N=z.bind(r),r.L=U.bind(r),r.B=H.bind(r),r.F=G.bind(r),r.domElement.addEventListener("pointerdown",r.N),r.domElement.addEventListener("pointermove",r.L),r.domElement.addEventListener("pointerup",r.F),r}return p(e,t.Object3D),c(e,[{key:"updateMatrixWorld",value:function(){void 0!==this.object&&(this.object.updateMatrixWorld(),null===this.object.parent||this.object.parent.matrixWorld.decompose(this.T,this.S,this._),this.object.matrixWorld.decompose(this.worldPosition,this.worldQuaternion,this.R),this.A.copy(this.S).invert(),this.C.copy(this.worldQuaternion).invert()),this.camera.updateMatrixWorld(),this.camera.matrixWorld.decompose(this.cameraPosition,this.cameraQuaternion,this.M),this.camera.isOrthographicCamera?this.camera.getWorldDirection(this.eye).negate():this.eye.copy(this.cameraPosition).sub(this.worldPosition).normalize(),T(e,"updateMatrixWorld",this,3)([this])}},{key:"pointerHover",value:function(t){if(void 0!==this.object&&!0!==this.dragging){if(this.clickDelay&&this.clickDelay.doubleClickDelay)if(Date.now()-this.lastInteractionTime<this.clickDelay.doubleClickDelay)return;O.setFromCamera(t,this.camera);var e=X(this.o.picker[this.mode],O);this.axis=e?e.object.name:null}}},{key:"pointerDown",value:function(t){if(void 0!==this.object&&!0!==this.dragging&&0===t.button){if(this.clickDelay&&this.clickDelay.doubleClickDelay){var e=Date.now();if(e-this.lastInteractionTime<this.clickDelay.doubleClickDelay)return;this.lastInteractionTime=e}if(null!==this.axis){O.setFromCamera(t,this.camera);var n=X(this.u,O,!0);n&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this.P.copy(this.object.position),this.j.copy(this.object.quaternion),this.D.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this.O),this.pointStart.copy(n.point).sub(this.worldPositionStart)),this.dragging=!0,I.mode=this.mode,this.dispatchEvent(I)}}}},{key:"pointerMove",value:function(t){var e=this.axis,n=this.mode,i=this.object,r=this.space;if("scale"===n?r="local":"E"!==e&&"XYZE"!==e&&"XYZ"!==e||(r="world"),void 0!==i&&null!==e&&!1!==this.dragging&&-1===t.button){O.setFromCamera(t,this.camera);var s=X(this.u,O,!0);if(s){if(this.pointEnd.copy(s.point).sub(this.worldPositionStart),"translate"===n)this.h.copy(this.pointEnd).sub(this.pointStart),"local"===r&&"XYZ"!==e&&this.h.applyQuaternion(this.C),-1===e.indexOf("X")&&(this.h.x=0),-1===e.indexOf("Y")&&(this.h.y=0),-1===e.indexOf("Z")&&(this.h.z=0),"local"===r&&"XYZ"!==e?this.h.applyQuaternion(this.j).divide(this._):this.h.applyQuaternion(this.A).divide(this._),i.position.copy(this.h).add(this.P),this.translationSnap&&("local"===r&&(i.position.applyQuaternion(P.copy(this.j).invert()),-1!==e.search("X")&&(i.position.x=Math.round(i.position.x/this.translationSnap)*this.translationSnap),-1!==e.search("Y")&&(i.position.y=Math.round(i.position.y/this.translationSnap)*this.translationSnap),-1!==e.search("Z")&&(i.position.z=Math.round(i.position.z/this.translationSnap)*this.translationSnap),i.position.applyQuaternion(this.j)),"world"===r&&(i.parent&&i.position.add(C.setFromMatrixPosition(i.parent.matrixWorld)),-1!==e.search("X")&&(i.position.x=Math.round(i.position.x/this.translationSnap)*this.translationSnap),-1!==e.search("Y")&&(i.position.y=Math.round(i.position.y/this.translationSnap)*this.translationSnap),-1!==e.search("Z")&&(i.position.z=Math.round(i.position.z/this.translationSnap)*this.translationSnap),i.parent&&i.position.sub(C.setFromMatrixPosition(i.parent.matrixWorld))));else if("scale"===n){if(-1!==e.search("XYZ")){var o=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(o*=-1),R.set(o,o,o)}else C.copy(this.pointStart),R.copy(this.pointEnd),C.applyQuaternion(this.C),R.applyQuaternion(this.C),R.divide(C),-1===e.search("X")&&(R.x=1),-1===e.search("Y")&&(R.y=1),-1===e.search("Z")&&(R.z=1);i.scale.copy(this.D).multiply(R),this.scaleSnap&&(-1!==e.search("X")&&(i.scale.x=Math.round(i.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),-1!==e.search("Y")&&(i.scale.y=Math.round(i.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),-1!==e.search("Z")&&(i.scale.z=Math.round(i.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if("rotate"===n){this.h.copy(this.pointEnd).sub(this.pointStart);var a=20/this.worldPosition.distanceTo(C.setFromMatrixPosition(this.camera.matrixWorld));"E"===e?(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this.l.copy(this.pointStart).normalize(),this.k.copy(this.pointEnd).normalize(),this.rotationAngle*=this.k.cross(this.l).dot(this.eye)<0?1:-1):"XYZE"===e?(this.rotationAxis.copy(this.h).cross(this.eye).normalize(),this.rotationAngle=this.h.dot(C.copy(this.rotationAxis).cross(this.eye))*a):"X"!==e&&"Y"!==e&&"Z"!==e||(this.rotationAxis.copy(j[e]),C.copy(j[e]),"local"===r&&C.applyQuaternion(this.worldQuaternion),this.rotationAngle=this.h.dot(C.cross(this.eye).normalize())*a),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),"local"===r&&"E"!==e&&"XYZE"!==e?(i.quaternion.copy(this.j),i.quaternion.multiply(P.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this.A),i.quaternion.copy(P.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),i.quaternion.multiply(this.j).normalize())}this.dispatchEvent(D),this.dispatchEvent(L)}}}},{key:"pointerUp",value:function(t){0===t.button&&(this.dragging&&null!==this.axis&&(N.mode=this.mode,this.dispatchEvent(N)),this.dragging=!1,this.axis=null)}},{key:"dispose",value:function(){this.domElement.removeEventListener("pointerdown",this.N),this.domElement.removeEventListener("pointermove",this.L),this.domElement.removeEventListener("pointermove",this.B),this.domElement.removeEventListener("pointerup",this.F),this.traverse(function(t){t.geometry&&t.geometry.dispose(),t.material&&t.material.dispose()})}},{key:"attach",value:function(t){return this.object=t,this.visible=!0,this}},{key:"detach",value:function(){return this.object=void 0,this.visible=!1,this.axis=null,this}},{key:"reset",value:function(){this.enabled&&this.dragging&&(this.object.position.copy(this.P),this.object.quaternion.copy(this.j),this.object.scale.copy(this.D),this.dispatchEvent(D),this.dispatchEvent(L),this.pointStart.copy(this.pointEnd))}},{key:"getRaycaster",value:function(){return O}},{key:"getMode",value:function(){return this.mode}},{key:"setMode",value:function(t){this.mode=t}},{key:"setTranslationSnap",value:function(t){this.translationSnap=t}},{key:"setRotationSnap",value:function(t){this.rotationSnap=t}},{key:"setScaleSnap",value:function(t){this.scaleSnap=t}},{key:"setSize",value:function(t){this.size=t}},{key:"setSpace",value:function(t){this.space=t}},{key:"setDelay",value:function(t){this.clickDelay=t}},{key:"updateInteractionTime",value:function(){this.lastInteractionTime=Date.now()}}])}();function F(t){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:t.button};var e=this.domElement.getBoundingClientRect();return{x:(t.clientX-e.left)/e.width*2-1,y:-(t.clientY-e.top)/e.height*2+1,button:t.button}}function U(t){if(this.enabled)switch(t.pointerType){case"mouse":case"pen":this.pointerHover(this.I(t))}}function z(t){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(t.pointerId),this.domElement.addEventListener("pointermove",this.B),this.pointerHover(this.I(t)),this.pointerDown(this.I(t)))}function H(t){this.enabled&&this.pointerMove(this.I(t))}function G(t){this.enabled&&(this.domElement.releasePointerCapture(t.pointerId),this.domElement.removeEventListener("pointermove",this.B),this.pointerUp(this.I(t)))}function X(t,e,n){for(var i=e.intersectObject(t,!0),r=0;r<i.length;r++)if(i[r].object.visible||n)return i[r];return!1}var V=new t.Euler,Y=new t.Vector3(0,1,0),K=new t.Vector3(0,0,0),Z=new t.Matrix4,W=new t.Quaternion,$=new t.Quaternion,J=new t.Vector3,q=new t.Matrix4,Q=new t.Vector3(1,0,0),tt=new t.Vector3(0,1,0),et=new t.Vector3(0,0,1),nt=new t.Vector3,it=new t.Vector3,rt=new t.Vector3,st=function(){function e(){var n;a(this,e),(n=o(this,e)).isTransformControlsGizmo=!0,n.type="TransformControlsGizmo";var i=new t.MeshBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),r=new t.LineBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),s=i.clone();s.opacity=.15;var u=r.clone();u.opacity=.5;var h=i.clone();h.color.setHex(16711680);var c=i.clone();c.color.setHex(65280);var l=i.clone();l.color.setHex(255);var f=i.clone();f.color.setHex(16711680),f.opacity=.5;var d=i.clone();d.color.setHex(65280),d.opacity=.5;var v=i.clone();v.color.setHex(255),v.opacity=.5;var p=i.clone();p.opacity=.25;var w=i.clone();w.color.setHex(16776960),w.opacity=.25,i.clone().color.setHex(16776960);var m=i.clone();m.color.setHex(7895160);var y=new t.CylinderGeometry(0,.04,.1,12);y.translate(0,.05,0);var g=new t.BoxGeometry(.08,.08,.08);g.translate(0,.04,0);var b=new t.BufferGeometry;b.setAttribute("position",new t.Float32BufferAttribute([0,0,0,1,0,0],3));var k=new t.CylinderGeometry(.0075,.0075,.5,3);function M(e,n){var i=new t.TorusGeometry(e,.0075,3,64,n*Math.PI*2);return i.rotateY(Math.PI/2),i.rotateX(Math.PI/2),i}k.translate(0,.25,0);var x,T={X:[[new t.Mesh(y,h),[.5,0,0],[0,0,-Math.PI/2]],[new t.Mesh(y,h),[-.5,0,0],[0,0,Math.PI/2]],[new t.Mesh(k,h),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new t.Mesh(y,c),[0,.5,0]],[new t.Mesh(y,c),[0,-.5,0],[Math.PI,0,0]],[new t.Mesh(k,c)]],Z:[[new t.Mesh(y,l),[0,0,.5],[Math.PI/2,0,0]],[new t.Mesh(y,l),[0,0,-.5],[-Math.PI/2,0,0]],[new t.Mesh(k,l),null,[Math.PI/2,0,0]]],XYZ:[[new t.Mesh(new t.OctahedronGeometry(.1,0),p.clone()),[0,0,0]]],XY:[[new t.Mesh(new t.BoxGeometry(.15,.15,.01),v.clone()),[.15,.15,0]]],YZ:[[new t.Mesh(new t.BoxGeometry(.15,.15,.01),f.clone()),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new t.Mesh(new t.BoxGeometry(.15,.15,.01),d.clone()),[.15,0,.15],[-Math.PI/2,0,0]]]},S={X:[[new t.Mesh(new t.CylinderGeometry(.2,0,.6,4),s),[.3,0,0],[0,0,-Math.PI/2]],[new t.Mesh(new t.CylinderGeometry(.2,0,.6,4),s),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new t.Mesh(new t.CylinderGeometry(.2,0,.6,4),s),[0,.3,0]],[new t.Mesh(new t.CylinderGeometry(.2,0,.6,4),s),[0,-.3,0],[0,0,Math.PI]]],Z:[[new t.Mesh(new t.CylinderGeometry(.2,0,.6,4),s),[0,0,.3],[Math.PI/2,0,0]],[new t.Mesh(new t.CylinderGeometry(.2,0,.6,4),s),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new t.Mesh(new t.OctahedronGeometry(.2,0),s)]],XY:[[new t.Mesh(new t.BoxGeometry(.2,.2,.01),s),[.15,.15,0]]],YZ:[[new t.Mesh(new t.BoxGeometry(.2,.2,.01),s),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new t.Mesh(new t.BoxGeometry(.2,.2,.01),s),[.15,0,.15],[-Math.PI/2,0,0]]]},E={START:[[new t.Mesh(new t.OctahedronGeometry(.01,2),u),null,null,null,"helper"]],END:[[new t.Mesh(new t.OctahedronGeometry(.01,2),u),null,null,null,"helper"]],DELTA:[[new t.Line((x=new t.BufferGeometry,x.setAttribute("position",new t.Float32BufferAttribute([0,0,0,1,1,1],3)),x),u),null,null,null,"helper"]],X:[[new t.Line(b,u.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new t.Line(b,u.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new t.Line(b,u.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},A={XYZE:[[new t.Mesh(M(.5,1),m),null,[0,Math.PI/2,0]]],X:[[new t.Mesh(M(.5,.5),h)]],Y:[[new t.Mesh(M(.5,.5),c),null,[0,0,-Math.PI/2]]],Z:[[new t.Mesh(M(.5,.5),l),null,[0,Math.PI/2,0]]],E:[[new t.Mesh(M(.75,1),w),null,[0,Math.PI/2,0]]]},_={AXIS:[[new t.Line(b,u.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},O={XYZE:[[new t.Mesh(new t.SphereGeometry(.25,10,8),s)]],X:[[new t.Mesh(new t.TorusGeometry(.5,.1,4,24),s),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new t.Mesh(new t.TorusGeometry(.5,.1,4,24),s),[0,0,0],[Math.PI/2,0,0]]],Z:[[new t.Mesh(new t.TorusGeometry(.5,.1,4,24),s),[0,0,0],[0,0,-Math.PI/2]]],E:[[new t.Mesh(new t.TorusGeometry(.75,.1,2,24),s)]]},C={X:[[new t.Mesh(g,h),[.5,0,0],[0,0,-Math.PI/2]],[new t.Mesh(k,h),[0,0,0],[0,0,-Math.PI/2]],[new t.Mesh(g,h),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new t.Mesh(g,c),[0,.5,0]],[new t.Mesh(k,c)],[new t.Mesh(g,c),[0,-.5,0],[0,0,Math.PI]]],Z:[[new t.Mesh(g,l),[0,0,.5],[Math.PI/2,0,0]],[new t.Mesh(k,l),[0,0,0],[Math.PI/2,0,0]],[new t.Mesh(g,l),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new t.Mesh(new t.BoxGeometry(.15,.15,.01),v),[.15,.15,0]]],YZ:[[new t.Mesh(new t.BoxGeometry(.15,.15,.01),f),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new t.Mesh(new t.BoxGeometry(.15,.15,.01),d),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new t.Mesh(new t.BoxGeometry(.1,.1,.1),p.clone())]]},R={X:[[new t.Mesh(new t.CylinderGeometry(.2,0,.6,4),s),[.3,0,0],[0,0,-Math.PI/2]],[new t.Mesh(new t.CylinderGeometry(.2,0,.6,4),s),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new t.Mesh(new t.CylinderGeometry(.2,0,.6,4),s),[0,.3,0]],[new t.Mesh(new t.CylinderGeometry(.2,0,.6,4),s),[0,-.3,0],[0,0,Math.PI]]],Z:[[new t.Mesh(new t.CylinderGeometry(.2,0,.6,4),s),[0,0,.3],[Math.PI/2,0,0]],[new t.Mesh(new t.CylinderGeometry(.2,0,.6,4),s),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new t.Mesh(new t.BoxGeometry(.2,.2,.01),s),[.15,.15,0]]],YZ:[[new t.Mesh(new t.BoxGeometry(.2,.2,.01),s),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new t.Mesh(new t.BoxGeometry(.2,.2,.01),s),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new t.Mesh(new t.BoxGeometry(.2,.2,.2),s),[0,0,0]]]},P={X:[[new t.Line(b,u.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new t.Line(b,u.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new t.Line(b,u.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function j(e){var n=new t.Object3D;for(var i in e)for(var r=e[i].length;r--;){var s=e[i][r][0].clone(),o=e[i][r][1],a=e[i][r][2],u=e[i][r][3],h=e[i][r][4];s.name=i,s.tag=h,o&&s.position.set(o[0],o[1],o[2]),a&&s.rotation.set(a[0],a[1],a[2]),u&&s.scale.set(u[0],u[1],u[2]),s.updateMatrix();var c=s.geometry.clone();c.applyMatrix4(s.matrix),s.geometry=c,s.renderOrder=1/0,s.position.set(0,0,0),s.rotation.set(0,0,0),s.scale.set(1,1,1),n.add(s)}return n}return n.gizmo={},n.picker={},n.helper={},n.add(n.gizmo.translate=j(T)),n.add(n.gizmo.rotate=j(A)),n.add(n.gizmo.scale=j(C)),n.add(n.picker.translate=j(S)),n.add(n.picker.rotate=j(O)),n.add(n.picker.scale=j(R)),n.add(n.helper.translate=j(E)),n.add(n.helper.rotate=j(_)),n.add(n.helper.scale=j(P)),n.picker.translate.visible=!1,n.picker.rotate.visible=!1,n.picker.scale.visible=!1,n}return p(e,t.Object3D),c(e,[{key:"updateMatrixWorld",value:function(t){var n=this,i="local"===("scale"===this.mode?"local":this.space)?this.worldQuaternion:$;this.gizmo.translate.visible="translate"===this.mode,this.gizmo.rotate.visible="rotate"===this.mode,this.gizmo.scale.visible="scale"===this.mode,this.helper.translate.visible="translate"===this.mode,this.helper.rotate.visible="rotate"===this.mode,this.helper.scale.visible="scale"===this.mode;var r=[];r=(r=(r=r.concat(this.picker[this.mode].children)).concat(this.gizmo[this.mode].children)).concat(this.helper[this.mode].children);for(var s=function(){var t,e=r[o];if(e.visible=!0,e.rotation.set(0,0,0),e.position.copy(n.worldPosition),t=n.camera.isOrthographicCamera?(n.camera.top-n.camera.bottom)/n.camera.zoom:n.worldPosition.distanceTo(n.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*n.camera.fov/360)/n.camera.zoom,7),e.scale.set(1,1,1).multiplyScalar(t*n.size/4),"helper"===e.tag)return e.visible=!1,"AXIS"===e.name?(e.visible=!!n.axis,"X"===n.axis&&(P.setFromEuler(V.set(0,0,0)),e.quaternion.copy(i).multiply(P),Math.abs(Y.copy(Q).applyQuaternion(i).dot(n.eye))>.9&&(e.visible=!1)),"Y"===n.axis&&(P.setFromEuler(V.set(0,0,Math.PI/2)),e.quaternion.copy(i).multiply(P),Math.abs(Y.copy(tt).applyQuaternion(i).dot(n.eye))>.9&&(e.visible=!1)),"Z"===n.axis&&(P.setFromEuler(V.set(0,Math.PI/2,0)),e.quaternion.copy(i).multiply(P),Math.abs(Y.copy(et).applyQuaternion(i).dot(n.eye))>.9&&(e.visible=!1)),"XYZE"===n.axis&&(P.setFromEuler(V.set(0,Math.PI/2,0)),Y.copy(n.rotationAxis),e.quaternion.setFromRotationMatrix(Z.lookAt(K,Y,tt)),e.quaternion.multiply(P),e.visible=n.dragging),"E"===n.axis&&(e.visible=!1)):"START"===e.name?(e.position.copy(n.worldPositionStart),e.visible=n.dragging):"END"===e.name?(e.position.copy(n.worldPosition),e.visible=n.dragging):"DELTA"===e.name?(e.position.copy(n.worldPositionStart),e.quaternion.copy(n.worldQuaternionStart),C.set(1e-10,1e-10,1e-10).add(n.worldPositionStart).sub(n.worldPosition).multiplyScalar(-1),C.applyQuaternion(n.worldQuaternionStart.clone().invert()),e.scale.copy(C),e.visible=n.dragging):(e.quaternion.copy(i),n.dragging?e.position.copy(n.worldPositionStart):e.position.copy(n.worldPosition),n.axis&&(e.visible=-1!==n.axis.search(e.name))),1;if(e.quaternion.copy(i),"translate"===n.mode||"scale"===n.mode){var s=.99;"X"===e.name&&Math.abs(Y.copy(Q).applyQuaternion(i).dot(n.eye))>s&&(e.scale.set(1e-10,1e-10,1e-10),e.visible=!1),"Y"===e.name&&Math.abs(Y.copy(tt).applyQuaternion(i).dot(n.eye))>s&&(e.scale.set(1e-10,1e-10,1e-10),e.visible=!1),"Z"===e.name&&Math.abs(Y.copy(et).applyQuaternion(i).dot(n.eye))>s&&(e.scale.set(1e-10,1e-10,1e-10),e.visible=!1),"XY"===e.name&&Math.abs(Y.copy(et).applyQuaternion(i).dot(n.eye))<.2&&(e.scale.set(1e-10,1e-10,1e-10),e.visible=!1),"YZ"===e.name&&Math.abs(Y.copy(Q).applyQuaternion(i).dot(n.eye))<.2&&(e.scale.set(1e-10,1e-10,1e-10),e.visible=!1),"XZ"===e.name&&Math.abs(Y.copy(tt).applyQuaternion(i).dot(n.eye))<.2&&(e.scale.set(1e-10,1e-10,1e-10),e.visible=!1)}else"rotate"===n.mode&&(W.copy(i),Y.copy(n.eye).applyQuaternion(P.copy(i).invert()),-1!==e.name.search("E")&&e.quaternion.setFromRotationMatrix(Z.lookAt(n.eye,K,tt)),"X"===e.name&&(P.setFromAxisAngle(Q,Math.atan2(-Y.y,Y.z)),P.multiplyQuaternions(W,P),e.quaternion.copy(P)),"Y"===e.name&&(P.setFromAxisAngle(tt,Math.atan2(Y.x,Y.z)),P.multiplyQuaternions(W,P),e.quaternion.copy(P)),"Z"===e.name&&(P.setFromAxisAngle(et,Math.atan2(Y.y,Y.x)),P.multiplyQuaternions(W,P),e.quaternion.copy(P)));e.visible=e.visible&&(-1===e.name.indexOf("X")||n.showX),e.visible=e.visible&&(-1===e.name.indexOf("Y")||n.showY),e.visible=e.visible&&(-1===e.name.indexOf("Z")||n.showZ),e.visible=e.visible&&(-1===e.name.indexOf("E")||n.showX&&n.showY&&n.showZ),e.visible=e.visible&&("XY"!==e.name||n.showXY),e.visible=e.visible&&("YZ"!==e.name||n.showYZ),e.visible=e.visible&&("XZ"!==e.name||n.showXZ),e.material.U=e.material.U||e.material.color.clone(),e.material.H=e.material.H||e.material.opacity,e.material.color.copy(e.material.U),e.material.opacity=e.material.H,n.enabled&&n.axis&&(e.name===n.axis||n.axis.split("").some(function(t){return e.name===t}))&&(e.material.color.setHex(16776960),e.material.opacity=1)},o=0;o<r.length;o++)s();T(e,"updateMatrixWorld",this,3)([t])}}])}(),ot=function(){function e(){var n;return a(this,e),(n=o(this,e,[new t.PlaneGeometry(1e5,1e5,2,2),new t.MeshBasicMaterial({visible:!1,wireframe:!0,side:t.DoubleSide,transparent:!0,opacity:.1,toneMapped:!1})])).isTransformControlsPlane=!0,n.type="TransformControlsPlane",n}return p(e,t.Mesh),c(e,[{key:"updateMatrixWorld",value:function(t){var n=this.space;switch(this.position.copy(this.worldPosition),"scale"===this.mode&&(n="local"),nt.copy(Q).applyQuaternion("local"===n?this.worldQuaternion:$),it.copy(tt).applyQuaternion("local"===n?this.worldQuaternion:$),rt.copy(et).applyQuaternion("local"===n?this.worldQuaternion:$),Y.copy(it),this.mode){case"translate":case"scale":switch(this.axis){case"X":Y.copy(this.eye).cross(nt),J.copy(nt).cross(Y);break;case"Y":Y.copy(this.eye).cross(it),J.copy(it).cross(Y);break;case"Z":Y.copy(this.eye).cross(rt),J.copy(rt).cross(Y);break;case"XY":J.copy(rt);break;case"YZ":J.copy(nt);break;case"XZ":Y.copy(rt),J.copy(it);break;case"XYZ":case"E":J.set(0,0,0)}break;default:J.set(0,0,0)}0===J.length()?this.quaternion.copy(this.cameraQuaternion):(q.lookAt(C.set(0,0,0),J,Y),this.quaternion.setFromRotationMatrix(q)),T(e,"updateMatrixWorld",this,3)([t])}}])}(),at=function(){return c(function t(e,n,i){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;a(this,t),this.scene=e,this.camera=n,this.renderer=i,this.orbitControls=r,this.transformControls=null,this.boundingBoxHelper=null,this.boundingBoxCache=new WeakMap,this.selectedObject=null,this.currentMode="translate",this.currentSpace="world",this.forceInvisible=!1,this.eventHandlers={keydown:null,click:null,transformStart:null,transformEnd:null,transforming:null},this.clickTiming={lastClickTime:0,lastClickedObject:null,doubleClickDelay:300},this.transformState={isTransforming:!1,initialTransform:null,currentTransform:null},this.config={size:1,enabled:!0,showX:!0,showY:!0,showZ:!0,snap:null,translationSnap:null,rotationSnap:null,scaleSnap:null,showBoundingBox:!0,boundingBoxColor:65280,useBoundingBoxSelection:!0},this.callbacks={onObjectSelect:null,onTransformStart:null,onTransform:null,onTransformEnd:null,onModeChange:null,onObjectRemoved:null},this.init()},[{key:"init",value:function(){this.createTransformControls(),this.setupEventListeners(),this.setupKeyboardControls()}},{key:"on",value:function(t){t.onObjectSelect&&(this.callbacks.onObjectSelect=t.onObjectSelect),t.onTransformStart&&(this.callbacks.onTransformStart=t.onTransformStart),t.onTransform&&(this.callbacks.onTransform=t.onTransform),t.onTransformEnd&&(this.callbacks.onTransformEnd=t.onTransformEnd),t.onModeChange&&(this.callbacks.onModeChange=t.onModeChange),t.onObjectRemoved&&(this.callbacks.onObjectRemoved=t.onObjectRemoved)}},{key:"createTransformControls",value:function(){this.transformControls=new B(this.camera,this.renderer.domElement),this.transformControls.setMode(this.currentMode),this.transformControls.setSpace(this.currentSpace),this.transformControls.setSize(this.config.size),this.transformControls.setDelay(this.clickTiming),this.transformControls.showX=this.config.showX,this.transformControls.showY=this.config.showY,this.transformControls.showZ=this.config.showZ,this.transformControls.showXY=!1,this.transformControls.showYZ=!1,this.transformControls.showXZ=!1,this.transformControls.isTransformControls=!0,this.transformControls.userData={isTransformControls:!0},this.scene.add(this.transformControls),this.transformControls.enabled=!1,this.G()}},{key:"setupEventListeners",value:function(){var t=this;this.eventHandlers.transformStart=function(){t.transformState.isTransforming=!0,t.selectedObject&&(t.transformState.initialTransform={position:t.selectedObject.position.clone(),rotation:t.selectedObject.rotation.clone(),scale:t.selectedObject.scale.clone()}),t.orbitControls&&(t.orbitControls.enabled=!1),t.callbacks.onTransformStart&&t.callbacks.onTransformStart(t.selectedObject,t.currentMode)},this.eventHandlers.transformEnd=function(){if(t.transformState.isTransforming=!1,t.orbitControls&&(t.orbitControls.enabled=!0),t.selectedObject&&(t.transformState.currentTransform={position:t.selectedObject.position.clone(),rotation:t.selectedObject.rotation.clone(),scale:t.selectedObject.scale.clone()},t.boundingBoxCache.has(t.selectedObject)&&t.boundingBoxCache.delete(t.selectedObject)),t.callbacks.onTransformEnd&&t.callbacks.onTransformEnd(t.selectedObject,t.transformState.initialTransform,t.transformState.currentTransform,t.currentMode),"undefined"!=typeof window){var e,n=new CustomEvent("sceneUpdateComplete",{detail:{timestamp:Date.now(),transformType:t.currentMode,objectName:(null===(e=t.selectedObject)||void 0===e?void 0:e.name)||"unknown"}});window.dispatchEvent(n)}},this.eventHandlers.transforming=function(){if(t.selectedObject&&t.boundingBoxCache.has(t.selectedObject)&&t.boundingBoxCache.delete(t.selectedObject),t.updateBoundingBox(),t.callbacks.onTransform&&t.callbacks.onTransform(t.selectedObject,t.currentMode),"undefined"!=typeof window){var e,n=new CustomEvent("sceneUpdateComplete",{detail:{timestamp:Date.now(),transformType:t.currentMode,objectName:(null===(e=t.selectedObject)||void 0===e?void 0:e.name)||"unknown",isTransforming:!0}});window.dispatchEvent(n)}},this.transformControls&&(this.eventHandlers.transformStart&&this.transformControls.removeEventListener("mouseDown",this.eventHandlers.transformStart),this.eventHandlers.transformEnd&&this.transformControls.removeEventListener("mouseUp",this.eventHandlers.transformEnd),this.eventHandlers.transforming&&this.transformControls.removeEventListener("objectChange",this.eventHandlers.transforming),this.transformControls.addEventListener("mouseDown",this.eventHandlers.transformStart),this.transformControls.addEventListener("mouseUp",this.eventHandlers.transformEnd),this.transformControls.addEventListener("objectChange",this.eventHandlers.transforming))}},{key:"setupKeyboardControls",value:function(){var t=this;this.eventHandlers.keydown=function(e){if(t.transformControls.enabled&&!t.transformState.isTransforming&&(!e.ctrlKey||"KeyZ"!==e.code))switch(e.code){case"KeyG":t.setMode("translate");break;case"KeyR":t.setMode("rotate");break;case"KeyS":t.setMode("scale");break;case"KeyW":t.setSpace("world");break;case"KeyL":t.setSpace("local");break;case"Escape":t.deselectObject();break;case"KeyX":t.setAxisConstraint("X");break;case"KeyY":t.setAxisConstraint("Y");break;case"KeyZ":e.ctrlKey||t.setAxisConstraint("Z");break;case"ShiftLeft":case"ShiftRight":t.clearAxisConstraint();break;case"Backspace":t.handleObjectRemoval()}},window.addEventListener("keydown",this.eventHandlers.keydown)}},{key:"setupObjectSelection",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,i=new n.Raycaster,r=new n.Vector2;this.eventHandlers.click=function(n){if(!t.transformState.isTransforming){var s=Date.now(),o=s-t.clickTiming.lastClickTime;t.V(n,r),i.setFromCamera(r,t.camera);var a=t.K(i,e),u=a===t.clickTiming.lastClickedObject,h=o<t.clickTiming.doubleClickDelay;u&&h&&null!==a?(t.selectObject(a),t.clickTiming.lastClickTime=0,t.clickTiming.lastClickedObject=null):(t.deselectObject(),a&&t.selectObjectForTransformOnly(a),t.clickTiming.lastClickTime=s,t.clickTiming.lastClickedObject=a)}},this.renderer.domElement.addEventListener("click",this.eventHandlers.click)}},{key:"_calculateMousePosition",value:function(t,e){var n=this.renderer.domElement.getBoundingClientRect();e.x=(t.clientX-n.left)/n.width*2-1,e.y=-(t.clientY-n.top)/n.height*2+1}},{key:"_findTargetObject",value:function(t,e){if(this.config.useBoundingBoxSelection){var n=this.W(t,e);if(n)return n}return this.$(t,e)}},{key:"_findTargetViaBoundingBox",value:function(t,e){var n=this.intersectObjectsBoundingBoxes(t,e);if(n.length>0){var i=n[0].object;if(this.J(i))return i}return null}},{key:"_findTargetViaMesh",value:function(t,e){var n=t.intersectObjects(this.scene.children,!0);if(n.length>0){var i=n[0].object;if(i=this.q(i),(e?e(i):this.isSelectableObject(i))&&this.J(i)){this.config.useBoundingBoxSelection;return i}}return null}},{key:"_resolveHierarchyTarget",value:function(t){var e,n,i;return this.isConnectorOrb(t)?t:null!==(e=t.parent)&&void 0!==e&&null!==(e=e.name)&&void 0!==e&&e.includes(" Component")?t.parent:null!==(n=t.parent)&&void 0!==n&&null!==(n=n.parent)&&void 0!==n&&null!==(n=n.name)&&void 0!==n&&n.includes(" Component")?t.parent.parent:(null!==(i=t.userData)&&void 0!==i&&i.isPipeSegment,t)}},{key:"_isValidSelectableObject",value:function(t){return!(!t||!t.parent)&&!!(t.position&&t.rotation&&t.scale&&t.updateMatrixWorld)}},{key:"isConnectorOrb",value:function(t){if(!t||!t.isObject3D)return!1;if(!t.isMesh||!t.geometry)return!1;var e="CONNECTOR-GEO"===t.geometry.uuid,n="SphereGeometry"===t.geometry.type&&t.geometry.parameters&&.2===t.geometry.parameters.radius,i=t.name&&t.name.toLowerCase().includes("connector");return(e||n)&&i}},{key:"isSelectableObject",value:function(t){var e,n,i,r,s,o,a,u;if(!t||!t.isObject3D)return!1;if(t.userData&&t.userData.isPipeSegment,t.isTransformControls||t.isTransformControlsPlane||t.isTransformControlsGizmo)return!1;var h=t.isHelper||(null===(e=t.userData)||void 0===e?void 0:e.isHelper)||(null===(n=t.userData)||void 0===n?void 0:n.isBoundingBox),c=null===(i=t.userData)||void 0===i?void 0:i.isBaseGround,l=null===(r=t.userData)||void 0===r?void 0:r.isBrickWall;if(h||c||l||!t.visible)return!1;if(t.name&&t.name.toLowerCase().includes("polyline")&&(null===(s=t.userData)||void 0===s||!s.isPipeSegment)&&(null===(o=t.userData)||void 0===o||!o.isPipeJunction))return!1;var f=!0===(null===(a=t.userData)||void 0===a?void 0:a.isPipeSegment),d=!0===(null===(u=t.userData)||void 0===u?void 0:u.isPipeJunction),v=t.name&&t.name.includes(" Component"),p=this.isConnectorOrb(t);return v||p||f||d}},{key:"selectObject",value:function(t){if(!t||!t.isObject3D)return!1;this.selectedObject=t,t.updateMatrixWorld(!0);var e=(new n.Box3).setFromObject(t);return this.boundingBoxCache.set(t,e),this.transformControls.attach(t),this.transformControls.updateInteractionTime&&this.transformControls.updateInteractionTime(),this.createBoundingBox(t),this.forceInvisible?(this.transformControls.enabled=!1,this.G()):(this.transformControls.enabled=this.config.enabled,this.tt()),this.callbacks.onObjectSelect&&this.callbacks.onObjectSelect(t),!0}},{key:"selectObjectForTransformOnly",value:function(t){if(!t||!t.isObject3D)return!1;this.selectedObject=t,t.updateMatrixWorld(!0);var e=(new n.Box3).setFromObject(t);return this.boundingBoxCache.set(t,e),this.transformControls.attach(t),this.transformControls.updateInteractionTime&&this.transformControls.updateInteractionTime(),this.createBoundingBox(t),this.forceInvisible?(this.transformControls.enabled=!1,this.G()):(this.transformControls.enabled=!0,this.tt()),!0}},{key:"deselectObject",value:function(){this.selectedObject,this.removeBoundingBox(),this.selectedObject=null,this.transformControls&&(this.transformControls.detach(),this.transformControls.enabled=!1,this.G()),this.callbacks.onObjectSelect&&this.callbacks.onObjectSelect(null)}},{key:"createBoundingBox",value:function(t){if(this.config.showBoundingBox&&(this.removeBoundingBox(),t))try{this.boundingBoxHelper=new n.BoxHelper(t,this.config.boundingBoxColor),this.boundingBoxHelper.isHelper=!0,this.boundingBoxHelper.userData={isBoundingBox:!0},this.scene.add(this.boundingBoxHelper)}catch(t){}}},{key:"removeBoundingBox",value:function(){if(this.boundingBoxHelper)try{this.boundingBoxHelper.parent&&this.boundingBoxHelper.parent.remove(this.boundingBoxHelper),this.boundingBoxHelper.geometry&&this.boundingBoxHelper.geometry.dispose(),this.boundingBoxHelper.material&&this.boundingBoxHelper.material.dispose()}catch(t){}finally{this.boundingBoxHelper=null}}},{key:"updateBoundingBox",value:function(){if(this.boundingBoxHelper&&this.selectedObject)try{if(this.selectedObject.updateMatrixWorld(!0),this.boundingBoxHelper.update(),this.boundingBoxCache.has(this.selectedObject)){var t=(new n.Box3).setFromObject(this.selectedObject);this.boundingBoxCache.set(this.selectedObject,t)}}catch(t){this.createBoundingBox(this.selectedObject)}}},{key:"setBoundingBoxVisibility",value:function(t){this.config.showBoundingBox=t,t&&this.selectedObject&&!this.boundingBoxHelper?this.createBoundingBox(this.selectedObject):!t&&this.boundingBoxHelper&&this.removeBoundingBox()}},{key:"setBoundingBoxColor",value:function(t){this.config.boundingBoxColor=t,this.boundingBoxHelper&&this.boundingBoxHelper.material&&this.boundingBoxHelper.material.color.setHex(t)}},{key:"setMode",value:function(t){if(["translate","rotate","scale"].includes(t)){var e=this.currentMode;this.currentMode=t,this.transformControls.setMode(t),this.callbacks.onModeChange&&this.callbacks.onModeChange(t,e)}}},{key:"setSpace",value:function(t){if(["world","local"].includes(t)){this.currentSpace;this.currentSpace=t,this.transformControls.setSpace(t)}}},{key:"setAxisConstraint",value:function(t){["X","Y","Z"].includes(t)&&(this.transformControls.showX=!1,this.transformControls.showY=!1,this.transformControls.showZ=!1,this.transformControls["show".concat(t)]=!0)}},{key:"clearAxisConstraint",value:function(){this.transformControls.showX=this.config.showX,this.transformControls.showY=this.config.showY,this.transformControls.showZ=this.config.showZ}},{key:"setSnap",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};void 0!==t.translation&&(this.config.translationSnap=t.translation,this.transformControls.setTranslationSnap(t.translation)),void 0!==t.rotation&&(this.config.rotationSnap=t.rotation,this.transformControls.setRotationSnap(t.rotation)),void 0!==t.scale&&(this.config.scaleSnap=t.scale,this.transformControls.setScaleSnap(t.scale))}},{key:"snapValues",get:function(){return{translation:this.config.translationSnap||.5,rotation:this.config.rotationSnap||Math.PI/2,scale:this.config.scaleSnap||.1}}},{key:"setSize",value:function(t){this.config.size=t,this.transformControls.setSize(t)}},{key:"setEnabled",value:function(t){this.config.enabled=t,this.selectedObject&&(this.transformControls.enabled=t)}},{key:"setShowPlanes",value:function(t){return!!this.transformControls&&(this.transformControls.showXY=t,this.transformControls.showYZ=t,this.transformControls.showXZ=t,!0)}},{key:"ensureSceneAttachment",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return!this.transformControls&&this.scene&&this.camera&&this.renderer?(this.createTransformControls(),this.setupEventListeners(),t||(this.transformControls.visible=!1),!0):!(!this.transformControls||!this.scene)&&(this.scene.children.includes(this.transformControls)?!this.transformControls.visible&&t?(this.transformControls.visible=!0,!0):this.transformControls.visible&&!t?(this.transformControls.visible=!1,!0):!(!this.transformControls.parent||this.transformControls.parent===this.scene)&&(this.transformControls.parent.remove(this.transformControls),this.scene.add(this.transformControls),!0):(this.scene.add(this.transformControls),this.transformControls.enabled=!1,this.selectedObject&&(this.transformControls.attach(this.selectedObject),this.transformControls.enabled=this.config.enabled),t||(this.transformControls.visible=!1),!0))}},{key:"getTransformData",value:function(){if(!this.selectedObject)return null;var t={position:this.selectedObject.position.clone(),rotation:this.selectedObject.rotation.clone(),scale:this.selectedObject.scale.clone()},e=this.getWorldTransformData();return{object:this.selectedObject,position:t.position,rotation:t.rotation,scale:t.scale,worldPosition:e.position,worldRotation:e.rotation,worldScale:e.scale,mode:this.currentMode,space:this.currentSpace,isTransforming:this.transformState.isTransforming}}},{key:"getWorldTransformData",value:function(){if(!this.selectedObject)return null;this.selectedObject.updateMatrixWorld(!0);var t=new n.Vector3;this.selectedObject.getWorldPosition(t);var e=new n.Quaternion;this.selectedObject.getWorldQuaternion(e);var i=new n.Euler;i.setFromQuaternion(e);var r=new n.Vector3;return this.selectedObject.getWorldScale(r),{position:t,rotation:i,scale:r}}},{key:"updateObjectTransform",value:function(t,e,n){var i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(this.selectedObject){var r=this.selectedObject,s=parseFloat(n);if(!isNaN(s)){if(i)this.updateWorldTransform(r,t,e,s);else switch(t){case"position":r.position[e]=s;break;case"rotation":r.rotation[e]=s*(Math.PI/180);break;case"scale":r.scale[e]=s;break;default:return}this.transformControls&&this.transformControls.updateMatrixWorld(),this.updateBoundingBox()}}}},{key:"updateWorldTransform",value:function(t,e,n,i){switch(t.updateMatrixWorld(!0),e){case"position":this.setWorldPosition(t,n,i);break;case"rotation":this.setWorldRotation(t,n,i);break;case"scale":this.setWorldScale(t,n,i)}}},{key:"setWorldPosition",value:function(t,e,i){var r=new n.Vector3;if(t.getWorldPosition(r),r[e]=i,t.parent){var s=new n.Matrix4;s.copy(t.parent.matrixWorld).invert(),r.applyMatrix4(s)}t.position.copy(r)}},{key:"setWorldRotation",value:function(t,e,i){var r=new n.Quaternion;t.getWorldQuaternion(r);var s=new n.Euler;s.setFromQuaternion(r),s[e]=i*(Math.PI/180);var o=new n.Quaternion;if(o.setFromEuler(s),t.parent){var a=new n.Quaternion;t.parent.getWorldQuaternion(a),a.invert(),o.premultiply(a)}t.quaternion.copy(o)}},{key:"setWorldScale",value:function(t,e,i){var r=new n.Vector3;t.getWorldScale(r);var s=i/r[e];t.scale[e]*=s}},{key:"getSelectableObjectsWithBounds",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,i=[];return this.scene.traverse(function(r){var s,o;if(r&&r.isObject3D&&!(r.isTransformControls||r.isTransformControlsPlane||r.isTransformControlsGizmo||r.isHelper||null!==(s=r.userData)&&void 0!==s&&s.isHelper||null!==(o=r.userData)&&void 0!==o&&o.isBoundingBox))try{if(e?e(r):t.isSelectableObject(r)){r.updateMatrixWorld(!0);var a=t.boundingBoxCache.get(r);a&&r!==t.selectedObject||(a=(new n.Box3).setFromObject(r),t.boundingBoxCache.set(r,a)),i.push({object:r,boundingBox:a})}}catch(t){}}),i}},{key:"intersectObjectsBoundingBoxes",value:function(t){var e,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=[],s=l(this.getSelectableObjectsWithBounds(i));try{for(s.s();!(e=s.n()).done;){var o=e.value,a=o.object,u=o.boundingBox,h=t.ray.intersectBox(u,new n.Vector3);if(h){var c=t.ray.origin.distanceTo(h);r.push({object:a,point:h,distance:c,boundingBox:u})}}}catch(t){s.e(t)}finally{s.f()}return r.sort(function(t,e){return t.distance-e.distance}),r}},{key:"setBoundingBoxSelection",value:function(t){this.config.useBoundingBoxSelection=t}},{key:"handleObjectRemoval",value:function(){var t;this.selectedObject&&"gateway"===(null===(t=this.selectedObject.userData)||void 0===t?void 0:t.componentType)&&this.handleGatewayRemoval()}},{key:"handleGatewayRemoval",value:function(){var t,e=this.selectedObject,n={uuid:e.uuid,userData:y({},e.userData),position:e.position.clone(),connections:(null===(t=e.userData)||void 0===t?void 0:t.connections)||null};e.userData.origin="computed",this.deselectObject(),this.callbacks.onObjectRemoved&&this.callbacks.onObjectRemoved(n)}},{key:"dispose",value:function(){this.eventHandlers.keydown&&window.removeEventListener("keydown",this.eventHandlers.keydown),this.eventHandlers.click&&this.renderer.domElement.removeEventListener("click",this.eventHandlers.click),this.removeBoundingBox(),this.selectedObject&&this.deselectObject(),this.transformControls&&(this.eventHandlers.transformStart&&this.transformControls.removeEventListener("mouseDown",this.eventHandlers.transformStart),this.eventHandlers.transformEnd&&this.transformControls.removeEventListener("mouseUp",this.eventHandlers.transformEnd),this.eventHandlers.transforming&&this.transformControls.removeEventListener("objectChange",this.eventHandlers.transforming),this.transformControls.detach(),this.scene&&this.transformControls.parent===this.scene&&this.scene.remove(this.transformControls),this.transformControls.dispose(),this.transformControls=null),this.selectedObject=null,this.orbitControls=null}},{key:"forceHide",value:function(){this.transformControls&&(this.G(),this.transformControls.enabled=!1)}},{key:"_hideTransformControls",value:function(){this.transformControls&&(this.transformControls.visible=!1,this.transformControls.o&&(this.transformControls.o.visible=!1),this.transformControls.u&&(this.transformControls.u.visible=!1))}},{key:"_showTransformControls",value:function(){this.transformControls&&(this.transformControls.visible=!0,this.transformControls.o&&(this.transformControls.o.visible=!0),this.transformControls.u&&(this.transformControls.u.visible=!0))}},{key:"getVisibilityState",value:function(){var t;return this.transformControls?{exists:!0,visible:this.transformControls.visible,enabled:this.transformControls.enabled,gizmoVisible:this.transformControls.o?this.transformControls.o.visible:"N/A",planeVisible:this.transformControls.u?this.transformControls.u.visible:"N/A",hasSelectedObject:!!this.selectedObject,selectedObjectName:(null===(t=this.selectedObject)||void 0===t?void 0:t.name)||"none"}:{exists:!1}}},{key:"_forceHideAllGizmoComponents",value:function(){if(this.transformControls&&this.transformControls.o){var t=this.transformControls.o;t.visible=!1,t.gizmo&&Object.keys(t.gizmo).forEach(function(e){t.gizmo[e]&&(t.gizmo[e].visible=!1)}),t.helper&&Object.keys(t.helper).forEach(function(e){t.helper[e]&&(t.helper[e].visible=!1)}),this.transformControls.u&&(this.transformControls.u.visible=!1)}}},{key:"_hidePlaneHelpers",value:function(){if(this.transformControls&&this.transformControls.o){var t=this.transformControls.o;if(t.gizmo&&t.gizmo.translate)t.gizmo.translate.traverse(function(t){"XY"!==t.name&&"YZ"!==t.name&&"XZ"!==t.name||(t.visible=!1)});if(t.picker&&t.picker.translate)t.picker.translate.traverse(function(t){"XY"!==t.name&&"YZ"!==t.name&&"XZ"!==t.name||(t.visible=!1)})}}},{key:"_showPlaneHelpers",value:function(){if(this.transformControls&&this.transformControls.o){var t=this.transformControls.o;if(t.gizmo&&t.gizmo.translate)t.gizmo.translate.traverse(function(t){"XY"!==t.name&&"YZ"!==t.name&&"XZ"!==t.name||(t.visible=!0)});if(t.picker&&t.picker.translate)t.picker.translate.traverse(function(t){"XY"!==t.name&&"YZ"!==t.name&&"XZ"!==t.name||(t.visible=!0)})}}}])}();function ut(t,e,n){return new at(t,e,n,arguments.length>3&&void 0!==arguments[3]?arguments[3]:null)}var ht=function(){return c(function t(e){a(this,t),this.sceneViewer=e||null,this.isDev="development"===process.env.NODE_ENV,this.instanceId=Date.now()+Math.random(),this.hotReloadCleanupHandler=null,this.visibilityChangeHandler=null,this.nuxtHotReloadHandler=null,this.memoryCheckInterval=null,this.timeoutIds=new Set,this.intervalIds=new Set},[{key:"setupHotReloadHandling",value:function(){var t=this;if(this.sceneViewer&&this.isDev){window._sceneViewerInstances||(window._sceneViewerInstances=new Set);try{window._sceneViewerInstances.add(this.sceneViewer)}catch(t){}this.hotReloadCleanupHandler=function(){if(t.sceneViewer){if(t.sceneViewer&&t.sceneViewer.tooltipsManager)try{t.sceneViewer.tooltipsManager.dispose(),t.sceneViewer.tooltipsManager=null}catch(t){}try{"function"==typeof t.sceneViewer.enhancedDisposal&&t.sceneViewer.enhancedDisposal()}catch(t){}try{Promise.resolve().then(function(){return Ze}).then(function(t){var e=t.PerformanceUI;e&&"function"==typeof e.cleanupAllInstances&&e.cleanupAllInstances()}).catch(function(t){})}catch(t){}if(window._sceneViewerInstances)try{window._sceneViewerInstances.delete(t.sceneViewer)}catch(t){}}};try{window.addEventListener("beforeunload",this.hotReloadCleanupHandler),window.addEventListener("pagehide",this.hotReloadCleanupHandler)}catch(t){}}}},{key:"cleanupHotReloadHandlers",value:function(){if(this.isDev)try{this.hotReloadCleanupHandler&&(window.removeEventListener("beforeunload",this.hotReloadCleanupHandler),window.removeEventListener("pagehide",this.hotReloadCleanupHandler),this.hotReloadCleanupHandler=null),this.visibilityChangeHandler&&(document.removeEventListener("visibilitychange",this.visibilityChangeHandler),this.visibilityChangeHandler=null),this.nuxtHotReloadHandler&&window.$nuxt&&window.$nuxt.$off&&(window.$nuxt.$off("routeChanged",this.nuxtHotReloadHandler),window.$nuxt.$off("$nuxtReady",this.nuxtHotReloadHandler),this.nuxtHotReloadHandler=null),this.memoryCheckInterval&&(clearInterval(this.memoryCheckInterval),this.memoryCheckInterval=null);this.sceneViewer;if(window._sceneViewerInstances&&this.sceneViewer)try{window._sceneViewerInstances.delete(this.sceneViewer)}catch(t){}this.sceneViewer=null,window._sceneViewerInstances&&0===window._sceneViewerInstances.size&&delete window._sceneViewerInstances}catch(t){}}},{key:"clearPendingOperations",value:function(){this.timeoutIds&&(this.timeoutIds.forEach(function(t){return clearTimeout(t)}),this.timeoutIds.clear()),this.intervalIds&&(this.intervalIds.forEach(function(t){return clearInterval(t)}),this.intervalIds.clear()),this.isDev}},{key:"forceGarbageCollectionHint",value:function(){this.isDev&&setTimeout(function(){window.gc?window.gc():new Array(1e6).fill(0).length=0},100)}},{key:"addTimeout",value:function(t){this.timeoutIds.add(t)}},{key:"addInterval",value:function(t){this.intervalIds.add(t)}},{key:"removeTimeout",value:function(t){this.timeoutIds.delete(t)}},{key:"removeInterval",value:function(t){this.intervalIds.delete(t)}}])}(),ct=function(){return c(function t(e){a(this,t),this.sceneViewer=e,this.isDev="development"===process.env.NODE_ENV},[{key:"enhancedDisposal",value:(e=s(g().m(function t(){return g().w(function(t){for(;;)switch(t.n){case 0:return this.isDev,this.forceStopOperations(),t.n=1,this.enhancedSceneCleanup();case 1:this.enhancedRendererCleanup(),this.sceneViewer.hotReloadManager&&this.sceneViewer.hotReloadManager.clearPendingOperations(),this.isDev&&this.sceneViewer.hotReloadManager&&this.sceneViewer.hotReloadManager.forceGarbageCollectionHint();case 2:return t.a(2)}},t,this)})),function(){return e.apply(this,arguments)})},{key:"forceStopOperations",value:function(){this.sceneViewer.isDestroyed=!0,this.sceneViewer.isLoading=!1,this.sceneViewer.currentTransition=null,this.sceneViewer.animationId&&(cancelAnimationFrame(this.sceneViewer.animationId),this.sceneViewer.animationId=null),this.isDev}},{key:"enhancedSceneCleanup",value:(t=s(g().m(function t(){var e,n=this;return g().w(function(t){for(;;)switch(t.n){case 0:if(e={textures:0,materials:0,geometries:0,objects:0},this.sceneViewer.scene){for(this.sceneViewer.scene.traverse(function(t){t.material&&(Array.isArray(t.material)?t.material.forEach(function(t){e.textures+=n.disposeMaterialTextures(t),t.dispose(),e.materials++}):(e.textures+=n.disposeMaterialTextures(t.material),t.material.dispose(),e.materials++)),t.geometry&&(t.geometry.dispose(),e.geometries++),e.objects++});this.sceneViewer.scene.children.length>0;)this.sceneViewer.scene.remove(this.sceneViewer.scene.children[0]);this.isDev}case 1:return t.a(2)}},t,this)})),function(){return t.apply(this,arguments)})},{key:"disposeMaterialTextures",value:function(t){var e=0;return["map","normalMap","roughnessMap","metalnessMap","envMap","lightMap","bumpMap","specularMap"].forEach(function(n){t[n]&&(t[n].dispose(),e++)}),e}},{key:"enhancedRendererCleanup",value:function(){if(this.sceneViewer.renderer){var t=this.sceneViewer.renderer.getContext();if(t&&"function"==typeof t.getExtension){var e=t.getExtension("WEBGL_lose_context");e&&e.loseContext()}this.sceneViewer.renderer.dispose(),this.sceneViewer.renderer.forceContextLoss(),this.sceneViewer.renderer=null,this.isDev}}},{key:"cleanupScene",value:function(){var t=this;if(this.sceneViewer.scene){var e=[];this.sceneViewer.scene.traverse(function(t){e.push(t)});for(var n=function(){var n=e[i];n.geometry&&n.geometry.dispose(),n.material&&(Array.isArray(n.material)?n.material.forEach(function(e){return t.disposeMaterial(e)}):t.disposeMaterial(n.material));["map","lightMap","bumpMap","normalMap","specularMap","envMap"].forEach(function(t){n[t]&&n[t].dispose()}),n.parent&&n.parent.remove(n)},i=e.length-1;i>=0;i--)n();this.sceneViewer.scene.environment&&(this.sceneViewer.scene.environment.dispose(),this.sceneViewer.scene.environment=null),this.sceneViewer.scene.background&&this.sceneViewer.scene.background.dispose&&(this.sceneViewer.scene.background.dispose(),this.sceneViewer.scene.background=null),this.sceneViewer.scene.clear(),this.sceneViewer.scene=null}}},{key:"disposeMaterial",value:function(t){for(var e=0,n=Object.entries(t);e<n.length;e++){var i=x(n[e],2);i[0];var r=i[1];r&&"object"===A(r)&&"function"==typeof r.dispose&&r.dispose()}t.dispose()}},{key:"cleanupRenderer",value:function(){this.sceneViewer.renderer&&(this.sceneViewer.renderer.domElement&&this.sceneViewer.renderer.domElement.parentNode&&this.sceneViewer.renderer.domElement.parentNode.removeChild(this.sceneViewer.renderer.domElement),this.sceneViewer.renderer.dispose(),this.sceneViewer.renderer.forceContextLoss(),this.sceneViewer.renderer=null)}},{key:"cleanupControls",value:function(){this.sceneViewer.controls&&(this.sceneViewer.controls.dispose(),this.sceneViewer.controls=null)}},{key:"cleanupEventListeners",value:function(){this.sceneViewer.handleResize&&(window.removeEventListener("resize",this.sceneViewer.handleResize),this.sceneViewer.handleResize=null),this.sceneViewer.resizeObserver&&(this.sceneViewer.resizeObserver.disconnect(),this.sceneViewer.resizeObserver=null),this.sceneViewer.handleKeyDown&&(window.removeEventListener("keydown",this.sceneViewer.handleKeyDown),this.sceneViewer.handleKeyDown=null),window._performanceKeyHandler&&(window.removeEventListener("keydown",window._performanceKeyHandler),delete window._performanceKeyHandler)}},{key:"cleanupPerformanceMonitoring",value:function(){if(this.sceneViewer.performanceMonitor){try{this.sceneViewer.performanceMonitor.stop()}catch(t){}this.sceneViewer.performanceMonitor=null}if(this.sceneViewer.performanceUI){try{"function"==typeof this.sceneViewer.performanceUI.dispose?this.sceneViewer.performanceUI.dispose():this.sceneViewer.performanceUI.hide()}catch(t){}this.sceneViewer.performanceUI=null}try{var t=document.querySelectorAll("#performance-monitor-ui");t.length>0&&t.forEach(function(t){t.parentNode&&t.parentNode.removeChild(t)})}catch(t){}}},{key:"cleanupGlobalReferences",value:function(){var t=this.parent;if(t){if(t.tooltipsManager)try{t.tooltipsManager.dispose()}catch(t){}finally{t.tooltipsManager=null}t.hotReloadManager=null,t.sceneExportManager=null,t.componentManager=null,t.sceneInitializationManager=null,t.environmentManager=null,t.keyboardControlsManager=null,t.pathfindingManager=null,t.sceneOperationsManager=null,t.animationManager=null,t.cameraControlsManager=null,t.disposalManager=null}}},{key:"cleanupNuxtEventListeners",value:function(){window.$nuxt&&window.$nuxt.$off&&(window.$nuxt.$off("loadNewScene"),window.$nuxt.$off("createNewScene"))}}]);var t,e}();function lt(t){if(!t)return null;var e=t.toUpperCase().replace(/\s+COMPONENT$/i,"").replace(/\s+/g,"-").replace(/[^A-Z0-9\-]/g,"");return e=e.replace(/-COMPONENT$/,"")}function ft(t,e){if(!t||!e)return null;var n=null;return t.traverse(function(t){var i;if(!n)if(t.uuid!==e)if((null===(i=t.userData)||void 0===i?void 0:i.originalUuid)!==e){if(t.name&&lt(t.name)===e)return void(n=t)}else n=t;else n=t}),n}function dt(t){var e;return t?null!==(e=t.userData)&&void 0!==e&&e.originalUuid?t.userData.originalUuid:t.uuid&&!t.uuid.includes("-")&&t.uuid.length>10?t.uuid:t.name?lt(t.name):null:null}var vt=function(){return c(function t(e){a(this,t),this.sceneViewer=e},[{key:"exportSceneData",value:function(){var t=this;if(!this.sceneViewer.scene)return null;var e=function(t){var n,i,r,s,o,a,u,h,c=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!t||null!==(n=t.name)&&void 0!==n&&n.includes("Polyline")||null!==(i=t.userData)&&void 0!==i&&i.isBrickWall||null!==(r=t.userData)&&void 0!==r&&r.isBaseGround||null!==(s=t.userData)&&void 0!==s&&s.isBaseGrid||t.isLight||null!==(o=t.userData)&&void 0!==o&&o.isTransformControls||t.isTransformControls||t.type&&t.type.includes("TransformControls"))return null;if(!(c||null!==(a=t.userData)&&void 0!==a&&a.componentType))return null;if(c&&(null===(u=t.userData)||void 0===u||!u.forExport))return null;if(c&&null!==(h=t.userData)&&void 0!==h&&h.forExport);var l,f,d,v={uuid:dt(t),name:t.name||"Unnamed Object",type:t.type||"Object3D"};(t.userData&&Object.keys(t.userData).length>0&&(v.userData={},Object.keys(t.userData).forEach(function(e){"worldBoundingBox"!==e&&"isBaseGround"!==e&&"isBrickWall"!==e&&"isBaseGrid"!==e&&"isTransformControls"!==e&&(v.userData[e]=t.userData[e])}),t.userData.dimensions&&(v.userData.dimensions=t.userData.dimensions),0===Object.keys(v.userData).length&&delete v.userData),v.position={x:parseFloat(t.position.x.toFixed(6)),y:parseFloat(t.position.y.toFixed(6)),z:parseFloat(t.position.z.toFixed(6))},v.rotation={x:parseFloat((t.rotation.x*(180/Math.PI)).toFixed(6)),y:parseFloat((t.rotation.y*(180/Math.PI)).toFixed(6)),z:parseFloat((t.rotation.z*(180/Math.PI)).toFixed(6))},v.scale={x:parseFloat(t.scale.x.toFixed(6)),y:parseFloat(t.scale.y.toFixed(6)),z:parseFloat(t.scale.z.toFixed(6))},t.geometry)&&(null!==(l=t.name)&&void 0!==l&&l.toLowerCase().includes("connector")?v.geometry="CONNECTOR-GEO":null!==(f=t.name)&&void 0!==f&&f.toLowerCase().includes("gateway")?v.geometry="GATEWAY-GEO":null!==(d=t.userData)&&void 0!==d&&d.libraryId&&(v.geometry="".concat(t.userData.libraryId,"-GEO")));if(t.children&&t.children.length>0){var p=[];t.children.forEach(function(t){var n=e(t,!0);n&&p.push(n)}),p.length>0&&(v.children=p)}return v},n=[];this.sceneViewer.scene.children.forEach(function(t){var i=e(t);i&&n.push(i)});var i,r,s={connections:(r=[],null!==(i=t.sceneViewer.currentSceneData)&&void 0!==i&&i.connections&&r.push.apply(r,S(t.sceneViewer.currentSceneData.connections)),r),scene:{object:{uuid:"PLANT-SCENE",name:"Scene",type:"Scene",children:n}}};return s.et={exportedAt:(new Date).toISOString(),exportedFrom:"SceneViewerEnhanced",version:"1.0.0",objectCount:n.length},s}},{key:"downloadSceneExport",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e=this.exportSceneData();if(!e)return!1;t||(t="cp-export.json");try{var n=JSON.stringify(e,null,2),i=new Blob([n],{type:"application/json"}),r=URL.createObjectURL(i),s=document.createElement("a");return s.href=r,s.download=t,document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(r),!0}catch(t){return!1}}},{key:"exportSceneDataAsString",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=this.exportSceneData();return e?t?JSON.stringify(e,null,2):JSON.stringify(e):null}},{key:"getExportMetadata",value:function(){var t;if(!this.sceneViewer.scene)return null;var e=0;return this.sceneViewer.scene.traverse(function(){return e++}),{totalObjects:e,hasCurrentSceneData:!!this.sceneViewer.currentSceneData,connectionsCount:(null===(t=this.sceneViewer.currentSceneData)||void 0===t||null===(t=t.connections)||void 0===t?void 0:t.length)||0,exportTimestamp:(new Date).toISOString()}}}])}();function pt(e,n){if(n===t.TrianglesDrawMode)return e;if(n===t.TriangleFanDrawMode||n===t.TriangleStripDrawMode){let i=e.getIndex();if(null===i){const t=[],n=e.getAttribute("position");if(void 0===n)return e;for(let e=0;e<n.count;e++)t.push(e);e.setIndex(t),i=e.getIndex()}const r=i.count-2,s=[];if(n===t.TriangleFanDrawMode)for(let t=1;t<=r;t++)s.push(i.getX(0)),s.push(i.getX(t)),s.push(i.getX(t+1));else for(let t=0;t<r;t++)t%2==0?(s.push(i.getX(t)),s.push(i.getX(t+1)),s.push(i.getX(t+2))):(s.push(i.getX(t+2)),s.push(i.getX(t+1)),s.push(i.getX(t)));s.length;const o=e.clone();return o.setIndex(s),o.clearGroups(),o}return e}class wt extends t.Loader{constructor(t){super(t),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new Mt(t)}),this.register(function(t){return new xt(t)}),this.register(function(t){return new Pt(t)}),this.register(function(t){return new jt(t)}),this.register(function(t){return new Dt(t)}),this.register(function(t){return new St(t)}),this.register(function(t){return new Et(t)}),this.register(function(t){return new At(t)}),this.register(function(t){return new _t(t)}),this.register(function(t){return new kt(t)}),this.register(function(t){return new Ot(t)}),this.register(function(t){return new Tt(t)}),this.register(function(t){return new Rt(t)}),this.register(function(t){return new Ct(t)}),this.register(function(t){return new gt(t)}),this.register(function(t){return new It(t)}),this.register(function(t){return new Nt(t)})}load(e,n,i,r){const s=this;let o;if(""!==this.resourcePath)o=this.resourcePath;else if(""!==this.path){const n=t.LoaderUtils.extractUrlBase(e);o=t.LoaderUtils.resolveURL(n,this.path)}else o=t.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const a=function(t){r&&r(t),s.manager.itemError(e),s.manager.itemEnd(e)},u=new t.FileLoader(this.manager);u.setPath(this.path),u.setResponseType("arraybuffer"),u.setRequestHeader(this.requestHeader),u.setWithCredentials(this.withCredentials),u.load(e,function(t){try{s.parse(t,o,function(t){n(t),s.manager.itemEnd(e)},a)}catch(t){a(t)}},i,a)}setDRACOLoader(t){return this.dracoLoader=t,this}setKTX2Loader(t){return this.ktx2Loader=t,this}setMeshoptDecoder(t){return this.meshoptDecoder=t,this}register(t){return-1===this.pluginCallbacks.indexOf(t)&&this.pluginCallbacks.push(t),this}unregister(t){return-1!==this.pluginCallbacks.indexOf(t)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(t),1),this}parse(t,e,n,i){let r;const s={},o={},a=new TextDecoder;if("string"==typeof t)r=JSON.parse(t);else if(t instanceof ArrayBuffer){if(a.decode(new Uint8Array(t,0,4))===Lt){try{s[yt.KHR_BINARY_GLTF]=new Ut(t)}catch(t){return void(i&&i(t))}r=JSON.parse(s[yt.KHR_BINARY_GLTF].content)}else r=JSON.parse(a.decode(t))}else r=t;if(void 0===r.asset||r.asset.version[0]<2)return void(i&&i(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const u=new fe(r,{path:e||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});u.fileLoader.setRequestHeader(this.requestHeader);for(let t=0;t<this.pluginCallbacks.length;t++){const e=this.pluginCallbacks[t](u);e.name,o[e.name]=e,s[e.name]=!0}if(r.extensionsUsed)for(let t=0;t<r.extensionsUsed.length;++t){const e=r.extensionsUsed[t],n=r.extensionsRequired||[];switch(e){case yt.KHR_MATERIALS_UNLIT:s[e]=new bt;break;case yt.KHR_DRACO_MESH_COMPRESSION:s[e]=new zt(r,this.dracoLoader);break;case yt.KHR_TEXTURE_TRANSFORM:s[e]=new Ht;break;case yt.KHR_MESH_QUANTIZATION:s[e]=new Gt;break;default:n.indexOf(e)>=0&&o[e]}}u.setExtensions(s),u.setPlugins(o),u.parse(n,i)}parseAsync(t,e){const n=this;return new Promise(function(i,r){n.parse(t,e,i,r)})}}function mt(){let t={};return{get:function(e){return t[e]},add:function(e,n){t[e]=n},remove:function(e){delete t[e]},removeAll:function(){t={}}}}const yt={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class gt{constructor(t){this.parser=t,this.name=yt.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}nt(){const t=this.parser,e=this.parser.json.nodes||[];for(let n=0,i=e.length;n<i;n++){const i=e[n];i.extensions&&i.extensions[this.name]&&void 0!==i.extensions[this.name].light&&t.it(this.cache,i.extensions[this.name].light)}}rt(e){const n=this.parser,i="light:"+e;let r=n.cache.get(i);if(r)return r;const s=n.json,o=((s.extensions&&s.extensions[this.name]||{}).lights||[])[e];let a;const u=new t.Color(16777215);void 0!==o.color&&u.setRGB(o.color[0],o.color[1],o.color[2],t.LinearSRGBColorSpace);const h=void 0!==o.range?o.range:0;switch(o.type){case"directional":a=new t.DirectionalLight(u),a.target.position.set(0,0,-1),a.add(a.target);break;case"point":a=new t.PointLight(u),a.distance=h;break;case"spot":a=new t.SpotLight(u),a.distance=h,o.spot=o.spot||{},o.spot.innerConeAngle=void 0!==o.spot.innerConeAngle?o.spot.innerConeAngle:0,o.spot.outerConeAngle=void 0!==o.spot.outerConeAngle?o.spot.outerConeAngle:Math.PI/4,a.angle=o.spot.outerConeAngle,a.penumbra=1-o.spot.innerConeAngle/o.spot.outerConeAngle,a.target.position.set(0,0,-1),a.add(a.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+o.type)}return a.position.set(0,0,0),oe(a,o),void 0!==o.intensity&&(a.intensity=o.intensity),a.name=n.createUniqueName(o.name||"light_"+e),r=Promise.resolve(a),n.cache.add(i,r),r}getDependency(t,e){if("light"===t)return this.rt(e)}createNodeAttachment(t){const e=this,n=this.parser,i=n.json.nodes[t],r=(i.extensions&&i.extensions[this.name]||{}).light;return void 0===r?null:this.rt(r).then(function(t){return n.st(e.cache,r,t)})}}class bt{constructor(){this.name=yt.KHR_MATERIALS_UNLIT}getMaterialType(){return t.MeshBasicMaterial}extendParams(e,n,i){const r=[];e.color=new t.Color(1,1,1),e.opacity=1;const s=n.pbrMetallicRoughness;if(s){if(Array.isArray(s.baseColorFactor)){const n=s.baseColorFactor;e.color.setRGB(n[0],n[1],n[2],t.LinearSRGBColorSpace),e.opacity=n[3]}void 0!==s.baseColorTexture&&r.push(i.assignTexture(e,"map",s.baseColorTexture,t.SRGBColorSpace))}return Promise.all(r)}}class kt{constructor(t){this.parser=t,this.name=yt.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(t,e){const n=this.parser.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name].emissiveStrength;return void 0!==i&&(e.emissiveIntensity=i),Promise.resolve()}}class Mt{constructor(t){this.parser=t,this.name=yt.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const n=this.parser.json.materials[e];return n.extensions&&n.extensions[this.name]?t.MeshPhysicalMaterial:null}extendMaterialParams(e,n){const i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const s=[],o=r.extensions[this.name];if(void 0!==o.clearcoatFactor&&(n.clearcoat=o.clearcoatFactor),void 0!==o.clearcoatTexture&&s.push(i.assignTexture(n,"clearcoatMap",o.clearcoatTexture)),void 0!==o.clearcoatRoughnessFactor&&(n.clearcoatRoughness=o.clearcoatRoughnessFactor),void 0!==o.clearcoatRoughnessTexture&&s.push(i.assignTexture(n,"clearcoatRoughnessMap",o.clearcoatRoughnessTexture)),void 0!==o.clearcoatNormalTexture&&(s.push(i.assignTexture(n,"clearcoatNormalMap",o.clearcoatNormalTexture)),void 0!==o.clearcoatNormalTexture.scale)){const e=o.clearcoatNormalTexture.scale;n.clearcoatNormalScale=new t.Vector2(e,e)}return Promise.all(s)}}class xt{constructor(t){this.parser=t,this.name=yt.KHR_MATERIALS_DISPERSION}getMaterialType(e){const n=this.parser.json.materials[e];return n.extensions&&n.extensions[this.name]?t.MeshPhysicalMaterial:null}extendMaterialParams(t,e){const n=this.parser.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name];return e.dispersion=void 0!==i.dispersion?i.dispersion:0,Promise.resolve()}}class Tt{constructor(t){this.parser=t,this.name=yt.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const n=this.parser.json.materials[e];return n.extensions&&n.extensions[this.name]?t.MeshPhysicalMaterial:null}extendMaterialParams(t,e){const n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];return void 0!==s.iridescenceFactor&&(e.iridescence=s.iridescenceFactor),void 0!==s.iridescenceTexture&&r.push(n.assignTexture(e,"iridescenceMap",s.iridescenceTexture)),void 0!==s.iridescenceIor&&(e.iridescenceIOR=s.iridescenceIor),void 0===e.iridescenceThicknessRange&&(e.iridescenceThicknessRange=[100,400]),void 0!==s.iridescenceThicknessMinimum&&(e.iridescenceThicknessRange[0]=s.iridescenceThicknessMinimum),void 0!==s.iridescenceThicknessMaximum&&(e.iridescenceThicknessRange[1]=s.iridescenceThicknessMaximum),void 0!==s.iridescenceThicknessTexture&&r.push(n.assignTexture(e,"iridescenceThicknessMap",s.iridescenceThicknessTexture)),Promise.all(r)}}class St{constructor(t){this.parser=t,this.name=yt.KHR_MATERIALS_SHEEN}getMaterialType(e){const n=this.parser.json.materials[e];return n.extensions&&n.extensions[this.name]?t.MeshPhysicalMaterial:null}extendMaterialParams(e,n){const i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const s=[];n.sheenColor=new t.Color(0,0,0),n.sheenRoughness=0,n.sheen=1;const o=r.extensions[this.name];if(void 0!==o.sheenColorFactor){const e=o.sheenColorFactor;n.sheenColor.setRGB(e[0],e[1],e[2],t.LinearSRGBColorSpace)}return void 0!==o.sheenRoughnessFactor&&(n.sheenRoughness=o.sheenRoughnessFactor),void 0!==o.sheenColorTexture&&s.push(i.assignTexture(n,"sheenColorMap",o.sheenColorTexture,t.SRGBColorSpace)),void 0!==o.sheenRoughnessTexture&&s.push(i.assignTexture(n,"sheenRoughnessMap",o.sheenRoughnessTexture)),Promise.all(s)}}class Et{constructor(t){this.parser=t,this.name=yt.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const n=this.parser.json.materials[e];return n.extensions&&n.extensions[this.name]?t.MeshPhysicalMaterial:null}extendMaterialParams(t,e){const n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];return void 0!==s.transmissionFactor&&(e.transmission=s.transmissionFactor),void 0!==s.transmissionTexture&&r.push(n.assignTexture(e,"transmissionMap",s.transmissionTexture)),Promise.all(r)}}class At{constructor(t){this.parser=t,this.name=yt.KHR_MATERIALS_VOLUME}getMaterialType(e){const n=this.parser.json.materials[e];return n.extensions&&n.extensions[this.name]?t.MeshPhysicalMaterial:null}extendMaterialParams(e,n){const i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const s=[],o=r.extensions[this.name];n.thickness=void 0!==o.thicknessFactor?o.thicknessFactor:0,void 0!==o.thicknessTexture&&s.push(i.assignTexture(n,"thicknessMap",o.thicknessTexture)),n.attenuationDistance=o.attenuationDistance||1/0;const a=o.attenuationColor||[1,1,1];return n.attenuationColor=(new t.Color).setRGB(a[0],a[1],a[2],t.LinearSRGBColorSpace),Promise.all(s)}}class _t{constructor(t){this.parser=t,this.name=yt.KHR_MATERIALS_IOR}getMaterialType(e){const n=this.parser.json.materials[e];return n.extensions&&n.extensions[this.name]?t.MeshPhysicalMaterial:null}extendMaterialParams(t,e){const n=this.parser.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name];return e.ior=void 0!==i.ior?i.ior:1.5,Promise.resolve()}}class Ot{constructor(t){this.parser=t,this.name=yt.KHR_MATERIALS_SPECULAR}getMaterialType(e){const n=this.parser.json.materials[e];return n.extensions&&n.extensions[this.name]?t.MeshPhysicalMaterial:null}extendMaterialParams(e,n){const i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const s=[],o=r.extensions[this.name];n.specularIntensity=void 0!==o.specularFactor?o.specularFactor:1,void 0!==o.specularTexture&&s.push(i.assignTexture(n,"specularIntensityMap",o.specularTexture));const a=o.specularColorFactor||[1,1,1];return n.specularColor=(new t.Color).setRGB(a[0],a[1],a[2],t.LinearSRGBColorSpace),void 0!==o.specularColorTexture&&s.push(i.assignTexture(n,"specularColorMap",o.specularColorTexture,t.SRGBColorSpace)),Promise.all(s)}}class Ct{constructor(t){this.parser=t,this.name=yt.EXT_MATERIALS_BUMP}getMaterialType(e){const n=this.parser.json.materials[e];return n.extensions&&n.extensions[this.name]?t.MeshPhysicalMaterial:null}extendMaterialParams(t,e){const n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];return e.bumpScale=void 0!==s.bumpFactor?s.bumpFactor:1,void 0!==s.bumpTexture&&r.push(n.assignTexture(e,"bumpMap",s.bumpTexture)),Promise.all(r)}}class Rt{constructor(t){this.parser=t,this.name=yt.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const n=this.parser.json.materials[e];return n.extensions&&n.extensions[this.name]?t.MeshPhysicalMaterial:null}extendMaterialParams(t,e){const n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];return void 0!==s.anisotropyStrength&&(e.anisotropy=s.anisotropyStrength),void 0!==s.anisotropyRotation&&(e.anisotropyRotation=s.anisotropyRotation),void 0!==s.anisotropyTexture&&r.push(n.assignTexture(e,"anisotropyMap",s.anisotropyTexture)),Promise.all(r)}}class Pt{constructor(t){this.parser=t,this.name=yt.KHR_TEXTURE_BASISU}loadTexture(t){const e=this.parser,n=e.json,i=n.textures[t];if(!i.extensions||!i.extensions[this.name])return null;const r=i.extensions[this.name],s=e.options.ktx2Loader;if(!s){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return e.loadTextureImage(t,r.source,s)}}class jt{constructor(t){this.parser=t,this.name=yt.EXT_TEXTURE_WEBP}loadTexture(t){const e=this.name,n=this.parser,i=n.json,r=i.textures[t];if(!r.extensions||!r.extensions[e])return null;const s=r.extensions[e],o=i.images[s.source];let a=n.textureLoader;if(o.uri){const t=n.options.manager.getHandler(o.uri);null!==t&&(a=t)}return n.loadTextureImage(t,s.source,a)}}class Dt{constructor(t){this.parser=t,this.name=yt.EXT_TEXTURE_AVIF}loadTexture(t){const e=this.name,n=this.parser,i=n.json,r=i.textures[t];if(!r.extensions||!r.extensions[e])return null;const s=r.extensions[e],o=i.images[s.source];let a=n.textureLoader;if(o.uri){const t=n.options.manager.getHandler(o.uri);null!==t&&(a=t)}return n.loadTextureImage(t,s.source,a)}}class It{constructor(t){this.name=yt.EXT_MESHOPT_COMPRESSION,this.parser=t}loadBufferView(t){const e=this.parser.json,n=e.bufferViews[t];if(n.extensions&&n.extensions[this.name]){const t=n.extensions[this.name],i=this.parser.getDependency("buffer",t.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.supported){if(e.extensionsRequired&&e.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return i.then(function(e){const n=t.byteOffset||0,i=t.byteLength||0,s=t.count,o=t.byteStride,a=new Uint8Array(e,n,i);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(s,o,a,t.mode,t.filter).then(function(t){return t.buffer}):r.ready.then(function(){const e=new ArrayBuffer(s*o);return r.decodeGltfBuffer(new Uint8Array(e),s,o,a,t.mode,t.filter),e})})}return null}}class Nt{constructor(t){this.name=yt.EXT_MESH_GPU_INSTANCING,this.parser=t}createNodeMesh(e){const n=this.parser.json,i=n.nodes[e];if(!i.extensions||!i.extensions[this.name]||void 0===i.mesh)return null;const r=n.meshes[i.mesh];for(const t of r.primitives)if(t.mode!==Kt.TRIANGLES&&t.mode!==Kt.TRIANGLE_STRIP&&t.mode!==Kt.TRIANGLE_FAN&&void 0!==t.mode)return null;const s=i.extensions[this.name].attributes,o=[],a={};for(const t in s)o.push(this.parser.getDependency("accessor",s[t]).then(e=>(a[t]=e,a[t])));return o.length<1?null:(o.push(this.parser.createNodeMesh(e)),Promise.all(o).then(e=>{const n=e.pop(),i=n.isGroup?n.children:[n],r=e[0].count,s=[];for(const e of i){const n=new t.Matrix4,i=new t.Vector3,o=new t.Quaternion,u=new t.Vector3(1,1,1),h=new t.InstancedMesh(e.geometry,e.material,r);for(let t=0;t<r;t++)a.TRANSLATION&&i.fromBufferAttribute(a.TRANSLATION,t),a.ROTATION&&o.fromBufferAttribute(a.ROTATION,t),a.SCALE&&u.fromBufferAttribute(a.SCALE,t),h.setMatrixAt(t,n.compose(i,o,u));for(const n in a)if("_COLOR_0"===n){const e=a[n];h.instanceColor=new t.InstancedBufferAttribute(e.array,e.itemSize,e.normalized)}else"TRANSLATION"!==n&&"ROTATION"!==n&&"SCALE"!==n&&e.geometry.setAttribute(n,a[n]);t.Object3D.prototype.copy.call(h,e),this.parser.assignFinalMaterial(h),s.push(h)}return n.isGroup?(n.clear(),n.add(...s),n):s[0]}))}}const Lt="glTF",Bt=1313821514,Ft=5130562;class Ut{constructor(t){this.name=yt.KHR_BINARY_GLTF,this.content=null,this.body=null;const e=new DataView(t,0,12),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(t.slice(0,4))),version:e.getUint32(4,!0),length:e.getUint32(8,!0)},this.header.magic!==Lt)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const i=this.header.length-12,r=new DataView(t,12);let s=0;for(;s<i;){const e=r.getUint32(s,!0);s+=4;const i=r.getUint32(s,!0);if(s+=4,i===Bt){const i=new Uint8Array(t,12+s,e);this.content=n.decode(i)}else if(i===Ft){const n=12+s;this.body=t.slice(n,n+e)}s+=e}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class zt{constructor(t,e){if(!e)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=yt.KHR_DRACO_MESH_COMPRESSION,this.json=t,this.dracoLoader=e,this.dracoLoader.preload()}decodePrimitive(e,n){const i=this.json,r=this.dracoLoader,s=e.extensions[this.name].bufferView,o=e.extensions[this.name].attributes,a={},u={},h={};for(const t in o){const e=qt[t]||t.toLowerCase();a[e]=o[t]}for(const t in e.attributes){const n=qt[t]||t.toLowerCase();if(void 0!==o[t]){const r=i.accessors[e.attributes[t]],s=Zt[r.componentType];h[n]=s.name,u[n]=!0===r.normalized}}return n.getDependency("bufferView",s).then(function(e){return new Promise(function(n,i){r.decodeDracoFile(e,function(t){for(const e in t.attributes){const n=t.attributes[e],i=u[e];void 0!==i&&(n.normalized=i)}n(t)},a,h,t.LinearSRGBColorSpace,i)})})}}class Ht{constructor(){this.name=yt.KHR_TEXTURE_TRANSFORM}extendTexture(t,e){return void 0!==e.texCoord&&e.texCoord!==t.channel||void 0!==e.offset||void 0!==e.rotation||void 0!==e.scale?(t=t.clone(),void 0!==e.texCoord&&(t.channel=e.texCoord),void 0!==e.offset&&t.offset.fromArray(e.offset),void 0!==e.rotation&&(t.rotation=e.rotation),void 0!==e.scale&&t.repeat.fromArray(e.scale),t.needsUpdate=!0,t):t}}class Gt{constructor(){this.name=yt.KHR_MESH_QUANTIZATION}}class Xt extends t.Interpolant{constructor(t,e,n,i){super(t,e,n,i)}copySampleValue_(t){const e=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=t*i*3+i;for(let t=0;t!==i;t++)e[t]=n[r+t];return e}interpolate_(t,e,n,i){const r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=2*o,u=3*o,h=i-e,c=(n-e)/h,l=c*c,f=l*c,d=t*u,v=d-u,p=-2*f+3*l,w=f-l,m=1-p,y=w-l+c;for(let t=0;t!==o;t++){const e=s[v+t+o],n=s[v+t+a]*h,i=s[d+t+o],u=s[d+t]*h;r[t]=m*e+y*n+p*i+w*u}return r}}const Vt=new t.Quaternion;class Yt extends Xt{interpolate_(t,e,n,i){const r=super.interpolate_(t,e,n,i);return Vt.fromArray(r).normalize().toArray(r),r}}const Kt={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},Zt={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Wt={9728:t.NearestFilter,9729:t.LinearFilter,9984:t.NearestMipmapNearestFilter,9985:t.LinearMipmapNearestFilter,9986:t.NearestMipmapLinearFilter,9987:t.LinearMipmapLinearFilter},$t={33071:t.ClampToEdgeWrapping,33648:t.MirroredRepeatWrapping,10497:t.RepeatWrapping},Jt={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},qt={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Qt={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},te={CUBICSPLINE:void 0,LINEAR:t.InterpolateLinear,STEP:t.InterpolateDiscrete},ee="OPAQUE",ne="MASK",ie="BLEND";function re(e){return void 0===e.DefaultMaterial&&(e.DefaultMaterial=new t.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:t.FrontSide})),e.DefaultMaterial}function se(t,e,n){for(const i in n.extensions)void 0===t[i]&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[i]=n.extensions[i])}function oe(t,e){void 0!==e.extras&&"object"==typeof e.extras&&Object.assign(t.userData,e.extras)}function ae(t,e){if(t.updateMorphTargets(),void 0!==e.weights)for(let n=0,i=e.weights.length;n<i;n++)t.morphTargetInfluences[n]=e.weights[n];if(e.extras&&Array.isArray(e.extras.targetNames)){const n=e.extras.targetNames;if(t.morphTargetInfluences.length===n.length){t.morphTargetDictionary={};for(let e=0,i=n.length;e<i;e++)t.morphTargetDictionary[n[e]]=e}}}function ue(t){let e;const n=t.extensions&&t.extensions[yt.KHR_DRACO_MESH_COMPRESSION];if(e=n?"draco:"+n.bufferView+":"+n.indices+":"+he(n.attributes):t.indices+":"+he(t.attributes)+":"+t.mode,void 0!==t.targets)for(let n=0,i=t.targets.length;n<i;n++)e+=":"+he(t.targets[n]);return e}function he(t){let e="";const n=Object.keys(t).sort();for(let i=0,r=n.length;i<r;i++)e+=n[i]+":"+t[n[i]]+";";return e}function ce(t){switch(t){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}const le=new t.Matrix4;class fe{constructor(e={},n={}){this.json=e,this.extensions={},this.plugins={},this.options=n,this.cache=new mt,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let i=!1,r=-1,s=!1,o=-1;if("undefined"!=typeof navigator){const t=navigator.userAgent;i=!0===/^((?!chrome|android).)*safari/i.test(t);const e=t.match(/Version\/(\d+)/);r=i&&e?parseInt(e[1],10):-1,s=t.indexOf("Firefox")>-1,o=s?t.match(/Firefox\/([0-9]+)\./)[1]:-1}"undefined"==typeof createImageBitmap||i&&r<17||s&&o<98?this.textureLoader=new t.TextureLoader(this.options.manager):this.textureLoader=new t.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new t.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(t){this.extensions=t}setPlugins(t){this.plugins=t}parse(t,e){const n=this,i=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this.ot(function(t){return t.nt&&t.nt()}),Promise.all(this.ot(function(t){return t.beforeRoot&&t.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(e){const s={scene:e[0][i.scene||0],scenes:e[0],animations:e[1],cameras:e[2],asset:i.asset,parser:n,userData:{}};return se(r,s,i),oe(s,i),Promise.all(n.ot(function(t){return t.afterRoot&&t.afterRoot(s)})).then(function(){for(const t of s.scenes)t.updateMatrixWorld();t(s)})}).catch(e)}nt(){const t=this.json.nodes||[],e=this.json.skins||[],n=this.json.meshes||[];for(let n=0,i=e.length;n<i;n++){const i=e[n].joints;for(let e=0,n=i.length;e<n;e++)t[i[e]].isBone=!0}for(let e=0,i=t.length;e<i;e++){const i=t[e];void 0!==i.mesh&&(this.it(this.meshCache,i.mesh),void 0!==i.skin&&(n[i.mesh].isSkinnedMesh=!0)),void 0!==i.camera&&this.it(this.cameraCache,i.camera)}}it(t,e){void 0!==e&&(void 0===t.refs[e]&&(t.refs[e]=t.uses[e]=0),t.refs[e]++)}st(t,e,n){if(t.refs[e]<=1)return n;const i=n.clone(),r=(t,e)=>{const n=this.associations.get(t);null!=n&&this.associations.set(e,n);for(const[n,i]of t.children.entries())r(i,e.children[n])};return r(n,i),i.name+="_instance_"+t.uses[e]++,i}ut(t){const e=Object.values(this.plugins);e.push(this);for(let n=0;n<e.length;n++){const i=t(e[n]);if(i)return i}return null}ot(t){const e=Object.values(this.plugins);e.unshift(this);const n=[];for(let i=0;i<e.length;i++){const r=t(e[i]);r&&n.push(r)}return n}getDependency(t,e){const n=t+":"+e;let i=this.cache.get(n);if(!i){switch(t){case"scene":i=this.loadScene(e);break;case"node":i=this.ut(function(t){return t.loadNode&&t.loadNode(e)});break;case"mesh":i=this.ut(function(t){return t.loadMesh&&t.loadMesh(e)});break;case"accessor":i=this.loadAccessor(e);break;case"bufferView":i=this.ut(function(t){return t.loadBufferView&&t.loadBufferView(e)});break;case"buffer":i=this.loadBuffer(e);break;case"material":i=this.ut(function(t){return t.loadMaterial&&t.loadMaterial(e)});break;case"texture":i=this.ut(function(t){return t.loadTexture&&t.loadTexture(e)});break;case"skin":i=this.loadSkin(e);break;case"animation":i=this.ut(function(t){return t.loadAnimation&&t.loadAnimation(e)});break;case"camera":i=this.loadCamera(e);break;default:if(i=this.ut(function(n){return n!=this&&n.getDependency&&n.getDependency(t,e)}),!i)throw new Error("Unknown type: "+t)}this.cache.add(n,i)}return i}getDependencies(t){let e=this.cache.get(t);if(!e){const n=this,i=this.json[t+("mesh"===t?"es":"s")]||[];e=Promise.all(i.map(function(e,i){return n.getDependency(t,i)})),this.cache.add(t,e)}return e}loadBuffer(e){const n=this.json.buffers[e],i=this.fileLoader;if(n.type&&"arraybuffer"!==n.type)throw new Error("THREE.GLTFLoader: "+n.type+" buffer type is not supported.");if(void 0===n.uri&&0===e)return Promise.resolve(this.extensions[yt.KHR_BINARY_GLTF].body);const r=this.options;return new Promise(function(e,s){i.load(t.LoaderUtils.resolveURL(n.uri,r.path),e,void 0,function(){s(new Error('THREE.GLTFLoader: Failed to load buffer "'+n.uri+'".'))})})}loadBufferView(t){const e=this.json.bufferViews[t];return this.getDependency("buffer",e.buffer).then(function(t){const n=e.byteLength||0,i=e.byteOffset||0;return t.slice(i,i+n)})}loadAccessor(e){const n=this,i=this.json,r=this.json.accessors[e];if(void 0===r.bufferView&&void 0===r.sparse){const e=Jt[r.type],n=Zt[r.componentType],i=!0===r.normalized,s=new n(r.count*e);return Promise.resolve(new t.BufferAttribute(s,e,i))}const s=[];return void 0!==r.bufferView?s.push(this.getDependency("bufferView",r.bufferView)):s.push(null),void 0!==r.sparse&&(s.push(this.getDependency("bufferView",r.sparse.indices.bufferView)),s.push(this.getDependency("bufferView",r.sparse.values.bufferView))),Promise.all(s).then(function(e){const s=e[0],o=Jt[r.type],a=Zt[r.componentType],u=a.BYTES_PER_ELEMENT,h=u*o,c=r.byteOffset||0,l=void 0!==r.bufferView?i.bufferViews[r.bufferView].byteStride:void 0,f=!0===r.normalized;let d,v;if(l&&l!==h){const e=Math.floor(c/l),i="InterleavedBuffer:"+r.bufferView+":"+r.componentType+":"+e+":"+r.count;let h=n.cache.get(i);h||(d=new a(s,e*l,r.count*l/u),h=new t.InterleavedBuffer(d,l/u),n.cache.add(i,h)),v=new t.InterleavedBufferAttribute(h,o,c%l/u,f)}else d=null===s?new a(r.count*o):new a(s,c,r.count*o),v=new t.BufferAttribute(d,o,f);if(void 0!==r.sparse){const n=Jt.SCALAR,i=Zt[r.sparse.indices.componentType],u=r.sparse.indices.byteOffset||0,h=r.sparse.values.byteOffset||0,c=new i(e[1],u,r.sparse.count*n),l=new a(e[2],h,r.sparse.count*o);null!==s&&(v=new t.BufferAttribute(v.array.slice(),v.itemSize,v.normalized)),v.normalized=!1;for(let t=0,e=c.length;t<e;t++){const e=c[t];if(v.setX(e,l[t*o]),o>=2&&v.setY(e,l[t*o+1]),o>=3&&v.setZ(e,l[t*o+2]),o>=4&&v.setW(e,l[t*o+3]),o>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}v.normalized=f}return v})}loadTexture(t){const e=this.json,n=this.options,i=e.textures[t].source,r=e.images[i];let s=this.textureLoader;if(r.uri){const t=n.manager.getHandler(r.uri);null!==t&&(s=t)}return this.loadTextureImage(t,i,s)}loadTextureImage(e,n,i){const r=this,s=this.json,o=s.textures[e],a=s.images[n],u=(a.uri||a.bufferView)+":"+o.sampler;if(this.textureCache[u])return this.textureCache[u];const h=this.loadImageSource(n,i).then(function(n){n.flipY=!1,n.name=o.name||a.name||"",""===n.name&&"string"==typeof a.uri&&!1===a.uri.startsWith("data:image/")&&(n.name=a.uri);const i=(s.samplers||{})[o.sampler]||{};return n.magFilter=Wt[i.magFilter]||t.LinearFilter,n.minFilter=Wt[i.minFilter]||t.LinearMipmapLinearFilter,n.wrapS=$t[i.wrapS]||t.RepeatWrapping,n.wrapT=$t[i.wrapT]||t.RepeatWrapping,n.generateMipmaps=!n.isCompressedTexture&&n.minFilter!==t.NearestFilter&&n.minFilter!==t.LinearFilter,r.associations.set(n,{textures:e}),n}).catch(function(){return null});return this.textureCache[u]=h,h}loadImageSource(e,n){const i=this,r=this.json,s=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then(t=>t.clone());const o=r.images[e],a=self.URL||self.webkitURL;let u=o.uri||"",h=!1;if(void 0!==o.bufferView)u=i.getDependency("bufferView",o.bufferView).then(function(t){h=!0;const e=new Blob([t],{type:o.mimeType});return u=a.createObjectURL(e),u});else if(void 0===o.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const c=Promise.resolve(u).then(function(e){return new Promise(function(i,r){let o=i;!0===n.isImageBitmapLoader&&(o=function(e){const n=new t.Texture(e);n.needsUpdate=!0,i(n)}),n.load(t.LoaderUtils.resolveURL(e,s.path),o,void 0,r)})}).then(function(t){var e;return!0===h&&a.revokeObjectURL(u),oe(t,o),t.userData.mimeType=o.mimeType||((e=o.uri).search(/\.jpe?g($|\?)/i)>0||0===e.search(/^data\:image\/jpeg/)?"image/jpeg":e.search(/\.webp($|\?)/i)>0||0===e.search(/^data\:image\/webp/)?"image/webp":e.search(/\.ktx2($|\?)/i)>0||0===e.search(/^data\:image\/ktx2/)?"image/ktx2":"image/png"),t}).catch(function(t){throw t});return this.sourceCache[e]=c,c}assignTexture(t,e,n,i){const r=this;return this.getDependency("texture",n.index).then(function(s){if(!s)return null;if(void 0!==n.texCoord&&n.texCoord>0&&((s=s.clone()).channel=n.texCoord),r.extensions[yt.KHR_TEXTURE_TRANSFORM]){const t=void 0!==n.extensions?n.extensions[yt.KHR_TEXTURE_TRANSFORM]:void 0;if(t){const e=r.associations.get(s);s=r.extensions[yt.KHR_TEXTURE_TRANSFORM].extendTexture(s,t),r.associations.set(s,e)}}return void 0!==i&&(s.colorSpace=i),t[e]=s,s})}assignFinalMaterial(e){const n=e.geometry;let i=e.material;const r=void 0===n.attributes.tangent,s=void 0!==n.attributes.color,o=void 0===n.attributes.normal;if(e.isPoints){const e="PointsMaterial:"+i.uuid;let n=this.cache.get(e);n||(n=new t.PointsMaterial,t.Material.prototype.copy.call(n,i),n.color.copy(i.color),n.map=i.map,n.sizeAttenuation=!1,this.cache.add(e,n)),i=n}else if(e.isLine){const e="LineBasicMaterial:"+i.uuid;let n=this.cache.get(e);n||(n=new t.LineBasicMaterial,t.Material.prototype.copy.call(n,i),n.color.copy(i.color),n.map=i.map,this.cache.add(e,n)),i=n}if(r||s||o){let t="ClonedMaterial:"+i.uuid+":";r&&(t+="derivative-tangents:"),s&&(t+="vertex-colors:"),o&&(t+="flat-shading:");let e=this.cache.get(t);e||(e=i.clone(),s&&(e.vertexColors=!0),o&&(e.flatShading=!0),r&&(e.normalScale&&(e.normalScale.y*=-1),e.clearcoatNormalScale&&(e.clearcoatNormalScale.y*=-1)),this.cache.add(t,e),this.associations.set(e,this.associations.get(i))),i=e}e.material=i}getMaterialType(){return t.MeshStandardMaterial}loadMaterial(e){const n=this,i=this.json,r=this.extensions,s=i.materials[e];let o;const a={},u=[];if((s.extensions||{})[yt.KHR_MATERIALS_UNLIT]){const t=r[yt.KHR_MATERIALS_UNLIT];o=t.getMaterialType(),u.push(t.extendParams(a,s,n))}else{const i=s.pbrMetallicRoughness||{};if(a.color=new t.Color(1,1,1),a.opacity=1,Array.isArray(i.baseColorFactor)){const e=i.baseColorFactor;a.color.setRGB(e[0],e[1],e[2],t.LinearSRGBColorSpace),a.opacity=e[3]}void 0!==i.baseColorTexture&&u.push(n.assignTexture(a,"map",i.baseColorTexture,t.SRGBColorSpace)),a.metalness=void 0!==i.metallicFactor?i.metallicFactor:1,a.roughness=void 0!==i.roughnessFactor?i.roughnessFactor:1,void 0!==i.metallicRoughnessTexture&&(u.push(n.assignTexture(a,"metalnessMap",i.metallicRoughnessTexture)),u.push(n.assignTexture(a,"roughnessMap",i.metallicRoughnessTexture))),o=this.ut(function(t){return t.getMaterialType&&t.getMaterialType(e)}),u.push(Promise.all(this.ot(function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,a)})))}!0===s.doubleSided&&(a.side=t.DoubleSide);const h=s.alphaMode||ee;if(h===ie?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,h===ne&&(a.alphaTest=void 0!==s.alphaCutoff?s.alphaCutoff:.5)),void 0!==s.normalTexture&&o!==t.MeshBasicMaterial&&(u.push(n.assignTexture(a,"normalMap",s.normalTexture)),a.normalScale=new t.Vector2(1,1),void 0!==s.normalTexture.scale)){const t=s.normalTexture.scale;a.normalScale.set(t,t)}if(void 0!==s.occlusionTexture&&o!==t.MeshBasicMaterial&&(u.push(n.assignTexture(a,"aoMap",s.occlusionTexture)),void 0!==s.occlusionTexture.strength&&(a.aoMapIntensity=s.occlusionTexture.strength)),void 0!==s.emissiveFactor&&o!==t.MeshBasicMaterial){const e=s.emissiveFactor;a.emissive=(new t.Color).setRGB(e[0],e[1],e[2],t.LinearSRGBColorSpace)}return void 0!==s.emissiveTexture&&o!==t.MeshBasicMaterial&&u.push(n.assignTexture(a,"emissiveMap",s.emissiveTexture,t.SRGBColorSpace)),Promise.all(u).then(function(){const t=new o(a);return s.name&&(t.name=s.name),oe(t,s),n.associations.set(t,{materials:e}),s.extensions&&se(r,t,s),t})}createUniqueName(e){const n=t.PropertyBinding.sanitizeNodeName(e||"");return n in this.nodeNamesUsed?n+"_"+ ++this.nodeNamesUsed[n]:(this.nodeNamesUsed[n]=0,n)}loadGeometries(e){const n=this,i=this.extensions,r=this.primitiveCache;function s(t){return i[yt.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(t,n).then(function(e){return de(e,t,n)})}const o=[];for(let i=0,a=e.length;i<a;i++){const a=e[i],u=ue(a),h=r[u];if(h)o.push(h.promise);else{let e;e=a.extensions&&a.extensions[yt.KHR_DRACO_MESH_COMPRESSION]?s(a):de(new t.BufferGeometry,a,n),r[u]={primitive:a,promise:e},o.push(e)}}return Promise.all(o)}loadMesh(e){const n=this,i=this.json,r=this.extensions,s=i.meshes[e],o=s.primitives,a=[];for(let t=0,e=o.length;t<e;t++){const e=void 0===o[t].material?re(this.cache):this.getDependency("material",o[t].material);a.push(e)}return a.push(n.loadGeometries(o)),Promise.all(a).then(function(i){const a=i.slice(0,i.length-1),u=i[i.length-1],h=[];for(let i=0,c=u.length;i<c;i++){const c=u[i],l=o[i];let f;const d=a[i];if(l.mode===Kt.TRIANGLES||l.mode===Kt.TRIANGLE_STRIP||l.mode===Kt.TRIANGLE_FAN||void 0===l.mode)f=!0===s.isSkinnedMesh?new t.SkinnedMesh(c,d):new t.Mesh(c,d),!0===f.isSkinnedMesh&&f.normalizeSkinWeights(),l.mode===Kt.TRIANGLE_STRIP?f.geometry=pt(f.geometry,t.TriangleStripDrawMode):l.mode===Kt.TRIANGLE_FAN&&(f.geometry=pt(f.geometry,t.TriangleFanDrawMode));else if(l.mode===Kt.LINES)f=new t.LineSegments(c,d);else if(l.mode===Kt.LINE_STRIP)f=new t.Line(c,d);else if(l.mode===Kt.LINE_LOOP)f=new t.LineLoop(c,d);else{if(l.mode!==Kt.POINTS)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+l.mode);f=new t.Points(c,d)}Object.keys(f.geometry.morphAttributes).length>0&&ae(f,s),f.name=n.createUniqueName(s.name||"mesh_"+e),oe(f,s),l.extensions&&se(r,f,l),n.assignFinalMaterial(f),h.push(f)}for(let t=0,i=h.length;t<i;t++)n.associations.set(h[t],{meshes:e,primitives:t});if(1===h.length)return s.extensions&&se(r,h[0],s),h[0];const c=new t.Group;s.extensions&&se(r,c,s),n.associations.set(c,{meshes:e});for(let t=0,e=h.length;t<e;t++)c.add(h[t]);return c})}loadCamera(e){let n;const i=this.json.cameras[e],r=i[i.type];if(r)return"perspective"===i.type?n=new t.PerspectiveCamera(t.MathUtils.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):"orthographic"===i.type&&(n=new t.OrthographicCamera(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),i.name&&(n.name=this.createUniqueName(i.name)),oe(n,i),Promise.resolve(n)}loadSkin(e){const n=this.json.skins[e],i=[];for(let t=0,e=n.joints.length;t<e;t++)i.push(this.ht(n.joints[t]));return void 0!==n.inverseBindMatrices?i.push(this.getDependency("accessor",n.inverseBindMatrices)):i.push(null),Promise.all(i).then(function(e){const n=e.pop(),i=e,r=[],s=[];for(let e=0,o=i.length;e<o;e++){const o=i[e];if(o){r.push(o);const i=new t.Matrix4;null!==n&&i.fromArray(n.array,16*e),s.push(i)}}return new t.Skeleton(r,s)})}loadAnimation(e){const n=this.json,i=this,r=n.animations[e],s=r.name?r.name:"animation_"+e,o=[],a=[],u=[],h=[],c=[];for(let t=0,e=r.channels.length;t<e;t++){const e=r.channels[t],n=r.samplers[e.sampler],i=e.target,s=i.node,l=void 0!==r.parameters?r.parameters[n.input]:n.input,f=void 0!==r.parameters?r.parameters[n.output]:n.output;void 0!==i.node&&(o.push(this.getDependency("node",s)),a.push(this.getDependency("accessor",l)),u.push(this.getDependency("accessor",f)),h.push(n),c.push(i))}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(u),Promise.all(h),Promise.all(c)]).then(function(e){const n=e[0],r=e[1],o=e[2],a=e[3],u=e[4],h=[];for(let t=0,e=n.length;t<e;t++){const e=n[t],s=r[t],c=o[t],l=a[t],f=u[t];if(void 0===e)continue;e.updateMatrix&&e.updateMatrix();const d=i.ct(e,s,c,l,f);if(d)for(let t=0;t<d.length;t++)h.push(d[t])}return new t.AnimationClip(s,void 0,h)})}createNodeMesh(t){const e=this.json,n=this,i=e.nodes[t];return void 0===i.mesh?null:n.getDependency("mesh",i.mesh).then(function(t){const e=n.st(n.meshCache,i.mesh,t);return void 0!==i.weights&&e.traverse(function(t){if(t.isMesh)for(let e=0,n=i.weights.length;e<n;e++)t.morphTargetInfluences[e]=i.weights[e]}),e})}loadNode(t){const e=this,n=this.json.nodes[t],i=e.ht(t),r=[],s=n.children||[];for(let t=0,n=s.length;t<n;t++)r.push(e.getDependency("node",s[t]));const o=void 0===n.skin?Promise.resolve(null):e.getDependency("skin",n.skin);return Promise.all([i,Promise.all(r),o]).then(function(t){const e=t[0],n=t[1],i=t[2];null!==i&&e.traverse(function(t){t.isSkinnedMesh&&t.bind(i,le)});for(let t=0,i=n.length;t<i;t++)e.add(n[t]);return e})}ht(e){const n=this.json,i=this.extensions,r=this;if(void 0!==this.nodeCache[e])return this.nodeCache[e];const s=n.nodes[e],o=s.name?r.createUniqueName(s.name):"",a=[],u=r.ut(function(t){return t.createNodeMesh&&t.createNodeMesh(e)});return u&&a.push(u),void 0!==s.camera&&a.push(r.getDependency("camera",s.camera).then(function(t){return r.st(r.cameraCache,s.camera,t)})),r.ot(function(t){return t.createNodeAttachment&&t.createNodeAttachment(e)}).forEach(function(t){a.push(t)}),this.nodeCache[e]=Promise.all(a).then(function(n){let a;if(a=!0===s.isBone?new t.Bone:n.length>1?new t.Group:1===n.length?n[0]:new t.Object3D,a!==n[0])for(let t=0,e=n.length;t<e;t++)a.add(n[t]);if(s.name&&(a.userData.name=s.name,a.name=o),oe(a,s),s.extensions&&se(i,a,s),void 0!==s.matrix){const e=new t.Matrix4;e.fromArray(s.matrix),a.applyMatrix4(e)}else void 0!==s.translation&&a.position.fromArray(s.translation),void 0!==s.rotation&&a.quaternion.fromArray(s.rotation),void 0!==s.scale&&a.scale.fromArray(s.scale);if(r.associations.has(a)){if(void 0!==s.mesh&&r.meshCache.refs[s.mesh]>1){const t=r.associations.get(a);r.associations.set(a,{...t})}}else r.associations.set(a,{});return r.associations.get(a).nodes=e,a}),this.nodeCache[e]}loadScene(e){const n=this.extensions,i=this.json.scenes[e],r=this,s=new t.Group;i.name&&(s.name=r.createUniqueName(i.name)),oe(s,i),i.extensions&&se(n,s,i);const o=i.nodes||[],a=[];for(let t=0,e=o.length;t<e;t++)a.push(r.getDependency("node",o[t]));return Promise.all(a).then(function(e){for(let t=0,n=e.length;t<n;t++)s.add(e[t]);return r.associations=(e=>{const n=new Map;for(const[e,i]of r.associations)(e instanceof t.Material||e instanceof t.Texture)&&n.set(e,i);return e.traverse(t=>{const e=r.associations.get(t);null!=e&&n.set(t,e)}),n})(s),s})}ct(e,n,i,r,s){const o=[],a=e.name?e.name:e.uuid,u=[];let h;switch(Qt[s.path]===Qt.weights?e.traverse(function(t){t.morphTargetInfluences&&u.push(t.name?t.name:t.uuid)}):u.push(a),Qt[s.path]){case Qt.weights:h=t.NumberKeyframeTrack;break;case Qt.rotation:h=t.QuaternionKeyframeTrack;break;case Qt.translation:case Qt.scale:h=t.VectorKeyframeTrack;break;default:if(1===i.itemSize)h=t.NumberKeyframeTrack;else h=t.VectorKeyframeTrack}const c=void 0!==r.interpolation?te[r.interpolation]:t.InterpolateLinear,l=this.lt(i);for(let t=0,e=u.length;t<e;t++){const e=new h(u[t]+"."+Qt[s.path],n.array,l,c);"CUBICSPLINE"===r.interpolation&&this.ft(e),o.push(e)}return o}lt(t){let e=t.array;if(t.normalized){const t=ce(e.constructor),n=new Float32Array(e.length);for(let i=0,r=e.length;i<r;i++)n[i]=e[i]*t;e=n}return e}ft(e){e.createInterpolant=function(e){return new(this instanceof t.QuaternionKeyframeTrack?Yt:Xt)(this.times,this.values,this.getValueSize()/3,e)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function de(e,n,i){const r=n.attributes,s=[];function o(t,n){return i.getDependency("accessor",t).then(function(t){e.setAttribute(n,t)})}for(const t in r){const n=qt[t]||t.toLowerCase();n in e.attributes||s.push(o(r[t],n))}if(void 0!==n.indices&&!e.index){const t=i.getDependency("accessor",n.indices).then(function(t){e.setIndex(t)});s.push(t)}return t.ColorManagement.workingColorSpace,t.LinearSRGBColorSpace,oe(e,n),function(e,n,i){const r=n.attributes,s=new t.Box3;if(void 0===r.POSITION)return;{const e=i.json.accessors[r.POSITION],n=e.min,o=e.max;if(void 0===n||void 0===o)return;if(s.set(new t.Vector3(n[0],n[1],n[2]),new t.Vector3(o[0],o[1],o[2])),e.normalized){const t=ce(Zt[e.componentType]);s.min.multiplyScalar(t),s.max.multiplyScalar(t)}}const o=n.targets;if(void 0!==o){const e=new t.Vector3,n=new t.Vector3;for(let t=0,r=o.length;t<r;t++){const r=o[t];if(void 0!==r.POSITION){const t=i.json.accessors[r.POSITION],s=t.min,o=t.max;if(void 0!==s&&void 0!==o){if(n.setX(Math.max(Math.abs(s[0]),Math.abs(o[0]))),n.setY(Math.max(Math.abs(s[1]),Math.abs(o[1]))),n.setZ(Math.max(Math.abs(s[2]),Math.abs(o[2]))),t.normalized){const e=ce(Zt[t.componentType]);n.multiplyScalar(e)}e.max(n)}}}s.expandByVector(e)}e.boundingBox=s;const a=new t.Sphere;s.getCenter(a.center),a.radius=s.min.distanceTo(s.max)/2,e.boundingSphere=a}(e,n,i),Promise.all(s).then(function(){return void 0!==n.targets?function(t,e,n){let i=!1,r=!1,s=!1;for(let t=0,n=e.length;t<n;t++){const n=e[t];if(void 0!==n.POSITION&&(i=!0),void 0!==n.NORMAL&&(r=!0),void 0!==n.COLOR_0&&(s=!0),i&&r&&s)break}if(!i&&!r&&!s)return Promise.resolve(t);const o=[],a=[],u=[];for(let h=0,c=e.length;h<c;h++){const c=e[h];if(i){const e=void 0!==c.POSITION?n.getDependency("accessor",c.POSITION):t.attributes.position;o.push(e)}if(r){const e=void 0!==c.NORMAL?n.getDependency("accessor",c.NORMAL):t.attributes.normal;a.push(e)}if(s){const e=void 0!==c.COLOR_0?n.getDependency("accessor",c.COLOR_0):t.attributes.color;u.push(e)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(u)]).then(function(e){const n=e[0],o=e[1],a=e[2];return i&&(t.morphAttributes.position=n),r&&(t.morphAttributes.normal=o),s&&(t.morphAttributes.color=a),t.morphTargetsRelative=!0,t})}(e,n.targets,i):e})}var ve=new(function(){return c(function t(){a(this,t),this.modelCache=new Map,this.loadingPromises=new Map,this.gltfLoader=new wt,this.isPreloading=!1,this.preloadingPromise=null,this.componentDictionary=null},[{key:"preloadAllModels",value:(n=s(g().m(function t(e){var n,i,r=this;return g().w(function(t){for(;;)switch(t.n){case 0:if(!this.isPreloading){t.n=1;break}return t.a(2,this.preloadingPromise);case 1:if(e&&"object"===A(e)){t.n=2;break}return t.a(2,Promise.reject(new Error("Invalid component dictionary")));case 2:return this.componentDictionary=e,this.isPreloading=!0,n=[],i=[],Object.keys(e).forEach(function(t){var i=e[t];i&&i.modelKey&&(n.includes(i.modelKey)||n.push(i.modelKey))}),n.forEach(function(t){i.push(r.preloadSingleModel(t))}),this.preloadingPromise=Promise.allSettled(i).then(function(t){var e=t.filter(function(t){return"fulfilled"===t.status}).length,i=t.filter(function(t){return"rejected"===t.status}).length;return r.isPreloading=!1,{successful:e,failed:i,total:n.length,cache:r.modelCache}}),t.a(2,this.preloadingPromise)}},t,this)})),function(t){return n.apply(this,arguments)})},{key:"preloadSingleModel",value:(e=s(g().m(function t(e){var n,i=this;return g().w(function(t){for(;;)switch(t.n){case 0:if(!this.modelCache.has(e)){t.n=1;break}return t.a(2,this.modelCache.get(e));case 1:if(!this.loadingPromises.has(e)){t.n=2;break}return t.a(2,this.loadingPromises.get(e));case 2:return n=new Promise(function(t,n){i.gltfLoader.load("/library/models/".concat(e),function(n){i.modelCache.set(e,n.scene),i.loadingPromises.delete(e),t(n.scene)},function(t){t.loaded,t.total},function(t){i.loadingPromises.delete(e),n(t)})}),this.loadingPromises.set(e,n),t.a(2,n)}},t,this)})),function(t){return e.apply(this,arguments)})},{key:"getCachedModel",value:function(t){return this.modelCache.has(t)?this.modelCache.get(t).clone():null}},{key:"getCachedModelWithDimensions",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(this.modelCache.has(t)){var n=this.modelCache.get(t).clone();if(e&&this.componentDictionary){var i=this.componentDictionary[e];i&&i.boundingBox&&(n.userData||(n.userData={}),n.userData.dimensions={x:i.boundingBox.x,y:i.boundingBox.y,z:i.boundingBox.z})}return n}return null}},{key:"addDimensionsToModel",value:function(t,e){if(!t||!e)return t;if(this.componentDictionary){var n=this.componentDictionary[e];n&&n.boundingBox&&(t.userData||(t.userData={}),t.userData.dimensions={x:n.boundingBox.x,y:n.boundingBox.y,z:n.boundingBox.z})}return t}},{key:"getStatus",value:function(){return{isPreloading:this.isPreloading,cachedModels:Array.from(this.modelCache.keys()),totalCached:this.modelCache.size,currentlyLoading:Array.from(this.loadingPromises.keys())}}},{key:"reloadModel",value:(t=s(g().m(function t(e){return g().w(function(t){for(;;)if(0===t.n)return this.modelCache.delete(e),this.loadingPromises.delete(e),t.a(2,this.preloadSingleModel(e))},t,this)})),function(e){return t.apply(this,arguments)})},{key:"clearCache",value:function(){this.modelCache.forEach(function(t,e){t&&t.traverse&&t.traverse(function(t){t.geometry&&t.geometry.dispose(),t.material&&(Array.isArray(t.material)?t.material.forEach(function(t){return t.dispose()}):t.material.dispose())})}),this.modelCache.clear(),this.loadingPromises.clear(),this.isPreloading=!1,this.preloadingPromise=null}},{key:"getCacheStats",value:function(){var t={totalModels:this.modelCache.size,loadingModels:this.loadingPromises.size,isPreloading:this.isPreloading,memoryUsage:0};return this.modelCache.forEach(function(e){e&&e.traverse&&e.traverse(function(e){var n;e.geometry&&(t.memoryUsage+=12*((null===(n=e.geometry.attributes.position)||void 0===n?void 0:n.count)||0))})}),t}}]);var t,e,n}()),pe=function(){return c(function t(e){a(this,t),this.sceneViewer=e},[{key:"addComponentToScene",value:(t=s(g().m(function t(e){var n,i,r,s,o,a,u,h,c,l,f=this;return g().w(function(t){for(;;)switch(t.n){case 0:if(t.p=0,e.libraryId&&e.modelKey){t.n=1;break}return t.a(2,!1);case 1:return i=e.libraryId+"-"+Date.now()+"-"+Math.random().toString(36).substr(2,9),r={},t.p=2,t.n=3,fetch("./library/component-dictionary.json");case 3:return s=t.v,t.n=4,s.json();case 4:r=t.v,t.n=6;break;case 5:return t.p=5,t.v,t.a(2,!1);case 6:if(o=r[e.libraryId]){t.n=7;break}return t.a(2,!1);case 7:if(a=e.position||{x:0,y:0,z:0},u=ve.getCachedModelWithDimensions(o.modelKey,e.libraryId)){t.n=11;break}return t.p=8,t.n=9,new Promise(function(t,e){f.sceneViewer.gltfLoader.load("./library/models/".concat(o.modelKey),t,void 0,e)});case 9:h=t.v,u=h.scene,u=ve.addDimensionsToModel(u,e.libraryId),t.n=11;break;case 10:return t.p=10,t.v,t.a(2,!1);case 11:return(c=u.clone()).uuid=i,c.name=(e.uuid||e.libraryId)+" Component",c.position.set(a.x,a.y,a.z),c.userData=y({libraryId:e.libraryId,componentType:"component",forExport:!0,originalUuid:i},(null===(n=u.userData)||void 0===n?void 0:n.dimensions)&&{dimensions:u.userData.dimensions}),o.boundingBox&&(c.userData.dimensions={x:o.boundingBox.x,y:o.boundingBox.y,z:o.boundingBox.z}),o.adaptedBoundingBox&&(c.userData.adaptedBoundingBox={x:o.adaptedBoundingBox.x,y:o.adaptedBoundingBox.y,z:o.adaptedBoundingBox.z}),c.traverse(function(t){t.isMesh&&(t.castShadow=!0,t.receiveShadow=!0,t.material&&(t.material.envMapIntensity=1),t.name&&t.name.toLowerCase().includes("connector")&&(t.userData||(t.userData={}),t.userData.forExport=!0,t.userData.componentType="connector"))}),this.sceneViewer.scene.add(c),"undefined"!=typeof window&&(l=new CustomEvent("componentAdded",{detail:{component:c,libraryId:e.libraryId,uuid:i,position:c.position,dimensions:c.userData.dimensions}}),window.dispatchEvent(l)),this.sceneViewer.enableTransformControls&&this.sceneViewer.enableTransformControls(),t.a(2,!0);case 12:return t.p=12,t.v,t.a(2,!1)}},t,this,[[8,10],[2,5],[0,12]])})),function(e){return t.apply(this,arguments)})},{key:"removeComponentFromScene",value:function(t){try{var e=ft(this.sceneViewer.scene,t);if(!e)return!1;if(e.traverse(function(t){t.geometry&&t.geometry.dispose(),t.material&&(Array.isArray(t.material)?t.material.forEach(function(t){return t.dispose()}):t.material.dispose())}),this.sceneViewer.scene.remove(e),"undefined"!=typeof window){var n,i=new CustomEvent("componentRemoved",{detail:{uuid:t,name:e.name,libraryId:null===(n=e.userData)||void 0===n?void 0:n.libraryId}});window.dispatchEvent(i)}return!0}catch(t){return!1}}},{key:"getSceneComponents",value:function(){var t=[];return this.sceneViewer.scene.traverse(function(e){var n,i;"component"===(null===(n=e.userData)||void 0===n?void 0:n.componentType)&&t.push({uuid:(null===(i=e.userData)||void 0===i?void 0:i.originalUuid)||e.uuid,name:e.name,libraryId:e.userData.libraryId,position:{x:e.position.x,y:e.position.y,z:e.position.z},rotation:{x:e.rotation.x,y:e.rotation.y,z:e.rotation.z},scale:{x:e.scale.x,y:e.scale.y,z:e.scale.z}})}),t}},{key:"updateComponent",value:function(t,e){try{var n,i,r,s,o,a,u,h,c,l=ft(this.sceneViewer.scene,t);if(!l)return!1;if(e.position)l.position.set(null!==(n=e.position.x)&&void 0!==n?n:l.position.x,null!==(i=e.position.y)&&void 0!==i?i:l.position.y,null!==(r=e.position.z)&&void 0!==r?r:l.position.z);if(e.rotation)l.rotation.set(null!==(s=e.rotation.x)&&void 0!==s?s:l.rotation.x,null!==(o=e.rotation.y)&&void 0!==o?o:l.rotation.y,null!==(a=e.rotation.z)&&void 0!==a?a:l.rotation.z);if(e.scale)l.scale.set(null!==(u=e.scale.x)&&void 0!==u?u:l.scale.x,null!==(h=e.scale.y)&&void 0!==h?h:l.scale.y,null!==(c=e.scale.z)&&void 0!==c?c:l.scale.z);return e.name&&(l.name=e.name),!0}catch(t){return!1}}}]);var t}();const we={type:"change"},me={type:"start"},ye={type:"end"},ge=new t.Ray,be=new t.Plane,ke=Math.cos(70*t.MathUtils.DEG2RAD),Me=new t.Vector3,xe=2*Math.PI,Te=-1,Se=0,Ee=1,Ae=2,_e=3,Oe=4,Ce=5,Re=6,Pe=1e-6;class je extends t.Controls{constructor(e,n=null){super(e,n),this.state=Te,this.target=new t.Vector3,this.cursor=new t.Vector3,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:t.MOUSE.ROTATE,MIDDLE:t.MOUSE.DOLLY,RIGHT:t.MOUSE.PAN},this.touches={ONE:t.TOUCH.ROTATE,TWO:t.TOUCH.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.dt=null,this.vt=new t.Vector3,this.wt=new t.Quaternion,this.yt=new t.Vector3,this.gt=(new t.Quaternion).setFromUnitVectors(e.up,new t.Vector3(0,1,0)),this.bt=this.gt.clone().invert(),this.kt=new t.Spherical,this.Mt=new t.Spherical,this.xt=1,this.Tt=new t.Vector3,this.St=new t.Vector2,this.Et=new t.Vector2,this.At=new t.Vector2,this._t=new t.Vector2,this.Ot=new t.Vector2,this.Ct=new t.Vector2,this.Rt=new t.Vector2,this.Pt=new t.Vector2,this.jt=new t.Vector2,this.Dt=new t.Vector3,this.It=new t.Vector2,this.Nt=!1,this.Lt=[],this.Bt={},this.Ft=!1,this.B=Ie.bind(this),this.N=De.bind(this),this.F=Ne.bind(this),this.Ut=Ge.bind(this),this.zt=Fe.bind(this),this.Ht=Ue.bind(this),this.Gt=ze.bind(this),this.Xt=He.bind(this),this.Vt=Le.bind(this),this.Yt=Be.bind(this),this.Kt=Xe.bind(this),this.Zt=Ve.bind(this),null!==this.domElement&&this.connect(this.domElement),this.update()}connect(t){super.connect(t),this.domElement.addEventListener("pointerdown",this.N),this.domElement.addEventListener("pointercancel",this.F),this.domElement.addEventListener("contextmenu",this.Ut),this.domElement.addEventListener("wheel",this.zt,{passive:!1});this.domElement.getRootNode().addEventListener("keydown",this.Kt,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this.N),this.domElement.removeEventListener("pointermove",this.B),this.domElement.removeEventListener("pointerup",this.F),this.domElement.removeEventListener("pointercancel",this.F),this.domElement.removeEventListener("wheel",this.zt),this.domElement.removeEventListener("contextmenu",this.Ut),this.stopListenToKeyEvents();this.domElement.getRootNode().removeEventListener("keydown",this.Kt,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this.kt.phi}getAzimuthalAngle(){return this.kt.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(t){t.addEventListener("keydown",this.Ht),this.dt=t}stopListenToKeyEvents(){null!==this.dt&&(this.dt.removeEventListener("keydown",this.Ht),this.dt=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(we),this.update(),this.state=Te}update(e=null){const n=this.object.position;Me.copy(n).sub(this.target),Me.applyQuaternion(this.gt),this.kt.setFromVector3(Me),this.autoRotate&&this.state===Te&&this.Wt(this.$t(e)),this.enableDamping?(this.kt.theta+=this.Mt.theta*this.dampingFactor,this.kt.phi+=this.Mt.phi*this.dampingFactor):(this.kt.theta+=this.Mt.theta,this.kt.phi+=this.Mt.phi);let i=this.minAzimuthAngle,r=this.maxAzimuthAngle;isFinite(i)&&isFinite(r)&&(i<-Math.PI?i+=xe:i>Math.PI&&(i-=xe),r<-Math.PI?r+=xe:r>Math.PI&&(r-=xe),this.kt.theta=i<=r?Math.max(i,Math.min(r,this.kt.theta)):this.kt.theta>(i+r)/2?Math.max(i,this.kt.theta):Math.min(r,this.kt.theta)),this.kt.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this.kt.phi)),this.kt.makeSafe(),!0===this.enableDamping?this.target.addScaledVector(this.Tt,this.dampingFactor):this.target.add(this.Tt),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let s=!1;if(this.zoomToCursor&&this.Nt||this.object.isOrthographicCamera)this.kt.radius=this.Jt(this.kt.radius);else{const t=this.kt.radius;this.kt.radius=this.Jt(this.kt.radius*this.xt),s=t!=this.kt.radius}if(Me.setFromSpherical(this.kt),Me.applyQuaternion(this.bt),n.copy(this.target).add(Me),this.object.lookAt(this.target),!0===this.enableDamping?(this.Mt.theta*=1-this.dampingFactor,this.Mt.phi*=1-this.dampingFactor,this.Tt.multiplyScalar(1-this.dampingFactor)):(this.Mt.set(0,0,0),this.Tt.set(0,0,0)),this.zoomToCursor&&this.Nt){let e=null;if(this.object.isPerspectiveCamera){const t=Me.length();e=this.Jt(t*this.xt);const n=t-e;this.object.position.addScaledVector(this.Dt,n),this.object.updateMatrixWorld(),s=!!n}else if(this.object.isOrthographicCamera){const n=new t.Vector3(this.It.x,this.It.y,0);n.unproject(this.object);const i=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this.xt)),this.object.updateProjectionMatrix(),s=i!==this.object.zoom;const r=new t.Vector3(this.It.x,this.It.y,0);r.unproject(this.object),this.object.position.sub(r).add(n),this.object.updateMatrixWorld(),e=Me.length()}else this.zoomToCursor=!1;null!==e&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(e).add(this.object.position):(ge.origin.copy(this.object.position),ge.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(ge.direction))<ke?this.object.lookAt(this.target):(be.setFromNormalAndCoplanarPoint(this.object.up,this.target),ge.intersectPlane(be,this.target))))}else if(this.object.isOrthographicCamera){const t=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this.xt)),t!==this.object.zoom&&(this.object.updateProjectionMatrix(),s=!0)}return this.xt=1,this.Nt=!1,!!(s||this.vt.distanceToSquared(this.object.position)>Pe||8*(1-this.wt.dot(this.object.quaternion))>Pe||this.yt.distanceToSquared(this.target)>Pe)&&(this.dispatchEvent(we),this.vt.copy(this.object.position),this.wt.copy(this.object.quaternion),this.yt.copy(this.target),!0)}$t(t){return null!==t?xe/60*this.autoRotateSpeed*t:xe/60/60*this.autoRotateSpeed}qt(t){const e=Math.abs(.01*t);return Math.pow(.95,this.zoomSpeed*e)}Wt(t){this.Mt.theta-=t}Qt(t){this.Mt.phi-=t}te(t,e){Me.setFromMatrixColumn(e,0),Me.multiplyScalar(-t),this.Tt.add(Me)}ee(t,e){!0===this.screenSpacePanning?Me.setFromMatrixColumn(e,1):(Me.setFromMatrixColumn(e,0),Me.crossVectors(this.object.up,Me)),Me.multiplyScalar(t),this.Tt.add(Me)}ne(t,e){const n=this.domElement;if(this.object.isPerspectiveCamera){const i=this.object.position;Me.copy(i).sub(this.target);let r=Me.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this.te(2*t*r/n.clientHeight,this.object.matrix),this.ee(2*e*r/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this.te(t*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this.ee(e*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):this.enablePan=!1}ie(t){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this.xt/=t:this.enableZoom=!1}re(t){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this.xt*=t:this.enableZoom=!1}se(t,e){if(!this.zoomToCursor)return;this.Nt=!0;const n=this.domElement.getBoundingClientRect(),i=t-n.left,r=e-n.top,s=n.width,o=n.height;this.It.x=i/s*2-1,this.It.y=-r/o*2+1,this.Dt.set(this.It.x,this.It.y,1).unproject(this.object).sub(this.object.position).normalize()}Jt(t){return Math.max(this.minDistance,Math.min(this.maxDistance,t))}oe(t){this.St.set(t.clientX,t.clientY)}ae(t){this.se(t.clientX,t.clientX),this.Rt.set(t.clientX,t.clientY)}ue(t){this._t.set(t.clientX,t.clientY)}he(t){this.Et.set(t.clientX,t.clientY),this.At.subVectors(this.Et,this.St).multiplyScalar(this.rotateSpeed);const e=this.domElement;this.Wt(xe*this.At.x/e.clientHeight),this.Qt(xe*this.At.y/e.clientHeight),this.St.copy(this.Et),this.update()}ce(t){this.Pt.set(t.clientX,t.clientY),this.jt.subVectors(this.Pt,this.Rt),this.jt.y>0?this.ie(this.qt(this.jt.y)):this.jt.y<0&&this.re(this.qt(this.jt.y)),this.Rt.copy(this.Pt),this.update()}le(t){this.Ot.set(t.clientX,t.clientY),this.Ct.subVectors(this.Ot,this._t).multiplyScalar(this.panSpeed),this.ne(this.Ct.x,this.Ct.y),this._t.copy(this.Ot),this.update()}fe(t){this.se(t.clientX,t.clientY),t.deltaY<0?this.re(this.qt(t.deltaY)):t.deltaY>0&&this.ie(this.qt(t.deltaY)),this.update()}de(t){let e=!1;switch(t.code){case this.keys.UP:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this.Qt(xe*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this.ne(0,this.keyPanSpeed),e=!0;break;case this.keys.BOTTOM:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this.Qt(-xe*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this.ne(0,-this.keyPanSpeed),e=!0;break;case this.keys.LEFT:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this.Wt(xe*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this.ne(this.keyPanSpeed,0),e=!0;break;case this.keys.RIGHT:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this.Wt(-xe*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this.ne(-this.keyPanSpeed,0),e=!0}e&&(t.preventDefault(),this.update())}ve(t){if(1===this.Lt.length)this.St.set(t.pageX,t.pageY);else{const e=this.pe(t),n=.5*(t.pageX+e.x),i=.5*(t.pageY+e.y);this.St.set(n,i)}}we(t){if(1===this.Lt.length)this._t.set(t.pageX,t.pageY);else{const e=this.pe(t),n=.5*(t.pageX+e.x),i=.5*(t.pageY+e.y);this._t.set(n,i)}}me(t){const e=this.pe(t),n=t.pageX-e.x,i=t.pageY-e.y,r=Math.sqrt(n*n+i*i);this.Rt.set(0,r)}ye(t){this.enableZoom&&this.me(t),this.enablePan&&this.we(t)}ge(t){this.enableZoom&&this.me(t),this.enableRotate&&this.ve(t)}be(t){if(1==this.Lt.length)this.Et.set(t.pageX,t.pageY);else{const e=this.pe(t),n=.5*(t.pageX+e.x),i=.5*(t.pageY+e.y);this.Et.set(n,i)}this.At.subVectors(this.Et,this.St).multiplyScalar(this.rotateSpeed);const e=this.domElement;this.Wt(xe*this.At.x/e.clientHeight),this.Qt(xe*this.At.y/e.clientHeight),this.St.copy(this.Et)}ke(t){if(1===this.Lt.length)this.Ot.set(t.pageX,t.pageY);else{const e=this.pe(t),n=.5*(t.pageX+e.x),i=.5*(t.pageY+e.y);this.Ot.set(n,i)}this.Ct.subVectors(this.Ot,this._t).multiplyScalar(this.panSpeed),this.ne(this.Ct.x,this.Ct.y),this._t.copy(this.Ot)}Me(t){const e=this.pe(t),n=t.pageX-e.x,i=t.pageY-e.y,r=Math.sqrt(n*n+i*i);this.Pt.set(0,r),this.jt.set(0,Math.pow(this.Pt.y/this.Rt.y,this.zoomSpeed)),this.ie(this.jt.y),this.Rt.copy(this.Pt);const s=.5*(t.pageX+e.x),o=.5*(t.pageY+e.y);this.se(s,o)}xe(t){this.enableZoom&&this.Me(t),this.enablePan&&this.ke(t)}Te(t){this.enableZoom&&this.Me(t),this.enableRotate&&this.be(t)}Se(t){this.Lt.push(t.pointerId)}Ee(t){delete this.Bt[t.pointerId];for(let e=0;e<this.Lt.length;e++)if(this.Lt[e]==t.pointerId)return void this.Lt.splice(e,1)}Ae(t){for(let e=0;e<this.Lt.length;e++)if(this.Lt[e]==t.pointerId)return!0;return!1}_e(e){let n=this.Bt[e.pointerId];void 0===n&&(n=new t.Vector2,this.Bt[e.pointerId]=n),n.set(e.pageX,e.pageY)}pe(t){const e=t.pointerId===this.Lt[0]?this.Lt[1]:this.Lt[0];return this.Bt[e]}Oe(t){const e=t.deltaMode,n={clientX:t.clientX,clientY:t.clientY,deltaY:t.deltaY};switch(e){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100}return t.ctrlKey&&!this.Ft&&(n.deltaY*=10),n}}function De(t){!1!==this.enabled&&(0===this.Lt.length&&(this.domElement.setPointerCapture(t.pointerId),this.domElement.addEventListener("pointermove",this.B),this.domElement.addEventListener("pointerup",this.F)),this.Ae(t)||(this.Se(t),"touch"===t.pointerType?this.Gt(t):this.Vt(t)))}function Ie(t){!1!==this.enabled&&("touch"===t.pointerType?this.Xt(t):this.Yt(t))}function Ne(t){switch(this.Ee(t),this.Lt.length){case 0:this.domElement.releasePointerCapture(t.pointerId),this.domElement.removeEventListener("pointermove",this.B),this.domElement.removeEventListener("pointerup",this.F),this.dispatchEvent(ye),this.state=Te;break;case 1:const e=this.Lt[0],n=this.Bt[e];this.Gt({pointerId:e,pageX:n.x,pageY:n.y})}}function Le(e){let n;switch(e.button){case 0:n=this.mouseButtons.LEFT;break;case 1:n=this.mouseButtons.MIDDLE;break;case 2:n=this.mouseButtons.RIGHT;break;default:n=-1}switch(n){case t.MOUSE.DOLLY:if(!1===this.enableZoom)return;this.ae(e),this.state=Ee;break;case t.MOUSE.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(!1===this.enablePan)return;this.ue(e),this.state=Ae}else{if(!1===this.enableRotate)return;this.oe(e),this.state=Se}break;case t.MOUSE.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(!1===this.enableRotate)return;this.oe(e),this.state=Se}else{if(!1===this.enablePan)return;this.ue(e),this.state=Ae}break;default:this.state=Te}this.state!==Te&&this.dispatchEvent(me)}function Be(t){switch(this.state){case Se:if(!1===this.enableRotate)return;this.he(t);break;case Ee:if(!1===this.enableZoom)return;this.ce(t);break;case Ae:if(!1===this.enablePan)return;this.le(t)}}function Fe(t){!1!==this.enabled&&!1!==this.enableZoom&&this.state===Te&&(t.preventDefault(),this.dispatchEvent(me),this.fe(this.Oe(t)),this.dispatchEvent(ye))}function Ue(t){!1!==this.enabled&&this.de(t)}function ze(e){switch(this._e(e),this.Lt.length){case 1:switch(this.touches.ONE){case t.TOUCH.ROTATE:if(!1===this.enableRotate)return;this.ve(e),this.state=_e;break;case t.TOUCH.PAN:if(!1===this.enablePan)return;this.we(e),this.state=Oe;break;default:this.state=Te}break;case 2:switch(this.touches.TWO){case t.TOUCH.DOLLY_PAN:if(!1===this.enableZoom&&!1===this.enablePan)return;this.ye(e),this.state=Ce;break;case t.TOUCH.DOLLY_ROTATE:if(!1===this.enableZoom&&!1===this.enableRotate)return;this.ge(e),this.state=Re;break;default:this.state=Te}break;default:this.state=Te}this.state!==Te&&this.dispatchEvent(me)}function He(t){switch(this._e(t),this.state){case _e:if(!1===this.enableRotate)return;this.be(t),this.update();break;case Oe:if(!1===this.enablePan)return;this.ke(t),this.update();break;case Ce:if(!1===this.enableZoom&&!1===this.enablePan)return;this.xe(t),this.update();break;case Re:if(!1===this.enableZoom&&!1===this.enableRotate)return;this.Te(t),this.update();break;default:this.state=Te}}function Ge(t){!1!==this.enabled&&t.preventDefault()}function Xe(t){if("Control"===t.key){this.Ft=!0;this.domElement.getRootNode().addEventListener("keyup",this.Zt,{passive:!0,capture:!0})}}function Ve(t){if("Control"===t.key){this.Ft=!1;this.domElement.getRootNode().removeEventListener("keyup",this.Zt,{passive:!0,capture:!0})}}var Ye=function(){return c(function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;a(this,t),this.renderer=e,this.stats={fps:{current:0,average:0,min:1/0,max:0,history:[]},frameTime:{current:0,average:0,min:1/0,max:0,history:[]},memory:{geometries:0,textures:0,programs:0,heapUsed:0,heapTotal:0},drawCalls:{current:0,average:0,triangles:0,points:0,lines:0},gpu:{memoryUsage:0,extensions:[]},scene:{objects:0,lights:0,meshes:0,materials:0,visible:0}},this.frameCount=0,this.lastTime=performance.now(),this.updateInterval=100,this.maxHistoryLength=300,this.thresholds={fps:{good:55,warning:45,critical:30},frameTime:{good:16.67,warning:22.22,critical:33.33},memory:{warning:200,critical:300},drawCalls:{warning:500,critical:1e3}},this.callbacks=new Map,this.isMonitoring=!1,this.update=this.update.bind(this),this.getGPUInfo=this.getGPUInfo.bind(this)},[{key:"start",value:function(){this.isMonitoring=!0,this.lastTime=performance.now(),this.getGPUInfo()}},{key:"stop",value:function(){this.isMonitoring=!1}},{key:"update",value:function(){if(this.isMonitoring){var t=performance.now(),e=t-this.lastTime;this.frameCount++;var n=1e3/e,i=e;this.stats.fps.current=n,this.stats.frameTime.current=i,this.addToHistory(this.stats.fps,n),this.addToHistory(this.stats.frameTime,i),this.frameCount%this.updateInterval===0&&(this.updateAverages(),this.updateMemoryStats(),this.updateDrawCallStats(),this.updateSceneStats(),this.checkThresholds()),this.lastTime=t}}},{key:"addToHistory",value:function(t,e){t.history.push(e),t.history.length>this.maxHistoryLength&&t.history.shift(),t.min=Math.min(t.min,e),t.max=Math.max(t.max,e)}},{key:"updateAverages",value:function(){this.stats.fps.history.length>0&&(this.stats.fps.average=this.stats.fps.history.reduce(function(t,e){return t+e},0)/this.stats.fps.history.length),this.stats.frameTime.history.length>0&&(this.stats.frameTime.average=this.stats.frameTime.history.reduce(function(t,e){return t+e},0)/this.stats.frameTime.history.length)}},{key:"updateMemoryStats",value:function(){var t;if(this.renderer){var e=this.renderer.info;this.stats.memory.geometries=e.memory.geometries,this.stats.memory.textures=e.memory.textures,this.stats.memory.programs=(null===(t=e.programs)||void 0===t?void 0:t.length)||0,performance.memory&&(this.stats.memory.heapUsed=Math.round(performance.memory.usedJSHeapSize/1024/1024),this.stats.memory.heapTotal=Math.round(performance.memory.totalJSHeapSize/1024/1024))}}},{key:"updateDrawCallStats",value:function(){if(this.renderer){var t=this.renderer.info.render;this.stats.drawCalls.current=t.calls,this.stats.drawCalls.triangles=t.triangles,this.stats.drawCalls.points=t.points,this.stats.drawCalls.lines=t.lines,this.stats.drawCalls.history||(this.stats.drawCalls.history=[]),this.addToHistory(this.stats.drawCalls,t.calls),this.stats.drawCalls.history.length>0&&(this.stats.drawCalls.average=this.stats.drawCalls.history.reduce(function(t,e){return t+e},0)/this.stats.drawCalls.history.length)}}},{key:"updateSceneStats",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;if(t){var e,n=0,i=0,r=0,s=new Set,o=0,a=l(t.children);try{for(a.s();!(e=a.n()).done;){var u=e.value;n++,u.visible&&o++,u.isLight&&i++,u.isMesh&&(r++,u.material&&(Array.isArray(u.material)?u.material.forEach(function(t){return s.add(t.uuid)}):s.add(u.material.uuid)))}}catch(t){a.e(t)}finally{a.f()}this.stats.scene={objects:n,lights:i,meshes:r,materials:s.size,visible:o}}}},{key:"getGPUInfo",value:function(){if(this.renderer){var t=this.renderer.getContext();this.stats.gpu.extensions=t.getSupportedExtensions()||[];var e=t.getExtension("WEBGL_debug_renderer_info");e&&(this.stats.gpu.renderer=t.getParameter(e.UNMASKED_RENDERER_WEBGL),this.stats.gpu.vendor=t.getParameter(e.UNMASKED_VENDOR_WEBGL))}}},{key:"checkThresholds",value:function(){var t=[];this.stats.fps.average<this.thresholds.fps.critical?t.push({type:"critical",category:"FPS",value:this.stats.fps.average.toFixed(1),threshold:this.thresholds.fps.critical}):this.stats.fps.average<this.thresholds.fps.warning&&t.push({type:"warning",category:"FPS",value:this.stats.fps.average.toFixed(1),threshold:this.thresholds.fps.warning}),this.stats.frameTime.average>this.thresholds.frameTime.critical?t.push({type:"critical",category:"Frame Time",value:this.stats.frameTime.average.toFixed(2)+"ms",threshold:this.thresholds.frameTime.critical+"ms"}):this.stats.frameTime.average>this.thresholds.frameTime.warning&&t.push({type:"warning",category:"Frame Time",value:this.stats.frameTime.average.toFixed(2)+"ms",threshold:this.thresholds.frameTime.warning+"ms"}),this.stats.memory.heapUsed>this.thresholds.memory.critical?t.push({type:"critical",category:"Memory",value:this.stats.memory.heapUsed+"MB",threshold:this.thresholds.memory.critical+"MB"}):this.stats.memory.heapUsed>this.thresholds.memory.warning&&t.push({type:"warning",category:"Memory",value:this.stats.memory.heapUsed+"MB",threshold:this.thresholds.memory.warning+"MB"}),this.stats.drawCalls.average>this.thresholds.drawCalls.critical?t.push({type:"critical",category:"Draw Calls",value:Math.round(this.stats.drawCalls.average),threshold:this.thresholds.drawCalls.critical}):this.stats.drawCalls.average>this.thresholds.drawCalls.warning&&t.push({type:"warning",category:"Draw Calls",value:Math.round(this.stats.drawCalls.average),threshold:this.thresholds.drawCalls.warning}),t.length>0&&this.triggerCallback("warning",t)}},{key:"on",value:function(t,e){this.callbacks.has(t)||this.callbacks.set(t,[]),this.callbacks.get(t).push(e)}},{key:"off",value:function(t,e){if(this.callbacks.has(t)){var n=this.callbacks.get(t),i=n.indexOf(e);i>-1&&n.splice(i,1)}}},{key:"triggerCallback",value:function(t,e){this.callbacks.has(t)&&this.callbacks.get(t).forEach(function(t){return t(e)})}},{key:"getSummary",value:function(){return{fps:{current:Math.round(this.stats.fps.current),average:Math.round(this.stats.fps.average),min:Math.round(this.stats.fps.min),max:Math.round(this.stats.fps.max)},frameTime:{current:this.stats.frameTime.current.toFixed(2)+"ms",average:this.stats.frameTime.average.toFixed(2)+"ms"},memory:{geometries:this.stats.memory.geometries,textures:this.stats.memory.textures,heapUsed:this.stats.memory.heapUsed+"MB",heapTotal:this.stats.memory.heapTotal+"MB"},drawCalls:{current:this.stats.drawCalls.current,average:Math.round(this.stats.drawCalls.average),triangles:this.stats.drawCalls.triangles.toLocaleString()},scene:this.stats.scene}}},{key:"logSummary",value:function(){this.getSummary()}},{key:"reset",value:function(){var t=this;Object.keys(this.stats).forEach(function(e){t.stats[e].history&&(t.stats[e].history=[]),void 0!==t.stats[e].min&&(t.stats[e].min=1/0,t.stats[e].max=0,t.stats[e].average=0)}),this.frameCount=0}},{key:"exportData",value:function(){return{timestamp:(new Date).toISOString(),stats:JSON.parse(JSON.stringify(this.stats)),thresholds:this.thresholds,frameCount:this.frameCount}}}])}(),Ke=function(){return c(function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document.body,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"dark";a(this,t),this.monitor=e,this.container=n,this.element=null,this.isVisible=!1,this.updateInterval=null,this.theme=i},[{key:"show",value:function(){var t=this;this.cleanupExistingElements(),this.element&&this.hide(),this.element=document.createElement("div"),this.element.id="performance-monitor-ui",this.element.innerHTML=this.getHTML(),this.addStyles(),this.container.appendChild(this.element),this.isVisible=!0,this.startUpdating(),this.element.querySelector("#perf-toggle").addEventListener("click",function(){return t.toggleDetails()}),this.toggleDetails()}},{key:"cleanupExistingElements",value:function(){document.querySelectorAll("#performance-monitor-ui").forEach(function(t){try{t.parentNode&&t.parentNode.removeChild(t)}catch(t){}})}},{key:"hide",value:function(){this.stopUpdating(),this.removeDOMElement(),this.isVisible=!1}},{key:"dispose",value:function(){this.hide(),this.cleanupExistingElements(),this.monitor=null,this.container=null,this.element=null}},{key:"stopUpdating",value:function(){this.updateInterval&&(clearInterval(this.updateInterval),this.updateInterval=null)}},{key:"removeDOMElement",value:function(){if(this.element){try{this.element.parentNode&&this.container&&this.container.contains(this.element)?this.container.removeChild(this.element):this.element.parentNode&&this.element.parentNode.removeChild(this.element)}catch(t){try{this.element.remove&&this.element.remove()}catch(t){}}this.element=null}}},{key:"toggleDetails",value:function(){var t=this.element.querySelector("#perf-details"),e="none"===t.style.display;t.style.display=e?"block":"none",this.element.querySelector("#perf-toggle").textContent=e?"โ–ผ":"โ–ฒ"}},{key:"startUpdating",value:function(){var t=this;this.updateInterval=setInterval(function(){t.isVisible&&t.element&&t.updateContent()},500)}},{key:"updateContent",value:function(){var t=this.monitor.getSummary();this.updateElement("#fps-value",t.fps.current),this.updateElement("#frametime-value",t.frameTime.current),this.updateElement("#memory-value",t.memory.heapUsed),this.updateElement("#drawcalls-value",t.drawCalls.current),this.updateElement("#fps-avg",t.fps.average),this.updateElement("#fps-min",t.fps.min),this.updateElement("#fps-max",t.fps.max),this.updateElement("#geometries-value",t.memory.geometries),this.updateElement("#textures-value",t.memory.textures),this.updateElement("#triangles-value",t.drawCalls.triangles),this.updateElement("#objects-value",t.scene.objects),this.updateElement("#meshes-value",t.scene.meshes),this.updatePerformanceIndicators(t)}},{key:"updateElement",value:function(t,e){var n=this.element.querySelector(t);n&&(n.textContent=e)}},{key:"updatePerformanceIndicators",value:function(t){var e=this.element.querySelector("#fps-value"),n=this.element.querySelector("#frametime-value");if(e){var i=t.fps.current;e.className=this.getPerformanceClass("fps",i)}if(n){var r=parseFloat(t.frameTime.current);n.className=this.getPerformanceClass("frameTime",r)}}},{key:"getPerformanceClass",value:function(t,e){var n=this.monitor.thresholds[t];return"fps"===t?e>=n.good?"perf-good":e>=n.warning?"perf-warning":"perf-critical":"frameTime"===t?e<=n.good?"perf-good":e<=n.warning?"perf-warning":"perf-critical":""}},{key:"getHTML",value:function(){return'\n <div class="perf-header">\n <span class="perf-title">Performance</span>\n <button id="perf-toggle">โ–ผ</button>\n </div>\n <div class="perf-main">\n <div class="perf-stat">\n <span class="perf-label">FPS:</span>\n <span id="fps-value" class="perf-value">0</span>\n </div>\n <div class="perf-stat">\n <span class="perf-label">Frame:</span>\n <span id="frametime-value" class="perf-value">0ms</span>\n </div>\n <div class="perf-stat">\n <span class="perf-label">Memory:</span>\n <span id="memory-value" class="perf-value">0MB</span>\n </div>\n <div class="perf-stat">\n <span class="perf-label">Calls:</span>\n <span id="drawcalls-value" class="perf-value">0</span>\n </div>\n </div>\n <div id="perf-details" class="perf-details">\n <div class="perf-section">\n <div class="perf-section-title">FPS Stats</div>\n <div class="perf-detail">Avg: <span id="fps-avg">0</span></div>\n <div class="perf-detail">Min: <span id="fps-min">0</span></div>\n <div class="perf-detail">Max: <span id="fps-max">0</span></div>\n </div>\n <div class="perf-section">\n <div class="perf-section-title">Memory</div>\n <div class="perf-detail">Geometries: <span id="geometries-value">0</span></div>\n <div class="perf-detail">Textures: <span id="textures-value">0</span></div>\n </div>\n <div class="perf-section">\n <div class="perf-section-title">Rendering</div>\n <div class="perf-detail">Triangles: <span id="triangles-value">0</span></div>\n <div class="perf-detail">Objects: <span id="objects-value">0</span></div>\n <div class="perf-detail">Meshes: <span id="meshes-value">0</span></div>\n </div>\n </div>\n '}},{key:"addStyles",value:function(){if(!document.getElementById("performance-monitor-styles")){var t=document.createElement("style");t.id="performance-monitor-styles";var e={dark:{background:"rgba(0, 0, 0, 0.8)",color:"white",borderColor:"rgba(255, 255, 255, 0.1)",separatorColor:"rgba(255, 255, 255, 0.2)",sectionTitleColor:"#FFC107",goodColor:"#4CAF50",warningColor:"#FF9800",criticalColor:"#F44336"},light:{background:"rgba(255, 255, 255, 0.95)",color:"#333333",borderColor:"rgba(0, 0, 0, 0.15)",separatorColor:"rgba(0, 0, 0, 0.1)",sectionTitleColor:"#1565C0",goodColor:"#2E7D32",warningColor:"#E65100",criticalColor:"#C62828"}},n=e[this.theme]||e.dark;t.textContent=" #performance-monitor-ui {\n position: fixed;\n bottom: 10px;\n right: 10px;\n background: ".concat(n.background,";\n color: ").concat(n.color,";\n font-family: 'Consolas', 'Monaco', 'Courier New', monospace;\n font-size: 12px;\n padding: 10px;\n border-radius: 5px;\n z-index: 10000;\n min-width: 150px;\n backdrop-filter: blur(5px);\n border: 1px solid ").concat(n.borderColor,";\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n }\n\n .perf-header {\n display: flex;\n justify-content: space-between;\n align-items: center;\n margin-bottom: 8px;\n border-bottom: 1px solid ").concat(n.separatorColor,";\n padding-bottom: 5px;\n }\n\n .perf-title {\n font-weight: bold;\n font-size: 14px;\n }\n\n #perf-toggle {\n background: none;\n border: none;\n color: ").concat(n.color,";\n cursor: pointer;\n font-size: 12px;\n padding: 0;\n width: 20px;\n height: 20px;\n }\n\n .perf-main {\n display: grid;\n grid-template-columns: 1fr;\n gap: 4px;\n }\n\n .perf-stat {\n display: flex;\n justify-content: space-between;\n align-items: center;\n }\n\n .perf-label {\n opacity: 0.8;\n }\n\n .perf-value {\n font-weight: bold;\n text-align: right;\n min-width: 50px;\n } .perf-good {\n color: ").concat(n.goodColor,";\n }\n\n .perf-warning {\n color: ").concat(n.warningColor,";\n }\n\n .perf-critical {\n color: ").concat(n.criticalColor,";\n }\n\n .perf-details {\n margin-top: 10px;\n padding-top: 8px;\n border-top: 1px solid ").concat(n.separatorColor,";\n }\n\n .perf-section {\n margin-bottom: 8px;\n }\n\n .perf-section-title {\n font-weight: bold;\n font-size: 11px;\n margin-bottom: 3px;\n color: ").concat(n.sectionTitleColor,";\n }\n\n .perf-detail {\n font-size: 10px;\n display: flex;\n justify-content: space-between;\n margin-bottom: 2px;\n opacity: 0.9;\n }\n "),document.head.appendChild(t)}}},{key:"setTheme",value:function(t){if("light"===t||"dark"===t){this.theme=t;var e=document.getElementById("performance-monitor-styles");e&&e.remove(),this.addStyles()}}}],[{key:"cleanupAllInstances",value:function(){var t=document.querySelectorAll("#performance-monitor-ui"),e=0;if(t.forEach(function(t){try{t.parentNode&&(t.parentNode.removeChild(t),e++)}catch(t){}}),0===document.querySelectorAll("#performance-monitor-ui").length){var n=document.getElementById("performance-monitor-styles");n&&n.remove()}return e}}])}(),Ze=Object.freeze({__proto__:null,PerformanceMonitor:Ye,PerformanceUI:Ke}),We=function(){return c(function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"SceneViewer",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"info";a(this,t),this.namespace=e,this.debugLevel=n,this.isProduction="production"===process.env.NODE_ENV,this.enabled=!this.isProduction,this.levels={error:0,warn:1,info:2,debug:3,verbose:4},this.currentLevel=this.levels[n]||this.levels.info},[{key:"setLevel",value:function(t){return this.currentLevel=this.levels[t]||this.levels.info,this}},{key:"enable",value:function(){return this.enabled=!0,this}},{key:"disable",value:function(){return this.enabled=!1,this}},{key:"_shouldLog",value:function(t){return this.enabled&&this.levels[t]<=this.currentLevel}},{key:"_formatMessage",value:function(t,e){for(var n="[".concat(this.namespace,":").concat(t.toUpperCase(),"]"),i=arguments.length,r=new Array(i>2?i-2:0),s=2;s<i;s++)r[s-2]=arguments[s];return[n,e].concat(r)}},{key:"error",value:function(t){if(this.Ce("error")){for(var e,n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];(e=console).error.apply(e,S(this.Re.apply(this,["error",t].concat(i))))}}},{key:"warn",value:function(t){if(this.Ce("warn")){for(var e,n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];(e=console).warn.apply(e,S(this.Re.apply(this,["warn",t].concat(i))))}}},{key:"info",value:function(t){if(this.Ce("info")){for(var e,n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];(e=console).log.apply(e,S(this.Re.apply(this,["info",t].concat(i))))}}},{key:"debug",value:function(t){if(this.Ce("debug")){for(var e,n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];(e=console).debug.apply(e,S(this.Re.apply(this,["debug",t].concat(i))))}}},{key:"verbose",value:function(t){if(this.Ce("verbose")){for(var e,n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];(e=console).debug.apply(e,S(this.Re.apply(this,["verbose",t].concat(i))))}}},{key:"phase",value:function(t,e){for(var n=arguments.length,i=new Array(n>2?n-2:0),r=2;r<n;r++)i[r-2]=arguments[r];this.info.apply(this,["๐Ÿ” PHASE ".concat(t,": ").concat(e)].concat(i))}},{key:"success",value:function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];this.info.apply(this,["โœ… ".concat(t)].concat(n))}},{key:"failure",value:function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];this.error.apply(this,["โŒ ".concat(t)].concat(n))}},{key:"loading",value:function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];this.debug.apply(this,["๐Ÿ”„ ".concat(t)].concat(n))}},{key:"timing",value:function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];this.debug.apply(this,["โฑ๏ธ ".concat(t)].concat(n))}}])}(),$e=new We("SceneViewer","info"),Je=new We("Transform","warn"),qe=new We("Pathfinder","info"),Qe=new We("Models","info");new We("Materials","warn");var tn=function(){return c(function t(e){a(this,t),this.sceneViewer=e,this.textureLoader=null,this.gltfLoader=null},[{key:"initializeScene",value:(e=s(g().m(function t(){var e,i,r,s;return g().w(function(t){for(;;)switch(t.n){case 0:(e=this.sceneViewer).scene=new n.Scene,i=e.$refs.container.getBoundingClientRect(),r=i.width,s=i.height,e.camera=new n.PerspectiveCamera(50,r/s,.01,1e3),e.camera.position.set(-8,4,9),e.renderer=new n.WebGLRenderer({antialias:!0}),e.renderer.setSize(r,s),e.renderer.setPixelRatio(Math.min(window.devicePixelRatio,2)),e.renderer.shadowMap.enabled=!0,e.renderer.shadowMap.type=n.PCFSoftShadowMap,e.renderer.physicallyCorrectLights=!0,e.renderer.outputColorSpace=n.SRGBColorSpace,e.renderer.toneMapping=n.LinearToneMapping,e.renderer.toneMappingExposure=1.5,e.$refs.container.appendChild(e.renderer.domElement),$e.info("Scene, camera, and renderer initialized");case 1:return t.a(2)}},t,this)})),function(){return e.apply(this,arguments)})},{key:"initializePerformanceMonitoring",value:function(){var t=this.sceneViewer;if("development"===process.env.NODE_ENV)try{var e=document.querySelectorAll("#performance-monitor-ui");e.length>0&&e.forEach(function(t){t.parentNode&&t.parentNode.removeChild(t)})}catch(t){}t.performanceMonitor=new Ye(t.renderer),t.performanceUI=new Ke(t.performanceMonitor,t.$refs.container,"light"),t.performanceMonitor.on("warning",function(t){}),t.performanceMonitor.start(),t.performanceUI.show(),this.exposePerformanceMonitoringGlobally(),$e.info("Performance monitoring initialized")}},{key:"exposePerformanceMonitoringGlobally",value:function(){var t=this,e=this.sceneViewer;"undefined"!=typeof window&&(window._performanceMonitor=e.performanceMonitor,window._performanceUI=e.performanceUI,window.performance3D={show:function(){return e.performanceUI.show()},hide:function(){return e.performanceUI.hide()},toggle:function(){return e.performanceUI.isVisible?e.performanceUI.hide():e.performanceUI.show()},setTheme:function(t){return e.performanceUI.setTheme(t)},log:function(){return e.performanceMonitor.logSummary()},reset:function(){return e.performanceMonitor.reset()},export:function(){return e.performanceMonitor.exportData()},cleanup:function(){return e.cleanupDuplicatePerformanceMonitors?e.cleanupDuplicatePerformanceMonitors():0},help:function(){}},window.cameraControls={autoRotate:{enable:function(){return t.toggleAutoRotation(!0)},disable:function(){return t.toggleAutoRotation(!1)},toggle:function(){return t.toggleAutoRotation()},setSpeed:function(t){if(e.controls)return e.controls.autoRotateSpeed=t,t}},help:function(){}})}},{key:"initializeLoaders",value:function(){var t=this.sceneViewer;this.textureLoader=new n.TextureLoader,t.textureLoader=this.textureLoader,this.gltfLoader=new wt,t.gltfLoader=this.gltfLoader,$e.info("Texture and GLTF loaders initialized")}},{key:"setupControls",value:function(){this.sceneViewer.controls=new je(this.sceneViewer.camera,this.sceneViewer.renderer.domElement),this.sceneViewer.controls.enableDamping=!0,this.sceneViewer.controls.dampingFactor=.05,this.sceneViewer.controls.minDistance=1,this.sceneViewer.controls.maxDistance=20,this.sceneViewer.controls.maxPolarAngle=Math.PI/1.5,this.sceneViewer.controls.autoRotate=!0,this.sceneViewer.controls.autoRotateSpeed=.5,$e.info("Orbit controls initialized with auto-rotation")}},{key:"setDefaultBackground",value:function(){this.sceneViewer.scene.background=new n.Color(8965358),$e.info("Default scene background set")}},{key:"initialize",value:(t=s(g().m(function t(){return g().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,this.initializeScene();case 1:this.initializePerformanceMonitoring(),this.initializeLoaders(),this.setupControls(),this.setDefaultBackground(),$e.info("Scene initialization completed");case 2:return t.a(2)}},t,this)})),function(){return t.apply(this,arguments)})},{key:"toggleAutoRotation",value:function(t){var e=this.sceneViewer;return!!e.controls&&(e.controls.autoRotate=void 0!==t?t:!e.controls.autoRotate,e.controls.autoRotate&&(e.controls.dampingFactor=1,setTimeout(function(){e.controls.dampingFactor=.05},100)),$e.info("Camera auto-rotation is now ".concat(e.controls.autoRotate?"ENABLED":"DISABLED")),e.controls.autoRotate)}}]);var t,e}();class en extends t.DataTextureLoader{constructor(e){super(e),this.type=t.HalfFloatType}parse(e){const n=function(t,e){switch(t){case 1:throw new Error("THREE.RGBELoader: Read Error: "+(e||""));case 2:throw new Error("THREE.RGBELoader: Write Error: "+(e||""));case 3:throw new Error("THREE.RGBELoader: Bad File Format: "+(e||""));default:throw new Error("THREE.RGBELoader: Memory Error: "+(e||""))}},i=function(t,e,n){e=e||1024;let i=t.pos,r=-1,s=0,o="",a=String.fromCharCode.apply(null,new Uint16Array(t.subarray(i,i+128)));for(;0>(r=a.indexOf("\n"))&&s<e&&i<t.byteLength;)o+=a,s+=a.length,i+=128,a+=String.fromCharCode.apply(null,new Uint16Array(t.subarray(i,i+128)));return-1<r&&(!1!==n&&(t.pos+=s+r+1),o+a.slice(0,r))},r=function(t,e,n,i){const r=t[e+3],s=Math.pow(2,r-128)/255;n[i+0]=t[e+0]*s,n[i+1]=t[e+1]*s,n[i+2]=t[e+2]*s,n[i+3]=1},s=function(e,n,i,r){const s=e[n+3],o=Math.pow(2,s-128)/255;i[r+0]=t.DataUtils.toHalfFloat(Math.min(e[n+0]*o,65504)),i[r+1]=t.DataUtils.toHalfFloat(Math.min(e[n+1]*o,65504)),i[r+2]=t.DataUtils.toHalfFloat(Math.min(e[n+2]*o,65504)),i[r+3]=t.DataUtils.toHalfFloat(1)},o=new Uint8Array(e);o.pos=0;const a=function(t){const e=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,r=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,s=/^\s*FORMAT=(\S+)\s*$/,o=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,a={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let u,h;for((t.pos>=t.byteLength||!(u=i(t)))&&n(1,"no header found"),(h=u.match(/^#\?(\S+)/))||n(3,"bad initial token"),a.valid|=1,a.programtype=h[1],a.string+=u+"\n";u=i(t),!1!==u;)if(a.string+=u+"\n","#"!==u.charAt(0)){if((h=u.match(e))&&(a.gamma=parseFloat(h[1])),(h=u.match(r))&&(a.exposure=parseFloat(h[1])),(h=u.match(s))&&(a.valid|=2,a.format=h[1]),(h=u.match(o))&&(a.valid|=4,a.height=parseInt(h[1],10),a.width=parseInt(h[2],10)),2&a.valid&&4&a.valid)break}else a.comments+=u+"\n";return 2&a.valid||n(3,"missing format specifier"),4&a.valid||n(3,"missing image size specifier"),a}(o),u=a.width,h=a.height,c=function(t,e,i){const r=e;if(r<8||r>32767||2!==t[0]||2!==t[1]||128&t[2])return new Uint8Array(t);r!==(t[2]<<8|t[3])&&n(3,"wrong scanline width");const s=new Uint8Array(4*e*i);s.length||n(4,"unable to allocate buffer space");let o=0,a=0;const u=4*r,h=new Uint8Array(4),c=new Uint8Array(u);let l=i;for(;l>0&&a<t.byteLength;){a+4>t.byteLength&&n(1),h[0]=t[a++],h[1]=t[a++],h[2]=t[a++],h[3]=t[a++],2==h[0]&&2==h[1]&&(h[2]<<8|h[3])==r||n(3,"bad rgbe scanline format");let e,i=0;for(;i<u&&a<t.byteLength;){e=t[a++];const r=e>128;if(r&&(e-=128),(0===e||i+e>u)&&n(3,"bad scanline data"),r){const n=t[a++];for(let t=0;t<e;t++)c[i++]=n}else c.set(t.subarray(a,a+e),i),i+=e,a+=e}const f=r;for(let t=0;t<f;t++){let e=0;s[o]=c[t+e],e+=r,s[o+1]=c[t+e],e+=r,s[o+2]=c[t+e],e+=r,s[o+3]=c[t+e],o+=4}l--}return s}(o.subarray(o.pos),u,h);let l,f,d;switch(this.type){case t.FloatType:d=c.length/4;const e=new Float32Array(4*d);for(let t=0;t<d;t++)r(c,4*t,e,4*t);l=e,f=t.FloatType;break;case t.HalfFloatType:d=c.length/4;const n=new Uint16Array(4*d);for(let t=0;t<d;t++)s(c,4*t,n,4*t);l=n,f=t.HalfFloatType;break;default:throw new Error("THREE.RGBELoader: Unsupported type: "+this.type)}return{width:u,height:h,data:l,header:a.string,gamma:a.gamma,exposure:a.exposure,type:f}}setDataType(t){return this.type=t,this}load(e,n,i,r){return super.load(e,function(e,i){switch(e.type){case t.FloatType:case t.HalfFloatType:e.colorSpace=t.LinearSRGBColorSpace,e.minFilter=t.LinearFilter,e.magFilter=t.LinearFilter,e.generateMipmaps=!1,e.flipY=!0}n&&n(e,i)},i,r)}}var nn={light_metal:{path:"/textures/gravel_embedded_concrete_1k",files:{diffuse:"diffuse.jpg",normal:"normal.jpg",roughness:"rough.jpg"},repeat:{x:2,y:2},materialProps:{color:12105912,metalness:.3,roughness:.3,normalScale:[.4,.4],clearcoat:.3,clearcoatRoughness:.2,envMapIntensity:1.6,reflectivity:.5}},brick:{path:"/textures/pavement_03_1k",files:{diffuse:"diffuse.jpg",normal:"normal.jpg",roughness:"rough.jpg"},repeat:{x:7.5,y:.75},materialProps:{color:10061960,roughness:.9,metalness:.1,normalScale:[1.5,1.5],bumpScale:.05,clearcoat:.05,clearcoatRoughness:.4}},gravel_embedded_concrete:{path:"/textures/gravel_embedded_concrete_1k",files:{diffuse:"diffuse.jpg",normal:"normal.jpg",roughness:"rough.jpg"},repeat:{x:7,y:7},materialProps:{color:6710886,metalness:0,roughness:1,normalScale:[1,1]}}};function rn(t,e){return sn.apply(this,arguments)}function sn(){return sn=s(g().m(function t(e,i){var r,o,a,u,h;return g().w(function(t){for(;;)switch(t.n){case 0:if(r=nn[e]){t.n=1;break}throw new Error('Texture set "'.concat(e,'" not found'));case 1:return o=function(t){return new Promise(function(e,n){i.load(t,function(t){e(t)},void 0,function(t){n(t)})})},a=Object.entries(r.files).map(function(){var t=s(g().m(function t(e){var n,i,s,a,u;return g().w(function(t){for(;;)switch(t.n){case 0:return n=x(e,2),i=n[0],s=n[1],a="".concat(r.path,"/").concat(s),t.n=1,o(a);case 1:return u=t.v,t.a(2,[i,u])}},t)}));return function(e){return t.apply(this,arguments)}}()),t.n=2,Promise.all(a);case 2:return u=t.v,h=Object.fromEntries(u),Object.values(h).forEach(function(t){t.wrapS=t.wrapT=n.RepeatWrapping,t.repeat.set(r.repeat.x,r.repeat.y)}),t.a(2,{textures:h,config:r})}},t)})),sn.apply(this,arguments)}function on(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=t.textures,r=t.config,s=y(y({map:i.diffuse,normalMap:i.normal,roughnessMap:i.roughness},r.materialProps),e);return s.normalScale&&Array.isArray(s.normalScale)&&(s.normalScale=u(n.Vector2,S(s.normalScale))),new n.MeshPhysicalMaterial(s)}function an(t,e){return un.apply(this,arguments)}function un(){return un=s(g().m(function t(e,n){var i,r,s=arguments;return g().w(function(t){for(;;)switch(t.n){case 0:return i=s.length>2&&void 0!==s[2]?s[2]:{},t.n=1,rn(e,n);case 1:return r=t.v,t.a(2,on(r,i))}},t)})),un.apply(this,arguments)}var hn=function(){return c(function t(e){a(this,t),this.sceneViewer=e},[{key:"createSkybox",value:(h=s(g().m(function t(){var e,i,r,s,o,a,u,h,c,f;return g().w(function(t){for(;;)switch(t.n){case 0:e=this.sceneViewer,(i=new n.PMREMGenerator(e.renderer)).compileEquirectangularShader(),r=[{type:"hdr",loader:new en,paths:["/skyboxes/kloofendal_48d_partly_cloudy_puresky_2k.hdr","/skyboxes/kloofendal_48d_partly_cloudy_puresky_1k.hdr"]},{type:"jpeg",loader:e.textureLoader,paths:["/skyboxes/sky_fallback.jpg"]}],s=function(t,r){try{var s,o;t.mapping=n.EquirectangularReflectionMapping;var a=i.fromEquirectangular(t).texture;return null!==(s=e.scene.environment)&&void 0!==s&&s.dispose&&e.scene.environment.dispose(),null!==(o=e.scene.background)&&void 0!==o&&o.dispose&&e.scene.background.dispose(),e.scene.environment=a,e.scene.background=a,t.dispose(),!0}catch(t){return!1}},o=g().m(function t(){var e,n,r,o,a,c,f,d;return g().w(function(t){for(;;)switch(t.n){case 0:(e=h[u]).type,n=e.loader,r=e.paths,o=l(r),t.p=1,c=g().m(function t(){var e,r;return g().w(function(t){for(;;)switch(t.n){case 0:return e=a.value,t.p=1,t.n=2,new Promise(function(t,i){var r=setTimeout(function(){return i(new Error("Timeout"))},1e4);n.load(e,function(e){clearTimeout(r),t(e)},void 0,function(t){clearTimeout(r),i(t)})});case 2:if(r=t.v,!s(r)){t.n=3;break}return i.dispose(),t.a(2,{v:{v:void 0}});case 3:t.n=5;break;case 4:t.p=4,t.v;case 5:return t.a(2)}},t,null,[[1,4]])}),o.s();case 2:if((a=o.n()).done){t.n=5;break}return t.d(k(c()),3);case 3:if(!(f=t.v)){t.n=4;break}return t.a(2,f.v);case 4:t.n=2;break;case 5:t.n=7;break;case 6:t.p=6,d=t.v,o.e(d);case 7:return t.p=7,o.f(),t.f(7);case 8:return t.a(2)}},t,null,[[1,6,7,8]])}),u=0,h=r;case 1:if(!(u<h.length)){t.n=4;break}return t.d(k(o()),2);case 2:if(!(a=t.v)){t.n=3;break}return t.a(2,a.v);case 3:u++,t.n=1;break;case 4:c=new n.AmbientLight(16777215,.6),e.scene.add(c),(f=new n.Scene).add(new n.HemisphereLight(8900331,4473975,1)),e.scene.environment=i.fromScene(f).texture,e.scene.background=new n.Color(8900331),i.dispose();case 5:return t.a(2)}},t,this)})),function(){return h.apply(this,arguments)})},{key:"setupLighting",value:function(){var t=this.sceneViewer;t.scene.children=t.scene.children.filter(function(t){return!(t instanceof n.Light)});var e=new n.DirectionalLight(16777195,5);e.position.set(15,30,-10),e.castShadow=!0,e.shadow.camera.near=.1,e.shadow.camera.far=100,e.shadow.camera.left=-50,e.shadow.camera.right=50,e.shadow.camera.top=50,e.shadow.camera.bottom=-50,e.shadow.mapSize.width=2048,e.shadow.mapSize.height=2048,t.scene.add(e);var i=new n.DirectionalLight(16777164,.4);i.position.set(-10,10,-10),t.scene.add(i),$e.info("Scene lighting setup completed")}},{key:"addTexturedGround",value:(u=s(g().m(function t(){var e,i,r,s,o,a;return g().w(function(t){for(;;)switch(t.n){case 0:return e=this.sceneViewer,$e.debug("Starting addTexturedGround..."),i=new n.PlaneGeometry(30,30),r=new n.MeshStandardMaterial({color:7829367,metalness:.2,roughness:.9}),(s=new n.Mesh(i,r)).rotation.x=-Math.PI/2,s.position.y=0,s.receiveShadow=!0,s.name="Ground",s.userData.isBaseGround=!0,e.scene.add(s),t.p=1,$e.debug("Loading concrete texture set..."),t.n=2,an("gravel_embedded_concrete",e.textureLoader);case 2:o=t.v,s.material=o,s.material.needsUpdate=!0,$e.success("Ground material updated with textures"),t.n=4;break;case 3:t.p=3,a=t.v,$e.warn("Error loading ground textures:",a);case 4:return t.a(2)}},t,this,[[1,3]])})),function(){return u.apply(this,arguments)})},{key:"addBrickWalls",value:(o=s(g().m(function t(){var e,i,r,s,o,a,u;return g().w(function(t){for(;;)switch(t.n){case 0:return e=this.sceneViewer,$e.debug("Starting addBrickWalls..."),i=2.5,r=.5,s=new n.MeshPhysicalMaterial({color:7824226,roughness:.9,metalness:.1,clearcoat:.05,clearcoatRoughness:.4}),o=function(t){var s=function(i,r,s,o,a,u){var h=arguments.length>6&&void 0!==arguments[6]?arguments[6]:0,c=arguments.length>7&&void 0!==arguments[7]?arguments[7]:1,l=new n.BoxGeometry(i,r,s);if(1!==c){for(var f=l.attributes.uv,d=f.array,v=0;v<d.length;v+=2)d[v+1]*=c;f.needsUpdate=!0}var p=new n.Mesh(l,t);return p.position.set(o,a-.56,u),0!==h&&p.rotateY(h),p.userData.isBrickWall=!0,p.castShadow=!0,p.receiveShadow=!0,p.name="Wall",e.scene.add(p),p};s(30,i,r,0,1.25,14.75,0,1),s(30,i,r,0,1.25,-14.75,0,1),s(r,8.5,29,14.75,4.25,0,0,3.4),s(r,i,29,-14.75,1.25,0,0,1)},o(s),$e.debug("Basic brick walls created"),t.p=1,$e.debug("Loading brick texture set..."),t.n=2,an("brick",e.textureLoader);case 2:a=t.v,e.scene.traverse(function(t){t.isMesh&&t.userData.isBrickWall&&(t.material=a,t.material.needsUpdate=!0)}),$e.success("Brick walls updated with textures"),t.n=4;break;case 3:t.p=3,u=t.v,$e.warn("Error loading brick textures:",u);case 4:return t.a(2)}},t,this,[[1,3]])})),function(){return o.apply(this,arguments)})},{key:"addHorizonFog",value:function(){var t=this.sceneViewer,e=new n.ShaderMaterial({transparent:!0,uniforms:{fogColor:{value:new n.Color(5533306)},fogDensity:{value:1}},vertexShader:"\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }\n ",fragmentShader:"\n uniform vec3 fogColor;\n uniform float fogDensity;\n varying vec2 vUv;\n \n void main() {\n vec2 center = vec2(0.5, 0.5);\n float dist = distance(vUv, center);\n float opacity = (1.0 - smoothstep(0.0, 0.5, dist)) * fogDensity;\n gl_FragColor = vec4(fogColor, opacity);\n }\n ",side:n.DoubleSide}),i=new n.PlaneGeometry(300,300),r=new n.Mesh(i,e);return r.rotation.x=-Math.PI/2,r.position.y=-3,r.name="fogPlane",t.scene.add(r),r}},{key:"initializeEnvironment",value:(r=s(g().m(function t(){return g().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,this.createSkybox();case 1:return this.setupLighting(),t.n=2,this.addTexturedGround();case 2:return t.n=3,this.addBrickWalls();case 3:this.addHorizonFog(),$e.info("Environment initialization completed");case 4:return t.a(2)}},t,this)})),function(){return r.apply(this,arguments)})},{key:"removeSkybox",value:function(){var t=this.sceneViewer;try{var e,i;return null!==(e=t.scene.environment)&&void 0!==e&&e.dispose&&t.scene.environment.dispose(),null!==(i=t.scene.background)&&void 0!==i&&i.dispose&&t.scene.background.dispose(),t.scene.environment=null,t.scene.background=new n.Color(16777215),$e.info("Skybox removed successfully"),!0}catch(t){return!1}}},{key:"setSkyboxType",value:(i=s(g().m(function t(e){var i,r,s,o,a;return g().w(function(t){for(;;)switch(t.n){case 0:i=this.sceneViewer,t.p=1,null!==(r=i.scene.environment)&&void 0!==r&&r.dispose&&i.scene.environment.dispose(),null!==(s=i.scene.background)&&void 0!==s&&s.dispose&&i.scene.background.dispose(),(o=new n.PMREMGenerator(i.renderer)).compileEquirectangularShader(),a=e,t.n="HDR"===a?2:"Fallback"===a?4:"Color"===a?6:7;break;case 2:return t.n=3,this.loadHDRSkybox(o);case 3:case 5:return t.a(3,8);case 4:return t.n=5,this.loadFallbackSkybox(o);case 6:return this.setColorBackground(),t.a(3,8);case 7:return t.n=8,this.loadHDRSkybox(o);case 8:return o.dispose(),$e.info("Skybox type changed to: ".concat(e)),t.a(2,!0);case 9:return t.p=9,t.v,t.a(2,!1)}},t,this,[[1,9]])})),function(t){return i.apply(this,arguments)})},{key:"loadHDRSkybox",value:(e=s(g().m(function t(e){var i,r,s,o,a,u,h;return g().w(function(t){for(;;)switch(t.n){case 0:i=this.sceneViewer,r=new en,s=["/skyboxes/kloofendal_48d_partly_cloudy_puresky_2k.hdr","/skyboxes/kloofendal_48d_partly_cloudy_puresky_1k.hdr"],o=g().m(function t(){var s,o,a;return g().w(function(t){for(;;)switch(t.n){case 0:return s=h[u],t.p=1,t.n=2,new Promise(function(t,e){var n=setTimeout(function(){return e(new Error("Timeout"))},1e4);r.load(s,function(e){clearTimeout(n),t(e)},void 0,function(t){clearTimeout(n),e(t)})});case 2:return(o=t.v).mapping=n.EquirectangularReflectionMapping,a=e.fromEquirectangular(o).texture,i.scene.environment=a,i.scene.background=a,o.dispose(),t.a(2,{v:void 0});case 3:t.p=3,t.v;case 4:return t.a(2)}},t,null,[[1,3]])}),u=0,h=s;case 1:if(!(u<h.length)){t.n=4;break}return t.d(k(o()),2);case 2:if(!(a=t.v)){t.n=3;break}return t.a(2,a.v);case 3:u++,t.n=1;break;case 4:throw new Error("Failed to load any HDR skybox");case 5:return t.a(2)}},t,this)})),function(t){return e.apply(this,arguments)})},{key:"loadFallbackSkybox",value:(t=s(g().m(function t(e){var i,r,s;return g().w(function(t){for(;;)switch(t.n){case 0:return i=this.sceneViewer,t.p=1,t.n=2,new Promise(function(t,e){var n=setTimeout(function(){return e(new Error("Timeout"))},1e4);i.textureLoader.load("/skyboxes/sky_fallback.jpg",function(e){clearTimeout(n),t(e)},void 0,function(t){clearTimeout(n),e(t)})});case 2:(r=t.v).mapping=n.EquirectangularReflectionMapping,s=e.fromEquirectangular(r).texture,i.scene.environment=s,i.scene.background=s,r.dispose(),t.n=4;break;case 3:throw t.p=3,t.v;case 4:return t.a(2)}},t,this,[[1,3]])})),function(e){return t.apply(this,arguments)})},{key:"setColorBackground",value:function(){var t=this.sceneViewer;t.scene.environment=null,t.scene.background=new n.Color(16777215);var e=new n.AmbientLight(16777215,.6);t.scene.add(e)}}]);var t,e,i,r,o,u,h}(),cn=function(){return c(function t(e){a(this,t),this.sceneViewer=e,this.handleKeyDown=null},[{key:"setupKeyboardControls",value:function(){var t=this;this.handleKeyDown=function(e){if(e.ctrlKey&&("z"===e.key.toLowerCase()||"KeyZ"===e.code))return e.preventDefault(),e.stopPropagation(),void t.undoTransform();if(e.altKey&&("r"===e.key.toLowerCase()||"KeyR"===e.code))return e.preventDefault(),e.stopPropagation(),void t.toggleShouldUpdatePaths();switch(e.key.toLowerCase()){case"p":t.togglePerformanceUI();break;case"l":t.logPerformanceSummary();break;case"r":t.resetPerformanceStats();break;case"a":t.toggleAutoRotation();break;case"e":t.cycleToneMapping();break;case"=":case"+":t.increaseExposure();break;case"-":t.decreaseExposure();break;case"h":t.showHelpInfo()}},window.addEventListener("keydown",this.handleKeyDown,!0),window._performanceKeyHandler=this.handleKeyDown,this.overrideTransformControlsKeyboard(),$e.info("Keyboard controls initialized with Ctrl+Z undo override")}},{key:"togglePerformanceUI",value:function(){var t=this.sceneViewer;t.performanceUI&&(t.performanceUI.isVisible?t.performanceUI.hide():t.performanceUI.show())}},{key:"logPerformanceSummary",value:function(){var t=this.sceneViewer;t.performanceMonitor&&t.performanceMonitor.logSummary()}},{key:"resetPerformanceStats",value:function(){var t=this.sceneViewer;t.performanceMonitor&&t.performanceMonitor.reset()}},{key:"cycleToneMapping",value:function(){var t=this.sceneViewer;if(t.renderer){var e=[{type:n.NoToneMapping,name:"None"},{type:n.LinearToneMapping,name:"Linear"},{type:n.ReinhardToneMapping,name:"Reinhard"},{type:n.CineonToneMapping,name:"Cineon"},{type:n.ACESFilmicToneMapping,name:"ACES Filmic"}],i=e.findIndex(function(e){return e.type===t.renderer.toneMapping}),r=(i+1)%e.length,s=(e[i],e[r]);t.renderer.toneMapping=s.type}}},{key:"increaseExposure",value:function(){var t=this.sceneViewer;t.renderer&&(t.renderer.toneMappingExposure=Math.min(t.renderer.toneMappingExposure+.1,3))}},{key:"decreaseExposure",value:function(){var t=this.sceneViewer;t.renderer&&(t.renderer.toneMappingExposure=Math.max(t.renderer.toneMappingExposure-.1,.1))}},{key:"showHelpInfo",value:function(){}},{key:"toggleShouldUpdatePaths",value:function(){var t=this.sceneViewer;t&&"function"==typeof t.toggleShouldUpdatePaths&&t.toggleShouldUpdatePaths()}},{key:"toggleAutoRotation",value:function(){var t=this.sceneViewer;if(t.sceneInitializationManager){var e=t.sceneInitializationManager.toggleAutoRotation();void 0!==t.isAutoRotating&&(t.isAutoRotating=e)}}},{key:"setupResizeHandler",value:function(){var t=this.sceneViewer;t.handleResize=function(){if(t.$refs.container&&t.camera&&t.renderer){var e=t.$refs.container.getBoundingClientRect(),n=e.width,i=e.height;t.camera.aspect=n/i,t.camera.updateProjectionMatrix(),t.renderer.setSize(n,i),t.composer&&(t.composer.setSize(n,i),t.ssaoPass&&t.ssaoPass.setSize(n,i),t.bloomPass&&t.bloomPass.resolution.set(n,i)),t.tooltipsManager&&t.tooltipsManager.resize()}},t.resizeObserver=new ResizeObserver(t.handleResize),t.resizeObserver.observe(t.$refs.container),window.addEventListener("resize",t.handleResize),$e.info("Resize handler initialized")}},{key:"cleanup",value:function(){this.handleKeyDown&&(window.removeEventListener("keydown",this.handleKeyDown,!0),this.handleKeyDown=null),window._performanceKeyHandler&&(window.removeEventListener("keydown",window._performanceKeyHandler,!0),delete window._performanceKeyHandler);var t=this.sceneViewer;t.handleResize&&(window.removeEventListener("resize",t.handleResize),t.handleResize=null),t.resizeObserver&&(t.resizeObserver.disconnect(),t.resizeObserver=null),$e.info("Keyboard controls cleanup completed")}},{key:"undoTransform",value:function(){var t=this.sceneViewer;t.centralPlant&&("function"==typeof t.centralPlant.undoTransform&&t.centralPlant.undoTransform()&&(t.sceneHelper&&"function"==typeof t.sceneHelper.requestRender&&t.sceneHelper.requestRender(),t.renderer&&t.renderer.render(t.scene,t.camera),t.updateComponentPositions&&"function"==typeof t.updateComponentPositions&&t.updateComponentPositions()))}},{key:"overrideTransformControlsKeyboard",value:function(){var t=this.sceneViewer;if(t.transformManager&&t.transformManager.eventHandlers&&t.transformManager.eventHandlers.keydown){var e=t.transformManager.eventHandlers.keydown;t.transformManager.eventHandlers.keydown=function(t){(!t.ctrlKey||"z"!==t.key.toLowerCase()&&"KeyZ"!==t.code)&&e(t)}}}}])}();class ln{constructor(t=0,e=0,n=0){this.x=t,this.y=e,this.z=n}clone(){return new ln(this.x,this.y,this.z)}toArray(){return[this.x,this.y,this.z]}normalize(){const t=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z);return t>0&&(this.x/=t,this.y/=t,this.z/=t),this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}}class fn{constructor(t){this.scene=t}getRoot(){return this.scene.object}getWorldPosition(t){if(!t.userData?.worldBoundingBox)return new ln;const{min:e,max:n}=t.userData.worldBoundingBox;return new ln((e[0]+n[0])/2,(e[1]+n[1])/2,(e[2]+n[2])/2)}getBoundingBox(t){if(!t.userData?.worldBoundingBox)return null;const{min:e,max:n}=t.userData.worldBoundingBox;return{min:new ln(e[0],e[1],e[2]),max:new ln(n[0],n[1],n[2])}}findObjectByUUID(t){return this.Pe(this.getRoot(),t)}Pe(t,e){if(t.uuid===e)return t;if(t.children)for(const n of t.children){const t=this.Pe(n,e);if(t)return t}return null}findParentObject(t){return t.userData&&Array.isArray(t.userData.direction)?{isDirectionParent:!0}:this.je(this.getRoot(),t)}je(t,e){if(t.children){for(const n of t.children)if(n.uuid===e.uuid)return"Scene"===t.type?null:t;for(const n of t.children){const t=this.je(n,e);if(t)return t}}return null}isVoxelOccupiedByMesh(t,e){const[n,i,r]=t.split(",").map(Number),s=new ln(n*e,i*e,r*e);return this.De(this.getRoot(),s)}De(t,e){if("Mesh"===t.type){const n=this.getBoundingBox(t);if(n&&e.x>=n.min.x&&e.x<=n.max.x&&e.y>=n.min.y&&e.y<=n.max.y&&e.z>=n.min.z&&e.z<=n.max.z)return!0}if(t.children)for(const n of t.children)if(this.De(n,e))return!0;return!1}}class dn{constructor(t=.5,e=0){this.gridSize=t,this.safetyMargin=e}voxelKey(t){return[Math.round(t.x/this.gridSize),Math.round(t.y/this.gridSize),Math.round(t.z/this.gridSize)].join(",")}voxelToVec3(t){const[e,n,i]=t.split(",").map(Number);return new ln(e*this.gridSize,n*this.gridSize,i*this.gridSize)}getNeighbors(t){const[e,n,i]=t.split(",").map(Number);return[[e+1,n,i],[e-1,n,i],[e,n+1,i],[e,n-1,i],[e,n,i+1],[e,n,i-1]].map(t=>t.join(","))}manhattan(t,e){const[n,i,r]=t.split(",").map(Number),[s,o,a]=e.split(",").map(Number);return Math.abs(n-s)+Math.abs(i-o)+Math.abs(r-a)}worldToVoxelDistance(t){return Math.ceil(t/this.gridSize)}voxelToWorldDistance(t){return t*this.gridSize}getSafetyMarginVoxels(){return this.worldToVoxelDistance(this.safetyMargin)}isVoxelInSafetyMargin(t,e){const n=this.voxelToVec3(t),i=this.safetyMargin;return n.x>=e.min.x-i&&n.x<=e.max.x+i&&n.y>=e.min.y-i&&n.y<=e.max.y+i&&n.z>=e.min.z-i&&n.z<=e.max.z+i}getVoxelsInBoundingBox(t){const e=this.getSafetyMarginVoxels(),n=t.min,i=t.max,r=[];for(let t=Math.round(n.x/this.gridSize)-e;t<=Math.round(i.x/this.gridSize)+e;t++)for(let s=Math.round(n.y/this.gridSize)-e;s<=Math.round(i.y/this.gridSize)+e;s++)for(let o=Math.round(n.z/this.gridSize)-e;o<=Math.round(i.z/this.gridSize)+e;o++)r.push(`${t},${s},${o}`);return r}}class vn{constructor(t,e,n,i){this.config=t,this.MIN_SEGMENT_LENGTH=e,this.sceneManager=n,this.gridSystem=i}isConnector(t){return!!this.config.connections&&this.config.connections.some(e=>e.from===t.uuid||e.to===t.uuid)}getConnectorDirection(t){if(t.userData&&Array.isArray(t.userData.direction)){const[e,n,i]=t.userData.direction;return new ln(e,n,i)}if(!t.parent)return null;const e=this.sceneManager.getWorldPosition(t);let n;const i=this.sceneManager.getBoundingBox(t.parent);n=i?new ln((i.min.x+i.max.x)/2,(i.min.y+i.max.y)/2,(i.min.z+i.max.z)/2):this.sceneManager.getWorldPosition(t.parent);const r=new ln(e.x-n.x,e.y-n.y,e.z-n.z).normalize(),s=Math.abs(r.x),o=Math.abs(r.y),a=Math.abs(r.z);return s>=o&&s>=a?(r.y=0,r.z=0,r.x=Math.sign(r.x)):o>=s&&o>=a?(r.x=0,r.z=0,r.y=Math.sign(r.y)):(r.x=0,r.y=0,r.z=Math.sign(r.z)),r}createVirtualSegment(t,e){const n=this.getConnectorDirection(t);if(!n)return null;const i=new ln(e.x+n.x*this.MIN_SEGMENT_LENGTH,e.y+n.y*this.MIN_SEGMENT_LENGTH,e.z+n.z*this.MIN_SEGMENT_LENGTH);return{startPos:e,endPos:i,direction:n,startKey:this.gridSystem.voxelKey(e),endKey:this.gridSystem.voxelKey(i)}}processConnectors(t,e,n,i){this.Ie(t,e,n,i)}Ie(t,e,n,i){if("Mesh"===t.type){if(t.uuid===n||t.uuid===i)return;const r=this.sceneManager.getWorldPosition(t),s=this.createVirtualSegment(t,r);s&&this.Ne(s,r,e)}if(t.children)for(const r of t.children)this.Ie(r,e,n,i)}Ne(t,e,n){const i=t.direction,r=this.gridSystem.worldToVoxelDistance(this.MIN_SEGMENT_LENGTH+2*this.gridSystem.safetyMargin);for(let t=0;t<=r;t++){const r=`${Math.round(e.x/this.gridSystem.gridSize+i.x*t)},${Math.round(e.y/this.gridSystem.gridSize+i.y*t)},${Math.round(e.z/this.gridSystem.gridSize+i.z*t)}`;n.add(r)}}clusterConnections(t){const e=new Map,n=new Map;let i=0;t.forEach(t=>{const{from:r,to:s}=t;if(e.has(r)||e.has(s)){if(e.has(r)&&!e.has(s)){const t=e.get(r);e.set(s,t),n.get(t).add(s)}else if(!e.has(r)&&e.has(s)){const t=e.get(s);e.set(r,t),n.get(t).add(r)}else if(e.has(r)&&e.has(s)){const t=e.get(r),i=e.get(s);if(t!==i){n.get(i).forEach(i=>{e.set(i,t),n.get(t).add(i)}),n.delete(i)}}}else{const t=i++;e.set(r,t),e.set(s,t),n.set(t,new Set([r,s]))}});const r=Array.from(n.entries()).map(([t,e])=>({clusterId:t,objects:Array.from(e)})).filter(t=>!t.objects.some(t=>t.includes("GATEWAY")));return r.forEach(t=>{t.objectPoints=t.objects.map(t=>{const e=this.sceneManager.findObjectByUUID(t);if(e&&e.userData.worldBoundingBox){return{uuid:t,point:this.sceneManager.getWorldPosition(e),direction:e.userData.direction?new ln(...e.userData.direction):null}}return null}).filter(t=>null!==t),t.displacedPoints=t.objectPoints.map(t=>{const e=t.direction?t.point.clone().add(t.direction.multiplyScalar(.5)):t.point.clone();return{uuid:t.uuid,originalPoint:t.point,displacedPoint:e,direction:t.direction}})}),r}}class pn{constructor(t,e,n,i,r){this.sceneManager=t,this.gridSystem=e,this.connectorManager=n,this.MIN_SEGMENT_LENGTH=i,this.ASTAR_TIMEOUT=r}astar(t,e,n){const i=new Set([t]),r={},s={[t]:0},o={[t]:this.gridSystem.manhattan(t,e)},a=Date.now();for(;i.size>0;){if(Date.now()-a>this.ASTAR_TIMEOUT)return null;let t=null,u=1/0;for(const e of i)o[e]<u&&(u=o[e],t=e);if(t===e){const e=[t];for(;r[t];)t=r[t],e.unshift(t);return e}i.delete(t);for(const a of this.gridSystem.getNeighbors(t)){if(n.has(a))continue;const u=s[t]+1;u<(s[a]??1/0)&&(r[a]=t,s[a]=u,o[a]=u+this.gridSystem.manhattan(a,e),i.add(a))}}return null}findPathWithVirtualSegments(t,e,n,i,r){let s=t,o=e;const a=new Set(n);if(i){s=i.endKey;const t=i.startPos,e=i.direction,n=this.gridSystem.worldToVoxelDistance(this.MIN_SEGMENT_LENGTH);for(let i=0;i<n;i++){const n=`${Math.round(t.x/this.gridSystem.gridSize+e.x*i)},${Math.round(t.y/this.gridSystem.gridSize+e.y*i)},${Math.round(t.z/this.gridSystem.gridSize+e.z*i)}`;a.add(n)}}if(r){o=r.endKey;const t=r.startPos,e=r.direction,n=this.gridSystem.worldToVoxelDistance(this.MIN_SEGMENT_LENGTH);for(let i=0;i<n;i++){const n=`${Math.round(t.x/this.gridSystem.gridSize+e.x*i)},${Math.round(t.y/this.gridSystem.gridSize+e.y*i)},${Math.round(t.z/this.gridSystem.gridSize+e.z*i)}`;a.add(n)}}const u=this.astar(s,o,a);if(!u)return null;let h=[];return i&&h.push(i.startKey),h=h.concat(u),r&&h.push(r.startKey),h}markAllMeshesAsOccupiedVoxels(t){const e=new Set,n=new Map,i=t=>{if("Mesh"!==t.type)return;const r=this.sceneManager.getBoundingBox(t);if(!r)return;const s=this.gridSystem.getVoxelsInBoundingBox(r),o=new Set(s);for(const t of s)e.add(t);if(n.set(t.uuid,o),t.children)for(const e of t.children)i(e)};if(t.children)for(const e of t.children)i(e);return{occupied:e,occupiedByUUID:n}}processConnection(t,e,n){const i=this.sceneManager.findObjectByUUID(t.from),r=this.sceneManager.findObjectByUUID(t.to);if(!i||!r)return null;if("Mesh"!==i.type||"Mesh"!==r.type)return null;i.parent=this.sceneManager.findParentObject(i),r.parent=this.sceneManager.findParentObject(r);const s=this.sceneManager.getWorldPosition(i),o=this.sceneManager.getWorldPosition(r),a=this.connectorManager.createVirtualSegment(i,s),u=this.connectorManager.createVirtualSegment(r,o),h=new Set(e),c=Array.from(h).map(t=>this.gridSystem.voxelToVec3(t)),l=this.sceneManager.getBoundingBox(i),f=this.sceneManager.getBoundingBox(r);if(!l||!f)return null;if(!a){const t=this.gridSystem.getVoxelsInBoundingBox(l);for(const e of t)h.delete(e)}if(!u){const t=this.gridSystem.getVoxelsInBoundingBox(f);for(const e of t)h.delete(e)}if(a){const t=a.direction,e=this.gridSystem.worldToVoxelDistance(this.MIN_SEGMENT_LENGTH+2*this.gridSystem.safetyMargin);for(let n=0;n<=e;n++){const e=Math.round(s.x/this.gridSystem.gridSize+t.x*n),i=Math.round(s.y/this.gridSystem.gridSize+t.y*n),r=Math.round(s.z/this.gridSystem.gridSize+t.z*n);h.delete(`${e},${i},${r}`)}}if(u){const t=u.direction,e=this.gridSystem.worldToVoxelDistance(this.MIN_SEGMENT_LENGTH+2*this.gridSystem.safetyMargin);for(let n=0;n<=e;n++){const e=Math.round(o.x/this.gridSystem.gridSize+t.x*n),i=Math.round(o.y/this.gridSystem.gridSize+t.y*n),r=Math.round(o.z/this.gridSystem.gridSize+t.z*n);h.delete(`${e},${i},${r}`)}}this.connectorManager.processConnectors(this.sceneManager.getRoot(),h,i.uuid,r.uuid);const d=Array.from(h).map(t=>this.gridSystem.voxelToVec3(t)),v=this.gridSystem.voxelKey(s),p=this.gridSystem.voxelKey(o),w=this.findPathWithVirtualSegments(v,p,h,a,u),m=Array.from(h).map(t=>this.gridSystem.voxelToVec3(t));if(w){const i=w.map(t=>this.gridSystem.voxelToVec3(t)),r=new Set;for(const t of i){const n=this.gridSystem.voxelKey(t);e.add(n),r.add(n)}const s=`path_${t.from}_${t.to}`;return n.set(s,r),{from:t.from,to:t.to,path:i,occupied:m,debug:{initial:c,afterSegments:d},occupiedByUUID:n}}return{from:t.from,to:t.to,path:null,start:s,end:o,occupied:m,debug:{initial:c,afterSegments:d},occupiedByUUID:n}}findPaths(t){if(!this.sceneManager.getRoot())return[];const{occupied:e,occupiedByUUID:n}=this.markAllMeshesAsOccupiedVoxels(this.sceneManager.getRoot()),i=[];for(const r of t){const t=this.processConnection(r,e,n);t&&i.push(t)}return i}}class wn{constructor(){}distance(t,e){const n=e.x-t.x,i=e.y-t.y,r=e.z-t.z;return Math.sqrt(n*n+i*i+r*r)}findMST(t){const e=t.length,n=[],i=new Set;for(i.add(0);i.size<e;){let r=1/0,s=null;for(const n of i)for(let o=0;o<e;o++)if(!i.has(o)){const e=this.distance(t[n],t[o]);e<r&&(r=e,s=[n,o])}if(!s)break;n.push(s),i.add(s[1])}return n}findSteinerPoint(t){if(t.length<=2)return null;const e=this.findMST(t);if(0===e.length)return null;let n=null,i=1/0;if(e.forEach(([e,r])=>{const s=this.distance(t[e],t[r]);s<i&&(i=s,n=[t[e],t[r]])}),!n)return null;const r=new ln(.5*(n[0].x+n[1].x),.5*(n[0].y+n[1].y),.5*(n[0].z+n[1].z)),s=t=>Math.round(2*t)/2;return r.x=s(r.x),r.y=s(r.y),r.z=s(r.z),r}}class mn{constructor(t={}){this.config=t;const e=t.grid||{};this.gridSystem=new dn(e.size??.5,e.safetyMargin??0),this.MIN_SEGMENT_LENGTH=e.minSegmentLength??.5,this.ASTAR_TIMEOUT=e.timeout??1e3,this.connectorManager=new vn({grid:e},this.MIN_SEGMENT_LENGTH,null,this.gridSystem),this.pathManager=new pn(null,this.gridSystem,this.connectorManager,this.MIN_SEGMENT_LENGTH,this.ASTAR_TIMEOUT),this.steinerTreeManager=new wn}findPaths(t,e){const n=new fn(t);this.connectorManager.sceneManager=n,this.pathManager.sceneManager=n;const i=this.connectorManager.clusterConnections(e),r=i.filter(t=>t.objects.length>2);r.forEach((t,e)=>{const n=t.displacedPoints.map(t=>t.displacedPoint);t.mst=this.steinerTreeManager.findMST(n),t.steinerPoint=this.steinerTreeManager.findSteinerPoint(n)});let s=1;const o=new Map;r.forEach(t=>{if(t.steinerPoint){const e=s++;o.set(t.clusterId,e)}}),r.forEach(e=>{if(e.steinerPoint){const n={uuid:`GATEWAY-${o.get(e.clusterId)}`,type:"Mesh",userData:{worldBoundingBox:{min:[e.steinerPoint.x-.25,e.steinerPoint.y-.25,e.steinerPoint.z-.25],max:[e.steinerPoint.x+.25,e.steinerPoint.y+.25,e.steinerPoint.z+.25]}}};t.object.children.push(n)}});const a=[],u=new Set;e.filter(t=>{const e=i.find(e=>e.objects.includes(t.from)),n=i.find(e=>e.objects.includes(t.to));return!e||!n||e.objects.length<=2||n.objects.length<=2}).forEach(t=>{u.has(JSON.stringify(t))||(a.push(t),u.add(JSON.stringify(t)))});const h=[];e.forEach(t=>{const e=i.find(e=>e.objects.includes(t.from))?.clusterId,n=i.find(e=>e.objects.includes(t.to))?.clusterId;if(void 0!==e&&void 0!==n){const i=`GATEWAY-${o.get(e)}`,r=`GATEWAY-${o.get(n)}`;if(i&&r)if(e===n){const e={from:t.from,to:i},n={from:i,to:t.to};u.has(JSON.stringify(e))||(h.push(e),u.add(JSON.stringify(e))),u.has(JSON.stringify(n))||(h.push(n),u.add(JSON.stringify(n)))}else{const e={from:t.from,to:i},n={from:i,to:r},s={from:r,to:t.to};u.has(JSON.stringify(e))||(h.push(e),u.add(JSON.stringify(e))),u.has(JSON.stringify(n))||(h.push(n),u.add(JSON.stringify(n))),u.has(JSON.stringify(s))||(h.push(s),u.add(JSON.stringify(s)))}}}),h.sort((t,e)=>{const i=n.findObjectByUUID(t.from),r=n.findObjectByUUID(t.to),s=n.findObjectByUUID(e.from),o=n.findObjectByUUID(e.to);if(!(i&&r&&s&&o))return 0;return this.steinerTreeManager.distance(n.getWorldPosition(i),n.getWorldPosition(r))-this.steinerTreeManager.distance(n.getWorldPosition(s),n.getWorldPosition(o))}),a.push(...h);return{paths:this.pathManager.findPaths(a||[]),rewiredConnections:a,gateways:Array.from(o.entries()).map(([t,e])=>({clusterId:t,id:e,position:i.find(e=>e.clusterId===t)?.steinerPoint}))}}}var yn=function(){return c(function t(e){a(this,t),this.sceneViewer=e,this.pathfinder=null,this.crosscubeTextureSet=null,this.pathfinderVersionInfo=null,this.pathfinderConfig={grid:{size:.5,safetyMargin:0,minSegmentLength:.5,timeout:1e3}}},[{key:"getPathfinderVersionInfo",value:(h=s(g().m(function t(){var e;return g().w(function(t){for(;;)switch(t.n){case 0:if(!this.pathfinderVersionInfo){t.n=1;break}return t.a(2,this.pathfinderVersionInfo);case 1:return e={version:"1.0.17",detectionMethod:"hardcoded-fallback",timestamp:(new Date).toISOString()},this.pathfinderVersionInfo=e,t.a(2,e)}},t,this)})),function(){return h.apply(this,arguments)})},{key:"logPathfinderVersion",value:(o=s(g().m(function t(){var e,n,i,r=arguments;return g().w(function(t){for(;;)switch(t.n){case 0:return e=r.length>0&&void 0!==r[0]?r[0]:"Unknown Context",t.p=1,t.n=2,this.getPathfinderVersionInfo();case 2:n=t.v,qe.info("[".concat(e,"] Pathfinder Module Information:"),{version:n.version,detectionMethod:n.detectionMethod,context:e,timestamp:n.timestamp,pathfinderInstance:!!this.pathfinder}),t.n=4;break;case 3:t.p=3,i=t.v,qe.error("[".concat(e,"] Failed to get pathfinder version:"),i);case 4:return t.a(2)}},t,this,[[1,3]])})),function(){return o.apply(this,arguments)})},{key:"getPathColor",value:function(t){var e=["#468e49","#245e29","#2e80d2","#1d51a1"];return e[t%e.length]}},{key:"_executePathfinding",value:(r=s(g().m(function t(e,i){var r,s,o,a,u,h,c,l=this,f=arguments;return g().w(function(t){for(;;)switch(t.n){case 0:return s=(r=f.length>2&&void 0!==f[2]?f[2]:{}).createGateways,o=void 0!==s&&s,a=r.context,u=void 0===a?"Pathfinding":a,t.n=1,this.logPathfinderVersion(u);case 1:return this.pathfinder=new mn(this.pathfinderConfig),this.sceneViewer.pathfinder=this.pathfinder,e.object.children=e.object.children.filter(function(t){return"computed"!==t.userData.origin}),h=this.pathfinder.findPaths(e,i),o&&h.gateways&&h.gateways.forEach(function(t){if(t.position){var e=new n.Mesh(new n.SphereGeometry(.15,16,16),new n.MeshStandardMaterial({color:16777215,roughness:.7,metalness:.3,emissive:0}));e.position.copy(t.position),e.name=t.id,e.uuid=t.id,e.userData={componentType:"gateway",forExport:!0,gatewayId:t.id,originalUuid:t.id,origin:"computed",connections:t.connections},l.sceneViewer.scene.add(e)}}),c=this.mergeColinearPaths(h.paths),this.createPipePaths(c,this.crosscubeTextureSet),t.a(2,h)}},t,this)})),function(t,e){return r.apply(this,arguments)})},{key:"initializePathfinder",value:(i=s(g().m(function t(e,n){var i;return g().w(function(t){for(;;)switch(t.n){case 0:return this.crosscubeTextureSet=n,t.n=1,this.Le(e.scene,e.connections,{createGateways:!0,context:"Scene Loading"});case 1:return(i=t.v).rewiredConnections,t.a(2,i)}},t,this)})),function(t,e){return i.apply(this,arguments)})},{key:"removeComputedObjects",value:function(){var t=this.sceneViewer,e=[];t.scene.traverse(function(t){if(t.name&&t.name.includes("Polyline")){var n=!1,i=[];if(t.traverse(function(t){t.userData&&t.userData.isPipeSegment&&t.userData.isManuallyPositioned&&(n=!0,i.push(t))}),n){var r=[];t.traverse(function(t){(t.userData&&t.userData.isPipeSegment&&!t.userData.isManuallyPositioned||t.userData&&t.userData.isPipeElbow)&&r.push(t)}),r.forEach(function(e){t.remove(e),e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(function(t){return t.dispose()}):e.material.dispose())}),0===t.children.length&&e.push(t)}else e.push(t)}t.userData&&"computed"===t.userData.origin&&e.push(t)});for(var n=0,i=e;n<i.length;n++){var r=i[n];t.scene.remove(r),r.geometry&&r.geometry.dispose(),r.material&&(Array.isArray(r.material)?r.material.forEach(function(t){return t.dispose()}):r.material.dispose())}}},{key:"createPipeMaterial",value:function(t,e){if(t){var i=y(y({},t.config.materialProps),{},{color:this.getPathColor(e),map:t.textures.diffuse,normalMap:t.textures.normal,roughnessMap:t.textures.roughness,metalness:.2,roughness:.9,clearcoat:.2,clearcoatRoughness:.2,envMapIntensity:.6,reflectivity:.4});i.normalScale&&Array.isArray(i.normalScale)&&(i.normalScale=u(n.Vector2,S(i.normalScale)));var r=new n.MeshPhysicalMaterial(i);return[r.map,r.normalMap,r.roughnessMap].filter(Boolean).forEach(function(e){e.wrapS=e.wrapT=n.RepeatWrapping,e.repeat.set(2*t.config.repeat.x,2*t.config.repeat.y)}),r}return new n.MeshPhysicalMaterial({color:this.getPathColor(e),metalness:.9,roughness:.7,clearcoat:.1,clearcoatRoughness:.3,envMapIntensity:1.5,reflectivity:.3})}},{key:"createPipePaths",value:function(t,e){var i=this,r=this.sceneViewer;t.forEach(function(t,s){if(t.path&&t.path.length>=2){var o=new n.Object3D;o.name="Polyline ".concat(t.from,"-").concat(t.to);for(var a=i.createPipeMaterial(e,s),u=t.path.map(function(t){return t instanceof n.Vector3?t.clone():Array.isArray(t)?(new n.Vector3).fromArray(t):void 0!==t.x&&void 0!==t.y&&void 0!==t.z?new n.Vector3(t.x,t.y,t.z):new n.Vector3(0,0,0)}),h=function(e){var h=u[e],c=u[e+1],l=(new n.Vector3).subVectors(c,h),f=l.length();if(f<1e-6)return 0;var d=!1;if(r.scene.traverse(function(n){n.userData&&n.userData.isPipeSegment&&n.userData.isManuallyPositioned&&n.userData.segmentId==="pipe-segment-".concat(t.from,"-").concat(t.to,"-").concat(e)&&(d=!0)}),d)return 0;var v=new n.CylinderGeometry(.1,.1,f,8,1,!1),p=new n.Mesh(v,a);p.position.copy(h).add(c).multiplyScalar(.5);var w=new n.Quaternion,m=new n.Vector3(0,1,0);w.setFromUnitVectors(m,l.clone().normalize()),p.quaternion.copy(w),p.castShadow=!0,p.receiveShadow=!0;var y="pipe-segment-".concat(t.from,"-").concat(t.to,"-").concat(e);if(p.name="Pipe Segment ".concat(e+1,": ").concat(t.from,"-").concat(t.to),p.userData={isPipeSegment:!0,segmentId:y,segmentIndex:e,pathFrom:t.from,pathTo:t.to,pathIndex:s,length:f.toFixed(2),component:{type:"PipeSegment",attributes:{length:{key:"Length",value:f.toFixed(2),unit:"m"}}}},o.add(p),e<u.length-2){var g=u[e+1].clone().sub(u[e]).normalize(),b=u[e+2].clone().sub(u[e+1]).normalize(),k=g.angleTo(b);if(k>Math.PI/36){var M=i.createElbowGeometry(u[e],u[e+1],u[e+2],.1);if(M){var x=new n.Mesh(M,a);x.castShadow=!0,x.receiveShadow=!0;var T="pipe-elbow-".concat(t.from,"-").concat(t.to,"-").concat(e);x.name="Pipe Elbow ".concat(e+1,": ").concat(t.from,"-").concat(t.to),x.userData={isPipeElbow:!0,elbowId:T,elbowIndex:e,pathFrom:t.from,pathTo:t.to,pathIndex:s,angle:(180*k/Math.PI).toFixed(1),component:{type:"PipeElbow",attributes:{angle:{key:"Bend Angle",value:(180*k/Math.PI).toFixed(1),unit:"ยฐ"}}}},o.add(x)}}}},c=0;c<u.length-1;c++)h(c);o.name="Polyline",r.scene.add(o)}})}},{key:"handleManualSegmentTransformation",value:function(t,e){if(t&&t.userData&&t.userData.isPipeSegment){var n=this.calculateSegmentEndpoints(t),i=this.createSegmentConnectors(t,n);this.addConnectorsToScene(i),this.convertConnectedGatewaysToManual(i,e);var r=this.findOriginalConnection(t,e.connections);r&&(this.restructureConnections(r,i,e),t.userData.isManuallyPositioned=!0,t.userData.manualConnectors=i.map(function(t){return t.uuid}),this.addManualSegmentToSceneData(t))}}},{key:"convertConnectedGatewaysToManual",value:function(t,e){var n,i,r=this,s=this.sceneViewer,o=[],a=null!==(n=t[0])&&void 0!==n&&null!==(n=n.userData)&&void 0!==n&&n.manualSegmentUuid?s.scene.getObjectByProperty("uuid",t[0].userData.manualSegmentUuid):null;a&&null!==(i=a.userData)&&void 0!==i&&i.isPipeSegment&&([a.userData.pathFrom,a.userData.pathTo].forEach(function(t){var n,i,a=null;(s.scene.traverse(function(e){var n;e.uuid!==t&&(null===(n=e.userData)||void 0===n?void 0:n.originalUuid)!==t||(a=e)}),a)&&("gateway"===(null===(n=a.userData)||void 0===n?void 0:n.componentType)&&"computed"===(null===(i=a.userData)||void 0===i?void 0:i.origin)&&(r.convertGatewayToManual(a,e),o.push(a)))}),o.length)}},{key:"convertGatewayToManual",value:function(t,e){var n;t.userData.origin="declared";for(var i=0;i<e.scene.object.children.length;i++){var r,s,o=e.scene.object.children[i];if(o.uuid===t.uuid||o.uuid===(null===(r=t.userData)||void 0===r?void 0:r.originalUuid)||t.uuid===(null===(s=o.userData)||void 0===s?void 0:s.originalUuid)){o.userData||(o.userData={}),o.userData.origin="declared";break}}if(null!==(n=t.userData)&&void 0!==n&&n.connections&&e.connections){var a=t.userData.connections,u=e.connections;a.removed&&Array.isArray(a.removed)&&(e.connections=u.filter(function(t){var e=a.removed.some(function(e){return e.from===t.from&&e.to===t.to||e.from===t.to&&e.to===t.from});return!e})),a.added&&Array.isArray(a.added)&&a.added.forEach(function(t){e.connections.some(function(e){return e.from===t.from&&e.to===t.to||e.from===t.to&&e.to===t.from})||e.connections.push(t)})}}},{key:"findOriginalConnection",value:function(t,e){var n=t.userData,i=n.pathFrom,r=n.pathTo,s=e.find(function(t){return t.from===i&&t.to===r||t.from===r&&t.to===i});if(s)return s;var o=this.sceneViewer,a=null,u=null;if(o.scene.traverse(function(t){var e,n;t.uuid!==i&&(null===(e=t.userData)||void 0===e?void 0:e.originalUuid)!==i||(a=t),t.uuid!==r&&(null===(n=t.userData)||void 0===n?void 0:n.originalUuid)!==r||(u=t)}),a&&u&&(s=e.find(function(t){return t.from===a.uuid&&t.to===u.uuid||t.from===u.uuid&&t.to===a.uuid})))return s;var h=e.filter(function(t){var e,n,s=t.from===i||t.from===r,a=t.to===i||t.to===r,u="gateway"===(null===(e=o.scene.getObjectByProperty("uuid",t.from))||void 0===e||null===(e=e.userData)||void 0===e?void 0:e.componentType),h="gateway"===(null===(n=o.scene.getObjectByProperty("uuid",t.to))||void 0===n||null===(n=n.userData)||void 0===n?void 0:n.componentType);return s||a||u||h});return h.length>0?h[0]:null}},{key:"calculateSegmentEndpoints",value:function(t){var e=t.geometry.parameters.height||1,i=new n.Vector3,r=new n.Vector3,s=new n.Vector3(0,1,0);return s.applyQuaternion(t.quaternion),i.copy(t.position).sub(s.clone().multiplyScalar(e/2)),r.copy(t.position).add(s.clone().multiplyScalar(e/2)),{start:i,end:r}}},{key:"createSegmentConnectors",value:function(t,e){var i=t.userData.segmentId,r=[],s=new n.Mesh(new n.SphereGeometry(.2,16,16),new n.MeshStandardMaterial({color:65280,roughness:.7,metalness:.3,emissive:13056}));s.position.copy(e.start),s.uuid="".concat(i,"-connector-start"),s.name="Manual Segment Start Connector: ".concat(t.name),s.userData={componentType:"connector",forExport:!0,isManualSegmentConnector:!0,segmentId:i,connectorType:"start",manualSegmentUuid:t.uuid};var o=new n.Mesh(new n.SphereGeometry(.2,16,16),new n.MeshStandardMaterial({color:16711680,roughness:.7,metalness:.3,emissive:3342336}));return o.position.copy(e.end),o.uuid="".concat(i,"-connector-end"),o.name="Manual Segment End Connector: ".concat(t.name),o.userData={componentType:"connector",forExport:!0,isManualSegmentConnector:!0,segmentId:i,connectorType:"end",manualSegmentUuid:t.uuid},r.push(s,o),r}},{key:"addConnectorsToScene",value:function(t){var e=this.sceneViewer;t.forEach(function(t){if(e.scene.add(t),e.currentSceneData&&e.currentSceneData.scene&&e.currentSceneData.scene.object){var n={uuid:t.uuid,name:t.name,type:t.type,userData:y({},t.userData),position:{x:t.position.x,y:t.position.y,z:t.position.z},rotation:{x:t.rotation.x,y:t.rotation.y,z:t.rotation.z},scale:{x:t.scale.x,y:t.scale.y,z:t.scale.z},geometry:"CONNECTOR-GEO"};e.currentSceneData.scene.object.children.push(n)}})}},{key:"addManualSegmentToSceneData",value:function(t){var e=this.sceneViewer;if(e.currentSceneData&&e.currentSceneData.scene&&e.currentSceneData.scene.object){var n={uuid:t.uuid,name:t.name,type:t.type,userData:y({},t.userData),position:{x:t.position.x,y:t.position.y,z:t.position.z},rotation:{x:t.rotation.x,y:t.rotation.y,z:t.rotation.z},scale:{x:t.scale.x,y:t.scale.y,z:t.scale.z}};e.currentSceneData.scene.object.children.push(n)}}},{key:"restructureConnections",value:function(t,e,n){var i=x(e,2),r=i[0],s=i[1],o=n.connections.findIndex(function(e){return e.from===t.from&&e.to===t.to||e.from===t.to&&e.to===t.from});if(-1!==o){n.connections.splice(o,1);var a={from:t.from,to:r.uuid},u={from:s.uuid,to:t.to};n.connections.push(a,u),this.sceneViewer.currentSceneData&&(this.sceneViewer.currentSceneData.connections=S(n.connections))}}},{key:"createElbowGeometry",value:function(t,e,i,r){try{var s=3*r,o=this.createElbowCurve(t,e,i,s);return new n.TubeGeometry(o,12,r,8,!1)}catch(t){return null}}},{key:"createElbowCurve",value:function(t,e,i,r){var s=e.clone().sub(t).normalize(),o=i.clone().sub(e).normalize(),a=.001*r,u=e.clone().sub(s.clone().multiplyScalar(a)),h=e.clone().add(o.clone().multiplyScalar(a)),c=e.clone();return new n.QuadraticBezierCurve3(u,c,h)}},{key:"recomputeWorldBoundingBoxes",value:function(t){this.sceneViewer.scene.traverse(function(e){if(e.isMesh){var i=null,r=function(t){var n,i=l(t);try{for(i.s();!(n=i.n()).done;){var s,o,a=n.value;if(a.uuid===e.uuid||a.uuid===(null===(s=e.userData)||void 0===s?void 0:s.originalUuid)||e.uuid===(null===(o=a.userData)||void 0===o?void 0:o.originalUuid))return a;if(e.name&&a.name){var u=lt(e.name),h=lt(a.name);if(u===h||u===a.uuid||h===e.uuid)return a}if(e.name&&a.name&&e.name===a.name)return a;if(a.children){var c=r(a.children);if(c)return c}}}catch(t){i.e(t)}finally{i.f()}return null};if(i=r(t.scene.object.children)){var s=(new n.Box3).setFromObject(e);i.userData||(i.userData={}),i.userData.worldBoundingBox={min:s.min.toArray(),max:s.max.toArray()},i.userData.origin||(i.userData.origin=e.userData.origin),i.userData.direction||(i.userData.direction=e.userData.direction),i.userData.group||(i.userData.group=e.userData.group),i.userData.connections||(i.userData.connections=e.userData.connections),e.userData.associatedJsonObject=i}}})}},{key:"updatePathfindingWithConnections",value:(e=s(g().m(function t(e){var n,i;return g().w(function(t){for(;;)switch(t.n){case 0:if((n=this.sceneViewer).currentSceneData){t.n=1;break}return t.a(2,!1);case 1:return this.removeComputedObjects(),(i=JSON.parse(JSON.stringify(n.currentSceneData))).connections=S(e),t.n=2,this.Le(i.scene,i.connections,{createGateways:!1,context:"Connections Update"});case 2:return n.currentSceneData=i,t.a(2,!0)}},t,this)})),function(t){return e.apply(this,arguments)})},{key:"updatePathfindingAfterTransform",value:(t=s(g().m(function t(e){return g().w(function(t){for(;;)switch(t.n){case 0:return this.removeComputedObjects(),t.n=1,this.Le(e.scene,e.connections,{createGateways:!0,context:"Transform Update"});case 1:return t.a(2)}},t,this)})),function(e){return t.apply(this,arguments)})},{key:"dispose",value:function(){this.removeComputedObjects(),this.pathfinder=null,this.crosscubeTextureSet=null,this.pathfinderVersionInfo=null,$e.info("PathfindingManager disposed")}},{key:"mergeColinearPaths",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.001,i=JSON.parse(JSON.stringify(t));return i.forEach(function(t){if(t.path&&!(t.path.length<=2)){var i=t.path.map(function(t){return t instanceof n.Vector3?t.clone():Array.isArray(t)?(new n.Vector3).fromArray(t):void 0!==t.x&&void 0!==t.y&&void 0!==t.z?new n.Vector3(t.x,t.y,t.z):new n.Vector3(0,0,0)});if(!(i.length<=2)){for(var r=[i[0]],s=0,o=function(){var t=i[s],o=i[s+1],a=(new n.Vector3).subVectors(o,t);if(a.length()<1e-6)return s++,1;a.normalize();for(var u=s+2;u<i.length;){var h=i[u],c=(new n.Vector3).subVectors(h,t);if(c.length()<1e-6)u++;else{c.normalize();var l=a.dot(c);if(!(Math.abs(l-1)<e))break;o=h,u++}}o.equals(t)||r.push(o);var f=i.findIndex(function(t,e){return e>s&&t.equals(o)});-1===f?s++:s=f};s<i.length-1;)o();var a=r.map(function(e){return Array.isArray(t.path[0])?[e.x,e.y,e.z]:void 0!==t.path[0].x?{x:e.x,y:e.y,z:e.z}:e});t.path=a;i.length,r.length}}}),i}}]);var t,e,i,r,o,h}(),gn=function(){return c(function t(e){a(this,t),this.sceneViewer=e},[{key:"clearSceneObjects",value:function(){var t=this.sceneViewer;this.deselectObject();var e=null;t.transformManager&&t.transformManager.transformControls&&(t.transformManager.setEnabled(!1),t.transformManager.transformControls.visible=!1,e=t.transformManager.transformControls);var n=[];t.scene.traverse(function(i){var r,s,o,a,u;0;var h=i===e||(null===(r=i.userData)||void 0===r?void 0:r.isTransformControls)||i.isTransformControls||i.type&&i.type.includes("TransformControls");h&&0,i===t.scene||null!==(s=i.userData)&&void 0!==s&&s.isBrickWall||null!==(o=i.userData)&&void 0!==o&&o.isBaseGround||null!==(a=i.userData)&&void 0!==a&&a.isBaseGrid||h||i.isLight||"PlaneGeometry"===(null===(u=i.geometry)||void 0===u?void 0:u.type)||n.push(i)}),n.forEach(function(e){t.scene.remove(e),e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(function(t){return t.dispose()}):e.material.dispose())}),t.selectedObjectForTransform=null,t.transformHistory&&(t.transformHistory=[]),t.transformManager&&t.transformManager.transformControls||t.initTransformControls(),this.ensureTransformControlsAttached(!1)}},{key:"ensureTransformControlsAttached",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=this.sceneViewer;if(e.transformManager){if(!e.transformManager.transformControls)return e.transformManager.createTransformControls(),void e.transformManager.setupEventListeners();e.transformManager.ensureSceneAttachment(t);!t&&e.transformManager.transformControls&&(e.transformManager.transformControls.visible=!1)}else e.initTransformControls()}},{key:"loadLibraryModel",value:(h=s(g().m(function t(e,i,r){var s,o,a,u,h,c,l,f,d,v,p,w,m,y,b,k;return g().w(function(t){for(;;)switch(t.n){case 0:if(s=this.sceneViewer,t.p=1,Qe.info("Loading library GLB model for ".concat(null===(o=i.userData)||void 0===o?void 0:o.libraryId,"...")),Qe.debug("Starting to load GLB model from /library/models/".concat(r.modelKey)),h=e.parent,c=e.position.clone(),l=e.quaternion.clone(),f=e.scale.clone(),d=e.name,v=e.uuid,p=[],e.children.forEach(function(t){var e=t.geometry&&("CONNECTOR-GEO"===t.geometry.uuid||"SphereGeometry"===t.geometry.type&&t.geometry.parameters),i=t.name&&t.name.toLowerCase().includes("connector");if(e&&i){if(t.userData||(t.userData={}),!t.userData.worldBoundingBox){var r=(new n.Box3).setFromObject(t);t.userData.worldBoundingBox={min:r.min.toArray(),max:r.max.toArray()}}var s=t.clone();if(t.userData){s.userData={},t.userData.worldBoundingBox&&(s.userData.worldBoundingBox={min:S(t.userData.worldBoundingBox.min),max:S(t.userData.worldBoundingBox.max)}),t.userData.direction&&(s.userData.direction=S(t.userData.direction));for(var o=0,a=Object.entries(t.userData);o<a.length;o++){var u=x(a[o],2),h=u[0],c=u[1];"worldBoundingBox"!==h&&"direction"!==h&&(s.userData[h]=c)}s.userData.originalUuid=t.uuid,void 0===s.userData.forExport&&(s.userData.forExport=!0),s.userData.componentType||(t.name&&t.name.toLowerCase().includes("connector")?s.userData.componentType="connector":t.name&&t.name.toLowerCase().includes("gateway")&&(s.userData.componentType="gateway"))}p.push(s)}}),!(w=ve.getCachedModelWithDimensions(r.modelKey,null===(a=i.userData)||void 0===a?void 0:a.libraryId))){t.n=2;break}t.n=8;break;case 2:if(!ve.getStatus().isPreloading){t.n=6;break}return t.p=3,t.n=4,ve.preloadingPromise;case 4:w=ve.getCachedModelWithDimensions(r.modelKey,null===(m=i.userData)||void 0===m?void 0:m.libraryId),t.n=6;break;case 5:t.p=5,t.v;case 6:if(w){t.n=8;break}return t.n=7,new Promise(function(t,e){s.gltfLoader.load("/library/models/".concat(r.modelKey),function(e){t(e)},function(t){},function(t){e(t)})});case 7:b=t.v,w=b.scene,null!==(y=i.userData)&&void 0!==y&&y.libraryId&&(w=ve.addDimensionsToModel(w,i.userData.libraryId));case 8:return(k=w.isCachedClone?w:w.clone()).uuid=v,k.name=d,k.quaternion.copy(l),k.scale.copy(f),k.userData||(k.userData={}),k.userData.originalUuid=v,k.userData.componentType="component",k.userData.libraryId=null===(u=i.userData)||void 0===u?void 0:u.libraryId,r.boundingBox&&(k.userData.dimensions={x:r.boundingBox.x,y:r.boundingBox.y,z:r.boundingBox.z}),r.adaptedBoundingBox&&(k.userData.adaptedBoundingBox={x:r.adaptedBoundingBox.x,y:r.adaptedBoundingBox.y,z:r.adaptedBoundingBox.z}),i.position&&i.rotation?(k.position.set(i.position.x,i.position.y,i.position.z),k.rotation.set(n.MathUtils.degToRad(i.rotation.x),n.MathUtils.degToRad(i.rotation.y),n.MathUtils.degToRad(i.rotation.z))):k.position.copy(c),k.traverse(function(t){t.isMesh&&(t.castShadow=!0,t.receiveShadow=!0,t.material&&(t.material.envMapIntensity=1))}),p.forEach(function(t){k.add(t)}),k.children.forEach(function(t,e){t.name&&t.name.toLowerCase().includes("connector")}),k.children.length>0&&k.children.forEach(function(t,e){}),h&&h.add&&"function"==typeof h.add?(h.remove(e),h.add(k)):(s.scene.remove(e),s.scene.add(k)),t.a(2,k);case 9:return t.p=9,t.v,t.a(2,e)}},t,this,[[3,5],[1,9]])})),function(t,e,n){return h.apply(this,arguments)})},{key:"verifyModelPreloaderCache",value:(u=s(g().m(function t(){var e;return g().w(function(t){for(;;)switch(t.n){case 0:if(!(e=ve.getStatus()).isPreloading){t.n=4;break}return t.p=1,t.n=2,ve.preloadingPromise;case 2:t.n=4;break;case 3:t.p=3,t.v;case 4:return t.a(2,e)}},t,null,[[1,3]])})),function(){return u.apply(this,arguments)})},{key:"preloadMissingModels",value:(o=s(g().m(function t(e,n){var i,r,s,o,a,u,h,c;return g().w(function(t){for(;;)switch(t.n){case 0:return i=new Set,e.scene.object.children.forEach(function(t){var e,r;if(null!==(e=t.userData)&&void 0!==e&&e.libraryId&&n[null===(r=t.userData)||void 0===r?void 0:r.libraryId]){var s,o=n[null===(s=t.userData)||void 0===s?void 0:s.libraryId].modelKey;o&&i.add(o)}}),t.n=1,this.verifyModelPreloaderCache();case 1:if(r=t.v,s=r.cachedModels,!((o=Array.from(i).filter(function(t){return!s.includes(t)})).length>0)){t.n=11;break}a=l(o),t.p=2,a.s();case 3:if((u=a.n()).done){t.n=8;break}return h=u.value,t.p=4,t.n=5,ve.preloadSingleModel(h);case 5:t.n=7;break;case 6:t.p=6,t.v;case 7:t.n=3;break;case 8:t.n=10;break;case 9:t.p=9,c=t.v,a.e(c);case 10:return t.p=10,a.f(),t.f(10);case 11:return t.a(2)}},t,this,[[4,6],[2,9,10,11]])})),function(t,e){return o.apply(this,arguments)})},{key:"createSceneMaterials",value:(r=s(g().m(function t(e){var n,i,r;return g().w(function(t){for(;;)switch(t.n){case 0:return n=this.sceneViewer,i={},r=null,t.p=1,t.n=2,rn("light_metal",n.textureLoader);case 2:r=t.v,t.n=7;break;case 3:return t.p=3,t.v,t.p=4,t.n=5,rn("gravel_embedded_concrete",n.textureLoader);case 5:r=t.v,t.n=7;break;case 6:t.p=6,t.v;case 7:return t.a(2,{materials:i,crosscubeTextureSet:r})}},t,this,[[4,6],[1,3]])})),function(t){return r.apply(this,arguments)})},{key:"createSceneGeometries",value:function(t,e){var i={};return t.scene.object.children.forEach(function(t){var r;if(null!==(r=t.userData)&&void 0!==r&&r.libraryId&&e[t.userData.libraryId]){var s=e[t.userData.libraryId].boundingBox,o=new n.BoxGeometry(s.x||1,s.y||1,s.z||1);i[t.geometry]=o}else{var a=t.uuid&&(t.uuid.toLowerCase().includes("connector")||t.uuid.toLowerCase().includes("gateway"));i[t.geometry]=a?new n.SphereGeometry(.1,16,16):new n.BoxGeometry(1,1,1)}}),i}},{key:"createSceneObject",value:function(t,e,i){var r=this,s=e[t.geometry],o=i[t.material];o||(o=new n.MeshPhysicalMaterial({color:12632256,roughness:.15,metalness:.9,emissive:0,envMapIntensity:1.5,transparent:!0,opacity:.8}));var a=new n.Mesh(s,o);if(a.uuid=t.uuid,a.name=t.name||t.uuid,a.userData||(a.userData={}),a.userData.originalUuid=t.uuid,t.userData&&(a.userData=y({},t.userData),a.userData.componentType||(a.userData.libraryId?a.userData.componentType="component":t.uuid&&t.uuid.toLowerCase().includes("connector")?a.userData.componentType="connector":t.uuid&&t.uuid.toLowerCase().includes("gateway")&&(a.userData.componentType="gateway"))),a.isMesh&&(a.castShadow=!0,a.receiveShadow=!0),t.position&&a.position.set(t.position.x||0,t.position.y||0,t.position.z||0),t.rotation){var u=t.rotation.x*(Math.PI/180),h=t.rotation.y*(Math.PI/180),c=t.rotation.z*(Math.PI/180);a.rotation.set(u,h,c)}return t.scale&&a.scale.set(t.scale.x||1,t.scale.y||1,t.scale.z||1),t.children&&t.children.forEach(function(t){a.add(r.createSceneObject(t,e,i))}),a}},{key:"computeWorldBoundingBoxes",value:function(t){this.sceneViewer.scene.traverse(function(e){if(e.isMesh){var i=null,r=function(t){var n,i=l(t);try{for(i.s();!(n=i.n()).done;){var s,o,a=n.value;if(a.uuid===e.uuid||a.uuid===(null===(s=e.userData)||void 0===s?void 0:s.originalUuid)||e.uuid===(null===(o=a.userData)||void 0===o?void 0:o.originalUuid))return a;if(a.children){var u=r(a.children);if(u)return u}}}catch(t){i.e(t)}finally{i.f()}return null};if(i=r(t.scene.object.children)){var s=(new n.Box3).setFromObject(e);i.userData||(i.userData={}),i.userData.worldBoundingBox={min:s.min.toArray(),max:s.max.toArray()}}}})}},{key:"loadSceneData",value:(i=s(g().m(function t(e){var i,r,s,o,a,u,h,c,l,f,d,v,p=this,w=arguments;return g().w(function(t){for(;;)switch(t.n){case 0:return i=!(w.length>1&&void 0!==w[1])||w[1],r=this.sceneViewer,t.p=1,s=function(t){t.traverse(function(t){if(t.userData&&t.userData.direction){var e=new n.Matrix4;e.copy(t.matrixWorld),t.userData.worldMatrixOriginal=e.elements}})},i&&(r.transformManager&&r.transformManager.transformControls,this.clearSceneObjects()),r.currentSceneData=e,o={},t.p=2,t.n=3,fetch("./library/component-dictionary.json");case 3:return a=t.v,t.n=4,a.json();case 4:o=t.v,t.n=6;break;case 5:t.p=5,t.v;case 6:return t.n=7,this.preloadMissingModels(e,o);case 7:return t.n=8,this.createSceneMaterials(e);case 8:if(u=t.v,h=u.materials,c=u.crosscubeTextureSet,l=this.createSceneGeometries(e,o),f=[],e.scene.object.children.forEach(function(t,e){var n,i,s,a=p.createSceneObject(t,l,h);r.scene.add(a),null!==(n=t.userData)&&void 0!==n&&n.libraryId&&o[null===(i=t.userData)||void 0===i?void 0:i.libraryId]&&f.push({basicObject:a,jsonData:t,componentData:o[null===(s=t.userData)||void 0===s?void 0:s.libraryId]})}),this.computeWorldBoundingBoxes(e),s(r.scene),d=[],f.forEach(function(t,e){var n=t.basicObject,i=t.jsonData,r=t.componentData,s=p.loadLibraryModel(n,i,r).then(function(t){return f[e].glbModel=t,t}).catch(function(t){return n});d.push(s)}),!(d.length>0)){t.n=10;break}return t.n=9,Promise.all(d);case 9:"undefined"!=typeof window&&(v=new CustomEvent("sceneUpdateComplete",{detail:{timestamp:Date.now()}}),window.dispatchEvent(v));case 10:if(f.forEach(function(t,e){t.basicObject;var i=t.jsonData,r=(t.componentData,t.glbModel);r.userData.associatedJsonObject=i;var s=(new n.Box3).setFromObject(r);i.type="Mesh",i.userData.worldBoundingBox.min=s.min.toArray(),i.userData.worldBoundingBox.max=s.max.toArray()}),e.scene.object.children.push({uuid:"GROUND",type:"Mesh",name:"Ground",layers:1,matrix:[1,0,0,0,0,0,-1,0,0,1,0,0,0,-.01,0,1],up:[0,1,0],userData:{worldBoundingBox:{min:[-30,-.01,-30],max:[30,-.01,30]}}}),!r.pathfindingManager){t.n=11;break}return t.n=11,r.pathfindingManager.initializePathfinder(e,c);case 11:r.currentSceneData=e,r.crosscubeTextureSet=c,i&&(r.transformManager&&r.transformManager.transformControls?r.transformManager.transformControls&&(r.transformManager.transformControls.visible=!1):r.initTransformControls(),r.ensureTransformControlsAttached(!1),r.transformManager&&r.transformManager.transformControls&&(r.keepTransformControlsInactive(),r.transformManager.transformControls.visible=!1)),t.n=13;break;case 12:t.p=12,t.v;case 13:return t.a(2)}},t,this,[[2,5],[1,12]])})),function(t){return i.apply(this,arguments)})},{key:"loadScene",value:(e=s(g().m(function t(){var e,n,i,r;return g().w(function(t){for(;;)switch(t.n){case 0:return e=this.sceneViewer,t.p=1,n=e.$config.defaultCentralPlantUrl,t.n=2,fetch(n);case 2:return i=t.v,t.n=3,i.json();case 3:return r=t.v,e.currentSceneData=r,t.n=4,this.loadSceneData(r,!1);case 4:t.n=6;break;case 5:t.p=5,t.v;case 6:return t.a(2)}},t,this,[[1,5]])})),function(){return e.apply(this,arguments)})},{key:"loadSceneFromData",value:(t=s(g().m(function t(e){return g().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,this.loadSceneData(e,!0);case 1:return t.a(2)}},t,this)})),function(e){return t.apply(this,arguments)})},{key:"createEmptyScene",value:function(){var t=this.sceneViewer;t.transformManager&&t.transformManager.transformControls&&t.disableTransformControls(),this.clearSceneObjects(),t.transformManager&&t.transformManager.transformControls&&(t.transformManager.setEnabled(!1),t.transformManager.transformControls.visible=!1,t.transformManager.selectedObject&&t.transformManager.deselectObject())}},{key:"clearModelCache",value:function(){var t=this.sceneViewer;t.modelCache&&t.modelCache.clear(),t.loadingPromises&&t.loadingPromises.clear()}},{key:"deselectObject",value:function(){var t=this.sceneViewer;t.transformManager&&t.transformManager.deselectObject(),t.selectedObjectForTransform=null}},{key:"setupEventListeners",value:function(){var t,e,n,i,r=this;this.sceneViewer;var o=this.loadSceneFromData.bind(this);null===(t=window.$nuxt)||void 0===t||null===(e=t.$on)||void 0===e||e.call(t,"loadNewScene",function(){var t=s(g().m(function t(e){return g().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,o(e);case 1:return t.a(2)}},t)}));return function(e){return t.apply(this,arguments)}}()),null===(n=window.$nuxt)||void 0===n||null===(i=n.$on)||void 0===i||i.call(n,"createNewScene",function(){r.createEmptyScene()})}},{key:"updateSceneDataAfterTransform",value:function(t,e){var i,r,s=!1;if(this.sceneViewer.pathfindingManager.recomputeWorldBoundingBoxes(e),"gateway"===(null===(i=t.userData)||void 0===i?void 0:i.componentType)&&"computed"===(null===(r=t.userData)||void 0===r?void 0:r.origin)){var o;t.userData.origin="declared";for(var a=0;a<e.scene.object.children.length;a++){var u,h,c=e.scene.object.children[a];if(c.uuid===t.uuid||c.uuid===(null===(u=t.userData)||void 0===u?void 0:u.originalUuid)||t.uuid===(null===(h=c.userData)||void 0===h?void 0:h.originalUuid)){c.userData||(c.userData={}),c.userData.origin="declared";break}}if(null!==(o=t.userData)&&void 0!==o&&o.connections&&e.connections){var l=t.userData.connections,f=e.connections;l.removed&&Array.isArray(l.removed)&&(e.connections=f.filter(function(t){var e=l.removed.some(function(e){return e.from===t.from&&e.to===t.to||e.from===t.to&&e.to===t.from});return!e})),l.added&&Array.isArray(l.added)&&l.added.forEach(function(t){e.connections.some(function(e){return e.from===t.from&&e.to===t.to||e.from===t.to&&e.to===t.from})||e.connections.push(t)})}}for(var d=function(){var i,r,o,a,u=e.scene.object.children[v],h=!1;if(u.uuid!==t.uuid&&u.uuid!==(null===(i=t.userData)||void 0===i?void 0:i.originalUuid)&&t.uuid!==(null===(r=u.userData)||void 0===r?void 0:r.originalUuid)||(h=!0),!h&&null!==(o=t.userData)&&void 0!==o&&o.libraryId&&null!==(a=u.userData)&&void 0!==a&&a.libraryId&&t.userData.libraryId===u.userData.libraryId){if(u.position&&t.position){var c=Math.abs(t.position.x-u.position.x),l=Math.abs(t.position.y-u.position.y),f=Math.abs(t.position.z-u.position.z);c<1&&l<1&&f<1&&(h=!0)}}if(h){var d=(new n.Box3).setFromObject(t),p=function(t,e){return t&&e?t.map(function(t){var i=e.find(function(e){var n,i,r,s;if(e.uuid===t.uuid||e.uuid===(null===(n=t.userData)||void 0===n?void 0:n.originalUuid)||(null===(i=e.userData)||void 0===i?void 0:i.originalUuid)===t.uuid)return!0;if(null!==(r=e.userData)&&void 0!==r&&r.componentType&&null!==(s=t.userData)&&void 0!==s&&s.componentType&&e.userData.componentType===t.userData.componentType&&"connector"===e.userData.componentType){if(t.position&&e.position){var o=Math.abs(e.position.x-t.position.x),a=Math.abs(e.position.y-t.position.y),u=Math.abs(e.position.z-t.position.z);if(o<.1&&a<.1&&u<.1)return!0}}return!1});if(i&&i.isMesh){var r=(new n.Box3).setFromObject(i);return y(y({},t),{},{userData:y(y(y({},t.userData),i.userData),{},{worldBoundingBox:{min:r.min.toArray(),max:r.max.toArray()}}),children:t.children?p(t.children,i.children):t.children})}return y(y({},t),{},{children:t.children?p(t.children,e):t.children})}):t};return t.traverse(function(t){if(t.userData&&t.userData.direction&&t.userData.worldMatrixOriginal){t.updateMatrixWorld(!0);var e=new n.Matrix4;e.copy(t.matrixWorld);var i=new n.Matrix4;i.elements=t.userData.worldMatrixOriginal;var r=new n.Matrix4,s=new n.Matrix4;r.extractRotation(e),s.extractRotation(i);var o=new n.Matrix4;o.copy(r),o.multiply(s.invert());var a=(new n.Vector3).fromArray(t.userData.direction);a.applyMatrix4(o),a.normalize();a.x=Math.abs(a.x)>.5?Math.sign(a.x):0,a.y=Math.abs(a.y)>.5?Math.sign(a.y):0,a.z=Math.abs(a.z)>.5?Math.sign(a.z):0,t.userData.direction=a.toArray(),t.userData.worldMatrixOriginal=e.elements}}),e.scene.object.children[v]=y(y({},u),{},{matrix:t.matrix.elements,position:{x:t.position.x,y:t.position.y,z:t.position.z},rotation:{x:t.rotation.x,y:t.rotation.y,z:t.rotation.z},scale:{x:t.scale.x,y:t.scale.y,z:t.scale.z},userData:y(y({},u.userData),{},{worldBoundingBox:{min:d.min.toArray(),max:d.max.toArray()}}),children:u.children?p(u.children,t.children):u.children}),s=!0,1}},v=0;v<e.scene.object.children.length&&!d();v++);return!!s}}]);var t,e,i,r,o,u,h}(),bn=function(){return c(function t(e){a(this,t),this.sceneViewer=e,this.lastFrameTime=0,this.targetFPS=60,this.frameInterval=1e3/this.targetFPS,this.animationId=null},[{key:"startAnimation",value:function(){var t=this,e=this.sceneViewer,n=function(i){e.isDestroyed||(t.animationId=requestAnimationFrame(n),i-t.lastFrameTime<t.frameInterval||(t.lastFrameTime=i,!e.isDestroyed&&e.controls&&e.renderer&&e.scene&&e.camera&&t.updateFrame()))};n(0),$e.info("Animation loop started")}},{key:"updateFrame",value:function(){var t=this.sceneViewer;t.controls.update(),t.performanceMonitor&&(t.performanceMonitor.update(),t.performanceMonitor.updateSceneStats(t.scene)),t.renderer.render(t.scene,t.camera),t.tooltipsManager&&t.tooltipsManager.render()}},{key:"stopAnimation",value:function(){this.animationId&&(cancelAnimationFrame(this.animationId),this.animationId=null,$e.info("Animation loop stopped"))}},{key:"setTargetFPS",value:function(t){this.targetFPS=t,this.frameInterval=1e3/this.targetFPS,$e.info("Target FPS set to: ".concat(t))}},{key:"getCurrentFPS",value:function(){var t=this.sceneViewer;return t.performanceMonitor?t.performanceMonitor.getCurrentFPS():null}},{key:"dispose",value:function(){this.stopAnimation(),this.lastFrameTime=0,$e.info("AnimationManager disposed")}}])}(),kn=function(){return c(function t(e){a(this,t),this.sceneViewer=e,this.autoRotateSpeed=1,this.Be=!1},[{key:"toggleCameraRotation",value:function(){var t=this.sceneViewer;if(!t.controls||!t.sceneInitializationManager)return!1;var e=t.sceneInitializationManager.toggleAutoRotation();return this.Be=e,e&&t.controls.autoRotateSpeed!==this.autoRotateSpeed&&(t.controls.autoRotateSpeed=this.autoRotateSpeed),e}},{key:"isAutoRotating",value:function(){return this.sceneViewer.controls&&(this.Be=this.sceneViewer.controls.autoRotate),this.Be}},{key:"setAutoRotation",value:function(t){var e=this.sceneViewer;if(e.sceneInitializationManager){var n=e.sceneInitializationManager.toggleAutoRotation(t);return this.Be=n,n}return!1}}])}();class Mn extends t.Object3D{constructor(e=document.createElement("div")){super(),this.isCSS2DObject=!0,this.element=e,this.element.style.position="absolute",this.element.style.userSelect="none",this.element.setAttribute("draggable",!1),this.center=new t.Vector2(.5,.5),this.addEventListener("removed",function(){this.traverse(function(t){t.element instanceof t.element.ownerDocument.defaultView.Element&&null!==t.element.parentNode&&t.element.remove()})})}copy(t,e){return super.copy(t,e),this.element=t.element.cloneNode(!0),this.center=t.center,this}}const xn=new t.Vector3,Tn=new t.Matrix4,Sn=new t.Matrix4,En=new t.Vector3,An=new t.Vector3;class _n{constructor(t={}){const e=this;let n,i,r,s;const o={objects:new WeakMap},a=void 0!==t.element?t.element:document.createElement("div");function u(t){t.isCSS2DObject&&(t.element.style.display="none");for(let e=0,n=t.children.length;e<n;e++)u(t.children[e])}function h(t,n,i){if(!1!==t.visible){if(t.isCSS2DObject){xn.setFromMatrixPosition(t.matrixWorld),xn.applyMatrix4(Sn);const u=xn.z>=-1&&xn.z<=1&&!0===t.layers.test(i.layers),h=t.element;h.style.display=!0===u?"":"none",!0===u&&(t.onBeforeRender(e,n,i),h.style.transform="translate("+-100*t.center.x+"%,"+-100*t.center.y+"%)translate("+(xn.x*r+r)+"px,"+(-xn.y*s+s)+"px)",h.parentNode!==a&&a.appendChild(h),t.onAfterRender(e,n,i));const l={distanceToCameraSquared:c(i,t)};o.objects.set(t,l)}for(let e=0,r=t.children.length;e<r;e++)h(t.children[e],n,i)}else u(t)}function c(t,e){return En.setFromMatrixPosition(t.matrixWorld),An.setFromMatrixPosition(e.matrixWorld),En.distanceToSquared(An)}a.style.overflow="hidden",this.domElement=a,this.getSize=function(){return{width:n,height:i}},this.render=function(t,e){!0===t.matrixWorldAutoUpdate&&t.updateMatrixWorld(),null===e.parent&&!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),Tn.copy(e.matrixWorldInverse),Sn.multiplyMatrices(e.projectionMatrix,Tn),h(t,t,e),function(t){const e=function(t){const e=[];return t.traverseVisible(function(t){t.isCSS2DObject&&e.push(t)}),e}(t).sort(function(t,e){if(t.renderOrder!==e.renderOrder)return e.renderOrder-t.renderOrder;return o.objects.get(t).distanceToCameraSquared-o.objects.get(e).distanceToCameraSquared}),n=e.length;for(let t=0,i=e.length;t<i;t++)e[t].element.style.zIndex=n-t}(t)},this.setSize=function(t,e){n=t,i=e,r=n/2,s=i/2,a.style.width=t+"px",a.style.height=e+"px"}}}var On,Cn=function(t){for(var e,n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];return(e=console).log.apply(e,["๐Ÿ” [Tooltips] ".concat(t)].concat(i))},Rn=function(t){for(var e,n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];return(e=console).log.apply(e,["โ„น๏ธ [Tooltips] ".concat(t)].concat(i))},Pn=function(t){for(var e,n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];return(e=console).warn.apply(e,["โš ๏ธ [Tooltips] ".concat(t)].concat(i))},jn=function(t){for(var e,n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];return(e=console).error.apply(e,["โŒ [Tooltips] ".concat(t)].concat(i))},Dn=function(){return c(function t(e,n,i){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;a(this,t),this.container=e,this.camera=n,this.scene=i,this.transformControlsManager=r,this.tooltipTemplate='\n<div class="component-tooltip" style="\n background-color: rgba(255, 255, 255, 0.95); \n color: #333333; \n border-radius: 8px; \n padding: 12px; \n width: 250px; \n font-family: -apple-system, BlinkMacSystemFont, \'Segoe UI\', Roboto, sans-serif;\n box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);\n border: 1px solid rgba(0, 0, 0, 0.1);\n user-select: none;\n pointer-events: auto;\n font-size: 13px;\n line-height: 1.4;\n transform: translate(-50%, -100%);\n margin-top: 0px;\n margin-left: 0px;\n position: relative;\n z-index: 1000;\n">\n <div class="tooltip-header" style="\n font-weight: 600; \n padding-bottom: 8px; \n border-bottom: 1px solid rgba(0, 0, 0, 0.1); \n margin-bottom: 8px;\n font-size: 14px;\n color: #2c3e50;\n ">Component Name</div>\n <div class="tooltip-body">\n <div class="tooltip-type" style="\n font-size: 12px;\n color: #666;\n margin-bottom: 8px;\n font-style: italic;\n text-transform: uppercase;\n letter-spacing: 0.5px;\n "></div>\n <div class="tooltip-attributes">\n \x3c!-- Dynamic attributes will be inserted here --\x3e\n </div>\n <div class="tooltip-row tooltip-actions" style="display: flex; align-items: center; justify-content: space-between; margin-top: 12px; padding-top: 8px; border-top: 1px solid rgba(0, 0, 0, 0.1);">\n <div class="tooltip-key" style="flex: 1; color: #555555; font-size: 12px;">Add:</div>\n <div class="tooltip-dropdown-container" style="flex: 1; text-align: center;">\n <select class="tooltip-dropdown" style="\n background-color: #f8f9fa;\n color: #333333;\n border: 1px solid #ddd;\n padding: 4px 8px;\n border-radius: 4px;\n width: 100%;\n cursor: pointer;\n pointer-events: auto;\n font-size: 12px;\n ">\n <option value="" disabled selected>Select...</option>\n <option value="gateway">Gateway</option>\n <option value="connector">Connector</option>\n </select>\n </div>\n </div>\n </div>\n</div>\n',this.tooltipRenderer=null,this.selectedMesh=null,this.tooltipParent=null,this.tooltipObject=null,this.init()},[{key:"init",value:function(){this.tooltipRenderer=new _n,this.tooltipRenderer.setSize(this.container.clientWidth,this.container.clientHeight),this.tooltipRenderer.domElement.style.position="absolute",this.tooltipRenderer.domElement.style.top="0",this.tooltipRenderer.domElement.style.left="0",this.tooltipRenderer.domElement.style.overflow="visible",this.tooltipRenderer.domElement.style.pointerEvents="none",this.tooltipRenderer.domElement.style.zIndex="100",this.container.appendChild(this.tooltipRenderer.domElement)}},{key:"resize",value:function(){this.tooltipRenderer&&this.tooltipRenderer.setSize(this.container.clientWidth,this.container.clientHeight)}},{key:"setTransformControlsManager",value:function(t){this.transformControlsManager=t,Rn("Transform controls manager set for tooltips"),this.transformControlsManager&&this.setupTransformControlsEvents(),this.tooltipObject&&this.updateTooltipForTransform()}},{key:"setupTransformControlsEvents",value:function(){var t=this;this.transformControlsManager&&this.transformControlsManager.on({onTransform:function(e){e===t.selectedMesh&&t.tooltipObject&&t.updateTooltipForTransform()},onTransformEnd:function(e){e===t.selectedMesh&&t.tooltipObject&&t.updateTooltipForTransform()}})}},{key:"setSelectedMesh",value:function(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;this.selectedMesh!==e&&(Rn("Setting selected mesh:",e?e.uuid:"none"),this.clearTooltip(),this.selectedMesh=e,e&&null!==(t=e.userData)&&void 0!==t&&null!==(t=t.component)&&void 0!==t&&t.attributes?(Rn("Mesh has component attributes, showing tooltip"),this.showTooltip()):e&&(Pn("Mesh does not have required component data for tooltip:",e),e.userData&&Cn("Available userData:",e.userData)))}},{key:"render",value:function(){if(this.tooltipRenderer&&this.camera&&this.scene)try{this.tooltipRenderer.render(this.scene,this.camera)}catch(t){jn("Error rendering tooltips:",t)}}},{key:"dispose",value:function(){this.clearTooltip(),this.transformControlsManager&&(this.transformControlsManager=null),this.tooltipRenderer&&this.tooltipRenderer.domElement&&this.tooltipRenderer.domElement.parentNode&&this.tooltipRenderer.domElement.parentNode.removeChild(this.tooltipRenderer.domElement),this.tooltipRenderer=null,this.selectedMesh=null,this.container=null,this.camera=null,this.scene=null}},{key:"showTooltip",value:function(){try{if(!this.selectedMesh||!this.selectedMesh.userData||!this.selectedMesh.userData.component)return void Pn("Cannot show tooltip, missing data in selectedMesh");Rn("Showing tooltip for:",this.selectedMesh.uuid);var t=this.selectedMesh.userData.component;if(!t.attributes)return void Pn("Component has no attributes:",t);var e=t.attributes,n=document.createElement("div");n.innerHTML=this.tooltipTemplate.trim();var i=n.firstElementChild||n.firstChild;Cn("showTooltip this.selectedMesh:",this.selectedMesh),Cn("showTooltip meshComponentData:",t);var r=i.querySelector(".tooltip-header");r&&(this.selectedMesh.name&&""!==this.selectedMesh.name?r.textContent=this.selectedMesh.name:r.textContent=this.selectedMesh.userData.originalUuid||this.selectedMesh.userData.uuid||"Unknown Component");var s=i.querySelector(".tooltip-type");s&&t.type&&(s.textContent=t.type);var o=i.querySelector(".tooltip-attributes");if(o&&e&&Object.keys(e).length>0){o.innerHTML="",Object.keys(e).forEach(function(t){var n=e[t],i=document.createElement("div");i.className="tooltip-row",i.style.display="flex",i.style.alignItems="center",i.style.justifyContent="space-between",i.style.marginBottom="5px";var r=document.createElement("div");r.className="tooltip-key",r.style.flex="1",r.style.color="#555555",r.textContent="".concat(n.key||t,":");var s=document.createElement("div");s.className="tooltip-value",s.style.flex="1",s.style.textAlign="center",s.style.color="#000000";var a=n.value||"0";n.unit&&(a+=" ".concat(n.unit)),s.textContent=a,i.appendChild(r),i.appendChild(s),o.appendChild(i)});var a=i.querySelector(".tooltip-dropdown");a&&a.addEventListener("change",function(t){t.stopPropagation();var e=t.target.value;Rn("Add option selected: ".concat(e)),"gateway"===e?Rn("Adding Gateway"):"connector"===e&&Rn("Adding Connector"),t.target.selectedIndex=0})}var u=new Mn(i);this.tooltipParent=this.selectedMesh,this.tooltipObject=u;var h=this.calculateTooltipPosition();u.position.set(h.x,h.y,h.z),u.userData={isTooltip:!0},this.selectedMesh.add(u),Rn("Tooltip positioned at:",h)}catch(t){jn("Error showing tooltip:",t)}}},{key:"updateTooltip",value:function(){if(this.tooltipParent&&this.tooltipObject){var t=this.calculateTooltipPosition();this.tooltipObject.position.set(t.x,t.y,t.z)}}},{key:"updateTooltipForTransform",value:function(){if(this.tooltipObject&&this.selectedMesh){var t=this.calculateTooltipPosition();this.tooltipObject.position.set(t.x,t.y,t.z),Cn("Tooltip position updated for transform")}}},{key:"getObjectBoundingBox",value:function(t){return(new n.Box3).setFromObject(t)}},{key:"calculateOptimalTooltipOffset",value:function(){if(!this.camera||!this.selectedMesh)return 1.5;var t=new n.Vector3;this.selectedMesh.getWorldPosition(t);var e=new n.Vector3;this.camera.getWorldPosition(e);return 1}},{key:"calculateTooltipPosition",value:function(){var t=this.getObjectBoundingBox(this.selectedMesh),e=this.findClosestBoundingBoxCorner(t),i=new n.Vector3;this.selectedMesh.getWorldPosition(i);var r=e.clone().sub(i),s=this.calculatePixelBasedOffset(r,i),o={x:r.x+s.x,y:r.y+s.y,z:r.z+s.z};if(this.transformControlsManager&&this.transformControlsManager.selectedObject===this.selectedMesh)try{var a=this.transformControlsManager.getWorldTransformData();if(a&&a.position)return Rn("Using transform controls position for tooltip at closest corner"),{x:r.x+s.x,y:r.y+s.y,z:r.z+s.z}}catch(t){Pn("Error getting transform controls position:",t)}return Rn("Positioning tooltip at closest corner to origin:",o),o}},{key:"calculatePixelBasedOffset",value:function(t,e){if(!this.camera)return{x:0,y:0,z:0};var i=250;if(this.tooltipObject&&this.tooltipObject.element){var r=this.tooltipObject.element;if(r.offsetWidth>0)i=r.offsetWidth;else{var s=document.createElement("div");s.style.position="absolute",s.style.visibility="hidden",s.style.top="-9999px",document.body.appendChild(s),s.appendChild(r),i=r.offsetWidth||250,document.body.removeChild(s)}}var o=i/2,a=e.clone().add(t),u=new n.Vector3;this.camera.getWorldPosition(u);var h=new n.Vector3;this.camera.getWorldDirection(h);var c=this.isPositionOnRightSideOfCameraMidline(a,u,h),l=a.distanceTo(u),f=0;if(this.camera.isPerspectiveCamera){var d=this.camera.fov*Math.PI/180,v=Math.tan(d/2)*l*this.camera.aspect;f=o/this.container.clientWidth*(2*v)}else if(this.camera.isOrthographicCamera){var p=(this.camera.right-this.camera.left)/2;f=o/this.container.clientWidth*(2*p)}var w=new n.Vector3;this.camera.getWorldDirection(w),w.cross(this.camera.up).normalize();var m=c?-1:1,y=w.multiplyScalar(f*m);return Cn("Tooltip pixel offset calculated:",{tooltipWidth:i,halfTooltipWidth:o,distanceToCamera:l,screenSpaceOffset:f,isOnRightSide:c,offsetDirection:m,worldOffset:y}),{x:y.x,y:0,z:y.z}}},{key:"findClosestBoundingBoxCorner",value:function(t){var e=t.min,i=t.max,r=[new n.Vector3(e.x,e.y,e.z),new n.Vector3(i.x,e.y,e.z),new n.Vector3(e.x,i.y,e.z),new n.Vector3(i.x,i.y,e.z),new n.Vector3(e.x,e.y,i.z),new n.Vector3(i.x,e.y,i.z),new n.Vector3(e.x,i.y,i.z),new n.Vector3(i.x,i.y,i.z)];return this.findCornerClosestToCameraVerticalMidline(r)}},{key:"findCornerClosestToCameraVerticalMidline",value:function(t){if(!this.camera)return Pn("No camera available, using first corner"),t[0];var e=new n.Vector3;this.camera.getWorldPosition(e);var i=new n.Vector3;this.camera.getWorldDirection(i);for(var r=t[0],s=this.getDistanceToVerticalMidline(t[0],e,i),o=1;o<t.length;o++){var a=this.getDistanceToVerticalMidline(t[o],e,i);a<s&&(s=a,r=t[o])}return Cn("Closest corner to camera vertical midline:",r,"Distance:",s),r}},{key:"getDistanceToVerticalMidline",value:function(t,e,n){var i=t.clone().sub(e),r=i.dot(n),s=n.clone().multiplyScalar(r);return i.clone().sub(s).length()}},{key:"clearTooltip",value:function(){this.tooltipParent&&this.tooltipObject&&(this.tooltipParent.remove(this.tooltipObject),this.tooltipParent=null,this.tooltipObject=null)}},{key:"handleSceneClick",value:function(t,e){this.clearTooltip(),this.selectedMesh=null}},{key:"isSelectableComponent",value:function(t){var e,n;return!!(t&&t.userData&&t.userData.component)||!(!t||!(null!==(e=t.userData)&&void 0!==e&&e.isPipeSegment||null!==(n=t.userData)&&void 0!==n&&n.isPipeJunction))}},{key:"isPositionOnRightSideOfCameraMidline",value:function(t,e,i){var r=new n.Vector3;return this.camera.getWorldDirection(r),r.cross(this.camera.up).normalize(),t.clone().sub(e).dot(r)>0}}])}(),In=function(){return c(function t(e){a(this,t),this.scene=e.scene,this.camera=e.camera,this.transformManager=e.transformManager,this.modelPreloader=e.modelPreloader,this.componentManager=e.componentManager,this.currentDragComponentData=null,this.dragPreviewSize=null,this.isCreatingDragPreview=!1,this.dragPreviewMesh=null,this.dragPreviewBoundingBox=null,this.dragTargetPosition=null,this.isDragOverScene=!1,this.onComponentDragStart=this.onComponentDragStart.bind(this),this.onComponentDragEnd=this.onComponentDragEnd.bind(this),this.onDragEnter=this.onDragEnter.bind(this),this.onDragLeave=this.onDragLeave.bind(this),this.onDragOver=this.onDragOver.bind(this),this.onDrop=this.onDrop.bind(this)},[{key:"onComponentDragStart",value:(l=s(g().m(function t(e,n){return g().w(function(t){for(;;)switch(t.n){case 0:return this.currentDragComponentData=e,t.n=1,this.calculateDragPreviewSize(e);case 1:return t.a(2,!0)}},t,this)})),function(t,e){return l.apply(this,arguments)})},{key:"onComponentDragEnd",value:function(){return this.currentDragComponentData=null,this.dragPreviewSize=null,this.isCreatingDragPreview=!1,this.clearDragPreview(),this.cleanupDragPreview(),this.dragTargetPosition=null,this.isDragOverScene=!1,!0}},{key:"onDragEnter",value:(h=s(g().m(function t(e,n){var i;return g().w(function(t){for(;;)switch(t.n){case 0:if(e.preventDefault(),this.isDragOverScene=!0,!this.currentDragComponentData)try{(i=e.dataTransfer.getData("application/json"))&&(this.currentDragComponentData=JSON.parse(i))}catch(t){}if(this.dragPreviewSize||!this.currentDragComponentData){t.n=1;break}return t.n=1,this.calculateDragPreviewSize(this.currentDragComponentData);case 1:if(this.dragPreviewMesh||!this.currentDragComponentData||this.isCreatingDragPreview){t.n=4;break}return this.isCreatingDragPreview=!0,t.p=2,t.n=3,this.createDragPreview();case 3:return t.p=3,this.isCreatingDragPreview=!1,t.f(3);case 4:case 5:return t.a(2)}},t,this,[[2,,3,4]])})),function(t,e){return h.apply(this,arguments)})},{key:"onDragLeave",value:function(t,e){e.contains(t.relatedTarget)||(this.isDragOverScene=!1,this.clearDragPreview())}},{key:"onDragOver",value:(u=s(g().m(function t(e,n){var i,r,s,o;return g().w(function(t){for(;;)switch(t.n){case 0:if(e.preventDefault(),e.dataTransfer.dropEffect="copy",this.currentDragComponentData){t.n=4;break}if(t.p=1,!(i=e.dataTransfer.getData("application/json"))){t.n=2;break}if(this.currentDragComponentData=JSON.parse(i),this.dragPreviewSize){t.n=2;break}return t.n=2,this.calculateDragPreviewSize(this.currentDragComponentData);case 2:t.n=4;break;case 3:t.p=3,t.v;case 4:if(!(r=this.calculateDropPosition(e,n))){t.n=6;break}return this.dragTargetPosition=r,t.n=5,this.updateDragPreview(r);case 5:this.dragPreviewMesh&&this.dragPreviewMesh.userData.isFallback&&(s=this.checkBoundingBoxOverlap(),o=s?16711680:65280,this.dragPreviewMesh.material.color.set(o));case 6:return t.a(2)}},t,this,[[1,3]])})),function(t,e){return u.apply(this,arguments)})},{key:"onDrop",value:(o=s(g().m(function t(e,n){var i,r,s,o,a,u,h=arguments;return g().w(function(t){for(;;)switch(t.n){case 0:if(i=h.length>2&&void 0!==h[2]?h[2]:{},e.preventDefault(),this.isDragOverScene=!1,t.p=1,r=e.dataTransfer.getData("application/json")){t.n=2;break}return i.onPlacementCanceled&&i.onPlacementCanceled({reason:"invalid-data",message:"No component data found in drop event"}),t.a(2,!1);case 2:t.p=2,s=JSON.parse(r),t.n=4;break;case 3:return t.p=3,t.v,i.onPlacementCanceled&&i.onPlacementCanceled({reason:"parse-error",message:"Could not parse component data"}),t.a(2,!1);case 4:if(s&&s.libraryId&&s.modelKey){t.n=5;break}return i.onPlacementCanceled&&i.onPlacementCanceled({reason:"invalid-data",message:"Component data missing required fields"}),t.a(2,!1);case 5:if(o=this.calculateDropPosition(e,n)){t.n=6;break}return i.onPlacementCanceled&&i.onPlacementCanceled({reason:"position-error",message:"Could not calculate drop position",componentData:s}),t.a(2,!1);case 6:if(s.position={x:o.x,y:o.y,z:o.z},a=this.checkBoundingBoxOverlap(),u=!1,!a){t.n=7;break}return i.onPlacementCanceled&&i.onPlacementCanceled({reason:"overlap",componentData:s}),t.a(2,!1);case 7:if(!i.onAddComponent){t.n=9;break}return t.n=8,i.onAddComponent(s);case 8:u=t.v,t.n=11;break;case 9:if(!this.componentManager){t.n=11;break}return t.n=10,this.componentManager.addComponentToScene(s);case 10:u=t.v;case 11:return u&&i.onComponentAdded&&i.onComponentAdded({componentData:s,position:o}),t.a(2,u);case 12:return t.p=12,t.v,t.a(2,!1);case 13:return t.p=13,this.clearDragPreview(),this.cleanupDragPreview(),this.currentDragComponentData=null,this.dragPreviewSize=null,this.dragTargetPosition=null,this.isDragOverScene=!1,t.f(13);case 14:return t.a(2)}},t,this,[[2,3],[1,12,13,14]])})),function(t,e){return o.apply(this,arguments)})},{key:"calculateDropPosition",value:function(t,e){if(!this.camera||!e)return null;try{var i,r=e.getBoundingClientRect(),s=(t.clientX-r.left)/r.width*2-1,o=-(t.clientY-r.top)/r.height*2+1,a=new n.Raycaster;a.setFromCamera({x:s,y:o},this.camera);var u=1/((null===(i=this.transformManager)||void 0===i||null===(i=i.snapValues)||void 0===i?void 0:i.translation)||.5),h=null;if(this.scene.traverse(function(t){var e;t.isMesh&&null!==(e=t.userData)&&void 0!==e&&e.isBaseGround&&(h=t)}),h){var c=a.intersectObject(h,!1);if(c.length>0){var l=c[0];return{x:Math.round(l.point.x*u)/u,y:Math.max(0,l.point.y),z:Math.round(l.point.z*u)/u}}}var f=new n.Plane(new n.Vector3(0,1,0),0),d=new n.Vector3;return a.ray.intersectPlane(f,d)&&d?{x:Math.round(d.x*u)/u,y:0,z:Math.round(d.z*u)/u}:{x:0,y:0,z:0}}catch(t){}return null}},{key:"calculateDragPreviewSize",value:(r=s(g().m(function t(e){var n,i,r,s,o,a;return g().w(function(t){for(;;)switch(t.n){case 0:return n=1,i=1,r=1,t.p=1,t.p=2,t.n=3,this.getModelBoundingBox(e);case 3:if(!(s=t.v)){t.n=4;break}n=s.width,i=s.height,r=s.depth,t.n=5;break;case 4:throw new Error("Could not get model bounding box");case 5:t.n=7;break;case 6:t.p=6,t.v,e.dimensions?(n=e.dimensions.width||e.dimensions.x||1,i=e.dimensions.height||e.dimensions.y||1,r=e.dimensions.depth||e.dimensions.z||1):e.boundingBox?(o=e.boundingBox).max&&o.min?(n=Math.abs(o.max.x-o.min.x)||1,i=Math.abs(o.max.y-o.min.y)||1,r=Math.abs(o.max.z-o.min.z)||1):void 0!==o.width&&void 0!==o.height&&void 0!==o.depth?(n=o.width||1,i=o.height||1,r=o.depth||1):"number"==typeof o.x&&"number"==typeof o.y&&"number"==typeof o.z&&(n=o.x||1,i=o.y||1,r=o.z||1):(a=e.type||"").toLowerCase().includes("chiller")?(n=2,i=2,r=2):a.toLowerCase().includes("pump")?(n=1,i=1,r=1):a.toLowerCase().includes("tower")?(n=3,i=4,r=3):(n=1,i=1,r=1);case 7:n=Math.max(n,.5),i=Math.max(i,.5),r=Math.max(r,.5),this.dragPreviewSize={width:n,height:i,depth:r},t.n=9;break;case 8:t.p=8,t.v,this.dragPreviewSize={width:1,height:1,depth:1};case 9:return t.a(2)}},t,this,[[2,6],[1,8]])})),function(t){return r.apply(this,arguments)})},{key:"getModelBoundingBox",value:(i=s(g().m(function t(e){var i,r,s,o,a,u,h;return g().w(function(t){for(;;)switch(t.n){case 0:if(e.libraryId){t.n=1;break}return t.a(2,null);case 1:return t.p=1,r={},t.p=2,t.n=3,fetch("./library/component-dictionary.json");case 3:return s=t.v,t.n=4,s.json();case 4:r=t.v,t.n=6;break;case 5:return t.p=5,t.v,t.a(2,null);case 6:if((o=r[e.libraryId])&&o.modelKey){t.n=7;break}return t.a(2,null);case 7:if(a=null===(i=this.modelPreloader)||void 0===i?void 0:i.getCachedModel(o.modelKey)){t.n=8;break}return t.a(2,null);case 8:return u=(new n.Box3).setFromObject(a),h=u.getSize(new n.Vector3),t.a(2,{width:h.x,height:h.y,depth:h.z});case 9:return t.p=9,t.v,t.a(2,null)}},t,this,[[2,5],[1,9]])})),function(t){return i.apply(this,arguments)})},{key:"updateDragPreview",value:(e=s(g().m(function t(e){return g().w(function(t){for(;;)switch(t.n){case 0:if(this.dragPreviewMesh||this.isCreatingDragPreview){t.n=3;break}return this.isCreatingDragPreview=!0,t.p=1,t.n=2,this.createDragPreview();case 2:return t.p=2,this.isCreatingDragPreview=!1,t.f(2);case 3:this.dragPreviewMesh&&e&&(this.dragPreviewMesh.position.set(e.x,e.y,e.z),this.dragPreviewMesh.visible=!0,this.dragPreviewBoundingBox&&(this.dragPreviewBoundingBox.position.set(e.x,e.y,e.z),this.dragPreviewBoundingBox.visible=!0));case 4:return t.a(2)}},t,this,[[1,,2,3]])})),function(t){return e.apply(this,arguments)})},{key:"createDragPreview",value:(t=s(g().m(function t(){var e,i,r,s,o,a,u,h,c;return g().w(function(t){for(;;)switch(t.n){case 0:if(this.clearDragPreview(),this.scene&&this.currentDragComponentData){t.n=1;break}return t.a(2);case 1:return t.p=1,e={},t.p=2,t.n=3,fetch("./library/component-dictionary.json");case 3:return i=t.v,t.n=4,i.json();case 4:e=t.v,t.n=6;break;case 5:t.p=5,t.v;case 6:if(r=this.currentDragComponentData.libraryId,s=e[r],o=null,s&&s.modelKey&&this.modelPreloader)try{(a=this.modelPreloader.getCachedModel(s.modelKey))&&((o=a.clone()).traverse(function(t){t.isMesh&&(t.material=t.material.clone(),t.material.transparent=!0,t.material.opacity=.4,t.material.depthTest=!0,t.material.depthWrite=!0,t.material.needsUpdate=!0)}),o.userData.isPreview=!0)}catch(t){o=null}return o||(u=this.dragPreviewSize||{width:1,height:1,depth:1},h=new n.BoxGeometry(u.width,u.height,u.depth),c=new n.MeshBasicMaterial({color:65280,wireframe:!0,transparent:!0,opacity:.6}),(o=new n.Mesh(h,c)).userData.isFallback=!0,o.userData.isPreview=!0),this.scene.add(o),this.dragPreviewMesh=o,this.dragPreviewMesh.visible=!1,this.createBoundingBoxHelper(),t.a(2,!0);case 7:return t.p=7,t.v,t.a(2,!1)}},t,this,[[2,5],[1,7]])})),function(){return t.apply(this,arguments)})},{key:"createBoundingBoxHelper",value:function(){if(this.dragPreviewMesh){var t=(new n.Box3).setFromObject(this.dragPreviewMesh),e=t.getSize(new n.Vector3);t.getCenter(new n.Vector3);var i=new n.BoxGeometry(e.x,e.y,e.z),r=new n.LineBasicMaterial({color:16776960,transparent:!0,opacity:.3}),s=new n.EdgesGeometry(i),o=new n.LineSegments(s,r);o.position.copy(this.dragPreviewMesh.position),this.scene.add(o),this.dragPreviewBoundingBox=o,this.dragPreviewBoundingBox.visible=!1}}},{key:"checkBoundingBoxOverlap",value:function(){var t=this;if(!this.dragPreviewMesh||!this.scene)return!1;var e=(new n.Box3).setFromObject(this.dragPreviewMesh),i=[];this.scene.traverse(function(e){!e.isMesh||e===t.dragPreviewMesh||e===t.dragPreviewBoundingBox||e.userData.isBaseGround||e.userData.isBrickWall||e.userData.isBaseGrid||e.userData&&("component"===e.userData.componentType||"connector"===e.userData.componentType||"gateway"===e.userData.componentType)&&i.push(e)});for(var r=0,s=i;r<s.length;r++){var o=s[r],a=(new n.Box3).setFromObject(o);if(e.intersectsBox(a))return!0}return!1}},{key:"clearDragPreview",value:function(){this.dragPreviewMesh&&(this.dragPreviewMesh.visible=!1),this.dragPreviewBoundingBox&&(this.dragPreviewBoundingBox.visible=!1)}},{key:"cleanupDragPreview",value:function(){this.dragPreviewMesh&&(this.scene.remove(this.dragPreviewMesh),this.dragPreviewMesh.geometry&&this.dragPreviewMesh.geometry.dispose(),this.dragPreviewMesh.material&&(Array.isArray(this.dragPreviewMesh.material)?this.dragPreviewMesh.material.forEach(function(t){return t.dispose()}):this.dragPreviewMesh.material.dispose()),this.dragPreviewMesh=null),this.dragPreviewBoundingBox&&(this.scene.remove(this.dragPreviewBoundingBox),this.dragPreviewBoundingBox.geometry&&this.dragPreviewBoundingBox.geometry.dispose(),this.dragPreviewBoundingBox.material&&this.dragPreviewBoundingBox.material.dispose(),this.dragPreviewBoundingBox=null)}},{key:"dispose",value:function(){this.cleanupDragPreview(),this.currentDragComponentData=null,this.dragPreviewSize=null,this.isDragOverScene=!1,this.dragTargetPosition=null}},{key:"getDragState",value:function(){return{isDragging:!!this.currentDragComponentData,isDragOverScene:this.isDragOverScene,dragComponentData:this.currentDragComponentData,dragTargetPosition:this.dragTargetPosition}}}]);var t,e,i,r,o,u,h,l}(),Nn=function(){return c(function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,t),this.scene=e.scene||null,this.camera=e.camera||null,this.renderer=e.renderer||null,this.controls=e.controls||null,this.transformManager=e.transformManager||null,this.componentManager=e.componentManager||null,this.pathfindingManager=e.pathfindingManager||null,this.currentSceneData=e.currentSceneData||null,this.logger=e.logger||console,this.isInitialized=!1,this.selectedObject=null,this.sceneObjects=[],this.logger.info("๐Ÿ”ง SceneHelper initialized")},[{key:"initialize",value:function(t){this.scene=t.scene,this.camera=t.camera,this.renderer=t.renderer,this.controls=t.controls,this.transformManager=t.transformManager,this.componentManager=t.componentManager,this.pathfindingManager=t.pathfindingManager,this.currentSceneData=t.currentSceneData,this.isInitialized=!0,this.logger.info("โœ… SceneHelper initialized with scene components")}},{key:"updateSceneData",value:function(t){this.currentSceneData=t}},{key:"isReady",value:function(){return this.isInitialized&&this.scene&&this.camera&&this.renderer}},{key:"getSceneObjects",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!this.scene)return this.logger.warn("โš ๏ธ Scene not available for object retrieval"),[];var e=t.includeComponents,n=void 0===e||e,i=t.includeConnectors,r=void 0===i||i,s=t.includeGateways,o=void 0===s||s,a=t.includeHelpers,u=void 0!==a&&a,h=t.includeInvisible,c=void 0!==h&&h,l=t.componentTypesFilter,f=void 0===l?null:l,d=[];return this.scene.traverse(function(t){if(t.userData){var e=t.userData.componentType,i=t.visible;(c||i)&&("component"!==e||n)&&("connector"!==e||r)&&("gateway"!==e||o)&&("helper"!==e||u)&&(f&&Array.isArray(f)&&!f.includes(e)||t.name&&(t.name.includes("helper")||t.name.includes("Helper")||t.name.includes("controls")||"CameraGimbal"===t.name||"GridHelper"===t.type||"AxesHelper"===t.type)||d.push({uuid:dt(t),name:t.name||"Unnamed Object",type:t.type,object:t,componentType:e,position:t.position.clone(),rotation:t.rotation.clone(),scale:t.scale.clone(),visible:i,userData:y({},t.userData)}))}}),d}},{key:"getSceneObjectsHierarchy",value:function(){if(!this.scene)return this.logger.warn("โš ๏ธ Scene not available for hierarchy retrieval"),[];var t=function(e){var n,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(e.name&&(e.name.includes("helper")||e.name.includes("Helper")||e.name.includes("controls")||"CameraGimbal"===e.name)||"GridHelper"===e.type||"AxesHelper"===e.type)return null;var r=null===(n=e.userData)||void 0===n?void 0:n.componentType;if(!("Scene"===e.type||"component"===r||"connector"===r||"gateway"===r)&&"Scene"!==e.type)return null;var s={uuid:dt(e),name:e.name||"Unnamed Object",type:e.type,object:e,componentType:r||"other",level:i,visible:e.visible,children:[]};return e.children&&e.children.length>0&&e.children.forEach(function(e){var n=t(e,i+1);n&&s.children.push(n)}),s},e=[];return this.scene.children&&this.scene.children.length>0&&this.scene.children.forEach(function(n){var i=t(n,0);i&&e.push(i)}),e}},{key:"findObjectByUuid",value:function(t){if(!this.scene||!t)return null;var e=null;return this.scene.traverse(function(n){dt(n)!==t||(e=n)}),e}},{key:"findObjectsByName",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!this.scene||!t)return[];var n=[];return this.scene.traverse(function(i){i.name&&((e?i.name===t:i.name.toLowerCase().includes(t.toLowerCase()))&&n.push(i))}),n}},{key:"findObjectsByComponentType",value:function(t){if(!this.scene||!t)return[];var e=[];return this.scene.traverse(function(n){var i;(null===(i=n.userData)||void 0===i?void 0:i.componentType)===t&&e.push(n)}),e}},{key:"isSelectableObject",value:function(t){var e;if(!t||!t.parent)return!1;var n=null===(e=t.userData)||void 0===e?void 0:e.componentType,i="component"===n,r="connector"===n,s="gateway"===n;return(t.isMesh||t.isObject3D)&&t.visible&&(i||r||s)}},{key:"selectObject",value:function(t){return t&&this.isSelectableObject(t)?(this.selectedObject=t,this.transformManager&&this.transformManager.selectObject(t),this.logger.info("โœ… Object selected: ".concat(t.name," (").concat(t.uuid,")")),!0):(this.logger.warn("โš ๏ธ Cannot select invalid object"),!1)}},{key:"deselectObject",value:function(){this.transformManager&&this.transformManager.deselectObject(),this.selectedObject=null,this.logger.info("โœ… Object deselected")}},{key:"getSelectedObject",value:function(){return this.selectedObject}},{key:"getSelectedTransform",value:function(){return this.transformManager&&this.selectedObject?this.transformManager.getTransformData():null}},{key:"focusOnObject",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(t&&this.camera&&this.controls){var i=e.distance,r=void 0===i?10:i,s=e.animate,o=void 0===s||s,a=e.duration,u=void 0===a?1e3:a,h=new n.Vector3;t.getWorldPosition(h);var c=h.clone().add(new n.Vector3(r,r,r));o&&this.controls.transitionTo?this.controls.transitionTo(c,h,u):(this.camera.position.copy(c),this.camera.lookAt(h),this.controls.target&&(this.controls.target.copy(h),this.controls.update())),this.logger.info("๐ŸŽฅ Camera focused on object: ".concat(t.name))}else this.logger.warn("โš ๏ธ Cannot focus on object: missing components")}},{key:"fitAllObjectsInView",value:function(){if(this.camera&&this.controls){var t=new n.Box3,e=this.getSceneObjects({includeHelpers:!1});if(0!==e.length){e.forEach(function(e){var n=e.object;t.expandByObject(n)});var i=t.getCenter(new n.Vector3),r=t.getSize(new n.Vector3),s=Math.max(r.x,r.y,r.z)/(2*Math.tan(Math.PI*this.camera.fov/360));this.camera.position.copy(i),this.camera.position.z+=1.5*s,this.controls.target&&(this.controls.target.copy(i),this.controls.update()),this.logger.info("๐ŸŽฅ Camera fitted to ".concat(e.length," objects"))}else this.logger.warn("โš ๏ธ No objects to fit in view")}else this.logger.warn("โš ๏ธ Cannot fit objects in view: missing camera or controls")}},{key:"getComponentsWithDimensions",value:function(){if(!this.currentSceneData)return[];var t=[];return this.scene.traverse(function(e){e.userData&&"component"===e.userData.componentType&&e.userData.dimensions&&t.push({name:e.name||"Unnamed Component",uuid:dt(e),position:e.position.clone(),rotation:e.rotation.clone(),dimensions:e.userData.dimensions,boundingBox:e.userData.adaptedBoundingBox,libraryId:e.userData.libraryId,object:e})}),t}},{key:"getSceneStats",value:function(){if(!this.scene)return{};var t={totalObjects:0,components:0,connectors:0,gateways:0,meshes:0,materials:0,textures:0,lights:0,cameras:0};return this.scene.traverse(function(e){var n,i,r;t.totalObjects++,"component"===(null===(n=e.userData)||void 0===n?void 0:n.componentType)&&t.components++,"connector"===(null===(i=e.userData)||void 0===i?void 0:i.componentType)&&t.connectors++,"gateway"===(null===(r=e.userData)||void 0===r?void 0:r.componentType)&&t.gateways++,e.isMesh&&t.meshes++,e.isLight&&t.lights++,e.isCamera&&t.cameras++,e.material&&t.materials++}),t}},{key:"debugSceneInfo",value:function(){var t,e=this.getSceneStats(),n=this.getSceneObjects();this.logger.info("๐Ÿ” Scene Debug Information:"),this.logger.info(" Statistics:",e),this.logger.info(" Objects:",n.length),this.logger.info(" Selected:",(null===(t=this.selectedObject)||void 0===t?void 0:t.name)||"None"),this.logger.info(" Scene Data:",this.currentSceneData?"Available":"Not Available")}},{key:"hasVisibleObjects",value:function(){var t=this;if(!this.scene)return!1;var e=!1;return this.scene.traverse(function(n){var i;n.visible&&null!==(i=n.userData)&&void 0!==i&&i.componentType&&n!==t.scene&&(e=!0)}),e}},{key:"dispose",value:function(){this.scene=null,this.camera=null,this.renderer=null,this.controls=null,this.transformManager=null,this.componentManager=null,this.pathfindingManager=null,this.currentSceneData=null,this.selectedObject=null,this.sceneObjects=[],this.isInitialized=!1,this.logger.info("๐Ÿงน SceneHelper disposed")}}])}(),Ln=function(){return c(function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;a(this,t),this.sceneViewer=e,this.managers={},this.utilities={},this.isInitialized=!1,this.importedSceneData=null,this.metadata={},this.transformHistory={lastTransform:null},this.setDefaultSceneMetadata(),this.initializeUtilities(),e&&(this.initializeManagers(),this.isInitialized=!0)},[{key:"setSceneViewer",value:function(t){this.sceneViewer=t,!this.isInitialized&&t&&(this.initializeManagers(),this.isInitialized=!0)}},{key:"initializeManagers",value:function(){this.sceneViewer&&(this.managers.hotReloadManager=new ht(this.sceneViewer),this.managers.disposalManager=new ct(this.sceneViewer),this.managers.sceneExportManager=new vt(this.sceneViewer),this.managers.componentManager=new pe(this.sceneViewer),this.managers.sceneInitializationManager=new tn(this.sceneViewer),this.managers.environmentManager=new hn(this.sceneViewer),this.managers.keyboardControlsManager=new cn(this.sceneViewer),this.managers.pathfindingManager=new yn(this.sceneViewer),this.managers.sceneOperationsManager=new gn(this.sceneViewer),this.managers.animationManager=new bn(this.sceneViewer),this.managers.cameraControlsManager=new kn(this.sceneViewer))}},{key:"initializeUtilities",value:function(){this.utilities.createTransformControls=ut,this.utilities.generateUuidFromName=lt,this.utilities.getHardcodedUuid=dt,this.utilities.logger=$e,this.utilities.transformLogger=Je,this.utilities.pathfinderLogger=qe,this.utilities.modelLogger=Qe,this.utilities.modelPreloader=ve,this.utilities.SceneHelper=Nn,this.utilities.DragDropManager=In}},{key:"attachToComponent",value:function(){var t=this;this.sceneViewer&&(this.isInitialized||this.initializeManagers(),Object.keys(this.managers).forEach(function(e){t.sceneViewer[e]=t.managers[e]}),Object.keys(this.utilities).forEach(function(e){t.sceneViewer[e]=t.utilities[e]}))}},{key:"initializePostSceneManagers",value:function(){this.sceneViewer.$refs.container&&this.sceneViewer.camera&&this.sceneViewer.scene&&(this.managers.tooltipsManager=new Dn(this.sceneViewer.$refs.container,this.sceneViewer.camera,this.sceneViewer.scene),this.sceneViewer.tooltipsManager=this.managers.tooltipsManager),this.sceneViewer.scene&&this.sceneViewer.camera&&(this.managers.dragDropManager=new In({scene:this.sceneViewer.scene,camera:this.sceneViewer.camera,transformManager:this.sceneViewer.transformManager,modelPreloader:this.utilities.modelPreloader,componentManager:this.sceneViewer.componentManager}),this.sceneViewer.dragDropManager=this.managers.dragDropManager),this.sceneViewer.scene&&this.sceneViewer.camera&&this.sceneViewer.renderer&&(this.utilities.sceneHelper=new Nn({scene:this.sceneViewer.scene,camera:this.sceneViewer.camera,renderer:this.sceneViewer.renderer,controls:this.sceneViewer.controls,transformManager:this.sceneViewer.transformManager,componentManager:this.sceneViewer.componentManager,pathfindingManager:this.sceneViewer.pathfindingManager,currentSceneData:this.sceneViewer.currentSceneData,logger:this.utilities.logger}),this.sceneViewer.sceneHelper=this.utilities.sceneHelper)}},{key:"updateSceneHelperData",value:function(t){this.utilities.sceneHelper&&"function"==typeof this.utilities.sceneHelper.updateSceneData&&this.utilities.sceneHelper.updateSceneData(t)}},{key:"setImportedSceneData",value:function(t){this.importedSceneData=y({},t),this.setDefaultImportedSceneMetadata(t),this.utilities.sceneHelper&&"function"==typeof this.utilities.sceneHelper.updateSceneData&&this.utilities.sceneHelper.updateSceneData(t)}},{key:"getImportedSceneData",value:function(){return this.importedSceneData}},{key:"getImportedConnections",value:function(){var t;return(null===(t=this.importedSceneData)||void 0===t?void 0:t.connections)||[]}},{key:"getImportedSceneObjects",value:function(){var t;return(null===(t=this.importedSceneData)||void 0===t||null===(t=t.scene)||void 0===t?void 0:t.object)||null}},{key:"clearImportedSceneData",value:function(){this.importedSceneData=null}},{key:"setMetadata",value:function(t,e){this.metadata[t]=e}},{key:"getMetadata",value:function(t){return this.metadata[t]}},{key:"getAllMetadata",value:function(){return y({},this.metadata)}},{key:"removeMetadata",value:function(t){delete this.metadata[t]}},{key:"clearAllMetadata",value:function(){this.metadata={}}},{key:"clearAllData",value:function(){this.metadata={},this.transformHistory.lastTransform=null}},{key:"recordTransform",value:function(t){var e,n;if(t&&t.object){t.previousValues;var i={type:t.type,object:t.object,values:t.values,previousValues:t.previousValues,timestamp:(new Date).toISOString(),objectId:(null===(e=t.object)||void 0===e?void 0:e.uuid)||(null===(n=t.object)||void 0===n?void 0:n.id)||"unknown"};this.transformHistory.lastTransform=i}}},{key:"getLastTransform",value:function(){return this.transformHistory.lastTransform}},{key:"getTransformHistory",value:function(){return y({},this.transformHistory)}},{key:"clearTransformHistory",value:function(){this.transformHistory.lastTransform=null}},{key:"hasMetadata",value:function(t){return t in this.metadata}},{key:"setDefaultSceneMetadata",value:function(){var t=this,e={sceneInfo:{name:"Untitled Central Plant Scene",description:"A central plant facility scene",version:"1.0.0",created:(new Date).toISOString(),lastModified:(new Date).toISOString(),author:"Engineering Team"},projectSettings:{units:"metric",scale:1,gridSize:1,snapToGrid:!0,showGrid:!0,showAxes:!0},viewportSettings:{defaultViewMode:"perspective",backgroundType:"skybox",showEnvironment:!0,autoRotate:!1,cameraPosition:{x:10,y:10,z:10},cameraTarget:{x:0,y:0,z:0}},componentSettings:{defaultComponentScale:1,showBoundingBoxes:!1,showConnectionPaths:!0,highlightOnHover:!0,selectionOutlineColor:"#00ff00"},spatialBoundaries:{min:{x:-60,y:-16,z:-60},max:{x:60,y:16,z:60},center:{x:0,y:4,z:0}},systemInfo:{centralPlantVersion:"2.0.0",buildDate:(new Date).toISOString(),platform:"undefined"!=typeof window?window.navigator.platform:"Unknown",userAgent:"undefined"!=typeof window?window.navigator.userAgent:"Unknown"}};Object.keys(e).forEach(function(n){t.hasMetadata(n)||t.setMetadata(n,e[n])})}},{key:"setDefaultImportedSceneMetadata",value:function(t){var e,n,i,r=(new Date).toISOString(),s=(null===(e=t.connections)||void 0===e?void 0:e.length)||0,o=(null===(n=t.scene)||void 0===n||null===(n=n.object)||void 0===n||null===(n=n.children)||void 0===n?void 0:n.length)||0,a={};null!==(i=t.scene)&&void 0!==i&&null!==(i=i.object)&&void 0!==i&&i.children&&t.scene.object.children.forEach(function(t){var e,n=(null===(e=t.userData)||void 0===e?void 0:e.componentType)||"unknown";a[n]=(a[n]||0)+1});var u={importInfo:{importTimestamp:r,originalFileName:null,fileSize:null,importMethod:"file-upload",importVersion:"1.0.0"},sceneAnalysis:{totalComponents:o,totalConnections:s,componentTypes:a,sceneComplexity:this.calculateSceneComplexity(s,o),hasValidStructure:this.validateImportedSceneStructure(t)},dataQuality:{hasConnections:s>0,hasComponents:o>0,hasValidScene:!!t.scene,missingData:this.identifyMissingData(t),warnings:this.generateImportWarnings(t)},processingStats:{processedAt:r,processingDuration:null,memoryUsage:this.estimateMemoryUsage(t),cacheStatus:"pending"}};if(this.setMetadata("lastImport",u),this.hasMetadata("sceneInfo")){var h=this.getMetadata("sceneInfo");this.setMetadata("sceneInfo",y(y({},h),{},{lastModified:r,importSource:"file-import",dataSourceType:"json"}))}}},{key:"calculateSceneComplexity",value:function(t,e){var n=t+e;return n<=10?"simple":n<=50?"moderate":n<=200?"complex":"very-complex"}},{key:"validateImportedSceneStructure",value:function(t){return!!(t&&t.scene&&t.scene.object&&Array.isArray(t.connections))}},{key:"identifyMissingData",value:function(t){var e,n=[];return t.connections&&0!==t.connections.length||n.push("No connection data found"),null!==(e=t.scene)&&void 0!==e&&null!==(e=e.object)&&void 0!==e&&e.children&&0!==t.scene.object.children.length||n.push("No component data found"),t.metadata||n.push("No metadata found"),t.version||n.push("No version information"),n}},{key:"generateImportWarnings",value:function(t){var e,n,i=[],r=(null===(e=t.scene)||void 0===e||null===(e=e.object)||void 0===e||null===(e=e.children)||void 0===e?void 0:e.length)||0;r>100&&i.push("Large scene detected (".concat(r," components) - may impact performance"));var s=(null===(n=t.connections)||void 0===n?void 0:n.length)||0;return r>0&&0===s&&i.push("Components found but no connections - scene may be incomplete"),t.version&&parseFloat(t.version)<1&&i.push("Scene data version is older than current - some features may not work correctly"),i}},{key:"estimateMemoryUsage",value:function(t){var e=JSON.stringify(t).length,n=(e/1024/1024).toFixed(2);return{jsonSizeBytes:e,estimatedMB:parseFloat(n),category:n<1?"small":n<10?"medium":"large"}}},{key:"updateMetadataCategory",value:function(t,e){if(this.hasMetadata(t)){var n=this.getMetadata(t);this.setMetadata(t,y(y({},n),e))}else this.setMetadata(t,e)}},{key:"undoTransform",value:function(){var t=this.getLastTransform();if(!t)return!1;try{var e,n=t.object,i=t.type,r=t.previousValues;if(!n||!r)return!1;if(this.debugTransformState(n,"Before Undo"),this.sceneViewer&&this.sceneViewer.scene){var s=!1;if(this.sceneViewer.scene.traverse(function(t){t===n&&(s=!0)}),!s)return!1}switch(i){case"translate":case"position":r.position?(void 0!==r.position.x&&(n.position.x=r.position.x),void 0!==r.position.y&&(n.position.y=r.position.y),void 0!==r.position.z&&(n.position.z=r.position.z)):(void 0!==r.x&&(n.position.x=r.x),void 0!==r.y&&(n.position.y=r.y),void 0!==r.z&&(n.position.z=r.z));break;case"rotate":case"rotation":r.rotation?(void 0!==r.rotation.x&&(n.rotation.x=r.rotation.x),void 0!==r.rotation.y&&(n.rotation.y=r.rotation.y),void 0!==r.rotation.z&&(n.rotation.z=r.rotation.z)):(void 0!==r.x&&(n.rotation.x=r.x),void 0!==r.y&&(n.rotation.y=r.y),void 0!==r.z&&(n.rotation.z=r.z));break;case"scale":r.scale?(void 0!==r.scale.x&&(n.scale.x=r.scale.x),void 0!==r.scale.y&&(n.scale.y=r.scale.y),void 0!==r.scale.z&&(n.scale.z=r.scale.z)):(void 0!==r.x&&(n.scale.x=r.x),void 0!==r.y&&(n.scale.y=r.y),void 0!==r.z&&(n.scale.z=r.z));break;default:return!1}n.updateMatrix(),n.updateMatrixWorld(!0);var o=null===(e=this.sceneViewer)||void 0===e?void 0:e.transformManager;if(o&&o.transformControls){var a=o.transformControls;a.object===n&&(a.detach(),o.ensureSceneAttachment&&o.ensureSceneAttachment(!0),a.attach(n),o.selectedObject=n,o.updateBoundingBox&&o.updateBoundingBox(),o.boundingBoxCache&&o.boundingBoxCache.has(n)&&o.boundingBoxCache.delete(n))}if(this.sceneViewer&&this.sceneViewer.sceneOperationsManager&&this.sceneViewer.currentSceneData)try{this.sceneViewer.onTransformEnd(n)}catch(t){}if("undefined"!=typeof window){var u=new CustomEvent("sceneUpdateComplete",{detail:{timestamp:Date.now(),action:"undo-transform",objectId:n.uuid||n.id||"unknown"}});window.dispatchEvent(u)}return this.clearTransformHistory(),this.ensureObjectSelectable(n),this.debugTransformState(n,"After Undo"),!0}catch(t){return!1}}},{key:"ensureObjectSelectable",value:function(t){if(!t||!this.sceneViewer)return!1;try{var e=this.sceneViewer.transformManager;return!!e&&(e.recoverTransformControls?e.recoverTransformControls(t):(t.updateMatrixWorld(!0),e.boundingBoxCache&&e.boundingBoxCache.has(t)&&e.boundingBoxCache.delete(t),e.ensureSceneAttachment&&e.ensureSceneAttachment(!0),e.selectedObject===t&&(e.deselectObject(),requestAnimationFrame(function(){e.selectObjectForTransformOnly(t)})),!0))}catch(t){return!1}}},{key:"debugTransformState",value:function(t){}},{key:"fixTransformControlsSelection",value:function(){if(!this.sceneViewer||!this.sceneViewer.transformManager)return!1;var t=this.sceneViewer.transformManager;if(t.recoverTransformControls&&t.recoverTransformControls())return!0;try{var e=t.currentMode,n=t.currentSpace;return t.transformControls&&(t.transformControls.detach(),t.scene.remove(t.transformControls),t.transformControls.dispose(),t.transformControls=null),t.createTransformControls(),t.setupEventListeners(),t.setMode(e),t.setSpace(n),!0}catch(t){return!1}}},{key:"isObjectInScene",value:function(t){if(!this.sceneViewer||!this.sceneViewer.scene)return!1;var e=!1;return this.sceneViewer.scene.traverse(function(n){n===t&&(e=!0)}),e}}])}(),Bn=c(function t(){a(this,t)});On=Bn,f(Bn,"PI",Math.PI),f(Bn,"TWO_PI",2*Math.PI),f(Bn,"HALF_PI",Math.PI/2),f(Bn,"DEG_TO_RAD",Math.PI/180),f(Bn,"RAD_TO_DEG",180/Math.PI),f(Bn,"EPSILON",1e-10),f(Bn,"angle",{toRadians:function(t){return t*On.DEG_TO_RAD},toDegrees:function(t){return t*On.RAD_TO_DEG},normalize:function(t){for(;t<0;)t+=On.TWO_PI;for(;t>=On.TWO_PI;)t-=On.TWO_PI;return t},normalizeSignedAngle:function(t){return(t=On.angle.normalize(t))>Math.PI?t-On.TWO_PI:t},distance:function(t,e){var n=On.angle.normalizeSignedAngle(e-t);return Math.abs(n)},lerp:function(t,e,n){var i=On.angle.normalizeSignedAngle(e-t);return On.angle.normalize(t+i*n)}}),f(Bn,"interpolation",{linear:function(t,e,n){return t+(e-t)*n},smoothstep:function(t,e,n){var i=n*n*(3-2*n);return On.interpolation.linear(t,e,i)},smootherstep:function(t,e,n){var i=n*n*n*(n*(6*n-15)+10);return On.interpolation.linear(t,e,i)},cosine:function(t,e,n){var i=n*Math.PI,r=.5*(1-Math.cos(i));return t*(1-r)+e*r},cubic:function(t,e,n,i,r){var s=r*r;return.5*(2*e+(-t+n)*r+(2*t-5*e+4*n-i)*s+(3*e-t-3*n+i)*(s*r))}}),f(Bn,"easing",{easeInQuad:function(t){return t*t},easeOutQuad:function(t){return t*(2-t)},easeInOutQuad:function(t){return t<.5?2*t*t:(4-2*t)*t-1},easeInCubic:function(t){return t*t*t},easeOutCubic:function(t){return--t*t*t+1},easeInOutCubic:function(t){return t<.5?4*t*t*t:(t-1)*(2*t-2)*(2*t-2)+1},easeInQuart:function(t){return t*t*t*t},easeOutQuart:function(t){return 1- --t*t*t*t},easeInOutQuart:function(t){return t<.5?8*t*t*t*t:1-8*--t*t*t*t},easeInQuint:function(t){return t*t*t*t*t},easeOutQuint:function(t){return 1+--t*t*t*t*t},easeInOutQuint:function(t){return t<.5?16*t*t*t*t*t:1+16*--t*t*t*t*t},easeInSine:function(t){return 1-Math.cos(t*On.HALF_PI)},easeOutSine:function(t){return Math.sin(t*On.HALF_PI)},easeInOutSine:function(t){return.5*(1-Math.cos(On.PI*t))},easeInExpo:function(t){return 0===t?0:Math.pow(2,10*(t-1))},easeOutExpo:function(t){return 1===t?1:1-Math.pow(2,-10*t)},easeInOutExpo:function(t){return 0===t?0:1===t?1:t<.5?.5*Math.pow(2,10*(2*t-1)):.5*(2-Math.pow(2,-10*(2*t-1)))},easeInCirc:function(t){return 1-Math.sqrt(1-t*t)},easeOutCirc:function(t){return Math.sqrt(1- --t*t)},easeInOutCirc:function(t){return(t*=2)<1?.5*(1-Math.sqrt(1-t*t)):(t-=2,.5*(Math.sqrt(1-t*t)+1))},easeInElastic:function(t){if(0===t)return 0;if(1===t)return 1;return-Math.pow(2,10*(t-=1))*Math.sin((t-.075)*On.TWO_PI/.3)},easeOutElastic:function(t){if(0===t)return 0;if(1===t)return 1;return Math.pow(2,-10*t)*Math.sin((t-.075)*On.TWO_PI/.3)+1}}),f(Bn,"geometry",{triangleArea:function(t,e,n){return.5*Math.abs((e[0]-t[0])*(n[1]-t[1])-(n[0]-t[0])*(e[1]-t[1]))},polygonArea:function(t){for(var e=0,n=t.length,i=0;i<n;i++){var r=(i+1)%n;e+=t[i][0]*t[r][1],e-=t[r][0]*t[i][1]}return Math.abs(e)/2},pointInTriangle:function(t,e,n,i){var r=On.geometry.triangleArea(e,n,i),s=On.geometry.triangleArea(t,n,i),o=On.geometry.triangleArea(e,t,i),a=On.geometry.triangleArea(e,n,t);return Math.abs(r-(s+o+a))<On.EPSILON},polygonCentroid:function(t){for(var e=0,n=0,i=0,r=t.length,s=0;s<r;s++){var o=(s+1)%r,a=t[s][0]*t[o][1]-t[o][0]*t[s][1];i+=a,e+=(t[s][0]+t[o][0])*a,n+=(t[s][1]+t[o][1])*a}return[e/=6*(i/=2),n/=6*i]}}),f(Bn,"random",{float:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return t+Math.random()*(e-t)},int:function(t,e){return Math.floor(On.random.float(t,e+1))},boolean:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:.5;return Math.random()<t},choice:function(t){return t[On.random.int(0,t.length-1)]},shuffle:function(t){for(var e=S(t),n=e.length-1;n>0;n--){var i=Math.floor(Math.random()*(n+1)),r=[e[i],e[n]];e[n]=r[0],e[i]=r[1]}return e},unitCircle:function(){var t=On.random.float(0,On.TWO_PI);return[Math.cos(t),Math.sin(t)]},insideUnitCircle:function(){var t=x(On.random.unitCircle(),2),e=t[0],n=t[1],i=Math.sqrt(Math.random());return[e*i,n*i]},unitSphere:function(){var t=Math.random(),e=Math.random(),n=On.TWO_PI*t,i=Math.acos(2*e-1);return[Math.sin(i)*Math.cos(n),Math.sin(i)*Math.sin(n),Math.cos(i)]}}),f(Bn,"color",{hslToRgb:function(t,e,n){t/=360;var i,r,s,o=(1-Math.abs(2*n-1))*e,a=o*(1-Math.abs(6*t%2-1)),u=n-o/2;return t<1/6?(i=o,r=a,s=0):t<2/6?(i=a,r=o,s=0):t<.5?(i=0,r=o,s=a):t<4/6?(i=0,r=a,s=o):t<5/6?(i=a,r=0,s=o):(i=o,r=0,s=a),[Math.round(255*(i+u)),Math.round(255*(r+u)),Math.round(255*(s+u))]},rgbToHsl:function(t,e,n){t/=255,e/=255,n/=255;var i=Math.max(t,e,n),r=Math.min(t,e,n),s=(i+r)/2;if(i===r)return[0,0,s];var o,a=i-r,u=s>.5?a/(2-i-r):a/(i+r);switch(i){case t:o=(e-n)/a+(e<n?6:0);break;case e:o=(n-t)/a+2;break;case n:o=(t-e)/a+4}return[360*(o/=6),u,s]},lerp:function(t,e,n){return[Math.round(On.interpolation.linear(t[0],e[0],n)),Math.round(On.interpolation.linear(t[1],e[1],n)),Math.round(On.interpolation.linear(t[2],e[2],n))]}}),f(Bn,"utils",{clamp:function(t,e,n){return Math.max(e,Math.min(n,t))},map:function(t,e,n,i,r){return i+(t-e)*(r-i)/(n-e)},isPowerOfTwo:function(t){return!(t&t-1)},nextPowerOfTwo:function(t){return Math.pow(2,Math.ceil(Math.log2(t)))},gcd:function(t,e){return 0===e?t:On.utils.gcd(e,t%e)},lcm:function(t,e){return Math.abs(t*e)/On.utils.gcd(t,e)},approxEqual:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:On.EPSILON;return Math.abs(t-e)<n},round:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=Math.pow(10,e);return Math.round(t*n)/n}});var Fn=function(){return c(function t(e){var n=this;a(this,t),f(this,"draw",{line:function(t,e,i,r){var s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};n.ctx&&(n.save(),n.setStyles(s),n.ctx.beginPath(),n.ctx.moveTo(t,e),n.ctx.lineTo(i,r),n.ctx.stroke(),n.restore())},rect:function(t,e,i,r){var s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};n.ctx&&(n.save(),n.setStyles(s),s.fillStyle&&n.ctx.fillRect(t,e,i,r),s.strokeStyle&&n.ctx.strokeRect(t,e,i,r),n.restore())},circle:function(t,e,i){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};n.ctx&&(n.save(),n.setStyles(r),n.ctx.beginPath(),n.ctx.arc(t,e,i,0,2*Math.PI),r.fillStyle&&n.ctx.fill(),r.strokeStyle&&n.ctx.stroke(),n.restore())},ellipse:function(t,e,i,r){var s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{};n.ctx&&(n.save(),n.setStyles(o),n.ctx.beginPath(),n.ctx.ellipse(t,e,i,r,s,0,2*Math.PI),o.fillStyle&&n.ctx.fill(),o.strokeStyle&&n.ctx.stroke(),n.restore())},polygon:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(n.ctx&&!(t.length<3)){n.save(),n.setStyles(e),n.ctx.beginPath(),n.ctx.moveTo(t[0][0],t[0][1]);for(var i=1;i<t.length;i++)n.ctx.lineTo(t[i][0],t[i][1]);n.ctx.closePath(),e.fillStyle&&n.ctx.fill(),e.strokeStyle&&n.ctx.stroke(),n.restore()}},bezierCurve:function(t,e,i,r,s,o,a,u){var h=arguments.length>8&&void 0!==arguments[8]?arguments[8]:{};n.ctx&&(n.save(),n.setStyles(h),n.ctx.beginPath(),n.ctx.moveTo(t,e),n.ctx.bezierCurveTo(i,r,s,o,a,u),n.ctx.stroke(),n.restore())},text:function(t,e,i){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};n.ctx&&(n.save(),n.setStyles(r),r.fillStyle&&n.ctx.fillText(t,e,i),r.strokeStyle&&n.ctx.strokeText(t,e,i),n.restore())},image:function(t,e,i){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null;n.ctx&&t&&(r&&s?n.ctx.drawImage(t,e,i,r,s):n.ctx.drawImage(t,e,i))}}),f(this,"transform",{translate:function(t,e){n.ctx&&n.ctx.translate(t,e)},rotate:function(t){n.ctx&&n.ctx.rotate(t)},scale:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t;n.ctx&&n.ctx.scale(t,e)},transform:function(t,e,i,r,s,o){n.ctx&&n.ctx.transform(t,e,i,r,s,o)},setTransform:function(t,e,i,r,s,o){n.ctx&&n.ctx.setTransform(t,e,i,r,s,o)},resetTransform:function(){n.ctx&&n.ctx.resetTransform()}}),f(this,"gradient",{linear:function(t,e,i,r,s){if(!n.ctx)return null;var o=n.ctx.createLinearGradient(t,e,i,r);return s.forEach(function(t){o.addColorStop(t.offset,t.color)}),o},radial:function(t,e,i,r,s,o,a){if(!n.ctx)return null;var u=n.ctx.createRadialGradient(t,e,i,r,s,o);return a.forEach(function(t){u.addColorStop(t.offset,t.color)}),u}}),f(this,"pattern",{fromImage:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"repeat";return n.ctx&&t?n.ctx.createPattern(t,e):null},fromCanvas:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"repeat";return n.ctx&&t?n.ctx.createPattern(t,e):null}}),f(this,"path",{begin:function(){n.ctx&&n.ctx.beginPath()},close:function(){n.ctx&&n.ctx.closePath()},moveTo:function(t,e){n.ctx&&n.ctx.moveTo(t,e)},lineTo:function(t,e){n.ctx&&n.ctx.lineTo(t,e)},arc:function(t,e,i,r,s){var o=arguments.length>5&&void 0!==arguments[5]&&arguments[5];n.ctx&&n.ctx.arc(t,e,i,r,s,o)},quadraticCurveTo:function(t,e,i,r){n.ctx&&n.ctx.quadraticCurveTo(t,e,i,r)},bezierCurveTo:function(t,e,i,r,s,o){n.ctx&&n.ctx.bezierCurveTo(t,e,i,r,s,o)},fill:function(){n.ctx&&n.ctx.fill()},stroke:function(){n.ctx&&n.ctx.stroke()},clip:function(){n.ctx&&n.ctx.clip()}}),f(this,"measure",{textWidth:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(!n.ctx)return 0;if(e){var i=n.ctx.font;n.ctx.font=e;var r=n.ctx.measureText(t).width;return n.ctx.font=i,r}return n.ctx.measureText(t).width},textMetrics:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(!n.ctx)return null;if(e){var i=n.ctx.font;n.ctx.font=e;var r=n.ctx.measureText(t);return n.ctx.font=i,r}return n.ctx.measureText(t)}}),f(this,"export",{toDataURL:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"image/png",e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.92;return n.canvas?n.canvas.toDataURL(t,e):""},toBlob:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"image/png",e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.92;return n.canvas?new Promise(function(i){n.canvas.toBlob(i,t,e)}):Promise.resolve(null)}}),this.canvas=e,this.ctx=null==e?void 0:e.getContext("2d"),this.width=(null==e?void 0:e.width)||800,this.height=(null==e?void 0:e.height)||600,this.pixelRatio=window.devicePixelRatio||1,this.state={transforms:[],styles:[]},this.setupCanvas()},[{key:"setupCanvas",value:function(){this.canvas&&this.ctx&&(this.canvas.width=this.width*this.pixelRatio,this.canvas.height=this.height*this.pixelRatio,this.ctx.scale(this.pixelRatio,this.pixelRatio),this.canvas.style.width=this.width+"px",this.canvas.style.height=this.height+"px")}},{key:"clear",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;this.ctx&&(t?(this.ctx.fillStyle=t,this.ctx.fillRect(0,0,this.width,this.height)):this.ctx.clearRect(0,0,this.width,this.height))}},{key:"save",value:function(){this.ctx&&(this.ctx.save(),this.state.transforms.push(this.ctx.getTransform()),this.state.styles.push({fillStyle:this.ctx.fillStyle,strokeStyle:this.ctx.strokeStyle,lineWidth:this.ctx.lineWidth,font:this.ctx.font,textAlign:this.ctx.textAlign,textBaseline:this.ctx.textBaseline}))}},{key:"restore",value:function(){this.ctx&&(this.ctx.restore(),this.state.transforms.pop(),this.state.styles.pop())}},{key:"setStyles",value:function(t){var e=this;this.ctx&&Object.keys(t).forEach(function(n){void 0!==e.ctx[n]&&(e.ctx[n]=t[n])})}},{key:"resize",value:function(t,e){this.width=t,this.height=e,this.setupCanvas()}},{key:"getDimensions",value:function(){return{width:this.width,height:this.height,pixelRatio:this.pixelRatio}}},{key:"dispose",value:function(){this.state.transforms=[],this.state.styles=[],this.canvas=null,this.ctx=null}}])}(),Un=Object.freeze({__proto__:null,Rendering2D:Fn}),zn=function(){return c(function t(){var e=this,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,t),f(this,"lighting",{addAmbient:function(){var t,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:4210752,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.4,s=new n.AmbientLight(i,r);return null===(t=e.scene)||void 0===t||t.add(s),s},addDirectional:function(){var t,i,r,s,o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},a=o.color,u=void 0===a?16777215:a,h=o.intensity,c=void 0===h?1:h,l=o.position,f=void 0===l?[10,10,5]:l,d=o.target,v=void 0===d?[0,0,0]:d,p=o.castShadow,w=void 0===p||p,m=o.shadowMapSize,y=void 0===m?2048:m,g=o.shadowCameraNear,b=void 0===g?.5:g,k=o.shadowCameraFar,M=void 0===k?50:k,x=o.shadowCameraLeft,T=void 0===x?-10:x,E=o.shadowCameraRight,A=void 0===E?10:E,_=o.shadowCameraTop,O=void 0===_?10:_,C=o.shadowCameraBottom,R=void 0===C?-10:C,P=new n.DirectionalLight(u,c);return(t=P.position).set.apply(t,S(f)),(i=P.target.position).set.apply(i,S(v)),w&&(P.castShadow=!0,P.shadow.mapSize.width=y,P.shadow.mapSize.height=y,P.shadow.camera.near=b,P.shadow.camera.far=M,P.shadow.camera.left=T,P.shadow.camera.right=A,P.shadow.camera.top=O,P.shadow.camera.bottom=R),null===(r=e.scene)||void 0===r||r.add(P),null===(s=e.scene)||void 0===s||s.add(P.target),P},addPoint:function(){var t,i,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},s=r.color,o=void 0===s?16777215:s,a=r.intensity,u=void 0===a?1:a,h=r.distance,c=void 0===h?0:h,l=r.decay,f=void 0===l?2:l,d=r.position,v=void 0===d?[0,10,0]:d,p=r.castShadow,w=void 0!==p&&p,m=r.shadowMapSize,y=void 0===m?1024:m,g=new n.PointLight(o,u,c,f);return(t=g.position).set.apply(t,S(v)),w&&(g.castShadow=!0,g.shadow.mapSize.width=y,g.shadow.mapSize.height=y,g.shadow.camera.near=.1,g.shadow.camera.far=25),null===(i=e.scene)||void 0===i||i.add(g),g},addSpot:function(){var t,i,r,s,o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},a=o.color,u=void 0===a?16777215:a,h=o.intensity,c=void 0===h?1:h,l=o.distance,f=void 0===l?0:l,d=o.angle,v=void 0===d?Math.PI/3:d,p=o.penumbra,w=void 0===p?0:p,m=o.decay,y=void 0===m?2:m,g=o.position,b=void 0===g?[0,10,0]:g,k=o.target,M=void 0===k?[0,0,0]:k,x=o.castShadow,T=void 0===x||x,E=o.shadowMapSize,A=void 0===E?1024:E,_=new n.SpotLight(u,c,f,v,w,y);return(t=_.position).set.apply(t,S(b)),(i=_.target.position).set.apply(i,S(M)),T&&(_.castShadow=!0,_.shadow.mapSize.width=A,_.shadow.mapSize.height=A,_.shadow.camera.near=.5,_.shadow.camera.far=50),null===(r=e.scene)||void 0===r||r.add(_),null===(s=e.scene)||void 0===s||s.add(_.target),_}}),f(this,"materials",{createStandard:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new n.MeshStandardMaterial(y({color:16777215,metalness:0,roughness:.5},t))},createPhysical:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new n.MeshPhysicalMaterial(y({color:16777215,metalness:0,roughness:.5,clearcoat:0,clearcoatRoughness:0},t))},createBasic:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new n.MeshBasicMaterial(y({color:16777215},t))},createShader:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new n.ShaderMaterial({vertexShader:t.vertexShader||"\n void main() {\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }\n ",fragmentShader:t.fragmentShader||"\n void main() {\n gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);\n }\n ",uniforms:t.uniforms||{}})}}),f(this,"geometry",{createBox:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;return new n.BoxGeometry(t,e,i)},createSphere:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:32,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:16;return new n.SphereGeometry(t,e,i)},createCylinder:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:32;return new n.CylinderGeometry(t,e,i,r)},createPlane:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return new n.PlaneGeometry(t,e)}}),f(this,"renderTargets",{create:function(t,i){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},s=new n.WebGLRenderTarget(t,i,y({minFilter:n.LinearFilter,magFilter:n.LinearFilter,format:n.RGBAFormat,type:n.UnsignedByteType},r)),o="rt_".concat(Date.now(),"_").concat(Math.random().toString(36).substr(2,9));return e.renderTargets.set(o,s),{id:o,renderTarget:s}},get:function(t){return e.renderTargets.get(t)},remove:function(t){var n=e.renderTargets.get(t);n&&(n.dispose(),e.renderTargets.delete(t))}}),f(this,"animation",{createMixer:function(t){return e.animationMixer=new n.AnimationMixer(t),e.animationMixer},addClip:function(t){if(!e.animationMixer)throw new Error("Animation mixer not created");return e.animationMixer.clipAction(t)},update:function(t){e.animationMixer&&e.animationMixer.update(t)}}),f(this,"screenshot",{toDataURL:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"image/png",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return e.renderer?e.renderer.domElement.toDataURL(t,n):""},toBlob:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"image/png",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return e.renderer?new Promise(function(i){e.renderer.domElement.toBlob(i,t,n)}):Promise.resolve(null)}}),this.options=y({antialias:!0,alpha:!0,shadowMapEnabled:!0,shadowMapType:n.PCFSoftShadowMap,toneMapping:n.ACESFilmicToneMapping,toneMappingExposure:1,outputColorSpace:n.SRGBColorSpace},i),this.renderer=null,this.scene=null,this.camera=null,this.controls=null,this.renderTargets=new Map,this.postProcessing={composer:null,passes:[]},this.stats={triangles:0,geometries:0,textures:0,calls:0,frameTime:0},this.animationMixer=null,this.clock=new n.Clock},[{key:"initializeRenderer",value:function(t){this.renderer&&this.dispose();try{return this.renderer=new n.WebGLRenderer({antialias:this.options.antialias,alpha:this.options.alpha,preserveDrawingBuffer:!1,powerPreference:"high-performance"}),this.renderer.setPixelRatio(Math.min(window.devicePixelRatio,2)),this.renderer.setSize(t.clientWidth,t.clientHeight),this.renderer.setClearColor(0,0),this.options.shadowMapEnabled&&(this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=this.options.shadowMapType),this.renderer.toneMapping=this.options.toneMapping,this.renderer.toneMappingExposure=this.options.toneMappingExposure,this.renderer.outputColorSpace=this.options.outputColorSpace,this.renderer.useLegacyLights=!1,t.appendChild(this.renderer.domElement),$e.info("โœ… 3D Renderer initialized"),this.renderer}catch(t){throw $e.error("โŒ Failed to initialize 3D renderer:",t),t}}},{key:"createScene",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=t.background,i=void 0===e?null:e,r=t.environment,s=void 0===r?null:r,o=t.fog,a=void 0===o?null:o;return this.scene=new n.Scene,i&&("string"==typeof i?this.scene.background=new n.Color(i):i.isTexture&&(this.scene.background=i)),s&&s.isTexture&&(this.scene.environment=s),a&&("linear"===a.type?this.scene.fog=new n.Fog(a.color,a.near,a.far):"exponential"===a.type&&(this.scene.fog=new n.FogExp2(a.color,a.density))),$e.info("โœ… 3D Scene created"),this.scene}},{key:"createCamera",value:function(){var t,e,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"perspective",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},s=null===(t=this.renderer)||void 0===t||null===(t=t.domElement)||void 0===t?void 0:t.parentElement,o=s?s.clientWidth/s.clientHeight:1;if("perspective"===i){var a=r.fov,u=void 0===a?75:a,h=r.near,c=void 0===h?.1:h,l=r.far,f=void 0===l?1e3:l;r.position,this.camera=new n.PerspectiveCamera(u,o,c,f)}else if("orthographic"===i){var d=r.left,v=void 0===d?-10:d,p=r.right,w=void 0===p?10:p,m=r.top,y=void 0===m?10:m,g=r.bottom,b=void 0===g?-10:g,k=r.near,M=void 0===k?.1:k,x=r.far,T=void 0===x?1e3:x;r.position,this.camera=new n.OrthographicCamera(v,w,y,b,M,T)}this.camera&&((e=this.camera.position).set.apply(e,S(position)),$e.info("โœ… ".concat(i," camera created")));return this.camera}},{key:"render",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;if(this.renderer){var i=t||this.scene,r=e||this.camera;if(i&&r){var s=performance.now(),o=this.clock.getDelta();this.animation.update(o),this.renderer.render(i,r,n),this.stats.frameTime=performance.now()-s,this.updateRenderStats()}}}},{key:"updateRenderStats",value:function(){if(this.renderer){var t=this.renderer.info;this.stats.triangles=t.render.triangles,this.stats.geometries=t.memory.geometries,this.stats.textures=t.memory.textures,this.stats.calls=t.render.calls}}},{key:"getRenderStats",value:function(){return y({},this.stats)}},{key:"resize",value:function(t,e){if(this.renderer){if(this.renderer.setSize(t,e),this.camera){if(this.camera.isPerspectiveCamera)this.camera.aspect=t/e;else if(this.camera.isOrthographicCamera){var n=t/e;this.camera.left=-10*n,this.camera.right=10*n,this.camera.top=10,this.camera.bottom=-10}this.camera.updateProjectionMatrix()}this.renderTargets.forEach(function(n){n.setSize(t,e)})}}},{key:"dispose",value:function(){this.renderTargets.forEach(function(t){t.dispose()}),this.renderTargets.clear(),this.animationMixer&&(this.animationMixer.stopAllAction(),this.animationMixer=null),this.renderer&&(this.renderer.dispose(),this.renderer.forceContextLoss(),this.renderer.domElement.parentElement&&this.renderer.domElement.parentElement.removeChild(this.renderer.domElement),this.renderer=null),this.scene=null,this.camera=null,this.controls=null,$e.info("โœ… 3D Rendering disposed")}}])}(),Hn=Object.freeze({__proto__:null,Rendering3D:zn});const Gn=new WeakMap;class Xn extends t.Loader{constructor(t){super(t),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(t){return this.decoderPath=t,this}setDecoderConfig(t){return this.decoderConfig=t,this}setWorkerLimit(t){return this.workerLimit=t,this}load(e,n,i,r){const s=new t.FileLoader(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,t=>{this.parse(t,n,r)},i,r)}parse(e,n,i=()=>{}){this.decodeDracoFile(e,n,null,null,t.SRGBColorSpace,i).catch(i)}decodeDracoFile(e,n,i,r,s=t.LinearSRGBColorSpace,o=()=>{}){const a={attributeIDs:i||this.defaultAttributeIDs,attributeTypes:r||this.defaultAttributeTypes,useUniqueIDs:!!i,vertexColorSpace:s};return this.decodeGeometry(e,a).then(n).catch(o)}decodeGeometry(t,e){const n=JSON.stringify(e);if(Gn.has(t)){const e=Gn.get(t);if(e.key===n)return e.promise;if(0===t.byteLength)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let i;const r=this.workerNextTaskID++,s=t.byteLength,o=this.Fe(r,s).then(n=>(i=n,new Promise((n,s)=>{i.Ue[r]={resolve:n,reject:s},i.postMessage({type:"decode",id:r,taskConfig:e,buffer:t},[t])}))).then(t=>this.ze(t.geometry));return o.catch(()=>!0).then(()=>{i&&r&&this.He(i,r)}),Gn.set(t,{key:n,promise:o}),o}ze(e){const n=new t.BufferGeometry;e.index&&n.setIndex(new t.BufferAttribute(e.index.array,1));for(let i=0;i<e.attributes.length;i++){const r=e.attributes[i],s=r.name,o=r.array,a=r.itemSize,u=new t.BufferAttribute(o,a);"color"===s&&(this.Ge(u,r.vertexColorSpace),u.normalized=o instanceof Float32Array==!1),n.setAttribute(s,u)}return n}Ge(e,n){if(n!==t.SRGBColorSpace)return;const i=new t.Color;for(let n=0,r=e.count;n<r;n++)i.fromBufferAttribute(e,n),t.ColorManagement.colorSpaceToWorking(i,t.SRGBColorSpace),e.setXYZ(n,i.r,i.g,i.b)}Xe(e,n){const i=new t.FileLoader(this.manager);return i.setPath(this.decoderPath),i.setResponseType(n),i.setWithCredentials(this.withCredentials),new Promise((t,n)=>{i.load(e,t,void 0,n)})}preload(){return this.Ve(),this}Ve(){if(this.decoderPending)return this.decoderPending;const t="object"!=typeof WebAssembly||"js"===this.decoderConfig.type,e=[];return t?e.push(this.Xe("draco_decoder.js","text")):(e.push(this.Xe("draco_wasm_wrapper.js","text")),e.push(this.Xe("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(e).then(e=>{const n=e[0];t||(this.decoderConfig.wasmBinary=e[1]);const i=Vn.toString(),r=["/* draco decoder */",n,"","/* worker */",i.substring(i.indexOf("{")+1,i.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([r]))}),this.decoderPending}Fe(t,e){return this.Ve().then(()=>{if(this.workerPool.length<this.workerLimit){const t=new Worker(this.workerSourceURL);t.Ue={},t.Ye={},t.Ke=0,t.postMessage({type:"init",decoderConfig:this.decoderConfig}),t.onmessage=function(e){const n=e.data;switch(n.type){case"decode":t.Ue[n.id].resolve(n);break;case"error":t.Ue[n.id].reject(n)}},this.workerPool.push(t)}else this.workerPool.sort(function(t,e){return t.Ke>e.Ke?-1:1});const n=this.workerPool[this.workerPool.length-1];return n.Ye[t]=e,n.Ke+=e,n})}He(t,e){t.Ke-=t.Ye[e],delete t.Ue[e],delete t.Ye[e]}debug(){}dispose(){for(let t=0;t<this.workerPool.length;++t)this.workerPool[t].terminate();return this.workerPool.length=0,""!==this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),this}}function Vn(){let t,e;function n(t,e,n,i,r,s){const o=s.num_components(),a=n.num_points()*o,u=a*r.BYTES_PER_ELEMENT,h=function(t,e){switch(e){case Float32Array:return t.DT_FLOAT32;case Int8Array:return t.DT_INT8;case Int16Array:return t.DT_INT16;case Int32Array:return t.DT_INT32;case Uint8Array:return t.DT_UINT8;case Uint16Array:return t.DT_UINT16;case Uint32Array:return t.DT_UINT32}}(t,r),c=t.Ze(u);e.GetAttributeDataArrayForAllPoints(n,s,h,u,c);const l=new r(t.HEAPF32.buffer,c,a).slice();return t.We(c),{name:i,array:l,itemSize:o}}onmessage=function(i){const r=i.data;switch(r.type){case"init":t=r.decoderConfig,e=new Promise(function(e){t.onModuleLoaded=function(t){e({draco:t})},DracoDecoderModule(t)});break;case"decode":const i=r.buffer,s=r.taskConfig;e.then(t=>{const e=t.draco,o=new e.Decoder;try{const t=function(t,e,i,r){const s=r.attributeIDs,o=r.attributeTypes;let a,u;const h=e.GetEncodedGeometryType(i);if(h===t.TRIANGULAR_MESH)a=new t.Mesh,u=e.DecodeArrayToMesh(i,i.byteLength,a);else{if(h!==t.POINT_CLOUD)throw new Error("THREE.DRACOLoader: Unexpected geometry type.");a=new t.PointCloud,u=e.DecodeArrayToPointCloud(i,i.byteLength,a)}if(!u.ok()||0===a.ptr)throw new Error("THREE.DRACOLoader: Decoding failed: "+u.error_msg());const c={index:null,attributes:[]};for(const i in s){const u=self[o[i]];let h,l;if(r.useUniqueIDs)l=s[i],h=e.GetAttributeByUniqueId(a,l);else{if(l=e.GetAttributeId(a,t[s[i]]),-1===l)continue;h=e.GetAttribute(a,l)}const f=n(t,e,a,i,u,h);"color"===i&&(f.vertexColorSpace=r.vertexColorSpace),c.attributes.push(f)}h===t.TRIANGULAR_MESH&&(c.index=function(t,e,n){const i=n.num_faces(),r=3*i,s=4*r,o=t.Ze(s);e.GetTrianglesUInt32Array(n,s,o);const a=new Uint32Array(t.HEAPF32.buffer,o,r).slice();return t.We(o),{array:a,itemSize:1}}(t,e,a));return t.destroy(a),c}(e,o,new Int8Array(i),s),a=t.attributes.map(t=>t.array.buffer);t.index&&a.push(t.index.array.buffer),self.postMessage({type:"decode",id:r.id,geometry:t},a)}catch(t){self.postMessage({type:"error",id:r.id,error:t.message})}finally{e.destroy(o)}})}}}var Yn=function(){return c(function t(){a(this,t),this.gltfLoader=new wt,this.dracoLoader=new Xn,this.textureLoader=new n.TextureLoader,this.dracoLoader.setDecoderPath("/draco/"),this.gltfLoader.setDRACOLoader(this.dracoLoader),this.supportedFormats={models:[".glb",".gltf"],textures:[".jpg",".jpeg",".png",".hdr",".exr"],scenes:[".json"],configs:[".json",".yaml",".yml"]}},[{key:"importModel",value:(r=s(g().m(function t(e){var n,i,r,s,o,a,u,h,c,l,f,d,v,p,w,m=this,y=arguments;return g().w(function(t){for(;;)switch(t.n){case 0:return i=(n=y.length>1&&void 0!==y[1]?y[1]:{}).scale,r=void 0===i?1:i,s=n.position,o=void 0===s?[0,0,0]:s,a=n.rotation,u=void 0===a?[0,0,0]:a,h=n.castShadow,c=void 0===h||h,l=n.receiveShadow,f=void 0===l||l,t.p=1,$e.info("๐Ÿ”„ Importing model: ".concat(e)),t.n=2,new Promise(function(t,n){m.gltfLoader.load(e,t,function(t){var e=(t.loaded/t.total*100).toFixed(1);$e.debug("Loading progress: ".concat(e,"%"))},n)});case 2:return p=t.v,1!==r&&p.scene.scale.setScalar(r),(d=p.scene.position).set.apply(d,S(o)),(v=p.scene.rotation).set.apply(v,S(u)),p.scene.traverse(function(t){t.isMesh&&(t.castShadow=c,t.receiveShadow=f)}),$e.info("โœ… Model imported successfully: ".concat(e)),t.a(2,{scene:p.scene,animations:p.animations,cameras:p.cameras,asset:p.asset});case 3:throw t.p=3,w=t.v,$e.error("โŒ Failed to import model ".concat(e,":"),w),w;case 4:return t.a(2)}},t,null,[[1,3]])})),function(t){return r.apply(this,arguments)})},{key:"importTextures",value:(i=s(g().m(function t(e){var n,i,r,s,o=this;return g().w(function(t){for(;;)switch(t.n){case 0:return n=Array.isArray(e)?e:[e],t.p=1,i=n.map(function(t){return new Promise(function(e,n){o.textureLoader.load(t,e,void 0,n)})}),t.n=2,Promise.all(i);case 2:return r=t.v,$e.info("โœ… Imported ".concat(r.length," texture(s)")),t.a(2,Array.isArray(e)?r:r[0]);case 3:throw t.p=3,s=t.v,$e.error("โŒ Failed to import textures:",s),s;case 4:return t.a(2)}},t,null,[[1,3]])})),function(t){return i.apply(this,arguments)})},{key:"importSceneConfig",value:(e=s(g().m(function t(e){var n,i,r,s,o,a;return g().w(function(t){for(;;)switch(t.n){case 0:return t.p=0,$e.info("๐Ÿ”„ Importing scene config: ".concat(e)),t.n=1,fetch(e);case 1:if((n=t.v).ok){t.n=2;break}throw new Error("HTTP ".concat(n.status,": ").concat(n.statusText));case 2:return t.n=3,n.json();case 3:for(i=t.v,r=0,s=["scene","connections"];r<s.length;r++)i[o=s[r]]||$e.warn("โš ๏ธ Missing required property: ".concat(o));return $e.info("โœ… Scene config imported: ".concat(e)),t.a(2,i);case 4:throw t.p=4,a=t.v,$e.error("โŒ Failed to import scene config ".concat(e,":"),a),a;case 5:return t.a(2)}},t,null,[[0,4]])})),function(t){return e.apply(this,arguments)})},{key:"importBatch",value:(t=s(g().m(function t(e){var n,i,r,s,o,a,u,h,c;return g().w(function(t){for(;;)switch(t.n){case 0:$e.info("๐Ÿ”„ Starting batch import of ".concat(e.length," files")),n=[],i=[],r=l(e),t.p=1,r.s();case 2:if((s=r.n()).done){t.n=14;break}o=s.value,t.p=3,a=void 0,u=o.type,t.n="model"===u?4:"texture"===u?6:"scene"===u?8:10;break;case 4:return t.n=5,this.importModel(o.url,o.options);case 5:return a=t.v,t.a(3,11);case 6:return t.n=7,this.importTextures(o.url);case 7:return a=t.v,t.a(3,11);case 8:return t.n=9,this.importSceneConfig(o.url);case 9:return a=t.v,t.a(3,11);case 10:throw new Error("Unknown import type: ".concat(o.type));case 11:n.push({url:o.url,type:o.type,data:a}),t.n=13;break;case 12:t.p=12,h=t.v,i.push({url:o.url,type:o.type,error:h}),$e.error("โŒ Failed to import ".concat(o.url,":"),h);case 13:t.n=2;break;case 14:t.n=16;break;case 15:t.p=15,c=t.v,r.e(c);case 16:return t.p=16,r.f(),t.f(16);case 17:return $e.info("โœ… Batch import complete: ".concat(n.length," successful, ").concat(i.length," failed")),t.a(2,{results:n,errors:i})}},t,this,[[3,12],[1,15,16,17]])})),function(e){return t.apply(this,arguments)})},{key:"isFormatSupported",value:function(t,e){var n,i="."+t.split(".").pop().toLowerCase();return(null===(n=this.supportedFormats[e])||void 0===n?void 0:n.includes(i))||!1}},{key:"getFormatInfo",value:function(t){for(var e="."+t.split(".").pop().toLowerCase(),n=0,i=Object.entries(this.supportedFormats);n<i.length;n++){var r=x(i[n],2),s=r[0];if(r[1].includes(e))return{category:s,extension:e,supported:!0}}return{category:"unknown",extension:e,supported:!1}}},{key:"dispose",value:function(){this.dracoLoader.dispose&&this.dracoLoader.dispose(),$e.info("Import disposed")}}]);var t,e,i,r}(),Kn=Object.freeze({__proto__:null,Import:Yn});const Zn={POSITION:["byte","byte normalized","unsigned byte","unsigned byte normalized","short","short normalized","unsigned short","unsigned short normalized"],NORMAL:["byte normalized","short normalized"],TANGENT:["byte normalized","short normalized"],TEXCOORD:["byte","byte normalized","unsigned byte","short","short normalized","unsigned short"]};class Wn{constructor(){this.textureUtils=null,this.pluginCallbacks=[],this.register(function(t){return new _i(t)}),this.register(function(t){return new Oi(t)}),this.register(function(t){return new ji(t)}),this.register(function(t){return new Di(t)}),this.register(function(t){return new Ii(t)}),this.register(function(t){return new Ni(t)}),this.register(function(t){return new Ci(t)}),this.register(function(t){return new Ri(t)}),this.register(function(t){return new Pi(t)}),this.register(function(t){return new Li(t)}),this.register(function(t){return new Bi(t)}),this.register(function(t){return new Fi(t)}),this.register(function(t){return new Ui(t)}),this.register(function(t){return new zi(t)})}register(t){return-1===this.pluginCallbacks.indexOf(t)&&this.pluginCallbacks.push(t),this}unregister(t){return-1!==this.pluginCallbacks.indexOf(t)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(t),1),this}setTextureUtils(t){return this.textureUtils=t,this}parse(t,e,n,i){const r=new Ai,s=[];for(let t=0,e=this.pluginCallbacks.length;t<e;t++)s.push(this.pluginCallbacks[t](r));r.setPlugins(s),r.setTextureUtils(this.textureUtils),r.writeAsync(t,e,i).catch(n)}parseAsync(t,e){const n=this;return new Promise(function(i,r){n.parse(t,i,r,e)})}}const $n=0,Jn=1,qn=2,Qn=3,ti=4,ei=5120,ni=5121,ii=5122,ri=5123,si=5124,oi=5125,ai=5126,ui=34962,hi=34963,ci=9728,li=9729,fi=9984,di=9985,vi=9986,pi=9987,wi=33071,mi=33648,yi=10497,gi="KHR_mesh_quantization",bi={};bi[t.NearestFilter]=ci,bi[t.NearestMipmapNearestFilter]=fi,bi[t.NearestMipmapLinearFilter]=vi,bi[t.LinearFilter]=li,bi[t.LinearMipmapNearestFilter]=di,bi[t.LinearMipmapLinearFilter]=pi,bi[t.ClampToEdgeWrapping]=wi,bi[t.RepeatWrapping]=yi,bi[t.MirroredRepeatWrapping]=mi;const ki={scale:"scale",position:"translation",quaternion:"rotation",morphTargetInfluences:"weights"},Mi=new t.Color;function xi(t,e){return t.length===e.length&&t.every(function(t,n){return t===e[n]})}function Ti(t){return 4*Math.ceil(t/4)}function Si(t,e=0){const n=Ti(t.byteLength);if(n!==t.byteLength){const i=new Uint8Array(n);if(i.set(new Uint8Array(t)),0!==e)for(let r=t.byteLength;r<n;r++)i[r]=e;return i.buffer}return t}function Ei(){return"undefined"==typeof document&&"undefined"!=typeof OffscreenCanvas?new OffscreenCanvas(1,1):document.createElement("canvas")}class Ai{constructor(){this.plugins=[],this.options={},this.pending=[],this.buffers=[],this.byteOffset=0,this.buffers=[],this.nodeMap=new Map,this.skins=[],this.extensionsUsed={},this.extensionsRequired={},this.uids=new Map,this.uid=0,this.json={asset:{version:"2.0",generator:"THREE.GLTFExporter r"+t.REVISION}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map},this.textureUtils=null}setPlugins(t){this.plugins=t}setTextureUtils(t){this.textureUtils=t}async writeAsync(t,e,n={}){this.options=Object.assign({binary:!1,trs:!1,onlyVisible:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1},n),this.options.animations.length>0&&(this.options.trs=!0),await this.processInputAsync(t),await Promise.all(this.pending);const i=this,r=i.buffers,s=i.json;n=i.options;const o=i.extensionsUsed,a=i.extensionsRequired,u=new Blob(r,{type:"application/octet-stream"}),h=Object.keys(o),c=Object.keys(a);if(h.length>0&&(s.extensionsUsed=h),c.length>0&&(s.extensionsRequired=c),s.buffers&&s.buffers.length>0&&(s.buffers[0].byteLength=u.size),!0===n.binary){const t=new FileReader;t.readAsArrayBuffer(u),t.onloadend=function(){const n=Si(t.result),i=new DataView(new ArrayBuffer(8));i.setUint32(0,n.byteLength,!0),i.setUint32(4,5130562,!0);const r=Si((o=JSON.stringify(s),(new TextEncoder).encode(o).buffer),32);var o;const a=new DataView(new ArrayBuffer(8));a.setUint32(0,r.byteLength,!0),a.setUint32(4,1313821514,!0);const u=new ArrayBuffer(12),h=new DataView(u);h.setUint32(0,1179937895,!0),h.setUint32(4,2,!0);const c=12+a.byteLength+r.byteLength+i.byteLength+n.byteLength;h.setUint32(8,c,!0);const l=new Blob([u,a,r,i,n],{type:"application/octet-stream"}),f=new FileReader;f.readAsArrayBuffer(l),f.onloadend=function(){e(f.result)}}}else if(s.buffers&&s.buffers.length>0){const t=new FileReader;t.readAsDataURL(u),t.onloadend=function(){const n=t.result;s.buffers[0].uri=n,e(s)}}else e(s)}serializeUserData(t,e){if(0===Object.keys(t.userData).length)return;const n=this.options,i=this.extensionsUsed;try{const r=JSON.parse(JSON.stringify(t.userData));if(n.includeCustomExtensions&&r.gltfExtensions){void 0===e.extensions&&(e.extensions={});for(const t in r.gltfExtensions)e.extensions[t]=r.gltfExtensions[t],i[t]=!0;delete r.gltfExtensions}Object.keys(r).length>0&&(e.extras=r)}catch(t){}}getUID(t,e=!1){if(!1===this.uids.has(t)){const e=new Map;e.set(!0,this.uid++),e.set(!1,this.uid++),this.uids.set(t,e)}return this.uids.get(t).get(e)}isNormalizedNormalAttribute(e){if(this.cache.attributesNormalized.has(e))return!1;const n=new t.Vector3;for(let t=0,i=e.count;t<i;t++)if(Math.abs(n.fromBufferAttribute(e,t).length()-1)>5e-4)return!1;return!0}createNormalizedNormalAttribute(e){const n=this.cache;if(n.attributesNormalized.has(e))return n.attributesNormalized.get(e);const i=e.clone(),r=new t.Vector3;for(let t=0,e=i.count;t<e;t++)r.fromBufferAttribute(i,t),0===r.x&&0===r.y&&0===r.z?r.setX(1):r.normalize(),i.setXYZ(t,r.x,r.y,r.z);return n.attributesNormalized.set(e,i),i}applyTextureTransform(t,e){let n=!1;const i={};0===e.offset.x&&0===e.offset.y||(i.offset=e.offset.toArray(),n=!0),0!==e.rotation&&(i.rotation=e.rotation,n=!0),1===e.repeat.x&&1===e.repeat.y||(i.scale=e.repeat.toArray(),n=!0),n&&(t.extensions=t.extensions||{},t.extensions.KHR_texture_transform=i,this.extensionsUsed.KHR_texture_transform=!0)}async buildMetalRoughTextureAsync(e,n){if(e===n)return e;function i(e){return e.colorSpace===t.SRGBColorSpace?function(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}:function(t){return t}}e instanceof t.CompressedTexture&&(e=await this.decompressTextureAsync(e)),n instanceof t.CompressedTexture&&(n=await this.decompressTextureAsync(n));const r=e?e.image:null,s=n?n.image:null,o=Math.max(r?r.width:0,s?s.width:0),a=Math.max(r?r.height:0,s?s.height:0),u=Ei();u.width=o,u.height=a;const h=u.getContext("2d",{willReadFrequently:!0});h.fillStyle="#00ffff",h.fillRect(0,0,o,a);const c=h.getImageData(0,0,o,a);if(r){h.drawImage(r,0,0,o,a);const t=i(e),n=h.getImageData(0,0,o,a).data;for(let e=2;e<n.length;e+=4)c.data[e]=256*t(n[e]/256)}if(s){h.drawImage(s,0,0,o,a);const t=i(n),e=h.getImageData(0,0,o,a).data;for(let n=1;n<e.length;n+=4)c.data[n]=256*t(e[n]/256)}h.putImageData(c,0,0);const l=(e||n).clone();return l.source=new t.Source(u),l.colorSpace=t.NoColorSpace,l.channel=(e||n).channel,e&&n&&(e.channel,n.channel),l}async decompressTextureAsync(t,e=1/0){if(null===this.textureUtils)throw new Error("THREE.GLTFExporter: setTextureUtils() must be called to process compressed textures.");return await this.textureUtils.decompress(t,e)}processBuffer(t){const e=this.json,n=this.buffers;return e.buffers||(e.buffers=[{byteLength:0}]),n.push(t),0}processBufferView(e,n,i,r,s){const o=this.json;let a;switch(o.bufferViews||(o.bufferViews=[]),n){case ei:case ni:a=1;break;case ii:case ri:a=2;break;default:a=4}let u=e.itemSize*a;s===ui&&(u=4*Math.ceil(u/4));const h=Ti(r*u),c=new DataView(new ArrayBuffer(h));let l=0;for(let s=i;s<i+r;s++){for(let i=0;i<e.itemSize;i++){let r;e.itemSize>4?r=e.array[s*e.itemSize+i]:(0===i?r=e.getX(s):1===i?r=e.getY(s):2===i?r=e.getZ(s):3===i&&(r=e.getW(s)),!0===e.normalized&&(r=t.MathUtils.normalize(r,e.array))),n===ai?c.setFloat32(l,r,!0):n===si?c.setInt32(l,r,!0):n===oi?c.setUint32(l,r,!0):n===ii?c.setInt16(l,r,!0):n===ri?c.setUint16(l,r,!0):n===ei?c.setInt8(l,r):n===ni&&c.setUint8(l,r),l+=a}l%u!==0&&(l+=u-l%u)}const f={buffer:this.processBuffer(c.buffer),byteOffset:this.byteOffset,byteLength:h};void 0!==s&&(f.target=s),s===ui&&(f.byteStride=u),this.byteOffset+=h,o.bufferViews.push(f);return{id:o.bufferViews.length-1,byteLength:0}}processBufferViewImage(t){const e=this,n=e.json;return n.bufferViews||(n.bufferViews=[]),new Promise(function(i){const r=new FileReader;r.readAsArrayBuffer(t),r.onloadend=function(){const t=Si(r.result),s={buffer:e.processBuffer(t),byteOffset:e.byteOffset,byteLength:t.byteLength};e.byteOffset+=t.byteLength,i(n.bufferViews.push(s)-1)}})}processAccessor(e,n,i,r){const s=this.json;let o;if(e.array.constructor===Float32Array)o=ai;else if(e.array.constructor===Int32Array)o=si;else if(e.array.constructor===Uint32Array)o=oi;else if(e.array.constructor===Int16Array)o=ii;else if(e.array.constructor===Uint16Array)o=ri;else if(e.array.constructor===Int8Array)o=ei;else{if(e.array.constructor!==Uint8Array)throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: "+e.array.constructor.name);o=ni}if(void 0===i&&(i=0),void 0!==r&&r!==1/0||(r=e.count),0===r)return null;const a=function(e,n,i){const r={min:new Array(e.itemSize).fill(Number.POSITIVE_INFINITY),max:new Array(e.itemSize).fill(Number.NEGATIVE_INFINITY)};for(let s=n;s<n+i;s++)for(let n=0;n<e.itemSize;n++){let i;e.itemSize>4?i=e.array[s*e.itemSize+n]:(0===n?i=e.getX(s):1===n?i=e.getY(s):2===n?i=e.getZ(s):3===n&&(i=e.getW(s)),!0===e.normalized&&(i=t.MathUtils.normalize(i,e.array))),r.min[n]=Math.min(r.min[n],i),r.max[n]=Math.max(r.max[n],i)}return r}(e,i,r);let u;void 0!==n&&(u=e===n.index?hi:ui);const h=this.processBufferView(e,o,i,r,u),c={bufferView:h.id,byteOffset:h.byteOffset,componentType:o,count:r,max:a.max,min:a.min,type:{1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",9:"MAT3",16:"MAT4"}[e.itemSize]};return!0===e.normalized&&(c.normalized=!0),s.accessors||(s.accessors=[]),s.accessors.push(c)-1}processImage(e,n,i,r="image/png"){if(null!==e){const n=this,s=n.cache,o=n.json,a=n.options,u=n.pending;s.images.has(e)||s.images.set(e,{});const h=s.images.get(e),c=r+":flipY/"+i.toString();if(void 0!==h[c])return h[c];o.images||(o.images=[]);const l={mimeType:r},f=Ei();f.width=Math.min(e.width,a.maxTextureSize),f.height=Math.min(e.height,a.maxTextureSize);const d=f.getContext("2d",{willReadFrequently:!0});if(!0===i&&(d.translate(0,f.height),d.scale(1,-1)),void 0!==e.data){t.RGBAFormat,e.width>a.maxTextureSize||(e.height,a.maxTextureSize);const n=new Uint8ClampedArray(e.height*e.width*4);for(let t=0;t<n.length;t+=4)n[t+0]=e.data[t+0],n[t+1]=e.data[t+1],n[t+2]=e.data[t+2],n[t+3]=e.data[t+3];d.putImageData(new ImageData(n,e.width,e.height),0,0)}else{if(!("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas))throw new Error("THREE.GLTFExporter: Invalid image type. Use HTMLImageElement, HTMLCanvasElement, ImageBitmap or OffscreenCanvas.");d.drawImage(e,0,0,f.width,f.height)}!0===a.binary?u.push(function(t,e){if(void 0!==t.toBlob)return new Promise(n=>t.toBlob(n,e));let n;return"image/jpeg"===e?n=.92:"image/webp"===e&&(n=.8),t.convertToBlob({type:e,quality:n})}(f,r).then(t=>n.processBufferViewImage(t)).then(t=>{l.bufferView=t})):l.uri=t.ImageUtils.getDataURL(f,r);const v=o.images.push(l)-1;return h[c]=v,v}throw new Error("THREE.GLTFExporter: No valid image data found. Unable to process texture.")}processSampler(t){const e=this.json;e.samplers||(e.samplers=[]);const n={magFilter:bi[t.magFilter],minFilter:bi[t.minFilter],wrapS:bi[t.wrapS],wrapT:bi[t.wrapT]};return e.samplers.push(n)-1}async processTextureAsync(e){const n=this.options,i=this.cache,r=this.json;if(i.textures.has(e))return i.textures.get(e);r.textures||(r.textures=[]),e instanceof t.CompressedTexture&&(e=await this.decompressTextureAsync(e,n.maxTextureSize));let s=e.userData.mimeType;"image/webp"===s&&(s="image/png");const o={sampler:this.processSampler(e),source:this.processImage(e.image,e.format,e.flipY,s)};e.name&&(o.name=e.name),await this.$e(async function(t){t.writeTexture&&await t.writeTexture(e,o)});const a=r.textures.push(o)-1;return i.textures.set(e,a),a}async processMaterialAsync(e){const n=this.cache,i=this.json;if(n.materials.has(e))return n.materials.get(e);if(e.isShaderMaterial)return null;i.materials||(i.materials=[]);const r={pbrMetallicRoughness:{}};!0!==e.isMeshStandardMaterial&&e.isMeshBasicMaterial;const s=e.color.toArray().concat([e.opacity]);if(xi(s,[1,1,1,1])||(r.pbrMetallicRoughness.baseColorFactor=s),e.isMeshStandardMaterial?(r.pbrMetallicRoughness.metallicFactor=e.metalness,r.pbrMetallicRoughness.roughnessFactor=e.roughness):(r.pbrMetallicRoughness.metallicFactor=0,r.pbrMetallicRoughness.roughnessFactor=1),e.metalnessMap||e.roughnessMap){const t=await this.buildMetalRoughTextureAsync(e.metalnessMap,e.roughnessMap),n={index:await this.processTextureAsync(t),texCoord:t.channel};this.applyTextureTransform(n,t),r.pbrMetallicRoughness.metallicRoughnessTexture=n}if(e.map){const t={index:await this.processTextureAsync(e.map),texCoord:e.map.channel};this.applyTextureTransform(t,e.map),r.pbrMetallicRoughness.baseColorTexture=t}if(e.emissive){const t=e.emissive;if(Math.max(t.r,t.g,t.b)>0&&(r.emissiveFactor=e.emissive.toArray()),e.emissiveMap){const t={index:await this.processTextureAsync(e.emissiveMap),texCoord:e.emissiveMap.channel};this.applyTextureTransform(t,e.emissiveMap),r.emissiveTexture=t}}if(e.normalMap){const t={index:await this.processTextureAsync(e.normalMap),texCoord:e.normalMap.channel};e.normalScale&&1!==e.normalScale.x&&(t.scale=e.normalScale.x),this.applyTextureTransform(t,e.normalMap),r.normalTexture=t}if(e.aoMap){const t={index:await this.processTextureAsync(e.aoMap),texCoord:e.aoMap.channel};1!==e.aoMapIntensity&&(t.strength=e.aoMapIntensity),this.applyTextureTransform(t,e.aoMap),r.occlusionTexture=t}e.transparent?r.alphaMode="BLEND":e.alphaTest>0&&(r.alphaMode="MASK",r.alphaCutoff=e.alphaTest),e.side===t.DoubleSide&&(r.doubleSided=!0),""!==e.name&&(r.name=e.name),this.serializeUserData(e,r),await this.$e(async function(t){t.writeMaterialAsync&&await t.writeMaterialAsync(e,r)});const o=i.materials.push(r)-1;return n.materials.set(e,o),o}async processMeshAsync(e){const n=this.cache,i=this.json,r=[e.geometry.uuid];if(Array.isArray(e.material))for(let t=0,n=e.material.length;t<n;t++)r.push(e.material[t].uuid);else r.push(e.material.uuid);const s=r.join(":");if(n.meshes.has(s))return n.meshes.get(s);const o=e.geometry;let a;a=e.isLineSegments?Jn:e.isLineLoop?qn:e.isLine?Qn:e.isPoints?$n:e.material.wireframe?Jn:ti;const u={},h={},c=[],l=[],f={uv:"TEXCOORD_0",uv1:"TEXCOORD_1",uv2:"TEXCOORD_2",uv3:"TEXCOORD_3",color:"COLOR_0",skinWeight:"WEIGHTS_0",skinIndex:"JOINTS_0"},d=o.getAttribute("normal");void 0===d||this.isNormalizedNormalAttribute(d)||o.setAttribute("normal",this.createNormalizedNormalAttribute(d));let v=null;for(let e in o.attributes){if("morph"===e.slice(0,5))continue;const i=o.attributes[e];e=f[e]||e.toUpperCase();if(/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(e)||(e="_"+e),n.attributes.has(this.getUID(i))){h[e]=n.attributes.get(this.getUID(i));continue}v=null;const r=i.array;"JOINTS_0"!==e||r instanceof Uint16Array||r instanceof Uint8Array?(r instanceof Uint32Array||r instanceof Int32Array)&&!e.startsWith("_")&&(v=Wn.Utils.toFloat32BufferAttribute(i)):v=new t.BufferAttribute(new Uint16Array(r),i.itemSize,i.normalized);const s=this.processAccessor(v||i,o);null!==s&&(e.startsWith("_")||this.detectMeshQuantization(e,i),h[e]=s,n.attributes.set(this.getUID(i),s))}if(void 0!==d&&o.setAttribute("normal",d),0===Object.keys(h).length)return null;if(void 0!==e.morphTargetInfluences&&e.morphTargetInfluences.length>0){const t=[],i=[],r={};if(void 0!==e.morphTargetDictionary)for(const t in e.morphTargetDictionary)r[e.morphTargetDictionary[t]]=t;for(let s=0;s<e.morphTargetInfluences.length;++s){const a={};let u=!1;for(const t in o.morphAttributes){if("position"!==t&&"normal"!==t){u||(u=!0);continue}const e=o.morphAttributes[t][s],i=t.toUpperCase(),r=o.attributes[t];if(n.attributes.has(this.getUID(e,!0))){a[i]=n.attributes.get(this.getUID(e,!0));continue}const h=e.clone();if(!o.morphTargetsRelative)for(let t=0,n=e.count;t<n;t++)for(let n=0;n<e.itemSize;n++)0===n&&h.setX(t,e.getX(t)-r.getX(t)),1===n&&h.setY(t,e.getY(t)-r.getY(t)),2===n&&h.setZ(t,e.getZ(t)-r.getZ(t)),3===n&&h.setW(t,e.getW(t)-r.getW(t));a[i]=this.processAccessor(h,o),n.attributes.set(this.getUID(r,!0),a[i])}l.push(a),t.push(e.morphTargetInfluences[s]),void 0!==e.morphTargetDictionary&&i.push(r[s])}u.weights=t,i.length>0&&(u.extras={},u.extras.targetNames=i)}const p=Array.isArray(e.material);if(p&&0===o.groups.length)return null;let w=!1;if(p&&null===o.index){const t=[];for(let e=0,n=o.attributes.position.count;e<n;e++)t[e]=e;o.setIndex(t),w=!0}const m=p?e.material:[e.material],y=p?o.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let t=0,e=y.length;t<e;t++){const e={mode:a,attributes:h};if(this.serializeUserData(o,e),l.length>0&&(e.targets=l),null!==o.index){let i=this.getUID(o.index);void 0===y[t].start&&void 0===y[t].count||(i+=":"+y[t].start+":"+y[t].count),n.attributes.has(i)?e.indices=n.attributes.get(i):(e.indices=this.processAccessor(o.index,o,y[t].start,y[t].count),n.attributes.set(i,e.indices)),null===e.indices&&delete e.indices}const i=await this.processMaterialAsync(m[y[t].materialIndex]);null!==i&&(e.material=i),c.push(e)}!0===w&&o.setIndex(null),u.primitives=c,i.meshes||(i.meshes=[]),await this.$e(function(t){t.writeMesh&&t.writeMesh(e,u)});const g=i.meshes.push(u)-1;return n.meshes.set(s,g),g}detectMeshQuantization(t,e){if(this.extensionsUsed[gi])return;let n;switch(e.array.constructor){case Int8Array:n="byte";break;case Uint8Array:n="unsigned byte";break;case Int16Array:n="short";break;case Uint16Array:n="unsigned short";break;default:return}e.normalized&&(n+=" normalized");const i=t.split("_",1)[0];Zn[i]&&Zn[i].includes(n)&&(this.extensionsUsed[gi]=!0,this.extensionsRequired[gi]=!0)}processCamera(e){const n=this.json;n.cameras||(n.cameras=[]);const i=e.isOrthographicCamera,r={type:i?"orthographic":"perspective"};return i?r.orthographic={xmag:2*e.right,ymag:2*e.top,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:r.perspective={aspectRatio:e.aspect,yfov:t.MathUtils.degToRad(e.fov),zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},""!==e.name&&(r.name=e.type),n.cameras.push(r)-1}processAnimation(e,n){const i=this.json,r=this.nodeMap;i.animations||(i.animations=[]);const s=(e=Wn.Utils.mergeMorphTargetTracks(e.clone(),n)).tracks,o=[],a=[];for(let e=0;e<s.length;++e){const i=s[e],u=t.PropertyBinding.parseTrackName(i.name);let h=t.PropertyBinding.findNode(n,u.nodeName);const c=ki[u.propertyName];if("bones"===u.objectName&&(h=!0===h.isSkinnedMesh?h.skeleton.getBoneByName(u.objectIndex):void 0),!h||!c)continue;const l=1;let f,d=i.values.length/i.times.length;c===ki.morphTargetInfluences&&(d/=h.morphTargetInfluences.length),!0===i.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline?(f="CUBICSPLINE",d/=3):f=i.getInterpolation()===t.InterpolateDiscrete?"STEP":"LINEAR",a.push({input:this.processAccessor(new t.BufferAttribute(i.times,l)),output:this.processAccessor(new t.BufferAttribute(i.values,d)),interpolation:f}),o.push({sampler:a.length-1,target:{node:r.get(h),path:c}})}return i.animations.push({name:e.name||"clip_"+i.animations.length,samplers:a,channels:o}),i.animations.length-1}processSkin(e){const n=this.json,i=this.nodeMap,r=n.nodes[i.get(e)],s=e.skeleton;if(void 0===s)return null;const o=e.skeleton.bones[0];if(void 0===o)return null;const a=[],u=new Float32Array(16*s.bones.length),h=new t.Matrix4;for(let t=0;t<s.bones.length;++t)a.push(i.get(s.bones[t])),h.copy(s.boneInverses[t]),h.multiply(e.bindMatrix).toArray(u,16*t);void 0===n.skins&&(n.skins=[]),n.skins.push({inverseBindMatrices:this.processAccessor(new t.BufferAttribute(u,16)),joints:a,skeleton:i.get(o)});return r.skin=n.skins.length-1}async processNodeAsync(t){const e=this.json,n=this.options,i=this.nodeMap;e.nodes||(e.nodes=[]);const r={};if(n.trs){const e=t.quaternion.toArray(),n=t.position.toArray(),i=t.scale.toArray();xi(e,[0,0,0,1])||(r.rotation=e),xi(n,[0,0,0])||(r.translation=n),xi(i,[1,1,1])||(r.scale=i)}else t.matrixAutoUpdate&&t.updateMatrix(),!1===xi(t.matrix.elements,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])&&(r.matrix=t.matrix.elements);if(""!==t.name&&(r.name=String(t.name)),this.serializeUserData(t,r),t.isMesh||t.isLine||t.isPoints){const e=await this.processMeshAsync(t);null!==e&&(r.mesh=e)}else t.isCamera&&(r.camera=this.processCamera(t));t.isSkinnedMesh&&this.skins.push(t);const s=e.nodes.push(r)-1;if(i.set(t,s),t.children.length>0){const e=[];for(let i=0,r=t.children.length;i<r;i++){const r=t.children[i];if(r.visible||!1===n.onlyVisible){const t=await this.processNodeAsync(r);null!==t&&e.push(t)}}e.length>0&&(r.children=e)}return await this.$e(function(e){e.writeNode&&e.writeNode(t,r)}),s}async processSceneAsync(t){const e=this.json,n=this.options;e.scenes||(e.scenes=[],e.scene=0);const i={};""!==t.name&&(i.name=t.name),e.scenes.push(i);const r=[];for(let e=0,i=t.children.length;e<i;e++){const i=t.children[e];if(i.visible||!1===n.onlyVisible){const t=await this.processNodeAsync(i);null!==t&&r.push(t)}}r.length>0&&(i.nodes=r),this.serializeUserData(t,i)}async processObjectsAsync(e){const n=new t.Scene;n.name="AuxScene";for(let t=0;t<e.length;t++)n.children.push(e[t]);await this.processSceneAsync(n)}async processInputAsync(e){const n=this.options;e=e instanceof Array?e:[e],await this.$e(function(t){t.beforeParse&&t.beforeParse(e)});const i=[];for(let n=0;n<e.length;n++)e[n]instanceof t.Scene?await this.processSceneAsync(e[n]):i.push(e[n]);i.length>0&&await this.processObjectsAsync(i);for(let t=0;t<this.skins.length;++t)this.processSkin(this.skins[t]);for(let t=0;t<n.animations.length;++t)this.processAnimation(n.animations[t],e[0]);await this.$e(function(t){t.afterParse&&t.afterParse(e)})}async $e(t){for(let e=0,n=this.plugins.length;e<n;e++)await t(this.plugins[e])}}class _i{constructor(t){this.writer=t,this.name="KHR_lights_punctual"}writeNode(t,e){if(!t.isLight)return;if(!t.isDirectionalLight&&!t.isPointLight&&!t.isSpotLight)return;const n=this.writer,i=n.json,r=n.extensionsUsed,s={};t.name&&(s.name=t.name),s.color=t.color.toArray(),s.intensity=t.intensity,t.isDirectionalLight?s.type="directional":t.isPointLight?(s.type="point",t.distance>0&&(s.range=t.distance)):t.isSpotLight&&(s.type="spot",t.distance>0&&(s.range=t.distance),s.spot={},s.spot.innerConeAngle=(1-t.penumbra)*t.angle,s.spot.outerConeAngle=t.angle),void 0!==t.decay&&t.decay,t.target&&(t.target.parent!==t||0!==t.target.position.x||0!==t.target.position.y||t.target.position.z),r[this.name]||(i.extensions=i.extensions||{},i.extensions[this.name]={lights:[]},r[this.name]=!0);const o=i.extensions[this.name].lights;o.push(s),e.extensions=e.extensions||{},e.extensions[this.name]={light:o.length-1}}}class Oi{constructor(t){this.writer=t,this.name="KHR_materials_unlit"}async writeMaterialAsync(t,e){if(!t.isMeshBasicMaterial)return;const n=this.writer.extensionsUsed;e.extensions=e.extensions||{},e.extensions[this.name]={},n[this.name]=!0,e.pbrMetallicRoughness.metallicFactor=0,e.pbrMetallicRoughness.roughnessFactor=.9}}class Ci{constructor(t){this.writer=t,this.name="KHR_materials_clearcoat"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||0===t.clearcoat)return;const n=this.writer,i=n.extensionsUsed,r={};if(r.clearcoatFactor=t.clearcoat,t.clearcoatMap){const e={index:await n.processTextureAsync(t.clearcoatMap),texCoord:t.clearcoatMap.channel};n.applyTextureTransform(e,t.clearcoatMap),r.clearcoatTexture=e}if(r.clearcoatRoughnessFactor=t.clearcoatRoughness,t.clearcoatRoughnessMap){const e={index:await n.processTextureAsync(t.clearcoatRoughnessMap),texCoord:t.clearcoatRoughnessMap.channel};n.applyTextureTransform(e,t.clearcoatRoughnessMap),r.clearcoatRoughnessTexture=e}if(t.clearcoatNormalMap){const e={index:await n.processTextureAsync(t.clearcoatNormalMap),texCoord:t.clearcoatNormalMap.channel};1!==t.clearcoatNormalScale.x&&(e.scale=t.clearcoatNormalScale.x),n.applyTextureTransform(e,t.clearcoatNormalMap),r.clearcoatNormalTexture=e}e.extensions=e.extensions||{},e.extensions[this.name]=r,i[this.name]=!0}}class Ri{constructor(t){this.writer=t,this.name="KHR_materials_dispersion"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||0===t.dispersion)return;const n=this.writer.extensionsUsed,i={};i.dispersion=t.dispersion,e.extensions=e.extensions||{},e.extensions[this.name]=i,n[this.name]=!0}}class Pi{constructor(t){this.writer=t,this.name="KHR_materials_iridescence"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||0===t.iridescence)return;const n=this.writer,i=n.extensionsUsed,r={};if(r.iridescenceFactor=t.iridescence,t.iridescenceMap){const e={index:await n.processTextureAsync(t.iridescenceMap),texCoord:t.iridescenceMap.channel};n.applyTextureTransform(e,t.iridescenceMap),r.iridescenceTexture=e}if(r.iridescenceIor=t.iridescenceIOR,r.iridescenceThicknessMinimum=t.iridescenceThicknessRange[0],r.iridescenceThicknessMaximum=t.iridescenceThicknessRange[1],t.iridescenceThicknessMap){const e={index:await n.processTextureAsync(t.iridescenceThicknessMap),texCoord:t.iridescenceThicknessMap.channel};n.applyTextureTransform(e,t.iridescenceThicknessMap),r.iridescenceThicknessTexture=e}e.extensions=e.extensions||{},e.extensions[this.name]=r,i[this.name]=!0}}class ji{constructor(t){this.writer=t,this.name="KHR_materials_transmission"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||0===t.transmission)return;const n=this.writer,i=n.extensionsUsed,r={};if(r.transmissionFactor=t.transmission,t.transmissionMap){const e={index:await n.processTextureAsync(t.transmissionMap),texCoord:t.transmissionMap.channel};n.applyTextureTransform(e,t.transmissionMap),r.transmissionTexture=e}e.extensions=e.extensions||{},e.extensions[this.name]=r,i[this.name]=!0}}class Di{constructor(t){this.writer=t,this.name="KHR_materials_volume"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||0===t.transmission)return;const n=this.writer,i=n.extensionsUsed,r={};if(r.thicknessFactor=t.thickness,t.thicknessMap){const e={index:await n.processTextureAsync(t.thicknessMap),texCoord:t.thicknessMap.channel};n.applyTextureTransform(e,t.thicknessMap),r.thicknessTexture=e}t.attenuationDistance!==1/0&&(r.attenuationDistance=t.attenuationDistance),r.attenuationColor=t.attenuationColor.toArray(),e.extensions=e.extensions||{},e.extensions[this.name]=r,i[this.name]=!0}}class Ii{constructor(t){this.writer=t,this.name="KHR_materials_ior"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||1.5===t.ior)return;const n=this.writer.extensionsUsed,i={};i.ior=t.ior,e.extensions=e.extensions||{},e.extensions[this.name]=i,n[this.name]=!0}}class Ni{constructor(t){this.writer=t,this.name="KHR_materials_specular"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||1===t.specularIntensity&&t.specularColor.equals(Mi)&&!t.specularIntensityMap&&!t.specularColorMap)return;const n=this.writer,i=n.extensionsUsed,r={};if(t.specularIntensityMap){const e={index:await n.processTextureAsync(t.specularIntensityMap),texCoord:t.specularIntensityMap.channel};n.applyTextureTransform(e,t.specularIntensityMap),r.specularTexture=e}if(t.specularColorMap){const e={index:await n.processTextureAsync(t.specularColorMap),texCoord:t.specularColorMap.channel};n.applyTextureTransform(e,t.specularColorMap),r.specularColorTexture=e}r.specularFactor=t.specularIntensity,r.specularColorFactor=t.specularColor.toArray(),e.extensions=e.extensions||{},e.extensions[this.name]=r,i[this.name]=!0}}class Li{constructor(t){this.writer=t,this.name="KHR_materials_sheen"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||0==t.sheen)return;const n=this.writer,i=n.extensionsUsed,r={};if(t.sheenRoughnessMap){const e={index:await n.processTextureAsync(t.sheenRoughnessMap),texCoord:t.sheenRoughnessMap.channel};n.applyTextureTransform(e,t.sheenRoughnessMap),r.sheenRoughnessTexture=e}if(t.sheenColorMap){const e={index:await n.processTextureAsync(t.sheenColorMap),texCoord:t.sheenColorMap.channel};n.applyTextureTransform(e,t.sheenColorMap),r.sheenColorTexture=e}r.sheenRoughnessFactor=t.sheenRoughness,r.sheenColorFactor=t.sheenColor.toArray(),e.extensions=e.extensions||{},e.extensions[this.name]=r,i[this.name]=!0}}class Bi{constructor(t){this.writer=t,this.name="KHR_materials_anisotropy"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||0==t.anisotropy)return;const n=this.writer,i=n.extensionsUsed,r={};if(t.anisotropyMap){const e={index:await n.processTextureAsync(t.anisotropyMap)};n.applyTextureTransform(e,t.anisotropyMap),r.anisotropyTexture=e}r.anisotropyStrength=t.anisotropy,r.anisotropyRotation=t.anisotropyRotation,e.extensions=e.extensions||{},e.extensions[this.name]=r,i[this.name]=!0}}class Fi{constructor(t){this.writer=t,this.name="KHR_materials_emissive_strength"}async writeMaterialAsync(t,e){if(!t.isMeshStandardMaterial||1===t.emissiveIntensity)return;const n=this.writer.extensionsUsed,i={};i.emissiveStrength=t.emissiveIntensity,e.extensions=e.extensions||{},e.extensions[this.name]=i,n[this.name]=!0}}class Ui{constructor(t){this.writer=t,this.name="EXT_materials_bump"}async writeMaterialAsync(t,e){if(!t.isMeshStandardMaterial||1===t.bumpScale&&!t.bumpMap)return;const n=this.writer,i=n.extensionsUsed,r={};if(t.bumpMap){const e={index:await n.processTextureAsync(t.bumpMap),texCoord:t.bumpMap.channel};n.applyTextureTransform(e,t.bumpMap),r.bumpTexture=e}r.bumpFactor=t.bumpScale,e.extensions=e.extensions||{},e.extensions[this.name]=r,i[this.name]=!0}}class zi{constructor(t){this.writer=t,this.name="EXT_mesh_gpu_instancing"}writeNode(e,n){if(!e.isInstancedMesh)return;const i=this.writer,r=e,s=new Float32Array(3*r.count),o=new Float32Array(4*r.count),a=new Float32Array(3*r.count),u=new t.Matrix4,h=new t.Vector3,c=new t.Quaternion,l=new t.Vector3;for(let t=0;t<r.count;t++)r.getMatrixAt(t,u),u.decompose(h,c,l),h.toArray(s,3*t),c.toArray(o,4*t),l.toArray(a,3*t);const f={TRANSLATION:i.processAccessor(new t.BufferAttribute(s,3)),ROTATION:i.processAccessor(new t.BufferAttribute(o,4)),SCALE:i.processAccessor(new t.BufferAttribute(a,3))};r.instanceColor&&(f.Je=i.processAccessor(r.instanceColor)),n.extensions=n.extensions||{},n.extensions[this.name]={attributes:f},i.extensionsUsed[this.name]=!0,i.extensionsRequired[this.name]=!0}}Wn.Utils={insertKeyframe:function(t,e){const n=.001,i=t.getValueSize(),r=new t.TimeBufferType(t.times.length+1),s=new t.ValueBufferType(t.values.length+i),o=t.createInterpolant(new t.ValueBufferType(i));let a;if(0===t.times.length){r[0]=e;for(let t=0;t<i;t++)s[t]=0;a=0}else if(e<t.times[0]){if(Math.abs(t.times[0]-e)<n)return 0;r[0]=e,r.set(t.times,1),s.set(o.evaluate(e),0),s.set(t.values,i),a=0}else if(e>t.times[t.times.length-1]){if(Math.abs(t.times[t.times.length-1]-e)<n)return t.times.length-1;r[r.length-1]=e,r.set(t.times,0),s.set(t.values,0),s.set(o.evaluate(e),t.values.length),a=r.length-1}else for(let u=0;u<t.times.length;u++){if(Math.abs(t.times[u]-e)<n)return u;if(t.times[u]<e&&t.times[u+1]>e){r.set(t.times.slice(0,u+1),0),r[u+1]=e,r.set(t.times.slice(u+1),u+2),s.set(t.values.slice(0,(u+1)*i),0),s.set(o.evaluate(e),(u+1)*i),s.set(t.values.slice((u+1)*i),(u+2)*i),a=u+1;break}}return t.times=r,t.values=s,a},mergeMorphTargetTracks:function(e,n){const i=[],r={},s=e.tracks;for(let e=0;e<s.length;++e){let o=s[e];const a=t.PropertyBinding.parseTrackName(o.name),u=t.PropertyBinding.findNode(n,a.nodeName);if("morphTargetInfluences"!==a.propertyName||void 0===a.propertyIndex){i.push(o);continue}if(o.createInterpolant!==o.InterpolantFactoryMethodDiscrete&&o.createInterpolant!==o.InterpolantFactoryMethodLinear){if(o.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline)throw new Error("THREE.GLTFExporter: Cannot merge tracks with glTF CUBICSPLINE interpolation.");o=o.clone(),o.setInterpolation(t.InterpolateLinear)}const h=u.morphTargetInfluences.length,c=u.morphTargetDictionary[a.propertyIndex];if(void 0===c)throw new Error("THREE.GLTFExporter: Morph target name not found: "+a.propertyIndex);let l;if(void 0===r[u.uuid]){l=o.clone();const t=new l.ValueBufferType(h*l.times.length);for(let e=0;e<l.times.length;e++)t[e*h+c]=l.values[e];l.name=(a.nodeName||"")+".morphTargetInfluences",l.values=t,r[u.uuid]=l,i.push(l);continue}const f=o.createInterpolant(new o.ValueBufferType(1));l=r[u.uuid];for(let t=0;t<l.times.length;t++)l.values[t*h+c]=f.evaluate(l.times[t]);for(let t=0;t<o.times.length;t++){const e=this.insertKeyframe(l,o.times[t]);l.values[e*h+c]=o.values[t]}}return e.tracks=i,e},toFloat32BufferAttribute:function(e){const n=new t.BufferAttribute(new Float32Array(e.count*e.itemSize),e.itemSize,!1);if(!e.normalized&&!e.isInterleavedBufferAttribute)return n.array.set(e.array),n;for(let t=0,i=e.count;t<i;t++)for(let i=0;i<e.itemSize;i++)n.setComponent(t,i,e.getComponent(t,i));return n}};class Hi{parse(e){let n="",i=0,r=0,s=0;const o=new t.Vector3,a=new t.Color,u=new t.Vector3,h=new t.Vector2,c=[];return e.traverse(function(e){!0===e.isMesh&&function(e){let a=0,l=0,f=0;const d=e.geometry,v=new t.Matrix3,p=d.getAttribute("position"),w=d.getAttribute("normal"),m=d.getAttribute("uv"),y=d.getIndex();if(n+="o "+e.name+"\n",e.material&&e.material.name&&(n+="usemtl "+e.material.name+"\n"),void 0!==p)for(let t=0,i=p.count;t<i;t++,a++)o.fromBufferAttribute(p,t),o.applyMatrix4(e.matrixWorld),n+="v "+o.x+" "+o.y+" "+o.z+"\n";if(void 0!==m)for(let t=0,e=m.count;t<e;t++,f++)h.fromBufferAttribute(m,t),n+="vt "+h.x+" "+h.y+"\n";if(void 0!==w){v.getNormalMatrix(e.matrixWorld);for(let t=0,e=w.count;t<e;t++,l++)u.fromBufferAttribute(w,t),u.applyMatrix3(v).normalize(),n+="vn "+u.x+" "+u.y+" "+u.z+"\n"}if(null!==y)for(let t=0,e=y.count;t<e;t+=3){for(let e=0;e<3;e++){const n=y.getX(t+e)+1;c[e]=i+n+(w||m?"/"+(m?r+n:"")+(w?"/"+(s+n):""):"")}n+="f "+c.join(" ")+"\n"}else for(let t=0,e=p.count;t<e;t+=3){for(let e=0;e<3;e++){const n=t+e+1;c[e]=i+n+(w||m?"/"+(m?r+n:"")+(w?"/"+(s+n):""):"")}n+="f "+c.join(" ")+"\n"}i+=a,r+=f,s+=l}(e),!0===e.isLine&&function(t){let e=0;const r=t.geometry,s=t.type,a=r.getAttribute("position");if(n+="o "+t.name+"\n",void 0!==a)for(let i=0,r=a.count;i<r;i++,e++)o.fromBufferAttribute(a,i),o.applyMatrix4(t.matrixWorld),n+="v "+o.x+" "+o.y+" "+o.z+"\n";if("Line"===s){n+="l ";for(let t=1,e=a.count;t<=e;t++)n+=i+t+" ";n+="\n"}if("LineSegments"===s)for(let t=1,e=t+1,r=a.count;t<r;t+=2,e=t+1)n+="l "+(i+t)+" "+(i+e)+"\n";i+=e}(e),!0===e.isPoints&&function(e){let r=0;const s=e.geometry,u=s.getAttribute("position"),h=s.getAttribute("color");if(n+="o "+e.name+"\n",void 0!==u){for(let i=0,s=u.count;i<s;i++,r++)o.fromBufferAttribute(u,i),o.applyMatrix4(e.matrixWorld),n+="v "+o.x+" "+o.y+" "+o.z,void 0!==h&&(a.fromBufferAttribute(h,i),t.ColorManagement.workingToColorSpace(a,t.SRGBColorSpace),n+=" "+a.r+" "+a.g+" "+a.b),n+="\n";n+="p ";for(let t=1,e=u.count;t<=e;t++)n+=i+t+" ";n+="\n"}i+=r}(e)}),n}}class Gi{parse(e,n={}){const i=(n=Object.assign({binary:!1},n)).binary,r=[];let s,o=0;e.traverse(function(t){if(t.isMesh){const e=t.geometry,n=e.index,i=e.getAttribute("position");o+=null!==n?n.count/3:i.count/3,r.push({object3d:t,geometry:e})}});let a=80;if(!0===i){const t=new ArrayBuffer(2*o+3*o*4*4+80+4);s=new DataView(t),s.setUint32(a,o,!0),a+=4}else s="",s+="solid exported\n";const u=new t.Vector3,h=new t.Vector3,c=new t.Vector3,l=new t.Vector3,f=new t.Vector3,d=new t.Vector3;for(let t=0,e=r.length;t<e;t++){const e=r[t].object3d,n=r[t].geometry,i=n.index,s=n.getAttribute("position");if(null!==i)for(let t=0;t<i.count;t+=3){v(i.getX(t+0),i.getX(t+1),i.getX(t+2),s,e)}else for(let t=0;t<s.count;t+=3){v(t+0,t+1,t+2,s,e)}}return!1===i&&(s+="endsolid exported\n"),s;function v(t,e,n,r,o){u.fromBufferAttribute(r,t),h.fromBufferAttribute(r,e),c.fromBufferAttribute(r,n),!0===o.isSkinnedMesh&&(o.applyBoneTransform(t,u),o.applyBoneTransform(e,h),o.applyBoneTransform(n,c)),u.applyMatrix4(o.matrixWorld),h.applyMatrix4(o.matrixWorld),c.applyMatrix4(o.matrixWorld),function(t,e,n){l.subVectors(n,e),f.subVectors(t,e),l.cross(f).normalize(),d.copy(l).normalize(),!0===i?(s.setFloat32(a,d.x,!0),a+=4,s.setFloat32(a,d.y,!0),a+=4,s.setFloat32(a,d.z,!0),a+=4):(s+="\tfacet normal "+d.x+" "+d.y+" "+d.z+"\n",s+="\t\touter loop\n")}(u,h,c),p(u),p(h),p(c),!0===i?(s.setUint16(a,0,!0),a+=2):(s+="\t\tendloop\n",s+="\tendfacet\n")}function p(t){!0===i?(s.setFloat32(a,t.x,!0),a+=4,s.setFloat32(a,t.y,!0),a+=4,s.setFloat32(a,t.z,!0),a+=4):s+="\t\t\tvertex "+t.x+" "+t.y+" "+t.z+"\n"}}}class Xi{parse(e,n,i={}){function r(t){e.traverse(function(e){if(!0===e.isMesh||e.isPoints){const n=e,i=n.geometry;!0===i.hasAttribute("position")&&t(n,i)}})}const s=(i=Object.assign({binary:!1,excludeAttributes:[],littleEndian:!1},i)).excludeAttributes;let o=!0,a=!1,u=!1,h=!1,c=0,l=0;e.traverse(function(t){if(!0===t.isMesh){const e=t.geometry,n=e.getAttribute("position"),i=e.getAttribute("normal"),r=e.getAttribute("uv"),s=e.getAttribute("color"),o=e.getIndex();if(void 0===n)return;c+=n.count,l+=o?o.count/3:n.count/3,void 0!==i&&(a=!0),void 0!==r&&(h=!0),void 0!==s&&(u=!0)}else if(t.isPoints){const e=t.geometry,n=e.getAttribute("position"),i=e.getAttribute("normal"),r=e.getAttribute("color");c+=n.count,void 0!==i&&(a=!0),void 0!==r&&(u=!0),o=!1}});const f=new t.Color;if(o=o&&-1===s.indexOf("index"),a=a&&-1===s.indexOf("normal"),u=u&&-1===s.indexOf("color"),h=h&&-1===s.indexOf("uv"),o&&l!==Math.floor(l))return null;let d=`ply\nformat ${i.binary?i.littleEndian?"binary_little_endian":"binary_big_endian":"ascii"} 1.0\nelement vertex ${c}\nproperty float x\nproperty float y\nproperty float z\n`;!0===a&&(d+="property float nx\nproperty float ny\nproperty float nz\n"),!0===h&&(d+="property float s\nproperty float t\n"),!0===u&&(d+="property uchar red\nproperty uchar green\nproperty uchar blue\n"),!0===o&&(d+=`element face ${l}\nproperty list uchar int vertex_index\n`),d+="end_header\n";const v=new t.Vector3,p=new t.Matrix3;let w=null;if(!0===i.binary){const e=(new TextEncoder).encode(d),n=c*(12+(a?12:0)+(u?3:0)+(h?8:0)),s=o?13*l:0,m=new DataView(new ArrayBuffer(e.length+n+s));new Uint8Array(m.buffer).set(e,0);let y=e.length,g=e.length+n,b=0;r(function(e,n){const r=n.getAttribute("position"),s=n.getAttribute("normal"),c=n.getAttribute("uv"),l=n.getAttribute("color"),d=n.getIndex();p.getNormalMatrix(e.matrixWorld);for(let n=0,o=r.count;n<o;n++)v.fromBufferAttribute(r,n),v.applyMatrix4(e.matrixWorld),m.setFloat32(y,v.x,i.littleEndian),y+=4,m.setFloat32(y,v.y,i.littleEndian),y+=4,m.setFloat32(y,v.z,i.littleEndian),y+=4,!0===a&&(null!=s?(v.fromBufferAttribute(s,n),v.applyMatrix3(p).normalize(),m.setFloat32(y,v.x,i.littleEndian),y+=4,m.setFloat32(y,v.y,i.littleEndian),y+=4,m.setFloat32(y,v.z,i.littleEndian),y+=4):(m.setFloat32(y,0,i.littleEndian),y+=4,m.setFloat32(y,0,i.littleEndian),y+=4,m.setFloat32(y,0,i.littleEndian),y+=4)),!0===h&&(null!=c?(m.setFloat32(y,c.getX(n),i.littleEndian),y+=4,m.setFloat32(y,c.getY(n),i.littleEndian),y+=4):(m.setFloat32(y,0,i.littleEndian),y+=4,m.setFloat32(y,0,i.littleEndian),y+=4)),!0===u&&(null!=l?(f.fromBufferAttribute(l,n),t.ColorManagement.workingToColorSpace(f,t.SRGBColorSpace),m.setUint8(y,Math.floor(255*f.r)),y+=1,m.setUint8(y,Math.floor(255*f.g)),y+=1,m.setUint8(y,Math.floor(255*f.b)),y+=1):(m.setUint8(y,255),y+=1,m.setUint8(y,255),y+=1,m.setUint8(y,255),y+=1));if(!0===o)if(null!==d)for(let t=0,e=d.count;t<e;t+=3)m.setUint8(g,3),g+=1,m.setUint32(g,d.getX(t+0)+b,i.littleEndian),g+=4,m.setUint32(g,d.getX(t+1)+b,i.littleEndian),g+=4,m.setUint32(g,d.getX(t+2)+b,i.littleEndian),g+=4;else for(let t=0,e=r.count;t<e;t+=3)m.setUint8(g,3),g+=1,m.setUint32(g,b+t,i.littleEndian),g+=4,m.setUint32(g,b+t+1,i.littleEndian),g+=4,m.setUint32(g,b+t+2,i.littleEndian),g+=4;b+=r.count}),w=m.buffer}else{let e=0,n="",i="";r(function(r,s){const c=s.getAttribute("position"),d=s.getAttribute("normal"),w=s.getAttribute("uv"),m=s.getAttribute("color"),y=s.getIndex();p.getNormalMatrix(r.matrixWorld);for(let e=0,i=c.count;e<i;e++){v.fromBufferAttribute(c,e),v.applyMatrix4(r.matrixWorld);let i=v.x+" "+v.y+" "+v.z;!0===a&&(null!=d?(v.fromBufferAttribute(d,e),v.applyMatrix3(p).normalize(),i+=" "+v.x+" "+v.y+" "+v.z):i+=" 0 0 0"),!0===h&&(i+=null!=w?" "+w.getX(e)+" "+w.getY(e):" 0 0"),!0===u&&(null!=m?(f.fromBufferAttribute(m,e),t.ColorManagement.workingToColorSpace(f,t.SRGBColorSpace),i+=" "+Math.floor(255*f.r)+" "+Math.floor(255*f.g)+" "+Math.floor(255*f.b)):i+=" 255 255 255"),n+=i+"\n"}if(!0===o){if(null!==y)for(let t=0,n=y.count;t<n;t+=3)i+=`3 ${y.getX(t+0)+e}`,i+=` ${y.getX(t+1)+e}`,i+=` ${y.getX(t+2)+e}\n`;else for(let t=0,n=c.count;t<n;t+=3)i+=`3 ${e+t} ${e+t+1} ${e+t+2}\n`;l+=y?y.count/3:c.count/3}e+=c.count}),w=`${d}${n}${o?`${i}\n`:"\n"}`}return"function"==typeof n&&requestAnimationFrame(()=>n(w)),w}}var Vi=function(){return c(function t(){a(this,t),this.exporters={gltf:new Wn,obj:new Hi,stl:new Gi,ply:new Xi},this.supportedFormats={models:["gltf","glb","obj","stl","ply","dae"],scenes:["json"],images:["png","jpg","jpeg","webp"],data:["json","csv","xml"]},this.exportHistory=[]},[{key:"exportModel",value:(o=s(g().m(function t(e,n){var i,r,s,o,a,u,h,c,l,f,d=arguments;return g().w(function(t){for(;;)switch(t.n){case 0:i=d.length>2&&void 0!==d[2]?d[2]:{},r=performance.now(),$e.info("๐Ÿ”„ Exporting model to ".concat(n.toUpperCase(),"...")),t.p=1,o=y({binary:"glb"===n,embedImages:!0,includeCustomExtensions:!1},i),l=n.toLowerCase(),t.n="gltf"===l||"glb"===l?2:"obj"===l?4:"stl"===l?6:8;break;case 2:return t.n=3,this.exportGLTF(e,o);case 3:case 5:case 7:return s=t.v,t.a(3,9);case 4:return t.n=5,this.exportOBJ(e,o);case 6:return t.n=7,this.exportSTL(e,o);case 8:throw new Error("Unsupported format: ".concat(n));case 9:return a=performance.now()-r,u={timestamp:(new Date).toISOString(),format:n.toLowerCase(),objectName:e.name||"Unnamed Object",exportTime:a,options:o,success:!0},this.exportHistory.push(u),$e.info("โœ… Model exported successfully to ".concat(n.toUpperCase()," in ").concat(a.toFixed(2),"ms")),t.a(2,{data:s,format:n,exportTime:a,filename:this.generateFilename(e.name||"model",n)});case 10:throw t.p=10,f=t.v,h=performance.now()-r,c={timestamp:(new Date).toISOString(),format:n.toLowerCase(),objectName:e.name||"Unnamed Object",exportTime:h,options:i,success:!1,error:f.message},this.exportHistory.push(c),$e.error("โŒ Failed to export model to ".concat(n.toUpperCase(),":"),f),f;case 11:return t.a(2)}},t,this,[[1,10]])})),function(t,e){return o.apply(this,arguments)})},{key:"exportGLTF",value:(r=s(g().m(function t(e){var n,i=this,r=arguments;return g().w(function(t){for(;;)if(0===t.n)return n=r.length>1&&void 0!==r[1]?r[1]:{},t.a(2,new Promise(function(t,r){i.exporters.gltf.parse(e,function(e){return t(e)},r,n)}))},t)})),function(t){return r.apply(this,arguments)})},{key:"exportOBJ",value:(i=s(g().m(function t(e){var n=this;return g().w(function(t){for(;;)if(0===t.n)return t.a(2,new Promise(function(t){t(n.exporters.obj.parse(e))}))},t)})),function(t){return i.apply(this,arguments)})},{key:"exportSTL",value:(n=s(g().m(function t(e){var n,i=this,r=arguments;return g().w(function(t){for(;;)if(0===t.n)return n=r.length>1&&void 0!==r[1]?r[1]:{},t.a(2,new Promise(function(t){t(i.exporters.stl.parse(e,n))}))},t)})),function(t){return n.apply(this,arguments)})},{key:"exportPLY",value:(e=s(g().m(function t(e){var n,i=this,r=arguments;return g().w(function(t){for(;;)if(0===t.n)return n=r.length>1&&void 0!==r[1]?r[1]:{},t.a(2,new Promise(function(t){t(i.exporters.ply.parse(e,n))}))},t)})),function(t){return e.apply(this,arguments)})},{key:"exportSceneConfig",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};$e.info("๐Ÿ”„ Exporting scene configuration...");try{var i={metadata:y({version:"1.0.0",generator:"Export",timestamp:(new Date).toISOString()},n),scene:this.serializeObject(t),connections:S(e),cameras:this.extractCameras(t),lights:this.extractLights(t)};return $e.info("โœ… Scene configuration exported successfully"),i}catch(t){throw $e.error("โŒ Failed to export scene configuration:",t),t}}},{key:"serializeObject",value:function(t){var e=this,n={uuid:t.uuid,name:t.name,type:t.type,position:t.position.toArray(),rotation:t.rotation.toArray(),scale:t.scale.toArray(),visible:t.visible,castShadow:t.castShadow,receiveShadow:t.receiveShadow,userData:y({},t.userData),children:[]};return t.geometry&&(n.geometry={type:t.geometry.type,uuid:t.geometry.uuid,attributes:this.serializeGeometryAttributes(t.geometry)}),t.material&&(n.material=this.serializeMaterial(t.material)),t.children.forEach(function(t){n.children.push(e.serializeObject(t))}),n}},{key:"serializeGeometryAttributes",value:function(t){var e={};return Object.keys(t.attributes).forEach(function(n){var i=t.attributes[n];e[n]={type:i.constructor.name,itemSize:i.itemSize,count:i.count,normalized:i.normalized}}),e}},{key:"serializeMaterial",value:function(t){var e={type:t.type,uuid:t.uuid,name:t.name,color:t.color?t.color.getHex():null,transparent:t.transparent,opacity:t.opacity,side:t.side,visible:t.visible};void 0!==t.metalness&&(e.metalness=t.metalness),void 0!==t.roughness&&(e.roughness=t.roughness),void 0!==t.clearcoat&&(e.clearcoat=t.clearcoat),void 0!==t.clearcoatRoughness&&(e.clearcoatRoughness=t.clearcoatRoughness);return["map","normalMap","roughnessMap","metalnessMap","aoMap","emissiveMap"].forEach(function(n){var i;t[n]&&(e[n]={uuid:t[n].uuid,name:t[n].name,image:(null===(i=t[n].image)||void 0===i?void 0:i.src)||null})}),e}},{key:"extractCameras",value:function(t){var e=[];return t.traverse(function(t){if(t.isCamera){var n={uuid:t.uuid,name:t.name,type:t.type,position:t.position.toArray(),rotation:t.rotation.toArray(),fov:t.fov,aspect:t.aspect,near:t.near,far:t.far};e.push(n)}}),e}},{key:"extractLights",value:function(t){var e=[];return t.traverse(function(t){if(t.isLight){var n={uuid:t.uuid,name:t.name,type:t.type,position:t.position.toArray(),color:t.color.getHex(),intensity:t.intensity};void 0!==t.distance&&(n.distance=t.distance),void 0!==t.decay&&(n.decay=t.decay),void 0!==t.angle&&(n.angle=t.angle),void 0!==t.penumbra&&(n.penumbra=t.penumbra),void 0!==t.castShadow&&(n.castShadow=t.castShadow),e.push(n)}}),e}},{key:"exportToCSV",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(!t||0===t.length)return"";e||(e=Object.keys(t[0]));var n=[];return n.push(e.join(",")),t.forEach(function(t){var i=e.map(function(e){var n=t[e];return"string"==typeof n&&(n.includes(",")||n.includes('"'))?'"'.concat(n.replace(/"/g,'""'),'"'):n});n.push(i.join(","))}),n.join("\n")}},{key:"exportToXML",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"root",i=function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=" ".repeat(n),s="";return Object.keys(t).forEach(function(o){var a=t[o];"object"!==A(a)||null===a||Array.isArray(a)?Array.isArray(a)?a.forEach(function(t){s+="".concat(r,"<").concat(o,">"),"object"===A(t)?s+="\n"+i(t,n+1)+r:s+=e.escapeXML(t),s+="</".concat(o,">\n")}):s+="".concat(r,"<").concat(o,">").concat(e.escapeXML(a),"</").concat(o,">\n"):(s+="".concat(r,"<").concat(o,">\n"),s+=i(a,n+1),s+="".concat(r,"</").concat(o,">\n"))}),s};return'<?xml version="1.0" encoding="UTF-8"?>\n'+"<".concat(n,">\n")+i(t,1)+"</".concat(n,">")}},{key:"downloadFile",value:function(t,e){var n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"application/octet-stream";n=t instanceof ArrayBuffer||"string"==typeof t?new Blob([t],{type:i}):new Blob([JSON.stringify(t,null,2)],{type:"application/json"});var r=URL.createObjectURL(n),s=document.createElement("a");s.href=r,s.download=e,s.style.display="none",document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(r),$e.info("โœ… File downloaded: ".concat(e))}},{key:"exportBatch",value:(t=s(g().m(function t(e){var n,i,r,s,o,a,u,h;return g().w(function(t){for(;;)switch(t.n){case 0:$e.info("๐Ÿ”„ Starting batch export of ".concat(e.length," objects...")),n=[],i=[],r=l(e),t.p=1,r.s();case 2:if((s=r.n()).done){t.n=7;break}return o=s.value,t.p=3,t.n=4,this.exportModel(o.object,o.format,o.options);case 4:a=t.v,n.push(a),t.n=6;break;case 5:t.p=5,u=t.v,i.push({object:o.object.name||"Unnamed Object",format:o.format,error:u.message});case 6:t.n=2;break;case 7:t.n=9;break;case 8:t.p=8,h=t.v,r.e(h);case 9:return t.p=9,r.f(),t.f(9);case 10:return $e.info("โœ… Batch export complete: ".concat(n.length," successful, ").concat(i.length," failed")),t.a(2,{results:n,errors:i})}},t,this,[[3,5],[1,8,9,10]])})),function(e){return t.apply(this,arguments)})},{key:"generateFilename",value:function(t,e){var n=(new Date).toISOString().replace(/[:.]/g,"-").slice(0,-5),i=t.replace(/[^a-zA-Z0-9_-]/g,"_");return"".concat(i,"_").concat(n,".").concat(e.toLowerCase())}},{key:"escapeXML",value:function(t){return null==t?"":String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}},{key:"isFormatSupported",value:function(t,e){var n;return(null===(n=this.supportedFormats[e])||void 0===n?void 0:n.includes(t.toLowerCase()))||!1}},{key:"getExportHistory",value:function(){return this.exportHistory}},{key:"clearHistory",value:function(){this.exportHistory=[]}},{key:"getSupportedFormats",value:function(){return y({},this.supportedFormats)}},{key:"dispose",value:function(){this.clearHistory(),$e.info("Export disposed")}}]);var t,e,n,i,r,o}(),Yi=Object.freeze({__proto__:null,Export:Vi}),Ki=function(){return c(function t(){var e=this;a(this,t),f(this,"vector",{add:function(t,e){return t.map(function(t,n){return t+(e[n]||0)})},subtract:function(t,e){return t.map(function(t,n){return t-(e[n]||0)})},scale:function(t,e){return t.map(function(t){return t*e})},dot:function(t,e){return t.reduce(function(t,n,i){return t+n*(e[i]||0)},0)},cross:function(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]},magnitude:function(t){return Math.sqrt(t.reduce(function(t,e){return t+e*e},0))},normalize:function(t){var n=e.vector.magnitude(t);return n>0?t.map(function(t){return t/n}):t.slice()},distance:function(t,n){return e.vector.magnitude(e.vector.subtract(t,n))},lerp:function(t,e,n){return t.map(function(t,i){return t+n*((e[i]||0)-t)})}}),f(this,"matrix",{identity:function(t){for(var e=Array(t).fill().map(function(){return Array(t).fill(0)}),n=0;n<t;n++)e[n][n]=1;return e},multiply:function(t,e){for(var n=t.length,i=e[0].length,r=Array(n).fill().map(function(){return Array(i).fill(0)}),s=0;s<n;s++)for(var o=0;o<i;o++)for(var a=0;a<t[0].length;a++)r[s][o]+=t[s][a]*e[a][o];return r},multiplyVector:function(t,e){return t.map(function(t){return t.reduce(function(t,n,i){return t+n*(e[i]||0)},0)})},determinant:function(t){var e=t.length;if(2===e)return t[0][0]*t[1][1]-t[0][1]*t[1][0];if(3===e)return t[0][0]*(t[1][1]*t[2][2]-t[1][2]*t[2][1])-t[0][1]*(t[1][0]*t[2][2]-t[1][2]*t[2][0])+t[0][2]*(t[1][0]*t[2][1]-t[1][1]*t[2][0]);throw new Error("Determinant calculation only supported for 2x2 and 3x3 matrices")},transpose:function(t){return t[0].map(function(e,n){return t.map(function(t){return t[n]})})}}),f(this,"analysis",{newtonRaphson:function(t,n,i){for(var r=i,s=0;s<e.maxIterations;){var o=t(r),a=n(r);if(Math.abs(a)<e.precision)throw new Error("Derivative too small, cannot continue");var u=r-o/a;if(Math.abs(u-r)<e.convergenceThreshold)return{root:u,iterations:s+1,converged:!0,error:Math.abs(t(u))};r=u,s++}return{root:r,iterations:s,converged:!1,error:Math.abs(t(r))}},bisection:function(t,n,i){if(t(n)*t(i)>=0)throw new Error("Function must have opposite signs at bounds");for(var r=n,s=i,o=0;o<e.maxIterations;){var a=(r+s)/2,u=t(a);if(Math.abs(u)<e.convergenceThreshold||Math.abs(s-r)<e.convergenceThreshold)return{root:a,iterations:o+1,converged:!0,error:Math.abs(u)};t(r)*u<0?s=a:r=a,o++}return{root:(r+s)/2,iterations:o,converged:!1,error:Math.abs(t((r+s)/2))}},simpson:function(t,e,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:100;i%2!=0&&i++;for(var r=(n-e)/i,s=t(e)+t(n),o=1;o<i;o++){s+=(o%2==0?2:4)*t(e+o*r)}return r/3*s},derivative:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1e-8;return(t(e+n)-t(e-n))/(2*n)}}),f(this,"stats",{mean:function(t){return t.reduce(function(t,e){return t+e},0)/t.length},median:function(t){var e=S(t).sort(function(t,e){return t-e}),n=Math.floor(e.length/2);return e.length%2==0?(e[n-1]+e[n])/2:e[n]},stdDev:function(t){var n=e.stats.mean(t),i=t.reduce(function(t,e){return t+Math.pow(e-n,2)},0)/t.length;return Math.sqrt(i)},correlation:function(t,n){for(var i=Math.min(t.length,n.length),r=e.stats.mean(t.slice(0,i)),s=e.stats.mean(n.slice(0,i)),o=0,a=0,u=0,h=0;h<i;h++){var c=t[h]-r,l=n[h]-s;o+=c*l,a+=c*c,u+=l*l}var f=Math.sqrt(a*u);return 0!==f?o/f:0},linearRegression:function(t,n){for(var i=Math.min(t.length,n.length),r=e.stats.mean(t.slice(0,i)),s=e.stats.mean(n.slice(0,i)),o=0,a=0,u=0;u<i;u++){var h=t[u]-r;o+=h*(n[u]-s),a+=h*h}for(var c=0!==a?o/a:0,l=s-c*r,f=0,d=0,v=0;v<i;v++){var p=c*t[v]+l;f+=Math.pow(n[v]-p,2),d+=Math.pow(n[v]-s,2)}return{slope:c,intercept:l,rSquared:0!==d?1-f/d:0,predict:function(t){return c*t+l}}}}),f(this,"utils",{clamp:function(t,e,n){return Math.max(e,Math.min(n,t))},map:function(t,e,n,i,r){return i+(t-e)*(r-i)/(n-e)},approxEqual:function(t,n){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.precision;return Math.abs(t-n)<i},round:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=Math.pow(10,e);return Math.round(t*n)/n},range:function(t,e){for(var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,i=[],r=t;r<=e;r+=n)i.push(r);return i},linspace:function(t,e,n){var i=(e-t)/(n-1);return Array.from({length:n},function(e,n){return t+n*i})}}),this.precision=1e-10,this.maxIterations=1e3,this.convergenceThreshold=1e-6},[{key:"setPrecision",value:function(t){this.precision=t}},{key:"setMaxIterations",value:function(t){this.maxIterations=t}},{key:"setConvergenceThreshold",value:function(t){this.convergenceThreshold=t}}])}(),Zi=Object.freeze({__proto__:null,Numerics:Ki}),Wi=function(){return c(function t(){a(this,t),this.analysisHistory=[],this.validationRules=new Map,this.adjustmentStrategies=new Map,this.initializeDefaultRules()},[{key:"initializeDefaultRules",value:function(){this.addValidationRule("component_bounds",{check:function(t){var e=(new n.Box3).setFromObject(t);return!e.isEmpty()&&e.getSize(new n.Vector3).length()>0},message:"Component has invalid bounding box"}),this.addValidationRule("component_position",{check:function(t){var e=t.position;return!isNaN(e.x)&&!isNaN(e.y)&&!isNaN(e.z)&&isFinite(e.x)&&isFinite(e.y)&&isFinite(e.z)},message:"Component has invalid position values"}),this.addValidationRule("component_scale",{check:function(t){var e=t.scale;return e.x>0&&e.y>0&&e.z>0&&e.x<1e3&&e.y<1e3&&e.z<1e3},message:"Component has invalid scale values"}),this.addValidationRule("scene_complexity",{check:function(t){var e=0;return t.traverse(function(t){t.isMesh&&e++}),e<1e4},message:"Scene complexity too high (too many meshes)"})}},{key:"addValidationRule",value:function(t,e){this.validationRules.set(t,e)}},{key:"addAdjustmentStrategy",value:function(t,e){this.adjustmentStrategies.set(t,e)}},{key:"analyzeScene",value:function(t){var e=performance.now();$e.info("๐Ÿ” Starting scene analysis...");var n={timestamp:(new Date).toISOString(),performance:{},structure:{},quality:{},recommendations:[]},i=0,r=0,s=0,o=0,a=new Set,u=new Set;t.traverse(function(t){if(t.isMesh){if(i++,t.geometry){r++;var e=t.geometry.getAttribute("position");e&&(s+=e.count,t.geometry.index?o+=t.geometry.index.count/3:o+=e.count/3)}if(t.material)if(Array.isArray(t.material))t.material.forEach(function(t){return a.add(t.uuid)});else{a.add(t.material.uuid);var n=t.material;Object.keys(n).forEach(function(t){n[t]&&n[t].isTexture&&u.add(n[t].uuid)})}}}),n.performance={meshCount:i,geometryCount:r,materialCount:a.size,textureCount:u.size,vertexCount:s,triangleCount:o,memoryEstimate:this.estimateMemoryUsage(s,a.size,u.size)},n.structure=this.analyzeSceneStructure(t),n.quality=this.analyzeQuality(t),n.recommendations=this.generateRecommendations(n);var h=performance.now();return n.performance.analysisTime=h-e,$e.info("โœ… Scene analysis complete in ".concat(n.performance.analysisTime.toFixed(2),"ms")),this.analysisHistory.push(n),n}},{key:"analyzeSceneStructure",value:function(t){var e={depth:0,branches:0,emptyNodes:0,namedObjects:0,groups:0},n=function(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;e.depth=Math.max(e.depth,i),t.children.length>0&&e.branches++,0!==t.children.length||t.isMesh||t.isLight||t.isCamera||e.emptyNodes++,t.name&&""!==t.name.trim()&&e.namedObjects++,t.isGroup&&e.groups++,t.children.forEach(function(t){return n(t,i+1)})};return n(t),e}},{key:"analyzeQuality",value:function(t){var e=this,n={duplicateMaterials:0,unusedMaterials:0,missingTextures:0,invalidTransforms:0,memoryLeaks:[],optimization:{mergeable:[],instancingCandidates:[]}},i=new Map,r=new Map;return t.traverse(function(t){if(t.material){var s=e.getMaterialSignature(t.material);i.has(s)?n.duplicateMaterials++:i.set(s,t.material)}if(t.geometry){var o=e.getGeometrySignature(t.geometry);r.has(o)||r.set(o,[]),r.get(o).push(t)}!t.position||isFinite(t.position.x)&&isFinite(t.position.y)&&isFinite(t.position.z)||n.invalidTransforms++}),r.forEach(function(t,e){t.length>1&&n.optimization.instancingCandidates.push({geometry:e,count:t.length,objects:t.map(function(t){return t.uuid})})}),n}},{key:"generateRecommendations",value:function(t){var e=[];return t.performance.triangleCount>5e5&&e.push({type:"performance",priority:"high",message:"Consider using Level of Detail (LOD) for high polygon models",action:"implement_lod"}),t.performance.materialCount>50&&e.push({type:"performance",priority:"medium",message:"High material count detected. Consider material atlasing",action:"optimize_materials"}),t.quality.duplicateMaterials>10&&e.push({type:"optimization",priority:"medium",message:"Duplicate materials found. Consider material sharing",action:"merge_materials"}),t.quality.optimization.instancingCandidates.length>0&&e.push({type:"optimization",priority:"high",message:"Instancing opportunities detected for repeated geometries",action:"implement_instancing"}),e}},{key:"validateScene",value:function(t){var e=this;$e.info("๐Ÿ” Validating scene components...");var n={passed:[],failed:[],warnings:[]};return this.validationRules.forEach(function(e,i){try{e.check(t)?n.passed.push({rule:i,target:"scene"}):n.failed.push({rule:i,target:"scene",message:e.message})}catch(t){n.warnings.push({rule:i,target:"scene",message:"Validation error: ".concat(t.message)})}}),t.traverse(function(t){t.isMesh&&e.validationRules.forEach(function(e,i){try{e.check(t)?n.passed.push({rule:i,target:t.uuid}):n.failed.push({rule:i,target:t.uuid,message:e.message,objectName:t.name||"Unnamed Object"})}catch(e){n.warnings.push({rule:i,target:t.uuid,message:"Validation error: ".concat(e.message),objectName:t.name||"Unnamed Object"})}})}),$e.info("โœ… Validation complete: ".concat(n.passed.length," passed, ").concat(n.failed.length," failed, ").concat(n.warnings.length," warnings")),n}},{key:"applyAdjustments",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];$e.info("๐Ÿ”ง Applying scene adjustments...");var i={applied:[],failed:[],skipped:[]};return n.forEach(function(n){var r=e.adjustmentStrategies.get(n.type);if(r)try{var s=r(t,n.options||{});i.applied.push({adjustment:n.type,result:s})}catch(t){i.failed.push({adjustment:n.type,error:t.message})}else i.skipped.push({adjustment:n.type,reason:"No strategy found"})}),$e.info("โœ… Adjustments complete: ".concat(i.applied.length," applied, ").concat(i.failed.length," failed, ").concat(i.skipped.length," skipped")),i}},{key:"getMaterialSignature",value:function(t){var e={type:t.type,color:t.color?t.color.getHex():null,metalness:t.metalness,roughness:t.roughness,transparent:t.transparent,opacity:t.opacity};return JSON.stringify(e)}},{key:"getGeometrySignature",value:function(t){var e,n=Object.keys(t.attributes),i=(null===(e=t.getAttribute("position"))||void 0===e?void 0:e.count)||0,r=!!t.index;return"".concat(t.type,"_").concat(i,"_").concat(r,"_").concat(n.join(","))}},{key:"estimateMemoryUsage",value:function(t,e,n){var i=32*t,r=1024*e,s=1048576*n,o=i+r+s;return{geometry:this.formatBytes(i),materials:this.formatBytes(r),textures:this.formatBytes(s),total:this.formatBytes(o),totalBytes:o}}},{key:"formatBytes",value:function(t){if(0===t)return"0 Bytes";var e=Math.floor(Math.log(t)/Math.log(1024));return parseFloat((t/Math.pow(1024,e)).toFixed(2))+" "+["Bytes","KB","MB","GB"][e]}},{key:"getAnalysisHistory",value:function(){return this.analysisHistory}},{key:"clearHistory",value:function(){this.analysisHistory=[]}},{key:"dispose",value:function(){this.clearHistory(),this.validationRules.clear(),this.adjustmentStrategies.clear(),$e.info("Analysis disposed")}}])}(),$i=Object.freeze({__proto__:null,Analysis:Wi}),Ji=function(){return c(function t(){var e,n=this;a(this,t),f(this,"mock",{create:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=y({calls:[],callCount:0},t);return Object.keys(t).forEach(function(n){var i=t[n];e[n]=function(){for(var t=arguments.length,r=new Array(t),s=0;s<t;s++)r[s]=arguments[s];return e.calls.push({method:n,args:r,timestamp:Date.now()}),e.callCount++,i.apply(void 0,r)}}),e},spy:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(){},e=function(){for(var n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return e.calls.push({args:i,timestamp:Date.now()}),e.callCount++,void 0!==e.returnValue?e.returnValue:t.apply(void 0,i)};return e.calls=[],e.callCount=0,e.returnValue=void 0,e.returns=function(t){return e.returnValue=t,e},e.throws=function(t){return e.throwError=t,e},e},three:{vector3:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return{x:t,y:e,z:n,set:function(i,r,s){t=i,e=r,n=s},clone:function(){return{x:t,y:e,z:n}},add:function(i){return{x:t+i.x,y:e+i.y,z:n+i.z}},sub:function(i){return{x:t-i.x,y:e-i.y,z:n-i.z}},length:function(){return Math.sqrt(t*t+e*e+n*n)},normalize:function(){var i=Math.sqrt(t*t+e*e+n*n);return{x:t/i,y:e/i,z:n/i}}}},object3D:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1},children:[],parent:null,name:t.name||"",uuid:t.uuid||Math.random().toString(36),add:function(t){this.children.push(t),t.parent=this},remove:function(t){var e=this.children.indexOf(t);e>-1&&this.children.splice(e,1)},traverse:function(t){t(this),this.children.forEach(function(e){return e.traverse(t)})}}},scene:function(){return y(y({},n.mock.three.object3D()),{},{background:null,environment:null,fog:null,type:"Scene"})}}}),f(this,"benchmark",{run:(e=s(g().m(function t(e,i){var r,s,o,a,u,h,c,l,f,d,v,p,w,m,y,b,k,M,x,T=arguments;return g().w(function(t){for(;;)switch(t.n){case 0:s=(r=T.length>2&&void 0!==T[2]?T[2]:{}).iterations,o=void 0===s?1e3:s,a=r.warmupIterations,u=void 0===a?10:a,h=r.timeout,c=void 0===h?5e3:h,$e.info("โฑ๏ธ Running benchmark: ".concat(e)),l=0;case 1:if(!(l<u)){t.n=3;break}return t.n=2,i();case 2:l++,t.n=1;break;case 3:f=[],d=performance.now(),v=0;case 4:if(!(v<o)){t.n=7;break}return p=performance.now(),t.n=5,i();case 5:if(w=performance.now(),f.push(w-p),!(performance.now()-d>c)){t.n=6;break}return $e.warn('โš ๏ธ Benchmark "'.concat(e,'" timed out after ').concat(v+1," iterations")),t.a(3,7);case 6:v++,t.n=4;break;case 7:return m=performance.now()-d,y=f.reduce(function(t,e){return t+e},0)/f.length,b=Math.min.apply(Math,f),k=Math.max.apply(Math,f),M=f.sort()[Math.floor(f.length/2)],x={name:e,iterations:f.length,totalTime:m,avgTime:y,minTime:b,maxTime:k,medianTime:M,opsPerSecond:1e3/y},n.benchmarks.set(e,x),$e.info('โœ… Benchmark "'.concat(e,'" completed: ').concat(x.opsPerSecond.toFixed(2)," ops/sec")),t.a(2,x)}},t)})),function(t,n){return e.apply(this,arguments)}),compare:function(t){var e=t.map(function(t){return n.benchmarks.get(t)}).filter(Boolean);if(e.length<2)throw new Error("Need at least 2 benchmarks to compare");var i=e.reduce(function(t,e){return t.opsPerSecond>e.opsPerSecond?t:e}),r=e.map(function(t){return{name:t.name,opsPerSecond:t.opsPerSecond,relativeSpeed:t.opsPerSecond/i.opsPerSecond,slower:i.opsPerSecond/t.opsPerSecond}});return{fastest:i.name,comparison:r}}}),this.testSuites=new Map,this.testResults=[],this.mockData=new Map,this.assertions=new Map,this.benchmarks=new Map,this.setupDefaultAssertions()},[{key:"setupDefaultAssertions",value:function(){this.addAssertion("equals",function(t,e,n){if(t!==e)throw new Error(n||"Expected ".concat(e,", got ").concat(t))}),this.addAssertion("notEquals",function(t,e,n){if(t===e)throw new Error(n||"Expected not ".concat(e,", got ").concat(t))}),this.addAssertion("deepEquals",function(t,e,n){if(JSON.stringify(t)!==JSON.stringify(e))throw new Error(n||"Deep equality failed")}),this.addAssertion("true",function(t,e){if(!0!==t)throw new Error(e||"Expected true, got ".concat(t))}),this.addAssertion("false",function(t,e){if(!1!==t)throw new Error(e||"Expected false, got ".concat(t))}),this.addAssertion("truthy",function(t,e){if(!t)throw new Error(e||"Expected truthy value, got ".concat(t))}),this.addAssertion("falsy",function(t,e){if(t)throw new Error(e||"Expected falsy value, got ".concat(t))}),this.addAssertion("null",function(t,e){if(null!==t)throw new Error(e||"Expected null, got ".concat(t))}),this.addAssertion("undefined",function(t,e){if(void 0!==t)throw new Error(e||"Expected undefined, got ".concat(t))}),this.addAssertion("defined",function(t,e){if(void 0===t)throw new Error(e||"Expected defined value, got undefined")}),this.addAssertion("instanceOf",function(t,e,n){if(!(t instanceof e))throw new Error(n||"Expected instance of ".concat(e.name,", got ").concat(A(t)))}),this.addAssertion("typeof",function(t,e,n){if(A(t)!==e)throw new Error(n||"Expected type ".concat(e,", got ").concat(A(t)))}),this.addAssertion("greaterThan",function(t,e,n){if(t<=e)throw new Error(n||"Expected ".concat(t," > ").concat(e))}),this.addAssertion("lessThan",function(t,e,n){if(t>=e)throw new Error(n||"Expected ".concat(t," < ").concat(e))}),this.addAssertion("greaterThanOrEqual",function(t,e,n){if(t<e)throw new Error(n||"Expected ".concat(t," >= ").concat(e))}),this.addAssertion("lessThanOrEqual",function(t,e,n){if(t>e)throw new Error(n||"Expected ".concat(t," <= ").concat(e))}),this.addAssertion("approximately",function(t,e,n,i){if(Math.abs(t-e)>n)throw new Error(i||"Expected ".concat(t," โ‰ˆ ").concat(e," (ยฑ").concat(n,")"))}),this.addAssertion("includes",function(t,e,n){if(!t.includes(e))throw new Error(n||'Expected "'.concat(t,'" to include "').concat(e,'"'))}),this.addAssertion("startsWith",function(t,e,n){if(!t.startsWith(e))throw new Error(n||'Expected "'.concat(t,'" to start with "').concat(e,'"'))}),this.addAssertion("endsWith",function(t,e,n){if(!t.endsWith(e))throw new Error(n||'Expected "'.concat(t,'" to end with "').concat(e,'"'))}),this.addAssertion("matches",function(t,e,n){if(!e.test(t))throw new Error(n||'Expected "'.concat(t,'" to match pattern ').concat(e))}),this.addAssertion("hasLength",function(t,e,n){if(t.length!==e)throw new Error(n||"Expected length ".concat(e,", got ").concat(t.length))}),this.addAssertion("isEmpty",function(t,e){if(0!==t.length)throw new Error(e||"Expected empty array/string, got length ".concat(t.length))}),this.addAssertion("isNotEmpty",function(t,e){if(0===t.length)throw new Error(e||"Expected non-empty array/string")}),this.addAssertion("hasProperty",function(t,e,n){if(!t.hasOwnProperty(e))throw new Error(n||'Expected object to have property "'.concat(e,'"'))}),this.addAssertion("hasMethod",function(t,e,n){if("function"!=typeof t[e])throw new Error(n||'Expected object to have method "'.concat(e,'"'))}),this.addAssertion("resolves",function(){var t=s(g().m(function t(e,n){var i;return g().w(function(t){for(;;)switch(t.n){case 0:return t.p=0,t.n=1,e;case 1:t.n=3;break;case 2:throw t.p=2,i=t.v,new Error(n||"Expected promise to resolve, but it rejected: ".concat(i.message));case 3:return t.a(2)}},t,null,[[0,2]])}));return function(e,n){return t.apply(this,arguments)}}()),this.addAssertion("rejects",function(){var t=s(g().m(function t(e,n){return g().w(function(t){for(;;)switch(t.n){case 0:return t.p=0,t.n=1,e;case 1:throw new Error(n||"Expected promise to reject, but it resolved");case 2:t.p=2,t.v;case 3:return t.a(2)}},t,null,[[0,2]])}));return function(e,n){return t.apply(this,arguments)}}()),this.addAssertion("throws",function(t,e){try{throw t(),new Error(e||"Expected function to throw, but it didn't")}catch(t){}})}},{key:"addAssertion",value:function(t,e){this.assertions.set(t,e)}},{key:"createTestSuite",value:function(t){var e=this,n={name:t,tests:[],beforeEach:null,afterEach:null,beforeAll:null,afterAll:null,setup:arguments.length>1&&void 0!==arguments[1]?arguments[1]:null};return this.testSuites.set(t,n),{test:function(n,i){return e.addTest(t,n,i)},beforeEach:function(t){n.beforeEach=t},afterEach:function(t){n.afterEach=t},beforeAll:function(t){n.beforeAll=t},afterAll:function(t){n.afterAll=t}}}},{key:"addTest",value:function(t,e,n){var i=this.testSuites.get(t);if(!i)throw new Error('Test suite "'.concat(t,'" not found'));i.tests.push({name:e,fn:n,skip:!1,only:!1})}},{key:"runAllTests",value:(n=s(g().m(function t(){var e,n,i,r,s,o,a,u;return g().w(function(t){for(;;)switch(t.n){case 0:$e.info("๐Ÿงช Running all test suites..."),e=performance.now(),n={suites:[],totalTests:0,passedTests:0,failedTests:0,skippedTests:0,duration:0},i=l(this.testSuites),t.p=1,i.s();case 2:if((r=i.n()).done){t.n=5;break}return s=x(r.value,2),o=s[0],s[1],t.n=3,this.runTestSuite(o);case 3:a=t.v,n.suites.push(a),n.totalTests+=a.totalTests,n.passedTests+=a.passedTests,n.failedTests+=a.failedTests,n.skippedTests+=a.skippedTests;case 4:t.n=2;break;case 5:t.n=7;break;case 6:t.p=6,u=t.v,i.e(u);case 7:return t.p=7,i.f(),t.f(7);case 8:return n.duration=performance.now()-e,$e.info("โœ… All tests completed: ".concat(n.passedTests,"/").concat(n.totalTests," passed in ").concat(n.duration.toFixed(2),"ms")),this.testResults.push(n),t.a(2,n)}},t,this,[[1,6,7,8]])})),function(){return n.apply(this,arguments)})},{key:"runTestSuite",value:(e=s(g().m(function t(e){var n,i,r,s,o,a,u,h,c;return g().w(function(t){for(;;)switch(t.n){case 0:if(n=this.testSuites.get(e)){t.n=1;break}throw new Error('Test suite "'.concat(e,'" not found'));case 1:if($e.info("๐Ÿงช Running test suite: ".concat(e)),i=performance.now(),r={name:e,tests:[],totalTests:n.tests.length,passedTests:0,failedTests:0,skippedTests:0,duration:0},t.p=2,!n.setup){t.n=3;break}return t.n=3,n.setup();case 3:if(!n.beforeAll){t.n=4;break}return t.n=4,n.beforeAll();case 4:s=l(n.tests),t.p=5,s.s();case 6:if((o=s.n()).done){t.n=9;break}return a=o.value,t.n=7,this.runTest(n,a);case 7:u=t.v,r.tests.push(u),"passed"===u.status?r.passedTests++:"failed"===u.status?r.failedTests++:"skipped"===u.status&&r.skippedTests++;case 8:t.n=6;break;case 9:t.n=11;break;case 10:t.p=10,h=t.v,s.e(h);case 11:return t.p=11,s.f(),t.f(11);case 12:if(!n.afterAll){t.n=13;break}return t.n=13,n.afterAll();case 13:t.n=15;break;case 14:t.p=14,c=t.v,$e.error('โŒ Test suite "'.concat(e,'" setup failed:'),c);case 15:return r.duration=performance.now()-i,$e.info('โœ… Suite "'.concat(e,'" completed: ').concat(r.passedTests,"/").concat(r.totalTests," passed")),t.a(2,r)}},t,this,[[5,10,11,12],[2,14]])})),function(t){return e.apply(this,arguments)})},{key:"runTest",value:(t=s(g().m(function t(e,n){var i,r,s,o;return g().w(function(t){for(;;)switch(t.n){case 0:if(!n.skip){t.n=1;break}return t.a(2,{name:n.name,status:"skipped",duration:0,error:null});case 1:if(i=performance.now(),r={name:n.name,status:"passed",duration:0,error:null},t.p=2,!e.beforeEach){t.n=3;break}return t.n=3,e.beforeEach();case 3:return s=this.createAssertionContext(),t.n=4,n.fn(s);case 4:if(!e.afterEach){t.n=5;break}return t.n=5,e.afterEach();case 5:t.n=7;break;case 6:t.p=6,o=t.v,r.status="failed",r.error={message:o.message,stack:o.stack},$e.error('โŒ Test "'.concat(n.name,'" failed:'),o.message);case 7:return r.duration=performance.now()-i,t.a(2,r)}},t,this,[[2,6]])})),function(e,n){return t.apply(this,arguments)})},{key:"createAssertionContext",value:function(){var t,e={},n=l(this.assertions);try{for(n.s();!(t=n.n()).done;){var i=x(t.value,2),r=i[0],s=i[1];e[r]=s}}catch(t){n.e(t)}finally{n.f()}return e}},{key:"generateReport",value:function(t){var e=(t.passedTests/t.totalTests*100).toFixed(1),n='\n<!DOCTYPE html>\n<html>\n<head>\n <title>Test Report</title>\n <style>\n body { font-family: Arial, sans-serif; margin: 20px; }\n .summary { background: #f5f5f5; padding: 15px; border-radius: 5px; margin-bottom: 20px; }\n .suite { margin-bottom: 20px; border: 1px solid #ddd; border-radius: 5px; }\n .suite-header { background: #e9e9e9; padding: 10px; font-weight: bold; }\n .test { padding: 10px; border-bottom: 1px solid #eee; }\n .test:last-child { border-bottom: none; }\n .passed { color: green; }\n .failed { color: red; }\n .skipped { color: orange; }\n .error { background: #ffe6e6; padding: 10px; margin-top: 5px; border-radius: 3px; }\n </style>\n</head>\n<body>\n <h1>Test Report</h1>\n \n <div class="summary">\n <h2>Summary</h2>\n <p><strong>Total Tests:</strong> '.concat(t.totalTests,'</p>\n <p><strong>Passed:</strong> <span class="passed">').concat(t.passedTests,'</span></p>\n <p><strong>Failed:</strong> <span class="failed">').concat(t.failedTests,'</span></p>\n <p><strong>Skipped:</strong> <span class="skipped">').concat(t.skippedTests,"</span></p>\n <p><strong>Pass Rate:</strong> ").concat(e,"%</p>\n <p><strong>Duration:</strong> ").concat(t.duration.toFixed(2),"ms</p>\n </div>\n \n <h2>Test Suites</h2>\n");return t.suites.forEach(function(t){n+='\n <div class="suite">\n <div class="suite-header">\n '.concat(t.name," (").concat(t.passedTests,"/").concat(t.totalTests," passed)\n </div>\n"),t.tests.forEach(function(t){n+='\n <div class="test">\n <span class="'.concat(t.status,'">').concat(t.status.toUpperCase(),"</span>\n <strong>").concat(t.name,"</strong>\n <small>(").concat(t.duration.toFixed(2),"ms)</small>\n"),t.error&&(n+='\n <div class="error">\n <strong>Error:</strong> '.concat(t.error.message,"\n </div>\n")),n+=" </div>"}),n+=" </div>"}),n+="\n</body>\n</html>\n"}},{key:"clearResults",value:function(){this.testResults=[]}},{key:"getResults",value:function(){return this.testResults}},{key:"getBenchmarks",value:function(){return this.benchmarks}},{key:"dispose",value:function(){this.testSuites.clear(),this.clearResults(),this.mockData.clear(),this.benchmarks.clear(),$e.info("Testing disposed")}}]);var t,e,n}(),qi=Object.freeze({__proto__:null,Testing:Ji});exports.Analysis=$i,exports.AnimationManager=bn,exports.CameraControlsManager=kn,exports.CentralPlant=Ln,exports.ComponentManager=pe,exports.DebugLogger=We,exports.DisposalManager=ct,exports.DragDropManager=In,exports.EnvironmentManager=hn,exports.ExportUtils=Yi,exports.HotReloadManager=ht,exports.ImportUtils=Kn,exports.KeyboardControlsManager=cn,exports.MathUtils=Bn,exports.Numerics=Zi,exports.PathfindingManager=yn,exports.PerformanceMonitor=Ye,exports.Rendering2D=Un,exports.Rendering3D=Hn,exports.SceneExportManager=vt,exports.SceneInitializationManager=tn,exports.SceneOperationsManager=gn,exports.SceneTooltipsManager=Dn,exports.Testing=qi,exports.createTransformControls=ut,exports.findObjectByHardcodedUuid=ft,exports.generateUuidFromName=lt,exports.getHardcodedUuid=dt,exports.loadTextureSetAndCreateMaterial=an,exports.logger=$e,exports.modelLogger=Qe,exports.modelPreloader=ve,exports.pathfinderLogger=qe,exports.transformLogger=Je;